2013-10-01 20:42:20 +00:00
|
|
|
// Register any plugin code.
|
|
|
|
$.fn.spin = function(opts) {
|
|
|
|
this.each(function() {
|
|
|
|
var $this = $(this),
|
|
|
|
spinner = $this.data('spinner');
|
|
|
|
|
|
|
|
if (spinner) spinner.stop();
|
|
|
|
if (opts !== false) {
|
|
|
|
options = {
|
|
|
|
color: $this.css('color') || '#000',
|
|
|
|
lines: 12, // The number of lines to draw
|
|
|
|
length: 7, // The length of each line
|
|
|
|
width: 4, // The line thickness
|
|
|
|
radius: 10, // The radius of the inner circle
|
|
|
|
speed: 1, // Rounds per second
|
|
|
|
trail: 100, // Afterglow percentage
|
|
|
|
shadow: false // Whether to render a shadow
|
|
|
|
};
|
|
|
|
|
|
|
|
opts = $.extend(options, opts);
|
|
|
|
spinner = new Spinner(opts).spin(this);
|
|
|
|
$this.data('spinner', spinner);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return this;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Start the application code itself.
|
2013-09-27 19:26:30 +00:00
|
|
|
quayApp = angular.module('quay', ['restangular', 'angularMoment'], function($provide) {
|
2013-09-26 23:59:58 +00:00
|
|
|
$provide.factory('UserService', ['Restangular', function(Restangular) {
|
|
|
|
var userResponse = {
|
|
|
|
verified: false,
|
|
|
|
anonymous: true,
|
|
|
|
username: null,
|
|
|
|
email: null
|
|
|
|
}
|
|
|
|
|
|
|
|
var userService = {}
|
|
|
|
|
|
|
|
userService.load = function() {
|
|
|
|
var userFetch = Restangular.one('user/');
|
|
|
|
userFetch.get().then(function(loadedUser) {
|
|
|
|
userResponse = loadedUser;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
userService.currentUser = function() {
|
|
|
|
return userResponse;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load the user the first time.
|
|
|
|
userService.load();
|
|
|
|
|
|
|
|
return userService;
|
|
|
|
}])
|
|
|
|
}).
|
2013-09-26 23:07:25 +00:00
|
|
|
config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
|
2013-09-24 22:21:14 +00:00
|
|
|
$routeProvider.
|
2013-09-26 23:07:25 +00:00
|
|
|
when('/repository/:namespace/:name', {templateUrl: '/static/partials/view-repo.html', controller: RepoCtrl}).
|
2013-09-27 00:34:58 +00:00
|
|
|
when('/repository/:namespace/:name/tag/:tag', {templateUrl: '/static/partials/view-repo.html', controller: RepoCtrl}).
|
|
|
|
when('/repository/:namespace/:name/admin', {templateUrl: '/static/partials/repo-admin.html', controller:RepoAdminCtrl}).
|
2013-09-26 23:07:25 +00:00
|
|
|
when('/repository/', {title: 'Repositories', templateUrl: '/static/partials/repo-list.html', controller: RepoListCtrl}).
|
|
|
|
when('/', {title: 'Quay', templateUrl: '/static/partials/landing.html', controller: LandingCtrl}).
|
|
|
|
otherwise({redirectTo: '/'});
|
2013-09-24 22:21:14 +00:00
|
|
|
}]).
|
|
|
|
config(function(RestangularProvider) {
|
|
|
|
RestangularProvider.setBaseUrl('/api/');
|
2013-09-26 21:59:20 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
quayApp.run(['$location', '$rootScope', function($location, $rootScope) {
|
2013-09-26 23:07:25 +00:00
|
|
|
$rootScope.$on('$routeChangeSuccess', function (event, current, previous) {
|
|
|
|
if (current.$$route.title) {
|
|
|
|
$rootScope.title = current.$$route.title;
|
|
|
|
}
|
|
|
|
});
|
2013-09-27 20:12:51 +00:00
|
|
|
}]);
|