人人商城

process.html 11KB

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