|
1 | 1 | angular.module('mnSettingsCluster').controller('mnSettingsClusterController',
|
2 |
| - function ($scope, mnSettingsClusterService, nodes, poolDefault, defaultCertificate, getVisulaSettings, mnHelper) { |
| 2 | + function ($scope, mnSettingsClusterService, nodes, poolDefault, defaultCertificate, mnHelper) { |
3 | 3 | $scope.focusMe = true;
|
4 | 4 |
|
5 | 5 | $scope.formData = {};
|
6 |
| - $scope.formData.tabName = getVisulaSettings.data.tabName; |
| 6 | + $scope.formData.clusterName = poolDefault.clusterName; |
7 | 7 | $scope.formData.memoryQuota = getInMegs(poolDefault.storageTotals.ram.quotaTotalPerNode);
|
8 | 8 | $scope.totalRam = getInMegs(nodes.ramTotalPerActiveNode);
|
9 | 9 | $scope.maxRamMegs = Math.max(getInMegs(nodes.ramTotalPerActiveNode) - 1024, Math.floor(nodes.ramTotalPerActiveNode * 4 / (5 * Math.Mi)));
|
10 | 10 | setCertificate(defaultCertificate.data);
|
11 | 11 |
|
12 | 12 | var liveValidation = _.debounce(function () {
|
13 |
| - mnSettingsClusterService.visualInternalSettingsValidation($scope.formData).error(setError).success(setError); |
| 13 | + var promise = mnSettingsClusterService.clusterSettingsValidation($scope.formData); |
| 14 | + mnHelper.promiseHelper($scope, promise).catchErrorsFromSuccess(); |
14 | 15 | }, 500);
|
15 | 16 |
|
16 | 17 | $scope.$watch('formData.memoryQuota', liveValidation);
|
17 | 18 |
|
18 | 19 | function setCertificate(certificate) {
|
19 | 20 | $scope.certificate = certificate;
|
20 | 21 | }
|
21 |
| - function setError(response) { |
22 |
| - $scope.errors = response.errors; |
23 |
| - } |
| 22 | + |
24 | 23 | function getInMegs(value) {
|
25 | 24 | return Math.floor(value / Math.Mi);
|
26 | 25 | }
|
27 | 26 |
|
28 | 27 | $scope.saveVisualInternalSettings = function () {
|
29 |
| - var promise = mnSettingsClusterService.saveVisualInternalSettings($scope.formData).error(setError); |
| 28 | + var promise = mnSettingsClusterService.saveClusterSettings($scope.formData); |
30 | 29 | mnHelper
|
31 | 30 | .promiseHelper($scope, promise)
|
| 31 | + .catchErrorsFromSuccess() |
32 | 32 | .showSpinner('settingsClusterLoaded')
|
33 | 33 | .reloadState();
|
34 | 34 | };
|
|
0 commit comments