From 580f77549bef6fb582749c13fa99cb344482bdb4 Mon Sep 17 00:00:00 2001 From: Scott Aslan Date: Thu, 14 Dec 2017 16:25:32 -0500 Subject: [PATCH] NIFIREG-30 - Add login component, auth guard to login, tenants, buckets, admin, and explorer routes. Also added route for login component. NIFIREG-20 - Improve page load times. NIFIREG-15 - Add loading screen. This closes #58. Signed-off-by: Bryan Bende --- .../src/main/locale/messages.es.xlf | 44 +- .../core/common/styles/_globalVars.scss | 4 +- .../core/common/styles/_helperClasses.scss | 5 + .../platform/core/common/styles/_inputs.scss | 2 +- .../platform/core/common/styles/_stepper.scss | 20 + .../common/styles/fluid-design-system.scss | 1 + .../src/main/webapp/WEB-INF/web.xml | 10 + .../nf-registry-administration.html | 22 +- .../nf-registry-administration.js | 35 +- .../nf-registry-administration.spec.js | 16 +- .../nf-registry-user-group-permissions.html | 28 - .../nf-registry-user-group-permissions.js | 70 --- .../users/details/nf-registry-user-details.js | 69 --- .../nf-registry-add-user-to-groups.html} | 21 +- .../nf-registry-add-user-to-groups.js} | 106 ++-- .../nf-registry-add-user-to-groups.spec.js} | 33 +- .../dialogs/add-user/nf-registry-add-user.js | 2 +- .../nf-registry-add-users-to-group.html | 80 +++ .../nf-registry-add-users-to-group.js | 234 +++++++ .../nf-registry-add-users-to-group.spec.js | 170 ++++++ .../nf-registry-users-administration.html | 24 +- .../users/nf-registry-users-administration.js | 73 +-- .../nf-registry-users-adminstration.spec.js | 27 +- .../nf-registry-manage-group.html | 154 +++++ .../manage-group/nf-registry-manage-group.js | 577 ++++++++++++++++++ .../manage-user/nf-registry-manage-user.html | 158 +++++ .../manage-user/nf-registry-manage-user.js | 577 ++++++++++++++++++ .../nf-registry-bucket-permissions.html | 88 ++- .../nf-registry-workflow-administration.html | 10 +- .../nf-registry-workflow-administration.js | 33 +- ...f-registry-workflow-administration.spec.js | 16 +- .../nf-registry-bucket-grid-list-viewer.js | 42 +- ...f-registry-bucket-grid-list-viewer.spec.js | 17 +- .../nf-registry-droplet-grid-list-viewer.js | 49 +- ...-registry-droplet-grid-list-viewer.spec.js | 17 +- .../nf-registry-grid-list-viewer.html | 9 +- .../registry/nf-registry-grid-list-viewer.js | 32 +- .../nf-registry-grid-list-viewer.spec.js | 16 +- .../explorer/nf-registry-explorer.spec.js | 16 +- .../login/dialogs/nf-registry-user-login.html | 45 ++ .../login/dialogs/nf-registry-user-login.js | 69 +++ .../nf-registry-login.html} | 13 +- .../nf-registry-login.js} | 53 +- .../nf-registry-page-not-found.html} | 13 +- .../nf-registry-page-not-found.js | 45 +- .../src/main/webapp/nf-registry.html | 14 +- .../src/main/webapp/nf-registry.js | 3 +- .../src/main/webapp/nf-registry.module.js | 31 +- .../src/main/webapp/nf-registry.routes.js | 46 +- .../src/main/webapp/nf-registry.spec.js | 16 +- .../main/webapp/services/nf-registry.api.js | 197 +++++- .../webapp/services/nf-registry.api.spec.js | 21 +- .../nf-registry.auth-guard.service.js | 257 ++++++++ .../services/nf-registry.auth.service.js | 2 +- .../webapp/services/nf-registry.service.js | 309 ++++++++-- .../services/nf-registry.service.spec.js | 30 +- .../main/webapp/systemjs.builder.config.js | 11 +- .../webapp/theming/_structureElements.scss | 26 +- 58 files changed, 3397 insertions(+), 711 deletions(-) create mode 100644 nifi-registry-web-ui/src/main/platform/core/common/styles/_stepper.scss delete mode 100644 nifi-registry-web-ui/src/main/webapp/components/administration/user-group/permissions/nf-registry-user-group-permissions.html delete mode 100644 nifi-registry-web-ui/src/main/webapp/components/administration/user-group/permissions/nf-registry-user-group-permissions.js delete mode 100644 nifi-registry-web-ui/src/main/webapp/components/administration/users/details/nf-registry-user-details.js rename nifi-registry-web-ui/src/main/webapp/components/administration/users/dialogs/{add-selected-users-to-group/nf-registry-add-selected-users-to-group.html => add-user-to-groups/nf-registry-add-user-to-groups.html} (79%) rename nifi-registry-web-ui/src/main/webapp/components/administration/users/dialogs/{add-selected-users-to-group/nf-registry-add-selected-users-to-group.js => add-user-to-groups/nf-registry-add-user-to-groups.js} (66%) rename nifi-registry-web-ui/src/main/webapp/components/administration/users/dialogs/{add-selected-users-to-group/nf-registry-add-selected-users-to-group.spec.js => add-user-to-groups/nf-registry-add-user-to-groups.spec.js} (81%) create mode 100644 nifi-registry-web-ui/src/main/webapp/components/administration/users/dialogs/add-users-to-group/nf-registry-add-users-to-group.html create mode 100644 nifi-registry-web-ui/src/main/webapp/components/administration/users/dialogs/add-users-to-group/nf-registry-add-users-to-group.js create mode 100644 nifi-registry-web-ui/src/main/webapp/components/administration/users/dialogs/add-users-to-group/nf-registry-add-users-to-group.spec.js create mode 100644 nifi-registry-web-ui/src/main/webapp/components/administration/users/sidenav/manage-group/nf-registry-manage-group.html create mode 100644 nifi-registry-web-ui/src/main/webapp/components/administration/users/sidenav/manage-group/nf-registry-manage-group.js create mode 100644 nifi-registry-web-ui/src/main/webapp/components/administration/users/sidenav/manage-user/nf-registry-manage-user.html create mode 100644 nifi-registry-web-ui/src/main/webapp/components/administration/users/sidenav/manage-user/nf-registry-manage-user.js create mode 100644 nifi-registry-web-ui/src/main/webapp/components/login/dialogs/nf-registry-user-login.html create mode 100644 nifi-registry-web-ui/src/main/webapp/components/login/dialogs/nf-registry-user-login.js rename nifi-registry-web-ui/src/main/webapp/components/{administration/users/details/nf-registry-user-details.html => login/nf-registry-login.html} (60%) rename nifi-registry-web-ui/src/main/webapp/components/{administration/users/permissions/nf-registry-user-permissions.js => login/nf-registry-login.js} (53%) rename nifi-registry-web-ui/src/main/webapp/components/{administration/users/permissions/nf-registry-user-permissions.html => page-not-found/nf-registry-page-not-found.html} (58%) create mode 100644 nifi-registry-web-ui/src/main/webapp/services/nf-registry.auth-guard.service.js diff --git a/nifi-registry-web-ui/src/main/locale/messages.es.xlf b/nifi-registry-web-ui/src/main/locale/messages.es.xlf index 9a093c9..9bee8cd 100644 --- a/nifi-registry-web-ui/src/main/locale/messages.es.xlf +++ b/nifi-registry-web-ui/src/main/locale/messages.es.xlf @@ -35,46 +35,76 @@ A description of the type of administration options available. Workflow administration tab + + Membership + afiliación + View the groups to which this user belongs. + Group membership tab, user management sidenav + + + Membership + afiliación + View the users that belong to this group. + User membership tab, group management sidenav + + + Policies + Políticas + View the policies grated this user. + User policy tab, user management sidenav + Create Crear - A button for creating a new bucket in the registry.@@nf-admin-workflow-create-bucket-button. + A button for creating a new bucket in the registry. Create new bucket button Add añadir - A button for adding a new user in the registry.@@nf-admin-workflow-add-user-button. + A button for adding a new user in the registry. Add new user button Cancel Cancelar - A button for cancelling the creation of a new user in the registry.@@nf-admin-workflow-add-user-button. + A button for cancelling the creation of a new user in the registry. Cancel creation of new user + + Clear + Claro + A button for clearing the login form. + Clear log in form + + + Log In + Iniciar sesión + A button for attempting to authenticate with the registry. + Log in form + Create Crear - A button for creating a new group in the registry.@@nf-admin-workflow-create-new-group-button. + A button for creating a new group in the registry. Create new group button Cancel Cancelar - A button for cancelling the creation of a new group in the registry.@@nf-admin-workflow-cancel-create-new-group-button. + A button for cancelling the creation of a new group in the registry. Cancel creation of new group Add añadir - A button for adding users to an existing group in the registry.@@nf-admin-workflow-create-new-group-button. + A button for adding users to an existing group in the registry. Add selected users to group button Cancel Cancelar - A button for cancelling the addition of selected users to a group in the registry.@@nf-admin-workflow-cancel-create-new-group-button. + A button for cancelling the addition of selected users to a group in the registry. Cancel addition of selected users to group diff --git a/nifi-registry-web-ui/src/main/platform/core/common/styles/_globalVars.scss b/nifi-registry-web-ui/src/main/platform/core/common/styles/_globalVars.scss index f43f214..77c6ee2 100644 --- a/nifi-registry-web-ui/src/main/platform/core/common/styles/_globalVars.scss +++ b/nifi-registry-web-ui/src/main/platform/core/common/styles/_globalVars.scss @@ -35,11 +35,13 @@ $grey2: #666666; $grey3: #999999; $grey4: #CCCCCC; $grey5: #EEEEEE; -$grey6: #F5F5F5; // or #FAFAFA +$grey6: #F8F9F9; // or #FAFAFA $grey7: #DDDDDD; $grey8: #CFD3D7; $grey9: #b2b8c1; $grey10: #dbdee2; +$grey11: #2C3E44; +$grey12: #EEEFF0; $blue1: #1491C1; $blue2: #E7f6Fc; $blue3: #A7DFF2; diff --git a/nifi-registry-web-ui/src/main/platform/core/common/styles/_helperClasses.scss b/nifi-registry-web-ui/src/main/platform/core/common/styles/_helperClasses.scss index 6b00b46..1298358 100644 --- a/nifi-registry-web-ui/src/main/platform/core/common/styles/_helperClasses.scss +++ b/nifi-registry-web-ui/src/main/platform/core/common/styles/_helperClasses.scss @@ -28,6 +28,11 @@ padding-bottom: 10px; } +.help-icon { + font-size: 12px; + color: $blue1; +} + .details-header { height: 92px; } diff --git a/nifi-registry-web-ui/src/main/platform/core/common/styles/_inputs.scss b/nifi-registry-web-ui/src/main/platform/core/common/styles/_inputs.scss index 4ab225a..392f5cb 100644 --- a/nifi-registry-web-ui/src/main/platform/core/common/styles/_inputs.scss +++ b/nifi-registry-web-ui/src/main/platform/core/common/styles/_inputs.scss @@ -32,7 +32,7 @@ body[fds] input.mat-input-element, body[fds] textarea.mat-input-element { border: 1px solid $grey8; height: 32px; padding: 0px 10px; - width: calc(100% - 22px); + width: calc(100% - 26px); } body[fds] textarea.mat-input-element { diff --git a/nifi-registry-web-ui/src/main/platform/core/common/styles/_stepper.scss b/nifi-registry-web-ui/src/main/platform/core/common/styles/_stepper.scss new file mode 100644 index 0000000..fda0b87 --- /dev/null +++ b/nifi-registry-web-ui/src/main/platform/core/common/styles/_stepper.scss @@ -0,0 +1,20 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +.td-step-header span { + display: none; +} \ No newline at end of file diff --git a/nifi-registry-web-ui/src/main/platform/core/common/styles/fluid-design-system.scss b/nifi-registry-web-ui/src/main/platform/core/common/styles/fluid-design-system.scss index 1ee9b70..7075f92 100644 --- a/nifi-registry-web-ui/src/main/platform/core/common/styles/fluid-design-system.scss +++ b/nifi-registry-web-ui/src/main/platform/core/common/styles/fluid-design-system.scss @@ -31,6 +31,7 @@ @import 'panels'; @import 'links'; @import 'sideNav'; +@import 'stepper'; @import 'tooltips'; @import 'expansionPanels'; @import 'menus'; diff --git a/nifi-registry-web-ui/src/main/webapp/WEB-INF/web.xml b/nifi-registry-web-ui/src/main/webapp/WEB-INF/web.xml index da27a62..c020795 100644 --- a/nifi-registry-web-ui/src/main/webapp/WEB-INF/web.xml +++ b/nifi-registry-web-ui/src/main/webapp/WEB-INF/web.xml @@ -26,6 +26,16 @@ /fluid-design-system + + + Login + /WEB-INF/pages/index.jsp + + + Login + /login/* + + Administration diff --git a/nifi-registry-web-ui/src/main/webapp/components/administration/nf-registry-administration.html b/nifi-registry-web-ui/src/main/webapp/components/administration/nf-registry-administration.html index 604af59..23f40a0 100644 --- a/nifi-registry-web-ui/src/main/webapp/components/administration/nf-registry-administration.html +++ b/nifi-registry-web-ui/src/main/webapp/components/administration/nf-registry-administration.html @@ -17,16 +17,22 @@ limitations under the License.
- + fxLayoutAlign="space-between center" class="tab-toggle-group"> + Buckets - + Users diff --git a/nifi-registry-web-ui/src/main/webapp/components/administration/nf-registry-administration.js b/nifi-registry-web-ui/src/main/webapp/components/administration/nf-registry-administration.js index 3a8376e..beba08d 100644 --- a/nifi-registry-web-ui/src/main/webapp/components/administration/nf-registry-administration.js +++ b/nifi-registry-web-ui/src/main/webapp/components/administration/nf-registry-administration.js @@ -23,11 +23,11 @@ var ngRouter = require('@angular/router'); * NfRegistryAdministration constructor. * * @param nfRegistryService The nf-registry.service module. - * @param ActivatedRoute The angular activated route module. + * @param router The angular router module. * @constructor */ -function NfRegistryAdministration(nfRegistryService, ActivatedRoute) { - this.route = ActivatedRoute; +function NfRegistryAdministration(nfRegistryService, router) { + this.router = router; this.nfRegistryService = nfRegistryService; }; @@ -49,6 +49,33 @@ NfRegistryAdministration.prototype = { ngOnDestroy: function () { this.nfRegistryService.perspective = ''; this.nfRegistryService.setBreadcrumbState('out'); + }, + + /** + * Navigates to admin perspective. + * + * @param $event + */ + navigateToAdminPerspective: function($event) { + this.router.navigateByUrl('nifi-registry/administration/' + $event.value); + }, + + /** + * Generate the user tab tooltip. + * + * @returns {*} + */ + getUserTooltip: function() { + if(this.nfRegistryService.currentUser.anonymous) { + return 'Please configure NiFi Registry security to enable.'; + } + else { + if(!this.nfRegistryService.currentUser.resourcePermissions.tenants.canRead) { + return 'You do not have permission. Please contact your System Administrator.' + } else { + return 'Manage NiFi Registry users and groups.' + } + } } }; @@ -64,7 +91,7 @@ NfRegistryAdministration.annotations = [ NfRegistryAdministration.parameters = [ NfRegistryService, - ngRouter.ActivatedRoute + ngRouter.Router ]; module.exports = NfRegistryAdministration; diff --git a/nifi-registry-web-ui/src/main/webapp/components/administration/nf-registry-administration.spec.js b/nifi-registry-web-ui/src/main/webapp/components/administration/nf-registry-administration.spec.js index 4cc7cf8..258ae06 100644 --- a/nifi-registry-web-ui/src/main/webapp/components/administration/nf-registry-administration.spec.js +++ b/nifi-registry-web-ui/src/main/webapp/components/administration/nf-registry-administration.spec.js @@ -32,9 +32,8 @@ var NfRegistryExplorer = require('nifi-registry/components/explorer/nf-registry- var NfRegistryAdministration = require('nifi-registry/components/administration/nf-registry-administration.js'); var NfRegistryUsersAdministration = require('nifi-registry/components/administration/users/nf-registry-users-administration.js'); var NfRegistryAddUser = require('nifi-registry/components/administration/users/dialogs/add-user/nf-registry-add-user.js'); -var NfRegistryUserDetails = require('nifi-registry/components/administration/users/details/nf-registry-user-details.js'); -var NfRegistryUserPermissions = require('nifi-registry/components/administration/users/permissions/nf-registry-user-permissions.js'); -var NfRegistryUserGroupPermissions = require('nifi-registry/components/administration/user-group/permissions/nf-registry-user-group-permissions.js'); +var NfRegistryManageUser = require('nifi-registry/components/administration/users/sidenav/manage-user/nf-registry-manage-user.js'); +var NfRegistryManageGroup = require('nifi-registry/components/administration/users/sidenav/manage-group/nf-registry-manage-group.js'); var NfRegistryBucketPermissions = require('nifi-registry/components/administration/workflow/buckets/permissions/nf-registry-bucket-permissions.js'); var NfRegistryWorkflowAdministration = require('nifi-registry/components/administration/workflow/nf-registry-workflow-administration.js'); var NfRegistryGridListViewer = require('nifi-registry/components/explorer/grid-list/registry/nf-registry-grid-list-viewer.js'); @@ -43,6 +42,8 @@ var NfRegistryDropletGridListViewer = require('nifi-registry/components/explorer var fdsCore = require('@fluid-design-system/core'); var ngMoment = require('angular2-moment'); var rxjs = require('rxjs/Rx'); +var NfLoginComponent = require('nifi-registry/components/login/nf-registry-login.js'); +var NfUserLoginComponent = require('nifi-registry/components/login/dialogs/nf-registry-user-login.js'); describe('NfRegistryAdministration Component', function () { var comp; @@ -66,16 +67,17 @@ describe('NfRegistryAdministration Component', function () { NfRegistryExplorer, NfRegistryAdministration, NfRegistryUsersAdministration, - NfRegistryUserDetails, - NfRegistryUserPermissions, - NfRegistryUserGroupPermissions, + NfRegistryManageUser, + NfRegistryManageGroup, NfRegistryBucketPermissions, NfRegistryAddUser, NfRegistryWorkflowAdministration, NfRegistryGridListViewer, NfRegistryBucketGridListViewer, NfRegistryDropletGridListViewer, - NfPageNotFoundComponent + NfPageNotFoundComponent, + NfLoginComponent, + NfUserLoginComponent ], providers: [ NfRegistryService, diff --git a/nifi-registry-web-ui/src/main/webapp/components/administration/user-group/permissions/nf-registry-user-group-permissions.html b/nifi-registry-web-ui/src/main/webapp/components/administration/user-group/permissions/nf-registry-user-group-permissions.html deleted file mode 100644 index f67161c..0000000 --- a/nifi-registry-web-ui/src/main/webapp/components/administration/user-group/permissions/nf-registry-user-group-permissions.html +++ /dev/null @@ -1,28 +0,0 @@ - - -
-
- {{nfRegistryService.group.identity}} - -
- -
diff --git a/nifi-registry-web-ui/src/main/webapp/components/administration/user-group/permissions/nf-registry-user-group-permissions.js b/nifi-registry-web-ui/src/main/webapp/components/administration/user-group/permissions/nf-registry-user-group-permissions.js deleted file mode 100644 index fe20949..0000000 --- a/nifi-registry-web-ui/src/main/webapp/components/administration/user-group/permissions/nf-registry-user-group-permissions.js +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -var ngCore = require('@angular/core'); -var NfRegistryService = require('nifi-registry/services/nf-registry.service.js'); -var ngRouter = require('@angular/router'); - -/** - * NfRegistryUserGroupsPermissions constructor. - * - * @param nfRegistryService The nf-registry.service module. - * @param Router The angular router module. - * @constructor - */ -function NfRegistryUserGroupsPermissions(nfRegistryService, Router) { - this.nfRegistryService = nfRegistryService; - this.router = Router; -}; - -NfRegistryUserGroupsPermissions.prototype = { - constructor: NfRegistryUserGroupsPermissions, - - /** - * Initialize the component. - */ - ngOnInit: function () { - this.nfRegistryService.sidenav.open(); - }, - - /** - * Destroy the component. - */ - ngOnDestroy: function () { - this.nfRegistryService.group = {}; - this.nfRegistryService.sidenav.close(); - }, - - /** - * Navigate to administer users for current registry. - */ - closeSideNav: function () { - this.router.navigateByUrl('/nifi-registry/administration/users'); - } -}; - -NfRegistryUserGroupsPermissions.annotations = [ - new ngCore.Component({ - template: require('./nf-registry-user-group-permissions.html!text') - }) -]; - -NfRegistryUserGroupsPermissions.parameters = [ - NfRegistryService, - ngRouter.Router -]; - -module.exports = NfRegistryUserGroupsPermissions; diff --git a/nifi-registry-web-ui/src/main/webapp/components/administration/users/details/nf-registry-user-details.js b/nifi-registry-web-ui/src/main/webapp/components/administration/users/details/nf-registry-user-details.js deleted file mode 100644 index ba676b3..0000000 --- a/nifi-registry-web-ui/src/main/webapp/components/administration/users/details/nf-registry-user-details.js +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -var ngCore = require('@angular/core'); -var NfRegistryService = require('nifi-registry/services/nf-registry.service.js'); -var ngRouter = require('@angular/router'); - -/** - * NfRegistryUserDetails constructor. - * - * @param nfRegistryService The nf-registry.service module. - * @param Router The angular router module. - * @constructor - */ -function NfRegistryUserDetails(nfRegistryService, Router) { - this.nfRegistryService = nfRegistryService; - this.router = Router; -}; - -NfRegistryUserDetails.prototype = { - constructor: NfRegistryUserDetails, - - /** - * Initialize the component. - */ - ngOnInit: function () { - this.nfRegistryService.sidenav.open(); - }, - - /** - * Destroy the component. - */ - ngOnDestroy: function () { - this.nfRegistryService.sidenav.close(); - }, - - /** - * Navigate to administer users for current registry. - */ - closeSideNav: function () { - this.router.navigateByUrl('/nifi-registry/administration/users'); - } -}; - -NfRegistryUserDetails.annotations = [ - new ngCore.Component({ - template: require('./nf-registry-user-details.html!text') - }) -]; - -NfRegistryUserDetails.parameters = [ - NfRegistryService, - ngRouter.Router -]; - -module.exports = NfRegistryUserDetails; diff --git a/nifi-registry-web-ui/src/main/webapp/components/administration/users/dialogs/add-selected-users-to-group/nf-registry-add-selected-users-to-group.html b/nifi-registry-web-ui/src/main/webapp/components/administration/users/dialogs/add-user-to-groups/nf-registry-add-user-to-groups.html similarity index 79% rename from nifi-registry-web-ui/src/main/webapp/components/administration/users/dialogs/add-selected-users-to-group/nf-registry-add-selected-users-to-group.html rename to nifi-registry-web-ui/src/main/webapp/components/administration/users/dialogs/add-user-to-groups/nf-registry-add-user-to-groups.html index e76e898..c3103e3 100644 --- a/nifi-registry-web-ui/src/main/webapp/components/administration/users/dialogs/add-selected-users-to-group/nf-registry-add-selected-users-to-group.html +++ b/nifi-registry-web-ui/src/main/webapp/components/administration/users/dialogs/add-user-to-groups/nf-registry-add-user-to-groups.html @@ -17,15 +17,15 @@ limitations under the License.
- Add to group + Add user to groups
-
+
-
{{column.label}}
-
-
+
{{column.format ? column.format(row[column.name]) : row[column.name]}}
- @@ -60,13 +61,17 @@ limitations under the License.
+
+

User belongs to all groups.

+
- +
+
+
+
+ {{column.label}} + + +
+
+ +
+
+
+
+
+
+
+ {{column.format ? + column.format(row[column.name]) : row[column.name]}} +
+
+
+ + +
+
+
+
+
+
+

All users belong to this group.

+
+
+ + + +
+
diff --git a/nifi-registry-web-ui/src/main/webapp/components/administration/users/dialogs/add-users-to-group/nf-registry-add-users-to-group.js b/nifi-registry-web-ui/src/main/webapp/components/administration/users/dialogs/add-users-to-group/nf-registry-add-users-to-group.js new file mode 100644 index 0000000..75f2385 --- /dev/null +++ b/nifi-registry-web-ui/src/main/webapp/components/administration/users/dialogs/add-users-to-group/nf-registry-add-users-to-group.js @@ -0,0 +1,234 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var covalentCore = require('@covalent/core'); +var NfRegistryApi = require('nifi-registry/services/nf-registry.api.js'); +var ngCore = require('@angular/core'); +var fdsSnackBarsModule = require('@fluid-design-system/snackbars'); +var NfRegistryService = require('nifi-registry/services/nf-registry.service.js'); +var ngMaterial = require('@angular/material'); +var $ = require('jquery'); + +/** + * NfRegistryAddUsersToGroup constructor. + * + * @param nfRegistryApi The api service. + * @param tdDataTableService The covalent data table service module. + * @param nfRegistryService The nf-registry.service module. + * @param matDialogRef The angular material dialog ref. + * @param fdsSnackBarService The FDS snack bar service module. + * @param data The data passed into this component. + * @constructor + */ +function NfRegistryAddUsersToGroup(nfRegistryApi, tdDataTableService, nfRegistryService, matDialogRef, fdsSnackBarService, data) { + this.dataTableService = tdDataTableService; + this.snackBarService = fdsSnackBarService; + this.nfRegistryService = nfRegistryService; + this.nfRegistryApi = nfRegistryApi; + this.dialogRef = matDialogRef; + this.data = data; + //make an independent copy of the users for sorting and selecting within the scope of this component + this.users = $.extend(true, [], this.nfRegistryService.users); + this.filteredUsers = []; + this.isAddSelectedUsersToGroupDisabled = true; + this.usersSearchTerms = []; + this.allUsersSelected = false; +}; + +NfRegistryAddUsersToGroup.prototype = { + constructor: NfRegistryAddUsersToGroup, + + /** + * Initialize the component. + */ + ngOnInit: function () { + var self = this; + + this.data.group.users.forEach(function (groupUser) { + self.users = self.users.filter(function (user) { + return (user.identifier !== groupUser.identifier) ? true : false + }); + }); + + this.filterUsers(); + this.determineAllUsersSelectedState(); + }, + + /** + * Filter users. + * + * @param {string} [sortBy] The column name to sort `userGroupsColumns` by. + * @param {string} [sortOrder] The order. Either 'ASC' or 'DES' + */ + filterUsers: function (sortBy, sortOrder) { + // if `sortOrder` is `undefined` then use 'ASC' + if (sortOrder === undefined) { + sortOrder = 'ASC' + } + // if `sortBy` is `undefined` then find the first sortable column in `dropletColumns` + if (sortBy === undefined) { + var arrayLength = this.nfRegistryService.userGroupsColumns.length; + for (var i = 0; i < arrayLength; i++) { + if (this.nfRegistryService.userGroupsColumns[i].sortable === true) { + sortBy = this.nfRegistryService.userGroupsColumns[i].name; + //only one column can be actively sorted so we reset all to inactive + this.nfRegistryService.userGroupsColumns.forEach(function (c) { + c.active = false; + }); + //and set this column as the actively sorted column + this.nfRegistryService.userGroupsColumns[i].active = true; + this.nfRegistryService.userGroupsColumns[i].sortOrder = sortOrder; + break; + } + } + } + + var newUsersData = this.users; + + for (var i = 0; i < this.usersSearchTerms.length; i++) { + newUsersData = this.nfRegistryService.filterData(newUsersData, this.usersSearchTerms[i], true); + } + + newUsersData = this.dataTableService.sortData(newUsersData, sortBy, sortOrder); + this.filteredUsers = newUsersData; + }, + + /** + * Sort `filteredUsers` by `column`. + * + * @param column The column to sort by. + */ + sortUsers: function (column) { + if (column.sortable) { + var sortBy = column.name; + var sortOrder = column.sortOrder = (column.sortOrder === 'ASC') ? 'DESC' : 'ASC'; + this.filterUsers(sortBy, sortOrder); + } + }, + + /** + * Checks the `allUsersSelected` property state and either selects + * or deselects each of the `filteredUsers`. + */ + toggleUsersSelectAll: function () { + if (this.allUsersSelected) { + this.selectAllUsers(); + } else { + this.deselectAllUsers(); + } + }, + + /** + * Sets the `checked` property of each of the `filteredUsers` to true + * and sets the `isAddSelectedUsersToGroupDisabled` and the `allUsersSelected` + * properties accordingly. + */ + selectAllUsers: function () { + this.filteredUsers.forEach(function (c) { + c.checked = true; + }); + this.isAddSelectedUsersToGroupDisabled = false; + this.allUsersSelected = true; + }, + + /** + * Sets the `checked` property of each group to false + * and sets the `isAddSelectedUsersToGroupDisabled` and the `allUsersSelected` + * properties accordingly. + */ + deselectAllUsers: function () { + this.filteredUsers.forEach(function (c) { + c.checked = false; + }); + this.isAddSelectedUsersToGroupDisabled = true; + this.allUsersSelected = false; + }, + + /** + * Checks of each of the `filteredUsers`'s checked property state + * and sets the `allBucketsSelected` and `isAddSelectedUsersToGroupDisabled` + * property accordingly. + */ + determineAllUsersSelectedState: function () { + var selected = 0; + var allSelected = true; + this.filteredUsers.forEach(function (c) { + if (c.checked) { + selected++; + } + if (c.checked === undefined || c.checked === false) { + allSelected = false; + } + }); + + if (selected > 0) { + this.isAddSelectedUsersToGroupDisabled = false; + } else { + this.isAddSelectedUsersToGroupDisabled = true; + } + + this.allUsersSelected = allSelected; + }, + + /** + * Adds each of the selected users to this group. + */ + addSelectedUsersToGroup: function () { + var self = this; + this.filteredUsers.filter(function (filteredUser) { + if(filteredUser.checked) { + self.data.group.users.push(filteredUser); + } + }); + this.nfRegistryApi.updateUserGroup(self.data.group.identifier, self.data.group.identity, self.data.group.users).subscribe(function (group) { + self.dialogRef.close(); + var snackBarRef = self.snackBarService.openCoaster({ + title: 'Success', + message: 'Selected users have been added to the ' + self.data.group.identity + ' group.', + verticalPosition: 'bottom', + horizontalPosition: 'right', + icon: 'fa fa-check-circle-o', + color: '#1EB475', + duration: 3000 + }); + }); + }, + + /** + * Cancel adding selected users to groups and close the dialog. + */ + cancel: function () { + this.dialogRef.close(); + } +}; + +NfRegistryAddUsersToGroup.annotations = [ + new ngCore.Component({ + template: require('./nf-registry-add-users-to-group.html!text') + }) +]; + +NfRegistryAddUsersToGroup.parameters = [ + NfRegistryApi, + covalentCore.TdDataTableService, + NfRegistryService, + ngMaterial.MatDialogRef, + fdsSnackBarsModule.FdsSnackBarService, + ngMaterial.MAT_DIALOG_DATA +]; + +module.exports = NfRegistryAddUsersToGroup; diff --git a/nifi-registry-web-ui/src/main/webapp/components/administration/users/dialogs/add-users-to-group/nf-registry-add-users-to-group.spec.js b/nifi-registry-web-ui/src/main/webapp/components/administration/users/dialogs/add-users-to-group/nf-registry-add-users-to-group.spec.js new file mode 100644 index 0000000..d8e41cb --- /dev/null +++ b/nifi-registry-web-ui/src/main/webapp/components/administration/users/dialogs/add-users-to-group/nf-registry-add-users-to-group.spec.js @@ -0,0 +1,170 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the 'License'); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var NfRegistryApi = require('nifi-registry/services/nf-registry.api.js'); +var NfRegistryService = require('nifi-registry/services/nf-registry.service.js'); +var NfRegistryAddUsersToGroup = require('nifi-registry/components/administration/users/dialogs/add-users-to-group/nf-registry-add-users-to-group.js'); +var rxjs = require('rxjs/Rx'); +var covalentCore = require('@covalent/core'); +var fdsSnackBarsModule = require('@fluid-design-system/snackbars'); + +describe('NfRegistryAddUsersToGroup Component isolated unit tests', function () { + var comp; + var nfRegistryService; + var nfRegistryApi; + var snackBarService; + var dataTableService; + + beforeEach(function () { + nfRegistryService = new NfRegistryService(); + // setup the nfRegistryService + nfRegistryService.group = {identifier: 1, identity: 'Group 1', users: []}; + nfRegistryService.users = [{identifier: 2, identity: 'User 1', checked: true}]; + + nfRegistryApi = new NfRegistryApi(); + snackBarService = new fdsSnackBarsModule.FdsSnackBarService(); + dataTableService = new covalentCore.TdDataTableService(); + comp = new NfRegistryAddUsersToGroup(nfRegistryApi, dataTableService, nfRegistryService, { + close: function () { + } + }, snackBarService, {group: nfRegistryService.group}); + + // Spy + spyOn(nfRegistryApi, 'updateUserGroup').and.callFake(function () { + }).and.returnValue(rxjs.Observable.of({identifier: 1, identity: 'Group 1'})); + spyOn(comp.dialogRef, 'close'); + spyOn(comp.snackBarService, 'openCoaster'); + spyOn(comp, 'filterUsers').and.callThrough(); + + // initialize the component + comp.ngOnInit(); + + //assertions + expect(comp.filterUsers).toHaveBeenCalled(); + expect(comp.filteredUsers[0].identity).toEqual('User 1'); + expect(comp.filteredUsers.length).toBe(1); + expect(comp).toBeDefined(); + }); + + it('should make a call to the api to add selected users to the group', function () { + // select a group + comp.filteredUsers[0].checked = true; + + // the function to test + comp.addSelectedUsersToGroup(); + + //assertions + expect(comp.dialogRef.close).toHaveBeenCalled(); + expect(comp.snackBarService.openCoaster).toHaveBeenCalled(); + }); + + it('should determine if all users are selected', function () { + // select a group + comp.filteredUsers[0].checked = true; + + // the function to test + comp.determineAllUsersSelectedState(); + + //assertions + expect(comp.allUsersSelected).toBe(true); + expect(comp.isAddSelectedUsersToGroupDisabled).toBe(false); + }); + + it('should determine all user groups are not selected', function () { + // select a group + comp.filteredUsers[0].checked = false; + + // the function to test + comp.determineAllUsersSelectedState(); + + //assertions + expect(comp.allUsersSelected).toBe(false); + expect(comp.isAddSelectedUsersToGroupDisabled).toBe(true); + }); + + it('should select all groups.', function () { + // The function to test + comp.selectAllUsers(); + + //assertions + expect(comp.filteredUsers[0].checked).toBe(true); + expect(comp.isAddSelectedUsersToGroupDisabled).toBe(false); + expect(comp.allUsersSelected).toBe(true); + }); + + it('should deselect all groups.', function () { + // select a group + comp.filteredUsers[0].checked = true; + + // The function to test + comp.deselectAllUsers(); + + //assertions + expect(comp.filteredUsers[0].checked).toBe(false); + expect(comp.isAddSelectedUsersToGroupDisabled).toBe(true); + expect(comp.allUsersSelected).toBe(false); + }); + + it('should toggle all groups `checked` properties to true.', function () { + //Spy + spyOn(comp, 'selectAllUsers').and.callFake(function () { + }); + + comp.allUsersSelected = true; + + // The function to test + comp.toggleUsersSelectAll(); + + //assertions + expect(comp.selectAllUsers).toHaveBeenCalled(); + }); + + it('should toggle all groups `checked` properties to false.', function () { + //Spy + spyOn(comp, 'deselectAllUsers').and.callFake(function () { + }); + + comp.allUsersSelected = false; + + // The function to test + comp.toggleUsersSelectAll(); + + //assertions + expect(comp.deselectAllUsers).toHaveBeenCalled(); + }); + + it('should sort `groups` by `column`', function () { + // object to be updated by the test + var column = {name: 'name', label: 'Group Name', sortable: true}; + + // The function to test + comp.sortUsers(column); + + //assertions + var filterUsersCall = comp.filterUsers.calls.mostRecent(); + expect(filterUsersCall.args[0]).toBe('name'); + expect(filterUsersCall.args[1]).toBe('ASC'); + }); + + it('should cancel the creation of a new user', function () { + // the function to test + comp.cancel(); + + //assertions + expect(comp.dialogRef.close).toHaveBeenCalled(); + }); +}); \ No newline at end of file diff --git a/nifi-registry-web-ui/src/main/webapp/components/administration/users/nf-registry-users-administration.html b/nifi-registry-web-ui/src/main/webapp/components/administration/users/nf-registry-users-administration.html index b7fe21c..59e8cfd 100644 --- a/nifi-registry-web-ui/src/main/webapp/components/administration/users/nf-registry-users-administration.html +++ b/nifi-registry-web-ui/src/main/webapp/components/administration/users/nf-registry-users-administration.html @@ -40,10 +40,6 @@ limitations under the License. (click)="createNewGroup()"> Create new group -
@@ -75,9 +71,9 @@ limitations under the License.
-
+
-
+
-
+
@@ -124,9 +120,9 @@ limitations under the License.
-
+
-
+
-
+
diff --git a/nifi-registry-web-ui/src/main/webapp/components/administration/users/nf-registry-users-administration.js b/nifi-registry-web-ui/src/main/webapp/components/administration/users/nf-registry-users-administration.js index 1fdef66..2cc8ff1 100644 --- a/nifi-registry-web-ui/src/main/webapp/components/administration/users/nf-registry-users-administration.js +++ b/nifi-registry-web-ui/src/main/webapp/components/administration/users/nf-registry-users-administration.js @@ -25,7 +25,6 @@ var ngMaterial = require('@angular/material'); var fdsDialogsModule = require('@fluid-design-system/dialogs'); var NfRegistryAddUser = require('nifi-registry/components/administration/users/dialogs/add-user/nf-registry-add-user.js'); var NfRegistryCreateNewGroup = require('nifi-registry/components/administration/users/dialogs/create-new-group/nf-registry-create-new-group.js'); -var NfRegistryAddSelectedUsersToGroup = require('nifi-registry/components/administration/users/dialogs/add-selected-users-to-group/nf-registry-add-selected-users-to-group.js'); /** * NfRegistryUsersAdministration constructor. @@ -45,26 +44,6 @@ function NfRegistryUsersAdministration(nfRegistryApi, nfStorage, nfRegistryServi this.nfRegistryApi = nfRegistryApi; this.dialogService = fdsDialogService; this.dialog = matDialog; - this.usersActions = [{ - name: 'permissions', - icon: 'fa fa-pencil', - tooltip: 'Manage User Policies', - type: 'sidenav' - }, { - name: 'Delete', - icon: 'fa fa-trash', - tooltip: 'Delete User' - }]; - this.userGroupsActions = [{ - name: 'permissions', - icon: 'fa fa-pencil', - tooltip: 'Manage User Group Policies', - type: 'sidenav' - }, { - name: 'Delete', - icon: 'fa fa-trash', - tooltip: 'Delete User Group' - }]; }; NfRegistryUsersAdministration.prototype = { @@ -76,27 +55,22 @@ NfRegistryUsersAdministration.prototype = { ngOnInit: function () { var self = this; this.nfRegistryService.inProgress = true; - // attempt kerberos authentication - this.nfRegistryApi.ticketExchange().subscribe(function (jwt) { - self.nfRegistryService.loadCurrentUser().subscribe(function (currentUser) { - self.route.params - .switchMap(function (params) { - self.nfRegistryService.adminPerspective = 'users'; - return new rxjs.Observable.forkJoin( - self.nfRegistryApi.getUsers(), - self.nfRegistryApi.getUserGroups() - ); - }) - .subscribe(function (response) { - var users = response[0]; - var groups = response[1]; - self.nfRegistryService.users = users; - self.nfRegistryService.groups = groups; - self.nfRegistryService.filterUsersAndGroups(); - self.nfRegistryService.inProgress = false; - }); + this.route.params + .switchMap(function (params) { + self.nfRegistryService.adminPerspective = 'users'; + return new rxjs.Observable.forkJoin( + self.nfRegistryApi.getUsers(), + self.nfRegistryApi.getUserGroups() + ); + }) + .subscribe(function (response) { + var users = response[0]; + var groups = response[1]; + self.nfRegistryService.users = users; + self.nfRegistryService.groups = groups; + self.nfRegistryService.filterUsersAndGroups(); + self.nfRegistryService.inProgress = false; }); - }); }, /** @@ -121,23 +95,6 @@ NfRegistryUsersAdministration.prototype = { */ createNewGroup: function () { this.dialog.open(NfRegistryCreateNewGroup); - }, - - /** - * Opens the add selected users to groups dialog. - */ - addSelectedUsersToGroup: function () { - if (this.nfRegistryService.getSelectedGroups().length === 0) { - // ok...only users are currently selected...go ahead and open the dialog to select groups - this.dialog.open(NfRegistryAddSelectedUsersToGroup); - } else { - self.dialogService.openConfirm({ - title: 'Error: Groups may not be added to a group. Please deselect any groups and try again', - message: error.message, - acceptButton: 'Ok', - acceptButtonColor: 'fds-warn' - }); - } } }; diff --git a/nifi-registry-web-ui/src/main/webapp/components/administration/users/nf-registry-users-adminstration.spec.js b/nifi-registry-web-ui/src/main/webapp/components/administration/users/nf-registry-users-adminstration.spec.js index 80fd245..9260dc3 100644 --- a/nifi-registry-web-ui/src/main/webapp/components/administration/users/nf-registry-users-adminstration.spec.js +++ b/nifi-registry-web-ui/src/main/webapp/components/administration/users/nf-registry-users-adminstration.spec.js @@ -30,9 +30,8 @@ var NfRegistryExplorer = require('nifi-registry/components/explorer/nf-registry- var NfRegistryAdministration = require('nifi-registry/components/administration/nf-registry-administration.js'); var NfRegistryUsersAdministration = require('nifi-registry/components/administration/users/nf-registry-users-administration.js'); var NfRegistryAddUser = require('nifi-registry/components/administration/users/dialogs/add-user/nf-registry-add-user.js'); -var NfRegistryUserDetails = require('nifi-registry/components/administration/users/details/nf-registry-user-details.js'); -var NfRegistryUserPermissions = require('nifi-registry/components/administration/users/permissions/nf-registry-user-permissions.js'); -var NfRegistryUserGroupPermissions = require('nifi-registry/components/administration/user-group/permissions/nf-registry-user-group-permissions.js'); +var NfRegistryManageUser = require('nifi-registry/components/administration/users/sidenav/manage-user/nf-registry-manage-user.js'); +var NfRegistryManageGroup = require('nifi-registry/components/administration/users/sidenav/manage-group/nf-registry-manage-group.js'); var NfRegistryBucketPermissions = require('nifi-registry/components/administration/workflow/buckets/permissions/nf-registry-bucket-permissions.js'); var NfRegistryWorkflowAdministration = require('nifi-registry/components/administration/workflow/nf-registry-workflow-administration.js'); var NfRegistryCreateBucket = require('nifi-registry/components/administration/workflow/dialogs/nf-registry-create-bucket.js'); @@ -46,6 +45,8 @@ var ngCommonHttp = require('@angular/common/http'); var NfRegistryTokenInterceptor = require('nifi-registry/services/nf-registry.token.interceptor.js'); var NfRegistryAuthService = require('nifi-registry/services/nf-registry.auth.service.js'); var NfStorage = require('nifi-registry/services/nf-storage.service.js'); +var NfLoginComponent = require('nifi-registry/components/login/nf-registry-login.js'); +var NfUserLoginComponent = require('nifi-registry/components/login/dialogs/nf-registry-user-login.js'); describe('NfRegistryUsersAdministration Component', function () { var comp; @@ -70,9 +71,8 @@ describe('NfRegistryUsersAdministration Component', function () { NfRegistryExplorer, NfRegistryAdministration, NfRegistryUsersAdministration, - NfRegistryUserDetails, - NfRegistryUserPermissions, - NfRegistryUserGroupPermissions, + NfRegistryManageUser, + NfRegistryManageGroup, NfRegistryBucketPermissions, NfRegistryAddUser, NfRegistryWorkflowAdministration, @@ -80,7 +80,9 @@ describe('NfRegistryUsersAdministration Component', function () { NfRegistryGridListViewer, NfRegistryBucketGridListViewer, NfRegistryDropletGridListViewer, - NfPageNotFoundComponent + NfPageNotFoundComponent, + NfLoginComponent, + NfUserLoginComponent ], entryComponents: [ NfRegistryCreateBucket @@ -173,17 +175,6 @@ describe('NfRegistryUsersAdministration Component', function () { expect(comp.dialog.open).toHaveBeenCalled(); }); - it('should open a dialog to add selected users to groups', function () { - spyOn(comp.dialog, 'open') - fixture.detectChanges(); - - // the function to test - comp.addSelectedUsersToGroup(); - - //assertions - expect(comp.dialog.open).toHaveBeenCalled(); - }); - it('should destroy the component', ngCoreTesting.fakeAsync(function () { fixture.detectChanges(); // wait for async getBucket call diff --git a/nifi-registry-web-ui/src/main/webapp/components/administration/users/sidenav/manage-group/nf-registry-manage-group.html b/nifi-registry-web-ui/src/main/webapp/components/administration/users/sidenav/manage-group/nf-registry-manage-group.html new file mode 100644 index 0000000..f9e2138 --- /dev/null +++ b/nifi-registry-web-ui/src/main/webapp/components/administration/users/sidenav/manage-group/nf-registry-manage-group.html @@ -0,0 +1,154 @@ + + +
+
+ {{nfRegistryService.group.identity}} + +
+
+ + + + +
+
+
+ Special Privileges + + +
+ + Can manage buckets + +
+ + Read + + + Write + + + Delete + +
+ + Can manage users + +
+ + Read + + + Write + + + Delete + +
+ + Can manage policies + +
+ + Read + + + Write + + + Delete + +
+ + Can proxy user requests + +
+ + + Membership + + +
+
+
+ Membership ({{nfRegistryService.group.users.length}}) + +
+
+
+ {{column.label}} + + +
+
+
+
+
+
+ {{column.format ? column.format(row[column.name]) : row[column.name]}} +
+
+
+
+ +
+
+
+
+
+

This group does not have any users yet.

+
+
+
+ +
diff --git a/nifi-registry-web-ui/src/main/webapp/components/administration/users/sidenav/manage-group/nf-registry-manage-group.js b/nifi-registry-web-ui/src/main/webapp/components/administration/users/sidenav/manage-group/nf-registry-manage-group.js new file mode 100644 index 0000000..a519887 --- /dev/null +++ b/nifi-registry-web-ui/src/main/webapp/components/administration/users/sidenav/manage-group/nf-registry-manage-group.js @@ -0,0 +1,577 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var covalentCore = require('@covalent/core'); +var fdsDialogsModule = require('@fluid-design-system/dialogs'); +var fdsSnackBarsModule = require('@fluid-design-system/snackbars'); +var ngCore = require('@angular/core'); +var NfRegistryService = require('nifi-registry/services/nf-registry.service.js'); +var ngRouter = require('@angular/router'); +var NfRegistryApi = require('nifi-registry/services/nf-registry.api.js'); +var ngMaterial = require('@angular/material'); +var NfRegistryAddUsersToGroup = require('nifi-registry/components/administration/users/dialogs/add-users-to-group/nf-registry-add-users-to-group.js'); + +/** + * NfRegistryManageGroup constructor. + * + * @param nfRegistryApi The api service. + * @param nfRegistryService The nf-registry.service module. + * @param tdDataTableService The covalent data table service module. + * @param fdsDialogService The FDS dialog service. + * @param fdsSnackBarService The FDS snack bar service module. + * @param activatedRoute The angular route module. + * @param router The angular router module. + * @param matDialog The angular material dialog module. + * @constructor + */ +function NfRegistryManageGroup(nfRegistryApi, nfRegistryService, tdDataTableService, fdsDialogService, fdsSnackBarService, activatedRoute, router, matDialog) { + this.filteredUsers = []; + this.usersSearchTerms = []; + this._groupname = ''; + this.manageGroupPerspective = 'membership'; + + // Services + this.nfRegistryService = nfRegistryService; + this.route = activatedRoute; + this.router = router; + this.dialog = matDialog; + this.nfRegistryApi = nfRegistryApi; + this.dialogService = fdsDialogService; + this.snackBarService = fdsSnackBarService; + this.dataTableService = tdDataTableService; +}; + +NfRegistryManageGroup.prototype = { + constructor: NfRegistryManageGroup, + + /** + * Initialize the component. + */ + ngOnInit: function () { + var self = this; + this.nfRegistryService.sidenav.open(); + + // subscribe to the route params + self.route.params + .switchMap(function (params) { + return self.nfRegistryApi.getUserGroup(params['groupId']); + }) + .subscribe(function (response) { + self.nfRegistryService.group = response; + self._groupname = response.identity; + self.filterUsers(); + }); + }, + + /** + * Destroy the component. + */ + ngOnDestroy: function () { + this.nfRegistryService.sidenav.close(); + }, + + /** + * Navigate to administer users for current registry. + */ + closeSideNav: function () { + this.router.navigateByUrl('/nifi-registry/administration/users'); + }, + + /** + * Toggles the manage bucket privileges for the group. + * + * @param $event + * @param policyAction The action to be toggled + */ + toggleGroupManageBucketsPrivileges: function ($event, policyAction) { + var self = this; + if ($event.checked) { + for (var resource in this.nfRegistryService.BUCKETS_PRIVS) { + if (this.nfRegistryService.BUCKETS_PRIVS.hasOwnProperty(resource)) { + this.nfRegistryService.BUCKETS_PRIVS[resource].forEach(function (action) { + if (!policyAction || (action === policyAction)) { + self.nfRegistryApi.getPolicyActionResource(action, resource).subscribe(function (policy) { + if (policy.status && policy.status === 409) { + // resource does NOT exist, let's create it + self.nfRegistryApi.postPolicyActionResource(action, resource, self.nfRegistryService.group.users, []).subscribe( + function (response) { + // can manage buckets privileges created and granted!!!...now update the view + response.userGroups.forEach(function (group) { + if (group.identifier === self.nfRegistryService.group.identifier) { + self.nfRegistryApi.getUserGroup(self.nfRegistryService.group.identifier).subscribe(function(response) { + self.nfRegistryService.group = response; + }); + } + }); + }); + } else { + // resource exists, let's update it + policy.userGroups.push(self.nfRegistryService.group); + self.nfRegistryApi.putPolicyActionResource(policy.identifier, policy.action, + policy.resource, policy.users, policy.userGroups).subscribe( + function (response) { + // can manage buckets privileges updated!!!...now update the view + response.userGroups.forEach(function (group) { + if (group.identifier === self.nfRegistryService.group.identifier) { + self.nfRegistryApi.getUserGroup(self.nfRegistryService.group.identifier).subscribe(function(response) { + self.nfRegistryService.group = response; + }); + } + }); + }); + } + }); + } + }); + } + } + } else { + // Remove the current group from the administrator resources + for (var resource in this.nfRegistryService.BUCKETS_PRIVS) { + if (this.nfRegistryService.BUCKETS_PRIVS.hasOwnProperty(resource)) { + this.nfRegistryService.BUCKETS_PRIVS[resource].forEach(function (action) { + if (!policyAction || (action === policyAction)) { + self.nfRegistryApi.getPolicyActionResource(action, resource).subscribe(function (policy) { + if (policy.status && policy.status === 409) { + // resource does NOT exist + } else { + // resource exists, let's filter out the current group and update it + policy.userGroups = policy.userGroups.filter(function (group) { + return (group.identifier !== self.nfRegistryService.group.identifier) ? true : false; + }); + self.nfRegistryApi.putPolicyActionResource(policy.identifier, policy.action, + policy.resource, policy.users, policy.userGroups).subscribe( + function (response) { + // can manage buckets privileges updated!!!...now update the view + self.nfRegistryApi.getUserGroup(self.nfRegistryService.group.identifier).subscribe(function(response) { + self.nfRegistryService.group = response; + }); + }); + } + }); + } + }); + } + } + + } + }, + + /** + * Toggles the manage tenants privileges for the group. + * + * @param $event + * @param policyAction The action to be toggled + */ + toggleGroupManageTenantsPrivileges: function ($event, policyAction) { + var self = this; + if ($event.checked) { + for (var resource in this.nfRegistryService.TENANTS_PRIVS) { + if (this.nfRegistryService.TENANTS_PRIVS.hasOwnProperty(resource)) { + this.nfRegistryService.TENANTS_PRIVS[resource].forEach(function (action) { + if (!policyAction || (action === policyAction)) { + self.nfRegistryApi.getPolicyActionResource(action, resource).subscribe(function (policy) { + if (policy.status && policy.status === 409) { + // resource does NOT exist, let's create it + self.nfRegistryApi.postPolicyActionResource(action, resource, self.nfRegistryService.group.users, []).subscribe( + function (response) { + // can manage tenants privileges created and granted!!!...now update the view + response.userGroups.forEach(function (group) { + if (group.identifier === self.nfRegistryService.group.identifier) { + self.nfRegistryApi.getUserGroup(self.nfRegistryService.group.identifier).subscribe(function(response) { + self.nfRegistryService.group = response; + }); + } + }); + }); + } else { + // resource exists, let's update it + policy.userGroups.push(self.nfRegistryService.group); + self.nfRegistryApi.putPolicyActionResource(policy.identifier, policy.action, + policy.resource, policy.users, policy.userGroups).subscribe( + function (response) { + // can manage tenants privileges updated!!!...now update the view + response.userGroups.forEach(function (group) { + if (group.identifier === self.nfRegistryService.group.identifier) { + self.nfRegistryApi.getUserGroup(self.nfRegistryService.group.identifier).subscribe(function(response) { + self.nfRegistryService.group = response; + }); + } + }); + }); + } + }); + } + }); + } + } + } else { + // Remove the current group from the administrator resources + for (var resource in this.nfRegistryService.TENANTS_PRIVS) { + if (this.nfRegistryService.TENANTS_PRIVS.hasOwnProperty(resource)) { + this.nfRegistryService.TENANTS_PRIVS[resource].forEach(function (action) { + if (!policyAction || (action === policyAction)) { + self.nfRegistryApi.getPolicyActionResource(action, resource).subscribe(function (policy) { + if (policy.status && policy.status === 409) { + // resource does NOT exist + } else { + // resource exists, let's filter out the current group and update it + policy.userGroups = policy.userGroups.filter(function (group) { + return (group.identifier !== self.nfRegistryService.group.identifier) ? true : false; + }); + self.nfRegistryApi.putPolicyActionResource(policy.identifier, policy.action, + policy.resource, policy.users, policy.userGroups).subscribe( + function (response) { + // can manage tenants privileges updated!!!...now update the view + self.nfRegistryApi.getUserGroup(self.nfRegistryService.group.identifier).subscribe(function(response) { + self.nfRegistryService.group = response; + }); + }); + } + }); + } + }); + } + } + + } + }, + + /** + * Toggles the manage policies privileges for the group. + * + * @param $event + * @param policyAction The action to be toggled + */ + toggleGroupManagePoliciesPrivileges: function ($event, policyAction) { + var self = this; + if ($event.checked) { + for (var resource in this.nfRegistryService.POLICIES_PRIVS) { + if (this.nfRegistryService.POLICIES_PRIVS.hasOwnProperty(resource)) { + this.nfRegistryService.POLICIES_PRIVS[resource].forEach(function (action) { + if (!policyAction || (action === policyAction)) { + self.nfRegistryApi.getPolicyActionResource(action, resource).subscribe(function (policy) { + if (policy.status && policy.status === 409) { + // resource does NOT exist, let's create it + self.nfRegistryApi.postPolicyActionResource(action, resource, self.nfRegistryService.group.users, []).subscribe( + function (response) { + // can manage policies privileges created and granted!!!...now update the view + response.userGroups.forEach(function (group) { + if (group.identifier === self.nfRegistryService.group.identifier) { + self.nfRegistryApi.getUserGroup(self.nfRegistryService.group.identifier).subscribe(function(response) { + self.nfRegistryService.group = response; + }); + } + }); + }); + } else { + // resource exists, let's update it + policy.userGroups.push(self.nfRegistryService.group); + self.nfRegistryApi.putPolicyActionResource(policy.identifier, policy.action, + policy.resource, policy.users, policy.userGroups).subscribe( + function (response) { + // can manage policies privileges updated!!!...now update the view + response.userGroups.forEach(function (group) { + if (group.identifier === self.nfRegistryService.group.identifier) { + self.nfRegistryApi.getUserGroup(self.nfRegistryService.group.identifier).subscribe(function(response) { + self.nfRegistryService.group = response; + }); + } + }); + }); + } + }); + } + }); + } + } + } else { + // Remove the current group from the administrator resources + for (var resource in this.nfRegistryService.POLICIES_PRIVS) { + if (this.nfRegistryService.POLICIES_PRIVS.hasOwnProperty(resource)) { + this.nfRegistryService.POLICIES_PRIVS[resource].forEach(function (action) { + if (!policyAction || (action === policyAction)) { + self.nfRegistryApi.getPolicyActionResource(action, resource).subscribe(function (policy) { + if (policy.status && policy.status === 409) { + // resource does NOT exist + } else { + // resource exists, let's filter out the current group and update it + policy.userGroups = policy.userGroups.filter(function (group) { + return (group.identifier !== self.nfRegistryService.group.identifier) ? true : false; + }); + self.nfRegistryApi.putPolicyActionResource(policy.identifier, policy.action, + policy.resource, policy.users, policy.userGroups).subscribe( + function (response) { + // can manage policies privileges updated!!!...now update the view + self.nfRegistryApi.getUserGroup(self.nfRegistryService.group.identifier).subscribe(function(response) { + self.nfRegistryService.group = response; + }); + }); + } + }); + } + }); + } + } + + } + }, + + /** + * Toggles the manage proxy privileges for the group. + * + * @param $event + * @param policyAction The action to be toggled + */ + toggleGroupManageProxyPrivileges: function ($event, policyAction) { + var self = this; + if ($event.checked) { + for (var resource in this.nfRegistryService.PROXY_PRIVS) { + if (this.nfRegistryService.PROXY_PRIVS.hasOwnProperty(resource)) { + this.nfRegistryService.PROXY_PRIVS[resource].forEach(function (action) { + if (!policyAction || (action === policyAction)) { + self.nfRegistryApi.getPolicyActionResource(action, resource).subscribe(function (policy) { + if (policy.status && policy.status === 409) { + // resource does NOT exist, let's create it + self.nfRegistryApi.postPolicyActionResource(action, resource, self.nfRegistryService.group.users, []).subscribe( + function (response) { + // can manage proxy privileges created and granted!!!...now update the view + response.userGroups.forEach(function (group) { + if (group.identifier === self.nfRegistryService.group.identifier) { + self.nfRegistryApi.getUserGroup(self.nfRegistryService.group.identifier).subscribe(function(response) { + self.nfRegistryService.group = response; + }); + } + }); + }); + } else { + // resource exists, let's update it + policy.userGroups.push(self.nfRegistryService.group); + self.nfRegistryApi.putPolicyActionResource(policy.identifier, policy.action, + policy.resource, policy.users, policy.userGroups).subscribe( + function (response) { + // can manage proxy privileges updated!!!...now update the view + response.userGroups.forEach(function (group) { + if (group.identifier === self.nfRegistryService.group.identifier) { + self.nfRegistryApi.getUserGroup(self.nfRegistryService.group.identifier).subscribe(function(response) { + self.nfRegistryService.group = response; + }); + } + }); + }); + } + }); + } + }); + } + } + } else { + // Remove the current group from the administrator resources + for (var resource in this.nfRegistryService.PROXY_PRIVS) { + if (this.nfRegistryService.PROXY_PRIVS.hasOwnProperty(resource)) { + this.nfRegistryService.PROXY_PRIVS[resource].forEach(function (action) { + if (!policyAction || (action === policyAction)) { + self.nfRegistryApi.getPolicyActionResource(action, resource).subscribe(function (policy) { + if (policy.status && policy.status === 409) { + // resource does NOT exist + } else { + // resource exists, let's filter out the current group and update it + policy.userGroups = policy.userGroups.filter(function (group) { + return (group.identifier !== self.nfRegistryService.group.identifier) ? true : false; + }); + self.nfRegistryApi.putPolicyActionResource(policy.identifier, policy.action, + policy.resource, policy.users, policy.userGroups).subscribe( + function (response) { + // can manage proxy privileges updated!!!...now update the view + self.nfRegistryApi.getUserGroup(self.nfRegistryService.group.identifier).subscribe(function(response) { + self.nfRegistryService.group = response; + }); + }); + } + }); + } + }); + } + } + + } + }, + + /** + * Opens a modal dialog UX enabling the addition of users to this group. + */ + addUsersToGroup: function () { + var self = this; + this.dialog.open(NfRegistryAddUsersToGroup, { + data: { + group: this.nfRegistryService.group + } + }).afterClosed().subscribe(function () { + self.nfRegistryApi.getUserGroup(self.nfRegistryService.group.identifier) + .subscribe(function (response) { + self.nfRegistryService.group = response; + self._groupname = response.identity; + self.filterUsers(); + }); + }); + }, + + /** + * Filter users. + * + * @param {string} [sortBy] The column name to sort `userGroupsColumns` by. + * @param {string} [sortOrder] The order. Either 'ASC' or 'DES' + */ + filterUsers: function (sortBy, sortOrder) { + // if `sortOrder` is `undefined` then use 'ASC' + if (sortOrder === undefined) { + sortOrder = 'ASC' + } + // if `sortBy` is `undefined` then find the first sortable column in `userGroupsColumns` + if (sortBy === undefined) { + var arrayLength = this.nfRegistryService.userGroupsColumns.length; + for (var i = 0; i < arrayLength; i++) { + if (this.nfRegistryService.userGroupsColumns[i].sortable === true) { + sortBy = this.nfRegistryService.userGroupsColumns[i].name; + //only one column can be actively sorted so we reset all to inactive + this.nfRegistryService.userGroupsColumns.forEach(function (c) { + c.active = false; + }); + //and set this column as the actively sorted column + this.nfRegistryService.userGroupsColumns[i].active = true; + this.nfRegistryService.userGroupsColumns[i].sortOrder = sortOrder; + break; + } + } + } + + var newUsersData = this.nfRegistryService.group.users || []; + + for (var i = 0; i < this.usersSearchTerms.length; i++) { + newUsersData = this.filterData(newUsersData, this.usersSearchTerms[i], true); + } + + newUsersData = this.dataTableService.sortData(newUsersData, sortBy, sortOrder); + this.filteredUsers = newUsersData; + }, + + /** + * Sort `users` by `column`. + * + * @param column The column to sort by. + */ + sortUsers: function (column) { + if (column.sortable) { + var sortBy = column.name; + var sortOrder = column.sortOrder = (column.sortOrder === 'ASC') ? 'DESC' : 'ASC'; + this.filterUsers(sortBy, sortOrder); + + //only one column can be actively sorted so we reset all to inactive + this.nfRegistryService.userGroupsColumns.forEach(function (c) { + c.active = false; + }); + //and set this column as the actively sorted column + column.active = true; + } + }, + + /** + * Remove user from group. + * + * @param user + */ + removeUserFromGroup: function (user) { + var self = this; + var users = this.nfRegistryService.group.users.filter(function (u) { + if (u.identifier !== user.identifier) { + return u; + } + }); + + this.nfRegistryApi.updateUserGroup(this.nfRegistryService.group.identifier, this.nfRegistryService.group.identity, users).subscribe(function (response) { + self.nfRegistryApi.getUserGroup(self.nfRegistryService.group.identifier) + .subscribe(function (response) { + self.nfRegistryService.group = response; + self.filterUsers(); + }); + var snackBarRef = self.snackBarService.openCoaster({ + title: 'Success', + message: 'The user has been removed from the ' + this.nfRegistryService.group.identity + ' group.', + verticalPosition: 'bottom', + horizontalPosition: 'right', + icon: 'fa fa-check-circle-o', + color: '#1EB475', + duration: 3000 + }); + }); + }, + + /** + * Update group name. + * + * @param groupname + */ + updateGroupName: function (groupname) { + var self = this; + this.nfRegistryApi.updateUserGroup(this.nfRegistryService.group.identifier, groupname, this.nfRegistryService.group.users).subscribe(function (response) { + if (!response.status || response.status === 200) { + self.nfRegistryService.group = response; + self.nfRegistryService.groups.filter(function (group) { + if (self.nfRegistryService.group.identifier === group.identifier) { + group.identity = response.identity; + } + }); + var snackBarRef = self.snackBarService.openCoaster({ + title: 'Success', + message: 'This group name has been updated.', + verticalPosition: 'bottom', + horizontalPosition: 'right', + icon: 'fa fa-check-circle-o', + color: '#1EB475', + duration: 3000 + }); + } else if (response.status === 409) { + self._groupname = self.nfRegistryService.group.identity; + self.dialogService.openConfirm({ + title: 'Error', + message: 'This group already exists. Please enter a different identity/group name.', + acceptButton: 'Ok', + acceptButtonColor: 'fds-warn' + }); + } + }); + } +}; + +NfRegistryManageGroup.annotations = [ + new ngCore.Component({ + template: require('./nf-registry-manage-group.html!text') + }) +]; + +NfRegistryManageGroup.parameters = [ + NfRegistryApi, + NfRegistryService, + covalentCore.TdDataTableService, + fdsDialogsModule.FdsDialogService, + fdsSnackBarsModule.FdsSnackBarService, + ngRouter.ActivatedRoute, + ngRouter.Router, + ngMaterial.MatDialog +]; + +module.exports = NfRegistryManageGroup; diff --git a/nifi-registry-web-ui/src/main/webapp/components/administration/users/sidenav/manage-user/nf-registry-manage-user.html b/nifi-registry-web-ui/src/main/webapp/components/administration/users/sidenav/manage-user/nf-registry-manage-user.html new file mode 100644 index 0000000..1f0feb5 --- /dev/null +++ b/nifi-registry-web-ui/src/main/webapp/components/administration/users/sidenav/manage-user/nf-registry-manage-user.html @@ -0,0 +1,158 @@ + + +
+
+ {{nfRegistryService.user.identity}} + +
+
+ + + + +
+
+
+ Special Privileges + + +
+ + Can manage buckets + +
+ + Read + + + Write + + + Delete + +
+ + Can manage users + +
+ + Read + + + Write + + + Delete + +
+ + Can manage policies + +
+ + Read + + + Write + + + Delete + +
+ + Can proxy user requests + +
+ + + Membership + + +
+
+
+ Membership ({{nfRegistryService.user.userGroups.length}}) + +
+
+
+ {{column.label}} + + +
+
+
+
+
+
+ {{column.format ? column.format(row[column.name]) : row[column.name]}} +
+
+
+
+ +
+
+
+
+
+

This user does not belong to any groups yet.

+
+
+
+ +
diff --git a/nifi-registry-web-ui/src/main/webapp/components/administration/users/sidenav/manage-user/nf-registry-manage-user.js b/nifi-registry-web-ui/src/main/webapp/components/administration/users/sidenav/manage-user/nf-registry-manage-user.js new file mode 100644 index 0000000..59aca5f --- /dev/null +++ b/nifi-registry-web-ui/src/main/webapp/components/administration/users/sidenav/manage-user/nf-registry-manage-user.js @@ -0,0 +1,577 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var covalentCore = require('@covalent/core'); +var fdsDialogsModule = require('@fluid-design-system/dialogs'); +var fdsSnackBarsModule = require('@fluid-design-system/snackbars'); +var ngCore = require('@angular/core'); +var NfRegistryService = require('nifi-registry/services/nf-registry.service.js'); +var ngRouter = require('@angular/router'); +var NfRegistryApi = require('nifi-registry/services/nf-registry.api.js'); +var ngMaterial = require('@angular/material'); +var NfRegistryAddUserToGroups = require('nifi-registry/components/administration/users/dialogs/add-user-to-groups/nf-registry-add-user-to-groups.js'); + +/** + * NfRegistryManageUser constructor. + * + * @param nfRegistryApi The api service. + * @param nfRegistryService The nf-registry.service module. + * @param tdDataTableService The covalent data table service module. + * @param fdsDialogService The FDS dialog service. + * @param fdsSnackBarService The FDS snack bar service module. + * @param activatedRoute The angular route module. + * @param router The angular router module. + * @param matDialog The angular material dialog module. + * @constructor + */ +function NfRegistryManageUser(nfRegistryApi, nfRegistryService, tdDataTableService, fdsDialogService, fdsSnackBarService, activatedRoute, router, matDialog) { + this.filteredUserGroups = []; + this.userGroupsSearchTerms = []; + this._username = ''; + this.manageUserPerspective = 'membership'; + + // Services + this.nfRegistryService = nfRegistryService; + this.route = activatedRoute; + this.router = router; + this.dialog = matDialog; + this.nfRegistryApi = nfRegistryApi; + this.dialogService = fdsDialogService; + this.snackBarService = fdsSnackBarService; + this.dataTableService = tdDataTableService; +}; + +NfRegistryManageUser.prototype = { + constructor: NfRegistryManageUser, + + /** + * Initialize the component. + */ + ngOnInit: function () { + var self = this; + this.nfRegistryService.sidenav.open(); + + // subscribe to the route params + self.route.params + .switchMap(function (params) { + return self.nfRegistryApi.getUser(params['userId']); + }) + .subscribe(function (response) { + self.nfRegistryService.user = response; + self._username = response.identity; + self.filterGroups(); + }); + }, + + /** + * Destroy the component. + */ + ngOnDestroy: function () { + this.nfRegistryService.sidenav.close(); + }, + + /** + * Navigate to administer users for current registry. + */ + closeSideNav: function () { + this.router.navigateByUrl('/nifi-registry/administration/users'); + }, + + /** + * Toggles the manage bucket privileges for the user. + * + * @param $event + * @param policyAction The action to be toggled + */ + toggleUserManageBucketsPrivileges: function ($event, policyAction) { + var self = this; + if($event.checked) { + for (var resource in this.nfRegistryService.BUCKETS_PRIVS) { + if (this.nfRegistryService.BUCKETS_PRIVS.hasOwnProperty(resource)) { + this.nfRegistryService.BUCKETS_PRIVS[resource].forEach(function (action) { + if (!policyAction || (action === policyAction)) { + self.nfRegistryApi.getPolicyActionResource(action, resource).subscribe(function (policy) { + if (policy.status && policy.status === 409) { + // resource does NOT exist, let's create it + self.nfRegistryApi.postPolicyActionResource(action, resource, [self.nfRegistryService.user], []).subscribe( + function (response) { + // can manage buckets privileges created and granted!!!...now update the view + response.users.forEach(function (user) { + if (user.identifier === self.nfRegistryService.user.identifier) { + self.nfRegistryApi.getUser(self.nfRegistryService.user.identifier).subscribe(function(response) { + self.nfRegistryService.user = response; + }); + } + }); + }); + } else { + // resource exists, let's update it + policy.users.push(self.nfRegistryService.user); + self.nfRegistryApi.putPolicyActionResource(policy.identifier, policy.action, + policy.resource, policy.users, policy.userGroups).subscribe( + function (response) { + // can manage buckets privileges updated!!!...now update the view + response.users.forEach(function (user) { + if (user.identifier === self.nfRegistryService.user.identifier) { + self.nfRegistryApi.getUser(self.nfRegistryService.user.identifier).subscribe(function(response) { + self.nfRegistryService.user = response; + }); + } + }); + }); + } + }); + } + }); + } + } + } else { + // Remove the current user from the /buckets resources + for (var resource in this.nfRegistryService.BUCKETS_PRIVS) { + if (this.nfRegistryService.BUCKETS_PRIVS.hasOwnProperty(resource)) { + this.nfRegistryService.BUCKETS_PRIVS[resource].forEach(function (action) { + if (!policyAction || (action === policyAction)) { + self.nfRegistryApi.getPolicyActionResource(action, resource).subscribe(function (policy) { + if (policy.status && policy.status === 409) { + // resource does NOT exist + } else { + // resource exists, let's filter out the current user and update it + policy.users = policy.users.filter(function (user) { + return (user.identifier !== self.nfRegistryService.user.identifier) ? true : false; + }) + self.nfRegistryApi.putPolicyActionResource(policy.identifier, policy.action, + policy.resource, policy.users, policy.userGroups).subscribe( + function (response) { + // can manage buckets privileges updated!!!...now update the view + self.nfRegistryApi.getUser(self.nfRegistryService.user.identifier).subscribe(function(response) { + self.nfRegistryService.user = response; + }); + }); + } + }); + } + }); + } + } + + } + }, + + /** + * Toggles the manage tenants privileges for the user. + * + * @param $event + * @param policyAction The action to be toggled + */ + toggleUserManageTenantsPrivileges: function ($event, policyAction) { + var self = this; + if($event.checked) { + for (var resource in this.nfRegistryService.TENANTS_PRIVS) { + if (this.nfRegistryService.TENANTS_PRIVS.hasOwnProperty(resource)) { + this.nfRegistryService.TENANTS_PRIVS[resource].forEach(function (action) { + if (!policyAction || (action === policyAction)) { + self.nfRegistryApi.getPolicyActionResource(action, resource).subscribe(function (policy) { + if (policy.status && policy.status === 409) { + // resource does NOT exist, let's create it + self.nfRegistryApi.postPolicyActionResource(action, resource, [self.nfRegistryService.user], []).subscribe( + function (response) { + // can manage tenants privileges created and granted!!!...now update the view + response.users.forEach(function (user) { + if (user.identifier === self.nfRegistryService.user.identifier) { + self.nfRegistryApi.getUser(self.nfRegistryService.user.identifier).subscribe(function (response) { + self.nfRegistryService.user = response; + }); + } + }); + }); + } else { + // resource exists, let's update it + policy.users.push(self.nfRegistryService.user); + self.nfRegistryApi.putPolicyActionResource(policy.identifier, policy.action, + policy.resource, policy.users, policy.userGroups).subscribe( + function (response) { + // can manage tenants privileges updated!!!...now update the view + response.users.forEach(function (user) { + if (user.identifier === self.nfRegistryService.user.identifier) { + self.nfRegistryApi.getUser(self.nfRegistryService.user.identifier).subscribe(function (response) { + self.nfRegistryService.user = response; + }); + } + }); + }); + } + }); + } + }); + } + } + } else { + // Remove the current user from the administrator resources + for (var resource in this.nfRegistryService.TENANTS_PRIVS) { + if (this.nfRegistryService.TENANTS_PRIVS.hasOwnProperty(resource)) { + this.nfRegistryService.TENANTS_PRIVS[resource].forEach(function (action) { + if (!policyAction || (action === policyAction)) { + self.nfRegistryApi.getPolicyActionResource(action, resource).subscribe(function (policy) { + if (policy.status && policy.status === 409) { + // resource does NOT exist + } else { + // resource exists, let's filter out the current user and update it + policy.users = policy.users.filter(function (user) { + return (user.identifier !== self.nfRegistryService.user.identifier) ? true : false; + }) + self.nfRegistryApi.putPolicyActionResource(policy.identifier, policy.action, + policy.resource, policy.users, policy.userGroups).subscribe( + function (response) { + // can manage tenants privileges updated!!!...now update the view + self.nfRegistryApi.getUser(self.nfRegistryService.user.identifier).subscribe(function (response) { + self.nfRegistryService.user = response; + }); + }); + } + }); + } + }); + } + } + + } + }, + + /** + * Toggles the manage policies privileges for the user. + * + * @param $event + * @param policyAction The action to be toggled + */ + toggleUserManagePoliciesPrivileges: function ($event, policyAction) { + var self = this; + if($event.checked) { + for (var resource in this.nfRegistryService.POLICIES_PRIVS) { + if (this.nfRegistryService.POLICIES_PRIVS.hasOwnProperty(resource)) { + this.nfRegistryService.POLICIES_PRIVS[resource].forEach(function (action) { + if (!policyAction || (action === policyAction)) { + self.nfRegistryApi.getPolicyActionResource(action, resource).subscribe(function (policy) { + if (policy.status && policy.status === 409) { + // resource does NOT exist, let's create it + self.nfRegistryApi.postPolicyActionResource(action, resource, [self.nfRegistryService.user], []).subscribe( + function (response) { + // can manage policies privileges created and granted!!!...now update the view + response.users.forEach(function (user) { + if (user.identifier === self.nfRegistryService.user.identifier) { + self.nfRegistryApi.getUser(self.nfRegistryService.user.identifier).subscribe(function (response) { + self.nfRegistryService.user = response; + }); + } + }); + }); + } else { + // resource exists, let's update it + policy.users.push(self.nfRegistryService.user); + self.nfRegistryApi.putPolicyActionResource(policy.identifier, policy.action, + policy.resource, policy.users, policy.userGroups).subscribe( + function (response) { + // can manage policies privileges updated!!!...now update the view + response.users.forEach(function (user) { + if (user.identifier === self.nfRegistryService.user.identifier) { + self.nfRegistryApi.getUser(self.nfRegistryService.user.identifier).subscribe(function (response) { + self.nfRegistryService.user = response; + }); + } + }); + }); + } + }); + } + }); + } + } + } else { + // Remove the current user from the administrator resources + for (var resource in this.nfRegistryService.POLICIES_PRIVS) { + if (this.nfRegistryService.POLICIES_PRIVS.hasOwnProperty(resource)) { + this.nfRegistryService.POLICIES_PRIVS[resource].forEach(function (action) { + if (!policyAction || (action === policyAction)) { + self.nfRegistryApi.getPolicyActionResource(action, resource).subscribe(function (policy) { + if (policy.status && policy.status === 409) { + // resource does NOT exist + } else { + // resource exists, let's filter out the current user and update it + policy.users = policy.users.filter(function (user) { + return (user.identifier !== self.nfRegistryService.user.identifier) ? true : false; + }) + self.nfRegistryApi.putPolicyActionResource(policy.identifier, policy.action, + policy.resource, policy.users, policy.userGroups).subscribe( + function (response) { + // can manage policies privileges updated!!!...now update the view + self.nfRegistryApi.getUser(self.nfRegistryService.user.identifier).subscribe(function (response) { + self.nfRegistryService.user = response; + }); + }); + } + }); + } + }); + } + } + + } + }, + + /** + * Toggles the manage proxy privileges for the user. + * + * @param $event + * @param policyAction The action to be toggled + */ + toggleUserManageProxyPrivileges: function ($event, policyAction) { + var self = this; + if($event.checked) { + for (var resource in this.nfRegistryService.PROXY_PRIVS) { + if (this.nfRegistryService.PROXY_PRIVS.hasOwnProperty(resource)) { + this.nfRegistryService.PROXY_PRIVS[resource].forEach(function (action) { + if (!policyAction || (action === policyAction)) { + self.nfRegistryApi.getPolicyActionResource(action, resource).subscribe(function (policy) { + if (policy.status && policy.status === 409) { + // resource does NOT exist, let's create it + self.nfRegistryApi.postPolicyActionResource(action, resource, [self.nfRegistryService.user], []).subscribe( + function (response) { + // can manage proxy privileges created and granted!!!...now update the view + response.users.forEach(function (user) { + if (user.identifier === self.nfRegistryService.user.identifier) { + self.nfRegistryApi.getUser(self.nfRegistryService.user.identifier).subscribe(function (response) { + self.nfRegistryService.user = response; + }); + } + }); + }); + } else { + // resource exists, let's update it + policy.users.push(self.nfRegistryService.user); + self.nfRegistryApi.putPolicyActionResource(policy.identifier, policy.action, + policy.resource, policy.users, policy.userGroups).subscribe( + function (response) { + // can manage proxy privileges updated!!!...now update the view + response.users.forEach(function (user) { + if (user.identifier === self.nfRegistryService.user.identifier) { + self.nfRegistryApi.getUser(self.nfRegistryService.user.identifier).subscribe(function (response) { + self.nfRegistryService.user = response; + }); + } + }); + }); + } + }); + } + }); + } + } + } else { + // Remove the current user from the administrator resources + for (var resource in this.nfRegistryService.PROXY_PRIVS) { + if (this.nfRegistryService.PROXY_PRIVS.hasOwnProperty(resource)) { + this.nfRegistryService.PROXY_PRIVS[resource].forEach(function (action) { + if (!policyAction || (action === policyAction)) { + self.nfRegistryApi.getPolicyActionResource(action, resource).subscribe(function (policy) { + if (policy.status && policy.status === 409) { + // resource does NOT exist + } else { + // resource exists, let's filter out the current user and update it + policy.users = policy.users.filter(function (user) { + return (user.identifier !== self.nfRegistryService.user.identifier) ? true : false; + }) + self.nfRegistryApi.putPolicyActionResource(policy.identifier, policy.action, + policy.resource, policy.users, policy.userGroups).subscribe( + function (response) { + // administrator privileges updated!!!...now update the view + self.nfRegistryApi.getUser(self.nfRegistryService.user.identifier).subscribe(function (response) { + self.nfRegistryService.user = response; + }); + }); + } + }); + } + }); + } + } + + } + }, + + /** + * Opens a modal dialog UX enabling the addition of this user to multiple groups. + */ + addUserToGroups: function () { + var self = this; + this.dialog.open(NfRegistryAddUserToGroups, { + data: { + user: this.nfRegistryService.user + } + }).afterClosed().subscribe(function () { + self.nfRegistryApi.getUser(self.nfRegistryService.user.identifier) + .subscribe(function (response) { + self.nfRegistryService.user = response; + self._username = response.identity; + self.filterGroups(); + }); + }); + }, + + /** + * Filter groups. + * + * @param {string} [sortBy] The column name to sort `userGroupsColumns` by. + * @param {string} [sortOrder] The order. Either 'ASC' or 'DES' + */ + filterGroups: function (sortBy, sortOrder) { + // if `sortOrder` is `undefined` then use 'ASC' + if (sortOrder === undefined) { + sortOrder = 'ASC' + } + // if `sortBy` is `undefined` then find the first sortable column in `userGroupsColumns` + if (sortBy === undefined) { + var arrayLength = this.nfRegistryService.userGroupsColumns.length; + for (var i = 0; i < arrayLength; i++) { + if (this.nfRegistryService.userGroupsColumns[i].sortable === true) { + sortBy = this.nfRegistryService.userGroupsColumns[i].name; + //only one column can be actively sorted so we reset all to inactive + this.nfRegistryService.userGroupsColumns.forEach(function (c) { + c.active = false; + }); + //and set this column as the actively sorted column + this.nfRegistryService.userGroupsColumns[i].active = true; + this.nfRegistryService.userGroupsColumns[i].sortOrder = sortOrder; + break; + } + } + } + + var newUserGroupsData = this.nfRegistryService.user.userGroups || []; + + for (var i = 0; i < this.userGroupsSearchTerms.length; i++) { + newUserGroupsData = this.filterData(newUserGroupsData, this.userGroupsSearchTerms[i], true); + } + + newUserGroupsData = this.dataTableService.sortData(newUserGroupsData, sortBy, sortOrder); + this.filteredUserGroups = newUserGroupsData; + }, + + /** + * Sort `groups` by `column`. + * + * @param column The column to sort by. + */ + sortGroups: function (column) { + if (column.sortable) { + var sortBy = column.name; + var sortOrder = column.sortOrder = (column.sortOrder === 'ASC') ? 'DESC' : 'ASC'; + this.filterGroups(sortBy, sortOrder); + + //only one column can be actively sorted so we reset all to inactive + this.nfRegistryService.userGroupsColumns.forEach(function (c) { + c.active = false; + }); + //and set this column as the actively sorted column + column.active = true; + } + }, + + /** + * Remove user from group. + * + * @param group + */ + removeUserFromGroup: function (group) { + var self = this; + var userGroups = this.nfRegistryService.user.userGroups.filter(function (userGroup) { + if (userGroup.identifier !== group.identifier) { + return userGroup; + } + }); + + this.nfRegistryApi.updateUserGroup(group.identifier, group.identity, userGroups).subscribe(function (response) { + self.nfRegistryApi.getUser(self.nfRegistryService.user.identifier) + .subscribe(function (response) { + self.nfRegistryService.user = response; + self.filterGroups(); + }); + var snackBarRef = self.snackBarService.openCoaster({ + title: 'Success', + message: 'This user has been removed from the ' + group.identity + ' group.', + verticalPosition: 'bottom', + horizontalPosition: 'right', + icon: 'fa fa-check-circle-o', + color: '#1EB475', + duration: 3000 + }); + }); + }, + + /** + * Update user name. + * + * @param username + */ + updateUserName: function (username) { + var self = this; + this.nfRegistryApi.updateUser(this.nfRegistryService.user.identifier, username).subscribe(function (response) { + if(!response.status || response.status === 200) { + self.nfRegistryService.user = response; + self.nfRegistryService.users.filter(function(user) { + if (self.nfRegistryService.user.identifier === user.identifier){ + user.identity = response.identity; + } + }); + var snackBarRef = self.snackBarService.openCoaster({ + title: 'Success', + message: 'This user name has been updated.', + verticalPosition: 'bottom', + horizontalPosition: 'right', + icon: 'fa fa-check-circle-o', + color: '#1EB475', + duration: 3000 + }); + } else if (response.status === 409) { + self._username = self.nfRegistryService.user.identity; + self.dialogService.openConfirm({ + title: 'Error', + message: 'This user already exists. Please enter a different identity/user name.', + acceptButton: 'Ok', + acceptButtonColor: 'fds-warn' + }); + } + }); + } +}; + +NfRegistryManageUser.annotations = [ + new ngCore.Component({ + template: require('./nf-registry-manage-user.html!text') + }) +]; + +NfRegistryManageUser.parameters = [ + NfRegistryApi, + NfRegistryService, + covalentCore.TdDataTableService, + fdsDialogsModule.FdsDialogService, + fdsSnackBarsModule.FdsSnackBarService, + ngRouter.ActivatedRoute, + ngRouter.Router, + ngMaterial.MatDialog +]; + +module.exports = NfRegistryManageUser; diff --git a/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/buckets/permissions/nf-registry-bucket-permissions.html b/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/buckets/permissions/nf-registry-bucket-permissions.html index 4c46910..bae5218 100644 --- a/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/buckets/permissions/nf-registry-bucket-permissions.html +++ b/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/buckets/permissions/nf-registry-bucket-permissions.html @@ -16,12 +16,98 @@ limitations under the License. -->
-
+
{{nfRegistryService.bucket.name}}
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/nf-registry-workflow-administration.html b/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/nf-registry-workflow-administration.html index 5ff3247..544e2d1 100644 --- a/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/nf-registry-workflow-administration.html +++ b/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/nf-registry-workflow-administration.html @@ -65,9 +65,9 @@ limitations under the License.
-
+
-
+
-
+
diff --git a/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/nf-registry-workflow-administration.js b/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/nf-registry-workflow-administration.js index 5a27be9..770b871 100644 --- a/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/nf-registry-workflow-administration.js +++ b/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/nf-registry-workflow-administration.js @@ -39,16 +39,6 @@ function NfRegistryWorkflowAdministration(nfRegistryApi, nfStorage, nfRegistrySe this.nfRegistryService = nfRegistryService; this.nfRegistryApi = nfRegistryApi; this.dialog = matDialog; - this.bucketActions = [{ - 'name': 'permissions', - 'icon': 'fa fa-pencil', - 'tooltip': 'Manage Bucket Policies', - 'type': 'sidenav' - }, { - 'name': 'Delete', - 'icon': 'fa fa-trash', - 'tooltip': 'Delete Bucket' - }]; }; NfRegistryWorkflowAdministration.prototype = { @@ -60,21 +50,16 @@ NfRegistryWorkflowAdministration.prototype = { ngOnInit: function () { var self = this; this.nfRegistryService.inProgress = true; - // attempt kerberos authentication - this.nfRegistryApi.ticketExchange().subscribe(function (jwt) { - self.nfRegistryService.loadCurrentUser().subscribe(function (currentUser) { - self.route.params - .switchMap(function (params) { - self.nfRegistryService.adminPerspective = 'workflow'; - return self.nfRegistryApi.getBuckets(); - }) - .subscribe(function (buckets) { - self.nfRegistryService.buckets = buckets; - self.nfRegistryService.filterBuckets(); - self.nfRegistryService.inProgress = false; - }); + this.route.params + .switchMap(function (params) { + self.nfRegistryService.adminPerspective = 'workflow'; + return self.nfRegistryApi.getBuckets(); + }) + .subscribe(function (buckets) { + self.nfRegistryService.buckets = buckets; + self.nfRegistryService.filterBuckets(); + self.nfRegistryService.inProgress = false; }); - }); }, /** diff --git a/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/nf-registry-workflow-administration.spec.js b/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/nf-registry-workflow-administration.spec.js index febac5c..1a1641b 100644 --- a/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/nf-registry-workflow-administration.spec.js +++ b/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/nf-registry-workflow-administration.spec.js @@ -30,9 +30,8 @@ var NfRegistryExplorer = require('nifi-registry/components/explorer/nf-registry- var NfRegistryAdministration = require('nifi-registry/components/administration/nf-registry-administration.js'); var NfRegistryUsersAdministration = require('nifi-registry/components/administration/users/nf-registry-users-administration.js'); var NfRegistryAddUser = require('nifi-registry/components/administration/users/dialogs/add-user/nf-registry-add-user.js'); -var NfRegistryUserDetails = require('nifi-registry/components/administration/users/details/nf-registry-user-details.js'); -var NfRegistryUserPermissions = require('nifi-registry/components/administration/users/permissions/nf-registry-user-permissions.js'); -var NfRegistryUserGroupPermissions = require('nifi-registry/components/administration/user-group/permissions/nf-registry-user-group-permissions.js'); +var NfRegistryManageUser = require('nifi-registry/components/administration/users/sidenav/manage-user/nf-registry-manage-user.js'); +var NfRegistryManageGroup = require('nifi-registry/components/administration/users/sidenav/manage-group/nf-registry-manage-group.js'); var NfRegistryBucketPermissions = require('nifi-registry/components/administration/workflow/buckets/permissions/nf-registry-bucket-permissions.js'); var NfRegistryWorkflowAdministration = require('nifi-registry/components/administration/workflow/nf-registry-workflow-administration.js'); var NfRegistryCreateBucket = require('nifi-registry/components/administration/workflow/dialogs/nf-registry-create-bucket.js'); @@ -46,6 +45,8 @@ var ngCommonHttp = require('@angular/common/http'); var NfRegistryTokenInterceptor = require('nifi-registry/services/nf-registry.token.interceptor.js'); var NfRegistryAuthService = require('nifi-registry/services/nf-registry.auth.service.js'); var NfStorage = require('nifi-registry/services/nf-storage.service.js'); +var NfLoginComponent = require('nifi-registry/components/login/nf-registry-login.js'); +var NfUserLoginComponent = require('nifi-registry/components/login/dialogs/nf-registry-user-login.js'); describe('NfRegistryWorkflowAdministration Component', function () { var comp; @@ -70,9 +71,8 @@ describe('NfRegistryWorkflowAdministration Component', function () { NfRegistryExplorer, NfRegistryAdministration, NfRegistryUsersAdministration, - NfRegistryUserDetails, - NfRegistryUserPermissions, - NfRegistryUserGroupPermissions, + NfRegistryManageUser, + NfRegistryManageGroup, NfRegistryBucketPermissions, NfRegistryAddUser, NfRegistryWorkflowAdministration, @@ -80,7 +80,9 @@ describe('NfRegistryWorkflowAdministration Component', function () { NfRegistryGridListViewer, NfRegistryBucketGridListViewer, NfRegistryDropletGridListViewer, - NfPageNotFoundComponent + NfPageNotFoundComponent, + NfLoginComponent, + NfUserLoginComponent ], entryComponents: [ NfRegistryCreateBucket diff --git a/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-bucket-grid-list-viewer.js b/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-bucket-grid-list-viewer.js index cbba95e..1712ada 100644 --- a/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-bucket-grid-list-viewer.js +++ b/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-bucket-grid-list-viewer.js @@ -52,30 +52,26 @@ NfRegistryBucketGridListViewer.prototype = { // reset the breadcrumb state this.nfRegistryService.droplet = {}; - // attempt kerberos authentication - this.nfRegistryApi.ticketExchange().subscribe(function (jwt) { - self.nfRegistryService.loadCurrentUser().subscribe(function (currentUser) { - self.route.params - .switchMap(function (params) { - return new rxjs.Observable.forkJoin( - self.nfRegistryApi.getBuckets(), - self.nfRegistryApi.getDroplets(params['bucketId']), - self.nfRegistryApi.getBucket(params['bucketId']) - ); - }) - .subscribe(function (response) { - var buckets = response[0]; - var droplets = response[1]; - var bucket = response[2]; - self.nfRegistryService.bucket = bucket; - self.nfRegistryService.buckets = buckets; - self.nfRegistryService.droplets = droplets; - self.nfRegistryService.filterDroplets(); - self.nfRegistryService.setBreadcrumbState('in'); - self.nfRegistryService.inProgress = false; - }); + // subscribe to the route params + self.route.params + .switchMap(function (params) { + return new rxjs.Observable.forkJoin( + self.nfRegistryApi.getBuckets(), + self.nfRegistryApi.getDroplets(params['bucketId']), + self.nfRegistryApi.getBucket(params['bucketId']) + ); + }) + .subscribe(function (response) { + var buckets = response[0]; + var droplets = response[1]; + var bucket = response[2]; + self.nfRegistryService.bucket = bucket; + self.nfRegistryService.buckets = buckets; + self.nfRegistryService.droplets = droplets; + self.nfRegistryService.filterDroplets(); + self.nfRegistryService.setBreadcrumbState('in'); + self.nfRegistryService.inProgress = false; }); - }); }, diff --git a/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-bucket-grid-list-viewer.spec.js b/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-bucket-grid-list-viewer.spec.js index 22805d0..3c9e5cc 100644 --- a/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-bucket-grid-list-viewer.spec.js +++ b/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-bucket-grid-list-viewer.spec.js @@ -17,7 +17,6 @@ var NfRegistryRoutes = require('nifi-registry/nf-registry.routes.js'); var ngCoreTesting = require('@angular/core/testing'); -var ngHttpTesting = require('@angular/http/testing'); var ngCommon = require('@angular/common'); var ngRouter = require('@angular/router'); var FdsDemo = require('nifi-registry/components/fluid-design-system/fds-demo.js'); @@ -29,9 +28,8 @@ var NfRegistryExplorer = require('nifi-registry/components/explorer/nf-registry- var NfRegistryAdministration = require('nifi-registry/components/administration/nf-registry-administration.js'); var NfRegistryUsersAdministration = require('nifi-registry/components/administration/users/nf-registry-users-administration.js'); var NfRegistryAddUser = require('nifi-registry/components/administration/users/dialogs/add-user/nf-registry-add-user.js'); -var NfRegistryUserDetails = require('nifi-registry/components/administration/users/details/nf-registry-user-details.js'); -var NfRegistryUserPermissions = require('nifi-registry/components/administration/users/permissions/nf-registry-user-permissions.js'); -var NfRegistryUserGroupPermissions = require('nifi-registry/components/administration/user-group/permissions/nf-registry-user-group-permissions.js'); +var NfRegistryManageUser = require('nifi-registry/components/administration/users/sidenav/manage-user/nf-registry-manage-user.js'); +var NfRegistryManageGroup = require('nifi-registry/components/administration/users/sidenav/manage-group/nf-registry-manage-group.js'); var NfRegistryBucketPermissions = require('nifi-registry/components/administration/workflow/buckets/permissions/nf-registry-bucket-permissions.js'); var NfRegistryWorkflowAdministration = require('nifi-registry/components/administration/workflow/nf-registry-workflow-administration.js'); var NfRegistryGridListViewer = require('nifi-registry/components/explorer/grid-list/registry/nf-registry-grid-list-viewer.js'); @@ -44,6 +42,8 @@ var ngCommonHttp = require('@angular/common/http'); var NfRegistryTokenInterceptor = require('nifi-registry/services/nf-registry.token.interceptor.js'); var NfRegistryAuthService = require('nifi-registry/services/nf-registry.auth.service.js'); var NfStorage = require('nifi-registry/services/nf-storage.service.js'); +var NfLoginComponent = require('nifi-registry/components/login/nf-registry-login.js'); +var NfUserLoginComponent = require('nifi-registry/components/login/dialogs/nf-registry-user-login.js'); describe('NfRegistryBucketGridListViewer Component', function () { var comp; @@ -65,16 +65,17 @@ describe('NfRegistryBucketGridListViewer Component', function () { NfRegistryExplorer, NfRegistryAdministration, NfRegistryUsersAdministration, - NfRegistryUserDetails, - NfRegistryUserPermissions, - NfRegistryUserGroupPermissions, + NfRegistryManageUser, + NfRegistryManageGroup, NfRegistryBucketPermissions, NfRegistryAddUser, NfRegistryWorkflowAdministration, NfRegistryGridListViewer, NfRegistryBucketGridListViewer, NfRegistryDropletGridListViewer, - NfPageNotFoundComponent + NfPageNotFoundComponent, + NfLoginComponent, + NfUserLoginComponent ], providers: [ NfRegistryService, diff --git a/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-droplet-grid-list-viewer.js b/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-droplet-grid-list-viewer.js index 41bef94..a8c1218 100644 --- a/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-droplet-grid-list-viewer.js +++ b/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-droplet-grid-list-viewer.js @@ -48,33 +48,30 @@ NfRegistryDropletGridListViewer.prototype = { var self = this; this.nfRegistryService.inProgress = true; this.nfRegistryService.explorerViewType = 'grid-list'; - // attempt kerberos authentication - this.nfRegistryApi.ticketExchange().subscribe(function (jwt) { - self.nfRegistryService.loadCurrentUser().subscribe(function (currentUser) { - self.route.params - .switchMap(function (params) { - return new rxjs.Observable.forkJoin( - self.nfRegistryApi.getDroplet(params['bucketId'], params['dropletType'], params['dropletId']), - self.nfRegistryApi.getBucket(params['bucketId']), - self.nfRegistryApi.getBuckets(), - self.nfRegistryApi.getDroplets(params['bucketId']) - ); - }) - .subscribe(function (response) { - var droplet = response[0]; - var bucket = response[1]; - var buckets = response[2]; - var droplets = response[3]; - self.nfRegistryService.bucket = bucket; - self.nfRegistryService.buckets = buckets; - self.nfRegistryService.droplet = droplet; - self.nfRegistryService.droplets = droplets; - self.nfRegistryService.filterDroplets(); - self.nfRegistryService.setBreadcrumbState('in'); - self.nfRegistryService.inProgress = false; - }); + + // subscribe to the route params + self.route.params + .switchMap(function (params) { + return new rxjs.Observable.forkJoin( + self.nfRegistryApi.getDroplet(params['bucketId'], params['dropletType'], params['dropletId']), + self.nfRegistryApi.getBucket(params['bucketId']), + self.nfRegistryApi.getBuckets(), + self.nfRegistryApi.getDroplets(params['bucketId']) + ); + }) + .subscribe(function (response) { + var droplet = response[0]; + var bucket = response[1]; + var buckets = response[2]; + var droplets = response[3]; + self.nfRegistryService.bucket = bucket; + self.nfRegistryService.buckets = buckets; + self.nfRegistryService.droplet = droplet; + self.nfRegistryService.droplets = droplets; + self.nfRegistryService.filterDroplets(); + self.nfRegistryService.setBreadcrumbState('in'); + self.nfRegistryService.inProgress = false; }); - }); }, /** diff --git a/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-droplet-grid-list-viewer.spec.js b/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-droplet-grid-list-viewer.spec.js index 8631eb4..b41d3c6 100644 --- a/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-droplet-grid-list-viewer.spec.js +++ b/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-droplet-grid-list-viewer.spec.js @@ -17,7 +17,6 @@ var NfRegistryRoutes = require('nifi-registry/nf-registry.routes.js'); var ngCoreTesting = require('@angular/core/testing'); -var ngHttpTesting = require('@angular/http/testing'); var ngCommon = require('@angular/common'); var ngRouter = require('@angular/router'); var FdsDemo = require('nifi-registry/components/fluid-design-system/fds-demo.js'); @@ -29,9 +28,8 @@ var NfRegistryExplorer = require('nifi-registry/components/explorer/nf-registry- var NfRegistryAdministration = require('nifi-registry/components/administration/nf-registry-administration.js'); var NfRegistryUsersAdministration = require('nifi-registry/components/administration/users/nf-registry-users-administration.js'); var NfRegistryAddUser = require('nifi-registry/components/administration/users/dialogs/add-user/nf-registry-add-user.js'); -var NfRegistryUserDetails = require('nifi-registry/components/administration/users/details/nf-registry-user-details.js'); -var NfRegistryUserPermissions = require('nifi-registry/components/administration/users/permissions/nf-registry-user-permissions.js'); -var NfRegistryUserGroupPermissions = require('nifi-registry/components/administration/user-group/permissions/nf-registry-user-group-permissions.js'); +var NfRegistryManageUser = require('nifi-registry/components/administration/users/sidenav/manage-user/nf-registry-manage-user.js'); +var NfRegistryManageGroup = require('nifi-registry/components/administration/users/sidenav/manage-group/nf-registry-manage-group.js'); var NfRegistryBucketPermissions = require('nifi-registry/components/administration/workflow/buckets/permissions/nf-registry-bucket-permissions.js'); var NfRegistryWorkflowAdministration = require('nifi-registry/components/administration/workflow/nf-registry-workflow-administration.js'); var NfRegistryGridListViewer = require('nifi-registry/components/explorer/grid-list/registry/nf-registry-grid-list-viewer.js'); @@ -44,6 +42,8 @@ var ngCommonHttp = require('@angular/common/http'); var NfRegistryTokenInterceptor = require('nifi-registry/services/nf-registry.token.interceptor.js'); var NfRegistryAuthService = require('nifi-registry/services/nf-registry.auth.service.js'); var NfStorage = require('nifi-registry/services/nf-storage.service.js'); +var NfLoginComponent = require('nifi-registry/components/login/nf-registry-login.js'); +var NfUserLoginComponent = require('nifi-registry/components/login/dialogs/nf-registry-user-login.js'); describe('NfRegistryDropletGridListViewer Component', function () { var comp; @@ -65,16 +65,17 @@ describe('NfRegistryDropletGridListViewer Component', function () { NfRegistryExplorer, NfRegistryAdministration, NfRegistryUsersAdministration, - NfRegistryUserDetails, - NfRegistryUserPermissions, - NfRegistryUserGroupPermissions, + NfRegistryManageUser, + NfRegistryManageGroup, NfRegistryBucketPermissions, NfRegistryAddUser, NfRegistryWorkflowAdministration, NfRegistryGridListViewer, NfRegistryBucketGridListViewer, NfRegistryDropletGridListViewer, - NfPageNotFoundComponent + NfPageNotFoundComponent, + NfLoginComponent, + NfUserLoginComponent ], providers: [ NfRegistryService, diff --git a/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-grid-list-viewer.html b/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-grid-list-viewer.html index bb8c52d..8e336ab 100644 --- a/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-grid-list-viewer.html +++ b/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-grid-list-viewer.html @@ -20,8 +20,8 @@ limitations under the License.
+ (add)="nfRegistryService.filterDroplets(nfRegistryService.activeDropletColumn.name, nfRegistryService.activeDropletColumn.sortOrder);" + (remove)="nfRegistryService.filterDroplets(nfRegistryService.activeDropletColumn.name, nfRegistryService.activeDropletColumn.sortOrder);" class="push-right-sm"> Sort by:
{{nfRegistryService.getSortByLabel()}}
@@ -84,12 +84,9 @@ limitations under the License.
- - - {{snapshotMeta.timestamp | amTimeAgo}} -
{{snapshotMeta.comments}} diff --git a/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-grid-list-viewer.js b/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-grid-list-viewer.js index adeee3f..b3ff7e7 100644 --- a/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-grid-list-viewer.js +++ b/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-grid-list-viewer.js @@ -53,25 +53,21 @@ NfRegistryGridListViewer.prototype = { this.nfRegistryService.bucket = {}; this.nfRegistryService.droplet = {}; - // attempt kerberos authentication - this.nfRegistryApi.ticketExchange().subscribe(function (jwt) { - self.nfRegistryService.loadCurrentUser().subscribe(function (currentUser) { - self.route.params - .switchMap(function (params) { - return new rxjs.Observable.forkJoin(self.nfRegistryApi.getDroplets(), - self.nfRegistryApi.getBuckets()); - }) - .subscribe(function (response) { - var droplets = response[0]; - var buckets = response[1]; - self.nfRegistryService.buckets = buckets; - self.nfRegistryService.droplets = droplets; - self.nfRegistryService.filterDroplets(); - self.nfRegistryService.setBreadcrumbState('in'); - self.nfRegistryService.inProgress = false; - }); + // subscribe to the route params + self.route.params + .switchMap(function (params) { + return new rxjs.Observable.forkJoin(self.nfRegistryApi.getDroplets(), + self.nfRegistryApi.getBuckets()); + }) + .subscribe(function (response) { + var droplets = response[0]; + var buckets = response[1]; + self.nfRegistryService.buckets = buckets; + self.nfRegistryService.droplets = droplets; + self.nfRegistryService.filterDroplets(); + self.nfRegistryService.setBreadcrumbState('in'); + self.nfRegistryService.inProgress = false; }); - }); }, /** diff --git a/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-grid-list-viewer.spec.js b/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-grid-list-viewer.spec.js index 2c926b4..be04713 100644 --- a/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-grid-list-viewer.spec.js +++ b/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/nf-registry-grid-list-viewer.spec.js @@ -28,9 +28,8 @@ var NfRegistryExplorer = require('nifi-registry/components/explorer/nf-registry- var NfRegistryAdministration = require('nifi-registry/components/administration/nf-registry-administration.js'); var NfRegistryUsersAdministration = require('nifi-registry/components/administration/users/nf-registry-users-administration.js'); var NfRegistryAddUser = require('nifi-registry/components/administration/users/dialogs/add-user/nf-registry-add-user.js'); -var NfRegistryUserDetails = require('nifi-registry/components/administration/users/details/nf-registry-user-details.js'); -var NfRegistryUserPermissions = require('nifi-registry/components/administration/users/permissions/nf-registry-user-permissions.js'); -var NfRegistryUserGroupPermissions = require('nifi-registry/components/administration/user-group/permissions/nf-registry-user-group-permissions.js'); +var NfRegistryManageUser = require('nifi-registry/components/administration/users/sidenav/manage-user/nf-registry-manage-user.js'); +var NfRegistryManageGroup = require('nifi-registry/components/administration/users/sidenav/manage-group/nf-registry-manage-group.js'); var NfRegistryBucketPermissions = require('nifi-registry/components/administration/workflow/buckets/permissions/nf-registry-bucket-permissions.js'); var NfRegistryWorkflowAdministration = require('nifi-registry/components/administration/workflow/nf-registry-workflow-administration.js'); var NfRegistryGridListViewer = require('nifi-registry/components/explorer/grid-list/registry/nf-registry-grid-list-viewer.js'); @@ -43,6 +42,8 @@ var ngCommonHttp = require('@angular/common/http'); var NfRegistryTokenInterceptor = require('nifi-registry/services/nf-registry.token.interceptor.js'); var NfRegistryAuthService = require('nifi-registry/services/nf-registry.auth.service.js'); var NfStorage = require('nifi-registry/services/nf-storage.service.js'); +var NfLoginComponent = require('nifi-registry/components/login/nf-registry-login.js'); +var NfUserLoginComponent = require('nifi-registry/components/login/dialogs/nf-registry-user-login.js'); describe('NfRegistryGridListViewer Component', function () { var comp; @@ -64,16 +65,17 @@ describe('NfRegistryGridListViewer Component', function () { NfRegistryExplorer, NfRegistryAdministration, NfRegistryUsersAdministration, - NfRegistryUserDetails, - NfRegistryUserPermissions, - NfRegistryUserGroupPermissions, + NfRegistryManageUser, + NfRegistryManageGroup, NfRegistryBucketPermissions, NfRegistryAddUser, NfRegistryWorkflowAdministration, NfRegistryGridListViewer, NfRegistryBucketGridListViewer, NfRegistryDropletGridListViewer, - NfPageNotFoundComponent + NfPageNotFoundComponent, + NfLoginComponent, + NfUserLoginComponent ], providers: [ NfRegistryService, diff --git a/nifi-registry-web-ui/src/main/webapp/components/explorer/nf-registry-explorer.spec.js b/nifi-registry-web-ui/src/main/webapp/components/explorer/nf-registry-explorer.spec.js index 605965a..228f9dd 100644 --- a/nifi-registry-web-ui/src/main/webapp/components/explorer/nf-registry-explorer.spec.js +++ b/nifi-registry-web-ui/src/main/webapp/components/explorer/nf-registry-explorer.spec.js @@ -27,9 +27,8 @@ var NfRegistryExplorer = require('nifi-registry/components/explorer/nf-registry- var NfRegistryAdministration = require('nifi-registry/components/administration/nf-registry-administration.js'); var NfRegistryUsersAdministration = require('nifi-registry/components/administration/users/nf-registry-users-administration.js'); var NfRegistryAddUser = require('nifi-registry/components/administration/users/dialogs/add-user/nf-registry-add-user.js'); -var NfRegistryUserDetails = require('nifi-registry/components/administration/users/details/nf-registry-user-details.js'); -var NfRegistryUserPermissions = require('nifi-registry/components/administration/users/permissions/nf-registry-user-permissions.js'); -var NfRegistryUserGroupPermissions = require('nifi-registry/components/administration/user-group/permissions/nf-registry-user-group-permissions.js'); +var NfRegistryManageUser = require('nifi-registry/components/administration/users/sidenav/manage-user/nf-registry-manage-user.js'); +var NfRegistryManageGroup = require('nifi-registry/components/administration/users/sidenav/manage-group/nf-registry-manage-group.js'); var NfRegistryBucketPermissions = require('nifi-registry/components/administration/workflow/buckets/permissions/nf-registry-bucket-permissions.js'); var NfRegistryWorkflowAdministration = require('nifi-registry/components/administration/workflow/nf-registry-workflow-administration.js'); var NfRegistryGridListViewer = require('nifi-registry/components/explorer/grid-list/registry/nf-registry-grid-list-viewer.js'); @@ -41,6 +40,8 @@ var ngCommonHttp = require('@angular/common/http'); var NfRegistryTokenInterceptor = require('nifi-registry/services/nf-registry.token.interceptor.js'); var NfRegistryAuthService = require('nifi-registry/services/nf-registry.auth.service.js'); var NfStorage = require('nifi-registry/services/nf-storage.service.js'); +var NfLoginComponent = require('nifi-registry/components/login/nf-registry-login.js'); +var NfUserLoginComponent = require('nifi-registry/components/login/dialogs/nf-registry-user-login.js'); describe('NfRegistryExplorer Component', function () { var comp; @@ -61,16 +62,17 @@ describe('NfRegistryExplorer Component', function () { NfRegistryExplorer, NfRegistryAdministration, NfRegistryUsersAdministration, - NfRegistryUserDetails, - NfRegistryUserPermissions, - NfRegistryUserGroupPermissions, + NfRegistryManageUser, + NfRegistryManageGroup, NfRegistryBucketPermissions, NfRegistryAddUser, NfRegistryWorkflowAdministration, NfRegistryGridListViewer, NfRegistryBucketGridListViewer, NfRegistryDropletGridListViewer, - NfPageNotFoundComponent + NfPageNotFoundComponent, + NfLoginComponent, + NfUserLoginComponent ], providers: [ NfRegistryService, diff --git a/nifi-registry-web-ui/src/main/webapp/components/login/dialogs/nf-registry-user-login.html b/nifi-registry-web-ui/src/main/webapp/components/login/dialogs/nf-registry-user-login.html new file mode 100644 index 0000000..5fc9c6c --- /dev/null +++ b/nifi-registry-web-ui/src/main/webapp/components/login/dialogs/nf-registry-user-login.html @@ -0,0 +1,45 @@ + + +
+
+ Log In +
+
+
+ + + +
+
+ + + +
+
+
+ + + +
+
\ No newline at end of file diff --git a/nifi-registry-web-ui/src/main/webapp/components/login/dialogs/nf-registry-user-login.js b/nifi-registry-web-ui/src/main/webapp/components/login/dialogs/nf-registry-user-login.js new file mode 100644 index 0000000..77fb7e2 --- /dev/null +++ b/nifi-registry-web-ui/src/main/webapp/components/login/dialogs/nf-registry-user-login.js @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var ngCore = require('@angular/core'); +var NfRegistryService = require('nifi-registry/services/nf-registry.service.js'); +var NfRegistryApi = require('nifi-registry/services/nf-registry.api.js'); +var ngMaterial = require('@angular/material'); + +/** + * NfRegistryUserLogin constructor. + * + * @param nfRegistryApi The api service. + * @param nfRegistryService The nf-registry.service module. + * @param matDialogRef The angular material dialog ref. + * @constructor + */ +function NfRegistryUserLogin(nfRegistryApi, nfRegistryService, matDialogRef) { + this.nfRegistryService = nfRegistryService; + this.nfRegistryApi = nfRegistryApi; + this.dialogRef = matDialogRef; +}; + +NfRegistryUserLogin.prototype = { + constructor: NfRegistryUserLogin, + + /** + * Submit login form. + * + * @param username The user name. + * @param password The password. + */ + login: function (username, password) { + var self = this; + this.nfRegistryApi.postToLogin(username.value, password.value).subscribe(function(response){ + if(!response.status || response.status === 200) { + //successful login + self.nfRegistryService.router.navigateByUrl(self.nfRegistryService.redirectUrl); + } + }); + } +}; + +NfRegistryUserLogin.annotations = [ + new ngCore.Component({ + template: require('./nf-registry-user-login.html!text') + }) +]; + +NfRegistryUserLogin.parameters = [ + NfRegistryApi, + NfRegistryService, + ngMaterial.MatDialogRef +]; + +module.exports = NfRegistryUserLogin; diff --git a/nifi-registry-web-ui/src/main/webapp/components/administration/users/details/nf-registry-user-details.html b/nifi-registry-web-ui/src/main/webapp/components/login/nf-registry-login.html similarity index 60% rename from nifi-registry-web-ui/src/main/webapp/components/administration/users/details/nf-registry-user-details.html rename to nifi-registry-web-ui/src/main/webapp/components/login/nf-registry-login.html index 0329093..93d0efc 100644 --- a/nifi-registry-web-ui/src/main/webapp/components/administration/users/details/nf-registry-user-details.html +++ b/nifi-registry-web-ui/src/main/webapp/components/login/nf-registry-login.html @@ -15,14 +15,5 @@ See the License for the specific language governing permissions and limitations under the License. --> -
-
- User Details - -
- -
+
+ diff --git a/nifi-registry-web-ui/src/main/webapp/components/administration/users/permissions/nf-registry-user-permissions.js b/nifi-registry-web-ui/src/main/webapp/components/login/nf-registry-login.js similarity index 53% rename from nifi-registry-web-ui/src/main/webapp/components/administration/users/permissions/nf-registry-user-permissions.js rename to nifi-registry-web-ui/src/main/webapp/components/login/nf-registry-login.js index cb6d17c..e81cc47 100644 --- a/nifi-registry-web-ui/src/main/webapp/components/administration/users/permissions/nf-registry-user-permissions.js +++ b/nifi-registry-web-ui/src/main/webapp/components/login/nf-registry-login.js @@ -15,55 +15,50 @@ * limitations under the License. */ var ngCore = require('@angular/core'); +var ngMaterial = require('@angular/material'); var NfRegistryService = require('nifi-registry/services/nf-registry.service.js'); -var ngRouter = require('@angular/router'); +var nfRegistryAnimations = require('nifi-registry/nf-registry.animations.js'); +var NfUserLoginComponent = require('nifi-registry/components/login/dialogs/nf-registry-user-login.js'); /** - * NfRegistryUserPermissions constructor. + * NfLoginComponent constructor. * * @param nfRegistryService The nf-registry.service module. - * @param Router The angular router module. - * @constructor + * @param matDialog The angular material dialog module. */ -function NfRegistryUserPermissions(nfRegistryService, Router) { +function NfLoginComponent(nfRegistryService, matDialog) { + // Services this.nfRegistryService = nfRegistryService; - this.router = Router; + this.dialog = matDialog; }; -NfRegistryUserPermissions.prototype = { - constructor: NfRegistryUserPermissions, +NfLoginComponent.prototype = { + constructor: NfLoginComponent, /** - * Initialize the component. + * Initialize the component */ ngOnInit: function () { - this.nfRegistryService.sidenav.open(); - }, - - /** - * Destroy the component. - */ - ngOnDestroy: function () { - this.nfRegistryService.sidenav.close(); - }, - - /** - * Navigate to administer users for current registry. - */ - closeSideNav: function () { - this.router.navigateByUrl('/nifi-registry/administration/users'); + this.nfRegistryService.perspective = 'login'; + this.dialog.open(NfUserLoginComponent, { + disableClose: true + }); } }; -NfRegistryUserPermissions.annotations = [ +NfLoginComponent.annotations = [ new ngCore.Component({ - template: require('./nf-registry-user-permissions.html!text') + template: require('./nf-registry-login.html!text'), + animations: [nfRegistryAnimations.slideInLeftAnimation], + host: { + '[@routeAnimation]': 'routeAnimation' + } }) ]; -NfRegistryUserPermissions.parameters = [ +NfLoginComponent.parameters = [ NfRegistryService, - ngRouter.Router + ngMaterial.MatDialog ]; -module.exports = NfRegistryUserPermissions; +module.exports = NfLoginComponent; diff --git a/nifi-registry-web-ui/src/main/webapp/components/administration/users/permissions/nf-registry-user-permissions.html b/nifi-registry-web-ui/src/main/webapp/components/page-not-found/nf-registry-page-not-found.html similarity index 58% rename from nifi-registry-web-ui/src/main/webapp/components/administration/users/permissions/nf-registry-user-permissions.html rename to nifi-registry-web-ui/src/main/webapp/components/page-not-found/nf-registry-page-not-found.html index 2069e3c..00c9582 100644 --- a/nifi-registry-web-ui/src/main/webapp/components/administration/users/permissions/nf-registry-user-permissions.html +++ b/nifi-registry-web-ui/src/main/webapp/components/page-not-found/nf-registry-page-not-found.html @@ -15,14 +15,5 @@ See the License for the specific language governing permissions and limitations under the License. --> -
-
- {{nfRegistryService.user.identity}} - -
- -
+
+ diff --git a/nifi-registry-web-ui/src/main/webapp/components/page-not-found/nf-registry-page-not-found.js b/nifi-registry-web-ui/src/main/webapp/components/page-not-found/nf-registry-page-not-found.js index 26c676b..28c1447 100644 --- a/nifi-registry-web-ui/src/main/webapp/components/page-not-found/nf-registry-page-not-found.js +++ b/nifi-registry-web-ui/src/main/webapp/components/page-not-found/nf-registry-page-not-found.js @@ -15,22 +15,57 @@ * limitations under the License. */ var ngCore = require('@angular/core'); +var NfRegistryService = require('nifi-registry/services/nf-registry.service.js'); +var nfRegistryAnimations = require('nifi-registry/nf-registry.animations.js'); +var fdsDialogsModule = require('@fluid-design-system/dialogs'); /** - * NfPageNotFoundComponent constructor. + * NfLoginComponent constructor. + * + * @param nfRegistryService The nf-registry.service module. + * @param fdsDialogService The FDS dialog service. */ -function NfPageNotFoundComponent() { - this.title = "Page Not Found!!!!"; +function NfPageNotFoundComponent(nfRegistryService, fdsDialogService) { + // Services + this.nfRegistryService = nfRegistryService; + this.dialogService = fdsDialogService; }; NfPageNotFoundComponent.prototype = { - constructor: NfPageNotFoundComponent + constructor: NfPageNotFoundComponent, + + /** + * Initialize the component + */ + ngOnInit: function () { + var self = this; + this.nfRegistryService.perspective = 'not-found'; + this.dialogService.openConfirm({ + title: 'Page Not Found', + acceptButton: 'Home', + acceptButtonColor: 'fds-warn' + }).afterClosed().subscribe( + function (accept) { + if (accept) { + self.nfRegistryService.router.navigateByUrl(self.nfRegistryService.redirectUrl); + } + }); + } }; NfPageNotFoundComponent.annotations = [ new ngCore.Component({ - template: '

Hello {{title}}!

' + template: require('./nf-registry-page-not-found.html!text'), + animations: [nfRegistryAnimations.slideInLeftAnimation], + host: { + '[@routeAnimation]': 'routeAnimation' + } }) ]; +NfPageNotFoundComponent.parameters = [ + NfRegistryService, + fdsDialogsModule.FdsDialogService, +]; + module.exports = NfPageNotFoundComponent; diff --git a/nifi-registry-web-ui/src/main/webapp/nf-registry.html b/nifi-registry-web-ui/src/main/webapp/nf-registry.html index b175233..21eaffa 100644 --- a/nifi-registry-web-ui/src/main/webapp/nf-registry.html +++ b/nifi-registry-web-ui/src/main/webapp/nf-registry.html @@ -23,7 +23,7 @@ limitations under the License.
-
+
{{nfRegistryService.registry.name}} -
+
{{nfRegistryService.currentUser.identity}}
logout
- - diff --git a/nifi-registry-web-ui/src/main/webapp/nf-registry.js b/nifi-registry-web-ui/src/main/webapp/nf-registry.js index df344f7..edf840c 100644 --- a/nifi-registry-web-ui/src/main/webapp/nf-registry.js +++ b/nifi-registry-web-ui/src/main/webapp/nf-registry.js @@ -68,7 +68,8 @@ NfRegistry.prototype = { * Invalidate old tokens and route to login page */ logout: function() { - this.nfRegistryService.currentUser = {}; + delete this.nfRegistryService.currentUser.identity; + delete this.nfRegistryService.currentUser.anonymous; this.nfStorage.removeItem('jwt'); this.router.navigateByUrl('/nifi-registry/login'); } diff --git a/nifi-registry-web-ui/src/main/webapp/nf-registry.module.js b/nifi-registry-web-ui/src/main/webapp/nf-registry.module.js index c862dab..b250d13 100644 --- a/nifi-registry-web-ui/src/main/webapp/nf-registry.module.js +++ b/nifi-registry-web-ui/src/main/webapp/nf-registry.module.js @@ -23,15 +23,17 @@ var NfRegistry = require('nifi-registry/nf-registry.js'); var NfRegistryApi = require('nifi-registry/services/nf-registry.api.js'); var NfRegistryService = require('nifi-registry/services/nf-registry.service.js'); var NfPageNotFoundComponent = require('nifi-registry/components/page-not-found/nf-registry-page-not-found.js'); +var NfLoginComponent = require('nifi-registry/components/login/nf-registry-login.js'); +var NfUserLoginComponent = require('nifi-registry/components/login/dialogs/nf-registry-user-login.js'); var NfRegistryExplorer = require('nifi-registry/components/explorer/nf-registry-explorer.js'); var NfRegistryAdministration = require('nifi-registry/components/administration/nf-registry-administration.js'); var NfRegistryUsersAdministration = require('nifi-registry/components/administration/users/nf-registry-users-administration.js'); var NfRegistryAddUser = require('nifi-registry/components/administration/users/dialogs/add-user/nf-registry-add-user.js'); var NfRegistryCreateNewGroup = require('nifi-registry/components/administration/users/dialogs/create-new-group/nf-registry-create-new-group.js'); -var NfRegistryAddSelectedToGroup = require('nifi-registry/components/administration/users/dialogs/add-selected-users-to-group/nf-registry-add-selected-users-to-group.js'); -var NfRegistryUserDetails = require('nifi-registry/components/administration/users/details/nf-registry-user-details.js'); -var NfRegistryUserPermissions = require('nifi-registry/components/administration/users/permissions/nf-registry-user-permissions.js'); -var NfRegistryUserGroupPermissions = require('nifi-registry/components/administration/user-group/permissions/nf-registry-user-group-permissions.js'); +var NfRegistryAddUserToGroups = require('nifi-registry/components/administration/users/dialogs/add-user-to-groups/nf-registry-add-user-to-groups.js'); +var NfRegistryAddUsersToGroup = require('nifi-registry/components/administration/users/dialogs/add-users-to-group/nf-registry-add-users-to-group.js'); +var NfRegistryManageUser = require('nifi-registry/components/administration/users/sidenav/manage-user/nf-registry-manage-user.js'); +var NfRegistryManageGroup = require('nifi-registry/components/administration/users/sidenav/manage-group/nf-registry-manage-group.js'); var NfRegistryBucketPermissions = require('nifi-registry/components/administration/workflow/buckets/permissions/nf-registry-bucket-permissions.js'); var NfRegistryWorkflowAdministration = require('nifi-registry/components/administration/workflow/nf-registry-workflow-administration.js'); var NfRegistryCreateBucket = require('nifi-registry/components/administration/workflow/dialogs/nf-registry-create-bucket.js'); @@ -42,6 +44,7 @@ var fdsCore = require('@fluid-design-system/core'); var ngCommonHttp = require('@angular/common/http'); var NfRegistryTokenInterceptor = require('nifi-registry/services/nf-registry.token.interceptor.js'); var NfRegistryAuthService = require('nifi-registry/services/nf-registry.auth.service.js'); +var nfRegistryAuthGuardService = require('nifi-registry/services/nf-registry.auth-guard.service.js'); var NfStorage = require('nifi-registry/services/nf-storage.service.js'); function NfRegistryModule() { @@ -65,29 +68,37 @@ NfRegistryModule.annotations = [ NfRegistryExplorer, NfRegistryAdministration, NfRegistryUsersAdministration, - NfRegistryUserDetails, - NfRegistryUserPermissions, - NfRegistryUserGroupPermissions, + NfRegistryManageUser, + NfRegistryManageGroup, NfRegistryBucketPermissions, NfRegistryWorkflowAdministration, NfRegistryAddUser, NfRegistryCreateBucket, NfRegistryCreateNewGroup, - NfRegistryAddSelectedToGroup, + NfRegistryAddUserToGroups, + NfRegistryAddUsersToGroup, NfRegistryGridListViewer, NfRegistryBucketGridListViewer, NfRegistryDropletGridListViewer, - NfPageNotFoundComponent + NfPageNotFoundComponent, + NfLoginComponent, + NfUserLoginComponent ], entryComponents: [ NfRegistryAddUser, NfRegistryCreateBucket, NfRegistryCreateNewGroup, - NfRegistryAddSelectedToGroup + NfRegistryAddUserToGroups, + NfRegistryAddUsersToGroup, + NfUserLoginComponent ], providers: [ NfRegistryService, NfRegistryAuthService, + nfRegistryAuthGuardService.NfRegistryUsersAdministrationAuthGuard, + nfRegistryAuthGuardService.NfRegistryWorkflowsAdministrationAuthGuard, + nfRegistryAuthGuardService.NfRegistryLoginAuthGuard, + nfRegistryAuthGuardService.NfRegistryResourcesAuthGuard, NfRegistryApi, NfStorage, { diff --git a/nifi-registry-web-ui/src/main/webapp/nf-registry.routes.js b/nifi-registry-web-ui/src/main/webapp/nf-registry.routes.js index 4cf5f60..9413777 100644 --- a/nifi-registry-web-ui/src/main/webapp/nf-registry.routes.js +++ b/nifi-registry-web-ui/src/main/webapp/nf-registry.routes.js @@ -18,17 +18,18 @@ var ngRouter = require('@angular/router'); var FdsDemo = require('nifi-registry/components/fluid-design-system/fds-demo.js'); var NfPageNotFoundComponent = require('nifi-registry/components/page-not-found/nf-registry-page-not-found.js'); +var NfLoginComponent = require('nifi-registry/components/login/nf-registry-login.js'); var NfRegistryExplorer = require('nifi-registry/components/explorer/nf-registry-explorer.js'); var NfRegistryAdministration = require('nifi-registry/components/administration/nf-registry-administration.js'); var NfRegistryUsersAdministration = require('nifi-registry/components/administration/users/nf-registry-users-administration.js'); -var NfRegistryUserDetails = require('nifi-registry/components/administration/users/details/nf-registry-user-details.js'); -var NfRegistryUserPermissions = require('nifi-registry/components/administration/users/permissions/nf-registry-user-permissions.js'); -var NfRegistryUserGroupPermissions = require('nifi-registry/components/administration/user-group/permissions/nf-registry-user-group-permissions.js'); +var NfRegistryManageUser = require('nifi-registry/components/administration/users/sidenav/manage-user/nf-registry-manage-user.js'); +var NfRegistryManageGroup = require('nifi-registry/components/administration/users/sidenav/manage-group/nf-registry-manage-group.js'); var NfRegistryBucketPermissions = require('nifi-registry/components/administration/workflow/buckets/permissions/nf-registry-bucket-permissions.js'); var NfRegistryWorkflowAdministration = require('nifi-registry/components/administration/workflow/nf-registry-workflow-administration.js'); var NfRegistryGridListViewer = require('nifi-registry/components/explorer/grid-list/registry/nf-registry-grid-list-viewer.js'); var NfRegistryBucketGridListViewer = require('nifi-registry/components/explorer/grid-list/registry/nf-registry-bucket-grid-list-viewer.js'); var NfRegistryDropletGridListViewer = require('nifi-registry/components/explorer/grid-list/registry/nf-registry-droplet-grid-list-viewer.js'); +var nfRegistryAuthGuardService = require('nifi-registry/services/nf-registry.auth-guard.service.js'); var NfRegistryRoutes = new ngRouter.RouterModule.forRoot([{ path: 'nifi-registry/explorer', @@ -36,17 +37,23 @@ var NfRegistryRoutes = new ngRouter.RouterModule.forRoot([{ children: [ { path: 'grid-list', - component: NfRegistryGridListViewer + component: NfRegistryGridListViewer, + canActivate: [nfRegistryAuthGuardService.NfRegistryResourcesAuthGuard] }, { path: 'grid-list/buckets/:bucketId', - component: NfRegistryBucketGridListViewer + component: NfRegistryBucketGridListViewer, + canActivate: [nfRegistryAuthGuardService.NfRegistryResourcesAuthGuard] }, { path: 'grid-list/buckets/:bucketId/:dropletType/:dropletId', - component: NfRegistryDropletGridListViewer + component: NfRegistryDropletGridListViewer, + canActivate: [nfRegistryAuthGuardService.NfRegistryResourcesAuthGuard] } - ] - // canActivate: [AuthGuard] //TODO: https://angular.io/api/router/CanActivate https://scotch.io/tutorials/routing-angular-2-single-page-apps-with-the-component-router + ] +}, { + path: 'nifi-registry/login', + component: NfLoginComponent, + canActivate: [nfRegistryAuthGuardService.NfRegistryLoginAuthGuard] }, { path: 'nifi-registry/fluid-design-system', component: FdsDemo @@ -55,14 +62,16 @@ var NfRegistryRoutes = new ngRouter.RouterModule.forRoot([{ component: NfRegistryAdministration, children: [{ path: '', - redirectTo: 'users', + redirectTo: 'workflow', pathMatch: 'full' }, { path: 'users', - component: NfRegistryUsersAdministration + component: NfRegistryUsersAdministration, + canActivate: [nfRegistryAuthGuardService.NfRegistryUsersAdministrationAuthGuard] }, { path: 'workflow', - component: NfRegistryWorkflowAdministration + component: NfRegistryWorkflowAdministration, + canActivate: [nfRegistryAuthGuardService.NfRegistryWorkflowsAdministrationAuthGuard] }] }, { path: 'nifi-registry/explorer/grid-list/buckets', @@ -80,20 +89,19 @@ var NfRegistryRoutes = new ngRouter.RouterModule.forRoot([{ path: '**', component: NfPageNotFoundComponent }, { - path: 'user/details/:userId', - component: NfRegistryUserDetails, + path: 'manage/user/:userId', + component: NfRegistryManageUser, + canActivate: [nfRegistryAuthGuardService.NfRegistryUsersAdministrationAuthGuard], outlet: 'sidenav' }, { - path: 'user/permissions/:userId', - component: NfRegistryUserPermissions, - outlet: 'sidenav' -}, { - path: 'group/permissions/:groupId', - component: NfRegistryUserGroupPermissions, + path: 'manage/group/:groupId', + component: NfRegistryManageGroup, + canActivate: [nfRegistryAuthGuardService.NfRegistryUsersAdministrationAuthGuard], outlet: 'sidenav' }, { path: 'bucket/permissions/:bucketId', component: NfRegistryBucketPermissions, + canActivate: [nfRegistryAuthGuardService.NfRegistryWorkflowsAdministrationAuthGuard], outlet: 'sidenav' }]); diff --git a/nifi-registry-web-ui/src/main/webapp/nf-registry.spec.js b/nifi-registry-web-ui/src/main/webapp/nf-registry.spec.js index 98ba0d4..09632be 100644 --- a/nifi-registry-web-ui/src/main/webapp/nf-registry.spec.js +++ b/nifi-registry-web-ui/src/main/webapp/nf-registry.spec.js @@ -27,9 +27,8 @@ var NfRegistryExplorer = require('nifi-registry/components/explorer/nf-registry- var NfRegistryAdministration = require('nifi-registry/components/administration/nf-registry-administration.js'); var NfRegistryUsersAdministration = require('nifi-registry/components/administration/users/nf-registry-users-administration.js'); var NfRegistryAddUser = require('nifi-registry/components/administration/users/dialogs/add-user/nf-registry-add-user.js'); -var NfRegistryUserGroupPermissions = require('nifi-registry/components/administration/user-group/permissions/nf-registry-user-group-permissions.js'); -var NfRegistryUserDetails = require('nifi-registry/components/administration/users/details/nf-registry-user-details.js'); -var NfRegistryUserPermissions = require('nifi-registry/components/administration/users/permissions/nf-registry-user-permissions.js'); +var NfRegistryManageGroup = require('nifi-registry/components/administration/users/sidenav/manage-group/nf-registry-manage-group.js'); +var NfRegistryManageUser = require('nifi-registry/components/administration/users/sidenav/manage-user/nf-registry-manage-user.js'); var NfRegistryBucketPermissions = require('nifi-registry/components/administration/workflow/buckets/permissions/nf-registry-bucket-permissions.js'); var NfRegistryWorkflowAdministration = require('nifi-registry/components/administration/workflow/nf-registry-workflow-administration.js'); var NfRegistryGridListViewer = require('nifi-registry/components/explorer/grid-list/registry/nf-registry-grid-list-viewer.js'); @@ -42,6 +41,8 @@ var ngCommonHttp = require('@angular/common/http'); var NfRegistryTokenInterceptor = require('nifi-registry/services/nf-registry.token.interceptor.js'); var NfRegistryAuthService = require('nifi-registry/services/nf-registry.auth.service.js'); var NfStorage = require('nifi-registry/services/nf-storage.service.js'); +var NfLoginComponent = require('nifi-registry/components/login/nf-registry-login.js'); +var NfUserLoginComponent = require('nifi-registry/components/login/dialogs/nf-registry-user-login.js'); describe('NfRegistry Component', function () { var comp; @@ -64,16 +65,17 @@ describe('NfRegistry Component', function () { NfRegistryExplorer, NfRegistryAdministration, NfRegistryUsersAdministration, - NfRegistryUserDetails, - NfRegistryUserPermissions, - NfRegistryUserGroupPermissions, + NfRegistryManageUser, + NfRegistryManageGroup, NfRegistryBucketPermissions, NfRegistryAddUser, NfRegistryWorkflowAdministration, NfRegistryGridListViewer, NfRegistryBucketGridListViewer, NfRegistryDropletGridListViewer, - NfPageNotFoundComponent + NfPageNotFoundComponent, + NfLoginComponent, + NfUserLoginComponent ], providers: [ NfRegistryService, diff --git a/nifi-registry-web-ui/src/main/webapp/services/nf-registry.api.js b/nifi-registry-web-ui/src/main/webapp/services/nf-registry.api.js index 5491c25..08bec02 100644 --- a/nifi-registry-web-ui/src/main/webapp/services/nf-registry.api.js +++ b/nifi-registry-web-ui/src/main/webapp/services/nf-registry.api.js @@ -264,10 +264,15 @@ NfRegistryApi.prototype = { }); }, - //TODO: REST call to API to get user by id. + /** + * Get user by id. + * + * @param userId + * @returns {*} + */ getUser: function (userId) { var self = this; - return this.http.get('/nifi-registry-api/users/' + userId) + return this.http.get('/nifi-registry-api/tenants/users/' + userId) .map(function (response) { return response; }) @@ -285,15 +290,40 @@ NfRegistryApi.prototype = { /** * Creates a user. * - * @param {string} identifier The identifier of the user. * @param {string} identity The identity of the user. * @returns {*} */ - addUser: function (identifier, identity) { + addUser: function (identity) { var self = this; return this.http.post('/nifi-registry-api/tenants/users', { - 'identifier': identifier, - 'identity': identity + identity: identity, + resourcePermissions: { + anyTopLevelResource: { + canRead: false, + canWrite: false, + canDelete: false + }, + buckets: { + canRead: false, + canWrite: false, + canDelete: false + }, + tenants: { + canRead: false, + canWrite: false, + canDelete: false + }, + policies: { + canRead: false, + canWrite: false, + canDelete: false + }, + proxy: { + canRead: false, + canWrite: false, + canDelete: false + } + } }, headers) .map(function (response) { return response; @@ -309,6 +339,27 @@ NfRegistryApi.prototype = { }); }, + /** + * Updates a user. + * + * @param {string} identifier The identifier of the user. + * @param {string} identity The identity of the user. + * @returns {*} + */ + updateUser: function (identifier, identity) { + var self = this; + return this.http.put('/nifi-registry-api/tenants/users/' + identifier, { + 'identifier': identifier, + 'identity': identity + }, headers) + .map(function (response) { + return response; + }) + .catch(function (error) { + return rxjs.Observable.of(error); + }); + }, + /** * Gets all users. * @@ -465,6 +516,48 @@ NfRegistryApi.prototype = { 'identifier': identifier, 'identity': identity, 'users': users + }, headers) + .map(function (response) { + return response; + }) + .catch(function (error) { + return rxjs.Observable.of(error); + }); + }, + + /** + * Get policy action resource. + * + * @param {string} action The name of the resource action (e.g. READ/WRITE/DELETE). + * @param {string} resource The name of the resource action (e.g. READ/WRITE/DELETE). + * @returns {*} + */ + getPolicyActionResource: function (action, resource) { + var self = this; + return this.http.get('/nifi-registry-api/policies/' + action + resource) + .map(function (response) { + return response; + }); + }, + + /** + * Update policy action resource. + * + * @param {string} identifier The identifier of the group. + * @param {string} action The name of the resource action (e.g. READ/WRITE/DELETE). + * @param {string} resource The name of the resource. + * @param {string} users The users with resource privileges. + * @param {string} userGroups The user groups with resource privileges. + * @returns {*} + */ + putPolicyActionResource: function (identifier, action, resource, users, userGroups) { + var self = this; + return this.http.put('/nifi-registry-api/policies/' + identifier, { + 'identifier': identifier, + 'resource': resource, + 'action': action, + 'users': users, + 'userGroups': userGroups }, headers) .map(function (response) { return response; @@ -480,6 +573,64 @@ NfRegistryApi.prototype = { }); }, + /** + * Creates a policy action resource. + * + * @param {string} action The name of the resource action (e.g. READ/WRITE/DELETE). + * @param {string} resource The name of the resource. + * @param {string} users The users with resource privileges. + * @param {string} userGroups The user groups with resource privileges. + * @returns {*} + */ + postPolicyActionResource: function (action, resource, users, userGroups) { + var self = this; + return this.http.post('/nifi-registry-api/policies', { + 'resource': resource, + 'action': action, + 'users': users, + 'userGroups': userGroups + }, headers) + .map(function (response) { + return response; + }) + .catch(function (error) { + self.dialogService.openConfirm({ + title: 'Error', + message: error.message, + acceptButton: 'Ok', + acceptButtonColor: 'fds-warn' + }); + return rxjs.Observable.of(error); + }); + }, + + /** + * Authenticate a user. + * + * @param {string} username The name of the user to authenticate. + * @param {string} password The user password. + * @returns {*} + */ + postToLogin: function (username, password) { + var self = this; + return this.http.post('/nifi-registry-api/access/token/login', { + 'username': username, + 'password': password + }, headers) + .map(function (response) { + return response; + }) + .catch(function (error) { + self.dialogService.openConfirm({ + title: 'Error', + message: 'Please contact your System Administrator.', + acceptButton: 'Ok', + acceptButtonColor: 'fds-warn' + }); + return rxjs.Observable.of(error); + }); + }, + /** * Kerberos ticket exchange. * @@ -494,7 +645,7 @@ NfRegistryApi.prototype = { .map(function (jwt) { // get the payload and store the token with the appropriate expiration var token = self.nfStorage.getJwtPayload(jwt); - if(token) { + if (token) { var expiration = parseInt(token['exp'], 10) * MILLIS_PER_SECOND; self.nfStorage.setItem('jwt', jwt, expiration); } @@ -523,7 +674,35 @@ NfRegistryApi.prototype = { if (error.status === 401) { self.router.navigateByUrl('/nifi-registry/login'); } - return rxjs.Observable.of({}); + return rxjs.Observable.of({ + resourcePermissions: { + anyTopLevelResource: { + canRead: false, + canWrite: false, + canDelete: false + }, + buckets: { + canRead: false, + canWrite: false, + canDelete: false + }, + tenants: { + canRead: false, + canWrite: false, + canDelete: false + }, + policies: { + canRead: false, + canWrite: false, + canDelete: false + }, + proxy: { + canRead: false, + canWrite: false, + canDelete: false + } + } + }); }); } }; @@ -535,4 +714,4 @@ NfRegistryApi.parameters = [ ngRouter.Router ]; -module.exports = NfRegistryApi; \ No newline at end of file +module.exports = NfRegistryApi; diff --git a/nifi-registry-web-ui/src/main/webapp/services/nf-registry.api.spec.js b/nifi-registry-web-ui/src/main/webapp/services/nf-registry.api.spec.js index b1a6609..3c9b6d6 100644 --- a/nifi-registry-web-ui/src/main/webapp/services/nf-registry.api.spec.js +++ b/nifi-registry-web-ui/src/main/webapp/services/nf-registry.api.spec.js @@ -28,9 +28,8 @@ var NfRegistryExplorer = require('nifi-registry/components/explorer/nf-registry- var NfRegistryAdministration = require('nifi-registry/components/administration/nf-registry-administration.js'); var NfRegistryUsersAdministration = require('nifi-registry/components/administration/users/nf-registry-users-administration.js'); var NfRegistryAddUser = require('nifi-registry/components/administration/users/dialogs/add-user/nf-registry-add-user.js'); -var NfRegistryUserDetails = require('nifi-registry/components/administration/users/details/nf-registry-user-details.js'); -var NfRegistryUserPermissions = require('nifi-registry/components/administration/users/permissions/nf-registry-user-permissions.js'); -var NfRegistryUserGroupPermissions = require('nifi-registry/components/administration/user-group/permissions/nf-registry-user-group-permissions.js'); +var NfRegistryManageUser = require('nifi-registry/components/administration/users/sidenav/manage-user/nf-registry-manage-user.js'); +var NfRegistryManageGroup = require('nifi-registry/components/administration/users/sidenav/manage-group/nf-registry-manage-group.js'); var NfRegistryBucketPermissions = require('nifi-registry/components/administration/workflow/buckets/permissions/nf-registry-bucket-permissions.js'); var NfRegistryWorkflowAdministration = require('nifi-registry/components/administration/workflow/nf-registry-workflow-administration.js'); var NfRegistryGridListViewer = require('nifi-registry/components/explorer/grid-list/registry/nf-registry-grid-list-viewer.js'); @@ -43,6 +42,8 @@ var ngCommonHttp = require('@angular/common/http'); var NfRegistryTokenInterceptor = require('nifi-registry/services/nf-registry.token.interceptor.js'); var NfRegistryAuthService = require('nifi-registry/services/nf-registry.auth.service.js'); var NfStorage = require('nifi-registry/services/nf-storage.service.js'); +var NfLoginComponent = require('nifi-registry/components/login/nf-registry-login.js'); +var NfUserLoginComponent = require('nifi-registry/components/login/dialogs/nf-registry-user-login.js'); xdescribe('NfRegistry API w/ Angular testing utils', function () { var nfRegistryApi; @@ -62,16 +63,17 @@ xdescribe('NfRegistry API w/ Angular testing utils', function () { NfRegistryExplorer, NfRegistryAdministration, NfRegistryUsersAdministration, - NfRegistryUserDetails, - NfRegistryUserPermissions, - NfRegistryUserGroupPermissions, + NfRegistryManageUser, + NfRegistryManageGroup, NfRegistryBucketPermissions, NfRegistryAddUser, NfRegistryWorkflowAdministration, NfRegistryGridListViewer, NfRegistryBucketGridListViewer, NfRegistryDropletGridListViewer, - NfPageNotFoundComponent + NfPageNotFoundComponent, + NfLoginComponent, + NfUserLoginComponent ], providers: [ NfRegistryService, @@ -1037,11 +1039,6 @@ xdescribe('NfRegistry API w/ Angular testing utils', function () { identity: 'User #1', identifier: '9999' }]).subscribe(function (response) { - var dialogServiceCall = nfRegistryApi.dialogService.openConfirm.calls.first(); - expect(dialogServiceCall.args[0].title).toBe('Error'); - expect(dialogServiceCall.args[0].message).toBe('Http failure response for /nifi-registry-api/tenants/user-groups/123: 401 PUT user groups mock error'); - expect(dialogServiceCall.args[0].acceptButton).toBe('Ok'); - expect(dialogServiceCall.args[0].acceptButtonColor).toBe('fds-warn'); }); // the request it made diff --git a/nifi-registry-web-ui/src/main/webapp/services/nf-registry.auth-guard.service.js b/nifi-registry-web-ui/src/main/webapp/services/nf-registry.auth-guard.service.js new file mode 100644 index 0000000..71580a2 --- /dev/null +++ b/nifi-registry-web-ui/src/main/webapp/services/nf-registry.auth-guard.service.js @@ -0,0 +1,257 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var NfRegistryService = require('nifi-registry/services/nf-registry.service.js'); + +/** + * NfRegistryUsersAdministrationAuthGuard constructor. + * + * @param nfRegistryService The nfRegistryService module. + * @constructor + */ +function NfRegistryUsersAdministrationAuthGuard(nfRegistryService) { + this.nfRegistryService = nfRegistryService; +}; + +NfRegistryUsersAdministrationAuthGuard.prototype = { + constructor: NfRegistryUsersAdministrationAuthGuard, + + /** + * Can activate guard. + * @returns {*} + */ + canActivate: function (route, state) { + var url = state.url; + + return this.checkLogin(url); + }, + + checkLogin: function (url) { + var self = this; + if (this.nfRegistryService.currentUser.resourcePermissions.tenants.canRead) { return true; } + + // Store the attempted URL for redirecting + this.nfRegistryService.redirectUrl = url; + + // attempt kerberos authentication + this.nfRegistryService.api.ticketExchange().subscribe(function (jwt) { + self.nfRegistryService.api.loadCurrentUser().subscribe(function (currentUser) { + self.nfRegistryService.currentUser = currentUser; + // if the user is logged, we want to determine if they were logged in using a certificate + if (currentUser.anonymous === false) { + // render the logout button if there is a token locally + if (self.nfRegistryService.nfStorage.getItem('jwt') !== null) { + self.nfRegistryService.currentUser.canLogout = true; + } + + // redirect to explorer perspective if not admin + if (!currentUser.resourcePermissions.anyTopLevelResource.canRead) { + self.nfRegistryService.router.navigateByUrl('/nifi-registry/explorer'); + } else { + self.nfRegistryService.router.navigateByUrl(url); + } + } else { + // navigate to the login page + self.nfRegistryService.router.navigateByUrl('/nifi-registry/login'); + } + }); + }); + + return false; + } +}; + +NfRegistryUsersAdministrationAuthGuard.parameters = [ + NfRegistryService +]; + +/** + * NfRegistryWorkflowsAdministrationAuthGuard constructor. + * + * @param nfRegistryService The nfRegistryService module. + * @constructor + */ +function NfRegistryWorkflowsAdministrationAuthGuard(nfRegistryService) { + this.nfRegistryService = nfRegistryService; +}; + +NfRegistryWorkflowsAdministrationAuthGuard.prototype = { + constructor: NfRegistryWorkflowsAdministrationAuthGuard, + + /** + * Can activate guard. + * @returns {*} + */ + canActivate: function (route, state) { + var url = state.url; + + return this.checkLogin(url); + }, + + checkLogin: function (url) { + var self = this; + if (this.nfRegistryService.currentUser.resourcePermissions.buckets.canRead || this.nfRegistryService.currentUser.anonymous) { return true; } + + // Store the attempted URL for redirecting + this.nfRegistryService.redirectUrl = url; + + // attempt kerberos authentication + this.nfRegistryService.api.ticketExchange().subscribe(function (jwt) { + self.nfRegistryService.api.loadCurrentUser().subscribe(function (currentUser) { + self.nfRegistryService.currentUser = currentUser; + // if the user is logged, we want to determine if they were logged in using a certificate + if (currentUser.anonymous === false) { + // render the logout button if there is a token locally + if (self.nfRegistryService.nfStorage.getItem('jwt') !== null) { + self.nfRegistryService.currentUser.canLogout = true; + } + + // redirect to explorer perspective if not admin + if (!currentUser.resourcePermissions.anyTopLevelResource.canRead) { + self.nfRegistryService.router.navigateByUrl('/nifi-registry/explorer'); + } else { + if (currentUser.resourcePermissions.buckets) { + self.nfRegistryService.router.navigateByUrl(url); + } else { + self.nfRegistryService.router.navigateByUrl('/nifi-registry/administration/users'); + } + } + } else { + // Navigate to the login page + self.nfRegistryService.router.navigateByUrl(url); + } + }); + }); + + return false; + } +}; + +NfRegistryWorkflowsAdministrationAuthGuard.parameters = [ + NfRegistryService +]; + +/** + * NfRegistryLoginAuthGuard constructor. + * + * @param nfRegistryService The nfRegistryService module. + * @constructor + */ +function NfRegistryLoginAuthGuard(nfRegistryService) { + this.nfRegistryService = nfRegistryService; +}; + +NfRegistryLoginAuthGuard.prototype = { + constructor: NfRegistryLoginAuthGuard, + + /** + * Can activate guard. + * @returns {*} + */ + canActivate: function (route, state) { + var url = state.url; + + return this.checkLogin(url); + }, + + checkLogin: function (url) { + var self = this; + if (this.nfRegistryService.currentUser.anonymous) { return true; } + // attempt kerberos authentication + this.nfRegistryService.api.ticketExchange().subscribe(function (jwt) { + self.nfRegistryService.api.loadCurrentUser().subscribe(function (currentUser) { + self.nfRegistryService.currentUser = currentUser; + // if the user is logged, we want to determine if they were logged in using a certificate + if (currentUser.anonymous === false) { + // render the logout button if there is a token locally + if (self.nfRegistryService.nfStorage.getItem('jwt') !== null) { + self.nfRegistryService.currentUser.canLogout = true; + } + self.nfRegistryService.router.navigateByUrl(self.nfRegistryService.redirectUrl); + } else { + self.nfRegistryService.router.navigateByUrl('/nifi-registry/login'); + } + }); + }); + + return false; + } +}; + +NfRegistryLoginAuthGuard.parameters = [ + NfRegistryService +]; + +/** + * NfRegistryResourcesAuthGuard constructor. + * + * @param nfRegistryService The nfRegistryService module. + * @constructor + */ +function NfRegistryResourcesAuthGuard(nfRegistryService) { + this.nfRegistryService = nfRegistryService; +}; + +NfRegistryResourcesAuthGuard.prototype = { + constructor: NfRegistryResourcesAuthGuard, + + /** + * Can activate guard. + * @returns {*} + */ + canActivate: function (route, state) { + var url = state.url; + + return this.checkLogin(url); + }, + + checkLogin: function (url) { + var self = this; + if (this.nfRegistryService.currentUser.resourcePermissions.buckets.canRead) { return true; } + + // Store the attempted URL for redirecting + this.nfRegistryService.redirectUrl = url; + + // attempt kerberos authentication + this.nfRegistryService.api.ticketExchange().subscribe(function (jwt) { + self.nfRegistryService.api.loadCurrentUser().subscribe(function (currentUser) { + self.nfRegistryService.currentUser = currentUser; + // if the user is logged, we want to determine if they were logged in using a certificate + if (currentUser.anonymous === false) { + // render the logout button if there is a token locally + if (self.nfRegistryService.nfStorage.getItem('jwt') !== null) { + self.nfRegistryService.currentUser.canLogout = true; + } + } + self.nfRegistryService.router.navigateByUrl(url); + }); + }); + + return false; + } +}; + +NfRegistryResourcesAuthGuard.parameters = [ + NfRegistryService +]; + +module.exports = { + NfRegistryUsersAdministrationAuthGuard: NfRegistryUsersAdministrationAuthGuard, + NfRegistryWorkflowsAdministrationAuthGuard: NfRegistryWorkflowsAdministrationAuthGuard, + NfRegistryLoginAuthGuard: NfRegistryLoginAuthGuard, + NfRegistryResourcesAuthGuard: NfRegistryResourcesAuthGuard +}; diff --git a/nifi-registry-web-ui/src/main/webapp/services/nf-registry.auth.service.js b/nifi-registry-web-ui/src/main/webapp/services/nf-registry.auth.service.js index 789988d..f2f143d 100644 --- a/nifi-registry-web-ui/src/main/webapp/services/nf-registry.auth.service.js +++ b/nifi-registry-web-ui/src/main/webapp/services/nf-registry.auth.service.js @@ -34,7 +34,7 @@ NfRegistryAuth.prototype = { * Gets the jwt token. * @returns {*} */ - getToken: function() { + getToken: function () { return this.nfStorage.getItem('jwt'); } }; diff --git a/nifi-registry-web-ui/src/main/webapp/services/nf-registry.service.js b/nifi-registry-web-ui/src/main/webapp/services/nf-registry.service.js index d63277f..9964ffd 100644 --- a/nifi-registry-web-ui/src/main/webapp/services/nf-registry.service.js +++ b/nifi-registry-web-ui/src/main/webapp/services/nf-registry.service.js @@ -38,6 +38,7 @@ function NfRegistryService(nfRegistryApi, nfStorage, tdDataTableService, router, this.registry = { name: "Nifi Registry" }; + this.redirectUrl = '/nifi-registry/explorer/grid-list'; // Services this.router = router; @@ -47,65 +48,7 @@ function NfRegistryService(nfRegistryApi, nfStorage, tdDataTableService, router, this.snackBarService = fdsSnackBarService; this.dataTableService = tdDataTableService; - // - - // General - this.bucket = {}; - this.buckets = []; - this.droplet = {}; - this.droplets = []; - this.currentUser = {}; - this.user = {}; - this.group = {}; - this.users = []; - this.groups = []; - this.alerts = []; - this.explorerViewType = ''; - this.perspective = ''; - this.breadCrumbState = 'out'; - - // Droplets - this.filteredDroplets = []; - this.dropletActions = [ - { - name: 'Delete', - icon: 'fa fa-trash', - tooltip: 'Delete' - } - ]; - this.dropletColumns = [ - { - name: 'name', - label: 'Name', - sortable: true - }, - { - name: 'modifiedTimestamp', - label: 'Updated', - sortable: true - } - ]; - this.autoCompleteDroplets = []; - this.dropletsSearchTerms = []; - - // Buckets - this.filteredBuckets = []; - this.bucketColumns = [ - { - name: 'name', - label: 'Bucket Name', - sortable: true, - tooltip: 'Sort Buckets by name.' - } - ]; - this.allBucketsSelected = false; - this.autoCompleteBuckets = []; - this.bucketsSearchTerms = []; - this.isMultiBucketActionsDisabled = true; - - // Users and Groups - this.filteredUsers = []; - this.filteredUserGroups = []; + // data table column definitions this.userColumns = [ { name: 'identity', @@ -115,11 +58,241 @@ function NfRegistryService(nfRegistryApi, nfStorage, tdDataTableService, router, width: 100 } ]; + this.userGroupsColumns = [ + { + name: 'identity', + label: 'Display Name', + sortable: true, + tooltip: 'Group name.', + width: 100 + } + ]; + this.userPoliciesColumns = [ + { + name: 'identity', + label: 'Bucket Name', + sortable: true, + tooltip: 'Bucket name.', + width: 100 + }, + { + name: 'identity', + label: 'Bucket Name', + sortable: true, + tooltip: 'Bucket name.', + width: 100 + } + ]; + this.dropletColumns = [ + { + name: 'name', + label: 'Name', + sortable: true, + active: true + }, + { + name: 'modifiedTimestamp', + label: 'Updated', + sortable: true + } + ]; + this.bucketColumns = [ + { + name: 'name', + label: 'Bucket Name', + sortable: true, + tooltip: 'Sort Buckets by name.' + } + ]; + + // data table available row action definitions + this.bucketActions = [ + { + 'name': 'permissions', + 'icon': 'fa fa-pencil', + 'tooltip': 'Manage Bucket Policies', + 'type': 'sidenav' + }, { + 'name': 'Delete', + 'icon': 'fa fa-trash', + 'tooltip': 'Delete Bucket' + } + ]; + this.dropletActions = [ + { + name: 'delete', + icon: 'fa fa-trash', + tooltip: 'Delete' + } + ]; + this.usersActions = [ + { + name: 'manage', + icon: 'fa fa-pencil', + tooltip: 'Manage User Policies', + type: 'sidenav', + tooltip: 'Manage User' + }, { + name: 'delete', + icon: 'fa fa-trash', + tooltip: 'Delete User' + } + ]; + this.userGroupsActions = [ + { + name: 'manage', + icon: 'fa fa-pencil', + tooltip: 'Manage User Group Policies', + type: 'sidenav' + }, { + name: 'delete', + icon: 'fa fa-trash', + tooltip: 'Delete User Group' + } + ]; + + // model for buckets privileges + this.BUCKETS_PRIVS = { + '/buckets': ['read', 'write', 'delete'] + }; + + // model for tenants privileges + this.TENANTS_PRIVS = { + '/tenants': ['read', 'write', 'delete'] + }; + + // model for policies privileges + this.POLICIES_PRIVS = { + '/policies': ['read', 'write', 'delete'] + }; + + // model for proxy privileges + this.PROXY_PRIVS = { + '/proxy': ['write'] + }; + + // + + // General + this.alerts = []; + this.inProgress = false; + this.perspective = ''; + this.breadCrumbState = 'out'; + this.explorerViewType = ''; + this.currentUser = { + resourcePermissions: { + anyTopLevelResource: { + canRead: false, + canWrite: false, + canDelete: false + }, + buckets: { + canRead: false, + canWrite: false, + canDelete: false + }, + tenants: { + canRead: false, + canWrite: false, + canDelete: false + }, + policies: { + canRead: false, + canWrite: false, + canDelete: false + }, + proxy: { + canRead: false, + canWrite: false, + canDelete: false + } + } + }; + this.bucket = {}; + this.buckets = []; + this.droplet = {}; + this.droplets = []; + this.user = { + resourcePermissions: { + anyTopLevelResource: { + canRead: false, + canWrite: false, + canDelete: false + }, + buckets: { + canRead: false, + canWrite: false, + canDelete: false + }, + tenants: { + canRead: false, + canWrite: false, + canDelete: false + }, + policies: { + canRead: false, + canWrite: false, + canDelete: false + }, + proxy: { + canRead: false, + canWrite: false, + canDelete: false + } + } + }; + this.users = []; + this.group = { + resourcePermissions: { + anyTopLevelResource: { + canRead: false, + canWrite: false, + canDelete: false + }, + buckets: { + canRead: false, + canWrite: false, + canDelete: false + }, + tenants: { + canRead: false, + canWrite: false, + canDelete: false + }, + policies: { + canRead: false, + canWrite: false, + canDelete: false + }, + proxy: { + canRead: false, + canWrite: false, + canDelete: false + } + } + }; + this.groups = []; + + // Droplets + this.filteredDroplets = []; + this.activeDropletColumn = this.dropletColumns[0]; + this.autoCompleteDroplets = []; + this.dropletsSearchTerms = []; + + // Buckets + this.filteredBuckets = []; + this.allBucketsSelected = false; + this.autoCompleteBuckets = []; + this.bucketsSearchTerms = []; + this.isMultiBucketActionsDisabled = true; + + // Users and Groups + this.filteredUsers = []; + this.filteredUserGroups = []; this.allUsersAndGroupsSelected = false; this.autoCompleteUsersAndGroups = []; this.usersSearchTerms = []; - this.inProgress = false; // }; @@ -347,6 +520,7 @@ NfRegistryService.prototype = { }); self.bucket = {}; self.filterBuckets(); + self.determineAllBucketsSelectedState(); }); } }); @@ -604,7 +778,7 @@ NfRegistryService.prototype = { // get the current user return rxjs.Observable.of(this.api.loadCurrentUser().subscribe(function (currentUser) { // if the user is logged, we want to determine if they were logged in using a certificate - if (currentUser.status !== "UNKNOWN") { + if (currentUser.anonymous === false) { // render the users name self.currentUser = currentUser; @@ -798,9 +972,10 @@ NfRegistryService.prototype = { */ executeUserAction: function (action, user) { var self = this; + this.user = user; switch (action.name.toLowerCase()) { case 'delete': - this.dialogService.openConfirm({ + return this.dialogService.openConfirm({ title: 'Delete User', message: 'This user will lose all access to the registry.', cancelButton: 'Cancel', @@ -823,12 +998,13 @@ NfRegistryService.prototype = { duration: 3000 }); self.filterUsersAndGroups(); + self.determineAllUsersAndGroupsSelectedState(); }); } }); break; - case 'permissions': - this.router.navigateByUrl('/nifi-registry/administration/users(' + action.type + ':user/' + action.name + '/' + user.identifier + ')'); + case 'manage': + this.router.navigateByUrl('/nifi-registry/administration/users(' + action.type + ':' + action.name + '/user/' + user.identifier + ')'); break; } }, @@ -867,12 +1043,13 @@ NfRegistryService.prototype = { duration: 3000 }); self.filterUsersAndGroups(); + self.determineAllUsersAndGroupsSelectedState(); }); } }); break; - case 'permissions': - this.router.navigateByUrl('/nifi-registry/administration/users(' + action.type + ':group/' + action.name + '/' + group.identifier + ')'); + case 'manage': + this.router.navigateByUrl('/nifi-registry/administration/users(' + action.type + ':' + action.name + '/group/' + group.identifier + ')'); break; } }, diff --git a/nifi-registry-web-ui/src/main/webapp/services/nf-registry.service.spec.js b/nifi-registry-web-ui/src/main/webapp/services/nf-registry.service.spec.js index 6668b60..e3d3164 100644 --- a/nifi-registry-web-ui/src/main/webapp/services/nf-registry.service.spec.js +++ b/nifi-registry-web-ui/src/main/webapp/services/nf-registry.service.spec.js @@ -28,9 +28,8 @@ var NfRegistryExplorer = require('nifi-registry/components/explorer/nf-registry- var NfRegistryAdministration = require('nifi-registry/components/administration/nf-registry-administration.js'); var NfRegistryUsersAdministration = require('nifi-registry/components/administration/users/nf-registry-users-administration.js'); var NfRegistryAddUser = require('nifi-registry/components/administration/users/dialogs/add-user/nf-registry-add-user.js'); -var NfRegistryUserDetails = require('nifi-registry/components/administration/users/details/nf-registry-user-details.js'); -var NfRegistryUserPermissions = require('nifi-registry/components/administration/users/permissions/nf-registry-user-permissions.js'); -var NfRegistryUserGroupPermissions = require('nifi-registry/components/administration/user-group/permissions/nf-registry-user-group-permissions.js'); +var NfRegistryManageUser = require('nifi-registry/components/administration/users/sidenav/manage-user/nf-registry-manage-user.js'); +var NfRegistryManageGroup = require('nifi-registry/components/administration/users/sidenav/manage-group/nf-registry-manage-group.js'); var NfRegistryBucketPermissions = require('nifi-registry/components/administration/workflow/buckets/permissions/nf-registry-bucket-permissions.js'); var NfRegistryWorkflowAdministration = require('nifi-registry/components/administration/workflow/nf-registry-workflow-administration.js'); var NfRegistryGridListViewer = require('nifi-registry/components/explorer/grid-list/registry/nf-registry-grid-list-viewer.js'); @@ -45,6 +44,8 @@ var ngCommonHttp = require('@angular/common/http'); var NfRegistryTokenInterceptor = require('nifi-registry/services/nf-registry.token.interceptor.js'); var NfRegistryAuthService = require('nifi-registry/services/nf-registry.auth.service.js'); var NfStorage = require('nifi-registry/services/nf-storage.service.js'); +var NfLoginComponent = require('nifi-registry/components/login/nf-registry-login.js'); +var NfUserLoginComponent = require('nifi-registry/components/login/dialogs/nf-registry-user-login.js'); describe('NfRegistry Service isolated unit tests', function () { var nfRegistryService; @@ -86,6 +87,7 @@ describe('NfRegistry Service isolated unit tests', function () { it('should get the `Oldest (update)` sort by label', function () { //Setup the nfRegistryService state for this test + nfRegistryService.dropletColumns[0].active = false; nfRegistryService.dropletColumns[1].active = true; // The function to test @@ -97,6 +99,7 @@ describe('NfRegistry Service isolated unit tests', function () { it('should get the `Newest (update)` sort by label', function () { //Setup the nfRegistryService state for this test + nfRegistryService.dropletColumns[0].active = false; nfRegistryService.dropletColumns[1].active = true; nfRegistryService.dropletColumns[1].sortOrder = 'ASC'; @@ -688,16 +691,17 @@ describe('NfRegistry Service w/ Angular testing utils', function () { NfRegistryExplorer, NfRegistryAdministration, NfRegistryUsersAdministration, - NfRegistryUserDetails, - NfRegistryUserPermissions, - NfRegistryUserGroupPermissions, + NfRegistryManageUser, + NfRegistryManageGroup, NfRegistryBucketPermissions, NfRegistryAddUser, NfRegistryWorkflowAdministration, NfRegistryGridListViewer, NfRegistryBucketGridListViewer, NfRegistryDropletGridListViewer, - NfPageNotFoundComponent + NfPageNotFoundComponent, + NfLoginComponent, + NfUserLoginComponent ], providers: [ NfRegistryService, @@ -963,7 +967,7 @@ describe('NfRegistry Service w/ Angular testing utils', function () { expect(nfRegistryService.users[0].identifier).toBe(1); }); - it('should execute a `permissions` action on a user.', function () { + it('should execute a `manage` action on a user.', function () { // from the root injector var router = ngCoreTesting.TestBed.get(ngRouter.Router); @@ -975,11 +979,11 @@ describe('NfRegistry Service w/ Angular testing utils', function () { var user = {identifier: '999'}; // The function to test - nfRegistryService.executeUserAction({name: 'permissions', type: 'sidenav'}, user); + nfRegistryService.executeUserAction({name: 'manage', type: 'sidenav'}, user); //assertions var navigateByUrlCall = router.navigateByUrl.calls.first(); - expect(navigateByUrlCall.args[0]).toBe('/nifi-registry/administration/users(sidenav:user/permissions/999)'); + expect(navigateByUrlCall.args[0]).toBe('/nifi-registry/administration/users(sidenav:manage/user/999)'); }); it('should execute a `delete` action on a group.', function () { @@ -1015,7 +1019,7 @@ describe('NfRegistry Service w/ Angular testing utils', function () { expect(nfRegistryService.groups[0].identifier).toBe(1); }); - it('should execute a `permissions` action on a group.', function () { + it('should execute a `manage` action on a group.', function () { // from the root injector var router = ngCoreTesting.TestBed.get(ngRouter.Router); @@ -1027,11 +1031,11 @@ describe('NfRegistry Service w/ Angular testing utils', function () { var group = {identifier: '999'}; // The function to test - nfRegistryService.executeGroupAction({name: 'permissions', type: 'sidenav'}, group); + nfRegistryService.executeGroupAction({name: 'manage', type: 'sidenav'}, group); //assertions var navigateByUrlCall = router.navigateByUrl.calls.first(); - expect(navigateByUrlCall.args[0]).toBe('/nifi-registry/administration/users(sidenav:group/permissions/999)'); + expect(navigateByUrlCall.args[0]).toBe('/nifi-registry/administration/users(sidenav:manage/group/999)'); }); it('should filter buckets by name.', function () { diff --git a/nifi-registry-web-ui/src/main/webapp/systemjs.builder.config.js b/nifi-registry-web-ui/src/main/webapp/systemjs.builder.config.js index 8d3073d..a66d70d 100644 --- a/nifi-registry-web-ui/src/main/webapp/systemjs.builder.config.js +++ b/nifi-registry-web-ui/src/main/webapp/systemjs.builder.config.js @@ -100,17 +100,20 @@ 'nifi-registry/services/nf-registry.service.js': 'services/nf-registry.service.js', 'nifi-registry/services/nf-storage.service.js': 'services/nf-storage.service.js', 'nifi-registry/services/nf-registry.auth.service.js': 'services/nf-registry.auth.service.js', + 'nifi-registry/services/nf-registry.auth-guard.service.js': 'services/nf-registry.auth-guard.service.js', 'nifi-registry/services/nf-registry.token.interceptor.js': 'services/nf-registry.token.interceptor.js', 'nifi-registry/components/page-not-found/nf-registry-page-not-found.js': 'components/page-not-found/nf-registry-page-not-found.js', + 'nifi-registry/components/login/nf-registry-login.js': 'components/login/nf-registry-login.js', + 'nifi-registry/components/login/dialogs/nf-registry-user-login.js': 'components/login/dialogs/nf-registry-user-login.js', 'nifi-registry/components/explorer/nf-registry-explorer.js': 'components/explorer/nf-registry-explorer.js', 'nifi-registry/components/administration/nf-registry-administration.js': 'components/administration/nf-registry-administration.js', 'nifi-registry/components/administration/users/nf-registry-users-administration.js': 'components/administration/users/nf-registry-users-administration.js', 'nifi-registry/components/administration/users/dialogs/add-user/nf-registry-add-user.js': 'components/administration/users/dialogs/add-user/nf-registry-add-user.js', 'nifi-registry/components/administration/users/dialogs/create-new-group/nf-registry-create-new-group.js': 'components/administration/users/dialogs/create-new-group/nf-registry-create-new-group.js', - 'nifi-registry/components/administration/users/dialogs/add-selected-users-to-group/nf-registry-add-selected-users-to-group.js': 'components/administration/users/dialogs/add-selected-users-to-group/nf-registry-add-selected-users-to-group.js', - 'nifi-registry/components/administration/users/details/nf-registry-user-details.js': 'components/administration/users/details/nf-registry-user-details.js', - 'nifi-registry/components/administration/users/permissions/nf-registry-user-permissions.js': 'components/administration/users/permissions/nf-registry-user-permissions.js', - 'nifi-registry/components/administration/user-group/permissions/nf-registry-user-group-permissions.js': 'components/administration/user-group/permissions/nf-registry-user-group-permissions.js', + 'nifi-registry/components/administration/users/dialogs/add-users-to-group/nf-registry-add-users-to-group.js': 'components/administration/users/dialogs/add-users-to-group/nf-registry-add-users-to-group.js', + 'nifi-registry/components/administration/users/dialogs/add-user-to-groups/nf-registry-add-user-to-groups.js': 'components/administration/users/dialogs/add-user-to-groups/nf-registry-add-user-to-groups.js', + 'nifi-registry/components/administration/users/sidenav/manage-user/nf-registry-manage-user.js': 'components/administration/users/sidenav/manage-user/nf-registry-manage-user.js', + 'nifi-registry/components/administration/users/sidenav/manage-group/nf-registry-manage-group.js': 'components/administration/users/sidenav/manage-group/nf-registry-manage-group.js', 'nifi-registry/components/administration/workflow/dialogs/nf-registry-create-bucket.js': 'components/administration/workflow/dialogs/nf-registry-create-bucket.js', 'nifi-registry/components/administration/workflow/buckets/permissions/nf-registry-bucket-permissions.js': 'components/administration/workflow/buckets/permissions/nf-registry-bucket-permissions.js', 'nifi-registry/components/administration/workflow/nf-registry-workflow-administration.js': 'components/administration/workflow/nf-registry-workflow-administration.js', diff --git a/nifi-registry-web-ui/src/main/webapp/theming/_structureElements.scss b/nifi-registry-web-ui/src/main/webapp/theming/_structureElements.scss index 5de1870..3e8fa40 100644 --- a/nifi-registry-web-ui/src/main/webapp/theming/_structureElements.scss +++ b/nifi-registry-web-ui/src/main/webapp/theming/_structureElements.scss @@ -16,10 +16,30 @@ */ body { - background: $grey5 url('/nifi-registry/images/registry-logo-web-app.svg') no-repeat center center; + background: $grey12 url('/nifi-registry/images/registry-logo-web-app.svg') no-repeat center center; background-size: 40%; } +#nifi-registry-login-perspective { + background: $grey12 url('/nifi-registry/images/registry-logo-web-app.svg') no-repeat center center; + background-size: 40%; + position: absolute; + top: 0px; + left: 0px; + right: 0px; + bottom: 0px; +} + +#nifi-registry-not-found-perspective { + background: $grey12 url('/nifi-registry/images/registry-logo-web-app.svg') no-repeat center center; + background-size: 40%; + position: absolute; + top: 0px; + left: 0px; + right: 0px; + bottom: 0px; +} + #nf-registry-app-container { margin: 0; width: 100%; @@ -48,7 +68,7 @@ body { background-color: #FFFFFF; position: absolute; z-index: 1000; - background: $grey1; + background: $grey11; } #nifi-registry-toolbar .mat-icon-button { @@ -74,7 +94,7 @@ body { min-height: 370px; min-width: 1045px; overflow: auto; - background: $grey5; + background: $grey12; background-size: 40%; }