diff --git a/web/js/__init__.js b/web/js/__init__.js index 4c859fa96..e4c133cba 100644 --- a/web/js/__init__.js +++ b/web/js/__init__.js @@ -1,16 +1,16 @@ $(document).ready(function(){ try{ - App.Utils.detectBrowser(); - - App.Env.world = 'DNS'; - App.Pages.init(); - - App.Ref.init(); + App.Utils.detectBrowser(); - //App.View.start(); - App.Core.listen(); - App.Core.initMenu(); - App.Helpers.liveValidate(); + App.Env.world = 'USER'; + App.Pages.init(); + + App.Ref.init(); + + //App.View.start(); + App.Core.listen(); + App.Core.initMenu(); + App.Helpers.liveValidate(); }catch(e){ fb.error(e); diff --git a/web/js/_settings.js b/web/js/_settings.js index d84fb1f46..2f14e0333 100644 --- a/web/js/_settings.js +++ b/web/js/_settings.js @@ -10,8 +10,9 @@ App.i18n.getMessage = function(key) // Constants -App.Constants.IP_FORM_ID = 'ip-form'; -App.Constants.DNS_FORM_ID = 'dns-form'; +App.Constants.IP_FORM_ID = 'ip-form'; +App.Constants.DNS_FORM_ID = 'dns-form'; +App.Constants.USER_FORM_ID = 'user-form'; App.Settings.ajax_url = 1; App.Settings.uri = location.href.replace('index.html', ''); @@ -59,4 +60,4 @@ App.Settings.getMethodName = function(action) } return type + '.' + method; -} \ No newline at end of file +} diff --git a/web/js/actions.js b/web/js/actions.js index 37de9f000..314d8dbc7 100644 --- a/web/js/actions.js +++ b/web/js/actions.js @@ -1,6 +1,13 @@ -/*App.Actions.cancel_ip_form = function(){ - alert(1); -}*/ +App.Actions.delete_entry = function(evt) +{ + var confirmed = confirm(App.i18n.getMessage('confirm')); + if (!confirmed) { + return; + } + var elm = $(evt.target); + var elm = elm.hasClass('row') ? elm : elm.parents('.row'); + App.Model.remove(App.Env.world, elm); +} App.Actions.show_subform = function(evt) { @@ -81,32 +88,47 @@ App.Actions.save_form = function(evt) { var elm_id = App.Env.world + '_FORM_ID'; var build_method = App.Env.getWorldName() + '_entry'; + if (!App.Validate.form(App.Env.world, elm)) { + return App.Validate.displayFormErrors(App.Env.world, elm); + } + if (elm.attr('id') == App.Constants[elm_id]) { // NEW ITEM var values = App.Helpers.getFormValues(elm); if(App.Validate.form(values, $('#'+elm_id))) { App.Model.add(values, source); - var tpl = App.HTML.Build[build_method](values, 'new'); - $('#' + App.Constants[elm_id]).replaceWith(tpl); + var form_id = App.Constants[App.Env.world + '_FORM_ID']; + $('#'+form_id).remove(); } } 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.update(values, source); - var tpl = App.HTML.Build[build_method](values); - elm.replaceWith(tpl); + App.Model.add(values, source); + //var form_id = App.Constants[App.Env.world + '_FORM_ID']; + //$('#'+form_id).remove(); + App.Model.update(values, source, elm); } - } - App.Helpers.updateScreen(); + /*if(App.Validate.form(values, $('#'+elm_id))) { + App.Model.update(values, source); + }*/ + } } // do_action_edit App.Actions.edit = function(evt) { var elm = $(evt.target); elm = elm.hasClass('row') ? elm : elm.parents('.row'); - App.Pages[App.Env.world].edit(elm); - App.Helpers.updateScreen(); + + var options = elm.find('.source').val(); + fb.warn(elm); + fb.warn(options); + var build_method = App.Env.getWorldName() + '_form'; + var tpl = App.HTML.Build[build_method](options); + elm.replaceWith(tpl); + + //App.Pages[App.Env.world].edit(elm); + //App.Helpers.updateScreen(); } // do_cancel_form @@ -160,4 +182,9 @@ App.Actions.save_dns_subrecords = function(evt) }); fb.warn($.toJSON(records)); -} \ No newline at end of file +} + +App.Actions.generate_pass = function() +{ + $('.password').val(App.Helpers.generatePassword()); +} diff --git a/web/js/app.js b/web/js/app.js index cd7b7e68a..8d741dfb3 100644 --- a/web/js/app.js +++ b/web/js/app.js @@ -1,5 +1,10 @@ var _DEBUG = true; +window.jsonParse=function(){var r="(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)",k='(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))';k='(?:"'+k+'*")';var s=new RegExp("(?:false|true|null|[\\{\\}\\[\\]]|"+r+"|"+k+")","g"),t=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),u={'"':'"',"/":"/","\\":"\\",b:"\u0008",f:"\u000c",n:"\n",r:"\r",t:"\t"};function v(h,j,e){return j?u[j]:String.fromCharCode(parseInt(e,16))}var w=new String(""),x=Object.hasOwnProperty;return function(h, +j){h=h.match(s);var e,c=h[0],l=false;if("{"===c)e={};else if("["===c)e=[];else{e=[];l=true}for(var b,d=[e],m=1-l,y=h.length;m=0;)delete f[i[g]]}return j.call(n, +o,f)};e=p({"":e},"")}return e}}(); + (function($){$.toJSON=function(o) {if(typeof(JSON)=='object'&&JSON.stringify) @@ -86,7 +91,7 @@ var App = { // pages related views Pages: { USER: {}, - WEBDOMAIN: {}, + WEB_DOMAIN: {}, MAIL: {}, DB: {}, DNS: {}, @@ -97,7 +102,7 @@ var App = { Messages: {}, Model: { USER: {}, - WEBDOMAIN: {}, + WEB_DOMAIN: {}, MAIL: {}, DB: {}, DNS: {}, @@ -109,7 +114,7 @@ var App = { }, Pages: { USER: {}, - WEBDOMAIN: {}, + WEB_DOMAIN: {}, MAIL: {}, DB: {}, DNS: {}, @@ -119,8 +124,10 @@ var App = { Ref: {}, Tmp: {}, Thread: { - run: function(delay, ref){ - setTimeout(function(){ + run: function(delay, ref) + { + setTimeout(function() + { ref(); }, delay*10); } @@ -136,7 +143,8 @@ var App = { }; // Internals -Array.prototype.set = function(key, value){ +Array.prototype.set = function(key, value) +{ var index = this[0][key]; this[1][index] = value; } @@ -144,23 +152,27 @@ Array.prototype.get = function(key){ var index = this[0][key]; return this[1][index]; } -Array.prototype.finalize = function(){ +Array.prototype.finalize = function() +{ this.shift(); this[0] = this[0].join(''); return this[0]; } -Array.prototype.done = function(){ +Array.prototype.done = function() +{ return this.join(''); } -String.prototype.wrapperize = function(key, ns){ +String.prototype.wrapperize = function(key, ns) +{ var tpl = App.Templates.get(key, ns); tpl.set(':content', this); return tpl.finalize(); } -App.Ajax.request = function(jedi_method, data, callback){ +App.Ajax.request = function(jedi_method, data, callback) +{ App.Helpers.beforeAjax(jedi_method); $.ajax({ url: function() { @@ -176,13 +188,17 @@ App.Ajax.request = function(jedi_method, data, callback){ global: false, type: data.request_method || "POST", data: $.extend(data, {'jedi_method': jedi_method}), - dataType: "json", + dataType: "text", async:true, - success: function(reply){ + success: function(reply) + { + timer.start(); + callback && callback(jsonParse(reply)); App.Helpers.afterAjax(); - callback && callback(reply); + timer.stop(jedi_method); }, - error: function() { + error: function() + { App.View.popup('error'); } }); @@ -207,7 +223,7 @@ timer.stop = function( msg ) timer.print = function( msg ) { var passed = timer.stop_time - timer.start_time; - fb.info( msg || '' + passed / 1000 ); + fb.info( (msg || '') + ': ' + passed / 1000 ); } diff --git a/web/js/helpers.js b/web/js/helpers.js index 489e1c4c0..529cb27c2 100644 --- a/web/js/helpers.js +++ b/web/js/helpers.js @@ -46,6 +46,7 @@ App.Helpers.beforeAjax = function(jedi_method) App.Helpers.showLoading(); break; default: + App.Helpers.showLoading(); break; } } @@ -189,4 +190,23 @@ App.Helpers.liveValidate = function() var elm = $(evt.target); fb.log(elm.attr('TAGNAME')); }); -} \ No newline at end of file +} + +App.Helpers.generatePassword = function() +{ + var length = 12; + var chars = "abcdefghijklmn.-%$#&-opqrstuvwxyz.-%$#&-ABCDEFGHIJKLMNOPQRSTUV.-%$#&-WXYZ1234567890.-%$#&-"; + var pass = ""; + + for (x=0;x.')); - tpl.set(':TTL', o.TTL); - tpl.set(':TPL', o.TPL); - tpl.set(':SOA', o.SOA); - tpl.set(':TTL', o.TTL); - tpl.set(':DATE', o.DATE); + tpl.set(':IP', ip.join('.')); tpl.set(':CHECKED', ''); if (is_new) { var now = new Date(); tpl.set(':DATE', now.format("d.mm.yyyy")); } - /*tpl.set(':NETMASK', o.NETMASK); - tpl.set(':IP_ADDRESS', o.IP_ADDRESS); - tpl.set(':SYS_USERS', o.U_SYS_USERS); - tpl.set(':WEB_DOMAINS', o.U_WEB_DOMAINS); - tpl.set(':DATE', o.DATE); - tpl.set(':INTERFACE', o.INTERFACE); - tpl.set(':NAME', o.NAME); - tpl.set(':OWNER', o.OWNER); - tpl.set(':STATUS', o.STATUS); - tpl.set(':U_SYS_USERS', o.U_SYS_USERS); - tpl.set(':U_WEB_DOMAINS', o.U_WEB_DOMAINS); - */ + if (App.Constants.SUSPENDED_YES == o.SUSPEND) { var sub_tpl = App.Templates.get('SUSPENDED_TPL_ENABLED', 'dns'); } @@ -199,6 +207,118 @@ App.HTML.Build.dns_entry = function(o, is_new){ return tpl.finalize(); } +App.HTML.Build.user_entry = function(o, key) +{ + var processed_data = { + 'NICKNAME': key, + 'BANDWIDTH_PERCENTS': 90, + 'U_DISK_PERCENTS': 80 + }; + var o = $.extend(o, processed_data); + var tpl = App.Templates.get('ENTRY', 'user'); + tpl = App.HTML.setTplKeys(tpl, o); + + 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()); + + return tpl.finalize(); +} + + +App.HTML.Build.user_form = function(options, id) +{ + if('undefined' == typeof App.Env.initialParams) { + return alert('PLease wait a bit. Some background processes are not yet executed. Thank you for patience.'); + } + var tpl = App.Templates.get('FORM', 'user'); + tpl.set(':source', options); + tpl.set(':id', id || ''); + options = App.Helpers.evalJSON(options) || {}; + if (App.Helpers.isEmpty(options)) { + tpl.set(':title', 'New user'); + tpl.set(':save_button', 'ADD'); + } + else { + tpl.set(':title', 'Edit user'); + tpl.set(':save_button', 'SAVE'); + } + + options = !App.Helpers.isEmpty(options) ? options : {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','NS':''}; + + tpl = App.HTML.setTplKeys(tpl, options, true); + tpl = App.HTML.Build.user_selects(tpl, options); + + return tpl.finalize(); +} + +App.HTML.Build.web_domain_entry = function(o, key) +{ + // TODO: + /*~!:ALIAS~!,\ + naumov-socolov.org.md,\ + naumov-socolov.to\*/ + var processed_data = { + DOMAIN: key + }; + var o = $.extend(o, processed_data); + //fb.info(o); + var tpl = App.Templates.get('ENTRY', 'web_domain'); + tpl = App.HTML.setTplKeys(tpl, o); + + /*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()); + */ + return tpl.finalize(); +} + +App.HTML.Build.mail_entry = function(o, key) +{ + var processed_data = { + DOMAIN: key + }; + var o = $.extend(o, processed_data); + var tpl = App.Templates.get('ENTRY', 'mail'); + tpl = App.HTML.setTplKeys(tpl, o); + + return tpl.finalize(); +} + +App.HTML.Build.db_entry = function(o, key) +{ + var processed_data = { + DOMAIN: key + }; + var o = $.extend(o, processed_data); + var tpl = App.Templates.get('ENTRY', 'db'); + tpl = App.HTML.setTplKeys(tpl, o); + + return tpl.finalize(); +} + +App.HTML.Build.cron_entry = function(o, key) +{ + var processed_data = { + DOMAIN: key + }; + var o = $.extend(o, processed_data); + var tpl = App.Templates.get('ENTRY', 'cron'); + tpl = App.HTML.setTplKeys(tpl, o); + + return tpl.finalize(); +} + + App.HTML.Build.dns_records = function(records) { var acc = []; @@ -206,7 +326,7 @@ App.HTML.Build.dns_records = function(records) { var record = records[i]; var tpl = App.HTML.Build.dns_subrecord(record); - acc[acc.length] = tpl.finalize(); + acc[acc.length++] = tpl.finalize(); }); return acc.done(); @@ -224,3 +344,42 @@ App.HTML.Build.dns_subrecord = function(record) return tpl; } +App.HTML.Build.user_selects = function(tpl, options) +{ + var acc = []; + // PACKAGE + var pkg = App.Env.initialParams.USERS.PACKAGE; + $.each(pkg, function(val) + { + var tpl = App.Templates.get('select_option', 'general'); + tpl.set(':VALUE', val); + tpl.set(':TEXT', pkg[val]); + acc[acc.length++] = tpl.finalize(); + }); + tpl.set(':PACKAGE_OPTIONS', acc.done()); + // ROLE + acc = []; + var roles = App.Env.initialParams.USERS.ROLE; + $.each(roles, function(val) + { + var tpl = App.Templates.get('select_option', 'general'); + tpl.set(':VALUE', val); + tpl.set(':TEXT', roles[val]); + acc[acc.length++] = tpl.finalize(); + }); + tpl.set(':ROLE_OPTIONS', acc.done()); + // SHELL + acc = []; + var shell = App.Env.initialParams.USERS.SHELL; + $.each(shell, function(val) + { + var tpl = App.Templates.get('select_option', 'general'); + tpl.set(':VALUE', val); + tpl.set(':TEXT', shell[val]); + acc[acc.length++] = tpl.finalize(); + }); + tpl.set(':SHELL_OPTIONS', acc.done()); + + return tpl; +} + diff --git a/web/js/model.js b/web/js/model.js index 312129a4e..b68caed49 100644 --- a/web/js/model.js +++ b/web/js/model.js @@ -1,31 +1,95 @@ -App.Model.DNS.loadList = function(){ +App.Model.DNS.loadList = function() +{ App.Ajax.request('DNS.getList', {}, App.View.listItems); } -App.Model.IP.loadList = function(){ +App.Model.IP.loadList = function() +{ App.Ajax.request('IP.getList', {}, App.View.listItems); } -App.Model.add = function(values, source_json) { +App.Model.USER.loadList = function() +{ + App.Ajax.request('USER.getList', {}, App.View.listItems); +} + +App.Model.WEB_DOMAIN.loadList = function() +{ + App.Ajax.request('WEB_DOMAIN.getList', {}, App.View.listItems); +} + +App.Model.MAIL.loadList = function() +{ + App.Ajax.request('MAIL.getList', {}, App.View.listItems); +} + +App.Model.DB.loadList = function() +{ + App.Ajax.request('DB.getList', {}, App.View.listItems); +} + +App.Model.CRON.loadList = function() +{ + App.Ajax.request('CRON.getList', {}, App.View.listItems); +} + + +App.Model.add = function(values, source_json) +{ var method = App.Settings.getMethodName('add'); App.Ajax.request(method, { spell: $.toJSON(values) }, function(reply){ if(!reply.result) { - alert('FALSE'); + App.Helpers.Warn('Changes were not applied'); + } + else { + var build_method = App.Env.getWorldName() + '_entry'; + var tpl = App.HTML.Build[build_method](values, 'new'); + App.Ref.CONTENT..replaceWith(tpl); + // todo: reply.data; } }); } -App.Model.update = function(values, source_json) { +App.Model.remove = function(world, elm) +{ + var method = App.Settings.getMethodName('delete'); + App.Ajax.request(method, + { + spell: $('.source', elm).val() + }, + function(reply) + { + if (!reply.result) { + App.Helpers.Warn('Changes were not applied'); + } + else { + $(elm).remove(); + } + }); +} + +App.Model.update = function(values, source_json, elm) +{ alert(source_json); var method = App.Settings.getMethodName('update'); + var build_method = App.Env.getWorldName() + '_entry'; App.Ajax.request(method, { 'old': source_json, 'new': App.Helpers.toJSON(values) }, function(reply){ if(!reply.result) { - alert('FALSE'); + var tpl = App.HTML.Build[build_method](App.Helpers.evalJSON(source_json)); + $(elm).replaceWith(tpl); + App.Helpers.updateScreen(); + App.Helpers.Warn('Changes were not applied'); } + else { + var tpl = App.HTML.Build[build_method](reply.data); + $(elm).replaceWith(tpl); + App.Helpers.updateScreen(); + } + // TODO: ! }); } diff --git a/web/js/pages.js b/web/js/pages.js index d2afebee4..26aff0889 100644 --- a/web/js/pages.js +++ b/web/js/pages.js @@ -44,91 +44,3 @@ App.Pages.DNS.edit = function(elm) { var tpl = App.HTML.Build.dns_form(options); elm.replaceWith(tpl); } - -/* - - - -// -// DNS - - -App.Pages.DNS.saveForm = function(evt, params){ - var elm = $(evt.target); - elm = elm.parents('.b-new-entry'); - - if (elm.attr('id') == App.Constants.DNS_FORM_ID) { - var values = App.Helpers.getFormValues(elm); - if(App.Validate.dnsForm(values)) { - App.Model.DNS.update(values, source); - var tpl = App.HTML.Build.dns_entry(values); - $('#' + App.Constants.DNS_FORM_ID).replaceWith(tpl); - } - } - else { - var source = $(elm).find('.source').val(); - var values = App.Helpers.getFormValues(elm); - if(App.Validate.dnsForm(values)) { - App.Model.DNS.update(values, source); - var tpl = App.HTML.Build.dns_entry(values); - elm.replaceWith(tpl); - } - } - App.Helpers.updateScreen(); -} - -// -// IP -App.Pages.IP.prepareHTML = function(){ - App.Model.IP.loadList(); -} - -App.Pages.IP.saveForm = function(evt, params){ - var elm = $(evt.target); - elm = elm.parents('.b-new-entry'); - - if (elm.attr('id') == App.Constants.IP_FORM_ID) { - var values = App.Helpers.getFormValues(elm); - if(App.Validate.ipForm(values)) { - App.Model.IP.update(values, source); - var tpl = App.HTML.Build.ip_entry(values); - $('#' + App.Constants.IP_FORM_ID).replaceWith(tpl); - } - } - else { - var source = $(elm).find('.source').val(); - var values = App.Helpers.getFormValues(elm); - if(App.Validate.ipForm(values)) { - App.Model.IP.update(values, source); - var tpl = App.HTML.Build.ip_entry(values); - elm.replaceWith(tpl); - } - } - App.Helpers.updateScreen(); -} -*/ - -/* -App.Pages.IP.edit = function(elm) { - var options = elm.find('.source').val(); - fb.warn(elm); - fb.warn(options); - var tpl = App.HTML.Build.ip_form(options); - elm.replaceWith(tpl); -} - -App.Pages.IP.ipNotSaved = function(reply) { - return App.Helpers.alert(reply.message); -} - -App.Pages.IP.remove = function(evt) { - var confirmed = confirm('Are you sure?'); - if (!confirmed) { - return; - } - var elm = $(evt.target); - elm.parents('.ip-details-row'); - var values = elm.find('.source').val(); - App.Model.IP.remove(values, elm); -} -*/ diff --git a/web/js/templates.js b/web/js/templates.js index 2937c81da..4f36cf634 100644 --- a/web/js/templates.js +++ b/web/js/templates.js @@ -21,6 +21,8 @@ App.Templates.html = { '], popup: ['\ '], + select_option: [''], + error_elm: ['
~!:ERROR~!
'] }, popup: { error: ['

Important: An Error Has Occured.


    Something went wrong and some of your actions can be not saved in system. Mostly, it happens when you have network connection errors.
,    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 this email: BLABLA,

Sorry for inconvinience. (We recommend you to reload the page)
'] @@ -38,7 +40,7 @@ App.Templates.html = {
\
\
\ - \ + \ \ \
\ @@ -75,7 +77,7 @@ App.Templates.html = { SUSPENDED_TPL_ENABLED : ['enabled\ delete'], SUSPENDED_TPL_DISABLED : ['suspended'], - ENTRIES_WRAPPER: ['
~!:content~!
'], + ENTRIES_WRAPPER: ['
~!:content~!
'], ENTRY: ['
\ \ \ @@ -83,7 +85,7 @@ App.Templates.html = {
\
\ ~!:SUSPENDED_TPL~!\ - delete\ + delete\
\
\
\ @@ -260,10 +262,400 @@ App.Templates.html = {
\ \ '], - ENTRIES_WRAPPER: ['
~!:content~!
'], + ENTRIES_WRAPPER: ['
~!:content~!
'], SUSPENDED_TPL_ENABLED : ['enabled\ delete'], SUSPENDED_TPL_DISABLED : ['suspended'] + }, + user: { + ENTRIES_WRAPPER: ['
~!:content~!
'], + FORM: ['
\ + \ + \ +
~!:title~!
\ + \ +
\ + \ + \ +
\ +
\ + \ + \ + Generate\ +
\ +
\ + \ + \ +
\ +
\ + \ + \ +
\ +
\ + \ + \ +
\ +
\ + \ + \ +
\ +
\ + \ + \ +
\ +
\ + \ + \ +
\ + \ +
\ + \ + Cancel\ + Help\ +
\ +
'], + ENTRY: ['
\ + \ + \ +
\ +
\ +
\ + ~!:SUSPENDED_TPL~!\ + delete\ +
\ +
\ +
\ +
~!:DATE~!
\ +
\ + \ + owner:\ + ~!:OWNER~!\ + \ +
\ +
\ +
\ +
\ +
\ +
\ + \ + ~!:LOGIN_NAME~!\ + (~!:ROLE~!)\ + \ + \ + package:\ + ~!:PACKAGE~!\ + \ +
\ +
\ + \ + name:\ + ~!:FULLNAME~!\ + \ + \ + email:\ + \ + ~!:CONTACT~!\ + (reports ~!:REPORTS_ENABLED~!)\ + \ + \ + \ + childs:\ + ~!:U_CHILDS~! (~!:MAX_CHILDS~!)\ \ +
\ +
\ + \ +
\ + disk usage:\ +
\ +
\ + ~!:U_DISK~!\ +
\ + \ +
\ +
\ +
~!:DISK_QUOTA~!~!:DISK_QUOTA_MEASURE~!
\ +
\ +
\ + \ +
\ + bandwidth:\ +
\ +
\ + ~!:U_BANDWIDTH~!\ +
\ + \ +
\ +
\ +
~!:BANDWIDTH~!~!:BANDWIDTH_MEASURE~!
\ +
\ +
\ + \ + \ + \ + \ +
\ +
\ + \ + web domains:\ + ~!:U_DNS_DOMAINS~! (~!:WEB_DOMAINS~!)\ + \ + \ + web ssl:\ + ~!:U_WEB_SSL~! (~!:WEB_SSL~!)\ + \ + \ + web alias:\ + (~!:WEB_ALIASES~!) per domain\ + \ + \ + web templates:\ + \ + ~!:WEB_TPL~!\ + \ + \ + \ + databases:\ + ~!:U_DATABASES~! (~!:DATABASES~!)\ + \ + \ + shell:\ + ~!:SHELL~!\ + \ + \ + backups:\ + retention ~!:BACKUPS~!\ + \ +
\ +
\ + \ + mailboxes:\ + ~!:U_MAIL_BOXES~! (~!:MAIL_BOXES~!)\ + \ + \ + mail forwarders:\ + ~!:U_MAIL_FORWARDERS~! (~!:MAIL_FORWARDERS~!)\ + \ + \ + mail domains:\ + ~!:U_MAIL_DOMAINS~! (~!:MAIL_DOMAINS~!)\ + \ + \ + dns domains:\ + ~!:U_DNS_DOMAINS~! (~!:DNS_DOMAINS~!)\ + \ + \ + ns list:\ + ~!:NS~!\ + \ +
\ +
\ +
'] + }, + web_domain: { + ENTRIES_WRAPPER: ['
~!:content~!
'], + ENTRY: ['
\ +
\ +
\ +
\ + enabled\ + delete\ +
\ +
\ +
\ +
~!:DATE~!
\ +
\ +
\ +
\ + ~!:DOMAIN~!\ + Alias:\ + ~!:ALIAS~!\ +
\ +
\ +
\ + ~!:IP~!\ + \ + template:\ + ~!:TPL~!\ + \ +
\ + \ +
\ + disk usage:\ +
\ +
\ + ~!:U_DISK~!\ +
\ + \ +
\ +
\ +
~!:DISK~!Mb
\ +
\ +
\ + \ +
\ + bandwidth:\ +
\ +
\ + ~!:U_BANDWIDTH~!\ +
\ + \ +
\ +
\ +
~!:BANDWIDTH~! Mb
\ +
\ +
\ +
\ +
\ + \ + php:\ + ~!:PHP~!\ + \ + \ + cgi:\ + ~!:CGI~!\ + \ + \ + elog:\ + ~!:ELOG~!\ + \ + \ + stats:\ + ~!:STATS~!\ + \ + ~!:STATS_AUTH~!\ + \ + \ +
\ +
\ + \ + ssl:\ + ~!:SSL~!\ + \ + \ + nginx:\ + ~!:NGINX~!\ + extension list\ + \ +
\ +
\ +
'] + }, + db: { + ENTRIES_WRAPPER: ['
~!:content~!
'], + ENTRY: ['
\ +
\ +
\ +
\ + delete\ +
\ +
\ +
\ +
\ + \ + Javier Henneman\ + \ +
\ +
~!:DATE~!
\ +
\ +
\ +
\ +
\ + ~!:DB_NAME~!\ +
\ +
\ +
\ +
\ + \ + ~!:USER~!\ + \ + change password \ +
\ +
\ + \ + socialmediaexaminer (read only)\ + \ + change password \ +
\ + Add user\ +
\ +
\ + backup\ + \ +
\ +
\ +
\ + ~!:U_DISK~!\ +
\ + \ +
\ +
\ +
~!:DISK~! Mb
\ +
\ +
\ +
\ +
\ +
'] + }, + cron: { + ENTRIES_WRAPPER: ['
~!:content~!
'], + ENTRY: ['
\ +
\ +
\ +
\ + enabled\ + delete\ +
\ +
\ +
\ +
~!:DATE~!
\ +
\ +
\ +
\ + \ + min\ + ~!:MIN~!\ + \ + \ + hour\ + ~!:HOUR~!\ + \ + \ + day of Month\ + ~!:DAY~!\ + \ + \ + Month\ + ~!:MONTH~!\ + \ + \ + day of Week\ + ~!:WDAY~!\ + \ +
\ +
\ + ~!:CMD~!\ +
\ +
\ + \ + reported to:\ + naumov.socolov@gmail.com,\ + vasysualiy.pupkin@gmail.com,\ + na-derevniu-dedushke@dachniy-poselok-za-mkadom.com,\ + vasysualiy.pupkin@gmail.com\ + \ +
\ +
\ +
'] } } @@ -344,4 +736,4 @@ Tpl.Templator = Templator(); Tpl.get = function(key, group){ return Tpl.Templator.getTemplate(group, key); -} \ No newline at end of file +} diff --git a/web/js/validators.js b/web/js/validators.js index 256644f9d..53ad7389a 100644 --- a/web/js/validators.js +++ b/web/js/validators.js @@ -15,18 +15,38 @@ App.Validate.Is = { -App.Validate.form = function(values, form_ref){ - // TODO: validate it! - return true; - var errors = []; - $.each(values, function(key) { - var value = values[key]; - /*if ('undefined' != typeof App.Validate.Is[key] ) { - if(var error = App.Validate.Is[key](value)) { - errors[erros.length++] = error; +App.Validate.form = function(world, elm) +{ + var form_valid = true; + App.Env.FormError = []; + $(elm).find('select, input, textarea').each(function(i, field) + { + if ($.inArray($(field).attr('name'), ['target', 'source', 'save']) != -1) { + //return; // pass + } + else { + + if ($(field).val().trim() == '') { + App.Env.FormError.push($(field).attr('name') + ' is required'); + form_valid = false; } - }*/ - }); + } + }); + return form_valid; +} + +App.Validate.displayFormErrors = function(world, elm) +{ + var errors_tpl = ''; + $(App.Env.FormError).each(function(i, error) + { + var tpl = App.Templates.get('error_elm', 'general'); + tpl.set(':ERROR', error); + errors_tpl += tpl.finalize(); + }); + var ref = $('.form-error', elm); + ref.removeClass('hidden'); + ref.html(errors_tpl); } diff --git a/web/js/view.js b/web/js/view.js index 34f49be27..dfe365b12 100644 --- a/web/js/view.js +++ b/web/js/view.js @@ -1,5 +1,5 @@ - -App.View.popup = function(content) { +App.View.popup = function(content) +{ var tpl = App.Templates.get('popup', 'general'); if ('undefined' != typeof App.Templates.html.popup[content]) { var content = App.Templates.get(content, 'popup').finalize(); @@ -10,26 +10,33 @@ App.View.popup = function(content) { $(document.body).append(tpl.finalize()); } -App.View.closePopup = function(){ +App.View.closePopup = function() +{ $('.black_overlay').remove(); $('.popup_content').remove(); } -App.View.updateInitialInfo = function(key, object) { +App.View.updateInitialInfo = function(key, object) +{ var expr = '.'+key; var object = parseInt(object, 10); var html = object + ' ' + App.Messages.get(key, (object > 1)); $(expr).html(html); } -App.View.listItems = function(reply){ +App.View.listItems = function(reply){ var acc = []; var build_method = App.Env.getWorldName() + '_entry'; - $(reply.data).each(function(i, o){ - acc[acc.length++] = App.HTML.Build[build_method](o); + var data = reply.data; + // TODO: fix it data.data + $.each(data, function(key) + { + var o = data[key]; + fb.warn(key); + acc[acc.length++] = App.HTML.Build[build_method](o, key); }); - var html = acc.done().wrapperize('ENTRIES_WRAPPER', 'ip'); + var html = acc.done().wrapperize('ENTRIES_WRAPPER', App.Env.getWorldName()); App.Ref.CONTENT.html(html); App.Helpers.updateScreen(); }