-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug 1307169: Emergency shut off frontend (#460). r=bhearsum
- Loading branch information
Showing
13 changed files
with
649 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
angular.module('app').controller('DisableUpdatesModalCtrl', | ||
function($scope, $modalInstance, EmergencyShutoffs, product, channel){ | ||
$scope.product = product; | ||
$scope.channel = channel; | ||
$scope.saving = false; | ||
|
||
$scope.disableUpdates = function() { | ||
$scope.saving = true; | ||
EmergencyShutoffs.create($scope.product, $scope.channel) | ||
.success(function(response) { | ||
$modalInstance.close(response); | ||
sweetAlert("Disabling Updates", "Updates were disabled successfully!", "success"); | ||
}) | ||
.error(function(response, status) { | ||
if (typeof response === 'object') { | ||
sweetAlert("Form submission error", response.data, "error"); | ||
} | ||
}) | ||
.finally(function() { | ||
$scope.saving = false; | ||
}); | ||
}; | ||
|
||
$scope.cancel = function() { | ||
$modalInstance.dismiss('cancel'); | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
angular.module('app').controller('EnableUpdatesCtrl', | ||
function($scope, $modalInstance, CSRF, EmergencyShutoffs, emergency_shutoff, signoffs_requirements){ | ||
$scope.saving = false; | ||
$scope.emergency_shutoff = emergency_shutoff; | ||
$scope.signoffs_requirements = signoffs_requirements.filter(function(required_signoff) { | ||
return required_signoff.product === emergency_shutoff.product && required_signoff.channel === emergency_shutoff.channel; | ||
}).reduce(function(signoffs_reqs, signoff) { | ||
signoffs_reqs.length++; | ||
signoffs_reqs.roles[signoff.role] = signoff.signoffs_required; | ||
return signoffs_reqs; | ||
}, {'length': 0, 'roles': {}}); | ||
|
||
$scope.enableUpdates = function() { | ||
$scope.saving = true; | ||
CSRF.getToken() | ||
.then(function(csrf_token) { | ||
if($scope.signoffs_requirements.length > 0) { | ||
EmergencyShutoffs.scheduleEnableUpdates($scope.emergency_shutoff, csrf_token) | ||
.success(function(response) { | ||
$modalInstance.close(); | ||
sweetAlert( | ||
"Enabling Updates", | ||
"Updates have been scheduled to be enabled successfully.", | ||
"success"); | ||
}) | ||
.error(function(response, status) { | ||
if (typeof response === 'object') { | ||
sweetAlert("Form submission error", response.data, "error"); | ||
} | ||
}) | ||
.finally(function(){ | ||
$scope.saving = false; | ||
}); | ||
} else { | ||
EmergencyShutoffs.delete( | ||
$scope.emergency_shutoff.product, | ||
$scope.emergency_shutoff.channel, | ||
$scope.emergency_shutoff.data_version, | ||
csrf_token) | ||
.success(function(response) { | ||
$modalInstance.close(); | ||
sweetAlert( | ||
"Enabling Updates", | ||
"Updates were enabled successfully.", | ||
"success"); | ||
}) | ||
.error(function(response, status) { | ||
if (typeof response === 'object') { | ||
sweetAlert("Form submission error", response.data, "error"); | ||
} | ||
}) | ||
.finally(function(){ | ||
$scope.saving = false; | ||
}); | ||
} | ||
}); | ||
}; | ||
|
||
$scope.cancel = function () { | ||
$modalInstance.dismiss('cancel'); | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.