forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhtml.js
More file actions
226 lines (192 loc) · 6.87 KB
/
Copy pathhtml.js
File metadata and controls
226 lines (192 loc) · 6.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
App.HTML.makeDatabases = function(databases){
var acc = [];
$(databases).each(function(i, o){
var tpl = App.Templates.get('database', 'database');
tpl.set(':name', o.Database);
tpl.set(':db_name', o.Database);
acc[acc.length++] = tpl.finalize();
});
return acc.done();
}
App.HTML.makeDbTableList = function(data){
var acc = [];
$(data).each(function(i, o){
var name = App.Helpers.getFirstValue(o);
var tpl = App.Templates.get('database_table', 'database');
tpl.set(':name', name);
tpl.set(':table_name', name);
acc[acc.length++] = tpl.finalize();
});
return acc.done();
}
App.HTML.makeDbFieldsList = function(data){
var acc = [];
$(data).each(function(i, o){
var details = [o['Type'], o['Null'], o['Key'], o['Default'], o['Extra']].join(' ');
var tpl = App.Templates.get('database_field', 'database');
tpl.set(':name', o.Field);
tpl.set(':details', details);
acc[acc.length++] = tpl.finalize();
});
return acc.done();
}
App.HTML.Build.dns_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', 'dns');
tpl.set(':source', options);
options = App.Helpers.evalJSON(options) || {};
if (App.Helpers.isEmpty(options)) {
tpl.set(':title', 'New dns record');
tpl.set(':save_button', 'ADD');
}
else {
tpl.set(':title', 'Edit dns record');
tpl.set(':save_button', 'SAVE');
}
tpl.set(':id', id || '');
tpl.set(':DNS_DOMAIN', options.DNS_DOMAIN || '');
tpl.set(':IP', options.IP || '');
tpl.set(':TTL', options.TTL || '');
tpl.set(':SOA', options.SOA || '');
tpl.set(':DATE', options.DATE || '');
tpl = App.HTML.Build.dns_selects(tpl, options);
return tpl.finalize();
}
App.HTML.Build.ip_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', 'ip');
tpl.set(':source', options);
options = App.Helpers.evalJSON(options) || {};
if (App.Helpers.isEmpty(options)) {
tpl.set(':title', 'New ip address');
tpl.set(':save_button', 'ADD');
}
else {
tpl.set(':title', 'Edit ip address');
tpl.set(':save_button', 'SAVE');
}
tpl.set(':id', id || '');
tpl.set(':IP_ADDRESS', options.IP_ADDRESS || '');
tpl.set(':NETMASK', options.NETMASK || '');
tpl.set(':NAME', options.NAME || '');
tpl = App.HTML.Build.ip_selects(tpl, options);
return tpl.finalize();
}
App.HTML.Build.ip_selects = function(tpl, options) {
// OWNER
var opts = App.HTML.Build.options(App.Env.initialParams.IP.SYS_USERS, options.OWNER);
tpl.set(':owner_options', opts);
// STATUS
var opts = App.HTML.Build.options(App.Env.initialParams.IP.STATUSES, options.STATUS);
tpl.set(':status_options', opts);
// INTERFACE
var opts = App.HTML.Build.options(App.Env.initialParams.IP.INTERFACES, options.INTERFACE);
tpl.set(':interface_options', opts);
return tpl;
}
App.HTML.Build.dns_selects = function(tpl, options) {
try{
// TPL
var obj = App.Env.initialParams.DNS.TPL;
var opts = App.HTML.Build.options(obj, options.TPL);
tpl.set(':TPL', opts);
tpl.set(':TPL_DEFAULT_VALUE', options.TPL || App.Helpers.getFirstKey(obj));
}
catch (e) {
return '';
}
return tpl;
}
App.HTML.Build.options = function(initial, default_value) {
var opts = [];
$.each(initial, function(key){
var selected = key == default_value ? 'selected="selected"' : '';
opts[opts.length++] = '<option value="'+key+'" '+selected+'>'+initial[key]+'</options>';
});
return opts.join('');
}
App.HTML.Build.ip_entry = function(o){
var tpl = App.Templates.get('ENTRY', 'ip');
tpl.set(':source',$.toJSON(o));
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.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.dns_entry = function(o, is_new){
var tpl = App.Templates.get('ENTRY', 'dns');
tpl.set(':source', App.Helpers.toJSON(o));
tpl.set(':DNS_DOMAIN', o.DNS_DOMAIN);
var ip = o.IP.split('.');
tpl.set(':IP', ip.join('<span class="dot">.</span>'));
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(':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');
}
else {
var sub_tpl = App.Templates.get('SUSPENDED_TPL_DISABLED', 'dns');
}
tpl.set(':SUSPENDED_TPL', sub_tpl.finalize());
return tpl.finalize();
}
App.HTML.Build.dns_records = function(records)
{
var acc = [];
$.each(records, function(i, record)
{
var record = records[i];
var tpl = App.HTML.Build.dns_subrecord(record);
acc[acc.length] = tpl.finalize();
});
return acc.done();
}
App.HTML.Build.dns_subrecord = function(record)
{
var tpl = App.Templates.get('SUBENTRY', 'dns');
tpl.set(':RECORD', record.RECORD || '');
tpl.set(':RECORD_VALUE', record.RECORD_VALUE || '');
tpl.set(':RECORD_ID', record.RECORD_ID || '');
//tpl.set(':RECORD_TYPE_VALUE', '');
tpl.set(':RECORD_TYPE', App.HTML.Build.options(App.Env.initialParams.DNS.record.RECORD_TYPE, (record.RECORD_TYPE || -1)));
return tpl;
}