InPanel 1.2.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- inpanel/__init__.py +29 -0
- inpanel/acme.py +289 -0
- inpanel/aliyuncs.py +269 -0
- inpanel/app.py +514 -0
- inpanel/apt.py +223 -0
- inpanel/base.py +200 -0
- inpanel/config.py +139 -0
- inpanel/data/config.ini +29 -0
- inpanel/data/history +5 -0
- inpanel/data/runlogs.ini +12 -0
- inpanel/data/update_info.ini +4 -0
- inpanel/dnf.py +225 -0
- inpanel/lib/__init__.py +9 -0
- inpanel/lib/async_process.py +98 -0
- inpanel/lib/filelock.py +82 -0
- inpanel/lib/magic.py +233 -0
- inpanel/lib/pxssh.py +310 -0
- inpanel/lib/pyDes.py +867 -0
- inpanel/mod/__init__.py +0 -0
- inpanel/mod/apt.py +316 -0
- inpanel/mod/certificate.py +268 -0
- inpanel/mod/config.py +372 -0
- inpanel/mod/cron.py +315 -0
- inpanel/mod/disk.py +322 -0
- inpanel/mod/dnf.py +239 -0
- inpanel/mod/file.py +722 -0
- inpanel/mod/firewall.py +199 -0
- inpanel/mod/firewall_base.py +137 -0
- inpanel/mod/firewall_firewalld.py +170 -0
- inpanel/mod/firewall_iptables.py +176 -0
- inpanel/mod/firewall_macos.py +213 -0
- inpanel/mod/firewall_ufw.py +128 -0
- inpanel/mod/ftp.py +231 -0
- inpanel/mod/httpd.py +1205 -0
- inpanel/mod/lighttpd.py +26 -0
- inpanel/mod/login.py +98 -0
- inpanel/mod/mysql.py +577 -0
- inpanel/mod/named.py +26 -0
- inpanel/mod/nginx.py +2327 -0
- inpanel/mod/package.py +33 -0
- inpanel/mod/package_apt.py +62 -0
- inpanel/mod/package_base.py +77 -0
- inpanel/mod/package_dnf.py +62 -0
- inpanel/mod/package_map.py +366 -0
- inpanel/mod/package_yum.py +64 -0
- inpanel/mod/php.py +289 -0
- inpanel/mod/process.py +291 -0
- inpanel/mod/proftpd.py +26 -0
- inpanel/mod/pureftpd.py +26 -0
- inpanel/mod/query.py +108 -0
- inpanel/mod/server.py +1319 -0
- inpanel/mod/service.py +262 -0
- inpanel/mod/setting.py +228 -0
- inpanel/mod/shell.py +78 -0
- inpanel/mod/ssh.py +280 -0
- inpanel/mod/system.py +220 -0
- inpanel/mod/task.py +1337 -0
- inpanel/mod/ufw.py +14 -0
- inpanel/mod/user.py +306 -0
- inpanel/mod/vsftpd.py +67 -0
- inpanel/mod/yum.py +243 -0
- inpanel/plugins/__init__.py +10 -0
- inpanel/plugins/__pycache__/__init__.cpython-313.pyc +0 -0
- inpanel/plugins/acme/static/index.html +10 -0
- inpanel/plugins/acme/static/index.js +13 -0
- inpanel/plugins/shadowsocks-libev/__pycache__/info.cpython-313.pyc +0 -0
- inpanel/plugins/shadowsocks-libev/info.py +73 -0
- inpanel/plugins/shadowsocks-libev/static/index.html +70 -0
- inpanel/plugins/shadowsocks-libev/static/index.js +18 -0
- inpanel/public/css/global.css +138 -0
- inpanel/public/favicon.ico +0 -0
- inpanel/public/images/alipay.jpg +0 -0
- inpanel/public/images/loading.gif +0 -0
- inpanel/public/images/weixin.jpg +0 -0
- inpanel/public/index.html +94 -0
- inpanel/public/js/controllers/controllers.js +566 -0
- inpanel/public/js/controllers/database.js +590 -0
- inpanel/public/js/controllers/ecs.js +624 -0
- inpanel/public/js/controllers/file.js +940 -0
- inpanel/public/js/controllers/plugins.js +105 -0
- inpanel/public/js/controllers/service.js +1460 -0
- inpanel/public/js/controllers/site.js +1241 -0
- inpanel/public/js/controllers/utils.js +2319 -0
- inpanel/public/js/core.js +221 -0
- inpanel/public/js/directives.js +784 -0
- inpanel/public/js/filters.js +395 -0
- inpanel/public/js/services.js +257 -0
- inpanel/public/lib/angular/1.0.2/angular-resource.min.js +10 -0
- inpanel/public/lib/angular/1.0.2/angular.min.js +158 -0
- inpanel/public/lib/bootstrap/css/bootstrap-theme.css +587 -0
- inpanel/public/lib/bootstrap/css/bootstrap-theme.css.map +1 -0
- inpanel/public/lib/bootstrap/css/bootstrap-theme.min.css +6 -0
- inpanel/public/lib/bootstrap/css/bootstrap-theme.min.css.map +1 -0
- inpanel/public/lib/bootstrap/css/bootstrap.css +6757 -0
- inpanel/public/lib/bootstrap/css/bootstrap.css.map +1 -0
- inpanel/public/lib/bootstrap/css/bootstrap.min.css +6 -0
- inpanel/public/lib/bootstrap/css/bootstrap.min.css.map +1 -0
- inpanel/public/lib/bootstrap/fonts/glyphicons-halflings-regular.eot +0 -0
- inpanel/public/lib/bootstrap/fonts/glyphicons-halflings-regular.svg +288 -0
- inpanel/public/lib/bootstrap/fonts/glyphicons-halflings-regular.ttf +0 -0
- inpanel/public/lib/bootstrap/fonts/glyphicons-halflings-regular.woff +0 -0
- inpanel/public/lib/bootstrap/fonts/glyphicons-halflings-regular.woff2 +0 -0
- inpanel/public/lib/bootstrap/img/glyphicons-halflings-white.png +0 -0
- inpanel/public/lib/bootstrap/img/glyphicons-halflings.png +0 -0
- inpanel/public/lib/bootstrap/js/bootstrap.js +2377 -0
- inpanel/public/lib/bootstrap/js/bootstrap.min.js +7 -0
- inpanel/public/lib/bootstrap/js/npm.js +13 -0
- inpanel/public/lib/codemirror/codemirror-compressed.js +1 -0
- inpanel/public/lib/codemirror/codemirror.css +173 -0
- inpanel/public/lib/jquery/jquery-1.12.4.min.js +5 -0
- inpanel/public/lib/md5/md5.js +379 -0
- inpanel/public/lib/md5/md5.min.js +1 -0
- inpanel/public/partials/database/index.html +172 -0
- inpanel/public/partials/database/mysql/dbedit.html +462 -0
- inpanel/public/partials/database/mysql/dbnew.html +348 -0
- inpanel/public/partials/database/mysql/useredit.html +310 -0
- inpanel/public/partials/database/mysql/usernew.html +97 -0
- inpanel/public/partials/directives/message.html +20 -0
- inpanel/public/partials/directives/navbar.html +25 -0
- inpanel/public/partials/directives/selector.html +57 -0
- inpanel/public/partials/directives/srvbase.html +72 -0
- inpanel/public/partials/directives/srvext.html +34 -0
- inpanel/public/partials/directives/srvfile.html +23 -0
- inpanel/public/partials/directives/srvinstall.html +34 -0
- inpanel/public/partials/directives/srvlog.html +23 -0
- inpanel/public/partials/directives/srvminiop.html +28 -0
- inpanel/public/partials/directives/srvuninstall.html +38 -0
- inpanel/public/partials/directives/srvupdate.html +30 -0
- inpanel/public/partials/ecs/account.html +156 -0
- inpanel/public/partials/ecs/ecs.html +198 -0
- inpanel/public/partials/ecs/index.html +40 -0
- inpanel/public/partials/ecs/setings.html +459 -0
- inpanel/public/partials/file/file.html +501 -0
- inpanel/public/partials/file/trash.html +95 -0
- inpanel/public/partials/ftp.html +36 -0
- inpanel/public/partials/log.html +83 -0
- inpanel/public/partials/login.html +79 -0
- inpanel/public/partials/logout.html +22 -0
- inpanel/public/partials/main.html +534 -0
- inpanel/public/partials/plugins/index.html +55 -0
- inpanel/public/partials/plugins/plugins.html +13 -0
- inpanel/public/partials/secure.html +13 -0
- inpanel/public/partials/service/apache.html +147 -0
- inpanel/public/partials/service/cron.html +71 -0
- inpanel/public/partials/service/index.html +293 -0
- inpanel/public/partials/service/iptables.html +40 -0
- inpanel/public/partials/service/lighttpd.html +63 -0
- inpanel/public/partials/service/mariadb.html +113 -0
- inpanel/public/partials/service/memcache.html +36 -0
- inpanel/public/partials/service/minio.html +44 -0
- inpanel/public/partials/service/mongodb.html +44 -0
- inpanel/public/partials/service/mysql.html +113 -0
- inpanel/public/partials/service/named.html +61 -0
- inpanel/public/partials/service/nginx.html +296 -0
- inpanel/public/partials/service/ntp.html +40 -0
- inpanel/public/partials/service/php.html +250 -0
- inpanel/public/partials/service/proftpd.html +59 -0
- inpanel/public/partials/service/pureftpd.html +59 -0
- inpanel/public/partials/service/redis.html +40 -0
- inpanel/public/partials/service/samba.html +58 -0
- inpanel/public/partials/service/sendmail.html +40 -0
- inpanel/public/partials/service/ssh.html +186 -0
- inpanel/public/partials/service/tomcat.html +65 -0
- inpanel/public/partials/service/vsftpd.html +195 -0
- inpanel/public/partials/setting.html +299 -0
- inpanel/public/partials/site/apache/site.html +277 -0
- inpanel/public/partials/site/index.html +344 -0
- inpanel/public/partials/site/nginx/site.html +558 -0
- inpanel/public/partials/sorry.html +19 -0
- inpanel/public/partials/storage/autofm.html +103 -0
- inpanel/public/partials/storage/backup.html +42 -0
- inpanel/public/partials/storage/index.html +360 -0
- inpanel/public/partials/storage/migrate.html +93 -0
- inpanel/public/partials/storage/movedata.html +98 -0
- inpanel/public/partials/storage/remote.html +77 -0
- inpanel/public/partials/utils/cron.html +486 -0
- inpanel/public/partials/utils/firewall.html +266 -0
- inpanel/public/partials/utils/index.html +193 -0
- inpanel/public/partials/utils/network.html +118 -0
- inpanel/public/partials/utils/process.html +239 -0
- inpanel/public/partials/utils/repository.html +373 -0
- inpanel/public/partials/utils/shell.html +28 -0
- inpanel/public/partials/utils/ssl.html +319 -0
- inpanel/public/partials/utils/time.html +109 -0
- inpanel/public/partials/utils/user.html +359 -0
- inpanel/public/robots.txt +2 -0
- inpanel/remote.py +109 -0
- inpanel/templates/file/preview.html +34 -0
- inpanel/templates/index.html +93 -0
- inpanel/utils.py +282 -0
- inpanel/web.py +1811 -0
- inpanel/yum.py +756 -0
- inpanel-1.2.1.dist-info/METADATA +399 -0
- inpanel-1.2.1.dist-info/RECORD +198 -0
- inpanel-1.2.1.dist-info/WHEEL +5 -0
- inpanel-1.2.1.dist-info/entry_points.txt +2 -0
- inpanel-1.2.1.dist-info/licenses/LICENSE +30 -0
- inpanel-1.2.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,2319 @@
|
|
|
1
|
+
var UtilsCtrl = ['$scope', 'Module', 'Request',
|
|
2
|
+
function($scope, Module, Request) {
|
|
3
|
+
var module = 'utils';
|
|
4
|
+
Module.init(module, '系统工具');
|
|
5
|
+
$scope.loaded = true;
|
|
6
|
+
|
|
7
|
+
$scope.rebootconfirm = function() {
|
|
8
|
+
$('#rebootconfirm').modal();
|
|
9
|
+
};
|
|
10
|
+
$scope.reboot = function() {
|
|
11
|
+
Request.post('/api/operation/reboot');
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
var UtilsUserCtrl = [
|
|
17
|
+
'$scope', '$routeParams', 'Module', 'Timeout', 'Request',
|
|
18
|
+
function($scope, $routeParams, Module, Timeout, Request) {
|
|
19
|
+
var module = 'utils.user';
|
|
20
|
+
var section = Module.getSection();
|
|
21
|
+
var enabled_sections = ['user', 'group'];
|
|
22
|
+
Module.init(module, '用户管理');
|
|
23
|
+
Module.initSection(enabled_sections[0]);
|
|
24
|
+
$scope.loaded = true;
|
|
25
|
+
$scope.loading = {
|
|
26
|
+
user: true,
|
|
27
|
+
group: true
|
|
28
|
+
}
|
|
29
|
+
$scope.tab_sec = function (section) {
|
|
30
|
+
// var init = Module.getSection() != section
|
|
31
|
+
section = (section && enabled_sections.indexOf(section) > -1) ? section : enabled_sections[0];
|
|
32
|
+
$scope.sec(section);
|
|
33
|
+
Module.setSection(section);
|
|
34
|
+
// $scope['load_' + section](init);
|
|
35
|
+
};
|
|
36
|
+
$scope.loadUsers = function() {
|
|
37
|
+
$scope.loading.user = true;
|
|
38
|
+
Request.post('/api/operation/user', {
|
|
39
|
+
'action': 'listuser'
|
|
40
|
+
}, function(data) {
|
|
41
|
+
$scope.loading.user = false;
|
|
42
|
+
if (data.code == 0) {
|
|
43
|
+
$scope.users = data.data;
|
|
44
|
+
}
|
|
45
|
+
}, false, true);
|
|
46
|
+
};
|
|
47
|
+
$scope.loadGroups = function() {
|
|
48
|
+
$scope.loading.group = true;
|
|
49
|
+
Request.post('/api/operation/user', {
|
|
50
|
+
'action': 'listgroup'
|
|
51
|
+
}, function(data) {
|
|
52
|
+
$scope.loading.group = false;
|
|
53
|
+
if (data.code == 0) {
|
|
54
|
+
$scope.groups = data.data;
|
|
55
|
+
}
|
|
56
|
+
}, false, true);
|
|
57
|
+
};
|
|
58
|
+
$scope.useraddconfirm = function() {
|
|
59
|
+
$scope.curuser = {
|
|
60
|
+
'pw_name': '',
|
|
61
|
+
'pw_gecos': '',
|
|
62
|
+
'pw_gname': '',
|
|
63
|
+
'pw_shell': '/bin/bash',
|
|
64
|
+
'pw_passwd': '',
|
|
65
|
+
'pw_passwdc': '',
|
|
66
|
+
'createhome': true,
|
|
67
|
+
'lock': false
|
|
68
|
+
};
|
|
69
|
+
$('#useraddconfirm').modal();
|
|
70
|
+
};
|
|
71
|
+
$scope.useradd = function() {
|
|
72
|
+
var userdata = $scope.curuser;
|
|
73
|
+
userdata['action'] = 'useradd';
|
|
74
|
+
Request.post('/api/operation/user', userdata, function(data) {
|
|
75
|
+
if (data.code == 0) {
|
|
76
|
+
$scope.loadUsers();
|
|
77
|
+
$scope.loadGroups();
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
$scope.usermodconfirm = function(i) {
|
|
82
|
+
var curuser = $scope.users[i];
|
|
83
|
+
$scope.curuser = {
|
|
84
|
+
'pw_name': curuser.pw_name,
|
|
85
|
+
'pw_gecos': curuser.pw_gecos,
|
|
86
|
+
'pw_gname': curuser.pw_gname,
|
|
87
|
+
'pw_dir': curuser.pw_dir,
|
|
88
|
+
'pw_shell': curuser.pw_shell,
|
|
89
|
+
'pw_passwd': '',
|
|
90
|
+
'pw_passwdc': '',
|
|
91
|
+
'lock': curuser.lock
|
|
92
|
+
};
|
|
93
|
+
$('#usermodconfirm').modal();
|
|
94
|
+
};
|
|
95
|
+
$scope.usermod = function() {
|
|
96
|
+
var userdata = $scope.curuser;
|
|
97
|
+
userdata['action'] = 'usermod';
|
|
98
|
+
Request.post('/api/operation/user', userdata, function(data) {
|
|
99
|
+
if (data.code == 0) {
|
|
100
|
+
$scope.loadUsers();
|
|
101
|
+
$scope.loadGroups();
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
$scope.userdelconfirm = function(i) {
|
|
106
|
+
var curuser = $scope.users[i];
|
|
107
|
+
$scope.curuser = {
|
|
108
|
+
'pw_name': curuser.pw_name
|
|
109
|
+
};
|
|
110
|
+
$('#userdelconfirm').modal();
|
|
111
|
+
};
|
|
112
|
+
$scope.userdel = function() {
|
|
113
|
+
Request.post('/api/operation/user', {
|
|
114
|
+
'action': 'userdel',
|
|
115
|
+
'pw_name': $scope.curuser['pw_name']
|
|
116
|
+
}, function(data) {
|
|
117
|
+
if (data.code == 0) {
|
|
118
|
+
$scope.loadUsers();
|
|
119
|
+
$scope.loadGroups();
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
$scope.groupaddconfirm = function() {
|
|
124
|
+
$scope.curgrp_name = '';
|
|
125
|
+
$('#groupaddconfirm').modal();
|
|
126
|
+
};
|
|
127
|
+
$scope.groupadd = function() {
|
|
128
|
+
Request.post('/api/operation/user', {
|
|
129
|
+
'action': 'groupadd',
|
|
130
|
+
'gr_name': $scope.curgrp_name
|
|
131
|
+
}, function(data) {
|
|
132
|
+
if (data.code == 0) {
|
|
133
|
+
$scope.loadGroups();
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
$scope.groupmodconfirm = function(i) {
|
|
138
|
+
$scope.curgrp_newname = $scope.curgrp_name = $scope.groups[i].gr_name;
|
|
139
|
+
$('#groupmodconfirm').modal();
|
|
140
|
+
};
|
|
141
|
+
$scope.groupmod = function() {
|
|
142
|
+
Request.post('/api/operation/user', {
|
|
143
|
+
'action': 'groupmod',
|
|
144
|
+
'gr_name': $scope.curgrp_name,
|
|
145
|
+
'gr_newname': $scope.curgrp_newname
|
|
146
|
+
}, function(data) {
|
|
147
|
+
if (data.code == 0) {
|
|
148
|
+
$scope.loadGroups();
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
$scope.groupdelconfirm = function(i) {
|
|
153
|
+
$scope.curgrp_name = $scope.groups[i].gr_name;
|
|
154
|
+
$('#groupdelconfirm').modal();
|
|
155
|
+
};
|
|
156
|
+
$scope.groupdel = function() {
|
|
157
|
+
Request.post('/api/operation/user', {
|
|
158
|
+
'action': 'groupdel',
|
|
159
|
+
'gr_name': $scope.curgrp_name
|
|
160
|
+
}, function(data) {
|
|
161
|
+
if (data.code == 0) {
|
|
162
|
+
$scope.loadGroups();
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
$scope.groupmemsaddconfirm = function(i) {
|
|
167
|
+
$scope.curgrp_name = $scope.groups[i].gr_name;
|
|
168
|
+
$scope.curgrp_mem = '';
|
|
169
|
+
$('#groupmemsaddconfirm').modal();
|
|
170
|
+
};
|
|
171
|
+
$scope.groupmemsadd = function() {
|
|
172
|
+
Request.post('/api/operation/user', {
|
|
173
|
+
'action': 'groupmems_add',
|
|
174
|
+
'gr_name': $scope.curgrp_name,
|
|
175
|
+
'mem': $scope.curgrp_mem
|
|
176
|
+
}, function(data) {
|
|
177
|
+
if (data.code == 0) {
|
|
178
|
+
$scope.loadUsers();
|
|
179
|
+
$scope.loadGroups();
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
$scope.groupmemsdelconfirm = function(i) {
|
|
184
|
+
$scope.curgrp_name = $scope.groups[i].gr_name;
|
|
185
|
+
$scope.curgrp_mems = $scope.groups[i].gr_mem;
|
|
186
|
+
$scope.curgrp_mem = '';
|
|
187
|
+
$('#groupmemsdelconfirm').modal();
|
|
188
|
+
};
|
|
189
|
+
$scope.groupmemsdel = function() {
|
|
190
|
+
Request.post('/api/operation/user', {
|
|
191
|
+
'action': 'groupmems_del',
|
|
192
|
+
'gr_name': $scope.curgrp_name,
|
|
193
|
+
'mem': $scope.curgrp_mem
|
|
194
|
+
}, function(data) {
|
|
195
|
+
if (data.code == 0) {
|
|
196
|
+
$scope.loadUsers();
|
|
197
|
+
$scope.loadGroups();
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
];
|
|
203
|
+
|
|
204
|
+
var UtilsProcessCtrl = [
|
|
205
|
+
'$scope', '$routeParams', 'Module', 'Timeout', 'Request',
|
|
206
|
+
function ($scope, $routeParams, Module, Timeout, Request) {
|
|
207
|
+
var module = 'utils.process';
|
|
208
|
+
var section = Module.getSection();
|
|
209
|
+
var enabled_sections = ['list', 'other'];
|
|
210
|
+
Module.init(module, '进程管理');
|
|
211
|
+
Module.initSection(enabled_sections[0]);
|
|
212
|
+
$scope.loaded = false;
|
|
213
|
+
$scope.init_process = true;
|
|
214
|
+
$scope.delete_process = '';
|
|
215
|
+
$scope.time_interval = 1000;
|
|
216
|
+
$scope.auto_refresh = false;
|
|
217
|
+
$scope.process = {
|
|
218
|
+
process: [],
|
|
219
|
+
total: 0
|
|
220
|
+
};
|
|
221
|
+
$scope.current_process = {};
|
|
222
|
+
$scope.current_process_loaded = {'info': false, 'status': false, 'file': false, 'io': false, 'memory': false, 'network': false}
|
|
223
|
+
|
|
224
|
+
$scope.load = function () {
|
|
225
|
+
$scope.loaded = true;
|
|
226
|
+
$scope.tab_sec(section);
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
$scope.tab_sec = function (section) {
|
|
230
|
+
var init = Module.getSection() != section
|
|
231
|
+
section = (section && enabled_sections.indexOf(section) > -1) ? section : enabled_sections[0];
|
|
232
|
+
$scope.sec(section);
|
|
233
|
+
Module.setSection(section);
|
|
234
|
+
$scope['load_' + section](init);
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
var getProcess = function() {
|
|
238
|
+
Request.get('/api/process/list', function (res) {
|
|
239
|
+
if (res && res.code == 0) {
|
|
240
|
+
$scope.process.process = res.data;
|
|
241
|
+
$scope.process.total = res.data.length;
|
|
242
|
+
}
|
|
243
|
+
if (!$scope.loaded) {
|
|
244
|
+
$scope.loaded = true;
|
|
245
|
+
}
|
|
246
|
+
if ($scope.init_process) {
|
|
247
|
+
$scope.init_process = false;
|
|
248
|
+
}
|
|
249
|
+
if (Module.getSection() == 'list' && $scope.auto_refresh) {
|
|
250
|
+
Timeout(getProcess, $scope.time_interval, module);
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
};
|
|
254
|
+
$scope.load_list = function (init) {
|
|
255
|
+
if (!init && !$scope.init_process) {
|
|
256
|
+
return; // Prevent duplicate requests
|
|
257
|
+
}
|
|
258
|
+
getProcess();
|
|
259
|
+
};
|
|
260
|
+
$scope.load_other = function (init) {
|
|
261
|
+
console.log('待开发功能', init)
|
|
262
|
+
}
|
|
263
|
+
$scope.processkillconfirm = function(i) {
|
|
264
|
+
$scope.delete_process = i || '';
|
|
265
|
+
$('#processkillconfirm').modal();
|
|
266
|
+
};
|
|
267
|
+
$scope.processkill = function () {
|
|
268
|
+
if ($scope.delete_process && $scope.delete_process['pid']) {
|
|
269
|
+
Request.post('/api/process/kill/' + $scope.delete_process['pid'], null, function () {
|
|
270
|
+
$scope.delete_process = '';
|
|
271
|
+
$scope.refresh();
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
$scope.process_detail = function (p) {
|
|
276
|
+
if (p && p['pid']) {
|
|
277
|
+
$('#process_detail_dialog').modal();
|
|
278
|
+
$scope.current_process.name = p['name'];
|
|
279
|
+
$scope.current_process.pid = p['pid'];
|
|
280
|
+
$scope.load_detial(p['pid']);
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
$scope.load_detial = function (pid) {
|
|
284
|
+
if (pid) {
|
|
285
|
+
$scope.current_process_loaded = {'info': false, 'status': false, 'file': false, 'io': false, 'memory': false, 'network': false}
|
|
286
|
+
Request.get('/api/process/info/' + pid, function (res) {
|
|
287
|
+
$scope.current_process_loaded.info = true;
|
|
288
|
+
if (res && res.code == 0) {
|
|
289
|
+
$scope.current_process.info = res.data;
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
// Request.get('/api/process/status/' + pid, function (res) {
|
|
293
|
+
// $scope.current_process_loaded.status = true;
|
|
294
|
+
// if (res && res.code == 0) {
|
|
295
|
+
// $scope.current_process.status = res.data;
|
|
296
|
+
// }
|
|
297
|
+
// });
|
|
298
|
+
Request.get('/api/process/file/' + pid, function (res) {
|
|
299
|
+
$scope.current_process_loaded.file = true;
|
|
300
|
+
if (res && res.code == 0) {
|
|
301
|
+
$scope.current_process.file = res.data;
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
// Request.get('/api/process/io/' + pid, function (res) {
|
|
305
|
+
// $scope.current_process_loaded.io = true;
|
|
306
|
+
// if (res && res.code == 0) {
|
|
307
|
+
// $scope.current_process.io = res.data;
|
|
308
|
+
// }
|
|
309
|
+
// });
|
|
310
|
+
// Request.get('/api/process/memory/' + pid, function (res) {
|
|
311
|
+
// $scope.current_process_loaded.memory = true;
|
|
312
|
+
// if (res && res.code == 0) {
|
|
313
|
+
// $scope.current_process.memory = res.data;
|
|
314
|
+
// }
|
|
315
|
+
// });
|
|
316
|
+
Request.get('/api/process/network/' + pid, function (res) {
|
|
317
|
+
$scope.current_process_loaded.network = true;
|
|
318
|
+
if (res && res.code == 0) {
|
|
319
|
+
$scope.current_process.network = res.data;
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
$scope.process_detail_close = function () {
|
|
325
|
+
Timeout(function() {
|
|
326
|
+
$scope.current_process = {};
|
|
327
|
+
}, 600, module);
|
|
328
|
+
}
|
|
329
|
+
$scope.refresh = function () {
|
|
330
|
+
console.log('刷新列表');
|
|
331
|
+
getProcess();
|
|
332
|
+
};
|
|
333
|
+
$scope.auto_refresh_open = function () {
|
|
334
|
+
console.log('打开自动刷新');
|
|
335
|
+
$scope.auto_refresh = true;
|
|
336
|
+
getProcess();
|
|
337
|
+
};
|
|
338
|
+
$scope.auto_refresh_close = function () {
|
|
339
|
+
console.log('关闭自动刷新');
|
|
340
|
+
$scope.auto_refresh = false;
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
]
|
|
344
|
+
|
|
345
|
+
var UtilsNetworkCtrl = [
|
|
346
|
+
'$scope', '$routeParams', 'Module', 'Timeout', 'Message', 'Request',
|
|
347
|
+
function($scope, $routeParams, Module, Timeout, Message, Request) {
|
|
348
|
+
var module = 'utils.network';
|
|
349
|
+
Module.init(module, '网络设置');
|
|
350
|
+
Module.initSection('hostname');
|
|
351
|
+
$scope.restartMessage = '是否要重启网络?';
|
|
352
|
+
$scope.loaded = true;
|
|
353
|
+
$scope.showRestartBtn = true;
|
|
354
|
+
|
|
355
|
+
$scope.loadHostName = function () {
|
|
356
|
+
Request.get('/api/network/hostname', function(data) {
|
|
357
|
+
$scope.hostname = data.hostname;
|
|
358
|
+
});
|
|
359
|
+
};
|
|
360
|
+
$scope.saveHostName = function () {
|
|
361
|
+
Request.post('/api/network/hostname', {
|
|
362
|
+
'hostname': $scope.hostname
|
|
363
|
+
}, function (data) {
|
|
364
|
+
if (data.code == 0) $scope.loadHostName();
|
|
365
|
+
});
|
|
366
|
+
};
|
|
367
|
+
$scope.loadIfNames = function() {
|
|
368
|
+
Request.get('/api/network/ifnames', function(data) {
|
|
369
|
+
$scope.ifnames = data.ifnames;
|
|
370
|
+
$scope.ifname = $scope.ifnames[0];
|
|
371
|
+
// load the default iface's config
|
|
372
|
+
$scope.loadIfConfig($scope.ifname);
|
|
373
|
+
});
|
|
374
|
+
};
|
|
375
|
+
$scope.loadIfConfig = function(ifname) {
|
|
376
|
+
$scope.ifname = ifname;
|
|
377
|
+
Request.get('/api/network/ifconfig/' + ifname, function(data) {
|
|
378
|
+
$scope.ip = data['ip'];
|
|
379
|
+
$scope.mask = data['mask'];
|
|
380
|
+
$scope.gw = data['gw'];
|
|
381
|
+
});
|
|
382
|
+
};
|
|
383
|
+
$scope.saveIfConfig = function() {
|
|
384
|
+
Request.post('/api/network/ifconfig/' + $scope.ifname, {
|
|
385
|
+
'ip': $scope.ip,
|
|
386
|
+
'mask': $scope.mask,
|
|
387
|
+
'gw': $scope.gw
|
|
388
|
+
}, function(data) {
|
|
389
|
+
if (data.code == 0) $scope.loadIfConfig($scope.ifname);
|
|
390
|
+
});
|
|
391
|
+
};
|
|
392
|
+
$scope.loadNameservers = function() {
|
|
393
|
+
Request.get('/api/network/nameservers', function(data) {
|
|
394
|
+
$scope.nameservers = data['nameservers'];
|
|
395
|
+
});
|
|
396
|
+
};
|
|
397
|
+
$scope.saveNameservers = function() {
|
|
398
|
+
var nameservers = [];
|
|
399
|
+
$('.nameserver').each(function() {
|
|
400
|
+
var ns = $(this).val();
|
|
401
|
+
if (ns) nameservers.push(ns);
|
|
402
|
+
});
|
|
403
|
+
Request.post('/api/network/nameservers', {
|
|
404
|
+
'nameservers': nameservers.join(',')
|
|
405
|
+
}, function(data) {
|
|
406
|
+
if (data.code == 0) $scope.loadNameservers();
|
|
407
|
+
});
|
|
408
|
+
};
|
|
409
|
+
$scope.addNameserver = function() {
|
|
410
|
+
$scope.nameservers.push('');
|
|
411
|
+
};
|
|
412
|
+
$scope.delNameserver = function(i) {
|
|
413
|
+
$scope.nameservers.splice(i, 1);
|
|
414
|
+
};
|
|
415
|
+
$scope.restart = function() {
|
|
416
|
+
$scope.restartMessage = '正在重启,请稍候...'
|
|
417
|
+
$scope.showRestartBtn = false;
|
|
418
|
+
Timeout(function() {
|
|
419
|
+
Request.post('/api/backend/service_restart', {
|
|
420
|
+
service: 'network'
|
|
421
|
+
}, function(data) {
|
|
422
|
+
var getRestartStatus = function() {
|
|
423
|
+
Request.get('/api/backend/service_restart_network', function(data) {
|
|
424
|
+
if (data.msg) $scope.restartMessage = data.msg;
|
|
425
|
+
if (data.status == 'finish') {
|
|
426
|
+
Message.setSuccess('');
|
|
427
|
+
Timeout(function() {
|
|
428
|
+
$scope.restartMessage = '是否要重启网络?';
|
|
429
|
+
$scope.showRestartBtn = true;
|
|
430
|
+
}, 3000, module);
|
|
431
|
+
} else
|
|
432
|
+
Timeout(getRestartStatus, 500, module);
|
|
433
|
+
});
|
|
434
|
+
};
|
|
435
|
+
Timeout(getRestartStatus, 500, module);
|
|
436
|
+
});
|
|
437
|
+
}, 1000, module);
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
];
|
|
441
|
+
|
|
442
|
+
var UtilsTimeCtrl = [
|
|
443
|
+
'$scope', '$routeParams', 'Module', 'Timeout', 'Request', 'Backend',
|
|
444
|
+
function($scope, $routeParams, Module, Timeout, Request, Backend) {
|
|
445
|
+
var module = 'utils.time';
|
|
446
|
+
Module.init(module, '时间设置');
|
|
447
|
+
Module.initSection('datetime');
|
|
448
|
+
$scope.loaded = true;
|
|
449
|
+
$scope.ntpdChecking = true;
|
|
450
|
+
$scope.ntpdStatus = null;
|
|
451
|
+
|
|
452
|
+
$scope.loadDatetime = function() {
|
|
453
|
+
Request.get('/api/time/datetime', function(data) {
|
|
454
|
+
$scope.datetime = data;
|
|
455
|
+
$scope.newDatetime = data.str;
|
|
456
|
+
});
|
|
457
|
+
};
|
|
458
|
+
$scope.saveDatetime = function() {
|
|
459
|
+
Request.post('/api/backend/datetime', {
|
|
460
|
+
'datetime': $scope.newDatetime
|
|
461
|
+
}, function(data) {
|
|
462
|
+
Request.setProcessing(true);
|
|
463
|
+
var getStatus = function() {
|
|
464
|
+
Request.get('/api/backend/datetime', function(data) {
|
|
465
|
+
if (data.status != 'finish') {
|
|
466
|
+
Request.setProcessing(true);
|
|
467
|
+
Timeout(getStatus, 500, module);
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
};
|
|
471
|
+
Timeout(getStatus, 500, module);
|
|
472
|
+
});
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
$scope.loadTimezone = function() {
|
|
476
|
+
Request.get('/api/time/timezone', function(data) {
|
|
477
|
+
var timezone = data.timezone;
|
|
478
|
+
$scope.timezone = timezone ? timezone : '时区不可识别';
|
|
479
|
+
if (timezone) {
|
|
480
|
+
var tzinfo = timezone.split('/');
|
|
481
|
+
$scope.timezone_region = tzinfo[0];
|
|
482
|
+
$scope.timezone_city = tzinfo[1];
|
|
483
|
+
} else {
|
|
484
|
+
$scope.timezone_region = 'Asia';
|
|
485
|
+
$scope.timezone_city = 'Shanghai';
|
|
486
|
+
}
|
|
487
|
+
});
|
|
488
|
+
};
|
|
489
|
+
$scope.loadTimezones = function(region, callback) {
|
|
490
|
+
if (region) {
|
|
491
|
+
Request.get('/api/time/timezone_list/' + region, function(data) {
|
|
492
|
+
$scope.cities = data.cities;
|
|
493
|
+
if (callback) callback.call();
|
|
494
|
+
});
|
|
495
|
+
} else {
|
|
496
|
+
Request.get('/api/time/timezone_list', function(data) {
|
|
497
|
+
$scope.regions = data.regions;
|
|
498
|
+
var getcities = function() {
|
|
499
|
+
Request.get('/api/time/timezone_list/' + $scope.timezone_region, function(data) {
|
|
500
|
+
$scope.cities = data.cities;
|
|
501
|
+
});
|
|
502
|
+
};
|
|
503
|
+
if ($scope.timezone_region) getcities();
|
|
504
|
+
else Timeout(getcities, 500, module);
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
$scope.setTimezone = function(region, city) {
|
|
509
|
+
$scope.timezone_region = region;
|
|
510
|
+
$scope.loadTimezones(region, function() {
|
|
511
|
+
$scope.timezone_city = city;
|
|
512
|
+
});
|
|
513
|
+
};
|
|
514
|
+
$scope.saveTimezone = function() {
|
|
515
|
+
var region = $scope.timezone_region;
|
|
516
|
+
var city = $scope.timezone_city;
|
|
517
|
+
Request.post('/api/time/timezone', {
|
|
518
|
+
'timezone': region + '/' + city
|
|
519
|
+
}, function(data) {
|
|
520
|
+
if (data.code == 0) {
|
|
521
|
+
$scope.loadTimezone();
|
|
522
|
+
$scope.loadDatetime();
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
};
|
|
526
|
+
|
|
527
|
+
$scope.synctime = function() {
|
|
528
|
+
var server = 'pool.ntp.org';
|
|
529
|
+
Request.post('/api/backend/ntpdate', {
|
|
530
|
+
'server': server
|
|
531
|
+
}, function(data) {
|
|
532
|
+
Request.setProcessing(true);
|
|
533
|
+
var getStatus = function() {
|
|
534
|
+
Request.get('/api/backend/ntpdate_' + server, function(data) {
|
|
535
|
+
if (data.status != 'finish') {
|
|
536
|
+
Request.setProcessing(true);
|
|
537
|
+
Timeout(getStatus, 500, module);
|
|
538
|
+
} else {
|
|
539
|
+
$scope.loadDatetime();
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
};
|
|
543
|
+
Timeout(getStatus, 500, module);
|
|
544
|
+
});
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
var installInit = function() {
|
|
548
|
+
$scope.installMessage = '时间同步需要使用 NTP 服务,您当前尚未安装该服务。<br>是否安装 ?';
|
|
549
|
+
$scope.showInstallBtn = true;
|
|
550
|
+
};
|
|
551
|
+
var startInit = function() {
|
|
552
|
+
$scope.startMessage = 'NTP 服务已安装但还未启动。是否启动同步 ?';
|
|
553
|
+
$scope.showStartBtn = true;
|
|
554
|
+
};
|
|
555
|
+
var stopInit = function() {
|
|
556
|
+
$scope.stopMessage = 'NTP 服务正在运行,系统时间会一直保持同步。是否停止同步 ?';
|
|
557
|
+
$scope.showStopBtn = true;
|
|
558
|
+
};
|
|
559
|
+
installInit();
|
|
560
|
+
startInit();
|
|
561
|
+
stopInit();
|
|
562
|
+
|
|
563
|
+
$scope.loadSync = function() {
|
|
564
|
+
Request.get('/api/query/service.ntpd', function(data) {
|
|
565
|
+
if (data['service.ntpd']) {
|
|
566
|
+
$scope.ntpdStatus = data['service.ntpd']['status'];
|
|
567
|
+
}
|
|
568
|
+
$scope.ntpdChecking = false;
|
|
569
|
+
});
|
|
570
|
+
};
|
|
571
|
+
$scope.ntp_install = function() {
|
|
572
|
+
$scope.installMessage = '正在安装,请稍候...'
|
|
573
|
+
$scope.showInstallBtn = false;
|
|
574
|
+
Backend.call(
|
|
575
|
+
$scope,
|
|
576
|
+
module,
|
|
577
|
+
'/api/backend/yum_install',
|
|
578
|
+
'/api/backend/yum_install_base_ntp', {
|
|
579
|
+
'repo': 'base',
|
|
580
|
+
'pkg': 'ntp'
|
|
581
|
+
}, {
|
|
582
|
+
'wait': function(data) {
|
|
583
|
+
$scope.installMessage = data.msg;
|
|
584
|
+
},
|
|
585
|
+
'success': function(data) {
|
|
586
|
+
$scope.installMessage = data.msg;
|
|
587
|
+
Timeout($scope.loadSync, 3000, module);
|
|
588
|
+
},
|
|
589
|
+
'error': function(data) {
|
|
590
|
+
$scope.installMessage = data.msg;
|
|
591
|
+
Timeout($scope.loadSync, 3000, module);
|
|
592
|
+
}
|
|
593
|
+
},
|
|
594
|
+
true
|
|
595
|
+
);
|
|
596
|
+
};
|
|
597
|
+
$scope.ntp_start = function() {
|
|
598
|
+
$scope.startMessage = '正在启动,请稍候...'
|
|
599
|
+
$scope.showStartBtn = false;
|
|
600
|
+
Backend.call(
|
|
601
|
+
$scope,
|
|
602
|
+
module,
|
|
603
|
+
'/api/backend/service_start',
|
|
604
|
+
'/api/backend/service_start_ntpd', {
|
|
605
|
+
name: 'NTP',
|
|
606
|
+
service: 'ntpd'
|
|
607
|
+
}, {
|
|
608
|
+
'wait': function(data) {
|
|
609
|
+
$scope.startMessage = data.msg;
|
|
610
|
+
},
|
|
611
|
+
'success': function(data) {
|
|
612
|
+
$scope.startMessage = data.msg;
|
|
613
|
+
Timeout(function() {
|
|
614
|
+
startInit();
|
|
615
|
+
$scope.loadSync();
|
|
616
|
+
}, 3000, module);
|
|
617
|
+
},
|
|
618
|
+
'error': function(data) {
|
|
619
|
+
$scope.startMessage = data.msg;
|
|
620
|
+
Timeout(function() {
|
|
621
|
+
startInit();
|
|
622
|
+
$scope.loadSync();
|
|
623
|
+
}, 3000, module);
|
|
624
|
+
}
|
|
625
|
+
},
|
|
626
|
+
true
|
|
627
|
+
);
|
|
628
|
+
};
|
|
629
|
+
$scope.ntp_stop = function() {
|
|
630
|
+
$scope.stopMessage = '正在停止,请稍候...'
|
|
631
|
+
$scope.showStopBtn = false;
|
|
632
|
+
Backend.call(
|
|
633
|
+
$scope,
|
|
634
|
+
module,
|
|
635
|
+
'/api/backend/service_stop',
|
|
636
|
+
'/api/backend/service_stop_ntpd', {
|
|
637
|
+
name: 'NTP',
|
|
638
|
+
service: 'ntpd'
|
|
639
|
+
}, {
|
|
640
|
+
'wait': function(data) {
|
|
641
|
+
$scope.stopMessage = data.msg;
|
|
642
|
+
},
|
|
643
|
+
'success': function(data) {
|
|
644
|
+
$scope.stopMessage = data.msg;
|
|
645
|
+
Timeout(function() {
|
|
646
|
+
stopInit();
|
|
647
|
+
$scope.loadSync();
|
|
648
|
+
}, 3000, module);
|
|
649
|
+
},
|
|
650
|
+
'error': function(data) {
|
|
651
|
+
$scope.stopMessage = data.msg;
|
|
652
|
+
Timeout(function() {
|
|
653
|
+
stopInit();
|
|
654
|
+
$scope.loadSync();
|
|
655
|
+
}, 3000, module);
|
|
656
|
+
}
|
|
657
|
+
},
|
|
658
|
+
true
|
|
659
|
+
);
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
];
|
|
663
|
+
|
|
664
|
+
var StorageCtrl = [
|
|
665
|
+
'$scope', 'Module', 'Timeout', 'Request', 'Message', 'Backend',
|
|
666
|
+
function($scope, Module, Timeout, Request, Message, Backend) {
|
|
667
|
+
var module = 'utils.storage';
|
|
668
|
+
Module.init(module, '磁盘管理');
|
|
669
|
+
$scope.loaded = false;
|
|
670
|
+
$scope.waiting = true;
|
|
671
|
+
$scope.init_local = true;
|
|
672
|
+
var section = Module.getSection();
|
|
673
|
+
var enabled_sections = ['local', 'remote'];
|
|
674
|
+
Module.initSection(enabled_sections[0]);
|
|
675
|
+
|
|
676
|
+
$scope.load = function () {
|
|
677
|
+
$scope.loaded = true;
|
|
678
|
+
$scope.tab_sec(section);
|
|
679
|
+
};
|
|
680
|
+
|
|
681
|
+
$scope.tab_sec = function (section) {
|
|
682
|
+
console.log(Module.getSection(), section);
|
|
683
|
+
section = (section && enabled_sections.indexOf(section) > -1) ? section : enabled_sections[0];
|
|
684
|
+
var init = Module.getSection() != section
|
|
685
|
+
$scope.sec(section);
|
|
686
|
+
Module.setSection(section);
|
|
687
|
+
$scope['load_' + section](init);
|
|
688
|
+
};
|
|
689
|
+
|
|
690
|
+
$scope.load_local = function(init) {
|
|
691
|
+
if (!init && !$scope.init_local) {
|
|
692
|
+
return; // Prevent duplicate requests
|
|
693
|
+
}
|
|
694
|
+
$scope.get_diskinfo();
|
|
695
|
+
};
|
|
696
|
+
$scope.load_remote = function(init) {
|
|
697
|
+
console.log('加载网络磁盘', init);
|
|
698
|
+
};
|
|
699
|
+
$scope.get_diskinfo = function () {
|
|
700
|
+
Request.get('/api/query/server.diskinfo', function(data) {
|
|
701
|
+
if (!$scope.loaded) $scope.loaded = true;
|
|
702
|
+
$scope.diskinfo = data['server.diskinfo'];
|
|
703
|
+
$scope.waiting = false;
|
|
704
|
+
if ($scope.init_local) {
|
|
705
|
+
$scope.init_local = false;
|
|
706
|
+
}
|
|
707
|
+
});
|
|
708
|
+
};
|
|
709
|
+
$scope.swaponconfirm = function(devname) {
|
|
710
|
+
$scope.devname = devname;
|
|
711
|
+
$('#swaponconfirm').modal();
|
|
712
|
+
};
|
|
713
|
+
$scope.swapon = function() {
|
|
714
|
+
Backend.call(
|
|
715
|
+
$scope,
|
|
716
|
+
module,
|
|
717
|
+
'/api/backend/swapon',
|
|
718
|
+
'/api/backend/swapon_on_' + $scope.devname, { 'devname': $scope.devname }, { 'success': $scope.get_diskinfo }
|
|
719
|
+
);
|
|
720
|
+
};
|
|
721
|
+
$scope.swapoffconfirm = function(devname) {
|
|
722
|
+
$scope.devname = devname;
|
|
723
|
+
$('#swapoffconfirm').modal();
|
|
724
|
+
};
|
|
725
|
+
$scope.swapoff = function() {
|
|
726
|
+
Backend.call(
|
|
727
|
+
$scope,
|
|
728
|
+
module,
|
|
729
|
+
'/api/backend/swapoff',
|
|
730
|
+
'/api/backend/swapon_off_' + $scope.devname, { 'devname': $scope.devname }, { 'success': $scope.get_diskinfo }
|
|
731
|
+
);
|
|
732
|
+
};
|
|
733
|
+
$scope.umountconfirm = function(devname) {
|
|
734
|
+
$scope.devname = devname;
|
|
735
|
+
$('#umountconfirm').modal();
|
|
736
|
+
};
|
|
737
|
+
$scope.umount = function() {
|
|
738
|
+
Backend.call(
|
|
739
|
+
$scope,
|
|
740
|
+
module,
|
|
741
|
+
'/api/backend/umount',
|
|
742
|
+
'/api/backend/mount_umount_' + $scope.devname, { 'devname': $scope.devname }, { 'success': $scope.get_diskinfo }
|
|
743
|
+
);
|
|
744
|
+
};
|
|
745
|
+
$scope.mountconfirm = function(devname, fstype) {
|
|
746
|
+
$scope.devname = devname;
|
|
747
|
+
$scope.mountpoint = '';
|
|
748
|
+
$scope.fstype = fstype;
|
|
749
|
+
Request.get('/api/query/config.fstab(' + devname + ')', function(data) {
|
|
750
|
+
if (data['config.fstab'] && typeof(data['config.fstab']['mount']) != 'undefined') {
|
|
751
|
+
$scope.mountpoint = data['config.fstab']['mount'];
|
|
752
|
+
}
|
|
753
|
+
});
|
|
754
|
+
$('#mountconfirm').modal();
|
|
755
|
+
};
|
|
756
|
+
$scope.selectmountpoint = function(i) {
|
|
757
|
+
$scope.selector_title = '请选择挂载点';
|
|
758
|
+
$scope.selector.onlydir = true;
|
|
759
|
+
$scope.selector.onlyfile = false;
|
|
760
|
+
$scope.selector.load($scope.mountpoint ? $scope.mountpoint : '/');
|
|
761
|
+
$scope.selector.selecthandler = function(path) {
|
|
762
|
+
$('#selector').modal('hide');
|
|
763
|
+
$scope.mountpoint = path;
|
|
764
|
+
};
|
|
765
|
+
$('#selector').modal();
|
|
766
|
+
};
|
|
767
|
+
$scope.mount = function() {
|
|
768
|
+
Backend.call(
|
|
769
|
+
$scope,
|
|
770
|
+
module,
|
|
771
|
+
'/api/backend/mount',
|
|
772
|
+
'/api/backend/mount_mount_' + $scope.devname, {
|
|
773
|
+
'devname': $scope.devname,
|
|
774
|
+
'mountpoint': $scope.mountpoint,
|
|
775
|
+
'fstype': $scope.fstype
|
|
776
|
+
}, { 'success': $scope.get_diskinfo }
|
|
777
|
+
);
|
|
778
|
+
};
|
|
779
|
+
$scope.formatconfirm = function(devname) {
|
|
780
|
+
$scope.devname = devname;
|
|
781
|
+
Request.get('/api/query/tool.supportfs', function(data) {
|
|
782
|
+
$scope.supportfs = data['tool.supportfs'];
|
|
783
|
+
});
|
|
784
|
+
$('#formatconfirm').modal();
|
|
785
|
+
};
|
|
786
|
+
$scope.format = function() {
|
|
787
|
+
Backend.call(
|
|
788
|
+
$scope,
|
|
789
|
+
module,
|
|
790
|
+
'/api/backend/format',
|
|
791
|
+
'/api/backend/format_' + $scope.devname, {
|
|
792
|
+
'devname': $scope.devname,
|
|
793
|
+
'fstype': $scope.fstype
|
|
794
|
+
}, { 'success': $scope.get_diskinfo }
|
|
795
|
+
);
|
|
796
|
+
};
|
|
797
|
+
$scope.addpartconfirm = function(devname, unpartition) {
|
|
798
|
+
$scope.devname = devname;
|
|
799
|
+
$scope.unpartition = unpartition;
|
|
800
|
+
$('#addpartconfirm').modal();
|
|
801
|
+
};
|
|
802
|
+
$scope.addpart = function() {
|
|
803
|
+
$scope.waiting = true;
|
|
804
|
+
Message.setInfo('正在 ' + $scope.devname + ' 上创建分区,请稍候...', true);
|
|
805
|
+
Request.post('/api/operation/fdisk', {
|
|
806
|
+
'action': 'add',
|
|
807
|
+
'devname': $scope.devname,
|
|
808
|
+
'size': $scope.size,
|
|
809
|
+
'unit': $scope.unit
|
|
810
|
+
}, function(data) {
|
|
811
|
+
if (data.code == 0)
|
|
812
|
+
$scope.get_diskinfo();
|
|
813
|
+
else
|
|
814
|
+
$scope.waiting = false;
|
|
815
|
+
});
|
|
816
|
+
};
|
|
817
|
+
$scope.delpartconfirm = function(devname) {
|
|
818
|
+
$scope.devname = devname;
|
|
819
|
+
$('#delpartconfirm').modal();
|
|
820
|
+
};
|
|
821
|
+
$scope.delpart = function() {
|
|
822
|
+
$scope.waiting = true;
|
|
823
|
+
Message.setInfo('正在删除分区 ' + $scope.devname + ',请稍候...', true);
|
|
824
|
+
Request.post('/api/operation/fdisk', {
|
|
825
|
+
'action': 'delete',
|
|
826
|
+
'devname': $scope.devname
|
|
827
|
+
}, function(data) {
|
|
828
|
+
if (data.code == 0)
|
|
829
|
+
$scope.get_diskinfo();
|
|
830
|
+
else
|
|
831
|
+
$scope.waiting = false;
|
|
832
|
+
});
|
|
833
|
+
};
|
|
834
|
+
$scope.scanpartconfirm = function(devname) {
|
|
835
|
+
$scope.devname = devname;
|
|
836
|
+
$('#scanpartconfirm').modal();
|
|
837
|
+
};
|
|
838
|
+
$scope.scanpart = function() {
|
|
839
|
+
$scope.waiting = true;
|
|
840
|
+
Message.setInfo('正在扫描 ' + $scope.devname + ' 的分区,请稍候...', true);
|
|
841
|
+
Request.post('/api/operation/fdisk', {
|
|
842
|
+
'action': 'scan',
|
|
843
|
+
'devname': $scope.devname
|
|
844
|
+
}, function(data) {
|
|
845
|
+
if (data.code == 0)
|
|
846
|
+
Timeout($scope.get_diskinfo, 1000, module);
|
|
847
|
+
else
|
|
848
|
+
$scope.waiting = false;
|
|
849
|
+
});
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
];
|
|
853
|
+
|
|
854
|
+
var StorageAutoFMCtrl = [
|
|
855
|
+
'$scope', 'Module', 'Timeout', 'Request', 'Message', 'Backend',
|
|
856
|
+
function($scope, Module, Timeout, Request, Message, Backend) {
|
|
857
|
+
var module = 'utils.autofm';
|
|
858
|
+
Module.init(module, '自动格式化挂载');
|
|
859
|
+
$scope.loaded = false;
|
|
860
|
+
$scope.waiting = true;
|
|
861
|
+
$scope.diskcount = 0;
|
|
862
|
+
|
|
863
|
+
$scope.loadDiskinfo = function() {
|
|
864
|
+
Request.get('/api/query/server.diskinfo', function(data) {
|
|
865
|
+
if (!$scope.loaded) $scope.loaded = true;
|
|
866
|
+
$scope.diskinfo = data['server.diskinfo'];
|
|
867
|
+
$scope.waiting = false;
|
|
868
|
+
$scope.diskcount = 0;
|
|
869
|
+
for (var i in data['server.diskinfo']['partitions']) {
|
|
870
|
+
var p = data['server.diskinfo']['partitions'][i];
|
|
871
|
+
if (p.is_hw && !p.is_pv && p.partcount == 0 && !p.mount) {
|
|
872
|
+
$scope.diskcount++;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
});
|
|
876
|
+
};
|
|
877
|
+
$scope.confirm = function(devname) {
|
|
878
|
+
$scope.devname = devname;
|
|
879
|
+
$scope.mountpoint = '';
|
|
880
|
+
$scope.fstype = '';
|
|
881
|
+
// check mount points under /data/
|
|
882
|
+
Request.post('/api/operation/file', {
|
|
883
|
+
'action': 'listdir',
|
|
884
|
+
'path': '/data',
|
|
885
|
+
'showhidden': true,
|
|
886
|
+
'remember': false
|
|
887
|
+
}, function(data) {
|
|
888
|
+
if (data.code == 0) {
|
|
889
|
+
var items = data.data;
|
|
890
|
+
if (items.length == 0) {
|
|
891
|
+
$scope.mountpoint = '/data/0';
|
|
892
|
+
} else {
|
|
893
|
+
var names = {};
|
|
894
|
+
for (var i = 0; i < items.length; i++) {
|
|
895
|
+
names[items[i].name] = true;
|
|
896
|
+
}
|
|
897
|
+
var diski = 0;
|
|
898
|
+
while (1) {
|
|
899
|
+
if (!names['' + diski]) break;
|
|
900
|
+
diski++;
|
|
901
|
+
}
|
|
902
|
+
$scope.mountpoint = '/data/' + diski;
|
|
903
|
+
}
|
|
904
|
+
} else {
|
|
905
|
+
// /data not exists, create it
|
|
906
|
+
Request.post('/api/operation/file', {
|
|
907
|
+
'action': 'createfolder',
|
|
908
|
+
'path': '/',
|
|
909
|
+
'name': 'data'
|
|
910
|
+
});
|
|
911
|
+
$scope.mountpoint = '/data/0';
|
|
912
|
+
}
|
|
913
|
+
}, false, true);
|
|
914
|
+
Request.get('/api/query/tool.supportfs', function(data) {
|
|
915
|
+
var fs = data['tool.supportfs'];
|
|
916
|
+
for (var i = 0; i < fs.length; i++) {
|
|
917
|
+
if (fs[i] == 'swap') fs.splice(i, 1);
|
|
918
|
+
if (fs[i] == 'xfs') $scope.fstype = 'xfs';
|
|
919
|
+
else if (fs[i] == 'ext4') $scope.fstype = 'ext4';
|
|
920
|
+
else if (fs[i] == 'ext3') $scope.fstype = 'ext3';
|
|
921
|
+
}
|
|
922
|
+
$scope.supportfs = fs;
|
|
923
|
+
});
|
|
924
|
+
$('#confirm').modal();
|
|
925
|
+
};
|
|
926
|
+
$scope.selectmountpoint = function(i) {
|
|
927
|
+
$scope.selector_title = '请选择挂载点';
|
|
928
|
+
$scope.selector.onlydir = true;
|
|
929
|
+
$scope.selector.onlyfile = false;
|
|
930
|
+
$scope.selector.load($scope.mountpoint);
|
|
931
|
+
$scope.selector.selecthandler = function(path) {
|
|
932
|
+
$('#selector').modal('hide');
|
|
933
|
+
$scope.mountpoint = path;
|
|
934
|
+
};
|
|
935
|
+
$('#selector').modal();
|
|
936
|
+
};
|
|
937
|
+
$scope.autofm = function() {
|
|
938
|
+
// check the mount point
|
|
939
|
+
Request.post('/api/operation/file', {
|
|
940
|
+
'action': 'listdir',
|
|
941
|
+
'path': $scope.mountpoint,
|
|
942
|
+
'showhidden': true,
|
|
943
|
+
'remember': false
|
|
944
|
+
}, function(data) {
|
|
945
|
+
if (data.code == 0) {
|
|
946
|
+
var items = data.data;
|
|
947
|
+
if (items.length > 0) {
|
|
948
|
+
var mount_detect = false;
|
|
949
|
+
for (var i = 0; i < items.length; i++) {
|
|
950
|
+
if (items[i].name == 'lost+found') {
|
|
951
|
+
mount_detect = true;
|
|
952
|
+
break;
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
if (mount_detect)
|
|
956
|
+
Message.setError('已有其它设备挂载在 ' + $scope.mountpoint + ' 下,请重新选择挂载点。');
|
|
957
|
+
else
|
|
958
|
+
Message.setError('挂载点 ' + $scope.mountpoint + ' 下存在文件或目录,无法挂载!请重新选择挂载点。');
|
|
959
|
+
} else {
|
|
960
|
+
$scope.format();
|
|
961
|
+
}
|
|
962
|
+
} else {
|
|
963
|
+
// mountpoint not exists, create it
|
|
964
|
+
var p = $scope.mountpoint.split('/');
|
|
965
|
+
var name = p.pop();
|
|
966
|
+
var path = p.join('/');
|
|
967
|
+
Request.post('/api/operation/file', {
|
|
968
|
+
'action': 'createfolder',
|
|
969
|
+
'path': path,
|
|
970
|
+
'name': name
|
|
971
|
+
}, $scope.format);
|
|
972
|
+
}
|
|
973
|
+
}, false, true);
|
|
974
|
+
};
|
|
975
|
+
$scope.mount = function() {
|
|
976
|
+
Backend.call(
|
|
977
|
+
$scope,
|
|
978
|
+
module,
|
|
979
|
+
'/api/backend/mount',
|
|
980
|
+
'/api/backend/mount_mount_' + $scope.devname, {
|
|
981
|
+
'devname': $scope.devname,
|
|
982
|
+
'mountpoint': $scope.mountpoint,
|
|
983
|
+
'fstype': $scope.fstype
|
|
984
|
+
}, { 'success': $scope.loadDiskinfo }
|
|
985
|
+
);
|
|
986
|
+
};
|
|
987
|
+
$scope.format = function() {
|
|
988
|
+
Backend.call(
|
|
989
|
+
$scope,
|
|
990
|
+
module,
|
|
991
|
+
'/api/backend/format',
|
|
992
|
+
'/api/backend/format_' + $scope.devname, {
|
|
993
|
+
'devname': $scope.devname,
|
|
994
|
+
'fstype': $scope.fstype
|
|
995
|
+
}, { 'success': $scope.mount }
|
|
996
|
+
);
|
|
997
|
+
};
|
|
998
|
+
}
|
|
999
|
+
];
|
|
1000
|
+
|
|
1001
|
+
var StorageMoveDataCtrl = [
|
|
1002
|
+
'$scope', 'Module', 'Timeout', 'Request', 'Message', 'Backend',
|
|
1003
|
+
function($scope, Module, Timeout, Request, Message, Backend) {
|
|
1004
|
+
var module = 'utils.movedata';
|
|
1005
|
+
Module.init(module, '数据移至数据盘');
|
|
1006
|
+
$scope.loaded = false;
|
|
1007
|
+
$scope.waiting = true;
|
|
1008
|
+
$scope.srcpath = '/var';
|
|
1009
|
+
$scope.despath = '/';
|
|
1010
|
+
$scope.mountpoint = '/';
|
|
1011
|
+
|
|
1012
|
+
$scope.loadMounts = function() {
|
|
1013
|
+
Request.get('/api/query/server.mounts', function(data) {
|
|
1014
|
+
if (!$scope.loaded) $scope.loaded = true;
|
|
1015
|
+
$scope.mounts = data['server.mounts'];
|
|
1016
|
+
$scope.waiting = false;
|
|
1017
|
+
});
|
|
1018
|
+
};
|
|
1019
|
+
$scope.setdespath = function(value) {
|
|
1020
|
+
$scope.despath = value;
|
|
1021
|
+
};
|
|
1022
|
+
$scope.selectsrcpath = function(i) {
|
|
1023
|
+
$scope.selector_title = '请选择要迁移的目录(原始目录)';
|
|
1024
|
+
$scope.selector.onlydir = true;
|
|
1025
|
+
$scope.selector.onlyfile = false;
|
|
1026
|
+
$scope.selector.load($scope.srcpath);
|
|
1027
|
+
$scope.selector.selecthandler = function(path) {
|
|
1028
|
+
$('#selector').modal('hide');
|
|
1029
|
+
$scope.srcpath = path;
|
|
1030
|
+
};
|
|
1031
|
+
$('#selector').modal();
|
|
1032
|
+
};
|
|
1033
|
+
$scope.selectdespath = function(i) {
|
|
1034
|
+
$scope.selector_title = '请选择要迁移到的目录(目标目录)';
|
|
1035
|
+
$scope.selector.onlydir = true;
|
|
1036
|
+
$scope.selector.onlyfile = false;
|
|
1037
|
+
$scope.selector.load($scope.despath);
|
|
1038
|
+
$scope.selector.selecthandler = function(path) {
|
|
1039
|
+
$('#selector').modal('hide');
|
|
1040
|
+
$scope.despath = path;
|
|
1041
|
+
};
|
|
1042
|
+
$('#selector').modal();
|
|
1043
|
+
};
|
|
1044
|
+
$scope.movedata = function() {
|
|
1045
|
+
$scope.waiting = true;
|
|
1046
|
+
var srcpath = $scope.srcpath.replace(/\/$/, '');
|
|
1047
|
+
var srcname = srcpath.split('/').pop();
|
|
1048
|
+
var despath = $scope.despath.replace(/\/$/, '') + '/' + srcname;
|
|
1049
|
+
if (despath == srcpath) {
|
|
1050
|
+
Message.setError('路径没有改变,无须迁移!');
|
|
1051
|
+
$scope.waiting = false;
|
|
1052
|
+
return;
|
|
1053
|
+
}
|
|
1054
|
+
// check the srcpath
|
|
1055
|
+
Message.setInfo('正在检测,请稍候...', true);
|
|
1056
|
+
Request.post('/api/operation/file', {
|
|
1057
|
+
'action': 'getitem',
|
|
1058
|
+
'path': srcpath
|
|
1059
|
+
}, function(data) {
|
|
1060
|
+
if (data.code == 0) {
|
|
1061
|
+
// check if dir or link
|
|
1062
|
+
if (!data.data.isdir) {
|
|
1063
|
+
Message.setError($scope.srcpath + ' 不是有效的目录!(可能是文件或链接)');
|
|
1064
|
+
$scope.waiting = false;
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
1067
|
+
// check the despath
|
|
1068
|
+
Request.post('/api/operation/file', {
|
|
1069
|
+
'action': 'getitem',
|
|
1070
|
+
'path': despath
|
|
1071
|
+
}, function(data) {
|
|
1072
|
+
if (data.code == 0) {
|
|
1073
|
+
Message.setError('目标目录下已有同名文件或目录 ' + despath + ',迁移失败!');
|
|
1074
|
+
$scope.waiting = false;
|
|
1075
|
+
} else {
|
|
1076
|
+
// moving
|
|
1077
|
+
Backend.call(
|
|
1078
|
+
$scope,
|
|
1079
|
+
module,
|
|
1080
|
+
'/api/backend/move',
|
|
1081
|
+
'/api/backend/move_' + srcpath + '_' + despath, {
|
|
1082
|
+
'srcpath': srcpath,
|
|
1083
|
+
'despath': despath
|
|
1084
|
+
}, {
|
|
1085
|
+
'success': function(data) {
|
|
1086
|
+
Message.setInfo('正在原始目录创建链接...');
|
|
1087
|
+
Request.post('/api/operation/file', {
|
|
1088
|
+
'action': 'link',
|
|
1089
|
+
'srcpath': despath,
|
|
1090
|
+
'despath': srcpath
|
|
1091
|
+
}, function(data) {
|
|
1092
|
+
if (data.code == 0) {
|
|
1093
|
+
Message.setSuccess('迁移完成!');
|
|
1094
|
+
} else {
|
|
1095
|
+
Message.setError('迁移失败!' + data.msg);
|
|
1096
|
+
}
|
|
1097
|
+
$scope.waiting = false;
|
|
1098
|
+
}, false, true);
|
|
1099
|
+
},
|
|
1100
|
+
'error': function(data) {
|
|
1101
|
+
Message.setError('迁移过程中发生错误,迁移失败!');
|
|
1102
|
+
$scope.waiting = false;
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
);
|
|
1106
|
+
}
|
|
1107
|
+
}, false, true);
|
|
1108
|
+
}
|
|
1109
|
+
});
|
|
1110
|
+
};
|
|
1111
|
+
}
|
|
1112
|
+
];
|
|
1113
|
+
|
|
1114
|
+
var UtilsSSLCtrl = ['$scope', 'Module', '$routeParams', 'Request', 'Message', 'Backend', 'Timeout',
|
|
1115
|
+
function($scope, Module, $routeParams, Request, Message, Backend, Timeout) {
|
|
1116
|
+
var module = 'utils.ssl';
|
|
1117
|
+
Module.init(module, 'SSL证书管理');
|
|
1118
|
+
var section = Module.getSection();
|
|
1119
|
+
var enabled_sections = ['keys', 'crts', 'csrs', 'host'];
|
|
1120
|
+
Module.initSection(enabled_sections[0]);
|
|
1121
|
+
$scope.installed = false;
|
|
1122
|
+
$scope.loaded = false;
|
|
1123
|
+
$scope.showAlertInfo = true;
|
|
1124
|
+
$scope.loading_keys = true;
|
|
1125
|
+
$scope.loading_crts = true;
|
|
1126
|
+
$scope.loading_csrs = true;
|
|
1127
|
+
$scope.loading_host = true;
|
|
1128
|
+
$scope.list_keys = [];
|
|
1129
|
+
$scope.list_crts = [];
|
|
1130
|
+
$scope.list_csrs = [];
|
|
1131
|
+
$scope.list_host = [];
|
|
1132
|
+
|
|
1133
|
+
$scope.load = function() {
|
|
1134
|
+
$scope.installed = true;
|
|
1135
|
+
$scope.loaded = true;
|
|
1136
|
+
$scope.tab_sec(section);
|
|
1137
|
+
};
|
|
1138
|
+
|
|
1139
|
+
$scope.tab_sec = function (section) {
|
|
1140
|
+
section = (section && enabled_sections.indexOf(section) > -1) ? section : enabled_sections[0];
|
|
1141
|
+
$scope.sec(section);
|
|
1142
|
+
Module.setSection(section);
|
|
1143
|
+
$scope['load_' + section]();
|
|
1144
|
+
};
|
|
1145
|
+
|
|
1146
|
+
$scope.load_keys = function (callback) {
|
|
1147
|
+
$scope.loading_keys = true;
|
|
1148
|
+
Request.get('/api/ssl/keys', function(res) {
|
|
1149
|
+
$scope.loading_keys = false;
|
|
1150
|
+
if (res.list) {
|
|
1151
|
+
$scope.list_keys = res.list;
|
|
1152
|
+
}
|
|
1153
|
+
if (callback) {
|
|
1154
|
+
callback.call();
|
|
1155
|
+
}
|
|
1156
|
+
});
|
|
1157
|
+
};
|
|
1158
|
+
$scope.load_crts = function (callback) {
|
|
1159
|
+
$scope.loading_crts = true;
|
|
1160
|
+
Request.get('/api/ssl/crts', function(res) {
|
|
1161
|
+
$scope.loading_crts = false;
|
|
1162
|
+
if (res.list) {
|
|
1163
|
+
$scope.list_crts = res.list;
|
|
1164
|
+
}
|
|
1165
|
+
if (callback) {
|
|
1166
|
+
callback.call();
|
|
1167
|
+
}
|
|
1168
|
+
});
|
|
1169
|
+
};
|
|
1170
|
+
$scope.load_csrs = function (callback) {
|
|
1171
|
+
$scope.loading_csrs = true;
|
|
1172
|
+
Request.get('/api/ssl/csrs', function(res) {
|
|
1173
|
+
$scope.loading_csrs = false;
|
|
1174
|
+
if (res.list) {
|
|
1175
|
+
$scope.list_csrs = res.list;
|
|
1176
|
+
}
|
|
1177
|
+
if (callback) {
|
|
1178
|
+
callback.call();
|
|
1179
|
+
}
|
|
1180
|
+
});
|
|
1181
|
+
};
|
|
1182
|
+
$scope.load_host = function (callback) {
|
|
1183
|
+
$scope.loading_host = true;
|
|
1184
|
+
Request.get('/api/ssl/host', function(res) {
|
|
1185
|
+
$scope.loading_host = false;
|
|
1186
|
+
if (res.list) {
|
|
1187
|
+
$scope.list_host = res.list;
|
|
1188
|
+
}
|
|
1189
|
+
if (callback) {
|
|
1190
|
+
callback.call();
|
|
1191
|
+
}
|
|
1192
|
+
});
|
|
1193
|
+
};
|
|
1194
|
+
$scope.add_domain_keys = function (callback) {
|
|
1195
|
+
$scope.loading_host = true;
|
|
1196
|
+
Request.post('/api/ssl/keys', {
|
|
1197
|
+
'action': 'add_domain_keys'
|
|
1198
|
+
}, function(res) {
|
|
1199
|
+
// $scope.loading_host = false;
|
|
1200
|
+
if (res) {
|
|
1201
|
+
console.log('创建成功')
|
|
1202
|
+
}
|
|
1203
|
+
if (callback) {
|
|
1204
|
+
callback.call();
|
|
1205
|
+
}
|
|
1206
|
+
});
|
|
1207
|
+
};
|
|
1208
|
+
$scope.keys_check = function (keys, callback) {
|
|
1209
|
+
console.log('keys_check', keys);
|
|
1210
|
+
if (callback) {
|
|
1211
|
+
callback.call();
|
|
1212
|
+
}
|
|
1213
|
+
};
|
|
1214
|
+
$scope.keys_delete = function (keys, confirmed, callback) {
|
|
1215
|
+
if (confirmed && confirmed == true) {
|
|
1216
|
+
console.log('keys_delete', keys);
|
|
1217
|
+
if (callback) {
|
|
1218
|
+
callback.call();
|
|
1219
|
+
}
|
|
1220
|
+
} else {
|
|
1221
|
+
$scope.keys_delete_confirm(keys, callback)
|
|
1222
|
+
}
|
|
1223
|
+
};
|
|
1224
|
+
$scope.keys_delete_confirm = function(keys, callback) {
|
|
1225
|
+
console.log('keys_delete_confirm', keys);
|
|
1226
|
+
$scope.confirm_title = '删除私钥确认';
|
|
1227
|
+
$scope.confirm_body = '<p>删除私钥后,可能会导致对应域名 https 请求出问题!<p><p>确认要删除吗?</p>';
|
|
1228
|
+
$('#confirm').modal();
|
|
1229
|
+
$scope.confirm = function() {
|
|
1230
|
+
$scope.keys_delete(keys, true, callback);
|
|
1231
|
+
};
|
|
1232
|
+
};
|
|
1233
|
+
$scope.crts_check = function (crts, callback) {
|
|
1234
|
+
console.log('crts_check', crts);
|
|
1235
|
+
if (callback) {
|
|
1236
|
+
callback.call();
|
|
1237
|
+
}
|
|
1238
|
+
};
|
|
1239
|
+
$scope.crts_renew = function (crts, callback) {
|
|
1240
|
+
console.log('crts_renew', crts);
|
|
1241
|
+
if (callback) {
|
|
1242
|
+
callback.call();
|
|
1243
|
+
}
|
|
1244
|
+
};
|
|
1245
|
+
$scope.crts_revoke = function (crts, confirmed, callback) {
|
|
1246
|
+
if (confirmed && confirmed == true) {
|
|
1247
|
+
console.log('crts_revoke', crts);
|
|
1248
|
+
if (callback) {
|
|
1249
|
+
callback.call();
|
|
1250
|
+
}
|
|
1251
|
+
} else {
|
|
1252
|
+
$scope.crts_revoke_confirm(crts, callback)
|
|
1253
|
+
}
|
|
1254
|
+
};
|
|
1255
|
+
$scope.crts_revoke_confirm = function(crts, callback) {
|
|
1256
|
+
console.log('crts_delete_confirm', crts);
|
|
1257
|
+
$scope.confirm_title = '吊销证书';
|
|
1258
|
+
$scope.confirm_body = '<p>吊销此证书后,会导致对应域名的 HTTPS 请求出问题!<p><p>确定要吊销吗?</p>';
|
|
1259
|
+
$('#confirm').modal();
|
|
1260
|
+
$scope.confirm = function() {
|
|
1261
|
+
$scope.crts_revoke(crts, true, callback);
|
|
1262
|
+
};
|
|
1263
|
+
};
|
|
1264
|
+
$scope.crts_delete = function (crts, confirmed, callback) {
|
|
1265
|
+
if (confirmed && confirmed == true) {
|
|
1266
|
+
console.log('crts_delete', crts);
|
|
1267
|
+
if (callback) {
|
|
1268
|
+
callback.call();
|
|
1269
|
+
}
|
|
1270
|
+
} else {
|
|
1271
|
+
$scope.crts_delete_confirm(crts, callback)
|
|
1272
|
+
}
|
|
1273
|
+
};
|
|
1274
|
+
$scope.crts_delete_confirm = function(crts, callback) {
|
|
1275
|
+
console.log('crts_delete_confirm', crts);
|
|
1276
|
+
$scope.confirm_title = '删除证书';
|
|
1277
|
+
$scope.confirm_body = '<p>删除证书后,会导致对应域名的 HTTPS 请求出问题!<p><p>确定要删除吗?</p>';
|
|
1278
|
+
$('#confirm').modal();
|
|
1279
|
+
$scope.confirm = function() {
|
|
1280
|
+
$scope.crts_delete(crts, true, callback);
|
|
1281
|
+
};
|
|
1282
|
+
};
|
|
1283
|
+
}
|
|
1284
|
+
];
|
|
1285
|
+
|
|
1286
|
+
var StorageRemoteCtrl = [
|
|
1287
|
+
'$scope', 'Module', '$routeParams', 'Timeout', 'Request', 'Message', 'Backend', '$location',
|
|
1288
|
+
function($scope, Module, $routeParams,Timeout, Request, Message, Backend, $location) {
|
|
1289
|
+
var module = 'utils.remote';
|
|
1290
|
+
Module.init(module, '网络磁盘');
|
|
1291
|
+
$scope.loaded = false;
|
|
1292
|
+
$scope.loading_info = true;
|
|
1293
|
+
$scope.action = '';
|
|
1294
|
+
$scope.protocol = 'ftp';
|
|
1295
|
+
$scope.storage_info = {
|
|
1296
|
+
'name': '',
|
|
1297
|
+
'address': '',
|
|
1298
|
+
'account': '',
|
|
1299
|
+
'password': '',
|
|
1300
|
+
'protocol': ''
|
|
1301
|
+
};
|
|
1302
|
+
$scope.checking_davfs2 = true;
|
|
1303
|
+
$scope.status_davfs2 = null;
|
|
1304
|
+
console.log('action', $routeParams.action)
|
|
1305
|
+
if ($routeParams.section && $routeParams.section.indexOf('edit_') == 0) {
|
|
1306
|
+
$scope.action = 'edit';
|
|
1307
|
+
} else {
|
|
1308
|
+
$scope.action = 'new';
|
|
1309
|
+
$scope.loading_info = false;
|
|
1310
|
+
}
|
|
1311
|
+
$scope.load = function () {
|
|
1312
|
+
$scope.loaded = true;
|
|
1313
|
+
if ($scope.action == 'edit') {
|
|
1314
|
+
$scope.load_info();
|
|
1315
|
+
}
|
|
1316
|
+
};
|
|
1317
|
+
$scope.load_info = function () {
|
|
1318
|
+
var tmp = $routeParams.section.split('_');
|
|
1319
|
+
// console.log(tmp);
|
|
1320
|
+
$scope.protocol = tmp[1];
|
|
1321
|
+
Timeout(function() {
|
|
1322
|
+
$scope.loading_info = false;
|
|
1323
|
+
// $scope.storage_info['name'] = '坚果云测试用';
|
|
1324
|
+
}, 600, module);
|
|
1325
|
+
};
|
|
1326
|
+
$scope.storage_add = function () {
|
|
1327
|
+
if ($scope.protocol == 'webdav') {
|
|
1328
|
+
console.log('storage_add/webdav');
|
|
1329
|
+
// if (!$scope.status_davfs2) {
|
|
1330
|
+
// $scope.loadDavfs2($scope.storage_add);
|
|
1331
|
+
// return;
|
|
1332
|
+
// }
|
|
1333
|
+
if (!$scope.protocol || !$scope.storage_info['address']) {
|
|
1334
|
+
return;
|
|
1335
|
+
}
|
|
1336
|
+
var data = {
|
|
1337
|
+
'name': $scope.storage_info['name'],
|
|
1338
|
+
'address': $scope.storage_info['address'],
|
|
1339
|
+
'account': $scope.storage_info['account'],
|
|
1340
|
+
'password': $scope.storage_info['password'],
|
|
1341
|
+
'protocol': $scope.protocol,
|
|
1342
|
+
};
|
|
1343
|
+
console.log('提交数据', data);
|
|
1344
|
+
Timeout(function() {
|
|
1345
|
+
$scope.loading_info = false;
|
|
1346
|
+
// $scope.storage_info['name'] = '_test';
|
|
1347
|
+
$location.path('/storage/remote/edit_' + encodeURIComponent(data.protocol + '_' + data.address));
|
|
1348
|
+
}, 600, module);
|
|
1349
|
+
}
|
|
1350
|
+
};
|
|
1351
|
+
$scope.storage_update = function () {
|
|
1352
|
+
console.log('保存');
|
|
1353
|
+
};
|
|
1354
|
+
|
|
1355
|
+
$scope.loadDavfs2 = function(callback) {
|
|
1356
|
+
Request.get('/api/query/service.davfs2', function(data) {
|
|
1357
|
+
$scope.checking_davfs2 = false;
|
|
1358
|
+
if (data['service.davfs2']) {
|
|
1359
|
+
$scope.status_davfs2 = data['service.davfs2']['status'];
|
|
1360
|
+
if (callback) {
|
|
1361
|
+
callback();
|
|
1362
|
+
};
|
|
1363
|
+
} else {
|
|
1364
|
+
$scope.installMessage = 'WebDAV 需要使用 davfs2 服务,您当前尚未安装该服务。<br>是否安装 ?';
|
|
1365
|
+
$scope.showInstallBtn = true;
|
|
1366
|
+
}
|
|
1367
|
+
});
|
|
1368
|
+
};
|
|
1369
|
+
$scope.install_davfs2 = function() {
|
|
1370
|
+
$scope.installMessage = '正在安装支持,请稍候...'
|
|
1371
|
+
$scope.showInstallBtn = false;
|
|
1372
|
+
Backend.call(
|
|
1373
|
+
$scope,
|
|
1374
|
+
module,
|
|
1375
|
+
'/api/backend/yum_install',
|
|
1376
|
+
'/api/backend/yum_install_epel_davfs2', {
|
|
1377
|
+
'repo': 'epel',
|
|
1378
|
+
'pkg': 'davfs2'
|
|
1379
|
+
}, {
|
|
1380
|
+
'wait': function(data) {
|
|
1381
|
+
$scope.installMessage = data.msg;
|
|
1382
|
+
},
|
|
1383
|
+
'success': function(data) {
|
|
1384
|
+
$scope.installMessage = data.msg;
|
|
1385
|
+
Timeout($scope.loadDavfs2, 3000, module);
|
|
1386
|
+
},
|
|
1387
|
+
'error': function(data) {
|
|
1388
|
+
$scope.installMessage = data.msg;
|
|
1389
|
+
Timeout($scope.loadDavfs2, 3000, module);
|
|
1390
|
+
}
|
|
1391
|
+
},
|
|
1392
|
+
true
|
|
1393
|
+
);
|
|
1394
|
+
};
|
|
1395
|
+
$scope.start_davfs2 = function() {
|
|
1396
|
+
$scope.startMessage = '正在启动,请稍候...'
|
|
1397
|
+
$scope.showStartBtn = false;
|
|
1398
|
+
Backend.call(
|
|
1399
|
+
$scope,
|
|
1400
|
+
module,
|
|
1401
|
+
'/api/backend/service_start',
|
|
1402
|
+
'/api/backend/service_start_davfs2', {
|
|
1403
|
+
name: 'Davfs2',
|
|
1404
|
+
service: 'davfs2'
|
|
1405
|
+
}, {
|
|
1406
|
+
'wait': function(data) {
|
|
1407
|
+
$scope.startMessage = data.msg;
|
|
1408
|
+
},
|
|
1409
|
+
'success': function(data) {
|
|
1410
|
+
$scope.startMessage = data.msg;
|
|
1411
|
+
Timeout(function() {
|
|
1412
|
+
// startInit();
|
|
1413
|
+
$scope.loadDavfs2();
|
|
1414
|
+
}, 3000, module);
|
|
1415
|
+
},
|
|
1416
|
+
'error': function(data) {
|
|
1417
|
+
$scope.startMessage = data.msg;
|
|
1418
|
+
Timeout(function() {
|
|
1419
|
+
// startInit();
|
|
1420
|
+
$scope.loadDavfs2();
|
|
1421
|
+
}, 3000, module);
|
|
1422
|
+
}
|
|
1423
|
+
},
|
|
1424
|
+
true
|
|
1425
|
+
);
|
|
1426
|
+
};
|
|
1427
|
+
|
|
1428
|
+
}
|
|
1429
|
+
];
|
|
1430
|
+
|
|
1431
|
+
var UtilsRepositoryCtrl = [
|
|
1432
|
+
'$scope', 'Module', '$routeParams', 'Timeout', 'Request', 'Message', 'Backend', '$location',
|
|
1433
|
+
function($scope, Module, $routeParams, Timeout, Request, Message, Backend, $location) {
|
|
1434
|
+
var module = 'utils.repository';
|
|
1435
|
+
Module.init(module, '软件仓库');
|
|
1436
|
+
$scope.loaded = false;
|
|
1437
|
+
$scope.action = '';
|
|
1438
|
+
var section = Module.getSection();
|
|
1439
|
+
var enabled_sections = ['yum', 'apt', 'pacman', 'dnf', 'zypper'];
|
|
1440
|
+
Module.initSection(enabled_sections[0]);
|
|
1441
|
+
$scope.loading = {
|
|
1442
|
+
yum: true,
|
|
1443
|
+
apt: true,
|
|
1444
|
+
pacman: true,
|
|
1445
|
+
dnf: true,
|
|
1446
|
+
zypper: true
|
|
1447
|
+
};
|
|
1448
|
+
$scope.supported = {
|
|
1449
|
+
yum: true,
|
|
1450
|
+
apt: false,
|
|
1451
|
+
pacman: false,
|
|
1452
|
+
dnf: false,
|
|
1453
|
+
zypper: false
|
|
1454
|
+
};
|
|
1455
|
+
$scope.load = function () {
|
|
1456
|
+
$scope.loaded = true;
|
|
1457
|
+
$scope.tab_sec(section);
|
|
1458
|
+
};
|
|
1459
|
+
|
|
1460
|
+
$scope.tab_sec = function (section) {
|
|
1461
|
+
var init = Module.getSection() != section
|
|
1462
|
+
section = (section && enabled_sections.indexOf(section) > -1) ? section : enabled_sections[0];
|
|
1463
|
+
$scope.sec(section);
|
|
1464
|
+
Module.setSection(section);
|
|
1465
|
+
$scope['load_' + section](init);
|
|
1466
|
+
};
|
|
1467
|
+
$scope.load_yum = function (init) {
|
|
1468
|
+
if (!init && !$scope.loading.yum) {
|
|
1469
|
+
return;
|
|
1470
|
+
}
|
|
1471
|
+
$scope.loading.yum = true;
|
|
1472
|
+
$scope.repos_yum = [];
|
|
1473
|
+
Request.get('/api/repos/yum/list', function (res) {
|
|
1474
|
+
$scope.loading.yum = false;
|
|
1475
|
+
if (res && res.code == 0) {
|
|
1476
|
+
$scope.repos_yum = res.data;
|
|
1477
|
+
}
|
|
1478
|
+
});
|
|
1479
|
+
};
|
|
1480
|
+
$scope.load_apt = function (init) {
|
|
1481
|
+
if (!init && !$scope.loading.apt) {
|
|
1482
|
+
return;
|
|
1483
|
+
}
|
|
1484
|
+
$scope.loading.apt = true;
|
|
1485
|
+
$scope.repos_apt = [];
|
|
1486
|
+
Request.get('/api/repos/apt/list', function (res) {
|
|
1487
|
+
$scope.loading.apt = false;
|
|
1488
|
+
if (res && res.code == 0) {
|
|
1489
|
+
$scope.repos_apt = res.data;
|
|
1490
|
+
}
|
|
1491
|
+
});
|
|
1492
|
+
};
|
|
1493
|
+
$scope.load_pacman = function (init) {
|
|
1494
|
+
if (!init && !$scope.loading.pacman) {
|
|
1495
|
+
return;
|
|
1496
|
+
}
|
|
1497
|
+
$scope.loading.pacman = true;
|
|
1498
|
+
$scope.repos_pacman = [];
|
|
1499
|
+
Request.get('/api/repos/pacman/list', function (res) {
|
|
1500
|
+
$scope.loading.pacman = false;
|
|
1501
|
+
if (res && res.code == 0) {
|
|
1502
|
+
$scope.repos_pacman = res.data;
|
|
1503
|
+
}
|
|
1504
|
+
});
|
|
1505
|
+
};
|
|
1506
|
+
$scope.load_dnf = function (init) {
|
|
1507
|
+
if (!init && !$scope.loading.dnf) {
|
|
1508
|
+
return;
|
|
1509
|
+
}
|
|
1510
|
+
$scope.loading.dnf = true;
|
|
1511
|
+
$scope.repos_dnf = [];
|
|
1512
|
+
Request.get('/api/repos/dnf/list', function (res) {
|
|
1513
|
+
$scope.loading.dnf = false;
|
|
1514
|
+
if (res && res.code == 0) {
|
|
1515
|
+
$scope.repos_dnf = res.data;
|
|
1516
|
+
}
|
|
1517
|
+
});
|
|
1518
|
+
};
|
|
1519
|
+
$scope.load_zypper = function (init) {
|
|
1520
|
+
if (!init && !$scope.loading.zypper) {
|
|
1521
|
+
return;
|
|
1522
|
+
}
|
|
1523
|
+
$scope.loading.zypper = true;
|
|
1524
|
+
$scope.repos_zypper = [];
|
|
1525
|
+
Request.get('/api/repos/zypper/list', function (res) {
|
|
1526
|
+
$scope.loading.zypper = false;
|
|
1527
|
+
if (res && res.code == 0) {
|
|
1528
|
+
$scope.repos_zypper = res.data;
|
|
1529
|
+
}
|
|
1530
|
+
});
|
|
1531
|
+
};
|
|
1532
|
+
|
|
1533
|
+
$scope.yum_add_confirm = function() {
|
|
1534
|
+
$scope.currepo = {
|
|
1535
|
+
'serverid': '',
|
|
1536
|
+
'name': '',
|
|
1537
|
+
'enabled': 1,
|
|
1538
|
+
'baseurl': '',
|
|
1539
|
+
'gpgcheck': 0,
|
|
1540
|
+
'repo': ''
|
|
1541
|
+
};
|
|
1542
|
+
$('#yum-add-confirm').modal();
|
|
1543
|
+
};
|
|
1544
|
+
$scope.yum_add = function() {
|
|
1545
|
+
Request.post('/api/repos/yum/add', $scope.currepo, function(data) {
|
|
1546
|
+
if (data.code == 0) {
|
|
1547
|
+
$scope.load_yum(true);
|
|
1548
|
+
}
|
|
1549
|
+
});
|
|
1550
|
+
};
|
|
1551
|
+
|
|
1552
|
+
$scope.yum_mod_confirm = function(i) {
|
|
1553
|
+
var repo = $scope.repos_yum[i];
|
|
1554
|
+
Request.get('/api/repos/yum/item', {repo: repo}, function(res) {
|
|
1555
|
+
if (res && res.code == 0) {
|
|
1556
|
+
var data = res.data;
|
|
1557
|
+
var id = Object.keys(data)[0];
|
|
1558
|
+
$scope.currepo = {
|
|
1559
|
+
'serverid': id,
|
|
1560
|
+
'name': data[id].name || '',
|
|
1561
|
+
'enabled': data[id].enabled || 1,
|
|
1562
|
+
'baseurl': data[id].baseurl || '',
|
|
1563
|
+
'gpgcheck': data[id].gpgcheck || 0,
|
|
1564
|
+
'repo': repo
|
|
1565
|
+
};
|
|
1566
|
+
$('#yum-add-confirm').modal();
|
|
1567
|
+
}
|
|
1568
|
+
});
|
|
1569
|
+
};
|
|
1570
|
+
|
|
1571
|
+
$scope.yum_del_confirm = function(i) {
|
|
1572
|
+
$scope.delrepo = $scope.repos_yum[i];
|
|
1573
|
+
$('#yum-del-confirm').modal();
|
|
1574
|
+
};
|
|
1575
|
+
$scope.yum_del = function() {
|
|
1576
|
+
Request.post('/api/repos/yum/del', {
|
|
1577
|
+
repo: $scope.delrepo
|
|
1578
|
+
}, function(data) {
|
|
1579
|
+
if (data.code == 0) {
|
|
1580
|
+
$scope.load_yum(true);
|
|
1581
|
+
}
|
|
1582
|
+
});
|
|
1583
|
+
};
|
|
1584
|
+
|
|
1585
|
+
$scope.dnf_add_confirm = function() {
|
|
1586
|
+
$scope.curdnf = {
|
|
1587
|
+
'serverid': '',
|
|
1588
|
+
'name': '',
|
|
1589
|
+
'enabled': 1,
|
|
1590
|
+
'baseurl': '',
|
|
1591
|
+
'gpgcheck': 0,
|
|
1592
|
+
'repo': ''
|
|
1593
|
+
};
|
|
1594
|
+
$('#dnf-add-confirm').modal();
|
|
1595
|
+
};
|
|
1596
|
+
$scope.dnf_add = function() {
|
|
1597
|
+
Request.post('/api/repos/dnf/add', $scope.curdnf, function(data) {
|
|
1598
|
+
if (data.code == 0) {
|
|
1599
|
+
$scope.load_dnf(true);
|
|
1600
|
+
}
|
|
1601
|
+
});
|
|
1602
|
+
};
|
|
1603
|
+
|
|
1604
|
+
$scope.dnf_mod_confirm = function(i) {
|
|
1605
|
+
var repo = $scope.repos_dnf[i];
|
|
1606
|
+
Request.get('/api/repos/dnf/item', {repo: repo}, function(res) {
|
|
1607
|
+
if (res && res.code == 0) {
|
|
1608
|
+
var data = res.data;
|
|
1609
|
+
var id = Object.keys(data)[0];
|
|
1610
|
+
$scope.curdnf = {
|
|
1611
|
+
'serverid': id,
|
|
1612
|
+
'name': data[id].name || '',
|
|
1613
|
+
'enabled': data[id].enabled || 1,
|
|
1614
|
+
'baseurl': data[id].baseurl || '',
|
|
1615
|
+
'gpgcheck': data[id].gpgcheck || 0,
|
|
1616
|
+
'repo': repo
|
|
1617
|
+
};
|
|
1618
|
+
$('#dnf-add-confirm').modal();
|
|
1619
|
+
}
|
|
1620
|
+
});
|
|
1621
|
+
};
|
|
1622
|
+
|
|
1623
|
+
$scope.dnf_del_confirm = function(i) {
|
|
1624
|
+
$scope.deldnf = $scope.repos_dnf[i];
|
|
1625
|
+
$('#dnf-del-confirm').modal();
|
|
1626
|
+
};
|
|
1627
|
+
$scope.dnf_del = function() {
|
|
1628
|
+
Request.post('/api/repos/dnf/del', {
|
|
1629
|
+
repo: $scope.deldnf
|
|
1630
|
+
}, function(data) {
|
|
1631
|
+
if (data.code == 0) {
|
|
1632
|
+
$scope.load_dnf(true);
|
|
1633
|
+
}
|
|
1634
|
+
});
|
|
1635
|
+
};
|
|
1636
|
+
|
|
1637
|
+
$scope.apt_add_confirm = function() {
|
|
1638
|
+
$scope.curapt = {
|
|
1639
|
+
'source': '',
|
|
1640
|
+
'content': ''
|
|
1641
|
+
};
|
|
1642
|
+
$('#apt-add-confirm').modal();
|
|
1643
|
+
};
|
|
1644
|
+
$scope.apt_add = function() {
|
|
1645
|
+
Request.post('/api/repos/apt/add', $scope.curapt, function(data) {
|
|
1646
|
+
if (data.code == 0) {
|
|
1647
|
+
$scope.load_apt(true);
|
|
1648
|
+
}
|
|
1649
|
+
});
|
|
1650
|
+
};
|
|
1651
|
+
|
|
1652
|
+
$scope.apt_mod_confirm = function(i) {
|
|
1653
|
+
var source = $scope.repos_apt[i];
|
|
1654
|
+
Request.get('/api/repos/apt/item', {source: source}, function(res) {
|
|
1655
|
+
if (res && res.code == 0) {
|
|
1656
|
+
$scope.curapt = {
|
|
1657
|
+
'source': source,
|
|
1658
|
+
'content': res.data.content || ''
|
|
1659
|
+
};
|
|
1660
|
+
$('#apt-add-confirm').modal();
|
|
1661
|
+
}
|
|
1662
|
+
});
|
|
1663
|
+
};
|
|
1664
|
+
|
|
1665
|
+
$scope.apt_del_confirm = function(i) {
|
|
1666
|
+
$scope.delapt = $scope.repos_apt[i];
|
|
1667
|
+
$('#apt-del-confirm').modal();
|
|
1668
|
+
};
|
|
1669
|
+
$scope.apt_del = function() {
|
|
1670
|
+
Request.post('/api/repos/apt/del', {
|
|
1671
|
+
source: $scope.delapt
|
|
1672
|
+
}, function(data) {
|
|
1673
|
+
if (data.code == 0) {
|
|
1674
|
+
$scope.load_apt(true);
|
|
1675
|
+
}
|
|
1676
|
+
});
|
|
1677
|
+
};
|
|
1678
|
+
}
|
|
1679
|
+
];
|
|
1680
|
+
|
|
1681
|
+
var UtilsCronCtrl = ['$scope', 'Module', 'Request', 'Timeout',
|
|
1682
|
+
function ($scope, Module, Request, Timeout) {
|
|
1683
|
+
var module = 'utils.cron';
|
|
1684
|
+
Module.init(module, '定时任务');
|
|
1685
|
+
var section = Module.getSection();
|
|
1686
|
+
var enabled_sections = ['normal', 'system', 'environment', 'local'];
|
|
1687
|
+
Module.initSection(enabled_sections[0]);
|
|
1688
|
+
$scope.loaded = false;
|
|
1689
|
+
$scope.cron_normal = {
|
|
1690
|
+
user: 'root',
|
|
1691
|
+
list: []
|
|
1692
|
+
};
|
|
1693
|
+
$scope.cron_system = {
|
|
1694
|
+
user: '',
|
|
1695
|
+
list: []
|
|
1696
|
+
};
|
|
1697
|
+
$scope.has_cron_service = false;
|
|
1698
|
+
|
|
1699
|
+
$scope.load = function () {
|
|
1700
|
+
Request.get('/api/query/service.crond', function(data) {
|
|
1701
|
+
if (data['service.crond'] && data['service.crond'].status) {
|
|
1702
|
+
$scope.has_cron_service = true;
|
|
1703
|
+
}
|
|
1704
|
+
$scope.tab_sec(section);
|
|
1705
|
+
$scope.loaded = true;
|
|
1706
|
+
$scope.load_user();
|
|
1707
|
+
});
|
|
1708
|
+
};
|
|
1709
|
+
|
|
1710
|
+
$scope.tab_sec = function (section) {
|
|
1711
|
+
var init = Module.getSection() != section
|
|
1712
|
+
section = (section && enabled_sections.indexOf(section) > -1) ? section : enabled_sections[0];
|
|
1713
|
+
$scope.sec(section);
|
|
1714
|
+
Module.setSection(section);
|
|
1715
|
+
$scope['load_' + section](init);
|
|
1716
|
+
};
|
|
1717
|
+
|
|
1718
|
+
$scope.common_options = '';
|
|
1719
|
+
$scope.cron_time = {
|
|
1720
|
+
minute: '',
|
|
1721
|
+
hour: '',
|
|
1722
|
+
day: '',
|
|
1723
|
+
month: '',
|
|
1724
|
+
weekday: ''
|
|
1725
|
+
};
|
|
1726
|
+
$scope.options = {
|
|
1727
|
+
minute: '',
|
|
1728
|
+
hour: '',
|
|
1729
|
+
day: '',
|
|
1730
|
+
month: '',
|
|
1731
|
+
weekday: ''
|
|
1732
|
+
};
|
|
1733
|
+
|
|
1734
|
+
$scope.task_id = '';
|
|
1735
|
+
$scope.task_time = '';
|
|
1736
|
+
$scope.task_user = '';
|
|
1737
|
+
$scope.task_level = '';
|
|
1738
|
+
$scope.task_email = '';
|
|
1739
|
+
$scope.task_command = '';
|
|
1740
|
+
|
|
1741
|
+
$scope.first = {
|
|
1742
|
+
normal: true,
|
|
1743
|
+
system: true,
|
|
1744
|
+
environment: true,
|
|
1745
|
+
local: true
|
|
1746
|
+
};
|
|
1747
|
+
$scope.load_normal = function (init) {
|
|
1748
|
+
if (init || $scope.first.normal) {
|
|
1749
|
+
$scope.load_normal_list();
|
|
1750
|
+
}
|
|
1751
|
+
};
|
|
1752
|
+
$scope.load_system = function (init) {
|
|
1753
|
+
if (init || $scope.first.system) {
|
|
1754
|
+
$scope.load_system_list();
|
|
1755
|
+
}
|
|
1756
|
+
};
|
|
1757
|
+
$scope.load_environment = function (init) {
|
|
1758
|
+
if (init || $scope.first.environment) {
|
|
1759
|
+
$scope.load_environment_list();
|
|
1760
|
+
}
|
|
1761
|
+
};
|
|
1762
|
+
$scope.load_local = function (init) {
|
|
1763
|
+
if (init || $scope.first.local) {
|
|
1764
|
+
$scope.load_local_list();
|
|
1765
|
+
}
|
|
1766
|
+
};
|
|
1767
|
+
|
|
1768
|
+
$scope.loading = {
|
|
1769
|
+
normal: false,
|
|
1770
|
+
system: false,
|
|
1771
|
+
environment: false,
|
|
1772
|
+
local: false
|
|
1773
|
+
};
|
|
1774
|
+
$scope.load_normal_list = function () {
|
|
1775
|
+
if (!$scope.has_cron_service || $scope.loading.normal) return; // Prevent duplicate requests
|
|
1776
|
+
$scope.loading.normal = true;
|
|
1777
|
+
$scope.first.normal = false;
|
|
1778
|
+
Request.post('/api/operation/cron', {
|
|
1779
|
+
'action': 'cron_list',
|
|
1780
|
+
'user': $scope.cron_normal.user,
|
|
1781
|
+
'level': 'normal'
|
|
1782
|
+
}, function (data) {
|
|
1783
|
+
$scope.loading.normal = false;
|
|
1784
|
+
if (data.code == 0) {
|
|
1785
|
+
$scope.cron_normal.list = data.data;
|
|
1786
|
+
}
|
|
1787
|
+
}, false, true);
|
|
1788
|
+
};
|
|
1789
|
+
$scope.load_system_list = function () {
|
|
1790
|
+
if (!$scope.has_cron_service || $scope.loading.system) return; // Prevent duplicate requests
|
|
1791
|
+
$scope.loading.system = true;
|
|
1792
|
+
$scope.first.system = false;
|
|
1793
|
+
Request.post('/api/operation/cron', {
|
|
1794
|
+
'action': 'cron_list',
|
|
1795
|
+
'user': $scope.cron_system.user,
|
|
1796
|
+
'level': 'system',
|
|
1797
|
+
}, function (data) {
|
|
1798
|
+
$scope.loading.system = false;
|
|
1799
|
+
if (data.code == 0) {
|
|
1800
|
+
$scope.cron_system.list = data.data;
|
|
1801
|
+
}
|
|
1802
|
+
}, false, true);
|
|
1803
|
+
};
|
|
1804
|
+
$scope.load_environment_list = function () {
|
|
1805
|
+
if (!$scope.has_cron_service || $scope.loading.environment) return; // Prevent duplicate requests
|
|
1806
|
+
$scope.loading.environment = true;
|
|
1807
|
+
$scope.first.environment = false;
|
|
1808
|
+
Timeout(function() {
|
|
1809
|
+
$scope.loading.environment = false;
|
|
1810
|
+
}, 500, module);
|
|
1811
|
+
// Request.post('/api/operation/cron', {'action': 'cron_list'}, function (data) {
|
|
1812
|
+
// $scope.loading.environment = false;
|
|
1813
|
+
// if (data.code == 0) {}
|
|
1814
|
+
// }, false, true);
|
|
1815
|
+
};
|
|
1816
|
+
$scope.load_local_list = function () {
|
|
1817
|
+
if (!$scope.has_cron_service || $scope.loading.local) return; // Prevent duplicate requests
|
|
1818
|
+
$scope.loading.local = true;
|
|
1819
|
+
$scope.first.local = false;
|
|
1820
|
+
Timeout(function() {
|
|
1821
|
+
$scope.loading.local = false;
|
|
1822
|
+
}, 500, module);
|
|
1823
|
+
// Request.post('/api/operation/cron', {'action': 'cron_list'}, function (data) {
|
|
1824
|
+
// $scope.loading.local = false;
|
|
1825
|
+
// if (data.code == 0) {}
|
|
1826
|
+
// }, false, true);
|
|
1827
|
+
};
|
|
1828
|
+
|
|
1829
|
+
$scope.$watch('cron_time', function (n) {
|
|
1830
|
+
$scope.task_time = n.minute + ' ' + n.hour + ' ' + n.day + ' ' + n.month + ' ' + n.weekday;
|
|
1831
|
+
}, true);
|
|
1832
|
+
$scope.select_common_option = function () {
|
|
1833
|
+
var option = $scope.common_options;
|
|
1834
|
+
if (option && option != '') {
|
|
1835
|
+
var option_array = option.split(' ');
|
|
1836
|
+
|
|
1837
|
+
$scope.cron_time.minute = option_array[0];
|
|
1838
|
+
$scope.cron_time.hour = option_array[1];
|
|
1839
|
+
$scope.cron_time.day = option_array[2];
|
|
1840
|
+
$scope.cron_time.month = option_array[3];
|
|
1841
|
+
$scope.cron_time.weekday = option_array[4];
|
|
1842
|
+
|
|
1843
|
+
$scope.options.minute = option_array[0];
|
|
1844
|
+
$scope.options.hour = option_array[1];
|
|
1845
|
+
$scope.options.day = option_array[2];
|
|
1846
|
+
$scope.options.month = option_array[3];
|
|
1847
|
+
$scope.options.weekday = option_array[4];
|
|
1848
|
+
} else {
|
|
1849
|
+
for (var i in $scope.cron_time) {
|
|
1850
|
+
$scope.cron_time[i] = ''
|
|
1851
|
+
}
|
|
1852
|
+
for (var j in $scope.options) {
|
|
1853
|
+
$scope.options[j] = ''
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
};
|
|
1857
|
+
$scope.input_single_option = function (type) {
|
|
1858
|
+
if (typeof type === 'undefined' || type === '') {
|
|
1859
|
+
return;
|
|
1860
|
+
};
|
|
1861
|
+
$scope.options[type] = $scope.cron_time[type];
|
|
1862
|
+
};
|
|
1863
|
+
$scope.select_single_option = function (type) {
|
|
1864
|
+
if (typeof type === 'undefined' || type === '') {
|
|
1865
|
+
return;
|
|
1866
|
+
};
|
|
1867
|
+
$scope.cron_time[type] = $scope.options[type];
|
|
1868
|
+
};
|
|
1869
|
+
|
|
1870
|
+
$scope.load_user = function () {
|
|
1871
|
+
Request.post('/api/operation/user', {
|
|
1872
|
+
'action': 'listuser',
|
|
1873
|
+
'fullinfo': false
|
|
1874
|
+
}, function (data) {
|
|
1875
|
+
if (data.code == 0) {
|
|
1876
|
+
$scope.users = data.data;
|
|
1877
|
+
}
|
|
1878
|
+
}, false, true);
|
|
1879
|
+
};
|
|
1880
|
+
$scope.add_cron_normal = function() {
|
|
1881
|
+
$scope.form_clear();
|
|
1882
|
+
$scope.task_user = $scope.cron_normal.user || "";
|
|
1883
|
+
$scope.task_level = 'normal';
|
|
1884
|
+
$('#cron-add-confirm').modal();
|
|
1885
|
+
};
|
|
1886
|
+
$scope.add_cron_system = function() {
|
|
1887
|
+
$scope.form_clear();
|
|
1888
|
+
$scope.task_user = $scope.cron_system.user || "";
|
|
1889
|
+
$scope.task_level = 'system';
|
|
1890
|
+
$('#cron-add-confirm').modal();
|
|
1891
|
+
};
|
|
1892
|
+
$scope.add_cron_jobs = function () {
|
|
1893
|
+
$('#cron-add-confirm').modal('hide');
|
|
1894
|
+
Request.post('/api/operation/cron', {
|
|
1895
|
+
action: 'cron_add',
|
|
1896
|
+
minute: $scope.cron_time.minute,
|
|
1897
|
+
hour: $scope.cron_time.hour,
|
|
1898
|
+
day: $scope.cron_time.day,
|
|
1899
|
+
month: $scope.cron_time.month,
|
|
1900
|
+
weekday: $scope.cron_time.weekday,
|
|
1901
|
+
command: $scope.task_command,
|
|
1902
|
+
user: $scope.task_user,
|
|
1903
|
+
email: $scope.task_email,
|
|
1904
|
+
level: $scope.task_level
|
|
1905
|
+
}, function(res) {
|
|
1906
|
+
if (res.code == 0) {
|
|
1907
|
+
$('#cron-add-confirm').modal('hide');
|
|
1908
|
+
if ($scope.task_level == 'system') {
|
|
1909
|
+
$scope.load_system_list();
|
|
1910
|
+
} else {
|
|
1911
|
+
$scope.load_normal_list();
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
});
|
|
1915
|
+
};
|
|
1916
|
+
$scope.form_clear = function () {
|
|
1917
|
+
// $scope.cron_time = {
|
|
1918
|
+
// minute: '',
|
|
1919
|
+
// hour: '',
|
|
1920
|
+
// day: '',
|
|
1921
|
+
// month: '',
|
|
1922
|
+
// weekday: '',
|
|
1923
|
+
// };
|
|
1924
|
+
$scope.common_options = ''
|
|
1925
|
+
$scope.select_common_option()
|
|
1926
|
+
$scope.task_id = '';
|
|
1927
|
+
$scope.task_user = '';
|
|
1928
|
+
$scope.task_email = '';
|
|
1929
|
+
$scope.task_level = '';
|
|
1930
|
+
$scope.task_command = '';
|
|
1931
|
+
};
|
|
1932
|
+
$scope.cron_detail = function (info, level) {
|
|
1933
|
+
$('#cron-add-confirm').modal();
|
|
1934
|
+
$scope.form_clear();
|
|
1935
|
+
$scope.cron_time = {
|
|
1936
|
+
minute: info.minute,
|
|
1937
|
+
hour: info.hour,
|
|
1938
|
+
day: info.day,
|
|
1939
|
+
month: info.month,
|
|
1940
|
+
weekday: info.weekday,
|
|
1941
|
+
};
|
|
1942
|
+
$scope.options = angular.copy($scope.cron_time);
|
|
1943
|
+
$scope.task_id = info.id;
|
|
1944
|
+
$scope.task_user = info.user;
|
|
1945
|
+
$scope.task_email = '';
|
|
1946
|
+
$scope.task_level = level;
|
|
1947
|
+
$scope.task_command = info.command;
|
|
1948
|
+
};
|
|
1949
|
+
$scope.update_cron_jobs = function () {
|
|
1950
|
+
$('#cron-add-confirm').modal('hide');
|
|
1951
|
+
var currlist = $scope.task_level == 'system' && $scope.cron_system.user ? $scope.cron_system.user : '';
|
|
1952
|
+
Request.post('/api/operation/cron', {
|
|
1953
|
+
action: 'cron_mod',
|
|
1954
|
+
minute: $scope.cron_time.minute,
|
|
1955
|
+
hour: $scope.cron_time.hour,
|
|
1956
|
+
day: $scope.cron_time.day,
|
|
1957
|
+
month: $scope.cron_time.month,
|
|
1958
|
+
weekday: $scope.cron_time.weekday,
|
|
1959
|
+
command: $scope.task_command,
|
|
1960
|
+
cronid: String($scope.task_id),
|
|
1961
|
+
user: $scope.task_user,
|
|
1962
|
+
level: $scope.task_level,
|
|
1963
|
+
email: $scope.task_email,
|
|
1964
|
+
currlist: currlist
|
|
1965
|
+
}, function(res) {
|
|
1966
|
+
if (res.code == 0) {
|
|
1967
|
+
$('#cron-add-confirm').modal('hide');
|
|
1968
|
+
if ($scope.task_level == 'system') {
|
|
1969
|
+
$scope.load_system_list();
|
|
1970
|
+
} else {
|
|
1971
|
+
$scope.load_normal_list();
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
});
|
|
1975
|
+
};
|
|
1976
|
+
$scope.cron_del_confirm = function(info, level) {
|
|
1977
|
+
if (!info || !info.id || !info.user) return;
|
|
1978
|
+
$scope.task_id = info.id;
|
|
1979
|
+
$scope.task_user = info.user;
|
|
1980
|
+
$scope.task_level = level;
|
|
1981
|
+
$('#cron-delete-confirm').modal();
|
|
1982
|
+
};
|
|
1983
|
+
$scope.del_cron_jobs = function () {
|
|
1984
|
+
$('#cron-delete-confirm').modal('hide');
|
|
1985
|
+
// current user's task on system level
|
|
1986
|
+
var currlist = $scope.task_level == 'system' && $scope.cron_system.user ? $scope.cron_system.user : '';
|
|
1987
|
+
Request.post('/api/operation/cron', {
|
|
1988
|
+
action: 'cron_del',
|
|
1989
|
+
cronid: String($scope.task_id),
|
|
1990
|
+
user: $scope.task_user,
|
|
1991
|
+
level: $scope.task_level,
|
|
1992
|
+
currlist: currlist
|
|
1993
|
+
}, function(res) {
|
|
1994
|
+
if (res.code == 0) {
|
|
1995
|
+
$('#cron-delete-confirm').modal('hide');
|
|
1996
|
+
if ($scope.task_level == 'system') {
|
|
1997
|
+
$scope.load_system_list();
|
|
1998
|
+
} else {
|
|
1999
|
+
$scope.load_normal_list();
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
});
|
|
2003
|
+
};
|
|
2004
|
+
$scope.add_environment = function () {
|
|
2005
|
+
console.log('add_environment');
|
|
2006
|
+
};
|
|
2007
|
+
$scope.add_cron_local = function() {
|
|
2008
|
+
console.log('add_cron_local');
|
|
2009
|
+
};
|
|
2010
|
+
}
|
|
2011
|
+
];
|
|
2012
|
+
|
|
2013
|
+
var UtilsShellCtrl = ['$scope', '$routeParams', 'Module', 'Timeout', 'Request',
|
|
2014
|
+
function($scope, $routeParams, Module, Timeout, Request) {
|
|
2015
|
+
var module = 'utils.shell';
|
|
2016
|
+
Module.init(module, 'SHELL 命令');
|
|
2017
|
+
var section = Module.getSection();
|
|
2018
|
+
var enabled_sections = ['base', 'advance'];
|
|
2019
|
+
Module.initSection(enabled_sections[0]);
|
|
2020
|
+
$scope.loaded = false;
|
|
2021
|
+
$scope.loading = false;
|
|
2022
|
+
$scope.base_cmds = [];
|
|
2023
|
+
$scope.base_cwd = '/';
|
|
2024
|
+
$scope.base_input = '';
|
|
2025
|
+
|
|
2026
|
+
$scope.load = function () {
|
|
2027
|
+
$scope.loaded = true;
|
|
2028
|
+
$scope.tab_sec(section);
|
|
2029
|
+
};
|
|
2030
|
+
$scope.tab_sec = function (section) {
|
|
2031
|
+
var init = Module.getSection() != section
|
|
2032
|
+
section = (section && enabled_sections.indexOf(section) > -1) ? section : enabled_sections[0];
|
|
2033
|
+
$scope.sec(section);
|
|
2034
|
+
Module.setSection(section);
|
|
2035
|
+
// $scope['load_' + section](init);
|
|
2036
|
+
};
|
|
2037
|
+
|
|
2038
|
+
$scope.send_base_cmd = function() {
|
|
2039
|
+
if ($scope.base_input == '') {
|
|
2040
|
+
return;
|
|
2041
|
+
}
|
|
2042
|
+
$scope.base_cmds.push('# ' + $scope.base_input);
|
|
2043
|
+
Request.post('/api/operation/shell', {
|
|
2044
|
+
'action': 'exec_command',
|
|
2045
|
+
'cmd': $scope.base_input,
|
|
2046
|
+
'cwd': $scope.base_cwd
|
|
2047
|
+
}, function (res) {
|
|
2048
|
+
$scope.base_input = '';
|
|
2049
|
+
if (res.code == 0) {
|
|
2050
|
+
if (res.data) {
|
|
2051
|
+
$scope.base_cmds.push(res.data.data);
|
|
2052
|
+
// for (i in res.data.data) {
|
|
2053
|
+
// $scope.base_cmds.push(res.data.data[i]);
|
|
2054
|
+
// }
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
});
|
|
2058
|
+
};
|
|
2059
|
+
}
|
|
2060
|
+
];
|
|
2061
|
+
|
|
2062
|
+
var UtilsMigrateCtrl = [
|
|
2063
|
+
'$scope', '$routeParams', 'Module', 'Message', 'Timeout', 'Request', 'Backend',
|
|
2064
|
+
function($scope, $routeParams, Module, Message, Timeout, Request, Backend) {
|
|
2065
|
+
var module = 'utils.migrate';
|
|
2066
|
+
var section = Module.getSection();
|
|
2067
|
+
var enabled_sections = ['ftp', 'nutstore'];
|
|
2068
|
+
Module.init(module, '文件传输');
|
|
2069
|
+
Module.initSection(enabled_sections[0]);
|
|
2070
|
+
$scope.loaded = true;
|
|
2071
|
+
$scope.remote = {
|
|
2072
|
+
'address': '',
|
|
2073
|
+
'account': '',
|
|
2074
|
+
'password': '',
|
|
2075
|
+
'source': '/',
|
|
2076
|
+
'target': ''
|
|
2077
|
+
};
|
|
2078
|
+
$scope.tab_sec = function (section) {
|
|
2079
|
+
var init = Module.getSection() != section
|
|
2080
|
+
section = (section && enabled_sections.indexOf(section) > -1) ? section : enabled_sections[0];
|
|
2081
|
+
$scope.sec(section);
|
|
2082
|
+
Module.setSection(section);
|
|
2083
|
+
$scope['load_' + section](init);
|
|
2084
|
+
};
|
|
2085
|
+
$scope.load_ftp = function () {
|
|
2086
|
+
console.log('传输到 FTP');
|
|
2087
|
+
};
|
|
2088
|
+
$scope.load_nutstore = function () {
|
|
2089
|
+
console.log('传输到坚果云');
|
|
2090
|
+
};
|
|
2091
|
+
$scope.reset_form = function () {
|
|
2092
|
+
$scope.remote = {
|
|
2093
|
+
'address': '',
|
|
2094
|
+
'account': '',
|
|
2095
|
+
'password': '',
|
|
2096
|
+
'source': '/',
|
|
2097
|
+
'target': '/var'
|
|
2098
|
+
};
|
|
2099
|
+
};
|
|
2100
|
+
$scope.select_files = function () {
|
|
2101
|
+
$scope.selector_title = '请选择需要传输的文件';
|
|
2102
|
+
$scope.selector.onlydir = false;
|
|
2103
|
+
$scope.selector.onlyfile = true;
|
|
2104
|
+
$scope.selector.load($scope.remote.source); // 加载默认
|
|
2105
|
+
$scope.selector.selecthandler = function (path) { // 回调函数
|
|
2106
|
+
$('#selector').modal('hide');
|
|
2107
|
+
$scope.remote.source = path;
|
|
2108
|
+
};
|
|
2109
|
+
$('#selector').modal();
|
|
2110
|
+
};
|
|
2111
|
+
$scope.migrate_ftp = function () {
|
|
2112
|
+
console.log('立即传输', $scope.remote);
|
|
2113
|
+
if ($scope.remote.address == '') {
|
|
2114
|
+
Message.setWarning('请输入服务器地址');
|
|
2115
|
+
} else if ($scope.remote.account == '') {
|
|
2116
|
+
Message.setWarning('请输入授权用户');
|
|
2117
|
+
} else if ($scope.remote.password == '') {
|
|
2118
|
+
Message.setWarning('请输入授权密码');
|
|
2119
|
+
} else if ($scope.remote.source == '') {
|
|
2120
|
+
Message.setWarning('请选择需要传输的文件');
|
|
2121
|
+
} else if ($scope.remote.target == '') {
|
|
2122
|
+
Message.setWarning('请输入远程服务器保存路径');
|
|
2123
|
+
} else {
|
|
2124
|
+
console.log('立即传输2', $scope.remote);
|
|
2125
|
+
$scope.trans_to_ftp();
|
|
2126
|
+
}
|
|
2127
|
+
};
|
|
2128
|
+
$scope.trans_to_ftp = function () {
|
|
2129
|
+
console.log('立即传输', $scope.remote);
|
|
2130
|
+
var op_data = angular.copy($scope.remote);
|
|
2131
|
+
// Backend.call = function ($scope, module, url, statusUrl, data, callback, quiet) {
|
|
2132
|
+
Backend.call($scope, module,
|
|
2133
|
+
'/api/backend/uploadtoftp',
|
|
2134
|
+
'/api/backend/uploadtoftp_' + op_data.address + '_' + op_data.source + '_' + op_data.target,
|
|
2135
|
+
op_data, {
|
|
2136
|
+
'wait': function (data) {
|
|
2137
|
+
Message.setInfo(data.msg || '正在处理');
|
|
2138
|
+
},
|
|
2139
|
+
'success': function (data) {
|
|
2140
|
+
Message.setInfo(data.msg || '传输成功!');
|
|
2141
|
+
},
|
|
2142
|
+
'error': function (data) {
|
|
2143
|
+
Message.setError(data.msg || '传输失败!');
|
|
2144
|
+
}
|
|
2145
|
+
},
|
|
2146
|
+
true
|
|
2147
|
+
);
|
|
2148
|
+
};
|
|
2149
|
+
}
|
|
2150
|
+
];
|
|
2151
|
+
|
|
2152
|
+
var UtilsFirewallCtrl = [
|
|
2153
|
+
'$scope', 'Module', '$routeParams', 'Timeout', 'Request', 'Message', 'Backend', '$location',
|
|
2154
|
+
function($scope, Module, $routeParams, Timeout, Request, Message, Backend, $location) {
|
|
2155
|
+
var module = 'utils.firewall';
|
|
2156
|
+
Module.init(module, '防火墙');
|
|
2157
|
+
$scope.loaded = false;
|
|
2158
|
+
$scope.loading = false;
|
|
2159
|
+
|
|
2160
|
+
$scope.firewall = {
|
|
2161
|
+
type: 'unknown',
|
|
2162
|
+
status: '',
|
|
2163
|
+
running: false,
|
|
2164
|
+
rules: []
|
|
2165
|
+
};
|
|
2166
|
+
|
|
2167
|
+
$scope.load = function () {
|
|
2168
|
+
$scope.loaded = true;
|
|
2169
|
+
$scope.load_status();
|
|
2170
|
+
$scope.load_rules();
|
|
2171
|
+
};
|
|
2172
|
+
|
|
2173
|
+
$scope.load_status = function() {
|
|
2174
|
+
$scope.loading = true;
|
|
2175
|
+
Request.get('/api/firewall/status', function(res) {
|
|
2176
|
+
$scope.loading = false;
|
|
2177
|
+
if (res && res.code == 0) {
|
|
2178
|
+
$scope.firewall.type = res.data.type;
|
|
2179
|
+
$scope.firewall.status = res.data.status;
|
|
2180
|
+
$scope.firewall.running = res.data.running;
|
|
2181
|
+
}
|
|
2182
|
+
});
|
|
2183
|
+
};
|
|
2184
|
+
|
|
2185
|
+
$scope.load_rules = function() {
|
|
2186
|
+
$scope.loading = true;
|
|
2187
|
+
Request.get('/api/firewall/list_rules', function(res) {
|
|
2188
|
+
$scope.loading = false;
|
|
2189
|
+
if (res && res.code == 0) {
|
|
2190
|
+
$scope.firewall.type = res.data.type;
|
|
2191
|
+
$scope.firewall.rules = res.data.rules || [];
|
|
2192
|
+
}
|
|
2193
|
+
});
|
|
2194
|
+
};
|
|
2195
|
+
|
|
2196
|
+
$scope.firewall_start = function() {
|
|
2197
|
+
Request.post('/api/firewall/start', {}, function(res) {
|
|
2198
|
+
if (res && res.code == 0) {
|
|
2199
|
+
$scope.load_status();
|
|
2200
|
+
$scope.load_rules();
|
|
2201
|
+
}
|
|
2202
|
+
});
|
|
2203
|
+
};
|
|
2204
|
+
|
|
2205
|
+
$scope.firewall_stop = function() {
|
|
2206
|
+
Request.post('/api/firewall/stop', {}, function(res) {
|
|
2207
|
+
if (res && res.code == 0) {
|
|
2208
|
+
$scope.load_status();
|
|
2209
|
+
$scope.load_rules();
|
|
2210
|
+
}
|
|
2211
|
+
});
|
|
2212
|
+
};
|
|
2213
|
+
|
|
2214
|
+
$scope.firewall_restart = function() {
|
|
2215
|
+
Request.post('/api/firewall/restart', {}, function(res) {
|
|
2216
|
+
if (res && res.code == 0) {
|
|
2217
|
+
$scope.load_status();
|
|
2218
|
+
$scope.load_rules();
|
|
2219
|
+
}
|
|
2220
|
+
});
|
|
2221
|
+
};
|
|
2222
|
+
|
|
2223
|
+
$scope.firewall_enable = function() {
|
|
2224
|
+
Request.post('/api/firewall/enable', {}, function(res) {
|
|
2225
|
+
if (res && res.code == 0) {
|
|
2226
|
+
$scope.load_status();
|
|
2227
|
+
}
|
|
2228
|
+
});
|
|
2229
|
+
};
|
|
2230
|
+
|
|
2231
|
+
$scope.firewall_disable = function() {
|
|
2232
|
+
Request.post('/api/firewall/disable', {}, function(res) {
|
|
2233
|
+
if (res && res.code == 0) {
|
|
2234
|
+
$scope.load_status();
|
|
2235
|
+
}
|
|
2236
|
+
});
|
|
2237
|
+
};
|
|
2238
|
+
|
|
2239
|
+
$scope.add_port_rule_confirm = function() {
|
|
2240
|
+
$scope.add_port = {
|
|
2241
|
+
'port': '',
|
|
2242
|
+
'protocol': 'tcp',
|
|
2243
|
+
'zone': ''
|
|
2244
|
+
};
|
|
2245
|
+
$('#firewall-add-port').modal();
|
|
2246
|
+
};
|
|
2247
|
+
|
|
2248
|
+
$scope.add_port_rule = function() {
|
|
2249
|
+
Request.post('/api/firewall/add_port_rule', $scope.add_port, function(res) {
|
|
2250
|
+
if (res && res.code == 0) {
|
|
2251
|
+
$scope.load_rules();
|
|
2252
|
+
}
|
|
2253
|
+
});
|
|
2254
|
+
};
|
|
2255
|
+
|
|
2256
|
+
$scope.remove_port_rule_confirm = function(rule) {
|
|
2257
|
+
$scope.del_port = {
|
|
2258
|
+
'port': rule.port,
|
|
2259
|
+
'protocol': rule.protocol,
|
|
2260
|
+
'zone': rule.zone
|
|
2261
|
+
};
|
|
2262
|
+
$('#firewall-del-port').modal();
|
|
2263
|
+
};
|
|
2264
|
+
|
|
2265
|
+
$scope.remove_port_rule = function() {
|
|
2266
|
+
Request.post('/api/firewall/remove_port_rule', $scope.del_port, function(res) {
|
|
2267
|
+
if (res && res.code == 0) {
|
|
2268
|
+
$scope.load_rules();
|
|
2269
|
+
}
|
|
2270
|
+
});
|
|
2271
|
+
};
|
|
2272
|
+
|
|
2273
|
+
$scope.add_ip_rule_confirm = function() {
|
|
2274
|
+
$scope.add_ip = {
|
|
2275
|
+
'ip': '',
|
|
2276
|
+
'action_type': 'allow'
|
|
2277
|
+
};
|
|
2278
|
+
$('#firewall-add-ip').modal();
|
|
2279
|
+
};
|
|
2280
|
+
|
|
2281
|
+
$scope.add_ip_rule = function() {
|
|
2282
|
+
Request.post('/api/firewall/add_ip_rule', $scope.add_ip, function(res) {
|
|
2283
|
+
if (res && res.code == 0) {
|
|
2284
|
+
$scope.load_rules();
|
|
2285
|
+
}
|
|
2286
|
+
});
|
|
2287
|
+
};
|
|
2288
|
+
|
|
2289
|
+
$scope.remove_ip_rule_confirm = function(rule) {
|
|
2290
|
+
$scope.del_ip = {
|
|
2291
|
+
'ip': rule.ip
|
|
2292
|
+
};
|
|
2293
|
+
$('#firewall-del-ip').modal();
|
|
2294
|
+
};
|
|
2295
|
+
|
|
2296
|
+
$scope.remove_ip_rule = function() {
|
|
2297
|
+
Request.post('/api/firewall/remove_ip_rule', $scope.del_ip, function(res) {
|
|
2298
|
+
if (res && res.code == 0) {
|
|
2299
|
+
$scope.load_rules();
|
|
2300
|
+
}
|
|
2301
|
+
});
|
|
2302
|
+
};
|
|
2303
|
+
|
|
2304
|
+
$scope.remove_app_rule_confirm = function(rule) {
|
|
2305
|
+
$scope.del_app = {
|
|
2306
|
+
'app_path': rule.app_path
|
|
2307
|
+
};
|
|
2308
|
+
$('#firewall-del-app').modal();
|
|
2309
|
+
};
|
|
2310
|
+
|
|
2311
|
+
$scope.remove_app_rule = function() {
|
|
2312
|
+
Request.post('/api/firewall/remove_app_rule', $scope.del_app, function(res) {
|
|
2313
|
+
if (res && res.code == 0) {
|
|
2314
|
+
$scope.load_rules();
|
|
2315
|
+
}
|
|
2316
|
+
});
|
|
2317
|
+
};
|
|
2318
|
+
}
|
|
2319
|
+
];
|