Skip to content

Commit 2265083

Browse files
committed
Merge branch 'master' of github.com:serghey-rodin/vesta
2 parents bb37747 + 2574231 commit 2265083

19 files changed

+9711
-1025
lines changed

web/index.html

Lines changed: 4 additions & 4 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,10 +202,10 @@ <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>
208-
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.1.js"></script>
207+
<script type="text/javascript" src="js/lib/jquery-1.6.1.js"></script>
208+
<script type="text/javascript" src="js/lib/jquery-ui-1.8.13.custom.min.js"></script>
209209
<script type="text/javascript" src="js/date_format.js"></script>
210210
<script type="text/javascript" src="js/lib/custom-form-elements.js"></script>
211211
<script type="text/javascript" src="js/lib/browser.js"></script>

web/js/_settings.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,17 @@ 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':''};
50+
App.Empty.WEB_DOMAIN = {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','NS':'', 'DOMAIN':'','SSL_CERT':'','SSL_HOME':'','STATS_PASSWORD':'','STATS_LOGIN':'','ALIAS':''};
4351

4452
App.Settings.getMethodName = function(action)
4553
{

web/js/actions.js

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,6 @@ App.Actions.show_subform = function(evt)
2424
// TODO: probably general way to embed subforms
2525
}
2626

27-
App.Actions.close_subform = function(evt)
28-
{
29-
var elm = $(evt.target);
30-
var ref = elm.hasClass('subform') ? elm : elm.parents('.subform');
31-
var parent_ref = ref.prev('.row');
32-
if (parent_ref.length > 0) {
33-
parent_ref.find('.show-records').removeClass('hidden');
34-
}
35-
ref.remove();
36-
}
37-
3827
App.Actions.view_template_settings = function(evt)
3928
{
4029
alert('TODO');
@@ -51,17 +40,6 @@ App.Actions.add_subrecord_dns = function(evt)
5140
}
5241
}
5342

54-
App.Actions.delete_subentry = function(evt)
55-
{
56-
var sure = confirm(App.i18n.getMessage('confirm'));
57-
if (!sure) {
58-
return;
59-
}
60-
var elm = $(evt.target);
61-
var ref = elm.hasClass('subrow') ? elm : elm.parents('.subrow');
62-
ref.effect('puff', {}, 300, function(){ref.remove();})
63-
}
64-
6543
/**
6644
* Embeds new item form
6745
* if exits custom method (App.Pages[ENVIRONMENT_NAME].newForm)
@@ -106,22 +84,20 @@ App.Actions.save_form = function(evt) {
10684
if(App.Validate.form(values, $('#'+elm_id))) {
10785
App.Model.update(values, source, elm);
10886
}
109-
}
87+
}
11088
}
11189

11290
// do_action_edit
11391
App.Actions.edit = function(evt) {
11492
var elm = $(evt.target);
11593
elm = elm.hasClass('row') ? elm : elm.parents('.row');
11694

117-
var options = elm.find('.source').val();
118-
fb.warn(elm);
119-
fb.warn(options);
95+
var options = elm.find('.source').val();
12096
var build_method = App.Env.getWorldName() + '_form';
12197
var tpl = App.HTML.Build[build_method](options);
12298
elm.replaceWith(tpl);
12399

124-
//App.Pages[App.Env.world].edit(elm);
100+
App.Helpers.disbleNotEditable();
125101
//App.Helpers.updateScreen();
126102
}
127103

@@ -213,17 +189,56 @@ App.Actions.close_popup = function()
213189
App.View.closePopup();
214190
}
215191

192+
193+
App.Actions.close_subform = function(evt, elm)
194+
{
195+
var elm = elm || $(evt.target);
196+
var ref = elm.hasClass('subform') ? elm : elm.parents('.subform');
197+
var parent_ref = ref.prev('.row');
198+
if (parent_ref.length > 0) {
199+
parent_ref.find('.show-records').removeClass('hidden');
200+
}
201+
ref.remove();
202+
}
203+
216204
App.Actions.save_dns_subrecords = function(evt)
217205
{
218206
var elm = $(evt.target);
219207
var ref = elm.hasClass('subform') ? elm : elm.parents('.subform');
220208

221-
var records = [];
222-
ref.find('.subrow').each(function(i, o){
223-
records[records.length++] = App.Helpers.getFormValuesFromElement(o);
209+
var data = [];
210+
$('.subform').find('.subrow').each(function(i, o)
211+
{
212+
data[data.length++] = App.Helpers.getFormValues(o);
224213
});
225214

226-
fb.warn($.toJSON(records));
215+
var parent_row = $(elm).parents('.subform').prev('.dns-details-row');
216+
var dns_json = $(parent_row).find('.source').val();
217+
218+
App.Ajax.request('DNS.changeRecords', {spell: App.Helpers.toJSON(data), dns: dns_json}, function(reply)
219+
{
220+
if (reply.result) {
221+
var emphasize = $('.show-records', parent_row);
222+
App.Actions.close_subform(null, elm);
223+
$(emphasize).effect("highlight", {'color':'#B0D635'}, 3000);
224+
225+
}
226+
else {
227+
App.Helpers.alert('Changes were not applied');
228+
}
229+
});
230+
}
231+
232+
App.Actions.delete_subentry = function(evt)
233+
{
234+
var sure = confirm(App.i18n.getMessage('confirm'));
235+
if (!sure) {
236+
return;
237+
}
238+
239+
var elm = $(evt.target);
240+
var ref = elm.hasClass('subrow') ? elm : elm.parents('.subrow');
241+
$(ref).remove();
227242
}
228243

229244
App.Actions.generate_pass = function()

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: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ App.HTML.Build.dns_form = function(options, id)
8383
}
8484

8585
tpl.set(':id', id || '');
86-
tpl.set(':DNS_DOMAIN', options.DNS_DOMAIN || '');
86+
tpl.set(':DNS_DOMAIN', options.DNS_DOMAIN || '');
8787
tpl.set(':IP', options.IP || '');
8888
tpl.set(':TTL', options.TTL || '');
8989
tpl.set(':SOA', options.SOA || '');
@@ -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

312-
options = !App.Helpers.isEmpty(options) ? options : {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','NS':''};
319+
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
}
@@ -373,11 +380,12 @@ App.HTML.Build.db_form = function(options, id)
373380
tpl.set(':save_button', 'SAVE');
374381
}
375382

376-
options = !App.Helpers.isEmpty(options) ? options : {'DB':'', 'USER':'','FORM':'', 'PASSWORD': ''};
377-
383+
options = !App.Helpers.isEmpty(options) ? options : {'DB':'', 'USER':'','FORM':'', 'PASSWORD': ''};
378384
tpl = App.HTML.setTplKeys(tpl, options, true);
379385
tpl = App.HTML.Build.db_selects(tpl, options);
380386

387+
tpl.set(':PASSWORD', '');
388+
381389
return tpl.finalize();
382390
}
383391

@@ -559,7 +567,27 @@ App.HTML.Build.dns_selects = function(tpl, options)
559567
tpl.set(':TPL_DEFAULT_VALUE', options.TPL || App.Helpers.getFirstKey(obj));
560568
}
561569
catch (e) {
562-
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;
563591
}
564592

565593
return tpl;

0 commit comments

Comments
 (0)