From b4fca91b4b332946b94ce9dffcf0566474972c66 Mon Sep 17 00:00:00 2001 From: Julien Bramary Date: Fri, 8 Jul 2016 15:47:16 +0100 Subject: [PATCH 01/14] TEAMFOUR-698 WIP --- src/app/api/account/account.api.js | 15 +- src/app/app.module.js | 3 +- src/app/model/account/account.model.js | 3 +- src/app/model/navigation/navigation.model.js | 31 ++-- src/app/utils/utils.module.js | 13 ++ src/app/utils/utils.service.js | 40 +++++ .../cluster/detail/cluster-detail.html | 13 +- .../cluster/detail/cluster-detail.module.js | 26 +++ .../organization-tile.directive.js | 57 +++++++ .../organization-tile/organization-tile.html | 16 ++ .../organization-tile/organization-tile.scss | 23 +++ .../tiles/cluster-tile/cluster-tile.scss | 2 +- src/app/view/endpoints/endpoints.module.js | 2 +- .../api/hcf/OrganizationQuotaDefinitions.js | 15 +- .../cloud-foundry/api/hcf/Organizations.js | 109 +++++++----- src/plugins/cloud-foundry/api/hcf/Users.js | 81 ++++++--- .../cloud-foundry/cloud-foundry.module.js | 2 +- .../model/organization/organization.model.js | 160 ++++++++++++++---- .../log-stream/log-stream.module.js | 4 +- 19 files changed, 489 insertions(+), 126 deletions(-) create mode 100644 src/app/utils/utils.module.js create mode 100644 src/app/utils/utils.service.js create mode 100644 src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.directive.js create mode 100644 src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.html create mode 100644 src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.scss diff --git a/src/app/api/account/account.api.js b/src/app/api/account/account.api.js index 6dab31d8e1..2a164cbb0c 100644 --- a/src/app/api/account/account.api.js +++ b/src/app/api/account/account.api.js @@ -42,6 +42,7 @@ this.$httpParamSerializer = $httpParamSerializer; this.$q = $q; this.$cookies = $cookies; + this.sessionName = 'stackato-console-session'; } angular.extend(AccountApi.prototype, { @@ -83,13 +84,19 @@ * @public */ verifySession: function () { - if (this.$cookies.get('portal-session')) { + if (this.$cookies.get(this.sessionName)) { return this.$http.get('/pp/v1/auth/session/verify'); } - return this.$q(function (resolve, reject) { - reject({}); - }); + return this.$q.reject(this.sessionName + ' cookie missing!'); + }, + + userInfo: function () { + if (this.$cookies.get(this.sessionName)) { + return this.$http.get('/pp/v1/userinfo'); + } + return this.$q.reject(this.sessionName + ' cookie missing!'); } + }); })(); diff --git a/src/app/app.module.js b/src/app/app.module.js index 7339e0cb74..82fceffaab 100644 --- a/src/app/app.module.js +++ b/src/app/app.module.js @@ -10,7 +10,8 @@ 'app.api', 'app.event', 'app.model', - 'app.view' + 'app.view', + 'app.utils' ]) .constant('app.basePath', 'app/') .run(setTranslationLanguage); diff --git a/src/app/model/account/account.model.js b/src/app/model/account/account.model.js index 518416c3f0..f87f0c550d 100644 --- a/src/app/model/account/account.model.js +++ b/src/app/model/account/account.model.js @@ -155,7 +155,8 @@ * @private */ onLoggedOut: function () { - this.$cookies.remove('portal-session'); + var sessionName = this.apiManager.retrieve('app.api.account').sessionName; + this.$cookies.remove(sessionName); this.loggedIn = false; delete this.data; } diff --git a/src/app/model/navigation/navigation.model.js b/src/app/model/navigation/navigation.model.js index 1a6f98d0f2..d9dd971d58 100644 --- a/src/app/model/navigation/navigation.model.js +++ b/src/app/model/navigation/navigation.model.js @@ -15,15 +15,16 @@ 'app.model.modelManager', 'app.event.eventService', '$state', - '$rootScope' + '$rootScope', + '$log' ]; - function registerModel(modelManager, eventService, $state, $rootScope) { + function registerModel(modelManager, eventService, $state, $rootScope, $log) { /** * Register 'app.model.navigation' with the model manager service. * This model hosts the application's navigation tree. */ - modelManager.register('app.model.navigation', new NavigationModel(eventService, $state, $rootScope)); + modelManager.register('app.model.navigation', new NavigationModel(eventService, $state, $rootScope, $log)); } /** @@ -38,11 +39,11 @@ * @property {object} $state - ui-router $state service * @property {app.model.navigation} menu - the navigation model */ - function NavigationModel(eventService, $state, $rootScope) { + function NavigationModel(eventService, $state, $rootScope, $log) { var that = this; this.eventService = eventService; this.$state = $state; - this.menu = new Menu(); + this.menu = new Menu($log); this.eventService.$on(this.eventService.events.LOGIN, function () { that.onLogin(); }); @@ -111,8 +112,9 @@ * @name app.model.navigation.Menu * @property {string} currentState - current ui-router state */ - function Menu() { + function Menu($log) { this.currentState = null; + this.$log = $log; } // Using an array as the prototype @@ -128,13 +130,13 @@ * @param {string} href - the href / ng-router state we go to when clicking the entry. * e.g. cf.applications.list.gallery-view * @param {string} text - the displayed text of the menu item - * @param {string} icon - the icon of the menu item + * @param {number=} pos - optional position in the menu to insert at + * @param {string=} icon - the icon of the menu item * @param {string=} baseState - optional href / ng-router top-level base state e.g. cf.applications or cf.workspaces * (defaults to name) - * @param {number} pos - optional position in the menu to insert at * @returns {app.model.navigation.Menu} The navigation's Menu object */ - addMenuItem: function (name, href, text, icon, baseState, pos) { + addMenuItem: function (name, href, text, pos, icon, baseState) { var item = { name: name, href: href, @@ -145,7 +147,16 @@ items: new Menu() // sub-menu }; if (angular.isNumber(pos)) { - this.splice(pos, 0, item); + // Fill in the array to have the required number of items + // This allows out of order addMenuItem calls to work as expected + while (this.length <= pos) { + this.push(null); + } + if (this[pos] !== null) { + this.$log.error('addMenuItem: items named ' + "'" + item.name + "' and '" + this[pos].name + + "' have the same position '" + pos + "'"); + } + this.splice(pos, 1, item); } else { this.push(item); } diff --git a/src/app/utils/utils.module.js b/src/app/utils/utils.module.js new file mode 100644 index 0000000000..834154c288 --- /dev/null +++ b/src/app/utils/utils.module.js @@ -0,0 +1,13 @@ +(function () { + 'use strict'; + + /** + * @namespace app.utils + * @memberof app + * @name utils + * @description Various utils such as string manipulations and size conversions + */ + angular + .module('app.utils', []); + +})(); diff --git a/src/app/utils/utils.service.js b/src/app/utils/utils.service.js new file mode 100644 index 0000000000..8c388feb23 --- /dev/null +++ b/src/app/utils/utils.service.js @@ -0,0 +1,40 @@ +(function () { + 'use strict'; + + angular + .module('app.utils') + .factory('app.utils.utilsService', utilsServiceFactory); + + utilsServiceFactory.$inject = [ + ]; + + /** + * @namespace app.utils.utilsService + * @memberof app.utils + * @name utilsService + * @description Various utility functions + * @returns {object} the utils service + */ + function utilsServiceFactory() { + return { + mbToHumanSize: mbToHumanSize + }; + + function mbToHumanSize(sizeMb) { + if (angular.isUndefined(sizeMb)) { + return ''; + } + if (sizeMb === -1) { + return '∞'; + } + if (sizeMb > 1048576) { + return (sizeMb / 1048576).toFixed(1) + ' TB'; + } + if (sizeMb > 1024) { + return (sizeMb / 1024).toFixed(1) + ' GB'; + } + return sizeMb + ' MB'; + } + } + +})(); diff --git a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.html b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.html index 2a002a9e85..94caac3acf 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.html +++ b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.html @@ -1 +1,12 @@ -

Cluster Summary: {{ clusterController.guid }}

+

{{ clusterController.clusterName }}

+
+ +
+
+
An error occurred retrieving organizations
+
+
+
+ +
+
diff --git a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.module.js b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.module.js index 52c0ed8969..83c67f88c0 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.module.js +++ b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.module.js @@ -24,7 +24,33 @@ ]; function ClusterDetailController(modelManager, $stateParams) { + var that = this; this.guid = $stateParams.guid; + + this.clusterName = 'TODO: get cluster name'; + + this.orgs = undefined; + this.organizationModel = modelManager.retrieve('cloud-foundry.model.organization'); + this.organizationModel.listAllOrganizations(this.guid, {}).then(function (orgs) { + that.organizations = []; + console.log('Received list of Orgs: ', orgs); + _.forEach(orgs, function (org) { + var promiseForDetails = that.organizationModel.getOrganizationDetails(that.guid, org).then(function (orgDetails) { + that.organizations.push(orgDetails); + console.log('that.organizations', JSON.stringify(that.organizations)); + }); + + }); + }); + + this.usersModel = modelManager.retrieve('cloud-foundry.model.users'); + this.usersModel.listAllUsers(this.guid, {}).then(function (res) { + console.log('Received list of Users: ', res); + }); + + this.foo = function () { + console.log('FOO!'); + }; } angular.extend(ClusterDetailController.prototype, {}); diff --git a/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.directive.js b/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.directive.js new file mode 100644 index 0000000000..b12f79c2c0 --- /dev/null +++ b/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.directive.js @@ -0,0 +1,57 @@ +(function () { + 'use strict'; + + angular + .module('app.view.endpoints') + .directive('organizationTile', OrganizationTile); + + OrganizationTile.$inject = []; + + function OrganizationTile() { + return { + bindToController: { + organization: '=' + }, + controller: OrganizationTileController, + controllerAs: 'organizationTileCtrl', + scope: {}, + templateUrl: 'app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.html' + }; + } + + OrganizationTileController.$inject = [ + '$state' + ]; + + /** + * @name OrganizationTileController + * @constructor + * @param {object} $state - the angular $state service + * @property {Array} actions - collection of relevant actions that can be executed against cluster + */ + function OrganizationTileController($state) { + this.$state = $state; + this.actions = []; + this.setActions(); + + console.log('organizationTileCtrl.organization.name', JSON.stringify(this.organization)); + } + + angular.extend(OrganizationTileController.prototype, { + + setActions: function () { + this.actions.push({ + name: 'Test', + execute: function () { + console.log('Test'); + } + }); + }, + + summary: function () { + console.log('This is', this); + } + + }); + +})(); diff --git a/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.html b/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.html new file mode 100644 index 0000000000..fc1bcebe41 --- /dev/null +++ b/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.html @@ -0,0 +1,16 @@ + + +
+
total apps
+
{{organizationTileCtrl.organization.total_apps}}
+
instances
+
{{organizationTileCtrl.organization.instances}}
+
memory utilization
+
{{ organizationTileCtrl.organization.memory_utilization }}
+
+
diff --git a/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.scss b/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.scss new file mode 100644 index 0000000000..81a07121e5 --- /dev/null +++ b/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.scss @@ -0,0 +1,23 @@ +.organization-tile { + + &.unlink { + // Override some extreme oddness in gallery-card with undefined on-card-click + .panel-heading.linked, .panel-body.linked { + cursor: default; + } + } + + .gallery-card-title { + text-transform: uppercase; + } + + .dl-horizontal { + dd { + font-weight: 500; + } + + dd:first-of-type { + text-transform: lowercase; + } + } +} diff --git a/src/app/view/endpoints/clusters/tiles/cluster-tile/cluster-tile.scss b/src/app/view/endpoints/clusters/tiles/cluster-tile/cluster-tile.scss index c0e1f3b9b0..edb9f6044a 100644 --- a/src/app/view/endpoints/clusters/tiles/cluster-tile/cluster-tile.scss +++ b/src/app/view/endpoints/clusters/tiles/cluster-tile/cluster-tile.scss @@ -1,7 +1,7 @@ .cluster-tile { &.unlink { - // Override some extreme oddness in gallary-card with undefined on-card-click + // Override some extreme oddness in gallery-card with undefined on-card-click .panel-heading.linked, .panel-body.linked { cursor: default; } diff --git a/src/app/view/endpoints/endpoints.module.js b/src/app/view/endpoints/endpoints.module.js index 728557b2fb..022c258b50 100644 --- a/src/app/view/endpoints/endpoints.module.js +++ b/src/app/view/endpoints/endpoints.module.js @@ -48,7 +48,7 @@ onLoggedIn: function() { var menu = this.modelManager.retrieve('app.model.navigation').menu; - menu.addMenuItem('endpoints', 'endpoint.dashboard', gettext('Endpoints')); + menu.addMenuItem('endpoints', 'endpoint.dashboard', gettext('Endpoints'), 1); } }); diff --git a/src/plugins/cloud-foundry/api/hcf/OrganizationQuotaDefinitions.js b/src/plugins/cloud-foundry/api/hcf/OrganizationQuotaDefinitions.js index 74c1d16d8c..cf7a62860b 100644 --- a/src/plugins/cloud-foundry/api/hcf/OrganizationQuotaDefinitions.js +++ b/src/plugins/cloud-foundry/api/hcf/OrganizationQuotaDefinitions.js @@ -35,7 +35,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -51,7 +52,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -67,7 +69,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -83,7 +86,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -100,7 +104,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/Organizations.js b/src/plugins/cloud-foundry/api/hcf/Organizations.js index 12c3b46167..0cdd5d2c86 100644 --- a/src/plugins/cloud-foundry/api/hcf/Organizations.js +++ b/src/plugins/cloud-foundry/api/hcf/Organizations.js @@ -46,7 +46,7 @@ AssociateAuditorWithOrganizationByUsername: function (guid, value, params, httpConfigOptions) { var config = {}; config.params = params; - config.url = '/pp/v1/proxyv2/organizations/' + guid + '/auditors'; + config.url = '/pp/v1/proxy/v2/organizations/' + guid + '/auditors'; config.method = 'PUT'; config.data = value; @@ -79,7 +79,7 @@ AssociateBillingManagerWithOrganizationByUsername: function (guid, value, params, httpConfigOptions) { var config = {}; config.params = params; - config.url = '/pp/v1/proxyv2/organizations/' + guid + '/billing_managers'; + config.url = '/pp/v1/proxy/v2/organizations/' + guid + '/billing_managers'; config.method = 'PUT'; config.data = value; @@ -100,7 +100,8 @@ config.method = 'PUT'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -112,7 +113,7 @@ AssociateManagerWithOrganizationByUsername: function (guid, value, params, httpConfigOptions) { var config = {}; config.params = params; - config.url = '/pp/v1/proxyv2/organizations/' + guid + '/managers'; + config.url = '/pp/v1/proxy/v2/organizations/' + guid + '/managers'; config.method = 'PUT'; config.data = value; @@ -133,7 +134,8 @@ config.method = 'PUT'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -149,7 +151,8 @@ config.method = 'PUT'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -161,12 +164,13 @@ AssociateUserWithOrganizationByUsername: function (guid, value, params, httpConfigOptions) { var config = {}; config.params = params; - config.url = '/pp/v1/proxyv2/organizations/' + guid + '/users'; + config.url = '/pp/v1/proxy/v2/organizations/' + guid + '/users'; config.method = 'PUT'; config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -183,7 +187,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -199,7 +204,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -215,7 +221,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -231,7 +238,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -247,7 +255,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -263,7 +272,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -279,7 +289,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -295,7 +306,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -311,7 +323,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -327,7 +340,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -343,7 +357,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -359,7 +374,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -375,7 +391,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -391,7 +408,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -403,12 +421,13 @@ RemoveAuditorWithOrganizationByUsername: function (guid, value, params, httpConfigOptions) { var config = {}; config.params = params; - config.url = '/pp/v1/proxyv2/organizations/' + guid + '/auditors'; + config.url = '/pp/v1/proxy/v2/organizations/' + guid + '/auditors'; config.method = 'DELETE'; config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -424,7 +443,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -436,12 +456,13 @@ RemoveBillingManagerWithOrganizationByUsername: function (guid, value, params, httpConfigOptions) { var config = {}; config.params = params; - config.url = '/pp/v1/proxyv2/organizations/' + guid + '/billing_managers'; + config.url = '/pp/v1/proxy/v2/organizations/' + guid + '/billing_managers'; config.method = 'DELETE'; config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -457,7 +478,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -469,12 +491,13 @@ RemoveManagerWithOrganizationByUsername: function (guid, value, params, httpConfigOptions) { var config = {}; config.params = params; - config.url = '/pp/v1/proxyv2/organizations/' + guid + '/managers'; + config.url = '/pp/v1/proxy/v2/organizations/' + guid + '/managers'; config.method = 'DELETE'; config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -490,7 +513,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -506,7 +530,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -518,12 +543,13 @@ RemoveUserWithOrganizationByUsername: function (guid, value, params, httpConfigOptions) { var config = {}; config.params = params; - config.url = '/pp/v1/proxyv2/organizations/' + guid + '/users'; + config.url = '/pp/v1/proxy/v2/organizations/' + guid + '/users'; config.method = 'DELETE'; config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -539,7 +565,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -557,7 +584,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -573,7 +601,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -589,7 +618,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -606,7 +636,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/Users.js b/src/plugins/cloud-foundry/api/hcf/Users.js index 0574916bec..d30d06b6d4 100644 --- a/src/plugins/cloud-foundry/api/hcf/Users.js +++ b/src/plugins/cloud-foundry/api/hcf/Users.js @@ -34,7 +34,8 @@ config.method = 'PUT'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -50,7 +51,8 @@ config.method = 'PUT'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -66,7 +68,8 @@ config.method = 'PUT'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -82,7 +85,8 @@ config.method = 'PUT'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -98,7 +102,8 @@ config.method = 'PUT'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -114,7 +119,8 @@ config.method = 'PUT'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -130,7 +136,8 @@ config.method = 'PUT'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -147,7 +154,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -163,7 +171,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -179,7 +188,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -195,7 +205,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -211,7 +222,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -227,7 +239,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -243,7 +256,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -259,7 +273,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -275,7 +290,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -291,7 +307,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -307,7 +324,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -323,7 +341,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -339,7 +358,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -355,7 +375,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -371,7 +392,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -387,7 +409,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -403,7 +426,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -419,7 +443,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -435,7 +460,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -452,7 +478,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/cloud-foundry.module.js b/src/plugins/cloud-foundry/cloud-foundry.module.js index 7a45078d08..aae80e997c 100644 --- a/src/plugins/cloud-foundry/cloud-foundry.module.js +++ b/src/plugins/cloud-foundry/cloud-foundry.module.js @@ -56,7 +56,7 @@ registerNavigation: function () { var menu = this.modelManager.retrieve('app.model.navigation').menu; - menu.addMenuItem('cf.applications', 'cf.applications.list.gallery-view', gettext('Applications'), null, null, 0); + menu.addMenuItem('cf.applications', 'cf.applications.list.gallery-view', gettext('Applications'), 0); } }); diff --git a/src/plugins/cloud-foundry/model/organization/organization.model.js b/src/plugins/cloud-foundry/model/organization/organization.model.js index c537504b81..383a53f253 100644 --- a/src/plugins/cloud-foundry/model/organization/organization.model.js +++ b/src/plugins/cloud-foundry/model/organization/organization.model.js @@ -11,11 +11,13 @@ registerOrgModel.$inject = [ 'app.model.modelManager', - 'app.api.apiManager' + 'app.api.apiManager', + 'app.utils.utilsService', + '$q' ]; - function registerOrgModel(modelManager, apiManager) { - modelManager.register('cloud-foundry.model.organization', new Organization(apiManager)); + function registerOrgModel(modelManager, apiManager, utils, $q) { + modelManager.register('cloud-foundry.model.organization', new Organization(apiManager, utils, $q)); } /** @@ -25,51 +27,143 @@ * @property {app.api.apiManager} apiManager - the API manager * @class */ - function Organization(apiManager) { + function Organization(apiManager, utils, $q) { this.apiManager = apiManager; + this.$q = $q; + this.utils = utils; + + var passThroughHeader = { + 'x-cnap-passthrough': 'true' + }; + + this.makeHttpConfig = function (cnsiGuid) { + var headers = {'x-cnap-cnsi-list': cnsiGuid}; + angular.extend(headers, passThroughHeader); + return { + headers: headers + }; + }; } angular.extend(Organization.prototype, { - /** - * @function listAllOrganizations - * @memberof cloud-foundry.model.organization - * @description lists all organizations - * @param {string} cnsiGuid - The GUID of the cloud-foundry server. - * @param {object} params - optional parameters - * @returns {promise} A resolved/rejected promise - * @public - */ + /** + * @function listAllOrganizations + * @memberof cloud-foundry.model.organization + * @description lists all organizations + * @param {string} cnsiGuid - The GUID of the cloud-foundry server. + * @param {object} params - optional parameters + * @returns {promise} A resolved/rejected promise + * @public + */ listAllOrganizations: function (cnsiGuid, params) { - var httpConfig = { - headers: { 'x-cnap-cnsi-list': cnsiGuid } - }; return this.apiManager.retrieve('cloud-foundry.api.Organizations') - .ListAllOrganizations(params, httpConfig) + .ListAllOrganizations(params, this.makeHttpConfig(cnsiGuid)) .then(function (response) { - return response.data[cnsiGuid].resources; + return response.data.resources; }); }, - /** - * @function listAllSpacesForOrganization - * @memberof cloud-foundry.model.organization - * @description lists all spaces for organization - * @param {string} cnsiGuid - The GUID of the cloud-foundry server. - * @param {string} orgGuid - organization id - * @param {object} params - optional parameters - * @returns {promise} A resolved/rejected promise - * @public - */ + /** + * @function listAllSpacesForOrganization + * @memberof cloud-foundry.model.organization + * @description lists all spaces for organization + * @param {string} cnsiGuid - The GUID of the cloud-foundry server. + * @param {string} orgGuid - organization id + * @param {object} params - optional parameters + * @returns {promise} A resolved/rejected promise + * @public + */ listAllSpacesForOrganization: function (cnsiGuid, orgGuid, params) { - var httpConfig = { - headers: { 'x-cnap-cnsi-list': cnsiGuid } - }; return this.apiManager.retrieve('cloud-foundry.api.Organizations') - .ListAllSpacesForOrganization(orgGuid, params, httpConfig) + .ListAllSpacesForOrganization(orgGuid, params, this.makeHttpConfig(cnsiGuid)) .then(function (response) { - return response.data[cnsiGuid].resources; + return response.data.resources; + }); + }, + + getOrganizationDetails: function (cnsiGuid, org, params) { + + var that = this; + var httpConfig = this.makeHttpConfig(cnsiGuid); + var orgGuid = org.metadata.guid; + var orgQuotaGuid = org.entity.quota_definition_guid; + + var spaceApi = that.apiManager.retrieve('cloud-foundry.api.Spaces'); + var orgsApi = that.apiManager.retrieve('cloud-foundry.api.Organizations'); + var orgsQuotaApi = that.apiManager.retrieve('cloud-foundry.api.OrganizationQuotaDefinitions'); + + var usedMemP = orgsApi.RetrievingOrganizationMemoryUsage(orgGuid, params, httpConfig); + var instancesP = orgsApi.RetrievingOrganizationInstanceUsage(orgGuid, params, httpConfig); + var quotaP = orgsQuotaApi.RetrieveOrganizationQuotaDefinition(orgQuotaGuid, params, httpConfig); + var rolesP = orgsApi.RetrievingRolesOfAllUsersInOrganization(orgGuid, params, httpConfig).then(function (res) { + console.log('RetrievingRolesOfAllUsersInOrganization', res); + }); + + var userInfoP = that.apiManager.retrieve('app.api.account').userInfo().then(function (res) { + console.log('userInfo', res); + + }, function (error) { + console.log('userInfo error', error); + }); + + + var appCountsP = this.apiManager.retrieve('cloud-foundry.api.Organizations') + .ListAllSpacesForOrganization(orgGuid, params, httpConfig).then(function (res) { + var spaces = res.data.resources; + var promises = []; + _.forEach(spaces, function (space) { + console.log('a space: ', space); + var promise = spaceApi.ListAllAppsForSpace(space.metadata.guid, params, httpConfig).then(function (res2) { + console.log('All apps: ', res2); + return res2.data.resources.length; + }); + promises.push(promise); + }); + return that.$q.all(promises).then(function (appCounts) { + var total = 0; + _.forEach(appCounts, function (count) { + total += count; + }); + return total; + }); }); + + return this.$q.all({ + memory: usedMemP, + quota: quotaP, + instances: instancesP, + apps: appCountsP + }).then(function (vals) { + var details = {}; + + // Set memory utilisation + var usedMem = vals.memory.data.memory_usage_in_mb; + var memQuota = vals.quota.data.entity.memory_limit; + + var usedMemHuman = that.utils.mbToHumanSize(usedMem); + var memQuotaHuman = that.utils.mbToHumanSize(memQuota); + + // var memQuota = that.utils.mbToHumanSize(-1); // test infinite quota + details.memory_utilization_percentage = (100 * usedMem / memQuota).toFixed(1); + details.memory_utilization = usedMemHuman + ' / ' + memQuotaHuman + ' [' + details.memory_utilization_percentage + '%]'; + + // Set instances utilisation + var instancesUsed = vals.instances.data.instance_usage; + var appInstanceQuota = vals.quota.data.entity.app_instance_limit; + if (appInstanceQuota === -1) { + appInstanceQuota = '∞'; + } + details.instances = instancesUsed + ' / ' + appInstanceQuota; + + // Set total apps count + details.total_apps = vals.apps; + + details.name = org.entity.name; + + return details; + }); } + }); })(); diff --git a/src/plugins/cloud-foundry/view/applications/application/log-stream/log-stream.module.js b/src/plugins/cloud-foundry/view/applications/application/log-stream/log-stream.module.js index dc23b9508d..3305ecd0da 100644 --- a/src/plugins/cloud-foundry/view/applications/application/log-stream/log-stream.module.js +++ b/src/plugins/cloud-foundry/view/applications/application/log-stream/log-stream.module.js @@ -60,10 +60,10 @@ var colour; switch (messageObj.source_type) { case 'APP': - colour = 'green'; + colour = 'red'; break; default: - colour = 'red'; + colour = 'yellow'; } var messageSource = coloredLog('[' + messageObj.source_type + '.' + messageObj.source_instance + ']', colour); From cebb3bb091a10b3fcb779b3ebeb1cddc324be91e Mon Sep 17 00:00:00 2001 From: Julien Bramary Date: Mon, 11 Jul 2016 13:21:53 +0100 Subject: [PATCH 02/14] Service for userinfo --- src/app/api/user-info.service.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/app/api/user-info.service.js diff --git a/src/app/api/user-info.service.js b/src/app/api/user-info.service.js new file mode 100644 index 0000000000..00fa55e394 --- /dev/null +++ b/src/app/api/user-info.service.js @@ -0,0 +1,30 @@ +(function () { + 'use strict'; + + /** + * @description user info service + */ + angular + .module('app') + .factory('userInfoService', UserInfoService); + + UserInfoService.$inject = [ + '$q', + '$cookies', + '$http', + 'app.api.apiManager' + ]; + + function UserInfoService($q, $cookies, $http, apiManager) { + var sessionName = apiManager.retrieve('app.api.account').sessionName; + return { + userInfo: function () { + if ($cookies.get(sessionName)) { + return $http.get('/pp/v1/userinfo'); + } + return $q.reject(sessionName + ' cookie missing!'); + } + + }; + } +})(); From 7f18bdf6da2b803ed8dba4b95a39774048ffc84f Mon Sep 17 00:00:00 2001 From: Julien Bramary Date: Mon, 11 Jul 2016 17:22:06 +0100 Subject: [PATCH 03/14] WIP --- src/app/api/account/account.api.js | 7 --- .../detail/cluster-detail-organizations.html | 13 +++++ .../cluster/detail/cluster-detail-users.html | 13 +++++ .../cluster/detail/cluster-detail.html | 46 ++++++++++++---- .../cluster/detail/cluster-detail.module.js | 55 ++++++++++++------- .../cluster-detail.organizations.module.js | 51 +++++++++++++++++ .../cluster/detail/cluster-detail.scss | 42 ++++++++++++++ .../detail/cluster-detail.users.module.js | 37 +++++++++++++ .../organization-tile.directive.js | 16 ++++-- .../organization-tile/organization-tile.html | 3 + .../organization-tile/organization-tile.scss | 1 + src/app/view/endpoints/clusters/clusters.scss | 3 +- .../cluster-tile/cluster-tile.directive.js | 2 +- .../clusters/tiles/cluster-tiles.scss | 12 ++-- .../cloud-foundry/cloud-foundry.module.js | 6 -- .../model/organization/organization.model.js | 43 ++++++++++----- .../applications/application/application.scss | 1 + 17 files changed, 281 insertions(+), 70 deletions(-) create mode 100644 src/app/view/endpoints/clusters/cluster/detail/cluster-detail-organizations.html create mode 100644 src/app/view/endpoints/clusters/cluster/detail/cluster-detail-users.html create mode 100644 src/app/view/endpoints/clusters/cluster/detail/cluster-detail.organizations.module.js create mode 100644 src/app/view/endpoints/clusters/cluster/detail/cluster-detail.scss create mode 100644 src/app/view/endpoints/clusters/cluster/detail/cluster-detail.users.module.js diff --git a/src/app/api/account/account.api.js b/src/app/api/account/account.api.js index 2a164cbb0c..c2c7f76ac5 100644 --- a/src/app/api/account/account.api.js +++ b/src/app/api/account/account.api.js @@ -88,13 +88,6 @@ return this.$http.get('/pp/v1/auth/session/verify'); } return this.$q.reject(this.sessionName + ' cookie missing!'); - }, - - userInfo: function () { - if (this.$cookies.get(this.sessionName)) { - return this.$http.get('/pp/v1/userinfo'); - } - return this.$q.reject(this.sessionName + ' cookie missing!'); } }); diff --git a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail-organizations.html b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail-organizations.html new file mode 100644 index 0000000000..c8650db3d7 --- /dev/null +++ b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail-organizations.html @@ -0,0 +1,13 @@ +
+ +
+
+
An error occurred retrieving organizations
+
+
+
+ +
+
+ + diff --git a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail-users.html b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail-users.html new file mode 100644 index 0000000000..b5afceffeb --- /dev/null +++ b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail-users.html @@ -0,0 +1,13 @@ +
+ +
+
+
An error occurred retrieving organizations
+
+
+
+ +
+
+ + diff --git a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.html b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.html index 94caac3acf..33f0a7bb50 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.html +++ b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.html @@ -1,12 +1,38 @@ -

{{ clusterController.clusterName }}

-
- -
-
-
An error occurred retrieving organizations
-
-
-
- +
+

{{ clusterController.cluster.name }}

+ + +
+ Placeholder for Cluster Details
+ CF Endpoint URL: + {{ clusterController.cluster.api_endpoint.Scheme }}://{{ clusterController.cluster.api_endpoint.Host }}
+ + + +
+ + + + diff --git a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.module.js b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.module.js index 83c67f88c0..d7996ef012 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.module.js +++ b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.module.js @@ -2,7 +2,10 @@ 'use strict'; angular - .module('app.view.endpoints.clusters.cluster.detail', []) + .module('app.view.endpoints.clusters.cluster.detail', [ + 'app.view.endpoints.clusters.cluster.detail.organizations', + 'app.view.endpoints.clusters.cluster.detail.users' + ]) .config(registerRoute); registerRoute.$inject = [ @@ -10,8 +13,10 @@ ]; function registerRoute($stateProvider) { + console.log('Registering endpoint.clusters.cluster.detail'); $stateProvider.state('endpoint.clusters.cluster.detail', { url: '', + abstract: true, templateUrl: 'app/view/endpoints/clusters/cluster/detail/cluster-detail.html', controller: ClusterDetailController, controllerAs: 'clusterController' @@ -27,30 +32,38 @@ var that = this; this.guid = $stateParams.guid; - this.clusterName = 'TODO: get cluster name'; - - this.orgs = undefined; - this.organizationModel = modelManager.retrieve('cloud-foundry.model.organization'); - this.organizationModel.listAllOrganizations(this.guid, {}).then(function (orgs) { - that.organizations = []; - console.log('Received list of Orgs: ', orgs); - _.forEach(orgs, function (org) { - var promiseForDetails = that.organizationModel.getOrganizationDetails(that.guid, org).then(function (orgDetails) { - that.organizations.push(orgDetails); - console.log('that.organizations', JSON.stringify(that.organizations)); - }); + // Get the cluster info + this.cluster = { + name: '', + api_endpoint: '' + }; - }); + this.cnsiModel = modelManager.retrieve('app.model.serviceInstance.user'); + this.cnsiModel.list().then(function (registeredInstances) { + that.cluster = registeredInstances[that.guid]; }); - this.usersModel = modelManager.retrieve('cloud-foundry.model.users'); - this.usersModel.listAllUsers(this.guid, {}).then(function (res) { - console.log('Received list of Users: ', res); - }); + this.clusterActions = [ + { + name: gettext('Create Organization'), + execute: function () { + }, + icon: 'helion-icon-lg helion-icon helion-icon-Tree' + }, + { + name: gettext('Create Space'), + execute: function () { + }, + icon: 'helion-icon-lg helion-icon helion-icon-Tree' + }, + { + name: gettext('Assign User(s)'), + execute: function () { + }, + icon: 'helion-icon-lg helion-icon helion-icon-Add_user' + } + ]; - this.foo = function () { - console.log('FOO!'); - }; } angular.extend(ClusterDetailController.prototype, {}); diff --git a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.organizations.module.js b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.organizations.module.js new file mode 100644 index 0000000000..6128cd869b --- /dev/null +++ b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.organizations.module.js @@ -0,0 +1,51 @@ +(function () { + 'use strict'; + + angular + .module('app.view.endpoints.clusters.cluster.detail.organizations', []) + .config(registerRoute); + + registerRoute.$inject = [ + '$stateProvider' + ]; + + function registerRoute($stateProvider) { + console.log('Registering route endpoint.clusters.cluster.detail.organizations'); + $stateProvider.state('endpoint.clusters.cluster.detail.organizations', { + url: '/organizations', + templateUrl: 'app/view/endpoints/clusters/cluster/detail/cluster-detail-organizations.html', + controller: ClusterOrganizationsController, + controllerAs: 'clusterOrganizationsController' + }); + } + + ClusterOrganizationsController.$inject = [ + 'app.model.modelManager', + '$stateParams' + ]; + + function ClusterOrganizationsController(modelManager, $stateParams) { + var that = this; + this.guid = $stateParams.guid; + + this.orgs = undefined; + this.organizationModel = modelManager.retrieve('cloud-foundry.model.organization'); + this.organizationModel.listAllOrganizations(this.guid, {}).then(function (orgs) { + that.organizations = []; + // console.log('Received list of Orgs: ', orgs); + _.forEach(orgs, function (org) { + var promiseForDetails = that.organizationModel.getOrganizationDetails(that.guid, org).then(function (orgDetails) { + that.organizations.push(orgDetails); + // console.log('that.organizations', JSON.stringify(that.organizations)); + }); + + }); + }); + + this.foo = function () { + console.log('FOO!'); + }; + } + + angular.extend(ClusterOrganizationsController.prototype, {}); +})(); diff --git a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.scss b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.scss new file mode 100644 index 0000000000..0bd4dedabe --- /dev/null +++ b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.scss @@ -0,0 +1,42 @@ +@import 'organization-tile/organization-tile'; + +.cluster-detail { + .cluster-detail-panel { + margin-bottom: 15px; + width: 100%; + height: 200px; + background-color: #ccc; + } + .application-nav { + margin-bottom: 15px; + } + + .organizations-card-container { + + + + .organizations-card { + min-height: 250px; + padding-left: 0; + } + + $organizations-card-max-width: 400px; + $organizations-card-layout-steps: 4; + + @for $i from 1 through $organizations-card-layout-steps { + @media (min-width: $i * $organizations-card-max-width) { + .organizations-card.col-md-4.col-sm-1 { + width: percentage(1/$i); + } + } + } + @for $i from $organizations-card-layout-steps through 1 { + @media (min-width: $i * $organizations-card-max-width) and (max-width: $organizations-card-max-width + $i * $organizations-card-max-width) { + :nth-child(#{$i}n) { + padding-right: 0 + } + } + } + } + +} diff --git a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.users.module.js b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.users.module.js new file mode 100644 index 0000000000..b530e3b07c --- /dev/null +++ b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.users.module.js @@ -0,0 +1,37 @@ +(function () { + 'use strict'; + + angular + .module('app.view.endpoints.clusters.cluster.detail.users', []) + .config(registerRoute); + + registerRoute.$inject = [ + '$stateProvider' + ]; + + function registerRoute($stateProvider) { + console.log('Registering route endpoint.clusters.cluster.detail.users'); + $stateProvider.state('endpoint.clusters.cluster.detail.users', { + url: '/users', + templateUrl: 'app/view/endpoints/clusters/cluster/detail/cluster-detail-users.html', + controller: ClusterUsersController, + controllerAs: 'clusterUsersController' + }); + } + + ClusterUsersController.$inject = [ + 'app.model.modelManager', + '$stateParams' + ]; + + function ClusterUsersController(modelManager, $stateParams) { + var that = this; + this.guid = $stateParams.guid; + this.usersModel = modelManager.retrieve('cloud-foundry.model.users'); + this.usersModel.listAllUsers(this.guid, {}).then(function (res) { + console.log('Received list of Users: ', res); + }); + } + + angular.extend(ClusterUsersController.prototype, {}); +})(); diff --git a/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.directive.js b/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.directive.js index b12f79c2c0..5fcbf73719 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.directive.js +++ b/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.directive.js @@ -33,23 +33,29 @@ this.$state = $state; this.actions = []; this.setActions(); - - console.log('organizationTileCtrl.organization.name', JSON.stringify(this.organization)); } angular.extend(OrganizationTileController.prototype, { setActions: function () { this.actions.push({ - name: 'Test', + name: 'Edit Organization', + execute: function () { + } + }); + this.actions.push({ + name: 'Delete Organization', + execute: function () { + } + }); + this.actions.push({ + name: 'Assign User(s)', execute: function () { - console.log('Test'); } }); }, summary: function () { - console.log('This is', this); } }); diff --git a/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.html b/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.html index fc1bcebe41..dbd97e3702 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.html +++ b/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.html @@ -12,5 +12,8 @@
{{organizationTileCtrl.organization.instances}}
memory utilization
{{ organizationTileCtrl.organization.memory_utilization }}
+ diff --git a/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.scss b/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.scss index 81a07121e5..0f3a90aaef 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.scss +++ b/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.scss @@ -14,6 +14,7 @@ .dl-horizontal { dd { font-weight: 500; + white-space: nowrap; } dd:first-of-type { diff --git a/src/app/view/endpoints/clusters/clusters.scss b/src/app/view/endpoints/clusters/clusters.scss index 35171e9140..63b60a3346 100644 --- a/src/app/view/endpoints/clusters/clusters.scss +++ b/src/app/view/endpoints/clusters/clusters.scss @@ -1 +1,2 @@ -@import 'tiles/cluster-tiles'; +@import 'tiles/cluster-tiles', + 'cluster/detail/cluster-detail'; diff --git a/src/app/view/endpoints/clusters/tiles/cluster-tile/cluster-tile.directive.js b/src/app/view/endpoints/clusters/tiles/cluster-tile/cluster-tile.directive.js index 3d4fa55964..1fef16f671 100644 --- a/src/app/view/endpoints/clusters/tiles/cluster-tile/cluster-tile.directive.js +++ b/src/app/view/endpoints/clusters/tiles/cluster-tile/cluster-tile.directive.js @@ -162,7 +162,7 @@ * @description Navigate to the cluster summary page for this cluster */ summary: function () { - this.$state.go('endpoint.clusters.cluster.detail', {guid: this.service.guid}); + this.$state.go('endpoint.clusters.cluster.detail.organizations', {guid: this.service.guid}); } }); diff --git a/src/app/view/endpoints/clusters/tiles/cluster-tiles.scss b/src/app/view/endpoints/clusters/tiles/cluster-tiles.scss index a153b1b858..e6957ec10e 100644 --- a/src/app/view/endpoints/clusters/tiles/cluster-tiles.scss +++ b/src/app/view/endpoints/clusters/tiles/cluster-tiles.scss @@ -18,12 +18,12 @@ } } -.flyout-content-thin { - .flyout-content { - width: 564px; - min-width: 564px; - max-width: 564px; + .flyout-content-thin { + .flyout-content { + width: 564px; + min-width: 564px; + max-width: 564px; + } } } -} diff --git a/src/plugins/cloud-foundry/cloud-foundry.module.js b/src/plugins/cloud-foundry/cloud-foundry.module.js index aae80e997c..dcda7fb7c7 100644 --- a/src/plugins/cloud-foundry/cloud-foundry.module.js +++ b/src/plugins/cloud-foundry/cloud-foundry.module.js @@ -42,12 +42,6 @@ // Only redirect from the login page: preserve ui-context when reloading/refreshing in nested views if (this.$location.path() === '') { this.eventService.$emit(this.eventService.events.REDIRECT, 'cf.applications.list.gallery-view'); - } else if (this.$state.current.name !== '') { - // If $location.path() is not empty and the state is set, ui-router won't reload for us - // We reload manually to trigger any $stateChangeSuccess logic - - // N.B we only reach this after pasting a deep URL in a new tab from a non-loggedIn state - this.$state.reload(); } }, diff --git a/src/plugins/cloud-foundry/model/organization/organization.model.js b/src/plugins/cloud-foundry/model/organization/organization.model.js index 383a53f253..2530940c83 100644 --- a/src/plugins/cloud-foundry/model/organization/organization.model.js +++ b/src/plugins/cloud-foundry/model/organization/organization.model.js @@ -13,11 +13,12 @@ 'app.model.modelManager', 'app.api.apiManager', 'app.utils.utilsService', + 'userInfoService', '$q' ]; - function registerOrgModel(modelManager, apiManager, utils, $q) { - modelManager.register('cloud-foundry.model.organization', new Organization(apiManager, utils, $q)); + function registerOrgModel(modelManager, apiManager, utils, userInfoService, $q) { + modelManager.register('cloud-foundry.model.organization', new Organization(apiManager, utils, userInfoService, $q)); } /** @@ -27,10 +28,11 @@ * @property {app.api.apiManager} apiManager - the API manager * @class */ - function Organization(apiManager, utils, $q) { + function Organization(apiManager, utils, userInfoService, $q) { this.apiManager = apiManager; this.$q = $q; this.utils = utils; + this.userInfoService = userInfoService; var passThroughHeader = { 'x-cnap-passthrough': 'true' @@ -95,15 +97,26 @@ var usedMemP = orgsApi.RetrievingOrganizationMemoryUsage(orgGuid, params, httpConfig); var instancesP = orgsApi.RetrievingOrganizationInstanceUsage(orgGuid, params, httpConfig); var quotaP = orgsQuotaApi.RetrieveOrganizationQuotaDefinition(orgQuotaGuid, params, httpConfig); - var rolesP = orgsApi.RetrievingRolesOfAllUsersInOrganization(orgGuid, params, httpConfig).then(function (res) { - console.log('RetrievingRolesOfAllUsersInOrganization', res); - }); - var userInfoP = that.apiManager.retrieve('app.api.account').userInfo().then(function (res) { - console.log('userInfo', res); + var rolesP = orgsApi.RetrievingRolesOfAllUsersInOrganization(orgGuid, params, httpConfig); + var userInfoP = that.userInfoService.userInfo(); + + that.$q.all({roles: rolesP, userInfo: userInfoP}).then(function(values) { + // console.log('Roles:', values.roles); + // console.log('userInfo:', values.userInfo); + // Find our user in the list of all OrgUsers + var userGuid; + for (var i = 0; i < values.userInfo.data.length; i++) { + var userPerms = values.userInfo.data[i]; + if (userPerms.type === 'hcf' && userPerms.cnsi_guid === cnsiGuid) { + userGuid = userPerms.user_guid; + break; + } + } + if (!userGuid) { + throw new Error('Failed to get HCF user GUID'); + } - }, function (error) { - console.log('userInfo error', error); }); @@ -112,9 +125,9 @@ var spaces = res.data.resources; var promises = []; _.forEach(spaces, function (space) { - console.log('a space: ', space); + // console.log('a space: ', space); var promise = spaceApi.ListAllAppsForSpace(space.metadata.guid, params, httpConfig).then(function (res2) { - console.log('All apps: ', res2); + // console.log('All apps: ', res2); return res2.data.resources.length; }); promises.push(promise); @@ -145,7 +158,11 @@ // var memQuota = that.utils.mbToHumanSize(-1); // test infinite quota details.memory_utilization_percentage = (100 * usedMem / memQuota).toFixed(1); - details.memory_utilization = usedMemHuman + ' / ' + memQuotaHuman + ' [' + details.memory_utilization_percentage + '%]'; + // details.memory_utilization = usedMemHuman + ' / ' + memQuotaHuman + ' [' + details.memory_utilization_percentage + '%]'; + details.memory_utilization = usedMemHuman + ' / ' + memQuotaHuman; + + details.mem_used = 1024 * usedMem; + details.mem_quota = 1024 * memQuota; // Set instances utilisation var instancesUsed = vals.instances.data.instance_usage; diff --git a/src/plugins/cloud-foundry/view/applications/application/application.scss b/src/plugins/cloud-foundry/view/applications/application/application.scss index fc6534ac00..d3da86e711 100644 --- a/src/plugins/cloud-foundry/view/applications/application/application.scss +++ b/src/plugins/cloud-foundry/view/applications/application/application.scss @@ -10,6 +10,7 @@ .btn { font-size: $font-size-large; + text-transform: none; height: auto; padding: $hpe-unit-space/2 $hpe-unit-space; From 9654956c15469b042021dba7cf5e5f8e40714394 Mon Sep 17 00:00:00 2001 From: Julien Bramary Date: Tue, 12 Jul 2016 15:33:04 +0100 Subject: [PATCH 04/14] WIP --- .../detail/cluster-detail-organizations.html | 8 +-- .../cluster/detail/cluster-detail.html | 42 +++++++++++++-- .../cluster/detail/cluster-detail.module.js | 38 ++++++++++++- .../cluster-detail.organizations.module.js | 28 +--------- .../cluster/detail/cluster-detail.scss | 54 +++++++++++++------ .../organization-tile.directive.js | 3 ++ .../organization-tile/organization-tile.html | 3 +- .../model/organization/organization.model.js | 24 ++++++--- 8 files changed, 139 insertions(+), 61 deletions(-) diff --git a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail-organizations.html b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail-organizations.html index c8650db3d7..7bea290c45 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail-organizations.html +++ b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail-organizations.html @@ -1,11 +1,11 @@ -
+
-
+
An error occurred retrieving organizations
-
-
+
+
diff --git a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.html b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.html index 33f0a7bb50..0bdfc067cf 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.html +++ b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.html @@ -1,11 +1,43 @@

{{ clusterController.cluster.name }}

- -
- Placeholder for Cluster Details
- CF Endpoint URL: - {{ clusterController.cluster.api_endpoint.Scheme }}://{{ clusterController.cluster.api_endpoint.Host }} +
+
+ Summary + + + Edit + +
+ +
+
+
+
Total Applications
+
+ {{ clusterController.totalApps }} +
+
Total Memory
+
+ {{ clusterController.totalMemoryUsed }} +
+
+
+
+
+
CF Endpoint URL
+
+ {{ clusterController.cluster.api_endpoint.Scheme }}://{{ clusterController.cluster.api_endpoint.Host }} +
+
CF Interactions
+
+ + CLI Commands + +
+
+
+
-
+
Total Applications
@@ -23,7 +23,7 @@

{{ clusterController.cluster.name }}

-
+
CF Endpoint URL
From 3de6ea3b8afb672247674043b262e99b56004a4c Mon Sep 17 00:00:00 2001 From: Julien Bramary Date: Tue, 12 Jul 2016 16:17:02 +0100 Subject: [PATCH 06/14] Minor tidy-ups --- .../clusters/cluster/detail/cluster-detail.html | 4 ++-- .../model/organization/organization.model.js | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.html b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.html index c57bc7137a..5cb73a1950 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.html +++ b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.html @@ -25,8 +25,8 @@

{{ clusterController.cluster.name }}

-
CF Endpoint URL
-
+
CF Endpoint URL
+
{{ clusterController.cluster.api_endpoint.Scheme }}://{{ clusterController.cluster.api_endpoint.Host }}
CF Interactions
diff --git a/src/plugins/cloud-foundry/model/organization/organization.model.js b/src/plugins/cloud-foundry/model/organization/organization.model.js index 8f22eadc2d..27581560c0 100644 --- a/src/plugins/cloud-foundry/model/organization/organization.model.js +++ b/src/plugins/cloud-foundry/model/organization/organization.model.js @@ -26,6 +26,8 @@ * @name Organization * @param {app.api.apiManager} apiManager - the API manager * @property {app.api.apiManager} apiManager - the API manager + * @param {app.api.apiManager} apiManager - the API manager + * @property {app.api.apiManager} apiManager - the API manager * @class */ function Organization(apiManager, utils, userInfoService, $q) { @@ -84,6 +86,15 @@ }); }, + /** + * @function getOrganizationDetails + * @memberof cloud-foundry.model.organization + * @description gather all sorts of details about an organization + * @param {string} cnsiGuid - The GUID of the cloud-foundry server + * @param {string} org - organization entry as returned by listAllOrganizations() + * @param {object} params - optional parameters + * @returns {promise} A promise which will be resolved with the organizations's details + * */ getOrganizationDetails: function (cnsiGuid, org, params) { var that = this; From e3be0a757a0619617f405369fe06859d54aab1c8 Mon Sep 17 00:00:00 2001 From: Julien Bramary Date: Tue, 12 Jul 2016 16:18:35 +0100 Subject: [PATCH 07/14] Disable actions until implemented --- .../endpoints/clusters/cluster/detail/cluster-detail.module.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.module.js b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.module.js index 13cca9143f..2632fe949c 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.module.js +++ b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.module.js @@ -53,18 +53,21 @@ this.clusterActions = [ { name: gettext('Create Organization'), + disabled: true, execute: function () { }, icon: 'helion-icon-lg helion-icon helion-icon-Tree' }, { name: gettext('Create Space'), + disabled: true, execute: function () { }, icon: 'helion-icon-lg helion-icon helion-icon-Tree' }, { name: gettext('Assign User(s)'), + disabled: true, execute: function () { }, icon: 'helion-icon-lg helion-icon helion-icon-Add_user' From 4f755b61daec56b5a8886b9bc6954a233d0d7e38 Mon Sep 17 00:00:00 2001 From: Julien Bramary Date: Wed, 13 Jul 2016 13:43:04 +0100 Subject: [PATCH 08/14] WIP --- .../cluster/detail/cluster-detail.module.js | 12 ++- .../organization-tile.directive.js | 54 ++++++++++--- .../organization-tile/organization-tile.html | 11 +-- .../organization-tile/organization-tile.scss | 6 +- .../model/organization/organization.model.js | 76 ++++++++++--------- 5 files changed, 104 insertions(+), 55 deletions(-) diff --git a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.module.js b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.module.js index 2632fe949c..59b0b65ad4 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.module.js +++ b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.module.js @@ -27,10 +27,11 @@ 'app.model.modelManager', '$stateParams', '$scope', + '$log', 'app.utils.utilsService' ]; - function ClusterDetailController(modelManager, $stateParams, $scope, utils) { + function ClusterDetailController(modelManager, $stateParams, $scope, $log, utils) { var that = this; this.guid = $stateParams.guid; @@ -78,27 +79,30 @@ that.totalApps = 0; var totalMemoryMb = 0; _.forEach(that.organizationModel.organizations[that.guid], function (org) { - that.totalApps += org.total_apps; - totalMemoryMb += org.mem_used; + that.totalApps += org.totalApps; + totalMemoryMb += org.memUsed; }); that.totalMemoryUsed = utils.mbToHumanSize(totalMemoryMb); }; this.organizationModel.listAllOrganizations(this.guid, {}).then(function (orgs) { that.organizations = []; + that.updateTotalApps(); _.forEach(orgs, function (org) { that.organizationModel.getOrganizationDetails(that.guid, org).then(function (orgDetails) { that.organizations.push(orgDetails); that.updateTotalApps(); - // Sort orgs by created date + // Sort organizations by created date that.organizations.sort(function (o1, o2) { return o1.created_at - o2.created_at; }); }); }); + }).catch(function (error) { + $log.error('Error while listing organizations', error); }); } diff --git a/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.directive.js b/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.directive.js index 56d2f6a09a..b272da47e7 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.directive.js +++ b/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.directive.js @@ -9,18 +9,19 @@ function OrganizationTile() { return { - bindToController: { - organization: '=' - }, + bindToController: true, controller: OrganizationTileController, controllerAs: 'organizationTileCtrl', - scope: {}, + scope: { + organization: '=' + }, templateUrl: 'app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.html' }; } OrganizationTileController.$inject = [ - '$state' + '$state', + 'app.utils.utilsService' ]; /** @@ -29,10 +30,48 @@ * @param {object} $state - the angular $state service * @property {Array} actions - collection of relevant actions that can be executed against cluster */ - function OrganizationTileController($state) { + function OrganizationTileController($state, utils) { this.$state = $state; this.actions = []; this.setActions(); + + // The list of all organization roles is: org_user, org_manager, org_auditor, billing_manager + var ROLE_TO_STRING = { + org_user: gettext('User'), + org_manager: gettext('Manager'), + org_auditor: gettext('Auditor'), + billing_manager: gettext('Billing Manager') + }; + + // Present memory usage + var usedMemHuman = utils.mbToHumanSize(this.organization.memUsed); + var memQuotaHuman = utils.mbToHumanSize(this.organization.memQuota); + this.memory = usedMemHuman + ' / ' + memQuotaHuman; + + // Present instances utilisation + var instancesUsed = this.organization.instances; + var appInstanceQuota = this.organization.instancesQuota; + if (appInstanceQuota === -1) { + appInstanceQuota = '∞'; + } + this.instances = instancesUsed + ' / ' + appInstanceQuota; + + // Present the user's roles + var roles = this.organization.roles; + if (roles.length === 0) { + // Shouldn't happen as we should at least be a user of the org + this.roles = gettext('none'); + } else { + // If there are more than one role, don't show the user role + if (roles.length > 1) { + _.remove(roles, function(role) { + return role === 'org_user'; + }); + } + this.roles = _.map(roles, function (role) { + return ROLE_TO_STRING[role]; + }).join(', '); + } } angular.extend(OrganizationTileController.prototype, { @@ -56,9 +95,6 @@ execute: function () { } }); - }, - - summary: function () { } }); diff --git a/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.html b/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.html index 416fe0b252..8e11eac09f 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.html +++ b/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.html @@ -6,15 +6,16 @@ on-card-click="organizationTileCtrl.summary()">
+
role(s)
+
{{organizationTileCtrl.roles}}
total apps
-
{{organizationTileCtrl.organization.total_apps}}
+
{{organizationTileCtrl.organization.totalApps}}
instances
-
{{organizationTileCtrl.organization.instances}}
+
{{organizationTileCtrl.instances}}
memory utilization
-
{{ organizationTileCtrl.organization.memory_utilization }}
+
{{ organizationTileCtrl.memory }}
diff --git a/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.scss b/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.scss index 0f3a90aaef..63cc3a71c8 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.scss +++ b/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.scss @@ -15,10 +15,10 @@ dd { font-weight: 500; white-space: nowrap; + text-transform: none; + text-overflow: ellipsis; + overflow: hidden; } - dd:first-of-type { - text-transform: lowercase; - } } } diff --git a/src/plugins/cloud-foundry/model/organization/organization.model.js b/src/plugins/cloud-foundry/model/organization/organization.model.js index 27581560c0..c698f52f07 100644 --- a/src/plugins/cloud-foundry/model/organization/organization.model.js +++ b/src/plugins/cloud-foundry/model/organization/organization.model.js @@ -14,11 +14,13 @@ 'app.api.apiManager', 'app.utils.utilsService', 'userInfoService', - '$q' + '$q', + '$log' ]; - function registerOrgModel(modelManager, apiManager, utils, userInfoService, $q) { - modelManager.register('cloud-foundry.model.organization', new Organization(apiManager, utils, userInfoService, $q)); + function registerOrgModel(modelManager, apiManager, utils, userInfoService, $q, $log) { + modelManager.register('cloud-foundry.model.organization', + new Organization(apiManager, utils, userInfoService, $q, $log)); } /** @@ -27,12 +29,13 @@ * @param {app.api.apiManager} apiManager - the API manager * @property {app.api.apiManager} apiManager - the API manager * @param {app.api.apiManager} apiManager - the API manager - * @property {app.api.apiManager} apiManager - the API manager + * @property {app.api.apiManager} apiManager - the API manager * @class */ - function Organization(apiManager, utils, userInfoService, $q) { + function Organization(apiManager, utils, userInfoService, $q, $log) { this.apiManager = apiManager; this.$q = $q; + this.$log = $log; this.utils = utils; this.userInfoService = userInfoService; this.organizations = {}; @@ -114,12 +117,11 @@ var rolesP = orgsApi.RetrievingRolesOfAllUsersInOrganization(orgGuid, params, httpConfig); var userInfoP = that.userInfoService.userInfo(); - that.$q.all({roles: rolesP, userInfo: userInfoP}).then(function(values) { - // console.log('Roles:', values.roles); - // console.log('userInfo:', values.userInfo); - // Find our user in the list of all OrgUsers - var userGuid; - for (var i = 0; i < values.userInfo.data.length; i++) { + var orgRolesP = that.$q.all({roles: rolesP, userInfo: userInfoP}).then(function(values) { + var i, userGuid, myRoles; + + // Find our user's GUID + for (i = 0; i < values.userInfo.data.length; i++) { var userPerms = values.userInfo.data[i]; if (userPerms.type === 'hcf' && userPerms.cnsi_guid === cnsiGuid) { userGuid = userPerms.user_guid; @@ -130,6 +132,18 @@ throw new Error('Failed to get HCF user GUID'); } + // Find my user's roles + for (i = 0; i < values.roles.data.resources.length; i++) { + var roles = values.roles.data.resources[i]; + if (roles.metadata.guid === userGuid) { + myRoles = roles.entity.organization_roles; + break; + } + } + if (!myRoles) { + throw new Error('Failed to find my roles in this organization'); + } + return myRoles; }); @@ -138,10 +152,11 @@ var spaces = res.data.resources; var promises = []; _.forEach(spaces, function (space) { - // console.log('a space: ', space); var promise = spaceApi.ListAllAppsForSpace(space.metadata.guid, params, httpConfig).then(function (res2) { - // console.log('All apps: ', res2); return res2.data.resources.length; + }).catch(function (error) { + that.$log.error('Failed to ListAllAppsForSpace', error); + throw error; }); promises.push(promise); }); @@ -152,46 +167,39 @@ }); return total; }); + }).catch(function (error) { + that.$log.error('Failed to ListAllSpacesForOrganization', error); + throw error; }); return this.$q.all({ memory: usedMemP, quota: quotaP, instances: instancesP, - apps: appCountsP + apps: appCountsP, + roles: orgRolesP }).then(function (vals) { var details = {}; + details.guid = orgGuid; + // Set created date for sorting details.created_at = createdDate.unix(); // Set memory utilisation - var usedMemMb = vals.memory.data.memory_usage_in_mb; - var memQuotaMb = vals.quota.data.entity.memory_limit; - - var usedMemHuman = that.utils.mbToHumanSize(usedMemMb); - var memQuotaHuman = that.utils.mbToHumanSize(memQuotaMb); - - // var memQuota = that.utils.mbToHumanSize(-1); // test infinite quota - details.memory_utilization_percentage = (100 * usedMemMb / memQuotaMb).toFixed(1); - details.memory_utilization = usedMemHuman + ' / ' + memQuotaHuman; + details.memUsed = vals.memory.data.memory_usage_in_mb; + details.memQuota = vals.quota.data.entity.memory_limit; - details.mem_used = usedMemMb; - details.mem_quota = memQuotaMb; - - // Set instances utilisation - var instancesUsed = vals.instances.data.instance_usage; - var appInstanceQuota = vals.quota.data.entity.app_instance_limit; - if (appInstanceQuota === -1) { - appInstanceQuota = '∞'; - } - details.instances = instancesUsed + ' / ' + appInstanceQuota; + details.instances = vals.instances.data.instance_usage; + details.instancesQuota = vals.quota.data.entity.app_instance_limit; // Set total apps count - details.total_apps = vals.apps; + details.totalApps = vals.apps; details.name = org.entity.name; + details.roles = vals.roles; + if (_.isUndefined(that.organizations[cnsiGuid])) { that.organizations[cnsiGuid] = {}; } From f69727a590b44103a20703208e2695cdbd936bb9 Mon Sep 17 00:00:00 2001 From: Julien Bramary Date: Wed, 13 Jul 2016 14:41:50 +0100 Subject: [PATCH 09/14] Finally got rid of misleading col-md-* classes --- .../detail/cluster-detail-organizations.html | 2 +- .../cluster/detail/cluster-detail.scss | 25 +++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail-organizations.html b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail-organizations.html index 7bea290c45..8a95384f43 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail-organizations.html +++ b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail-organizations.html @@ -5,7 +5,7 @@
An error occurred retrieving organizations
-
+
diff --git a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.scss b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.scss index 61c92fe83f..55f0813f2c 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.scss +++ b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.scss @@ -23,21 +23,30 @@ $organizations-card-max-width: 420px; $organizations-card-layout-steps: 5; - .organizations-card { + .organization-card { padding-left: 0; - @for $i from 1 through $organizations-card-layout-steps { + position: relative; + float: left; + padding-right: 15px; + min-height: 1px; + + // Set width in percentages for all layout steps + width: 100%; + + // Many columns + @for $i from 2 through $organizations-card-layout-steps { @media (min-width: $i * $organizations-card-max-width) { - &.col-md-4.col-sm-1 { - width: percentage(1/$i); - } + width: percentage(1/$i); } } - @media (min-width: 768px) { + // Give more room to the value than the label + @media (min-width: 2 * $organizations-card-max-width) { gallery-card { .card .dl-horizontal dd { margin-left: 100px; + text-align: right; } .dl-horizontal dt { width: 140px; @@ -45,6 +54,7 @@ } } + // Pull the percent-gauge up .percent-gauge { padding-top: 0; .percent-gauge-quota-bar { @@ -54,8 +64,9 @@ } + // Ensure the last card in every row doesn't have right-padding @for $i from $organizations-card-layout-steps through 1 { - @media (min-width: $i * $organizations-card-max-width) and (max-width: $organizations-card-max-width + $i * $organizations-card-max-width) { + @media (min-width: $i * $organizations-card-max-width) and (max-width: $organizations-card-max-width + $i * $organizations-card-max-width - 1) { >:nth-child(#{$i}n) { padding-right: 0 } From dce074072f187180a21bce6263bff3aa20a02424 Mon Sep 17 00:00:00 2001 From: Julien Bramary Date: Wed, 13 Jul 2016 16:13:18 +0100 Subject: [PATCH 10/14] Fix lint errors in APIs --- .../cloud-foundry/api/hcf/AppUsageEvents.js | 9 +- src/plugins/cloud-foundry/api/hcf/Apps.js | 57 +++++--- .../cloud-foundry/api/hcf/Blobstores.js | 3 +- .../cloud-foundry/api/hcf/Buildpacks.js | 21 ++- .../api/hcf/DomainsDeprecated.js | 18 ++- .../api/hcf/EnvironmentVariableGroups.js | 12 +- src/plugins/cloud-foundry/api/hcf/Events.js | 129 ++++++++++++------ .../cloud-foundry/api/hcf/FeatureFlags.js | 42 ++++-- src/plugins/cloud-foundry/api/hcf/Files.js | 3 +- src/plugins/cloud-foundry/api/hcf/Info.js | 3 +- src/plugins/cloud-foundry/api/hcf/Jobs.js | 12 +- .../cloud-foundry/api/hcf/Organizations.js | 15 +- .../cloud-foundry/api/hcf/PrivateDomains.js | 18 ++- .../cloud-foundry/api/hcf/ResourceMatch.js | 3 +- src/plugins/cloud-foundry/api/hcf/Routes.js | 33 +++-- .../cloud-foundry/api/hcf/RoutesMapping.js | 15 +- .../api/hcf/SecurityGroupRunningDefaults.js | 9 +- .../api/hcf/SecurityGroupStagingDefaults.js | 9 +- .../cloud-foundry/api/hcf/SecurityGroups.js | 24 ++-- .../cloud-foundry/api/hcf/ServiceBindings.js | 12 +- .../cloud-foundry/api/hcf/ServiceBrokers.js | 15 +- .../cloud-foundry/api/hcf/ServiceInstances.js | 33 +++-- .../cloud-foundry/api/hcf/ServiceKeys.js | 12 +- .../api/hcf/ServicePlanVisibilities.js | 15 +- .../cloud-foundry/api/hcf/ServicePlans.js | 15 +- .../api/hcf/ServiceUsageEvents.js | 9 +- src/plugins/cloud-foundry/api/hcf/Services.js | 12 +- .../cloud-foundry/api/hcf/SharedDomains.js | 15 +- .../api/hcf/SpaceQuotaDefinitions.js | 24 ++-- src/plugins/cloud-foundry/api/hcf/Spaces.js | 105 +++++++++----- src/plugins/cloud-foundry/api/hcf/Stacks.js | 12 +- .../api/hcf/UserProvidedServiceInstances.js | 27 ++-- 32 files changed, 492 insertions(+), 249 deletions(-) diff --git a/src/plugins/cloud-foundry/api/hcf/AppUsageEvents.js b/src/plugins/cloud-foundry/api/hcf/AppUsageEvents.js index 0ade377f3a..7cb5f4a8ae 100644 --- a/src/plugins/cloud-foundry/api/hcf/AppUsageEvents.js +++ b/src/plugins/cloud-foundry/api/hcf/AppUsageEvents.js @@ -37,7 +37,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -57,7 +58,8 @@ config.method = 'POST'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -73,7 +75,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/Apps.js b/src/plugins/cloud-foundry/api/hcf/Apps.js index 8a83a3ff4b..dec739423b 100644 --- a/src/plugins/cloud-foundry/api/hcf/Apps.js +++ b/src/plugins/cloud-foundry/api/hcf/Apps.js @@ -34,7 +34,8 @@ config.method = 'PUT'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -54,7 +55,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -71,7 +73,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -88,7 +91,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -104,7 +108,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -123,7 +128,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -139,7 +145,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -156,7 +163,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -173,7 +181,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -201,7 +210,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -217,7 +227,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -233,7 +244,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -249,7 +261,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -265,7 +278,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -281,7 +295,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -297,7 +312,8 @@ config.method = 'POST'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -313,7 +329,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -329,7 +346,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -346,7 +364,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/Blobstores.js b/src/plugins/cloud-foundry/api/hcf/Blobstores.js index 82464bd9e4..245339234a 100644 --- a/src/plugins/cloud-foundry/api/hcf/Blobstores.js +++ b/src/plugins/cloud-foundry/api/hcf/Blobstores.js @@ -39,7 +39,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/Buildpacks.js b/src/plugins/cloud-foundry/api/hcf/Buildpacks.js index e096d98447..7ae9207a6d 100644 --- a/src/plugins/cloud-foundry/api/hcf/Buildpacks.js +++ b/src/plugins/cloud-foundry/api/hcf/Buildpacks.js @@ -38,7 +38,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -55,7 +56,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -71,7 +73,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -88,7 +91,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -104,7 +108,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -121,7 +126,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -137,7 +143,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/DomainsDeprecated.js b/src/plugins/cloud-foundry/api/hcf/DomainsDeprecated.js index 67f957eeed..15498474c6 100644 --- a/src/plugins/cloud-foundry/api/hcf/DomainsDeprecated.js +++ b/src/plugins/cloud-foundry/api/hcf/DomainsDeprecated.js @@ -35,7 +35,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -52,7 +53,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -68,7 +70,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -84,7 +87,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -100,7 +104,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -116,7 +121,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/EnvironmentVariableGroups.js b/src/plugins/cloud-foundry/api/hcf/EnvironmentVariableGroups.js index 22fe3a7222..acb98ef05a 100644 --- a/src/plugins/cloud-foundry/api/hcf/EnvironmentVariableGroups.js +++ b/src/plugins/cloud-foundry/api/hcf/EnvironmentVariableGroups.js @@ -35,7 +35,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -52,7 +53,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -70,7 +72,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -88,7 +91,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/Events.js b/src/plugins/cloud-foundry/api/hcf/Events.js index ec7edf1424..9b2dbbb7bd 100644 --- a/src/plugins/cloud-foundry/api/hcf/Events.js +++ b/src/plugins/cloud-foundry/api/hcf/Events.js @@ -34,7 +34,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -50,7 +51,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -66,7 +68,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -82,7 +85,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -98,7 +102,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -114,7 +119,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -130,7 +136,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -146,7 +153,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -162,7 +170,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -178,7 +187,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -194,7 +204,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -210,7 +221,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -226,7 +238,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -242,7 +255,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -258,7 +272,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -274,7 +289,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -290,7 +306,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -306,7 +323,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -322,7 +340,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -338,7 +357,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -354,7 +374,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -370,7 +391,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -386,7 +408,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -402,7 +425,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -418,7 +442,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -434,7 +459,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -450,7 +476,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -466,7 +493,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -482,7 +510,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -498,7 +527,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -514,7 +544,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -530,7 +561,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -546,7 +578,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -562,7 +595,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -578,7 +612,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -594,7 +629,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -610,7 +646,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -626,7 +663,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -642,7 +680,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -658,7 +697,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -674,7 +714,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -690,7 +731,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -706,7 +748,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/FeatureFlags.js b/src/plugins/cloud-foundry/api/hcf/FeatureFlags.js index 6b02c75526..8c2e50590a 100644 --- a/src/plugins/cloud-foundry/api/hcf/FeatureFlags.js +++ b/src/plugins/cloud-foundry/api/hcf/FeatureFlags.js @@ -34,7 +34,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -51,7 +52,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -68,7 +70,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -86,7 +89,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -103,7 +107,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -120,7 +125,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -137,7 +143,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -158,7 +165,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -176,7 +184,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -194,7 +203,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -211,7 +221,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -232,7 +243,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -249,7 +261,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -266,7 +279,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/Files.js b/src/plugins/cloud-foundry/api/hcf/Files.js index 57dbd5b5e9..058d6071ba 100644 --- a/src/plugins/cloud-foundry/api/hcf/Files.js +++ b/src/plugins/cloud-foundry/api/hcf/Files.js @@ -36,7 +36,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/Info.js b/src/plugins/cloud-foundry/api/hcf/Info.js index 6a015954f4..b9c5c6d840 100644 --- a/src/plugins/cloud-foundry/api/hcf/Info.js +++ b/src/plugins/cloud-foundry/api/hcf/Info.js @@ -34,7 +34,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/Jobs.js b/src/plugins/cloud-foundry/api/hcf/Jobs.js index 3ff035b5ac..d1aac57538 100644 --- a/src/plugins/cloud-foundry/api/hcf/Jobs.js +++ b/src/plugins/cloud-foundry/api/hcf/Jobs.js @@ -34,7 +34,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -50,7 +51,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -66,7 +68,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -82,7 +85,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/Organizations.js b/src/plugins/cloud-foundry/api/hcf/Organizations.js index 0cdd5d2c86..8339284e65 100644 --- a/src/plugins/cloud-foundry/api/hcf/Organizations.js +++ b/src/plugins/cloud-foundry/api/hcf/Organizations.js @@ -34,7 +34,8 @@ config.method = 'PUT'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -51,7 +52,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -67,7 +69,8 @@ config.method = 'PUT'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -84,7 +87,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -118,7 +122,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, diff --git a/src/plugins/cloud-foundry/api/hcf/PrivateDomains.js b/src/plugins/cloud-foundry/api/hcf/PrivateDomains.js index 872d72cd7d..d97ef8b081 100644 --- a/src/plugins/cloud-foundry/api/hcf/PrivateDomains.js +++ b/src/plugins/cloud-foundry/api/hcf/PrivateDomains.js @@ -35,7 +35,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -51,7 +52,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -67,7 +69,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -83,7 +86,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -99,7 +103,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -115,7 +120,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/ResourceMatch.js b/src/plugins/cloud-foundry/api/hcf/ResourceMatch.js index a1577076c0..5ca09d5e79 100644 --- a/src/plugins/cloud-foundry/api/hcf/ResourceMatch.js +++ b/src/plugins/cloud-foundry/api/hcf/ResourceMatch.js @@ -41,7 +41,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/Routes.js b/src/plugins/cloud-foundry/api/hcf/Routes.js index 7729e53c91..9b1dac3151 100644 --- a/src/plugins/cloud-foundry/api/hcf/Routes.js +++ b/src/plugins/cloud-foundry/api/hcf/Routes.js @@ -34,7 +34,8 @@ config.method = 'PUT'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -51,7 +52,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -68,7 +70,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -85,7 +88,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -101,7 +105,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -117,7 +122,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -133,7 +139,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -149,7 +156,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -165,7 +173,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -181,7 +190,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -198,7 +208,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/RoutesMapping.js b/src/plugins/cloud-foundry/api/hcf/RoutesMapping.js index 60b9dbc5d5..bb1dc65681 100644 --- a/src/plugins/cloud-foundry/api/hcf/RoutesMapping.js +++ b/src/plugins/cloud-foundry/api/hcf/RoutesMapping.js @@ -34,7 +34,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -50,7 +51,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -67,7 +69,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -83,7 +86,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -100,7 +104,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/SecurityGroupRunningDefaults.js b/src/plugins/cloud-foundry/api/hcf/SecurityGroupRunningDefaults.js index b2fe81f659..8299975054 100644 --- a/src/plugins/cloud-foundry/api/hcf/SecurityGroupRunningDefaults.js +++ b/src/plugins/cloud-foundry/api/hcf/SecurityGroupRunningDefaults.js @@ -34,7 +34,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -50,7 +51,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -66,7 +68,8 @@ config.method = 'PUT'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/SecurityGroupStagingDefaults.js b/src/plugins/cloud-foundry/api/hcf/SecurityGroupStagingDefaults.js index 21a0efbc61..6bd9079fbe 100644 --- a/src/plugins/cloud-foundry/api/hcf/SecurityGroupStagingDefaults.js +++ b/src/plugins/cloud-foundry/api/hcf/SecurityGroupStagingDefaults.js @@ -34,7 +34,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -50,7 +51,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -66,7 +68,8 @@ config.method = 'PUT'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/SecurityGroups.js b/src/plugins/cloud-foundry/api/hcf/SecurityGroups.js index bc88edf7e7..4d32c23225 100644 --- a/src/plugins/cloud-foundry/api/hcf/SecurityGroups.js +++ b/src/plugins/cloud-foundry/api/hcf/SecurityGroups.js @@ -34,7 +34,8 @@ config.method = 'PUT'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -51,7 +52,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -67,7 +69,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -83,7 +86,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -99,7 +103,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -115,7 +120,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -131,7 +137,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -148,7 +155,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/ServiceBindings.js b/src/plugins/cloud-foundry/api/hcf/ServiceBindings.js index 21c6a8cf41..f248dcc396 100644 --- a/src/plugins/cloud-foundry/api/hcf/ServiceBindings.js +++ b/src/plugins/cloud-foundry/api/hcf/ServiceBindings.js @@ -35,7 +35,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -51,7 +52,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -67,7 +69,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -83,7 +86,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/ServiceBrokers.js b/src/plugins/cloud-foundry/api/hcf/ServiceBrokers.js index c5e2269022..a66d20cb1c 100644 --- a/src/plugins/cloud-foundry/api/hcf/ServiceBrokers.js +++ b/src/plugins/cloud-foundry/api/hcf/ServiceBrokers.js @@ -35,7 +35,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -51,7 +52,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -67,7 +69,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -83,7 +86,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -100,7 +104,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/ServiceInstances.js b/src/plugins/cloud-foundry/api/hcf/ServiceInstances.js index bde99f875c..2ab9043335 100644 --- a/src/plugins/cloud-foundry/api/hcf/ServiceInstances.js +++ b/src/plugins/cloud-foundry/api/hcf/ServiceInstances.js @@ -35,7 +35,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -52,7 +53,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -68,7 +70,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -84,7 +87,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -100,7 +104,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -116,7 +121,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -132,7 +138,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -148,7 +155,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -164,7 +172,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -180,7 +189,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -197,7 +207,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/ServiceKeys.js b/src/plugins/cloud-foundry/api/hcf/ServiceKeys.js index 392cf0073c..2113b44f9a 100644 --- a/src/plugins/cloud-foundry/api/hcf/ServiceKeys.js +++ b/src/plugins/cloud-foundry/api/hcf/ServiceKeys.js @@ -35,7 +35,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -51,7 +52,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -67,7 +69,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -83,7 +86,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/ServicePlanVisibilities.js b/src/plugins/cloud-foundry/api/hcf/ServicePlanVisibilities.js index c1336bcd81..d4907c6ed5 100644 --- a/src/plugins/cloud-foundry/api/hcf/ServicePlanVisibilities.js +++ b/src/plugins/cloud-foundry/api/hcf/ServicePlanVisibilities.js @@ -35,7 +35,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -51,7 +52,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -67,7 +69,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -83,7 +86,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -100,7 +104,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/ServicePlans.js b/src/plugins/cloud-foundry/api/hcf/ServicePlans.js index 6f757fa218..e5987215d3 100644 --- a/src/plugins/cloud-foundry/api/hcf/ServicePlans.js +++ b/src/plugins/cloud-foundry/api/hcf/ServicePlans.js @@ -34,7 +34,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -50,7 +51,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -66,7 +68,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -82,7 +85,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -99,7 +103,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/ServiceUsageEvents.js b/src/plugins/cloud-foundry/api/hcf/ServiceUsageEvents.js index 8264e0319a..a6de179bfc 100644 --- a/src/plugins/cloud-foundry/api/hcf/ServiceUsageEvents.js +++ b/src/plugins/cloud-foundry/api/hcf/ServiceUsageEvents.js @@ -37,7 +37,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -57,7 +58,8 @@ config.method = 'POST'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -73,7 +75,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/Services.js b/src/plugins/cloud-foundry/api/hcf/Services.js index 5395e77c03..28b1e73efa 100644 --- a/src/plugins/cloud-foundry/api/hcf/Services.js +++ b/src/plugins/cloud-foundry/api/hcf/Services.js @@ -35,7 +35,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -51,7 +52,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -67,7 +69,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -83,7 +86,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/SharedDomains.js b/src/plugins/cloud-foundry/api/hcf/SharedDomains.js index 6249ebf65b..71642db516 100644 --- a/src/plugins/cloud-foundry/api/hcf/SharedDomains.js +++ b/src/plugins/cloud-foundry/api/hcf/SharedDomains.js @@ -35,7 +35,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -51,7 +52,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -67,7 +69,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -83,7 +86,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -99,7 +103,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/SpaceQuotaDefinitions.js b/src/plugins/cloud-foundry/api/hcf/SpaceQuotaDefinitions.js index f67f6377c0..79c9c20011 100644 --- a/src/plugins/cloud-foundry/api/hcf/SpaceQuotaDefinitions.js +++ b/src/plugins/cloud-foundry/api/hcf/SpaceQuotaDefinitions.js @@ -34,7 +34,8 @@ config.method = 'PUT'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -51,7 +52,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -67,7 +69,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -83,7 +86,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -99,7 +103,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -115,7 +120,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -131,7 +137,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -148,7 +155,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/Spaces.js b/src/plugins/cloud-foundry/api/hcf/Spaces.js index 088ad3ed45..c88877b6ae 100644 --- a/src/plugins/cloud-foundry/api/hcf/Spaces.js +++ b/src/plugins/cloud-foundry/api/hcf/Spaces.js @@ -34,7 +34,8 @@ config.method = 'PUT'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -46,12 +47,13 @@ AssociateAuditorWithSpaceByUsername: function (guid, value, params, httpConfigOptions) { var config = {}; config.params = params; - config.url = '/pp/v1/proxyv2/spaces/' + guid + '/auditors'; + config.url = '/pp/v1/proxy/v2/spaces/' + guid + '/auditors'; config.method = 'PUT'; config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -67,7 +69,8 @@ config.method = 'PUT'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -79,12 +82,13 @@ AssociateDeveloperWithSpaceByUsername: function (guid, value, params, httpConfigOptions) { var config = {}; config.params = params; - config.url = '/pp/v1/proxyv2/spaces/' + guid + '/developers'; + config.url = '/pp/v1/proxy/v2/spaces/' + guid + '/developers'; config.method = 'PUT'; config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -100,7 +104,8 @@ config.method = 'PUT'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -112,12 +117,13 @@ AssociateManagerWithSpaceByUsername: function (guid, value, params, httpConfigOptions) { var config = {}; config.params = params; - config.url = '/pp/v1/proxyv2/spaces/' + guid + '/managers'; + config.url = '/pp/v1/proxy/v2/spaces/' + guid + '/managers'; config.method = 'PUT'; config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -133,7 +139,8 @@ config.method = 'PUT'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -150,7 +157,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -166,7 +174,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -182,7 +191,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -198,7 +208,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -214,7 +225,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -230,7 +242,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -246,7 +259,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -262,7 +276,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -278,7 +293,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -294,7 +310,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -310,7 +327,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -326,7 +344,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -342,7 +361,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -358,7 +378,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -374,7 +395,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -386,12 +408,13 @@ RemoveAuditorWithSpaceByUsername: function (guid, value, params, httpConfigOptions) { var config = {}; config.params = params; - config.url = '/pp/v1/proxyv2/spaces/' + guid + '/auditors'; + config.url = '/pp/v1/proxy/v2/spaces/' + guid + '/auditors'; config.method = 'DELETE'; config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -407,7 +430,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -419,12 +443,13 @@ RemoveDeveloperWithSpaceByUsername: function (guid, value, params, httpConfigOptions) { var config = {}; config.params = params; - config.url = '/pp/v1/proxyv2/spaces/' + guid + '/developers'; + config.url = '/pp/v1/proxy/v2/spaces/' + guid + '/developers'; config.method = 'DELETE'; config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -440,7 +465,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -452,12 +478,13 @@ RemoveManagerWithSpaceByUsername: function (guid, value, params, httpConfigOptions) { var config = {}; config.params = params; - config.url = '/pp/v1/proxyv2/spaces/' + guid + '/managers'; + config.url = '/pp/v1/proxy/v2/spaces/' + guid + '/managers'; config.method = 'DELETE'; config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -473,7 +500,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -489,7 +517,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -505,7 +534,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -522,7 +552,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/Stacks.js b/src/plugins/cloud-foundry/api/hcf/Stacks.js index 171f172950..3c07cb0025 100644 --- a/src/plugins/cloud-foundry/api/hcf/Stacks.js +++ b/src/plugins/cloud-foundry/api/hcf/Stacks.js @@ -35,7 +35,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -51,7 +52,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -67,7 +69,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -83,7 +86,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } diff --git a/src/plugins/cloud-foundry/api/hcf/UserProvidedServiceInstances.js b/src/plugins/cloud-foundry/api/hcf/UserProvidedServiceInstances.js index ccf5428141..5759d86b40 100644 --- a/src/plugins/cloud-foundry/api/hcf/UserProvidedServiceInstances.js +++ b/src/plugins/cloud-foundry/api/hcf/UserProvidedServiceInstances.js @@ -34,7 +34,8 @@ config.method = 'PUT'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -51,7 +52,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -67,7 +69,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -83,7 +86,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -99,7 +103,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -115,7 +120,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -131,7 +137,8 @@ config.method = 'DELETE'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -147,7 +154,8 @@ config.method = 'GET'; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); }, @@ -164,7 +172,8 @@ config.data = value; for (var option in httpConfigOptions) { - config[option] = httpConfigOptions[option] + if (!httpConfigOptions.hasOwnProperty(option)) { continue; } + config[option] = httpConfigOptions[option]; } return this.$http(config); } From 3ad654b6127cf93b372dd5c1313bb0a5e220de08 Mon Sep 17 00:00:00 2001 From: Julien Bramary Date: Wed, 13 Jul 2016 17:02:46 +0100 Subject: [PATCH 11/14] Removed debug output --- .../endpoints/clusters/cluster/detail/cluster-detail.module.js | 1 - .../clusters/cluster/detail/cluster-detail.users.module.js | 1 - 2 files changed, 2 deletions(-) diff --git a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.module.js b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.module.js index 59b0b65ad4..ed851f2ab8 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.module.js +++ b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.module.js @@ -13,7 +13,6 @@ ]; function registerRoute($stateProvider) { - console.log('Registering endpoint.clusters.cluster.detail'); $stateProvider.state('endpoint.clusters.cluster.detail', { url: '', abstract: true, diff --git a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.users.module.js b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.users.module.js index b530e3b07c..5a733a7cdd 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.users.module.js +++ b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.users.module.js @@ -10,7 +10,6 @@ ]; function registerRoute($stateProvider) { - console.log('Registering route endpoint.clusters.cluster.detail.users'); $stateProvider.state('endpoint.clusters.cluster.detail.users', { url: '/users', templateUrl: 'app/view/endpoints/clusters/cluster/detail/cluster-detail-users.html', From a39cfd3314dd7321217eb5adc4d2c045af040fcd Mon Sep 17 00:00:00 2001 From: Julien Bramary Date: Wed, 13 Jul 2016 17:12:22 +0100 Subject: [PATCH 12/14] lint --- src/app/model/navigation/navigation.model.js | 2 ++ .../detail/cluster-detail.users.module.js | 8 ++++---- .../organization-tile.directive.js | 3 ++- .../model/organization/organization.model.js | 17 +++++++++++------ 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/app/model/navigation/navigation.model.js b/src/app/model/navigation/navigation.model.js index d9dd971d58..29bf386c94 100644 --- a/src/app/model/navigation/navigation.model.js +++ b/src/app/model/navigation/navigation.model.js @@ -35,6 +35,7 @@ * @param {app.event.eventService} eventService - the event bus service * @param {object} $state - ui-router $state service * @param {object} $rootScope - Angular rootScope object + * @param {object} $log - angular log service * @property {app.event.eventService} eventService - the event bus service * @property {object} $state - ui-router $state service * @property {app.model.navigation} menu - the navigation model @@ -110,6 +111,7 @@ * @namespace app.model.navigation.Menu * @memberof app.model.navigation * @name app.model.navigation.Menu + * @param {object} $log - angular log service * @property {string} currentState - current ui-router state */ function Menu($log) { diff --git a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.users.module.js b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.users.module.js index 5a733a7cdd..aeaf79f406 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.users.module.js +++ b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.users.module.js @@ -20,15 +20,15 @@ ClusterUsersController.$inject = [ 'app.model.modelManager', - '$stateParams' + '$stateParams', + '$log' ]; - function ClusterUsersController(modelManager, $stateParams) { - var that = this; + function ClusterUsersController(modelManager, $stateParams, $log) { this.guid = $stateParams.guid; this.usersModel = modelManager.retrieve('cloud-foundry.model.users'); this.usersModel.listAllUsers(this.guid, {}).then(function (res) { - console.log('Received list of Users: ', res); + $log.debug('Received list of Users: ', res); }); } diff --git a/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.directive.js b/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.directive.js index b272da47e7..2aeadfd9d7 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.directive.js +++ b/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.directive.js @@ -28,6 +28,7 @@ * @name OrganizationTileController * @constructor * @param {object} $state - the angular $state service + * @param {object} utils - our utils service * @property {Array} actions - collection of relevant actions that can be executed against cluster */ function OrganizationTileController($state, utils) { @@ -64,7 +65,7 @@ } else { // If there are more than one role, don't show the user role if (roles.length > 1) { - _.remove(roles, function(role) { + _.remove(roles, function (role) { return role === 'org_user'; }); } diff --git a/src/plugins/cloud-foundry/model/organization/organization.model.js b/src/plugins/cloud-foundry/model/organization/organization.model.js index c698f52f07..1b6a922493 100644 --- a/src/plugins/cloud-foundry/model/organization/organization.model.js +++ b/src/plugins/cloud-foundry/model/organization/organization.model.js @@ -26,10 +26,16 @@ /** * @memberof cloud-foundry.model * @name Organization - * @param {app.api.apiManager} apiManager - the API manager - * @property {app.api.apiManager} apiManager - the API manager - * @param {app.api.apiManager} apiManager - the API manager - * @property {app.api.apiManager} apiManager - the API manager + * @param {object} apiManager - the API manager + * @property {object} apiManager - the API manager + * @param {object} utils - the utils service + * @property {object} utils - the utils service + * @param {object} userInfoService - the userInfoService service + * @property {object} userInfoService - the userInfoService service + * @param {object} $q - angular $q service + * @property {object} $q - angular $q service + * @param {object} $log - angular $log service + * @property {object} $log - angular $log service * @class */ function Organization(apiManager, utils, userInfoService, $q, $log) { @@ -117,7 +123,7 @@ var rolesP = orgsApi.RetrievingRolesOfAllUsersInOrganization(orgGuid, params, httpConfig); var userInfoP = that.userInfoService.userInfo(); - var orgRolesP = that.$q.all({roles: rolesP, userInfo: userInfoP}).then(function(values) { + var orgRolesP = that.$q.all({roles: rolesP, userInfo: userInfoP}).then(function (values) { var i, userGuid, myRoles; // Find our user's GUID @@ -146,7 +152,6 @@ return myRoles; }); - var appCountsP = this.apiManager.retrieve('cloud-foundry.api.Organizations') .ListAllSpacesForOrganization(orgGuid, params, httpConfig).then(function (res) { var spaces = res.data.resources; From 96284f33b48d5bd49706bb916b82aba80f370318 Mon Sep 17 00:00:00 2001 From: Julien Bramary Date: Tue, 19 Jul 2016 16:53:27 +0100 Subject: [PATCH 13/14] TEAMFOUR-698, TEAMFOUR-699 --- src/app/api/stackato-info.service.js | 45 ++++++++++ src/app/api/user-info.service.js | 30 ------- src/app/model/stackato-info.model.js | 67 +++++++++++++++ src/app/utils/utils.service.js | 29 ++++++- .../cluster/detail/cluster-detail-users.html | 45 +++++++--- .../cluster/detail/cluster-detail.module.js | 71 +++++++++------ .../cluster/detail/cluster-detail.scss | 78 +++++++++++++++-- .../detail/cluster-detail.users.module.js | 86 +++++++++++++++++-- .../organization-tile.directive.js | 18 ++-- .../organization-tile/organization-tile.scss | 3 - .../dashboard/endpoints-dashboard.html | 2 +- .../dashboard/endpoints-dashboard.module.js | 47 +++++----- .../model/organization/organization.model.js | 56 ++++++------ 13 files changed, 428 insertions(+), 149 deletions(-) create mode 100644 src/app/api/stackato-info.service.js delete mode 100644 src/app/api/user-info.service.js create mode 100644 src/app/model/stackato-info.model.js diff --git a/src/app/api/stackato-info.service.js b/src/app/api/stackato-info.service.js new file mode 100644 index 0000000000..86bb480b13 --- /dev/null +++ b/src/app/api/stackato-info.service.js @@ -0,0 +1,45 @@ +(function () { + 'use strict'; + + /** + * @description user info service + */ + angular + .module('app') + .factory('stackatoInfoService', StackatoInfoService); + + StackatoInfoService.$inject = [ + '$q', + '$cookies', + '$http', + 'app.api.apiManager' + ]; + + /** + * @memberof app + * @name app.stackatoInfoService + * @description User information service provider + * @param {object} $q - the angular $q service + * @param {object} $cookies - the angular $cookies service + * @param {object} $http - the $http service + * @param {object} apiManager - API Manager used to fetch session details + * @returns {object} The user info service + */ + function StackatoInfoService($q, $cookies, $http, apiManager) { + var sessionName = apiManager.retrieve('app.api.account').sessionName; + return { + /** + * @function stackatoInfo + * @memberof app.stackatoInfoService + * @description Fetch the user's authorisation information + * @returns {promise} A promise object + */ + stackatoInfo: function () { + if ($cookies.get(sessionName)) { + return $http.get('/pp/v1/stackato/info'); + } + return $q.reject(sessionName + ' cookie missing!'); + } + }; + } +})(); diff --git a/src/app/api/user-info.service.js b/src/app/api/user-info.service.js deleted file mode 100644 index 00fa55e394..0000000000 --- a/src/app/api/user-info.service.js +++ /dev/null @@ -1,30 +0,0 @@ -(function () { - 'use strict'; - - /** - * @description user info service - */ - angular - .module('app') - .factory('userInfoService', UserInfoService); - - UserInfoService.$inject = [ - '$q', - '$cookies', - '$http', - 'app.api.apiManager' - ]; - - function UserInfoService($q, $cookies, $http, apiManager) { - var sessionName = apiManager.retrieve('app.api.account').sessionName; - return { - userInfo: function () { - if ($cookies.get(sessionName)) { - return $http.get('/pp/v1/userinfo'); - } - return $q.reject(sessionName + ' cookie missing!'); - } - - }; - } -})(); diff --git a/src/app/model/stackato-info.model.js b/src/app/model/stackato-info.model.js new file mode 100644 index 0000000000..dede209b67 --- /dev/null +++ b/src/app/model/stackato-info.model.js @@ -0,0 +1,67 @@ +(function () { + 'use strict'; + + /** + * @namespace app.model.user-info + * @memberOf app.model + * @name user-info + * @description User model + */ + angular + .module('app.model') + .run(registerStackatoInfoModel); + + registerStackatoInfoModel.$inject = [ + 'app.model.modelManager', + 'stackatoInfoService' + ]; + + function registerStackatoInfoModel(modelManager, stackatoInfoService) { + modelManager.register('app.model.stackatoInfo', new StackatoInfo(stackatoInfoService)); + } + + /** + * @namespace app.model.userInfo.UserInfo + * @memberof app.model.userInfo + * @name app.model.userInfo.UserInfo + * @param {app.api.stackatoInfoService} stackatoInfoService - Service with which to fetch data from + * @property {app.api.stackatoInfoService} stackatoInfoService - Service with which to fetch data from + * @property {object} info - the user info data object + * @class + */ + function StackatoInfo(stackatoInfoService) { + this.stackatoInfo = stackatoInfoService; + this.info = {}; + } + + angular.extend(StackatoInfo.prototype, { + /** + * @function getStackatoInfo + * @memberof app.model.stackatoInfo.StackatoInfo + * @description Fetch the user's authorisation information per cnsi + * @returns {promise} A promise object + * @public + */ + getStackatoInfo: function () { + var that = this; + return this.stackatoInfo.stackatoInfo() + .then(function (response) { + that.onStackatoInfo(response); + return that.info; + }); + }, + + /** + * @function onLoggedIn + * @memberof app.model.account.Account + * @description Logged-in handler at model layer + * @param {object} response - the HTTP response object + * @private + */ + onStackatoInfo: function (response) { + this.info = response.data; + } + + }); + +})(); diff --git a/src/app/utils/utils.service.js b/src/app/utils/utils.service.js index 8c388feb23..b7743a4528 100644 --- a/src/app/utils/utils.service.js +++ b/src/app/utils/utils.service.js @@ -6,6 +6,7 @@ .factory('app.utils.utilsService', utilsServiceFactory); utilsServiceFactory.$inject = [ + '$log' ]; /** @@ -15,9 +16,10 @@ * @description Various utility functions * @returns {object} the utils service */ - function utilsServiceFactory() { + function utilsServiceFactory($log) { return { - mbToHumanSize: mbToHumanSize + mbToHumanSize: mbToHumanSize, + chainStateResolve: chainStateResolve }; function mbToHumanSize(sizeMb) { @@ -35,6 +37,29 @@ } return sizeMb + ' MB'; } + + /** + * Chain promise returning init functions for ensuring in-order Controller initialisation of nested states + * NB: this uses custom state data to mimick ui-router's resolve functionality. + * Unfortunately we cannot reliably use ui-router's built-in resolve because of the way we register plugins + * during the run phase instead of the config phase. + * @param {Object} $state - The ui-router $state for the current state + * @param {function} initFunc - The promise returning init function for setting up the current state + * */ + function chainStateResolve($state, initFunc) { + $state.current.data = $state.current.data || {}; + var parentPromise = $state.current.data.initialized; + var thisPromise; + if (_.isUndefined(parentPromise)) { + $log.debug('Init promise chain starting from state ' + $state.current.name); + thisPromise = initFunc(); + } else { + $log.debug('Init promise chain continued by state ' + $state.current.name); + thisPromise = parentPromise.then(initFunc); + } + $state.current.data.initialized = thisPromise; + } + } })(); diff --git a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail-users.html b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail-users.html index b5afceffeb..04300d7e84 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail-users.html +++ b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail-users.html @@ -1,13 +1,36 @@ -
- -
-
-
An error occurred retrieving organizations
-
-
-
- +
+
+
+ + + + + + + + + + + + + + + + + +
USERS({{ clusterUsersController.users.length }})Organization RolesACTION
{{ user.entity.username }} +
{{ orgRole.name }}: {{ orgRole.role }}
+
None assigned
+
+ + +
+
+
- - diff --git a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.module.js b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.module.js index ed851f2ab8..a8e2f79900 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.module.js +++ b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.module.js @@ -18,24 +18,29 @@ abstract: true, templateUrl: 'app/view/endpoints/clusters/cluster/detail/cluster-detail.html', controller: ClusterDetailController, - controllerAs: 'clusterController' + controllerAs: 'clusterController', + data: {} }); } ClusterDetailController.$inject = [ 'app.model.modelManager', '$stateParams', + '$state', '$scope', + '$q', '$log', 'app.utils.utilsService' ]; - function ClusterDetailController(modelManager, $stateParams, $scope, $log, utils) { + function ClusterDetailController(modelManager, $stateParams, $state, $scope, $q, $log, utils) { var that = this; this.guid = $stateParams.guid; this.$scope = $scope; this.organizationModel = modelManager.retrieve('cloud-foundry.model.organization'); + + // TODO: use model cache instead this.organizations = []; this.totalApps = 0; @@ -46,9 +51,38 @@ }; this.cnsiModel = modelManager.retrieve('app.model.serviceInstance.user'); - this.cnsiModel.list().then(function (registeredInstances) { - that.cluster = registeredInstances[that.guid]; - }); + + function init() { + var listCnsisP = that.cnsiModel.list().then(function (registeredInstances) { + that.cluster = registeredInstances[that.guid]; + }); + + var listOrgsDetailsP = that.organizationModel.listAllOrganizations(that.guid, {}).then(function (orgs) { + that.organizations = []; + that.updateTotalApps(); + var promises = []; + _.forEach(orgs, function (org) { + var promise = that.organizationModel.getOrganizationDetails(that.guid, org).then(function (orgDetails) { + that.organizations.push(orgDetails); + + that.updateTotalApps(); + + // Sort organizations by created date + that.organizations.sort(function (o1, o2) { + return o1.created_at - o2.created_at; + }); + }); + promises.push(promise); + }); + return $q.all(promises); + }).catch(function (error) { + $log.error('Error while listing organizations', error); + }); + + return $q.all([listCnsisP, listOrgsDetailsP]).then(function () { + $log.debug('ClusterUsersController finished init'); + }); + } this.clusterActions = [ { @@ -77,34 +111,15 @@ this.updateTotalApps = function () { that.totalApps = 0; var totalMemoryMb = 0; - _.forEach(that.organizationModel.organizations[that.guid], function (org) { - that.totalApps += org.totalApps; - totalMemoryMb += org.memUsed; + _.forEach(that.organizations, function (orgDetails) { + that.totalApps += orgDetails.totalApps; + totalMemoryMb += orgDetails.memUsed; }); that.totalMemoryUsed = utils.mbToHumanSize(totalMemoryMb); }; - this.organizationModel.listAllOrganizations(this.guid, {}).then(function (orgs) { - that.organizations = []; - that.updateTotalApps(); - _.forEach(orgs, function (org) { - that.organizationModel.getOrganizationDetails(that.guid, org).then(function (orgDetails) { - that.organizations.push(orgDetails); - - that.updateTotalApps(); - - // Sort organizations by created date - that.organizations.sort(function (o1, o2) { - return o1.created_at - o2.created_at; - }); - }); - - }); - }).catch(function (error) { - $log.error('Error while listing organizations', error); - }); + utils.chainStateResolve($state, init); } - angular.extend(ClusterDetailController.prototype, {}); })(); diff --git a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.scss b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.scss index 55f0813f2c..35889a33bc 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.scss +++ b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.scss @@ -23,25 +23,29 @@ $organizations-card-max-width: 420px; $organizations-card-layout-steps: 5; + width: 100%; + display: flex; + flex-flow: row wrap; + .organization-card { - padding-left: 0; + padding-right: 10px; + padding-left: 10px; position: relative; float: left; - padding-right: 15px; min-height: 1px; - // Set width in percentages for all layout steps - width: 100%; + // Set flex-base in percentages for all layout steps + flex: 1 1 100%; // Many columns @for $i from 2 through $organizations-card-layout-steps { @media (min-width: $i * $organizations-card-max-width) { - width: percentage(1/$i); + flex: 1 1 percentage(1/$i) } } - // Give more room to the value than the label + // Inside the cards, give more room to the value than the label @media (min-width: 2 * $organizations-card-max-width) { gallery-card { .card .dl-horizontal dd { @@ -65,13 +69,71 @@ } // Ensure the last card in every row doesn't have right-padding - @for $i from $organizations-card-layout-steps through 1 { + @for $i from $organizations-card-layout-steps - 1 through 1 { @media (min-width: $i * $organizations-card-max-width) and (max-width: $organizations-card-max-width + $i * $organizations-card-max-width - 1) { >:nth-child(#{$i}n) { - padding-right: 0 + padding-right: 0; + } + >:nth-child(#{$i}n+1) { + padding-left: 0; } } } + + @media (min-width: $organizations-card-layout-steps * $organizations-card-max-width) { + >:nth-child(#{$organizations-card-layout-steps}n) { + padding-right: 0; + } + >:nth-child(#{$organizations-card-layout-steps}n+1) { + padding-left: 0; + } + } + + >:last-child { + padding-right: 0; + } + + } + + .cluster-users-table { + > div { + padding-top: 60px; + } + + .select-all-checkbox { + .checkbox-input { + margin-bottom: -5px; + } + } + + th { + text-transform: none; + } + + .user-name { + white-space: nowrap; + min-width: 200px; + } + + .roles-list { + + .role-pill { + cursor: default; + float: left; + margin: 0 8px 8px 0; + padding: 0 4px 4px 4px; + border: solid 2px #ccc; + border-radius: 5px; + } + + i.helion-icon.close-icon { + font-size: 12px; + font-weight: bolder; + color: #aaa; + margin-left: 10px; + } + } + } } diff --git a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.users.module.js b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.users.module.js index aeaf79f406..6e93e0a526 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.users.module.js +++ b/src/app/view/endpoints/clusters/cluster/detail/cluster-detail.users.module.js @@ -21,16 +21,90 @@ ClusterUsersController.$inject = [ 'app.model.modelManager', '$stateParams', - '$log' + '$state', + '$log', + 'app.utils.utilsService' ]; - function ClusterUsersController(modelManager, $stateParams, $log) { + function ClusterUsersController(modelManager, $stateParams, $state, $log, utils) { + var that = this; + this.guid = $stateParams.guid; + this.users = []; this.usersModel = modelManager.retrieve('cloud-foundry.model.users'); - this.usersModel.listAllUsers(this.guid, {}).then(function (res) { - $log.debug('Received list of Users: ', res); - }); + this.organizationModel = modelManager.retrieve('cloud-foundry.model.organization'); + + this.userRoles = {}; + + this.selectAllUsers = false; + this.selectedUsers = {}; + + function init() { + return that.usersModel.listAllUsers(that.guid, {}).then(function (res) { + + $log.debug('Received list of Users: ', res); + that.users = res; + + // For each user, get its roles in all organization + _.forEach(that.users, function (aUser) { + var myRoles = {}; + _.forEach(that.organizationModel.organizations[that.guid], function (org) { + var roles = org.roles[aUser.metadata.guid]; + if (!_.isUndefined(roles)) { + myRoles[org.details.name] = roles; + } + }); + that.userRoles[aUser.metadata.guid] = []; + + // Format that in an array of pairs for direct use in the template + _.forEach(myRoles, function (orgRoles, orgName) { + _.forEach(orgRoles, function (role) { + that.userRoles[aUser.metadata.guid].push({ + name: orgName, + role: role // TODO: use role name mapping from organizations-model + }); + }); + }); + + }); + }).then(function () { + $log.debug('ClusterUsersController finished init'); + }); + } + + this.userActions = [ + { + name: gettext('Manage Roles'), + disabled: true, + execute: function (aUser) { + $log.info('TODO: implement manage roles', aUser); + } + }, + { + name: gettext('Remove all roles'), + disabled: true, + execute: function (aUser) { + $log.info('TODO: implement remove all roles', aUser); + } + } + ]; + + this.getOrganizationsRoles = function (aUser) { + return that.userRoles[aUser.metadata.guid]; + }; + + this.selectAllChanged = function () { + if (that.selectAllUsers) { + _.forEach(that.visibleUsers, function (user) { + that.selectedUsers[user.metadata.guid] = true; + }); + } else { + that.selectedUsers = {}; + } + }; + + // Ensure the parent state is fully initialised before we start our own init + utils.chainStateResolve($state, init); } - angular.extend(ClusterUsersController.prototype, {}); })(); diff --git a/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.directive.js b/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.directive.js index 2aeadfd9d7..2c0f4ac249 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.directive.js +++ b/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.directive.js @@ -34,7 +34,6 @@ function OrganizationTileController($state, utils) { this.$state = $state; this.actions = []; - this.setActions(); // The list of all organization roles is: org_user, org_manager, org_auditor, billing_manager var ROLE_TO_STRING = { @@ -73,31 +72,30 @@ return ROLE_TO_STRING[role]; }).join(', '); } - } - angular.extend(OrganizationTileController.prototype, { - - setActions: function () { + this.setActions = function () { this.actions.push({ - name: 'Edit Organization', + name: gettext('Edit Organization'), disabled: true, execute: function () { } }); this.actions.push({ - name: 'Delete Organization', + name: gettext('Delete Organization'), disabled: true, execute: function () { } }); this.actions.push({ - name: 'Assign User(s)', + name: gettext('Assign User(s)'), disabled: true, execute: function () { } }); - } + }; + + this.setActions(); - }); + } })(); diff --git a/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.scss b/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.scss index 63cc3a71c8..0c2914b101 100644 --- a/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.scss +++ b/src/app/view/endpoints/clusters/cluster/detail/organization-tile/organization-tile.scss @@ -14,10 +14,7 @@ .dl-horizontal { dd { font-weight: 500; - white-space: nowrap; text-transform: none; - text-overflow: ellipsis; - overflow: hidden; } } diff --git a/src/app/view/endpoints/dashboard/endpoints-dashboard.html b/src/app/view/endpoints/dashboard/endpoints-dashboard.html index 194133831c..be3d6cfe2e 100644 --- a/src/app/view/endpoints/dashboard/endpoints-dashboard.html +++ b/src/app/view/endpoints/dashboard/endpoints-dashboard.html @@ -8,7 +8,7 @@ ng-show="endpointsDashboardCtrl.isUserAdmin()">
- Welcome to Stackato + Welcome to Stackato ! endpointsDashboardCtrl.isUserAdmin() === {{ endpointsDashboardCtrl.isUserAdmin() }} diff --git a/src/app/view/endpoints/dashboard/endpoints-dashboard.module.js b/src/app/view/endpoints/dashboard/endpoints-dashboard.module.js index f02e552c52..8f9790286b 100644 --- a/src/app/view/endpoints/dashboard/endpoints-dashboard.module.js +++ b/src/app/view/endpoints/dashboard/endpoints-dashboard.module.js @@ -38,7 +38,7 @@ * @constructor */ function EndpointsDashboardController(modelManager, $state, hceRegistration, hcfRegistration, $q) { - + var that = this; this.modelManager = modelManager; this.serviceInstanceModel = modelManager.retrieve('app.model.serviceInstance'); this.userServiceInstanceModel = modelManager.retrieve('app.model.serviceInstance.user'); @@ -53,18 +53,14 @@ // serviceInstanceModel has previously been updated // to decrease load time, we will use that data. this.listPromiseResolved = true; - this._updateLocalServiceInstances(); + _updateLocalServiceInstances(); } // Show welcome message only if no endpoints are registered this.showWelcomeMessage = this.serviceInstanceModel.serviceInstances.length === 0; this.serviceInstanceModel.list(); this.$q = $q; - this._updateEndpoints(); - - } - - angular.extend(EndpointsDashboardController.prototype, { + _updateEndpoints(); /** * @namespace app.view.endpoints.dashboard @@ -73,7 +69,7 @@ * @description Show cluster add form * @param {boolean} isHcf when true show cluster add form for HCF */ - showClusterAddForm: function (isHcf) { + this.showClusterAddForm = function (isHcf) { var that = this; if (isHcf) { this.hcfRegistration.add() @@ -86,7 +82,7 @@ return that._updateEndpoints; }); } - }, + }; /** * @namespace app.view.endpoints.dashboard @@ -94,9 +90,9 @@ * @name hideWelcomeMessage * @description Hide Welcome message */ - hideWelcomeMessage: function () { + this.hideWelcomeMessage = function () { this.showWelcomeMessage = false; - }, + }; /** * @function isUserAdmin @@ -104,9 +100,9 @@ * @description Is current user an admin? * @returns {Boolean} */ - isUserAdmin: function () { - return this.currentUserAccount.isAdmin(); - }, + this.isUserAdmin = function () { + return that.currentUserAccount.isAdmin(); + }; /** * @function _updateLocalServiceInstances @@ -114,12 +110,11 @@ * @description Updates local service instances * @private */ - _updateLocalServiceInstances: function () { - var that = this; - if (this.showWelcomeMessage && this.serviceInstanceModel.serviceInstances.length > 0) { - this.showWelcomeMessage = false; + function _updateLocalServiceInstances() { + if (that.showWelcomeMessage && that.serviceInstanceModel.serviceInstances.length > 0) { + that.showWelcomeMessage = false; } - _.forEach(this.serviceInstanceModel.serviceInstances, function (serviceInstance) { + _.forEach(that.serviceInstanceModel.serviceInstances, function (serviceInstance) { var guid = serviceInstance.guid; if (angular.isUndefined(that.serviceInstances[guid])) { that.serviceInstances[guid] = serviceInstance; @@ -127,23 +122,23 @@ angular.extend(that.serviceInstances[guid], serviceInstance); } }); - }, /** + } + + /** * @function _updateEndpoints * @memberOf app.view.endpoints.dashboard * @description Is current user an admin? * @returns {*} * @private */ - _updateEndpoints: function () { - - var that = this; - return this.$q.all([this.serviceInstanceModel.list(), this.userServiceInstanceModel.list()]) + function _updateEndpoints() { + return that.$q.all([that.serviceInstanceModel.list(), that.userServiceInstanceModel.list()]) .then(function () { - that._updateLocalServiceInstances(); + _updateLocalServiceInstances(); }).then(function () { that.listPromiseResolved = true; }); } - }); + } })(); diff --git a/src/plugins/cloud-foundry/model/organization/organization.model.js b/src/plugins/cloud-foundry/model/organization/organization.model.js index 1b6a922493..1d5047e1a5 100644 --- a/src/plugins/cloud-foundry/model/organization/organization.model.js +++ b/src/plugins/cloud-foundry/model/organization/organization.model.js @@ -13,37 +13,37 @@ 'app.model.modelManager', 'app.api.apiManager', 'app.utils.utilsService', - 'userInfoService', '$q', '$log' ]; - function registerOrgModel(modelManager, apiManager, utils, userInfoService, $q, $log) { + function registerOrgModel(modelManager, apiManager, utils, $q, $log) { modelManager.register('cloud-foundry.model.organization', - new Organization(apiManager, utils, userInfoService, $q, $log)); + new Organization(modelManager, apiManager, utils, $q, $log)); } /** * @memberof cloud-foundry.model * @name Organization + * @param {object} modelManager - the model manager * @param {object} apiManager - the API manager * @property {object} apiManager - the API manager * @param {object} utils - the utils service * @property {object} utils - the utils service - * @param {object} userInfoService - the userInfoService service - * @property {object} userInfoService - the userInfoService service + * @param {object} stackatoInfoModel - the stackatoInfoModel model + * @property {object} stackatoInfoModel - the stackatoInfoModel model * @param {object} $q - angular $q service * @property {object} $q - angular $q service * @param {object} $log - angular $log service * @property {object} $log - angular $log service * @class */ - function Organization(apiManager, utils, userInfoService, $q, $log) { + function Organization(modelManager, apiManager, utils, $q, $log) { this.apiManager = apiManager; this.$q = $q; this.$log = $log; this.utils = utils; - this.userInfoService = userInfoService; + this.stackatoInfoModel = modelManager.retrieve('app.model.stackatoInfo'); this.organizations = {}; var passThroughHeader = { @@ -95,6 +95,24 @@ }); }, + initOrganizationCache: function (cnsiGuid, orgGuid) { + this.organizations[cnsiGuid] = this.organizations[cnsiGuid] || {}; + this.organizations[cnsiGuid][orgGuid] = this.organizations[cnsiGuid][orgGuid] || {details: {}, roles: {}}; + }, + + cacheOrganizationDetails: function (cnsiGuid, orgGuid, details) { + this.initOrganizationCache(cnsiGuid, orgGuid); + this.organizations[cnsiGuid][orgGuid].details = details; + }, + + cacheOrganizationUsersRoles: function (cnsiGuid, orgGuid, roles) { + var that = this; + this.initOrganizationCache(cnsiGuid, orgGuid); + _.forEach(roles, function (user) { + that.organizations[cnsiGuid][orgGuid].roles[user.metadata.guid] = user.entity.organization_roles; + }); + }, + /** * @function getOrganizationDetails * @memberof cloud-foundry.model.organization @@ -105,7 +123,6 @@ * @returns {promise} A promise which will be resolved with the organizations's details * */ getOrganizationDetails: function (cnsiGuid, org, params) { - var that = this; var httpConfig = this.makeHttpConfig(cnsiGuid); var orgGuid = org.metadata.guid; @@ -121,22 +138,16 @@ var quotaP = orgsQuotaApi.RetrieveOrganizationQuotaDefinition(orgQuotaGuid, params, httpConfig); var rolesP = orgsApi.RetrievingRolesOfAllUsersInOrganization(orgGuid, params, httpConfig); - var userInfoP = that.userInfoService.userInfo(); + var stackatoInfoP = that.stackatoInfoModel.getStackatoInfo(); - var orgRolesP = that.$q.all({roles: rolesP, userInfo: userInfoP}).then(function (values) { + var orgRolesP = that.$q.all({roles: rolesP, stackatoInfo: stackatoInfoP}).then(function (values) { var i, userGuid, myRoles; + // TODO: there may be many pages of Users! + that.cacheOrganizationUsersRoles(cnsiGuid, orgGuid, values.roles.data.resources); + // Find our user's GUID - for (i = 0; i < values.userInfo.data.length; i++) { - var userPerms = values.userInfo.data[i]; - if (userPerms.type === 'hcf' && userPerms.cnsi_guid === cnsiGuid) { - userGuid = userPerms.user_guid; - break; - } - } - if (!userGuid) { - throw new Error('Failed to get HCF user GUID'); - } + userGuid = values.stackatoInfo.endpoints.hcf[cnsiGuid].user.guid; // Find my user's roles for (i = 0; i < values.roles.data.resources.length; i++) { @@ -205,10 +216,7 @@ details.roles = vals.roles; - if (_.isUndefined(that.organizations[cnsiGuid])) { - that.organizations[cnsiGuid] = {}; - } - that.organizations[cnsiGuid][orgGuid] = details; + that.cacheOrganizationDetails(cnsiGuid, orgGuid, details); return details; }); } From 30995642a442a97fea7d37d454bcdac90a81e62a Mon Sep 17 00:00:00 2001 From: Julien Bramary Date: Wed, 20 Jul 2016 12:16:04 +0100 Subject: [PATCH 14/14] Removed left-over isAdmin debug code --- src/app/view/endpoints/dashboard/endpoints-dashboard.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/view/endpoints/dashboard/endpoints-dashboard.html b/src/app/view/endpoints/dashboard/endpoints-dashboard.html index be3d6cfe2e..194133831c 100644 --- a/src/app/view/endpoints/dashboard/endpoints-dashboard.html +++ b/src/app/view/endpoints/dashboard/endpoints-dashboard.html @@ -8,7 +8,7 @@ ng-show="endpointsDashboardCtrl.isUserAdmin()">
- Welcome to Stackato ! endpointsDashboardCtrl.isUserAdmin() === {{ endpointsDashboardCtrl.isUserAdmin() }} + Welcome to Stackato