- Make the discovery information be preloaded via a bootstrap.js file before angular runs
- Have ApiService generate all the api methods specified by the API discovery information - Change all call sites (except for a select few when it does not make sense) to use ApiService
This commit is contained in:
parent
1904e6d0c8
commit
56bb46ffb2
6 changed files with 423 additions and 212 deletions
|
@ -69,6 +69,17 @@ def internal_api_call(f):
|
||||||
return decorated_view
|
return decorated_view
|
||||||
|
|
||||||
|
|
||||||
|
def org_api_call(user_call_name):
|
||||||
|
def internal_decorator(f):
|
||||||
|
@wraps(f)
|
||||||
|
def decorated_view(*args, **kwargs):
|
||||||
|
return f(*args, **kwargs)
|
||||||
|
|
||||||
|
decorated_view.__user_call = user_call_name
|
||||||
|
return decorated_view
|
||||||
|
|
||||||
|
return internal_decorator
|
||||||
|
|
||||||
@app.errorhandler(model.DataModelException)
|
@app.errorhandler(model.DataModelException)
|
||||||
def handle_dme(ex):
|
def handle_dme(ex):
|
||||||
return make_response(ex.message, 400)
|
return make_response(ex.message, 400)
|
||||||
|
@ -79,6 +90,32 @@ def handle_dme_key_error(ex):
|
||||||
return make_response(ex.message, 400)
|
return make_response(ex.message, 400)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/discovery')
|
||||||
|
def discovery():
|
||||||
|
routes = []
|
||||||
|
for rule in app.url_map.iter_rules():
|
||||||
|
if rule.rule.startswith('/api/'):
|
||||||
|
endpoint_method = globals()[rule.endpoint]
|
||||||
|
is_internal = '__internal_call' in dir(endpoint_method)
|
||||||
|
is_org_api = '__user_call' in dir(endpoint_method)
|
||||||
|
methods = list(rule.methods.difference(['HEAD', 'OPTIONS']))
|
||||||
|
|
||||||
|
route = {
|
||||||
|
'name': rule.endpoint,
|
||||||
|
'methods': methods,
|
||||||
|
'path': rule.rule,
|
||||||
|
'parameters': list(rule.arguments)
|
||||||
|
}
|
||||||
|
|
||||||
|
if is_org_api:
|
||||||
|
route['user_method'] = endpoint_method.__user_call
|
||||||
|
|
||||||
|
routes.append(route)
|
||||||
|
|
||||||
|
return jsonify({
|
||||||
|
'endpoints': routes
|
||||||
|
})
|
||||||
|
|
||||||
@app.route('/api/')
|
@app.route('/api/')
|
||||||
@internal_api_call
|
@internal_api_call
|
||||||
def welcome():
|
def welcome():
|
||||||
|
@ -438,6 +475,7 @@ def get_organization(orgname):
|
||||||
|
|
||||||
@app.route('/api/organization/<orgname>', methods=['PUT'])
|
@app.route('/api/organization/<orgname>', methods=['PUT'])
|
||||||
@api_login_required
|
@api_login_required
|
||||||
|
@org_api_call('change_user_details')
|
||||||
def change_organization_details(orgname):
|
def change_organization_details(orgname):
|
||||||
permission = AdministerOrganizationPermission(orgname)
|
permission = AdministerOrganizationPermission(orgname)
|
||||||
if permission.can():
|
if permission.can():
|
||||||
|
@ -1466,6 +1504,7 @@ def get_user_card():
|
||||||
@app.route('/api/organization/<orgname>/card', methods=['GET'])
|
@app.route('/api/organization/<orgname>/card', methods=['GET'])
|
||||||
@api_login_required
|
@api_login_required
|
||||||
@internal_api_call
|
@internal_api_call
|
||||||
|
@org_api_call('get_user_card')
|
||||||
def get_org_card(orgname):
|
def get_org_card(orgname):
|
||||||
permission = AdministerOrganizationPermission(orgname)
|
permission = AdministerOrganizationPermission(orgname)
|
||||||
if permission.can():
|
if permission.can():
|
||||||
|
@ -1488,6 +1527,7 @@ def set_user_card():
|
||||||
|
|
||||||
@app.route('/api/organization/<orgname>/card', methods=['POST'])
|
@app.route('/api/organization/<orgname>/card', methods=['POST'])
|
||||||
@api_login_required
|
@api_login_required
|
||||||
|
@org_api_call('set_user_card')
|
||||||
def set_org_card(orgname):
|
def set_org_card(orgname):
|
||||||
permission = AdministerOrganizationPermission(orgname)
|
permission = AdministerOrganizationPermission(orgname)
|
||||||
if permission.can():
|
if permission.can():
|
||||||
|
@ -1642,6 +1682,7 @@ def list_user_invoices():
|
||||||
|
|
||||||
@app.route('/api/organization/<orgname>/invoices', methods=['GET'])
|
@app.route('/api/organization/<orgname>/invoices', methods=['GET'])
|
||||||
@api_login_required
|
@api_login_required
|
||||||
|
@org_api_call('list_user_invoices')
|
||||||
def list_org_invoices(orgname):
|
def list_org_invoices(orgname):
|
||||||
permission = AdministerOrganizationPermission(orgname)
|
permission = AdministerOrganizationPermission(orgname)
|
||||||
if permission.can():
|
if permission.can():
|
||||||
|
@ -1679,6 +1720,7 @@ def get_invoices(customer_id):
|
||||||
@app.route('/api/organization/<orgname>/plan', methods=['PUT'])
|
@app.route('/api/organization/<orgname>/plan', methods=['PUT'])
|
||||||
@api_login_required
|
@api_login_required
|
||||||
@internal_api_call
|
@internal_api_call
|
||||||
|
@org_api_call('update_user_subscription')
|
||||||
def update_org_subscription(orgname):
|
def update_org_subscription(orgname):
|
||||||
permission = AdministerOrganizationPermission(orgname)
|
permission = AdministerOrganizationPermission(orgname)
|
||||||
if permission.can():
|
if permission.can():
|
||||||
|
@ -1694,7 +1736,7 @@ def update_org_subscription(orgname):
|
||||||
@app.route('/api/user/plan', methods=['GET'])
|
@app.route('/api/user/plan', methods=['GET'])
|
||||||
@api_login_required
|
@api_login_required
|
||||||
@internal_api_call
|
@internal_api_call
|
||||||
def get_subscription():
|
def get_user_subscription():
|
||||||
user = current_user.db_user()
|
user = current_user.db_user()
|
||||||
private_repos = model.get_private_repo_count(user.username)
|
private_repos = model.get_private_repo_count(user.username)
|
||||||
|
|
||||||
|
@ -1713,6 +1755,7 @@ def get_subscription():
|
||||||
@app.route('/api/organization/<orgname>/plan', methods=['GET'])
|
@app.route('/api/organization/<orgname>/plan', methods=['GET'])
|
||||||
@api_login_required
|
@api_login_required
|
||||||
@internal_api_call
|
@internal_api_call
|
||||||
|
@org_api_call('get_user_subscription')
|
||||||
def get_org_subscription(orgname):
|
def get_org_subscription(orgname):
|
||||||
permission = AdministerOrganizationPermission(orgname)
|
permission = AdministerOrganizationPermission(orgname)
|
||||||
if permission.can():
|
if permission.can():
|
||||||
|
@ -1751,6 +1794,7 @@ def get_user_robots():
|
||||||
|
|
||||||
@app.route('/api/organization/<orgname>/robots', methods=['GET'])
|
@app.route('/api/organization/<orgname>/robots', methods=['GET'])
|
||||||
@api_login_required
|
@api_login_required
|
||||||
|
@org_api_call('get_user_robots')
|
||||||
def get_org_robots(orgname):
|
def get_org_robots(orgname):
|
||||||
permission = OrganizationMemberPermission(orgname)
|
permission = OrganizationMemberPermission(orgname)
|
||||||
if permission.can():
|
if permission.can():
|
||||||
|
@ -1764,7 +1808,7 @@ def get_org_robots(orgname):
|
||||||
|
|
||||||
@app.route('/api/user/robots/<robot_shortname>', methods=['PUT'])
|
@app.route('/api/user/robots/<robot_shortname>', methods=['PUT'])
|
||||||
@api_login_required
|
@api_login_required
|
||||||
def create_robot(robot_shortname):
|
def create_user_robot(robot_shortname):
|
||||||
parent = current_user.db_user()
|
parent = current_user.db_user()
|
||||||
robot, password = model.create_robot(robot_shortname, parent)
|
robot, password = model.create_robot(robot_shortname, parent)
|
||||||
resp = jsonify(robot_view(robot.username, password))
|
resp = jsonify(robot_view(robot.username, password))
|
||||||
|
@ -1776,6 +1820,7 @@ def create_robot(robot_shortname):
|
||||||
@app.route('/api/organization/<orgname>/robots/<robot_shortname>',
|
@app.route('/api/organization/<orgname>/robots/<robot_shortname>',
|
||||||
methods=['PUT'])
|
methods=['PUT'])
|
||||||
@api_login_required
|
@api_login_required
|
||||||
|
@org_api_call('create_user_robot')
|
||||||
def create_org_robot(orgname, robot_shortname):
|
def create_org_robot(orgname, robot_shortname):
|
||||||
permission = AdministerOrganizationPermission(orgname)
|
permission = AdministerOrganizationPermission(orgname)
|
||||||
if permission.can():
|
if permission.can():
|
||||||
|
@ -1791,7 +1836,7 @@ def create_org_robot(orgname, robot_shortname):
|
||||||
|
|
||||||
@app.route('/api/user/robots/<robot_shortname>', methods=['DELETE'])
|
@app.route('/api/user/robots/<robot_shortname>', methods=['DELETE'])
|
||||||
@api_login_required
|
@api_login_required
|
||||||
def delete_robot(robot_shortname):
|
def delete_user_robot(robot_shortname):
|
||||||
parent = current_user.db_user()
|
parent = current_user.db_user()
|
||||||
model.delete_robot(format_robot_username(parent.username, robot_shortname))
|
model.delete_robot(format_robot_username(parent.username, robot_shortname))
|
||||||
log_action('delete_robot', parent.username, {'robot': robot_shortname})
|
log_action('delete_robot', parent.username, {'robot': robot_shortname})
|
||||||
|
@ -1801,6 +1846,7 @@ def delete_robot(robot_shortname):
|
||||||
@app.route('/api/organization/<orgname>/robots/<robot_shortname>',
|
@app.route('/api/organization/<orgname>/robots/<robot_shortname>',
|
||||||
methods=['DELETE'])
|
methods=['DELETE'])
|
||||||
@api_login_required
|
@api_login_required
|
||||||
|
@org_api_call('delete_user_robot')
|
||||||
def delete_org_robot(orgname, robot_shortname):
|
def delete_org_robot(orgname, robot_shortname):
|
||||||
permission = AdministerOrganizationPermission(orgname)
|
permission = AdministerOrganizationPermission(orgname)
|
||||||
if permission.can():
|
if permission.can():
|
||||||
|
@ -1848,6 +1894,7 @@ def list_repo_logs(namespace, repository):
|
||||||
|
|
||||||
@app.route('/api/organization/<orgname>/logs', methods=['GET'])
|
@app.route('/api/organization/<orgname>/logs', methods=['GET'])
|
||||||
@api_login_required
|
@api_login_required
|
||||||
|
@org_api_call('list_user_logs')
|
||||||
def list_org_logs(orgname):
|
def list_org_logs(orgname):
|
||||||
permission = AdministerOrganizationPermission(orgname)
|
permission = AdministerOrganizationPermission(orgname)
|
||||||
if permission.can():
|
if permission.can():
|
||||||
|
|
320
static/js/app.js
320
static/js/app.js
|
@ -1,6 +1,18 @@
|
||||||
var TEAM_PATTERN = '^[a-zA-Z][a-zA-Z0-9]+$';
|
var TEAM_PATTERN = '^[a-zA-Z][a-zA-Z0-9]+$';
|
||||||
var ROBOT_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) {
|
function getFirstTextLine(commentString) {
|
||||||
if (!commentString) { return ''; }
|
if (!commentString) { return ''; }
|
||||||
|
|
||||||
|
@ -34,11 +46,8 @@ function getFirstTextLine(commentString) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function createRobotAccount(Restangular, is_org, orgname, name, callback) {
|
function createRobotAccount(ApiService, is_org, orgname, name, callback) {
|
||||||
var url = is_org ? getRestUrl('organization', orgname, 'robots', name) :
|
ApiService.createRobot(is_org ? orgname : null, null, {'robot_shortname': name}).then(callback, function(resp) {
|
||||||
getRestUrl('user/robots', name);
|
|
||||||
var createRobot = Restangular.one(url);
|
|
||||||
createRobot.customPUT().then(callback, function(resp) {
|
|
||||||
bootbox.dialog({
|
bootbox.dialog({
|
||||||
"message": resp.data ? resp.data : 'The robot account could not be created',
|
"message": resp.data ? resp.data : 'The robot account could not be created',
|
||||||
"title": "Cannot create robot account",
|
"title": "Cannot create robot account",
|
||||||
|
@ -52,14 +61,18 @@ function createRobotAccount(Restangular, is_org, orgname, name, callback) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createOrganizationTeam(Restangular, orgname, teamname, callback) {
|
function createOrganizationTeam(ApiService, orgname, teamname, callback) {
|
||||||
var createTeam = Restangular.one(getRestUrl('organization', orgname, 'team', teamname));
|
|
||||||
var data = {
|
var data = {
|
||||||
'name': teamname,
|
'name': teamname,
|
||||||
'role': 'member'
|
'role': 'member'
|
||||||
};
|
};
|
||||||
|
|
||||||
createTeam.customPOST(data).then(callback, function() {
|
var params = {
|
||||||
|
'orgname': orgname,
|
||||||
|
'teamname': teamname
|
||||||
|
};
|
||||||
|
|
||||||
|
ApiService.updateOrganizationTeam(data, params).then(callback, function() {
|
||||||
bootbox.dialog({
|
bootbox.dialog({
|
||||||
"message": resp.data ? resp.data : 'The team could not be created',
|
"message": resp.data ? resp.data : 'The team could not be created',
|
||||||
"title": "Cannot create team",
|
"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) {
|
function getMarkedDown(string) {
|
||||||
return Markdown.getSanitizingConverter().makeHtml(string || '');
|
return Markdown.getSanitizingConverter().makeHtml(string || '');
|
||||||
}
|
}
|
||||||
|
@ -92,6 +94,137 @@ function getMarkedDown(string) {
|
||||||
quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'restangular', 'angularMoment', 'angulartics', /*'angulartics.google.analytics',*/ 'angulartics.mixpanel', '$strap.directives', 'ngCookies'], function($provide, cfpLoadingBarProvider) {
|
quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'restangular', 'angularMoment', 'angulartics', /*'angulartics.google.analytics',*/ 'angulartics.mixpanel', '$strap.directives', 'ngCookies'], function($provide, cfpLoadingBarProvider) {
|
||||||
cfpLoadingBarProvider.includeSpinner = false;
|
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) {
|
$provide.factory('CookieService', ['$cookies', '$cookieStore', function($cookies, $cookieStore) {
|
||||||
var cookieService = {};
|
var cookieService = {};
|
||||||
cookieService.putPermanent = function(name, value) {
|
cookieService.putPermanent = function(name, value) {
|
||||||
|
@ -113,7 +246,7 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'rest
|
||||||
return cookieService;
|
return cookieService;
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
$provide.factory('UserService', ['Restangular', 'CookieService', function(Restangular, CookieService) {
|
$provide.factory('UserService', ['ApiService', 'CookieService', function(ApiService, CookieService) {
|
||||||
var userResponse = {
|
var userResponse = {
|
||||||
verified: false,
|
verified: false,
|
||||||
anonymous: true,
|
anonymous: true,
|
||||||
|
@ -139,8 +272,7 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'rest
|
||||||
};
|
};
|
||||||
|
|
||||||
userService.load = function(opt_callback) {
|
userService.load = function(opt_callback) {
|
||||||
var userFetch = Restangular.one('user/');
|
ApiService.getLoggedInUser().then(function(loadedUser) {
|
||||||
userFetch.get().then(function(loadedUser) {
|
|
||||||
userResponse = loadedUser;
|
userResponse = loadedUser;
|
||||||
|
|
||||||
if (!userResponse.anonymous) {
|
if (!userResponse.anonymous) {
|
||||||
|
@ -198,48 +330,6 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'rest
|
||||||
return userService;
|
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) {
|
$provide.factory('KeyService', ['$location', function($location) {
|
||||||
var keyService = {}
|
var keyService = {}
|
||||||
|
|
||||||
|
@ -254,8 +344,8 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'rest
|
||||||
return keyService;
|
return keyService;
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
$provide.factory('PlanService', ['Restangular', 'KeyService', 'UserService', 'CookieService',
|
$provide.factory('PlanService', ['KeyService', 'UserService', 'CookieService', 'ApiService',
|
||||||
function(Restangular, KeyService, UserService, CookieService) {
|
function(KeyService, UserService, CookieService, ApiService) {
|
||||||
var plans = null;
|
var plans = null;
|
||||||
var planDict = {};
|
var planDict = {};
|
||||||
var planService = {};
|
var planService = {};
|
||||||
|
@ -353,8 +443,7 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'rest
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var getPlans = Restangular.one('plans');
|
ApiService.listPlans().then(function(data) {
|
||||||
getPlans.get().then(function(data) {
|
|
||||||
var i = 0;
|
var i = 0;
|
||||||
for(i = 0; i < data.plans.length; i++) {
|
for(i = 0; i < data.plans.length; i++) {
|
||||||
planDict[data.plans[i].stripeId] = data.plans[i];
|
planDict[data.plans[i].stripeId] = data.plans[i];
|
||||||
|
@ -412,13 +501,7 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'rest
|
||||||
};
|
};
|
||||||
|
|
||||||
planService.getSubscription = function(orgname, success, failure) {
|
planService.getSubscription = function(orgname, success, failure) {
|
||||||
var url = planService.getSubscriptionUrl(orgname);
|
ApiService.getSubscription(orgname).then(success, failure);
|
||||||
var getSubscription = Restangular.one(url);
|
|
||||||
getSubscription.get().then(success, failure);
|
|
||||||
};
|
|
||||||
|
|
||||||
planService.getSubscriptionUrl = function(orgname) {
|
|
||||||
return orgname ? getRestUrl('organization', orgname, 'plan') : 'user/plan';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
planService.setSubscription = function(orgname, planId, success, failure, opt_token) {
|
planService.setSubscription = function(orgname, planId, success, failure, opt_token) {
|
||||||
|
@ -430,9 +513,7 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'rest
|
||||||
subscriptionDetails['token'] = opt_token.id;
|
subscriptionDetails['token'] = opt_token.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
var url = planService.getSubscriptionUrl(orgname);
|
ApiService.updateSubscription(orgname, subscriptionDetails).then(function(resp) {
|
||||||
var createSubscriptionRequest = Restangular.one(url);
|
|
||||||
createSubscriptionRequest.customPUT(subscriptionDetails).then(function(resp) {
|
|
||||||
success(resp);
|
success(resp);
|
||||||
planService.getPlan(planId, function(plan) {
|
planService.getPlan(planId, function(plan) {
|
||||||
for (var i = 0; i < listeners.length; ++i) {
|
for (var i = 0; i < listeners.length; ++i) {
|
||||||
|
@ -443,9 +524,7 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'rest
|
||||||
};
|
};
|
||||||
|
|
||||||
planService.getCardInfo = function(orgname, callback) {
|
planService.getCardInfo = function(orgname, callback) {
|
||||||
var url = orgname ? getRestUrl('organization', orgname, 'card') : 'user/card';
|
ApiService.getCard(orgname).then(function(resp) {
|
||||||
var getCard = Restangular.one(url);
|
|
||||||
getCard.customGET().then(function(resp) {
|
|
||||||
callback(resp.card);
|
callback(resp.card);
|
||||||
}, function() {
|
}, function() {
|
||||||
callback({'is_valid': false});
|
callback({'is_valid': false});
|
||||||
|
@ -492,9 +571,7 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'rest
|
||||||
'token': token.id
|
'token': token.id
|
||||||
};
|
};
|
||||||
|
|
||||||
var url = orgname ? getRestUrl('organization', orgname, 'card') : 'user/card';
|
ApiService.setCard(orgname, cardInfo).then(callbacks['success'], function(resp) {
|
||||||
var changeCardRequest = Restangular.one(url);
|
|
||||||
changeCardRequest.customPOST(cardInfo).then(callbacks['success'], function(resp) {
|
|
||||||
planService.handleCardError(resp);
|
planService.handleCardError(resp);
|
||||||
callbacks['failure'](resp);
|
callbacks['failure'](resp);
|
||||||
});
|
});
|
||||||
|
@ -739,10 +816,9 @@ quayApp.directive('userSetup', function () {
|
||||||
'signInStarted': '&signInStarted',
|
'signInStarted': '&signInStarted',
|
||||||
'signedIn': '&signedIn'
|
'signedIn': '&signedIn'
|
||||||
},
|
},
|
||||||
controller: function($scope, $location, $timeout, Restangular, KeyService, UserService) {
|
controller: function($scope, $location, $timeout, ApiService, KeyService, UserService) {
|
||||||
$scope.sendRecovery = function() {
|
$scope.sendRecovery = function() {
|
||||||
var signinPost = Restangular.one('recovery');
|
ApiService.requestRecoveryEmail($scope.recovery).then(function() {
|
||||||
signinPost.customPOST($scope.recovery).then(function() {
|
|
||||||
$scope.invalidEmail = false;
|
$scope.invalidEmail = false;
|
||||||
$scope.sent = true;
|
$scope.sent = true;
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
|
@ -772,7 +848,7 @@ quayApp.directive('signinForm', function () {
|
||||||
'signInStarted': '&signInStarted',
|
'signInStarted': '&signInStarted',
|
||||||
'signedIn': '&signedIn'
|
'signedIn': '&signedIn'
|
||||||
},
|
},
|
||||||
controller: function($scope, $location, $timeout, Restangular, KeyService, UserService) {
|
controller: function($scope, $location, $timeout, ApiService, KeyService, UserService) {
|
||||||
$scope.showGithub = function() {
|
$scope.showGithub = function() {
|
||||||
$scope.markStarted();
|
$scope.markStarted();
|
||||||
|
|
||||||
|
@ -799,8 +875,7 @@ quayApp.directive('signinForm', function () {
|
||||||
$scope.signin = function() {
|
$scope.signin = function() {
|
||||||
$scope.markStarted();
|
$scope.markStarted();
|
||||||
|
|
||||||
var signinPost = Restangular.one('signin');
|
ApiService.signinUser($scope.user).then(function() {
|
||||||
signinPost.customPOST($scope.user).then(function() {
|
|
||||||
$scope.needsEmailVerification = false;
|
$scope.needsEmailVerification = false;
|
||||||
$scope.invalidCredentials = false;
|
$scope.invalidCredentials = false;
|
||||||
|
|
||||||
|
@ -840,7 +915,7 @@ quayApp.directive('signupForm', function () {
|
||||||
scope: {
|
scope: {
|
||||||
|
|
||||||
},
|
},
|
||||||
controller: function($scope, $location, $timeout, Restangular, KeyService, UserService) {
|
controller: function($scope, $location, $timeout, ApiService, KeyService, UserService) {
|
||||||
$('.form-signup').popover();
|
$('.form-signup').popover();
|
||||||
|
|
||||||
angulartics.waitForVendorApi(mixpanel, 500, function(loadedMixpanel) {
|
angulartics.waitForVendorApi(mixpanel, 500, function(loadedMixpanel) {
|
||||||
|
@ -857,8 +932,7 @@ quayApp.directive('signupForm', function () {
|
||||||
$('.form-signup').popover('hide');
|
$('.form-signup').popover('hide');
|
||||||
$scope.registering = true;
|
$scope.registering = true;
|
||||||
|
|
||||||
var newUserPost = Restangular.one('user/');
|
ApiService.createNewUser($scope.newUser).then(function() {
|
||||||
newUserPost.customPOST($scope.newUser).then(function() {
|
|
||||||
$scope.awaitingConfirmation = true;
|
$scope.awaitingConfirmation = true;
|
||||||
$scope.registering = false;
|
$scope.registering = false;
|
||||||
|
|
||||||
|
@ -911,7 +985,7 @@ quayApp.directive('dockerAuthDialog', function () {
|
||||||
'shown': '=shown',
|
'shown': '=shown',
|
||||||
'counter': '=counter'
|
'counter': '=counter'
|
||||||
},
|
},
|
||||||
controller: function($scope, $element, Restangular) {
|
controller: function($scope, $element) {
|
||||||
$scope.isDownloadSupported = function() {
|
$scope.isDownloadSupported = function() {
|
||||||
try { return !!new Blob(); } catch(e){}
|
try { return !!new Blob(); } catch(e){}
|
||||||
return false;
|
return false;
|
||||||
|
@ -981,7 +1055,7 @@ quayApp.directive('billingInvoices', function () {
|
||||||
'user': '=user',
|
'user': '=user',
|
||||||
'visible': '=visible'
|
'visible': '=visible'
|
||||||
},
|
},
|
||||||
controller: function($scope, $element, $sce, Restangular) {
|
controller: function($scope, $element, $sce, ApiService) {
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
$scope.invoiceExpanded = {};
|
$scope.invoiceExpanded = {};
|
||||||
|
|
||||||
|
@ -1000,13 +1074,7 @@ quayApp.directive('billingInvoices', function () {
|
||||||
|
|
||||||
$scope.loading = true;
|
$scope.loading = true;
|
||||||
|
|
||||||
var url = getRestUrl('user/invoices');
|
ApiService.listInvoices($scope.organization).then(function(resp) {
|
||||||
if ($scope.organization) {
|
|
||||||
url = getRestUrl('organization', $scope.organization.name, 'invoices');
|
|
||||||
}
|
|
||||||
|
|
||||||
var getInvoices = Restangular.one(url);
|
|
||||||
getInvoices.get().then(function(resp) {
|
|
||||||
$scope.invoices = resp.invoices;
|
$scope.invoices = resp.invoices;
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
});
|
});
|
||||||
|
@ -1036,7 +1104,7 @@ quayApp.directive('logsView', function () {
|
||||||
'repository': '=repository',
|
'repository': '=repository',
|
||||||
'performer': '=performer'
|
'performer': '=performer'
|
||||||
},
|
},
|
||||||
controller: function($scope, $element, $sce, Restangular) {
|
controller: function($scope, $element, $sce, Restangular, ApiService) {
|
||||||
$scope.loading = true;
|
$scope.loading = true;
|
||||||
$scope.logs = null;
|
$scope.logs = null;
|
||||||
$scope.kindsAllowed = null;
|
$scope.kindsAllowed = null;
|
||||||
|
@ -1152,6 +1220,8 @@ quayApp.directive('logsView', function () {
|
||||||
|
|
||||||
$scope.loading = true;
|
$scope.loading = true;
|
||||||
|
|
||||||
|
// Note: We construct the URLs here manually because we also use it for the download
|
||||||
|
// path.
|
||||||
var url = getRestUrl('user/logs');
|
var url = getRestUrl('user/logs');
|
||||||
if ($scope.organization) {
|
if ($scope.organization) {
|
||||||
url = getRestUrl('organization', $scope.organization.name, 'logs');
|
url = getRestUrl('organization', $scope.organization.name, 'logs');
|
||||||
|
@ -1255,7 +1325,7 @@ quayApp.directive('robotsManager', function () {
|
||||||
'organization': '=organization',
|
'organization': '=organization',
|
||||||
'user': '=user'
|
'user': '=user'
|
||||||
},
|
},
|
||||||
controller: function($scope, $element, Restangular) {
|
controller: function($scope, $element, ApiService) {
|
||||||
$scope.ROBOT_PATTERN = ROBOT_PATTERN;
|
$scope.ROBOT_PATTERN = ROBOT_PATTERN;
|
||||||
$scope.robots = null;
|
$scope.robots = null;
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
|
@ -1280,7 +1350,7 @@ quayApp.directive('robotsManager', function () {
|
||||||
$scope.createRobot = function(name) {
|
$scope.createRobot = function(name) {
|
||||||
if (!name) { return; }
|
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) {
|
function(created) {
|
||||||
$scope.robots.push(created);
|
$scope.robots.push(created);
|
||||||
});
|
});
|
||||||
|
@ -1288,11 +1358,7 @@ quayApp.directive('robotsManager', function () {
|
||||||
|
|
||||||
$scope.deleteRobot = function(info) {
|
$scope.deleteRobot = function(info) {
|
||||||
var shortName = $scope.getShortenedName(info.name);
|
var shortName = $scope.getShortenedName(info.name);
|
||||||
var url = $scope.organization ? getRestUrl('organization', $scope.organization.name, 'robots', shortName) :
|
ApiService.deleteRobot($scope.organization, null, {'robot_shortname': shortName}).then(function(resp) {
|
||||||
getRestUrl('user/robots', shortName);
|
|
||||||
|
|
||||||
var deleteRobot = Restangular.one(url);
|
|
||||||
deleteRobot.customDELETE().then(function(resp) {
|
|
||||||
for (var i = 0; i < $scope.robots.length; ++i) {
|
for (var i = 0; i < $scope.robots.length; ++i) {
|
||||||
if ($scope.robots[i].name == info.name) {
|
if ($scope.robots[i].name == info.name) {
|
||||||
$scope.robots.splice(i, 1);
|
$scope.robots.splice(i, 1);
|
||||||
|
@ -1318,9 +1384,7 @@ quayApp.directive('robotsManager', function () {
|
||||||
if ($scope.loading) { return; }
|
if ($scope.loading) { return; }
|
||||||
|
|
||||||
$scope.loading = true;
|
$scope.loading = true;
|
||||||
var url = $scope.organization ? getRestUrl('organization', $scope.organization.name, 'robots') : 'user/robots';
|
ApiService.getRobots($scope.organization).then(function(resp) {
|
||||||
var getRobots = Restangular.one(url);
|
|
||||||
getRobots.customGET($scope.obj).then(function(resp) {
|
|
||||||
$scope.robots = resp.robots;
|
$scope.robots = resp.robots;
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
});
|
});
|
||||||
|
@ -1553,7 +1617,7 @@ quayApp.directive('headerBar', function () {
|
||||||
restrict: 'C',
|
restrict: 'C',
|
||||||
scope: {
|
scope: {
|
||||||
},
|
},
|
||||||
controller: function($scope, $element, $location, UserService, PlanService, Restangular) {
|
controller: function($scope, $element, $location, UserService, PlanService, ApiService) {
|
||||||
$scope.overPlan = false;
|
$scope.overPlan = false;
|
||||||
|
|
||||||
var checkOverPlan = function() {
|
var checkOverPlan = function() {
|
||||||
|
@ -1562,8 +1626,7 @@ quayApp.directive('headerBar', function () {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var checkPrivate = Restangular.one('user/private');
|
ApiService.getUserPrivateCount().then(function(resp) {
|
||||||
checkPrivate.customGET().then(function(resp) {
|
|
||||||
$scope.overPlan = resp.privateCount > resp.reposAllowed;
|
$scope.overPlan = resp.privateCount > resp.reposAllowed;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -1575,8 +1638,7 @@ quayApp.directive('headerBar', function () {
|
||||||
PlanService.registerListener(this, checkOverPlan);
|
PlanService.registerListener(this, checkOverPlan);
|
||||||
|
|
||||||
$scope.signout = function() {
|
$scope.signout = function() {
|
||||||
var signoutPost = Restangular.one('signout');
|
ApiService.logout().then(function() {
|
||||||
signoutPost.customPOST().then(function() {
|
|
||||||
UserService.load();
|
UserService.load();
|
||||||
$location.path('/');
|
$location.path('/');
|
||||||
});
|
});
|
||||||
|
@ -1609,7 +1671,7 @@ quayApp.directive('entitySearch', function () {
|
||||||
'includeTeams': '=includeTeams',
|
'includeTeams': '=includeTeams',
|
||||||
'isOrganization': '=isOrganization'
|
'isOrganization': '=isOrganization'
|
||||||
},
|
},
|
||||||
controller: function($scope, $element, Restangular, UserService) {
|
controller: function($scope, $element, Restangular, UserService, ApiService) {
|
||||||
$scope.lazyLoading = true;
|
$scope.lazyLoading = true;
|
||||||
$scope.isAdmin = false;
|
$scope.isAdmin = false;
|
||||||
|
|
||||||
|
@ -1619,16 +1681,12 @@ quayApp.directive('entitySearch', function () {
|
||||||
$scope.isAdmin = UserService.isNamespaceAdmin($scope.namespace);
|
$scope.isAdmin = UserService.isNamespaceAdmin($scope.namespace);
|
||||||
|
|
||||||
if ($scope.isOrganization && $scope.includeTeams) {
|
if ($scope.isOrganization && $scope.includeTeams) {
|
||||||
var url = getRestUrl('organization', $scope.namespace);
|
ApiService.getOrganization(null, {'orgname': $scope.namespace}).then(function(resp) {
|
||||||
var getOrganization = Restangular.one(url);
|
|
||||||
getOrganization.customGET().then(function(resp) {
|
|
||||||
$scope.teams = resp.teams;
|
$scope.teams = resp.teams;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var url = $scope.isOrganization ? getRestUrl('organization', $scope.namespace, 'robots') : 'user/robots';
|
ApiService.getRobots($scope.isOrganization ? $scope.namespace : null).then(function(resp) {
|
||||||
var getRobots = Restangular.one(url);
|
|
||||||
getRobots.customGET().then(function(resp) {
|
|
||||||
$scope.robots = resp.robots;
|
$scope.robots = resp.robots;
|
||||||
$scope.lazyLoading = false;
|
$scope.lazyLoading = false;
|
||||||
}, function() {
|
}, function() {
|
||||||
|
@ -1648,7 +1706,7 @@ quayApp.directive('entitySearch', function () {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
createOrganizationTeam(Restangular, $scope.namespace, teamname, function(created) {
|
createOrganizationTeam(ApiService, $scope.namespace, teamname, function(created) {
|
||||||
$scope.setEntity(created.name, 'team', false);
|
$scope.setEntity(created.name, 'team', false);
|
||||||
$scope.teams[teamname] = created;
|
$scope.teams[teamname] = created;
|
||||||
});
|
});
|
||||||
|
@ -1667,7 +1725,7 @@ quayApp.directive('entitySearch', function () {
|
||||||
return;
|
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.setEntity(created.name, 'user', true);
|
||||||
$scope.robots.push(created);
|
$scope.robots.push(created);
|
||||||
});
|
});
|
||||||
|
@ -1793,7 +1851,7 @@ quayApp.directive('billingOptions', function () {
|
||||||
'user': '=user',
|
'user': '=user',
|
||||||
'organization': '=organization'
|
'organization': '=organization'
|
||||||
},
|
},
|
||||||
controller: function($scope, $element, PlanService, Restangular) {
|
controller: function($scope, $element, PlanService, ApiService) {
|
||||||
$scope.invoice_email = false;
|
$scope.invoice_email = false;
|
||||||
$scope.currentCard = null;
|
$scope.currentCard = null;
|
||||||
|
|
||||||
|
@ -1863,9 +1921,7 @@ quayApp.directive('billingOptions', function () {
|
||||||
|
|
||||||
var save = function() {
|
var save = function() {
|
||||||
$scope.working = true;
|
$scope.working = true;
|
||||||
var url = $scope.organization ? getRestUrl('organization', $scope.organization.name) : 'user/';
|
ApiService.changeDetails($scope.organization, $scope.obj).then(function(resp) {
|
||||||
var conductSave = Restangular.one(url);
|
|
||||||
conductSave.customPUT($scope.obj).then(function(resp) {
|
|
||||||
$scope.working = false;
|
$scope.working = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -1900,7 +1956,7 @@ quayApp.directive('planManager', function () {
|
||||||
'readyForPlan': '&readyForPlan',
|
'readyForPlan': '&readyForPlan',
|
||||||
'planChanged': '&planChanged'
|
'planChanged': '&planChanged'
|
||||||
},
|
},
|
||||||
controller: function($scope, $element, PlanService, Restangular) {
|
controller: function($scope, $element, PlanService, ApiService) {
|
||||||
var hasSubscription = false;
|
var hasSubscription = false;
|
||||||
|
|
||||||
$scope.isPlanVisible = function(plan, subscribedPlan) {
|
$scope.isPlanVisible = function(plan, subscribedPlan) {
|
||||||
|
|
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);
|
||||||
|
}
|
||||||
|
});
|
|
@ -67,14 +67,15 @@ function RepoListCtrl($scope, Restangular, UserService, ApiService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var options = {'public': false, 'sort': true, 'namespace': namespace};
|
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;
|
return resp.repositories;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var loadPublicRepos = function() {
|
var loadPublicRepos = function() {
|
||||||
var options = {'public': true, 'private': false, 'sort': true, 'limit': 10};
|
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;
|
return resp.repositories;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -118,7 +119,7 @@ function LandingCtrl($scope, UserService, ApiService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var options = {'limit': 4, 'public': false, 'sort': true, 'namespace': namespace };
|
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;
|
return resp.repositories;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -169,7 +170,8 @@ function RepoCtrl($scope, Restangular, ApiService, $routeParams, $rootScope, $lo
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.loadImageChanges = function(image) {
|
$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;
|
$scope.currentImageChanges = ci;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -240,8 +242,9 @@ function RepoCtrl($scope, Restangular, ApiService, $routeParams, $rootScope, $lo
|
||||||
};
|
};
|
||||||
|
|
||||||
var fetchRepository = function() {
|
var fetchRepository = function() {
|
||||||
|
var params = {'repository': namespace + '/' + name};
|
||||||
$rootScope.title = 'Loading Repository...';
|
$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.
|
// Set the repository object.
|
||||||
$scope.repo = repo;
|
$scope.repo = repo;
|
||||||
|
|
||||||
|
@ -283,6 +286,7 @@ function RepoCtrl($scope, Restangular, ApiService, $routeParams, $rootScope, $lo
|
||||||
};
|
};
|
||||||
|
|
||||||
var getBuildInfo = function(repo) {
|
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/');
|
var buildInfo = Restangular.one('repository/' + repo.namespace + '/' + repo.name + '/build/');
|
||||||
buildInfo.withHttpConfig({
|
buildInfo.withHttpConfig({
|
||||||
'ignoreLoadingBar': true
|
'ignoreLoadingBar': true
|
||||||
|
@ -312,7 +316,8 @@ function RepoCtrl($scope, Restangular, ApiService, $routeParams, $rootScope, $lo
|
||||||
};
|
};
|
||||||
|
|
||||||
var listImages = function() {
|
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.
|
// Dispose of any existing tree.
|
||||||
if ($scope.tree) {
|
if ($scope.tree) {
|
||||||
$scope.tree.dispose();
|
$scope.tree.dispose();
|
||||||
|
@ -443,8 +448,8 @@ function RepoAdminCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
|
||||||
'friendlyName': $scope.newToken.friendlyName
|
'friendlyName': $scope.newToken.friendlyName
|
||||||
};
|
};
|
||||||
|
|
||||||
var permissionPost = Restangular.one('repository/' + namespace + '/' + name + '/tokens/');
|
var params = {'repository': namespace + '/' + name};
|
||||||
permissionPost.customPOST(friendlyName).then(function(newToken) {
|
ApiService.createToken(friendlyName, params).then(function(newToken) {
|
||||||
$scope.newToken.friendlyName = '';
|
$scope.newToken.friendlyName = '';
|
||||||
$scope.createTokenForm.$setPristine();
|
$scope.createTokenForm.$setPristine();
|
||||||
$scope.tokens[newToken.code] = newToken;
|
$scope.tokens[newToken.code] = newToken;
|
||||||
|
@ -452,8 +457,12 @@ function RepoAdminCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.deleteToken = function(tokenCode) {
|
$scope.deleteToken = function(tokenCode) {
|
||||||
var deleteAction = Restangular.one('repository/' + namespace + '/' + name + '/tokens/' + tokenCode);
|
var params = {
|
||||||
deleteAction.customDELETE().then(function() {
|
'repository': namespace + '/' + name,
|
||||||
|
'code': tokenCode
|
||||||
|
};
|
||||||
|
|
||||||
|
ApiService.deleteToken(null, params).then(function() {
|
||||||
delete $scope.tokens[tokenCode];
|
delete $scope.tokens[tokenCode];
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -463,8 +472,12 @@ function RepoAdminCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
|
||||||
'role': newAccess
|
'role': newAccess
|
||||||
};
|
};
|
||||||
|
|
||||||
var deleteAction = Restangular.one('repository/' + namespace + '/' + name + '/tokens/' + tokenCode);
|
var params = {
|
||||||
deleteAction.customPUT(role).then(function(updated) {
|
'repository': namespace + '/' + name,
|
||||||
|
'code': tokenCode
|
||||||
|
};
|
||||||
|
|
||||||
|
ApiService.changeToken(role, params).then(function(updated) {
|
||||||
$scope.tokens[updated.code] = updated;
|
$scope.tokens[updated.code] = updated;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -486,8 +499,12 @@ function RepoAdminCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
|
||||||
var visibility = {
|
var visibility = {
|
||||||
'visibility': newAccess
|
'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';
|
$scope.repo.is_public = newAccess == 'public';
|
||||||
}, function() {
|
}, function() {
|
||||||
$('#cannotchangeModal').modal({});
|
$('#cannotchangeModal').modal({});
|
||||||
|
@ -501,8 +518,11 @@ function RepoAdminCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
|
||||||
$scope.deleteRepo = function() {
|
$scope.deleteRepo = function() {
|
||||||
$('#confirmdeleteModal').modal('hide');
|
$('#confirmdeleteModal').modal('hide');
|
||||||
|
|
||||||
var deleteAction = Restangular.one('repository/' + namespace + '/' + name);
|
var params = {
|
||||||
deleteAction.customDELETE().then(function() {
|
'repository': namespace + '/' + name
|
||||||
|
};
|
||||||
|
|
||||||
|
ApiService.deleteRepository(null, params).then(function() {
|
||||||
$scope.repo = null;
|
$scope.repo = null;
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
@ -514,8 +534,12 @@ function RepoAdminCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.loadWebhooks = function() {
|
$scope.loadWebhooks = function() {
|
||||||
|
var params = {
|
||||||
|
'repository': namespace + '/' + name
|
||||||
|
};
|
||||||
|
|
||||||
$scope.newWebhook = {};
|
$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;
|
$scope.webhooks = resp.webhooks;
|
||||||
return $scope.webhooks;
|
return $scope.webhooks;
|
||||||
});
|
});
|
||||||
|
@ -526,8 +550,11 @@ function RepoAdminCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var newWebhook = Restangular.one('repository/' + namespace + '/' + name + '/webhook/');
|
var params = {
|
||||||
newWebhook.customPOST($scope.newWebhook).then(function(resp) {
|
'repository': namespace + '/' + name
|
||||||
|
};
|
||||||
|
|
||||||
|
ApiService.createWebhook($scope.newWebhook, params).then(function(resp) {
|
||||||
$scope.webhooks.push(resp);
|
$scope.webhooks.push(resp);
|
||||||
$scope.newWebhook.url = '';
|
$scope.newWebhook.url = '';
|
||||||
$scope.createWebhookForm.$setPristine();
|
$scope.createWebhookForm.$setPristine();
|
||||||
|
@ -535,15 +562,22 @@ function RepoAdminCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.deleteWebhook = function(webhook) {
|
$scope.deleteWebhook = function(webhook) {
|
||||||
var deleteWebhookReq = Restangular.one('repository/' + namespace + '/' + name + '/webhook/' + webhook.public_id);
|
var params = {
|
||||||
deleteWebhookReq.customDELETE().then(function(resp) {
|
'repository': namespace + '/' + name,
|
||||||
|
'public_id': webhook.public_id
|
||||||
|
};
|
||||||
|
|
||||||
|
ApiService.deleteWebhook(null, params).then(function(resp) {
|
||||||
$scope.webhooks.splice($scope.webhooks.indexOf(webhook), 1);
|
$scope.webhooks.splice($scope.webhooks.indexOf(webhook), 1);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var fetchTokens = function() {
|
var fetchTokens = function() {
|
||||||
var tokensFetch = Restangular.one('repository/' + namespace + '/' + name + '/tokens/');
|
var params = {
|
||||||
tokensFetch.get().then(function(resp) {
|
'repository': namespace + '/' + name
|
||||||
|
};
|
||||||
|
|
||||||
|
ApiService.listRepoTokens(null, params).then(function(resp) {
|
||||||
$scope.tokens = resp.tokens;
|
$scope.tokens = resp.tokens;
|
||||||
}, function() {
|
}, function() {
|
||||||
$scope.tokens = null;
|
$scope.tokens = null;
|
||||||
|
@ -560,7 +594,11 @@ function RepoAdminCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
|
||||||
};
|
};
|
||||||
|
|
||||||
var fetchRepository = function() {
|
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;
|
$scope.repo = repo;
|
||||||
|
|
||||||
$rootScope.title = 'Settings - ' + namespace + '/' + name;
|
$rootScope.title = 'Settings - ' + namespace + '/' + name;
|
||||||
|
@ -580,7 +618,7 @@ function RepoAdminCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
|
||||||
fetchRepository();
|
fetchRepository();
|
||||||
}
|
}
|
||||||
|
|
||||||
function UserAdminCtrl($scope, $timeout, $location, Restangular, PlanService, UserService, KeyService, $routeParams) {
|
function UserAdminCtrl($scope, $timeout, $location, ApiService, PlanService, UserService, KeyService, $routeParams) {
|
||||||
if ($routeParams['migrate']) {
|
if ($routeParams['migrate']) {
|
||||||
$('#migrateTab').tab('show')
|
$('#migrateTab').tab('show')
|
||||||
}
|
}
|
||||||
|
@ -645,8 +683,7 @@ function UserAdminCtrl($scope, $timeout, $location, Restangular, PlanService, Us
|
||||||
'plan': $scope.org.plan.stripeId
|
'plan': $scope.org.plan.stripeId
|
||||||
};
|
};
|
||||||
|
|
||||||
var convertAccount = Restangular.one('user/convert');
|
ApiService.convertUserToOrganization(data).then(function(resp) {
|
||||||
convertAccount.customPOST(data).then(function(resp) {
|
|
||||||
UserService.load();
|
UserService.load();
|
||||||
$location.path('/');
|
$location.path('/');
|
||||||
}, function(resp) {
|
}, function(resp) {
|
||||||
|
@ -663,8 +700,8 @@ function UserAdminCtrl($scope, $timeout, $location, Restangular, PlanService, Us
|
||||||
$('.form-change-pw').popover('hide');
|
$('.form-change-pw').popover('hide');
|
||||||
$scope.updatingUser = true;
|
$scope.updatingUser = true;
|
||||||
$scope.changePasswordSuccess = false;
|
$scope.changePasswordSuccess = false;
|
||||||
var changePasswordPost = Restangular.one('user/');
|
|
||||||
changePasswordPost.customPUT($scope.user).then(function() {
|
ApiService.changeUserDetails($scope.user).then(function() {
|
||||||
$scope.updatingUser = false;
|
$scope.updatingUser = false;
|
||||||
$scope.changePasswordSuccess = true;
|
$scope.changePasswordSuccess = true;
|
||||||
|
|
||||||
|
@ -686,7 +723,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 namespace = $routeParams.namespace;
|
||||||
var name = $routeParams.name;
|
var name = $routeParams.name;
|
||||||
var imageid = $routeParams.image;
|
var imageid = $routeParams.image;
|
||||||
|
@ -742,7 +779,12 @@ function ImageViewCtrl($scope, $routeParams, $rootScope, $timeout, ApiService, R
|
||||||
};
|
};
|
||||||
|
|
||||||
var fetchImage = function() {
|
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 = {
|
$scope.repo = {
|
||||||
'name': name,
|
'name': name,
|
||||||
'namespace': namespace
|
'namespace': namespace
|
||||||
|
@ -762,8 +804,12 @@ function ImageViewCtrl($scope, $routeParams, $rootScope, $timeout, ApiService, R
|
||||||
};
|
};
|
||||||
|
|
||||||
var fetchChanges = function() {
|
var fetchChanges = function() {
|
||||||
var changesFetch = Restangular.one('repository/' + namespace + '/' + name + '/image/' + imageid + '/changes');
|
var params = {
|
||||||
changesFetch.get().then(function(changes) {
|
'repository': namespace + '/' + name,
|
||||||
|
'image_id': imageid
|
||||||
|
};
|
||||||
|
|
||||||
|
ApiService.getImageChanges(null, params).then(function(changes) {
|
||||||
var combinedChanges = [];
|
var combinedChanges = [];
|
||||||
var addCombinedChanges = function(c, kind) {
|
var addCombinedChanges = function(c, kind) {
|
||||||
for (var i = 0; i < c.length; ++i) {
|
for (var i = 0; i < c.length; ++i) {
|
||||||
|
@ -791,7 +837,7 @@ function V1Ctrl($scope, $location, UserService) {
|
||||||
UserService.updateUserIn($scope);
|
UserService.updateUserIn($scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
function NewRepoCtrl($scope, $location, $http, $timeout, UserService, Restangular, PlanService) {
|
function NewRepoCtrl($scope, $location, $http, $timeout, UserService, ApiService, PlanService) {
|
||||||
UserService.updateUserIn($scope);
|
UserService.updateUserIn($scope);
|
||||||
|
|
||||||
$scope.repo = {
|
$scope.repo = {
|
||||||
|
@ -822,8 +868,7 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, Restangula
|
||||||
if (isUserNamespace) {
|
if (isUserNamespace) {
|
||||||
// Load the user's subscription information in case they want to create a private
|
// Load the user's subscription information in case they want to create a private
|
||||||
// repository.
|
// repository.
|
||||||
var checkPrivateAllowed = Restangular.one('user/private');
|
ApiService.getUserPrivateCount().then(function(resp) {
|
||||||
checkPrivateAllowed.get().then(function(resp) {
|
|
||||||
if (resp.privateCount + 1 > resp.reposAllowed) {
|
if (resp.privateCount + 1 > resp.reposAllowed) {
|
||||||
PlanService.getMinimumPlan(resp.privateCount + 1, false, function(minimum) {
|
PlanService.getMinimumPlan(resp.privateCount + 1, false, function(minimum) {
|
||||||
$scope.planRequired = minimum;
|
$scope.planRequired = minimum;
|
||||||
|
@ -836,8 +881,7 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, Restangula
|
||||||
$scope.checkingPlan = false;
|
$scope.checkingPlan = false;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var checkPrivateAllowed = Restangular.one('organization/' + namespace + '/private');
|
ApiService.getOrganizationPrivateAllowed(null, {'orgname': namespace}).then(function(resp) {
|
||||||
checkPrivateAllowed.get().then(function(resp) {
|
|
||||||
$scope.planRequired = resp.privateAllowed ? null : {};
|
$scope.planRequired = resp.privateAllowed ? null : {};
|
||||||
$scope.checkingPlan = false;
|
$scope.checkingPlan = false;
|
||||||
}, function() {
|
}, function() {
|
||||||
|
@ -868,8 +912,7 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, Restangula
|
||||||
'description': repo.description
|
'description': repo.description
|
||||||
};
|
};
|
||||||
|
|
||||||
var createPost = Restangular.one('repository');
|
ApiService.createRepo(data).then(function(created) {
|
||||||
createPost.customPOST(data).then(function(created) {
|
|
||||||
$scope.creating = false;
|
$scope.creating = false;
|
||||||
$scope.created = created;
|
$scope.created = created;
|
||||||
|
|
||||||
|
@ -912,9 +955,12 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, Restangula
|
||||||
'file_id': fileId
|
'file_id': fileId
|
||||||
};
|
};
|
||||||
|
|
||||||
var startBuildCall = Restangular.one('repository/' + repo.namespace + '/' + repo.name + '/build/');
|
var params = {
|
||||||
startBuildCall.customPOST(data).then(function(resp) {
|
'repository': repo.namespace + '/' + repo.name
|
||||||
$location.path('/repository/' + repo.namespace + '/' + repo.name);
|
};
|
||||||
|
|
||||||
|
ApiService.requestRepoBuild(data, params).then(function(resp) {
|
||||||
|
$location.path('/repository/' + params.repository);
|
||||||
}, function() {
|
}, function() {
|
||||||
$('#couldnotbuildModal').modal();
|
$('#couldnotbuildModal').modal();
|
||||||
});
|
});
|
||||||
|
@ -963,8 +1009,7 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, Restangula
|
||||||
'mimeType': mimeType
|
'mimeType': mimeType
|
||||||
};
|
};
|
||||||
|
|
||||||
var getUploadUrl = Restangular.one('filedrop/');
|
var getUploadUrl = ApiService.getFiledropUrl(data).then(function(resp) {
|
||||||
getUploadUrl.customPOST(data).then(function(resp) {
|
|
||||||
conductUpload(repo, file, resp.url, resp.file_id, mimeType);
|
conductUpload(repo, file, resp.url, resp.file_id, mimeType);
|
||||||
}, function() {
|
}, function() {
|
||||||
$('#couldnotbuildModal').modal();
|
$('#couldnotbuildModal').modal();
|
||||||
|
@ -992,7 +1037,7 @@ 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;
|
var orgname = $routeParams.orgname;
|
||||||
|
|
||||||
$scope.TEAM_PATTERN = TEAM_PATTERN;
|
$scope.TEAM_PATTERN = TEAM_PATTERN;
|
||||||
|
@ -1008,10 +1053,14 @@ function OrgViewCtrl($rootScope, $scope, Restangular, ApiService, $routeParams)
|
||||||
var previousRole = $scope.organization.teams[teamname].role;
|
var previousRole = $scope.organization.teams[teamname].role;
|
||||||
$scope.organization.teams[teamname].role = 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];
|
var data = $scope.organization.teams[teamname];
|
||||||
|
|
||||||
updateTeam.customPUT(data).then(function(resp) {
|
ApiService.updateOrganizationTeam(data, params).then(function(resp) {
|
||||||
}, function(resp) {
|
}, function(resp) {
|
||||||
$scope.organization.teams[teamname].role = previousRole;
|
$scope.organization.teams[teamname].role = previousRole;
|
||||||
$scope.roleError = resp.data || '';
|
$scope.roleError = resp.data || '';
|
||||||
|
@ -1032,7 +1081,7 @@ function OrgViewCtrl($rootScope, $scope, Restangular, ApiService, $routeParams)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
createOrganizationTeam(Restangular, orgname, teamname, function(created) {
|
createOrganizationTeam(ApiService, orgname, teamname, function(created) {
|
||||||
$scope.organization.teams[teamname] = created;
|
$scope.organization.teams[teamname] = created;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -1047,8 +1096,12 @@ function OrgViewCtrl($rootScope, $scope, Restangular, ApiService, $routeParams)
|
||||||
if (!$scope.currentDeleteTeam) { return; }
|
if (!$scope.currentDeleteTeam) { return; }
|
||||||
|
|
||||||
var teamname = $scope.currentDeleteTeam;
|
var teamname = $scope.currentDeleteTeam;
|
||||||
var deleteAction = Restangular.one(getRestUrl('organization', orgname, 'team', teamname));
|
var params = {
|
||||||
deleteAction.customDELETE().then(function() {
|
'orgname': orgname,
|
||||||
|
'teamname': teamname
|
||||||
|
};
|
||||||
|
|
||||||
|
ApiService.deleteOrganizationTeam(null, params).then(function() {
|
||||||
delete $scope.organization.teams[teamname];
|
delete $scope.organization.teams[teamname];
|
||||||
$scope.currentDeleteTeam = null;
|
$scope.currentDeleteTeam = null;
|
||||||
}, function() {
|
}, function() {
|
||||||
|
@ -1058,7 +1111,7 @@ function OrgViewCtrl($rootScope, $scope, Restangular, ApiService, $routeParams)
|
||||||
};
|
};
|
||||||
|
|
||||||
var loadOrganization = function() {
|
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.organization = org;
|
||||||
$rootScope.title = orgname;
|
$rootScope.title = orgname;
|
||||||
$rootScope.description = 'Viewing organization ' + orgname;
|
$rootScope.description = 'Viewing organization ' + orgname;
|
||||||
|
@ -1110,8 +1163,11 @@ function OrgAdminCtrl($rootScope, $scope, Restangular, $routeParams, UserService
|
||||||
if ($scope.membersFound) { return; }
|
if ($scope.membersFound) { return; }
|
||||||
$scope.membersLoading = true;
|
$scope.membersLoading = true;
|
||||||
|
|
||||||
var getMembers = Restangular.one(getRestUrl('organization', orgname, 'members'));
|
var params = {
|
||||||
getMembers.get().then(function(resp) {
|
'orgname': orgname
|
||||||
|
};
|
||||||
|
|
||||||
|
ApiService.getOrganizationMembers(null, params).then(function(resp) {
|
||||||
var membersArray = [];
|
var membersArray = [];
|
||||||
for (var key in resp.members) {
|
for (var key in resp.members) {
|
||||||
if (resp.members.hasOwnProperty(key)) {
|
if (resp.members.hasOwnProperty(key)) {
|
||||||
|
@ -1125,7 +1181,7 @@ function OrgAdminCtrl($rootScope, $scope, Restangular, $routeParams, UserService
|
||||||
};
|
};
|
||||||
|
|
||||||
var loadOrganization = function() {
|
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) {
|
if (org && org.is_admin) {
|
||||||
$scope.organization = org;
|
$scope.organization = org;
|
||||||
$rootScope.title = orgname + ' (Admin)';
|
$rootScope.title = orgname + ' (Admin)';
|
||||||
|
@ -1155,8 +1211,13 @@ function TeamViewCtrl($rootScope, $scope, Restangular, ApiService, $routeParams)
|
||||||
$scope.addNewMember = function(member) {
|
$scope.addNewMember = function(member) {
|
||||||
if ($scope.members[member.name]) { return; }
|
if ($scope.members[member.name]) { return; }
|
||||||
|
|
||||||
var addMember = Restangular.one(getRestUrl('organization', $scope.orgname, 'team', teamname, 'members', member.name));
|
var params = {
|
||||||
addMember.customPOST().then(function(resp) {
|
'orgname': orgname,
|
||||||
|
'teamname': teamname,
|
||||||
|
'membername': member.name
|
||||||
|
};
|
||||||
|
|
||||||
|
ApiService.updateOrganizationTeamMember(null, params).then(function(resp) {
|
||||||
$scope.members[member.name] = resp;
|
$scope.members[member.name] = resp;
|
||||||
}, function() {
|
}, function() {
|
||||||
$('#cannotChangeMembersModal').modal({});
|
$('#cannotChangeMembersModal').modal({});
|
||||||
|
@ -1164,8 +1225,13 @@ function TeamViewCtrl($rootScope, $scope, Restangular, ApiService, $routeParams)
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.removeMember = function(username) {
|
$scope.removeMember = function(username) {
|
||||||
var removeMember = Restangular.one(getRestUrl('organization', $scope.orgname, 'team', teamname, 'members', username));
|
var params = {
|
||||||
removeMember.customDELETE().then(function(resp) {
|
'orgname': orgname,
|
||||||
|
'teamname': teamname,
|
||||||
|
'membername': username
|
||||||
|
};
|
||||||
|
|
||||||
|
ApiService.deleteOrganizationTeamMember(null, params).then(function(resp) {
|
||||||
delete $scope.members[username];
|
delete $scope.members[username];
|
||||||
}, function() {
|
}, function() {
|
||||||
$('#cannotChangeMembersModal').modal({});
|
$('#cannotChangeMembersModal').modal({});
|
||||||
|
@ -1175,16 +1241,20 @@ function TeamViewCtrl($rootScope, $scope, Restangular, ApiService, $routeParams)
|
||||||
$scope.updateForDescription = function(content) {
|
$scope.updateForDescription = function(content) {
|
||||||
$scope.organization.teams[teamname].description = content;
|
$scope.organization.teams[teamname].description = content;
|
||||||
|
|
||||||
var updateTeam = Restangular.one(getRestUrl('organization', $scope.orgname, 'team', teamname));
|
var params = {
|
||||||
var data = $scope.organization.teams[teamname];
|
'orgname': orgname,
|
||||||
updateTeam.customPUT(data).then(function(resp) {
|
'teamname': teamname
|
||||||
|
};
|
||||||
|
|
||||||
|
var teaminfo = $scope.organization.teams[teamname];
|
||||||
|
ApiService.updateOrganizationTeam(teaminfo, params).then(function(resp) {
|
||||||
}, function() {
|
}, function() {
|
||||||
$('#cannotChangeTeamModal').modal({});
|
$('#cannotChangeTeamModal').modal({});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var loadOrganization = function() {
|
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.organization = org;
|
||||||
$scope.team = $scope.organization.teams[teamname];
|
$scope.team = $scope.organization.teams[teamname];
|
||||||
$rootScope.title = teamname + ' (' + $scope.orgname + ')';
|
$rootScope.title = teamname + ' (' + $scope.orgname + ')';
|
||||||
|
@ -1195,7 +1265,12 @@ function TeamViewCtrl($rootScope, $scope, Restangular, ApiService, $routeParams)
|
||||||
};
|
};
|
||||||
|
|
||||||
var loadMembers = function() {
|
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.members = resp.members;
|
||||||
$scope.canEditMembers = resp.can_edit;
|
$scope.canEditMembers = resp.can_edit;
|
||||||
return resp.members;
|
return resp.members;
|
||||||
|
@ -1208,11 +1283,10 @@ function TeamViewCtrl($rootScope, $scope, Restangular, ApiService, $routeParams)
|
||||||
|
|
||||||
function OrgsCtrl($scope, UserService) {
|
function OrgsCtrl($scope, UserService) {
|
||||||
UserService.updateUserIn($scope);
|
UserService.updateUserIn($scope);
|
||||||
|
|
||||||
browserchrome.update();
|
browserchrome.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
function NewOrgCtrl($scope, $routeParams, $timeout, $location, UserService, PlanService, Restangular) {
|
function NewOrgCtrl($scope, $routeParams, $timeout, $location, UserService, PlanService, ApiService) {
|
||||||
UserService.updateUserIn($scope);
|
UserService.updateUserIn($scope);
|
||||||
|
|
||||||
var requested = $routeParams['plan'];
|
var requested = $routeParams['plan'];
|
||||||
|
@ -1252,8 +1326,7 @@ function NewOrgCtrl($scope, $routeParams, $timeout, $location, UserService, Plan
|
||||||
'email': org.email
|
'email': org.email
|
||||||
};
|
};
|
||||||
|
|
||||||
var createPost = Restangular.one('organization/');
|
ApiService.createOrganization(data).then(function(created) {
|
||||||
createPost.customPOST(data).then(function(created) {
|
|
||||||
$scope.created = created;
|
$scope.created = created;
|
||||||
|
|
||||||
// Reset the organizations list.
|
// Reset the organizations list.
|
||||||
|
@ -1300,14 +1373,19 @@ function OrgMemberLogsCtrl($scope, $routeParams, $rootScope, $timeout, Restangul
|
||||||
$scope.ready = false;
|
$scope.ready = false;
|
||||||
|
|
||||||
var loadOrganization = function() {
|
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.organization = org;
|
||||||
return org;
|
return org;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var loadMemberInfo = function() {
|
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;
|
$scope.memberInfo = resp.member;
|
||||||
|
|
||||||
$rootScope.title = 'Logs for ' + $scope.memberInfo.username + ' (' + $scope.orgname + ')';
|
$rootScope.title = 'Logs for ' + $scope.memberInfo.username + ' (' + $scope.orgname + ')';
|
||||||
|
|
|
@ -65,6 +65,7 @@
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
<script src="static/js/bootstrap.js"></script>
|
||||||
<script src="static/js/app.js"></script>
|
<script src="static/js/app.js"></script>
|
||||||
<script src="static/js/controllers.js"></script>
|
<script src="static/js/controllers.js"></script>
|
||||||
<script src="static/js/graphing.js"></script>
|
<script src="static/js/graphing.js"></script>
|
||||||
|
@ -122,6 +123,22 @@ var isProd = document.location.hostname === 'quay.io';
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Modal message dialog -->
|
||||||
|
<div class="modal fade" id="couldnotloadModal" data-backdrop="static">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h4 class="modal-title">Uh Oh...</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
Something went wrong when trying to load Quay.io! Please report this to <a href="mailto:support@quay.io">support@quay.io</a>.
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
</div>
|
||||||
|
</div><!-- /.modal-content -->
|
||||||
|
</div><!-- /.modal-dialog -->
|
||||||
|
</div><!-- /.modal -->
|
||||||
|
|
||||||
<!-- begin olark code -->
|
<!-- begin olark code -->
|
||||||
{% if request.host == 'quay.io' %}
|
{% if request.host == 'quay.io' %}
|
||||||
<script data-cfasync="false" type='text/javascript'>/*<![CDATA[*/window.olark||(function(c){var f=window,d=document,l=f.location.protocol=="https:"?"https:":"http:",z=c.name,r="load";var nt=function(){
|
<script data-cfasync="false" type='text/javascript'>/*<![CDATA[*/window.olark||(function(c){var f=window,d=document,l=f.location.protocol=="https:"?"https:":"http:",z=c.name,r="load";var nt=function(){
|
||||||
|
|
|
@ -408,7 +408,7 @@ def build_specs():
|
||||||
TestSpec(url_for('update_org_subscription', orgname=ORG),
|
TestSpec(url_for('update_org_subscription', orgname=ORG),
|
||||||
401, 403, 403, 400).set_method('PUT'),
|
401, 403, 403, 400).set_method('PUT'),
|
||||||
|
|
||||||
TestSpec(url_for('get_subscription'), 401, 200, 200, 200),
|
TestSpec(url_for('get_user_subscription'), 401, 200, 200, 200),
|
||||||
|
|
||||||
TestSpec(url_for('get_org_subscription', orgname=ORG)),
|
TestSpec(url_for('get_org_subscription', orgname=ORG)),
|
||||||
|
|
||||||
|
|
Reference in a new issue