process.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. {template 'common/header'}
  2. <script type="text/javascript">
  3. <!--
  4. var packet = {php echo ($packet ? json_encode($packet) : 'null');};
  5. angular.module('cloudApp');
  6. angular.module('cloudApp')
  7. .controller('FileProcessorCtrl', function($scope, $http, config) {
  8. $scope.files = config.files;
  9. $scope.fails = [];
  10. var total = $scope.files.length;
  11. var i = 1;
  12. var errormsg = '';
  13. var tasknum = config.tasknum && config.type != '' ? config.tasknum : 1;
  14. if (tasknum > total) {
  15. tasknum = 1;
  16. }
  17. var proc = function() {
  18. var path = $scope.files.pop();
  19. if(!path && i >= total) {
  20. if ($scope.fails && $scope.fails.length > 0) {
  21. util.message('文件同步失败,可能是目录权限问题,请重试同步成功后继续。', './index.php?c=cloud&a=upgrade&', 'info');
  22. } else {
  23. var targetUrl = '';
  24. if (config.type == 'theme') {
  25. targetUrl = './index.php?c=cloud&a=process&step=schemas&t=' + config.appname + '&is_upgrade=' + config.is_upgrade;
  26. } else if (config.type == 'webtheme') {
  27. targetUrl = './index.php?c=cloud&a=process&step=schemas&w=' + config.appname + '&is_upgrade=' + config.is_upgrade;
  28. } else {
  29. targetUrl = './index.php?c=cloud&a=process&step=schemas&m=' + config.appname + '&is_upgrade=' + config.is_upgrade + '&batch=1&support=' + config.account_type + '&has_new_support={$has_new_support}';
  30. }
  31. util.message('文件同步完成,正在处理数据同步......', targetUrl, 'success');
  32. }
  33. return;
  34. }
  35. $scope.file = path;
  36. $scope.pragress = i + '/' + total;
  37. $scope.pragressPer = Math.floor((i / total) * 100);
  38. $scope.topPragress = $scope.pragressPer < 50 ? $scope.pragressPer * 3.6 - 135 : 45;
  39. $scope.bottomPragress = $scope.pragressPer > 50 ? ($scope.pragressPer - 50) * 3.6 - 135 : -135;
  40. var params = {path: path, type : config.type};
  41. $http.post(location.href, params).success(function(dat){
  42. i++;
  43. if(dat != 'success') {
  44. $scope.fails.push('['+dat+'] ' + path);
  45. errormsg = dat;
  46. }
  47. proc();
  48. }).error(function(){
  49. i++;
  50. $scope.fails.push(path);
  51. proc();
  52. });
  53. }
  54. for (j = 0; j < tasknum; j++) {
  55. proc();
  56. }
  57. })
  58. .controller('SchemasProcessorCtrl', function($scope, $http, config){
  59. if (packet && (packet.files.length > 0)) {
  60. util.message('请先完成文件同步', './index.php?c=cloud&a=upgrade');
  61. return false;
  62. }
  63. $scope.schemas = config.schemas;
  64. $scope.fails = [];
  65. var is_m_install = config.is_module_install;
  66. var total = $scope.schemas.length;
  67. var i = 1;
  68. var error = function() {
  69. util.message('未能成功执行处理数据库, 请联系开发商解决. ');
  70. }
  71. var proc = function() {
  72. var schema = $scope.schemas.pop();
  73. if(!schema) {
  74. if($scope.fails.length > 0) {
  75. error();
  76. return;
  77. } else {
  78. if(is_m_install == 1) {
  79. location.href = '';
  80. } else {
  81. location.href = '';
  82. }
  83. return;
  84. }
  85. }
  86. $scope.schema = schema;
  87. $scope.pragress = i + '/' + total;
  88. $scope.pragressPer = Math.floor((i / total) * 100);
  89. $scope.topPragress = $scope.pragressPer < 50 ? $scope.pragressPer * 3.6 - 135 : 45;
  90. $scope.bottomPragress = $scope.pragressPer > 50 ? ($scope.pragressPer - 50) * 3.6 - 135 : -135;
  91. var params = {table: schema};
  92. $http.post(location.href, params).success(function(dat){
  93. i++;
  94. if(dat != 'success') {
  95. $scope.fails.push(schema)
  96. }
  97. if (dat['message']) {
  98. util.message(dat['message']);
  99. return;
  100. }
  101. proc();
  102. }).error(function(){
  103. i++;
  104. $scope.fails.push(schema);
  105. proc();
  106. });
  107. }
  108. proc();
  109. })
  110. .controller('processor', function($scope, $http){
  111. if (packet && (packet.files.length > 0 || packet.files.schemas > 0)) {
  112. util.message('请先完成文件或是数据库同步', './index.php?c=cloud&a=upgrade');
  113. return false;
  114. }
  115. $scope.scripts = {php echo json_encode($scripts);};
  116. $scope.fails = [];
  117. var is_upgrade = "{php echo $is_upgrade}";
  118. var total = $scope.scripts.length;
  119. var i = 1;
  120. var error = function() {
  121. util.message('未能成功执行清理升级操作, 请联系开发者. ');
  122. }
  123. var proc = function() {
  124. var script = $scope.scripts.shift();
  125. if(!script) {
  126. if($scope.fails.length > 0) {
  127. error();
  128. } else {
  129. if(is_upgrade == 1) {
  130. {if $_GPC['batch']}
  131. location.href = '{url "system/module/upgrade" array("m" => $m, "flag" => 1, "batch_from_cloud" => 1)}';
  132. {else}
  133. location.href = '{url "system/module/upgrade" array("m" => $m, "flag" => 1)}';
  134. {/if}
  135. return;
  136. }
  137. var is_confirm = "{php echo $_GPC['is_confirm']}";
  138. if(is_confirm == 1) {
  139. if(confirm('已经成功执行升级操作! '+"\n"+' 由于数据库更新, 可能会产生多余的字段. 你可以按照需要删除')) {
  140. location.href = '{url "cloud/upgrade"}';
  141. } else {
  142. location.href = '{url "cloud/upgrade"}';
  143. }
  144. } else {
  145. util.message('已经成功执行升级操作! '+"\n"+' 由于数据库更新, 可能会产生多余的字段. 你可以按照需要删除.', '{url "cloud/upgrade"}');
  146. }
  147. return;
  148. }
  149. }
  150. $scope.script = script.fname;
  151. $scope.message = script.message;
  152. $scope.pragress = i + '/' + total;
  153. $scope.pragressPer = Math.floor((i / total) * 100);
  154. $scope.topPragress = $scope.pragressPer < 50 ? $scope.pragressPer * 3.6 - 135 : 45;
  155. $scope.bottomPragress = $scope.pragressPer > 50 ? ($scope.pragressPer - 50) * 3.6 - 135 : -135;
  156. var params = {fname: script.fname};
  157. $http.post(location.href, params).success(function(dat){
  158. i++;
  159. if(dat != 'success') {
  160. $scope.fails.push(script.fname)
  161. error();
  162. return;
  163. }
  164. proc();
  165. }).error(function(){
  166. i++;
  167. $scope.fails.push(script.fname);
  168. error();
  169. });
  170. }
  171. proc();
  172. });
  173. //-->
  174. </script>
  175. {if $step == 'files'}
  176. {if !empty($_GPC['m'])}
  177. <ul class="we7-step">
  178. <li class="active"><span class="content">1 安装应用</span></li>
  179. <li ><span class="content">2 分配应用权限</span> </li>
  180. <li><span class="content">3 安装成功</span> </li>
  181. </ul>
  182. {/if}
  183. <div class="clearfix js-processor" ng-controller="FileProcessorCtrl" ng-cloak>
  184. <div class="upgrade-pragress we7-margin-bottom">
  185. <div class="wrapper top">
  186. <div class="circleProgress topcircle" ng-style="{transform: 'rotate('+ topPragress +'deg)'}"></div>
  187. </div>
  188. <div class="wrapper bottom">
  189. <div class="circleProgress bottomcircle" ng-style="{transform: 'rotate('+ bottomPragress +'deg)'}"></div>
  190. </div>
  191. <div class="circle">
  192. <img src="./resource/images/upgrade.png" alt="">
  193. <div class="pragress">
  194. {{pragressPer}}%
  195. </div>
  196. </div>
  197. </div>
  198. <div class="alert we7-page-alert">
  199. 正在更新系统文件, 请不要关闭窗口
  200. </div>
  201. <div class="alert we7-page-alert">
  202. 如果下载文件失败,可能造成的原因:写入失败,请仔细检查写入权限是否正确。
  203. </div>
  204. <div class="alert alert-info form-horizontal ng-cloak" >
  205. <dl class="dl-horizontal">
  206. <dt>整体进度</dt>
  207. <dd>{{pragress}}</dd>
  208. <dt>正在下载文件</dt>
  209. <dd class="text-over">{{file}}</dd>
  210. </dl>
  211. <dl class="dl-horizontal" ng-show="fails.length > 0">
  212. <dt>下载失败的文件</dt>
  213. <dd>
  214. <p class="text-danger text-over" ng-repeat="file in fails" style="margin:0;">{{file}}</p>
  215. </dd>
  216. </dl>
  217. </div>
  218. <script type="text/javascript">
  219. angular.module('cloudApp').value('config', {
  220. files : {php echo $packet['files'] ? json_encode($packet['files']) : '[]'},
  221. type : '{$type}',
  222. appname : '{$m}',
  223. is_upgrade : '{$is_upgrade}',
  224. account_type : "{$_GPC['support']}",
  225. tasknum : "{$packet['task']}",
  226. });
  227. angular.bootstrap($('.js-processor'), ['cloudApp']);
  228. </script>
  229. </div>
  230. {/if}
  231. {if $step == 'schemas'}
  232. <div class="clearfix js-processor" ng-cloak ng-controller="SchemasProcessorCtrl">
  233. {if empty($packet['schemas'])}
  234. <!-- 如果是安装模块,数据库操作完成后,不处理script,直接跳转到system/module/install -->
  235. <!-- 安装 -->
  236. {if !empty($packet['install'])}
  237. {if $packet['type'] == 'theme'}
  238. <script>
  239. location.href = '{url "system/template/install" array("templateid" => $m, "flag" => 1)}';
  240. </script>
  241. {elseif $packet['type'] == 'webtheme'}
  242. <script>
  243. location.href = '{url "system/webtheme/install" array("webtheme" => $m, "flag" => 1)}';
  244. </script>
  245. {else}
  246. <script>
  247. location.href = '{url "module/manage-system/install" array("module_name" => $m, "flag" => 1, "support" => $_GPC["support"])}';
  248. </script>
  249. {/if}
  250. {/if}
  251. <!-- 升级 -->
  252. {if $packet['type'] == 'theme'}
  253. <script>
  254. location.href = '{url "cloud/process" array("step" => "scripts", "t" => $m, "is_upgrade" => $is_upgrade)}';
  255. </script>
  256. {elseif $packet['type'] == 'webtheme'}
  257. <script>
  258. location.href = '{url "cloud/process" array("step" => "scripts", "w" => $m, "is_upgrade" => $is_upgrade)}';
  259. </script>
  260. {else}
  261. <script>
  262. {if $_GPC['batch']}
  263. location.href = '{url "cloud/process" array("step" => "scripts", "m" => $m, "is_upgrade" => $is_upgrade, "batch" => 1, "support" => $_GPC["support"], "has_new_support" => $has_new_support)}';
  264. {else}
  265. location.href = '{url "cloud/process" array("step" => "scripts", "m" => $m, "is_upgrade" => $is_upgrade, "support" => $_GPC["support"], "has_new_support" => $has_new_support)}';
  266. {/if}
  267. </script>
  268. {/if}
  269. {/if}
  270. <div class="upgrade-pragress we7-margin-bottom">
  271. <div class="wrapper top">
  272. <div class="circleProgress topcircle" ng-style="{transform: 'rotate('+ topPragress +'deg)'}"></div>
  273. </div>
  274. <div class="wrapper bottom">
  275. <div class="circleProgress bottomcircle" ng-style="{transform: 'rotate('+ bottomPragress +'deg)'}"></div>
  276. </div>
  277. <div class="circle">
  278. <img src="./resource/images/upgrade.png" alt="">
  279. <div class="pragress">
  280. {{pragressPer}}%
  281. </div>
  282. </div>
  283. </div>
  284. <div class="alert alert-warning we7-page-alert">
  285. 正在更新数据库, 请不要关闭窗口.
  286. </div>
  287. <div class="alert alert-info form-horizontal" >
  288. <dl class="dl-horizontal">
  289. <dt>整体进度</dt>
  290. <dd>{{pragress}}</dd>
  291. <dt>正在处理数据表</dt>
  292. <dd>{{schema}}</dd>
  293. </dl>
  294. <dl class="dl-horizontal" ng-show="fails.length > 0">
  295. <dt>处理失败的数据表</dt>
  296. <dd>
  297. <p class="text-danger" ng-repeat="schema in fails" style="margin:0;">{{schema}}</p>
  298. </dd>
  299. </dl>
  300. </div>
  301. <script type="text/javascript">
  302. angular.module('cloudApp').value('config', {
  303. schemas : {php echo $schemas ? json_encode($schemas) : '[]'},
  304. is_module_install : {php echo !empty($packet['install']) ? 'true' : 'false'},
  305. });
  306. angular.bootstrap($('.js-processor'), ['cloudApp']);
  307. </script>
  308. </div>
  309. {/if}
  310. {if $step == 'scripts'}
  311. <div class="clearfix js-processor" ng-cloak ng-controller="processor">
  312. {if empty($packet['scripts']) || !empty($packet['type'])}
  313. <!-- 如果是更新模块,跳转到system/module/upgrade -->
  314. {if $is_upgrade == 1}
  315. {if $packet['type'] == 'theme'}
  316. <script>
  317. location.href = '{url "system/template/upgrade" array("templateid" => $m, "flag" => 1)}';
  318. </script>
  319. {elseif $packet['type'] == 'webtheme'}
  320. <script>
  321. location.href = '{url "system/webtheme/upgrade" array("webthemeid" => $m, "flag" => 1)}';
  322. </script>
  323. {else}
  324. <script>
  325. location.href = '{url "module/manage-system/upgrade" array("module_name" => $m, "flag" => 1, "support" => $_GPC["support"], "has_new_support" => $has_new_support)}';
  326. </script>
  327. {/if}
  328. {/if}
  329. <script>
  330. var is_confirm = "{php echo $_GPC['is_confirm']}";
  331. if(is_confirm == 1) {
  332. if(confirm('已经成功执行升级操作! '+"\n"+' 由于数据库更新, 可能会产生多余的字段. 你可以按照需要删除')) {
  333. location.href = '{url "cloud/upgrade"}';
  334. } else {
  335. location.href = '{url "cloud/upgrade"}';
  336. }
  337. } else {
  338. require(['util'], function(u){
  339. u.message('已经成功执行升级操作! '+"\n"+' 由于数据库更新, 可能会产生多余的字段. 你可以按照需要删除.', '{url "cloud/upgrade"}');
  340. });
  341. }
  342. </script>
  343. {/if}
  344. <div class="upgrade-pragress we7-margin-bottom">
  345. <div class="wrapper top">
  346. <div class="circleProgress topcircle" ng-style="{transform: 'rotate('+ topPragress +'deg)'}"></div>
  347. </div>
  348. <div class="wrapper bottom">
  349. <div class="circleProgress bottomcircle" ng-style="{transform: 'rotate('+ bottomPragress +'deg)'}"></div>
  350. </div>
  351. <div class="circle">
  352. <img src="./resource/images/upgrade.png" alt="">
  353. <div class="pragress">
  354. {{pragressPer}}%
  355. </div>
  356. </div>
  357. </div>
  358. <div class="alert alert-warning we7-page-alert">
  359. 正在数据迁移及清理操作, 请不要关闭窗口.
  360. </div>
  361. <div class="alert alert-info form-horizontal " >
  362. <dl class="dl-horizontal">
  363. <dt>整体进度</dt>
  364. <dd>{{pragress}}</dd>
  365. <dt>正在处理</dt>
  366. <dd>{{script}}<br />{{message}}</dd>
  367. </dl>
  368. <dl class="dl-horizontal" ng-show="fails.length > 0">
  369. <dt>处理失败的操作</dt>
  370. <dd>
  371. <p class="text-danger" ng-repeat="script in fails" style="margin:0;">{{script}}</p>
  372. </dd>
  373. </dl>
  374. </div>
  375. <script>
  376. angular.bootstrap($('.js-processor'), ['cloudApp']);
  377. </script>
  378. </div>
  379. {/if}
  380. {template 'common/footer'}