mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-526: Move handling of request error notification to guacNotification, resolving circular dependency.
This commit is contained in:
@@ -379,7 +379,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
|
|||||||
connectionService.saveConnection($scope.selectedDataSource, $scope.connection)
|
connectionService.saveConnection($scope.selectedDataSource, $scope.connection)
|
||||||
.then(function savedConnection() {
|
.then(function savedConnection() {
|
||||||
$location.url('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections');
|
$location.url('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections');
|
||||||
}, requestService.SHOW_NOTIFICATION);
|
}, guacNotification.SHOW_REQUEST_ERROR);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -419,7 +419,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
|
|||||||
connectionService.deleteConnection($scope.selectedDataSource, $scope.connection)
|
connectionService.deleteConnection($scope.selectedDataSource, $scope.connection)
|
||||||
.then(function deletedConnection() {
|
.then(function deletedConnection() {
|
||||||
$location.path('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections');
|
$location.path('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections');
|
||||||
}, requestService.SHOW_NOTIFICATION);
|
}, guacNotification.SHOW_REQUEST_ERROR);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -221,7 +221,7 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope'
|
|||||||
connectionGroupService.saveConnectionGroup($scope.selectedDataSource, $scope.connectionGroup)
|
connectionGroupService.saveConnectionGroup($scope.selectedDataSource, $scope.connectionGroup)
|
||||||
.then(function savedConnectionGroup() {
|
.then(function savedConnectionGroup() {
|
||||||
$location.path('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections');
|
$location.path('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections');
|
||||||
}, requestService.SHOW_NOTIFICATION);
|
}, guacNotification.SHOW_REQUEST_ERROR);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -261,7 +261,7 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope'
|
|||||||
connectionGroupService.deleteConnectionGroup($scope.selectedDataSource, $scope.connectionGroup)
|
connectionGroupService.deleteConnectionGroup($scope.selectedDataSource, $scope.connectionGroup)
|
||||||
.then(function deletedConnectionGroup() {
|
.then(function deletedConnectionGroup() {
|
||||||
$location.path('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections');
|
$location.path('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections');
|
||||||
}, requestService.SHOW_NOTIFICATION);
|
}, guacNotification.SHOW_REQUEST_ERROR);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -342,7 +342,7 @@ angular.module('manage').controller('manageSharingProfileController', ['$scope',
|
|||||||
sharingProfileService.saveSharingProfile($scope.selectedDataSource, $scope.sharingProfile)
|
sharingProfileService.saveSharingProfile($scope.selectedDataSource, $scope.sharingProfile)
|
||||||
.then(function savedSharingProfile() {
|
.then(function savedSharingProfile() {
|
||||||
$location.url('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections');
|
$location.url('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections');
|
||||||
}, requestService.SHOW_NOTIFICATION);
|
}, guacNotification.SHOW_REQUEST_ERROR);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -370,7 +370,7 @@ angular.module('manage').controller('manageSharingProfileController', ['$scope',
|
|||||||
sharingProfileService.deleteSharingProfile($scope.selectedDataSource, $scope.sharingProfile)
|
sharingProfileService.deleteSharingProfile($scope.selectedDataSource, $scope.sharingProfile)
|
||||||
.then(function deletedSharingProfile() {
|
.then(function deletedSharingProfile() {
|
||||||
$location.path('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections');
|
$location.path('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections');
|
||||||
}, requestService.SHOW_NOTIFICATION);
|
}, guacNotification.SHOW_REQUEST_ERROR);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -1141,9 +1141,9 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
|
|||||||
permissionService.patchPermissions(selectedDataSource, $scope.user.username, permissionsAdded, permissionsRemoved)
|
permissionService.patchPermissions(selectedDataSource, $scope.user.username, permissionsAdded, permissionsRemoved)
|
||||||
.then(function patchedUserPermissions() {
|
.then(function patchedUserPermissions() {
|
||||||
$location.url('/settings/users');
|
$location.url('/settings/users');
|
||||||
}, requestService.SHOW_NOTIFICATION);
|
}, guacNotification.SHOW_REQUEST_ERROR);
|
||||||
|
|
||||||
}, requestService.SHOW_NOTIFICATION);
|
}, guacNotification.SHOW_REQUEST_ERROR);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1183,7 +1183,7 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
|
|||||||
userService.deleteUser(selectedDataSource, $scope.user)
|
userService.deleteUser(selectedDataSource, $scope.user)
|
||||||
.then(function deletedUser() {
|
.then(function deletedUser() {
|
||||||
$location.path('/settings/users');
|
$location.path('/settings/users');
|
||||||
}, requestService.SHOW_NOTIFICATION);
|
}, guacNotification.SHOW_REQUEST_ERROR);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -21,5 +21,6 @@
|
|||||||
* The module for code used to display arbitrary notifications.
|
* The module for code used to display arbitrary notifications.
|
||||||
*/
|
*/
|
||||||
angular.module('notification', [
|
angular.module('notification', [
|
||||||
|
'rest',
|
||||||
'storage'
|
'storage'
|
||||||
]);
|
]);
|
||||||
|
@@ -25,6 +25,7 @@ angular.module('notification').factory('guacNotification', ['$injector',
|
|||||||
|
|
||||||
// Required services
|
// Required services
|
||||||
var $rootScope = $injector.get('$rootScope');
|
var $rootScope = $injector.get('$rootScope');
|
||||||
|
var requestService = $injector.get('requestService');
|
||||||
var sessionStorageFactory = $injector.get('sessionStorageFactory');
|
var sessionStorageFactory = $injector.get('sessionStorageFactory');
|
||||||
|
|
||||||
var service = {};
|
var service = {};
|
||||||
@@ -93,26 +94,24 @@ angular.module('notification').factory('guacNotification', ['$injector',
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows the given REST error response as a modal status. If a status
|
* Promise error callback which displays a modal notification for all
|
||||||
* notification is already currently shown, this function will have no
|
* rejections due to REST errors. The message displayed to the user within
|
||||||
* effect.
|
* the notification is provided by the contents of the @link{Error} object
|
||||||
|
* within the REST response. All other rejections, such as those due to
|
||||||
|
* JavaScript errors, are logged to the browser console without displaying
|
||||||
|
* any notification.
|
||||||
*
|
*
|
||||||
* @param {Error} error
|
* @constant
|
||||||
* The error object returned from the failed REST request.
|
* @type Function
|
||||||
*
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* someService.updateObject(object)
|
|
||||||
* ['catch'](guacNotification.showRequestError);
|
|
||||||
*/
|
*/
|
||||||
service.showRequestError = function showRequestError(error) {
|
service.SHOW_REQUEST_ERROR = requestService.createErrorCallback(function showRequestError(error) {
|
||||||
service.showStatus({
|
service.showStatus({
|
||||||
className : 'error',
|
className : 'error',
|
||||||
title : 'APP.DIALOG_HEADER_ERROR',
|
title : 'APP.DIALOG_HEADER_ERROR',
|
||||||
text : error.translatableMessage,
|
text : error.translatableMessage,
|
||||||
actions : [ service.ACKNOWLEDGE_ACTION ]
|
actions : [ service.ACKNOWLEDGE_ACTION ]
|
||||||
});
|
});
|
||||||
};
|
});
|
||||||
|
|
||||||
// Hide status upon navigation
|
// Hide status upon navigation
|
||||||
$rootScope.$on('$routeChangeSuccess', function() {
|
$rootScope.$on('$routeChangeSuccess', function() {
|
||||||
|
@@ -22,6 +22,5 @@
|
|||||||
* Guacamole web application.
|
* Guacamole web application.
|
||||||
*/
|
*/
|
||||||
angular.module('rest', [
|
angular.module('rest', [
|
||||||
'auth',
|
'auth'
|
||||||
'notification'
|
|
||||||
]);
|
]);
|
||||||
|
@@ -25,9 +25,8 @@ angular.module('rest').factory('requestService', ['$injector',
|
|||||||
function requestService($injector) {
|
function requestService($injector) {
|
||||||
|
|
||||||
// Required services
|
// Required services
|
||||||
var $http = $injector.get('$http');
|
var $http = $injector.get('$http');
|
||||||
var $log = $injector.get('$log');
|
var $log = $injector.get('$log');
|
||||||
var guacNotification = $injector.get('guacNotification');
|
|
||||||
|
|
||||||
// Required types
|
// Required types
|
||||||
var Error = $injector.get('Error');
|
var Error = $injector.get('Error');
|
||||||
@@ -116,19 +115,6 @@ angular.module('rest').factory('requestService', ['$injector',
|
|||||||
$log.warn(error.type, error.message || error.translatableMessage);
|
$log.warn(error.type, error.message || error.translatableMessage);
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* Promise error callback which displays a modal notification for all
|
|
||||||
* rejections due to REST errors. The message displayed to the user within
|
|
||||||
* the notification is provided by the contents of the @link{Error} object
|
|
||||||
* within the REST response. All other rejections, such as those due to
|
|
||||||
* JavaScript errors, are logged to the browser console without displaying
|
|
||||||
* any notification.
|
|
||||||
*
|
|
||||||
* @constant
|
|
||||||
* @type Function
|
|
||||||
*/
|
|
||||||
service.SHOW_NOTIFICATION = service.createErrorCallback(guacNotification.showRequestError);
|
|
||||||
|
|
||||||
return service;
|
return service;
|
||||||
|
|
||||||
}]);
|
}]);
|
||||||
|
@@ -165,7 +165,7 @@ angular.module('settings').directive('guacSettingsPreferences', [function guacSe
|
|||||||
},
|
},
|
||||||
actions : [ ACKNOWLEDGE_ACTION ]
|
actions : [ ACKNOWLEDGE_ACTION ]
|
||||||
});
|
});
|
||||||
}, requestService.SHOW_NOTIFICATION);
|
}, guacNotification.SHOW_REQUEST_ERROR);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -316,7 +316,7 @@ angular.module('settings').directive('guacSettingsSessions', [function guacSetti
|
|||||||
// Clear selection
|
// Clear selection
|
||||||
allSelectedWrappers = {};
|
allSelectedWrappers = {};
|
||||||
|
|
||||||
}, requestService.SHOW_NOTIFICATION);
|
}, guacNotification.SHOW_REQUEST_ERROR);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user