2013-10-01 20:42:20 +00:00
|
|
|
// Start the application code itself.
|
2013-10-03 19:46:22 +00:00
|
|
|
quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics', 'angulartics.mixpanel'], 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;
|
2013-10-03 19:46:22 +00:00
|
|
|
|
2013-10-03 20:16:10 +00:00
|
|
|
if (!userResponse.anonymous) {
|
|
|
|
mixpanel.identify(userResponse.username);
|
|
|
|
mixpanel.people.set({
|
|
|
|
'$email': userResponse.email,
|
|
|
|
'$username': userResponse.username,
|
|
|
|
'verified': userResponse.verified
|
|
|
|
});
|
|
|
|
}
|
2013-09-26 23:59:58 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
userService.currentUser = function() {
|
|
|
|
return userResponse;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load the user the first time.
|
|
|
|
userService.load();
|
|
|
|
|
|
|
|
return userService;
|
|
|
|
}])
|
|
|
|
}).
|
2013-10-01 23:37:33 +00:00
|
|
|
directive('match', function($parse) {
|
|
|
|
return {
|
|
|
|
require: 'ngModel',
|
|
|
|
link: function(scope, elem, attrs, ctrl) {
|
|
|
|
scope.$watch(function() {
|
|
|
|
return $parse(attrs.match)(scope) === ctrl.$modelValue;
|
|
|
|
}, function(currentValue) {
|
|
|
|
ctrl.$setValidity('mismatch', currentValue);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}).
|
2013-10-03 19:46:22 +00:00
|
|
|
config(['$routeProvider', '$locationProvider', '$analyticsProvider',
|
|
|
|
function($routeProvider, $locationProvider, $analyticsProvider) {
|
|
|
|
|
2013-10-03 20:16:10 +00:00
|
|
|
$analyticsProvider.virtualPageviews(true);
|
|
|
|
|
|
|
|
$routeProvider.
|
|
|
|
when('/repository/:namespace/:name', {templateUrl: '/static/partials/view-repo.html', controller: RepoCtrl}).
|
|
|
|
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}).
|
|
|
|
when('/repository/', {title: 'Repositories', templateUrl: '/static/partials/repo-list.html', controller: RepoListCtrl}).
|
|
|
|
when('/user', {title: 'User Admin', templateUrl: '/static/partials/user-admin.html', controller: UserAdminCtrl}).
|
|
|
|
when('/guide/', {title: 'Getting Started Guide', templateUrl: '/static/partials/guide.html', controller: GuideCtrl}).
|
|
|
|
when('/plans/', {title: 'Quay Plans', templateUrl: '/static/partials/plans.html', controller: PlansCtrl}).
|
|
|
|
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
|
|
|
}]);
|