Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse unbound routes #1223

Merged
merged 17 commits into from
Aug 18, 2017
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions components/app-core/frontend/src/view/navbar/navbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,11 @@ nav.secondary-nav {

&:hover {
color: $navbar-hover-fg;
background-color: $navbar-hover-bg;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two background-color's are needed

}

&.active {
background-color: $navbar-active-bg;
color: $navbar-active-fg;
background-color: transparent;
}

> a {
Expand Down
18 changes: 15 additions & 3 deletions components/cloud-foundry/frontend/i18n/en_US/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@
}
},
"app-tabs": {
"routes": {
"add": {
"create": {
"title": "Create New Route"
},
"reuse": {
"title": "Use Existing Route"
}
}
},
"summary": {
"label": "Summary",
"instructions": {
Expand Down Expand Up @@ -140,7 +150,7 @@
"add-route-dialog": {
"title": "Add a Route",
"host-label": "Host",
"host-error-exists": "A route with this name already exists. Choose a new one",
"host-error-exists": "A route with this name already exists.",
"host-error-required": "Host is required",
"host-placeholder": "a unique identifier for this route",
"domain-label": "Domain",
Expand All @@ -152,8 +162,10 @@
"port-label": "Port",
"port-placeholder": "port for this route",
"button": {
"submit": "Create route"
}
"submit": "Add route"
},
"search-placeholder": "Search by name",
"no-routes-found": "No routes found"
}
},
"service-instances-panel": {
Expand Down
40 changes: 21 additions & 19 deletions components/cloud-foundry/frontend/src/api/Apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
.module('cloud-foundry.api')
.run(registerApi);

var BASE_URL = '/pp/v1/proxy/v2/apps';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the past we've avoided making changes to 'api' files as they were originally auto-generated. Going forward I don't think there's much harm in re-factoring but we need to bear in mind we might auto-generate these files for v3 of the cf api.


function registerApi($http, apiManager) {
apiManager.register('cloud-foundry.api.Apps', new AppsApi($http));
}
Expand All @@ -25,7 +27,7 @@
AssociateRouteWithApp: function (guid, route_guid, params, httpConfigOptions) {
var config = {};
config.params = params;
config.url = '/pp/v1/proxy/v2/apps/' + guid + '/routes/' + route_guid + '';
config.url = BASE_URL + '/' + guid + '/routes/' + route_guid + '';
config.method = 'PUT';

for (var option in httpConfigOptions) {
Expand All @@ -45,7 +47,7 @@
CopyAppBitsForApp: function (guid, value, params, httpConfigOptions) {
var config = {};
config.params = params;
config.url = '/pp/v1/proxy/v2/apps/' + guid + '/copy_bits';
config.url = BASE_URL + '/' + guid + '/copy_bits';
config.method = 'POST';
config.data = value;

Expand All @@ -63,7 +65,7 @@
CreateDockerAppExperimental: function (value, params, httpConfigOptions) {
var config = {};
config.params = params;
config.url = '/pp/v1/proxy/v2/apps';
config.url = BASE_URL + '';
config.method = 'POST';
config.data = value;

Expand All @@ -81,7 +83,7 @@
CreateApp: function (value, params, httpConfigOptions) {
var config = {};
config.params = params;
config.url = '/pp/v1/proxy/v2/apps';
config.url = BASE_URL + '';
config.method = 'POST';
config.data = value;

Expand All @@ -99,7 +101,7 @@
DeleteApp: function (guid, params, httpConfigOptions) {
var config = {};
config.params = params;
config.url = '/pp/v1/proxy/v2/apps/' + guid + '';
config.url = BASE_URL + '/' + guid + '';
config.method = 'DELETE';

for (var option in httpConfigOptions) {
Expand All @@ -119,7 +121,7 @@
DownloadsStagedDropletForApp: function (guid, params, httpConfigOptions) {
var config = {};
config.params = params;
config.url = '/pp/v1/proxy/v2/apps/' + guid + '/droplet/download';
config.url = BASE_URL + '/' + guid + '/droplet/download';
config.method = 'GET';

for (var option in httpConfigOptions) {
Expand All @@ -136,7 +138,7 @@
GetAppSummary: function (guid, params, httpConfigOptions) {
var config = {};
config.params = params;
config.url = '/pp/v1/proxy/v2/apps/' + guid + '/summary';
config.url = BASE_URL + '/' + guid + '/summary';
config.method = 'GET';

for (var option in httpConfigOptions) {
Expand All @@ -154,7 +156,7 @@
GetDetailedStatsForStartedApp: function (guid, params, httpConfigOptions) {
var config = {};
config.params = params;
config.url = '/pp/v1/proxy/v2/apps/' + guid + '/stats';
config.url = BASE_URL + '/' + guid + '/stats';
config.method = 'GET';

for (var option in httpConfigOptions) {
Expand All @@ -172,7 +174,7 @@
GetEnvForApp: function (guid, params, httpConfigOptions) {
var config = {};
config.params = params;
config.url = '/pp/v1/proxy/v2/apps/' + guid + '/env';
config.url = BASE_URL + '/' + guid + '/env';
config.method = 'GET';

for (var option in httpConfigOptions) {
Expand Down Expand Up @@ -201,7 +203,7 @@
GetInstanceInformationForStartedApp: function (guid, params, httpConfigOptions) {
var config = {};
config.params = params;
config.url = '/pp/v1/proxy/v2/apps/' + guid + '/instances';
config.url = BASE_URL + '/' + guid + '/instances';
config.method = 'GET';

for (var option in httpConfigOptions) {
Expand All @@ -218,7 +220,7 @@
ListAllApps: function (params, httpConfigOptions) {
var config = {};
config.params = params;
config.url = '/pp/v1/proxy/v2/apps';
config.url = BASE_URL + '';
config.method = 'GET';

for (var option in httpConfigOptions) {
Expand All @@ -235,7 +237,7 @@
ListAllRoutesForApp: function (guid, params, httpConfigOptions) {
var config = {};
config.params = params;
config.url = '/pp/v1/proxy/v2/apps/' + guid + '/routes';
config.url = BASE_URL + '/' + guid + '/routes';
config.method = 'GET';

for (var option in httpConfigOptions) {
Expand All @@ -252,7 +254,7 @@
ListAllServiceBindingsForApp: function (guid, params, httpConfigOptions) {
var config = {};
config.params = params;
config.url = '/pp/v1/proxy/v2/apps/' + guid + '/service_bindings';
config.url = BASE_URL + '/' + guid + '/service_bindings';
config.method = 'GET';

for (var option in httpConfigOptions) {
Expand All @@ -269,7 +271,7 @@
RemoveRouteFromApp: function (guid, route_guid, params, httpConfigOptions) {
var config = {};
config.params = params;
config.url = '/pp/v1/proxy/v2/apps/' + guid + '/routes/' + route_guid + '';
config.url = BASE_URL + '/' + guid + '/routes/' + route_guid + '';
config.method = 'DELETE';

for (var option in httpConfigOptions) {
Expand All @@ -286,7 +288,7 @@
RemoveServiceBindingFromApp: function (guid, service_binding_guid, params, httpConfigOptions) {
var config = {};
config.params = params;
config.url = '/pp/v1/proxy/v2/apps/' + guid + '/service_bindings/' + service_binding_guid + '';
config.url = BASE_URL + '/' + guid + '/service_bindings/' + service_binding_guid + '';
config.method = 'DELETE';

for (var option in httpConfigOptions) {
Expand All @@ -303,7 +305,7 @@
RestageApp: function (guid, params, httpConfigOptions) {
var config = {};
config.params = params;
config.url = '/pp/v1/proxy/v2/apps/' + guid + '/restage';
config.url = BASE_URL + '/' + guid + '/restage';
config.method = 'POST';

for (var option in httpConfigOptions) {
Expand All @@ -320,7 +322,7 @@
RetrieveApp: function (guid, params, httpConfigOptions) {
var config = {};
config.params = params;
config.url = '/pp/v1/proxy/v2/apps/' + guid + '';
config.url = BASE_URL + '/' + guid + '';
config.method = 'GET';

for (var option in httpConfigOptions) {
Expand All @@ -337,7 +339,7 @@
TerminateRunningAppInstanceAtGivenIndex: function (guid, index, params, httpConfigOptions) {
var config = {};
config.params = params;
config.url = '/pp/v1/proxy/v2/apps/' + guid + '/instances/' + index + '';
config.url = BASE_URL + '/' + guid + '/instances/' + index + '';
config.method = 'DELETE';

for (var option in httpConfigOptions) {
Expand All @@ -354,7 +356,7 @@
UpdateApp: function (guid, value, params, httpConfigOptions) {
var config = {};
config.params = params;
config.url = '/pp/v1/proxy/v2/apps/' + guid + '';
config.url = BASE_URL + '/' + guid + '';
config.method = 'PUT';
config.data = value;

Expand Down
20 changes: 10 additions & 10 deletions components/cloud-foundry/frontend/src/model/route.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
*/
function Route(apiManager, modelUtils) {

var routesApi = apiManager.retrieve('cloud-foundry.api.Routes');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've had some issues in the past where the apiManager/modelManager cannot retrieve the objects when their host function is run first, so will grab them when needed. It's probably best to leave these as is.


var model = {
route: {},
checkRouteExists: checkRouteExists,
Expand Down Expand Up @@ -52,7 +54,7 @@
* @public
*/
function checkRouteExists(cnsiGuid, domainGuid, host, path, port) {
return apiManager.retrieve('cloud-foundry.api.Routes')
return routesApi
.CheckRouteExists(domainGuid, host, path || '', port || '', {}, modelUtils.makeHttpConfig(cnsiGuid))
.then(function (response) {
return response.data;
Expand All @@ -70,7 +72,7 @@
* @public
*/
function associateAppWithRoute(cnsiGuid, guid, appGuid) {
return apiManager.retrieve('cloud-foundry.api.Routes')
return routesApi
.AssociateAppWithRoute(guid, appGuid, {}, modelUtils.makeHttpConfig(cnsiGuid));
}

Expand All @@ -85,13 +87,13 @@
* @public
*/
function removeAppFromRoute(cnsiGuid, guid, appGuid) {
return apiManager.retrieve('cloud-foundry.api.Routes')
return routesApi
.RemoveAppFromRoute(guid, appGuid, {}, modelUtils.makeHttpConfig(cnsiGuid));
}

function createRoute(cnsiGuid, routeSpec, params) {
var routeParams = params || {};
return apiManager.retrieve('cloud-foundry.api.Routes')
return routesApi
.CreateRoute(routeSpec, routeParams, modelUtils.makeHttpConfig(cnsiGuid))
.then(function (response) {
return response.data;
Expand All @@ -109,7 +111,7 @@
* @public
*/
function deleteRoute(cnsiGuid, guid, recursive) {
return apiManager.retrieve('cloud-foundry.api.Routes')
return routesApi
.DeleteRoute(guid, recursive, {}, modelUtils.makeHttpConfig(cnsiGuid));
}

Expand All @@ -126,7 +128,7 @@
* @public
*/
function listAllAppsForRoute(cnsiGuid, guid, params, paginate) {
return apiManager.retrieve('cloud-foundry.api.Routes')
return routesApi
.ListAllAppsForRoute(guid, params, modelUtils.makeHttpConfig(cnsiGuid))
.then(function (response) {
if (paginate) {
Expand Down Expand Up @@ -163,7 +165,7 @@
* @public
*/
function listAllAppsForRouteWithoutStore(cnsiGuid, guid, params, paginate) {
return apiManager.retrieve('cloud-foundry.api.Routes')
return routesApi
.ListAllAppsForRoute(guid, params, modelUtils.makeHttpConfig(cnsiGuid))
.then(function (response) {
if (paginate) {
Expand Down Expand Up @@ -195,7 +197,7 @@
* @public
*/
function listAllRouteMappingsForRoute(cnsiGuid, guid, params, paginate) {
return apiManager.retrieve('cloud-foundry.api.Routes')
return routesApi
.ListAllRouteMappingsForRoute(guid, params, modelUtils.makeHttpConfig(cnsiGuid))
.then(function (response) {
if (!paginate) {
Expand All @@ -204,7 +206,5 @@
return response.data.resources;
});
}

}

})();
Loading