Skip to content

Commit 2574231

Browse files
committed
Javascript update set
1 parent 0b9711d commit 2574231

File tree

9 files changed

+94
-48
lines changed

9 files changed

+94
-48
lines changed

web/index.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ <h1 class="logo"><a href="#">Vesta panel <span>&nbsp;</span></a></h1>
124124
<i class="add-entry do_action_new_entry">&nbsp;</i>
125125
</dt>
126126
<dd class="section-contains">
127-
<span class="def total_dns_records">0 total records</span>
127+
<span class="def"><span class="num-total">0</span> total records</span>
128128
</dd>
129129
</dl>
130130
</div>
@@ -202,8 +202,7 @@ <h1 class="logo"><a href="#">Vesta panel <span>&nbsp;</span></a></h1>
202202
</div>
203203

204204

205-
206-
<!-- script type="text/javascript" src="js/lib/jquery-1.4.4.min.js"></script -->
205+
207206
<script type="text/javascript" src="js/lib/cookie.js"></script>
208207
<script type="text/javascript" src="js/lib/jquery-1.6.1.js"></script>
209208
<script type="text/javascript" src="js/lib/jquery-ui-1.8.13.custom.min.js"></script>

web/js/_settings.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ App.Messages.get = function(key, plural) {
3737
}
3838
}
3939

40+
// Imutable
41+
App.Settings.Imutable = {};
42+
App.Settings.Imutable.USER = ['LOGIN_NAME'];
43+
App.Settings.Imutable.DB = ['DB', 'TYPE', 'USER'];
44+
App.Settings.Imutable.DNS = ['DNS_DOMAIN'];
45+
46+
4047
// Empty
4148
App.Empty = {};
4249
App.Empty.USER = {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','LNAME':'', 'FNAME':'','NS1':'','NS2':'','NS3':'','NS4':'','NS5':'','NS6':'','NS7':'','NS8':''};

web/js/actions.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,20 @@ App.Actions.save_form = function(evt) {
8484
if(App.Validate.form(values, $('#'+elm_id))) {
8585
App.Model.update(values, source, elm);
8686
}
87-
}
87+
}
8888
}
8989

9090
// do_action_edit
9191
App.Actions.edit = function(evt) {
9292
var elm = $(evt.target);
9393
elm = elm.hasClass('row') ? elm : elm.parents('.row');
9494

95-
var options = elm.find('.source').val();
96-
fb.warn(elm);
97-
fb.warn(options);
95+
var options = elm.find('.source').val();
9896
var build_method = App.Env.getWorldName() + '_form';
9997
var tpl = App.HTML.Build[build_method](options);
10098
elm.replaceWith(tpl);
10199

102-
//App.Pages[App.Env.world].edit(elm);
100+
App.Helpers.disbleNotEditable();
103101
//App.Helpers.updateScreen();
104102
}
105103

web/js/helpers.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,14 @@ App.Helpers.getFormValuesFromElement = function(ref)
202202
App.Helpers.updateScreen = function()
203203
{
204204
Custom.init();
205+
App.Ajax.request('MAIN.getInitial', {}, function(reply){
206+
App.Env.initialParams = reply.data;
207+
App.Helpers.updateInitial();
208+
});
205209
//$(document.body).find('select').each(function(i, o){
206210
// $(o).selectbox();
207211
//});
208-
}
212+
}
209213

210214
App.Helpers.alert = function(msg)
211215
{
@@ -287,3 +291,21 @@ App.Helpers.getBackendUrl = function()
287291

288292
return url_parts.join('/');
289293
}
294+
295+
App.Helpers.disbleNotEditable = function()
296+
{
297+
if ('undefined' == typeof App.Settings.Imutable[App.Env.world]) {
298+
return false;
299+
}
300+
301+
$('.form').each(function(i, form)
302+
{
303+
if ($(form).attr('id') == '') {
304+
$('input, select, textarea', form).each(function(i, elm) {
305+
if ($.inArray($(elm).attr('name'), App.Settings.Imutable[App.Env.world]) != -1) {
306+
$(elm).attr('disabled', true);
307+
}
308+
});
309+
}
310+
});
311+
}

