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" + } +}