Merge branch 'master' into fix_build
This commit is contained in:
commit
96fdae4f0d
23 changed files with 1323 additions and 692 deletions
531
static/js/app.js
531
static/js/app.js
|
@ -1,6 +1,18 @@
|
|||
var TEAM_PATTERN = '^[a-zA-Z][a-zA-Z0-9]+$';
|
||||
var ROBOT_PATTERN = '^[a-zA-Z][a-zA-Z0-9]+$';
|
||||
|
||||
function getRestUrl(args) {
|
||||
var url = '';
|
||||
for (var i = 0; i < arguments.length; ++i) {
|
||||
if (i > 0) {
|
||||
url += '/';
|
||||
}
|
||||
url += encodeURI(arguments[i])
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
function getFirstTextLine(commentString) {
|
||||
if (!commentString) { return ''; }
|
||||
|
||||
|
@ -34,11 +46,8 @@ function getFirstTextLine(commentString) {
|
|||
return '';
|
||||
}
|
||||
|
||||
function createRobotAccount(Restangular, is_org, orgname, name, callback) {
|
||||
var url = is_org ? getRestUrl('organization', orgname, 'robots', name) :
|
||||
getRestUrl('user/robots', name);
|
||||
var createRobot = Restangular.one(url);
|
||||
createRobot.customPUT().then(callback, function(resp) {
|
||||
function createRobotAccount(ApiService, is_org, orgname, name, callback) {
|
||||
ApiService.createRobot(is_org ? orgname : null, null, {'robot_shortname': name}).then(callback, function(resp) {
|
||||
bootbox.dialog({
|
||||
"message": resp.data ? resp.data : 'The robot account could not be created',
|
||||
"title": "Cannot create robot account",
|
||||
|
@ -52,14 +61,18 @@ function createRobotAccount(Restangular, is_org, orgname, name, callback) {
|
|||
});
|
||||
}
|
||||
|
||||
function createOrganizationTeam(Restangular, orgname, teamname, callback) {
|
||||
var createTeam = Restangular.one(getRestUrl('organization', orgname, 'team', teamname));
|
||||
function createOrganizationTeam(ApiService, orgname, teamname, callback) {
|
||||
var data = {
|
||||
'name': teamname,
|
||||
'role': 'member'
|
||||
};
|
||||
|
||||
var params = {
|
||||
'orgname': orgname,
|
||||
'teamname': teamname
|
||||
};
|
||||
|
||||
createTeam.customPOST(data).then(callback, function() {
|
||||
ApiService.updateOrganizationTeam(data, params).then(callback, function() {
|
||||
bootbox.dialog({
|
||||
"message": resp.data ? resp.data : 'The team could not be created',
|
||||
"title": "Cannot create team",
|
||||
|
@ -73,17 +86,6 @@ function createOrganizationTeam(Restangular, orgname, teamname, callback) {
|
|||
});
|
||||
}
|
||||
|
||||
function getRestUrl(args) {
|
||||
var url = '';
|
||||
for (var i = 0; i < arguments.length; ++i) {
|
||||
if (i > 0) {
|
||||
url += '/';
|
||||
}
|
||||
url += encodeURI(arguments[i])
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
function getMarkedDown(string) {
|
||||
return Markdown.getSanitizingConverter().makeHtml(string || '');
|
||||
}
|
||||
|
@ -91,6 +93,137 @@ function getMarkedDown(string) {
|
|||
// Start the application code itself.
|
||||
quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'restangular', 'angularMoment', 'angulartics', /*'angulartics.google.analytics',*/ 'angulartics.mixpanel', '$strap.directives', 'ngCookies'], function($provide, cfpLoadingBarProvider) {
|
||||
cfpLoadingBarProvider.includeSpinner = false;
|
||||
|
||||
$provide.factory('ApiService', ['Restangular', function(Restangular) {
|
||||
var apiService = {};
|
||||
|
||||
var getResource = function(path) {
|
||||
var resource = {};
|
||||
resource.url = path;
|
||||
resource.withOptions = function(options) {
|
||||
this.options = options;
|
||||
return this;
|
||||
};
|
||||
|
||||
resource.get = function(processor, opt_errorHandler) {
|
||||
var options = this.options;
|
||||
var performer = Restangular.one(this.url);
|
||||
|
||||
var result = {
|
||||
'loading': true,
|
||||
'value': null,
|
||||
'hasError': false
|
||||
};
|
||||
|
||||
performer.get(options).then(function(resp) {
|
||||
result.value = processor(resp);
|
||||
result.loading = false;
|
||||
}, function(resp) {
|
||||
result.hasError = true;
|
||||
result.loading = false;
|
||||
if (opt_errorHandler) {
|
||||
opt_errorHandler(resp);
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
return resource;
|
||||
};
|
||||
|
||||
var formatMethodName = function(endpointName) {
|
||||
var formatted = '';
|
||||
for (var i = 0; i < endpointName.length; ++i) {
|
||||
var c = endpointName[i];
|
||||
if (c == '_') {
|
||||
c = endpointName[i + 1].toUpperCase();
|
||||
i++;
|
||||
}
|
||||
|
||||
formatted += c;
|
||||
}
|
||||
|
||||
return formatted;
|
||||
};
|
||||
|
||||
var buildUrl = function(path, parameters) {
|
||||
// We already have /api/ on the URLs, so remove them from the paths.
|
||||
path = path.substr('/api/'.length, path.length);
|
||||
|
||||
var url = '';
|
||||
for (var i = 0; i < path.length; ++i) {
|
||||
var c = path[i];
|
||||
if (c == '<') {
|
||||
var end = path.indexOf('>', i);
|
||||
var varName = path.substr(i + 1, end - i - 1);
|
||||
var colon = varName.indexOf(':');
|
||||
var isPathVar = false;
|
||||
if (colon > 0) {
|
||||
isPathVar = true;
|
||||
varName = varName.substr(colon + 1);
|
||||
}
|
||||
|
||||
if (!parameters[varName]) {
|
||||
throw new Error('Missing parameter: ' + varName);
|
||||
}
|
||||
|
||||
url += isPathVar ? parameters[varName] : encodeURI(parameters[varName]);
|
||||
i = end;
|
||||
continue;
|
||||
}
|
||||
|
||||
url += c;
|
||||
}
|
||||
|
||||
return url;
|
||||
};
|
||||
|
||||
var getGenericMethodName = function(userMethodName) {
|
||||
return formatMethodName(userMethodName.replace('_user', ''));
|
||||
};
|
||||
|
||||
var buildMethodsForEndpoint = function(endpoint) {
|
||||
var method = endpoint.methods[0].toLowerCase();
|
||||
var methodName = formatMethodName(endpoint['name']);
|
||||
apiService[methodName] = function(opt_options, opt_parameters) {
|
||||
return Restangular.one(buildUrl(endpoint['path'], opt_parameters))['custom' + method.toUpperCase()](opt_options);
|
||||
};
|
||||
|
||||
if (method == 'get') {
|
||||
apiService[methodName + 'AsResource'] = function(opt_parameters) {
|
||||
return getResource(buildUrl(endpoint['path'], opt_parameters));
|
||||
};
|
||||
}
|
||||
|
||||
if (endpoint['user_method']) {
|
||||
apiService[getGenericMethodName(endpoint['user_method'])] = function(orgname, opt_options, opt_parameters) {
|
||||
if (orgname) {
|
||||
if (orgname.name) {
|
||||
orgname = orgname.name;
|
||||
}
|
||||
|
||||
var params = jQuery.extend({'orgname' : orgname}, opt_parameters || {});
|
||||
return apiService[methodName](opt_options, params);
|
||||
} else {
|
||||
return apiService[formatMethodName(endpoint['user_method'])](opt_options, opt_parameters);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
// Construct the methods for each API endpoint.
|
||||
if (!window.__endpoints) {
|
||||
return apiService;
|
||||
}
|
||||
|
||||
for (var i = 0; i < window.__endpoints.length; ++i) {
|
||||
var endpoint = window.__endpoints[i];
|
||||
buildMethodsForEndpoint(endpoint);
|
||||
}
|
||||
|
||||
return apiService;
|
||||
}]);
|
||||
|
||||
$provide.factory('CookieService', ['$cookies', '$cookieStore', function($cookies, $cookieStore) {
|
||||
var cookieService = {};
|
||||
|
@ -113,7 +246,7 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'rest
|
|||
return cookieService;
|
||||
}]);
|
||||
|
||||
$provide.factory('UserService', ['Restangular', 'CookieService', function(Restangular, CookieService) {
|
||||
$provide.factory('UserService', ['ApiService', 'CookieService', function(ApiService, CookieService) {
|
||||
var userResponse = {
|
||||
verified: false,
|
||||
anonymous: true,
|
||||
|
@ -139,8 +272,7 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'rest
|
|||
};
|
||||
|
||||
userService.load = function(opt_callback) {
|
||||
var userFetch = Restangular.one('user/');
|
||||
userFetch.get().then(function(loadedUser) {
|
||||
ApiService.getLoggedInUser().then(function(loadedUser) {
|
||||
userResponse = loadedUser;
|
||||
|
||||
if (!userResponse.anonymous) {
|
||||
|
@ -198,48 +330,6 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'rest
|
|||
return userService;
|
||||
}]);
|
||||
|
||||
|
||||
$provide.factory('ApiService', ['Restangular', function(Restangular) {
|
||||
var apiService = {}
|
||||
apiService.at = function(locationPieces) {
|
||||
var location = getRestUrl.apply(this, arguments);
|
||||
var info = {
|
||||
'url': location,
|
||||
'caller': Restangular.one(location),
|
||||
'withOptions': function(options) {
|
||||
info.options = options;
|
||||
return info;
|
||||
},
|
||||
'get': function(processor, opt_errorHandler) {
|
||||
var options = info.options;
|
||||
var caller = info.caller;
|
||||
var result = {
|
||||
'loading': true,
|
||||
'value': null,
|
||||
'hasError': false
|
||||
};
|
||||
|
||||
caller.get(options).then(function(resp) {
|
||||
result.value = processor(resp);
|
||||
result.loading = false;
|
||||
}, function(resp) {
|
||||
result.hasError = true;
|
||||
result.loading = false;
|
||||
if (opt_errorHandler) {
|
||||
opt_errorHandler(resp);
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
return info;
|
||||
};
|
||||
|
||||
return apiService;
|
||||
}]);
|
||||
|
||||
$provide.factory('KeyService', ['$location', function($location) {
|
||||
var keyService = {}
|
||||
|
||||
|
@ -254,13 +344,17 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'rest
|
|||
return keyService;
|
||||
}]);
|
||||
|
||||
$provide.factory('PlanService', ['Restangular', 'KeyService', 'UserService', 'CookieService',
|
||||
function(Restangular, KeyService, UserService, CookieService) {
|
||||
$provide.factory('PlanService', ['KeyService', 'UserService', 'CookieService', 'ApiService',
|
||||
function(KeyService, UserService, CookieService, ApiService) {
|
||||
var plans = null;
|
||||
var planDict = {};
|
||||
var planService = {};
|
||||
var listeners = [];
|
||||
|
||||
planService.getFreePlan = function() {
|
||||
return 'free';
|
||||
};
|
||||
|
||||
planService.registerListener = function(obj, callback) {
|
||||
listeners.push({'obj': obj, 'callback': callback});
|
||||
};
|
||||
|
@ -278,6 +372,27 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'rest
|
|||
CookieService.putSession('quay.notedplan', planId);
|
||||
};
|
||||
|
||||
planService.isOrgCompatible = function(plan) {
|
||||
return plan['stripeId'] == planService.getFreePlan() || plan['bus_features'];
|
||||
};
|
||||
|
||||
planService.getMatchingBusinessPlan = function(callback) {
|
||||
planService.getPlans(function() {
|
||||
planService.getSubscription(null, function(sub) {
|
||||
var plan = planDict[sub.plan];
|
||||
if (!plan) {
|
||||
planService.getMinimumPlan(0, true, callback);
|
||||
return;
|
||||
}
|
||||
|
||||
var count = Math.max(sub.usedPrivateRepos, plan.privateRepos);
|
||||
planService.getMinimumPlan(count, true, callback);
|
||||
}, function() {
|
||||
planService.getMinimumPlan(0, true, callback);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
planService.handleNotedPlan = function() {
|
||||
var planId = planService.getAndResetNotedPlan();
|
||||
if (!planId) { return; }
|
||||
|
@ -288,13 +403,11 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'rest
|
|||
}
|
||||
|
||||
planService.getPlan(planId, function(plan) {
|
||||
planService.isBusinessPlan(planId, function(bus) {
|
||||
if (bus) {
|
||||
document.location = '/organizations/new/?plan=' + planId;
|
||||
} else {
|
||||
document.location = '/user?plan=' + planId;
|
||||
}
|
||||
});
|
||||
if (planService.isOrgCompatible(plan)) {
|
||||
document.location = '/organizations/new/?plan=' + planId;
|
||||
} else {
|
||||
document.location = '/user?plan=' + planId;
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
@ -330,72 +443,53 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'rest
|
|||
return;
|
||||
}
|
||||
|
||||
var getPlans = Restangular.one('plans');
|
||||
getPlans.get().then(function(data) {
|
||||
ApiService.listPlans().then(function(data) {
|
||||
var i = 0;
|
||||
for(i = 0; i < data.user.length; i++) {
|
||||
planDict[data.user[i].stripeId] = data.user[i];
|
||||
for(i = 0; i < data.plans.length; i++) {
|
||||
planDict[data.plans[i].stripeId] = data.plans[i];
|
||||
}
|
||||
for(i = 0; i < data.business.length; i++) {
|
||||
planDict[data.business[i].stripeId] = data.business[i];
|
||||
}
|
||||
plans = data;
|
||||
plans = data.plans;
|
||||
callback(plans);
|
||||
}, function() { callback([]); });
|
||||
};
|
||||
|
||||
planService.getMatchingBusinessPlan = function(callback) {
|
||||
planService.getPlans(function() {
|
||||
planService.getSubscription(null, function(sub) {
|
||||
var plan = planDict[sub.plan];
|
||||
if (!plan) {
|
||||
planService.getMinimumPlan(0, true, callback);
|
||||
return;
|
||||
}
|
||||
|
||||
var count = Math.max(sub.usedPrivateRepos, plan.privateRepos);
|
||||
planService.getMinimumPlan(count, true, callback);
|
||||
}, function() {
|
||||
planService.getMinimumPlan(0, true, callback);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
planService.isBusinessPlan = function(planId, callback) {
|
||||
planService.getPlans = function(callback, opt_includePersonal) {
|
||||
planService.verifyLoaded(function() {
|
||||
planSource = plans.business;
|
||||
for (var i = 0; i < planSource.length; i++) {
|
||||
var plan = planSource[i];
|
||||
if (plan.stripeId == planId) {
|
||||
callback(true);
|
||||
return;
|
||||
}
|
||||
var filtered = [];
|
||||
for (var i = 0; i < plans.length; ++i) {
|
||||
var plan = plans[i];
|
||||
if (plan['deprecated']) { continue; }
|
||||
if (!opt_includePersonal && !planService.isOrgCompatible(plan)) { continue; }
|
||||
filtered.push(plan);
|
||||
}
|
||||
callback(false);
|
||||
callback(filtered);
|
||||
});
|
||||
};
|
||||
|
||||
planService.getPlans = function(callback) {
|
||||
planService.verifyLoaded(callback);
|
||||
};
|
||||
|
||||
planService.getPlan = function(planId, callback) {
|
||||
planService.getPlanIncludingDeprecated(planId, function(plan) {
|
||||
if (!plan['deprecated']) {
|
||||
callback(plan);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
planService.getPlanIncludingDeprecated = function(planId, callback) {
|
||||
planService.verifyLoaded(function() {
|
||||
if (planDict[planId]) {
|
||||
if (planDict[planId]) {
|
||||
callback(planDict[planId]);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
planService.getMinimumPlan = function(privateCount, isBusiness, callback) {
|
||||
planService.verifyLoaded(function() {
|
||||
var planSource = plans.user;
|
||||
if (isBusiness) {
|
||||
planSource = plans.business;
|
||||
}
|
||||
planService.getPlans(function(plans) {
|
||||
for (var i = 0; i < plans.length; i++) {
|
||||
var plan = plans[i];
|
||||
if (isBusiness && !planService.isOrgCompatible(plan)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (var i = 0; i < planSource.length; i++) {
|
||||
var plan = planSource[i];
|
||||
if (plan.privateRepos >= privateCount) {
|
||||
callback(plan);
|
||||
return;
|
||||
|
@ -407,13 +501,7 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'rest
|
|||
};
|
||||
|
||||
planService.getSubscription = function(orgname, success, failure) {
|
||||
var url = planService.getSubscriptionUrl(orgname);
|
||||
var getSubscription = Restangular.one(url);
|
||||
getSubscription.get().then(success, failure);
|
||||
};
|
||||
|
||||
planService.getSubscriptionUrl = function(orgname) {
|
||||
return orgname ? getRestUrl('organization', orgname, 'plan') : 'user/plan';
|
||||
ApiService.getSubscription(orgname).then(success, failure);
|
||||
};
|
||||
|
||||
planService.setSubscription = function(orgname, planId, success, failure, opt_token) {
|
||||
|
@ -425,9 +513,7 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'rest
|
|||
subscriptionDetails['token'] = opt_token.id;
|
||||
}
|
||||
|
||||
var url = planService.getSubscriptionUrl(orgname);
|
||||
var createSubscriptionRequest = Restangular.one(url);
|
||||
createSubscriptionRequest.customPUT(subscriptionDetails).then(function(resp) {
|
||||
ApiService.updateSubscription(orgname, subscriptionDetails).then(function(resp) {
|
||||
success(resp);
|
||||
planService.getPlan(planId, function(plan) {
|
||||
for (var i = 0; i < listeners.length; ++i) {
|
||||
|
@ -438,9 +524,7 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'rest
|
|||
};
|
||||
|
||||
planService.getCardInfo = function(orgname, callback) {
|
||||
var url = orgname ? getRestUrl('organization', orgname, 'card') : 'user/card';
|
||||
var getCard = Restangular.one(url);
|
||||
getCard.customGET().then(function(resp) {
|
||||
ApiService.getCard(orgname).then(function(resp) {
|
||||
callback(resp.card);
|
||||
}, function() {
|
||||
callback({'is_valid': false});
|
||||
|
@ -453,6 +537,8 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'rest
|
|||
}
|
||||
|
||||
planService.getPlan(planId, function(plan) {
|
||||
if (orgname && !planService.isOrgCompatible(plan)) { return; }
|
||||
|
||||
planService.getCardInfo(orgname, function(cardInfo) {
|
||||
if (plan.price > 0 && !cardInfo.last4) {
|
||||
planService.showSubscribeDialog($scope, orgname, planId, callbacks);
|
||||
|
@ -485,12 +571,10 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'rest
|
|||
'token': token.id
|
||||
};
|
||||
|
||||
var url = orgname ? getRestUrl('organization', orgname, 'card') : 'user/card';
|
||||
var changeCardRequest = Restangular.one(url);
|
||||
changeCardRequest.customPOST(cardInfo).then(callbacks['success'], function(resp) {
|
||||
planService.handleCardError(resp);
|
||||
callbacks['failure'](resp);
|
||||
});
|
||||
ApiService.setCard(orgname, cardInfo).then(callbacks['success'], function(resp) {
|
||||
planService.handleCardError(resp);
|
||||
callbacks['failure'](resp);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -732,10 +816,9 @@ quayApp.directive('userSetup', function () {
|
|||
'signInStarted': '&signInStarted',
|
||||
'signedIn': '&signedIn'
|
||||
},
|
||||
controller: function($scope, $location, $timeout, Restangular, KeyService, UserService) {
|
||||
controller: function($scope, $location, $timeout, ApiService, KeyService, UserService) {
|
||||
$scope.sendRecovery = function() {
|
||||
var signinPost = Restangular.one('recovery');
|
||||
signinPost.customPOST($scope.recovery).then(function() {
|
||||
ApiService.requestRecoveryEmail($scope.recovery).then(function() {
|
||||
$scope.invalidEmail = false;
|
||||
$scope.sent = true;
|
||||
}, function(result) {
|
||||
|
@ -765,7 +848,7 @@ quayApp.directive('signinForm', function () {
|
|||
'signInStarted': '&signInStarted',
|
||||
'signedIn': '&signedIn'
|
||||
},
|
||||
controller: function($scope, $location, $timeout, Restangular, KeyService, UserService) {
|
||||
controller: function($scope, $location, $timeout, ApiService, KeyService, UserService) {
|
||||
$scope.showGithub = function() {
|
||||
$scope.markStarted();
|
||||
|
||||
|
@ -792,8 +875,7 @@ quayApp.directive('signinForm', function () {
|
|||
$scope.signin = function() {
|
||||
$scope.markStarted();
|
||||
|
||||
var signinPost = Restangular.one('signin');
|
||||
signinPost.customPOST($scope.user).then(function() {
|
||||
ApiService.signinUser($scope.user).then(function() {
|
||||
$scope.needsEmailVerification = false;
|
||||
$scope.invalidCredentials = false;
|
||||
|
||||
|
@ -833,7 +915,7 @@ quayApp.directive('signupForm', function () {
|
|||
scope: {
|
||||
|
||||
},
|
||||
controller: function($scope, $location, $timeout, Restangular, KeyService, UserService) {
|
||||
controller: function($scope, $location, $timeout, ApiService, KeyService, UserService) {
|
||||
$('.form-signup').popover();
|
||||
|
||||
angulartics.waitForVendorApi(mixpanel, 500, function(loadedMixpanel) {
|
||||
|
@ -850,8 +932,7 @@ quayApp.directive('signupForm', function () {
|
|||
$('.form-signup').popover('hide');
|
||||
$scope.registering = true;
|
||||
|
||||
var newUserPost = Restangular.one('user/');
|
||||
newUserPost.customPOST($scope.newUser).then(function() {
|
||||
ApiService.createNewUser($scope.newUser).then(function() {
|
||||
$scope.awaitingConfirmation = true;
|
||||
$scope.registering = false;
|
||||
|
||||
|
@ -904,7 +985,7 @@ quayApp.directive('dockerAuthDialog', function () {
|
|||
'shown': '=shown',
|
||||
'counter': '=counter'
|
||||
},
|
||||
controller: function($scope, $element, Restangular) {
|
||||
controller: function($scope, $element) {
|
||||
$scope.isDownloadSupported = function() {
|
||||
try { return !!new Blob(); } catch(e){}
|
||||
return false;
|
||||
|
@ -962,6 +1043,53 @@ quayApp.filter('visibleLogFilter', function () {
|
|||
});
|
||||
|
||||
|
||||
quayApp.directive('billingInvoices', function () {
|
||||
var directiveDefinitionObject = {
|
||||
priority: 0,
|
||||
templateUrl: '/static/directives/billing-invoices.html',
|
||||
replace: false,
|
||||
transclude: false,
|
||||
restrict: 'C',
|
||||
scope: {
|
||||
'organization': '=organization',
|
||||
'user': '=user',
|
||||
'visible': '=visible'
|
||||
},
|
||||
controller: function($scope, $element, $sce, ApiService) {
|
||||
$scope.loading = false;
|
||||
$scope.invoiceExpanded = {};
|
||||
|
||||
$scope.toggleInvoice = function(id) {
|
||||
$scope.invoiceExpanded[id] = !$scope.invoiceExpanded[id];
|
||||
};
|
||||
|
||||
var update = function() {
|
||||
var hasValidUser = !!$scope.user;
|
||||
var hasValidOrg = !!$scope.organization;
|
||||
var isValid = hasValidUser || hasValidOrg;
|
||||
|
||||
if (!$scope.visible || !isValid) {
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.loading = true;
|
||||
|
||||
ApiService.listInvoices($scope.organization).then(function(resp) {
|
||||
$scope.invoices = resp.invoices;
|
||||
$scope.loading = false;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.$watch('organization', update);
|
||||
$scope.$watch('user', update);
|
||||
$scope.$watch('visible', update);
|
||||
}
|
||||
};
|
||||
|
||||
return directiveDefinitionObject;
|
||||
});
|
||||
|
||||
|
||||
quayApp.directive('logsView', function () {
|
||||
var directiveDefinitionObject = {
|
||||
priority: 0,
|
||||
|
@ -976,7 +1104,7 @@ quayApp.directive('logsView', function () {
|
|||
'repository': '=repository',
|
||||
'performer': '=performer'
|
||||
},
|
||||
controller: function($scope, $element, $sce, Restangular) {
|
||||
controller: function($scope, $element, $sce, Restangular, ApiService) {
|
||||
$scope.loading = true;
|
||||
$scope.logs = null;
|
||||
$scope.kindsAllowed = null;
|
||||
|
@ -1092,6 +1220,8 @@ quayApp.directive('logsView', function () {
|
|||
|
||||
$scope.loading = true;
|
||||
|
||||
// Note: We construct the URLs here manually because we also use it for the download
|
||||
// path.
|
||||
var url = getRestUrl('user/logs');
|
||||
if ($scope.organization) {
|
||||
url = getRestUrl('organization', $scope.organization.name, 'logs');
|
||||
|
@ -1195,7 +1325,7 @@ quayApp.directive('robotsManager', function () {
|
|||
'organization': '=organization',
|
||||
'user': '=user'
|
||||
},
|
||||
controller: function($scope, $element, Restangular) {
|
||||
controller: function($scope, $element, ApiService) {
|
||||
$scope.ROBOT_PATTERN = ROBOT_PATTERN;
|
||||
$scope.robots = null;
|
||||
$scope.loading = false;
|
||||
|
@ -1220,7 +1350,7 @@ quayApp.directive('robotsManager', function () {
|
|||
$scope.createRobot = function(name) {
|
||||
if (!name) { return; }
|
||||
|
||||
createRobotAccount(Restangular, !!$scope.organization, $scope.organization ? $scope.organization.name : '', name,
|
||||
createRobotAccount(ApiService, !!$scope.organization, $scope.organization ? $scope.organization.name : '', name,
|
||||
function(created) {
|
||||
$scope.robots.push(created);
|
||||
});
|
||||
|
@ -1228,11 +1358,7 @@ quayApp.directive('robotsManager', function () {
|
|||
|
||||
$scope.deleteRobot = function(info) {
|
||||
var shortName = $scope.getShortenedName(info.name);
|
||||
var url = $scope.organization ? getRestUrl('organization', $scope.organization.name, 'robots', shortName) :
|
||||
getRestUrl('user/robots', shortName);
|
||||
|
||||
var deleteRobot = Restangular.one(url);
|
||||
deleteRobot.customDELETE().then(function(resp) {
|
||||
ApiService.deleteRobot($scope.organization, null, {'robot_shortname': shortName}).then(function(resp) {
|
||||
for (var i = 0; i < $scope.robots.length; ++i) {
|
||||
if ($scope.robots[i].name == info.name) {
|
||||
$scope.robots.splice(i, 1);
|
||||
|
@ -1258,9 +1384,7 @@ quayApp.directive('robotsManager', function () {
|
|||
if ($scope.loading) { return; }
|
||||
|
||||
$scope.loading = true;
|
||||
var url = $scope.organization ? getRestUrl('organization', $scope.organization.name, 'robots') : 'user/robots';
|
||||
var getRobots = Restangular.one(url);
|
||||
getRobots.customGET($scope.obj).then(function(resp) {
|
||||
ApiService.getRobots($scope.organization).then(function(resp) {
|
||||
$scope.robots = resp.robots;
|
||||
$scope.loading = false;
|
||||
});
|
||||
|
@ -1493,7 +1617,7 @@ quayApp.directive('headerBar', function () {
|
|||
restrict: 'C',
|
||||
scope: {
|
||||
},
|
||||
controller: function($scope, $element, $location, UserService, PlanService, Restangular) {
|
||||
controller: function($scope, $element, $location, UserService, PlanService, ApiService) {
|
||||
$scope.overPlan = false;
|
||||
|
||||
var checkOverPlan = function() {
|
||||
|
@ -1502,8 +1626,7 @@ quayApp.directive('headerBar', function () {
|
|||
return;
|
||||
}
|
||||
|
||||
var checkPrivate = Restangular.one('user/private');
|
||||
checkPrivate.customGET().then(function(resp) {
|
||||
ApiService.getUserPrivateCount().then(function(resp) {
|
||||
$scope.overPlan = resp.privateCount > resp.reposAllowed;
|
||||
});
|
||||
};
|
||||
|
@ -1515,10 +1638,9 @@ quayApp.directive('headerBar', function () {
|
|||
PlanService.registerListener(this, checkOverPlan);
|
||||
|
||||
$scope.signout = function() {
|
||||
var signoutPost = Restangular.one('signout');
|
||||
signoutPost.customPOST().then(function() {
|
||||
UserService.load();
|
||||
$location.path('/');
|
||||
ApiService.logout().then(function() {
|
||||
UserService.load();
|
||||
$location.path('/');
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -1549,7 +1671,7 @@ quayApp.directive('entitySearch', function () {
|
|||
'includeTeams': '=includeTeams',
|
||||
'isOrganization': '=isOrganization'
|
||||
},
|
||||
controller: function($scope, $element, Restangular, UserService) {
|
||||
controller: function($scope, $element, Restangular, UserService, ApiService) {
|
||||
$scope.lazyLoading = true;
|
||||
$scope.isAdmin = false;
|
||||
|
||||
|
@ -1559,16 +1681,12 @@ quayApp.directive('entitySearch', function () {
|
|||
$scope.isAdmin = UserService.isNamespaceAdmin($scope.namespace);
|
||||
|
||||
if ($scope.isOrganization && $scope.includeTeams) {
|
||||
var url = getRestUrl('organization', $scope.namespace);
|
||||
var getOrganization = Restangular.one(url);
|
||||
getOrganization.customGET().then(function(resp) {
|
||||
ApiService.getOrganization(null, {'orgname': $scope.namespace}).then(function(resp) {
|
||||
$scope.teams = resp.teams;
|
||||
});
|
||||
}
|
||||
|
||||
var url = $scope.isOrganization ? getRestUrl('organization', $scope.namespace, 'robots') : 'user/robots';
|
||||
var getRobots = Restangular.one(url);
|
||||
getRobots.customGET().then(function(resp) {
|
||||
ApiService.getRobots($scope.isOrganization ? $scope.namespace : null).then(function(resp) {
|
||||
$scope.robots = resp.robots;
|
||||
$scope.lazyLoading = false;
|
||||
}, function() {
|
||||
|
@ -1588,7 +1706,7 @@ quayApp.directive('entitySearch', function () {
|
|||
return;
|
||||
}
|
||||
|
||||
createOrganizationTeam(Restangular, $scope.namespace, teamname, function(created) {
|
||||
createOrganizationTeam(ApiService, $scope.namespace, teamname, function(created) {
|
||||
$scope.setEntity(created.name, 'team', false);
|
||||
$scope.teams[teamname] = created;
|
||||
});
|
||||
|
@ -1607,7 +1725,7 @@ quayApp.directive('entitySearch', function () {
|
|||
return;
|
||||
}
|
||||
|
||||
createRobotAccount(Restangular, $scope.isOrganization, $scope.namespace, robotname, function(created) {
|
||||
createRobotAccount(ApiService, $scope.isOrganization, $scope.namespace, robotname, function(created) {
|
||||
$scope.setEntity(created.name, 'user', true);
|
||||
$scope.robots.push(created);
|
||||
});
|
||||
|
@ -1733,7 +1851,7 @@ quayApp.directive('billingOptions', function () {
|
|||
'user': '=user',
|
||||
'organization': '=organization'
|
||||
},
|
||||
controller: function($scope, $element, PlanService, Restangular) {
|
||||
controller: function($scope, $element, PlanService, ApiService) {
|
||||
$scope.invoice_email = false;
|
||||
$scope.currentCard = null;
|
||||
|
||||
|
@ -1803,9 +1921,7 @@ quayApp.directive('billingOptions', function () {
|
|||
|
||||
var save = function() {
|
||||
$scope.working = true;
|
||||
var url = $scope.organization ? getRestUrl('organization', $scope.organization.name) : 'user/';
|
||||
var conductSave = Restangular.one(url);
|
||||
conductSave.customPUT($scope.obj).then(function(resp) {
|
||||
ApiService.changeDetails($scope.organization, $scope.obj).then(function(resp) {
|
||||
$scope.working = false;
|
||||
});
|
||||
};
|
||||
|
@ -1840,11 +1956,19 @@ quayApp.directive('planManager', function () {
|
|||
'readyForPlan': '&readyForPlan',
|
||||
'planChanged': '&planChanged'
|
||||
},
|
||||
controller: function($scope, $element, PlanService, Restangular) {
|
||||
controller: function($scope, $element, PlanService, ApiService) {
|
||||
var hasSubscription = false;
|
||||
|
||||
$scope.getActiveSubClass = function() {
|
||||
return 'active';
|
||||
$scope.isPlanVisible = function(plan, subscribedPlan) {
|
||||
if (plan['deprecated']) {
|
||||
return plan == subscribedPlan;
|
||||
}
|
||||
|
||||
if ($scope.organization && !PlanService.isOrgCompatible(plan)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
$scope.changeSubscription = function(planId) {
|
||||
|
@ -1865,17 +1989,17 @@ quayApp.directive('planManager', function () {
|
|||
};
|
||||
|
||||
$scope.cancelSubscription = function() {
|
||||
$scope.changeSubscription(getFreePlan());
|
||||
$scope.changeSubscription(PlanService.getFreePlan());
|
||||
};
|
||||
|
||||
var subscribedToPlan = function(sub) {
|
||||
$scope.subscription = sub;
|
||||
|
||||
if (sub.plan != getFreePlan()) {
|
||||
if (sub.plan != PlanService.getFreePlan()) {
|
||||
hasSubscription = true;
|
||||
}
|
||||
|
||||
PlanService.getPlan(sub.plan, function(subscribedPlan) {
|
||||
PlanService.getPlanIncludingDeprecated(sub.plan, function(subscribedPlan) {
|
||||
$scope.subscribedPlan = subscribedPlan;
|
||||
$scope.planUsagePercent = sub.usedPrivateRepos * 100 / $scope.subscribedPlan.privateRepos;
|
||||
|
||||
|
@ -1905,22 +2029,13 @@ quayApp.directive('planManager', function () {
|
|||
});
|
||||
};
|
||||
|
||||
var getFreePlan = function() {
|
||||
for (var i = 0; i < $scope.plans.length; ++i) {
|
||||
if ($scope.plans[i].price == 0) {
|
||||
return $scope.plans[i].stripeId;
|
||||
}
|
||||
}
|
||||
return 'free';
|
||||
};
|
||||
|
||||
var update = function() {
|
||||
$scope.planLoading = true;
|
||||
if (!$scope.plans) { return; }
|
||||
|
||||
PlanService.getSubscription($scope.organization, subscribedToPlan, function() {
|
||||
// User/Organization has no subscription.
|
||||
subscribedToPlan({ 'plan': getFreePlan() });
|
||||
subscribedToPlan({ 'plan': PlanService.getFreePlan() });
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -1929,13 +2044,13 @@ quayApp.directive('planManager', function () {
|
|||
if (!$scope.user && !$scope.organization) { return; }
|
||||
|
||||
$scope.loadingPlans = true;
|
||||
PlanService.getPlans(function(plans) {
|
||||
$scope.plans = plans[$scope.organization ? 'business' : 'user'];
|
||||
PlanService.verifyLoaded(function(plans) {
|
||||
$scope.plans = plans;
|
||||
update();
|
||||
|
||||
if ($scope.readyForPlan) {
|
||||
var planRequested = $scope.readyForPlan();
|
||||
if (planRequested && planRequested != getFreePlan()) {
|
||||
if (planRequested && planRequested != PlanService.getFreePlan()) {
|
||||
$scope.changeSubscription(planRequested);
|
||||
}
|
||||
}
|
||||
|
@ -2101,15 +2216,27 @@ quayApp.run(['$location', '$rootScope', 'Restangular', 'UserService', 'PlanServi
|
|||
// Check if we need to redirect based on a previously chosen plan.
|
||||
PlanService.handleNotedPlan();
|
||||
|
||||
var changeTab = function(activeTab) {
|
||||
var changeTab = function(activeTab, opt_timeout) {
|
||||
var checkCount = 0;
|
||||
|
||||
$timeout(function() {
|
||||
if (checkCount > 5) { return; }
|
||||
checkCount++;
|
||||
|
||||
$('a[data-toggle="tab"]').each(function(index) {
|
||||
var tabName = this.getAttribute('data-target').substr(1);
|
||||
if (tabName == activeTab) {
|
||||
this.click();
|
||||
if (tabName != activeTab) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.clientWidth == 0) {
|
||||
changeTab(activeTab, 500);
|
||||
return;
|
||||
}
|
||||
|
||||
this.click();
|
||||
});
|
||||
});
|
||||
}, opt_timeout);
|
||||
};
|
||||
|
||||
var resetDefaultTab = function() {
|
||||
|
|
13
static/js/bootstrap.js
vendored
Normal file
13
static/js/bootstrap.js
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
$.ajax({
|
||||
type: 'GET',
|
||||
async: false,
|
||||
url: '/api/discovery',
|
||||
success: function(data) {
|
||||
window.__endpoints = data.endpoints;
|
||||
},
|
||||
error: function() {
|
||||
setTimeout(function() {
|
||||
$('#couldnotloadModal').modal({});
|
||||
}, 250);
|
||||
}
|
||||
});
|
|
@ -22,7 +22,7 @@ function PlansCtrl($scope, $location, UserService, PlanService) {
|
|||
// Load the list of plans.
|
||||
PlanService.getPlans(function(plans) {
|
||||
$scope.plans = plans;
|
||||
});
|
||||
}, /* include the personal plan */ true);
|
||||
|
||||
// Monitor any user changes and place the current user into the scope.
|
||||
UserService.updateUserIn($scope);
|
||||
|
@ -33,19 +33,10 @@ function PlansCtrl($scope, $location, UserService, PlanService) {
|
|||
};
|
||||
|
||||
$scope.buyNow = function(plan) {
|
||||
PlanService.notePlan(plan);
|
||||
if ($scope.user && !$scope.user.anonymous) {
|
||||
document.location = '/user?plan=' + plan;
|
||||
PlanService.handleNotedPlan();
|
||||
} else {
|
||||
PlanService.notePlan(plan);
|
||||
$('#signinModal').modal({});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.createOrg = function(plan) {
|
||||
if ($scope.user && !$scope.user.anonymous) {
|
||||
document.location = '/organizations/new/?plan=' + plan;
|
||||
} else {
|
||||
PlanService.notePlan(plan);
|
||||
$('#signinModal').modal({});
|
||||
}
|
||||
};
|
||||
|
@ -76,14 +67,15 @@ function RepoListCtrl($scope, Restangular, UserService, ApiService) {
|
|||
}
|
||||
|
||||
var options = {'public': false, 'sort': true, 'namespace': namespace};
|
||||
$scope.user_repositories = ApiService.at('repository').withOptions(options).get(function(resp) {
|
||||
|
||||
$scope.user_repositories = ApiService.listReposAsResource().withOptions(options).get(function(resp) {
|
||||
return resp.repositories;
|
||||
});
|
||||
};
|
||||
|
||||
var loadPublicRepos = function() {
|
||||
var options = {'public': true, 'private': false, 'sort': true, 'limit': 10};
|
||||
$scope.public_repositories = ApiService.at('repository').withOptions(options).get(function(resp) {
|
||||
$scope.public_repositories = ApiService.listReposAsResource().withOptions(options).get(function(resp) {
|
||||
return resp.repositories;
|
||||
});
|
||||
};
|
||||
|
@ -127,7 +119,7 @@ function LandingCtrl($scope, UserService, ApiService) {
|
|||
}
|
||||
|
||||
var options = {'limit': 4, 'public': false, 'sort': true, 'namespace': namespace };
|
||||
$scope.my_repositories = ApiService.at('repository').withOptions(options).get(function(resp) {
|
||||
$scope.my_repositories = ApiService.listReposAsResource().withOptions(options).get(function(resp) {
|
||||
return resp.repositories;
|
||||
});
|
||||
};
|
||||
|
@ -178,7 +170,8 @@ function RepoCtrl($scope, Restangular, ApiService, $routeParams, $rootScope, $lo
|
|||
};
|
||||
|
||||
$scope.loadImageChanges = function(image) {
|
||||
$scope.currentImageChangeResource = ApiService.at('repository', namespace, name, 'image', image.id, 'changes').get(function(ci) {
|
||||
var params = {'repository': namespace + '/' + name, 'image_id': image.id};
|
||||
$scope.currentImageChangeResource = ApiService.getImageChangesAsResource(params).get(function(ci) {
|
||||
$scope.currentImageChanges = ci;
|
||||
});
|
||||
};
|
||||
|
@ -249,8 +242,9 @@ function RepoCtrl($scope, Restangular, ApiService, $routeParams, $rootScope, $lo
|
|||
};
|
||||
|
||||
var fetchRepository = function() {
|
||||
var params = {'repository': namespace + '/' + name};
|
||||
$rootScope.title = 'Loading Repository...';
|
||||
$scope.repository = ApiService.at('repository', namespace, name).get(function(repo) {
|
||||
$scope.repository = ApiService.getRepoAsResource(params).get(function(repo) {
|
||||
// Set the repository object.
|
||||
$scope.repo = repo;
|
||||
|
||||
|
@ -292,6 +286,7 @@ function RepoCtrl($scope, Restangular, ApiService, $routeParams, $rootScope, $lo
|
|||
};
|
||||
|
||||
var getBuildInfo = function(repo) {
|
||||
// Note: We use restangular manually here because we need to turn off the loading bar.
|
||||
var buildInfo = Restangular.one('repository/' + repo.namespace + '/' + repo.name + '/build/');
|
||||
buildInfo.withHttpConfig({
|
||||
'ignoreLoadingBar': true
|
||||
|
@ -321,7 +316,8 @@ function RepoCtrl($scope, Restangular, ApiService, $routeParams, $rootScope, $lo
|
|||
};
|
||||
|
||||
var listImages = function() {
|
||||
$scope.imageHistory = ApiService.at('repository', namespace, name, 'image').get(function(resp) {
|
||||
var params = {'repository': namespace + '/' + name};
|
||||
$scope.imageHistory = ApiService.listRepositoryImagesAsResource(params).get(function(resp) {
|
||||
// Dispose of any existing tree.
|
||||
if ($scope.tree) {
|
||||
$scope.tree.dispose();
|
||||
|
@ -361,11 +357,6 @@ function RepoCtrl($scope, Restangular, ApiService, $routeParams, $rootScope, $lo
|
|||
}
|
||||
|
||||
function RepoAdminCtrl($scope, Restangular, ApiService, $routeParams, $rootScope) {
|
||||
$('.info-icon').popover({
|
||||
'trigger': 'hover',
|
||||
'html': true
|
||||
});
|
||||
|
||||
var namespace = $routeParams.namespace;
|
||||
var name = $routeParams.name;
|
||||
|
||||
|
@ -452,8 +443,8 @@ function RepoAdminCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
|
|||
'friendlyName': $scope.newToken.friendlyName
|
||||
};
|
||||
|
||||
var permissionPost = Restangular.one('repository/' + namespace + '/' + name + '/tokens/');
|
||||
permissionPost.customPOST(friendlyName).then(function(newToken) {
|
||||
var params = {'repository': namespace + '/' + name};
|
||||
ApiService.createToken(friendlyName, params).then(function(newToken) {
|
||||
$scope.newToken.friendlyName = '';
|
||||
$scope.createTokenForm.$setPristine();
|
||||
$scope.tokens[newToken.code] = newToken;
|
||||
|
@ -461,8 +452,12 @@ function RepoAdminCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
|
|||
};
|
||||
|
||||
$scope.deleteToken = function(tokenCode) {
|
||||
var deleteAction = Restangular.one('repository/' + namespace + '/' + name + '/tokens/' + tokenCode);
|
||||
deleteAction.customDELETE().then(function() {
|
||||
var params = {
|
||||
'repository': namespace + '/' + name,
|
||||
'code': tokenCode
|
||||
};
|
||||
|
||||
ApiService.deleteToken(null, params).then(function() {
|
||||
delete $scope.tokens[tokenCode];
|
||||
});
|
||||
};
|
||||
|
@ -472,8 +467,12 @@ function RepoAdminCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
|
|||
'role': newAccess
|
||||
};
|
||||
|
||||
var deleteAction = Restangular.one('repository/' + namespace + '/' + name + '/tokens/' + tokenCode);
|
||||
deleteAction.customPUT(role).then(function(updated) {
|
||||
var params = {
|
||||
'repository': namespace + '/' + name,
|
||||
'code': tokenCode
|
||||
};
|
||||
|
||||
ApiService.changeToken(role, params).then(function(updated) {
|
||||
$scope.tokens[updated.code] = updated;
|
||||
});
|
||||
};
|
||||
|
@ -495,8 +494,12 @@ function RepoAdminCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
|
|||
var visibility = {
|
||||
'visibility': newAccess
|
||||
};
|
||||
var visibilityPost = Restangular.one('repository/' + namespace + '/' + name + '/changevisibility');
|
||||
visibilityPost.customPOST(visibility).then(function() {
|
||||
|
||||
var params = {
|
||||
'repository': namespace + '/' + name
|
||||
};
|
||||
|
||||
ApiService.changeRepoVisibility(visibility, params).then(function() {
|
||||
$scope.repo.is_public = newAccess == 'public';
|
||||
}, function() {
|
||||
$('#cannotchangeModal').modal({});
|
||||
|
@ -510,8 +513,11 @@ function RepoAdminCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
|
|||
$scope.deleteRepo = function() {
|
||||
$('#confirmdeleteModal').modal('hide');
|
||||
|
||||
var deleteAction = Restangular.one('repository/' + namespace + '/' + name);
|
||||
deleteAction.customDELETE().then(function() {
|
||||
var params = {
|
||||
'repository': namespace + '/' + name
|
||||
};
|
||||
|
||||
ApiService.deleteRepository(null, params).then(function() {
|
||||
$scope.repo = null;
|
||||
|
||||
setTimeout(function() {
|
||||
|
@ -523,8 +529,12 @@ function RepoAdminCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
|
|||
};
|
||||
|
||||
$scope.loadWebhooks = function() {
|
||||
var params = {
|
||||
'repository': namespace + '/' + name
|
||||
};
|
||||
|
||||
$scope.newWebhook = {};
|
||||
$scope.webhooksResource = ApiService.at('repository', namespace, name, 'webhook').get(function(resp) {
|
||||
$scope.webhooksResource = ApiService.listWebhooksAsResource(params).get(function(resp) {
|
||||
$scope.webhooks = resp.webhooks;
|
||||
return $scope.webhooks;
|
||||
});
|
||||
|
@ -535,8 +545,11 @@ function RepoAdminCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
|
|||
return;
|
||||
}
|
||||
|
||||
var newWebhook = Restangular.one('repository/' + namespace + '/' + name + '/webhook/');
|
||||
newWebhook.customPOST($scope.newWebhook).then(function(resp) {
|
||||
var params = {
|
||||
'repository': namespace + '/' + name
|
||||
};
|
||||
|
||||
ApiService.createWebhook($scope.newWebhook, params).then(function(resp) {
|
||||
$scope.webhooks.push(resp);
|
||||
$scope.newWebhook.url = '';
|
||||
$scope.createWebhookForm.$setPristine();
|
||||
|
@ -544,15 +557,22 @@ function RepoAdminCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
|
|||
};
|
||||
|
||||
$scope.deleteWebhook = function(webhook) {
|
||||
var deleteWebhookReq = Restangular.one('repository/' + namespace + '/' + name + '/webhook/' + webhook.public_id);
|
||||
deleteWebhookReq.customDELETE().then(function(resp) {
|
||||
var params = {
|
||||
'repository': namespace + '/' + name,
|
||||
'public_id': webhook.public_id
|
||||
};
|
||||
|
||||
ApiService.deleteWebhook(null, params).then(function(resp) {
|
||||
$scope.webhooks.splice($scope.webhooks.indexOf(webhook), 1);
|
||||
});
|
||||
};
|
||||
|
||||
var fetchTokens = function() {
|
||||
var tokensFetch = Restangular.one('repository/' + namespace + '/' + name + '/tokens/');
|
||||
tokensFetch.get().then(function(resp) {
|
||||
var params = {
|
||||
'repository': namespace + '/' + name
|
||||
};
|
||||
|
||||
ApiService.listRepoTokens(null, params).then(function(resp) {
|
||||
$scope.tokens = resp.tokens;
|
||||
}, function() {
|
||||
$scope.tokens = null;
|
||||
|
@ -569,7 +589,11 @@ function RepoAdminCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
|
|||
};
|
||||
|
||||
var fetchRepository = function() {
|
||||
$scope.repository = ApiService.at('repository', namespace, name).get(function(repo) {
|
||||
var params = {
|
||||
'repository': namespace + '/' + name
|
||||
};
|
||||
|
||||
$scope.repository = ApiService.getRepoAsResource(params).get(function(repo) {
|
||||
$scope.repo = repo;
|
||||
|
||||
$rootScope.title = 'Settings - ' + namespace + '/' + name;
|
||||
|
@ -581,6 +605,11 @@ function RepoAdminCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
|
|||
fetchPermissions('team');
|
||||
fetchTokens();
|
||||
|
||||
$('.info-icon').popover({
|
||||
'trigger': 'hover',
|
||||
'html': true
|
||||
});
|
||||
|
||||
return $scope.repo;
|
||||
});
|
||||
};
|
||||
|
@ -589,13 +618,14 @@ function RepoAdminCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
|
|||
fetchRepository();
|
||||
}
|
||||
|
||||
function UserAdminCtrl($scope, $timeout, $location, Restangular, PlanService, UserService, KeyService, $routeParams) {
|
||||
function UserAdminCtrl($scope, $timeout, $location, ApiService, PlanService, UserService, KeyService, $routeParams) {
|
||||
if ($routeParams['migrate']) {
|
||||
$('#migrateTab').tab('show')
|
||||
}
|
||||
|
||||
UserService.updateUserIn($scope, function(user) {
|
||||
$scope.askForPassword = user.askForPassword;
|
||||
$scope.cuser = jQuery.extend({}, user);
|
||||
});
|
||||
|
||||
$scope.readyForPlan = function() {
|
||||
|
@ -611,8 +641,22 @@ function UserAdminCtrl($scope, $timeout, $location, Restangular, PlanService, Us
|
|||
|
||||
$('.form-change-pw').popover();
|
||||
|
||||
$scope.logsShown = 0;
|
||||
$scope.invoicesShown = 0;
|
||||
|
||||
$scope.loadLogs = function() {
|
||||
if (!$scope.hasPaidBusinessPlan) { return; }
|
||||
$scope.logsShown++;
|
||||
};
|
||||
|
||||
$scope.loadInvoices = function() {
|
||||
if (!$scope.hasPaidBusinessPlan) { return; }
|
||||
$scope.invoicesShown++;
|
||||
};
|
||||
|
||||
$scope.planChanged = function(plan) {
|
||||
$scope.hasPaidPlan = plan && plan.price > 0;
|
||||
$scope.hasPaidBusinessPlan = PlanService.isOrgCompatible(plan) && plan.price > 0;
|
||||
};
|
||||
|
||||
$scope.showConvertForm = function() {
|
||||
|
@ -621,7 +665,7 @@ function UserAdminCtrl($scope, $timeout, $location, Restangular, PlanService, Us
|
|||
});
|
||||
|
||||
PlanService.getPlans(function(plans) {
|
||||
$scope.orgPlans = plans.business;
|
||||
$scope.orgPlans = plans;
|
||||
});
|
||||
|
||||
$scope.convertStep = 1;
|
||||
|
@ -640,8 +684,7 @@ function UserAdminCtrl($scope, $timeout, $location, Restangular, PlanService, Us
|
|||
'plan': $scope.org.plan.stripeId
|
||||
};
|
||||
|
||||
var convertAccount = Restangular.one('user/convert');
|
||||
convertAccount.customPOST(data).then(function(resp) {
|
||||
ApiService.convertUserToOrganization(data).then(function(resp) {
|
||||
UserService.load();
|
||||
$location.path('/');
|
||||
}, function(resp) {
|
||||
|
@ -658,14 +701,14 @@ function UserAdminCtrl($scope, $timeout, $location, Restangular, PlanService, Us
|
|||
$('.form-change-pw').popover('hide');
|
||||
$scope.updatingUser = true;
|
||||
$scope.changePasswordSuccess = false;
|
||||
var changePasswordPost = Restangular.one('user/');
|
||||
changePasswordPost.customPUT($scope.user).then(function() {
|
||||
|
||||
ApiService.changeUserDetails($scope.cuser).then(function() {
|
||||
$scope.updatingUser = false;
|
||||
$scope.changePasswordSuccess = true;
|
||||
|
||||
// Reset the form
|
||||
$scope.user.password = '';
|
||||
$scope.user.repeatPassword = '';
|
||||
$scope.cuser.password = '';
|
||||
$scope.cuser.repeatPassword = '';
|
||||
$scope.changePasswordForm.$setPristine();
|
||||
|
||||
// Reload the user.
|
||||
|
@ -681,7 +724,7 @@ function UserAdminCtrl($scope, $timeout, $location, Restangular, PlanService, Us
|
|||
};
|
||||
}
|
||||
|
||||
function ImageViewCtrl($scope, $routeParams, $rootScope, $timeout, ApiService, Restangular) {
|
||||
function ImageViewCtrl($scope, $routeParams, $rootScope, $timeout, ApiService) {
|
||||
var namespace = $routeParams.namespace;
|
||||
var name = $routeParams.name;
|
||||
var imageid = $routeParams.image;
|
||||
|
@ -737,7 +780,12 @@ function ImageViewCtrl($scope, $routeParams, $rootScope, $timeout, ApiService, R
|
|||
};
|
||||
|
||||
var fetchImage = function() {
|
||||
$scope.image = ApiService.at('repository', namespace, name, 'image', imageid).get(function(image) {
|
||||
var params = {
|
||||
'repository': namespace + '/' + name,
|
||||
'image_id': imageid
|
||||
};
|
||||
|
||||
$scope.image = ApiService.getImageAsResource(params).get(function(image) {
|
||||
$scope.repo = {
|
||||
'name': name,
|
||||
'namespace': namespace
|
||||
|
@ -757,8 +805,12 @@ function ImageViewCtrl($scope, $routeParams, $rootScope, $timeout, ApiService, R
|
|||
};
|
||||
|
||||
var fetchChanges = function() {
|
||||
var changesFetch = Restangular.one('repository/' + namespace + '/' + name + '/image/' + imageid + '/changes');
|
||||
changesFetch.get().then(function(changes) {
|
||||
var params = {
|
||||
'repository': namespace + '/' + name,
|
||||
'image_id': imageid
|
||||
};
|
||||
|
||||
ApiService.getImageChanges(null, params).then(function(changes) {
|
||||
var combinedChanges = [];
|
||||
var addCombinedChanges = function(c, kind) {
|
||||
for (var i = 0; i < c.length; ++i) {
|
||||
|
@ -786,7 +838,7 @@ function V1Ctrl($scope, $location, UserService) {
|
|||
UserService.updateUserIn($scope);
|
||||
}
|
||||
|
||||
function NewRepoCtrl($scope, $location, $http, $timeout, UserService, Restangular, PlanService) {
|
||||
function NewRepoCtrl($scope, $location, $http, $timeout, UserService, ApiService, PlanService) {
|
||||
UserService.updateUserIn($scope);
|
||||
|
||||
$scope.repo = {
|
||||
|
@ -817,8 +869,7 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, Restangula
|
|||
if (isUserNamespace) {
|
||||
// Load the user's subscription information in case they want to create a private
|
||||
// repository.
|
||||
var checkPrivateAllowed = Restangular.one('user/private');
|
||||
checkPrivateAllowed.get().then(function(resp) {
|
||||
ApiService.getUserPrivateCount().then(function(resp) {
|
||||
if (resp.privateCount + 1 > resp.reposAllowed) {
|
||||
PlanService.getMinimumPlan(resp.privateCount + 1, false, function(minimum) {
|
||||
$scope.planRequired = minimum;
|
||||
|
@ -831,8 +882,7 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, Restangula
|
|||
$scope.checkingPlan = false;
|
||||
});
|
||||
} else {
|
||||
var checkPrivateAllowed = Restangular.one('organization/' + namespace + '/private');
|
||||
checkPrivateAllowed.get().then(function(resp) {
|
||||
ApiService.getOrganizationPrivateAllowed(null, {'orgname': namespace}).then(function(resp) {
|
||||
$scope.planRequired = resp.privateAllowed ? null : {};
|
||||
$scope.checkingPlan = false;
|
||||
}, function() {
|
||||
|
@ -863,8 +913,7 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, Restangula
|
|||
'description': repo.description
|
||||
};
|
||||
|
||||
var createPost = Restangular.one('repository');
|
||||
createPost.customPOST(data).then(function(created) {
|
||||
ApiService.createRepo(data).then(function(created) {
|
||||
$scope.creating = false;
|
||||
$scope.created = created;
|
||||
|
||||
|
@ -907,9 +956,12 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, Restangula
|
|||
'file_id': fileId
|
||||
};
|
||||
|
||||
var startBuildCall = Restangular.one('repository/' + repo.namespace + '/' + repo.name + '/build/');
|
||||
startBuildCall.customPOST(data).then(function(resp) {
|
||||
$location.path('/repository/' + repo.namespace + '/' + repo.name);
|
||||
var params = {
|
||||
'repository': repo.namespace + '/' + repo.name
|
||||
};
|
||||
|
||||
ApiService.requestRepoBuild(data, params).then(function(resp) {
|
||||
$location.path('/repository/' + params.repository);
|
||||
}, function() {
|
||||
$('#couldnotbuildModal').modal();
|
||||
});
|
||||
|
@ -958,8 +1010,7 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, Restangula
|
|||
'mimeType': mimeType
|
||||
};
|
||||
|
||||
var getUploadUrl = Restangular.one('filedrop/');
|
||||
getUploadUrl.customPOST(data).then(function(resp) {
|
||||
var getUploadUrl = ApiService.getFiledropUrl(data).then(function(resp) {
|
||||
conductUpload(repo, file, resp.url, resp.file_id, mimeType);
|
||||
}, function() {
|
||||
$('#couldnotbuildModal').modal();
|
||||
|
@ -987,14 +1038,9 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, Restangula
|
|||
};
|
||||
}
|
||||
|
||||
function OrgViewCtrl($rootScope, $scope, Restangular, ApiService, $routeParams) {
|
||||
function OrgViewCtrl($rootScope, $scope, ApiService, $routeParams) {
|
||||
var orgname = $routeParams.orgname;
|
||||
|
||||
$('.info-icon').popover({
|
||||
'trigger': 'hover',
|
||||
'html': true
|
||||
});
|
||||
|
||||
$scope.TEAM_PATTERN = TEAM_PATTERN;
|
||||
$rootScope.title = 'Loading...';
|
||||
|
||||
|
@ -1008,10 +1054,14 @@ function OrgViewCtrl($rootScope, $scope, Restangular, ApiService, $routeParams)
|
|||
var previousRole = $scope.organization.teams[teamname].role;
|
||||
$scope.organization.teams[teamname].role = role;
|
||||
|
||||
var updateTeam = Restangular.one(getRestUrl('organization', orgname, 'team', teamname));
|
||||
var params = {
|
||||
'orgname': orgname,
|
||||
'teamname': teamname
|
||||
};
|
||||
|
||||
var data = $scope.organization.teams[teamname];
|
||||
|
||||
updateTeam.customPUT(data).then(function(resp) {
|
||||
ApiService.updateOrganizationTeam(data, params).then(function(resp) {
|
||||
}, function(resp) {
|
||||
$scope.organization.teams[teamname].role = previousRole;
|
||||
$scope.roleError = resp.data || '';
|
||||
|
@ -1032,7 +1082,7 @@ function OrgViewCtrl($rootScope, $scope, Restangular, ApiService, $routeParams)
|
|||
return;
|
||||
}
|
||||
|
||||
createOrganizationTeam(Restangular, orgname, teamname, function(created) {
|
||||
createOrganizationTeam(ApiService, orgname, teamname, function(created) {
|
||||
$scope.organization.teams[teamname] = created;
|
||||
});
|
||||
};
|
||||
|
@ -1047,8 +1097,12 @@ function OrgViewCtrl($rootScope, $scope, Restangular, ApiService, $routeParams)
|
|||
if (!$scope.currentDeleteTeam) { return; }
|
||||
|
||||
var teamname = $scope.currentDeleteTeam;
|
||||
var deleteAction = Restangular.one(getRestUrl('organization', orgname, 'team', teamname));
|
||||
deleteAction.customDELETE().then(function() {
|
||||
var params = {
|
||||
'orgname': orgname,
|
||||
'teamname': teamname
|
||||
};
|
||||
|
||||
ApiService.deleteOrganizationTeam(null, params).then(function() {
|
||||
delete $scope.organization.teams[teamname];
|
||||
$scope.currentDeleteTeam = null;
|
||||
}, function() {
|
||||
|
@ -1058,10 +1112,15 @@ function OrgViewCtrl($rootScope, $scope, Restangular, ApiService, $routeParams)
|
|||
};
|
||||
|
||||
var loadOrganization = function() {
|
||||
$scope.orgResource = ApiService.at('organization', orgname).get(function(org) {
|
||||
$scope.orgResource = ApiService.getOrganizationAsResource({'orgname': orgname}).get(function(org) {
|
||||
$scope.organization = org;
|
||||
$rootScope.title = orgname;
|
||||
$rootScope.description = 'Viewing organization ' + orgname;
|
||||
|
||||
$('.info-icon').popover({
|
||||
'trigger': 'hover',
|
||||
'html': true
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -1074,17 +1133,12 @@ function OrgAdminCtrl($rootScope, $scope, Restangular, $routeParams, UserService
|
|||
|
||||
// Load the list of plans.
|
||||
PlanService.getPlans(function(plans) {
|
||||
$scope.plans = plans.business;
|
||||
$scope.plans = plans;
|
||||
$scope.plan_map = {};
|
||||
|
||||
var addPlans = function(plans) {
|
||||
for (var i = 0; i < plans.length; ++i) {
|
||||
$scope.plan_map[plans[i].stripeId] = plans[i];
|
||||
}
|
||||
};
|
||||
|
||||
addPlans(plans.user);
|
||||
addPlans(plans.business);
|
||||
for (var i = 0; i < plans.length; ++i) {
|
||||
$scope.plan_map[plans[i].stripeId] = plans[i];
|
||||
}
|
||||
});
|
||||
|
||||
$scope.orgname = orgname;
|
||||
|
@ -1092,37 +1146,29 @@ function OrgAdminCtrl($rootScope, $scope, Restangular, $routeParams, UserService
|
|||
$scope.membersFound = null;
|
||||
$scope.invoiceLoading = true;
|
||||
$scope.logsShown = 0;
|
||||
$scope.invoicesShown = 0;
|
||||
|
||||
$scope.loadLogs = function() {
|
||||
$scope.logsShown++;
|
||||
};
|
||||
|
||||
$scope.loadInvoices = function() {
|
||||
$scope.invoicesShown++;
|
||||
};
|
||||
|
||||
$scope.planChanged = function(plan) {
|
||||
$scope.hasPaidPlan = plan && plan.price > 0;
|
||||
};
|
||||
|
||||
$scope.loadInvoices = function() {
|
||||
if ($scope.invoices) { return; }
|
||||
$scope.invoiceLoading = true;
|
||||
|
||||
var getInvoices = Restangular.one(getRestUrl('organization', orgname, 'invoices'));
|
||||
getInvoices.get().then(function(resp) {
|
||||
$scope.invoiceExpanded = {};
|
||||
$scope.invoices = resp.invoices;
|
||||
$scope.invoiceLoading = false;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.toggleInvoice = function(id) {
|
||||
$scope.invoiceExpanded[id] = !$scope.invoiceExpanded[id];
|
||||
};
|
||||
|
||||
$scope.loadMembers = function() {
|
||||
if ($scope.membersFound) { return; }
|
||||
$scope.membersLoading = true;
|
||||
|
||||
var getMembers = Restangular.one(getRestUrl('organization', orgname, 'members'));
|
||||
getMembers.get().then(function(resp) {
|
||||
|
||||
var params = {
|
||||
'orgname': orgname
|
||||
};
|
||||
|
||||
ApiService.getOrganizationMembers(null, params).then(function(resp) {
|
||||
var membersArray = [];
|
||||
for (var key in resp.members) {
|
||||
if (resp.members.hasOwnProperty(key)) {
|
||||
|
@ -1136,7 +1182,7 @@ function OrgAdminCtrl($rootScope, $scope, Restangular, $routeParams, UserService
|
|||
};
|
||||
|
||||
var loadOrganization = function() {
|
||||
$scope.orgResource = ApiService.at('organization', orgname).get(function(org) {
|
||||
$scope.orgResource = ApiService.getOrganizationAsResource({'orgname': orgname}).get(function(org) {
|
||||
if (org && org.is_admin) {
|
||||
$scope.organization = org;
|
||||
$rootScope.title = orgname + ' (Admin)';
|
||||
|
@ -1150,11 +1196,6 @@ function OrgAdminCtrl($rootScope, $scope, Restangular, $routeParams, UserService
|
|||
}
|
||||
|
||||
function TeamViewCtrl($rootScope, $scope, Restangular, ApiService, $routeParams) {
|
||||
$('.info-icon').popover({
|
||||
'trigger': 'hover',
|
||||
'html': true
|
||||
});
|
||||
|
||||
var teamname = $routeParams.teamname;
|
||||
var orgname = $routeParams.orgname;
|
||||
|
||||
|
@ -1166,8 +1207,13 @@ function TeamViewCtrl($rootScope, $scope, Restangular, ApiService, $routeParams)
|
|||
$scope.addNewMember = function(member) {
|
||||
if ($scope.members[member.name]) { return; }
|
||||
|
||||
var addMember = Restangular.one(getRestUrl('organization', $scope.orgname, 'team', teamname, 'members', member.name));
|
||||
addMember.customPOST().then(function(resp) {
|
||||
var params = {
|
||||
'orgname': orgname,
|
||||
'teamname': teamname,
|
||||
'membername': member.name
|
||||
};
|
||||
|
||||
ApiService.updateOrganizationTeamMember(null, params).then(function(resp) {
|
||||
$scope.members[member.name] = resp;
|
||||
}, function() {
|
||||
$('#cannotChangeMembersModal').modal({});
|
||||
|
@ -1175,8 +1221,13 @@ function TeamViewCtrl($rootScope, $scope, Restangular, ApiService, $routeParams)
|
|||
};
|
||||
|
||||
$scope.removeMember = function(username) {
|
||||
var removeMember = Restangular.one(getRestUrl('organization', $scope.orgname, 'team', teamname, 'members', username));
|
||||
removeMember.customDELETE().then(function(resp) {
|
||||
var params = {
|
||||
'orgname': orgname,
|
||||
'teamname': teamname,
|
||||
'membername': username
|
||||
};
|
||||
|
||||
ApiService.deleteOrganizationTeamMember(null, params).then(function(resp) {
|
||||
delete $scope.members[username];
|
||||
}, function() {
|
||||
$('#cannotChangeMembersModal').modal({});
|
||||
|
@ -1186,16 +1237,20 @@ function TeamViewCtrl($rootScope, $scope, Restangular, ApiService, $routeParams)
|
|||
$scope.updateForDescription = function(content) {
|
||||
$scope.organization.teams[teamname].description = content;
|
||||
|
||||
var updateTeam = Restangular.one(getRestUrl('organization', $scope.orgname, 'team', teamname));
|
||||
var data = $scope.organization.teams[teamname];
|
||||
updateTeam.customPUT(data).then(function(resp) {
|
||||
var params = {
|
||||
'orgname': orgname,
|
||||
'teamname': teamname
|
||||
};
|
||||
|
||||
var teaminfo = $scope.organization.teams[teamname];
|
||||
ApiService.updateOrganizationTeam(teaminfo, params).then(function(resp) {
|
||||
}, function() {
|
||||
$('#cannotChangeTeamModal').modal({});
|
||||
});
|
||||
};
|
||||
|
||||
var loadOrganization = function() {
|
||||
$scope.orgResource = ApiService.at('organization', orgname).get(function(org) {
|
||||
$scope.orgResource = ApiService.getOrganizationAsResource({'orgname': orgname}).get(function(org) {
|
||||
$scope.organization = org;
|
||||
$scope.team = $scope.organization.teams[teamname];
|
||||
$rootScope.title = teamname + ' (' + $scope.orgname + ')';
|
||||
|
@ -1206,11 +1261,22 @@ function TeamViewCtrl($rootScope, $scope, Restangular, ApiService, $routeParams)
|
|||
};
|
||||
|
||||
var loadMembers = function() {
|
||||
$scope.membersResource = ApiService.at('organization', $scope.orgname, 'team', teamname, 'members').get(function(resp) {
|
||||
var params = {
|
||||
'orgname': orgname,
|
||||
'teamname': teamname
|
||||
};
|
||||
|
||||
$scope.membersResource = ApiService.getOrganizationTeamMembersAsResource(params).get(function(resp) {
|
||||
$scope.members = resp.members;
|
||||
$scope.canEditMembers = resp.can_edit;
|
||||
|
||||
$('.info-icon').popover({
|
||||
'trigger': 'hover',
|
||||
'html': true
|
||||
});
|
||||
|
||||
return resp.members;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// Load the organization.
|
||||
|
@ -1219,18 +1285,17 @@ function TeamViewCtrl($rootScope, $scope, Restangular, ApiService, $routeParams)
|
|||
|
||||
function OrgsCtrl($scope, UserService) {
|
||||
UserService.updateUserIn($scope);
|
||||
|
||||
browserchrome.update();
|
||||
}
|
||||
|
||||
function NewOrgCtrl($scope, $routeParams, $timeout, $location, UserService, PlanService, Restangular) {
|
||||
function NewOrgCtrl($scope, $routeParams, $timeout, $location, UserService, PlanService, ApiService) {
|
||||
UserService.updateUserIn($scope);
|
||||
|
||||
var requested = $routeParams['plan'];
|
||||
|
||||
// Load the list of plans.
|
||||
PlanService.getPlans(function(plans) {
|
||||
$scope.plans = plans.business;
|
||||
$scope.plans = plans;
|
||||
$scope.currentPlan = null;
|
||||
if (requested) {
|
||||
PlanService.getPlan(requested, function(plan) {
|
||||
|
@ -1263,8 +1328,7 @@ function NewOrgCtrl($scope, $routeParams, $timeout, $location, UserService, Plan
|
|||
'email': org.email
|
||||
};
|
||||
|
||||
var createPost = Restangular.one('organization/');
|
||||
createPost.customPOST(data).then(function(created) {
|
||||
ApiService.createOrganization(data).then(function(created) {
|
||||
$scope.created = created;
|
||||
|
||||
// Reset the organizations list.
|
||||
|
@ -1311,14 +1375,19 @@ function OrgMemberLogsCtrl($scope, $routeParams, $rootScope, $timeout, Restangul
|
|||
$scope.ready = false;
|
||||
|
||||
var loadOrganization = function() {
|
||||
$scope.orgResource = ApiService.at('organization', orgname).get(function(org) {
|
||||
$scope.orgResource = ApiService.getOrganizationAsResource({'orgname': orgname}).get(function(org) {
|
||||
$scope.organization = org;
|
||||
return org;
|
||||
});
|
||||
};
|
||||
|
||||
var loadMemberInfo = function() {
|
||||
$scope.memberResource = ApiService.at('organization', $scope.orgname, 'members', membername).get(function(resp) {
|
||||
var params = {
|
||||
'orgname': orgname,
|
||||
'membername': membername
|
||||
};
|
||||
|
||||
$scope.memberResource = ApiService.getOrganizationMemberAsResource(params).get(function(resp) {
|
||||
$scope.memberInfo = resp.member;
|
||||
|
||||
$rootScope.title = 'Logs for ' + $scope.memberInfo.username + ' (' + $scope.orgname + ')';
|
||||
|
|
Reference in a new issue