mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-14 02:28:03 -07:00
USERS / CRON / IP ready. DNS (partly). JS form validators written. Added functionality
This commit is contained in:
parent
ea5a8a2659
commit
04c7a8b545
15 changed files with 568 additions and 297 deletions
|
@ -8,34 +8,38 @@ App.i18n.getMessage = function(key)
|
|||
}
|
||||
|
||||
|
||||
|
||||
// Constants
|
||||
App.Constants.IP_FORM_ID = 'ip-form';
|
||||
App.Constants.DNS_FORM_ID = 'dns-form';
|
||||
App.Constants.USER_FORM_ID = 'user-form';
|
||||
App.Constants.WEB_DOMAIN_FORM_ID = 'web_domain-form';
|
||||
App.Constants.DB_FORM_ID = 'db-form';
|
||||
App.Constants.CRON_FORM_ID = 'cron-form';
|
||||
App.Constants.IP_FORM_ID = 'ip-form';
|
||||
App.Constants.DNS_FORM_ID = 'dns-form';
|
||||
App.Constants.USER_FORM_ID = 'user-form';
|
||||
App.Constants.WEB_DOMAIN_FORM_ID = 'web_domain-form';
|
||||
App.Constants.DB_FORM_ID = 'db-form';
|
||||
App.Constants.CRON_FORM_ID = 'cron-form';
|
||||
App.Constants.IP = 'IP';
|
||||
App.Constants.DNS = 'DNS';
|
||||
App.Constants.SUSPENDED_YES = 'yes';
|
||||
App.Constants.DNS_TEMPLATES = {'default': 'Default'};
|
||||
|
||||
App.Settings.ajax_url = 1;
|
||||
App.Settings.uri = location.href.replace('index.html', '');
|
||||
App.Settings.popup_conf = { 'centered' : true, 'bgcolor' : '#FF0000', 'lightboxSpeed' : 'fast', 'destroyOnClose': true };
|
||||
// Settings
|
||||
App.Settings.USER_VISIBLE_NS = 2;
|
||||
App.Settings.NS_MIN = 2;
|
||||
App.Settings.NS_MAX = 8;
|
||||
App.Settings.ajax_url = 1;
|
||||
App.Settings.uri = location.href.replace('index.html', '');
|
||||
App.Settings.popup_conf = { 'centered' : true, 'bgcolor' : '#FF0000', 'lightboxSpeed' : 'fast', 'destroyOnClose': true };
|
||||
|
||||
App.Constants.SUSPENDED_YES = 'yes';
|
||||
|
||||
App.Constants.IP = 'IP';
|
||||
App.Constants.DNS = 'DNS';
|
||||
|
||||
App.Constants.DNS_TEMPLATES = {'default': 'Default'};
|
||||
|
||||
// Messages
|
||||
App.Messages.total_dns_records = {single: 'total record', plural: 'total records'};
|
||||
|
||||
App.Messages.get = function(key, plural) {
|
||||
if ('undefined' != typeof App.Messages[key]) {
|
||||
return plural ? App.Messages[key].plural : App.Messages[key].single;
|
||||
}
|
||||
}
|
||||
|
||||
// Empty
|
||||
App.Empty = {};
|
||||
App.Empty.USER = {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','LNAME':'', 'FNAME':'','NS1':'','NS2':'','NS3':'','NS4':'','NS5':'','NS6':'','NS7':'','NS8':''};
|
||||
|
||||
App.Settings.getMethodName = function(action)
|
||||
{
|
||||
|
|
|
@ -103,8 +103,7 @@ App.Actions.save_form = function(evt) {
|
|||
else { // OLD ITEM, UPDATING IT
|
||||
var source = $(elm).find('.source').val();
|
||||
var values = App.Helpers.getFormValues(elm);
|
||||
if(App.Validate.form(values, $('#'+elm_id))) {
|
||||
App.Model.add(values, source);
|
||||
if(App.Validate.form(values, $('#'+elm_id))) {
|
||||
App.Model.update(values, source, elm);
|
||||
}
|
||||
}
|
||||
|
@ -146,12 +145,49 @@ App.Actions.cancel_form = function(evt, params) {
|
|||
|
||||
App.Actions.suspend = function(evt)
|
||||
{
|
||||
alert('Suspend?');
|
||||
var confirmed = confirm('Suspend?');
|
||||
if (!confirmed) {
|
||||
return ;
|
||||
}
|
||||
var elm = $(evt.target);
|
||||
var row = elm.parents('.row');
|
||||
|
||||
var options = row.find('.source').val();
|
||||
App.Ajax.request(App.Env.world+'.suspend', {spell: options}, function(reply) {
|
||||
if (reply.result) {
|
||||
//var tpl = App.Templates.get('SUSPENDED_TPL_SUSPENDED', 'general');
|
||||
//$(elm).replaceWith(tpl.finalize());
|
||||
App.Pages.prepareHTML();
|
||||
App.Helpers.updateScreen();
|
||||
}
|
||||
else {
|
||||
return App.Helpers.alert('Failed to suspend');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
App.Actions.unsuspend = function(evt)
|
||||
{
|
||||
alert('Unsuspend?');
|
||||
var confirmed = confirm('Unsuspend?');
|
||||
if (!confirmed) {
|
||||
return ;
|
||||
}
|
||||
|
||||
var elm = $(evt.target);
|
||||
var row = elm.parents('.row');
|
||||
|
||||
var options = row.find('.source').val();
|
||||
App.Ajax.request(App.Env.world+'.unsuspend', {spell: options}, function(reply) {
|
||||
if (reply.result) {
|
||||
//var tpl = App.Templates.get('SUSPENDED_TPL_NOT_SUSPENDED', 'general');
|
||||
//$(elm).replaceWith(tpl.finalize());
|
||||
App.Pages.prepareHTML();
|
||||
App.Helpers.updateScreen();
|
||||
}
|
||||
else {
|
||||
return App.Helpers.alert('Failed to suspend');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// do_action_form_help
|
||||
|
@ -230,3 +266,56 @@ App.Actions.backup_db = function(evt)
|
|||
{
|
||||
alert('TODO');
|
||||
}
|
||||
|
||||
App.Actions.add_form_ns = function(evt)
|
||||
{
|
||||
var elm = $(evt.target);
|
||||
|
||||
form = elm.parents('.form:first');
|
||||
var total_nses = $(form).find('.ns-entry').length;
|
||||
if (total_nses == App.Settings.NS_MAX) {
|
||||
return App.Helpers.alert('Maximum number of NS cannot be more than ' + App.Settings.NS_MAX);
|
||||
}
|
||||
|
||||
var tpl = App.Templates.get('NS_INPUT', 'user');
|
||||
tpl.set(':NAME', '');
|
||||
tpl.set(':NS_LABEL', 'NS');
|
||||
elm.before(tpl.finalize());
|
||||
|
||||
if ((total_nses + 1) == App.Settings.NS_MAX ) { // added last NS
|
||||
$('.additional-ns-add', form).addClass('hidden');
|
||||
}
|
||||
|
||||
$(form).find('.ns-entry').each(function(i, o)
|
||||
{
|
||||
$(o).find('label').text('NS #' + (i + 1));
|
||||
$(o).find('input').attr('name', 'NS' + (i + 1));
|
||||
});
|
||||
}
|
||||
|
||||
App.Actions.delete_ns = function(evt)
|
||||
{
|
||||
var elm = $(evt.target);
|
||||
|
||||
form = elm.parents('.form:first');
|
||||
var total_nses = $(form).find('.ns-entry').length;
|
||||
if (total_nses == App.Settings.NS_MIN) {
|
||||
return App.Helpers.alert('Minimum number of NS is ' + App.Settings.NS_MIN);
|
||||
}
|
||||
|
||||
var form = elm.parents('.form:first');
|
||||
$(elm).parents('.form:first').find('.additional-ns-add').removeClass('hidden');
|
||||
$(elm).parents('.ns-entry').remove();
|
||||
|
||||
$(form).find('.ns-entry').each(function(i, o)
|
||||
{
|
||||
$(o).find('label').text('NS #' + (i + 1));
|
||||
$(o).find('input').attr('name', 'NS' + (i + 1));
|
||||
});
|
||||
}
|
||||
|
||||
App.Actions.view_full_ns_list = function(evt)
|
||||
{
|
||||
var elm = $(evt.target);
|
||||
App.Helpers.openInnerPopup(elm, $(elm).parents('.prop-box').find('.ns-full-list:first').html());
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
App.HTML.setTplKeys = function(tpl, o, empty)
|
||||
{
|
||||
var empty = empty || '-';
|
||||
var empty = empty || '';
|
||||
fb.log(empty);
|
||||
tpl.set(':source', $.toJSON(o).replace(/'/gi, "\\'"))
|
||||
$(o).each(function(i, object)
|
||||
|
@ -12,7 +12,7 @@ App.HTML.setTplKeys = function(tpl, o, empty)
|
|||
tpl.set(':' + key, val || '');
|
||||
}
|
||||
else {
|
||||
tpl.set(':' + key, val || '-');
|
||||
tpl.set(':' + key, val || '');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -138,14 +138,14 @@ App.HTML.Build.ip_entry = function(o)
|
|||
var tpl = App.Templates.get('ENTRY', 'ip');
|
||||
tpl = App.HTML.setTplKeys(tpl, o);
|
||||
|
||||
if (App.Constants.SUSPENDED_YES == o.SUSPENDED) {
|
||||
/*if (App.Constants.SUSPENDED_YES == o.SUSPENDED) {
|
||||
var sub_tpl = App.Templates.get('SUSPENDED_TPL_ENABLED', 'ip');
|
||||
}
|
||||
else {
|
||||
var sub_tpl = App.Templates.get('SUSPENDED_TPL_DISABLED', 'ip');
|
||||
}
|
||||
}*/
|
||||
|
||||
tpl.set(':SUSPENDED_TPL', sub_tpl.finalize());
|
||||
tpl.set(':SUSPENDED_TPL', '');
|
||||
|
||||
return tpl.finalize();
|
||||
}
|
||||
|
@ -163,14 +163,14 @@ App.HTML.Build.dns_entry = function(o, is_new)
|
|||
tpl.set(':DATE', now.format("d.mm.yyyy"));
|
||||
}
|
||||
|
||||
if (App.Constants.SUSPENDED_YES == o.SUSPEND) {
|
||||
/*if (App.Constants.SUSPENDED_YES == o.SUSPEND) {
|
||||
var sub_tpl = App.Templates.get('SUSPENDED_TPL_NOT_SUSPENDED', 'general');
|
||||
}
|
||||
else {
|
||||
var sub_tpl = App.Templates.get('SUSPENDED_TPL_SUSPENDED', 'general');
|
||||
}
|
||||
}*/
|
||||
|
||||
tpl.set(':SUSPENDED_TPL', sub_tpl.finalize());
|
||||
tpl.set(':SUSPENDED_TPL', '');
|
||||
|
||||
return tpl.finalize();
|
||||
}
|
||||
|
@ -190,13 +190,41 @@ App.HTML.Build.user_entry = function(o, key)
|
|||
var tpl = App.Templates.get('ENTRY', 'user');
|
||||
tpl = App.HTML.setTplKeys(tpl, o);
|
||||
|
||||
if (App.Constants.SUSPENDED_YES == o.SUSPENDED) {
|
||||
/*if (App.Constants.SUSPENDED_YES == o.SUSPENDED) {
|
||||
var sub_tpl = App.Templates.get('SUSPENDED_TPL_SUSPENDED', 'general');
|
||||
}
|
||||
else {
|
||||
var sub_tpl = App.Templates.get('SUSPENDED_TPL_NOT_SUSPENDED', 'general');
|
||||
}*/
|
||||
tpl.set(':SUSPENDED_TPL', '');//sub_tpl.finalize());
|
||||
|
||||
var ns = [];
|
||||
var ns_full = [];
|
||||
fb.info(o);
|
||||
$([1,2,3,4,5,6,7,8]).each(function(i, index)
|
||||
{
|
||||
if (o['NS'+index].trim() != '') {
|
||||
var tpl_ns = App.Templates.get('NS_RECORD', 'user');
|
||||
tpl_ns.set(':NAME', o['NS'+index]);
|
||||
var tpl_finalized = tpl_ns.finalize();
|
||||
ns_full[ns_full.length++] = tpl_finalized;
|
||||
if (i < App.Settings.USER_VISIBLE_NS) {
|
||||
ns[ns.length++] = tpl_finalized;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (ns_full.length <= App.Settings.USER_VISIBLE_NS) {
|
||||
tpl.set(':NS', ns.done());
|
||||
}
|
||||
tpl.set(':SUSPENDED_TPL', sub_tpl.finalize());
|
||||
else {
|
||||
var ns_custom = App.Templates.get('NS_MINIMIZED', 'user');
|
||||
ns_custom.set(':NS_MINI', ns.done());
|
||||
ns_custom.set(':NS_FULL', ns_full.done());
|
||||
ns_custom.set(':MORE_NUMBER', Math.abs(App.Settings.USER_VISIBLE_NS - ns_full.length));
|
||||
tpl.set(':NS', ns_custom.finalize());
|
||||
}
|
||||
|
||||
|
||||
return tpl.finalize();
|
||||
}
|
||||
|
@ -220,7 +248,22 @@ App.HTML.Build.user_form = function(options, id)
|
|||
tpl.set(':save_button', 'SAVE');
|
||||
}
|
||||
|
||||
options = !App.Helpers.isEmpty(options) ? options : {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','LNAME':'', 'FNAME':''};
|
||||
options = !App.Helpers.isEmpty(options) ? options : App.Empty.USER;
|
||||
|
||||
// NS
|
||||
var ns = [];
|
||||
$([3,4,5,6,7,8]).each(function(i, index)
|
||||
{fb.warn(options);
|
||||
if (options['NS'+index].trim() != '') {
|
||||
var tpl_ns = App.Templates.get('NS_INPUT', 'user');
|
||||
tpl_ns.set(':NS_LABEL', 'NS #' + (index));
|
||||
tpl_ns.set(':NAME', options['NS'+index]);
|
||||
ns[ns.length++] = tpl_ns.finalize();
|
||||
}
|
||||
});
|
||||
ns[ns.length++] = App.Templates.get('PLUS_ONE_NS', 'user').finalize();
|
||||
|
||||
tpl.set(':NS', ns.done());
|
||||
|
||||
tpl = App.HTML.setTplKeys(tpl, options, true);
|
||||
tpl = App.HTML.Build.user_selects(tpl, options);
|
||||
|
@ -491,7 +534,7 @@ App.HTML.Build.db_selects = function(tpl, options)
|
|||
App.HTML.Build.ip_selects = function(tpl, options)
|
||||
{
|
||||
// OWNER
|
||||
var users = App.Env.initialParams.IP.SYS_USERS || ['Skid'];
|
||||
var users = App.Env.initialParams.IP.SYS_USERS;
|
||||
var opts = App.HTML.Build.options(users, options.OWNER);
|
||||
tpl.set(':owner_options', opts);
|
||||
|
||||
|
|
|
@ -77,6 +77,7 @@ App.Model.add = function(values, source_json)
|
|||
App.Ref.CONTENT..replaceWith(tpl);*/
|
||||
// todo: reply.data;
|
||||
App.Pages.prepareHTML();
|
||||
App.Helpers.updateScreen();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -114,8 +115,11 @@ App.Model.update = function(values, source_json, elm)
|
|||
App.Helpers.Warn('Changes were not applied');
|
||||
}
|
||||
else {
|
||||
var tpl = App.HTML.Build[build_method](reply.data);
|
||||
/*var tpl = App.HTML.Build[build_method](reply.data);
|
||||
$(elm).replaceWith(tpl);
|
||||
App.Helpers.updateScreen();*/
|
||||
// todo: reply.data;
|
||||
App.Pages.prepareHTML();
|
||||
App.Helpers.updateScreen();
|
||||
}
|
||||
// TODO: !
|
||||
|
|
|
@ -32,7 +32,7 @@ App.Templates.html = {
|
|||
select_option: ['<option ~!:SELECTED~! value="~!:VALUE~!">~!:TEXT~!</option>'],
|
||||
error_elm: ['<div class="error-box">~!:ERROR~!</div>'],
|
||||
SUSPENDED_TPL_NOT_SUSPENDED : ['<span class="ip-status-info ip-enabled-status do_action_suspend"><span class="ip-status-text do_action_suspend">enabled</span></span>'],
|
||||
SUSPENDED_TPL_SUSPENDED : ['<span class="ip-status-info ip-enabled-status do_action_unsuspend"><span class="ip-status-text do_action_unsuspend">disabled</span></span>']
|
||||
SUSPENDED_TPL_SUSPENDED : ['<span class="ip-status-info ip-suspended-status do_action_unsuspend"><span class="ip-status-text do_action_unsuspend">suspended</span></span>']
|
||||
},
|
||||
popup: {
|
||||
error: ['<div class="error"><center><h1 style="color: red;">Important: An Error Has Occured.</h1><hr></center> Something went wrong and some of your actions can be not saved in system. Mostly, it happens when you have network connection errors.<br>, However, please notify us about the situation. It would be helpfull if you will write us approximate time the error occured and last actions you were performing. You send your petition on <a href="mail_to">this email: BLABLA</a>,<br><br><center><span style="color: rgb(92, 92, 92);">Sorry for inconvinience. (We recommend you to reload the page)</span></center></div>']
|
||||
|
@ -47,17 +47,17 @@ App.Templates.html = {
|
|||
<input type="hidden" name="source" class="source" value=~!:source~!>\
|
||||
<input type="hidden" name="target" class="target" value=\'\'>\
|
||||
<div class="entry-header">~!:title~!</div>\
|
||||
<div class="errors">\
|
||||
<div class="form-error hidden">\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<input type="hidden" value="~!:DATE~!" name="DATE">\
|
||||
<label for="#" class="field-label">domain:</label>\
|
||||
<input type="text" name="DNS_DOMAIN" value="~!:DNS_DOMAIN~!" class="text-field DNS_DOMAIN">\
|
||||
<input type="text" name="DNS_DOMAIN" value="~!:DNS_DOMAIN~!" class="text-field rule-required rule-domain">\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">ip address:</label>\
|
||||
<div class="autocomplete-box">\
|
||||
<input type="text" name="IP" value="~!:IP~!" class="text-field IP">\
|
||||
<input type="text" name="IP" value="~!:IP~!" class="text-field rule-required rule-ip">\
|
||||
<i class="arrow"> </i>\
|
||||
</div>\
|
||||
</div>\
|
||||
|
@ -71,11 +71,11 @@ App.Templates.html = {
|
|||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">ttl:</label>\
|
||||
<input type="text" value="~!:TTL~!" name="TTL" class="text-field ttl-field">\
|
||||
<input type="text" value="~!:TTL~!" name="TTL" class="text-field ttl-field rule-required rule-numeric">\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">soa:</label>\
|
||||
<input type="text" value="~!:SOA~!" name="SOA" class="text-field">\
|
||||
<input type="text" value="~!:SOA~!" name="SOA" class="text-field rule-required rule-numeric">\
|
||||
</div>\
|
||||
<div class="form-row buttons-row cc">\
|
||||
<input type="submit" value="~!:save_button~!" class="add-entry-btn do_action_save_form" name="save">\
|
||||
|
@ -171,11 +171,11 @@ App.Templates.html = {
|
|||
<input type="hidden" name="source" class="source" value=\'~!:source~!\'>\
|
||||
<input type="hidden" name="target" class="target" value=\'~!:target~!\'>\
|
||||
<div class="entry-header">~!:title~!</div>\
|
||||
<div class="form-error">\
|
||||
<div class="form-error hidden">\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">ip address:</label>\
|
||||
<input type="text" value="~!:IP_ADDRESS~!" name="IP_ADDRESS" class="text-field">\
|
||||
<input type="text" value="~!:IP_ADDRESS~!" name="IP_ADDRESS" class="text-field rule-required rule-ip">\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">owner:</label>\
|
||||
|
@ -192,7 +192,7 @@ App.Templates.html = {
|
|||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">name:</label>\
|
||||
<input type="text" name="NAME" value="~!:NAME~!" class="text-field">\
|
||||
<input type="text" name="NAME" value="~!:NAME~!" class="text-field rule-abc">\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">interface:</label>\
|
||||
|
@ -276,12 +276,24 @@ App.Templates.html = {
|
|||
SUSPENDED_TPL_DISABLED : ['<span class="ip-status-info ip-suspended-status do_action_delete_ip"><span class="ip-status-text">suspended</span></span>']
|
||||
},
|
||||
user: {
|
||||
NS_MINIMIZED: ['~!:NS_MINI~!\
|
||||
<span class="group-switcher">\
|
||||
<span class="group-values-count do_action_view_full_ns_list">~!:MORE_NUMBER~! more</span>\
|
||||
</span><span class="hidden ns-full-list"><span class="group-values group-values__bullet">~!:NS_FULL~!</span></span>'],
|
||||
/*NS_RECORD_POPUP_WRAP: ['<ul class="d-popup-items">~!:CONTENT~!</ul>'],
|
||||
NS_RECORD_POPUP: ['<li class="item">~!:NAME~!</li>'],*/
|
||||
NS_RECORD: ['<span class="prop-value">~!:NAME~!</span>'],
|
||||
NS_INPUT: ['<div class="form-row ns-entry cc"><label for="#" class="field-label">~!:NS_LABEL~!:</label>\
|
||||
<input type="text" value="~!:NAME~!" name="" class="text-field ns-input rule-required rule-ns">\
|
||||
<button class="do_action_delete_ns">Delete</button>\
|
||||
</div>'],
|
||||
PLUS_ONE_NS: ['<button class="additional-ns-add do_action_add_form_ns">Add additional NS</button>'],
|
||||
ENTRIES_WRAPPER: ['<div class="users-list items-list">~!:content~!</div>'],
|
||||
FORM: ['<div id="~!:id~!" class="b-new-entry b-new-entry_user">\
|
||||
FORM: ['<div id="~!:id~!" class="b-new-entry b-new-entry_user form">\
|
||||
<input type="hidden" name="source" class="source" value=\'~!:source~!\'>\
|
||||
<input type="hidden" name="target" class="target" value=\'\'>\
|
||||
<div class="entry-header">~!:title~!</div>\
|
||||
<div class="form-error">\
|
||||
<div class="form-error hidden">\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">username:</label>\
|
||||
|
@ -320,20 +332,21 @@ App.Templates.html = {
|
|||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">Firstname:</label>\
|
||||
<input type="text" name="FNAME" class="not-styled rule-abc rule-required" value="~!:FNAME~!">\
|
||||
<input type="text" name="FNAME" class="not-styled text-field rule-abc rule-required" value="~!:FNAME~!">\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">Lastname:</label>\
|
||||
<input type="text" name="LNAME" class="not-styled rule-abc rule-required" value="~!:LNAME~!">\
|
||||
<input type="text" name="LNAME" class="not-styled text-field rule-abc rule-required" value="~!:LNAME~!">\
|
||||
</div>\
|
||||
<div class="form-row cc hidden">\
|
||||
<label for="#" class="field-label">ns1:</label>\
|
||||
<input type="text" name="NS" class="text-field" value="~!:NS~!">\
|
||||
<div class="form-row ns-entry cc">\
|
||||
<label for="#" class="field-label">NS #1:</label>\
|
||||
<input type="text" value="~!:NS1~!" name="NS1" class="text-field rule-required rule-ns">\
|
||||
</div>\
|
||||
<!-- div class="form-row cc">\
|
||||
<label for="#" class="field-label">ns2:</label>\
|
||||
<input type="text" value="custom-edge-cdn2.digital-photography-school.com" class="text-field">\
|
||||
</div -->\
|
||||
<div class="form-row ns-entry cc">\
|
||||
<label for="#" class="field-label">NS #2:</label>\
|
||||
<input type="text" value="~!:NS2~!" name="NS2" class="text-field rule-required rule-ns">\
|
||||
</div>\
|
||||
~!:NS~!\
|
||||
<div class="form-row buttons-row cc">\
|
||||
<input type="submit" value="~!:save_button~!" name="save" class="add-entry-btn do_action_save_form">\
|
||||
<span class="cancel-btn do_action_cancel_form">Cancel</span>\
|
||||
|
@ -365,7 +378,7 @@ App.Templates.html = {
|
|||
<div class="username-box">\
|
||||
<span class="user">\
|
||||
<span class="nickname do_action_edit">~!:LOGIN_NAME~!</span>\
|
||||
<span class="role">~!:FNAME~! ~!:LNAME~!</span>\
|
||||
<span class="role"></span>\
|
||||
<span class="role">(~!:ROLE~!)</span>\
|
||||
</span>\
|
||||
<span class="prop-box template-box">\
|
||||
|
@ -472,7 +485,8 @@ App.Templates.html = {
|
|||
</span>\
|
||||
<span class="prop-box prop-box_group-values cc ns-list-box">\
|
||||
<span class="prop-title">ns list:</span>\
|
||||
<span class="group-values group-values__bullet">~!:NS~!</span>\
|
||||
<span class="group-values group-values__bullet">\
|
||||
~!:NS~!</span>\
|
||||
</span>\
|
||||
</div>\
|
||||
</div><!-- // .row-details -->\
|
||||
|
@ -776,48 +790,48 @@ App.Templates.html = {
|
|||
<input type="hidden" name="source" class="source" value=\'~!:source~!\'>\
|
||||
<input type="hidden" name="target" class="target" value=\'\'>\
|
||||
<div class="entry-header">~!:title~!</div>\
|
||||
<div class="form-error">\
|
||||
<div class="form-error hidden">\
|
||||
<div class="error-box">\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="form-row form-row-line run-at-box cc">\
|
||||
<span class="row-header">run at:</span>\
|
||||
<div class="field-box cron-minute-box">\
|
||||
<label for="#" class="field-label">minute:<br>(0—59)</label>\
|
||||
<label for="#" class="field-label ">minute:<br>(0—59)</label>\
|
||||
<div class="field-box-inner cc">\
|
||||
<input type="text" value="~!:MIN~!" name="MIN" class="text-field">\
|
||||
<input type="text" value="~!:MIN~!" name="MIN" class="text-field rule-required rule-minute">\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="field-box cron-hour-box">\
|
||||
<label for="#" class="field-label">hour:<br>(0—23)</label>\
|
||||
<div class="field-box-inner cc">\
|
||||
<input type="text" value="~!:HOUR~!" name="HOUR" class="text-field">\
|
||||
<input type="text" value="~!:HOUR~!" name="HOUR" class="text-field rule-required rule-hour">\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="field-box cron-day-box">\
|
||||
<label for="#" class="field-label">day of Month:<br>(1—31)</label>\
|
||||
<div class="field-box-inner cc">\
|
||||
<input type="text" value="~!:DAY~!" name="DAY" class="text-field">\
|
||||
<input type="text" value="~!:DAY~!" name="DAY" class="text-field rule-required rule-day">\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="field-box cron-month-box">\
|
||||
<label for="#" class="field-label">Month:<br>(1—12)(Jan—Dec)</label>\
|
||||
<div class="field-box-inner cc">\
|
||||
<input type="text" value="~!:MONTH~!" name="MONTH" class="text-field">\
|
||||
<input type="text" value="~!:MONTH~!" name="MONTH" class="text-field rule-required rule-month">\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="field-box cron-week-box">\
|
||||
<label for="#" class="field-label">day of Week:<br>(1—7)(Sun—Sat)</label>\
|
||||
<div class="field-box-inner cc">\
|
||||
<input type="text" value="~!:WDAY~!" name="WDAY" class="text-field">\
|
||||
<input type="text" value="~!:WDAY~!" name="WDAY" class="text-field rule-required rule-wday">\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">command:</label>\
|
||||
<textarea class="textarea" name="CMD">~!:CMD~!</textarea>\
|
||||
<textarea class="textarea rule-required" name="CMD">~!:CMD~!</textarea>\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<div class="form-row cc hidden">\
|
||||
<label for="#" class="field-label">report to: <span class="remark">(devide by comma ",")</span></label>\
|
||||
<textarea class="textarea" name="REPORT_TO"></textarea>\
|
||||
</div>\
|
||||
|
@ -867,7 +881,7 @@ App.Templates.html = {
|
|||
<div class="cron-command-box">\
|
||||
<strong class="cron-command-line do_action_edit">~!:CMD~!</strong>\
|
||||
</div>\
|
||||
<div class="cron-reported-to">\
|
||||
<div class="cron-reported-to hidden">\
|
||||
<span class="prop-box cron-report-box">\
|
||||
<span class="prop-title">reported to:</span>\
|
||||
<span class="prop-value">naumov.socolov@gmail.com,</span>\
|
||||
|
|
|
@ -16,8 +16,12 @@ App.Validate.Is = {
|
|||
App.Validate.getFieldName = function(elm)
|
||||
{
|
||||
fb.log(elm);
|
||||
fb.warn($(elm).prev('label').text());
|
||||
return ['<strong>', $(elm).prev('label').text(), '</strong>'].join('');
|
||||
var txt_label = $(elm).prev('label').text();
|
||||
if (txt_label.trim() == '') {
|
||||
txt_label = $(elm).parents('.field-box').select('label:first').text();
|
||||
}
|
||||
|
||||
return ['<strong>', txt_label, '</strong>'].join('');
|
||||
}
|
||||
|
||||
App.Validate.Rule = {
|
||||
|
@ -27,15 +31,21 @@ App.Validate.Rule = {
|
|||
}
|
||||
return {VALID: true};
|
||||
},
|
||||
'numeric': function(elm) {
|
||||
if ($(elm).val().trim() != '' && isNaN(parseInt($(elm).val(), 10))) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' is incorrect'};
|
||||
}
|
||||
return {VALID: true};
|
||||
},
|
||||
'no-spaces': function(elm) {
|
||||
if ($(elm).val().search(/\s/) != -1) {
|
||||
if ($(elm).val().trim() != '' && $(elm).val().search(/\s/) != -1) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' cannot contain spaces'};
|
||||
}
|
||||
return {VALID: true};
|
||||
},
|
||||
'abc': function(elm) {
|
||||
if ($(elm).val().search(/[^a-zA-Z]+/) != -1) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' must contain only letters'};
|
||||
if ($(elm).val().trim() != '' && $(elm).val().search(/[^a-zA-Z]+/) != -1) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' must contain only letters without spaces or other symbols'};
|
||||
}
|
||||
return {VALID: true};
|
||||
},
|
||||
|
@ -44,6 +54,74 @@ App.Validate.Rule = {
|
|||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' not a valid email'};
|
||||
}
|
||||
return {VALID: true};
|
||||
},
|
||||
'ip': function(elm) {
|
||||
if ($(elm).val().trim() != '' && (/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/).test($(elm).val()) == false) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' not a valid IP value'};
|
||||
}
|
||||
return {VALID: true};
|
||||
},
|
||||
'domain': function(elm) {
|
||||
if ($(elm).val().trim() != '' && (/^([a-z0-9\.])*[a-z0-9][a-z0-9\-]+[a-z0-9](\.[a-z]{2,4})+$/).test($(elm).val()) == false) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' not a valid domain name'};
|
||||
}
|
||||
return {VALID: true};
|
||||
},
|
||||
'ns': function(elm) {
|
||||
if ($(elm).val().trim() != '' && (/^([a-z0-9\.])*[a-z0-9][a-z0-9\-]+[a-z0-9](\.[a-z]{2,4})+$/).test($(elm).val()) == false) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' not a valid NS name'};
|
||||
}
|
||||
return {VALID: true};
|
||||
},
|
||||
'minute': function(elm) {
|
||||
if ($(elm).val() == '*') {
|
||||
return {VALID: true};
|
||||
}
|
||||
var minute = parseInt($(elm).val(), 10);
|
||||
if (minute > 60 || minute < 0) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' wrong minute value'};
|
||||
}
|
||||
return {VALID: true};
|
||||
},
|
||||
'hour': function(elm) {
|
||||
if ($(elm).val() == '*') {
|
||||
return {VALID: true};
|
||||
}
|
||||
var hour = parseInt($(elm).val(), 10);
|
||||
if (hour > 60 || hour < 0) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' wrong hour value'};
|
||||
}
|
||||
return {VALID: true};
|
||||
},
|
||||
'wday': function(elm) {
|
||||
if ($(elm).val() == '*') {
|
||||
return {VALID: true};
|
||||
}
|
||||
var wday = parseInt($(elm).val(), 10);
|
||||
if (wday > 7 || wday < 1) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' wrong week day value'};
|
||||
}
|
||||
return {VALID: true};
|
||||
},
|
||||
'month': function(elm) {
|
||||
if ($(elm).val() == '*') {
|
||||
return {VALID: true};
|
||||
}
|
||||
var month = parseInt($(elm).val(), 10);
|
||||
if (month > 1 || month < 12) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' wrong month value'};
|
||||
}
|
||||
return {VALID: true};
|
||||
},
|
||||
'day': function(elm) {
|
||||
if ($(elm).val() == '*') {
|
||||
return {VALID: true};
|
||||
}
|
||||
var day = parseInt($(elm).val(), 10);
|
||||
if (day > 31 || day < 1) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' wrong day value'};
|
||||
}
|
||||
return {VALID: true};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,7 +131,12 @@ App.Validate.form = function(world, elm)
|
|||
var form_valid = true;
|
||||
App.Env.FormError = [];
|
||||
$(elm).find('select, input, textarea').each(function(i, field)
|
||||
{
|
||||
{
|
||||
if ($(field).attr('type') == 'checkbox') {
|
||||
var value = $(field).attr('checked') ? 'on' : 'off';
|
||||
$(field).val(value);
|
||||
}
|
||||
|
||||
if ($.inArray($(field).attr('name'), ['target', 'source', 'save']) != -1) {
|
||||
//return; // pass
|
||||
}
|
||||
|
@ -61,7 +144,7 @@ App.Validate.form = function(world, elm)
|
|||
var rules = App.Validate.getRules(field);
|
||||
$(rules).each(function(i, rule)
|
||||
{
|
||||
fb.log('Validate with %o %o', rule, field);
|
||||
fb.log('Validate with %o %o', rule, field);
|
||||
if (App.Validate.Rule[rule]) {
|
||||
var result = App.Validate.Rule[rule](field);
|
||||
fb.log(result);
|
||||
|
@ -96,18 +179,24 @@ App.Validate.displayFormErrors = function(world, elm)
|
|||
|
||||
App.Validate.getRules = function(elm)
|
||||
{
|
||||
var rules_string = $(elm).attr('class');
|
||||
var rules = [];
|
||||
$(rules_string.split(/\s/)).each(function(i, str)
|
||||
{
|
||||
var rule = str.split('rule-');
|
||||
if (rule.length > 1) {
|
||||
rules[rules.length++] = rule[1];
|
||||
}
|
||||
});
|
||||
|
||||
return rules;
|
||||
try {
|
||||
var rules_string = $(elm).attr('class');
|
||||
var rules = [];
|
||||
$(rules_string.split(/\s/)).each(function(i, str)
|
||||
{
|
||||
var rule = str.split('rule-');
|
||||
if (rule.length > 1) {
|
||||
rules[rules.length++] = rule[1];
|
||||
}
|
||||
});
|
||||
|
||||
return rules;
|
||||
}
|
||||
catch(e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue