From 18fbdb75d05dc58d3a5057bae776a15ab7de1eb0 Mon Sep 17 00:00:00 2001 From: Vito Albano Date: Fri, 16 Sep 2016 11:46:16 +0100 Subject: [PATCH 01/26] Start adding ecmUser component --- .../ng2-alfresco-userinfo/.editorconfig | 23 ++++ .../ng2-alfresco-userinfo/.gitignore | 13 ++ .../ng2-alfresco-userinfo/.travis.yml | 8 ++ ng2-components/ng2-alfresco-userinfo/LICENSE | 13 ++ .../ng2-alfresco-userinfo/README.md | 43 ++++++ .../ng2-alfresco-userinfo/angular-cli.json | 27 ++++ .../ng2-alfresco-userinfo/demo/.editorconfig | 10 ++ .../ng2-alfresco-userinfo/demo/.gitignore | 5 + .../ng2-alfresco-userinfo/demo/README.md | 19 +++ .../ng2-alfresco-userinfo/demo/index.html | 36 +++++ .../ng2-alfresco-userinfo/demo/package.json | 56 ++++++++ .../ng2-alfresco-userinfo/demo/src/main.ts | 57 ++++++++ .../demo/systemjs.config.js | 56 ++++++++ .../ng2-alfresco-userinfo/demo/tsconfig.json | 19 +++ .../ng2-alfresco-userinfo/demo/tslint.json | 124 ++++++++++++++++++ .../ng2-alfresco-userinfo/demo/typings.json | 7 + ng2-components/ng2-alfresco-userinfo/index.ts | 10 ++ .../ng2-alfresco-userinfo/karma-test-shim.js | 110 ++++++++++++++++ .../ng2-alfresco-userinfo/karma.conf.js | 87 ++++++++++++ .../ng2-alfresco-userinfo/package.json | 83 ++++++++++++ .../src/models/ecmCompany.model.ts | 27 ++++ .../src/models/ecmUser.model.ts | 39 ++++++ .../src/services/ecmUser.service.ts | 63 +++++++++ .../src/userinfo.component.html | 1 + .../src/userinfo.component.spec.ts | 16 +++ .../src/userinfo.component.ts | 31 +++++ .../ng2-alfresco-userinfo/tsconfig.json | 27 ++++ .../ng2-alfresco-userinfo/tslint.json | 121 +++++++++++++++++ .../ng2-alfresco-userinfo/typings.json | 7 + 29 files changed, 1138 insertions(+) create mode 100644 ng2-components/ng2-alfresco-userinfo/.editorconfig create mode 100644 ng2-components/ng2-alfresco-userinfo/.gitignore create mode 100644 ng2-components/ng2-alfresco-userinfo/.travis.yml create mode 100644 ng2-components/ng2-alfresco-userinfo/LICENSE create mode 100644 ng2-components/ng2-alfresco-userinfo/README.md create mode 100644 ng2-components/ng2-alfresco-userinfo/angular-cli.json create mode 100644 ng2-components/ng2-alfresco-userinfo/demo/.editorconfig create mode 100644 ng2-components/ng2-alfresco-userinfo/demo/.gitignore create mode 100644 ng2-components/ng2-alfresco-userinfo/demo/README.md create mode 100644 ng2-components/ng2-alfresco-userinfo/demo/index.html create mode 100644 ng2-components/ng2-alfresco-userinfo/demo/package.json create mode 100644 ng2-components/ng2-alfresco-userinfo/demo/src/main.ts create mode 100644 ng2-components/ng2-alfresco-userinfo/demo/systemjs.config.js create mode 100644 ng2-components/ng2-alfresco-userinfo/demo/tsconfig.json create mode 100644 ng2-components/ng2-alfresco-userinfo/demo/tslint.json create mode 100644 ng2-components/ng2-alfresco-userinfo/demo/typings.json create mode 100644 ng2-components/ng2-alfresco-userinfo/index.ts create mode 100644 ng2-components/ng2-alfresco-userinfo/karma-test-shim.js create mode 100644 ng2-components/ng2-alfresco-userinfo/karma.conf.js create mode 100644 ng2-components/ng2-alfresco-userinfo/package.json create mode 100644 ng2-components/ng2-alfresco-userinfo/src/models/ecmCompany.model.ts create mode 100644 ng2-components/ng2-alfresco-userinfo/src/models/ecmUser.model.ts create mode 100644 ng2-components/ng2-alfresco-userinfo/src/services/ecmUser.service.ts create mode 100644 ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html create mode 100644 ng2-components/ng2-alfresco-userinfo/src/userinfo.component.spec.ts create mode 100644 ng2-components/ng2-alfresco-userinfo/src/userinfo.component.ts create mode 100644 ng2-components/ng2-alfresco-userinfo/tsconfig.json create mode 100644 ng2-components/ng2-alfresco-userinfo/tslint.json create mode 100644 ng2-components/ng2-alfresco-userinfo/typings.json diff --git a/ng2-components/ng2-alfresco-userinfo/.editorconfig b/ng2-components/ng2-alfresco-userinfo/.editorconfig new file mode 100644 index 0000000000..75a2477db7 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/.editorconfig @@ -0,0 +1,23 @@ +# http://editorconfig.org + +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 4 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[package.json] +indent_style = space +indent_size = 2 + +[karma.conf.js] +indent_style = space +indent_size = 2 + +[*.md] +insert_final_newline = false +trim_trailing_whitespace = false diff --git a/ng2-components/ng2-alfresco-userinfo/.gitignore b/ng2-components/ng2-alfresco-userinfo/.gitignore new file mode 100644 index 0000000000..3bea8a0c07 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/.gitignore @@ -0,0 +1,13 @@ +npm-debug.log +node_modules +jspm_packages +.idea +typings +coverage +src/**/*.js +src/**/*.js.map +src/**/*.d.ts +demo/**/*.js +demo/**/*.js.map +demo/**/*.d.ts +!systemjs.config.js diff --git a/ng2-components/ng2-alfresco-userinfo/.travis.yml b/ng2-components/ng2-alfresco-userinfo/.travis.yml new file mode 100644 index 0000000000..781e6204e8 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/.travis.yml @@ -0,0 +1,8 @@ +language: node_js +node_js: + - v5 + - v4 +install: npm install +sudo: false +after_success: + npm run coverage diff --git a/ng2-components/ng2-alfresco-userinfo/LICENSE b/ng2-components/ng2-alfresco-userinfo/LICENSE new file mode 100644 index 0000000000..bfd4a66b0c --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/LICENSE @@ -0,0 +1,13 @@ +Copyright 2016 vito albano + +Licensed 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. diff --git a/ng2-components/ng2-alfresco-userinfo/README.md b/ng2-components/ng2-alfresco-userinfo/README.md new file mode 100644 index 0000000000..fe8a836e34 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/README.md @@ -0,0 +1,43 @@ +# ng2-alfresco-userinfo +This component will show the user information for ECM and BPM + +## Installation + +```bash +npm install ng2-alfresco-userinfo --save +``` + +## Example + +```html + +``` + +## Reference + +Attribute | Options | Default | Description +--- | --- | --- | --- +`foo` | *string* | `bar` | Lorem ipsum dolor. + + +Method | Parameters | Returns | Description +--- | --- | --- | --- +`methodName()` | None. | void | Lorem ipsum dolor. + +## NPM scripts + +| Command | Description | +| --- | --- | +| npm run build | Build component | +| npm run build:w | Build component and keep watching the changes | +| npm run test | Run unit tests in the console | +| npm run test-browser | Run unit tests in the browser +| npm run coverage | Run unit tests and display code coverage report | + +## History + +For detailed changelog, check [Releases](https://github.com/alfresco/ng2-alfresco-userinfo/releases). + +## Contributors + +[Contributors](https://github.com/alfresco/ng2-alfresco-userinfo/graphs/contributors) diff --git a/ng2-components/ng2-alfresco-userinfo/angular-cli.json b/ng2-components/ng2-alfresco-userinfo/angular-cli.json new file mode 100644 index 0000000000..ef1d3675f0 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/angular-cli.json @@ -0,0 +1,27 @@ +{ + "project": { + "version": "ng2-alfresco-userinfo", + "name": "0.1.0" + }, + "apps": [ + { + "main": "src/ng2-alfresco-userinfo.component.ts", + "tsconfig": "tsconfig.json", + "mobile": false + } + ], + "addons": [], + "packages": [], + "test": { + "karma": { + "config": "karma.conf.js" + } + }, + "defaults": { + "prefix": "", + "sourceDir": "src", + "styleExt": "css", + "prefixInterfaces": false, + "lazyRoutePrefix": "+" + } +} diff --git a/ng2-components/ng2-alfresco-userinfo/demo/.editorconfig b/ng2-components/ng2-alfresco-userinfo/demo/.editorconfig new file mode 100644 index 0000000000..8ed330c4a2 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/demo/.editorconfig @@ -0,0 +1,10 @@ + +root = true + +[{src,scripts}/**.{ts,json,js}] +end_of_line = crlf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +indent_style = space +indent_size = 4 diff --git a/ng2-components/ng2-alfresco-userinfo/demo/.gitignore b/ng2-components/ng2-alfresco-userinfo/demo/.gitignore new file mode 100644 index 0000000000..7c04460244 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/demo/.gitignore @@ -0,0 +1,5 @@ +typings/ +node_modules/ +.idea +dist/ +!systemjs.config.js diff --git a/ng2-components/ng2-alfresco-userinfo/demo/README.md b/ng2-components/ng2-alfresco-userinfo/demo/README.md new file mode 100644 index 0000000000..7b59778398 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/demo/README.md @@ -0,0 +1,19 @@ +# ng2-alfresco-userinfo - Demo + +* To install dependencies + +```sh +$ npm install +``` + +* To provide a live demo + +```sh +$ npm run start +``` + +* To clean npm_modules and typings folder + +```sh +$ npm run clean +``` diff --git a/ng2-components/ng2-alfresco-userinfo/demo/index.html b/ng2-components/ng2-alfresco-userinfo/demo/index.html new file mode 100644 index 0000000000..87aedd2904 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/demo/index.html @@ -0,0 +1,36 @@ + + + + + + + ng2-alfresco-userinfo Angular 2 + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + diff --git a/ng2-components/ng2-alfresco-userinfo/demo/package.json b/ng2-components/ng2-alfresco-userinfo/demo/package.json new file mode 100644 index 0000000000..9566571b1f --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/demo/package.json @@ -0,0 +1,56 @@ +{ + "name": "ng2-alfresco-userinfo-demo", + "description": "This component will show the user information for ECM and BPM - Demo", + "version": "0.1.0", + "author": "vito albano ", + "main": "./dist/index.js", + "typings": "./dist/index.d.ts", + "scripts": { + "clean": "rimraf dist node_modules typings", + "typings": "typings install", + "postinstall": "npm run typings && npm run build", + "start": "npm run tslint && rimraf dist && tsc && concurrently \"tsc -w\" \"npm run server\" ", + "server": "wsrv -o -l -s", + "build": "npm run tslint && rimraf dist && tsc", + "build:w": "npm run tslint && rimraf dist && tsc -w", + "tslint": "tslint -c tslint.json *.ts && tslint -c tslint.json src/{,**/}**.ts" + }, + "keywords": [ + "ng2", + "angular", + "angular2", + "alfresco", + "demo" + ], + "dependencies": { + "@angular/common": "2.0.0-rc.3", + "@angular/compiler": "2.0.0-rc.3", + "@angular/core": "2.0.0-rc.3", + "@angular/http": "2.0.0-rc.3", + "@angular/platform-browser": "2.0.0-rc.3", + "@angular/platform-browser-dynamic": "2.0.0-rc.3", + "@angular/router": "3.0.0-alpha.7", + "@angular/router-deprecated": "2.0.0-rc.2", + "@angular/upgrade": "2.0.0-rc.3", + "systemjs": "0.19.27", + "core-js": "^2.4.0", + "reflect-metadata": "^0.1.3", + "rxjs": "5.0.0-beta.6", + "zone.js": "^0.6.12", + "material-design-icons": "^2.2.3", + "material-design-lite": "^1.1.3", + "ng2-translate": "2.2.2", + + "ng2-alfresco-userinfo": "file:../", + "ng2-alfresco-core": "^0.3.0", + "alfresco-js-api": "^0.3.0" + }, + "devDependencies": { + "concurrently": "^2.0.0", + "rimraf": "2.5.2", + "tslint": "^3.8.1", + "typescript": "^1.8.10", + "typings": "^1.0.4", + "wsrv": "^0.1.4" + } +} diff --git a/ng2-components/ng2-alfresco-userinfo/demo/src/main.ts b/ng2-components/ng2-alfresco-userinfo/demo/src/main.ts new file mode 100644 index 0000000000..8801ffcb21 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/demo/src/main.ts @@ -0,0 +1,57 @@ + +import { Component, OnInit } from '@angular/core'; +import { bootstrap } from '@angular/platform-browser-dynamic'; +import { UserInfoComponent } from 'ng2-alfresco-userinfo'; +import { HTTP_PROVIDERS } from '@angular/http'; +import { + AlfrescoSettingsService, + AlfrescoAuthenticationService, + ALFRESCO_CORE_PROVIDERS +} from 'ng2-alfresco-core'; + +@Component({ + selector: 'my-app', + template: `

START

`, + directives: [ UserInfoComponent ], + providers: [AlfrescoAuthenticationService, AlfrescoSettingsService] +}) + + +class UserInfoDemo implements OnInit { + + private authenticated: boolean; + private ticket: string; + // private ecmHost: string; + + constructor(private authService: AlfrescoAuthenticationService, + private settingsService: AlfrescoSettingsService) { + this.settingsService.setProviders('ECM'); + } + + public ngOnInit(): void { + this.login(); + } + + login() { + this.authService.login('test', 'test').subscribe( + ticket => { + console.log(ticket); + this.ticket = this.authService.getTicketEcm(); + this.authenticated = true; + }, + error => { + console.log(error); + this.authenticated = false; + }); + } +} + + + + + +bootstrap(UserInfoDemo, [ + UserInfoComponent, + HTTP_PROVIDERS, + ALFRESCO_CORE_PROVIDERS +]); diff --git a/ng2-components/ng2-alfresco-userinfo/demo/systemjs.config.js b/ng2-components/ng2-alfresco-userinfo/demo/systemjs.config.js new file mode 100644 index 0000000000..ead7634f8a --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/demo/systemjs.config.js @@ -0,0 +1,56 @@ + +'use strict'; +(function(/*global*/) { + + // map tells the System loader where to look for things + var map = { + app: 'dist/', + '@angular': 'node_modules/@angular', + rxjs: 'node_modules/rxjs', + + 'ng2-translate': 'node_modules/ng2-translate', + 'ng2-alfresco-core': 'node_modules/ng2-alfresco-core/dist', + + 'ng2-alfresco-userinfo': 'node_modules/ng2-alfresco-userinfo/dist' + }; + + // packages tells the System loader how to load when no filename and/or no extension + var packages = { + app: { main: 'main.js', defaultExtension: 'js' }, + rxjs: { defaultExtension: 'js' }, + + 'ng2-translate': { defaultExtension: 'js' }, + 'ng2-alfresco-core': { main: 'index.js', defaultExtension: 'js' }, + + 'ng2-alfresco-userinfo': { main: 'index.js', defaultExtension: 'js' } + }; + + var ngPackageNames = [ + 'common', + 'compiler', + 'core', + 'http', + 'platform-browser', + 'platform-browser-dynamic', + 'router', + 'router-deprecated', + 'upgrade' + ]; + // Individual files (~300 requests): + function packIndex(pkgName) { + packages['@angular/' + pkgName] = { main: 'index.js', defaultExtension: 'js' }; + } + // Bundled (~40 requests): + function packUmd(pkgName) { + packages['@angular/' + pkgName] = { main: '/bundles/' + pkgName + '.umd.js', defaultExtension: 'js' }; + } + // Most environments should use UMD; some (Karma) need the individual index files + var setPackageConfig = System.packageWithIndex ? packIndex : packUmd; + // Add package entries for angular packages + ngPackageNames.forEach(setPackageConfig); + var config = { + map: map, + packages: packages + }; + System.config(config); +})(this); diff --git a/ng2-components/ng2-alfresco-userinfo/demo/tsconfig.json b/ng2-components/ng2-alfresco-userinfo/demo/tsconfig.json new file mode 100644 index 0000000000..772c3a7e75 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/demo/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "system", + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "sourceMap": true, + "removeComments": true, + "declaration": true, + "outDir": "dist" + }, + "exclude": [ + "dist", + "node_modules", + "typings/main", + "typings/main.d.ts" + ] +} diff --git a/ng2-components/ng2-alfresco-userinfo/demo/tslint.json b/ng2-components/ng2-alfresco-userinfo/demo/tslint.json new file mode 100644 index 0000000000..8c48e76469 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/demo/tslint.json @@ -0,0 +1,124 @@ +{ + "rules": { + "align": [ + true, + "parameters", + "arguments", + "statements" + ], + "ban": false, + "class-name": true, + "comment-format": [ + true, + "check-space", + "check-lowercase" + ], + "curly": true, + "eofline": true, + "forin": true, + "indent": [ + true, + "spaces" + ], + "interface-name": false, + "jsdoc-format": true, + "label-position": true, + "label-undefined": true, + "max-line-length": [ + true, + 140 + ], + "member-ordering": [ + true, + "public-before-private", + "static-before-instance", + "variables-before-functions" + ], + "no-any": false, + "no-arg": true, + "no-bitwise": true, + "no-conditional-assignment": true, + "no-consecutive-blank-lines": false, + "no-console": [ + true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-construct": true, + "no-constructor-vars": false, + "no-debugger": true, + "no-duplicate-key": true, + "no-duplicate-variable": true, + "no-empty": true, + "no-eval": true, + "no-inferrable-types": false, + "no-internal-module": true, + "no-require-imports": true, + "no-shadowed-variable": true, + "no-switch-case-fall-through": true, + "no-trailing-whitespace": true, + "no-unreachable": true, + "no-unused-expression": true, + "no-unused-variable": true, + "no-use-before-declare": true, + "no-var-keyword": true, + "no-var-requires": true, + "object-literal-sort-keys": false, + "one-line": [ + true, + "check-open-brace", + "check-catch", + "check-else", + "check-whitespace" + ], + "quotemark": [ + true, + "single", + "avoid-escape" + ], + "radix": true, + "semicolon": true, + "switch-default": true, + "trailing-comma": [ + true, + { + "multiline": "never", + "singleline": "never" + } + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "typedef": false, + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "use-strict": false, + "variable-name": [ + true, + "check-format", + "allow-leading-underscore", + "ban-keywords" + ], + "whitespace": [ + true, + "check-branch", + "check-operator", + "check-separator", + "check-type", + "check-module", + "check-decl" + ] + } +} diff --git a/ng2-components/ng2-alfresco-userinfo/demo/typings.json b/ng2-components/ng2-alfresco-userinfo/demo/typings.json new file mode 100644 index 0000000000..7e0e18568d --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/demo/typings.json @@ -0,0 +1,7 @@ +{ + "globalDependencies": { + "core-js": "registry:dt/core-js#0.0.0+20160317120654", + "jasmine": "registry:dt/jasmine#2.2.0+20160505161446", + "node": "registry:dt/node#4.0.0+20160509154515" + } +} diff --git a/ng2-components/ng2-alfresco-userinfo/index.ts b/ng2-components/ng2-alfresco-userinfo/index.ts new file mode 100644 index 0000000000..3548a5fae7 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/index.ts @@ -0,0 +1,10 @@ +import { ECMUserService } from './src/services/ecmUser.service'; + + +export * from './src/userinfo.component'; +export * from './src/services/ecmUser.service'; + + +export const USER_INFO_SERVICE: [any] = [ + ECMUserService +]; diff --git a/ng2-components/ng2-alfresco-userinfo/karma-test-shim.js b/ng2-components/ng2-alfresco-userinfo/karma-test-shim.js new file mode 100644 index 0000000000..445a2b98d0 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/karma-test-shim.js @@ -0,0 +1,110 @@ +'use strict'; +// Tun on full stack traces in errors to help debugging +Error.stackTraceLimit = Infinity; +jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000; +__karma__.loaded = function() {}; + +var map = { + app: 'base/dist', + rxjs: 'base/node_modules/rxjs', + '@angular': 'base/node_modules/@angular', + 'ng2-translate': '/base/node_modules/ng2-translate', + 'ng2-alfresco-core': '/base/node_modules/ng2-alfresco-core/dist' +}; + +var packages = { + app: { main: 'main.js', defaultExtension: 'js' }, + rxjs: { defaultExtension: 'js' }, + 'ng2-translate': { defaultExtension: 'js' }, + 'ng2-alfresco-core': { main: 'index.js', defaultExtension: 'js' } +}; + +var packageNames = [ + '@angular/common', + '@angular/compiler', + '@angular/core', + '@angular/http', + '@angular/platform-browser', + '@angular/platform-browser-dynamic', + '@angular/router', + '@angular/router-deprecated', + '@angular/testing', + '@angular/upgrade' +]; + +packageNames.forEach(function(pkgName) { + packages[pkgName] = { main: 'index.js', defaultExtension: 'js' }; +}); + +packages['base/dist'] = { + defaultExtension: 'js', + format: 'register', + map: Object.keys(window.__karma__.files).filter(onlyAppFiles).reduce(createPathRecords, {}) +}; + +var config = { + map: map, + packages: packages +}; + +System.config(config); + +System.import('@angular/platform-browser/src/browser/browser_adapter') + .then(function(browserAdapter) { + browserAdapter.BrowserDomAdapter.makeCurrent(); + }) + .then(function() { + return Promise.all([ + System.import('@angular/core/testing'), + System.import('@angular/platform-browser-dynamic/testing') + ]); + }) + .then(function(providers) { + var testing = providers[0]; + var testingBrowser = providers[1]; + + testing.setBaseTestProviders( + testingBrowser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, + testingBrowser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS); + }) + .then(function() { + return Promise.all(resolveTestFiles()); + }) + .then( + function() { + __karma__.start(); + }, + function(error) { + if (typeof __karma__.error === 'function') { + __karma__.error(error.stack || error); + } else { + console.error(error); + } + } + ); + +function createPathRecords(pathsMapping, appPath) { + var pathParts = appPath.split('/'); + var moduleName = './' + pathParts.slice(Math.max(pathParts.length - 2, 1)).join('/'); + moduleName = moduleName.replace(/\.js$/, ''); + pathsMapping[moduleName] = appPath + '?' + window.__karma__.files[appPath]; + return pathsMapping; +} + +function onlyAppFiles(filePath) { + return /\/base\/dist\/(?!.*\.spec\.js$).*\.js$/.test(filePath); +} + +function onlySpecFiles(path) { + return /\.spec\.js$/.test(path); +} + +function resolveTestFiles() { + return Object.keys(window.__karma__.files) // All files served by Karma. + .filter(onlySpecFiles) + .map(function(moduleName) { + // loads all spec files via their global module names (e.g. + // 'base/dist/vg-player/vg-player.spec') + return System.import(moduleName); + }); +} diff --git a/ng2-components/ng2-alfresco-userinfo/karma.conf.js b/ng2-components/ng2-alfresco-userinfo/karma.conf.js new file mode 100644 index 0000000000..c822c9fcd6 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/karma.conf.js @@ -0,0 +1,87 @@ +'use strict'; + +module.exports = function(config) { + config.set({ + + basePath: '.', + + frameworks: ['jasmine'], + + files: [ + // paths loaded by Karma + {pattern: 'node_modules/reflect-metadata/Reflect.js', included: true, watched: false}, + {pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: false}, + {pattern: 'node_modules/zone.js/dist/zone.js', included: true, watched: false}, + {pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false}, + {pattern: 'node_modules/rxjs/**/*.map', included: false, watched: false}, + {pattern: 'node_modules/@angular/**/*.js', included: false, watched: false}, + {pattern: 'node_modules/@angular/**/*.map', included: false, watched: false}, + {pattern: 'node_modules/ng2-translate/**/*.js', included: false, served: true, watched: false}, + {pattern: 'node_modules/ng2-alfresco-core/dist/**/*.js', included: false, served: true, watched: false}, + {pattern: 'node_modules/alfresco-core-rest-api/bundle.js', included: true, watched: false}, + + {pattern: 'karma-test-shim.js', included: true, watched: true}, + + // paths loaded via module imports + {pattern: 'dist/**/*.js', included: false, watched: true}, + {pattern: 'dist/**/*.html', included: true, served: true, watched: true}, + {pattern: 'dist/**/*.css', included: true, served: true, watched: true}, + + // paths to support debugging with source maps in dev tools + {pattern: 'src/**/*.ts', included: false, watched: false}, + {pattern: 'dist/**/*.js.map', included: false, watched: false} + ], + + // proxied base paths + proxies: { + // required for component assets fetched by Angular's compiler + '/src/': '/base/src/' + }, + + // list of files to exclude + exclude: [ + 'node_modules/**/*spec.js' + ], + + port: 9876, + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + colors: true, + + autoWatch: true, + + browsers: ['Chrome'], + + // Karma plugins loaded + plugins: [ + 'karma-jasmine', + 'karma-coverage', + 'karma-chrome-launcher', + 'karma-mocha-reporter', + 'karma-jasmine-html-reporter' + ], + + // Coverage reporter generates the coverage + reporters: ['mocha', 'coverage', 'kjhtml'], + + // Source files that you wanna generate coverage for. + // Do not include tests or libraries (these files will be instrumented by Istanbul) + preprocessors: { + 'dist/**/!(*spec).js': ['coverage'] + }, + + coverageReporter: { + dir: 'coverage/', + subdir: 'report', + reporters: [ + {type: 'text'}, + {type: 'text-summary'}, + {type: 'json', file: 'coverage-final.json'}, + {type: 'html'} + ] + } + }); +}; diff --git a/ng2-components/ng2-alfresco-userinfo/package.json b/ng2-components/ng2-alfresco-userinfo/package.json new file mode 100644 index 0000000000..34b6de40e7 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/package.json @@ -0,0 +1,83 @@ +{ + "name": "ng2-alfresco-userinfo", + "description": "This component will show the user information for ECM and BPM", + "version": "0.1.0", + "author": "vito albano ", + "scripts": { + "postinstall": "typings install", + "clean": "rimraf dist node_modules typings", + "typings": "typings install", + "license-check": "echo 'license check is disabled'", + "build": "npm run tslint && rimraf dist && tsc && npm run copy-dist && npm run license-check", + "build:w": "npm run tslint && rimraf dist && npm run watch-task", + "watch-task": "concurrently \"npm run tsc:w\" \"npm run copy-dist:w\" \"npm run license-check\"", + "tslint": "tslint -c tslint.json *.ts && tslint -c tslint.json src/{,**/}**.ts", + "copy-dist": "cpx \"./src/**/*.{html,css,json,png,jpg,gif,svg}\" ./dist/src", + "copy-dist:w": "cpx \"./src/**/*.{html,css,json,png,jpg,gif,svg}\" ./dist/src -w", + "tsc": "tsc", + "tsc:w": "tsc -w", + "pretest": "npm run build", + "test": "karma start karma.conf.js --reporters mocha,coverage --single-run", + "test-browser": "npm run build && concurrently \"karma start karma.conf.js --reporters kjhtml\" \"npm run watch-task\"", + "posttest": "remap-istanbul -i coverage/report/coverage-final.json -o coverage/report -t html && remap-istanbul -i coverage/report/coverage-final.json -o coverage/report/coverage-final.json", + "coverage": "npm run test && wsrv -o -p 9875 ./coverage/report", + "prepublish": "npm run build", + "travis": "echo 'placeholder'" + }, + "main": "./dist/index.js", + "typings": "./dist/index.d.ts", + "repository": { + "type": "git", + "url": "https://github.com/alfresco/ng2-alfresco-userinfo.git" + }, + "bugs": { + "url": "https://github.com/alfresco/ng2-alfresco-userinfo/issues" + }, + "dependencies": { + "@angular/common": "2.0.0-rc.3", + "@angular/compiler": "2.0.0-rc.3", + "@angular/core": "2.0.0-rc.3", + "@angular/http": "2.0.0-rc.3", + "@angular/platform-browser": "2.0.0-rc.3", + "@angular/platform-browser-dynamic": "2.0.0-rc.3", + "@angular/router": "3.0.0-alpha.7", + "@angular/router-deprecated": "2.0.0-rc.2", + "@angular/upgrade": "2.0.0-rc.3", + "systemjs": "0.19.27", + "core-js": "^2.4.0", + "reflect-metadata": "^0.1.3", + "rxjs": "5.0.0-beta.6", + "zone.js": "^0.6.12", + "ng2-translate": "2.2.2", + "alfresco-js-api": "^0.3.0", + "ng2-alfresco-core": "0.3.2" + }, + "devDependencies": { + "angular-cli": "1.0.0-beta.9", + "concurrently": "^2.1.0", + "cpx": "^1.3.1", + "jasmine-ajax": "^3.2.0", + "jasmine-core": "2.4.1", + "karma": "~0.13.22", + "karma-chrome-launcher": "~1.0.1", + "karma-coverage": "^1.0.0", + "karma-jasmine": "~1.0.2", + "karma-jasmine-ajax": "^0.1.13", + "karma-jasmine-html-reporter": "^0.2.0", + "karma-mocha-reporter": "^2.0.3", + "remap-istanbul": "^0.6.3", + "rimraf": "2.5.2", + "traceur": "^0.0.91", + "tslint": "^3.8.1", + "typescript": "^1.8.10", + "typings": "^1.0.4", + "wsrv": "^0.1.3" + }, + "keywords": [ + "component", + "userinfo", + "alfresco", + "alfresco-component" + ], + "license": "Apache-2.0" +} diff --git a/ng2-components/ng2-alfresco-userinfo/src/models/ecmCompany.model.ts b/ng2-components/ng2-alfresco-userinfo/src/models/ecmCompany.model.ts new file mode 100644 index 0000000000..458b6b8ed5 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/src/models/ecmCompany.model.ts @@ -0,0 +1,27 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed 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. + */ + +export class EcmCompanyModel { + organization: string; + address1: string; + address2: string; + address3: string; + postcode: string; + telephone: string; + fax: string; + email: string; +} diff --git a/ng2-components/ng2-alfresco-userinfo/src/models/ecmUser.model.ts b/ng2-components/ng2-alfresco-userinfo/src/models/ecmUser.model.ts new file mode 100644 index 0000000000..436604989c --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/src/models/ecmUser.model.ts @@ -0,0 +1,39 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed 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. + */ + +import { EcmCompanyModel } from './ecmCompany.model'; + +export class EcmUserModel { + id: string; + firstName: string; + lastName: string; + description: string; + avatarId: string; + email: string; + skypeId: string; + googleId: string; + instantMessageId: string; + jobTitle: string; + location: string; + company: EcmCompanyModel; + mobile: string; + telephone: string; + statusUpdatedAt: string; + userStatus: string; + enabled: boolean; + emailNotificationsEnabled: boolean; +} diff --git a/ng2-components/ng2-alfresco-userinfo/src/services/ecmUser.service.ts b/ng2-components/ng2-alfresco-userinfo/src/services/ecmUser.service.ts new file mode 100644 index 0000000000..f6d237ecd6 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/src/services/ecmUser.service.ts @@ -0,0 +1,63 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed 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. + */ + +import { AlfrescoApiService } from 'ng2-alfresco-core'; +import { Injectable } from '@angular/core'; +import { Response } from '@angular/http'; +import { Observable } from 'rxjs/Observable'; +import { EcmUserModel } from '../models/ecmUser.model'; +/** + * + * ECMUserService retrieve all the information of an Ecm user. + * + * @returns {ECMUserService} . + */ +@Injectable() +export class ECMUserService { + + constructor(private apiService: AlfrescoApiService) {} + + /** + * get User Information via ECM + * @param userName - the user name + */ + getUserInfo(userName: string): Observable { + return Observable.fromPromise(this.callApiGetPersonInfo(userName)) + .map( data => data ) + .do( + data => console.log('Node data', data) + ) // eyeball results in the console + .catch(this.handleError); + } + + private callApiGetPersonInfo(userName: string, opts?: any) { + return this.apiService.getInstance().core.peopleApi.getPerson(userName, opts); + } + + /** + * Throw the error + * @param error + * @returns {ErrorObservable} + */ + private handleError(error: Response) { + // in a real world app, we may send the error to some remote logging infrastructure + // instead of just logging it to the console + console.error(error); + return Observable.throw(error || 'Server error'); + } + +} diff --git a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html new file mode 100644 index 0000000000..116e372f29 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html @@ -0,0 +1 @@ +
TEST
diff --git a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.spec.ts b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.spec.ts new file mode 100644 index 0000000000..e7917d1f0b --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.spec.ts @@ -0,0 +1,16 @@ + +import {describe, expect, it, inject} from '@angular/core/testing'; +import { TestComponentBuilder } from '@angular/compiler/testing'; +import { UserInfoComponent } from '../src/userinfo.component'; + +describe('Basic Example test ng2-alfresco-userinfo', () => { + it('Test hello world', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { + return tcb + .createAsync(UserInfoComponent) + .then((fixture) => { + let element = fixture.nativeElement; + expect(element.querySelector('h1')).toBeDefined(); + expect(element.getElementsByTagName('h1')[0].innerHTML).toEqual('Hello World Angular 2 ng2-alfresco-userinfo'); + }); + })); +}); diff --git a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.ts b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.ts new file mode 100644 index 0000000000..ccf3384bac --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.ts @@ -0,0 +1,31 @@ + +import { Component } from '@angular/core'; +import { ECMUserService } from './services/ecmUser.service'; +import { EcmUserModel } from './models/ecmUser.model'; + +@Component({ + selector: 'ng2-alfresco-userinfo', + styles: [`:host h1 { font-size:22px }`], + template: `

Hello World Angular 2 ng2-alfresco-userinfo

`, + providers: [ ECMUserService ] +}) + + +export class UserInfoComponent { + + private ecmUser: EcmUserModel; + + constructor(private ecmUserService: ECMUserService) { + console.log('User info component constr'); + } + + doQueryUser() { + this.ecmUserService.getUserInfo('admin') + .subscribe( + res => this.ecmUser = res.entry + ); + } + + + +} diff --git a/ng2-components/ng2-alfresco-userinfo/tsconfig.json b/ng2-components/ng2-alfresco-userinfo/tsconfig.json new file mode 100644 index 0000000000..e4d2ae201a --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "system", + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "sourceMap": true, + "removeComments": true, + "declaration": true, + "noLib": false, + "allowUnreachableCode": false, + "allowUnusedLabels": false, + "noImplicitAny": false, + "noImplicitReturns": false, + "noImplicitUseStrict": false, + "noFallthroughCasesInSwitch": true, + "outDir": "dist" + }, + "exclude": [ + "demo", + "node_modules", + "typings/main", + "typings/main.d.ts", + "dist" + ] +} diff --git a/ng2-components/ng2-alfresco-userinfo/tslint.json b/ng2-components/ng2-alfresco-userinfo/tslint.json new file mode 100644 index 0000000000..33220e5038 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/tslint.json @@ -0,0 +1,121 @@ +{ + "rules": { + "align": [ + true, + "parameters", + "statements" + ], + "ban": false, + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "curly": true, + "eofline": true, + "forin": true, + "indent": [ + true, + "spaces" + ], + "interface-name": false, + "jsdoc-format": true, + "label-position": true, + "label-undefined": true, + "max-line-length": [ + true, + 140 + ], + "member-ordering": [ + true, + "static-before-instance", + "variables-before-functions" + ], + "no-any": false, + "no-arg": true, + "no-bitwise": false, + "no-conditional-assignment": true, + "no-consecutive-blank-lines": false, + "no-console": [ + true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-construct": true, + "no-constructor-vars": false, + "no-debugger": true, + "no-duplicate-key": true, + "no-duplicate-variable": true, + "no-empty": false, + "no-eval": true, + "no-inferrable-types": false, + "no-internal-module": true, + "no-require-imports": true, + "no-shadowed-variable": true, + "no-switch-case-fall-through": true, + "no-trailing-whitespace": true, + "no-unreachable": true, + "no-unused-expression": true, + "no-unused-variable": true, + "no-use-before-declare": true, + "no-var-keyword": true, + "no-var-requires": true, + "object-literal-sort-keys": false, + "one-line": [ + true, + "check-open-brace", + "check-catch", + "check-else", + "check-whitespace" + ], + "quotemark": [ + true, + "single", + "avoid-escape" + ], + "radix": true, + "semicolon": true, + "switch-default": true, + "trailing-comma": [ + true, + { + "multiline": "never", + "singleline": "never" + } + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "typedef": false, + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "use-strict": false, + "variable-name": [ + true, + "check-format", + "allow-leading-underscore", + "ban-keywords" + ], + "whitespace": [ + true, + "check-branch", + "check-operator", + "check-separator", + "check-type", + "check-module", + "check-decl" + ] + } +} diff --git a/ng2-components/ng2-alfresco-userinfo/typings.json b/ng2-components/ng2-alfresco-userinfo/typings.json new file mode 100644 index 0000000000..7e0e18568d --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/typings.json @@ -0,0 +1,7 @@ +{ + "globalDependencies": { + "core-js": "registry:dt/core-js#0.0.0+20160317120654", + "jasmine": "registry:dt/jasmine#2.2.0+20160505161446", + "node": "registry:dt/node#4.0.0+20160509154515" + } +} From 86e5b3f1e5fca6129266b4c699e159b73b6c0af9 Mon Sep 17 00:00:00 2001 From: Vito Albano Date: Mon, 19 Sep 2016 11:53:55 +0100 Subject: [PATCH 02/26] Add BPM user logged in --- .../ng2-alfresco-userinfo/demo/src/main.ts | 35 ++--- .../src/models/bpmUser.model.ts | 39 +++++ .../src/services/bpmUser.service.ts | 65 ++++++++ .../src/services/ecmUser.service.ts | 4 +- .../src/userinfo.component.html | 140 +++++++++++++++++- .../src/userinfo.component.ts | 41 +++-- 6 files changed, 288 insertions(+), 36 deletions(-) create mode 100644 ng2-components/ng2-alfresco-userinfo/src/models/bpmUser.model.ts create mode 100644 ng2-components/ng2-alfresco-userinfo/src/services/bpmUser.service.ts diff --git a/ng2-components/ng2-alfresco-userinfo/demo/src/main.ts b/ng2-components/ng2-alfresco-userinfo/demo/src/main.ts index 8801ffcb21..a7c5c03cb1 100644 --- a/ng2-components/ng2-alfresco-userinfo/demo/src/main.ts +++ b/ng2-components/ng2-alfresco-userinfo/demo/src/main.ts @@ -11,7 +11,7 @@ import { @Component({ selector: 'my-app', - template: `

START

`, + template: `

START

`, directives: [ UserInfoComponent ], providers: [AlfrescoAuthenticationService, AlfrescoSettingsService] }) @@ -20,36 +20,31 @@ import { class UserInfoDemo implements OnInit { private authenticated: boolean; - private ticket: string; - // private ecmHost: string; + private token: any; constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) { - this.settingsService.setProviders('ECM'); + this.settingsService.setProviders('ALL'); } public ngOnInit(): void { this.login(); } - login() { - this.authService.login('test', 'test').subscribe( - ticket => { - console.log(ticket); - this.ticket = this.authService.getTicketEcm(); - this.authenticated = true; - }, - error => { - console.log(error); - this.authenticated = false; - }); - } + login() { + this.authService.login('test', 'test').subscribe( + token => { + console.log(token); + this.token = token; + this.authenticated = true; + }, + error => { + console.log(error); + this.authenticated = false; + }); + } } - - - - bootstrap(UserInfoDemo, [ UserInfoComponent, HTTP_PROVIDERS, diff --git a/ng2-components/ng2-alfresco-userinfo/src/models/bpmUser.model.ts b/ng2-components/ng2-alfresco-userinfo/src/models/bpmUser.model.ts new file mode 100644 index 0000000000..3ee3fd7222 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/src/models/bpmUser.model.ts @@ -0,0 +1,39 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed 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. + */ + +export class BpmUserModel { + apps: any; + capabilities: string; + company: string; + created: string; + email: string; + externalId: string; + firstName: string; + lastName: string; + fullname: string; + groups: any; + id: string; + lastUpdate: string; + latestSyncTimeStamp: string; + password: string; + pictureId: string; + status: string; + tenantId: string; + tenantName: string; + tenantPictureId: string; + type: string; +} diff --git a/ng2-components/ng2-alfresco-userinfo/src/services/bpmUser.service.ts b/ng2-components/ng2-alfresco-userinfo/src/services/bpmUser.service.ts new file mode 100644 index 0000000000..593079a8cf --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/src/services/bpmUser.service.ts @@ -0,0 +1,65 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed 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. + */ + +import { AlfrescoAuthenticationService } from 'ng2-alfresco-core'; +import { Injectable } from '@angular/core'; +import { Response } from '@angular/http'; +import { Observable } from 'rxjs/Observable'; +import { BpmUserModel } from '../models/bpmUser.model'; +/** + * + * BPMUserService retrieve all the information of an Ecm user. + * + * @returns {BPMUserService} . + */ +@Injectable() +export class BPMUserService { + + constructor(public authService: AlfrescoAuthenticationService) {} + + /** + * get User Information via ECM + * @param userName - the user name + */ + getCurrentUserInfo(): Observable { + return Observable.fromPromise(this.callApiGetProfile()) + .map( + data => data + ) + .do( + data => console.log('Node data', data) + ) // eyeball results in the console + .catch(this.handleError); + } + + private callApiGetProfile() { + return this.authService.getAlfrescoApi().activiti.profileApi.getProfile(); + } + + /** + * Throw the error + * @param error + * @returns {ErrorObservable} + */ + private handleError(error: Response) { + // in a real world app, we may send the error to some remote logging infrastructure + // instead of just logging it to the console + console.error(error); + return Observable.throw(error || 'Server error'); + } + +} diff --git a/ng2-components/ng2-alfresco-userinfo/src/services/ecmUser.service.ts b/ng2-components/ng2-alfresco-userinfo/src/services/ecmUser.service.ts index f6d237ecd6..dbb005892a 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/services/ecmUser.service.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/services/ecmUser.service.ts @@ -37,9 +37,9 @@ export class ECMUserService { */ getUserInfo(userName: string): Observable { return Observable.fromPromise(this.callApiGetPersonInfo(userName)) - .map( data => data ) + .map( data => data['entry']) .do( - data => console.log('Node data', data) + data => console.log('Node data', data['entry']) ) // eyeball results in the console .catch(this.handleError); } diff --git a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html index 116e372f29..4a1c172487 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html +++ b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html @@ -1 +1,139 @@ -
TEST
+
+
+ +
+ ECM + BPM +
+ + +
+
    +
  • + + person + {{ecmUser.firstName}} {{ecmUser.lastName}} + +
  • +
  • + Id: + +
  • +
  • + Description: + +
  • +
  • + Email: + +
  • +
  • + Skype Id: + +
  • +
  • + Google Id: + +
  • +
  • + Instant Message Id: + +
  • +
  • + Job Title: + +
  • +
  • + Location: + +
  • +
  • + Mobile: + +
  • +
  • + Telephone: + +
  • +
  • + User Status: + +
  • +
  • + Enabled: + +
  • +
  • + Email Notifications: + +
  • +
+
+
+
    +
  • + + person + {{bpmUser.fullname}} + +
  • +
  • + Id: + +
  • +
  • + Email: + +
  • +
  • + Status: + +
  • +
  • + Tenant Name: + +
  • +
  • + Company: + +
  • +
+
+
+
diff --git a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.ts b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.ts index ccf3384bac..f29d945b8e 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.ts @@ -1,31 +1,46 @@ -import { Component } from '@angular/core'; +import { Component, OnInit, Input } from '@angular/core'; import { ECMUserService } from './services/ecmUser.service'; +import { BPMUserService } from './services/bpmUser.service'; import { EcmUserModel } from './models/ecmUser.model'; +import { BpmUserModel } from './models/bpmUser.model'; +import { AlfrescoContentService } from 'ng2-alfresco-core'; + +declare let __moduleName: string; @Component({ selector: 'ng2-alfresco-userinfo', + moduleId: __moduleName, styles: [`:host h1 { font-size:22px }`], - template: `

Hello World Angular 2 ng2-alfresco-userinfo

`, - providers: [ ECMUserService ] + templateUrl: './userinfo.component.html', + providers: [ ECMUserService, BPMUserService, AlfrescoContentService ] }) +export class UserInfoComponent implements OnInit { -export class UserInfoComponent { + @Input() + userEmail: string; private ecmUser: EcmUserModel; + private bpmUser: BpmUserModel; - constructor(private ecmUserService: ECMUserService) { - console.log('User info component constr'); + constructor(private ecmUserService: ECMUserService, + private bpmUserService: BPMUserService, + private contentService: AlfrescoContentService) { } - doQueryUser() { - this.ecmUserService.getUserInfo('admin') - .subscribe( - res => this.ecmUser = res.entry - ); + ngOnInit() { + this.ecmUserService.getUserInfo(this.userEmail) + .subscribe( + res => this.ecmUser = res + ); + this.bpmUserService.getCurrentUserInfo() + .subscribe( + res => this.bpmUser = res + ); } - - + public getDocumentThumbnailUrl(avatarId: string): string { + return this.contentService.getDocumentThumbnailUrl(document); + } } From a8c7486a26d57416b2c3df8c3dc8605d3214fed3 Mon Sep 17 00:00:00 2001 From: Vito Albano Date: Tue, 20 Sep 2016 17:03:13 +0100 Subject: [PATCH 03/26] Added the change for user image --- .../components/profile/AboutComponent.java | 55 +++++++ .../components/profile/profile.component.html | 0 .../components/profile/profile.component.ts | 0 .../ng2-alfresco-userinfo/demo/src/main.ts | 106 +++++++++++-- .../src/img/anonymous.gif | Bin 0 -> 1765 bytes .../src/services/bpmUser.service.ts | 19 ++- .../src/services/ecmUser.service.ts | 2 +- .../src/userinfo.component.css | 14 ++ .../src/userinfo.component.html | 144 +----------------- .../src/userinfo.component.ts | 60 +++++++- 10 files changed, 239 insertions(+), 161 deletions(-) create mode 100644 demo-shell-ng2/app/components/profile/AboutComponent.java create mode 100644 demo-shell-ng2/app/components/profile/profile.component.html create mode 100644 demo-shell-ng2/app/components/profile/profile.component.ts create mode 100644 ng2-components/ng2-alfresco-userinfo/src/img/anonymous.gif create mode 100644 ng2-components/ng2-alfresco-userinfo/src/userinfo.component.css diff --git a/demo-shell-ng2/app/components/profile/AboutComponent.java b/demo-shell-ng2/app/components/profile/AboutComponent.java new file mode 100644 index 0000000000..30b667a14a --- /dev/null +++ b/demo-shell-ng2/app/components/profile/AboutComponent.java @@ -0,0 +1,55 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed 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. + */ + +import { Component, OnInit } from '@angular/core'; +import { Http } from '@angular/http'; +import { + ALFRESCO_DATATABLE_DIRECTIVES, + ObjectDataTableAdapter /*, + DataSorting, + ObjectDataRow, + ObjectDataColumn*/ +} from 'ng2-alfresco-datatable'; + +declare let __moduleName: string; + +@Component({ + moduleId: __moduleName, + selector: 'about-page', + templateUrl: './about.component.html', + directives: [ALFRESCO_DATATABLE_DIRECTIVES] +}) +export class AboutComponent implements OnInit { + + data: ObjectDataTableAdapter; + + constructor(private http: Http) {} + + ngOnInit() { + // this.data = new ObjectDataTableAdapter(); + this.http.get('/versions').subscribe(response => { + let data = response.json() || {}; + let packages = data.packages || []; + + this.data = new ObjectDataTableAdapter(packages, [ + { type: 'text', key: 'name', title: 'Name', sortable: true }, + { type: 'text', key: 'version', title: 'Version', sortable: true } + ]); + }); + + } +} diff --git a/demo-shell-ng2/app/components/profile/profile.component.html b/demo-shell-ng2/app/components/profile/profile.component.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/demo-shell-ng2/app/components/profile/profile.component.ts b/demo-shell-ng2/app/components/profile/profile.component.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ng2-components/ng2-alfresco-userinfo/demo/src/main.ts b/ng2-components/ng2-alfresco-userinfo/demo/src/main.ts index a7c5c03cb1..5e5ff8772c 100644 --- a/ng2-components/ng2-alfresco-userinfo/demo/src/main.ts +++ b/ng2-components/ng2-alfresco-userinfo/demo/src/main.ts @@ -11,7 +11,43 @@ import { @Component({ selector: 'my-app', - template: `

START

`, + styles: [`:host h1 { font-size:22px }`], + template: ` +

START DEMO USERINFO

+
+

+ +

+

+ +

+
+
+ +
+

+
+

+ Username + +

+

+ Password + +

+ +
+{{loginErrorMessage}} + +`, directives: [ UserInfoComponent ], providers: [AlfrescoAuthenticationService, AlfrescoSettingsService] }) @@ -19,30 +55,68 @@ import { class UserInfoDemo implements OnInit { + public userToLogin: string = 'admin'; + public password: string = 'admin'; + public loginErrorMessage: string; + public providers: string = 'BPM'; private authenticated: boolean; private token: any; constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) { - this.settingsService.setProviders('ALL'); } - public ngOnInit(): void { - this.login(); + ngOnInit() { + this.settingsService.setProviders(this.providers); } - login() { - this.authService.login('test', 'test').subscribe( - token => { - console.log(token); - this.token = token; - this.authenticated = true; - }, - error => { - console.log(error); - this.authenticated = false; - }); - } + attemptLogin() { + this.loginErrorMessage = ''; + this.login(this.userToLogin, this.password); + } + + logout() { + this.authService.logout(); + } + + login(user, password) { + this.settingsService.setProviders(this.providers); + this.authService.login(user, password).subscribe( + token => { + console.log(token); + this.token = token; + this.authenticated = true; + }, + error => { + console.log(error); + this.authenticated = false; + this.loginErrorMessage = error; + }); + } + + isLoggedIn(): boolean { + return this.authService.isLoggedIn(); + } + + toggleECM(checked) { + if (checked && this.providers === 'BPM') { + this.providers = 'ALL'; + } else if (checked) { + this.providers = 'ECM'; + } else { + this.providers = undefined; + } + } + + toggleBPM(checked) { + if (checked && this.providers === 'ECM') { + this.providers = 'ALL'; + } else if (checked) { + this.providers = 'BPM'; + } else { + this.providers = undefined; + } + } } bootstrap(UserInfoDemo, [ diff --git a/ng2-components/ng2-alfresco-userinfo/src/img/anonymous.gif b/ng2-components/ng2-alfresco-userinfo/src/img/anonymous.gif new file mode 100644 index 0000000000000000000000000000000000000000..e1b58fa57dfcdfd452ec498c98b930aa905d21d6 GIT binary patch literal 1765 zcmb8pizCyC0|4;vcMq|L=guW!Vi%c59pzQG$YVmt(9<&qUk|0_<~^#dpPrfJR`3LkEhFNwuD*UseB%E9NpnxZIwFun4Gh4>giwRA zc0?x^01y1ne**w~537AIAf!0BrjESujDjDc-khY>t=wMO?<%F(;}2yFR74Dt%}a)P zREJt`!8kwqm|RZoeK}|r3IHK##rgzkWXR z#*`{VI@~f{tInV0ukwK$G*WXf9#@J?Z!6r2$!xjap@7u(QUCMI;#?2#}9bcnDw%MSwt8tuX$>-NEJGdr(T*AtL&uqN~#WT z-g_QP^LsP+c=+}i&ztKwm?_}Wl%Vf);6;vy(fFPKq-Krf{zpQvQICg(?Ug@>Nx&U+ zjC*f3!1kFY4zS~t!;(qN5%NIU3H4v3)8o8SJ&}xYli-Iq9S6HVS;BT^QM6I<7xiew zs43F&{rZ7&()90DAGOE2XC;|(F#99fIapv)+E_ML>o!h2H=U!U*6L3=``J^Qqoo7W zf@~)ZW~T7YOjSR6)Sl9&+Nd*+aNRrksZvj^#`9rO9o8rC1d|21)u|F3inL-f#Wi}R<~|kmHN&5; z3B)yYe%YIv8;IuZpFayGV;%0-^uB2NgFe{gg7ft_xj^TT_Y{uR${^)A3ysIpSs39& z9ijG;m}vnKkiUg2%P?vsYQCJO@$_OV@CO0Hu)t)o;|R^??X%tO1-F=8j*)@eCsBO8 zi%eVFsxw-!Lvd0lwD|S>cPa5}M3u<4Tb}T$Ox;$^a_lM*m{i5Pu{oB{h2Ay`Po(Dx zD#N-MNvdBGX_`Lud8}5idh^1LixlXK&^sCJ@PI-IJn*VhrM|k_W5)x{ zzhbeqUP%h#MU{Oa-7EuT&#~1EiAPO=nPq4Rbk@D@* z6M~fh0C=qA2Fx`k=Mt6^izaq#br)QLk3CvAW9%+&^6yXaFr(JLRl%+P{?WF8(;BaX zE{t!)7R`6~pLq*@-8wtlZL#g$h)*e9)U%B{XxYCXGPN_V;k|Z!l;3$33aB3vZ~j!f z8jhOM^$Qdom4h>-B7!MgsLVCNNk__$82?`QspL*0zwl&CWb!J(Q;GX2gTXNKJLh7b zN8^5=;xVjOqw+n`ziQf<^ritlK&M(Z8LjoT%+`GX4nZhrFaHSbxJOg`KARNhh?nMx zGP`u#0?`@`N33T&?%+eSu$L?L=-+paXBat?0s^Lq(6>66KiD9fJaJdGPrldmp)ES9 zq5Q@w&+dWzairp+mQ9lhlYn@l$-pFQ%6Vm;W0F$S`6)^oDnz!UA}W)wZD#Nf-02yE zSxiRiSbJrnHZpS2^QFqWDWYiJ2_&D4GxJTob6game4Rnp4-a8oK0|uY-oP;ACYJg= zfzq$)JUSkdEEQ-FsXFl0O1;D@^(Svq!Dtb~|zD{Xe%&8EA}t;;Z>bJpL9WgQD_~sHG5(h>mr{Irog}T$u=eqGe-Q&yn=bw z7r-~(&JD^vmmxkz!hBa8Ik(`jlhvudkmrW!#)Y{1Gd3YvBL>qqDmh!%F}{e44g(m3 zaqT=bY?~3aCoJ(;oj;Ql3NL$?!}~e$!?~b?QkCYp)qa#vtFm`QZozZZrH&eTD*&+g E7ZAQxl>h($ literal 0 HcmV?d00001 diff --git a/ng2-components/ng2-alfresco-userinfo/src/services/bpmUser.service.ts b/ng2-components/ng2-alfresco-userinfo/src/services/bpmUser.service.ts index 593079a8cf..455e04bd70 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/services/bpmUser.service.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/services/bpmUser.service.ts @@ -18,7 +18,7 @@ import { AlfrescoAuthenticationService } from 'ng2-alfresco-core'; import { Injectable } from '@angular/core'; import { Response } from '@angular/http'; -import { Observable } from 'rxjs/Observable'; +import { Observable } from 'rxjs/Rx'; import { BpmUserModel } from '../models/bpmUser.model'; /** * @@ -46,10 +46,25 @@ export class BPMUserService { .catch(this.handleError); } + /** + * get User Information via ECM + * @param userName - the user name + */ + getCurrentUserProfileImage(): Observable { + return Observable.fromPromise(this.callApiGetProfileImage()) + .do( + data => console.log('Node data', data) + ) // eyeball results in the console + .catch(this.handleError); + } + + private callApiGetProfileImage() { + return this.authService.getAlfrescoApi().activiti.profileApi.getProfilePicture(); + } + private callApiGetProfile() { return this.authService.getAlfrescoApi().activiti.profileApi.getProfile(); } - /** * Throw the error * @param error diff --git a/ng2-components/ng2-alfresco-userinfo/src/services/ecmUser.service.ts b/ng2-components/ng2-alfresco-userinfo/src/services/ecmUser.service.ts index dbb005892a..1f6dd6c7d5 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/services/ecmUser.service.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/services/ecmUser.service.ts @@ -18,7 +18,7 @@ import { AlfrescoApiService } from 'ng2-alfresco-core'; import { Injectable } from '@angular/core'; import { Response } from '@angular/http'; -import { Observable } from 'rxjs/Observable'; +import { Observable } from 'rxjs/Rx'; import { EcmUserModel } from '../models/ecmUser.model'; /** * diff --git a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.css b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.css new file mode 100644 index 0000000000..9f59213ab7 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.css @@ -0,0 +1,14 @@ +.profile-image { + text-align: center; + border-radius: 90%; + width: 40px; + margin-right: 0%; + cursor: pointer; + border: 2px solid #999999; +} + +.button-profile { + display: inline-block; + margin-right: -10px; + border: 0px; +} diff --git a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html index 4a1c172487..153b90b6bd 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html +++ b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html @@ -1,139 +1,9 @@ -
-
- -
- ECM - BPM -
- - -
-
    -
  • - - person - {{ecmUser.firstName}} {{ecmUser.lastName}} - -
  • -
  • - Id: - -
  • -
  • - Description: - -
  • -
  • - Email: - -
  • -
  • - Skype Id: - -
  • -
  • - Google Id: - -
  • -
  • - Instant Message Id: - -
  • -
  • - Job Title: - -
  • -
  • - Location: - -
  • -
  • - Mobile: - -
  • -
  • - Telephone: - -
  • -
  • - User Status: - -
  • -
  • - Enabled: - -
  • -
  • - Email Notifications: - -
  • -
-
-
-
    -
  • - - person - {{bpmUser.fullname}} - -
  • -
  • - Id: - -
  • -
  • - Email: - -
  • -
  • - Status: - -
  • -
  • - Tenant Name: - -
  • -
  • - Company: - -
  • -
+
+
+ {{ecmUser.firstName}} {{ecmUser.lastName}} + {{bpmUser.fullname}} +
-
diff --git a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.ts b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.ts index f29d945b8e..49f38942f0 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.ts @@ -1,3 +1,19 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed 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. + */ import { Component, OnInit, Input } from '@angular/core'; import { ECMUserService } from './services/ecmUser.service'; @@ -11,7 +27,7 @@ declare let __moduleName: string; @Component({ selector: 'ng2-alfresco-userinfo', moduleId: __moduleName, - styles: [`:host h1 { font-size:22px }`], + styleUrls: ['./userinfo.component.css'], templateUrl: './userinfo.component.html', providers: [ ECMUserService, BPMUserService, AlfrescoContentService ] }) @@ -23,6 +39,10 @@ export class UserInfoComponent implements OnInit { private ecmUser: EcmUserModel; private bpmUser: BpmUserModel; + public bpmUserImage: any; + public ecmUserImage: any; + + private baseComponentPath = __moduleName.replace('userinfo.component.js', ''); constructor(private ecmUserService: ECMUserService, private bpmUserService: BPMUserService, @@ -32,15 +52,45 @@ export class UserInfoComponent implements OnInit { ngOnInit() { this.ecmUserService.getUserInfo(this.userEmail) .subscribe( - res => this.ecmUser = res + res => { + this.ecmUser = res; + this.getUserProfileImage(); + console.log(this.ecmUserImage); + } ); this.bpmUserService.getCurrentUserInfo() .subscribe( - res => this.bpmUser = res + res => { + this.bpmUser = res; + } ); + } - public getDocumentThumbnailUrl(avatarId: string): string { - return this.contentService.getDocumentThumbnailUrl(document); + private getUserProfileImage() { + if (this.ecmUser && this.ecmUser.avatarId) { + let nodeObj = { entry: { id: this.ecmUser.avatarId } }; + this.ecmUserImage = this.contentService.getContentUrl(nodeObj); + } + if (this.bpmUser) { + this.bpmUserService.getCurrentUserProfileImage() + .subscribe( + res => this.bpmUserImage = res + ); + } } + + public getUserAvatar() { + if (this.ecmUserImage) { + return this.ecmUserImage; + } + if (this.bpmUserImage) { + return this.bpmUserImage; + } + if (!this.ecmUserImage && !this.bpmUserImage) { + return this.baseComponentPath + '/img/anonymous.gif'; + } + } + + } From 3b6b8ed59b3ae06428d937b4691e80f492b062e4 Mon Sep 17 00:00:00 2001 From: Vito Albano Date: Thu, 22 Sep 2016 01:14:15 +0100 Subject: [PATCH 04/26] Added some upgrades to demo and added the component to demo shell --- demo-shell-ng2/app/app.component.html | 4 + .../components/profile/profile.component.ts | 16 ++++ .../ng2-alfresco-upload/demo/index.html | 1 + .../ng2-alfresco-userinfo/demo/index.html | 3 +- .../ng2-alfresco-userinfo/demo/package.json | 47 +++++++---- .../ng2-alfresco-userinfo/demo/src/main.ts | 5 +- .../ng2-alfresco-userinfo/package.json | 51 ++++++------ .../src/services/bpmUser.service.ts | 38 +++++---- .../src/services/ecmUser.service.ts | 16 +++- .../src/userinfo.component.html | 25 +++--- .../src/userinfo.component.ts | 80 +++++++++---------- 11 files changed, 167 insertions(+), 119 deletions(-) diff --git a/demo-shell-ng2/app/app.component.html b/demo-shell-ng2/app/app.component.html index e4b21d6861..d8131ce30b 100644 --- a/demo-shell-ng2/app/app.component.html +++ b/demo-shell-ng2/app/app.component.html @@ -21,6 +21,10 @@ Login +
+ +
+ `, directives: [ UserInfoComponent ], - providers: [AlfrescoAuthenticationService, AlfrescoSettingsService] + providers: [AlfrescoAuthenticationService, AlfrescoSettingsService, MDL] }) diff --git a/ng2-components/ng2-alfresco-userinfo/package.json b/ng2-components/ng2-alfresco-userinfo/package.json index 34b6de40e7..538102137b 100644 --- a/ng2-components/ng2-alfresco-userinfo/package.json +++ b/ng2-components/ng2-alfresco-userinfo/package.json @@ -4,9 +4,7 @@ "version": "0.1.0", "author": "vito albano ", "scripts": { - "postinstall": "typings install", - "clean": "rimraf dist node_modules typings", - "typings": "typings install", + "clean": "rimraf dist node_modules", "license-check": "echo 'license check is disabled'", "build": "npm run tslint && rimraf dist && tsc && npm run copy-dist && npm run license-check", "build:w": "npm run tslint && rimraf dist && npm run watch-task", @@ -21,7 +19,6 @@ "test-browser": "npm run build && concurrently \"karma start karma.conf.js --reporters kjhtml\" \"npm run watch-task\"", "posttest": "remap-istanbul -i coverage/report/coverage-final.json -o coverage/report -t html && remap-istanbul -i coverage/report/coverage-final.json -o coverage/report/coverage-final.json", "coverage": "npm run test && wsrv -o -p 9875 ./coverage/report", - "prepublish": "npm run build", "travis": "echo 'placeholder'" }, "main": "./dist/index.js", @@ -33,10 +30,13 @@ "bugs": { "url": "https://github.com/alfresco/ng2-alfresco-userinfo/issues" }, + "dependencies": { + "alfresco-js-api": "^0.3.0", "@angular/common": "2.0.0-rc.3", "@angular/compiler": "2.0.0-rc.3", "@angular/core": "2.0.0-rc.3", + "@angular/forms": "0.1.1", "@angular/http": "2.0.0-rc.3", "@angular/platform-browser": "2.0.0-rc.3", "@angular/platform-browser-dynamic": "2.0.0-rc.3", @@ -44,34 +44,35 @@ "@angular/router-deprecated": "2.0.0-rc.2", "@angular/upgrade": "2.0.0-rc.3", "systemjs": "0.19.27", - "core-js": "^2.4.0", - "reflect-metadata": "^0.1.3", + "core-js": "2.4.0", + "reflect-metadata": "0.1.3", "rxjs": "5.0.0-beta.6", - "zone.js": "^0.6.12", + "zone.js": "0.6.12", "ng2-translate": "2.2.2", - "alfresco-js-api": "^0.3.0", - "ng2-alfresco-core": "0.3.2" + "ng2-alfresco-core": "0.3.2", + "material-design-icons": "2.2.3", + "material-design-lite": "1.1.3" }, "devDependencies": { - "angular-cli": "1.0.0-beta.9", - "concurrently": "^2.1.0", - "cpx": "^1.3.1", - "jasmine-ajax": "^3.2.0", + "@types/core-js": "^0.9.32", + "@types/jasmine": "^2.2.33", + "cpx": "1.3.1", + "jasmine-ajax": "3.2.0", "jasmine-core": "2.4.1", - "karma": "~0.13.22", - "karma-chrome-launcher": "~1.0.1", - "karma-coverage": "^1.0.0", - "karma-jasmine": "~1.0.2", + "karma": "0.13.22", + "karma-chrome-launcher": "1.0.1", + "karma-coverage": "1.0.0", + "karma-jasmine": "1.0.2", "karma-jasmine-ajax": "^0.1.13", - "karma-jasmine-html-reporter": "^0.2.0", - "karma-mocha-reporter": "^2.0.3", - "remap-istanbul": "^0.6.3", + "karma-jasmine-html-reporter": "0.2.0", + "karma-mocha-reporter": "2.0.3", + "license-check": "1.1.5", + "remap-istanbul": "0.6.3", "rimraf": "2.5.2", - "traceur": "^0.0.91", - "tslint": "^3.8.1", - "typescript": "^1.8.10", - "typings": "^1.0.4", - "wsrv": "^0.1.3" + "traceur": "0.0.91", + "tslint": "3.8.1", + "typescript": "^2.0.2", + "wsrv": "^0.1.5" }, "keywords": [ "component", diff --git a/ng2-components/ng2-alfresco-userinfo/src/services/bpmUser.service.ts b/ng2-components/ng2-alfresco-userinfo/src/services/bpmUser.service.ts index 455e04bd70..5d3f2bd163 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/services/bpmUser.service.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/services/bpmUser.service.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { AlfrescoAuthenticationService } from 'ng2-alfresco-core'; +import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core'; import { Injectable } from '@angular/core'; import { Response } from '@angular/http'; import { Observable } from 'rxjs/Rx'; @@ -29,37 +29,35 @@ import { BpmUserModel } from '../models/bpmUser.model'; @Injectable() export class BPMUserService { - constructor(public authService: AlfrescoAuthenticationService) {} + constructor(private authService: AlfrescoAuthenticationService, + private settingService: AlfrescoSettingsService) { + } /** * get User Information via ECM * @param userName - the user name */ getCurrentUserInfo(): Observable { - return Observable.fromPromise(this.callApiGetProfile()) - .map( - data => data - ) - .do( - data => console.log('Node data', data) - ) // eyeball results in the console - .catch(this.handleError); + if ( this.authService.getAlfrescoApi().bpmAuth.isLoggedIn() ) { + return Observable.fromPromise(this.callApiGetProfile()) + .map( + data => data + ) + .do( + data => console.log('Node data', data) + ) // eyeball results in the console + .catch(this.handleError); + } } /** * get User Information via ECM * @param userName - the user name */ - getCurrentUserProfileImage(): Observable { - return Observable.fromPromise(this.callApiGetProfileImage()) - .do( - data => console.log('Node data', data) - ) // eyeball results in the console - .catch(this.handleError); - } - - private callApiGetProfileImage() { - return this.authService.getAlfrescoApi().activiti.profileApi.getProfilePicture(); + getCurrentUserProfileImage(): string { + if ( this.authService.getAlfrescoApi().bpmAuth.isLoggedIn() ) { + return this.settingService.getBPMApiBaseUrl() + '/api/enterprise/profile-picture'; + } } private callApiGetProfile() { diff --git a/ng2-components/ng2-alfresco-userinfo/src/services/ecmUser.service.ts b/ng2-components/ng2-alfresco-userinfo/src/services/ecmUser.service.ts index 1f6dd6c7d5..e85f34b116 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/services/ecmUser.service.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/services/ecmUser.service.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { AlfrescoApiService } from 'ng2-alfresco-core'; +import { AlfrescoAuthenticationService, AlfrescoContentService } from 'ng2-alfresco-core'; import { Injectable } from '@angular/core'; import { Response } from '@angular/http'; import { Observable } from 'rxjs/Rx'; @@ -29,23 +29,33 @@ import { EcmUserModel } from '../models/ecmUser.model'; @Injectable() export class ECMUserService { - constructor(private apiService: AlfrescoApiService) {} + constructor(private authService: AlfrescoAuthenticationService, + private contentService: AlfrescoContentService) {} /** * get User Information via ECM * @param userName - the user name */ getUserInfo(userName: string): Observable { + if ( this.authService.getAlfrescoApi().ecmAuth.isLoggedIn() ) { return Observable.fromPromise(this.callApiGetPersonInfo(userName)) .map( data => data['entry']) .do( data => console.log('Node data', data['entry']) ) // eyeball results in the console .catch(this.handleError); + } } private callApiGetPersonInfo(userName: string, opts?: any) { - return this.apiService.getInstance().core.peopleApi.getPerson(userName, opts); + return this.authService.getAlfrescoApi().core.peopleApi.getPerson(userName, opts); + } + + getCurrentUserProfileImageUrl(avatarId: string) { + if ( avatarId ) { + let nodeObj = {entry: {id: avatarId}}; + return this.contentService.getContentUrl(nodeObj); + } } /** diff --git a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html index 153b90b6bd..bf39e21403 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html +++ b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html @@ -1,9 +1,16 @@ -
-
- {{ecmUser.firstName}} {{ecmUser.lastName}} - {{bpmUser.fullname}} - -
-
+{{ecmUser.firstName}} {{ecmUser.lastName}} +{{bpmUser.fullname}} + + +
    +
  • Some Action
  • +
  • Another Action
  • +
  • Disabled Action
  • +
  • Yet Another Action
  • +
diff --git a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.ts b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.ts index 49f38942f0..20becdb6b3 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.ts @@ -15,12 +15,12 @@ * limitations under the License. */ -import { Component, OnInit, Input } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { ECMUserService } from './services/ecmUser.service'; import { BPMUserService } from './services/bpmUser.service'; import { EcmUserModel } from './models/ecmUser.model'; import { BpmUserModel } from './models/bpmUser.model'; -import { AlfrescoContentService } from 'ng2-alfresco-core'; +import { AlfrescoAuthenticationService } from 'ng2-alfresco-core'; declare let __moduleName: string; @@ -29,14 +29,11 @@ declare let __moduleName: string; moduleId: __moduleName, styleUrls: ['./userinfo.component.css'], templateUrl: './userinfo.component.html', - providers: [ ECMUserService, BPMUserService, AlfrescoContentService ] + providers: [ECMUserService, BPMUserService, AlfrescoAuthenticationService] }) export class UserInfoComponent implements OnInit { - @Input() - userEmail: string; - private ecmUser: EcmUserModel; private bpmUser: BpmUserModel; public bpmUserImage: any; @@ -46,51 +43,48 @@ export class UserInfoComponent implements OnInit { constructor(private ecmUserService: ECMUserService, private bpmUserService: BPMUserService, - private contentService: AlfrescoContentService) { + public authService: AlfrescoAuthenticationService) { } ngOnInit() { - this.ecmUserService.getUserInfo(this.userEmail) - .subscribe( - res => { - this.ecmUser = res; - this.getUserProfileImage(); - console.log(this.ecmUserImage); - } - ); - this.bpmUserService.getCurrentUserInfo() - .subscribe( - res => { - this.bpmUser = res; - } - ); - + if (this.authService.getAlfrescoApi().ecmAuth.isLoggedIn()) { + this.ecmUserService.getUserInfo('-me-') + .subscribe( + (res) => { + this.ecmUser = res; + this.getUserProfileImage(); + } + ); + } + if (this.authService.getAlfrescoApi().bpmAuth.isLoggedIn()) { + this.bpmUserService.getCurrentUserInfo() + .subscribe( + (res) => { + this.bpmUser = res; + this.getUserProfileImage(); + } + ); + } } private getUserProfileImage() { - if (this.ecmUser && this.ecmUser.avatarId) { - let nodeObj = { entry: { id: this.ecmUser.avatarId } }; - this.ecmUserImage = this.contentService.getContentUrl(nodeObj); - } - if (this.bpmUser) { - this.bpmUserService.getCurrentUserProfileImage() - .subscribe( - res => this.bpmUserImage = res - ); - } + if (this.ecmUser) { + this.ecmUserImage = this.ecmUserService.getCurrentUserProfileImageUrl(this.ecmUser.avatarId); + } + if (this.bpmUser) { + this.bpmUserImage = this.bpmUserService.getCurrentUserProfileImage(); + } } public getUserAvatar() { - if (this.ecmUserImage) { - return this.ecmUserImage; - } - if (this.bpmUserImage) { - return this.bpmUserImage; - } - if (!this.ecmUserImage && !this.bpmUserImage) { - return this.baseComponentPath + '/img/anonymous.gif'; - } + if (this.ecmUserImage) { + return this.ecmUserImage; + } + if (this.bpmUserImage) { + return this.bpmUserImage; + } + if (!this.ecmUserImage && !this.bpmUserImage) { + return this.baseComponentPath + '/img/anonymous.gif'; + } } - - } From 9ed232df5b1ac869d8108aace23f06a6b1c1da6b Mon Sep 17 00:00:00 2001 From: Vito Albano Date: Fri, 23 Sep 2016 00:04:03 +0100 Subject: [PATCH 05/26] Added fix for first component style --- demo-shell-ng2/app/app.component.css | 3 + demo-shell-ng2/app/app.component.html | 2 +- .../src/userinfo.component.css | 12 ++- .../src/userinfo.component.html | 74 +++++++++++++++---- .../src/userinfo.component.ts | 31 +++----- 5 files changed, 85 insertions(+), 37 deletions(-) diff --git a/demo-shell-ng2/app/app.component.css b/demo-shell-ng2/app/app.component.css index 700caa1af0..cdfe6eb2e7 100644 --- a/demo-shell-ng2/app/app.component.css +++ b/demo-shell-ng2/app/app.component.css @@ -7,3 +7,6 @@ .mdl-layout-title{ font-size: 17px; } +.user-profile{ + margin-right: 3px; +} \ No newline at end of file diff --git a/demo-shell-ng2/app/app.component.html b/demo-shell-ng2/app/app.component.html index d8131ce30b..463e250c35 100644 --- a/demo-shell-ng2/app/app.component.html +++ b/demo-shell-ng2/app/app.component.html @@ -21,7 +21,7 @@ Login -
+ diff --git a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.css b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.css index 9f59213ab7..bcd1bc0bca 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.css +++ b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.css @@ -4,11 +4,19 @@ width: 40px; margin-right: 0%; cursor: pointer; - border: 2px solid #999999; + border: 1px solid #999999; } .button-profile { display: inline-block; - margin-right: -10px; border: 0px; } + +.detail-user-profile-list-mdl{ + margin-right: 100px; +} + +.user-profile-list-mdl{ + max-height: 250px; + width: 400px; +} diff --git a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html index bf39e21403..5437e89627 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html +++ b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html @@ -1,16 +1,60 @@ -{{ecmUser.firstName}} {{ecmUser.lastName}} -{{bpmUser.fullname}} - +
+ {{ecmUser.firstName || ecmUser.lastName}} + {{bpmUser.firstName || bpmUser.lastName || bpmUser.fullName}} +
+ +
+ +
+ -
    -
  • Some Action
  • -
  • Another Action
  • -
  • Disabled Action
  • -
  • Yet Another Action
  • -
diff --git a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.ts b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.ts index 20becdb6b3..4ed268af9b 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.ts @@ -36,10 +36,11 @@ export class UserInfoComponent implements OnInit { private ecmUser: EcmUserModel; private bpmUser: BpmUserModel; + private baseComponentPath = __moduleName.replace('userinfo.component.js', ''); + private anonymouseImageUrl: string = this.baseComponentPath + 'img/anonymous.gif'; public bpmUserImage: any; public ecmUserImage: any; - private baseComponentPath = __moduleName.replace('userinfo.component.js', ''); constructor(private ecmUserService: ECMUserService, private bpmUserService: BPMUserService, @@ -52,7 +53,7 @@ export class UserInfoComponent implements OnInit { .subscribe( (res) => { this.ecmUser = res; - this.getUserProfileImage(); + this.getEcmUserProfileImage(); } ); } @@ -61,30 +62,22 @@ export class UserInfoComponent implements OnInit { .subscribe( (res) => { this.bpmUser = res; - this.getUserProfileImage(); + this.getBpmUserProfileImage(); } ); } } - private getUserProfileImage() { - if (this.ecmUser) { - this.ecmUserImage = this.ecmUserService.getCurrentUserProfileImageUrl(this.ecmUser.avatarId); - } - if (this.bpmUser) { - this.bpmUserImage = this.bpmUserService.getCurrentUserProfileImage(); - } + private getBpmUserProfileImage() { + this.bpmUserImage = this.bpmUserService.getCurrentUserProfileImage(); + } + + private getEcmUserProfileImage() { + this.ecmUserImage = this.ecmUserService.getCurrentUserProfileImageUrl(this.ecmUser.avatarId); } public getUserAvatar() { - if (this.ecmUserImage) { - return this.ecmUserImage; - } - if (this.bpmUserImage) { - return this.bpmUserImage; - } - if (!this.ecmUserImage && !this.bpmUserImage) { - return this.baseComponentPath + '/img/anonymous.gif'; - } + return this.ecmUserImage || this.bpmUserImage || this.anonymouseImageUrl; } + } From b68e07286c00237a2e786f4f3fe464a9979c8086 Mon Sep 17 00:00:00 2001 From: Vito Albano Date: Fri, 23 Sep 2016 11:35:46 +0100 Subject: [PATCH 06/26] Added some syle improvements --- .../src/services/bpmUser.service.ts | 5 +- .../src/services/ecmUser.service.ts | 7 +- .../src/userinfo.component.css | 3 +- .../src/userinfo.component.html | 68 ++++++++++++++----- 4 files changed, 56 insertions(+), 27 deletions(-) diff --git a/ng2-components/ng2-alfresco-userinfo/src/services/bpmUser.service.ts b/ng2-components/ng2-alfresco-userinfo/src/services/bpmUser.service.ts index 5d3f2bd163..6e8204a234 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/services/bpmUser.service.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/services/bpmUser.service.ts @@ -41,11 +41,8 @@ export class BPMUserService { if ( this.authService.getAlfrescoApi().bpmAuth.isLoggedIn() ) { return Observable.fromPromise(this.callApiGetProfile()) .map( - data => data + (data) => data ) - .do( - data => console.log('Node data', data) - ) // eyeball results in the console .catch(this.handleError); } } diff --git a/ng2-components/ng2-alfresco-userinfo/src/services/ecmUser.service.ts b/ng2-components/ng2-alfresco-userinfo/src/services/ecmUser.service.ts index e85f34b116..56b0e62c0b 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/services/ecmUser.service.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/services/ecmUser.service.ts @@ -39,10 +39,9 @@ export class ECMUserService { getUserInfo(userName: string): Observable { if ( this.authService.getAlfrescoApi().ecmAuth.isLoggedIn() ) { return Observable.fromPromise(this.callApiGetPersonInfo(userName)) - .map( data => data['entry']) - .do( - data => console.log('Node data', data['entry']) - ) // eyeball results in the console + .map( + (data) => data['entry'] + ) .catch(this.handleError); } } diff --git a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.css b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.css index bcd1bc0bca..55b411d282 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.css +++ b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.css @@ -17,6 +17,7 @@ } .user-profile-list-mdl{ - max-height: 250px; + max-height: 450px; width: 400px; + overflow: auto; } diff --git a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html index 5437e89627..8311349814 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html +++ b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html @@ -13,44 +13,76 @@ From 078e7659af8eeed098ee1daebacd2d595e5d923a Mon Sep 17 00:00:00 2001 From: Vito Albano Date: Fri, 23 Sep 2016 11:46:40 +0100 Subject: [PATCH 07/26] Added min-width to component style --- .../ng2-alfresco-userinfo/src/userinfo.component.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.css b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.css index 55b411d282..dbf99bfc30 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.css +++ b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.css @@ -18,6 +18,7 @@ .user-profile-list-mdl{ max-height: 450px; - width: 400px; + max-width: 450px; + min-width: 410px; overflow: auto; } From 6f375b0a5c8611378b110b4d010e9bef59dc1683 Mon Sep 17 00:00:00 2001 From: Vito Albano Date: Fri, 23 Sep 2016 15:49:41 +0100 Subject: [PATCH 08/26] Added more style improvements --- .../src/userinfo.component.css | 35 +++++- .../src/userinfo.component.html | 105 +++++++----------- .../src/userinfo.component.ts | 12 ++ 3 files changed, 82 insertions(+), 70 deletions(-) diff --git a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.css b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.css index dbf99bfc30..93254d00fa 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.css +++ b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.css @@ -5,20 +5,49 @@ margin-right: 0%; cursor: pointer; border: 1px solid #999999; + vertical-align: middle; } .button-profile { display: inline-block; border: 0px; + vertical-align: middle; } .detail-user-profile-list-mdl{ - margin-right: 100px; + margin-right: 10px; } .user-profile-list-mdl{ max-height: 450px; - max-width: 450px; - min-width: 410px; + min-width: 450px; overflow: auto; } + +.header-profile{ + color: rgb(255,152,0); + margin-left: 10px; +} + +hr.title-start { + border: 0; + height: 1px; + background: #333; + background-image: linear-gradient(to right, #ccc, #333, #ccc); +} + +span.role-label-user{ + font-weight: 400; + line-height: 1; + letter-spacing: 0; + color: rgba(0,0,0,.87); +} + +.custom-role-style{ + font-size: 14px; + color: #9e9e9e; +} + +.truncate-long-names{ + text-overflow: ellipsis; +} diff --git a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html index 8311349814..74e47e341f 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html +++ b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html @@ -1,6 +1,10 @@
{{ecmUser.firstName || ecmUser.lastName}} - {{bpmUser.firstName || bpmUser.lastName || bpmUser.fullName}} + + {{ formatValue(bpmUser.firstName) || + formatValue(bpmUser.lastName) || + formatValue(bpmUser.fullName) }} +
+ for="user-profile">
-
+
BPM
From b3b381536e960c7d8b69b576a35f2a356873e56c Mon Sep 17 00:00:00 2001 From: Vito Albano Date: Tue, 27 Sep 2016 12:26:13 +0100 Subject: [PATCH 11/26] Added ReadMe --- .../ng2-alfresco-userinfo/README.md | 54 ++++++++++++++----- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/ng2-components/ng2-alfresco-userinfo/README.md b/ng2-components/ng2-alfresco-userinfo/README.md index fe8a836e34..f100be7287 100644 --- a/ng2-components/ng2-alfresco-userinfo/README.md +++ b/ng2-components/ng2-alfresco-userinfo/README.md @@ -1,28 +1,58 @@ -# ng2-alfresco-userinfo +# Alfresco User Info Component for Angular 2 This component will show the user information for ECM and BPM + +## Prerequisites + +Before you start using this development framework, make sure you have installed all required software and done all the +necessary configuration, see this [page](https://github.com/Alfresco/alfresco-ng2-components/blob/master/PREREQUISITES.md). + ## Installation ```bash npm install ng2-alfresco-userinfo --save ``` +## Dependencies +Add the following dependency to your index.html: +```html + +``` + +You must separately install the following libraries for your application: + +- [ng2-translate](https://github.com/ocombe/ng2-translate) +- [ng2-alfresco-core](https://www.npmjs.com/package/ng2-alfresco-core) + +```sh +npm install --save ng2-translate ng2-alfresco-core +``` + +#### Material Design Lite + +The style of this component is based on [material design](https://getmdl.io/), so if you want to visualize it correctly you have to add the material +design dependency to your project: + +```sh +npm install --save material-design-icons material-design-lite +``` + +Also make sure you include these dependencies in your `index.html` file: + +```html + + + + +``` + ## Example ```html ``` - -## Reference - -Attribute | Options | Default | Description ---- | --- | --- | --- -`foo` | *string* | `bar` | Lorem ipsum dolor. - - -Method | Parameters | Returns | Description ---- | --- | --- | --- -`methodName()` | None. | void | Lorem ipsum dolor. +This will show a round icon with user and on click some user information are showed. +If user is logged in with ECM and BPM the ECM image will be showed. ## NPM scripts From 0d7f32a6491e4d9dc924b58881ccbfbbb2ff0302 Mon Sep 17 00:00:00 2001 From: Vito Albano Date: Tue, 27 Sep 2016 18:12:53 +0100 Subject: [PATCH 12/26] Fixed structure and naming convention --- .../ng2-alfresco-userinfo/angular-cli.json | 27 --- ng2-components/ng2-alfresco-userinfo/index.ts | 47 ++++- .../ng2-alfresco-userinfo/karma-test-shim.js | 194 ++++++++++-------- .../ng2-alfresco-userinfo/karma.conf.js | 94 ++++++--- .../ng2-alfresco-userinfo/package.json | 79 ++++--- .../user-info.component.css} | 0 .../user-info.component.html} | 0 .../components/user-info.component.spec.ts | 25 +++ .../user-info.component.ts} | 14 +- .../{bpmUser.model.ts => bpm-user.model.ts} | 0 ...mCompany.model.ts => ecm-company.model.ts} | 0 .../{ecmUser.model.ts => ecm-user.model.ts} | 2 +- ...bpmUser.service.ts => bpm-user.service.ts} | 4 +- ...ecmUser.service.ts => ecm-user.service.ts} | 4 +- .../src/userinfo.component.spec.ts | 16 -- .../ng2-alfresco-userinfo/tsconfig.json | 49 +++-- 16 files changed, 323 insertions(+), 232 deletions(-) delete mode 100644 ng2-components/ng2-alfresco-userinfo/angular-cli.json rename ng2-components/ng2-alfresco-userinfo/src/{userinfo.component.css => components/user-info.component.css} (100%) rename ng2-components/ng2-alfresco-userinfo/src/{userinfo.component.html => components/user-info.component.html} (100%) create mode 100644 ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.spec.ts rename ng2-components/ng2-alfresco-userinfo/src/{userinfo.component.ts => components/user-info.component.ts} (86%) rename ng2-components/ng2-alfresco-userinfo/src/models/{bpmUser.model.ts => bpm-user.model.ts} (100%) rename ng2-components/ng2-alfresco-userinfo/src/models/{ecmCompany.model.ts => ecm-company.model.ts} (100%) rename ng2-components/ng2-alfresco-userinfo/src/models/{ecmUser.model.ts => ecm-user.model.ts} (95%) rename ng2-components/ng2-alfresco-userinfo/src/services/{bpmUser.service.ts => bpm-user.service.ts} (96%) rename ng2-components/ng2-alfresco-userinfo/src/services/{ecmUser.service.ts => ecm-user.service.ts} (96%) delete mode 100644 ng2-components/ng2-alfresco-userinfo/src/userinfo.component.spec.ts diff --git a/ng2-components/ng2-alfresco-userinfo/angular-cli.json b/ng2-components/ng2-alfresco-userinfo/angular-cli.json deleted file mode 100644 index ef1d3675f0..0000000000 --- a/ng2-components/ng2-alfresco-userinfo/angular-cli.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "project": { - "version": "ng2-alfresco-userinfo", - "name": "0.1.0" - }, - "apps": [ - { - "main": "src/ng2-alfresco-userinfo.component.ts", - "tsconfig": "tsconfig.json", - "mobile": false - } - ], - "addons": [], - "packages": [], - "test": { - "karma": { - "config": "karma.conf.js" - } - }, - "defaults": { - "prefix": "", - "sourceDir": "src", - "styleExt": "css", - "prefixInterfaces": false, - "lazyRoutePrefix": "+" - } -} diff --git a/ng2-components/ng2-alfresco-userinfo/index.ts b/ng2-components/ng2-alfresco-userinfo/index.ts index 3548a5fae7..a75fe639fd 100644 --- a/ng2-components/ng2-alfresco-userinfo/index.ts +++ b/ng2-components/ng2-alfresco-userinfo/index.ts @@ -1,10 +1,47 @@ -import { ECMUserService } from './src/services/ecmUser.service'; +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed 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. + */ +import { NgModule, ModuleWithProviders } from '@angular/core'; +import { CoreModule } from 'ng2-alfresco-core'; +import { EcmUserService } from './src/services/ecm-user.service'; +import { BpmUserService } from './src/services/bpm-user.service'; -export * from './src/userinfo.component'; -export * from './src/services/ecmUser.service'; - +export * from './src/components/user-info.component'; export const USER_INFO_SERVICE: [any] = [ - ECMUserService + EcmUserService, + BpmUserService ]; + +@NgModule({ + imports: [ + CoreModule + ], + declarations: [ + ...USER_INFO_SERVICE + ], + exports: [ + ...USER_INFO_SERVICE + ] +}) +export class UserInfoModule { + static forRoot(): ModuleWithProviders { + return { + ngModule: UserInfoModule + }; + } +} diff --git a/ng2-components/ng2-alfresco-userinfo/karma-test-shim.js b/ng2-components/ng2-alfresco-userinfo/karma-test-shim.js index 445a2b98d0..fb1c3905f3 100644 --- a/ng2-components/ng2-alfresco-userinfo/karma-test-shim.js +++ b/ng2-components/ng2-alfresco-userinfo/karma-test-shim.js @@ -1,110 +1,128 @@ -'use strict'; // Tun on full stack traces in errors to help debugging Error.stackTraceLimit = Infinity; + jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000; + __karma__.loaded = function() {}; +var builtPath = '/base/dist/'; + +function isJsFile(path) { + return path.slice(-3) == '.js'; +} + +function isSpecFile(path) { + return /\.spec\.(.*\.)?js$/.test(path); +} + +function isBuiltFile(path) { + return isJsFile(path) && (path.substr(0, builtPath.length) == builtPath); +} + +var allSpecFiles = Object.keys(window.__karma__.files) + .filter(isSpecFile) + .filter(isBuiltFile); + +var paths = { + // paths serve as alias + 'npm:': 'base/node_modules/' +}; + var map = { - app: 'base/dist', - rxjs: 'base/node_modules/rxjs', - '@angular': 'base/node_modules/@angular', - 'ng2-translate': '/base/node_modules/ng2-translate', - 'ng2-alfresco-core': '/base/node_modules/ng2-alfresco-core/dist' + 'app': 'base/dist', + // angular bundles + '@angular/core': 'npm:@angular/core/bundles/core.umd.js', + '@angular/common': 'npm:@angular/common/bundles/common.umd.js', + '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js', + '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js', + '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js', + '@angular/http': 'npm:@angular/http/bundles/http.umd.js', + '@angular/router': 'npm:@angular/router/bundles/router.umd.js', + '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js', + // testing + '@angular/core/testing': 'npm:@angular/core/bundles/core-testing.umd.js', + '@angular/common/testing': 'npm:@angular/common/bundles/common-testing.umd.js', + '@angular/compiler/testing': 'npm:@angular/compiler/bundles/compiler-testing.umd.js', + '@angular/platform-browser/testing': 'npm:@angular/platform-browser/bundles/platform-browser-testing.umd.js', + '@angular/platform-browser-dynamic/testing': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js', + '@angular/http/testing': 'npm:@angular/http/bundles/http-testing.umd.js', + '@angular/router/testing': 'npm:@angular/router/bundles/router-testing.umd.js', + '@angular/forms/testing': 'npm:@angular/forms/bundles/forms-testing.umd.js', + + // other libraries + 'rxjs': 'npm:rxjs', + 'ng2-translate': 'npm:ng2-translate', + + 'alfresco-js-api': 'npm:alfresco-js-api/dist', + 'ng2-activiti-form': 'npm:ng2-activiti-form/dist', + 'ng2-activiti-processlist': 'npm:ng2-activiti-processlist/dist', + 'ng2-activiti-tasklist': 'npm:ng2-activiti-tasklist/dist', + 'ng2-alfresco-core': 'npm:ng2-alfresco-core/dist', + 'ng2-alfresco-datatable': 'npm:ng2-alfresco-datatable/dist', + 'ng2-alfresco-documentlist': 'npm:ng2-alfresco-documentlist/dist', + 'ng2-alfresco-login': 'npm:ng2-alfresco-login/dist', + 'ng2-alfresco-search': 'npm:ng2-alfresco-search/dist', + 'ng2-alfresco-tag': 'npm:ng2-alfresco-tag/dist', + 'ng2-alfresco-upload': 'npm:ng2-alfresco-upload/dist', + 'ng2-alfresco-viewer': 'npm:ng2-alfresco-viewer/dist', + 'ng2-alfresco-webscript': 'npm:ng2-alfresco-webscript/dist', + 'ng2-alfresco-userinfo': 'npm:ng2-alfresco-userinfo/dist' }; var packages = { - app: { main: 'main.js', defaultExtension: 'js' }, - rxjs: { defaultExtension: 'js' }, - 'ng2-translate': { defaultExtension: 'js' }, - 'ng2-alfresco-core': { main: 'index.js', defaultExtension: 'js' } -}; + 'app': { main: 'index.js', defaultExtension: 'js', format: 'register' }, + 'rxjs': { defaultExtension: 'js' }, + 'ng2-translate': { defaultExtension: 'js' }, -var packageNames = [ - '@angular/common', - '@angular/compiler', - '@angular/core', - '@angular/http', - '@angular/platform-browser', - '@angular/platform-browser-dynamic', - '@angular/router', - '@angular/router-deprecated', - '@angular/testing', - '@angular/upgrade' -]; - -packageNames.forEach(function(pkgName) { - packages[pkgName] = { main: 'index.js', defaultExtension: 'js' }; -}); - -packages['base/dist'] = { - defaultExtension: 'js', - format: 'register', - map: Object.keys(window.__karma__.files).filter(onlyAppFiles).reduce(createPathRecords, {}) + 'alfresco-js-api': { main: './alfresco-js-api.js', defaultExtension: 'js'}, + 'ng2-activiti-form': { main: './index.js', defaultExtension: 'js'}, + 'ng2-activiti-processlist': { main: './index.js', defaultExtension: 'js'}, + 'ng2-activiti-tasklist': { main: './index.js', defaultExtension: 'js'}, + 'ng2-alfresco-core': { main: './index.js', defaultExtension: 'js'}, + 'ng2-alfresco-datatable': { main: './index.js', defaultExtension: 'js'}, + 'ng2-alfresco-documentlist': { main: './index.js', defaultExtension: 'js'}, + 'ng2-alfresco-login': { main: './index.js', defaultExtension: 'js'}, + 'ng2-alfresco-search': { main: './index.js', defaultExtension: 'js'}, + 'ng2-alfresco-tag': { main: './index.js', defaultExtension: 'js'}, + 'ng2-alfresco-upload': { main: './index.js', defaultExtension: 'js'}, + 'ng2-alfresco-viewer': { main: './index.js', defaultExtension: 'js'}, + 'ng2-alfresco-webscript': { main: './index.js', defaultExtension: 'js'}, + 'ng2-alfresco-userinfo': { main: './index.js', defaultExtension: 'js'} }; var config = { - map: map, - packages: packages + paths: paths, + map: map, + packages: packages }; System.config(config); -System.import('@angular/platform-browser/src/browser/browser_adapter') - .then(function(browserAdapter) { - browserAdapter.BrowserDomAdapter.makeCurrent(); - }) - .then(function() { +System.import('app') + .then(initTestBed) + .then(initTesting); + +function initTestBed(){ return Promise.all([ - System.import('@angular/core/testing'), - System.import('@angular/platform-browser-dynamic/testing') - ]); - }) - .then(function(providers) { - var testing = providers[0]; - var testingBrowser = providers[1]; + System.import('@angular/core/testing'), + System.import('@angular/platform-browser-dynamic/testing') + ]) + .then(function (providers) { + var coreTesting = providers[0]; + var browserTesting = providers[1]; - testing.setBaseTestProviders( - testingBrowser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, - testingBrowser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS); - }) - .then(function() { - return Promise.all(resolveTestFiles()); - }) - .then( - function() { - __karma__.start(); - }, - function(error) { - if (typeof __karma__.error === 'function') { - __karma__.error(error.stack || error); - } else { - console.error(error); - } - } - ); - -function createPathRecords(pathsMapping, appPath) { - var pathParts = appPath.split('/'); - var moduleName = './' + pathParts.slice(Math.max(pathParts.length - 2, 1)).join('/'); - moduleName = moduleName.replace(/\.js$/, ''); - pathsMapping[moduleName] = appPath + '?' + window.__karma__.files[appPath]; - return pathsMapping; + coreTesting.TestBed.initTestEnvironment( + browserTesting.BrowserDynamicTestingModule, + browserTesting.platformBrowserDynamicTesting()); + }) } -function onlyAppFiles(filePath) { - return /\/base\/dist\/(?!.*\.spec\.js$).*\.js$/.test(filePath); -} - -function onlySpecFiles(path) { - return /\.spec\.js$/.test(path); -} - -function resolveTestFiles() { - return Object.keys(window.__karma__.files) // All files served by Karma. - .filter(onlySpecFiles) - .map(function(moduleName) { - // loads all spec files via their global module names (e.g. - // 'base/dist/vg-player/vg-player.spec') - return System.import(moduleName); - }); +// Import all spec files and start karma +function initTesting () { + return Promise.all( + allSpecFiles.map(function (moduleName) { + return System.import(moduleName); + }) + ) + .then(__karma__.start, __karma__.error); } diff --git a/ng2-components/ng2-alfresco-userinfo/karma.conf.js b/ng2-components/ng2-alfresco-userinfo/karma.conf.js index c822c9fcd6..c0374b25c3 100644 --- a/ng2-components/ng2-alfresco-userinfo/karma.conf.js +++ b/ng2-components/ng2-alfresco-userinfo/karma.conf.js @@ -1,48 +1,78 @@ 'use strict'; -module.exports = function(config) { - config.set({ - +module.exports = function (config) { + var configuration = { basePath: '.', - frameworks: ['jasmine'], + frameworks: ['jasmine-ajax', 'jasmine'], files: [ - // paths loaded by Karma - {pattern: 'node_modules/reflect-metadata/Reflect.js', included: true, watched: false}, - {pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: false}, - {pattern: 'node_modules/zone.js/dist/zone.js', included: true, watched: false}, - {pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false}, - {pattern: 'node_modules/rxjs/**/*.map', included: false, watched: false}, - {pattern: 'node_modules/@angular/**/*.js', included: false, watched: false}, - {pattern: 'node_modules/@angular/**/*.map', included: false, watched: false}, - {pattern: 'node_modules/ng2-translate/**/*.js', included: false, served: true, watched: false}, - {pattern: 'node_modules/ng2-alfresco-core/dist/**/*.js', included: false, served: true, watched: false}, - {pattern: 'node_modules/alfresco-core-rest-api/bundle.js', included: true, watched: false}, + // System.js for module loading + 'node_modules/systemjs/dist/system.src.js', - {pattern: 'karma-test-shim.js', included: true, watched: true}, + // Polyfills + 'node_modules/core-js/client/shim.js', + 'node_modules/reflect-metadata/Reflect.js', + + // zone.js + 'node_modules/zone.js/dist/zone.js', + 'node_modules/zone.js/dist/long-stack-trace-zone.js', + 'node_modules/zone.js/dist/proxy.js', + 'node_modules/zone.js/dist/sync-test.js', + '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', + + // 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: + // Angular itself + {pattern: 'node_modules/@angular/**/*.js', included: false, watched: false}, + {pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false}, + + 'node_modules/alfresco-js-api/dist/alfresco-js-api.js', + {pattern: 'node_modules/ng2-translate/**/*.js', included: false, watched: false}, + {pattern: 'node_modules/ng2-translate/**/*.js.map', included: false, watched: false}, + + 'karma-test-shim.js', // paths loaded via module imports {pattern: 'dist/**/*.js', included: false, watched: true}, {pattern: 'dist/**/*.html', included: true, served: true, watched: true}, {pattern: 'dist/**/*.css', included: true, served: true, watched: true}, + // ng2-components + { pattern: 'node_modules/ng2-activiti-form/dist/**/*.js', included: false, served: true, watched: false }, + { pattern: 'node_modules/ng2-activiti-processlist/dist/**/*.js', included: false, served: true, watched: false }, + { pattern: 'node_modules/ng2-activiti-tasklist/dist/**/*.js', included: false, served: true, watched: false }, + { pattern: 'node_modules/ng2-alfresco-core/dist/**/*.js', included: false, served: true, watched: false }, + { pattern: 'node_modules/ng2-alfresco-datatable/dist/**/*.js', included: false, served: true, watched: false }, + { pattern: 'node_modules/ng2-alfresco-documentlist/dist/**/*.js', included: false, served: true, watched: false }, + { pattern: 'node_modules/ng2-alfresco-login/dist/**/*.js', included: false, served: true, watched: false }, + { pattern: 'node_modules/ng2-alfresco-search/dist/**/*.js', included: false, served: true, watched: false }, + { pattern: 'node_modules/ng2-alfresco-tag/dist/**/*.js', included: false, served: true, watched: false }, + { pattern: 'node_modules/ng2-alfresco-upload/dist/**/*.js', included: false, served: true, watched: false }, + { pattern: 'node_modules/ng2-alfresco-viewer/dist/**/*.js', included: false, served: true, watched: false }, + { pattern: 'node_modules/ng2-alfresco-webscript/dist/**/*.js', included: false, served: true, watched: false }, + { pattern: 'node_modules/ng2-alfresco-userinfo/dist/**/*.js', included: false, served: true, watched: false }, + // paths to support debugging with source maps in dev tools {pattern: 'src/**/*.ts', included: false, watched: false}, {pattern: 'dist/**/*.js.map', included: false, watched: false} ], + exclude: [ + 'node_modules/**/*spec.js' + ], + // proxied base paths proxies: { // required for component assets fetched by Angular's compiler '/src/': '/base/src/' }, - // list of files to exclude - exclude: [ - 'node_modules/**/*spec.js' - ], - port: 9876, // level of logging @@ -55,10 +85,18 @@ module.exports = function(config) { browsers: ['Chrome'], + customLaunchers: { + Chrome_travis_ci: { + base: 'Chrome', + flags: ['--no-sandbox'] + } + }, + // Karma plugins loaded plugins: [ 'karma-jasmine', 'karma-coverage', + 'karma-jasmine-ajax', 'karma-chrome-launcher', 'karma-mocha-reporter', 'karma-jasmine-html-reporter' @@ -70,7 +108,7 @@ module.exports = function(config) { // Source files that you wanna generate coverage for. // Do not include tests or libraries (these files will be instrumented by Istanbul) preprocessors: { - 'dist/**/!(*spec).js': ['coverage'] + // 'dist/**/!(*spec).js': ['coverage'] }, coverageReporter: { @@ -78,10 +116,16 @@ module.exports = function(config) { subdir: 'report', reporters: [ {type: 'text'}, - {type: 'text-summary'}, {type: 'json', file: 'coverage-final.json'}, - {type: 'html'} + {type: 'html'}, + {type: 'lcov'} ] } - }); + }; + + if (process.env.TRAVIS) { + configuration.browsers = ['Chrome_travis_ci']; + } + + config.set(configuration) }; diff --git a/ng2-components/ng2-alfresco-userinfo/package.json b/ng2-components/ng2-alfresco-userinfo/package.json index 538102137b..19e3865dde 100644 --- a/ng2-components/ng2-alfresco-userinfo/package.json +++ b/ng2-components/ng2-alfresco-userinfo/package.json @@ -5,11 +5,10 @@ "author": "vito albano ", "scripts": { "clean": "rimraf dist node_modules", - "license-check": "echo 'license check is disabled'", - "build": "npm run tslint && rimraf dist && tsc && npm run copy-dist && npm run license-check", + "build": "npm run tslint && rimraf dist && tsc && npm run copy-dist", "build:w": "npm run tslint && rimraf dist && npm run watch-task", - "watch-task": "concurrently \"npm run tsc:w\" \"npm run copy-dist:w\" \"npm run license-check\"", - "tslint": "tslint -c tslint.json *.ts && tslint -c tslint.json src/{,**/}**.ts", + "watch-task": "concurrently \"npm run tsc:w\" \"npm run copy-dist:w\" \"license-check\"", + "tslint": "tslint -c tslint.json *.ts && tslint -c tslint.json 'src/{,**/}**.ts'", "copy-dist": "cpx \"./src/**/*.{html,css,json,png,jpg,gif,svg}\" ./dist/src", "copy-dist:w": "cpx \"./src/**/*.{html,css,json,png,jpg,gif,svg}\" ./dist/src -w", "tsc": "tsc", @@ -19,43 +18,53 @@ "test-browser": "npm run build && concurrently \"karma start karma.conf.js --reporters kjhtml\" \"npm run watch-task\"", "posttest": "remap-istanbul -i coverage/report/coverage-final.json -o coverage/report -t html && remap-istanbul -i coverage/report/coverage-final.json -o coverage/report/coverage-final.json", "coverage": "npm run test && wsrv -o -p 9875 ./coverage/report", - "travis": "echo 'placeholder'" + "travis": "npm link ng2-alfresco-core" }, "main": "./dist/index.js", "typings": "./dist/index.d.ts", "repository": { "type": "git", - "url": "https://github.com/alfresco/ng2-alfresco-userinfo.git" + "url": "https://github.com/Alfresco/alfresco-ng2-components.git" }, "bugs": { - "url": "https://github.com/alfresco/ng2-alfresco-userinfo/issues" + "url": "https://github.com/Alfresco/alfresco-ng2-components/issues" }, - + "license": "Apache-2.0", + "contributors": [ + { + "name": "Vito Albano", + "email": "vito.albano@alfresco.com" + } + ], + "keywords": [ + "ng2", + "angular", + "angular2", + "alfresco" + ], "dependencies": { - "alfresco-js-api": "^0.3.0", - "@angular/common": "2.0.0-rc.3", - "@angular/compiler": "2.0.0-rc.3", - "@angular/core": "2.0.0-rc.3", - "@angular/forms": "0.1.1", - "@angular/http": "2.0.0-rc.3", - "@angular/platform-browser": "2.0.0-rc.3", - "@angular/platform-browser-dynamic": "2.0.0-rc.3", - "@angular/router": "3.0.0-alpha.7", - "@angular/router-deprecated": "2.0.0-rc.2", - "@angular/upgrade": "2.0.0-rc.3", + "@angular/common": "2.0.0", + "@angular/compiler": "2.0.0", + "@angular/core": "2.0.0", + "@angular/forms": "2.0.0", + "@angular/http": "2.0.0", + "@angular/platform-browser": "2.0.0", + "@angular/platform-browser-dynamic": "2.0.0", + "@angular/router": "3.0.0", + "@angular/upgrade": "2.0.0", + "core-js": "^2.4.1", + "reflect-metadata": "^0.1.3", + "rxjs": "5.0.0-beta.12", "systemjs": "0.19.27", - "core-js": "2.4.0", - "reflect-metadata": "0.1.3", - "rxjs": "5.0.0-beta.6", - "zone.js": "0.6.12", - "ng2-translate": "2.2.2", - "ng2-alfresco-core": "0.3.2", - "material-design-icons": "2.2.3", - "material-design-lite": "1.1.3" + "zone.js": "^0.6.23", + + "ng2-translate": "2.5.0", + "ng2-alfresco-core": "0.3.2" }, "devDependencies": { "@types/core-js": "^0.9.32", "@types/jasmine": "^2.2.33", + "concurrently": "^2.2.0", "cpx": "1.3.1", "jasmine-ajax": "3.2.0", "jasmine-core": "2.4.1", @@ -74,11 +83,13 @@ "typescript": "^2.0.2", "wsrv": "^0.1.5" }, - "keywords": [ - "component", - "userinfo", - "alfresco", - "alfresco-component" - ], - "license": "Apache-2.0" + "license-check-config": { + "src": [ + "./dist/**/*.js" + ], + "path": "assets/license_header.txt", + "blocking": true, + "logInfo": false, + "logError": true + } } diff --git a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.css b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.css similarity index 100% rename from ng2-components/ng2-alfresco-userinfo/src/userinfo.component.css rename to ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.css diff --git a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.html similarity index 100% rename from ng2-components/ng2-alfresco-userinfo/src/userinfo.component.html rename to ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.html diff --git a/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.spec.ts b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.spec.ts new file mode 100644 index 0000000000..a91e2f2ac8 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.spec.ts @@ -0,0 +1,25 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed 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. + */ +// import { UserInfoComponent } from '../src/userinfo.component'; + +describe('Basic Example test ng2-alfresco-userinfo', () => { + + it('Test hello world', () => { + expect(true).toBe(true); + }); + +}); diff --git a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.ts b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.ts similarity index 86% rename from ng2-components/ng2-alfresco-userinfo/src/userinfo.component.ts rename to ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.ts index f991d8825f..d54b9669e3 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.ts @@ -16,10 +16,10 @@ */ import { Component, OnInit } from '@angular/core'; -import { ECMUserService } from './services/ecmUser.service'; -import { BPMUserService } from './services/bpmUser.service'; -import { EcmUserModel } from './models/ecmUser.model'; -import { BpmUserModel } from './models/bpmUser.model'; +import { EcmUserService } from './../services/ecm-user.service'; +import { BpmUserService } from './../services/bpm-user.service'; +import { EcmUserModel } from './../models/ecm-user.model'; +import { BpmUserModel } from './../models/bpm-user.model'; import { AlfrescoAuthenticationService } from 'ng2-alfresco-core'; declare let __moduleName: string; @@ -29,7 +29,7 @@ declare let __moduleName: string; moduleId: __moduleName, styleUrls: ['./userinfo.component.css'], templateUrl: './userinfo.component.html', - providers: [ECMUserService, BPMUserService, AlfrescoAuthenticationService] + providers: [EcmUserService, BpmUserService, AlfrescoAuthenticationService] }) export class UserInfoComponent implements OnInit { @@ -42,8 +42,8 @@ export class UserInfoComponent implements OnInit { public ecmUserImage: any; - constructor(private ecmUserService: ECMUserService, - private bpmUserService: BPMUserService, + constructor(private ecmUserService: EcmUserService, + private bpmUserService: BpmUserService, public authService: AlfrescoAuthenticationService) { } diff --git a/ng2-components/ng2-alfresco-userinfo/src/models/bpmUser.model.ts b/ng2-components/ng2-alfresco-userinfo/src/models/bpm-user.model.ts similarity index 100% rename from ng2-components/ng2-alfresco-userinfo/src/models/bpmUser.model.ts rename to ng2-components/ng2-alfresco-userinfo/src/models/bpm-user.model.ts diff --git a/ng2-components/ng2-alfresco-userinfo/src/models/ecmCompany.model.ts b/ng2-components/ng2-alfresco-userinfo/src/models/ecm-company.model.ts similarity index 100% rename from ng2-components/ng2-alfresco-userinfo/src/models/ecmCompany.model.ts rename to ng2-components/ng2-alfresco-userinfo/src/models/ecm-company.model.ts diff --git a/ng2-components/ng2-alfresco-userinfo/src/models/ecmUser.model.ts b/ng2-components/ng2-alfresco-userinfo/src/models/ecm-user.model.ts similarity index 95% rename from ng2-components/ng2-alfresco-userinfo/src/models/ecmUser.model.ts rename to ng2-components/ng2-alfresco-userinfo/src/models/ecm-user.model.ts index 436604989c..08f24fbcdb 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/models/ecmUser.model.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/models/ecm-user.model.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { EcmCompanyModel } from './ecmCompany.model'; +import { EcmCompanyModel } from './ecm-company.model'; export class EcmUserModel { id: string; diff --git a/ng2-components/ng2-alfresco-userinfo/src/services/bpmUser.service.ts b/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.ts similarity index 96% rename from ng2-components/ng2-alfresco-userinfo/src/services/bpmUser.service.ts rename to ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.ts index 6e8204a234..089320a264 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/services/bpmUser.service.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.ts @@ -19,7 +19,7 @@ import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfr import { Injectable } from '@angular/core'; import { Response } from '@angular/http'; import { Observable } from 'rxjs/Rx'; -import { BpmUserModel } from '../models/bpmUser.model'; +import { BpmUserModel } from '../models/bpm-user.model'; /** * * BPMUserService retrieve all the information of an Ecm user. @@ -27,7 +27,7 @@ import { BpmUserModel } from '../models/bpmUser.model'; * @returns {BPMUserService} . */ @Injectable() -export class BPMUserService { +export class BpmUserService { constructor(private authService: AlfrescoAuthenticationService, private settingService: AlfrescoSettingsService) { diff --git a/ng2-components/ng2-alfresco-userinfo/src/services/ecmUser.service.ts b/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.ts similarity index 96% rename from ng2-components/ng2-alfresco-userinfo/src/services/ecmUser.service.ts rename to ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.ts index 56b0e62c0b..6875ee7d48 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/services/ecmUser.service.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.ts @@ -19,7 +19,7 @@ import { AlfrescoAuthenticationService, AlfrescoContentService } from 'ng2-alfre import { Injectable } from '@angular/core'; import { Response } from '@angular/http'; import { Observable } from 'rxjs/Rx'; -import { EcmUserModel } from '../models/ecmUser.model'; +import { EcmUserModel } from '../models/ecm-user.model'; /** * * ECMUserService retrieve all the information of an Ecm user. @@ -27,7 +27,7 @@ import { EcmUserModel } from '../models/ecmUser.model'; * @returns {ECMUserService} . */ @Injectable() -export class ECMUserService { +export class EcmUserService { constructor(private authService: AlfrescoAuthenticationService, private contentService: AlfrescoContentService) {} diff --git a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.spec.ts b/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.spec.ts deleted file mode 100644 index e7917d1f0b..0000000000 --- a/ng2-components/ng2-alfresco-userinfo/src/userinfo.component.spec.ts +++ /dev/null @@ -1,16 +0,0 @@ - -import {describe, expect, it, inject} from '@angular/core/testing'; -import { TestComponentBuilder } from '@angular/compiler/testing'; -import { UserInfoComponent } from '../src/userinfo.component'; - -describe('Basic Example test ng2-alfresco-userinfo', () => { - it('Test hello world', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { - return tcb - .createAsync(UserInfoComponent) - .then((fixture) => { - let element = fixture.nativeElement; - expect(element.querySelector('h1')).toBeDefined(); - expect(element.getElementsByTagName('h1')[0].innerHTML).toEqual('Hello World Angular 2 ng2-alfresco-userinfo'); - }); - })); -}); diff --git a/ng2-components/ng2-alfresco-userinfo/tsconfig.json b/ng2-components/ng2-alfresco-userinfo/tsconfig.json index e4d2ae201a..b1effea355 100644 --- a/ng2-components/ng2-alfresco-userinfo/tsconfig.json +++ b/ng2-components/ng2-alfresco-userinfo/tsconfig.json @@ -1,27 +1,26 @@ { - "compilerOptions": { - "target": "es5", - "module": "system", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": true, - "removeComments": true, - "declaration": true, - "noLib": false, - "allowUnreachableCode": false, - "allowUnusedLabels": false, - "noImplicitAny": false, - "noImplicitReturns": false, - "noImplicitUseStrict": false, - "noFallthroughCasesInSwitch": true, - "outDir": "dist" - }, - "exclude": [ - "demo", - "node_modules", - "typings/main", - "typings/main.d.ts", - "dist" - ] + "compilerOptions": { + "target": "es5", + "module": "system", + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "sourceMap": true, + "removeComments": true, + "declaration": true, + "noLib": false, + "allowUnreachableCode": false, + "allowUnusedLabels": false, + "noImplicitAny": false, + "noImplicitReturns": false, + "noImplicitUseStrict": false, + "noFallthroughCasesInSwitch": true, + "outDir": "dist", + "types": ["core-js", "jasmine"] + }, + "exclude": [ + "demo", + "node_modules", + "dist" + ] } From d946532f14239d8b0ced7f6e273892d01585fc4d Mon Sep 17 00:00:00 2001 From: Vito Albano Date: Thu, 29 Sep 2016 02:55:39 +0100 Subject: [PATCH 13/26] Added new version for component --- .gitignore | 6 +- demo-shell-ng2/app/app.module.ts | 8 +- .../ng2-alfresco-userinfo-old/.editorconfig | 23 ++ .../ng2-alfresco-userinfo-old/.gitignore | 13 + .../ng2-alfresco-userinfo-old/.travis.yml | 8 + .../ng2-alfresco-userinfo-old/LICENSE | 13 + .../ng2-alfresco-userinfo-old/README.md | 73 ++++ .../demo/.editorconfig | 0 .../ng2-alfresco-userinfo-old/demo/.gitignore | 5 + .../ng2-alfresco-userinfo-old/demo/README.md | 19 + .../ng2-alfresco-userinfo-old/demo/index.html | 71 ++++ .../demo/package.json | 89 +++++ .../demo/src/main.ts | 95 +++++ .../demo/systemjs.config.js | 0 .../demo/tsconfig.json | 18 +- .../demo/tslint.json | 124 ++++++ .../demo/typings.json | 0 .../ng2-alfresco-userinfo-old/index.ts | 58 +++ .../karma-test-shim.js | 128 ++++++ .../ng2-alfresco-userinfo-old/karma.conf.js | 131 ++++++ .../ng2-alfresco-userinfo-old/package.json | 94 +++++ .../src/components/user-info.component.css | 53 +++ .../src/components/user-info.component.html | 63 +++ .../components/user-info.component.spec.ts | 25 ++ .../src/components/user-info.component.ts | 93 +++++ .../src/i18n/en.json | 24 ++ .../src/i18n/it.json | 24 ++ .../src/img/anonymous.gif | Bin 0 -> 1765 bytes .../src/models/bpm-user.model.ts | 39 ++ .../src/models/ecm-company.model.ts | 27 ++ .../src/models/ecm-user.model.ts | 39 ++ .../src/services/bpm-user.service.ts | 75 ++++ .../src/services/ecm-user.service.ts | 72 ++++ .../ng2-alfresco-userinfo-old/tsconfig.json | 26 ++ .../ng2-alfresco-userinfo-old/tslint.json | 121 ++++++ .../typings.json | 0 .../ng2-alfresco-userinfo/.travis.yml | 4 + ng2-components/ng2-alfresco-userinfo/LICENSE | 2 +- .../ng2-alfresco-userinfo/README.md | 376 ++++++++++++++++-- .../assets/license_header.txt | 16 + .../ng2-alfresco-userinfo/demo/.gitignore | 1 + .../ng2-alfresco-userinfo/demo/README.md | 2 +- .../ng2-alfresco-userinfo/demo/index.html | 28 +- .../ng2-alfresco-userinfo/demo/package.json | 71 ---- .../ng2-alfresco-userinfo/demo/src/main.ts | 208 +++++----- .../ng2-alfresco-userinfo/demo/tslint.json | 2 +- ng2-components/ng2-alfresco-userinfo/index.ts | 25 +- .../ng2-alfresco-userinfo/karma-test-shim.js | 4 +- .../ng2-alfresco-userinfo/karma.conf.js | 2 +- .../ng2-alfresco-userinfo/package.json | 68 ++-- .../components/user-info.component.spec.ts | 35 +- .../src/components/user-info.component.ts | 12 +- .../src/services/bpm-user.service.spec.ts | 48 +++ .../src/services/bpm-user.service.ts | 31 +- .../src/services/ecm-user.service.spec.ts | 69 ++++ .../ng2-alfresco-userinfo/tsconfig.json | 48 +-- .../ng2-alfresco-userinfo/tslint.json | 2 +- 57 files changed, 2375 insertions(+), 336 deletions(-) create mode 100644 ng2-components/ng2-alfresco-userinfo-old/.editorconfig create mode 100644 ng2-components/ng2-alfresco-userinfo-old/.gitignore create mode 100644 ng2-components/ng2-alfresco-userinfo-old/.travis.yml create mode 100644 ng2-components/ng2-alfresco-userinfo-old/LICENSE create mode 100644 ng2-components/ng2-alfresco-userinfo-old/README.md rename ng2-components/{ng2-alfresco-userinfo => ng2-alfresco-userinfo-old}/demo/.editorconfig (100%) create mode 100644 ng2-components/ng2-alfresco-userinfo-old/demo/.gitignore create mode 100644 ng2-components/ng2-alfresco-userinfo-old/demo/README.md create mode 100644 ng2-components/ng2-alfresco-userinfo-old/demo/index.html create mode 100644 ng2-components/ng2-alfresco-userinfo-old/demo/package.json create mode 100644 ng2-components/ng2-alfresco-userinfo-old/demo/src/main.ts rename ng2-components/{ng2-alfresco-userinfo => ng2-alfresco-userinfo-old}/demo/systemjs.config.js (100%) rename ng2-components/{ng2-alfresco-userinfo => ng2-alfresco-userinfo-old}/demo/tsconfig.json (54%) create mode 100644 ng2-components/ng2-alfresco-userinfo-old/demo/tslint.json rename ng2-components/{ng2-alfresco-userinfo => ng2-alfresco-userinfo-old}/demo/typings.json (100%) create mode 100644 ng2-components/ng2-alfresco-userinfo-old/index.ts create mode 100644 ng2-components/ng2-alfresco-userinfo-old/karma-test-shim.js create mode 100644 ng2-components/ng2-alfresco-userinfo-old/karma.conf.js create mode 100644 ng2-components/ng2-alfresco-userinfo-old/package.json create mode 100644 ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.css create mode 100644 ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.html create mode 100644 ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.spec.ts create mode 100644 ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.ts create mode 100644 ng2-components/ng2-alfresco-userinfo-old/src/i18n/en.json create mode 100644 ng2-components/ng2-alfresco-userinfo-old/src/i18n/it.json create mode 100644 ng2-components/ng2-alfresco-userinfo-old/src/img/anonymous.gif create mode 100644 ng2-components/ng2-alfresco-userinfo-old/src/models/bpm-user.model.ts create mode 100644 ng2-components/ng2-alfresco-userinfo-old/src/models/ecm-company.model.ts create mode 100644 ng2-components/ng2-alfresco-userinfo-old/src/models/ecm-user.model.ts create mode 100644 ng2-components/ng2-alfresco-userinfo-old/src/services/bpm-user.service.ts create mode 100644 ng2-components/ng2-alfresco-userinfo-old/src/services/ecm-user.service.ts create mode 100644 ng2-components/ng2-alfresco-userinfo-old/tsconfig.json create mode 100644 ng2-components/ng2-alfresco-userinfo-old/tslint.json rename ng2-components/{ng2-alfresco-userinfo => ng2-alfresco-userinfo-old}/typings.json (100%) create mode 100644 ng2-components/ng2-alfresco-userinfo/assets/license_header.txt delete mode 100644 ng2-components/ng2-alfresco-userinfo/demo/package.json create mode 100644 ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.spec.ts create mode 100644 ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.spec.ts diff --git a/.gitignore b/.gitignore index fd050d0b70..62258c2884 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,8 @@ node_modules workspace.xml .idea/ dist/ -!systemjs.config.js \ No newline at end of file +!systemjs.config.js +demo-shell-ng2/app/components/router/ +ng2-components/ng2-alfresco-userinfo-old/demo/src/app/ +ng2-components/ng2-alfresco-userinfo-old/src/services/bpm-user.service.spec.ts +ng2-components/ng2-alfresco-userinfo-old/src/services/ecm-user.service.spec.ts diff --git a/demo-shell-ng2/app/app.module.ts b/demo-shell-ng2/app/app.module.ts index 156ed434f4..1726859603 100644 --- a/demo-shell-ng2/app/app.module.ts +++ b/demo-shell-ng2/app/app.module.ts @@ -30,7 +30,7 @@ import { ViewerModule } from 'ng2-alfresco-viewer'; import { ActivitiFormModule } from 'ng2-activiti-form'; import { ActivitiTaskListModule } from 'ng2-activiti-tasklist'; import { ActivitiProcessListModule } from 'ng2-activiti-processlist'; -import { UserInfoComponent } from 'ng2-alfresco-userinfo'; +import { UserInfoComponentModule } from 'ng2-alfresco-userinfo'; import { AppComponent } from './app.component'; import { routing } from './app.routes'; @@ -64,7 +64,8 @@ import { ViewerModule.forRoot(), ActivitiFormModule.forRoot(), ActivitiTaskListModule.forRoot(), - ActivitiProcessListModule.forRoot() + ActivitiProcessListModule.forRoot(), + UserInfoComponentModule.forRoot() ], declarations: [ AppComponent, @@ -79,8 +80,7 @@ import { TagComponent, AboutComponent, FilesComponent, - FormNodeViewer, - UserInfoComponent + FormNodeViewer ], providers: [], bootstrap: [ AppComponent ] diff --git a/ng2-components/ng2-alfresco-userinfo-old/.editorconfig b/ng2-components/ng2-alfresco-userinfo-old/.editorconfig new file mode 100644 index 0000000000..75a2477db7 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/.editorconfig @@ -0,0 +1,23 @@ +# http://editorconfig.org + +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 4 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[package.json] +indent_style = space +indent_size = 2 + +[karma.conf.js] +indent_style = space +indent_size = 2 + +[*.md] +insert_final_newline = false +trim_trailing_whitespace = false diff --git a/ng2-components/ng2-alfresco-userinfo-old/.gitignore b/ng2-components/ng2-alfresco-userinfo-old/.gitignore new file mode 100644 index 0000000000..3bea8a0c07 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/.gitignore @@ -0,0 +1,13 @@ +npm-debug.log +node_modules +jspm_packages +.idea +typings +coverage +src/**/*.js +src/**/*.js.map +src/**/*.d.ts +demo/**/*.js +demo/**/*.js.map +demo/**/*.d.ts +!systemjs.config.js diff --git a/ng2-components/ng2-alfresco-userinfo-old/.travis.yml b/ng2-components/ng2-alfresco-userinfo-old/.travis.yml new file mode 100644 index 0000000000..781e6204e8 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/.travis.yml @@ -0,0 +1,8 @@ +language: node_js +node_js: + - v5 + - v4 +install: npm install +sudo: false +after_success: + npm run coverage diff --git a/ng2-components/ng2-alfresco-userinfo-old/LICENSE b/ng2-components/ng2-alfresco-userinfo-old/LICENSE new file mode 100644 index 0000000000..bfd4a66b0c --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/LICENSE @@ -0,0 +1,13 @@ +Copyright 2016 vito albano + +Licensed 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. diff --git a/ng2-components/ng2-alfresco-userinfo-old/README.md b/ng2-components/ng2-alfresco-userinfo-old/README.md new file mode 100644 index 0000000000..f100be7287 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/README.md @@ -0,0 +1,73 @@ +# Alfresco User Info Component for Angular 2 +This component will show the user information for ECM and BPM + + +## Prerequisites + +Before you start using this development framework, make sure you have installed all required software and done all the +necessary configuration, see this [page](https://github.com/Alfresco/alfresco-ng2-components/blob/master/PREREQUISITES.md). + +## Installation + +```bash +npm install ng2-alfresco-userinfo --save +``` +## Dependencies + +Add the following dependency to your index.html: +```html + +``` + +You must separately install the following libraries for your application: + +- [ng2-translate](https://github.com/ocombe/ng2-translate) +- [ng2-alfresco-core](https://www.npmjs.com/package/ng2-alfresco-core) + +```sh +npm install --save ng2-translate ng2-alfresco-core +``` + +#### Material Design Lite + +The style of this component is based on [material design](https://getmdl.io/), so if you want to visualize it correctly you have to add the material +design dependency to your project: + +```sh +npm install --save material-design-icons material-design-lite +``` + +Also make sure you include these dependencies in your `index.html` file: + +```html + + + + +``` + +## Example + +```html + +``` +This will show a round icon with user and on click some user information are showed. +If user is logged in with ECM and BPM the ECM image will be showed. + +## NPM scripts + +| Command | Description | +| --- | --- | +| npm run build | Build component | +| npm run build:w | Build component and keep watching the changes | +| npm run test | Run unit tests in the console | +| npm run test-browser | Run unit tests in the browser +| npm run coverage | Run unit tests and display code coverage report | + +## History + +For detailed changelog, check [Releases](https://github.com/alfresco/ng2-alfresco-userinfo/releases). + +## Contributors + +[Contributors](https://github.com/alfresco/ng2-alfresco-userinfo/graphs/contributors) diff --git a/ng2-components/ng2-alfresco-userinfo/demo/.editorconfig b/ng2-components/ng2-alfresco-userinfo-old/demo/.editorconfig similarity index 100% rename from ng2-components/ng2-alfresco-userinfo/demo/.editorconfig rename to ng2-components/ng2-alfresco-userinfo-old/demo/.editorconfig diff --git a/ng2-components/ng2-alfresco-userinfo-old/demo/.gitignore b/ng2-components/ng2-alfresco-userinfo-old/demo/.gitignore new file mode 100644 index 0000000000..7c04460244 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/demo/.gitignore @@ -0,0 +1,5 @@ +typings/ +node_modules/ +.idea +dist/ +!systemjs.config.js diff --git a/ng2-components/ng2-alfresco-userinfo-old/demo/README.md b/ng2-components/ng2-alfresco-userinfo-old/demo/README.md new file mode 100644 index 0000000000..7b59778398 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/demo/README.md @@ -0,0 +1,19 @@ +# ng2-alfresco-userinfo - Demo + +* To install dependencies + +```sh +$ npm install +``` + +* To provide a live demo + +```sh +$ npm run start +``` + +* To clean npm_modules and typings folder + +```sh +$ npm run clean +``` diff --git a/ng2-components/ng2-alfresco-userinfo-old/demo/index.html b/ng2-components/ng2-alfresco-userinfo-old/demo/index.html new file mode 100644 index 0000000000..ab1420147f --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/demo/index.html @@ -0,0 +1,71 @@ + + + + + + + NgModule Minimal + + + + + + + + + + + + + + + + +Loading... + + + + + \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-userinfo-old/demo/package.json b/ng2-components/ng2-alfresco-userinfo-old/demo/package.json new file mode 100644 index 0000000000..3cc656550a --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/demo/package.json @@ -0,0 +1,89 @@ +{ + "name": "ng2-alfresco-userinfo-demo", + "description": "This component will show the user information for ECM and BPM - Demo", + "version": "0.1.0", + "author": "vito albano ", + "scripts": { + "clean": "rimraf dist node_modules", + "build": "npm run tslint && rimraf dist && tsc && npm run copy-dist", + "build:w": "npm run tslint && rimraf dist && npm run watch-task", + "watch-task": "concurrently \"npm run tsc:w\" \"npm run copy-dist:w\" ", + "start": "npm run build && concurrently \"npm run tsc:w\" \"npm run server\" ", + "server": "wsrv -o -l -s", + "tslint": "tslint -c tslint.json *.ts && tslint -c tslint.json 'src/{,**/}**.ts'", + "copy-dist": "cpx \"./src/**/*.{html,css,json,png,jpg,gif,svg}\" ./dist/src", + "copy-dist:w": "cpx \"./src/**/*.{html,css,json,png,jpg,gif,svg}\" ./dist/src -w", + "tsc": "tsc", + "tsc:w": "tsc -w", + "pretest": "npm run build", + "test": "karma start karma.conf.js --reporters mocha,coverage --single-run", + "test-browser": "npm run build && concurrently \"karma start karma.conf.js --reporters kjhtml\" \"npm run watch-task\"" + }, + "main": "index.js", + "typings": "./dist/index.d.ts", + "repository": { + "type": "git", + "url": "https://github.com/Alfresco/alfresco-ng2-components.git" + }, + "bugs": { + "url": "https://github.com/Alfresco/alfresco-ng2-components/issues" + }, + "license": "Apache-2.0", + "contributors": [ + { + "name": "Vito Albano", + "email": "vito.albano@alfresco.com" + } + ], + "keywords": [ + "ng2", + "angular", + "angular2", + "alfresco", + "demo" + ], + "dependencies": { + "@angular/common": "2.0.0", + "@angular/compiler": "2.0.0", + "@angular/core": "2.0.0", + + "@angular/http": "2.0.0", + "@angular/platform-browser": "2.0.0", + "@angular/platform-browser-dynamic": "2.0.0", + "@angular/router": "3.0.0", + "@angular/upgrade": "2.0.0", + "core-js": "^2.4.1", + "reflect-metadata": "^0.1.3", + "rxjs": "5.0.0-beta.12", + "systemjs": "0.19.27", + "zone.js": "^0.6.23", + "ng2-translate": "2.5.0", + "ng2-alfresco-core": "0.3.2", + "material-design-icons": "2.2.3", + "material-design-lite": "1.2.1", + "ng2-alfresco-userinfo": "file:../" + }, + "devDependencies": { + "@types/core-js": "^0.9.32", + "@types/jasmine": "^2.2.33", + "concurrently": "^2.2.0", + "cpx": "1.3.1", + "jasmine-ajax": "3.2.0", + "jasmine-core": "2.4.1", + "karma": "0.13.22", + "karma-chrome-launcher": "1.0.1", + "karma-coverage": "1.0.0", + "karma-jasmine": "1.0.2", + "karma-jasmine-ajax": "^0.1.13", + "karma-jasmine-html-reporter": "0.2.0", + "karma-mocha-reporter": "2.0.3", + "license-check": "1.1.5", + "remap-istanbul": "0.6.3", + "rimraf": "2.5.2", + "traceur": "0.0.91", + "tslint": "3.8.1", + "typescript": "^2.0.3", + "wsrv": "^0.1.5" + } + +} diff --git a/ng2-components/ng2-alfresco-userinfo-old/demo/src/main.ts b/ng2-components/ng2-alfresco-userinfo-old/demo/src/main.ts new file mode 100644 index 0000000000..0e50689d4d --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/demo/src/main.ts @@ -0,0 +1,95 @@ +/* +import { NgModule, Component, OnInit } from '@angular/core'; +import { UserInfoComponent } from 'ng2-alfresco-userinfo'; +import { BrowserModule } from '@angular/platform-browser'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { CoreModule, + AlfrescoSettingsService, + AlfrescoAuthenticationService } from 'ng2-alfresco-core'; + +@Component({ + selector: 'my-app', + styles: [`:host h1 { font-size:22px }`], + template: `

TEST

` +}) + + +class UserInfoDemo implements OnInit { + + public userToLogin: string = 'admin'; + public password: string = 'admin'; + public loginErrorMessage: string; + public providers: string = 'BPM'; + private authenticated: boolean; + private token: any; + + constructor(private authService: AlfrescoAuthenticationService, + private settingsService: AlfrescoSettingsService) { + } + + ngOnInit() { + this.settingsService.setProviders(this.providers); + } + + attemptLogin() { + this.loginErrorMessage = ''; + this.login(this.userToLogin, this.password); + } + + logout() { + this.authService.logout(); + } + + login(user, password) { + this.settingsService.setProviders(this.providers); + this.authService.login(user, password).subscribe( + token => { + console.log(token); + this.token = token; + this.authenticated = true; + }, + error => { + console.log(error); + this.authenticated = false; + this.loginErrorMessage = error; + }); + } + + isLoggedIn(): boolean { + return this.authService.isLoggedIn(); + } + + toggleECM(checked) { + if (checked && this.providers === 'BPM') { + this.providers = 'ALL'; + } else if (checked) { + this.providers = 'ECM'; + } else { + this.providers = undefined; + } + } + + toggleBPM(checked) { + if (checked && this.providers === 'ECM') { + this.providers = 'ALL'; + } else if (checked) { + this.providers = 'BPM'; + } else { + this.providers = undefined; + } + } +} + +@NgModule({ + imports: [ + BrowserModule, + CoreModule.forRoot(), + UserInfoComponent + ], + declarations: [ UserInfoComponent ], + bootstrap: [ UserInfoComponent ] +}) +export class AppModule { } + +platformBrowserDynamic().bootstrapModule(AppModule); +*/ diff --git a/ng2-components/ng2-alfresco-userinfo/demo/systemjs.config.js b/ng2-components/ng2-alfresco-userinfo-old/demo/systemjs.config.js similarity index 100% rename from ng2-components/ng2-alfresco-userinfo/demo/systemjs.config.js rename to ng2-components/ng2-alfresco-userinfo-old/demo/systemjs.config.js diff --git a/ng2-components/ng2-alfresco-userinfo/demo/tsconfig.json b/ng2-components/ng2-alfresco-userinfo-old/demo/tsconfig.json similarity index 54% rename from ng2-components/ng2-alfresco-userinfo/demo/tsconfig.json rename to ng2-components/ng2-alfresco-userinfo-old/demo/tsconfig.json index 772c3a7e75..2712940af4 100644 --- a/ng2-components/ng2-alfresco-userinfo/demo/tsconfig.json +++ b/ng2-components/ng2-alfresco-userinfo-old/demo/tsconfig.json @@ -1,4 +1,4 @@ -{ +/*{ "compilerOptions": { "target": "es5", "module": "system", @@ -16,4 +16,18 @@ "typings/main", "typings/main.d.ts" ] -} +} */ + +{ + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "moduleResolution": "node", + "sourceMap": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "removeComments": false, + "noImplicitAny": true, + "suppressImplicitAnyIndexErrors": true + } +} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-userinfo-old/demo/tslint.json b/ng2-components/ng2-alfresco-userinfo-old/demo/tslint.json new file mode 100644 index 0000000000..8c48e76469 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/demo/tslint.json @@ -0,0 +1,124 @@ +{ + "rules": { + "align": [ + true, + "parameters", + "arguments", + "statements" + ], + "ban": false, + "class-name": true, + "comment-format": [ + true, + "check-space", + "check-lowercase" + ], + "curly": true, + "eofline": true, + "forin": true, + "indent": [ + true, + "spaces" + ], + "interface-name": false, + "jsdoc-format": true, + "label-position": true, + "label-undefined": true, + "max-line-length": [ + true, + 140 + ], + "member-ordering": [ + true, + "public-before-private", + "static-before-instance", + "variables-before-functions" + ], + "no-any": false, + "no-arg": true, + "no-bitwise": true, + "no-conditional-assignment": true, + "no-consecutive-blank-lines": false, + "no-console": [ + true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-construct": true, + "no-constructor-vars": false, + "no-debugger": true, + "no-duplicate-key": true, + "no-duplicate-variable": true, + "no-empty": true, + "no-eval": true, + "no-inferrable-types": false, + "no-internal-module": true, + "no-require-imports": true, + "no-shadowed-variable": true, + "no-switch-case-fall-through": true, + "no-trailing-whitespace": true, + "no-unreachable": true, + "no-unused-expression": true, + "no-unused-variable": true, + "no-use-before-declare": true, + "no-var-keyword": true, + "no-var-requires": true, + "object-literal-sort-keys": false, + "one-line": [ + true, + "check-open-brace", + "check-catch", + "check-else", + "check-whitespace" + ], + "quotemark": [ + true, + "single", + "avoid-escape" + ], + "radix": true, + "semicolon": true, + "switch-default": true, + "trailing-comma": [ + true, + { + "multiline": "never", + "singleline": "never" + } + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "typedef": false, + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "use-strict": false, + "variable-name": [ + true, + "check-format", + "allow-leading-underscore", + "ban-keywords" + ], + "whitespace": [ + true, + "check-branch", + "check-operator", + "check-separator", + "check-type", + "check-module", + "check-decl" + ] + } +} diff --git a/ng2-components/ng2-alfresco-userinfo/demo/typings.json b/ng2-components/ng2-alfresco-userinfo-old/demo/typings.json similarity index 100% rename from ng2-components/ng2-alfresco-userinfo/demo/typings.json rename to ng2-components/ng2-alfresco-userinfo-old/demo/typings.json diff --git a/ng2-components/ng2-alfresco-userinfo-old/index.ts b/ng2-components/ng2-alfresco-userinfo-old/index.ts new file mode 100644 index 0000000000..6f5555dbda --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/index.ts @@ -0,0 +1,58 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed 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. + */ + +import { NgModule, ModuleWithProviders } from '@angular/core'; +import { CoreModule } from 'ng2-alfresco-core'; +import { EcmUserService } from './src/services/ecm-user.service'; +import { BpmUserService } from './src/services/bpm-user.service'; +import { UserInfoComponent } from './src/components/user-info.component'; +import { AlfrescoAuthenticationService } from 'ng2-alfresco-core'; + +export * from './src/components/user-info.component'; +export * from './src/services/bpm-user.service'; +export * from './src/services/ecm-user.service'; + +export const USER_INFO_SERVICE: any[] = [ + EcmUserService, + BpmUserService, + AlfrescoAuthenticationService +]; + +@NgModule({ + imports: [ + CoreModule + ], + declarations: [ + UserInfoComponent + ], + providers: [ + ...USER_INFO_SERVICE + ], + exports: [ + UserInfoComponent + ] +}) +export class UserInfoComponentModule { + static forRoot(): ModuleWithProviders { + return { + ngModule: UserInfoComponentModule, + providers: [ + ...USER_INFO_SERVICE + ] + }; + } +} diff --git a/ng2-components/ng2-alfresco-userinfo-old/karma-test-shim.js b/ng2-components/ng2-alfresco-userinfo-old/karma-test-shim.js new file mode 100644 index 0000000000..fb1c3905f3 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/karma-test-shim.js @@ -0,0 +1,128 @@ +// Tun on full stack traces in errors to help debugging +Error.stackTraceLimit = Infinity; + +jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000; + +__karma__.loaded = function() {}; + +var builtPath = '/base/dist/'; + +function isJsFile(path) { + return path.slice(-3) == '.js'; +} + +function isSpecFile(path) { + return /\.spec\.(.*\.)?js$/.test(path); +} + +function isBuiltFile(path) { + return isJsFile(path) && (path.substr(0, builtPath.length) == builtPath); +} + +var allSpecFiles = Object.keys(window.__karma__.files) + .filter(isSpecFile) + .filter(isBuiltFile); + +var paths = { + // paths serve as alias + 'npm:': 'base/node_modules/' +}; + +var map = { + 'app': 'base/dist', + // angular bundles + '@angular/core': 'npm:@angular/core/bundles/core.umd.js', + '@angular/common': 'npm:@angular/common/bundles/common.umd.js', + '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js', + '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js', + '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js', + '@angular/http': 'npm:@angular/http/bundles/http.umd.js', + '@angular/router': 'npm:@angular/router/bundles/router.umd.js', + '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js', + // testing + '@angular/core/testing': 'npm:@angular/core/bundles/core-testing.umd.js', + '@angular/common/testing': 'npm:@angular/common/bundles/common-testing.umd.js', + '@angular/compiler/testing': 'npm:@angular/compiler/bundles/compiler-testing.umd.js', + '@angular/platform-browser/testing': 'npm:@angular/platform-browser/bundles/platform-browser-testing.umd.js', + '@angular/platform-browser-dynamic/testing': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js', + '@angular/http/testing': 'npm:@angular/http/bundles/http-testing.umd.js', + '@angular/router/testing': 'npm:@angular/router/bundles/router-testing.umd.js', + '@angular/forms/testing': 'npm:@angular/forms/bundles/forms-testing.umd.js', + + // other libraries + 'rxjs': 'npm:rxjs', + 'ng2-translate': 'npm:ng2-translate', + + 'alfresco-js-api': 'npm:alfresco-js-api/dist', + 'ng2-activiti-form': 'npm:ng2-activiti-form/dist', + 'ng2-activiti-processlist': 'npm:ng2-activiti-processlist/dist', + 'ng2-activiti-tasklist': 'npm:ng2-activiti-tasklist/dist', + 'ng2-alfresco-core': 'npm:ng2-alfresco-core/dist', + 'ng2-alfresco-datatable': 'npm:ng2-alfresco-datatable/dist', + 'ng2-alfresco-documentlist': 'npm:ng2-alfresco-documentlist/dist', + 'ng2-alfresco-login': 'npm:ng2-alfresco-login/dist', + 'ng2-alfresco-search': 'npm:ng2-alfresco-search/dist', + 'ng2-alfresco-tag': 'npm:ng2-alfresco-tag/dist', + 'ng2-alfresco-upload': 'npm:ng2-alfresco-upload/dist', + 'ng2-alfresco-viewer': 'npm:ng2-alfresco-viewer/dist', + 'ng2-alfresco-webscript': 'npm:ng2-alfresco-webscript/dist', + 'ng2-alfresco-userinfo': 'npm:ng2-alfresco-userinfo/dist' +}; + +var packages = { + 'app': { main: 'index.js', defaultExtension: 'js', format: 'register' }, + 'rxjs': { defaultExtension: 'js' }, + 'ng2-translate': { defaultExtension: 'js' }, + + 'alfresco-js-api': { main: './alfresco-js-api.js', defaultExtension: 'js'}, + 'ng2-activiti-form': { main: './index.js', defaultExtension: 'js'}, + 'ng2-activiti-processlist': { main: './index.js', defaultExtension: 'js'}, + 'ng2-activiti-tasklist': { main: './index.js', defaultExtension: 'js'}, + 'ng2-alfresco-core': { main: './index.js', defaultExtension: 'js'}, + 'ng2-alfresco-datatable': { main: './index.js', defaultExtension: 'js'}, + 'ng2-alfresco-documentlist': { main: './index.js', defaultExtension: 'js'}, + 'ng2-alfresco-login': { main: './index.js', defaultExtension: 'js'}, + 'ng2-alfresco-search': { main: './index.js', defaultExtension: 'js'}, + 'ng2-alfresco-tag': { main: './index.js', defaultExtension: 'js'}, + 'ng2-alfresco-upload': { main: './index.js', defaultExtension: 'js'}, + 'ng2-alfresco-viewer': { main: './index.js', defaultExtension: 'js'}, + 'ng2-alfresco-webscript': { main: './index.js', defaultExtension: 'js'}, + 'ng2-alfresco-userinfo': { main: './index.js', defaultExtension: 'js'} +}; + +var config = { + paths: paths, + map: map, + packages: packages +}; + +System.config(config); + +System.import('app') + .then(initTestBed) + .then(initTesting); + +function initTestBed(){ + return Promise.all([ + System.import('@angular/core/testing'), + System.import('@angular/platform-browser-dynamic/testing') + ]) + .then(function (providers) { + var coreTesting = providers[0]; + var browserTesting = providers[1]; + + coreTesting.TestBed.initTestEnvironment( + browserTesting.BrowserDynamicTestingModule, + browserTesting.platformBrowserDynamicTesting()); + }) +} + +// Import all spec files and start karma +function initTesting () { + return Promise.all( + allSpecFiles.map(function (moduleName) { + return System.import(moduleName); + }) + ) + .then(__karma__.start, __karma__.error); +} diff --git a/ng2-components/ng2-alfresco-userinfo-old/karma.conf.js b/ng2-components/ng2-alfresco-userinfo-old/karma.conf.js new file mode 100644 index 0000000000..c0374b25c3 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/karma.conf.js @@ -0,0 +1,131 @@ +'use strict'; + +module.exports = function (config) { + var configuration = { + basePath: '.', + + frameworks: ['jasmine-ajax', 'jasmine'], + + files: [ + // System.js for module loading + 'node_modules/systemjs/dist/system.src.js', + + // Polyfills + 'node_modules/core-js/client/shim.js', + 'node_modules/reflect-metadata/Reflect.js', + + // zone.js + 'node_modules/zone.js/dist/zone.js', + 'node_modules/zone.js/dist/long-stack-trace-zone.js', + 'node_modules/zone.js/dist/proxy.js', + 'node_modules/zone.js/dist/sync-test.js', + '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', + + // 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: + // Angular itself + {pattern: 'node_modules/@angular/**/*.js', included: false, watched: false}, + {pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false}, + + 'node_modules/alfresco-js-api/dist/alfresco-js-api.js', + {pattern: 'node_modules/ng2-translate/**/*.js', included: false, watched: false}, + {pattern: 'node_modules/ng2-translate/**/*.js.map', included: false, watched: false}, + + 'karma-test-shim.js', + + // paths loaded via module imports + {pattern: 'dist/**/*.js', included: false, watched: true}, + {pattern: 'dist/**/*.html', included: true, served: true, watched: true}, + {pattern: 'dist/**/*.css', included: true, served: true, watched: true}, + + // ng2-components + { pattern: 'node_modules/ng2-activiti-form/dist/**/*.js', included: false, served: true, watched: false }, + { pattern: 'node_modules/ng2-activiti-processlist/dist/**/*.js', included: false, served: true, watched: false }, + { pattern: 'node_modules/ng2-activiti-tasklist/dist/**/*.js', included: false, served: true, watched: false }, + { pattern: 'node_modules/ng2-alfresco-core/dist/**/*.js', included: false, served: true, watched: false }, + { pattern: 'node_modules/ng2-alfresco-datatable/dist/**/*.js', included: false, served: true, watched: false }, + { pattern: 'node_modules/ng2-alfresco-documentlist/dist/**/*.js', included: false, served: true, watched: false }, + { pattern: 'node_modules/ng2-alfresco-login/dist/**/*.js', included: false, served: true, watched: false }, + { pattern: 'node_modules/ng2-alfresco-search/dist/**/*.js', included: false, served: true, watched: false }, + { pattern: 'node_modules/ng2-alfresco-tag/dist/**/*.js', included: false, served: true, watched: false }, + { pattern: 'node_modules/ng2-alfresco-upload/dist/**/*.js', included: false, served: true, watched: false }, + { pattern: 'node_modules/ng2-alfresco-viewer/dist/**/*.js', included: false, served: true, watched: false }, + { pattern: 'node_modules/ng2-alfresco-webscript/dist/**/*.js', included: false, served: true, watched: false }, + { pattern: 'node_modules/ng2-alfresco-userinfo/dist/**/*.js', included: false, served: true, watched: false }, + + // paths to support debugging with source maps in dev tools + {pattern: 'src/**/*.ts', included: false, watched: false}, + {pattern: 'dist/**/*.js.map', included: false, watched: false} + ], + + exclude: [ + 'node_modules/**/*spec.js' + ], + + // proxied base paths + proxies: { + // required for component assets fetched by Angular's compiler + '/src/': '/base/src/' + }, + + port: 9876, + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + colors: true, + + autoWatch: true, + + browsers: ['Chrome'], + + customLaunchers: { + Chrome_travis_ci: { + base: 'Chrome', + flags: ['--no-sandbox'] + } + }, + + // Karma plugins loaded + plugins: [ + 'karma-jasmine', + 'karma-coverage', + 'karma-jasmine-ajax', + 'karma-chrome-launcher', + 'karma-mocha-reporter', + 'karma-jasmine-html-reporter' + ], + + // Coverage reporter generates the coverage + reporters: ['mocha', 'coverage', 'kjhtml'], + + // Source files that you wanna generate coverage for. + // Do not include tests or libraries (these files will be instrumented by Istanbul) + preprocessors: { + // 'dist/**/!(*spec).js': ['coverage'] + }, + + coverageReporter: { + dir: 'coverage/', + subdir: 'report', + reporters: [ + {type: 'text'}, + {type: 'json', file: 'coverage-final.json'}, + {type: 'html'}, + {type: 'lcov'} + ] + } + }; + + if (process.env.TRAVIS) { + configuration.browsers = ['Chrome_travis_ci']; + } + + config.set(configuration) +}; diff --git a/ng2-components/ng2-alfresco-userinfo-old/package.json b/ng2-components/ng2-alfresco-userinfo-old/package.json new file mode 100644 index 0000000000..e7981fb168 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/package.json @@ -0,0 +1,94 @@ +{ + "name": "ng2-alfresco-userinfo", + "description": "This component will show the user information for ECM and BPM", + "version": "0.1.0", + "author": "vito albano ", + "scripts": { + "clean": "rimraf dist node_modules", + "build": "npm run tslint && rimraf dist && tsc && npm run copy-dist", + "build:w": "npm run tslint && rimraf dist && npm run watch-task", + "watch-task": "concurrently \"npm run tsc:w\" \"npm run copy-dist:w\" \"license-check\"", + "tslint": "tslint -c tslint.json *.ts && tslint -c tslint.json 'src/{,**/}**.ts'", + "copy-dist": "cpx \"./src/**/*.{html,css,json,png,jpg,gif,svg}\" ./dist/src", + "copy-dist:w": "cpx \"./src/**/*.{html,css,json,png,jpg,gif,svg}\" ./dist/src -w", + "tsc": "tsc", + "tsc:w": "tsc -w", + "pretest": "npm run build", + "test": "karma start karma.conf.js --reporters mocha,coverage --single-run", + "test-browser": "npm run build && concurrently \"karma start karma.conf.js --reporters kjhtml\" \"npm run watch-task\"", + "posttest": "remap-istanbul -i coverage/report/coverage-final.json -o coverage/report -t html && remap-istanbul -i coverage/report/coverage-final.json -o coverage/report/coverage-final.json", + "coverage": "npm run test && wsrv -o -p 9875 ./coverage/report", + "travis": "npm link ng2-alfresco-core" + }, + "main": "./dist/index.js", + "typings": "./dist/index.d.ts", + "repository": { + "type": "git", + "url": "https://github.com/Alfresco/alfresco-ng2-components.git" + }, + "bugs": { + "url": "https://github.com/Alfresco/alfresco-ng2-components/issues" + }, + "license": "Apache-2.0", + "contributors": [ + { + "name": "Vito Albano", + "email": "vito.albano@alfresco.com" + } + ], + "keywords": [ + "ng2", + "angular", + "angular2", + "alfresco" + ], + "dependencies": { + "@angular/common": "2.0.0", + "@angular/compiler": "2.0.0", + "@angular/core": "2.0.0", + "@angular/forms": "2.0.0", + "@angular/http": "2.0.0", + "@angular/platform-browser": "2.0.0", + "@angular/platform-browser-dynamic": "2.0.0", + "@angular/router": "3.0.0", + "@angular/upgrade": "2.0.0", + "core-js": "^2.4.1", + "reflect-metadata": "^0.1.3", + "rxjs": "5.0.0-beta.12", + "systemjs": "0.19.27", + "zone.js": "^0.6.23", + "ng2-translate": "2.5.0", + "ng2-alfresco-core": "0.3.2" + }, + "devDependencies": { + "@types/core-js": "^0.9.32", + "@types/jasmine": "^2.2.33", + "concurrently": "^2.2.0", + "cpx": "1.3.1", + "jasmine-ajax": "3.2.0", + "jasmine-core": "2.4.1", + "karma": "0.13.22", + "karma-chrome-launcher": "1.0.1", + "karma-coverage": "1.0.0", + "karma-jasmine": "1.0.2", + "karma-jasmine-ajax": "^0.1.13", + "karma-jasmine-html-reporter": "0.2.0", + "karma-mocha-reporter": "2.0.3", + "license-check": "1.1.5", + "remap-istanbul": "0.6.3", + "rimraf": "2.5.2", + "traceur": "0.0.91", + "tslint": "3.8.1", + "typescript": "^2.0.2", + "wsrv": "^0.1.5" + }, + "license-check-config": { + "src": [ + "./dist/**/*.js" + ], + "path": "assets/license_header.txt", + "blocking": true, + "logInfo": false, + "logError": true + } +} diff --git a/ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.css b/ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.css new file mode 100644 index 0000000000..93254d00fa --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.css @@ -0,0 +1,53 @@ +.profile-image { + text-align: center; + border-radius: 90%; + width: 40px; + margin-right: 0%; + cursor: pointer; + border: 1px solid #999999; + vertical-align: middle; +} + +.button-profile { + display: inline-block; + border: 0px; + vertical-align: middle; +} + +.detail-user-profile-list-mdl{ + margin-right: 10px; +} + +.user-profile-list-mdl{ + max-height: 450px; + min-width: 450px; + overflow: auto; +} + +.header-profile{ + color: rgb(255,152,0); + margin-left: 10px; +} + +hr.title-start { + border: 0; + height: 1px; + background: #333; + background-image: linear-gradient(to right, #ccc, #333, #ccc); +} + +span.role-label-user{ + font-weight: 400; + line-height: 1; + letter-spacing: 0; + color: rgba(0,0,0,.87); +} + +.custom-role-style{ + font-size: 14px; + color: #9e9e9e; +} + +.truncate-long-names{ + text-overflow: ellipsis; +} diff --git a/ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.html b/ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.html new file mode 100644 index 0000000000..8c01dc7120 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.html @@ -0,0 +1,63 @@ +
+ {{ecmUser.firstName || ecmUser.lastName}} + + {{ formatValue(bpmUser.firstName) || + formatValue(bpmUser.lastName) || + formatValue(bpmUser.fullName) }} + +
+ +
+ +
+ + diff --git a/ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.spec.ts b/ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.spec.ts new file mode 100644 index 0000000000..a91e2f2ac8 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.spec.ts @@ -0,0 +1,25 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed 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. + */ +// import { UserInfoComponent } from '../src/userinfo.component'; + +describe('Basic Example test ng2-alfresco-userinfo', () => { + + it('Test hello world', () => { + expect(true).toBe(true); + }); + +}); diff --git a/ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.ts b/ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.ts new file mode 100644 index 0000000000..5154ab5dcf --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.ts @@ -0,0 +1,93 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed 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. + */ + +import { Component, OnInit } from '@angular/core'; +import { EcmUserModel } from './../models/ecm-user.model'; +import { BpmUserModel } from './../models/bpm-user.model'; +import { EcmUserService } from './../services/ecm-user.service'; +import { BpmUserService } from './../services/bpm-user.service'; +import { AlfrescoAuthenticationService } from 'ng2-alfresco-core'; + +declare let __moduleName: string; + +@Component({ + selector: 'ng2-alfresco-userinfo', + moduleId: __moduleName, + styleUrls: ['./userinfo.component.css'], + template: `

HELLO

` +}) + +export class UserInfoComponent implements OnInit { + + private ecmUser: EcmUserModel; + private bpmUser: BpmUserModel; + private baseComponentPath = __moduleName.replace('userinfo.component.js', ''); + private anonymouseImageUrl: string = this.baseComponentPath + 'img/anonymous.gif'; + public bpmUserImage: any; + public ecmUserImage: any; + + constructor(private ecmUserService: EcmUserService, + private bpmUserService: BpmUserService, + public authService: AlfrescoAuthenticationService) { + } + + ngOnInit() { + if (this.authService.getAlfrescoApi().ecmAuth.isLoggedIn()) { + this.ecmUserService.getUserInfo('-me-') + .subscribe( + (res) => { + this.ecmUser = res; + this.getEcmUserProfileImage(); + } + ); + } + if (this.authService.getAlfrescoApi().bpmAuth.isLoggedIn()) { + this.bpmUserService.getCurrentUserInfo() + .subscribe( + (res) => { + this.bpmUser = res; + this.getBpmUserProfileImage(); + } + ); + } + } + + private getBpmUserProfileImage() { + this.bpmUserImage = this.bpmUserService.getCurrentUserProfileImage(); + } + + private getEcmUserProfileImage() { + this.ecmUserImage = this.ecmUserService.getCurrentUserProfileImageUrl(this.ecmUser.avatarId); + } + + public getUserAvatar() { + return this.ecmUserImage || this.bpmUserImage || this.anonymouseImageUrl; + } + + public getBpmUserDetailAvatarUrl() { + return this.bpmUserImage || this.anonymouseImageUrl; + } + + public getEcmUserDetailAvatarUrl() { + return this.ecmUserImage || this.anonymouseImageUrl; + } + + public formatValue(value: string) { + return value === 'null' ? null : value; + } + +} diff --git a/ng2-components/ng2-alfresco-userinfo-old/src/i18n/en.json b/ng2-components/ng2-alfresco-userinfo-old/src/i18n/en.json new file mode 100644 index 0000000000..9400e18911 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/src/i18n/en.json @@ -0,0 +1,24 @@ +{ + "FILE_UPLOAD": { + "BUTTON": { + "UPLOAD_FILE": "Upload file", + "UPLOAD_FOLDER": "Upload folder", + "CANCEL": "CANCEL" + }, + "MESSAGES": { + "COMPLETED": "uploads complete", + "PROGRESS": "Upload in progress...", + "FOLDER_ALREADY_EXIST": "The folder {0} already exist", + "FOLDER_NOT_SUPPORTED": "Folder upload isn't supported by your browser" + }, + "FILE_INFO": { + "NAME": "File name", + "PROGRESS": "File progress", + "SIZE": "File size", + "ACTION": "Actions" + }, + "ACTION": { + "UNDO": "Undo" + } + } +} diff --git a/ng2-components/ng2-alfresco-userinfo-old/src/i18n/it.json b/ng2-components/ng2-alfresco-userinfo-old/src/i18n/it.json new file mode 100644 index 0000000000..0208da3079 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/src/i18n/it.json @@ -0,0 +1,24 @@ +{ + "FILE_UPLOAD": { + "BUTTON": { + "UPLOAD_FILE": "Carica un file", + "UPLOAD_FOLDER": "Carica una cartella", + "CANCEL": "CANCELLA" + }, + "MESSAGES": { + "COMPLETED": "caricamenti completati", + "PROGRESS": "caricamento in corso...", + "FOLDER_ALREADY_EXIST": "Cartella {0} già presente", + "FOLDER_NOT_SUPPORTED": "L' upload di cartelle non é supportato dal tuo browser" + }, + "FILE_INFO": { + "NAME": "Nome file", + "PROGRESS": "Percentuale caricamento", + "SIZE": "Dimensione file", + "ACTION": "Azioni" + }, + "ACTION": { + "UNDO": "Annulla" + } + } +} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-userinfo-old/src/img/anonymous.gif b/ng2-components/ng2-alfresco-userinfo-old/src/img/anonymous.gif new file mode 100644 index 0000000000000000000000000000000000000000..e1b58fa57dfcdfd452ec498c98b930aa905d21d6 GIT binary patch literal 1765 zcmb8pizCyC0|4;vcMq|L=guW!Vi%c59pzQG$YVmt(9<&qUk|0_<~^#dpPrfJR`3LkEhFNwuD*UseB%E9NpnxZIwFun4Gh4>giwRA zc0?x^01y1ne**w~537AIAf!0BrjESujDjDc-khY>t=wMO?<%F(;}2yFR74Dt%}a)P zREJt`!8kwqm|RZoeK}|r3IHK##rgzkWXR z#*`{VI@~f{tInV0ukwK$G*WXf9#@J?Z!6r2$!xjap@7u(QUCMI;#?2#}9bcnDw%MSwt8tuX$>-NEJGdr(T*AtL&uqN~#WT z-g_QP^LsP+c=+}i&ztKwm?_}Wl%Vf);6;vy(fFPKq-Krf{zpQvQICg(?Ug@>Nx&U+ zjC*f3!1kFY4zS~t!;(qN5%NIU3H4v3)8o8SJ&}xYli-Iq9S6HVS;BT^QM6I<7xiew zs43F&{rZ7&()90DAGOE2XC;|(F#99fIapv)+E_ML>o!h2H=U!U*6L3=``J^Qqoo7W zf@~)ZW~T7YOjSR6)Sl9&+Nd*+aNRrksZvj^#`9rO9o8rC1d|21)u|F3inL-f#Wi}R<~|kmHN&5; z3B)yYe%YIv8;IuZpFayGV;%0-^uB2NgFe{gg7ft_xj^TT_Y{uR${^)A3ysIpSs39& z9ijG;m}vnKkiUg2%P?vsYQCJO@$_OV@CO0Hu)t)o;|R^??X%tO1-F=8j*)@eCsBO8 zi%eVFsxw-!Lvd0lwD|S>cPa5}M3u<4Tb}T$Ox;$^a_lM*m{i5Pu{oB{h2Ay`Po(Dx zD#N-MNvdBGX_`Lud8}5idh^1LixlXK&^sCJ@PI-IJn*VhrM|k_W5)x{ zzhbeqUP%h#MU{Oa-7EuT&#~1EiAPO=nPq4Rbk@D@* z6M~fh0C=qA2Fx`k=Mt6^izaq#br)QLk3CvAW9%+&^6yXaFr(JLRl%+P{?WF8(;BaX zE{t!)7R`6~pLq*@-8wtlZL#g$h)*e9)U%B{XxYCXGPN_V;k|Z!l;3$33aB3vZ~j!f z8jhOM^$Qdom4h>-B7!MgsLVCNNk__$82?`QspL*0zwl&CWb!J(Q;GX2gTXNKJLh7b zN8^5=;xVjOqw+n`ziQf<^ritlK&M(Z8LjoT%+`GX4nZhrFaHSbxJOg`KARNhh?nMx zGP`u#0?`@`N33T&?%+eSu$L?L=-+paXBat?0s^Lq(6>66KiD9fJaJdGPrldmp)ES9 zq5Q@w&+dWzairp+mQ9lhlYn@l$-pFQ%6Vm;W0F$S`6)^oDnz!UA}W)wZD#Nf-02yE zSxiRiSbJrnHZpS2^QFqWDWYiJ2_&D4GxJTob6game4Rnp4-a8oK0|uY-oP;ACYJg= zfzq$)JUSkdEEQ-FsXFl0O1;D@^(Svq!Dtb~|zD{Xe%&8EA}t;;Z>bJpL9WgQD_~sHG5(h>mr{Irog}T$u=eqGe-Q&yn=bw z7r-~(&JD^vmmxkz!hBa8Ik(`jlhvudkmrW!#)Y{1Gd3YvBL>qqDmh!%F}{e44g(m3 zaqT=bY?~3aCoJ(;oj;Ql3NL$?!}~e$!?~b?QkCYp)qa#vtFm`QZozZZrH&eTD*&+g E7ZAQxl>h($ literal 0 HcmV?d00001 diff --git a/ng2-components/ng2-alfresco-userinfo-old/src/models/bpm-user.model.ts b/ng2-components/ng2-alfresco-userinfo-old/src/models/bpm-user.model.ts new file mode 100644 index 0000000000..3ee3fd7222 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/src/models/bpm-user.model.ts @@ -0,0 +1,39 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed 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. + */ + +export class BpmUserModel { + apps: any; + capabilities: string; + company: string; + created: string; + email: string; + externalId: string; + firstName: string; + lastName: string; + fullname: string; + groups: any; + id: string; + lastUpdate: string; + latestSyncTimeStamp: string; + password: string; + pictureId: string; + status: string; + tenantId: string; + tenantName: string; + tenantPictureId: string; + type: string; +} diff --git a/ng2-components/ng2-alfresco-userinfo-old/src/models/ecm-company.model.ts b/ng2-components/ng2-alfresco-userinfo-old/src/models/ecm-company.model.ts new file mode 100644 index 0000000000..458b6b8ed5 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/src/models/ecm-company.model.ts @@ -0,0 +1,27 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed 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. + */ + +export class EcmCompanyModel { + organization: string; + address1: string; + address2: string; + address3: string; + postcode: string; + telephone: string; + fax: string; + email: string; +} diff --git a/ng2-components/ng2-alfresco-userinfo-old/src/models/ecm-user.model.ts b/ng2-components/ng2-alfresco-userinfo-old/src/models/ecm-user.model.ts new file mode 100644 index 0000000000..08f24fbcdb --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/src/models/ecm-user.model.ts @@ -0,0 +1,39 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed 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. + */ + +import { EcmCompanyModel } from './ecm-company.model'; + +export class EcmUserModel { + id: string; + firstName: string; + lastName: string; + description: string; + avatarId: string; + email: string; + skypeId: string; + googleId: string; + instantMessageId: string; + jobTitle: string; + location: string; + company: EcmCompanyModel; + mobile: string; + telephone: string; + statusUpdatedAt: string; + userStatus: string; + enabled: boolean; + emailNotificationsEnabled: boolean; +} diff --git a/ng2-components/ng2-alfresco-userinfo-old/src/services/bpm-user.service.ts b/ng2-components/ng2-alfresco-userinfo-old/src/services/bpm-user.service.ts new file mode 100644 index 0000000000..089320a264 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/src/services/bpm-user.service.ts @@ -0,0 +1,75 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed 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. + */ + +import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core'; +import { Injectable } from '@angular/core'; +import { Response } from '@angular/http'; +import { Observable } from 'rxjs/Rx'; +import { BpmUserModel } from '../models/bpm-user.model'; +/** + * + * BPMUserService retrieve all the information of an Ecm user. + * + * @returns {BPMUserService} . + */ +@Injectable() +export class BpmUserService { + + constructor(private authService: AlfrescoAuthenticationService, + private settingService: AlfrescoSettingsService) { + } + + /** + * get User Information via ECM + * @param userName - the user name + */ + getCurrentUserInfo(): Observable { + if ( this.authService.getAlfrescoApi().bpmAuth.isLoggedIn() ) { + return Observable.fromPromise(this.callApiGetProfile()) + .map( + (data) => data + ) + .catch(this.handleError); + } + } + + /** + * get User Information via ECM + * @param userName - the user name + */ + getCurrentUserProfileImage(): string { + if ( this.authService.getAlfrescoApi().bpmAuth.isLoggedIn() ) { + return this.settingService.getBPMApiBaseUrl() + '/api/enterprise/profile-picture'; + } + } + + private callApiGetProfile() { + return this.authService.getAlfrescoApi().activiti.profileApi.getProfile(); + } + /** + * Throw the error + * @param error + * @returns {ErrorObservable} + */ + private handleError(error: Response) { + // in a real world app, we may send the error to some remote logging infrastructure + // instead of just logging it to the console + console.error(error); + return Observable.throw(error || 'Server error'); + } + +} diff --git a/ng2-components/ng2-alfresco-userinfo-old/src/services/ecm-user.service.ts b/ng2-components/ng2-alfresco-userinfo-old/src/services/ecm-user.service.ts new file mode 100644 index 0000000000..6875ee7d48 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/src/services/ecm-user.service.ts @@ -0,0 +1,72 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed 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. + */ + +import { AlfrescoAuthenticationService, AlfrescoContentService } from 'ng2-alfresco-core'; +import { Injectable } from '@angular/core'; +import { Response } from '@angular/http'; +import { Observable } from 'rxjs/Rx'; +import { EcmUserModel } from '../models/ecm-user.model'; +/** + * + * ECMUserService retrieve all the information of an Ecm user. + * + * @returns {ECMUserService} . + */ +@Injectable() +export class EcmUserService { + + constructor(private authService: AlfrescoAuthenticationService, + private contentService: AlfrescoContentService) {} + + /** + * get User Information via ECM + * @param userName - the user name + */ + getUserInfo(userName: string): Observable { + if ( this.authService.getAlfrescoApi().ecmAuth.isLoggedIn() ) { + return Observable.fromPromise(this.callApiGetPersonInfo(userName)) + .map( + (data) => data['entry'] + ) + .catch(this.handleError); + } + } + + private callApiGetPersonInfo(userName: string, opts?: any) { + return this.authService.getAlfrescoApi().core.peopleApi.getPerson(userName, opts); + } + + getCurrentUserProfileImageUrl(avatarId: string) { + if ( avatarId ) { + let nodeObj = {entry: {id: avatarId}}; + return this.contentService.getContentUrl(nodeObj); + } + } + + /** + * Throw the error + * @param error + * @returns {ErrorObservable} + */ + private handleError(error: Response) { + // in a real world app, we may send the error to some remote logging infrastructure + // instead of just logging it to the console + console.error(error); + return Observable.throw(error || 'Server error'); + } + +} diff --git a/ng2-components/ng2-alfresco-userinfo-old/tsconfig.json b/ng2-components/ng2-alfresco-userinfo-old/tsconfig.json new file mode 100644 index 0000000000..b1effea355 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "system", + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "sourceMap": true, + "removeComments": true, + "declaration": true, + "noLib": false, + "allowUnreachableCode": false, + "allowUnusedLabels": false, + "noImplicitAny": false, + "noImplicitReturns": false, + "noImplicitUseStrict": false, + "noFallthroughCasesInSwitch": true, + "outDir": "dist", + "types": ["core-js", "jasmine"] + }, + "exclude": [ + "demo", + "node_modules", + "dist" + ] +} diff --git a/ng2-components/ng2-alfresco-userinfo-old/tslint.json b/ng2-components/ng2-alfresco-userinfo-old/tslint.json new file mode 100644 index 0000000000..33220e5038 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo-old/tslint.json @@ -0,0 +1,121 @@ +{ + "rules": { + "align": [ + true, + "parameters", + "statements" + ], + "ban": false, + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "curly": true, + "eofline": true, + "forin": true, + "indent": [ + true, + "spaces" + ], + "interface-name": false, + "jsdoc-format": true, + "label-position": true, + "label-undefined": true, + "max-line-length": [ + true, + 140 + ], + "member-ordering": [ + true, + "static-before-instance", + "variables-before-functions" + ], + "no-any": false, + "no-arg": true, + "no-bitwise": false, + "no-conditional-assignment": true, + "no-consecutive-blank-lines": false, + "no-console": [ + true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-construct": true, + "no-constructor-vars": false, + "no-debugger": true, + "no-duplicate-key": true, + "no-duplicate-variable": true, + "no-empty": false, + "no-eval": true, + "no-inferrable-types": false, + "no-internal-module": true, + "no-require-imports": true, + "no-shadowed-variable": true, + "no-switch-case-fall-through": true, + "no-trailing-whitespace": true, + "no-unreachable": true, + "no-unused-expression": true, + "no-unused-variable": true, + "no-use-before-declare": true, + "no-var-keyword": true, + "no-var-requires": true, + "object-literal-sort-keys": false, + "one-line": [ + true, + "check-open-brace", + "check-catch", + "check-else", + "check-whitespace" + ], + "quotemark": [ + true, + "single", + "avoid-escape" + ], + "radix": true, + "semicolon": true, + "switch-default": true, + "trailing-comma": [ + true, + { + "multiline": "never", + "singleline": "never" + } + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "typedef": false, + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "use-strict": false, + "variable-name": [ + true, + "check-format", + "allow-leading-underscore", + "ban-keywords" + ], + "whitespace": [ + true, + "check-branch", + "check-operator", + "check-separator", + "check-type", + "check-module", + "check-decl" + ] + } +} diff --git a/ng2-components/ng2-alfresco-userinfo/typings.json b/ng2-components/ng2-alfresco-userinfo-old/typings.json similarity index 100% rename from ng2-components/ng2-alfresco-userinfo/typings.json rename to ng2-components/ng2-alfresco-userinfo-old/typings.json diff --git a/ng2-components/ng2-alfresco-userinfo/.travis.yml b/ng2-components/ng2-alfresco-userinfo/.travis.yml index 781e6204e8..ab817d7644 100644 --- a/ng2-components/ng2-alfresco-userinfo/.travis.yml +++ b/ng2-components/ng2-alfresco-userinfo/.travis.yml @@ -2,7 +2,11 @@ language: node_js node_js: - v5 - v4 + - '0.12' + - '0.10' install: npm install sudo: false after_success: npm run coverage +# Send coverage data to Coveralls +after_script: "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js" diff --git a/ng2-components/ng2-alfresco-userinfo/LICENSE b/ng2-components/ng2-alfresco-userinfo/LICENSE index bfd4a66b0c..de3d8c60b8 100644 --- a/ng2-components/ng2-alfresco-userinfo/LICENSE +++ b/ng2-components/ng2-alfresco-userinfo/LICENSE @@ -1,4 +1,4 @@ -Copyright 2016 vito albano +Copyright 2016 Alfresco Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/ng2-components/ng2-alfresco-userinfo/README.md b/ng2-components/ng2-alfresco-userinfo/README.md index f100be7287..a7519e00ea 100644 --- a/ng2-components/ng2-alfresco-userinfo/README.md +++ b/ng2-components/ng2-alfresco-userinfo/README.md @@ -1,43 +1,75 @@ -# Alfresco User Info Component for Angular 2 -This component will show the user information for ECM and BPM +# Alfresco Tag Component for Angular 2 +

+ + travis
+    Status + + + travis
+    Status + + + Coverage Status + + + npm downloads + + + license + + + alfresco component + + + angular 2 + + + typescript + + + node version + +

+### Node +To correctly use this component check that on your machine is running Node version 5.0.0 or higher. -## Prerequisites +## Install -Before you start using this development framework, make sure you have installed all required software and done all the -necessary configuration, see this [page](https://github.com/Alfresco/alfresco-ng2-components/blob/master/PREREQUISITES.md). - -## Installation - -```bash -npm install ng2-alfresco-userinfo --save +```sh +npm install --save ng2-alfresco-tag ``` -## Dependencies + +Components included: + +* Alfresco Tag Component + +#### Dependencies Add the following dependency to your index.html: + ```html ``` - -You must separately install the following libraries for your application: - -- [ng2-translate](https://github.com/ocombe/ng2-translate) -- [ng2-alfresco-core](https://www.npmjs.com/package/ng2-alfresco-core) -```sh -npm install --save ng2-translate ng2-alfresco-core -``` - -#### Material Design Lite +The following component needs to be added to your systemjs.config: -The style of this component is based on [material design](https://getmdl.io/), so if you want to visualize it correctly you have to add the material +- ng2-translate +- ng2-alfresco-core + +Please refer to the following example to have an idea of how your systemjs.config should look like : + +https://github.com/Alfresco/alfresco-ng2-components/blob/master/ng2-components/ng2-alfresco-tag/demo/systemjs.config.js + +#### Style +The style of this component is based on material design, so if you want to visualize it correctly you have to add the material design dependency to your project: ```sh npm install --save material-design-icons material-design-lite ``` -Also make sure you include these dependencies in your `index.html` file: +Also make sure you include these dependencies in your .html page: ```html @@ -45,29 +77,293 @@ Also make sure you include these dependencies in your `index.html` file: ``` - -## Example + +#### Basic usage + +In this component are present three different tags : + +* alfresco-tag-node-actions-list +* alfresco-tag-list +* alfresco-tag-node-list + +## alfresco-tag-node-actions-list ```html - + +``` + +```ts +import { Component, OnInit, Input } from '@angular/core'; +import { bootstrap } from '@angular/platform-browser-dynamic'; +import { HTTP_PROVIDERS } from '@angular/http'; +import { + ALFRESCO_CORE_PROVIDERS, + AlfrescoSettingsService, + AlfrescoAuthenticationService +} from 'ng2-alfresco-core'; +import { TAGCOMPONENT, TAGSERVICES } from 'ng2-alfresco-tag'; + +@Component({ + selector: 'alfresco-tag-demo', + template: ` +
+ +
+ `, + directives: [TAGCOMPONENT], + providers: [TAGSERVICES] +}) +class TagDemo implements OnInit { + + @Input() + nodeId: string = '74cd8a96-8a21-47e5-9b3b-a1b3e296787d'; + + authenticated: boolean; + + ecmHost: string = 'http://127.0.0.1:8080'; + + ticket: string; + + constructor(private authService: AlfrescoAuthenticationService, + private settingsService: AlfrescoSettingsService) { + settingsService.ecmHost = this.ecmHost; + settingsService.setProviders('ECM'); + } + + ngOnInit() { + this.login(); + } + + login() { + this.authService.login('admin', 'admin').subscribe( + ticket => { + this.authenticated = true; + }, + error => { + this.authenticated = false; + }); + } + + public updateHost(): void { + this.settingsService.ecmHost = this.ecmHost; + this.login(); + } + + logData(data) { + console.log(data); + } +} +bootstrap(TagDemo, [ + HTTP_PROVIDERS, + ALFRESCO_CORE_PROVIDERS +]); +``` + +### Options + +Attribute | Options | Default | Description | Mandatory +--- | --- | --- | --- | --- +`nodeId` | *string* | | The identifier of a node.| + +![Custom columns](docs/assets/tag3.png) + +## alfresco-tag-node-list + +```html + +``` + +```ts +import { Component, OnInit, Input } from '@angular/core'; +import { bootstrap } from '@angular/platform-browser-dynamic'; +import { HTTP_PROVIDERS } from '@angular/http'; +import { + ALFRESCO_CORE_PROVIDERS, + AlfrescoSettingsService, + AlfrescoAuthenticationService +} from 'ng2-alfresco-core'; + +import { TAGCOMPONENT, TAGSERVICES } from 'ng2-alfresco-tag'; + +@Component({ + selector: 'alfresco-tag-demo', + template: ` +
+ +
+ `, + directives: [TAGCOMPONENT], + providers: [TAGSERVICES] +}) +class TagDemo implements OnInit { + + @Input() + nodeId: string = '74cd8a96-8a21-47e5-9b3b-a1b3e296787d'; + + authenticated: boolean; + + ecmHost: string = 'http://127.0.0.1:8080'; + + ticket: string; + + constructor(private authService: AlfrescoAuthenticationService, + private settingsService: AlfrescoSettingsService) { + settingsService.ecmHost = this.ecmHost; + settingsService.setProviders('ECM'); + } + + ngOnInit() { + this.login(); + } + + login() { + this.authService.login('admin', 'admin').subscribe( + ticket => { + this.authenticated = true; + }, + error => { + this.authenticated = false; + }); + } + + public updateHost(): void { + this.settingsService.ecmHost = this.ecmHost; + this.login(); + } + + logData(data) { + console.log(data); + } +} +bootstrap(TagDemo, [ + HTTP_PROVIDERS, + ALFRESCO_CORE_PROVIDERS +]); +``` + +### Options + +Attribute | Options | Default | Description | Mandatory +--- | --- | --- | --- | --- +`nodeId` | *string* | | The identifier of a node.| + +![Custom columns](docs/assets/tag1.png) + +## alfresco-tag-list + +```html + +``` + +```ts +import { Component, OnInit, Input } from '@angular/core'; +import { bootstrap } from '@angular/platform-browser-dynamic'; +import { HTTP_PROVIDERS } from '@angular/http'; +import { + ALFRESCO_CORE_PROVIDERS, + AlfrescoSettingsService, + AlfrescoAuthenticationService +} from 'ng2-alfresco-core'; + +import { TAGCOMPONENT, TAGSERVICES } from 'ng2-alfresco-tag'; + +@Component({ + selector: 'alfresco-tag-demo', + template: ` +
+ +
+ `, + directives: [TAGCOMPONENT], + providers: [TAGSERVICES] +}) +class TagDemo implements OnInit { + + authenticated: boolean; + + ecmHost: string = 'http://127.0.0.1:8080'; + + constructor(private authService: AlfrescoAuthenticationService, + private settingsService: AlfrescoSettingsService) { + settingsService.ecmHost = this.ecmHost; + settingsService.setProviders('ECM'); + } + + ngOnInit() { + this.login(); + } + + login() { + this.authService.login('admin', 'admin').subscribe( + ticket => { + this.authenticated = true; + }, + error => { + this.authenticated = false; + }); + } + + public updateHost(): void { + this.settingsService.ecmHost = this.ecmHost; + this.login(); + } + + logData(data) { + console.log(data); + } +} +bootstrap(TagDemo, [ + HTTP_PROVIDERS, + ALFRESCO_CORE_PROVIDERS +]); +``` + +![Custom columns](docs/assets/tag2.png) + + +## Build from sources +Alternatively you can build component from sources with the following commands: + + +```sh +npm install +npm run build ``` -This will show a round icon with user and on click some user information are showed. -If user is logged in with ECM and BPM the ECM image will be showed. -## NPM scripts +##Build the files and keep watching for changes -| Command | Description | -| --- | --- | -| npm run build | Build component | -| npm run build:w | Build component and keep watching the changes | -| npm run test | Run unit tests in the console | -| npm run test-browser | Run unit tests in the browser -| npm run coverage | Run unit tests and display code coverage report | +```sh +npm run build:w +``` + +## Running unit tests -## History +```sh +npm test +``` -For detailed changelog, check [Releases](https://github.com/alfresco/ng2-alfresco-userinfo/releases). +## Running unit tests in browser -## Contributors +```sh +npm test-browser +``` + +This task rebuilds all the code, runs tslint, license checks and other quality check tools +before performing unit testing. + +## Code coverage + +```sh +npm run coverage +``` + +## Demo + +If you want have a demo of how the component works, please check the demo folder : + +```sh +cd demo +npm install +npm start +``` -[Contributors](https://github.com/alfresco/ng2-alfresco-userinfo/graphs/contributors) diff --git a/ng2-components/ng2-alfresco-userinfo/assets/license_header.txt b/ng2-components/ng2-alfresco-userinfo/assets/license_header.txt new file mode 100644 index 0000000000..83fd1531a3 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/assets/license_header.txt @@ -0,0 +1,16 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed 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. + */ \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-userinfo/demo/.gitignore b/ng2-components/ng2-alfresco-userinfo/demo/.gitignore index 7c04460244..6afdbb8367 100644 --- a/ng2-components/ng2-alfresco-userinfo/demo/.gitignore +++ b/ng2-components/ng2-alfresco-userinfo/demo/.gitignore @@ -3,3 +3,4 @@ node_modules/ .idea dist/ !systemjs.config.js +!browser-sync-config.js diff --git a/ng2-components/ng2-alfresco-userinfo/demo/README.md b/ng2-components/ng2-alfresco-userinfo/demo/README.md index 7b59778398..8d399e6fef 100644 --- a/ng2-components/ng2-alfresco-userinfo/demo/README.md +++ b/ng2-components/ng2-alfresco-userinfo/demo/README.md @@ -1,4 +1,4 @@ -# ng2-alfresco-userinfo - Demo +# ng2-alfresco-tag - Demo * To install dependencies diff --git a/ng2-components/ng2-alfresco-userinfo/demo/index.html b/ng2-components/ng2-alfresco-userinfo/demo/index.html index d6b7f0a7d8..ee97252ec1 100644 --- a/ng2-components/ng2-alfresco-userinfo/demo/index.html +++ b/ng2-components/ng2-alfresco-userinfo/demo/index.html @@ -1,20 +1,20 @@ - + + Alfresco Angular 2 Tag - Demo + - - ng2-alfresco-userinfo Angular 2 - - + - + + @@ -24,14 +24,16 @@ - - - -
-
- + + + + + diff --git a/ng2-components/ng2-alfresco-userinfo/demo/package.json b/ng2-components/ng2-alfresco-userinfo/demo/package.json deleted file mode 100644 index 5349c4e2a1..0000000000 --- a/ng2-components/ng2-alfresco-userinfo/demo/package.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "name": "ng2-alfresco-userinfo-demo", - "description": "This component will show the user information for ECM and BPM - Demo", - "version": "0.1.0", - "author": "vito albano ", - "main": "./dist/index.js", - "typings": "./dist/index.d.ts", - "scripts": { - "clean": "rimraf dist node_modules typings", - "postinstall": "npm run build", - "start": "npm run tslint && rimraf dist && tsc && concurrently \"tsc -w\" \"npm run server\" ", - "server": "wsrv -o -l -s", - "build": "npm run tslint && rimraf dist && tsc", - "build:w": "npm run tslint && rimraf dist && tsc -w", - "tslint": "tslint -c tslint.json *.ts && tslint -c tslint.json src/{,**/}**.ts" - }, - "keywords": [ - "ng2", - "angular", - "angular2", - "alfresco", - "demo" - ], - "dependencies": { - "alfresco-js-api": "^0.3.0", - "@angular/common": "2.0.0-rc.3", - "@angular/compiler": "2.0.0-rc.3", - "@angular/core": "2.0.0-rc.3", - "@angular/forms": "0.1.1", - "@angular/http": "2.0.0-rc.3", - "@angular/platform-browser": "2.0.0-rc.3", - "@angular/platform-browser-dynamic": "2.0.0-rc.3", - "@angular/router": "3.0.0-alpha.7", - "@angular/router-deprecated": "2.0.0-rc.2", - "@angular/upgrade": "2.0.0-rc.3", - "systemjs": "0.19.27", - "core-js": "2.4.0", - "reflect-metadata": "0.1.3", - "rxjs": "5.0.0-beta.6", - "zone.js": "0.6.12", - "ng2-translate": "2.2.2", - "ng2-alfresco-core": "0.3.2", - "ng2-alfresco-userinfo": "file:../" - }, - "peerDependencies": { - "material-design-icons": "^2.2.3", - "material-design-lite": "^1.1.3" - }, - "devDependencies": { - "@types/core-js": "^0.9.32", - "@types/jasmine": "^2.2.33", - "cpx": "1.3.1", - "jasmine-ajax": "3.2.0", - "jasmine-core": "2.4.1", - "karma": "0.13.22", - "karma-chrome-launcher": "1.0.1", - "karma-coverage": "1.0.0", - "karma-jasmine": "1.0.2", - "karma-jasmine-ajax": "^0.1.13", - "karma-jasmine-html-reporter": "0.2.0", - "karma-mocha-reporter": "2.0.3", - "license-check": "1.1.5", - "remap-istanbul": "0.6.3", - "rimraf": "2.5.2", - "traceur": "0.0.91", - "tslint": "3.8.1", - "typescript": "^2.0.2", - "wsrv": "^0.1.5" - } - -} diff --git a/ng2-components/ng2-alfresco-userinfo/demo/src/main.ts b/ng2-components/ng2-alfresco-userinfo/demo/src/main.ts index c21351590c..8af97cc33a 100644 --- a/ng2-components/ng2-alfresco-userinfo/demo/src/main.ts +++ b/ng2-components/ng2-alfresco-userinfo/demo/src/main.ts @@ -1,127 +1,115 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed 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. + */ -import { Component, OnInit } from '@angular/core'; -import { bootstrap } from '@angular/platform-browser-dynamic'; -import { UserInfoComponent } from 'ng2-alfresco-userinfo'; -import { HTTP_PROVIDERS } from '@angular/http'; -import { - AlfrescoSettingsService, - AlfrescoAuthenticationService, - MDL, - ALFRESCO_CORE_PROVIDERS -} from 'ng2-alfresco-core'; +import { NgModule, Component, Input, OnInit } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; + +import { CoreModule, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; +import { TagModule } from 'ng2-alfresco-tag'; @Component({ - selector: 'my-app', - styles: [`:host h1 { font-size:22px }`], - template: ` -

START DEMO USERINFO

-
-

- -

-

- -

-
-
- -
-

-
-

- Username - -

-

- Password - -

- -
-{{loginErrorMessage}} - -`, - directives: [ UserInfoComponent ], - providers: [AlfrescoAuthenticationService, AlfrescoSettingsService, MDL] + selector: 'alfresco-tag-demo', + template: ` +
+
+
+

+
+ Authentication failed to ip {{ ecmHost }} with user: admin, admin, you can still try to add a valid ticket to perform + operations. +
+
+
+
+
+
+
+
List Tags ECM
+
+ Tag list By Node ID + +
+
+
+ ` }) +class TagDemo implements OnInit { + @Input() + nodeId: string = '74cd8a96-8a21-47e5-9b3b-a1b3e296787d'; -class UserInfoDemo implements OnInit { + authenticated: boolean; - public userToLogin: string = 'admin'; - public password: string = 'admin'; - public loginErrorMessage: string; - public providers: string = 'BPM'; - private authenticated: boolean; - private token: any; + ecmHost: string = 'http://127.0.0.1:8080'; - constructor(private authService: AlfrescoAuthenticationService, - private settingsService: AlfrescoSettingsService) { - } + ticket: string; - ngOnInit() { - this.settingsService.setProviders(this.providers); - } + constructor(private authService: AlfrescoAuthenticationService, + private settingsService: AlfrescoSettingsService) { - attemptLogin() { - this.loginErrorMessage = ''; - this.login(this.userToLogin, this.password); - } + settingsService.ecmHost = this.ecmHost; + settingsService.setProviders('ECM'); - logout() { - this.authService.logout(); - } + if (this.authService.getTicketEcm()) { + this.ticket = this.authService.getTicketEcm(); + } + } - login(user, password) { - this.settingsService.setProviders(this.providers); - this.authService.login(user, password).subscribe( - token => { - console.log(token); - this.token = token; - this.authenticated = true; - }, - error => { - console.log(error); - this.authenticated = false; - this.loginErrorMessage = error; - }); - } + ngOnInit() { + this.login(); + } - isLoggedIn(): boolean { - return this.authService.isLoggedIn(); - } + login() { + this.authService.login('admin', 'admin').subscribe( + ticket => { + console.log(ticket); + this.ticket = this.authService.getTicketEcm(); + this.authenticated = true; + }, + error => { + console.log(error); + this.authenticated = false; + }); + } - toggleECM(checked) { - if (checked && this.providers === 'BPM') { - this.providers = 'ALL'; - } else if (checked) { - this.providers = 'ECM'; - } else { - this.providers = undefined; - } - } + public updateTicket(): void { + localStorage.setItem('ticket-ECM', this.ticket); + } - toggleBPM(checked) { - if (checked && this.providers === 'ECM') { - this.providers = 'ALL'; - } else if (checked) { - this.providers = 'BPM'; - } else { - this.providers = undefined; - } - } + public updateHost(): void { + this.settingsService.ecmHost = this.ecmHost; + this.login(); + } + + logData(data) { + console.log(data); + } } -bootstrap(UserInfoDemo, [ - UserInfoComponent, - HTTP_PROVIDERS, - ALFRESCO_CORE_PROVIDERS -]); +@NgModule({ + imports: [ + BrowserModule, + CoreModule.forRoot(), + TagModule + ], + declarations: [ TagDemo ], + bootstrap: [ TagDemo ] +}) +export class AppModule { } + +platformBrowserDynamic().bootstrapModule(AppModule); diff --git a/ng2-components/ng2-alfresco-userinfo/demo/tslint.json b/ng2-components/ng2-alfresco-userinfo/demo/tslint.json index 8c48e76469..e550ac11d4 100644 --- a/ng2-components/ng2-alfresco-userinfo/demo/tslint.json +++ b/ng2-components/ng2-alfresco-userinfo/demo/tslint.json @@ -26,7 +26,7 @@ "label-undefined": true, "max-line-length": [ true, - 140 + 180 ], "member-ordering": [ true, diff --git a/ng2-components/ng2-alfresco-userinfo/index.ts b/ng2-components/ng2-alfresco-userinfo/index.ts index a75fe639fd..41ab68dfa4 100644 --- a/ng2-components/ng2-alfresco-userinfo/index.ts +++ b/ng2-components/ng2-alfresco-userinfo/index.ts @@ -17,12 +17,20 @@ import { NgModule, ModuleWithProviders } from '@angular/core'; import { CoreModule } from 'ng2-alfresco-core'; + +import { UserInfoComponent } from './src/components/user-info.component'; import { EcmUserService } from './src/services/ecm-user.service'; import { BpmUserService } from './src/services/bpm-user.service'; export * from './src/components/user-info.component'; +export * from './src/services/bpm-user.service'; +export * from './src/services/ecm-user.service'; -export const USER_INFO_SERVICE: [any] = [ +export const USER_INFO_DIRECTIVES: any[] = [ + UserInfoComponent +]; + +export const USER_INFO_PROVIDERS: any[] = [ EcmUserService, BpmUserService ]; @@ -32,16 +40,23 @@ export const USER_INFO_SERVICE: [any] = [ CoreModule ], declarations: [ - ...USER_INFO_SERVICE + ...USER_INFO_DIRECTIVES + ], + providers: [ + ...USER_INFO_PROVIDERS ], exports: [ - ...USER_INFO_SERVICE + ...USER_INFO_DIRECTIVES ] }) -export class UserInfoModule { +export class UserInfoComponentModule { static forRoot(): ModuleWithProviders { return { - ngModule: UserInfoModule + ngModule: UserInfoComponentModule, + providers: [ + ...USER_INFO_PROVIDERS + ] }; } } + diff --git a/ng2-components/ng2-alfresco-userinfo/karma-test-shim.js b/ng2-components/ng2-alfresco-userinfo/karma-test-shim.js index fb1c3905f3..d7f5a90d43 100644 --- a/ng2-components/ng2-alfresco-userinfo/karma-test-shim.js +++ b/ng2-components/ng2-alfresco-userinfo/karma-test-shim.js @@ -70,7 +70,7 @@ var map = { }; var packages = { - 'app': { main: 'index.js', defaultExtension: 'js', format: 'register' }, + 'app': { main: 'main.js', defaultExtension: 'js' }, 'rxjs': { defaultExtension: 'js' }, 'ng2-translate': { defaultExtension: 'js' }, @@ -98,7 +98,7 @@ var config = { System.config(config); -System.import('app') +System.import('@angular/core/testing') .then(initTestBed) .then(initTesting); diff --git a/ng2-components/ng2-alfresco-userinfo/karma.conf.js b/ng2-components/ng2-alfresco-userinfo/karma.conf.js index c0374b25c3..5495861358 100644 --- a/ng2-components/ng2-alfresco-userinfo/karma.conf.js +++ b/ng2-components/ng2-alfresco-userinfo/karma.conf.js @@ -108,7 +108,7 @@ module.exports = function (config) { // Source files that you wanna generate coverage for. // Do not include tests or libraries (these files will be instrumented by Istanbul) preprocessors: { - // 'dist/**/!(*spec).js': ['coverage'] + // 'dist/**/!(*spec).js': ['coverage'] }, coverageReporter: { diff --git a/ng2-components/ng2-alfresco-userinfo/package.json b/ng2-components/ng2-alfresco-userinfo/package.json index 19e3865dde..49787abe9d 100644 --- a/ng2-components/ng2-alfresco-userinfo/package.json +++ b/ng2-components/ng2-alfresco-userinfo/package.json @@ -1,11 +1,13 @@ { - "name": "ng2-alfresco-userinfo", - "description": "This component will show the user information for ECM and BPM", - "version": "0.1.0", - "author": "vito albano ", + "name": "ng2-alfresco-tag", + "description": "Alfresco tag component", + "version": "0.3.2", + "author": "Alfresco Software, Ltd.", + "main": "./dist/index.js", + "typings": "./dist/index.d.ts", "scripts": { "clean": "rimraf dist node_modules", - "build": "npm run tslint && rimraf dist && tsc && npm run copy-dist", + "build": "npm run tslint && rimraf dist && tsc && npm run copy-dist && license-check", "build:w": "npm run tslint && rimraf dist && npm run watch-task", "watch-task": "concurrently \"npm run tsc:w\" \"npm run copy-dist:w\" \"license-check\"", "tslint": "tslint -c tslint.json *.ts && tslint -c tslint.json 'src/{,**/}**.ts'", @@ -18,10 +20,9 @@ "test-browser": "npm run build && concurrently \"karma start karma.conf.js --reporters kjhtml\" \"npm run watch-task\"", "posttest": "remap-istanbul -i coverage/report/coverage-final.json -o coverage/report -t html && remap-istanbul -i coverage/report/coverage-final.json -o coverage/report/coverage-final.json", "coverage": "npm run test && wsrv -o -p 9875 ./coverage/report", - "travis": "npm link ng2-alfresco-core" + "prepublish": "npm run build", + "travis": "echo 'placeholder'" }, - "main": "./dist/index.js", - "typings": "./dist/index.d.ts", "repository": { "type": "git", "url": "https://github.com/Alfresco/alfresco-ng2-components.git" @@ -29,19 +30,6 @@ "bugs": { "url": "https://github.com/Alfresco/alfresco-ng2-components/issues" }, - "license": "Apache-2.0", - "contributors": [ - { - "name": "Vito Albano", - "email": "vito.albano@alfresco.com" - } - ], - "keywords": [ - "ng2", - "angular", - "angular2", - "alfresco" - ], "dependencies": { "@angular/common": "2.0.0", "@angular/compiler": "2.0.0", @@ -58,6 +46,7 @@ "systemjs": "0.19.27", "zone.js": "^0.6.23", + "alfresco-js-api": "^0.3.0", "ng2-translate": "2.5.0", "ng2-alfresco-core": "0.3.2" }, @@ -65,31 +54,36 @@ "@types/core-js": "^0.9.32", "@types/jasmine": "^2.2.33", "concurrently": "^2.2.0", - "cpx": "1.3.1", - "jasmine-ajax": "3.2.0", + "cpx": "^1.3.1", + "jasmine-ajax": "^3.2.0", "jasmine-core": "2.4.1", - "karma": "0.13.22", - "karma-chrome-launcher": "1.0.1", - "karma-coverage": "1.0.0", - "karma-jasmine": "1.0.2", + "karma": "~0.13.22", + "karma-chrome-launcher": "~1.0.1", + "karma-coverage": "^1.0.0", + "karma-jasmine": "~1.0.2", "karma-jasmine-ajax": "^0.1.13", - "karma-jasmine-html-reporter": "0.2.0", - "karma-mocha-reporter": "2.0.3", - "license-check": "1.1.5", - "remap-istanbul": "0.6.3", + "karma-jasmine-html-reporter": "^0.2.0", + "karma-mocha-reporter": "^2.0.3", + "license-check": "^1.0.4", + "remap-istanbul": "^0.6.3", "rimraf": "2.5.2", - "traceur": "0.0.91", - "tslint": "3.8.1", - "typescript": "^2.0.2", + "traceur": "^0.0.91", + "tslint": "^3.8.1", + "typescript": "^2.0.3", "wsrv": "^0.1.5" }, + "keywords": [ + "userinfo", + "alfresco-component" + ], "license-check-config": { "src": [ - "./dist/**/*.js" + "./dist/**/*.js" ], "path": "assets/license_header.txt", - "blocking": true, + "blocking": false, "logInfo": false, "logError": true - } + }, + "license": "Apache-2.0" } diff --git a/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.spec.ts b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.spec.ts index a91e2f2ac8..7fe9af0ca4 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.spec.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.spec.ts @@ -14,12 +14,37 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// import { UserInfoComponent } from '../src/userinfo.component'; -describe('Basic Example test ng2-alfresco-userinfo', () => { +import { UserInfoComponent } from './user-info.component'; +import { EcmUserService } from '../services/ecm-user.service'; +import { BpmUserService } from '../services/bpm-user.service'; +import { AlfrescoAuthenticationService, + AlfrescoApiService, + AlfrescoSettingsService } from 'ng2-alfresco-core'; - it('Test hello world', () => { - expect(true).toBe(true); - }); +describe('User info component', () => { + + let userInfoComp: UserInfoComponent; + let ecmUserService = new EcmUserService(null, null); + let bpmUserService = new BpmUserService(null); + let authService = new AlfrescoAuthenticationService(new AlfrescoSettingsService() , + new AlfrescoApiService()); + + beforeEach(() => { + userInfoComp = new UserInfoComponent(ecmUserService, bpmUserService, authService); + }); + + it('should get the ecm user informations when is logged in', () => { + spyOn(ecmUserService, 'getUserInfo'); + spyOn(bpmUserService, 'getCurrentUserInfo'); + spyOn(authService, 'getAlfrescoApi').and.callThrough(); + // spyOn(authService.getAlfrescoApi(), 'ecmAuth').and.callThrough(); + spyOn(authService, 'getAlfrescoApi().ecmAuth.isLoggedIn').and.returnValue(true); + userInfoComp.ngOnInit(); + + expect(ecmUserService.getUserInfo).toHaveBeenCalledWith('-me-'); + expect(bpmUserService.getCurrentUserInfo).not.toHaveBeenCalled(); + + }); }); diff --git a/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.ts b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.ts index d54b9669e3..9ca5f1aa18 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.ts @@ -16,10 +16,10 @@ */ import { Component, OnInit } from '@angular/core'; -import { EcmUserService } from './../services/ecm-user.service'; -import { BpmUserService } from './../services/bpm-user.service'; import { EcmUserModel } from './../models/ecm-user.model'; import { BpmUserModel } from './../models/bpm-user.model'; +import { EcmUserService } from './../services/ecm-user.service'; +import { BpmUserService } from './../services/bpm-user.service'; import { AlfrescoAuthenticationService } from 'ng2-alfresco-core'; declare let __moduleName: string; @@ -27,21 +27,19 @@ declare let __moduleName: string; @Component({ selector: 'ng2-alfresco-userinfo', moduleId: __moduleName, - styleUrls: ['./userinfo.component.css'], - templateUrl: './userinfo.component.html', - providers: [EcmUserService, BpmUserService, AlfrescoAuthenticationService] + styleUrls: ['./user-info.component.css'], + templateUrl: './user-info.component.html' }) export class UserInfoComponent implements OnInit { private ecmUser: EcmUserModel; private bpmUser: BpmUserModel; - private baseComponentPath = __moduleName.replace('userinfo.component.js', ''); + private baseComponentPath = __moduleName.replace('components/user-info.component.js', ''); private anonymouseImageUrl: string = this.baseComponentPath + 'img/anonymous.gif'; public bpmUserImage: any; public ecmUserImage: any; - constructor(private ecmUserService: EcmUserService, private bpmUserService: BpmUserService, public authService: AlfrescoAuthenticationService) { diff --git a/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.spec.ts b/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.spec.ts new file mode 100644 index 0000000000..ab002e9957 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.spec.ts @@ -0,0 +1,48 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed 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. + */ +// import { UserInfoComponent } from '../src/userinfo.component'; + +/* +describe('Bpm User Service', () => { + + beforeEachProviders(() => { + return [ + HTTP_PROVIDERS, + AlfrescoSettingsService, + AlfrescoAuthenticationService, + WidgetVisibilityService + ]; + }); + + beforeEach( + inject([WidgetVisibilityService], (activitiService: WidgetVisibilityService) => { + jasmine.Ajax.install(); + service = activitiService; + }) + ); + + afterEach(() => { + jasmine.Ajax.uninstall(); + }); + + + it('should be able to get current user information', () => { + + }); + +}); +*/ diff --git a/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.ts b/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.ts index 089320a264..98d637a6ed 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core'; +import { AlfrescoAuthenticationService } from 'ng2-alfresco-core'; import { Injectable } from '@angular/core'; import { Response } from '@angular/http'; import { Observable } from 'rxjs/Rx'; @@ -29,12 +29,11 @@ import { BpmUserModel } from '../models/bpm-user.model'; @Injectable() export class BpmUserService { - constructor(private authService: AlfrescoAuthenticationService, - private settingService: AlfrescoSettingsService) { + constructor(private authService: AlfrescoAuthenticationService) { } /** - * get User Information via ECM + * get Current User information for BPM * @param userName - the user name */ getCurrentUserInfo(): Observable { @@ -47,19 +46,31 @@ export class BpmUserService { } } - /** - * get User Information via ECM - * @param userName - the user name - */ - getCurrentUserProfileImage(): string { + getCurrentUserProfileImage(): any { if ( this.authService.getAlfrescoApi().bpmAuth.isLoggedIn() ) { - return this.settingService.getBPMApiBaseUrl() + '/api/enterprise/profile-picture'; + return Observable.fromPromise(this.callApiGetProfilePicture()) + .map( + (data) => data + ) + .catch(this.handleError); } } + /** + * Call js api to get current user profile picture + */ + private callApiGetProfilePicture() { + return this.authService.getAlfrescoApi().activiti.profileApi.getProfile(); + } + + /** + * Call js api to get current user information + */ private callApiGetProfile() { return this.authService.getAlfrescoApi().activiti.profileApi.getProfile(); } + + /** * Throw the error * @param error diff --git a/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.spec.ts b/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.spec.ts new file mode 100644 index 0000000000..5bc6a53e0f --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.spec.ts @@ -0,0 +1,69 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed 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. + */ +/* +// import { AlfrescoAuthenticationService, AlfrescoContentService } from 'ng2-alfresco-core'; +import { EcmUserService } from './ecm-user.service'; +import { ReflectiveInjector } from '@angular/core'; +import { EcmUserModel } from '../models/ecm-user.model'; + +declare var AlfrescoApi: any; +declare let jasmine: any; + +describe('Ecm User service', () => { + + let injector; + let ecmUserService: EcmUserService; + // let contentService: AlfrescoContentService; + // let authService: AlfrescoAuthenticationService; + + beforeEach(() => { + + injector = ReflectiveInjector.resolveAndCreate([ + EcmUserService + ]); + + // contentService = injector.get(AlfrescoContentService); + // authService = injector.get(AlfrescoAuthenticationService); + ecmUserService = injector.get(EcmUserService); + + jasmine.Ajax.install(); + }); + + afterEach(() => { + jasmine.Ajax.uninstall(); + }); + + it('should be able', (done) => { + let authService = new AlfrescoAuthenticationService(); + spyOn(authService, ) + ecmUserService.getUserInfo('fake-user').subscribe((res) => { + expect(res).not.toBeUndefined(); + expect(res).toEqual(jasmine.any(EcmUserModel)); + expect(res.firstName).toEqual('fake-user-response'); + expect(res.email).toEqual('fake@email.com'); + done(); + }); + + jasmine.Ajax.requests.mostRecent().respondWith({ + 'status': 201, + contentType: 'application/json', + responseText: JSON.stringify({'entry': {'firstName': 'fake-user-response', 'id': 'fake@email.com'}}) + }); + }); + +}); +*/ diff --git a/ng2-components/ng2-alfresco-userinfo/tsconfig.json b/ng2-components/ng2-alfresco-userinfo/tsconfig.json index b1effea355..ae39a67a17 100644 --- a/ng2-components/ng2-alfresco-userinfo/tsconfig.json +++ b/ng2-components/ng2-alfresco-userinfo/tsconfig.json @@ -1,26 +1,26 @@ { - "compilerOptions": { - "target": "es5", - "module": "system", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": true, - "removeComments": true, - "declaration": true, - "noLib": false, - "allowUnreachableCode": false, - "allowUnusedLabels": false, - "noImplicitAny": false, - "noImplicitReturns": false, - "noImplicitUseStrict": false, - "noFallthroughCasesInSwitch": true, - "outDir": "dist", - "types": ["core-js", "jasmine"] - }, - "exclude": [ - "demo", - "node_modules", - "dist" - ] + "compilerOptions": { + "target": "es5", + "module": "system", + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "sourceMap": true, + "removeComments": true, + "declaration": true, + "noLib": false, + "allowUnreachableCode": false, + "allowUnusedLabels": false, + "noImplicitAny": false, + "noImplicitReturns": false, + "noImplicitUseStrict": false, + "noFallthroughCasesInSwitch": true, + "outDir": "dist", + "types": ["core-js", "jasmine"] + }, + "exclude": [ + "demo", + "node_modules", + "dist" + ] } diff --git a/ng2-components/ng2-alfresco-userinfo/tslint.json b/ng2-components/ng2-alfresco-userinfo/tslint.json index 33220e5038..ba706079f4 100644 --- a/ng2-components/ng2-alfresco-userinfo/tslint.json +++ b/ng2-components/ng2-alfresco-userinfo/tslint.json @@ -24,7 +24,7 @@ "label-undefined": true, "max-line-length": [ true, - 140 + 180 ], "member-ordering": [ true, From 336ffe75d8ccbd6cc5d74597eea76793cc690784 Mon Sep 17 00:00:00 2001 From: Vito Albano Date: Fri, 30 Sep 2016 00:54:23 +0100 Subject: [PATCH 14/26] Added tests for user-info component --- .../AlfrescoAuthentication.service.spec.ts | 13 + .../AlfrescoAuthentication.service.ts | 15 ++ .../components/user-info.component.spec.ts | 240 ++++++++++++++++-- .../src/components/user-info.component.ts | 17 +- .../src/services/bpm-user.service.ts | 4 +- .../src/services/ecm-user.service.ts | 6 +- .../src/testing/fake-bpm-user.service.ts | 89 +++++++ .../src/testing/fake-ecm-user.service.ts | 99 ++++++++ 8 files changed, 452 insertions(+), 31 deletions(-) create mode 100644 ng2-components/ng2-alfresco-userinfo/src/testing/fake-bpm-user.service.ts create mode 100644 ng2-components/ng2-alfresco-userinfo/src/testing/fake-ecm-user.service.ts diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.spec.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.spec.ts index c43a10b753..1071d838ad 100644 --- a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.spec.ts +++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.spec.ts @@ -74,6 +74,7 @@ describe('AlfrescoAuthentication', () => { authService.login('fake-username', 'fake-password').subscribe(() => { expect(authService.isLoggedIn()).toBe(true); expect(authService.getTicketEcm()).toEqual('fake-post-ticket'); + expect(authService.isEcmLoggedIn()).toBe(true); done(); }); @@ -106,6 +107,7 @@ describe('AlfrescoAuthentication', () => { (err: any) => { expect(authService.isLoggedIn()).toBe(false); expect(authService.getTicketEcm()).toBe(null); + expect(authService.isEcmLoggedIn()).toBe(false); done(); }); @@ -141,6 +143,7 @@ describe('AlfrescoAuthentication', () => { authService.logout().subscribe(() => { expect(authService.isLoggedIn()).toBe(false); expect(authService.getTicketEcm()).toBe(null); + expect(authService.isEcmLoggedIn()).toBe(false); done(); }); @@ -158,6 +161,7 @@ describe('AlfrescoAuthentication', () => { it('should return false if the user is not logged in', () => { expect(authService.isLoggedIn()).toBe(false); + expect(authService.isEcmLoggedIn()).toBe(false); }); }); @@ -171,6 +175,7 @@ describe('AlfrescoAuthentication', () => { authService.login('fake-username', 'fake-password').subscribe(() => { expect(authService.isLoggedIn()).toBe(true); expect(authService.getTicketBpm()).toEqual('Basic ZmFrZS11c2VybmFtZTpmYWtlLXBhc3N3b3Jk'); + expect(authService.isBpmLoggedIn()).toBe(true); done(); }); @@ -201,6 +206,7 @@ describe('AlfrescoAuthentication', () => { (err: any) => { expect(authService.isLoggedIn()).toBe(false); expect(authService.getTicketBpm()).toBe(null); + expect(authService.isBpmLoggedIn()).toBe(false); done(); }); @@ -214,6 +220,7 @@ describe('AlfrescoAuthentication', () => { authService.logout().subscribe(() => { expect(authService.isLoggedIn()).toBe(false); expect(authService.getTicketBpm()).toBe(null); + expect(authService.isBpmLoggedIn()).toBe(false); done(); }); @@ -280,6 +287,8 @@ describe('AlfrescoAuthentication', () => { expect(authService.isLoggedIn()).toBe(true); expect(authService.getTicketEcm()).toEqual('fake-post-ticket'); expect(authService.getTicketBpm()).toEqual('Basic ZmFrZS11c2VybmFtZTpmYWtlLXBhc3N3b3Jk'); + expect(authService.isBpmLoggedIn()).toBe(true); + expect(authService.isEcmLoggedIn()).toBe(true); done(); }); @@ -302,6 +311,7 @@ describe('AlfrescoAuthentication', () => { expect(authService.isLoggedIn()).toBe(false); expect(authService.getTicketEcm()).toBe(null); expect(authService.getTicketBpm()).toBe(null); + expect(authService.isEcmLoggedIn()).toBe(false); done(); }); @@ -322,6 +332,7 @@ describe('AlfrescoAuthentication', () => { expect(authService.isLoggedIn()).toBe(false); expect(authService.getTicketEcm()).toBe(null); expect(authService.getTicketBpm()).toBe(null); + expect(authService.isBpmLoggedIn()).toBe(false); done(); }); @@ -344,6 +355,8 @@ describe('AlfrescoAuthentication', () => { expect(authService.isLoggedIn()).toBe(false); expect(authService.getTicketEcm()).toBe(null); expect(authService.getTicketBpm()).toBe(null); + expect(authService.isBpmLoggedIn()).toBe(false); + expect(authService.isEcmLoggedIn()).toBe(false); done(); }); diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.ts index fed60c3356..26a031c2e9 100644 --- a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.ts +++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.ts @@ -82,6 +82,7 @@ export class AlfrescoAuthenticationService { * @returns {Observable|Observable} */ login(username: string, password: string): Observable<{ type: string, ticket: any }> { + this.removeTicket(); return Observable.fromPromise(this.callApiLogin(username, password)) .map((response: any) => { this.saveTickets(); @@ -191,6 +192,20 @@ export class AlfrescoAuthenticationService { } } + /** + * The method return true if user is logged in on ecm provider + */ + public isEcmLoggedIn() { + return this.alfrescoApi.ecmAuth && !!this.alfrescoApi.ecmAuth.isLoggedIn(); + } + + /** + * The method return true if user is logged in on bpm provider + */ + public isBpmLoggedIn() { + return this.alfrescoApi.bpmAuth && !!this.alfrescoApi.bpmAuth.isLoggedIn(); + } + /** * The method write the error in the console browser * @param error diff --git a/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.spec.ts b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.spec.ts index 7fe9af0ca4..b78cc8cb41 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.spec.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.spec.ts @@ -18,33 +18,233 @@ import { UserInfoComponent } from './user-info.component'; import { EcmUserService } from '../services/ecm-user.service'; import { BpmUserService } from '../services/bpm-user.service'; -import { AlfrescoAuthenticationService, - AlfrescoApiService, - AlfrescoSettingsService } from 'ng2-alfresco-core'; +import { FakeEcmUserService } from '../testing/fake-ecm-user.service'; +import { FakeBpmUserService } from '../testing/fake-bpm-user.service'; +import { AlfrescoAuthenticationService, AlfrescoContentService } from 'ng2-alfresco-core'; +import { ComponentFixture, TestBed, async } from '@angular/core/testing'; + + +class StubAuthentication { + isEcmConnected: boolean; + isBpmConnected: boolean; + setIsEcmLoggedIn(logged: boolean) { this.isEcmConnected = logged; }; + setIsBpmLoggedIn(logged: boolean) { this.isBpmConnected = logged; }; + isEcmLoggedIn() { return this.isEcmConnected; }; + isBpmLoggedIn() { return this.isBpmConnected; }; +} + +class StubAlfrescoContentService { + getContentUrl() { return 'fake/url/image/for/ecm/user'; } ; +} + describe('User info component', () => { let userInfoComp: UserInfoComponent; - let ecmUserService = new EcmUserService(null, null); - let bpmUserService = new BpmUserService(null); - let authService = new AlfrescoAuthenticationService(new AlfrescoSettingsService() , - new AlfrescoApiService()); + let fixture: ComponentFixture; + let authStub: StubAuthentication; + let fakeEcmService: FakeEcmUserService; + let fakeBpmService: FakeBpmUserService; - beforeEach(() => { - userInfoComp = new UserInfoComponent(ecmUserService, bpmUserService, authService); + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ UserInfoComponent ], + providers: [{ provide: EcmUserService, useClass: FakeEcmUserService}, + { provide: BpmUserService, useClass: FakeBpmUserService}, + { provide: AlfrescoAuthenticationService, useClass: StubAuthentication }, + { provide: AlfrescoContentService, useClass: StubAlfrescoContentService } + ] + }).compileComponents().then(() => { + fixture = TestBed.createComponent(UserInfoComponent); + userInfoComp = fixture.componentInstance; + }); + })); + + it('should NOT have users before ngOnInit only anonymous image', () => { + expect(userInfoComp.ecmUser).toBeUndefined(); + expect(userInfoComp.ecmUserImage).toBeUndefined(); + expect(userInfoComp.bpmUser).toBeUndefined(); + expect(userInfoComp.bpmUserImage).toBeUndefined(); + expect(userInfoComp.anonymouseImageUrl).not.toBeUndefined(); }); - it('should get the ecm user informations when is logged in', () => { - spyOn(ecmUserService, 'getUserInfo'); - spyOn(bpmUserService, 'getCurrentUserInfo'); - spyOn(authService, 'getAlfrescoApi').and.callThrough(); - // spyOn(authService.getAlfrescoApi(), 'ecmAuth').and.callThrough(); - spyOn(authService, 'getAlfrescoApi().ecmAuth.isLoggedIn').and.returnValue(true); - userInfoComp.ngOnInit(); - - expect(ecmUserService.getUserInfo).toHaveBeenCalledWith('-me-'); - expect(bpmUserService.getCurrentUserInfo).not.toHaveBeenCalled(); - + it('should NOT have users immediately after ngOnInit', () => { + fixture.detectChanges(); + expect(userInfoComp.ecmUser).toBeUndefined(); + expect(userInfoComp.ecmUserImage).toBeUndefined(); + expect(userInfoComp.bpmUser).toBeUndefined(); + expect(userInfoComp.bpmUserImage).toBeUndefined(); + expect(userInfoComp.anonymouseImageUrl).not.toBeUndefined(); }); + describe('when user is logged on ecm', () => { + + beforeEach( async(() => { + authStub = fixture.debugElement.injector.get(AlfrescoAuthenticationService); + fakeEcmService = fixture.debugElement.injector.get(EcmUserService); + + authStub.setIsEcmLoggedIn(true); + fixture.detectChanges(); // runs ngOnInit -> getUsers + fixture.whenStable() + .then( () => { + fixture.detectChanges(); + } ); + })); + + it('should get the ecm current user image from the service', () => { + expect(userInfoComp.ecmUser).not.toBeUndefined(); + expect(userInfoComp.ecmUserImage).not.toBeUndefined(); + expect(userInfoComp.ecmUserImage).toEqual('fake/url/image/for/ecm/user'); + }); + + it('should get the ecm user informations from the service', () => { + expect(userInfoComp.ecmUser).not.toBeUndefined(); + expect(userInfoComp.ecmUser.firstName).toEqual('fake-first-name'); + expect(userInfoComp.ecmUser.lastName).toEqual('fake-last-name'); + }); + + it('should return the anonynous user avatar image url when user does not have avatarId', async(() => { + fakeEcmService.userNeeded = 1; + userInfoComp.ngOnInit(); + fixture.whenStable() + .then( () => { + fixture.detectChanges(); + let res = userInfoComp.getEcmUserDetailAvatarUrl(); + expect(userInfoComp.ecmUserImage).toBeUndefined(); + expect(res).toEqual(userInfoComp.anonymouseImageUrl); + }); + })); + }); + + describe('when user is logged on bpm', () => { + + beforeEach( async(() => { + authStub = fixture.debugElement.injector.get(AlfrescoAuthenticationService); + fakeBpmService = fixture.debugElement.injector.get(BpmUserService); + + authStub.setIsBpmLoggedIn(true); + fixture.detectChanges(); // runs ngOnInit -> getUsers + fixture.whenStable() + .then( () => { + fixture.detectChanges(); + } ); + })); + + it('should get the bpm current user image from the service', () => { + expect(userInfoComp.bpmUser).not.toBeUndefined(); + expect(userInfoComp.bpmUserImage).not.toBeUndefined(); + expect(userInfoComp.bpmUserImage).toEqual('fake-picture-id'); + }); + + it('should get the bpm user informations from the service', () => { + expect(userInfoComp.bpmUser).not.toBeUndefined(); + expect(userInfoComp.bpmUser.firstName).toEqual('fake-first-name'); + expect(userInfoComp.bpmUser.lastName).toEqual('fake-last-name'); + }); + + it('should return the anonynous user avatar image url when user does not have avatarId', async(() => { + fakeBpmService.userNeeded = 1; + userInfoComp.ngOnInit(); + fixture.whenStable() + .then( () => { + fixture.detectChanges(); + let res = userInfoComp.getBpmUserDetailAvatarUrl(); + expect(userInfoComp.bpmUserImage).toBeUndefined(); + expect(res).toEqual(userInfoComp.anonymouseImageUrl); + }); + })); + }); + + describe('when user is logged on bpm and ecm', () => { + + beforeEach( async(() => { + authStub = fixture.debugElement.injector.get(AlfrescoAuthenticationService); + fakeBpmService = fixture.debugElement.injector.get(BpmUserService); + fakeEcmService = fixture.debugElement.injector.get(EcmUserService); + + authStub.setIsBpmLoggedIn(true); + authStub.setIsEcmLoggedIn(true); + fixture.detectChanges(); // runs ngOnInit -> getUsers + fixture.whenStable() + .then( () => { + fixture.detectChanges(); + } ); + })); + + it('should get the bpm current user image from the service', () => { + expect(userInfoComp.bpmUser).not.toBeUndefined(); + expect(userInfoComp.bpmUserImage).not.toBeUndefined(); + expect(userInfoComp.bpmUserImage).toEqual('fake-picture-id'); + expect(userInfoComp.ecmUser).not.toBeUndefined(); + expect(userInfoComp.ecmUserImage).not.toBeUndefined(); + expect(userInfoComp.ecmUserImage).toEqual('fake/url/image/for/ecm/user'); + }); + + it('should get the bpm user informations from the service', () => { + expect(userInfoComp.bpmUser).not.toBeUndefined(); + expect(userInfoComp.bpmUser.firstName).toEqual('fake-first-name'); + expect(userInfoComp.bpmUser.lastName).toEqual('fake-last-name'); + expect(userInfoComp.ecmUser).not.toBeUndefined(); + expect(userInfoComp.ecmUser.firstName).toEqual('fake-first-name'); + expect(userInfoComp.ecmUser.lastName).toEqual('fake-last-name'); + }); + + it('should return the anonynous user avatar image url when user does not have avatarId', async(() => { + fakeBpmService.userNeeded = 1; + fakeEcmService.userNeeded = 1; + userInfoComp.ngOnInit(); + fixture.whenStable() + .then( () => { + fixture.detectChanges(); + let resBpm = userInfoComp.getBpmUserDetailAvatarUrl(); + expect(userInfoComp.bpmUserImage).toBeUndefined(); + expect(resBpm).toEqual(userInfoComp.anonymouseImageUrl); + let resEcm = userInfoComp.getEcmUserDetailAvatarUrl(); + expect(userInfoComp.ecmUserImage).toBeUndefined(); + expect(resEcm).toEqual(userInfoComp.anonymouseImageUrl); + }); + })); + + it('should return the ecm image if exists', async(() => { + fakeBpmService.userNeeded = 0; + fakeEcmService.userNeeded = 0; + userInfoComp.ngOnInit(); + fixture.whenStable() + .then( () => { + fixture.detectChanges(); + let res = userInfoComp.getUserAvatar(); + expect(userInfoComp.bpmUserImage).not.toBeUndefined(); + expect(userInfoComp.ecmUserImage).not.toBeUndefined(); + expect(res).toEqual(userInfoComp.ecmUserImage); + }); + })); + + it('should return the bpm image if ecm does not have it', async(() => { + fakeBpmService.userNeeded = 0; + fakeEcmService.userNeeded = 1; + userInfoComp.ngOnInit(); + fixture.whenStable() + .then( () => { + fixture.detectChanges(); + let res = userInfoComp.getUserAvatar(); + expect(userInfoComp.bpmUserImage).not.toBeUndefined(); + expect(userInfoComp.ecmUserImage).toBeUndefined(); + expect(res).toEqual(userInfoComp.bpmUserImage); + }); + })); + + it('should return the anonynous avatar if no user has it', async(() => { + fakeBpmService.userNeeded = 1; + fakeEcmService.userNeeded = 1; + userInfoComp.ngOnInit(); + fixture.whenStable() + .then( () => { + fixture.detectChanges(); + let res = userInfoComp.getUserAvatar(); + expect(userInfoComp.bpmUserImage).toBeUndefined(); + expect(userInfoComp.ecmUserImage).toBeUndefined(); + expect(res).toEqual(userInfoComp.anonymouseImageUrl); + }); + })); + }); }); diff --git a/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.ts b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.ts index 9ca5f1aa18..339ddfcc06 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.ts @@ -33,12 +33,13 @@ declare let __moduleName: string; export class UserInfoComponent implements OnInit { - private ecmUser: EcmUserModel; - private bpmUser: BpmUserModel; private baseComponentPath = __moduleName.replace('components/user-info.component.js', ''); - private anonymouseImageUrl: string = this.baseComponentPath + 'img/anonymous.gif'; - public bpmUserImage: any; - public ecmUserImage: any; + + ecmUser: EcmUserModel; + bpmUser: BpmUserModel; + anonymouseImageUrl: string = this.baseComponentPath + 'img/anonymous.gif'; + bpmUserImage: any; + ecmUserImage: any; constructor(private ecmUserService: EcmUserService, private bpmUserService: BpmUserService, @@ -46,8 +47,8 @@ export class UserInfoComponent implements OnInit { } ngOnInit() { - if (this.authService.getAlfrescoApi().ecmAuth.isLoggedIn()) { - this.ecmUserService.getUserInfo('-me-') + if ( this.authService.isEcmLoggedIn() ) { + this.ecmUserService.getCurrentUserInfo() .subscribe( (res) => { this.ecmUser = res; @@ -55,7 +56,7 @@ export class UserInfoComponent implements OnInit { } ); } - if (this.authService.getAlfrescoApi().bpmAuth.isLoggedIn()) { + if ( this.authService.isBpmLoggedIn() ) { this.bpmUserService.getCurrentUserInfo() .subscribe( (res) => { diff --git a/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.ts b/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.ts index 98d637a6ed..208206066b 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.ts @@ -37,7 +37,7 @@ export class BpmUserService { * @param userName - the user name */ getCurrentUserInfo(): Observable { - if ( this.authService.getAlfrescoApi().bpmAuth.isLoggedIn() ) { + if ( this.authService.isBpmLoggedIn() ) { return Observable.fromPromise(this.callApiGetProfile()) .map( (data) => data @@ -47,7 +47,7 @@ export class BpmUserService { } getCurrentUserProfileImage(): any { - if ( this.authService.getAlfrescoApi().bpmAuth.isLoggedIn() ) { + if ( this.authService.isBpmLoggedIn() ) { return Observable.fromPromise(this.callApiGetProfilePicture()) .map( (data) => data diff --git a/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.ts b/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.ts index 6875ee7d48..83fbd67bde 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.ts @@ -37,7 +37,7 @@ export class EcmUserService { * @param userName - the user name */ getUserInfo(userName: string): Observable { - if ( this.authService.getAlfrescoApi().ecmAuth.isLoggedIn() ) { + if ( this.authService.isEcmLoggedIn() ) { return Observable.fromPromise(this.callApiGetPersonInfo(userName)) .map( (data) => data['entry'] @@ -46,6 +46,10 @@ export class EcmUserService { } } + getCurrentUserInfo() { + return this.getUserInfo('-me-'); + } + private callApiGetPersonInfo(userName: string, opts?: any) { return this.authService.getAlfrescoApi().core.peopleApi.getPerson(userName, opts); } diff --git a/ng2-components/ng2-alfresco-userinfo/src/testing/fake-bpm-user.service.ts b/ng2-components/ng2-alfresco-userinfo/src/testing/fake-bpm-user.service.ts new file mode 100644 index 0000000000..51a6602cc6 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/src/testing/fake-bpm-user.service.ts @@ -0,0 +1,89 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed 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. + */ + +// re-export for tester convenience +export { BpmUserModel } from '../models/bpm-user.model'; +export { BpmUserService } from '../services/bpm-user.service'; + +import { BpmUserModel } from '../models/bpm-user.model'; +import { Observable } from 'rxjs/Rx'; + +export var fakeBpmUserNoImage: BpmUserModel = { + apps: {}, + capabilities: 'fake-capability', + company: 'fake-company', + created: 'fake-create-date', + email: 'fakeBpm@fake.com', + externalId: 'fake-external-id', + firstName: 'fake-first-name', + lastName: 'fake-last-name', + fullname: 'fake-full-name', + groups: {}, + id: 'fake-id', + lastUpdate: 'fake-update-date', + latestSyncTimeStamp: 'fake-timestamp', + password: 'fake-password', + pictureId: undefined, + status: 'fake-status', + tenantId: 'fake-tenant-id', + tenantName: 'fake-tenant-name', + tenantPictureId: 'fake-tenant-picture-id', + type: 'fake-type' +}; + +export var fakeBpmUser: BpmUserModel = { + apps: {}, + capabilities: 'fake-capability', + company: 'fake-company', + created: 'fake-create-date', + email: 'fakeBpm@fake.com', + externalId: 'fake-external-id', + firstName: 'fake-first-name', + lastName: 'fake-last-name', + fullname: 'fake-full-name', + groups: {}, + id: 'fake-id', + lastUpdate: 'fake-update-date', + latestSyncTimeStamp: 'fake-timestamp', + password: 'fake-password', + pictureId: 'fake-picture-id', + status: 'fake-status', + tenantId: 'fake-tenant-id', + tenantName: 'fake-tenant-name', + tenantPictureId: 'fake-tenant-picture-id', + type: 'fake-type' +}; + +export class FakeBpmUserService { + + lastPromise: Observable; + public userNeeded = 0; + usersList = [fakeBpmUser, fakeBpmUserNoImage]; + + getUserInfo(userName: string) { + return this.lastPromise = Observable.of(this.usersList[this.userNeeded]); + }; + + getCurrentUserInfo() { + return this.getUserInfo('fake-id'); + }; + + getCurrentUserProfileImage() { + return this.usersList[this.userNeeded].pictureId; + }; + +} diff --git a/ng2-components/ng2-alfresco-userinfo/src/testing/fake-ecm-user.service.ts b/ng2-components/ng2-alfresco-userinfo/src/testing/fake-ecm-user.service.ts new file mode 100644 index 0000000000..0ee8694ede --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/src/testing/fake-ecm-user.service.ts @@ -0,0 +1,99 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed 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. + */ + +// re-export for tester convenience +export { EcmUserModel } from '../models/ecm-user.model'; +export { EcmUserService } from '../services/ecm-user.service'; + +import { EcmUserModel } from '../models/ecm-user.model'; +import { EcmCompanyModel } from '../models/ecm-company.model'; +import { Observable } from 'rxjs/Rx'; + +export var fakeEcmCompany: EcmCompanyModel = { + organization: 'company-fake-name', + address1: 'fake-address-1', + address2: 'fake-address-2', + address3: 'fake-address-3', + postcode: 'fAk1', + telephone: '00000000', + fax: '11111111', + email: 'fakeCompany@fake.com' +}; + +export var fakeEcmUserNoImage: EcmUserModel = { + id: 'fake-id', + firstName: 'fake-first-name', + lastName: 'fake-last-name', + description: 'i am a fake user for test', + avatarId: undefined, + email: 'fakeEcm@ecmUser.com', + skypeId: 'fake-skype-id', + googleId: 'fake-googleId-id', + instantMessageId: 'fake-instantMessageId-id', + company: fakeEcmCompany, + jobTitle: 'test job', + location: 'fake location', + mobile: '000000000', + telephone: '11111111', + statusUpdatedAt: 'fake-date', + userStatus: 'active', + enabled: true, + emailNotificationsEnabled: true +}; + +export var fakeEcmUser: EcmUserModel = { + id: 'fake-id', + firstName: 'fake-first-name', + lastName: 'fake-last-name', + description: 'i am a fake user for test', + avatarId: 'fake-avatar-id', + email: 'fakeEcm@ecmUser.com', + skypeId: 'fake-skype-id', + googleId: 'fake-googleId-id', + instantMessageId: 'fake-instantMessageId-id', + company: fakeEcmCompany, + jobTitle: 'test job', + location: 'fake location', + mobile: '000000000', + telephone: '11111111', + statusUpdatedAt: 'fake-date', + userStatus: 'active', + enabled: true, + emailNotificationsEnabled: true +}; + +export class FakeEcmUserService { + + lastPromise: Observable; + public userNeeded = 0; + usersList = [fakeEcmUser, fakeEcmUserNoImage]; + + getUserInfo(userName: string) { + return this.lastPromise = Observable.of(this.usersList[this.userNeeded]); + }; + + getCurrentUserInfo() { + return this.getUserInfo('fake-id'); + }; + + getCurrentUserProfileImageUrl(avatarId: string) { + if ( avatarId ) { + return 'fake/url/image/for/ecm/user'; + } + }; + +} From 0b7f3cc9a6495b427e7932465cf11f490ea645cb Mon Sep 17 00:00:00 2001 From: Vito Albano Date: Fri, 30 Sep 2016 03:47:49 +0100 Subject: [PATCH 15/26] Added unit tests for services --- .../src/services/bpm-user.service.spec.ts | 144 +++++++++++--- .../src/services/bpm-user.service.ts | 4 +- .../src/services/ecm-user.service.spec.ts | 184 ++++++++++++++---- .../src/services/ecm-user.service.ts | 2 +- 4 files changed, 271 insertions(+), 63 deletions(-) diff --git a/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.spec.ts b/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.spec.ts index ab002e9957..a9586bad3d 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.spec.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.spec.ts @@ -14,35 +14,133 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// import { UserInfoComponent } from '../src/userinfo.component'; -/* -describe('Bpm User Service', () => { +import { BpmUserService } from '../services/bpm-user.service'; +import { AlfrescoAuthenticationService } from 'ng2-alfresco-core'; +import { TestBed, async, inject } from '@angular/core/testing'; +import { BpmUserModel } from '../models/bpm-user.model'; - beforeEachProviders(() => { - return [ - HTTP_PROVIDERS, - AlfrescoSettingsService, - AlfrescoAuthenticationService, - WidgetVisibilityService - ]; - }); +export var fakeBpmUser: BpmUserModel = { + apps: {}, + capabilities: 'fake-capability', + company: 'fake-company', + created: 'fake-create-date', + email: 'fakeBpm@fake.com', + externalId: 'fake-external-id', + firstName: 'fake-first-name', + lastName: 'fake-last-name', + fullname: 'fake-full-name', + groups: {}, + id: 'fake-id', + lastUpdate: 'fake-update-date', + latestSyncTimeStamp: 'fake-timestamp', + password: 'fake-password', + pictureId: 'fake-picture-id', + status: 'fake-status', + tenantId: 'fake-tenant-id', + tenantName: 'fake-tenant-name', + tenantPictureId: 'fake-tenant-picture-id', + type: 'fake-type' +}; - beforeEach( - inject([WidgetVisibilityService], (activitiService: WidgetVisibilityService) => { - jasmine.Ajax.install(); - service = activitiService; - }) - ); +class StubAuthentication { + isEcmConnected: boolean; + isBpmConnected: boolean; + setIsEcmLoggedIn(logged: boolean) { this.isEcmConnected = logged; }; + setIsBpmLoggedIn(logged: boolean) { this.isBpmConnected = logged; }; + isEcmLoggedIn() { return this.isEcmConnected; }; + isBpmLoggedIn() { return this.isBpmConnected; }; + callApiGetPersonInfo() { return Promise.resolve(fakeEcmUser); }; +}; - afterEach(() => { - jasmine.Ajax.uninstall(); - }); +describe('Bpm User service', () => { + beforeEach( async(() => { + TestBed.configureTestingModule({ + providers: [ BpmUserService, + { provide: AlfrescoAuthenticationService, useClass: StubAuthentication } + ] + }) + .compileComponents(); + })); - it('should be able to get current user information', () => { + it('can instantiate service when inject service', + inject([BpmUserService], (service: BpmUserService) => { + expect(service instanceof BpmUserService).toBe(true); + })); - }); + it('can instantiate service with authorization', inject([AlfrescoAuthenticationService], + (auth: AlfrescoAuthenticationService) => { + expect(auth).not.toBeNull('authorization should be provided'); + let service = new BpmUserService(auth, null); + expect(service instanceof BpmUserService).toBe(true, 'new service should be ok'); + })); + describe('when user is logged in', () => { + let service: BpmUserService; + let authServiceForTest: AlfrescoAuthenticationService; + + beforeEach( + inject( + [AlfrescoAuthenticationService ], + ( authService: AlfrescoAuthenticationService ) => { + authServiceForTest = authService; + service = new BpmUserService(authService); + spyOn(authServiceForTest, 'isBpmLoggedIn').and.returnValue(true); + })); + + it('should be able to retrieve current user info', (done) => { + spyOn(service, 'callApiGetProfile').and.returnValue(Promise.resolve(fakeBpmUser)); + service.getCurrentUserInfo().subscribe( + (user) => { + expect(user).not.toBeUndefined(); + expect(user.firstName).toEqual('fake-first-name'); + expect(user.lastName).toEqual('fake-last-name'); + expect(user.email).toEqual('fakeBpm@fake.com'); + done(); + }); + }); + + it('should retrieve current logged user information via js api', () => { + spyOn(service, 'callApiGetProfile'); + service.getCurrentUserInfo(); + expect(service.callApiGetProfile).toHaveBeenCalled(); + }); + + it('should retrieve avatar url for current user', (done) => { + spyOn(service, 'callApiGetProfilePicture').and.returnValue(Promise.resolve('fake/img/path')); + service.getCurrentUserProfileImage().subscribe( + (path) => { + expect(path).not.toBeUndefined(); + expect(path).toEqual('fake/img/path'); + done(); + }); + }); + }); + + describe('when user is not logged in', () => { + let service: BpmUserService; + let authServiceForTest: AlfrescoAuthenticationService; + + beforeEach( + inject( + [AlfrescoAuthenticationService], + (authService: AlfrescoAuthenticationService) => { + authServiceForTest = authService; + service = new BpmUserService(authService); + spyOn(authServiceForTest, 'isBpmLoggedIn').and.returnValue(false); + })); + + it('should not retrieve the user information', () => { + spyOn(service, 'callApiGetProfile'); + service.getCurrentUserInfo(); + expect(service.callApiGetProfile).not.toHaveBeenCalled(); + }); + + it('should not retrieve the user avatar', () => { + spyOn(service, 'callApiGetProfilePicture'); + service.getCurrentUserInfo(); + expect(service.callApiGetProfilePicture).not.toHaveBeenCalled(); + }); + }); }); -*/ diff --git a/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.ts b/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.ts index 208206066b..9f2c5626dd 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.ts @@ -59,14 +59,14 @@ export class BpmUserService { /** * Call js api to get current user profile picture */ - private callApiGetProfilePicture() { + callApiGetProfilePicture() { return this.authService.getAlfrescoApi().activiti.profileApi.getProfile(); } /** * Call js api to get current user information */ - private callApiGetProfile() { + callApiGetProfile() { return this.authService.getAlfrescoApi().activiti.profileApi.getProfile(); } diff --git a/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.spec.ts b/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.spec.ts index 5bc6a53e0f..871f26b86a 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.spec.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.spec.ts @@ -14,56 +14,166 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* -// import { AlfrescoAuthenticationService, AlfrescoContentService } from 'ng2-alfresco-core'; -import { EcmUserService } from './ecm-user.service'; -import { ReflectiveInjector } from '@angular/core'; -import { EcmUserModel } from '../models/ecm-user.model'; -declare var AlfrescoApi: any; -declare let jasmine: any; +import { EcmUserService } from '../services/ecm-user.service'; +import { AlfrescoAuthenticationService, AlfrescoContentService } from 'ng2-alfresco-core'; +import { TestBed, async, inject } from '@angular/core/testing'; +import { EcmUserModel } from '../models/ecm-user.model'; +import { EcmCompanyModel } from '../models/ecm-company.model'; + +export var fakeEcmCompany: EcmCompanyModel = { + organization: 'company-fake-name', + address1: 'fake-address-1', + address2: 'fake-address-2', + address3: 'fake-address-3', + postcode: 'fAk1', + telephone: '00000000', + fax: '11111111', + email: 'fakeCompany@fake.com' +}; + +export var fakeEcmUser: EcmUserModel = { + id: 'fake-id', + firstName: 'fake-first-name', + lastName: 'fake-last-name', + description: 'i am a fake user for test', + avatarId: 'fake-avatar-id', + email: 'fakeEcm@ecmUser.com', + skypeId: 'fake-skype-id', + googleId: 'fake-googleId-id', + instantMessageId: 'fake-instantMessageId-id', + company: fakeEcmCompany, + jobTitle: 'test job', + location: 'fake location', + mobile: '000000000', + telephone: '11111111', + statusUpdatedAt: 'fake-date', + userStatus: 'active', + enabled: true, + emailNotificationsEnabled: true +}; + +class StubAuthentication { + isEcmConnected: boolean; + isBpmConnected: boolean; + setIsEcmLoggedIn(logged: boolean) { this.isEcmConnected = logged; }; + setIsBpmLoggedIn(logged: boolean) { this.isBpmConnected = logged; }; + isEcmLoggedIn() { return this.isEcmConnected; }; + isBpmLoggedIn() { return this.isBpmConnected; }; + callApiGetPersonInfo() { return Promise.resolve(fakeEcmUser); }; +}; + +class StubAlfrescoContentService { + getContentUrl() { return 'fake/url/image/for/ecm/user'; } ; +} describe('Ecm User service', () => { - let injector; - let ecmUserService: EcmUserService; - // let contentService: AlfrescoContentService; - // let authService: AlfrescoAuthenticationService; + beforeEach( async(() => { + TestBed.configureTestingModule({ + providers: [ EcmUserService, + { provide: AlfrescoAuthenticationService, useClass: StubAuthentication }, + { provide: AlfrescoContentService, useClass: StubAlfrescoContentService } + ] + }) + .compileComponents(); + })); - beforeEach(() => { + it('can instantiate service when inject service', + inject([EcmUserService], (service: EcmUserService) => { + expect(service instanceof EcmUserService).toBe(true); + })); - injector = ReflectiveInjector.resolveAndCreate([ - EcmUserService - ]); + it('can instantiate service with authorization', inject([AlfrescoAuthenticationService], + (auth: AlfrescoAuthenticationService) => { + expect(auth).not.toBeNull('authorization should be provided'); + let service = new EcmUserService(auth, null); + expect(service instanceof EcmUserService).toBe(true, 'new service should be ok'); + })); - // contentService = injector.get(AlfrescoContentService); - // authService = injector.get(AlfrescoAuthenticationService); - ecmUserService = injector.get(EcmUserService); + it('can instantiate service with content service', inject([AlfrescoContentService], + (content: AlfrescoContentService) => { + expect(content).not.toBeNull('contentService should be provided'); + let service = new EcmUserService(null, content); + expect(service instanceof EcmUserService).toBe(true, 'new service should be ok'); + })); - jasmine.Ajax.install(); - }); + describe('when user is logged in', () => { + let service: EcmUserService; + let authServiceForTest: AlfrescoAuthenticationService; + let contentServiceForTest: AlfrescoContentService; - afterEach(() => { - jasmine.Ajax.uninstall(); - }); + beforeEach( + inject( + [AlfrescoAuthenticationService, AlfrescoContentService], + (authService: AlfrescoAuthenticationService, content: AlfrescoContentService) => { + authServiceForTest = authService; + contentServiceForTest = content; + service = new EcmUserService(authService, content); + spyOn(authServiceForTest, 'isEcmLoggedIn').and.returnValue(true); + })); - it('should be able', (done) => { - let authService = new AlfrescoAuthenticationService(); - spyOn(authService, ) - ecmUserService.getUserInfo('fake-user').subscribe((res) => { - expect(res).not.toBeUndefined(); - expect(res).toEqual(jasmine.any(EcmUserModel)); - expect(res.firstName).toEqual('fake-user-response'); - expect(res.email).toEqual('fake@email.com'); - done(); + it('should be able to retrieve current user info', (done) => { + let userJsApiResponse = {entry: fakeEcmUser}; + spyOn(service, 'callApiGetPersonInfo').and.returnValue(Promise.resolve(userJsApiResponse)); + service.getCurrentUserInfo().subscribe( + (user) => { + expect(user).not.toBeUndefined(); + expect(user.firstName).toEqual('fake-first-name'); + expect(user.lastName).toEqual('fake-last-name'); + expect(user.email).toEqual('fakeEcm@ecmUser.com'); + done(); + }); }); - jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 201, - contentType: 'application/json', - responseText: JSON.stringify({'entry': {'firstName': 'fake-user-response', 'id': 'fake@email.com'}}) + it('should retrieve current logged user information', () => { + spyOn(service, 'getUserInfo'); + spyOn(service, 'callApiGetPersonInfo').and.callThrough(); + service.getCurrentUserInfo(); + expect(service.getUserInfo).toHaveBeenCalledWith('-me-'); + }); + + it('should retrieve avatar url for current user', () => { + spyOn(contentServiceForTest, 'getContentUrl').and.returnValue('fake/url/image/for/ecm/user'); + let urlRs = service.getCurrentUserProfileImageUrl('fake-avatar-id'); + + expect(urlRs).toEqual('fake/url/image/for/ecm/user'); + }); + + it('should not call content service without avatar id', () => { + spyOn(contentServiceForTest, 'getContentUrl').and.callThrough(); + let urlRs = service.getCurrentUserProfileImageUrl(); + expect(urlRs).toBeUndefined(); + expect(contentServiceForTest.getContentUrl).not.toHaveBeenCalled(); + }); + + it('should build the body for the content service', () => { + spyOn(contentServiceForTest, 'getContentUrl').and.callThrough(); + let urlRs = service.getCurrentUserProfileImageUrl('fake-avatar-id'); + expect(urlRs).not.toBeUndefined(); + expect(contentServiceForTest.getContentUrl).toHaveBeenCalledWith( {entry: {id: 'fake-avatar-id'} }); }); }); + describe('when user is not logged in', () => { + let service: EcmUserService; + let authServiceForTest: AlfrescoAuthenticationService; + let contentServiceForTest: AlfrescoContentService; + + beforeEach( + inject( + [AlfrescoAuthenticationService, AlfrescoContentService], + (authService: AlfrescoAuthenticationService, content: AlfrescoContentService) => { + authServiceForTest = authService; + contentServiceForTest = content; + service = new EcmUserService(authService, content); + spyOn(authServiceForTest, 'isEcmLoggedIn').and.returnValue(false); + })); + + it('should not retrieve the user information', () => { + spyOn(service, 'callApiGetPersonInfo'); + service.getCurrentUserInfo(); + expect(service.callApiGetPersonInfo).not.toHaveBeenCalled(); + }); + }); }); -*/ diff --git a/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.ts b/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.ts index 83fbd67bde..1175af0f1a 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.ts @@ -50,7 +50,7 @@ export class EcmUserService { return this.getUserInfo('-me-'); } - private callApiGetPersonInfo(userName: string, opts?: any) { + callApiGetPersonInfo(userName: string, opts?: any) { return this.authService.getAlfrescoApi().core.peopleApi.getPerson(userName, opts); } From 0635b652d205a89745b7ed0c87957f7aa3e2f138 Mon Sep 17 00:00:00 2001 From: Vito Albano Date: Fri, 30 Sep 2016 10:29:23 +0100 Subject: [PATCH 16/26] fixed build errors --- .../src/services/bpm-user.service.spec.ts | 4 ++-- .../src/services/ecm-user.service.spec.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.spec.ts b/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.spec.ts index a9586bad3d..b9655e6951 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.spec.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.spec.ts @@ -50,7 +50,7 @@ class StubAuthentication { setIsBpmLoggedIn(logged: boolean) { this.isBpmConnected = logged; }; isEcmLoggedIn() { return this.isEcmConnected; }; isBpmLoggedIn() { return this.isBpmConnected; }; - callApiGetPersonInfo() { return Promise.resolve(fakeEcmUser); }; + callApiGetPersonInfo() { return Promise.resolve(fakeBpmUser); }; }; describe('Bpm User service', () => { @@ -72,7 +72,7 @@ describe('Bpm User service', () => { it('can instantiate service with authorization', inject([AlfrescoAuthenticationService], (auth: AlfrescoAuthenticationService) => { expect(auth).not.toBeNull('authorization should be provided'); - let service = new BpmUserService(auth, null); + let service = new BpmUserService(auth); expect(service instanceof BpmUserService).toBe(true, 'new service should be ok'); })); diff --git a/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.spec.ts b/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.spec.ts index 871f26b86a..0677818dfa 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.spec.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.spec.ts @@ -142,7 +142,7 @@ describe('Ecm User service', () => { it('should not call content service without avatar id', () => { spyOn(contentServiceForTest, 'getContentUrl').and.callThrough(); - let urlRs = service.getCurrentUserProfileImageUrl(); + let urlRs = service.getCurrentUserProfileImageUrl(undefined); expect(urlRs).toBeUndefined(); expect(contentServiceForTest.getContentUrl).not.toHaveBeenCalled(); }); From b5a944219eb4c5ced2e396c54cf569236cad3736 Mon Sep 17 00:00:00 2001 From: Vito Albano Date: Mon, 3 Oct 2016 10:21:17 +0100 Subject: [PATCH 17/26] remove wrong pushed folder --- .../ng2-alfresco-userinfo-old/.editorconfig | 23 --- .../ng2-alfresco-userinfo-old/.gitignore | 13 -- .../ng2-alfresco-userinfo-old/.travis.yml | 8 -- .../ng2-alfresco-userinfo-old/LICENSE | 13 -- .../ng2-alfresco-userinfo-old/README.md | 73 ---------- .../demo/.editorconfig | 10 -- .../ng2-alfresco-userinfo-old/demo/.gitignore | 5 - .../ng2-alfresco-userinfo-old/demo/README.md | 19 --- .../ng2-alfresco-userinfo-old/demo/index.html | 71 ---------- .../demo/package.json | 89 ------------ .../demo/src/main.ts | 95 ------------- .../demo/systemjs.config.js | 56 -------- .../demo/tsconfig.json | 33 ----- .../demo/tslint.json | 124 ----------------- .../demo/typings.json | 7 - .../ng2-alfresco-userinfo-old/index.ts | 58 -------- .../karma-test-shim.js | 128 ----------------- .../ng2-alfresco-userinfo-old/karma.conf.js | 131 ------------------ .../ng2-alfresco-userinfo-old/package.json | 94 ------------- .../src/components/user-info.component.css | 53 ------- .../src/components/user-info.component.html | 63 --------- .../components/user-info.component.spec.ts | 25 ---- .../src/components/user-info.component.ts | 93 ------------- .../src/i18n/en.json | 24 ---- .../src/i18n/it.json | 24 ---- .../src/img/anonymous.gif | Bin 1765 -> 0 bytes .../src/models/bpm-user.model.ts | 39 ------ .../src/models/ecm-company.model.ts | 27 ---- .../src/models/ecm-user.model.ts | 39 ------ .../src/services/bpm-user.service.ts | 75 ---------- .../src/services/ecm-user.service.ts | 72 ---------- .../ng2-alfresco-userinfo-old/tsconfig.json | 26 ---- .../ng2-alfresco-userinfo-old/tslint.json | 121 ---------------- .../ng2-alfresco-userinfo-old/typings.json | 7 - 34 files changed, 1738 deletions(-) delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/.editorconfig delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/.gitignore delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/.travis.yml delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/LICENSE delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/README.md delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/demo/.editorconfig delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/demo/.gitignore delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/demo/README.md delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/demo/index.html delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/demo/package.json delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/demo/src/main.ts delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/demo/systemjs.config.js delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/demo/tsconfig.json delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/demo/tslint.json delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/demo/typings.json delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/index.ts delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/karma-test-shim.js delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/karma.conf.js delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/package.json delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.css delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.html delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.spec.ts delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.ts delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/src/i18n/en.json delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/src/i18n/it.json delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/src/img/anonymous.gif delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/src/models/bpm-user.model.ts delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/src/models/ecm-company.model.ts delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/src/models/ecm-user.model.ts delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/src/services/bpm-user.service.ts delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/src/services/ecm-user.service.ts delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/tsconfig.json delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/tslint.json delete mode 100644 ng2-components/ng2-alfresco-userinfo-old/typings.json diff --git a/ng2-components/ng2-alfresco-userinfo-old/.editorconfig b/ng2-components/ng2-alfresco-userinfo-old/.editorconfig deleted file mode 100644 index 75a2477db7..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/.editorconfig +++ /dev/null @@ -1,23 +0,0 @@ -# http://editorconfig.org - -root = true - -[*] -charset = utf-8 -indent_style = space -indent_size = 4 -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true - -[package.json] -indent_style = space -indent_size = 2 - -[karma.conf.js] -indent_style = space -indent_size = 2 - -[*.md] -insert_final_newline = false -trim_trailing_whitespace = false diff --git a/ng2-components/ng2-alfresco-userinfo-old/.gitignore b/ng2-components/ng2-alfresco-userinfo-old/.gitignore deleted file mode 100644 index 3bea8a0c07..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -npm-debug.log -node_modules -jspm_packages -.idea -typings -coverage -src/**/*.js -src/**/*.js.map -src/**/*.d.ts -demo/**/*.js -demo/**/*.js.map -demo/**/*.d.ts -!systemjs.config.js diff --git a/ng2-components/ng2-alfresco-userinfo-old/.travis.yml b/ng2-components/ng2-alfresco-userinfo-old/.travis.yml deleted file mode 100644 index 781e6204e8..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: node_js -node_js: - - v5 - - v4 -install: npm install -sudo: false -after_success: - npm run coverage diff --git a/ng2-components/ng2-alfresco-userinfo-old/LICENSE b/ng2-components/ng2-alfresco-userinfo-old/LICENSE deleted file mode 100644 index bfd4a66b0c..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/LICENSE +++ /dev/null @@ -1,13 +0,0 @@ -Copyright 2016 vito albano - -Licensed 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. diff --git a/ng2-components/ng2-alfresco-userinfo-old/README.md b/ng2-components/ng2-alfresco-userinfo-old/README.md deleted file mode 100644 index f100be7287..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# Alfresco User Info Component for Angular 2 -This component will show the user information for ECM and BPM - - -## Prerequisites - -Before you start using this development framework, make sure you have installed all required software and done all the -necessary configuration, see this [page](https://github.com/Alfresco/alfresco-ng2-components/blob/master/PREREQUISITES.md). - -## Installation - -```bash -npm install ng2-alfresco-userinfo --save -``` -## Dependencies - -Add the following dependency to your index.html: -```html - -``` - -You must separately install the following libraries for your application: - -- [ng2-translate](https://github.com/ocombe/ng2-translate) -- [ng2-alfresco-core](https://www.npmjs.com/package/ng2-alfresco-core) - -```sh -npm install --save ng2-translate ng2-alfresco-core -``` - -#### Material Design Lite - -The style of this component is based on [material design](https://getmdl.io/), so if you want to visualize it correctly you have to add the material -design dependency to your project: - -```sh -npm install --save material-design-icons material-design-lite -``` - -Also make sure you include these dependencies in your `index.html` file: - -```html - - - - -``` - -## Example - -```html - -``` -This will show a round icon with user and on click some user information are showed. -If user is logged in with ECM and BPM the ECM image will be showed. - -## NPM scripts - -| Command | Description | -| --- | --- | -| npm run build | Build component | -| npm run build:w | Build component and keep watching the changes | -| npm run test | Run unit tests in the console | -| npm run test-browser | Run unit tests in the browser -| npm run coverage | Run unit tests and display code coverage report | - -## History - -For detailed changelog, check [Releases](https://github.com/alfresco/ng2-alfresco-userinfo/releases). - -## Contributors - -[Contributors](https://github.com/alfresco/ng2-alfresco-userinfo/graphs/contributors) diff --git a/ng2-components/ng2-alfresco-userinfo-old/demo/.editorconfig b/ng2-components/ng2-alfresco-userinfo-old/demo/.editorconfig deleted file mode 100644 index 8ed330c4a2..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/demo/.editorconfig +++ /dev/null @@ -1,10 +0,0 @@ - -root = true - -[{src,scripts}/**.{ts,json,js}] -end_of_line = crlf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true -indent_style = space -indent_size = 4 diff --git a/ng2-components/ng2-alfresco-userinfo-old/demo/.gitignore b/ng2-components/ng2-alfresco-userinfo-old/demo/.gitignore deleted file mode 100644 index 7c04460244..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/demo/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -typings/ -node_modules/ -.idea -dist/ -!systemjs.config.js diff --git a/ng2-components/ng2-alfresco-userinfo-old/demo/README.md b/ng2-components/ng2-alfresco-userinfo-old/demo/README.md deleted file mode 100644 index 7b59778398..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/demo/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# ng2-alfresco-userinfo - Demo - -* To install dependencies - -```sh -$ npm install -``` - -* To provide a live demo - -```sh -$ npm run start -``` - -* To clean npm_modules and typings folder - -```sh -$ npm run clean -``` diff --git a/ng2-components/ng2-alfresco-userinfo-old/demo/index.html b/ng2-components/ng2-alfresco-userinfo-old/demo/index.html deleted file mode 100644 index ab1420147f..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/demo/index.html +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - NgModule Minimal - - - - - - - - - - - - - - - - -Loading... - - - - - \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-userinfo-old/demo/package.json b/ng2-components/ng2-alfresco-userinfo-old/demo/package.json deleted file mode 100644 index 3cc656550a..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/demo/package.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "name": "ng2-alfresco-userinfo-demo", - "description": "This component will show the user information for ECM and BPM - Demo", - "version": "0.1.0", - "author": "vito albano ", - "scripts": { - "clean": "rimraf dist node_modules", - "build": "npm run tslint && rimraf dist && tsc && npm run copy-dist", - "build:w": "npm run tslint && rimraf dist && npm run watch-task", - "watch-task": "concurrently \"npm run tsc:w\" \"npm run copy-dist:w\" ", - "start": "npm run build && concurrently \"npm run tsc:w\" \"npm run server\" ", - "server": "wsrv -o -l -s", - "tslint": "tslint -c tslint.json *.ts && tslint -c tslint.json 'src/{,**/}**.ts'", - "copy-dist": "cpx \"./src/**/*.{html,css,json,png,jpg,gif,svg}\" ./dist/src", - "copy-dist:w": "cpx \"./src/**/*.{html,css,json,png,jpg,gif,svg}\" ./dist/src -w", - "tsc": "tsc", - "tsc:w": "tsc -w", - "pretest": "npm run build", - "test": "karma start karma.conf.js --reporters mocha,coverage --single-run", - "test-browser": "npm run build && concurrently \"karma start karma.conf.js --reporters kjhtml\" \"npm run watch-task\"" - }, - "main": "index.js", - "typings": "./dist/index.d.ts", - "repository": { - "type": "git", - "url": "https://github.com/Alfresco/alfresco-ng2-components.git" - }, - "bugs": { - "url": "https://github.com/Alfresco/alfresco-ng2-components/issues" - }, - "license": "Apache-2.0", - "contributors": [ - { - "name": "Vito Albano", - "email": "vito.albano@alfresco.com" - } - ], - "keywords": [ - "ng2", - "angular", - "angular2", - "alfresco", - "demo" - ], - "dependencies": { - "@angular/common": "2.0.0", - "@angular/compiler": "2.0.0", - "@angular/core": "2.0.0", - - "@angular/http": "2.0.0", - "@angular/platform-browser": "2.0.0", - "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", - "@angular/upgrade": "2.0.0", - "core-js": "^2.4.1", - "reflect-metadata": "^0.1.3", - "rxjs": "5.0.0-beta.12", - "systemjs": "0.19.27", - "zone.js": "^0.6.23", - "ng2-translate": "2.5.0", - "ng2-alfresco-core": "0.3.2", - "material-design-icons": "2.2.3", - "material-design-lite": "1.2.1", - "ng2-alfresco-userinfo": "file:../" - }, - "devDependencies": { - "@types/core-js": "^0.9.32", - "@types/jasmine": "^2.2.33", - "concurrently": "^2.2.0", - "cpx": "1.3.1", - "jasmine-ajax": "3.2.0", - "jasmine-core": "2.4.1", - "karma": "0.13.22", - "karma-chrome-launcher": "1.0.1", - "karma-coverage": "1.0.0", - "karma-jasmine": "1.0.2", - "karma-jasmine-ajax": "^0.1.13", - "karma-jasmine-html-reporter": "0.2.0", - "karma-mocha-reporter": "2.0.3", - "license-check": "1.1.5", - "remap-istanbul": "0.6.3", - "rimraf": "2.5.2", - "traceur": "0.0.91", - "tslint": "3.8.1", - "typescript": "^2.0.3", - "wsrv": "^0.1.5" - } - -} diff --git a/ng2-components/ng2-alfresco-userinfo-old/demo/src/main.ts b/ng2-components/ng2-alfresco-userinfo-old/demo/src/main.ts deleted file mode 100644 index 0e50689d4d..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/demo/src/main.ts +++ /dev/null @@ -1,95 +0,0 @@ -/* -import { NgModule, Component, OnInit } from '@angular/core'; -import { UserInfoComponent } from 'ng2-alfresco-userinfo'; -import { BrowserModule } from '@angular/platform-browser'; -import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; -import { CoreModule, - AlfrescoSettingsService, - AlfrescoAuthenticationService } from 'ng2-alfresco-core'; - -@Component({ - selector: 'my-app', - styles: [`:host h1 { font-size:22px }`], - template: `

TEST

` -}) - - -class UserInfoDemo implements OnInit { - - public userToLogin: string = 'admin'; - public password: string = 'admin'; - public loginErrorMessage: string; - public providers: string = 'BPM'; - private authenticated: boolean; - private token: any; - - constructor(private authService: AlfrescoAuthenticationService, - private settingsService: AlfrescoSettingsService) { - } - - ngOnInit() { - this.settingsService.setProviders(this.providers); - } - - attemptLogin() { - this.loginErrorMessage = ''; - this.login(this.userToLogin, this.password); - } - - logout() { - this.authService.logout(); - } - - login(user, password) { - this.settingsService.setProviders(this.providers); - this.authService.login(user, password).subscribe( - token => { - console.log(token); - this.token = token; - this.authenticated = true; - }, - error => { - console.log(error); - this.authenticated = false; - this.loginErrorMessage = error; - }); - } - - isLoggedIn(): boolean { - return this.authService.isLoggedIn(); - } - - toggleECM(checked) { - if (checked && this.providers === 'BPM') { - this.providers = 'ALL'; - } else if (checked) { - this.providers = 'ECM'; - } else { - this.providers = undefined; - } - } - - toggleBPM(checked) { - if (checked && this.providers === 'ECM') { - this.providers = 'ALL'; - } else if (checked) { - this.providers = 'BPM'; - } else { - this.providers = undefined; - } - } -} - -@NgModule({ - imports: [ - BrowserModule, - CoreModule.forRoot(), - UserInfoComponent - ], - declarations: [ UserInfoComponent ], - bootstrap: [ UserInfoComponent ] -}) -export class AppModule { } - -platformBrowserDynamic().bootstrapModule(AppModule); -*/ diff --git a/ng2-components/ng2-alfresco-userinfo-old/demo/systemjs.config.js b/ng2-components/ng2-alfresco-userinfo-old/demo/systemjs.config.js deleted file mode 100644 index ead7634f8a..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/demo/systemjs.config.js +++ /dev/null @@ -1,56 +0,0 @@ - -'use strict'; -(function(/*global*/) { - - // map tells the System loader where to look for things - var map = { - app: 'dist/', - '@angular': 'node_modules/@angular', - rxjs: 'node_modules/rxjs', - - 'ng2-translate': 'node_modules/ng2-translate', - 'ng2-alfresco-core': 'node_modules/ng2-alfresco-core/dist', - - 'ng2-alfresco-userinfo': 'node_modules/ng2-alfresco-userinfo/dist' - }; - - // packages tells the System loader how to load when no filename and/or no extension - var packages = { - app: { main: 'main.js', defaultExtension: 'js' }, - rxjs: { defaultExtension: 'js' }, - - 'ng2-translate': { defaultExtension: 'js' }, - 'ng2-alfresco-core': { main: 'index.js', defaultExtension: 'js' }, - - 'ng2-alfresco-userinfo': { main: 'index.js', defaultExtension: 'js' } - }; - - var ngPackageNames = [ - 'common', - 'compiler', - 'core', - 'http', - 'platform-browser', - 'platform-browser-dynamic', - 'router', - 'router-deprecated', - 'upgrade' - ]; - // Individual files (~300 requests): - function packIndex(pkgName) { - packages['@angular/' + pkgName] = { main: 'index.js', defaultExtension: 'js' }; - } - // Bundled (~40 requests): - function packUmd(pkgName) { - packages['@angular/' + pkgName] = { main: '/bundles/' + pkgName + '.umd.js', defaultExtension: 'js' }; - } - // Most environments should use UMD; some (Karma) need the individual index files - var setPackageConfig = System.packageWithIndex ? packIndex : packUmd; - // Add package entries for angular packages - ngPackageNames.forEach(setPackageConfig); - var config = { - map: map, - packages: packages - }; - System.config(config); -})(this); diff --git a/ng2-components/ng2-alfresco-userinfo-old/demo/tsconfig.json b/ng2-components/ng2-alfresco-userinfo-old/demo/tsconfig.json deleted file mode 100644 index 2712940af4..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/demo/tsconfig.json +++ /dev/null @@ -1,33 +0,0 @@ -/*{ - "compilerOptions": { - "target": "es5", - "module": "system", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": true, - "removeComments": true, - "declaration": true, - "outDir": "dist" - }, - "exclude": [ - "dist", - "node_modules", - "typings/main", - "typings/main.d.ts" - ] -} */ - -{ - "compilerOptions": { - "target": "es5", - "module": "commonjs", - "moduleResolution": "node", - "sourceMap": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "removeComments": false, - "noImplicitAny": true, - "suppressImplicitAnyIndexErrors": true - } -} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-userinfo-old/demo/tslint.json b/ng2-components/ng2-alfresco-userinfo-old/demo/tslint.json deleted file mode 100644 index 8c48e76469..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/demo/tslint.json +++ /dev/null @@ -1,124 +0,0 @@ -{ - "rules": { - "align": [ - true, - "parameters", - "arguments", - "statements" - ], - "ban": false, - "class-name": true, - "comment-format": [ - true, - "check-space", - "check-lowercase" - ], - "curly": true, - "eofline": true, - "forin": true, - "indent": [ - true, - "spaces" - ], - "interface-name": false, - "jsdoc-format": true, - "label-position": true, - "label-undefined": true, - "max-line-length": [ - true, - 140 - ], - "member-ordering": [ - true, - "public-before-private", - "static-before-instance", - "variables-before-functions" - ], - "no-any": false, - "no-arg": true, - "no-bitwise": true, - "no-conditional-assignment": true, - "no-consecutive-blank-lines": false, - "no-console": [ - true, - "debug", - "info", - "time", - "timeEnd", - "trace" - ], - "no-construct": true, - "no-constructor-vars": false, - "no-debugger": true, - "no-duplicate-key": true, - "no-duplicate-variable": true, - "no-empty": true, - "no-eval": true, - "no-inferrable-types": false, - "no-internal-module": true, - "no-require-imports": true, - "no-shadowed-variable": true, - "no-switch-case-fall-through": true, - "no-trailing-whitespace": true, - "no-unreachable": true, - "no-unused-expression": true, - "no-unused-variable": true, - "no-use-before-declare": true, - "no-var-keyword": true, - "no-var-requires": true, - "object-literal-sort-keys": false, - "one-line": [ - true, - "check-open-brace", - "check-catch", - "check-else", - "check-whitespace" - ], - "quotemark": [ - true, - "single", - "avoid-escape" - ], - "radix": true, - "semicolon": true, - "switch-default": true, - "trailing-comma": [ - true, - { - "multiline": "never", - "singleline": "never" - } - ], - "triple-equals": [ - true, - "allow-null-check" - ], - "typedef": false, - "typedef-whitespace": [ - true, - { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace" - } - ], - "use-strict": false, - "variable-name": [ - true, - "check-format", - "allow-leading-underscore", - "ban-keywords" - ], - "whitespace": [ - true, - "check-branch", - "check-operator", - "check-separator", - "check-type", - "check-module", - "check-decl" - ] - } -} diff --git a/ng2-components/ng2-alfresco-userinfo-old/demo/typings.json b/ng2-components/ng2-alfresco-userinfo-old/demo/typings.json deleted file mode 100644 index 7e0e18568d..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/demo/typings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "globalDependencies": { - "core-js": "registry:dt/core-js#0.0.0+20160317120654", - "jasmine": "registry:dt/jasmine#2.2.0+20160505161446", - "node": "registry:dt/node#4.0.0+20160509154515" - } -} diff --git a/ng2-components/ng2-alfresco-userinfo-old/index.ts b/ng2-components/ng2-alfresco-userinfo-old/index.ts deleted file mode 100644 index 6f5555dbda..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/index.ts +++ /dev/null @@ -1,58 +0,0 @@ -/*! - * @license - * Copyright 2016 Alfresco Software, Ltd. - * - * Licensed 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. - */ - -import { NgModule, ModuleWithProviders } from '@angular/core'; -import { CoreModule } from 'ng2-alfresco-core'; -import { EcmUserService } from './src/services/ecm-user.service'; -import { BpmUserService } from './src/services/bpm-user.service'; -import { UserInfoComponent } from './src/components/user-info.component'; -import { AlfrescoAuthenticationService } from 'ng2-alfresco-core'; - -export * from './src/components/user-info.component'; -export * from './src/services/bpm-user.service'; -export * from './src/services/ecm-user.service'; - -export const USER_INFO_SERVICE: any[] = [ - EcmUserService, - BpmUserService, - AlfrescoAuthenticationService -]; - -@NgModule({ - imports: [ - CoreModule - ], - declarations: [ - UserInfoComponent - ], - providers: [ - ...USER_INFO_SERVICE - ], - exports: [ - UserInfoComponent - ] -}) -export class UserInfoComponentModule { - static forRoot(): ModuleWithProviders { - return { - ngModule: UserInfoComponentModule, - providers: [ - ...USER_INFO_SERVICE - ] - }; - } -} diff --git a/ng2-components/ng2-alfresco-userinfo-old/karma-test-shim.js b/ng2-components/ng2-alfresco-userinfo-old/karma-test-shim.js deleted file mode 100644 index fb1c3905f3..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/karma-test-shim.js +++ /dev/null @@ -1,128 +0,0 @@ -// Tun on full stack traces in errors to help debugging -Error.stackTraceLimit = Infinity; - -jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000; - -__karma__.loaded = function() {}; - -var builtPath = '/base/dist/'; - -function isJsFile(path) { - return path.slice(-3) == '.js'; -} - -function isSpecFile(path) { - return /\.spec\.(.*\.)?js$/.test(path); -} - -function isBuiltFile(path) { - return isJsFile(path) && (path.substr(0, builtPath.length) == builtPath); -} - -var allSpecFiles = Object.keys(window.__karma__.files) - .filter(isSpecFile) - .filter(isBuiltFile); - -var paths = { - // paths serve as alias - 'npm:': 'base/node_modules/' -}; - -var map = { - 'app': 'base/dist', - // angular bundles - '@angular/core': 'npm:@angular/core/bundles/core.umd.js', - '@angular/common': 'npm:@angular/common/bundles/common.umd.js', - '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js', - '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js', - '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js', - '@angular/http': 'npm:@angular/http/bundles/http.umd.js', - '@angular/router': 'npm:@angular/router/bundles/router.umd.js', - '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js', - // testing - '@angular/core/testing': 'npm:@angular/core/bundles/core-testing.umd.js', - '@angular/common/testing': 'npm:@angular/common/bundles/common-testing.umd.js', - '@angular/compiler/testing': 'npm:@angular/compiler/bundles/compiler-testing.umd.js', - '@angular/platform-browser/testing': 'npm:@angular/platform-browser/bundles/platform-browser-testing.umd.js', - '@angular/platform-browser-dynamic/testing': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js', - '@angular/http/testing': 'npm:@angular/http/bundles/http-testing.umd.js', - '@angular/router/testing': 'npm:@angular/router/bundles/router-testing.umd.js', - '@angular/forms/testing': 'npm:@angular/forms/bundles/forms-testing.umd.js', - - // other libraries - 'rxjs': 'npm:rxjs', - 'ng2-translate': 'npm:ng2-translate', - - 'alfresco-js-api': 'npm:alfresco-js-api/dist', - 'ng2-activiti-form': 'npm:ng2-activiti-form/dist', - 'ng2-activiti-processlist': 'npm:ng2-activiti-processlist/dist', - 'ng2-activiti-tasklist': 'npm:ng2-activiti-tasklist/dist', - 'ng2-alfresco-core': 'npm:ng2-alfresco-core/dist', - 'ng2-alfresco-datatable': 'npm:ng2-alfresco-datatable/dist', - 'ng2-alfresco-documentlist': 'npm:ng2-alfresco-documentlist/dist', - 'ng2-alfresco-login': 'npm:ng2-alfresco-login/dist', - 'ng2-alfresco-search': 'npm:ng2-alfresco-search/dist', - 'ng2-alfresco-tag': 'npm:ng2-alfresco-tag/dist', - 'ng2-alfresco-upload': 'npm:ng2-alfresco-upload/dist', - 'ng2-alfresco-viewer': 'npm:ng2-alfresco-viewer/dist', - 'ng2-alfresco-webscript': 'npm:ng2-alfresco-webscript/dist', - 'ng2-alfresco-userinfo': 'npm:ng2-alfresco-userinfo/dist' -}; - -var packages = { - 'app': { main: 'index.js', defaultExtension: 'js', format: 'register' }, - 'rxjs': { defaultExtension: 'js' }, - 'ng2-translate': { defaultExtension: 'js' }, - - 'alfresco-js-api': { main: './alfresco-js-api.js', defaultExtension: 'js'}, - 'ng2-activiti-form': { main: './index.js', defaultExtension: 'js'}, - 'ng2-activiti-processlist': { main: './index.js', defaultExtension: 'js'}, - 'ng2-activiti-tasklist': { main: './index.js', defaultExtension: 'js'}, - 'ng2-alfresco-core': { main: './index.js', defaultExtension: 'js'}, - 'ng2-alfresco-datatable': { main: './index.js', defaultExtension: 'js'}, - 'ng2-alfresco-documentlist': { main: './index.js', defaultExtension: 'js'}, - 'ng2-alfresco-login': { main: './index.js', defaultExtension: 'js'}, - 'ng2-alfresco-search': { main: './index.js', defaultExtension: 'js'}, - 'ng2-alfresco-tag': { main: './index.js', defaultExtension: 'js'}, - 'ng2-alfresco-upload': { main: './index.js', defaultExtension: 'js'}, - 'ng2-alfresco-viewer': { main: './index.js', defaultExtension: 'js'}, - 'ng2-alfresco-webscript': { main: './index.js', defaultExtension: 'js'}, - 'ng2-alfresco-userinfo': { main: './index.js', defaultExtension: 'js'} -}; - -var config = { - paths: paths, - map: map, - packages: packages -}; - -System.config(config); - -System.import('app') - .then(initTestBed) - .then(initTesting); - -function initTestBed(){ - return Promise.all([ - System.import('@angular/core/testing'), - System.import('@angular/platform-browser-dynamic/testing') - ]) - .then(function (providers) { - var coreTesting = providers[0]; - var browserTesting = providers[1]; - - coreTesting.TestBed.initTestEnvironment( - browserTesting.BrowserDynamicTestingModule, - browserTesting.platformBrowserDynamicTesting()); - }) -} - -// Import all spec files and start karma -function initTesting () { - return Promise.all( - allSpecFiles.map(function (moduleName) { - return System.import(moduleName); - }) - ) - .then(__karma__.start, __karma__.error); -} diff --git a/ng2-components/ng2-alfresco-userinfo-old/karma.conf.js b/ng2-components/ng2-alfresco-userinfo-old/karma.conf.js deleted file mode 100644 index c0374b25c3..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/karma.conf.js +++ /dev/null @@ -1,131 +0,0 @@ -'use strict'; - -module.exports = function (config) { - var configuration = { - basePath: '.', - - frameworks: ['jasmine-ajax', 'jasmine'], - - files: [ - // System.js for module loading - 'node_modules/systemjs/dist/system.src.js', - - // Polyfills - 'node_modules/core-js/client/shim.js', - 'node_modules/reflect-metadata/Reflect.js', - - // zone.js - 'node_modules/zone.js/dist/zone.js', - 'node_modules/zone.js/dist/long-stack-trace-zone.js', - 'node_modules/zone.js/dist/proxy.js', - 'node_modules/zone.js/dist/sync-test.js', - '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', - - // 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: - // Angular itself - {pattern: 'node_modules/@angular/**/*.js', included: false, watched: false}, - {pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false}, - - 'node_modules/alfresco-js-api/dist/alfresco-js-api.js', - {pattern: 'node_modules/ng2-translate/**/*.js', included: false, watched: false}, - {pattern: 'node_modules/ng2-translate/**/*.js.map', included: false, watched: false}, - - 'karma-test-shim.js', - - // paths loaded via module imports - {pattern: 'dist/**/*.js', included: false, watched: true}, - {pattern: 'dist/**/*.html', included: true, served: true, watched: true}, - {pattern: 'dist/**/*.css', included: true, served: true, watched: true}, - - // ng2-components - { pattern: 'node_modules/ng2-activiti-form/dist/**/*.js', included: false, served: true, watched: false }, - { pattern: 'node_modules/ng2-activiti-processlist/dist/**/*.js', included: false, served: true, watched: false }, - { pattern: 'node_modules/ng2-activiti-tasklist/dist/**/*.js', included: false, served: true, watched: false }, - { pattern: 'node_modules/ng2-alfresco-core/dist/**/*.js', included: false, served: true, watched: false }, - { pattern: 'node_modules/ng2-alfresco-datatable/dist/**/*.js', included: false, served: true, watched: false }, - { pattern: 'node_modules/ng2-alfresco-documentlist/dist/**/*.js', included: false, served: true, watched: false }, - { pattern: 'node_modules/ng2-alfresco-login/dist/**/*.js', included: false, served: true, watched: false }, - { pattern: 'node_modules/ng2-alfresco-search/dist/**/*.js', included: false, served: true, watched: false }, - { pattern: 'node_modules/ng2-alfresco-tag/dist/**/*.js', included: false, served: true, watched: false }, - { pattern: 'node_modules/ng2-alfresco-upload/dist/**/*.js', included: false, served: true, watched: false }, - { pattern: 'node_modules/ng2-alfresco-viewer/dist/**/*.js', included: false, served: true, watched: false }, - { pattern: 'node_modules/ng2-alfresco-webscript/dist/**/*.js', included: false, served: true, watched: false }, - { pattern: 'node_modules/ng2-alfresco-userinfo/dist/**/*.js', included: false, served: true, watched: false }, - - // paths to support debugging with source maps in dev tools - {pattern: 'src/**/*.ts', included: false, watched: false}, - {pattern: 'dist/**/*.js.map', included: false, watched: false} - ], - - exclude: [ - 'node_modules/**/*spec.js' - ], - - // proxied base paths - proxies: { - // required for component assets fetched by Angular's compiler - '/src/': '/base/src/' - }, - - port: 9876, - - // level of logging - // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG - logLevel: config.LOG_INFO, - - colors: true, - - autoWatch: true, - - browsers: ['Chrome'], - - customLaunchers: { - Chrome_travis_ci: { - base: 'Chrome', - flags: ['--no-sandbox'] - } - }, - - // Karma plugins loaded - plugins: [ - 'karma-jasmine', - 'karma-coverage', - 'karma-jasmine-ajax', - 'karma-chrome-launcher', - 'karma-mocha-reporter', - 'karma-jasmine-html-reporter' - ], - - // Coverage reporter generates the coverage - reporters: ['mocha', 'coverage', 'kjhtml'], - - // Source files that you wanna generate coverage for. - // Do not include tests or libraries (these files will be instrumented by Istanbul) - preprocessors: { - // 'dist/**/!(*spec).js': ['coverage'] - }, - - coverageReporter: { - dir: 'coverage/', - subdir: 'report', - reporters: [ - {type: 'text'}, - {type: 'json', file: 'coverage-final.json'}, - {type: 'html'}, - {type: 'lcov'} - ] - } - }; - - if (process.env.TRAVIS) { - configuration.browsers = ['Chrome_travis_ci']; - } - - config.set(configuration) -}; diff --git a/ng2-components/ng2-alfresco-userinfo-old/package.json b/ng2-components/ng2-alfresco-userinfo-old/package.json deleted file mode 100644 index e7981fb168..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/package.json +++ /dev/null @@ -1,94 +0,0 @@ -{ - "name": "ng2-alfresco-userinfo", - "description": "This component will show the user information for ECM and BPM", - "version": "0.1.0", - "author": "vito albano ", - "scripts": { - "clean": "rimraf dist node_modules", - "build": "npm run tslint && rimraf dist && tsc && npm run copy-dist", - "build:w": "npm run tslint && rimraf dist && npm run watch-task", - "watch-task": "concurrently \"npm run tsc:w\" \"npm run copy-dist:w\" \"license-check\"", - "tslint": "tslint -c tslint.json *.ts && tslint -c tslint.json 'src/{,**/}**.ts'", - "copy-dist": "cpx \"./src/**/*.{html,css,json,png,jpg,gif,svg}\" ./dist/src", - "copy-dist:w": "cpx \"./src/**/*.{html,css,json,png,jpg,gif,svg}\" ./dist/src -w", - "tsc": "tsc", - "tsc:w": "tsc -w", - "pretest": "npm run build", - "test": "karma start karma.conf.js --reporters mocha,coverage --single-run", - "test-browser": "npm run build && concurrently \"karma start karma.conf.js --reporters kjhtml\" \"npm run watch-task\"", - "posttest": "remap-istanbul -i coverage/report/coverage-final.json -o coverage/report -t html && remap-istanbul -i coverage/report/coverage-final.json -o coverage/report/coverage-final.json", - "coverage": "npm run test && wsrv -o -p 9875 ./coverage/report", - "travis": "npm link ng2-alfresco-core" - }, - "main": "./dist/index.js", - "typings": "./dist/index.d.ts", - "repository": { - "type": "git", - "url": "https://github.com/Alfresco/alfresco-ng2-components.git" - }, - "bugs": { - "url": "https://github.com/Alfresco/alfresco-ng2-components/issues" - }, - "license": "Apache-2.0", - "contributors": [ - { - "name": "Vito Albano", - "email": "vito.albano@alfresco.com" - } - ], - "keywords": [ - "ng2", - "angular", - "angular2", - "alfresco" - ], - "dependencies": { - "@angular/common": "2.0.0", - "@angular/compiler": "2.0.0", - "@angular/core": "2.0.0", - "@angular/forms": "2.0.0", - "@angular/http": "2.0.0", - "@angular/platform-browser": "2.0.0", - "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", - "@angular/upgrade": "2.0.0", - "core-js": "^2.4.1", - "reflect-metadata": "^0.1.3", - "rxjs": "5.0.0-beta.12", - "systemjs": "0.19.27", - "zone.js": "^0.6.23", - "ng2-translate": "2.5.0", - "ng2-alfresco-core": "0.3.2" - }, - "devDependencies": { - "@types/core-js": "^0.9.32", - "@types/jasmine": "^2.2.33", - "concurrently": "^2.2.0", - "cpx": "1.3.1", - "jasmine-ajax": "3.2.0", - "jasmine-core": "2.4.1", - "karma": "0.13.22", - "karma-chrome-launcher": "1.0.1", - "karma-coverage": "1.0.0", - "karma-jasmine": "1.0.2", - "karma-jasmine-ajax": "^0.1.13", - "karma-jasmine-html-reporter": "0.2.0", - "karma-mocha-reporter": "2.0.3", - "license-check": "1.1.5", - "remap-istanbul": "0.6.3", - "rimraf": "2.5.2", - "traceur": "0.0.91", - "tslint": "3.8.1", - "typescript": "^2.0.2", - "wsrv": "^0.1.5" - }, - "license-check-config": { - "src": [ - "./dist/**/*.js" - ], - "path": "assets/license_header.txt", - "blocking": true, - "logInfo": false, - "logError": true - } -} diff --git a/ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.css b/ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.css deleted file mode 100644 index 93254d00fa..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.css +++ /dev/null @@ -1,53 +0,0 @@ -.profile-image { - text-align: center; - border-radius: 90%; - width: 40px; - margin-right: 0%; - cursor: pointer; - border: 1px solid #999999; - vertical-align: middle; -} - -.button-profile { - display: inline-block; - border: 0px; - vertical-align: middle; -} - -.detail-user-profile-list-mdl{ - margin-right: 10px; -} - -.user-profile-list-mdl{ - max-height: 450px; - min-width: 450px; - overflow: auto; -} - -.header-profile{ - color: rgb(255,152,0); - margin-left: 10px; -} - -hr.title-start { - border: 0; - height: 1px; - background: #333; - background-image: linear-gradient(to right, #ccc, #333, #ccc); -} - -span.role-label-user{ - font-weight: 400; - line-height: 1; - letter-spacing: 0; - color: rgba(0,0,0,.87); -} - -.custom-role-style{ - font-size: 14px; - color: #9e9e9e; -} - -.truncate-long-names{ - text-overflow: ellipsis; -} diff --git a/ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.html b/ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.html deleted file mode 100644 index 8c01dc7120..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.html +++ /dev/null @@ -1,63 +0,0 @@ -
- {{ecmUser.firstName || ecmUser.lastName}} - - {{ formatValue(bpmUser.firstName) || - formatValue(bpmUser.lastName) || - formatValue(bpmUser.fullName) }} - -
- -
- -
- - diff --git a/ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.spec.ts b/ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.spec.ts deleted file mode 100644 index a91e2f2ac8..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -/*! - * @license - * Copyright 2016 Alfresco Software, Ltd. - * - * Licensed 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. - */ -// import { UserInfoComponent } from '../src/userinfo.component'; - -describe('Basic Example test ng2-alfresco-userinfo', () => { - - it('Test hello world', () => { - expect(true).toBe(true); - }); - -}); diff --git a/ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.ts b/ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.ts deleted file mode 100644 index 5154ab5dcf..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/src/components/user-info.component.ts +++ /dev/null @@ -1,93 +0,0 @@ -/*! - * @license - * Copyright 2016 Alfresco Software, Ltd. - * - * Licensed 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. - */ - -import { Component, OnInit } from '@angular/core'; -import { EcmUserModel } from './../models/ecm-user.model'; -import { BpmUserModel } from './../models/bpm-user.model'; -import { EcmUserService } from './../services/ecm-user.service'; -import { BpmUserService } from './../services/bpm-user.service'; -import { AlfrescoAuthenticationService } from 'ng2-alfresco-core'; - -declare let __moduleName: string; - -@Component({ - selector: 'ng2-alfresco-userinfo', - moduleId: __moduleName, - styleUrls: ['./userinfo.component.css'], - template: `

HELLO

` -}) - -export class UserInfoComponent implements OnInit { - - private ecmUser: EcmUserModel; - private bpmUser: BpmUserModel; - private baseComponentPath = __moduleName.replace('userinfo.component.js', ''); - private anonymouseImageUrl: string = this.baseComponentPath + 'img/anonymous.gif'; - public bpmUserImage: any; - public ecmUserImage: any; - - constructor(private ecmUserService: EcmUserService, - private bpmUserService: BpmUserService, - public authService: AlfrescoAuthenticationService) { - } - - ngOnInit() { - if (this.authService.getAlfrescoApi().ecmAuth.isLoggedIn()) { - this.ecmUserService.getUserInfo('-me-') - .subscribe( - (res) => { - this.ecmUser = res; - this.getEcmUserProfileImage(); - } - ); - } - if (this.authService.getAlfrescoApi().bpmAuth.isLoggedIn()) { - this.bpmUserService.getCurrentUserInfo() - .subscribe( - (res) => { - this.bpmUser = res; - this.getBpmUserProfileImage(); - } - ); - } - } - - private getBpmUserProfileImage() { - this.bpmUserImage = this.bpmUserService.getCurrentUserProfileImage(); - } - - private getEcmUserProfileImage() { - this.ecmUserImage = this.ecmUserService.getCurrentUserProfileImageUrl(this.ecmUser.avatarId); - } - - public getUserAvatar() { - return this.ecmUserImage || this.bpmUserImage || this.anonymouseImageUrl; - } - - public getBpmUserDetailAvatarUrl() { - return this.bpmUserImage || this.anonymouseImageUrl; - } - - public getEcmUserDetailAvatarUrl() { - return this.ecmUserImage || this.anonymouseImageUrl; - } - - public formatValue(value: string) { - return value === 'null' ? null : value; - } - -} diff --git a/ng2-components/ng2-alfresco-userinfo-old/src/i18n/en.json b/ng2-components/ng2-alfresco-userinfo-old/src/i18n/en.json deleted file mode 100644 index 9400e18911..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/src/i18n/en.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "FILE_UPLOAD": { - "BUTTON": { - "UPLOAD_FILE": "Upload file", - "UPLOAD_FOLDER": "Upload folder", - "CANCEL": "CANCEL" - }, - "MESSAGES": { - "COMPLETED": "uploads complete", - "PROGRESS": "Upload in progress...", - "FOLDER_ALREADY_EXIST": "The folder {0} already exist", - "FOLDER_NOT_SUPPORTED": "Folder upload isn't supported by your browser" - }, - "FILE_INFO": { - "NAME": "File name", - "PROGRESS": "File progress", - "SIZE": "File size", - "ACTION": "Actions" - }, - "ACTION": { - "UNDO": "Undo" - } - } -} diff --git a/ng2-components/ng2-alfresco-userinfo-old/src/i18n/it.json b/ng2-components/ng2-alfresco-userinfo-old/src/i18n/it.json deleted file mode 100644 index 0208da3079..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/src/i18n/it.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "FILE_UPLOAD": { - "BUTTON": { - "UPLOAD_FILE": "Carica un file", - "UPLOAD_FOLDER": "Carica una cartella", - "CANCEL": "CANCELLA" - }, - "MESSAGES": { - "COMPLETED": "caricamenti completati", - "PROGRESS": "caricamento in corso...", - "FOLDER_ALREADY_EXIST": "Cartella {0} già presente", - "FOLDER_NOT_SUPPORTED": "L' upload di cartelle non é supportato dal tuo browser" - }, - "FILE_INFO": { - "NAME": "Nome file", - "PROGRESS": "Percentuale caricamento", - "SIZE": "Dimensione file", - "ACTION": "Azioni" - }, - "ACTION": { - "UNDO": "Annulla" - } - } -} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-userinfo-old/src/img/anonymous.gif b/ng2-components/ng2-alfresco-userinfo-old/src/img/anonymous.gif deleted file mode 100644 index e1b58fa57dfcdfd452ec498c98b930aa905d21d6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1765 zcmb8pizCyC0|4;vcMq|L=guW!Vi%c59pzQG$YVmt(9<&qUk|0_<~^#dpPrfJR`3LkEhFNwuD*UseB%E9NpnxZIwFun4Gh4>giwRA zc0?x^01y1ne**w~537AIAf!0BrjESujDjDc-khY>t=wMO?<%F(;}2yFR74Dt%}a)P zREJt`!8kwqm|RZoeK}|r3IHK##rgzkWXR z#*`{VI@~f{tInV0ukwK$G*WXf9#@J?Z!6r2$!xjap@7u(QUCMI;#?2#}9bcnDw%MSwt8tuX$>-NEJGdr(T*AtL&uqN~#WT z-g_QP^LsP+c=+}i&ztKwm?_}Wl%Vf);6;vy(fFPKq-Krf{zpQvQICg(?Ug@>Nx&U+ zjC*f3!1kFY4zS~t!;(qN5%NIU3H4v3)8o8SJ&}xYli-Iq9S6HVS;BT^QM6I<7xiew zs43F&{rZ7&()90DAGOE2XC;|(F#99fIapv)+E_ML>o!h2H=U!U*6L3=``J^Qqoo7W zf@~)ZW~T7YOjSR6)Sl9&+Nd*+aNRrksZvj^#`9rO9o8rC1d|21)u|F3inL-f#Wi}R<~|kmHN&5; z3B)yYe%YIv8;IuZpFayGV;%0-^uB2NgFe{gg7ft_xj^TT_Y{uR${^)A3ysIpSs39& z9ijG;m}vnKkiUg2%P?vsYQCJO@$_OV@CO0Hu)t)o;|R^??X%tO1-F=8j*)@eCsBO8 zi%eVFsxw-!Lvd0lwD|S>cPa5}M3u<4Tb}T$Ox;$^a_lM*m{i5Pu{oB{h2Ay`Po(Dx zD#N-MNvdBGX_`Lud8}5idh^1LixlXK&^sCJ@PI-IJn*VhrM|k_W5)x{ zzhbeqUP%h#MU{Oa-7EuT&#~1EiAPO=nPq4Rbk@D@* z6M~fh0C=qA2Fx`k=Mt6^izaq#br)QLk3CvAW9%+&^6yXaFr(JLRl%+P{?WF8(;BaX zE{t!)7R`6~pLq*@-8wtlZL#g$h)*e9)U%B{XxYCXGPN_V;k|Z!l;3$33aB3vZ~j!f z8jhOM^$Qdom4h>-B7!MgsLVCNNk__$82?`QspL*0zwl&CWb!J(Q;GX2gTXNKJLh7b zN8^5=;xVjOqw+n`ziQf<^ritlK&M(Z8LjoT%+`GX4nZhrFaHSbxJOg`KARNhh?nMx zGP`u#0?`@`N33T&?%+eSu$L?L=-+paXBat?0s^Lq(6>66KiD9fJaJdGPrldmp)ES9 zq5Q@w&+dWzairp+mQ9lhlYn@l$-pFQ%6Vm;W0F$S`6)^oDnz!UA}W)wZD#Nf-02yE zSxiRiSbJrnHZpS2^QFqWDWYiJ2_&D4GxJTob6game4Rnp4-a8oK0|uY-oP;ACYJg= zfzq$)JUSkdEEQ-FsXFl0O1;D@^(Svq!Dtb~|zD{Xe%&8EA}t;;Z>bJpL9WgQD_~sHG5(h>mr{Irog}T$u=eqGe-Q&yn=bw z7r-~(&JD^vmmxkz!hBa8Ik(`jlhvudkmrW!#)Y{1Gd3YvBL>qqDmh!%F}{e44g(m3 zaqT=bY?~3aCoJ(;oj;Ql3NL$?!}~e$!?~b?QkCYp)qa#vtFm`QZozZZrH&eTD*&+g E7ZAQxl>h($ diff --git a/ng2-components/ng2-alfresco-userinfo-old/src/models/bpm-user.model.ts b/ng2-components/ng2-alfresco-userinfo-old/src/models/bpm-user.model.ts deleted file mode 100644 index 3ee3fd7222..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/src/models/bpm-user.model.ts +++ /dev/null @@ -1,39 +0,0 @@ -/*! - * @license - * Copyright 2016 Alfresco Software, Ltd. - * - * Licensed 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. - */ - -export class BpmUserModel { - apps: any; - capabilities: string; - company: string; - created: string; - email: string; - externalId: string; - firstName: string; - lastName: string; - fullname: string; - groups: any; - id: string; - lastUpdate: string; - latestSyncTimeStamp: string; - password: string; - pictureId: string; - status: string; - tenantId: string; - tenantName: string; - tenantPictureId: string; - type: string; -} diff --git a/ng2-components/ng2-alfresco-userinfo-old/src/models/ecm-company.model.ts b/ng2-components/ng2-alfresco-userinfo-old/src/models/ecm-company.model.ts deleted file mode 100644 index 458b6b8ed5..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/src/models/ecm-company.model.ts +++ /dev/null @@ -1,27 +0,0 @@ -/*! - * @license - * Copyright 2016 Alfresco Software, Ltd. - * - * Licensed 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. - */ - -export class EcmCompanyModel { - organization: string; - address1: string; - address2: string; - address3: string; - postcode: string; - telephone: string; - fax: string; - email: string; -} diff --git a/ng2-components/ng2-alfresco-userinfo-old/src/models/ecm-user.model.ts b/ng2-components/ng2-alfresco-userinfo-old/src/models/ecm-user.model.ts deleted file mode 100644 index 08f24fbcdb..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/src/models/ecm-user.model.ts +++ /dev/null @@ -1,39 +0,0 @@ -/*! - * @license - * Copyright 2016 Alfresco Software, Ltd. - * - * Licensed 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. - */ - -import { EcmCompanyModel } from './ecm-company.model'; - -export class EcmUserModel { - id: string; - firstName: string; - lastName: string; - description: string; - avatarId: string; - email: string; - skypeId: string; - googleId: string; - instantMessageId: string; - jobTitle: string; - location: string; - company: EcmCompanyModel; - mobile: string; - telephone: string; - statusUpdatedAt: string; - userStatus: string; - enabled: boolean; - emailNotificationsEnabled: boolean; -} diff --git a/ng2-components/ng2-alfresco-userinfo-old/src/services/bpm-user.service.ts b/ng2-components/ng2-alfresco-userinfo-old/src/services/bpm-user.service.ts deleted file mode 100644 index 089320a264..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/src/services/bpm-user.service.ts +++ /dev/null @@ -1,75 +0,0 @@ -/*! - * @license - * Copyright 2016 Alfresco Software, Ltd. - * - * Licensed 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. - */ - -import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core'; -import { Injectable } from '@angular/core'; -import { Response } from '@angular/http'; -import { Observable } from 'rxjs/Rx'; -import { BpmUserModel } from '../models/bpm-user.model'; -/** - * - * BPMUserService retrieve all the information of an Ecm user. - * - * @returns {BPMUserService} . - */ -@Injectable() -export class BpmUserService { - - constructor(private authService: AlfrescoAuthenticationService, - private settingService: AlfrescoSettingsService) { - } - - /** - * get User Information via ECM - * @param userName - the user name - */ - getCurrentUserInfo(): Observable { - if ( this.authService.getAlfrescoApi().bpmAuth.isLoggedIn() ) { - return Observable.fromPromise(this.callApiGetProfile()) - .map( - (data) => data - ) - .catch(this.handleError); - } - } - - /** - * get User Information via ECM - * @param userName - the user name - */ - getCurrentUserProfileImage(): string { - if ( this.authService.getAlfrescoApi().bpmAuth.isLoggedIn() ) { - return this.settingService.getBPMApiBaseUrl() + '/api/enterprise/profile-picture'; - } - } - - private callApiGetProfile() { - return this.authService.getAlfrescoApi().activiti.profileApi.getProfile(); - } - /** - * Throw the error - * @param error - * @returns {ErrorObservable} - */ - private handleError(error: Response) { - // in a real world app, we may send the error to some remote logging infrastructure - // instead of just logging it to the console - console.error(error); - return Observable.throw(error || 'Server error'); - } - -} diff --git a/ng2-components/ng2-alfresco-userinfo-old/src/services/ecm-user.service.ts b/ng2-components/ng2-alfresco-userinfo-old/src/services/ecm-user.service.ts deleted file mode 100644 index 6875ee7d48..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/src/services/ecm-user.service.ts +++ /dev/null @@ -1,72 +0,0 @@ -/*! - * @license - * Copyright 2016 Alfresco Software, Ltd. - * - * Licensed 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. - */ - -import { AlfrescoAuthenticationService, AlfrescoContentService } from 'ng2-alfresco-core'; -import { Injectable } from '@angular/core'; -import { Response } from '@angular/http'; -import { Observable } from 'rxjs/Rx'; -import { EcmUserModel } from '../models/ecm-user.model'; -/** - * - * ECMUserService retrieve all the information of an Ecm user. - * - * @returns {ECMUserService} . - */ -@Injectable() -export class EcmUserService { - - constructor(private authService: AlfrescoAuthenticationService, - private contentService: AlfrescoContentService) {} - - /** - * get User Information via ECM - * @param userName - the user name - */ - getUserInfo(userName: string): Observable { - if ( this.authService.getAlfrescoApi().ecmAuth.isLoggedIn() ) { - return Observable.fromPromise(this.callApiGetPersonInfo(userName)) - .map( - (data) => data['entry'] - ) - .catch(this.handleError); - } - } - - private callApiGetPersonInfo(userName: string, opts?: any) { - return this.authService.getAlfrescoApi().core.peopleApi.getPerson(userName, opts); - } - - getCurrentUserProfileImageUrl(avatarId: string) { - if ( avatarId ) { - let nodeObj = {entry: {id: avatarId}}; - return this.contentService.getContentUrl(nodeObj); - } - } - - /** - * Throw the error - * @param error - * @returns {ErrorObservable} - */ - private handleError(error: Response) { - // in a real world app, we may send the error to some remote logging infrastructure - // instead of just logging it to the console - console.error(error); - return Observable.throw(error || 'Server error'); - } - -} diff --git a/ng2-components/ng2-alfresco-userinfo-old/tsconfig.json b/ng2-components/ng2-alfresco-userinfo-old/tsconfig.json deleted file mode 100644 index b1effea355..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/tsconfig.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "module": "system", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": true, - "removeComments": true, - "declaration": true, - "noLib": false, - "allowUnreachableCode": false, - "allowUnusedLabels": false, - "noImplicitAny": false, - "noImplicitReturns": false, - "noImplicitUseStrict": false, - "noFallthroughCasesInSwitch": true, - "outDir": "dist", - "types": ["core-js", "jasmine"] - }, - "exclude": [ - "demo", - "node_modules", - "dist" - ] -} diff --git a/ng2-components/ng2-alfresco-userinfo-old/tslint.json b/ng2-components/ng2-alfresco-userinfo-old/tslint.json deleted file mode 100644 index 33220e5038..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/tslint.json +++ /dev/null @@ -1,121 +0,0 @@ -{ - "rules": { - "align": [ - true, - "parameters", - "statements" - ], - "ban": false, - "class-name": true, - "comment-format": [ - true, - "check-space" - ], - "curly": true, - "eofline": true, - "forin": true, - "indent": [ - true, - "spaces" - ], - "interface-name": false, - "jsdoc-format": true, - "label-position": true, - "label-undefined": true, - "max-line-length": [ - true, - 140 - ], - "member-ordering": [ - true, - "static-before-instance", - "variables-before-functions" - ], - "no-any": false, - "no-arg": true, - "no-bitwise": false, - "no-conditional-assignment": true, - "no-consecutive-blank-lines": false, - "no-console": [ - true, - "debug", - "info", - "time", - "timeEnd", - "trace" - ], - "no-construct": true, - "no-constructor-vars": false, - "no-debugger": true, - "no-duplicate-key": true, - "no-duplicate-variable": true, - "no-empty": false, - "no-eval": true, - "no-inferrable-types": false, - "no-internal-module": true, - "no-require-imports": true, - "no-shadowed-variable": true, - "no-switch-case-fall-through": true, - "no-trailing-whitespace": true, - "no-unreachable": true, - "no-unused-expression": true, - "no-unused-variable": true, - "no-use-before-declare": true, - "no-var-keyword": true, - "no-var-requires": true, - "object-literal-sort-keys": false, - "one-line": [ - true, - "check-open-brace", - "check-catch", - "check-else", - "check-whitespace" - ], - "quotemark": [ - true, - "single", - "avoid-escape" - ], - "radix": true, - "semicolon": true, - "switch-default": true, - "trailing-comma": [ - true, - { - "multiline": "never", - "singleline": "never" - } - ], - "triple-equals": [ - true, - "allow-null-check" - ], - "typedef": false, - "typedef-whitespace": [ - true, - { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace" - } - ], - "use-strict": false, - "variable-name": [ - true, - "check-format", - "allow-leading-underscore", - "ban-keywords" - ], - "whitespace": [ - true, - "check-branch", - "check-operator", - "check-separator", - "check-type", - "check-module", - "check-decl" - ] - } -} diff --git a/ng2-components/ng2-alfresco-userinfo-old/typings.json b/ng2-components/ng2-alfresco-userinfo-old/typings.json deleted file mode 100644 index 7e0e18568d..0000000000 --- a/ng2-components/ng2-alfresco-userinfo-old/typings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "globalDependencies": { - "core-js": "registry:dt/core-js#0.0.0+20160317120654", - "jasmine": "registry:dt/jasmine#2.2.0+20160505161446", - "node": "registry:dt/node#4.0.0+20160509154515" - } -} From 64331a3350c03a69ba1cfd131fead2180d13aedd Mon Sep 17 00:00:00 2001 From: Vito Albano Date: Mon, 3 Oct 2016 10:21:36 +0100 Subject: [PATCH 18/26] Fix name in package.json --- ng2-components/ng2-alfresco-userinfo/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ng2-components/ng2-alfresco-userinfo/package.json b/ng2-components/ng2-alfresco-userinfo/package.json index 49787abe9d..178fcc0e01 100644 --- a/ng2-components/ng2-alfresco-userinfo/package.json +++ b/ng2-components/ng2-alfresco-userinfo/package.json @@ -1,6 +1,6 @@ { - "name": "ng2-alfresco-tag", - "description": "Alfresco tag component", + "name": "ng2-alfresco-userinfo", + "description": "Alfresco User Info component", "version": "0.3.2", "author": "Alfresco Software, Ltd.", "main": "./dist/index.js", From 27003dd4c4447462aa77a170ee6ddc6688adc9c0 Mon Sep 17 00:00:00 2001 From: Vito Albano Date: Mon, 3 Oct 2016 10:58:20 +0100 Subject: [PATCH 19/26] Fixed naming for tests --- .../components/user-info.component.spec.ts | 54 +++++++++---------- .../src/services/bpm-user.service.spec.ts | 4 +- .../src/services/ecm-user.service.spec.ts | 6 +-- .../src/testing/fake-bpm-user.service.ts | 9 ++++ .../src/testing/fake-ecm-user.service.ts | 8 +++ 5 files changed, 49 insertions(+), 32 deletions(-) diff --git a/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.spec.ts b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.spec.ts index b78cc8cb41..abf318c877 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.spec.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.spec.ts @@ -65,7 +65,7 @@ describe('User info component', () => { expect(userInfoComp.ecmUserImage).toBeUndefined(); expect(userInfoComp.bpmUser).toBeUndefined(); expect(userInfoComp.bpmUserImage).toBeUndefined(); - expect(userInfoComp.anonymouseImageUrl).not.toBeUndefined(); + expect(userInfoComp.anonymouseImageUrl).toBeDefined(); }); it('should NOT have users immediately after ngOnInit', () => { @@ -74,7 +74,7 @@ describe('User info component', () => { expect(userInfoComp.ecmUserImage).toBeUndefined(); expect(userInfoComp.bpmUser).toBeUndefined(); expect(userInfoComp.bpmUserImage).toBeUndefined(); - expect(userInfoComp.anonymouseImageUrl).not.toBeUndefined(); + expect(userInfoComp.anonymouseImageUrl).toBeDefined(); }); describe('when user is logged on ecm', () => { @@ -92,19 +92,19 @@ describe('User info component', () => { })); it('should get the ecm current user image from the service', () => { - expect(userInfoComp.ecmUser).not.toBeUndefined(); - expect(userInfoComp.ecmUserImage).not.toBeUndefined(); + expect(userInfoComp.ecmUser).toBeDefined(); + expect(userInfoComp.ecmUserImage).toBeDefined(); expect(userInfoComp.ecmUserImage).toEqual('fake/url/image/for/ecm/user'); }); it('should get the ecm user informations from the service', () => { - expect(userInfoComp.ecmUser).not.toBeUndefined(); + expect(userInfoComp.ecmUser).toBeDefined(); expect(userInfoComp.ecmUser.firstName).toEqual('fake-first-name'); expect(userInfoComp.ecmUser.lastName).toEqual('fake-last-name'); }); it('should return the anonynous user avatar image url when user does not have avatarId', async(() => { - fakeEcmService.userNeeded = 1; + fakeEcmService.respondWithTheUserWithoutImage(); userInfoComp.ngOnInit(); fixture.whenStable() .then( () => { @@ -131,19 +131,19 @@ describe('User info component', () => { })); it('should get the bpm current user image from the service', () => { - expect(userInfoComp.bpmUser).not.toBeUndefined(); - expect(userInfoComp.bpmUserImage).not.toBeUndefined(); + expect(userInfoComp.bpmUser).toBeDefined(); + expect(userInfoComp.bpmUserImage).toBeDefined(); expect(userInfoComp.bpmUserImage).toEqual('fake-picture-id'); }); it('should get the bpm user informations from the service', () => { - expect(userInfoComp.bpmUser).not.toBeUndefined(); + expect(userInfoComp.bpmUser).toBeDefined(); expect(userInfoComp.bpmUser.firstName).toEqual('fake-first-name'); expect(userInfoComp.bpmUser.lastName).toEqual('fake-last-name'); }); it('should return the anonynous user avatar image url when user does not have avatarId', async(() => { - fakeBpmService.userNeeded = 1; + fakeBpmService.respondWithTheUserWithoutImage(); userInfoComp.ngOnInit(); fixture.whenStable() .then( () => { @@ -172,26 +172,26 @@ describe('User info component', () => { })); it('should get the bpm current user image from the service', () => { - expect(userInfoComp.bpmUser).not.toBeUndefined(); - expect(userInfoComp.bpmUserImage).not.toBeUndefined(); + expect(userInfoComp.bpmUser).toBeDefined(); + expect(userInfoComp.bpmUserImage).toBeDefined(); expect(userInfoComp.bpmUserImage).toEqual('fake-picture-id'); - expect(userInfoComp.ecmUser).not.toBeUndefined(); - expect(userInfoComp.ecmUserImage).not.toBeUndefined(); + expect(userInfoComp.ecmUser).toBeDefined(); + expect(userInfoComp.ecmUserImage).toBeDefined(); expect(userInfoComp.ecmUserImage).toEqual('fake/url/image/for/ecm/user'); }); it('should get the bpm user informations from the service', () => { - expect(userInfoComp.bpmUser).not.toBeUndefined(); + expect(userInfoComp.bpmUser).toBeDefined(); expect(userInfoComp.bpmUser.firstName).toEqual('fake-first-name'); expect(userInfoComp.bpmUser.lastName).toEqual('fake-last-name'); - expect(userInfoComp.ecmUser).not.toBeUndefined(); + expect(userInfoComp.ecmUser).toBeDefined(); expect(userInfoComp.ecmUser.firstName).toEqual('fake-first-name'); expect(userInfoComp.ecmUser.lastName).toEqual('fake-last-name'); }); it('should return the anonynous user avatar image url when user does not have avatarId', async(() => { - fakeBpmService.userNeeded = 1; - fakeEcmService.userNeeded = 1; + fakeBpmService.respondWithTheUserWithoutImage(); + fakeEcmService.respondWithTheUserWithoutImage(); userInfoComp.ngOnInit(); fixture.whenStable() .then( () => { @@ -206,36 +206,36 @@ describe('User info component', () => { })); it('should return the ecm image if exists', async(() => { - fakeBpmService.userNeeded = 0; - fakeEcmService.userNeeded = 0; + fakeBpmService.respondWithTheUserWithImage(); + fakeEcmService.respondWithTheUserWithImage(); userInfoComp.ngOnInit(); fixture.whenStable() .then( () => { fixture.detectChanges(); let res = userInfoComp.getUserAvatar(); - expect(userInfoComp.bpmUserImage).not.toBeUndefined(); - expect(userInfoComp.ecmUserImage).not.toBeUndefined(); + expect(userInfoComp.bpmUserImage).toBeDefined(); + expect(userInfoComp.ecmUserImage).toBeDefined(); expect(res).toEqual(userInfoComp.ecmUserImage); }); })); it('should return the bpm image if ecm does not have it', async(() => { - fakeBpmService.userNeeded = 0; - fakeEcmService.userNeeded = 1; + fakeBpmService.respondWithTheUserWithImage(); + fakeEcmService.respondWithTheUserWithoutImage(); userInfoComp.ngOnInit(); fixture.whenStable() .then( () => { fixture.detectChanges(); let res = userInfoComp.getUserAvatar(); - expect(userInfoComp.bpmUserImage).not.toBeUndefined(); + expect(userInfoComp.bpmUserImage).toBeDefined(); expect(userInfoComp.ecmUserImage).toBeUndefined(); expect(res).toEqual(userInfoComp.bpmUserImage); }); })); it('should return the anonynous avatar if no user has it', async(() => { - fakeBpmService.userNeeded = 1; - fakeEcmService.userNeeded = 1; + fakeBpmService.respondWithTheUserWithoutImage(); + fakeEcmService.respondWithTheUserWithoutImage(); userInfoComp.ngOnInit(); fixture.whenStable() .then( () => { diff --git a/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.spec.ts b/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.spec.ts index b9655e6951..8899f70daf 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.spec.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.spec.ts @@ -93,7 +93,7 @@ describe('Bpm User service', () => { spyOn(service, 'callApiGetProfile').and.returnValue(Promise.resolve(fakeBpmUser)); service.getCurrentUserInfo().subscribe( (user) => { - expect(user).not.toBeUndefined(); + expect(user).toBeDefined(); expect(user.firstName).toEqual('fake-first-name'); expect(user.lastName).toEqual('fake-last-name'); expect(user.email).toEqual('fakeBpm@fake.com'); @@ -111,7 +111,7 @@ describe('Bpm User service', () => { spyOn(service, 'callApiGetProfilePicture').and.returnValue(Promise.resolve('fake/img/path')); service.getCurrentUserProfileImage().subscribe( (path) => { - expect(path).not.toBeUndefined(); + expect(path).toBeDefined(); expect(path).toEqual('fake/img/path'); done(); }); diff --git a/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.spec.ts b/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.spec.ts index 0677818dfa..4d88d66fe9 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.spec.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.spec.ts @@ -28,7 +28,7 @@ export var fakeEcmCompany: EcmCompanyModel = { address3: 'fake-address-3', postcode: 'fAk1', telephone: '00000000', - fax: '11111111', + fax: '=1111111', email: 'fakeCompany@fake.com' }; @@ -118,7 +118,7 @@ describe('Ecm User service', () => { spyOn(service, 'callApiGetPersonInfo').and.returnValue(Promise.resolve(userJsApiResponse)); service.getCurrentUserInfo().subscribe( (user) => { - expect(user).not.toBeUndefined(); + expect(user).toBeDefined(); expect(user.firstName).toEqual('fake-first-name'); expect(user.lastName).toEqual('fake-last-name'); expect(user.email).toEqual('fakeEcm@ecmUser.com'); @@ -150,7 +150,7 @@ describe('Ecm User service', () => { it('should build the body for the content service', () => { spyOn(contentServiceForTest, 'getContentUrl').and.callThrough(); let urlRs = service.getCurrentUserProfileImageUrl('fake-avatar-id'); - expect(urlRs).not.toBeUndefined(); + expect(urlRs).toBeDefined(); expect(contentServiceForTest.getContentUrl).toHaveBeenCalledWith( {entry: {id: 'fake-avatar-id'} }); }); }); diff --git a/ng2-components/ng2-alfresco-userinfo/src/testing/fake-bpm-user.service.ts b/ng2-components/ng2-alfresco-userinfo/src/testing/fake-bpm-user.service.ts index 51a6602cc6..b7a2f87d91 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/testing/fake-bpm-user.service.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/testing/fake-bpm-user.service.ts @@ -86,4 +86,13 @@ export class FakeBpmUserService { return this.usersList[this.userNeeded].pictureId; }; + respondWithTheUserWithoutImage() { + this.userNeeded = 1; + } + + respondWithTheUserWithImage() { + this.userNeeded = 0; + } + + } diff --git a/ng2-components/ng2-alfresco-userinfo/src/testing/fake-ecm-user.service.ts b/ng2-components/ng2-alfresco-userinfo/src/testing/fake-ecm-user.service.ts index 0ee8694ede..2133e780b1 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/testing/fake-ecm-user.service.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/testing/fake-ecm-user.service.ts @@ -96,4 +96,12 @@ export class FakeEcmUserService { } }; + respondWithTheUserWithoutImage() { + this.userNeeded = 1; + }; + + respondWithTheUserWithImage() { + this.userNeeded = 0; + }; + } From ab1f65d44bd1ce75cc43b2e69acefca6b9f07d82 Mon Sep 17 00:00:00 2001 From: Vito Albano Date: Mon, 3 Oct 2016 13:07:53 +0100 Subject: [PATCH 20/26] Fixed double name when the two user log in --- .../src/components/user-info.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.html b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.html index 8c01dc7120..41c334ce54 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.html +++ b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.html @@ -1,6 +1,6 @@
{{ecmUser.firstName || ecmUser.lastName}} - + {{ formatValue(bpmUser.firstName) || formatValue(bpmUser.lastName) || formatValue(bpmUser.fullName) }} From 2219047c1a4b60fd5d06cb431ff2946e28f6f50a Mon Sep 17 00:00:00 2001 From: Vito Albano Date: Mon, 3 Oct 2016 13:41:34 +0100 Subject: [PATCH 21/26] Fixed wrong method and style a little --- .../src/components/user-info.component.html | 8 ++++---- .../src/services/bpm-user.service.ts | 7 ++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.html b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.html index 41c334ce54..5a8b50db9c 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.html +++ b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.html @@ -16,8 +16,8 @@ for="user-profile">