Skip to content

Commit

Permalink
Reuse unbound routes (#1223)
Browse files Browse the repository at this point in the history
* Add tabs to add route modal

* Add getUnboundRoute method to route model and small tidy ups

* List existing routes on add route modal

* Tidy up route fetch code

* Check validilty of add route modal depending on what tab is selected

* Allow users to assign existing route to application

* Fix undefined form validation exception

* Actually use the st-table directive and filtering

* Update resue route tab styling

* Don't show existing routes tab if no existing routes can be found

* More styling changes for the existing routes tab

* Override nav styles on route modal

* Added 'load all' option to route table

* Remove uneeded application id from routes request

* Fixed and added test for route add modal

* Minor changes after review
  • Loading branch information
KlapTrap authored and richard-cox committed Aug 18, 2017
1 parent 58df812 commit c92c19a
Show file tree
Hide file tree
Showing 8 changed files with 459 additions and 98 deletions.
6 changes: 3 additions & 3 deletions components/app-core/frontend/src/view/navbar/navbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ nav.secondary-nav {
}
}
}

.secondary-navbar {
flex: 1 1 0;
background-color: $navbar-bottom-border-color;
Expand Down Expand Up @@ -198,7 +198,7 @@ nav.secondary-nav {
svg {
width: 28px;
height: 28px;

> path {
fill: $navbar-text-color;
}
Expand All @@ -221,8 +221,8 @@ nav.secondary-nav {
}

&:hover {
color: $navbar-hover-fg;
background-color: $navbar-hover-bg;
color: $navbar-hover-fg;
}

&.active {
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';

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');

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

0 comments on commit c92c19a

Please sign in to comment.