Skip to content

Commit eb2e896

Browse files
committed
Php+Js update set
1 parent 2574231 commit eb2e896

File tree

11 files changed

+249
-140
lines changed

11 files changed

+249
-140
lines changed

web/js/_settings.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ App.Settings.ajax_url = 1;
2828
App.Settings.uri = location.href.replace('index.html', '');
2929
App.Settings.popup_conf = { 'centered' : true, 'bgcolor' : '#FF0000', 'lightboxSpeed' : 'fast', 'destroyOnClose': true };
3030

31+
App.Settings.PASSWORD_IMMUTE = '********';
3132

3233
// Messages
3334
App.Messages.total_dns_records = {single: 'total record', plural: 'total records'};
@@ -42,12 +43,14 @@ App.Settings.Imutable = {};
4243
App.Settings.Imutable.USER = ['LOGIN_NAME'];
4344
App.Settings.Imutable.DB = ['DB', 'TYPE', 'USER'];
4445
App.Settings.Imutable.DNS = ['DNS_DOMAIN'];
46+
App.Settings.Imutable.IP = ['INTERFACE'];
4547

4648

4749
// Empty
4850
App.Empty = {};
49-
App.Empty.USER = {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','LNAME':'', 'FNAME':'','NS1':'','NS2':'','NS3':'','NS4':'','NS5':'','NS6':'','NS7':'','NS8':''};
51+
App.Empty.USER = {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','LNAME':'', 'FNAME':'','NS1':'','NS2':'','NS3':'','NS4':'','NS5':'','NS6':'','NS7':'','NS8':''};
5052
App.Empty.WEB_DOMAIN = {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','NS':'', 'DOMAIN':'','SSL_CERT':'','SSL_HOME':'','STATS_PASSWORD':'','STATS_LOGIN':'','ALIAS':''};
53+
App.Empty.DB = {'DB':'', 'USER':'','FORM':'', 'PASSWORD': ''};
5154

5255
App.Settings.getMethodName = function(action)
5356
{

web/js/helpers.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
1+
App.Helpers.scrollTo = function(elm)
2+
{
3+
fb.log(elm);
4+
var scroll_to = $(elm).offset().top;
5+
if (scroll_to > 1000) {
6+
var scroll_time = 300;
7+
}
8+
else {
9+
var scroll_time = 550;
10+
}
11+
$('html, body').animate({
12+
'scrollTop': scroll_to
13+
}, scroll_time);
14+
}
215

316
App.Helpers.getMbHumanMeasure = function(val)
417
{
@@ -201,7 +214,7 @@ App.Helpers.getFormValuesFromElement = function(ref)
201214

202215
App.Helpers.updateScreen = function()
203216
{
204-
Custom.init();
217+
//Custom.init();
205218
App.Ajax.request('MAIN.getInitial', {}, function(reply){
206219
App.Env.initialParams = reply.data;
207220
App.Helpers.updateInitial();

web/js/html.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,6 @@ App.HTML.Build.user_entry = function(o, key)
190190
var tpl = App.Templates.get('ENTRY', 'user');
191191
tpl = App.HTML.setTplKeys(tpl, o);
192192

193-
/*if (App.Constants.SUSPENDED_YES == o.SUSPENDED) {
194-
var sub_tpl = App.Templates.get('SUSPENDED_TPL_SUSPENDED', 'general');
195-
}
196-
else {
197-
var sub_tpl = App.Templates.get('SUSPENDED_TPL_NOT_SUSPENDED', 'general');
198-
}*/
199193
tpl.set(':SUSPENDED_TPL', '');//sub_tpl.finalize());
200194

201195
var ns = [];
@@ -225,13 +219,18 @@ App.HTML.Build.user_entry = function(o, key)
225219
tpl.set(':NS', ns_custom.finalize());
226220
}
227221

228-
222+
tpl.set(':REPORTS_ENABLED', o.REPORTS_ENABLED == 'yes' ? 'enabled' : 'DISABLED');
223+
229224
return tpl.finalize();
230225
}
231226

232227

233228
App.HTML.Build.user_form = function(options, id)
234229
{
230+
var in_edit = false;
231+
if (!App.Helpers.isEmpty(options)) {
232+
in_edit = true;
233+
}
235234
if('undefined' == typeof App.Env.initialParams) {
236235
return alert('Please wait a bit. Some background processes are not yet executed. Thank you for patience.');
237236
}
@@ -253,7 +252,7 @@ App.HTML.Build.user_form = function(options, id)
253252
// NS
254253
var ns = [];
255254
$([3,4,5,6,7,8]).each(function(i, index)
256-
{fb.warn(options);
255+
{
257256
if (options['NS'+index].trim() != '') {
258257
var tpl_ns = App.Templates.get('NS_INPUT', 'user');
259258
tpl_ns.set(':NS_LABEL', 'NS #' + (index));
@@ -264,7 +263,9 @@ App.HTML.Build.user_form = function(options, id)
264263
ns[ns.length++] = App.Templates.get('PLUS_ONE_NS', 'user').finalize();
265264

266265
tpl.set(':NS', ns.done());
267-
266+
if (in_edit == true) {
267+
options.PASSWORD = App.Settings.PASSWORD_IMMUTE;
268+
}
268269
tpl = App.HTML.setTplKeys(tpl, options, true);
269270
tpl = App.HTML.Build.user_selects(tpl, options);
270271

@@ -287,7 +288,7 @@ App.HTML.Build.web_domain_entry = function(o, key)
287288
var tpl = App.Templates.get('ENTRY', 'web_domain');
288289
tpl = App.HTML.setTplKeys(tpl, o);
289290

290-
if (App.Constants.SUSPENDED_YES == o.SUSPENDED) {
291+
if (App.Constants.SUSPENDED_YES == o.SUSPEND) {
291292
var sub_tpl = App.Templates.get('SUSPENDED_TPL_SUSPENDED', 'general');
292293
}
293294
else {
@@ -364,6 +365,10 @@ App.HTML.Build.db_entry = function(o, key)
364365

365366
App.HTML.Build.db_form = function(options, id)
366367
{
368+
var in_edit = false;
369+
if (!App.Helpers.isEmpty(options)) {
370+
in_edit = true;
371+
}
367372
if('undefined' == typeof App.Env.initialParams) {
368373
return alert('PLease wait a bit. Some background processes are not yet executed. Thank you for patience.');
369374
}
@@ -380,11 +385,12 @@ App.HTML.Build.db_form = function(options, id)
380385
tpl.set(':save_button', 'SAVE');
381386
}
382387

383-
options = !App.Helpers.isEmpty(options) ? options : {'DB':'', 'USER':'','FORM':'', 'PASSWORD': ''};
388+
options = !App.Helpers.isEmpty(options) ? options : App.Empty.DB;
389+
if (in_edit == true) {
390+
options.PASSWORD = App.Settings.PASSWORD_IMMUTE;
391+
}
384392
tpl = App.HTML.setTplKeys(tpl, options, true);
385-
tpl = App.HTML.Build.db_selects(tpl, options);
386-
387-
tpl.set(':PASSWORD', '');
393+
tpl = App.HTML.Build.db_selects(tpl, options);
388394

389395
return tpl.finalize();
390396
}
@@ -542,7 +548,7 @@ App.HTML.Build.db_selects = function(tpl, options)
542548
App.HTML.Build.ip_selects = function(tpl, options)
543549
{
544550
// OWNER
545-
var users = App.Env.initialParams.IP.SYS_USERS;
551+
var users = App.Env.initialParams.IP.OWNER;
546552
var opts = App.HTML.Build.options(users, options.OWNER);
547553
tpl.set(':owner_options', opts);
548554

web/js/templates.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ App.Templates.html = {
310310
~!:PACKAGE_OPTIONS~!\
311311
</select>\
312312
</div>\
313-
<div class="form-row cc hidden">\
313+
<div class="form-row cc">\
314314
<label for="#" class="field-label">shell:</label>\
315315
<select class="not-styled" name="SHELL">\
316316
~!:SHELL_OPTIONS~!\
@@ -511,7 +511,15 @@ App.Templates.html = {
511511
</select>\
512512
</div>\
513513
</div>\
514-
<!-- advanced options -->\
514+
<div class="form-row cc">\
515+
<label for="#" class="field-label">CGI:</label>\
516+
<input type="checkbox" value="~!:CGI~!" ~!:CHECKED_CGI~! name="CGI" class="not-styled">\
517+
</div>\
518+
<div class="form-row cc">\
519+
<label for="#" class="field-label">ELOG:</label>\
520+
<input type="checkbox" value="~!:ELOG~!" ~!:CHECKED_ELOG~! name="ELOG" class="not-styled">\
521+
</div>\
522+
<!-- advanced options -->\
515523
<div class="form-options-group">\
516524
<div class="group-header cc collapsed">\
517525
<span class="group-title-outer do_action_toggle_section">\
@@ -531,26 +539,26 @@ App.Templates.html = {
531539
</div>\
532540
<div class="form-row cc">\
533541
<label for="#" class="field-label">statistics:</label>\
534-
<input type="checkbox" name="STATS" ~!:stats_checked~!="" value="~!:STATS~!" class="styled">\
542+
<input type="checkbox" name="STATS" ~!:stats_checked~!="" value="~!:STATS~!" class="not-styled">\
535543
</div>\
536544
<div class="stats-settings">\
537545
<div class="form-row cc">\
538546
<label for="#" class="field-label">stats auth:</label>\
539-
<input type="checkbox" name="STATS_AUTH" ~!:stats_auth_checked~!="" value="~!:STATS_AUTH~!" class="styled">\
547+
<input id="stats-auth-enable" type="checkbox" name="STATS_AUTH" ~!:stats_auth_checked~!="" value="~!:STATS_AUTH~!" class="not-styled">\
540548
</div>\
541549
<div class="form-row cc">\
542-
<label for="#" class="field-label">login:</label>\
543-
<input type="text" class="text-field rule-username" name="STATS_LOGIN" value="~!:STATS_LOGIN~!">\
550+
<label for="#" class="field-label">stats login:</label>\
551+
<input type="text" class="text-field rule-statslogin" name="STATS_LOGIN" value="~!:STATS_LOGIN~!">\
544552
</div>\
545553
<div class="form-row pwd-box cc">\
546554
<label for="#" class="field-label">password:</label>\
547-
<input type="text" value="~!:STATS_PASSWORD~!" name="STATS_PASSWORD" class="text-field rule-password">\
555+
<input type="text" value="~!:STATS_PASSWORD~!" name="STATS_PASSWORD" class="text-field rule-statspassword password">\
548556
<span class="generate-pwd do_action_generate_pass">Generate</span>\
549557
</div>\
550558
</div><!-- // stats settings -->\
551559
<div class="form-row cc">\
552560
<label for="#" class="field-label">ssl:</label>\
553-
<input type="checkbox" class="styled" ~!:ssl_checked~!="" value="~!SSL~!">\
561+
<input type="checkbox" name="SSL" class="styled" ~!:ssl_checked~!="" value="~!SSL~!">\
554562
</div>\
555563
<div class="form-row cc">\
556564
<label for="#" class="field-label">ssl home:</label>\
@@ -572,7 +580,7 @@ App.Templates.html = {
572580
<div class="sub_section hidden">\
573581
<div class="form-row cc">\
574582
<label for="#" class="field-label">create dns domain:</label>\
575-
<input type="checkbox" value="" class="not-styled">\
583+
<input type="checkbox" value="~!:DNS~!" ~!:CHECKED_DNS~! name="DNS" class="not-styled">\
576584
</div>\
577585
</div><!-- DNS options -->\
578586
<div class="form-options-group">\
@@ -584,7 +592,7 @@ App.Templates.html = {
584592
<div class="sub_section hidden">\
585593
<div class="form-row cc">\
586594
<label for="#" class="field-label">create mail domain:</label>\
587-
<input type="checkbox" value="" class="not-styled">\
595+
<input type="checkbox" value="~!:MAIL~!" ~!:CHECKED_MAIL~! name="MAIL" class="not-styled">\
588596
</div>\
589597
</div>\
590598
</div>\

web/js/validators.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,25 @@ App.Validate.getFieldName = function(elm)
2525
}
2626

2727
App.Validate.Rule = {
28+
'statslogin' : function(elm) {
29+
if (!!$('#stats-auth-enable').attr('checked') == true) {
30+
if ($(elm).val().trim() == '' || $(elm).val().search(/[^a-zA-Z_]+/) != -1) {
31+
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' is invalid'};
32+
}
33+
}
34+
return {VALID: true};
35+
},
36+
'statspassword': function(elm) {
37+
if (!!$('#stats-auth-enable').attr('checked') == true) {
38+
if ($(elm).val().trim() == '') {
39+
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' is required'};
40+
}
41+
}
42+
return {VALID: true};
43+
},
2844
'username' : function(elm) {
2945
if ($(elm).val().trim() != '' && $(elm).val().search(/[^a-zA-Z_]+/) != -1) {
30-
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' is required'};
46+
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' is invalid'};
3147
}
3248
return {VALID: true};
3349
},
@@ -173,14 +189,16 @@ App.Validate.displayFormErrors = function(world, elm)
173189
var ref = $('.form-error', elm);
174190
ref.removeClass('hidden');
175191
ref.html(errors_tpl);
192+
App.Helpers.scrollTo(ref);
176193
}
177194

178195
App.Validate.getRules = function(elm)
179196
{
180197
try {
181198
var rules_string = $(elm).attr('class');
182199
var rules = [];
183-
$(rules_string.split(/\s/)).each(function(i, str)
200+
var rules_splitted = rules_string.split(/\s/);
201+
$(rules_splitted).each(function(i, str)
184202
{
185203
var rule = str.split('rule-');
186204
if (rule.length > 1) {

web/vesta/api/AjaxHandler.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class AjaxHandler {
1313
static public $instance = null;
1414

1515
const JSON = 'json';
16+
const TEXT = 'text';
1617
public $errors = array();
1718
public $status = TRUE;
1819

0 commit comments

Comments
 (0)