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,395 @@
1
+ angular.module('inpanel.filters', []).
2
+ filter('iftrue', function () {
3
+ return function (input, cond) {
4
+ return cond ? input : '';
5
+ };
6
+ }).
7
+ filter('ifmatch', function () {
8
+ return function (input, cond) {
9
+ return cond[0].match(new RegExp('^' + cond[1] + '$')) ? input : '';
10
+ };
11
+ }).
12
+ filter('ifnotmatch', function () {
13
+ return function (input, cond) {
14
+ return cond[0].match(new RegExp('^' + cond[1] + '$')) ? '' : input;
15
+ };
16
+ }).
17
+ filter('ifin', function () {
18
+ return function (input, cond) {
19
+ return typeof cond[1][cond[0]] != 'undefined' ? input : '';
20
+ };
21
+ }).
22
+ filter('ifnotin', function () {
23
+ return function (input, cond) {
24
+ return typeof cond[1][cond[0]] != 'undefined' ? '' : input;
25
+ };
26
+ }).
27
+ filter('ifverget', function () { // version great or equal then
28
+ return function (input, cond) {
29
+ if (!cond[0] || !cond[1]) return '';
30
+ var v1parts = cond[0].split('.');
31
+ var v2parts = cond[1].split('.');
32
+ for (var i = 0; i < v1parts.length; i++) {
33
+ if (v2parts.length == i) {
34
+ return input;
35
+ }
36
+ if (v1parts[i] == v2parts[i]) {
37
+ continue;
38
+ } else if (v1parts[i] > v2parts[i]) {
39
+ return input;
40
+ } else {
41
+ return '';
42
+ }
43
+ }
44
+ if (v1parts.length != v2parts.length) {
45
+ return '';
46
+ }
47
+ return input;
48
+ };
49
+ }).
50
+ filter('urlencode', function () {
51
+ return function (input) {
52
+ return input ? encodeURIComponent(input) : '';
53
+ };
54
+ }).
55
+ filter('datetime', function () {
56
+ return function (input) {
57
+ function fix(x) {
58
+ return x < 10 ? '0' + x : x
59
+ }
60
+ var t = input ? new Date(input) : new Date()
61
+ var y = t.getFullYear()
62
+ var m = fix(t.getMonth() + 1)
63
+ var d = fix(t.getDate())
64
+ var h = fix(t.getHours())
65
+ var mi = fix(t.getMinutes())
66
+ var s = fix(t.getSeconds())
67
+ return y + '-' + m + '-' + d + ' ' + h + ':' + mi + ':' + s
68
+ };
69
+ }).
70
+ filter('netiface.updown', function () {
71
+ return function (input) {
72
+ return input == 'up' ?
73
+ '<span class="label label-success">启用</span>' :
74
+ '<span class="label label-warning">停用</span>';
75
+ };
76
+ }).
77
+ filter('netiface.encap', function () {
78
+ return function (input) {
79
+ if (input == 'Local Loopback') return '本地回环';
80
+ if (input == 'Ethernet') return '以太网';
81
+ if (input == 'Point-to-Point Protocol') return '点对点';
82
+ if (input == 'UNSPEC') return '未识别';
83
+ return input;
84
+ };
85
+ }).
86
+ filter('loadavg.overload', function () {
87
+ return function (input, cpucount) {
88
+ if (!input) return '';
89
+ var overload = input - cpucount;
90
+ overload = parseInt(overload * 100 / cpucount);
91
+ if (overload < 0) {
92
+ return '<span class="label label-success">' + Math.abs(overload) + '%空闲</span>';
93
+ } else {
94
+ if (overload > 100) {
95
+ return '<span class="label label-danger">' + overload + '%过载</span>';
96
+ } else {
97
+ return '<span class="label label-warning">' + overload + '%过载</span>';
98
+ }
99
+ }
100
+ };
101
+ }).
102
+ filter('uptime.idlerate', function () {
103
+ return function (input) {
104
+ if (!input) return '';
105
+ var rate = parseInt(input);
106
+ if (rate < 10) {
107
+ return '<span class="label label-default">' + input + '空闲</span>';
108
+ } else if (rate < 25) {
109
+ return '<span class="label label-warning">' + input + '空闲</span>';
110
+ } else {
111
+ return '<span class="label label-success">' + input + '空闲</span>';
112
+ }
113
+ };
114
+ }).
115
+ filter('space.used', function () {
116
+ return function (input) {
117
+ if (!input) return '';
118
+ var rate = parseInt(input);
119
+ if (rate > 90) {
120
+ return '<span class="label label-danger">' + input + '</span>';
121
+ } else if (rate > 75) {
122
+ return '<span class="label label-warning">' + input + '</span>';
123
+ } else {
124
+ return '<span class="label label-success">' + input + '</span>';
125
+ }
126
+ };
127
+ }).
128
+ filter('space.free', function () {
129
+ return function (input) {
130
+ if (!input) return '';
131
+ var rate = parseInt(input);
132
+ if (rate < 10) {
133
+ return '<span class="label label-default">' + input + '</span>';
134
+ } else if (rate < 25) {
135
+ return '<span class="label label-warning">' + input + '</span>';
136
+ } else {
137
+ return '<span class="label label-success">' + input + '</span>';
138
+ }
139
+ };
140
+ }).
141
+ filter('space.available', function () {
142
+ return function (input) {
143
+ if (!input) return '';
144
+ var rate = parseInt(input);
145
+ if (rate < 10) {
146
+ return '<span class="label label-default">' + input + '</span>';
147
+ } else if (rate < 25) {
148
+ return '<span class="label label-warning">' + input + '</span>';
149
+ } else {
150
+ return '<span class="label label-success">' + input + '</span>';
151
+ }
152
+ };
153
+ }).
154
+ filter('service.status', function () {
155
+ return function (input) {
156
+ if (!input) return '<span class="label label-info">未安装</span>';
157
+ return input == 'running' ?
158
+ '<span class="label label-success">运行中</span>' :
159
+ '<span class="label label-default">已停止</span>';
160
+ };
161
+ }).
162
+ filter('user.lock', function () {
163
+ return function (input) {
164
+ return input ?
165
+ '<span class="label label-default">锁定</span>' :
166
+ '<span class="label label-success">正常</span>';
167
+ };
168
+ }).
169
+ filter('process.status', function () {
170
+ return function (input) {
171
+ var status_type = {
172
+ 'R': '<span class="label label-success">运行</span>',
173
+ 'S': '<span class="label label-primary">休眠</span>',
174
+ 'D': '<span class="label label-warning">等待</span>',
175
+ 'T': '<span class="label label-info">停止</span>',
176
+ 'Z': '<span class="label label-danger">退出</span>',
177
+ 'X': '<span class="label label-default">已退出</span>'
178
+ };
179
+ if (status_type.hasOwnProperty(input)) {
180
+ return status_type[input];
181
+ } else {
182
+ return '<span class="label label-default">未知</span>';
183
+ }
184
+ };
185
+ }).
186
+ filter('site.status', function () {
187
+ return function (input) {
188
+ return input == 'on' ?
189
+ '<span class="label label-success">启用</span>' :
190
+ '<span class="label label-default">停用</span>';
191
+ };
192
+ }).
193
+ filter('site.engine', function () {
194
+ return function (input) {
195
+ if (input == 'static')
196
+ return '静态';
197
+ else if (input == 'fastcgi')
198
+ return 'FastCGI';
199
+ else if (input == 'scgi')
200
+ return 'SCGI';
201
+ else if (input == 'uwsgi')
202
+ return 'uWSGI';
203
+ else if (input == 'redirect')
204
+ return '跳转';
205
+ else if (input == 'rewrite')
206
+ return '重写';
207
+ else if (input == 'proxy')
208
+ return '反代';
209
+ else if (input == 'return')
210
+ return '错误';
211
+ else
212
+ return input;
213
+ };
214
+ }).
215
+ filter('site.ip', function () {
216
+ return function (input) {
217
+ return input && input.indexOf(':') > -1 ? '[' + input + ']' : input;
218
+ };
219
+ }).
220
+ filter('site.port', function () {
221
+ return function (input) {
222
+ if (input == '80')
223
+ return 'http';
224
+ else if (input == '443')
225
+ return 'https';
226
+ else
227
+ return ''
228
+ };
229
+ }).
230
+ filter('site.default_server', function () {
231
+ return function (input) {
232
+ return !input ? '<span class="label label-info">默认</span>' : '';
233
+ };
234
+ }).
235
+ filter('bytes2human', function () {
236
+ return function (n) {
237
+ if (!n) return 0;
238
+ var symbols = ['G', 'M', 'K'];
239
+ var x = symbols.length;
240
+ var units = [];
241
+ for (var i = 0; i < x; i++) {
242
+ units[i] = 1 << (x - i) * 10;
243
+ }
244
+ for (var i = 0; i < x; i++)
245
+ if (n >= units[i])
246
+ return Math.round((n / units[i]) * 10) / 10 + symbols[i];
247
+ return n + 'B';
248
+ };
249
+ }).
250
+ filter('mysql.user', function () {
251
+ return function (input) {
252
+ return input == '' ? '<span class="text-error">任意</span>' : input;
253
+ };
254
+ }).
255
+ filter('mysql.haspasswd', function () {
256
+ return function (input) {
257
+ return input == 'N' ? '<span class="text-error">否</span>' : '是';
258
+ };
259
+ }).
260
+ filter('mysql.grant', function () {
261
+ return function (input) {
262
+ return input == 'N' ? '否' : '是';
263
+ };
264
+ }).
265
+ filter('mysql.privtype', function () {
266
+ return function (input, dbname) {
267
+ if (input == '*' || input == '') return '全局指定';
268
+ if (input == dbname) return '按数据库指定';
269
+ return '通配符';
270
+ };
271
+ }).
272
+ filter('mysql.privtype_en', function () {
273
+ return function (input, dbname) {
274
+ if (input == '*' || input == '') return 'global';
275
+ if (input == dbname) return 'bydb';
276
+ return 'wildcard';
277
+ };
278
+ }).
279
+ filter('mysql.privs', function () {
280
+ return function (user, type) {
281
+ if (!user) return '---';
282
+ var privs = [
283
+ 'Select_priv',
284
+ 'Insert_priv',
285
+ 'Update_priv',
286
+ 'Delete_priv',
287
+ 'Create_priv',
288
+ 'Alter_priv',
289
+ 'Index_priv',
290
+ 'Drop_priv',
291
+ 'Create_tmp_table_priv',
292
+ 'Show_view_priv',
293
+ 'Create_routine_priv',
294
+ 'Alter_routine_priv',
295
+ 'Execute_priv',
296
+ 'Create_view_priv',
297
+ 'Event_priv',
298
+ 'Trigger_priv',
299
+ 'Lock_tables_priv',
300
+ 'References_priv'
301
+ ];
302
+ var global_privs = [
303
+ 'File_priv',
304
+ 'Super_priv',
305
+ 'Process_priv',
306
+ 'Reload_priv',
307
+ 'Shutdown_priv',
308
+ 'Show_db_priv',
309
+ 'Repl_client_priv',
310
+ 'Repl_slave_priv',
311
+ 'Create_user_priv'
312
+ //'Create_tablespace_priv'
313
+ ];
314
+ if (type == 'global') privs = privs.concat(global_privs);
315
+
316
+ var privs_count = 0;
317
+ for (var i = 0; i < privs.length; i++) {
318
+ if (user[privs[i]] == 'Y') privs_count++;
319
+ }
320
+ if (privs_count == 0) {
321
+ return type == 'global' ? '无全局权限' : '无权限';
322
+ } else if (privs_count == privs.length) {
323
+ return '所有权限';
324
+ } else {
325
+ return '部分权限';
326
+ }
327
+ };
328
+ }).
329
+ filter('account.status', function () {
330
+ return function (input) {
331
+ return input ?
332
+ '<span class="label label-success">启用管理</span>' :
333
+ '<span class="label">停用管理</span>';
334
+ };
335
+ }).
336
+ filter('account.secret', function () {
337
+ return function (input) {
338
+ var s = '';
339
+ for (var i = 0; i < input.length; i++) {
340
+ s += '*'
341
+ }
342
+ return s;
343
+ };
344
+ }).
345
+ filter('instance.status', function () {
346
+ return function (input) {
347
+ if (!input) return '';
348
+ input = input.toLowerCase();
349
+ if (input == 'pending') return '<span class="label">待启动</span>';
350
+ if (input == 'starting') return '<span class="label label-info">正在启动</span>';
351
+ if (input == 'startfailure') return '<span class="label label-important">启动失败</span>';
352
+ if (input == 'running') return '<span class="label label-success">运行中</span>';
353
+ if (input == 'stopping') return '<span class="label label-info">正在停止</span>';
354
+ if (input == 'stopfailure') return '<span class="label label-important">停止失败</span>';
355
+ if (input == 'transferring') return '<span class="label label-info">正在迁移</span>';
356
+ if (input == 'stopped') return '<span class="label label-warning">已停止</span>';
357
+ if (input == 'released') return '<span class="label label-inverse">已释放</span>';
358
+ if (input == 'resetting') return '<span class="label label-info">正在重置</span>';
359
+ if (input == 'resetfailure') return '<span class="label label-important">重置失败</span>';
360
+ };
361
+ }).
362
+ filter('instance.inpanelstatus', function () {
363
+ return function (input) {
364
+ return input ? '<span class="label label-success">已配置</span>' :
365
+ '<span class="label">未配置</span>';
366
+ };
367
+ }).
368
+ filter('instance.datacenter', function () {
369
+ return function (input) {
370
+ if (!input) return '';
371
+ input = input.toLowerCase();
372
+ if (input.indexOf('cn-benjin-btc') != -1) return '中国北京北土城 (' + input + ')';
373
+ if (input.indexOf('cn-hangzhou-dg') != -1) return '中国杭州东冠 (' + input + ')';
374
+ if (input.indexOf('cn-hangzhou-xy') != -1) return '中国杭州兴义 (' + input + ')';
375
+ if (input.indexOf('cn-benjin') != -1) return '中国北京 (' + input + ')';
376
+ if (input.indexOf('cn-hangzhou') != -1) return '中国杭州 (' + input + ')';
377
+ if (input.indexOf('cn-shanghai') != -1) return '中国上海 (' + input + ')';
378
+ return input;
379
+ };
380
+ }).
381
+ filter('disk.type', function () {
382
+ return function (input) {
383
+ if (!input) return '';
384
+ input = input.toLowerCase();
385
+ if (input == 'system') return '系统盘';
386
+ if (input == 'data') return '数据盘';
387
+ return input;
388
+ };
389
+ }).
390
+ filter('snapshot.time', function () {
391
+ return function (input) {
392
+ if (!input) return '';
393
+ return input.replace('T', ' ').replace('Z', ' ');
394
+ };
395
+ });
@@ -0,0 +1,257 @@
1
+ angular.module('inpanel.services', []).
2
+ factory('Auth', ['$rootScope', '$http', '$location', function ($scope, $http, $location) {
3
+ var Auth = {};
4
+ Auth.required = function (callback, errCallback) {
5
+ $http.post('/api/authstatus').success(function (data) {
6
+ if (callback) callback.call(null, data.authed == 'yes');
7
+ if (data.authed == 'no') {
8
+ $scope.loginto = $location.path();
9
+ $scope.loginto_section = $location.search().s;
10
+ if ($scope.loginto == '/login' || $scope.loginto == '/logout') {
11
+ $scope.loginto = '/';
12
+ $scope.loginto_section = '';
13
+ }
14
+ $location.path('/login');
15
+ $scope.sec(null);
16
+ }
17
+ }).error(function (data, status) {
18
+ if (errCallback) errCallback.call(null, status);
19
+ });
20
+ };
21
+ Auth.getlastactive = function (callback) {
22
+ $http.get('/api/authstatus?' + Math.random()).success(function (data) {
23
+ if (callback) callback.call(null, data.lastactive);
24
+ });
25
+ };
26
+ return Auth;
27
+ }]).
28
+ factory('Module', ['$rootScope', '$location', function ($scope, $location) {
29
+ var Module = {}
30
+ Module.init = function (module, htmlTitle) {
31
+ $scope.module = module;
32
+ $scope.htmlTitle = htmlTitle;
33
+ };
34
+ Module.initSection = function (defaultSec) {
35
+ var section = $location.search().s;
36
+ $scope.activeTabName = section ? section : defaultSec;
37
+ };
38
+ Module.getSection = function () {
39
+ return $location.search().s;
40
+ };
41
+ Module.setSection = function (sec) {
42
+ $scope.activeTabName = sec;
43
+ };
44
+ Module.getParam = function (p) {
45
+ return $location.search()[p];
46
+ };
47
+ return Module;
48
+ }]).
49
+ factory('Timeout', ['$rootScope', '$timeout', function ($scope, $timeout) {
50
+ var Timeout = function (func, secs, module, singleton, timeout_name) {
51
+ if (module && $scope.module != module) return;
52
+ if (singleton && $scope[timeout_name]) return;
53
+ if (!timeout_name) timeout_name = 'timeout';
54
+ $scope[timeout_name] = $timeout(function () {
55
+ if ($scope[timeout_name]) delete $scope[timeout_name];
56
+ if (!module || $scope.module == module) func.call();
57
+ }, secs);
58
+ };
59
+ return Timeout;
60
+ }]).
61
+ factory('Message', ['$rootScope', '$timeout', function ($scope, $timeout) {
62
+ var Message = {};
63
+ $scope.showSuccessMsg = false;
64
+ $scope.showErrorMsg = false;
65
+ $scope.showWarningMsg = false;
66
+ $scope.showInfoMsg = false;
67
+ $scope.msgTimeout = 0;
68
+
69
+ var delayClearMsg = function () {
70
+ if ($scope.msgTimeout) $timeout.cancel($scope.msgTimeout);
71
+ $scope.msgTimeout = $timeout(function () {
72
+ $scope.showSuccessMsg = false;
73
+ $scope.showErrorMsg = false;
74
+ $scope.showInfoMsg = false;
75
+ $scope.msgTimeout = 0;
76
+ }, 5000);
77
+ };
78
+
79
+ Message.setSuccess = function (msg, keepMsg) {
80
+ $scope.successMessage = msg;
81
+ if (msg) {
82
+ $scope.showSuccessMsg = true;
83
+ $scope.showErrorMsg = false;
84
+ $scope.showInfoMsg = false;
85
+ if (!keepMsg) delayClearMsg();
86
+ } else {
87
+ $scope.showSuccessMsg = false;
88
+ $scope.showErrorMsg = false;
89
+ $scope.showInfoMsg = false;
90
+ }
91
+ };
92
+
93
+ Message.setError = function (msg, keepMsg) {
94
+ $scope.errorMessage = msg;
95
+ if (msg) {
96
+ $scope.showSuccessMsg = false;
97
+ $scope.showErrorMsg = true;
98
+ $scope.showInfoMsg = false;
99
+ if (!keepMsg) delayClearMsg();
100
+ } else {
101
+ $scope.showSuccessMsg = false;
102
+ $scope.showErrorMsg = false;
103
+ $scope.showInfoMsg = false;
104
+ }
105
+ };
106
+
107
+ Message.setInfo = function (msg, keepMsg) {
108
+ $scope.infoMessage = msg;
109
+ if (msg) {
110
+ $scope.showSuccessMsg = false;
111
+ $scope.showErrorMsg = false;
112
+ $scope.showInfoMsg = true;
113
+ if (!keepMsg) delayClearMsg();
114
+ } else {
115
+ $scope.showSuccessMsg = false;
116
+ $scope.showErrorMsg = false;
117
+ $scope.showInfoMsg = false;
118
+ }
119
+ };
120
+
121
+ Message.setWarning = function (msg, keepMsg) {
122
+ $scope.warningMessage = msg;
123
+ if (msg) {
124
+ $scope.showWarningMsg = true;
125
+ if (!keepMsg) delayClearMsg();
126
+ } else {
127
+ $scope.showWarningMsg = false;
128
+ }
129
+ };
130
+
131
+ return Message;
132
+ }]).
133
+ factory('Request', ['$http', '$rootScope', '$location', '$timeout', 'Message', function ($http, $scope, $location, $timeout, Message) {
134
+ var Request = {};
135
+
136
+ var _successFuncBinder = function (callback, quiet) {
137
+ return function (data) {
138
+ $scope.processing = false;
139
+ if (!quiet && data.msg) {
140
+ if (data.code == 0) {
141
+ Message.setSuccess(data.msg);
142
+ } else if (data.code == -1) {
143
+ Message.setError(data.msg);
144
+ } else if (data.code == 1) {
145
+ Message.setWarning(data.msg);
146
+ } else if (data.code == 2) {
147
+ Message.setInfo(data.msg);
148
+ }
149
+ }
150
+ if (callback) callback.call(null, data);
151
+ };
152
+ };
153
+
154
+ var _errorFuncBinder = function (callback, quiet) {
155
+ return function (data, status) {
156
+ $scope.processing = false;
157
+ if (!quiet && callback) {
158
+ if (!callback.call(null, data, status)) return;
159
+ }
160
+ if (status == 403) {
161
+ Message.setError('登录无效或超时,请重新登录。', true);
162
+ $scope.loginto = $location.path();
163
+ $scope.loginto_section = $location.search().s;
164
+ if ($scope.loginto == '/login' || $scope.loginto == '/logout') {
165
+ $scope.loginto = '/';
166
+ $scope.loginto_section = '';
167
+ }
168
+ $location.path('/login');
169
+ $scope.sec(null);
170
+ } else {
171
+ Message.setError('发生未知错误!');
172
+ }
173
+ };
174
+ };
175
+
176
+ Request.setProcessing = function (processing) {
177
+ $scope.processing = processing;
178
+ };
179
+
180
+ Request.get = function (url, callback, errcallback, quiet) {
181
+ $scope.processing = true;
182
+ var rurl = $scope.$proxyroot + url;
183
+ if (rurl.indexOf('?') > 0)
184
+ rurl += '&' + Math.random();
185
+ else
186
+ rurl += '?' + Math.random();
187
+ $http.get(rurl)
188
+ .success(_successFuncBinder(callback, quiet))
189
+ .error(_errorFuncBinder(errcallback, quiet));
190
+ };
191
+
192
+ Request.post = function (url, data, callback, errcallback, quiet) {
193
+ $scope.processing = true;
194
+ $http.post($scope.$proxyroot + url, data)
195
+ .success(_successFuncBinder(callback, quiet))
196
+ .error(_errorFuncBinder(errcallback, quiet));
197
+ };
198
+
199
+ return Request;
200
+ }]).
201
+ factory('Backend', ['Timeout', 'Request', function (Timeout, Request) {
202
+ var Backend = {};
203
+
204
+ Backend.call = function ($scope, module, url, statusUrl, data, callback, quiet) {
205
+ $scope.waiting = true;
206
+ Request.post(url, data, function (data) {
207
+ if (data.code == -1) {
208
+ if (callback) {
209
+ if (typeof callback.error == 'function') {
210
+ callback.error.call(null, data.data);
211
+ }
212
+ }
213
+ return;
214
+ }
215
+ var getStatus = function () {
216
+ Request.get(statusUrl, function (data) {
217
+ if (data.status == 'finish') {
218
+ $scope.waiting = false;
219
+ if (data.code == 0) {
220
+ if (callback) {
221
+ if (typeof callback == 'function') {
222
+ callback.call(null, data);
223
+ } else if (typeof callback.success == 'function') {
224
+ callback.success.call(null, data);
225
+ }
226
+ }
227
+ } else {
228
+ if (callback) {
229
+ if (typeof callback == 'function'){
230
+ callback.call(null, data);
231
+ } else if (typeof callback.error == 'function') {
232
+ callback.error.call(null, data);
233
+ }
234
+ }
235
+ }
236
+ } else {
237
+ if (callback) {
238
+ if (typeof callback.wait == 'function') {
239
+ callback.wait.call(null, data);
240
+ }
241
+ }
242
+ Timeout(getStatus, 500, module);
243
+ }
244
+ }, false, quiet);
245
+ };
246
+ Timeout(getStatus, 500, module);
247
+ }, function (data) {
248
+ if (callback) {
249
+ if (typeof callback.error == 'function') {
250
+ callback.error.call(null, data);
251
+ }
252
+ }
253
+ });
254
+ };
255
+
256
+ return Backend;
257
+ }]);
@@ -0,0 +1,10 @@
1
+ /*
2
+ AngularJS v1.0.2
3
+ (c) 2010-2012 Google, Inc. http://angularjs.org
4
+ License: MIT
5
+ */
6
+ (function(A,f,u){'use strict';f.module("ngResource",["ng"]).factory("$resource",["$http","$parse",function(v,w){function g(b,c){return encodeURIComponent(b).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(c?null:/%20/g,"+")}function l(b,c){this.template=b+="#";this.defaults=c||{};var a=this.urlParams={};j(b.split(/\W/),function(c){c&&b.match(RegExp("[^\\\\]:"+c+"\\W"))&&(a[c]=!0)});this.template=b.replace(/\\:/g,":")}function s(b,c,a){function f(d){var b=
7
+ {};j(c||{},function(a,x){var m;a.charAt&&a.charAt(0)=="@"?(m=a.substr(1),m=w(m)(d)):m=a;b[x]=m});return b}function e(a){t(a||{},this)}var y=new l(b),a=r({},z,a);j(a,function(d,g){var l=d.method=="POST"||d.method=="PUT"||d.method=="PATCH";e[g]=function(a,b,c,g){var i={},h,k=o,p=null;switch(arguments.length){case 4:p=g,k=c;case 3:case 2:if(q(b)){if(q(a)){k=a;p=b;break}k=b;p=c}else{i=a;h=b;k=c;break}case 1:q(a)?k=a:l?h=a:i=a;break;case 0:break;default:throw"Expected between 0-4 arguments [params, data, success, error], got "+
8
+ arguments.length+" arguments.";}var n=this instanceof e?this:d.isArray?[]:new e(h);v({method:d.method,url:y.url(r({},f(h),d.params||{},i)),data:h}).then(function(a){var b=a.data;if(b)d.isArray?(n.length=0,j(b,function(a){n.push(new e(a))})):t(b,n);(k||o)(n,a.headers)},p);return n};e.bind=function(d){return s(b,r({},c,d),a)};e.prototype["$"+g]=function(a,b,d){var c=f(this),i=o,h;switch(arguments.length){case 3:c=a;i=b;h=d;break;case 2:case 1:q(a)?(i=a,h=b):(c=a,i=b||o);case 0:break;default:throw"Expected between 1-3 arguments [params, success, error], got "+
9
+ arguments.length+" arguments.";}e[g].call(this,c,l?this:u,i,h)}});return e}var z={get:{method:"GET"},save:{method:"POST"},query:{method:"GET",isArray:!0},remove:{method:"DELETE"},"delete":{method:"DELETE"}},o=f.noop,j=f.forEach,r=f.extend,t=f.copy,q=f.isFunction;l.prototype={url:function(b){var c=this,a=this.template,f,b=b||{};j(this.urlParams,function(e,d){f=g(b[d]||c.defaults[d]||"",!0).replace(/%26/gi,"&").replace(/%3D/gi,"=").replace(/%2B/gi,"+");a=a.replace(RegExp(":"+d+"(\\W)"),f+"$1")});var a=
10
+ a.replace(/\/?#$/,""),e=[];j(b,function(a,b){c.urlParams[b]||e.push(g(b)+"="+g(a))});e.sort();a=a.replace(/\/*$/,"");return a+(e.length?"?"+e.join("&"):"")}};return s}])})(window,window.angular);