Replaced all hard-coded api/v1 references with dynamic references or with v2

This commit is contained in:
Michael Abashian
2017-05-24 17:04:10 -04:00
parent aaf039c23d
commit b875fd65e1
36 changed files with 64 additions and 70 deletions
@@ -61,7 +61,7 @@ export default ['$scope', '$rootScope',
if ($rootScope.current_user && $rootScope.current_user.is_superuser) { if ($rootScope.current_user && $rootScope.current_user.is_superuser) {
$scope.canShareCredential = true; $scope.canShareCredential = true;
} else { } else {
Rest.setUrl(`/api/v1/users/${$rootScope.current_user.id}/admin_of_organizations`); Rest.setUrl(GetBasePath('users') + `${$rootScope.current_user.id}/admin_of_organizations`);
Rest.get() Rest.get()
.success(function(data) { .success(function(data) {
$scope.canShareCredential = (data.count) ? true : false; $scope.canShareCredential = (data.count) ? true : false;
@@ -431,7 +431,7 @@ export default ['i18n', function(i18n) {
dataTipWatch: 'permissionsTooltip', dataTipWatch: 'permissionsTooltip',
awToolTipTabEnabledInEditMode: true, awToolTipTabEnabledInEditMode: true,
dataPlacement: 'right', dataPlacement: 'right',
basePath: 'api/v1/credentials/{{$stateParams.credential_id}}/access_list/', basePath: 'api/v2/credentials/{{$stateParams.credential_id}}/access_list/',
search: { search: {
order_by: 'username' order_by: 'username'
}, },
@@ -55,7 +55,7 @@ export default ['$scope', '$rootScope', '$location',
if ($rootScope.current_user && $rootScope.current_user.is_superuser) { if ($rootScope.current_user && $rootScope.current_user.is_superuser) {
$scope.canShareCredential = true; $scope.canShareCredential = true;
} else { } else {
Rest.setUrl(`/api/v1/users/${$rootScope.current_user.id}/admin_of_organizations`); Rest.setUrl(GetBasePath('users') + `${$rootScope.current_user.id}/admin_of_organizations`);
Rest.get() Rest.get()
.success(function(data) { .success(function(data) {
$scope.canShareCredential = (data.count) ? true : false; $scope.canShareCredential = (data.count) ? true : false;
@@ -30,14 +30,10 @@ export default
// smartStatus?, launchUrl, editUrl, name // smartStatus?, launchUrl, editUrl, name
scope.templates = _.map(list, function(template){ return { scope.templates = _.map(list, function(template){ return {
recent_jobs: template.summary_fields.recent_jobs, recent_jobs: template.summary_fields.recent_jobs,
launch_url: template.url,
edit_url: template.url.replace('api/v1', '#'),
name: template.name, name: template.name,
id: template.id, id: template.id,
type: template.type type: template.type
}; }); }; });
scope.snapRows = (list.length < 4);
} }
scope.isSuccessful = function (status) { scope.isSuccessful = function (status) {
@@ -29,14 +29,12 @@ export default
// detailsUrl, status, name, time // detailsUrl, status, name, time
scope.jobs = _.map(list, function(job){ scope.jobs = _.map(list, function(job){
return { return {
detailsUrl: job.type && job.type === 'workflow_job' ? job.url.replace("api/v1/workflow_jobs", "#/workflows") : job.url.replace("api/v1", "#"), detailsUrl: job.type && job.type === 'workflow_job' ? job.url.replace(/api\/v\d+\/workflow_jobs/, "#/workflows") : job.url.replace(/api\/v\d+/, "#"),
status: job.status, status: job.status,
name: job.name, name: job.name,
id: job.id, id: job.id,
time: $filter('longDate')(job.finished) time: $filter('longDate')(job.finished)
}; }); }; });
scope.snapRows = (list.length < 4);
} }
scope.isSuccessful = function (status) { scope.isSuccessful = function (status) {
+2 -2
View File
@@ -23,7 +23,7 @@ export default ['$scope', '$rootScope','Wait',
ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard host graph data: ' + status }); ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard host graph data: ' + status });
}); });
Rest.setUrl("api/v1/unified_jobs?order_by=-finished&page_size=5&finished__isnull=false&type=workflow_job,job"); Rest.setUrl(GetBasePath("unified_jobs") + "?order_by=-finished&page_size=5&finished__isnull=false&type=workflow_job,job");
Rest.get() Rest.get()
.success(function (data) { .success(function (data) {
$scope.dashboardJobsListData = data.results; $scope.dashboardJobsListData = data.results;
@@ -99,7 +99,7 @@ export default ['$scope', '$rootScope','Wait',
.error(function (data, status) { .error(function (data, status) {
ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard: ' + status }); ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard: ' + status });
}); });
Rest.setUrl("api/v1/unified_jobs?order_by=-finished&page_size=5&finished__isnull=false&type=workflow_job,job"); Rest.setUrl(GetBasePath("unified_jobs") + "?order_by=-finished&page_size=5&finished__isnull=false&type=workflow_job,job");
Rest.get() Rest.get()
.success(function (data) { .success(function (data) {
data = data.results; data = data.results;
@@ -112,7 +112,7 @@ export default ['i18n', 'InventoryCompletedJobsList', function(i18n, InventoryCo
name: 'permissions', name: 'permissions',
awToolTip: i18n._('Please save before assigning permissions'), awToolTip: i18n._('Please save before assigning permissions'),
dataPlacement: 'top', dataPlacement: 'top',
basePath: 'api/v1/inventories/{{$stateParams.smartinventory_id}}/access_list/', basePath: 'api/v2/inventories/{{$stateParams.smartinventory_id}}/access_list/',
type: 'collection', type: 'collection',
title: i18n._('Permissions'), title: i18n._('Permissions'),
iterator: 'permission', iterator: 'permission',
@@ -1,5 +1,5 @@
export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count', '$scope', 'ParseTypeChange', 'ParseVariableString', 'jobResultsService', 'eventQueue', '$compile', '$log', 'Dataset', '$q', 'QuerySet', '$rootScope', 'moment', '$stateParams', 'i18n', 'fieldChoices', 'fieldLabels', 'workflowResultsService', 'statusSocket', export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count', '$scope', 'ParseTypeChange', 'ParseVariableString', 'jobResultsService', 'eventQueue', '$compile', '$log', 'Dataset', '$q', 'QuerySet', '$rootScope', 'moment', '$stateParams', 'i18n', 'fieldChoices', 'fieldLabels', 'workflowResultsService', 'statusSocket', 'GetBasePath',
function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTypeChange, ParseVariableString, jobResultsService, eventQueue, $compile, $log, Dataset, $q, QuerySet, $rootScope, moment, $stateParams, i18n, fieldChoices, fieldLabels, workflowResultsService, statusSocket) { function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTypeChange, ParseVariableString, jobResultsService, eventQueue, $compile, $log, Dataset, $q, QuerySet, $rootScope, moment, $stateParams, i18n, fieldChoices, fieldLabels, workflowResultsService, statusSocket, GetBasePath) {
var toDestroy = []; var toDestroy = [];
var cancelRequests = false; var cancelRequests = false;
var runTimeElapsedTimer = null; var runTimeElapsedTimer = null;
@@ -49,7 +49,7 @@ function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTy
var getTowerLink = function(key) { var getTowerLink = function(key) {
if(key === 'schedule') { if(key === 'schedule') {
if($scope.job.related.schedule) { if($scope.job.related.schedule) {
return '/#/templates/job_template/' + $scope.job.job_template + '/schedules' + $scope.job.related.schedule.split('api/v1/schedules')[1]; return '/#/templates/job_template/' + $scope.job.job_template + '/schedules' + $scope.job.related.schedule.split(/api\/v\d+\/schedules/)[1];
} }
else { else {
return null; return null;
@@ -66,7 +66,7 @@ function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTy
else { else {
if ($scope.job.related[key]) { if ($scope.job.related[key]) {
return '/#/' + $scope.job.related[key] return '/#/' + $scope.job.related[key]
.split('api/v1/')[1]; .split(/api\/v\d+\//)[1];
} else { } else {
return null; return null;
} }
@@ -132,7 +132,7 @@ function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTy
// return a promise from the options request with the permission type choices (including adhoc) as a param // return a promise from the options request with the permission type choices (including adhoc) as a param
var fieldChoice = fieldChoices({ var fieldChoice = fieldChoices({
$scope: $scope, $scope: $scope,
url: 'api/v1/unified_jobs/', url: GetBasePath('unified_jobs'),
field: 'type' field: 'type'
}); });
@@ -505,7 +505,7 @@
<a ng-show="job.status === 'failed' || <a ng-show="job.status === 'failed' ||
job.status === 'successful' || job.status === 'successful' ||
job.status === 'canceled'" job.status === 'canceled'"
href="/api/v1/jobs/{{ job.id }}/stdout?format=txt_download"> href="/api/v2/jobs/{{ job.id }}/stdout?format=txt_download">
<button class="StandardOut-actionButton" <button class="StandardOut-actionButton"
aw-tool-tip="{{ standardOutTooltip }}" aw-tool-tip="{{ standardOutTooltip }}"
data-tip-watch="standardOutTooltip" data-tip-watch="standardOutTooltip"
@@ -152,7 +152,7 @@ export default
getUser: function () { getUser: function () {
return $http({ return $http({
method: 'GET', method: 'GET',
url: '/api/v1/me/', url: GetBasePath('me'),
headers: { headers: {
'Authorization': 'Token ' + this.getToken(), 'Authorization': 'Token ' + this.getToken(),
"X-Auth-Token": 'Token ' + this.getToken() "X-Auth-Token": 'Token ' + this.getToken()
@@ -38,10 +38,10 @@
* *
* When the the login button is clicked, the following occurs: * When the the login button is clicked, the following occurs:
* *
* - Call Authorization.retrieveToken(username, password) - sends a POST request to /api/v1/authtoken to get a new token value. * - Call Authorization.retrieveToken(username, password) - sends a POST request to /api/v2/authtoken to get a new token value.
* - Call Authorization.setToken(token, expires) to store the token and exipration time in a session cookie. * - Call Authorization.setToken(token, expires) to store the token and exipration time in a session cookie.
* - Start the expiration timer by calling the init() method of [js/shared/Timer.js](/static/docs/api/shared.function:Timer) * - Start the expiration timer by calling the init() method of [js/shared/Timer.js](/static/docs/api/shared.function:Timer)
* - Get user informaton by calling Authorization.getUser() - sends a GET request to /api/v1/me * - Get user informaton by calling Authorization.getUser() - sends a GET request to /api/v2/me
* - Store user information in the session cookie by calling Authorization.setUser(). * - Store user information in the session cookie by calling Authorization.setUser().
* - Get the Tower license by calling ConfigService.getConfig() - sends a GET request to /api/vi/config * - Get the Tower license by calling ConfigService.getConfig() - sends a GET request to /api/vi/config
* - Stores the license object in memory by calling CheckLicense.test(). This adds the Tower version and a tested flag to the license object. The tested flag is initially set to false. Additionally, the pendoService and FeaturesService are called to initiate the other startup services of Tower * - Stores the license object in memory by calling CheckLicense.test(). This adds the Tower version and a tested flag to the license object. The tested flag is initially set to false. Additionally, the pendoService and FeaturesService are called to initiate the other startup services of Tower
@@ -15,7 +15,7 @@ export default ['$window', '$scope', 'thirdPartySignOnService',
function ($window, $scope, thirdPartySignOnService) { function ($window, $scope, thirdPartySignOnService) {
thirdPartySignOnService( thirdPartySignOnService(
{scope: $scope, url: "api/v1/auth/"}).then(function (data) { {scope: $scope, url: "api/v2/auth/"}).then(function (data) {
if (data && data.options && data.options.length > 0) { if (data && data.options && data.options.length > 0) {
$scope.thirdPartyLoginSupported = true; $scope.thirdPartyLoginSupported = true;
$scope.loginItems = data.options; $scope.loginItems = data.options;
@@ -57,7 +57,7 @@ export default ['NotificationsList', 'i18n',
name: 'users', name: 'users',
dataPlacement: 'top', dataPlacement: 'top',
awToolTip: i18n._('Please save before adding users'), awToolTip: i18n._('Please save before adding users'),
basePath: 'api/v1/organizations/{{$stateParams.organization_id}}/access_list/', basePath: 'api/v2/organizations/{{$stateParams.organization_id}}/access_list/',
search: { search: {
order_by: 'username' order_by: 'username'
}, },
+1 -1
View File
@@ -225,7 +225,7 @@ export default ['i18n', 'NotificationsList', function(i18n, NotificationsList) {
awToolTip: i18n._('Please save before assigning permissions'), awToolTip: i18n._('Please save before assigning permissions'),
djangoModel: 'access_list', djangoModel: 'access_list',
dataPlacement: 'top', dataPlacement: 'top',
basePath: 'api/v1/projects/{{$stateParams.project_id}}/access_list/', basePath: 'api/v2/projects/{{$stateParams.project_id}}/access_list/',
search: { search: {
order_by: 'username' order_by: 'username'
}, },
@@ -19,8 +19,8 @@
* Note that $http will automaticall encode the URL, replacing spaces and special characters with appropriate %hex codes. Example URL values might include: * Note that $http will automaticall encode the URL, replacing spaces and special characters with appropriate %hex codes. Example URL values might include:
* *
* ``` * ```
* /api/v1/inventories/9/ * /api/v2/inventories/9/
* /api/v1/credentials/?name=SSH Key&kind=ssh * /api/v2/credentials/?name=SSH Key&kind=ssh
* ``` * ```
* *
* When constructing the URL be sure to use the GetBasePath() method found in js/shared/Utilities.js. GetBasePath uses the response objects from /api and * When constructing the URL be sure to use the GetBasePath() method found in js/shared/Utilities.js. GetBasePath uses the response objects from /api and
+1 -1
View File
@@ -339,7 +339,7 @@ export default
return qs.search(path, $stateParams[`${list.iterator}_search`]); return qs.search(path, $stateParams[`${list.iterator}_search`]);
} }
], ],
ParentObject: [() =>{return {endpoint:'/api/v1/schedules'}; }], ParentObject: ['GetBasePath', (GetBasePath) =>{return {endpoint:GetBasePath('schedules')}; }],
UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q', UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q',
function(Rest, GetBasePath, $stateParams, $q) { function(Rest, GetBasePath, $stateParams, $q) {
Rest.setUrl(GetBasePath('unified_jobs')); Rest.setUrl(GetBasePath('unified_jobs'));
+3 -3
View File
@@ -13,8 +13,8 @@ export default {
}, },
resolve: { resolve: {
orgAdmin: orgAdmin:
['$rootScope', 'ProcessErrors', 'Rest', ['$rootScope', 'ProcessErrors', 'Rest', 'GetBasePath',
function($rootScope, ProcessErrors, Rest){ function($rootScope, ProcessErrors, Rest, GetBasePath){
return $rootScope.loginConfig.promise.then(function () { return $rootScope.loginConfig.promise.then(function () {
if($rootScope.current_user.related.admin_of_organizations){ if($rootScope.current_user.related.admin_of_organizations){
@@ -22,7 +22,7 @@ export default {
if ($rootScope.current_user.is_superuser) { if ($rootScope.current_user.is_superuser) {
return true; return true;
} else { } else {
Rest.setUrl(`/api/v1/users/${$rootScope.current_user.id}/admin_of_organizations`); Rest.setUrl(GetBasePath('users') + `${$rootScope.current_user.id}/admin_of_organizations`);
return Rest.get().then(function(data){ return Rest.get().then(function(data){
if(data.data.count){ if(data.data.count){
return true; return true;
+1 -1
View File
@@ -63,7 +63,7 @@ angular.module('ApiLoader', ['Utilities'])
.factory('GetBasePath', ['$rootScope', 'Store', 'LoadBasePaths', 'Empty', .factory('GetBasePath', ['$rootScope', 'Store', 'LoadBasePaths', 'Empty',
function ($rootScope, Store, LoadBasePaths, Empty) { function ($rootScope, Store, LoadBasePaths, Empty) {
return function (set) { return function (set) {
// use /api/v1/ results to construct API URLs. // use /api/v2/ results to construct API URLs.
if (Empty($rootScope.defaultUrls)) { if (Empty($rootScope.defaultUrls)) {
// browser refresh must have occurred. load from local storage // browser refresh must have occurred. load from local storage
if (Store('api')) { if (Store('api')) {
@@ -130,7 +130,7 @@
<button class="StandardOut-actionButton" aw-tool-tip="{{ toggleStdoutFullscreenTooltip }}" data-tip-watch="toggleStdoutFullscreenTooltip" data-placement="top" ng-class="{'StandardOut-actionButton--active': stdoutFullScreen}" ng-click="toggleStdoutFullscreen()"> <button class="StandardOut-actionButton" aw-tool-tip="{{ toggleStdoutFullscreenTooltip }}" data-tip-watch="toggleStdoutFullscreenTooltip" data-placement="top" ng-class="{'StandardOut-actionButton--active': stdoutFullScreen}" ng-click="toggleStdoutFullscreen()">
<i class="fa fa-arrows-alt"></i> <i class="fa fa-arrows-alt"></i>
</button> </button>
<a href="/api/v1/ad_hoc_commands/{{ job.id }}/stdout?format=txt_download"> <a href="/api/v2/ad_hoc_commands/{{ job.id }}/stdout?format=txt_download">
<button class="StandardOut-actionButton" aw-tool-tip="{{'Download Output'|translate}}" data-placement="top"> <button class="StandardOut-actionButton" aw-tool-tip="{{'Download Output'|translate}}" data-placement="top">
<i class="fa fa-download"></i> <i class="fa fa-download"></i>
</button> </button>
@@ -124,7 +124,7 @@
<button class="StandardOut-actionButton" aw-tool-tip="{{ toggleStdoutFullscreenTooltip }}" data-tip-watch="toggleStdoutFullscreenTooltip" data-placement="top" ng-class="{'StandardOut-actionButton--active': stdoutFullScreen}"ng-click="toggleStdoutFullscreen()"> <button class="StandardOut-actionButton" aw-tool-tip="{{ toggleStdoutFullscreenTooltip }}" data-tip-watch="toggleStdoutFullscreenTooltip" data-placement="top" ng-class="{'StandardOut-actionButton--active': stdoutFullScreen}"ng-click="toggleStdoutFullscreen()">
<i class="fa fa-arrows-alt"></i> <i class="fa fa-arrows-alt"></i>
</button> </button>
<a href="/api/v1/inventory_updates/{{ job.id }}/stdout?format=txt_download"> <a href="/api/v2/inventory_updates/{{ job.id }}/stdout?format=txt_download">
<button class="StandardOut-actionButton" aw-tool-tip="{{'Download Output'|translate}}" data-placement="top"> <button class="StandardOut-actionButton" aw-tool-tip="{{'Download Output'|translate}}" data-placement="top">
<i class="fa fa-download"></i> <i class="fa fa-download"></i>
</button> </button>
@@ -98,7 +98,7 @@
<button class="StandardOut-actionButton" aw-tool-tip="{{ toggleStdoutFullscreenTooltip }}" data-tip-watch="toggleStdoutFullscreenTooltip" data-placement="top" ng-class="{'StandardOut-actionButton--active': stdoutFullScreen}"ng-click="toggleStdoutFullscreen()"> <button class="StandardOut-actionButton" aw-tool-tip="{{ toggleStdoutFullscreenTooltip }}" data-tip-watch="toggleStdoutFullscreenTooltip" data-placement="top" ng-class="{'StandardOut-actionButton--active': stdoutFullScreen}"ng-click="toggleStdoutFullscreen()">
<i class="fa fa-arrows-alt"></i> <i class="fa fa-arrows-alt"></i>
</button> </button>
<a href="/api/v1/project_updates/{{ job.id }}/stdout?format=txt_download"> <a href="/api/v2/project_updates/{{ job.id }}/stdout?format=txt_download">
<button class="StandardOut-actionButton" aw-tool-tip="{{'Download Output'|translate}}" data-placement="top"> <button class="StandardOut-actionButton" aw-tool-tip="{{'Download Output'|translate}}" data-placement="top">
<i class="fa fa-download"></i> <i class="fa fa-download"></i>
</button> </button>
@@ -87,7 +87,7 @@ export default ['$scope', '$rootScope', '$stateParams', 'TeamForm', 'Rest',
$scope.convertApiUrl = function(str) { $scope.convertApiUrl = function(str) {
if (str) { if (str) {
return str.replace("api/v1", "#"); return str.replace(/api\/v\d+/, "#");
} else { } else {
return null; return null;
} }
+2 -2
View File
@@ -67,7 +67,7 @@ export default ['i18n', function(i18n) {
name: 'users', name: 'users',
dataPlacement: 'top', dataPlacement: 'top',
awToolTip: i18n._('Please save before adding users'), awToolTip: i18n._('Please save before adding users'),
basePath: 'api/v1/teams/{{$stateParams.team_id}}/access_list/', basePath: 'api/v2/teams/{{$stateParams.team_id}}/access_list/',
search: { search: {
order_by: 'username' order_by: 'username'
}, },
@@ -104,7 +104,7 @@ export default ['i18n', function(i18n) {
}, },
permissions: { permissions: {
name: 'permissions', name: 'permissions',
basePath: 'api/v1/teams/{{$stateParams.team_id}}/roles/', basePath: 'api/v2/teams/{{$stateParams.team_id}}/roles/',
search: { search: {
page_size: '10', page_size: '10',
// @todo ask about name field / serializer on this endpoint // @todo ask about name field / serializer on this endpoint
@@ -11,7 +11,7 @@ export default ['i18n', function(i18n) {
awToolTip: i18n._('Please save and run a job to view'), awToolTip: i18n._('Please save and run a job to view'),
dataPlacement: 'top', dataPlacement: 'top',
name: 'completed_jobs', name: 'completed_jobs',
basePath: 'api/v1/job_templates/{{$stateParams.job_template_id}}/jobs/?or__status=successful&or__status=failed&or__status=error&or__status=canceled', basePath: 'api/v2/job_templates/{{$stateParams.job_template_id}}/jobs/?or__status=successful&or__status=failed&or__status=error&or__status=canceled',
iterator: 'completed_job', iterator: 'completed_job',
editTitle: i18n._('COMPLETED JOBS'), editTitle: i18n._('COMPLETED JOBS'),
index: false, index: false,
@@ -426,7 +426,7 @@ function(NotificationsList, CompletedJobsList, i18n) {
name: 'permissions', name: 'permissions',
awToolTip: i18n._('Please save before assigning permissions'), awToolTip: i18n._('Please save before assigning permissions'),
dataPlacement: 'top', dataPlacement: 'top',
basePath: 'api/v1/job_templates/{{$stateParams.job_template_id}}/access_list/', basePath: 'api/v2/job_templates/{{$stateParams.job_template_id}}/access_list/',
search: { search: {
order_by: 'username' order_by: 'username'
}, },
@@ -137,7 +137,7 @@
callback: 'choicesReadyVerbosity' callback: 'choicesReadyVerbosity'
}); });
Rest.setUrl('api/v1/labels'); Rest.setUrl(GetBasePath('labels'));
Rest.get() Rest.get()
.success(function (data) { .success(function (data) {
$scope.labelOptions = data.results $scope.labelOptions = data.results
@@ -351,7 +351,7 @@ export default
callback: 'choicesReady' callback: 'choicesReady'
}); });
Rest.setUrl('api/v1/labels'); Rest.setUrl(GetBasePath('labels'));
Wait("start"); Wait("start");
Rest.get() Rest.get()
.success(function (data) { .success(function (data) {
@@ -108,7 +108,7 @@ export default ['NotificationsList', 'i18n', function(NotificationsList, i18n) {
name: 'permissions', name: 'permissions',
awToolTip: i18n._('Please save before assigning permissions'), awToolTip: i18n._('Please save before assigning permissions'),
dataPlacement: 'top', dataPlacement: 'top',
basePath: 'api/v1/workflow_job_templates/{{$stateParams.workflow_job_template_id}}/access_list/', basePath: 'api/v2/workflow_job_templates/{{$stateParams.workflow_job_template_id}}/access_list/',
search: { search: {
order_by: 'username' order_by: 'username'
}, },
@@ -47,7 +47,7 @@ export default [
templateType: 'workflow_job_template' templateType: 'workflow_job_template'
}); });
Rest.setUrl('api/v1/labels'); Rest.setUrl(GetBasePath('labels'));
Wait("start"); Wait("start");
Rest.get() Rest.get()
.success(function (data) { .success(function (data) {
@@ -128,7 +128,7 @@ export default ['$scope', '$rootScope', '$stateParams', 'UserForm', 'Rest',
$scope.convertApiUrl = function(str) { $scope.convertApiUrl = function(str) {
if (str) { if (str) {
return str.replace("api/v1", "#"); return str.replace(/api\/v\d+/, "#");
} else { } else {
return null; return null;
} }
+3 -3
View File
@@ -119,7 +119,7 @@ export default ['i18n', function(i18n) {
organizations: { organizations: {
name: 'organizations', name: 'organizations',
awToolTip: i18n._('Please save before assigning to organizations'), awToolTip: i18n._('Please save before assigning to organizations'),
basePath: 'api/v1/users/{{$stateParams.user_id}}/organizations', basePath: 'api/v2/users/{{$stateParams.user_id}}/organizations',
emptyListText: i18n._('Please add user to an Organization.'), emptyListText: i18n._('Please add user to an Organization.'),
search: { search: {
page_size: '10' page_size: '10'
@@ -147,7 +147,7 @@ export default ['i18n', function(i18n) {
teams: { teams: {
name: 'teams', name: 'teams',
awToolTip: i18n._('Please save before assigning to teams'), awToolTip: i18n._('Please save before assigning to teams'),
basePath: 'api/v1/users/{{$stateParams.user_id}}/teams', basePath: 'api/v2/users/{{$stateParams.user_id}}/teams',
search: { search: {
page_size: '10' page_size: '10'
}, },
@@ -172,7 +172,7 @@ export default ['i18n', function(i18n) {
}, },
permissions: { permissions: {
name: 'permissions', name: 'permissions',
basePath: 'api/v1/users/{{$stateParams.user_id}}/roles/', basePath: 'api/v2/users/{{$stateParams.user_id}}/roles/',
search: { search: {
page_size: '10', page_size: '10',
order_by: 'id' order_by: 'id'
@@ -10,7 +10,7 @@ export default ['workflowData', 'workflowResultsService', 'workflowDataOptions',
var getTowerLink = function(key) { var getTowerLink = function(key) {
if(key === 'schedule') { if(key === 'schedule') {
if($scope.workflow.related.schedule) { if($scope.workflow.related.schedule) {
return '/#/templates/workflow_job_template/' + $scope.workflow.workflow_job_template + '/schedules' + $scope.workflow.related.schedule.split('api/v1/schedules')[1]; return '/#/templates/workflow_job_template/' + $scope.workflow.workflow_job_template + '/schedules' + $scope.workflow.related.schedule.split(/api\/v\d+\/schedules/)[1];
} }
else { else {
return null; return null;
@@ -19,7 +19,7 @@ export default ['workflowData', 'workflowResultsService', 'workflowDataOptions',
else { else {
if ($scope.workflow.related[key]) { if ($scope.workflow.related[key]) {
return '/#/' + $scope.workflow.related[key] return '/#/' + $scope.workflow.related[key]
.split('api/v1/')[1]; .split(/api\/v\d+\//)[1];
} else { } else {
return null; return null;
} }
@@ -20,7 +20,7 @@ describe('Service: InventoryManageService', () => {
spyOn(InventoryManageService, 'error'); spyOn(InventoryManageService, 'error');
}); });
it('InventoryManageService.getInventory should handle errors', () => { it('InventoryManageService.getInventory should handle errors', () => {
Rest.expectGET('/api/v1/inventory:id/').respond(400, {}); Rest.expectGET('/api/v2/inventory:id/').respond(400, {});
Rest.flush(); Rest.flush();
expect(InventoryManageService.error).toHaveBeenCalled(); expect(InventoryManageService.error).toHaveBeenCalled();
}); });
@@ -198,12 +198,12 @@ describe('Controller: jobResultsController', () => {
describe('getTowerLinks()', () => { describe('getTowerLinks()', () => {
beforeEach(() => { beforeEach(() => {
jobData.related = { jobData.related = {
"created_by": "api/v1/users/12", "created_by": "api/v2/users/12",
"inventory": "api/v1/inventories/12", "inventory": "api/v2/inventories/12",
"project": "api/v1/projects/12", "project": "api/v2/projects/12",
"credential": "api/v1/credentials/12", "credential": "api/v2/credentials/12",
"cloud_credential": "api/v1/credentials/13", "cloud_credential": "api/v2/credentials/13",
"network_credential": "api/v1/credentials/14", "network_credential": "api/v2/credentials/14",
}; };
jobData.summary_fields.inventory = { jobData.summary_fields.inventory = {
@@ -60,8 +60,8 @@ describe('Service: QuerySet', () => {
describe('fn search', () => { describe('fn search', () => {
let pattern = /\/api\/v1\/inventories\/(.+)\/groups\/*/, let pattern = /\/api\/v2\/inventories\/(.+)\/groups\/*/,
endpoint = '/api/v1/inventories/1/groups/', endpoint = '/api/v2/inventories/1/groups/',
params = { params = {
or__name: 'borg', or__name: 'borg',
or__description__icontains: 'assimilate' or__description__icontains: 'assimilate'
@@ -72,7 +72,7 @@ describe('Service: QuerySet', () => {
.expectGET(pattern) .expectGET(pattern)
.respond(200, {}); .respond(200, {});
QuerySet.search(endpoint, params).then((data) =>{ QuerySet.search(endpoint, params).then((data) =>{
expect(data.config.url).toEqual('/api/v1/inventories/1/groups/?or__name=borg&or__description__icontains=assimilate'); expect(data.config.url).toEqual('/api/v2/inventories/1/groups/?or__name=borg&or__description__icontains=assimilate');
}); });
$httpBackend.flush(); $httpBackend.flush();
}); });
@@ -1,17 +1,17 @@
export default { export default {
"id": 109, "id": 109,
"type": "workflow_job", "type": "workflow_job",
"url": "/api/v1/workflow_jobs/109/", "url": "/api/v2/workflow_jobs/109/",
"related": { "related": {
"created_by": "/api/v1/users/1/", "created_by": "/api/v2/users/1/",
"unified_job_template": "/api/v1/workflow_job_templates/27/", "unified_job_template": "/api/v2/workflow_job_templates/27/",
"workflow_job_template": "/api/v1/workflow_job_templates/27/", "workflow_job_template": "/api/v2/workflow_job_templates/27/",
"notifications": "/api/v1/workflow_jobs/109/notifications/", "notifications": "/api/v2/workflow_jobs/109/notifications/",
"workflow_nodes": "/api/v1/workflow_jobs/109/workflow_nodes/", "workflow_nodes": "/api/v2/workflow_jobs/109/workflow_nodes/",
"labels": "/api/v1/workflow_jobs/109/labels/", "labels": "/api/v2/workflow_jobs/109/labels/",
"activity_stream": "/api/v1/workflow_jobs/109/activity_stream/", "activity_stream": "/api/v2/workflow_jobs/109/activity_stream/",
"relaunch": "/api/v1/workflow_jobs/109/relaunch/", "relaunch": "/api/v2/workflow_jobs/109/relaunch/",
"cancel": "/api/v1/workflow_jobs/109/cancel/" "cancel": "/api/v2/workflow_jobs/109/cancel/"
}, },
"summary_fields": { "summary_fields": {
"workflow_job_template": { "workflow_job_template": {