web/js/html.js

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,10 @@ App.HTML.Build.user_entry = function(o, key)
197197
var sub_tpl = App.Templates.get('SUSPENDED_TPL_NOT_SUSPENDED', 'general');
198198
}*/
199199
tpl.set(':SUSPENDED_TPL', '');//sub_tpl.finalize());
200-
200+
201201
var ns = [];
202202
var ns_full = [];
203-
fb.info(o);
203+
204204
$([1,2,3,4,5,6,7,8]).each(function(i, index)
205205
{
206206
if (o['NS'+index].trim() != '') {
@@ -233,7 +233,7 @@ App.HTML.Build.user_entry = function(o, key)
233233
App.HTML.Build.user_form = function(options, id)
234234
{
235235
if('undefined' == typeof App.Env.initialParams) {
236-
return alert('PLease wait a bit. Some background processes are not yet executed. Thank you for patience.');
236+
return alert('Please wait a bit. Some background processes are not yet executed. Thank you for patience.');
237237
}
238238
var tpl = App.Templates.get('FORM', 'user');
239239
tpl.set(':source', options);
@@ -268,6 +268,13 @@ App.HTML.Build.user_form = function(options, id)
268268
tpl = App.HTML.setTplKeys(tpl, options, true);
269269
tpl = App.HTML.Build.user_selects(tpl, options);
270270

271+
if (options.REPORTS_ENABLED == 'yes') {
272+
tpl.set(':CHECKED', 'checked="checked"');
273+
}
274+
else {
275+
tpl.set(':CHECKED', '');
276+
}
277+
271278
return tpl.finalize();
272279
}
273280

@@ -301,18 +308,18 @@ App.HTML.Build.web_domain_form = function(options, id)
301308
tpl.set(':id', id || '');
302309
options = App.Helpers.evalJSON(options) || {};
303310
if (App.Helpers.isEmpty(options)) {
304-
tpl.set(':title', 'New user');
311+
tpl.set(':title', 'New WEB domain');
305312
tpl.set(':save_button', 'ADD');
306313
}
307314
else {
308-
tpl.set(':title', 'Edit user');
315+
tpl.set(':title', 'Edit WEB domain');
309316
tpl.set(':save_button', 'SAVE');
310317
}
311318

312319
options = !App.Helpers.isEmpty(options) ? options : App.Empty.WEB_DOMAIN;
313320

314321
tpl = App.HTML.setTplKeys(tpl, options, true);
315-
tpl = App.HTML.Build.user_selects(tpl, options);
322+
tpl = App.HTML.Build.web_domain_selects(tpl, options);
316323

317324
return tpl.finalize();
318325
}
@@ -560,7 +567,27 @@ App.HTML.Build.dns_selects = function(tpl, options)
560567
tpl.set(':TPL_DEFAULT_VALUE', options.TPL || App.Helpers.getFirstKey(obj));
561568
}
562569
catch (e) {
563-
return '';
570+
return tpl;
571+
}
572+
573+
return tpl;
574+
}
575+
576+
App.HTML.Build.web_domain_selects = function(tpl, options)
577+
{
578+
try {
579+
// IP
580+
var obj = App.Env.initialParams.WEB_DOMAIN.IP;
581+
var opts = App.HTML.Build.options(obj, options.IP);
582+
tpl.set(':IP_OPTIONS', opts);
583+
584+
// TPL
585+
var obj = App.Env.initialParams.WEB_DOMAIN.TPL;
586+
var opts = App.HTML.Build.options(obj, options.TPL);
587+
tpl.set(':TPL_OPTIONS', opts);
588+
}
589+
catch (e) {
590+
return tpl;
564591
}
565592

566593
return tpl;

web/js/model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ App.Model.add = function(values, source_json)
6969
spell: $.toJSON(values)
7070
}, function(reply){
7171
if(!reply.result) {
72-
App.Helpers.Warn('Changes were not applied');
72+
App.Helpers.Warn('Changes were not applied ' + App.Helpers.toJSON(reply.errors) );
7373
}
7474
else {
7575
/*var build_method = App.Env.getWorldName() + '_entry';

web/js/pages.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ App.Pages.DNS.edit = function(elm) {
4848
var tpl = App.HTML.Build.dns_form(options);
4949
elm.replaceWith(tpl);
5050
}
51+

web/js/templates.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ App.Templates.html = {
4343
},
4444
dns: {
4545
FORM: [
46-
'<div style="margin-top: 25px;" class="b-new-entry b-new-entry_dns" id="~!:id~!">\
46+
'<div style="margin-top: 25px;" class="b-new-entry b-new-entry_dns form" id="~!:id~!">\
4747
<input type="hidden" name="source" class="source" value=~!:source~!>\
4848
<input type="hidden" name="target" class="target" value=\'\'>\
4949
<div class="entry-header">~!:title~!</div>\
@@ -167,7 +167,7 @@ App.Templates.html = {
167167
},
168168
ip: {
169169
FORM: ['\
170-
<div class="b-new-entry b-new-entry_ip" id="~!:id~!">\
170+
<div class="b-new-entry b-new-entry_ip form" id="~!:id~!">\
171171
<input type="hidden" name="source" class="source" value=\'~!:source~!\'>\
172172
<input type="hidden" name="target" class="target" value=\'~!:target~!\'>\
173173
<div class="entry-header">~!:title~!</div>\
@@ -328,7 +328,7 @@ App.Templates.html = {
328328
</div>\
329329
<div class="form-row cc">\
330330
<label for="#" class="field-label">reports:</label>\
331-
<input type="checkbox" name="REPORTS_ENABLED" class="not-styled" value="~!:REPORTS_ENABLED~!">\
331+
<input type="checkbox" name="REPORTS_ENABLED" ~!:CHECKED~! class="not-styled" value="~!:REPORTS_ENABLED~!">\
332332
</div>\
333333
<div class="form-row cc">\
334334
<label for="#" class="field-label">Firstname:</label>\
@@ -493,7 +493,7 @@ App.Templates.html = {
493493
</div>']
494494
},
495495
web_domain: {
496-
FORM: ['<div id="~!:id~!" class="b-new-entry b-new-entry_domain">\
496+
FORM: ['<div id="~!:id~!" class="b-new-entry b-new-entry_domain form">\
497497
<input type="hidden" class="source" name="source" value=\'~!:source~!\' />\
498498
<input type="hidden" class="target" name="target" value="" />\
499499
<div class="entry-header">~!:title~!</div>\
@@ -699,11 +699,11 @@ App.Templates.html = {
699699
</span>\
700700
</div>'],
701701
ENTRIES_WRAPPER: ['<div class="db-list">~!:content~!</div>'],
702-
FORM: ['<div id="~!:id~!" class="b-new-entry b-new-entry_db">\
702+
FORM: ['<div id="~!:id~!" class="b-new-entry b-new-entry_db form">\
703703
<input type="hidden" name="source" class="source" value=\'~!:source~!\'>\
704704
<input type="hidden" name="target" class="target" value=\'\'>\
705705
<div class="entry-header">~!:title~!</div>\
706-
<div class="form-error">\
706+
<div class="form-error hidden">\
707707
</div>\
708708
<div class="form-row cc">\
709709
<label for="#" class="field-label">db type:</label>\
@@ -785,7 +785,7 @@ App.Templates.html = {
785785
</div>']
786786
},
787787
cron: {
788-
FORM: ['<div class="b-new-entry b-new-entry_cron" id="~!:id~!" >\
788+
FORM: ['<div class="b-new-entry b-new-entry_cron form" id="~!:id~!" >\
789789
<input type="hidden" name="source" class="source" value=\'~!:source~!\'>\
790790
<input type="hidden" name="target" class="target" value=\'\'>\
791791
<div class="entry-header">~!:title~!</div>\
@@ -798,31 +798,31 @@ App.Templates.html = {
798798
<div class="field-box cron-minute-box">\
799799
<label for="#" class="field-label ">minute:<br>(0&mdash;59)</label>\
800800
<div class="field-box-inner cc">\
801-
<input type="text" value="~!:MIN~!" name="MIN" class="text-field rule-required rule-minute">\
801+
<input type="text" value="~!:MIN~!" name="MIN" class="text-field rule-required rule-cronminute">\
802802
</div>\
803803
</div>\
804804
<div class="field-box cron-hour-box">\
805805
<label for="#" class="field-label">hour:<br>(0&mdash;23)</label>\
806806
<div class="field-box-inner cc">\
807-
<input type="text" value="~!:HOUR~!" name="HOUR" class="text-field rule-required rule-hour">\
807+
<input type="text" value="~!:HOUR~!" name="HOUR" class="text-field rule-required rule-cronhour">\
808808
</div>\
809809
</div>\
810810
<div class="field-box cron-day-box">\
811811
<label for="#" class="field-label">day of Month:<br>(1&mdash;31)</label>\
812812
<div class="field-box-inner cc">\
813-
<input type="text" value="~!:DAY~!" name="DAY" class="text-field rule-required rule-day">\
813+
<input type="text" value="~!:DAY~!" name="DAY" class="text-field rule-required rule-cronday">\
814814
</div>\
815815
</div>\
816816
<div class="field-box cron-month-box">\
817817
<label for="#" class="field-label">Month:<br>(1&mdash;12)(Jan&mdash;Dec)</label>\
818818
<div class="field-box-inner cc">\
819-
<input type="text" value="~!:MONTH~!" name="MONTH" class="text-field rule-required rule-month">\
819+
<input type="text" value="~!:MONTH~!" name="MONTH" class="text-field rule-required rule-cronmonth">\
820820
</div>\
821821
</div>\
822822
<div class="field-box cron-week-box">\
823823
<label for="#" class="field-label">day of Week:<br>(1&mdash;7)(Sun&mdash;Sat)</label>\
824824
<div class="field-box-inner cc">\
825-
<input type="text" value="~!:WDAY~!" name="WDAY" class="text-field rule-required rule-wday">\
825+
<input type="text" value="~!:WDAY~!" name="WDAY" class="text-field rule-required rule-cronwday">\
826826
</div>\
827827
</div>\
828828
</div>\

web/js/validators.js

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,52 +79,44 @@ App.Validate.Rule = {
7979
}
8080
return {VALID: true};
8181
},
82-
'minute': function(elm) {
83-
if ($(elm).val() == '*') {
84-
return {VALID: true};
85-
}
86-
var minute = parseInt($(elm).val(), 10);
87-
if (minute > 60 || minute < 0) {
82+
'cronminute': function(elm) {
83+
if ($(elm).val().trim() != '' && $(elm).val().search(/[^0-9\/\*-,]+/) != -1) {
8884
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' wrong minute value'};
8985
}
9086
return {VALID: true};
9187
},
92-
'hour': function(elm) {
88+
'cronhour': function(elm) {
9389
if ($(elm).val() == '*') {
9490
return {VALID: true};
9591
}
96-
var hour = parseInt($(elm).val(), 10);
97-
if (hour > 60 || hour < 0) {
92+
if ($(elm).val().trim() != '' && $(elm).val().search(/[^0-9\/\*-,]+/) != -1) {
9893
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' wrong hour value'};
9994
}
10095
return {VALID: true};
10196
},
102-
'wday': function(elm) {
97+
'cronwday': function(elm) {
10398
if ($(elm).val() == '*') {
10499
return {VALID: true};
105100
}
106-
var wday = parseInt($(elm).val(), 10);
107-
if (wday > 7 || wday < 1) {
101+
if ($(elm).val().trim() != '' && $(elm).val().search(/[^123456\/\*-,]+/) != -1) {
108102
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' wrong week day value'};
109103
}
110104
return {VALID: true};
111105
},
112-
'month': function(elm) {
106+
'cronmonth': function(elm) {
113107
if ($(elm).val() == '*') {
114108
return {VALID: true};
115-
}
116-
var month = parseInt($(elm).val(), 10);
117-
if (month > 1 || month < 12) {
109+
}
110+
if ($(elm).val().trim() != '' && $(elm).val().search(/[^0-9\/\*-,]+/) != -1) {
118111
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' wrong month value'};
119112
}
120113
return {VALID: true};
121114
},
122-
'day': function(elm) {
115+
'cronday': function(elm) {
123116
if ($(elm).val() == '*') {
124117
return {VALID: true};
125118
}
126-
var day = parseInt($(elm).val(), 10);
127-
if (day > 31 || day < 1) {
119+
if ($(elm).val().trim() != '' && $(elm).val().search(/[^0-9\/\*-,]+/) != -1) {
128120
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' wrong day value'};
129121
}
130122
return {VALID: true};

0 commit comments

Comments
 (0)