Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
TEAMFOUR-397 - Delete and unmap routes (#434)
Browse files Browse the repository at this point in the history
* TEAMFOUR-397 - delete and unmap routes

* added gettexts
  • Loading branch information
irfanhabib authored and richard-cox committed Jul 7, 2016
1 parent ece1bf5 commit 876f06e
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,14 @@
</tr>
</thead>
<tbody>
<tr ng-repeat="route in appCtrl.model.application.summary.routes">
<tr ng-repeat="route in appCtrl.model.application.summary.routes track by applicationSummaryCtrl.getRouteId(route)">
<td>{{ route.host + '.' + route.domain.name + route.path }}</td>
<td></td>
<td>
<actions-menu actions="applicationSummaryCtrl.routesActionMenu"
action-target="route"
menu-position="actions-menu-right"
menu-icon="helion-icon helion-icon-More"></actions-menu>
</td>
</tr>
</tbody>
</table>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(function() {
(function () {
'use strict';

angular
Expand All @@ -9,7 +9,7 @@
'$stateProvider'
];

function registerRoute($stateProvider) {
function registerRoute ($stateProvider) {
$stateProvider.state('cf.applications.application.summary', {
url: '/summary',
templateUrl: 'plugins/cloud-foundry/view/applications/application/summary/summary.html',
Expand All @@ -21,7 +21,8 @@
ApplicationSummaryController.$inject = [
'app.model.modelManager',
'$stateParams',
'cloud-foundry.view.applications.application.summary.addRoutes'
'cloud-foundry.view.applications.application.summary.addRoutes',
'helion.framework.widgets.dialog.confirm'
];

/**
Expand All @@ -30,17 +31,37 @@
* @param {app.model.modelManager} modelManager - the Model management service
* @param {object} $stateParams - the UI router $stateParams service
* @param {cloud-foundry.view.applications.application.summary.addRoutes} addRoutesService - add routes service
* @param confirmDialog
* @property {cloud-foundry.model.application} model - the Cloud Foundry Applications Model
* @property {app.model.serviceInstance.user} userCnsiModel - the user service instance model
* @property {string} id - the application GUID
* @property {cloud-foundry.view.applications.application.summary.addRoutes} addRoutesService - add routes service
*/
function ApplicationSummaryController(modelManager, $stateParams, addRoutesService) {
function ApplicationSummaryController (modelManager, $stateParams, addRoutesService, confirmDialog) {
this.model = modelManager.retrieve('cloud-foundry.model.application');
this.userCnsiModel = modelManager.retrieve('app.model.serviceInstance.user');
this.routesModel = modelManager.retrieve('cloud-foundry.model.route');
this.id = $stateParams.guid;
this.cnsiGuid = $stateParams.cnsiGuid;
this.addRoutesService = addRoutesService;
this.confirmDialog = confirmDialog;
this.userCnsiModel.list();

var that = this;
this.routesActionMenu = [
{
name: gettext('Unmap from App'),
execute: function (route) {
that.unmapRoute(route);
}
},
{
name: gettext('Delete Route'),
execute: function (route) {
that.deleteRoute(route);
}
}
];
}

angular.extend(ApplicationSummaryController.prototype, {
Expand All @@ -51,7 +72,7 @@
* @returns {boolean} Indicating if supplies buildpack is a web link
* @public
**/
isWebLink: function(buildpack) {
isWebLink: function (buildpack) {
var url = angular.isDefined(buildpack) && buildpack !== null ? buildpack : '';
url = url.trim().toLowerCase();
return url.indexOf('http://') === 0 || url.indexOf('https://') === 0;
Expand All @@ -62,8 +83,58 @@
* @description Show Add a Route form
* @public
**/
showAddRouteForm: function() {
showAddRouteForm: function () {
this.addRoutesService.add();
},

/**
* @function unmapRoute
* @description Unmap route from application
* @param {object} route route metadata
*/
unmapRoute: function (route) {
var that = this;
this.confirmDialog({
title: gettext('Unmap Route from Application'),
description: gettext('Are you sure you want to unmap ') + this.getRouteId(route) + '?',
buttonText: {
yes: gettext('Delete'),
no: gettext('Cancel')
},
callback: function () {
that.routesModel.removeAppFromRoute(that.cnsiGuid, route.guid, that.id);
}
});
},

/**
* @function deleteRoute
* @description Unmap and delete route
* @param {object} route route metadata
*/
deleteRoute: function (route) {
var that = this;
this.confirmDialog({
title: gettext('Delete Route'),
description: gettext('Are you sure you want to delete ') + this.getRouteId(route) + '?',
buttonText: {
yes: gettext('Delete'),
no: gettext('Cancel')
},
callback: function () {
that.routesModel.deleteRoute(that.cnsiGuid, route.guid);
}
});
},

/**
* @function getRouteId
* @description tracking function for routes
* @param {object} route route metadata
* @returns {string} route ID
*/
getRouteId: function (route) {
return route.host + '.' + route.domain.name + route.path;
}
});

Expand Down

0 comments on commit 876f06e

Please sign in to comment.