NIFIREG-21 - Leverage REST API and add unit test coverage and update .travis.yml
This closes #15. Signed-off-by: Bryan Bende <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/nifi-registry/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi-registry/commit/7b707a05 Tree: http://git-wip-us.apache.org/repos/asf/nifi-registry/tree/7b707a05 Diff: http://git-wip-us.apache.org/repos/asf/nifi-registry/diff/7b707a05 Branch: refs/heads/master Commit: 7b707a05d98079948b76d7894ed9bfb663273d8e Parents: 1687089 Author: Scott Aslan <[email protected]> Authored: Fri Oct 6 22:53:26 2017 -0400 Committer: Bryan Bende <[email protected]> Committed: Mon Oct 9 12:25:42 2017 -0400 ---------------------------------------------------------------------- .travis.yml | 43 +- nifi-registry-web-ui/pom.xml | 62 +- .../src/main/frontend/karma.conf.ci.js | 39 - .../src/main/frontend/karma.conf.js | 63 +- .../src/main/frontend/package.json | 7 +- .../confirm-dialog.component.html | 4 +- .../confirm-dialog/confirm-dialog.component.js | 4 +- .../platform/core/fluid-design-system.module.js | 5 - .../nf-registry-administration.html | 6 +- .../nf-registry-administration.js | 21 +- .../nf-registry-administration.spec.js | 149 ++-- .../users/add/nf-registry-add-user.js | 2 +- .../users/details/nf-registry-user-details.js | 2 +- .../users/nf-registry-users-administration.js | 10 +- .../permissions/nf-registry-user-permissions.js | 2 +- .../nf-registry-bucket-permissions.html | 2 +- .../nf-registry-bucket-permissions.js | 4 +- .../nf-registry-workflow-administration.html | 93 +-- .../nf-registry-workflow-administration.js | 74 +- .../nf-registry-workflow-administration.spec.js | 177 +++++ .../nf-registry-explorer-grid-list-viewer.html | 18 - .../nf-registry-explorer-grid-list-viewer.js | 43 -- .../nf-registry-droplet-grid-list-viewer.html | 17 - .../nf-registry-droplet-grid-list-viewer.js | 75 -- .../nf-registry-bucket-grid-list-viewer.html | 18 - .../nf-registry-bucket-grid-list-viewer.js | 76 -- .../nf-registry-bucket-grid-list-viewer.js | 82 ++ .../nf-registry-bucket-grid-list-viewer.spec.js | 185 +++++ .../nf-registry-droplet-grid-list-viewer.js | 86 +++ ...nf-registry-droplet-grid-list-viewer.spec.js | 214 ++++++ .../registry/nf-registry-grid-list-viewer.html | 100 +-- .../registry/nf-registry-grid-list-viewer.js | 59 +- .../nf-registry-grid-list-viewer.spec.js | 172 +++++ .../explorer/nf-registry-explorer.spec.js | 109 +++ .../fluid-design-system/fds-demo.html | 18 +- .../components/fluid-design-system/fds-demo.js | 10 +- .../src/main/webapp/nf-registry.html | 24 +- .../src/main/webapp/nf-registry.js | 6 +- .../src/main/webapp/nf-registry.module.js | 30 +- .../src/main/webapp/nf-registry.routes.js | 44 +- .../src/main/webapp/nf-registry.spec.js | 47 +- .../src/main/webapp/services/nf-registry.api.js | 427 +++++++++++ .../webapp/services/nf-registry.api.spec.js | 538 +++++++++++++ .../main/webapp/services/nf-registry.service.js | 751 ++++--------------- .../webapp/services/nf-registry.service.spec.js | 424 +++++++++++ .../src/main/webapp/systemjs.builder.config.js | 19 +- .../src/main/webapp/systemjs.spec.config.js | 24 +- 47 files changed, 2986 insertions(+), 1399 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7b707a05/.travis.yml ---------------------------------------------------------------------- diff --git a/.travis.yml b/.travis.yml index 4bef783..6811415 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,9 +13,42 @@ # See the License for the specific language governing permissions and # limitations under the License. -# before_install -# 1. Configures pre-installed Chrome on Travis CI for karma testing +language: java + +env: + - USER_LANGUAGE=en USER_REGION=US' + - USER_LANGUAGE=fr USER_REGION=FR' + - USER_LANGUAGE=ja USER_REGION=JP' + - USER_LANGUAGE=pt USER_REGION=BR' + - USER_LANGUAGE=default USER_REGION=default + +os: + - linux + +jdk: + - oraclejdk8 + +# Caches mvn repository in order to speed up builds +cache: + directories: + - $HOME/.m2 + - $HOME/.npm + +before_cache: + # Remove nifi repo again to save travis from caching it + - rm -rf $HOME/.m2/repository/org/apache/nifi-registry/ + +addons: + chrome: stable + +# before_install aids in setting up the Travis-CI environment +# 1. simulate an `X` server on Travis CI for karma tests that require a GUI +# 2. Configures pre-installed Chrome on Travis CI to be used in âheadlessâ mode before_install: - - export CHROME_BIN=chromium-browser - - export DISPLAY=:99.0 - - sh -e /etc/init.d/xvfb start \ No newline at end of file + - export DISPLAY=:99.0 + - sh -e /etc/init.d/xvfb start + - sleep 3 # give xvfb some time to start + - google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost & + +install: true +script: mvn -T 2C clean install -PjsUnitTests \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7b707a05/nifi-registry-web-ui/pom.xml ---------------------------------------------------------------------- diff --git a/nifi-registry-web-ui/pom.xml b/nifi-registry-web-ui/pom.xml index 7240345..9ea2f4e 100644 --- a/nifi-registry-web-ui/pom.xml +++ b/nifi-registry-web-ui/pom.xml @@ -27,7 +27,6 @@ <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <properties> - <skipTests>true</skipTests> <staging.dir>${project.build.directory}/tmp</staging.dir> <registry.filter>registry-min.properties</registry.filter> <frontend.source>${basedir}/src/main</frontend.source> @@ -267,17 +266,6 @@ </configuration> </plugin> <!-- - Skip tests by default - --> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <version>2.12.4</version> - <configuration> - <skipTests>${skipTests}</skipTests> - </configuration> - </plugin> - <!-- Speed up build time by excluding node, npm, and any node_modules from `mvn clean` since the front-end-maven plugin uses these directories as cache. --> @@ -352,20 +340,6 @@ </configuration> </execution> <!-- - Selenium, Karma/Jasmine JS unit tests. - --> - <execution> - <id>javascript-tests</id> - <goals> - <goal>npm</goal> - </goals> - <phase>test</phase> - <configuration> - <arguments>run test:ci</arguments> - <workingDirectory>${frontend.working.dir}</workingDirectory> - </configuration> - </execution> - <!-- Compile nifi registry web ui SASS into css and gzip compress it. --> <execution> @@ -468,4 +442,40 @@ </plugin> </plugins> </build> + <profiles> + <profile> + <id>jsUnitTests</id> + <activation> + <activeByDefault>false</activeByDefault> + </activation> + <build> + <plugins> + <!-- + Selenium, Karma/Jasmine JS unit tests. + --> + <plugin> + <groupId>com.github.eirslett</groupId> + <artifactId>frontend-maven-plugin</artifactId> + <version>1.5</version> + <configuration> + <installDirectory>${frontend.working.dir}</installDirectory> + </configuration> + <executions> + <execution> + <id>javascript-tests</id> + <goals> + <goal>npm</goal> + </goals> + <phase>test</phase> + <configuration> + <arguments>run test</arguments> + <workingDirectory>${frontend.working.dir}</workingDirectory> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> </project> http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7b707a05/nifi-registry-web-ui/src/main/frontend/karma.conf.ci.js ---------------------------------------------------------------------- diff --git a/nifi-registry-web-ui/src/main/frontend/karma.conf.ci.js b/nifi-registry-web-ui/src/main/frontend/karma.conf.ci.js deleted file mode 100644 index c03db0d..0000000 --- a/nifi-registry-web-ui/src/main/frontend/karma.conf.ci.js +++ /dev/null @@ -1,39 +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 baseConfig = require('./karma.conf.js'); - -module.exports = function (config) { - // Load base config - baseConfig(config); - - if (process.env.TRAVIS) { - config.set({ - browsers: ['Chrome_travis_ci'] - }); - } - - // Override base config - config.set({ - singleRun: true, - autoWatch: false, - reporters: ['progress', 'spec', 'coverage'], - specReporter: { - failFast: true - } - }); -}; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7b707a05/nifi-registry-web-ui/src/main/frontend/karma.conf.js ---------------------------------------------------------------------- diff --git a/nifi-registry-web-ui/src/main/frontend/karma.conf.js b/nifi-registry-web-ui/src/main/frontend/karma.conf.js index f3946b7..b2aa3fa 100644 --- a/nifi-registry-web-ui/src/main/frontend/karma.conf.js +++ b/nifi-registry-web-ui/src/main/frontend/karma.conf.js @@ -21,8 +21,17 @@ module.exports = function (config) { config.set({ basePath: '', + browserNoActivityTimeout: 9999999, //default 10000 + browserDisconnectTimeout: 999999, // default 2000 + browserDisconnectTolerance: 1, // default 0 + captureTimeout: 999999, frameworks: ['jasmine'], - + customLaunchers: { + Chrome_travis_ci: { + base: 'Chrome', + flags: ['--no-sandbox'] + } + }, plugins: [ require('karma-jasmine'), require('karma-chrome-launcher'), @@ -51,13 +60,18 @@ module.exports = function (config) { 'node_modules/zone.js/dist/jasmine-patch.js', 'node_modules/zone.js/dist/async-test.js', 'node_modules/zone.js/dist/fake-async-test.js', + + // others 'node_modules/hammerjs/hammer.js', + 'node_modules/moment/moment.js', + 'node_modules/superagent/superagent.js', // RxJs {pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false}, {pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false}, // Paths loaded via module imports: + {pattern: 'node_modules/systemjs/**/*.js.map', included: false, watched: false}, {pattern: 'node_modules/@angular/**/*.js', included: false, watched: false}, {pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false}, {pattern: 'node_modules/@covalent/**/*.js', included: false, watched: false}, @@ -65,6 +79,9 @@ module.exports = function (config) { {pattern: 'node_modules/@fluid-design-system/**/*.js', included: false, watched: false}, {pattern: 'node_modules/jquery/**/*.js', included: false, watched: false}, {pattern: 'node_modules/roboto-fontface/**/*.ttf', included: false, watched: false}, + {pattern: 'node_modules/angular2-moment/**/*.js', included: false, watched: false}, + {pattern: 'node_modules/angular2-moment/**/*.js.map', included: false, watched: false}, + {pattern: 'node_modules/querystring/**/*.js', included: false, watched: false}, {pattern: 'node_modules/systemjs-plugin-text/text.js', included: false, watched: false}, {pattern: appBase + 'systemjs.spec.config.js', included: false, watched: false}, @@ -73,28 +90,30 @@ module.exports = function (config) { // Include the Fluid Design System (which includes the Teradata Covalent and // Angular Material themes) in the test suite. { - pattern: 'node_modules/@fluid-design-system/dist/platform/core/common/styles/css/fluid-design-system.min.css', + pattern: 'node_modules/@fluid-design-system/dist/platform/core/common/styles/css/*.min.css', included: true, watched: true, served: true }, { - pattern: 'node_modules/@fluid-design-system/dist/platform/core/common/styles/css/fluid-design-system.min.css.map', - included: false, - watched: false + pattern: 'node_modules/@fluid-design-system/dist/platform/core/**/*.html', + included: true, + watched: true, + served: true }, // Include the Nifi Registry styles (currently built based off of the // @fluid-design-system/dist/platform/core/common/styles/_globalVars.scss) { - pattern: 'webapp/css/nf-registry.min.css', + pattern: 'webapp/css/*.css', included: true, watched: true }, { - pattern: 'webapp/css/nf-registry.min.css.map', - included: false, - watched: false + pattern: 'webapp/**/*.html', + included: true, + watched: true, + served: true }, // Asset (HTML) paths loaded via Angular's component compiler @@ -105,6 +124,9 @@ module.exports = function (config) { {pattern: '**/*.svg', watched: false, included: false, served: true}, // Paths for debugging with source maps in dev tools + {pattern: 'node_modules/@fluid-design-system/dist/platform/**/*.css.map', included: false, watched: false}, + {pattern: appBase + '**/*.js.map', included: false, watched: false}, + {pattern: appBase + '**/*.css.map', included: false, watched: false}, {pattern: appBase + '**/*.js', included: false, watched: false} ], @@ -119,10 +141,9 @@ module.exports = function (config) { exclude: [], preprocessors: { - 'webapp/**/!(*spec|*mock).js': 'coverage', - 'platform/**/!(*spec|*mock).js': 'coverage' + 'webapp/**/!(*spec|*mock|*stub|*config|*extras|*fds-demo).js': 'coverage' }, - reporters: ['progress', 'kjhtml', 'spec', 'coverage'], + reporters: ['kjhtml', 'coverage'], coverageReporter: { type: 'html', dir: 'coverage/' @@ -136,5 +157,21 @@ module.exports = function (config) { autoWatch: true, browsers: ['Chrome'], singleRun: false - }) + }); + + if (process.env.TRAVIS) { + config.set({ + browsers: ['Chrome_travis_ci'] + }); + + // Override base config + config.set({ + singleRun: true, + autoWatch: false, + reporters: ['spec', 'coverage'], + specReporter: { + failFast: true + } + }); + } } http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7b707a05/nifi-registry-web-ui/src/main/frontend/package.json ---------------------------------------------------------------------- diff --git a/nifi-registry-web-ui/src/main/frontend/package.json b/nifi-registry-web-ui/src/main/frontend/package.json index 7317475..c7615bd 100644 --- a/nifi-registry-web-ui/src/main/frontend/package.json +++ b/nifi-registry-web-ui/src/main/frontend/package.json @@ -4,9 +4,8 @@ "description": "", "scripts": { "protractor": "protractor protractor.config.js", - "test:dev": "./node_modules/protractor/bin/webdriver-manager update --gecko false && karma start karma.conf.js", - "test:ci": "./node_modules/protractor/bin/webdriver-manager update --gecko false && karma start karma.conf.ci.js", - "test:once": "karma start karma.conf.js --single-run" + "test": "./node_modules/protractor/bin/webdriver-manager update --gecko false && karma start karma.conf.js --single-run", + "test:dev": "./node_modules/protractor/bin/webdriver-manager update --gecko false && karma start karma.conf.js" }, "keywords": [], "author": "", @@ -54,8 +53,10 @@ "lodash": "4.16.2", "material-design-icons": "3.0.1", "protractor": "4.0.14", + "querystring": "0.2.0", "reset-css": "2.2.0", "rxjs": "5.4.3", + "superagent": "3.6.3", "systemjs": "0.20.17", "systemjs-plugin-text": "0.0.11", "zone.js": "0.8.4" http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7b707a05/nifi-registry-web-ui/src/main/platform/core/dialogs/confirm-dialog/confirm-dialog.component.html ---------------------------------------------------------------------- diff --git a/nifi-registry-web-ui/src/main/platform/core/dialogs/confirm-dialog/confirm-dialog.component.html b/nifi-registry-web-ui/src/main/platform/core/dialogs/confirm-dialog/confirm-dialog.component.html index 101cd9e..2aab042 100644 --- a/nifi-registry-web-ui/src/main/platform/core/dialogs/confirm-dialog/confirm-dialog.component.html +++ b/nifi-registry-web-ui/src/main/platform/core/dialogs/confirm-dialog/confirm-dialog.component.html @@ -28,13 +28,13 @@ limitations under the License. {{message}} </fds-dialog-content> <fds-dialog-actions> - <button md-raised-button + <button *ngIf="cancelButton" md-raised-button color="{{cancelButtonColor}}" #closeBtn (keydown.arrowright)="acceptBtn.focus()" (click)="cancel()">{{cancelButton}} </button> - <button md-raised-button + <button *ngIf="acceptButton" md-raised-button color="{{acceptButtonColor}}" #acceptBtn (keydown.arrowleft)="closeBtn.focus()" http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7b707a05/nifi-registry-web-ui/src/main/platform/core/dialogs/confirm-dialog/confirm-dialog.component.js ---------------------------------------------------------------------- diff --git a/nifi-registry-web-ui/src/main/platform/core/dialogs/confirm-dialog/confirm-dialog.component.js b/nifi-registry-web-ui/src/main/platform/core/dialogs/confirm-dialog/confirm-dialog.component.js index 4236b1a..552e68f 100644 --- a/nifi-registry-web-ui/src/main/platform/core/dialogs/confirm-dialog/confirm-dialog.component.js +++ b/nifi-registry-web-ui/src/main/platform/core/dialogs/confirm-dialog/confirm-dialog.component.js @@ -25,9 +25,9 @@ var ngCore = require('@angular/core'); function FdsConfirmDialogComponent() { this.title = ''; this.message = ''; - this.acceptButton = 'ACCEPT'; + this.acceptButton = ''; this.acceptButtonColor = 'fds-primary'; - this.cancelButton = 'CANCEL'; + this.cancelButton = ''; this.cancelButtonColor = 'fds-regular'; this.dialogRef = undefined; this.viewContainerRef = undefined; http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7b707a05/nifi-registry-web-ui/src/main/platform/core/fluid-design-system.module.js ---------------------------------------------------------------------- diff --git a/nifi-registry-web-ui/src/main/platform/core/fluid-design-system.module.js b/nifi-registry-web-ui/src/main/platform/core/fluid-design-system.module.js index 46cf881..2cc3e0f 100644 --- a/nifi-registry-web-ui/src/main/platform/core/fluid-design-system.module.js +++ b/nifi-registry-web-ui/src/main/platform/core/fluid-design-system.module.js @@ -20,7 +20,6 @@ var ngCore = require('@angular/core'); var ngFlex = require('@angular/flex-layout'); var ngMaterial = require('@angular/material'); var ngCommon = require('@angular/common'); -var ngHttp = require('@angular/http'); var ngPlatformBrowser = require('@angular/platform-browser'); var ngAnimations = require('@angular/platform-browser/animations'); var covalentCore = require('@covalent/core'); @@ -57,8 +56,6 @@ FluidDesignSystemModule.annotations = [ ngAnimations.BrowserAnimationsModule, ngCommon.CommonModule, ngPlatformBrowser.BrowserModule, - ngHttp.HttpModule, - ngHttp.JsonpModule, ngMaterial.MaterialModule, covalentCore.CovalentCommonModule, covalentCore.CovalentChipsModule, @@ -78,8 +75,6 @@ FluidDesignSystemModule.annotations = [ ngAnimations.BrowserAnimationsModule, ngCommon.CommonModule, ngPlatformBrowser.BrowserModule, - ngHttp.HttpModule, - ngHttp.JsonpModule, ngMaterial.MaterialModule, covalentCore.CovalentCommonModule, covalentCore.CovalentChipsModule, http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7b707a05/nifi-registry-web-ui/src/main/webapp/components/administration/nf-registry-administration.html ---------------------------------------------------------------------- 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 8770fad..99b2b5e 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 @@ -19,18 +19,18 @@ limitations under the License. <md-button-toggle-group name="nifi-registry-administration-perspective" fxLayout="row" fxLayoutAlign="space-between center" class="tab-toggle-group"> <md-button-toggle [checked]="nfRegistryService.adminPerspective === 'general'" value="general" class="uppercase" - routerLink="/nifi-registry/administration/{{nfRegistryService.registry.id}}/general" + routerLink="/nifi-registry/administration/general" i18n="General administration tab|A description of the type of administration options available.@@nf-admin-general-tab-title"> general </md-button-toggle> <md-button-toggle [checked]="nfRegistryService.adminPerspective === 'users'" value="users" class="uppercase" - routerLink="/nifi-registry/administration/{{nfRegistryService.registry.id}}/users" + routerLink="/nifi-registry/administration/users" i18n="Users administration tab|A description of the type of administration options available.@@nf-admin-users-tab-title"> Users </md-button-toggle> <md-button-toggle [checked]="nfRegistryService.adminPerspective === 'workflow'" value="workflow" class="uppercase" - routerLink="/nifi-registry/administration/{{nfRegistryService.registry.id}}/workflow" + routerLink="/nifi-registry/administration/workflow" i18n="Workflow administration tab|A description of the type of administration options available.@@nf-admin-workflow-tab-title"> Workflow </md-button-toggle> http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7b707a05/nifi-registry-web-ui/src/main/webapp/components/administration/nf-registry-administration.js ---------------------------------------------------------------------- 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 6bf1a6b..5285b40 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 @@ -40,15 +40,7 @@ NfRegistryAdministration.prototype = { ngOnInit: function () { var self = this; this.nfRegistryService.perspective = 'administration'; - this.route.params - .switchMap(function (params) { - self.nfRegistryService.setBreadcrumbState('out'); - return self.nfRegistryService.getRegistry(params['registryId']); - }) - .subscribe(function (registry) { - self.nfRegistryService.registry = registry; - self.nfRegistryService.setBreadcrumbState('in'); - }); + this.nfRegistryService.setBreadcrumbState('in'); }, /** @@ -56,16 +48,7 @@ NfRegistryAdministration.prototype = { */ ngOnDestroy: function () { this.nfRegistryService.perspective = ''; - this.nfRegistryService.registry = {}; - }, - - /** - * Navigate to administer the registry. - * - * @param id The registry id.. - */ - navigateToAdministration: function (id) { - this.route.navigateByUrl('nifi-registry/administration/' + id); + this.nfRegistryService.setBreadcrumbState('out'); } }; http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7b707a05/nifi-registry-web-ui/src/main/webapp/components/administration/nf-registry-administration.spec.js ---------------------------------------------------------------------- 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 91a2da2..7d1259f 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 @@ -18,28 +18,28 @@ var NfRegistryRoutes = require('nifi-registry/nf-registry.routes.js'); var ngCoreTesting = require('@angular/core/testing'); var ngCommon = require('@angular/common'); -var ngRouter = require('@angular/router'); var ngPlatformBrowser = require('@angular/platform-browser'); var FdsDemo = require('nifi-registry/components/fluid-design-system/fds-demo.js'); 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 NfRegistryExplorer = require('nifi-registry/components/explorer/nf-registry-explorer.js'); -var NfRegistryExplorerGridListViewer = require('nifi-registry/components/explorer/grid-list/nf-registry-explorer-grid-list-viewer.js'); var NfRegistryAdministration = require('nifi-registry/components/administration/nf-registry-administration.js'); var NfRegistryGeneralAdministration = require('nifi-registry/components/administration/general/nf-registry-general-administration.js'); var NfRegistryUsersAdministration = require('nifi-registry/components/administration/users/nf-registry-users-administration.js'); var NfRegistryAddUser = require('nifi-registry/components/administration/users/add/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 NfRegistryBucketDetails = require('nifi-registry/components/administration/workflow/buckets/details/nf-registry-bucket-details.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/bucket/nf-registry-bucket-grid-list-viewer.js'); -var NfRegistryDropletGridListViewer = require('nifi-registry/components/explorer/grid-list/registry/bucket/droplet/nf-registry-droplet-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 fdsCore = require('@fluid-design-system/core'); +var ngMoment = require('angular2-moment'); var rxjs = require('rxjs/Rx'); +var ngHttp = require('@angular/http'); describe('NfRegistryAdministration Component', function () { var comp; @@ -47,106 +47,93 @@ describe('NfRegistryAdministration Component', function () { var de; var el; var nfRegistryService; - var originalTimeout; - - function ActivatedRouteStub() { - this._testParamMap = ngRouter.ParamMap; - this.subject = new rxjs.BehaviorSubject(ngRouter.convertToParamMap(this.testParamMap)); - this.paramMap = this.subject.asObservable(); - - this.params = { - switchMap: function () { - return Observable.of({ - id: '1234', - name: "Test Registry", - certifications: [], - users: [], - buckets: [] - }); - } - }; - }; - - ActivatedRouteStub.prototype = { - constructor: ActivatedRouteStub, - navigateByUrl: function (url) { - return url; - } - }; - - Object.defineProperty(ActivatedRouteStub.prototype, "testParamMap", { - get: function () { - return this._testParamMap; - }, - set: function (params) { - this._testParamMap = ngRouter.convertToParamMap(params); - this.subject.next(this._testParamMap); - } - }); + var nfRegistryApi; beforeEach(function () { - originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; - jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; - }); - - afterEach(function () { - jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; - }); - - beforeEach(ngCoreTesting.async(function () { ngCoreTesting.TestBed.configureTestingModule({ imports: [ + ngMoment.MomentModule, + ngHttp.HttpModule, + ngHttp.JsonpModule, fdsCore, NfRegistryRoutes ], - declarations: [FdsDemo, NfRegistry, NfRegistryExplorer, NfRegistryExplorerGridListViewer, NfRegistryAdministration, NfRegistryGeneralAdministration, NfRegistryUsersAdministration, NfRegistryUserDetails, NfRegistryUserPermissions, NfRegistryBucketDetails, NfRegistryBucketPermissions, NfRegistryAddUser, NfRegistryWorkflowAdministration, NfRegistryGridListViewer, NfRegistryBucketGridListViewer, NfRegistryDropletGridListViewer, NfPageNotFoundComponent], - providers: [NfRegistryService, { - provide: ngCommon.APP_BASE_HREF, - useValue: '/' - }, {provide: ngRouter.ActivatedRoute, useClass: ActivatedRouteStub}] + declarations: [ + FdsDemo, + NfRegistry, + NfRegistryExplorer, + NfRegistryAdministration, + NfRegistryGeneralAdministration, + NfRegistryUsersAdministration, + NfRegistryUserDetails, + NfRegistryUserPermissions, + NfRegistryBucketPermissions, + NfRegistryAddUser, + NfRegistryWorkflowAdministration, + NfRegistryGridListViewer, + NfRegistryBucketGridListViewer, + NfRegistryDropletGridListViewer, + NfPageNotFoundComponent + ], + providers: [ + NfRegistryService, + NfRegistryApi, + { + provide: ngCommon.APP_BASE_HREF, + useValue: '/' + } + ] }); - })); - beforeEach(function () { fixture = ngCoreTesting.TestBed.createComponent(NfRegistryAdministration); - // NfRegistryAdministration test instance + // test instance comp = fixture.componentInstance; - // NfRegistryService from the root injector + // from the root injector nfRegistryService = ngCoreTesting.TestBed.get(NfRegistryService); - // spyOn(nfRegistryService, 'getRegistries').and.returnValue(Promise.resolve([{ - // id: '1234', - // name: "Test Registry", - // certifications: [], - // users: [], - // buckets: [] - // }])); - + nfRegistryApi = ngCoreTesting.TestBed.get(NfRegistryApi); de = fixture.debugElement.query(ngPlatformBrowser.By.css('#nifi-registry-administration-perspective')); el = de.nativeElement; + + // Spy + spyOn(nfRegistryApi, 'getDroplets').and.callFake(function () { + }).and.returnValue(rxjs.Observable.of([{ + "identifier": "2e04b4fb-9513-47bb-aa74-1ae34616bfdc", + "name": "Flow #1", + "description": "This is flow #1", + "bucketIdentifier": "2f7f9e54-dc09-4ceb-aa58-9fe581319cdc", + "createdTimestamp": 1505931890999, + "modifiedTimestamp": 1505931890999, + "type": "FLOW", + "snapshotMetadata": null, + "link": { + "params": { + "rel": "self" + }, + "href": "flows/2e04b4fb-9513-47bb-aa74-1ae34616bfdc" + } + }])); }); it('should have a defined component', function () { fixture.detectChanges(); + + //assertions expect(comp).toBeDefined(); + expect(nfRegistryService.perspective).toBe('administration'); + expect(nfRegistryService.breadCrumbState).toBe('in'); expect(de).toBeDefined(); }); - it('should call Router.navigateByUrl("nifi-registry/administration/:registryId") with the ID of the registry', ngCoreTesting.inject([ngRouter.ActivatedRoute], function (router) { + it('should destroy the component', function () { fixture.detectChanges(); - var spy = spyOn(router, 'navigateByUrl'); - comp.navigateToAdministration('23f6cc59-0156-1000-06b4-2b0810089090'); - var url = spy.calls.first().args[0]; - expect(url).toBe('nifi-registry/administration/23f6cc59-0156-1000-06b4-2b0810089090'); - })); - xit('should call `NfRegistryService.getRegistry` when the route ID changes', ngCoreTesting.inject([ngRouter.ActivatedRoute], function (activeRoute) { - spyOn(nfRegistryService, 'getRegistry'); - activeRoute.testParamMap = {registryId: 1234}; - fixture = ngCoreTesting.TestBed.createComponent(NfRegistryAdministration); - comp = fixture.componentInstance; // NfRegistryAdministration test instance - fixture.detectChanges(); - expect(nfRegistryService.getRegistry).toHaveBeenCalledWith(1234); - })); + // The function to test + comp.ngOnDestroy(); + + //assertions + expect(nfRegistryService.perspective).toBe(''); + expect(nfRegistryService.breadCrumbState).toBe('out'); + }); }); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7b707a05/nifi-registry-web-ui/src/main/webapp/components/administration/users/add/nf-registry-add-user.js ---------------------------------------------------------------------- diff --git a/nifi-registry-web-ui/src/main/webapp/components/administration/users/add/nf-registry-add-user.js b/nifi-registry-web-ui/src/main/webapp/components/administration/users/add/nf-registry-add-user.js index 2cbeb3b..c4ef909 100644 --- a/nifi-registry-web-ui/src/main/webapp/components/administration/users/add/nf-registry-add-user.js +++ b/nifi-registry-web-ui/src/main/webapp/components/administration/users/add/nf-registry-add-user.js @@ -51,7 +51,7 @@ NfRegistryAddUser.prototype = { * Navigate to administer users for current registry. */ closeSideNav: function () { - this.router.navigateByUrl('/nifi-registry/administration/' + this.nfRegistryService.registry.id + '/users'); + this.router.navigateByUrl('/nifi-registry/administration/users'); } }; http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7b707a05/nifi-registry-web-ui/src/main/webapp/components/administration/users/details/nf-registry-user-details.js ---------------------------------------------------------------------- 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 index 5001586..6b04b95 100644 --- 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 @@ -51,7 +51,7 @@ NfRegistryUserDetails.prototype = { * Navigate to administer users for current registry. */ closeSideNav: function () { - this.router.navigateByUrl('/nifi-registry/administration/' + this.nfRegistryService.registry.id + '/users'); + this.router.navigateByUrl('/nifi-registry/administration/users'); } }; http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7b707a05/nifi-registry-web-ui/src/main/webapp/components/administration/users/nf-registry-users-administration.js ---------------------------------------------------------------------- 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 272df0c..f5405ba 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 @@ -47,7 +47,7 @@ NfRegistryUsersAdministration.prototype = { this.route.params .switchMap(function (params) { self.nfRegistryService.adminPerspective = 'users'; - return self.nfRegistryService.getUsers(self.nfRegistryService.registry.id); + return self.nfRegistryService.api.getUsers(); }) .subscribe(function (users) { self.nfRegistryService.users = self.nfRegistryService.filteredUsers = users; @@ -85,7 +85,7 @@ NfRegistryUsersAdministration.prototype = { }).afterClosed().subscribe( function (accept) { if (accept) { - self.nfRegistryService.deleteUser(user.id); + self.nfRegistryService.api.deleteUser(user.identifier); } }); break; @@ -99,15 +99,15 @@ NfRegistryUsersAdministration.prototype = { }).afterClosed().subscribe( function (accept) { if (accept) { - self.nfRegistryService.suspendUser(user.id); + self.nfRegistryService.api.suspendUser(user.identifier); } }); break; case 'add': - this.router.navigateByUrl('/nifi-registry/administration/' + this.nfRegistryService.registry.id + '/users(sidenav:user/add)'); + this.router.navigateByUrl('/nifi-registry/administration/users(sidenav:user/add)'); break; default: - this.router.navigateByUrl('/nifi-registry/administration/' + this.nfRegistryService.registry.id + '/users(' + action.type + ':user/' + action.name + '/' + user.id + ')'); + this.router.navigateByUrl('/nifi-registry/administration/users(' + action.type + ':user/' + action.name + '/' + user.id + ')'); break; } } http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7b707a05/nifi-registry-web-ui/src/main/webapp/components/administration/users/permissions/nf-registry-user-permissions.js ---------------------------------------------------------------------- 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/administration/users/permissions/nf-registry-user-permissions.js index 0569409..66f92cb 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/administration/users/permissions/nf-registry-user-permissions.js @@ -51,7 +51,7 @@ NfRegistryUserPermissions.prototype = { * Navigate to administer users for current registry. */ closeSideNav: function () { - this.router.navigateByUrl('/nifi-registry/administration/' + this.nfRegistryService.registry.id + '/users'); + this.router.navigateByUrl('/nifi-registry/administration/users'); } }; http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7b707a05/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/buckets/permissions/nf-registry-bucket-permissions.html ---------------------------------------------------------------------- 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 ff6bbdd..648987d 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 @@ -17,7 +17,7 @@ limitations under the License. <div fxFill> <div fxLayout="row" fxLayoutAlign="space-between center" class="pad-top-md pad-bottom-md pad-left-sm pad-right-sm"> - <span *ngIf="nfRegistryService.bucket.id" class="mat-card-title">{{nfRegistryService.bucket.name}}</span> + <span *ngIf="nfRegistryService.bucket.identifier" class="mat-card-title">{{nfRegistryService.bucket.name}}</span> <button md-icon-button (click)="closeSideNav()"> <md-icon color="primary">close</md-icon> </button> http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7b707a05/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/buckets/permissions/nf-registry-bucket-permissions.js ---------------------------------------------------------------------- diff --git a/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/buckets/permissions/nf-registry-bucket-permissions.js b/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/buckets/permissions/nf-registry-bucket-permissions.js index 98c5b0f..6dbb0c9 100644 --- a/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/buckets/permissions/nf-registry-bucket-permissions.js +++ b/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/buckets/permissions/nf-registry-bucket-permissions.js @@ -43,7 +43,7 @@ NfRegistryBucketPermissions.prototype = { this.nfRegistryService.sidenav.open(); this.route.params .switchMap(function (params) { - return self.nfRegistryService.getBucket(self.nfRegistryService.registry.id, params['bucketId']); + return self.nfRegistryService.api.getBucket(params['bucketId']); }) .subscribe(function (bucket) { self.nfRegistryService.bucket = bucket; @@ -62,7 +62,7 @@ NfRegistryBucketPermissions.prototype = { * Navigate to administer the buckets of the current registry. */ closeSideNav: function () { - this.router.navigateByUrl('/nifi-registry/administration/' + this.nfRegistryService.registry.id + '/workflow'); + this.router.navigateByUrl('/nifi-registry/administration/workflow'); } }; http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7b707a05/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/nf-registry-workflow-administration.html ---------------------------------------------------------------------- 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 a00c419..ebf689d 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 @@ -20,9 +20,9 @@ limitations under the License. <span class="mat-card-title">Buckets ({{nfRegistryService.buckets.length}})</span> <div flex fxLayoutAlign="start center" class="pad-top-md pad-bottom-sm"> <md-input-container flex> - <input mdInput placeholder="Create New Bucket"> + <input #newBucketInput mdInput placeholder="Create New Bucket"> </md-input-container> - <button class="input-button" color="fds-regular" md-raised-button + <button (click)="createBucket(newBucketInput)" class="input-button" color="fds-regular" md-raised-button i18n="Create new bucket button|A button for creating a new bucket in the registry.@@nf-admin-workflow-create-bucket-button"> Create </button> @@ -51,9 +51,9 @@ limitations under the License. </div> </div> <div class="td-data-table-cell"> - <div *ngIf="row.actions"> - <div *ngIf="row.actions.length <= 4" fxLayout="row" fxLayoutAlign="end center"> - <button (click)="execute(action, row)" *ngFor="let action of row.actions" + <div> + <div *ngIf="bucketActions.length <= 4" fxLayout="row" fxLayoutAlign="end center"> + <button (click)="nfRegistryService.executeBucketAction(action, row);row.checked = !row.checked;" *ngFor="let action of bucketActions" mdTooltip="{{action.tooltip}}" md-icon-button color="accent" [disabled]="action.disabled ? '' : null"> <i class="{{action.icon}}" aria-hidden="true"></i> @@ -62,13 +62,13 @@ limitations under the License. (change)="nfRegistryService.toggleBucketSelect(row)" (click)="row.checked = !row.checked;nfRegistryService.toggleBucketSelect(row)"></md-checkbox> </div> - <div *ngIf="row.actions.length > 4" fxLayout="row" fxLayoutAlign="end center"> + <div *ngIf="bucketActions.length > 4" fxLayout="row" fxLayoutAlign="end center"> <button (click)="row.checked = !row.checked" mdTooltip="Actions" md-icon-button [mdMenuTriggerFor]="bucketTableActionMenu"> <i class="fa fa-ellipsis-h" aria-hidden="true"></i> </button> <md-menu #bucketTableActionMenu="mdMenu" [overlapTrigger]="false"> - <button (click)="execute(action, row)" *ngFor="let action of row.actions" + <button (click)="nfRegistryService.executeBucketAction(action, row);row.checked = !row.checked;" *ngFor="let action of bucketActions" mdTooltip="{{action.tooltip}}" md-menu-item [disabled]="action.disabled ? '' : null"> <i class="{{action.icon}}" aria-hidden="true"></i> @@ -80,7 +80,7 @@ limitations under the License. (click)="row.checked = !row.checked;nfRegistryService.toggleBucketSelect(row)"></md-checkbox> </div> </div> - <div *ngIf="!row.actions" fxLayout="row" fxLayoutAlign="end center"> + <div *ngIf="!bucketActions" fxLayout="row" fxLayoutAlign="end center"> <md-checkbox [(ngModel)]="row.checked" [checked]="row.checked" (change)="nfRegistryService.toggleBucketSelect(row)" (click)="row.checked = !row.checked;nfRegistryService.toggleBucketSelect(row)"></md-checkbox> @@ -90,81 +90,4 @@ limitations under the License. </div> </div> </div> -<div *ngIf="false" id="nifi-registry-workflow-administration-perspective-certifications-container" - class="mat-elevation-z5"> - <div flex fxFill class="pad-top-md pad-bottom-sm pad-left-md pad-right-md"> - <span class="mat-card-title">Certifications ({{nfRegistryService.certifications.length}})</span> - <div flex fxLayoutAlign="start center" class="pad-top-md pad-bottom-sm"> - <md-input-container flex> - <input mdInput placeholder="Create New Certifications"> - </md-input-container> - <button class="input-button" color="fds-regular" md-raised-button> - Create - </button> - </div> - <div id="nifi-registry-workflow-administration-certifications-list-container-column-header" flex - class="td-data-table"> - <div class="td-data-table-column" (click)="nfRegistryService.sortCertifications($event, column)" - [mdTooltip]="column.tooltip" *ngFor="let column of nfRegistryService.certificationColumns" - fxFlex="{{column.width}}"> - {{column.label}} - <i *ngIf="column.active && column.sortable && column.sortOrder === 'ASC'" class="fa fa-caret-up" - aria-hidden="true"></i> - <i *ngIf="column.active && column.sortable && column.sortOrder === 'DESC'" class="fa fa-caret-down" - aria-hidden="true"></i> - </div> - <div class="td-data-table-column" fxFlex="20"></div> - </div> - <div id="nifi-registry-workflow-administration-certifications-list-container"> - <div fxLayout="row" fxLayoutAlign="space-between center" class="td-data-table-row" - [ngClass]="{'selected' : row.checked}" *ngFor="let row of nfRegistryService.filteredCertifications"> - <div class="td-data-table-cell" *ngFor="let column of nfRegistryService.certificationColumns" - fxFlex="{{column.width}}"> - <div *ngIf="column.name !== 'usage' && column.name !== 'badge'"> - {{column.format ? column.format(row[column.name]) : row[column.name]}} - </div> - <div *ngIf="column.name === 'usage'"> - <md-button-toggle-group class="on-off-toggle-group" (change)="row['usage'] = !row['usage']"> - <md-button-toggle value="true" [checked]="row[column.name] === true"> - ON - </md-button-toggle> - <md-button-toggle value="false" [checked]="row[column.name] !== true" class="off-toggle"> - OFF - </md-button-toggle> - </md-button-toggle-group> - </div> - <div *ngIf="column.name === 'badge'" class="pad-left-md"> - <button [style.background]="row[column.name].background" [style.color]="row[column.name].color" - mdTooltip="{{row[column.name].tooltip}}" md-icon-button class="badge" - [disabled]="!row['usage'] ? '' : null"> - <i class="{{row[column.name].icon}}" aria-hidden="true"></i> - </button> - </div> - </div> - <div class="td-data-table-cell" fxFlex="20"> - <div *ngIf="row.actions"> - <div *ngIf="row.actions.length < 4" fxLayout="row" fxLayoutAlign="end center"> - <button *ngFor="let action of row.actions" mdTooltip="{{action.tooltip}}" md-icon-button - color="accent" [disabled]="action.disabled ? '' : null"> - <i class="{{action.icon}}" aria-hidden="true"></i> - </button> - </div> - <div *ngIf="row.actions.length >= 4" fxLayout="row" fxLayoutAlign="end center"> - <button mdTooltip="Actions" md-icon-button [mdMenuTriggerFor]="tableActionMenu"> - <i class="fa fa-ellipsis-h" aria-hidden="true"></i> - </button> - <md-menu #tableActionMenu="mdMenu" [overlapTrigger]="false"> - <button *ngFor="let action of row.actions" mdTooltip="{{action.tooltip}}" md-menu-item - [disabled]="action.disabled ? '' : null"> - <i class="{{action.icon}}" aria-hidden="true"></i> - <span>{{action.name}}</span> - </button> - </md-menu> - </div> - </div> - </div> - </div> - </div> - </div> -</div> <router-outlet></router-outlet> http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7b707a05/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/nf-registry-workflow-administration.js ---------------------------------------------------------------------- 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 eb64298..1101a84 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 @@ -16,24 +16,29 @@ */ var ngCore = require('@angular/core'); 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 fdsDialogsModule = require('@fluid-design-system/dialogs'); +var ngRouter = require('@angular/router'); /** * NfRegistryWorkflowAdministration constructor. * * @param nfRegistryService The nf-registry.service module. * @param ActivatedRoute The angular activated route module. - * @param Router The angular router module. - * @param FdsDialogService The FDS dialog service. * @constructor */ -function NfRegistryWorkflowAdministration(nfRegistryService, ActivatedRoute, Router, FdsDialogService) { +function NfRegistryWorkflowAdministration(nfRegistryService, ActivatedRoute) { this.route = ActivatedRoute; this.nfRegistryService = nfRegistryService; - this.router = Router; - this.dialogService = FdsDialogService; + this.bucketActions = [{ + 'name': 'permissions', + 'icon': 'fa fa-key', + 'tooltip': 'Manage Bucket Policies', + 'type': 'sidenav' + }, { + 'name': 'Delete', + 'icon': 'fa fa-trash', + 'tooltip': 'Delete Bucket' + }]; }; NfRegistryWorkflowAdministration.prototype = { @@ -45,19 +50,13 @@ NfRegistryWorkflowAdministration.prototype = { ngOnInit: function () { var self = this; this.route.params - .subscribe(function () { + .switchMap(function (params) { self.nfRegistryService.adminPerspective = 'workflow'; - // TODO: implement certifications - // self.nfRegistryService.getCertifications(self.nfRegistryService.registry.id).then(function(certifications) { - // self.nfRegistryService.certifications = self.nfRegistryService.filteredCertifications = certifications; - // self.nfRegistryService.filterCertifications(); - // }); - - self.nfRegistryService.getBuckets(self.nfRegistryService.registry.id).then(function (buckets) { - self.nfRegistryService.buckets = self.nfRegistryService.filteredBuckets = buckets; - self.nfRegistryService.filterBuckets(); - }); - + return self.nfRegistryService.api.getBuckets(); + }) + .subscribe(function (buckets) { + self.nfRegistryService.buckets = buckets; + self.nfRegistryService.filterBuckets(); }); }, @@ -67,42 +66,19 @@ NfRegistryWorkflowAdministration.prototype = { */ ngOnDestroy: function () { this.nfRegistryService.adminPerspective = ''; - this.nfRegistryService.certifications = this.nfRegistryService.filteredCertifications = []; this.nfRegistryService.buckets = []; this.nfRegistryService.filteredBuckets = []; - this.autoCompleteBuckets = []; }, /** - * Execute the given bucket action. - * - * @param action The action object. - * @param bucket The bucket object the `action` will act upon. + * Create a new bucket. */ - execute: function (action, bucket) { + createBucket: function (newBucketInput) { var self = this; - bucket.checked = !bucket.checked; - switch (action.name.toLowerCase()) { - case 'delete': - this.dialogService.openConfirm({ - title: 'Delete Bucket', - message: 'All versions of all flows will be deleted.', - cancelButton: 'Cancel', - acceptButton: 'Delete', - acceptButtonColor: 'fds-warn' - }).afterClosed().subscribe( - function (accept) { - if (accept) { - self.nfRegistryService.deleteBucket(bucket.id); - } - }); - break; - case 'permissions': - this.router.navigateByUrl('/nifi-registry/administration/' + this.nfRegistryService.registry.id + '/workflow(' + action.type + ':bucket/' + action.name + '/' + bucket.id + ')'); - break; - default: - break; - } + this.nfRegistryService.api.createBucket(newBucketInput.value).subscribe(function (bucket) { + self.nfRegistryService.buckets.push(bucket); + self.nfRegistryService.filterBuckets(); + }) } }; @@ -116,6 +92,6 @@ NfRegistryWorkflowAdministration.annotations = [ }) ]; -NfRegistryWorkflowAdministration.parameters = [NfRegistryService, ngRouter.ActivatedRoute, ngRouter.Router, fdsDialogsModule.FdsDialogService]; +NfRegistryWorkflowAdministration.parameters = [NfRegistryService, ngRouter.ActivatedRoute]; module.exports = NfRegistryWorkflowAdministration; http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7b707a05/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/nf-registry-workflow-administration.spec.js ---------------------------------------------------------------------- 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 new file mode 100644 index 0000000..8ce5809 --- /dev/null +++ b/nifi-registry-web-ui/src/main/webapp/components/administration/workflow/nf-registry-workflow-administration.spec.js @@ -0,0 +1,177 @@ +/* + * 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 NfRegistryRoutes = require('nifi-registry/nf-registry.routes.js'); +var ngCoreTesting = require('@angular/core/testing'); +var ngCommon = require('@angular/common'); +var ngRouter = require('@angular/router'); +var ngPlatformBrowser = require('@angular/platform-browser'); +var FdsDemo = require('nifi-registry/components/fluid-design-system/fds-demo.js'); +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 NfRegistryExplorer = require('nifi-registry/components/explorer/nf-registry-explorer.js'); +var NfRegistryAdministration = require('nifi-registry/components/administration/nf-registry-administration.js'); +var NfRegistryGeneralAdministration = require('nifi-registry/components/administration/general/nf-registry-general-administration.js'); +var NfRegistryUsersAdministration = require('nifi-registry/components/administration/users/nf-registry-users-administration.js'); +var NfRegistryAddUser = require('nifi-registry/components/administration/users/add/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 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 fdsCore = require('@fluid-design-system/core'); +var ngMoment = require('angular2-moment'); +var rxjs = require('rxjs/Rx'); +var ngHttp = require('@angular/http'); + +describe('NfRegistryWorkflowAdministration Component', function () { + var comp; + var fixture; + var de; + var el; + var nfRegistryService; + var nfRegistryApi; + + beforeEach(function () { + ngCoreTesting.TestBed.configureTestingModule({ + imports: [ + ngMoment.MomentModule, + ngHttp.HttpModule, + ngHttp.JsonpModule, + fdsCore, + NfRegistryRoutes + ], + declarations: [ + FdsDemo, + NfRegistry, + NfRegistryExplorer, + NfRegistryAdministration, + NfRegistryGeneralAdministration, + NfRegistryUsersAdministration, + NfRegistryUserDetails, + NfRegistryUserPermissions, + NfRegistryBucketPermissions, + NfRegistryAddUser, + NfRegistryWorkflowAdministration, + NfRegistryGridListViewer, + NfRegistryBucketGridListViewer, + NfRegistryDropletGridListViewer, + NfPageNotFoundComponent + ], + providers: [ + NfRegistryService, + NfRegistryApi, + { + provide: ngCommon.APP_BASE_HREF, + useValue: '/' + }, { + provide: ngRouter.ActivatedRoute, + useValue: { + params: rxjs.Observable.of({}) + } + } + ] + }); + + fixture = ngCoreTesting.TestBed.createComponent(NfRegistryWorkflowAdministration); + + // test instance + comp = fixture.componentInstance; + + // from the root injector + nfRegistryService = ngCoreTesting.TestBed.get(NfRegistryService); + nfRegistryApi = ngCoreTesting.TestBed.get(NfRegistryApi); + de = fixture.debugElement.query(ngPlatformBrowser.By.css('#nifi-registry-workflow-administration-perspective-buckets-container')); + el = de.nativeElement; + + // Spy + spyOn(nfRegistryService.api, 'getDroplets').and.callFake(function () { + }).and.returnValue(rxjs.Observable.of([{ + "identifier": "2e04b4fb-9513-47bb-aa74-1ae34616bfdc", + "name": "Flow #1", + "description": "This is flow #1", + "bucketIdentifier": "2f7f9e54-dc09-4ceb-aa58-9fe581319cdc", + "createdTimestamp": 1505931890999, + "modifiedTimestamp": 1505931890999, + "type": "FLOW", + "snapshotMetadata": null, + "link": { + "params": { + "rel": "self" + }, + "href": "flows/2e04b4fb-9513-47bb-aa74-1ae34616bfdc" + } + }])); + spyOn(nfRegistryApi, 'getBuckets').and.callFake(function () { + }).and.returnValue(rxjs.Observable.of([{name: 'Bucket #1'}])); + spyOn(nfRegistryApi, 'createBucket').and.callFake(function () { + }).and.returnValue(rxjs.Observable.of({name: 'Newly Created Bucket'})); + spyOn(nfRegistryService, 'filterBuckets'); + }); + + it('should have a defined component', ngCoreTesting.async(function () { + fixture.detectChanges(); + fixture.whenStable().then(function () { // wait for async getBuckets + fixture.detectChanges(); + + //assertions + expect(comp).toBeDefined(); + expect(de).toBeDefined(); + expect(nfRegistryService.adminPerspective).toBe('workflow'); + expect(nfRegistryService.buckets[0].name).toEqual('Bucket #1'); + expect(nfRegistryService.buckets.length).toBe(1); + expect(nfRegistryService.filterBuckets).toHaveBeenCalled(); + }); + })); + + it('should create a new bucket', ngCoreTesting.async(function () { + fixture.detectChanges(); + fixture.whenStable().then(function () { // wait for async getBuckets + fixture.detectChanges(); + comp.createBucket({value: 'This bucket name.'}); + fixture.detectChanges(); + fixture.whenStable().then(function () { // wait for async createBucket + fixture.detectChanges(); + + //assertions + expect(nfRegistryApi.createBucket).toHaveBeenCalledWith('This bucket name.'); + expect(nfRegistryService.buckets[1].name).toEqual('Newly Created Bucket'); + expect(nfRegistryService.buckets.length).toBe(2); + expect(nfRegistryService.filterBuckets).toHaveBeenCalled(); + }); + }); + })); + + it('should destroy the component', ngCoreTesting.fakeAsync(function () { + fixture.detectChanges(); + // wait for async getBucket call + ngCoreTesting.tick(); + fixture.detectChanges(); + + // The function to test + comp.ngOnDestroy(); + + //assertions + expect(nfRegistryService.adminPerspective).toBe(''); + expect(nfRegistryService.buckets.length).toBe(0); + expect(nfRegistryService.filteredBuckets.length).toBe(0); + })); +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7b707a05/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/nf-registry-explorer-grid-list-viewer.html ---------------------------------------------------------------------- diff --git a/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/nf-registry-explorer-grid-list-viewer.html b/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/nf-registry-explorer-grid-list-viewer.html deleted file mode 100644 index 694065b..0000000 --- a/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/nf-registry-explorer-grid-list-viewer.html +++ /dev/null @@ -1,18 +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. ---> - -<router-outlet></router-outlet> http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7b707a05/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/nf-registry-explorer-grid-list-viewer.js ---------------------------------------------------------------------- diff --git a/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/nf-registry-explorer-grid-list-viewer.js b/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/nf-registry-explorer-grid-list-viewer.js deleted file mode 100644 index 9aa528a..0000000 --- a/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/nf-registry-explorer-grid-list-viewer.js +++ /dev/null @@ -1,43 +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'); - -/** - * NfRegistryExplorerGridListViewer constructor. - * - * @param nfRegistryService The nf-registry.service module. - * @constructor - */ - -function NfRegistryExplorerGridListViewer(nfRegistryService) { - this.nfRegistryService = nfRegistryService; -}; - -NfRegistryExplorerGridListViewer.prototype = { - constructor: NfRegistryExplorerGridListViewer -}; - -NfRegistryExplorerGridListViewer.annotations = [ - new ngCore.Component({ - template: require('./nf-registry-explorer-grid-list-viewer.html!text') - }) -]; - -NfRegistryExplorerGridListViewer.parameters = [NfRegistryService]; - -module.exports = NfRegistryExplorerGridListViewer; http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7b707a05/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/bucket/droplet/nf-registry-droplet-grid-list-viewer.html ---------------------------------------------------------------------- diff --git a/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/bucket/droplet/nf-registry-droplet-grid-list-viewer.html b/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/bucket/droplet/nf-registry-droplet-grid-list-viewer.html deleted file mode 100644 index e277b48..0000000 --- a/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/bucket/droplet/nf-registry-droplet-grid-list-viewer.html +++ /dev/null @@ -1,17 +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. ---> - http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7b707a05/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/bucket/droplet/nf-registry-droplet-grid-list-viewer.js ---------------------------------------------------------------------- diff --git a/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/bucket/droplet/nf-registry-droplet-grid-list-viewer.js b/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/bucket/droplet/nf-registry-droplet-grid-list-viewer.js deleted file mode 100644 index 9a681d2..0000000 --- a/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/bucket/droplet/nf-registry-droplet-grid-list-viewer.js +++ /dev/null @@ -1,75 +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'); - -/** - * NfRegistryDropletGridListViewer constructor. - * - * @param nfRegistryService The nf-registry.service module. - * @param ActivatedRoute The angular activated route module. - * @constructor - */ -function NfRegistryDropletGridListViewer(nfRegistryService, ActivatedRoute) { - this.route = ActivatedRoute; - this.nfRegistryService = nfRegistryService; -}; - -NfRegistryDropletGridListViewer.prototype = { - constructor: NfRegistryDropletGridListViewer, - - /** - * Initialize the component. - */ - ngOnInit: function () { - var self = this; - this.route.params - .switchMap(function (params) { - return self.nfRegistryService.getDroplets(self.nfRegistryService.registry.id, self.nfRegistryService.bucket.id, params['dropletId']); - }) - .subscribe(function (droplets) { - self.nfRegistryService.droplet = droplets[0]; - self.nfRegistryService.droplets = self.nfRegistryService.filteredDroplets = droplets; - self.nfRegistryService.filterDroplets(); - }); - }, - - /** - * Destroy the component. - */ - ngOnDestroy: function () { - var self = this; - this.nfRegistryService.droplet = {}; - this.nfRegistryService.getDroplets(this.nfRegistryService.registry.id, - this.nfRegistryService.bucket.id).then( - function (droplets) { - self.nfRegistryService.droplets = self.nfRegistryService.filteredDroplets = droplets; - self.nfRegistryService.filterDroplets(); - }); - } -}; - -NfRegistryDropletGridListViewer.annotations = [ - new ngCore.Component({ - template: require('./nf-registry-droplet-grid-list-viewer.html!text') - }) -]; - -NfRegistryDropletGridListViewer.parameters = [NfRegistryService, ngRouter.ActivatedRoute]; - -module.exports = NfRegistryDropletGridListViewer; http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7b707a05/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/bucket/nf-registry-bucket-grid-list-viewer.html ---------------------------------------------------------------------- diff --git a/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/bucket/nf-registry-bucket-grid-list-viewer.html b/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/bucket/nf-registry-bucket-grid-list-viewer.html deleted file mode 100644 index 694065b..0000000 --- a/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/bucket/nf-registry-bucket-grid-list-viewer.html +++ /dev/null @@ -1,18 +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. ---> - -<router-outlet></router-outlet> http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7b707a05/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/bucket/nf-registry-bucket-grid-list-viewer.js ---------------------------------------------------------------------- diff --git a/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/bucket/nf-registry-bucket-grid-list-viewer.js b/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/bucket/nf-registry-bucket-grid-list-viewer.js deleted file mode 100644 index a992768..0000000 --- a/nifi-registry-web-ui/src/main/webapp/components/explorer/grid-list/registry/bucket/nf-registry-bucket-grid-list-viewer.js +++ /dev/null @@ -1,76 +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'); - -/** - * NfRegistryBucketGridListViewer constructor. - * - * @param nfRegistryService The nf-registry.service module. - * @param ActivatedRoute The angular activated route module. - * @constructor - */ -function NfRegistryBucketGridListViewer(nfRegistryService, ActivatedRoute) { - this.route = ActivatedRoute; - this.nfRegistryService = nfRegistryService; -}; - -NfRegistryBucketGridListViewer.prototype = { - constructor: NfRegistryBucketGridListViewer, - - /** - * Initialize the component. - */ - ngOnInit: function () { - var self = this; - this.route.params - .switchMap(function (params) { - return self.nfRegistryService.getBuckets(self.nfRegistryService.registry.id, params['bucketId']); - }) - .subscribe(function (buckets) { - self.nfRegistryService.bucket = buckets[0]; - self.nfRegistryService.getDroplets(self.nfRegistryService.registry.id, self.nfRegistryService.bucket.id).then(function (droplets) { - self.nfRegistryService.droplets = self.nfRegistryService.filteredDroplets = droplets; - self.nfRegistryService.filterDroplets(); - }); - }); - }, - - /** - * Destroy the component. - */ - ngOnDestroy: function () { - var self = this; - this.nfRegistryService.bucket = {}; - this.nfRegistryService.getDroplets(this.nfRegistryService.registry.id).then( - function (droplets) { - self.nfRegistryService.droplets = self.nfRegistryService.filteredDroplets = droplets; - self.nfRegistryService.filterDroplets(); - }); - } -}; - -NfRegistryBucketGridListViewer.annotations = [ - new ngCore.Component({ - template: require('./nf-registry-bucket-grid-list-viewer.html!text') - }) -]; - -NfRegistryBucketGridListViewer.parameters = [NfRegistryService, ngRouter.ActivatedRoute]; - -module.exports = NfRegistryBucketGridListViewer;
