status.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * Copyright © 2013-2017 Magento, Inc. All rights reserved.
  3. * See COPYING.txt for license details.
  4. */
  5. 'use strict';
  6. angular.module('status', ['ngStorage'])
  7. .controller('statusController', ['$scope', '$interval', '$sce', '$timeout', '$localStorage', '$rootScope', '$http', function ($scope, $interval, $sce, $timeout, $localStorage, $rootScope, $http) {
  8. $scope.isConsole = true;
  9. $scope.isShowCleanUpBox = false;
  10. $scope.error = false;
  11. $scope.rollbackStarted = false;
  12. $scope.nextButton = false;
  13. $scope.toggleConsole = function () {
  14. $scope.isConsole = $scope.isConsole === false;
  15. };
  16. $scope.rollback = function () {
  17. $http.post('index.php/rollback');
  18. $scope.error = true;
  19. $scope.rollbackStarted = true;
  20. };
  21. $scope.goToSuccessPage = function () {
  22. window.location.href = '../setup/index.php#/updater-success';
  23. };
  24. $interval(
  25. function () {
  26. $http.post('index.php/status')
  27. .success(function (result) {
  28. if (result['complete']) {
  29. $localStorage.rollbackStarted = $scope.rollbackStarted;
  30. if ($scope.rollbackStarted === true) {
  31. $scope.nextButton = true;
  32. } else {
  33. $scope.goToSuccessPage();
  34. }
  35. }
  36. if (result.statusMessage) {
  37. $('#console').html(result.statusMessage);
  38. }
  39. var statusText = "";
  40. if (result.isUpdateInProgress) {
  41. statusText = "Update application is running";
  42. } else if (result.pending) {
  43. statusText = "Update pending";
  44. } else {
  45. statusText = "Update application is not running";
  46. }
  47. $('#status').html(statusText);
  48. if (result['error'] || $scope.error) {
  49. $scope.error = true;
  50. }
  51. })
  52. .error(function (result) {
  53. $scope.error = true;
  54. $scope.rollbackStarted = false;
  55. });
  56. },
  57. 3000
  58. );
  59. $interval(
  60. function () {
  61. $http.post('../setup/index.php/session/prolong')
  62. .success(function (result) {
  63. })
  64. .error(function (result) {
  65. });
  66. },
  67. 120000
  68. );
  69. }]);