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

Commit

Permalink
Endpoints (#436)
Browse files Browse the repository at this point in the history
* Initial commit

* endpoints (wip)

* endpoints [wip]

* Added flyOut for HCF

* Moved goToEndpointsView to service-tile

* added credentials flyout to login to cluster

* Migated endpoints to /app & added hceRegistration factory

* Added duplicate URL warning code to hce-registration factory

* Include endpoints-dashboard.scss in view.scss

* minor update

* Created root endpoints state, split out generic endpoints pages into hce/hcf

* Merged base-tile & service-tile

* Admin operations are hidden to non-admin users

* Refactored HCF Add cluster form to a detailView

* Add jsdoc comments

* Added basic clusters page, placeholder for cluster summary page

* 720-Cluster tile view WIP
- Updating branch with latest and not-quite greatest

* 720-Cluster tile view WIP
- Updating branch with latest and not-quite greatest
- Wired in connect/disconnect/register/unregister
- updated url of dashboard state from /endpoints/dashboard to /endpoints

* 720-Cluster tile view WIP
- Updating branch with latest and not-quite greatest
- Created cf users model
- Added user/org count to cluster tile

* 720-Cluster tile view WIP
- Fixed endpoint top menu button (location og register + selected state)
- ux tweaks
- admin only actions are now admin only

* Added unit tests

+ Fixed flickering states issue
+ Minor peformance improvements
+ Migrated to action-menu

* Fixed issue with drop down menu actions

* Style updates for endpoints dashboard - use thin detail views

* More styling updates

* Style change to connect dialog to make it thinner.

We really need to refactor all of these dialogs using a common pattern.

* 720-Cluster tile view WIP
- Added 'expired' alert
- Added action-menu pos (requires PR 80 in helion-ui-framework to work)

* Updated styles
- endpoints now have root style + per section style
- Clusters + HCE endpoint titles now back to bigger
- Fixed welcome message

* Add specific modules names back in

* Trivial fix for unit test

* 720-Cluster tile view WIP
- Unit tests for cluster.tile

* TEAMFOUR-124 - Added view for "no registered endpoints" case

+ Added confirmation dialog when unregistering an endpoint
+ Fixed an issue where the incorrect icon was being displayed for HCE

* Decreased loading times when serviceInstanceModel is already initialised

* 720-Cluster tile view WIP
- Unit tests for clusters page
- When a cluster is disconnected it can never be expired

* Fixed typo

* Fixed welcome-message in endpoints-view

* Fixed lint errors, added jsdocs

* Fixed linting issues.

* Added gettext to action-menu items

* Fixed some translation issues
  • Loading branch information
richard-cox committed Jul 7, 2016
1 parent 05eb568 commit ece1bf5
Show file tree
Hide file tree
Showing 47 changed files with 2,976 additions and 97 deletions.
76 changes: 76 additions & 0 deletions e2e/endpoints/endpoints-dashboard.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
'use strict';

var helpers = require('../po/helpers.po');
var resetTo = require('../po/resets.po');
var loginPage = require('../po/login-page.po');
var endpointsDashboardPage = require('../po/endpoints-dashboard.po.js');

describe('Endpoints Dashboard', function() {

describe('No clusters', function() {

beforeAll(function() {
browser.driver.wait(resetTo.zeroClusterAdminWorkflow())
.then(function() {
helpers.setBrowserNormal();
helpers.loadApp();
loginPage.loginAsAdmin();
});
});

it('should show welcome endpoints page', function() {
endpointsDashboardPage.showEndpoints();
expect(browser.getCurrentUrl()).toBe('http://' + helpers.getHost() + '/#/cf/applications/endpoints-dashboard');
expect(endpointsDashboardPage.welcomeMessage().isDisplayed()).toBeTruthy();
expect(endpointsDashboardPage.registerCloudFoundryTile().isDisplayed()).toBeTruthy();
expect(endpointsDashboardPage.registerCodeEngineTile().isDisplayed()).toBeTruthy();
});

it('should show add cluster form flyout when btn is pressed', function() {
endpointsDashboardPage.showEndpoints();
endpointsDashboardPage.clickAddClusterInWelcomeMessage('hcf');
expect(endpointsDashboardPage.getAddClusterForm().isDisplayed()).toBeTruthy();
});

it('should show add cluster form detail view when btn is pressed', function() {
endpointsDashboardPage.showEndpoints();
endpointsDashboardPage.clickAddClusterInWelcomeMessage('hce');
expect(endpointsDashboardPage.getAddEndpointFlyout().isDisplayed()).toBeTruthy();
});

it('should show add cluster form detail view when tile btn is pressed', function() {
endpointsDashboardPage.showEndpoints();
endpointsDashboardPage.clickAddClusterInTille('hcf');
expect(endpointsDashboardPage.getAddClusterForm().isDisplayed()).toBeTruthy();
});

it('should show add cluster form detail view when tile btn is pressed', function() {
endpointsDashboardPage.showEndpoints();
endpointsDashboardPage.clickAddClusterInTille('hce');
expect(endpointsDashboardPage.getAddEndpointFlyout().isDisplayed()).toBeTruthy();
});

});

describe('With clusters', function() {

beforeAll(function() {
browser.driver.wait(resetTo.nClustersAdminWorkflow())
.then(function() {
helpers.setBrowserNormal();
helpers.loadApp();
loginPage.loginAsAdmin();
});
});

it('should show welcome endpoints page', function() {
endpointsDashboardPage.showEndpoints();
expect(browser.getCurrentUrl()).toBe('http://' + helpers.getHost() + '/#/cf/applications/endpoints-dashboard');
expect(endpointsDashboardPage.welcomeMessage().isDisplayed()).toBeFalsy();
expect(endpointsDashboardPage.registerCloudFoundryTile().isDisplayed()).toBeFalsy();
expect(endpointsDashboardPage.registerCodeEngineTile().isDisplayed()).toBeFalsy();
});

});

});
63 changes: 63 additions & 0 deletions e2e/po/endpoints-dashboard.po.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
'use strict';

var navbar = require('./navbar.po');

module.exports = {
showEndpoints: showEndpoints,
clickAddClusterInWelcomeMessage: clickAddClusterInWelcomeMessage,
clickAddClusterInTille: clickAddClusterInTille,
welcomeMessage: welcomeMessage,
registerCloudFoundryTile: registerCloudFoundryTile,
registerCodeEngineTile: registerCodeEngineTile,
getAddEndpointFlyout: getAddEndpointFlyout,
getAddClusterForm: getAddClusterForm,
getBaseTile: getBaseTile
};

function showEndpoints() {
navbar.goToView('Endpoints');
}

function welcomeMessage() {
return element(by.id('welcome-message'));
}

function clickAddClusterInWelcomeMessage(serviceType) {
if (serviceType === 'hcf') {
return driver.findElement(by.linkText('register Cloud Foundry clusters')).click();
} else {
return driver.findElement(by.linkText('Code Engine endpoints')).click();
}
}

function clickAddClusterInTille(serviceType) {
if (serviceType === 'hcf') {
return driver.findElement(by.linkText('Register a Cluster')).click();
} else {
return driver.findElement(by.linkText('Register an Endpoint')).click();
}
}

function registerCloudFoundryTile() {
return getNoInstanceTile('hcf)');
}

function registerCodeEngineTile() {
return getNoInstanceTile('hce)');
}

function getNoInstanceTile(serviceType) {
return element(by.id(serviceType + '-no-instances-tile'));
}

function getAddEndpointFlyout() {
return element(by.tagName('add-cluster-form'));
}

function getAddClusterForm() {
return element(by.css('hce-registration'));
}

function getBaseTile(serviceType) {
return element(by.tagName('base-tile'));
}
6 changes: 4 additions & 2 deletions e2e/po/login-page.po.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

// Login page helpers
var helpers = require('./helpers.po');
var adminUser = browser.params.adminUser || 'admin';
var adminPassword = browser.params.adminPassword || 'admin';

module.exports = {

Expand Down Expand Up @@ -63,9 +65,9 @@ function enterLogin(username, password) {
function login(username, password) {
enterLogin(username, password);
loginButton().click();
browser.driver.sleep(1000);
browser.driver.sleep(10000);
}

function loginAsAdmin() {
login('admin', 'admin');
login(adminUser, adminPassword);
}
20 changes: 11 additions & 9 deletions e2e/po/resets.po.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
var request = require('../../tools/node_modules/request');
var helpers = require('./helpers.po');
var host = helpers.getHost();
var adminUser = browser.params.adminUser || 'admin';
var adminPassword = browser.params.adminPassword || 'admin';

module.exports = {

Expand All @@ -22,8 +24,8 @@ module.exports = {
function devWorkflow(firstTime) {
var req = newRequest();

return new Promise(function (resolve, reject) {
createSession(req, 'dev', 'dev').then(function () {
return new Promise(function(resolve, reject) {
createSession(req, 'dev', 'dev').then(function() {
var promises = [];
promises.push(setUser(req, !firstTime));
promises.push(resetClusters(req));
Expand All @@ -50,9 +52,9 @@ function devWorkflow(firstTime) {
function zeroClusterAdminWorkflow() {
var req = newRequest();

return new Promise(function (resolve, reject) {
createSession(req, 'admin', 'admin').then(function () {
removeClusters(req).then(function () {
return new Promise(function(resolve, reject) {
createSession(req, adminUser, adminPassword).then(function() {
removeClusters(req).then(function() {
resolve();
}, function () {
reject();
Expand All @@ -70,8 +72,8 @@ function zeroClusterAdminWorkflow() {
function nClustersAdminWorkflow() {
var req = newRequest();

return new Promise(function (resolve, reject) {
createSession(req, 'admin', 'admin').then(function () {
return new Promise(function(resolve, reject) {
createSession(req, adminUser, adminPassword).then(function() {
var promises = [];
promises.push(resetClusters(req));

Expand Down Expand Up @@ -139,9 +141,9 @@ function createSession(req, username, password) {
password: password || 'dev'
})
};
req.post('http://' + host + '/pp/v1/auth/login/uaa', options)
.on('response', function(response) {

req.post('http://' + host + '/api/auth/login', options)
.on('response', function (response) {
if (response.statusCode === 200) {
resolve();
} else {
Expand Down
16 changes: 14 additions & 2 deletions src/app/model/account/account.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
'app.api.apiManager'
];

function registerAccountModel($cookies, modelManager, apiManager) {
function registerAccountModel ($cookies, modelManager, apiManager) {
modelManager.register('app.model.account', new Account($cookies, apiManager));
}

Expand All @@ -33,11 +33,14 @@
* @property {object} data - the account data object
* @class
*/
function Account($cookies, apiManager) {
function Account ($cookies, apiManager) {
this.$cookies = $cookies;
this.apiManager = apiManager;
this.loggedIn = false;
this.data = {};

// TODO(irfan) Hook for development
this.adminOverride = false;
}

angular.extend(Account.prototype, {
Expand Down Expand Up @@ -99,6 +102,10 @@
return p;
},

setAdminOverride: function (bool) {
this.adminOverride = bool;
},

/**
* @function isAdmin
* @memberof app.model.account.Account
Expand All @@ -107,6 +114,11 @@
* @returns {boolean} True if this user is an ITOps admin
*/
isAdmin: function () {

//TODO(irfan) Hook for development
if (this.adminOverride) {
return false;
}
var ADMIN_SCOPES = [
'cloud_controller.admin',
'ucp.admin'
Expand Down
13 changes: 10 additions & 3 deletions src/app/model/navigation/navigation.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,25 @@
* @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) {
this.push({
addMenuItem: function (name, href, text, icon, baseState, pos) {
var item = {
name: name,
href: href,
text: text,
icon: icon,
// baseState is used to work out which menu entry is active based on any child state
baseState: baseState || name, // defaults to name
items: new Menu() // sub-menu
});
};
if (angular.isNumber(pos)) {
this.splice(pos, 0, item);
} else {
this.push(item);
}

return this;
},

Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
add-cluster-form {
display: flex;
justify-content: center;

.add-cluster-form {
max-width: 350px;

h2 {
margin-top: $hpe-unit-space * 2.5;
}
}
.add-cluster-form {
margin: 0 $hpe-unit-space * 5;

form {
margin-top: $hpe-unit-space;

.form-group {
width: 100%;
.form-actions {
margin-top: $hpe-unit-space * 2;
text-align: right;
padding: $hpe-unit-space 0 0 0;
border-top: 1px solid #e5e5e5;
}
}
//
//h2 {
// margin-top: $hpe-unit-space * 2.5;
//}
//
//form {
// margin-top: $hpe-unit-space;
//
// .form-group {
// width: 100%;
// }
//}

.alert-danger {
margin-top: $hpe-unit-space;
}

.form-actions {
display: flex;
justify-content: flex-end;
margin-top: $hpe-unit-space;

button:not(:first-child) {
margin-left: $hpe-unit-space / 4;
}
}
//
//.form-actions {
// display: flex;
// justify-content: flex-end;
// margin-top: $hpe-unit-space;
//
// button:not(:first-child) {
// margin-left: $hpe-unit-space / 4;
// }
//}
}
Loading

0 comments on commit ece1bf5

Please sign in to comment.