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/.travis.yml b/.travis.yml index 01b318ed4f..3a5d6d84f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,7 @@ env: - MODULE=ng2-activiti-tasklist - MODULE=ng2-activiti-processlist - MODULE=ng2-activiti-analytics + - MODULE=ng2-alfresco-userinfo before_script: - if ([ "$MODULE" != "ng2-alfresco-core" ]); then @@ -83,3 +84,4 @@ cache: - ng2-components/ng2-alfresco-webscript/node_modules - ng2-components/ng2-alfresco-tag/node_modules - ng2-components/ng2-alfresco-analytics/node_modules + - ng2-components/ng2-alfresco-userinfo/node_modules 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 e4b21d6861..463e250c35 100644 --- a/demo-shell-ng2/app/app.component.html +++ b/demo-shell-ng2/app/app.component.html @@ -21,6 +21,10 @@ Login +
+ +
+ + + {{loginErrorMessage}} + `, + styles: [ + ':host > .container {padding: 10px}', + '.p-10 { padding: 10px; }' + ] +}) +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(), + UserInfoComponentModule.forRoot() + ], + declarations: [ UserInfoDemo ], + bootstrap: [ UserInfoDemo ] +}) +export class AppModule { } + +platformBrowserDynamic().bootstrapModule(AppModule); 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..0e5c19f9a4 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/demo/systemjs.config.js @@ -0,0 +1,49 @@ +/** + * System configuration for Angular 2 samples + * Adjust as necessary for your application needs. + */ +(function (global) { + System.config({ + paths: { + // paths serve as alias + 'npm:': 'node_modules/' + }, + // map tells the System loader where to look for things + map: { + // our app is within the app folder + app: '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', + // other libraries + 'rxjs': 'npm:rxjs', + 'ng2-translate': 'npm:ng2-translate', + 'ng2-alfresco-core': 'npm:ng2-alfresco-core/dist', + 'ng2-alfresco-login': 'npm:ng2-alfresco-login/dist', + 'ng2-alfresco-userinfo': 'npm:ng2-alfresco-userinfo/dist', + 'alfresco-js-api': 'npm:alfresco-js-api/dist' + }, + // packages tells the System loader how to load when no filename and/or no extension + packages: { + app: { + main: './main.js', + defaultExtension: 'js' + }, + rxjs: { + defaultExtension: 'js' + }, + 'ng2-translate': { defaultExtension: 'js' }, + + 'ng2-alfresco-core': { main: './index.js', defaultExtension: 'js'}, + 'ng2-alfresco-login': { main: './index.js', defaultExtension: 'js'}, + 'ng2-alfresco-userinfo': { main: './index.js', defaultExtension: 'js'}, + 'alfresco-js-api': { main: './alfresco-js-api.js', defaultExtension: 'js'} + } + }); +})(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..b1effea355 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/demo/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/demo/tslint.json b/ng2-components/ng2-alfresco-userinfo/demo/tslint.json new file mode 100644 index 0000000000..85e9df53c1 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/demo/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, + 180 + ], + "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/index.ts b/ng2-components/ng2-alfresco-userinfo/index.ts new file mode 100644 index 0000000000..41ab68dfa4 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/index.ts @@ -0,0 +1,62 @@ +/*! + * @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 { 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_DIRECTIVES: any[] = [ + UserInfoComponent +]; + +export const USER_INFO_PROVIDERS: any[] = [ + EcmUserService, + BpmUserService +]; + +@NgModule({ + imports: [ + CoreModule + ], + declarations: [ + ...USER_INFO_DIRECTIVES + ], + providers: [ + ...USER_INFO_PROVIDERS + ], + exports: [ + ...USER_INFO_DIRECTIVES + ] +}) +export class UserInfoComponentModule { + static forRoot(): ModuleWithProviders { + return { + 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 new file mode 100644 index 0000000000..d7f5a90d43 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/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: 'main.js', defaultExtension: 'js' }, + '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('@angular/core/testing') + .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/karma.conf.js b/ng2-components/ng2-alfresco-userinfo/karma.conf.js new file mode 100644 index 0000000000..5495861358 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/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/package.json b/ng2-components/ng2-alfresco-userinfo/package.json new file mode 100644 index 0000000000..178fcc0e01 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/package.json @@ -0,0 +1,89 @@ +{ + "name": "ng2-alfresco-userinfo", + "description": "Alfresco User Info 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 && 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'", + "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'" + }, + "repository": { + "type": "git", + "url": "https://github.com/Alfresco/alfresco-ng2-components.git" + }, + "bugs": { + "url": "https://github.com/Alfresco/alfresco-ng2-components/issues" + }, + "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", + + "alfresco-js-api": "^0.3.0", + "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.0.4", + "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" + }, + "keywords": [ + "userinfo", + "alfresco-component" + ], + "license-check-config": { + "src": [ + "./dist/**/*.js" + ], + "path": "assets/license_header.txt", + "blocking": false, + "logInfo": false, + "logError": true + }, + "license": "Apache-2.0" +} diff --git a/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.css b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.css new file mode 100644 index 0000000000..93254d00fa --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/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/src/components/user-info.component.html b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.html new file mode 100644 index 0000000000..5a8b50db9c --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/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/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..abf318c877 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.spec.ts @@ -0,0 +1,250 @@ +/*! + * @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 './user-info.component'; +import { EcmUserService } from '../services/ecm-user.service'; +import { BpmUserService } from '../services/bpm-user.service'; +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 fixture: ComponentFixture; + let authStub: StubAuthentication; + let fakeEcmService: FakeEcmUserService; + let fakeBpmService: FakeBpmUserService; + + 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).toBeDefined(); + }); + + 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).toBeDefined(); + }); + + 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).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).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.respondWithTheUserWithoutImage(); + 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).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).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.respondWithTheUserWithoutImage(); + 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).toBeDefined(); + expect(userInfoComp.bpmUserImage).toBeDefined(); + expect(userInfoComp.bpmUserImage).toEqual('fake-picture-id'); + 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).toBeDefined(); + expect(userInfoComp.bpmUser.firstName).toEqual('fake-first-name'); + expect(userInfoComp.bpmUser.lastName).toEqual('fake-last-name'); + 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.respondWithTheUserWithoutImage(); + fakeEcmService.respondWithTheUserWithoutImage(); + 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.respondWithTheUserWithImage(); + fakeEcmService.respondWithTheUserWithImage(); + userInfoComp.ngOnInit(); + fixture.whenStable() + .then( () => { + fixture.detectChanges(); + let res = userInfoComp.getUserAvatar(); + 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.respondWithTheUserWithImage(); + fakeEcmService.respondWithTheUserWithoutImage(); + userInfoComp.ngOnInit(); + fixture.whenStable() + .then( () => { + fixture.detectChanges(); + let res = userInfoComp.getUserAvatar(); + 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.respondWithTheUserWithoutImage(); + fakeEcmService.respondWithTheUserWithoutImage(); + 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 new file mode 100644 index 0000000000..339ddfcc06 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.ts @@ -0,0 +1,94 @@ +/*! + * @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: ['./user-info.component.css'], + templateUrl: './user-info.component.html' +}) + +export class UserInfoComponent implements OnInit { + + private baseComponentPath = __moduleName.replace('components/user-info.component.js', ''); + + ecmUser: EcmUserModel; + bpmUser: BpmUserModel; + anonymouseImageUrl: string = this.baseComponentPath + 'img/anonymous.gif'; + bpmUserImage: any; + ecmUserImage: any; + + constructor(private ecmUserService: EcmUserService, + private bpmUserService: BpmUserService, + public authService: AlfrescoAuthenticationService) { + } + + ngOnInit() { + if ( this.authService.isEcmLoggedIn() ) { + this.ecmUserService.getCurrentUserInfo() + .subscribe( + (res) => { + this.ecmUser = res; + this.getEcmUserProfileImage(); + } + ); + } + if ( this.authService.isBpmLoggedIn() ) { + 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/src/img/anonymous.gif b/ng2-components/ng2-alfresco-userinfo/src/img/anonymous.gif new file mode 100644 index 0000000000..e1b58fa57d Binary files /dev/null and b/ng2-components/ng2-alfresco-userinfo/src/img/anonymous.gif differ diff --git a/ng2-components/ng2-alfresco-userinfo/src/models/bpm-user.model.ts b/ng2-components/ng2-alfresco-userinfo/src/models/bpm-user.model.ts new file mode 100644 index 0000000000..3ee3fd7222 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/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/src/models/ecm-company.model.ts b/ng2-components/ng2-alfresco-userinfo/src/models/ecm-company.model.ts new file mode 100644 index 0000000000..458b6b8ed5 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/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/src/models/ecm-user.model.ts b/ng2-components/ng2-alfresco-userinfo/src/models/ecm-user.model.ts new file mode 100644 index 0000000000..08f24fbcdb --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/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/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..8899f70daf --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.spec.ts @@ -0,0 +1,146 @@ +/*! + * @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 { 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'; + +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' +}; + +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(fakeBpmUser); }; +}; + +describe('Bpm User service', () => { + + beforeEach( async(() => { + TestBed.configureTestingModule({ + providers: [ BpmUserService, + { provide: AlfrescoAuthenticationService, useClass: StubAuthentication } + ] + }) + .compileComponents(); + })); + + 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); + 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).toBeDefined(); + 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).toBeDefined(); + 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 new file mode 100644 index 0000000000..1c0dff5bce --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.ts @@ -0,0 +1,91 @@ +/*! + * @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/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) { + } + + /** + * get Current User information for BPM + * @param userName - the user name + */ + getCurrentUserInfo(): Observable { + if ( this.authService.isBpmLoggedIn() ) { + return Observable.fromPromise(this.callApiGetProfile()) + .map( + (data) => data + ) + .catch(this.handleError); + } + } + + getCurrentUserProfileImage(): any { + if ( this.authService.isBpmLoggedIn() ) { + return Observable.fromPromise(this.callApiGetProfilePicture()) + .map( + (data) => data + ) + .catch(this.handleError); + } + } + + /** + * Call js api to get current user profile picture + */ + callApiGetProfilePicture() { + try { + return this.authService.getAlfrescoApi().activiti.profileApi.getProfilePicture(); + } catch (exc) { + console.error(exc); + return null; + } + } + + /** + * Call js api to get current user information + */ + 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/ecm-user.service.spec.ts b/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.spec.ts new file mode 100644 index 0000000000..4d88d66fe9 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.spec.ts @@ -0,0 +1,179 @@ +/*! + * @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 { 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: '=1111111', + 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', () => { + + beforeEach( async(() => { + TestBed.configureTestingModule({ + providers: [ EcmUserService, + { provide: AlfrescoAuthenticationService, useClass: StubAuthentication }, + { provide: AlfrescoContentService, useClass: StubAlfrescoContentService } + ] + }) + .compileComponents(); + })); + + it('can instantiate service when inject service', + inject([EcmUserService], (service: EcmUserService) => { + expect(service instanceof EcmUserService).toBe(true); + })); + + 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'); + })); + + 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'); + })); + + describe('when user is 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(true); + })); + + 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).toBeDefined(); + expect(user.firstName).toEqual('fake-first-name'); + expect(user.lastName).toEqual('fake-last-name'); + expect(user.email).toEqual('fakeEcm@ecmUser.com'); + done(); + }); + }); + + 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(undefined); + 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).toBeDefined(); + 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 new file mode 100644 index 0000000000..1175af0f1a --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.ts @@ -0,0 +1,76 @@ +/*! + * @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.isEcmLoggedIn() ) { + return Observable.fromPromise(this.callApiGetPersonInfo(userName)) + .map( + (data) => data['entry'] + ) + .catch(this.handleError); + } + } + + getCurrentUserInfo() { + return this.getUserInfo('-me-'); + } + + 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/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..b7a2f87d91 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/src/testing/fake-bpm-user.service.ts @@ -0,0 +1,98 @@ +/*! + * @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; + }; + + 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 new file mode 100644 index 0000000000..2133e780b1 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/src/testing/fake-ecm-user.service.ts @@ -0,0 +1,107 @@ +/*! + * @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'; + } + }; + + respondWithTheUserWithoutImage() { + this.userNeeded = 1; + }; + + respondWithTheUserWithImage() { + this.userNeeded = 0; + }; + +} diff --git a/ng2-components/ng2-alfresco-userinfo/tsconfig.json b/ng2-components/ng2-alfresco-userinfo/tsconfig.json new file mode 100644 index 0000000000..ae39a67a17 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/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/tslint.json b/ng2-components/ng2-alfresco-userinfo/tslint.json new file mode 100644 index 0000000000..ba706079f4 --- /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, + 180 + ], + "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/update.sh b/ng2-components/update.sh index df9f5c4548..0f7732c5ba 100755 --- a/ng2-components/update.sh +++ b/ng2-components/update.sh @@ -34,3 +34,6 @@ (cd ng2-alfresco-tag; npm update;) (cd ng2-alfresco-tag/demo; npm update;) + +(cd ng2-alfresco-userinfo; npm update;) +(cd ng2-alfresco-userinfo/demo; npm update;) diff --git a/scripts/npm-build-all.sh b/scripts/npm-build-all.sh index 55d3310667..5767e52d7a 100755 --- a/scripts/npm-build-all.sh +++ b/scripts/npm-build-all.sh @@ -22,6 +22,7 @@ for PACKAGE in \ ng2-alfresco-search \ ng2-alfresco-tag \ ng2-alfresco-upload \ + ng2-alfresco-userinfo \ ng2-alfresco-viewer \ ng2-alfresco-webscript do diff --git a/scripts/npm-check.sh b/scripts/npm-check.sh index e98fea6553..704e3b72a4 100755 --- a/scripts/npm-check.sh +++ b/scripts/npm-check.sh @@ -19,7 +19,8 @@ for PACKAGE in \ ng2-alfresco-tag \ ng2-alfresco-upload \ ng2-alfresco-viewer \ - ng2-alfresco-webscript + ng2-alfresco-webscript \ + ng2-alfresco-userinfo do echo "====== Check component: ${PACKAGE} =====" cd "$DIR/../ng2-components/${PACKAGE}" diff --git a/scripts/npm-clean.sh b/scripts/npm-clean.sh index 557d336dbf..eeffa98fc0 100755 --- a/scripts/npm-clean.sh +++ b/scripts/npm-clean.sh @@ -15,7 +15,8 @@ for PACKAGE in \ ng2-alfresco-tag \ ng2-alfresco-upload \ ng2-alfresco-viewer \ - ng2-alfresco-webscript + ng2-alfresco-webscript \ + ng2-alfresco-userinfo do echo "====== clean component: ${PACKAGE} =====" cd "$DIR/../ng2-components/${PACKAGE}" diff --git a/scripts/npm-link-demo-shell.sh b/scripts/npm-link-demo-shell.sh index 3712f17a71..966f1833df 100755 --- a/scripts/npm-link-demo-shell.sh +++ b/scripts/npm-link-demo-shell.sh @@ -75,7 +75,8 @@ for PACKAGE in \ ng2-alfresco-login \ ng2-alfresco-search \ ng2-alfresco-upload \ - ng2-activiti-analytics + ng2-activiti-analytics \ + ng2-alfresco-userinfo do DESTDIR="$DIR/../ng2-components/${PACKAGE}" echo "====== linking component: ${PACKAGE} =====" @@ -102,6 +103,7 @@ for PACKAGE in \ ng2-alfresco-upload \ ng2-alfresco-viewer \ ng2-alfresco-webscript \ + ng2-alfresco-userinfo do DESTDIR="$DIR/../ng2-components/${PACKAGE}" echo "====== demo shell linking: ${PACKAGE} =====" diff --git a/scripts/npm-publish.sh b/scripts/npm-publish.sh index 8f06c4d942..8d483d2ee7 100755 --- a/scripts/npm-publish.sh +++ b/scripts/npm-publish.sh @@ -17,7 +17,8 @@ for PACKAGE in \ ng2-alfresco-tag \ ng2-alfresco-upload \ ng2-alfresco-viewer \ - ng2-alfresco-webscript + ng2-alfresco-webscript \ + ng2-alfresco-userinfo do DESTDIR="$DIR/../ng2-components/${PACKAGE}" echo "====== PUBLISHING: ${DESTDIR} =====" diff --git a/scripts/update-version.sh b/scripts/update-version.sh index 52faaf612f..dca9b25a6b 100755 --- a/scripts/update-version.sh +++ b/scripts/update-version.sh @@ -27,7 +27,8 @@ for PACKAGE in \ ng2-alfresco-tag \ ng2-alfresco-upload \ ng2-alfresco-viewer \ - ng2-alfresco-webscript + ng2-alfresco-webscript \ + ng2-alfresco-userinfo do DESTDIR="$DIR/../ng2-components/${PACKAGE}" echo "====== UPDATE VERSION of ${PACKAGE} to ${VERSION} version in all the package.json ======" @@ -47,7 +48,8 @@ for PACKAGE in \ ng2-alfresco-tag \ ng2-alfresco-upload \ ng2-alfresco-viewer \ - ng2-alfresco-webscript + ng2-alfresco-webscript \ + ng2-alfresco-userinfo do DESTDIR="$DIR/../ng2-components/${PACKAGE}" echo "====== UPDATE VERSION OF ${PACKAGE} to ${VERSION} version ======"