forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel.js
More file actions
172 lines (156 loc) · 4.43 KB
/
Copy pathmodel.js
File metadata and controls
172 lines (156 loc) · 4.43 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
App.Model.DNS.loadList = function(callback)
{
if (!callback) {
callback = App.View.listItems;
}
App.Ajax.request('DNS.getList', {}, callback);
}
App.Model.IP.loadList = function(callback)
{
if (!callback) {
callback = App.View.listItems;
}
App.Ajax.request('IP.getList', {}, callback);
}
App.Model.USER.loadList = function(callback)
{
if (!callback) {
callback = App.View.listItems;
}
App.Ajax.request('USER.getList', {}, callback);
}
App.Model.WEB_DOMAIN.loadList = function(callback)
{
if (!callback) {
callback = App.View.listItems;
}
App.Ajax.request('WEB_DOMAIN.getList', {}, callback);
}
App.Model.MAIL.loadList = function(callback)
{
//App.Ajax.request('MAIL.getList', {}, App.View.listItems);
App.Ref.CONTENT.html('<center><h1 style="padding-top: 20px; font-size: 28px; position: absolute; margin-left: 351px; color: white; text-shadow: 2px 1px 1px rgb(65, 124, 213);">Under maintanance</h1><img width="900px" src="'+App.Helpers.generateUrl('images/Asteroid_Vesta.jpg')+'"></center>');
}
App.Model.DB.loadList = function(callback)
{
if (!callback) {
callback = function(reply) {
var acc = [];
var build_method = App.Env.getWorldName() + '_entry';
var data = reply.data;
// TODO: fix it data.data
$.each(data, function(key)
{
var db_list = data[key];
fb.warn('KEY: %o', key);
fb.warn('DATA: %o', data[key]);
var tpl_divider = App.Templates.get('DIVIDER', 'db');
tpl_divider.set(':TYPE', key);
acc[acc.length++] = tpl_divider.finalize();
$(db_list).each(function(i, o)
{
acc[acc.length++] = App.HTML.Build[build_method](o, 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', App.Env.getWorldName());
App.Ref.CONTENT.html(html);
App.Helpers.updateScreen();
};
}
App.Ajax.request('DB.getList', {}, callback);
}
App.Model.CRON.loadList = function(callback)
{
if (!callback) {
callback = App.View.listItems;
}
App.Ajax.request('CRON.getList', {}, callback);
}
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) {
App.Helpers.Warn('Changes were not applied ' + App.Helpers.toJSON(reply.errors) );
}
else {
App.Pages.prepareHTML();
}
});
}
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)
{
var method = App.Settings.getMethodName('update');
var build_method = App.Env.getWorldName() + '_entry';
var params = {
'old': source_json,
'new': App.Helpers.toJSON(values)
};
App.Ajax.request(method, params, function(reply){
if(!reply.result) {
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. ' + reply.message);
}
else {
var tpl = App.HTML.Build[build_method]($.extend(App.Helpers.evalJSON(source_json), values));
$(elm).replaceWith(tpl);
App.Helpers.updateScreen();
}
});
}
/*
App.Model.IP.update = function(values, source_json) {
App.Ajax.request('IP.update', {
'source': source_json,
'target': App.Helpers.toJSON(values)
}, function(reply){
if(!reply.result) {
App.Pages.IP.ipNotSaved(reply);
}
});
}
App.Model.IP.add = function(values) {
App.Ajax.request('IP.add', {
'target': App.Helpers.toJSON(values)
}, function(reply){
if(!reply.result) {
App.Helpers.alert(reply.message)
}
});
}
App.Model.IP.remove = function(values_json, elm) {
App.Ajax.request('IP.remove', {
'target': values_json
}, function(reply){
if(!reply.result) {
App.Helpers.alert(reply.message);
}
else {
elm.remove();
}
});
}*/