Code cleanup part #1: move all the services and directive JS code in the app.js file into its own files
This commit is contained in:
parent
3cae6609a7
commit
9b87999c1c
97 changed files with 7076 additions and 6870 deletions
69
static/js/directives/ui/notification-view.js
Normal file
69
static/js/directives/ui/notification-view.js
Normal file
|
@ -0,0 +1,69 @@
|
|||
/**
|
||||
* An element which displays an application notification's information.
|
||||
*/
|
||||
angular.module('quay').directive('notificationView', function () {
|
||||
var directiveDefinitionObject = {
|
||||
priority: 0,
|
||||
templateUrl: '/static/directives/notification-view.html',
|
||||
replace: false,
|
||||
transclude: false,
|
||||
restrict: 'C',
|
||||
scope: {
|
||||
'notification': '=notification',
|
||||
'parent': '=parent'
|
||||
},
|
||||
controller: function($scope, $element, $window, $location, UserService, NotificationService, ApiService) {
|
||||
var stringStartsWith = function (str, prefix) {
|
||||
return str.slice(0, prefix.length) == prefix;
|
||||
};
|
||||
|
||||
$scope.getMessage = function(notification) {
|
||||
return NotificationService.getMessage(notification);
|
||||
};
|
||||
|
||||
$scope.getAvatar = function(orgname) {
|
||||
var organization = UserService.getOrganization(orgname);
|
||||
return organization['avatar'] || '';
|
||||
};
|
||||
|
||||
$scope.parseDate = function(dateString) {
|
||||
return Date.parse(dateString);
|
||||
};
|
||||
|
||||
$scope.showNotification = function() {
|
||||
var url = NotificationService.getPage($scope.notification);
|
||||
if (url) {
|
||||
if (stringStartsWith(url, 'http://') || stringStartsWith(url, 'https://')) {
|
||||
$window.location.href = url;
|
||||
} else {
|
||||
var parts = url.split('?')
|
||||
$location.path(parts[0]);
|
||||
|
||||
if (parts.length > 1) {
|
||||
$location.search(parts[1]);
|
||||
}
|
||||
|
||||
$scope.parent.$hide();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$scope.dismissNotification = function(notification) {
|
||||
NotificationService.dismissNotification(notification);
|
||||
};
|
||||
|
||||
$scope.canDismiss = function(notification) {
|
||||
return NotificationService.canDismiss(notification);
|
||||
};
|
||||
|
||||
$scope.getClass = function(notification) {
|
||||
return NotificationService.getClass(notification);
|
||||
};
|
||||
|
||||
$scope.getActions = function(notification) {
|
||||
return NotificationService.getActions(notification);
|
||||
};
|
||||
}
|
||||
};
|
||||
return directiveDefinitionObject;
|
||||
});
|
Reference in a new issue