diff --git a/src/js/client.js b/src/js/client.js index 4068c4712..2f77f0a51 100644 --- a/src/js/client.js +++ b/src/js/client.js @@ -193,12 +193,7 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N /* - Example usage with an action: - - var actionScope = $scope.$new(true); - actionScope.action = '/#/certs'; - - Client.notify('title', 'message', true, actionScope); + If `action` is a non-empty string, it will be treated as a url, if it is a function, that function will be exectued on click */ Client.prototype.notify = function (title, message, persistent, type, action) { diff --git a/src/js/main.js b/src/js/main.js index 926a1ec59..8ee3d8396 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -73,38 +73,26 @@ angular.module('Application').controller('MainController', ['$scope', '$route', function runConfigurationChecks() { if ($scope.config.update && $scope.config.update.box) { - var updateActionScope = $scope.$new(true); - updateActionScope.action = '/#/settings'; - Client.notify('Update Available', 'Update now to version ' + $scope.config.update.box.version + '.', true, 'success', updateActionScope); + Client.notify('Update Available', 'Update now to version ' + $scope.config.update.box.version + '.', true, 'success', '/#/settings'); } Client.getBackupConfig(function (error, backupConfig) { if (error) return console.error(error); if (backupConfig.provider === 'noop') { - var actionScope = $scope.$new(true); - actionScope.action = '/#/backups'; - - Client.notify('Backup Configuration', 'Cloudron backups are disabled. Please ensure this server is backed up using alternate means.', false, 'info', actionScope); + Client.notify('Backup Configuration', 'Cloudron backups are disabled. Please ensure this server is backed up using alternate means.', false, 'info', '/#/backups'); } else if (backupConfig.provider === 'filesystem' && !backupConfig.externalDisk) { - var actionScope = $scope.$new(true); - actionScope.action = '/#/backups'; - Client.notify('Backup Configuration', 'Cloudron backups are currently on the same disk as the Cloudron server instance. This is dangerous and can lead to complete data loss if the disk fails.', - false /* persistent */, 'info', actionScope); + false /* persistent */, 'info', '/#/backups'); } }); Client.isRebootRequired(function (error, isRequired) { if (error) return console.error(error); - if (!isRequired) return; - var actionScope = $scope.$new(true); - actionScope.action = '/#/system'; - - Client.notify('Reboot Required', 'To finish security updates, a reboot is necessary.', true /* persistent */, 'warning', actionScope); + Client.notify('Reboot Required', 'To finish security updates, a reboot is necessary.', true /* persistent */, 'warning', '/#/system'); }); Client.getNotifications(false, 1, 100, function (error, results) { diff --git a/src/views/tokens.js b/src/views/tokens.js index e0e1f62fe..aed542876 100644 --- a/src/views/tokens.js +++ b/src/views/tokens.js @@ -55,13 +55,6 @@ angular.module('Application').controller('TokensController', ['$scope', 'Client' } else { console.error(error); } - return; - } else if (error && error.statusCode === 412) { - var actionScope = $scope.$new(true); - actionScope.action = '/#/settings'; - - Client.notify('Not allowed', 'You have to enable the external API in the settings.', false, 'error', actionScope); - return; } else if (error) return console.error('Unable to create API client.', error.statusCode, error.message); @@ -87,17 +80,7 @@ angular.module('Application').controller('TokensController', ['$scope', 'Client' Client.delOAuthClient($scope.clientRemove.client.id, function (error) { $scope.clientRemove.busy = false; - - if (error && error.statusCode === 412) { - var actionScope = $scope.$new(true); - actionScope.action = '/#/settings'; - - Client.notify('Not allowed', 'You have to enable the external API in the settings.', false, 'error', actionScope); - - return; - } else if (error) { - return console.error(error); - } + if (error) return console.error(error); $scope.clientRemove.client = {}; @@ -119,16 +102,7 @@ angular.module('Application').controller('TokensController', ['$scope', 'Client' var expiresAt = Date.now() + 100 * 365 * 24 * 60 * 60 * 1000; // ~100 years from now Client.createTokenByClientId(client.id, '*' /* scope */, expiresAt, '' /* name */, function (error, result) { - if (error && error.statusCode === 412) { - var actionScope = $scope.$new(true); - actionScope.action = '/#/settings'; - - Client.notify('Not allowed', 'You have to enable the external API in the settings.', false, 'error', actionScope); - - return; - } else if (error) { - return console.error(error); - } + if (error) return console.error(error); $scope.tokenAdd.busy = false; $scope.tokenAdd.token = result;