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.
Files changed (198) hide show
  1. inpanel/__init__.py +29 -0
  2. inpanel/acme.py +289 -0
  3. inpanel/aliyuncs.py +269 -0
  4. inpanel/app.py +514 -0
  5. inpanel/apt.py +223 -0
  6. inpanel/base.py +200 -0
  7. inpanel/config.py +139 -0
  8. inpanel/data/config.ini +29 -0
  9. inpanel/data/history +5 -0
  10. inpanel/data/runlogs.ini +12 -0
  11. inpanel/data/update_info.ini +4 -0
  12. inpanel/dnf.py +225 -0
  13. inpanel/lib/__init__.py +9 -0
  14. inpanel/lib/async_process.py +98 -0
  15. inpanel/lib/filelock.py +82 -0
  16. inpanel/lib/magic.py +233 -0
  17. inpanel/lib/pxssh.py +310 -0
  18. inpanel/lib/pyDes.py +867 -0
  19. inpanel/mod/__init__.py +0 -0
  20. inpanel/mod/apt.py +316 -0
  21. inpanel/mod/certificate.py +268 -0
  22. inpanel/mod/config.py +372 -0
  23. inpanel/mod/cron.py +315 -0
  24. inpanel/mod/disk.py +322 -0
  25. inpanel/mod/dnf.py +239 -0
  26. inpanel/mod/file.py +722 -0
  27. inpanel/mod/firewall.py +199 -0
  28. inpanel/mod/firewall_base.py +137 -0
  29. inpanel/mod/firewall_firewalld.py +170 -0
  30. inpanel/mod/firewall_iptables.py +176 -0
  31. inpanel/mod/firewall_macos.py +213 -0
  32. inpanel/mod/firewall_ufw.py +128 -0
  33. inpanel/mod/ftp.py +231 -0
  34. inpanel/mod/httpd.py +1205 -0
  35. inpanel/mod/lighttpd.py +26 -0
  36. inpanel/mod/login.py +98 -0
  37. inpanel/mod/mysql.py +577 -0
  38. inpanel/mod/named.py +26 -0
  39. inpanel/mod/nginx.py +2327 -0
  40. inpanel/mod/package.py +33 -0
  41. inpanel/mod/package_apt.py +62 -0
  42. inpanel/mod/package_base.py +77 -0
  43. inpanel/mod/package_dnf.py +62 -0
  44. inpanel/mod/package_map.py +366 -0
  45. inpanel/mod/package_yum.py +64 -0
  46. inpanel/mod/php.py +289 -0
  47. inpanel/mod/process.py +291 -0
  48. inpanel/mod/proftpd.py +26 -0
  49. inpanel/mod/pureftpd.py +26 -0
  50. inpanel/mod/query.py +108 -0
  51. inpanel/mod/server.py +1319 -0
  52. inpanel/mod/service.py +262 -0
  53. inpanel/mod/setting.py +228 -0
  54. inpanel/mod/shell.py +78 -0
  55. inpanel/mod/ssh.py +280 -0
  56. inpanel/mod/system.py +220 -0
  57. inpanel/mod/task.py +1337 -0
  58. inpanel/mod/ufw.py +14 -0
  59. inpanel/mod/user.py +306 -0
  60. inpanel/mod/vsftpd.py +67 -0
  61. inpanel/mod/yum.py +243 -0
  62. inpanel/plugins/__init__.py +10 -0
  63. inpanel/plugins/__pycache__/__init__.cpython-313.pyc +0 -0
  64. inpanel/plugins/acme/static/index.html +10 -0
  65. inpanel/plugins/acme/static/index.js +13 -0
  66. inpanel/plugins/shadowsocks-libev/__pycache__/info.cpython-313.pyc +0 -0
  67. inpanel/plugins/shadowsocks-libev/info.py +73 -0
  68. inpanel/plugins/shadowsocks-libev/static/index.html +70 -0
  69. inpanel/plugins/shadowsocks-libev/static/index.js +18 -0
  70. inpanel/public/css/global.css +138 -0
  71. inpanel/public/favicon.ico +0 -0
  72. inpanel/public/images/alipay.jpg +0 -0
  73. inpanel/public/images/loading.gif +0 -0
  74. inpanel/public/images/weixin.jpg +0 -0
  75. inpanel/public/index.html +94 -0
  76. inpanel/public/js/controllers/controllers.js +566 -0
  77. inpanel/public/js/controllers/database.js +590 -0
  78. inpanel/public/js/controllers/ecs.js +624 -0
  79. inpanel/public/js/controllers/file.js +940 -0
  80. inpanel/public/js/controllers/plugins.js +105 -0
  81. inpanel/public/js/controllers/service.js +1460 -0
  82. inpanel/public/js/controllers/site.js +1241 -0
  83. inpanel/public/js/controllers/utils.js +2319 -0
  84. inpanel/public/js/core.js +221 -0
  85. inpanel/public/js/directives.js +784 -0
  86. inpanel/public/js/filters.js +395 -0
  87. inpanel/public/js/services.js +257 -0
  88. inpanel/public/lib/angular/1.0.2/angular-resource.min.js +10 -0
  89. inpanel/public/lib/angular/1.0.2/angular.min.js +158 -0
  90. inpanel/public/lib/bootstrap/css/bootstrap-theme.css +587 -0
  91. inpanel/public/lib/bootstrap/css/bootstrap-theme.css.map +1 -0
  92. inpanel/public/lib/bootstrap/css/bootstrap-theme.min.css +6 -0
  93. inpanel/public/lib/bootstrap/css/bootstrap-theme.min.css.map +1 -0
  94. inpanel/public/lib/bootstrap/css/bootstrap.css +6757 -0
  95. inpanel/public/lib/bootstrap/css/bootstrap.css.map +1 -0
  96. inpanel/public/lib/bootstrap/css/bootstrap.min.css +6 -0
  97. inpanel/public/lib/bootstrap/css/bootstrap.min.css.map +1 -0
  98. inpanel/public/lib/bootstrap/fonts/glyphicons-halflings-regular.eot +0 -0
  99. inpanel/public/lib/bootstrap/fonts/glyphicons-halflings-regular.svg +288 -0
  100. inpanel/public/lib/bootstrap/fonts/glyphicons-halflings-regular.ttf +0 -0
  101. inpanel/public/lib/bootstrap/fonts/glyphicons-halflings-regular.woff +0 -0
  102. inpanel/public/lib/bootstrap/fonts/glyphicons-halflings-regular.woff2 +0 -0
  103. inpanel/public/lib/bootstrap/img/glyphicons-halflings-white.png +0 -0
  104. inpanel/public/lib/bootstrap/img/glyphicons-halflings.png +0 -0
  105. inpanel/public/lib/bootstrap/js/bootstrap.js +2377 -0
  106. inpanel/public/lib/bootstrap/js/bootstrap.min.js +7 -0
  107. inpanel/public/lib/bootstrap/js/npm.js +13 -0
  108. inpanel/public/lib/codemirror/codemirror-compressed.js +1 -0
  109. inpanel/public/lib/codemirror/codemirror.css +173 -0
  110. inpanel/public/lib/jquery/jquery-1.12.4.min.js +5 -0
  111. inpanel/public/lib/md5/md5.js +379 -0
  112. inpanel/public/lib/md5/md5.min.js +1 -0
  113. inpanel/public/partials/database/index.html +172 -0
  114. inpanel/public/partials/database/mysql/dbedit.html +462 -0
  115. inpanel/public/partials/database/mysql/dbnew.html +348 -0
  116. inpanel/public/partials/database/mysql/useredit.html +310 -0
  117. inpanel/public/partials/database/mysql/usernew.html +97 -0
  118. inpanel/public/partials/directives/message.html +20 -0
  119. inpanel/public/partials/directives/navbar.html +25 -0
  120. inpanel/public/partials/directives/selector.html +57 -0
  121. inpanel/public/partials/directives/srvbase.html +72 -0
  122. inpanel/public/partials/directives/srvext.html +34 -0
  123. inpanel/public/partials/directives/srvfile.html +23 -0
  124. inpanel/public/partials/directives/srvinstall.html +34 -0
  125. inpanel/public/partials/directives/srvlog.html +23 -0
  126. inpanel/public/partials/directives/srvminiop.html +28 -0
  127. inpanel/public/partials/directives/srvuninstall.html +38 -0
  128. inpanel/public/partials/directives/srvupdate.html +30 -0
  129. inpanel/public/partials/ecs/account.html +156 -0
  130. inpanel/public/partials/ecs/ecs.html +198 -0
  131. inpanel/public/partials/ecs/index.html +40 -0
  132. inpanel/public/partials/ecs/setings.html +459 -0
  133. inpanel/public/partials/file/file.html +501 -0
  134. inpanel/public/partials/file/trash.html +95 -0
  135. inpanel/public/partials/ftp.html +36 -0
  136. inpanel/public/partials/log.html +83 -0
  137. inpanel/public/partials/login.html +79 -0
  138. inpanel/public/partials/logout.html +22 -0
  139. inpanel/public/partials/main.html +534 -0
  140. inpanel/public/partials/plugins/index.html +55 -0
  141. inpanel/public/partials/plugins/plugins.html +13 -0
  142. inpanel/public/partials/secure.html +13 -0
  143. inpanel/public/partials/service/apache.html +147 -0
  144. inpanel/public/partials/service/cron.html +71 -0
  145. inpanel/public/partials/service/index.html +293 -0
  146. inpanel/public/partials/service/iptables.html +40 -0
  147. inpanel/public/partials/service/lighttpd.html +63 -0
  148. inpanel/public/partials/service/mariadb.html +113 -0
  149. inpanel/public/partials/service/memcache.html +36 -0
  150. inpanel/public/partials/service/minio.html +44 -0
  151. inpanel/public/partials/service/mongodb.html +44 -0
  152. inpanel/public/partials/service/mysql.html +113 -0
  153. inpanel/public/partials/service/named.html +61 -0
  154. inpanel/public/partials/service/nginx.html +296 -0
  155. inpanel/public/partials/service/ntp.html +40 -0
  156. inpanel/public/partials/service/php.html +250 -0
  157. inpanel/public/partials/service/proftpd.html +59 -0
  158. inpanel/public/partials/service/pureftpd.html +59 -0
  159. inpanel/public/partials/service/redis.html +40 -0
  160. inpanel/public/partials/service/samba.html +58 -0
  161. inpanel/public/partials/service/sendmail.html +40 -0
  162. inpanel/public/partials/service/ssh.html +186 -0
  163. inpanel/public/partials/service/tomcat.html +65 -0
  164. inpanel/public/partials/service/vsftpd.html +195 -0
  165. inpanel/public/partials/setting.html +299 -0
  166. inpanel/public/partials/site/apache/site.html +277 -0
  167. inpanel/public/partials/site/index.html +344 -0
  168. inpanel/public/partials/site/nginx/site.html +558 -0
  169. inpanel/public/partials/sorry.html +19 -0
  170. inpanel/public/partials/storage/autofm.html +103 -0
  171. inpanel/public/partials/storage/backup.html +42 -0
  172. inpanel/public/partials/storage/index.html +360 -0
  173. inpanel/public/partials/storage/migrate.html +93 -0
  174. inpanel/public/partials/storage/movedata.html +98 -0
  175. inpanel/public/partials/storage/remote.html +77 -0
  176. inpanel/public/partials/utils/cron.html +486 -0
  177. inpanel/public/partials/utils/firewall.html +266 -0
  178. inpanel/public/partials/utils/index.html +193 -0
  179. inpanel/public/partials/utils/network.html +118 -0
  180. inpanel/public/partials/utils/process.html +239 -0
  181. inpanel/public/partials/utils/repository.html +373 -0
  182. inpanel/public/partials/utils/shell.html +28 -0
  183. inpanel/public/partials/utils/ssl.html +319 -0
  184. inpanel/public/partials/utils/time.html +109 -0
  185. inpanel/public/partials/utils/user.html +359 -0
  186. inpanel/public/robots.txt +2 -0
  187. inpanel/remote.py +109 -0
  188. inpanel/templates/file/preview.html +34 -0
  189. inpanel/templates/index.html +93 -0
  190. inpanel/utils.py +282 -0
  191. inpanel/web.py +1811 -0
  192. inpanel/yum.py +756 -0
  193. inpanel-1.2.1.dist-info/METADATA +399 -0
  194. inpanel-1.2.1.dist-info/RECORD +198 -0
  195. inpanel-1.2.1.dist-info/WHEEL +5 -0
  196. inpanel-1.2.1.dist-info/entry_points.txt +2 -0
  197. inpanel-1.2.1.dist-info/licenses/LICENSE +30 -0
  198. inpanel-1.2.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,784 @@
