This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/static/js/app.js

77 lines
2.5 KiB
JavaScript
Raw Normal View History

// 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.
quayApp = angular.module('quay', ['restangular', 'angularMoment'], function($provide) {
$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;
}
});
}]);