1
+ angular.module('inpanel.directives', []).
2
+ directive('navbar', function () {
3
+ return {
4
+ restrict: 'A',
5
+ transclude: true,
6
+ scope: {},
7
+ replace: true,
8
+ templateUrl: template_path + '/partials/directives/navbar.html',
9
+ controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
10
+ $rootScope.navbar_loaded = true;
11
+ }]
12
+ };
13
+ }).
14
+ directive('loading', function () {
15
+ return {
16
+ restrict: 'A',
17
+ transclude: true,
18
+ scope: {},
19
+ controller: ['$scope', function ($scope) {
20
+ if (!$scope.loadingText) $scope.loadingText = '模块加载中,请稍候......';
21
+ }],
22
+ template: '<div class="text-center">\
23
+ <h6>{{loadingText}}</h6>\
24
+ <div class="progress" style="width:230px;margin-left: auto;margin-right: auto;">\
25
+ <div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="100" style="width:100%;"></div>\
26
+ </div></div>',
27
+ replace: true
28
+ };
29
+ }).
30
+ directive('message', function () {
31
+ return {
32
+ restrict: 'A',
33
+ transclude: true,
34
+ scope: {},
35
+ replace: true,
36
+ templateUrl: template_path + '/partials/directives/message.html',
37
+ controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
38
+ $rootScope.showErrorMsg = false;
39
+ $rootScope.errorMessage = '';
40
+ $rootScope.showSuccessMsg = false;
41
+ $rootScope.successMessage = '';
42
+ $rootScope.showWarningMsg = false;
43
+ $rootScope.warningMessage = '';
44
+ $rootScope.showInfoMsg = false;
45
+ $rootScope.infoMessage = '';
46
+ $scope.$rootScope = $rootScope;
47
+ if (!$scope.id) $scope.id = 'message';
48
+ }]
49
+ };
50
+ }).
51
+ directive('srvminiop', function () {
52
+ return {
53
+ restrict: 'A',
54
+ transclude: true,
55
+ scope: {},
56
+ replace: true,
57
+ templateUrl: template_path + '/partials/directives/srvminiop.html',
58
+ controller: ['$scope', function ($scope) {
59
+ $scope.$scope = $scope.$parent;
60
+ }]
61
+ };
62
+ }).
63
+ directive('srvbase', function () {
64
+ return {
65
+ restrict: 'A',
66
+ transclude: true,
67
+ scope: {},
68
+ replace: true,
69
+ templateUrl: template_path + '/partials/directives/srvbase.html',
70
+ controller: ['$rootScope', '$scope', 'Request', 'Backend', function ($rootScope, $scope, Request, Backend) {
71
+ $scope.$scope = $scope.$parent;
72
+ $scope.pkginfo = null;
73
+
74
+ $scope.$parent.checkVersion = function () {
75
+ Backend.call(
76
+ $scope.$parent,
77
+ $rootScope.module,
78
+ '/api/backend/yum_info',
79
+ '/api/backend/yum_info_' + $scope.pkg, {
80
+ 'pkg': $scope.pkg,
81
+ 'repo': 'installed'
82
+ }, {
83
+ 'success': function (data) {
84
+ $scope.$parent.pkginfo = $scope.pkginfo = data.data[0];
85
+ },
86
+ 'error': function (data) {
87
+ $scope.pkginfo = {
88
+ 'name': '获取失败!'
89
+ };
90
+ }
91
+ },
92
+ true
93
+ );
94
+ };
95
+
96
+ $scope.toggleAutostart = function () {
97
+ Request.post('/api/operation/service', {
98
+ 'action': 'chkconfig',
99
+ 'name': $scope.name,
100
+ 'service': $scope.service,
101
+ 'autostart': !$scope.$parent.autostart
102
+ }, function (data) {
103
+ $scope.$parent.checkInstalled();
104
+ });
105
+ };
106
+
107
+ var serviceop = function (action) {
108
+ return function () {
109
+ Backend.call(
110
+ $scope.$parent,
111
+ $rootScope.module,
112
+ '/api/backend/service_' + action,
113
+ '/api/backend/service_' + action + '_' + $scope.service, {
114
+ 'name': $scope.name,
115
+ 'service': $scope.service
116
+ },
117
+ $scope.$parent.checkInstalled
118
+ );
119
+ };
120
+ };
121
+
122
+ $scope.start = serviceop('start');
123
+ $scope.stop = serviceop('stop');
124
+ $scope.restart = serviceop('restart');
125
+ }]
126
+ };
127
+ }).
128
+ directive('srvinstall', function () {
129
+ return {
130
+ restrict: 'A',
131
+ transclude: true,
132
+ scope: {},
133
+ replace: true,
134
+ templateUrl: template_path + '/partials/directives/srvinstall.html',
135
+ controller: ['$rootScope', '$scope', 'Request', 'Timeout', 'Backend', function ($rootScope, $scope, Request, Timeout, Backend) {
136
+ $scope.$scope = $scope.$parent;
137
+
138
+ var repolist = [];
139
+ $scope.installing = false;
140
+ $scope.installMsg = '';
141
+
142
+ // check repolist
143
+ $scope.startInstall = function () {
144
+ $scope.installMsg = '正在检测软件源...';
145
+ $scope.installing = true;
146
+ Backend.call(
147
+ $scope.$parent,
148
+ $rootScope.module,
149
+ '/api/backend/yum_repolist',
150
+ '/api/backend/yum_repolist', {}, {
151
+ 'wait': function (data) {
152
+ $scope.installMsg = data.msg;
153
+ },
154
+ 'success': function (data) {
155
+ $scope.installMsg = data.msg;
156
+ if (data && data.data) {
157
+ repolist = data.data;
158
+ }
159
+ $scope.installRepo();
160
+ },
161
+ 'error': function (data) {
162
+ $scope.installMsg = data.msg;
163
+ Timeout(function () {
164
+ $scope.installing = false;
165
+ }, 3000, $rootScope.module);
166
+ }
167
+ },
168
+ true
169
+ );
170
+ };
171
+
172
+ // install expected repolist
173
+ $scope.installRepo = function () {
174
+ var newrepo_found = false;
175
+ for (var i = 0; i < $scope.expected_repolist.length; i++) {
176
+ var repo_found = false;
177
+ for (var j = 0; j < repolist.length; j++) {
178
+ if (repolist[j] == $scope.expected_repolist[i]) {
179
+ repo_found = true;
180
+ break;
181
+ }
182
+ }
183
+ if (repo_found) continue;
184
+
185
+ // install repo once a time
186
+ newrepo_found = true;
187
+ Backend.call(
188
+ $scope.$parent,
189
+ $rootScope.module,
190
+ '/api/backend/yum_installrepo',
191
+ '/api/backend/yum_installrepo_' + $scope.expected_repolist[i], {
192
+ 'repo': $scope.expected_repolist[i]
193
+ }, {
194
+ 'wait': function (data) {
195
+ $scope.installMsg = data.msg;
196
+ },
197
+ 'success': function (data) {
198
+ $scope.installMsg = data.msg;
199
+ repolist.push($scope.expected_repolist[i]);
200
+ $scope.installRepo();
201
+ },
202
+ 'error': function (data) {
203
+ $scope.installMsg = data.msg;
204
+ Timeout(function () {
205
+ $scope.installing = false;
206
+ }, 3000, $rootScope.module);
207
+ }
208
+ },
209
+ true
210
+ );
211
+ break;
212
+ }
213
+ // if no new repo be installed, goto next step
214
+ if (!newrepo_found) $scope.checkVersion();
215
+ };
216
+
217
+ // check and list versions of the pkg
218
+ $scope.showVerList = false;
219
+ $scope.checkVersion = function () {
220
+ Backend.call(
221
+ $scope.$parent,
222
+ $rootScope.module,
223
+ '/api/backend/yum_info',
224
+ '/api/backend/yum_info_' + $scope.pkg, {
225
+ 'pkg': $scope.pkg
226
+ }, {
227
+ 'wait': function (data) {
228
+ $scope.installMsg = data.msg;
229
+ },
230
+ 'success': function (data) {
231
+ $scope.installMsg = data.msg;
232
+ $scope.pkgs = data.data;
233
+ $scope.showVerList = true;
234
+ },
235
+ 'error': function (data) {
236
+ $scope.installMsg = data.msg;
237
+ Timeout(function () {
238
+ $scope.installing = false;
239
+ }, 3000, $rootScope.module);
240
+ }
241
+ },
242
+ true
243
+ );
244
+ };
245
+
246
+ // install specified version of pkg in specified repository
247
+ $scope.install = function (repo, name, version, release) {
248
+ $scope.installMsg = '开始安装...';
249
+ $scope.showVerList = false;
250
+ Backend.call(
251
+ $scope.$parent,
252
+ $rootScope.module,
253
+ '/api/backend/yum_install',
254
+ '/api/backend/yum_install_' + repo + '_' + name + '_' + version + '_' + release, {
255
+ 'repo': repo,
256
+ 'pkg': name,
257
+ 'version': version,
258
+ 'release': release
259
+ }, {
260
+ 'wait': function (data) {
261
+ $scope.installMsg = data.msg;
262
+ },
263
+ 'success': function (data) {
264
+ $scope.installMsg = data.msg;
265
+ $scope.$parent.activeTabName = 'base';
266
+ Timeout(function () {
267
+ $scope.installing = false;
268
+ $scope.$parent.checkInstalled();
269
+ }, 3000, $rootScope.module);
270
+ },
271
+ 'error': function (data) {
272
+ $scope.installMsg = data.msg;
273
+ Timeout(function () {
274
+ $scope.installing = false;
275
+ }, 3000, $rootScope.module);
276
+ }
277
+ },
278
+ true
279
+ );
280
+ };
281
+
282
+ // uninstall specified version of pkg in specified repository
283
+ $scope.uninstall = function (repo, name, version, release) {
284
+ $scope.installMsg = '正在清理...';
285
+ $scope.showVerList = false;
286
+ Backend.call(
287
+ $scope.$parent,
288
+ $rootScope.module,
289
+ '/api/backend/yum_uninstall',
290
+ '/api/backend/yum_uninstall_' + name + '_' + version + '_' + release, {
291
+ 'repo': repo,
292
+ 'pkg': name,
293
+ 'version': version,
294
+ 'release': release
295
+ }, {
296
+ 'wait': function (data) {
297
+ $scope.installMsg = data.msg;
298
+ },
299
+ 'success': function (data) {
300
+ $scope.installMsg = data.msg;
301
+ Timeout(function () {
302
+ $scope.installing = false;
303
+ $scope.$parent.checkInstalled();
304
+ }, 3000, $rootScope.module);
305
+ },
306
+ 'error': function (data) {
307
+ $scope.installMsg = data.msg;
308
+ Timeout(function () {
309
+ $scope.installing = false;
310
+ }, 3000, $rootScope.module);
311
+ }
312
+ },
313
+ true
314
+ );
315
+ };
316
+ }]
317
+ };
318
+ }).
319
+ directive('srvupdate', function () {
320
+ return {
321
+ restrict: 'A',
322
+ transclude: true,
323
+ scope: {},
324
+ replace: true,
325
+ templateUrl: template_path + '/partials/directives/srvupdate.html',
326
+ controller: ['$rootScope', '$scope', 'Request', 'Timeout', 'Backend', function ($rootScope, $scope, Request, Timeout, Backend) {
327
+ $scope.$scope = $scope.$parent;
328
+
329
+ $scope.updating = false;
330
+ $scope.updateMsg = '';
331
+
332
+ // check pkg version
333
+ $scope.startUpdate = function () {
334
+ $scope.updating = true;
335
+ $scope.updateMsg = '正在检测当前版本信息...';
336
+ Backend.call(
337
+ $scope.$parent,
338
+ $rootScope.module,
339
+ '/api/backend/yum_info',
340
+ '/api/backend/yum_info_' + $scope.pkg, {
341
+ 'pkg': $scope.pkg,
342
+ 'repo': 'installed'
343
+ }, {
344
+ 'wait': function (data) {
345
+ $scope.updateMsg = data.msg;
346
+ },
347
+ 'success': function (data) {
348
+ $scope.updateMsg = data.msg;
349
+ $scope.pkginfo = data.data[0];
350
+ $scope.checkVersion($scope.pkginfo.name);
351
+ },
352
+ 'error': function (data) {
353
+ $scope.updateMsg = data.msg;
354
+ Timeout(function () {
355
+ $scope.updating = false;
356
+ }, 3000, $rootScope.module);
357
+ }
358
+ },
359
+ true
360
+ );
361
+ };
362
+
363
+ // check and list versions of the pkg
364
+ $scope.showVerList = false;
365
+ $scope.checkVersion = function (name) {
366
+ $scope.updateMsg = '正在检测新版本...';
367
+ Backend.call(
368
+ $scope.$parent,
369
+ $rootScope.module,
370
+ '/api/backend/yum_info',
371
+ '/api/backend/yum_info_' + name, {
372
+ 'pkg': name,
373
+ 'option': 'update'
374
+ }, {
375
+ 'wait': function (data) {
376
+ $scope.updateMsg = data.msg;
377
+ },
378
+ 'success': function (data) {
379
+ $scope.updateMsg = data.msg;
380
+ $scope.pkgs = data.data;
381
+ $scope.showVerList = true;
382
+ },
383
+ 'error': function (data) {
384
+ $scope.updateMsg = data.msg;
385
+ Timeout(function () {
386
+ $scope.updating = false;
387
+ }, 3000, $rootScope.module);
388
+ }
389
+ },
390
+ true
391
+ );
392
+ };
393
+
394
+ // update pkg
395
+ $scope.update = function (repo, name, version, release) {
396
+ $scope.updateMsg = '开始升级...';
397
+ $scope.showVerList = false;
398
+ Backend.call(
399
+ $scope.$parent,
400
+ $rootScope.module,
401
+ '/api/backend/yum_update',
402
+ '/api/backend/yum_update_' + repo + '_' + name + '_' + version + '_' + release, {
403
+ 'repo': repo,
404
+ 'pkg': name,
405
+ 'version': version,
406
+ 'release': release
407
+ }, {
408
+ 'wait': function (data) {
409
+ $scope.updateMsg = data.msg;
410
+ },
411
+ 'success': function (data) {
412
+ $scope.updateMsg = data.msg;
413
+ $scope.$parent.activeTabName = 'base';
414
+ Timeout(function () {
415
+ $scope.updating = false;
416
+ $scope.$parent.checkInstalled();
417
+ }, 3000, $rootScope.module);
418
+ },
419
+ 'error': function (data) {
420
+ $scope.updateMsg = data.msg;
421
+ Timeout(function () {
422
+ $scope.updating = false;
423
+ }, 3000, $rootScope.module);
424
+ }
425
+ },
426
+ true
427
+ );
428
+ };
429
+ }]
430
+ };
431
+ }).
432
+ directive('srvext', function () {
433
+ return {
434
+ restrict: 'A',
435
+ transclude: true,
436
+ scope: {},
437
+ replace: true,
438
+ templateUrl: template_path + '/partials/directives/srvext.html',
439
+ controller: ['$rootScope', '$scope', 'Request', 'Timeout', 'Backend', function ($rootScope, $scope, Request, Timeout, Backend) {
440
+ $scope.$scope = $scope.$parent;
441
+
442
+ $scope.operating = false;
443
+ $scope.showMsg = '';
444
+
445
+ $scope.start = function () {
446
+ $scope.operating = true;
447
+ $scope.showMsg = '正在检测版本信息...';
448
+ Backend.call(
449
+ $scope.$parent,
450
+ $rootScope.module,
451
+ '/api/backend/yum_info',
452
+ '/api/backend/yum_info_' + $scope.pkg, {
453
+ 'pkg': $scope.pkg,
454
+ 'repo': 'installed'
455
+ }, {
456
+ 'wait': function (data) {
457
+ $scope.showMsg = data.msg;
458
+ },
459
+ 'success': function (data) {
460
+ $scope.showMsg = data.msg;
461
+ $scope.pkginfo = data.data[0];
462
+ $scope.checkExt();
463
+ },
464
+ 'error': function (data) {
465
+ $scope.showMsg = data.msg;
466
+ Timeout(function () {
467
+ $scope.operating = false;
468
+ }, 3000, $rootScope.module);
469
+ }
470
+ },
471
+ true
472
+ );
473
+ };
474
+
475
+ // check and list ext of the pkg
476
+ $scope.showExtList = false;
477
+ $scope.checkExt = function () {
478
+ $scope.operating = true;
479
+ $scope.showExtList = false;
480
+ $scope.showMsg = '正在检测扩展...';
481
+ Backend.call(
482
+ $scope.$parent,
483
+ $rootScope.module,
484
+ '/api/backend/yum_ext_info',
485
+ '/api/backend/yum_ext_info_' + $scope.pkginfo.name, {
486
+ 'pkg': $scope.pkginfo.name
487
+ }, {
488
+ 'wait': function (data) {
489
+ $scope.showMsg = data.msg;
490
+ },
491
+ 'success': function (data) {
492
+ $scope.showMsg = data.msg;
493
+ $scope.exts = data.data;
494
+ $scope.showExtList = true;
495
+ },
496
+ 'error': function (data) {
497
+ $scope.showMsg = data.msg;
498
+ Timeout(function () {
499
+ $scope.operating = false;
500
+ }, 3000, $rootScope.module);
501
+ }
502
+ },
503
+ true
504
+ );
505
+ };
506
+
507
+ // install specified version of ext in specified repository
508
+ $scope.install = function (repo, name, version, release) {
509
+ $scope.showMsg = '开始安装...';
510
+ $scope.showExtList = false;
511
+ Backend.call(
512
+ $scope.$parent,
513
+ $rootScope.module,
514
+ '/api/backend/yum_install',
515
+ '/api/backend/yum_install_' + repo + '_' + $scope.pkginfo.name + '_' + name + '_' + version + '_' + release, {
516
+ 'repo': repo,
517
+ 'pkg': $scope.pkginfo.name,
518
+ 'ext': name,
519
+ 'version': version,
520
+ 'release': release
521
+ }, {
522
+ 'wait': function (data) {
523
+ $scope.showMsg = data.msg;
524
+ },
525
+ 'success': function (data) {
526
+ $scope.showMsg = data.msg;
527
+ Timeout(function () {
528
+ $scope.operating = false;
529
+ $scope.checkExt();
530
+ }, 3000, $rootScope.module);
531
+ },
532
+ 'error': function (data) {
533
+ $scope.showMsg = data.msg;
534
+ Timeout(function () {
535
+ $scope.operating = false;
536
+ }, 3000, $rootScope.module);
537
+ }
538
+ },
539
+ true
540
+ );
541
+ };
542
+
543
+ // uninstall specified version of ext in specified repository
544
+ $scope.uninstall = function (repo, name, version, release) {
545
+ $scope.showMsg = '正在删除...';
546
+ $scope.showExtList = false;
547
+ Backend.call(
548
+ $scope.$parent,
549
+ $rootScope.module,
550
+ '/api/backend/yum_uninstall',
551
+ '/api/backend/yum_uninstall_' + $scope.pkginfo.name + '_' + name + '_' + version + '_' + release, {
552
+ 'repo': repo,
553
+ 'pkg': $scope.pkginfo.name,
554
+ 'ext': name,
555
+ 'version': version,
556
+ 'release': release
557
+ }, {
558
+ 'wait': function (data) {
559
+ $scope.showMsg = data.msg;
560
+ },
561
+ 'success': function (data) {
562
+ $scope.showMsg = data.msg;
563
+ Timeout(function () {
564
+ $scope.operating = false;
565
+ $scope.checkExt();
566
+ }, 3000, $rootScope.module);
567
+ },
568
+ 'error': function (data) {
569
+ $scope.showMsg = data.msg;
570
+ Timeout(function () {
571
+ $scope.operating = false;
572
+ }, 3000, $rootScope.module);
573
+ }
574
+ },
575
+ true
576
+ );
577
+ };
578
+ }]
579
+ };
580
+ }).
581
+ directive('srvuninstall', function () {
582
+ return {
583
+ restrict: 'A',
584
+ transclude: true,
585
+ scope: {},
586
+ replace: true,
587
+ templateUrl: template_path + '/partials/directives/srvuninstall.html',
588
+ controller: ['$rootScope', '$scope', 'Request', 'Timeout', 'Backend', function ($rootScope, $scope, Request, Timeout, Backend) {
589
+ $scope.$scope = $scope.$parent;
590
+
591
+ $scope.uninstalling = false;
592
+ $scope.uninstallMsg = '';
593
+
594
+ // check pkg version
595
+ $scope.startUninstall = function () {
596
+ $scope.uninstallMsg = '开始卸载...';
597
+ $scope.uninstalling = true;
598
+ Backend.call(
599
+ $scope.$parent,
600
+ $rootScope.module,
601
+ '/api/backend/yum_info',
602
+ '/api/backend/yum_info_' + $scope.pkg, {
603
+ 'pkg': $scope.pkg,
604
+ 'repo': 'installed'
605
+ }, {
606
+ 'wait': function (data) {
607
+ $scope.uninstallMsg = data.msg;
608
+ },
609
+ 'success': function (data) {
610
+ $scope.uninstallMsg = data.msg;
611
+ $scope.pkginfo = data.data[0];
612
+ $scope.showVersion = true;
613
+ },
614
+ 'error': function (data) {
615
+ $scope.uninstallMsg = data.msg;
616
+ Timeout(function () {
617
+ $scope.uninstalling = false;
618
+ }, 3000, $rootScope.module);
619
+ }
620
+ },
621
+ true
622
+ );
623
+ };
624
+
625
+ // uninstall specified version of pkg in specified repository
626
+ $scope.uninstall = function (repo, name, version, release) {
627
+ $scope.uninstallMsg = '正在卸载...';
628
+ $scope.showVersion = false;
629
+ Backend.call(
630
+ $scope.$parent,
631
+ $rootScope.module,
632
+ '/api/backend/yum_uninstall',
633
+ '/api/backend/yum_uninstall_' + name + '_' + version + '_' + release, {
634
+ 'repo': repo,
635
+ 'pkg': name,
636
+ 'version': version,
637
+ 'release': release
638
+ }, {
639
+ 'wait': function (data) {
640
+ $scope.uninstallMsg = data.msg;
641
+ },
642
+ 'success': function (data) {
643
+ $scope.uninstallMsg = data.msg;
644
+ Timeout(function () {
645
+ $scope.uninstalling = false;
646
+ $scope.$parent.checkInstalled();
647
+ }, 3000, $rootScope.module);
648
+ },
649
+ 'error': function (data) {
650
+ $scope.uninstallMsg = data.msg;
651
+ Timeout(function () {
652
+ $scope.uninstalling = false;
653
+ }, 3000, $rootScope.module);
654
+ }
655
+ },
656
+ true
657
+ );
658
+ };
659
+ }]
660
+ };
661
+ }).
662
+ directive('srvfile', function () {
663
+ return {
664
+ restrict: 'A',
665
+ transclude: true,
666
+ scope: {},
667
+ replace: true,
668
+ templateUrl: template_path + '/partials/directives/srvfile.html',
669
+ controller: ['$scope', function ($scope) { }]
670
+ };
671
+ }).
672
+ directive('srvlog', function () {
673
+ return {
674
+ restrict: 'A',
675
+ transclude: true,
676
+ scope: {},
677
+ replace: true,
678
+ templateUrl: template_path + '/partials/directives/srvlog.html',
679
+ controller: ['$scope', function ($scope) { }]
680
+ };
681
+ }).
682
+ directive('selector', function () {
683
+ return {
684
+ restrict: 'A',
685
+ transclude: true,
686
+ scope: {},
687
+ replace: true,
688
+ templateUrl: template_path + '/partials/directives/selector.html',
689
+ controller: ['$scope', 'Request', function ($scope, Request) {
690
+ $scope.$scope = $scope.$parent;
691
+ $scope.onlydir = true;
692
+ $scope.onlyfile = true;
693
+ $scope.path = '/';
694
+ var parse_path = function () {
695
+ // parse dir to array
696
+ if (!$scope.curpath) return;
697
+ var pathnames = $scope.curpath.split('/');
698
+ var pathinfos = [];
699
+ for (var i = 1; i < pathnames.length; i++) {
700
+ if (!pathnames[i]) continue;
701
+ var fullpath = pathnames[i - 1] + '/' + pathnames[i];
702
+ pathinfos.push({
703
+ 'name': pathnames[i],
704
+ 'path': fullpath
705
+ });
706
+ pathnames[i] = fullpath;
707
+ }
708
+ $scope.pathinfos = pathinfos;
709
+ };
710
+ $scope.load = function (path) {
711
+ if ($scope.onlyfile) {
712
+ $scope.otherdir = true;
713
+ $scope.listdir(path);
714
+ } else {
715
+ $scope.otherdir = false;
716
+ $scope.path = path;
717
+ }
718
+ };
719
+ $scope.listdir = function (path) {
720
+ if (path) $scope.path = path;
721
+ if (!$scope.path)
722
+ $scope.path = '/root';
723
+ else if ($scope.path != '/' && $scope.path.substr(-1) == '/')
724
+ $scope.path = $scope.path.substr(0, $scope.path.length - 1);
725
+ $scope.path = $scope.path.replace('//', '/');
726
+
727
+ var curpath = $scope.path;
728
+ Request.post('/api/operation/file', {
729
+ 'action': 'listdir',
730
+ 'path': curpath,
731
+ 'showhidden': false,
732
+ 'remember': false,
733
+ 'onlydir': $scope.onlydir
734
+ }, function (data) {
735
+ if (data.code == 0) {
736
+ $scope.items = data.data;
737
+ $scope.curpath = curpath;
738
+ $scope.lastpath = curpath;
739
+ $scope.curpath_pre = curpath == '/' ? '' : curpath;
740
+ } else {
741
+ $scope.path = $scope.lastpath;
742
+ }
743
+ parse_path();
744
+ }, false, true);
745
+ };
746
+ //$scope.listdir();
747
+ $scope.$parent.selector = $scope;
748
+ }]
749
+ };
750
+ }).
751
+ directive('autofocus', function () {
752
+ return function ($scope, element) {
753
+ element[0].focus();
754
+ };
755
+ }).
756
+ directive('waiting', function () {
757
+ return {
758
+ restrict: 'A',
759
+ transclude: true,
760
+ scope: {},
761
+ controller: ['$scope', function ($scope) {
762
+ $scope.waitingText = $scope.waitingText || '正在加载列表,请稍候......';
763
+ }],
764
+ template: '<div class="well"><img src="images/loading.gif" style="margin-right: 10px;">{{waitingText}}</div>',
765
+ replace: true
766
+ };
767
+ }).
768
+ directive('plugins', function () {
769
+ return {
770
+ restrict: 'A',
771
+ transclude: true,
772
+ scope: {
773
+ 'pluginsName': '='
774
+ },
775
+ replace: true,
776
+ templateUrl: template_path + '/plugins/acme/static/index.html',
777
+ link: function ($scope, $element, $attrs, ctrl) {
778
+ console.log($scope.pluginsName);
779
+ },
780
+ controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
781
+ $rootScope.navbar_loaded = true;
782
+ }]
783
+ };
784
+ });