diff --git a/.travis.yml b/.travis.yml index 43479887c4..a65574b973 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,19 +28,20 @@ env: - MODULE=ng2-alfresco-viewer - MODULE=ng2-activiti-form - MODULE=ng2-alfresco-webscript + - MODULE=ng2-activiti-processlist before_script: - if ([ "$MODULE" != "ng2-alfresco-core" ] && [ "$MODULE" != "ng2-alfresco-viewer" ]); then (cd ng2-components/ng2-alfresco-core; npm install; npm link); fi - - if ([ "$MODULE" == "ng2-alfresco-documentlist" ] || [ "$MODULE" == "ng2-alfresco-webscript" ]); then - (cd ng2-components/ng2-alfresco-datatable;npm link ng2-alfresco-core; npm install; npm link); + - if ([ "$MODULE" == "ng2-alfresco-documentlist" ] || [ "$MODULE" == "ng2-alfresco-webscript" ] || [ "$MODULE" == "ng2-activiti-processlist" ]); then + (cd ng2-components/ng2-alfresco-datatable; npm link ng2-alfresco-core; npm install; npm link); fi - cd ng2-components/$MODULE; - if ([ "$MODULE" != "ng2-alfresco-core" ] && [ "$MODULE" != "ng2-alfresco-viewer" ]); then npm link ng2-alfresco-core; fi - - if ([ "$MODULE" == "ng2-alfresco-documentlist" ] || [ "$MODULE" == "ng2-alfresco-webscript" ]); then + - if ([ "$MODULE" == "ng2-alfresco-documentlist" ] || [ "$MODULE" == "ng2-alfresco-webscript" ] || [ "$MODULE" == "ng2-activiti-processlist" ]); then npm link ng2-alfresco-datatable; fi - npm install; diff --git a/ng2-components/ng2-activiti-processlist/.editorconfig b/ng2-components/ng2-activiti-processlist/.editorconfig new file mode 100644 index 0000000000..75a2477db7 --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/.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-activiti-processlist/.gitignore b/ng2-components/ng2-activiti-processlist/.gitignore new file mode 100644 index 0000000000..3bea8a0c07 --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/.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-activiti-processlist/.travis.yml b/ng2-components/ng2-activiti-processlist/.travis.yml new file mode 100644 index 0000000000..ab817d7644 --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/.travis.yml @@ -0,0 +1,12 @@ +language: node_js +node_js: + - v5 + - v4 + - '0.12' + - '0.10' +install: npm install +sudo: false +after_success: + npm run coverage +# Send coverage data to Coveralls +after_script: "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js" diff --git a/ng2-components/ng2-activiti-processlist/LICENSE b/ng2-components/ng2-activiti-processlist/LICENSE new file mode 100644 index 0000000000..430d42bbea --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS diff --git a/ng2-components/ng2-activiti-processlist/README.md b/ng2-components/ng2-activiti-processlist/README.md new file mode 100644 index 0000000000..f4c967396b --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/README.md @@ -0,0 +1,101 @@ +# <ng-2-activiti-processlist> +[![NPM version][npm-image]][npm-url] +[![Build Status][travis-image]][travis-url] +[![Dependency Status][daviddm-image]][daviddm-url] +[![Coverage percentage][coveralls-image]][coveralls-url] +[![Style guide][style-image]][style-url] +[![Alfresco component][alfrescocomponent-image]][alfrescocomponent-url] + +## About ng-2-activiti-processlist +> Show available processes from the Activiti BPM suite + +## Installation + +```bash +npm install ng-2-activiti-processlist --save +``` + +## Example + +```html + +``` + +## Reference + +Attribute | Options | Default | Description +--- | --- | --- | --- +`foo` | *string* | `bar` | Lorem ipsum dolor. + + +Method | Parameters | Returns | Description +--- | --- | --- | --- +`methodName()` | None. | void | Lorem ipsum dolor. + +## Develop command list + + +* To test your component + + ```sh + $ npm run test + ``` + +* To run the test in the browser + + ```sh + $ npm run test-browser + ``` + +* To run the test coverage + + ```sh + $ npm run coverage + ``` + +* To build the component + + ```sh + $ npm run build + ``` + +* To build the component and keep watching the changes + + ```sh + $ npm run build:w + ``` + +* To provide a live demo + + ```sh + $ cd demo + $ npm run start + ``` + +* To clean npm_modules and typings folder + + ```sh + $ npm run clean + ``` + +## History + +For detailed changelog, check [Releases](https://github.com/Alfresco/ng-2-activiti-processlist/releases). + +## Contributors + +[Contributors](https://github.com/Alfresco/ng-2-activiti-processlist/graphs/contributors) + + +[npm-image]: https://badge.fury.io/js/ng-2-activiti-processlist.svg +[npm-url]: https://npmjs.org/package/ng-2-activiti-processlist +[travis-image]: https://travis-ci.org/Alfresco/ng-2-activiti-processlist.svg?branch=master +[travis-url]: https://travis-ci.org/Alfresco/ng-2-activiti-processlist +[daviddm-image]: https://david-dm.org/Alfresco/ng-2-activiti-processlist.svg?theme=shields.io +[daviddm-url]: https://david-dm.org/Alfresco/ng-2-activiti-processlist +[coveralls-image]: https://coveralls.io/repos/Alfresco/ng-2-activiti-processlist/badge.svg +[coveralls-url]: https://coveralls.io/r/Alfresco/ng-2-activiti-processlist +[style-url]: https://github.com/mgechev/angular2-style-guide +[style-image]: https://mgechev.github.io/angular2-style-guide/images/badge.svg +[alfrescocomponent-image]: https://img.shields.io/badge/Alfresco%20component-approved-green.svg +[alfrescocomponent-url]: https://www.alfresco.com diff --git a/ng2-components/ng2-activiti-processlist/angular-cli.json b/ng2-components/ng2-activiti-processlist/angular-cli.json new file mode 100644 index 0000000000..c6a5e72386 --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/angular-cli.json @@ -0,0 +1,27 @@ +{ + "project": { + "version": "ng2-activiti-processlist", + "name": "0.1.0" + }, + "apps": [ + { + "main": "src/ng2-activiti-processlist.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-activiti-processlist/assets/license_header.txt b/ng2-components/ng2-activiti-processlist/assets/license_header.txt new file mode 100644 index 0000000000..83fd1531a3 --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/assets/license_header.txt @@ -0,0 +1,16 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ \ No newline at end of file diff --git a/ng2-components/ng2-activiti-processlist/demo/.editorconfig b/ng2-components/ng2-activiti-processlist/demo/.editorconfig new file mode 100644 index 0000000000..8ed330c4a2 --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/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-activiti-processlist/demo/.gitignore b/ng2-components/ng2-activiti-processlist/demo/.gitignore new file mode 100644 index 0000000000..6afdbb8367 --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/demo/.gitignore @@ -0,0 +1,6 @@ +typings/ +node_modules/ +.idea +dist/ +!systemjs.config.js +!browser-sync-config.js diff --git a/ng2-components/ng2-activiti-processlist/demo/README.md b/ng2-components/ng2-activiti-processlist/demo/README.md new file mode 100644 index 0000000000..2596f9176b --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/demo/README.md @@ -0,0 +1,19 @@ +# ng2-activiti-processlist - 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-activiti-processlist/demo/browser-sync-config.js b/ng2-components/ng2-activiti-processlist/demo/browser-sync-config.js new file mode 100644 index 0000000000..2fb5e7fd5d --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/demo/browser-sync-config.js @@ -0,0 +1,23 @@ +var browserSync = require("browser-sync").create(); +var historyApiFallback = require('connect-history-api-fallback'); + +browserSync.init({ + + server: { + baseDir: './', + middleware: [ historyApiFallback() ] + }, + + files: [ + 'index.html', + 'dist/**/*.{html,htm,css,js}', + 'node_modules/ng2-alfresco-core/dist/**/*.{html,htm,css,js}', + 'node_modules/ng2-alfresco-datatable/dist/**/*.{html,htm,css,js}', + 'node_modules/ng2-alfresco-documentlist/dist/**/*.{html,htm,css,js}', + 'node_modules/ng2-alfresco-login/dist/**/*.{html,htm,css,js}', + 'node_modules/ng2-alfresco-search/dist/**/*.{html,htm,css,js}', + 'node_modules/ng2-alfresco-upload/dist/**/*.{html,htm,css,js}', + 'node_modules/ng2-alfresco-viewer/dist/**/*.{html,htm,css,js}'], + + reloadDelay: 1000 +}); diff --git a/ng2-components/ng2-activiti-processlist/demo/index.html b/ng2-components/ng2-activiti-processlist/demo/index.html new file mode 100644 index 0000000000..63fd1b2b57 --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/demo/index.html @@ -0,0 +1,37 @@ + + + + + ng2-activiti-processlist Angular 2 + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + diff --git a/ng2-components/ng2-activiti-processlist/demo/package.json b/ng2-components/ng2-activiti-processlist/demo/package.json new file mode 100644 index 0000000000..e68aadab99 --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/demo/package.json @@ -0,0 +1,58 @@ +{ + "name": "ng2-activiti-processlist-demo", + "description": "Show available processes from the Activiti BPM suite - Demo", + "version": "0.1.0", + "author": "Will Abson", + "main": "index.js", + "scripts": { + "clean": "rimraf dist node_modules typings", + "typings": "typings install", + "postinstall": "npm run typings && npm run build", + "start": "npm install && npm run typings && concurrently \"npm run build:w\" \"npm run server\" ", + "server": "node browser-sync-config.js", + "build": "npm run tslint && rimraf dist && tsc", + "build:w": "npm run tslint && rimraf dist && tsc -w", + "tslint": "npm run tslint-src && npm run tslint-root", + "tslint-src": "tslint -c tslint.json src/**/*.ts", + "tslint-root": "tslint -c tslint.json *.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", + "ng2-activiti-processlist": "file:../", + "alfresco-js-api": "^0.1.0", + "material-design-icons": "^2.2.3", + "material-design-lite": "^1.1.3" + }, + "devDependencies": { + "browser-sync": "^2.10.0", + "connect-history-api-fallback": "^1.2.0", + "concurrently": "^2.0.0", + "rimraf": "2.5.2", + "tslint": "^3.8.1", + "typescript": "^1.8.10", + "typings": "^1.0.4" + }, + "publishConfig": { + "registry": "http://devproducts.alfresco.me:4873/" + } +} diff --git a/ng2-components/ng2-activiti-processlist/demo/src/main.ts b/ng2-components/ng2-activiti-processlist/demo/src/main.ts new file mode 100644 index 0000000000..bb7c305d6c --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/demo/src/main.ts @@ -0,0 +1,95 @@ +/*! + * @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, Injectable, provide } from '@angular/core'; +import { bootstrap } from '@angular/platform-browser-dynamic'; +import { + ACTIVITI_PROCESSLIST_PROVIDERS, + ACTIVITI_PROCESSLIST_DIRECTIVES +} from 'ng2-activiti-processlist/dist/ng2-activiti-processlist'; +import { + AlfrescoAuthenticationService, + AlfrescoSettingsService, + ALFRESCO_CORE_PROVIDERS +} from 'ng2-alfresco-core'; +import { HTTP_PROVIDERS, BrowserXhr } from '@angular/http'; + +@Component({ + selector: 'my-app', + template: ``, + providers: [ACTIVITI_PROCESSLIST_PROVIDERS], + directives: [ACTIVITI_PROCESSLIST_DIRECTIVES] +}) +class MyDemoApp implements OnInit { + + authenticated: boolean; + host: string = 'http://127.0.0.1:9999'; + token: string; + + constructor( + private authService: AlfrescoAuthenticationService, + private alfrescoSettingsService: AlfrescoSettingsService + ) { + console.log('constructor'); + + alfrescoSettingsService.host = this.host; + if (this.authService.getTicket()) { + this.token = this.authService.getTicket(); + } + } + + ngOnInit() { + this.login(); + } + + public updateToken(): void { + localStorage.setItem('token', this.token); + } + + public updateHost(): void { + this.alfrescoSettingsService.host = this.host; + this.login(); + } + + login() { + this.authService.login('admin@app.activiti.com', 'admin', ['BPM']).subscribe( + token => { + console.log(token); + this.token = token; + this.authenticated = true; + }, + error => { + console.log(error); + this.authenticated = false; + }); + } +} + +@Injectable() +export class CustomBrowserXhr extends BrowserXhr { + constructor() {} + build(): any { + let xhr = super.build(); + xhr.withCredentials = true; + return (xhr); + } +} + +bootstrap(MyDemoApp, [ + ALFRESCO_CORE_PROVIDERS, + HTTP_PROVIDERS, + provide(BrowserXhr, { useClass: CustomBrowserXhr }) +]); diff --git a/ng2-components/ng2-activiti-processlist/demo/systemjs.config.js b/ng2-components/ng2-activiti-processlist/demo/systemjs.config.js new file mode 100644 index 0000000000..a09961cab3 --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/demo/systemjs.config.js @@ -0,0 +1,71 @@ +/** + * @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. + */ + +(function (global) { + + // map tells the System loader where to look for things + var map = { + 'app': 'dist', + '@angular': 'node_modules/@angular', + 'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api', + 'rxjs': 'node_modules/rxjs', + 'ng2-translate': 'node_modules/ng2-translate', + 'ng2-activiti-processlist': 'node_modules/ng2-activiti-processlist', + 'ng2-alfresco-core': 'node_modules/ng2-alfresco-core/dist', + 'ng2-alfresco-datatable': 'node_modules/ng2-alfresco-datatable/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' }, + 'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' }, + 'ng2-translate': { defaultExtension: 'js' }, + 'ng2-activiti-processlist': { main: 'index.js', defaultExtension: 'js' }, + 'ng2-alfresco-core': { main: 'index.js', defaultExtension: 'js' }, + 'ng2-alfresco-datatable': { 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-activiti-processlist/demo/tsconfig.json b/ng2-components/ng2-activiti-processlist/demo/tsconfig.json new file mode 100644 index 0000000000..772c3a7e75 --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/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-activiti-processlist/demo/tslint.json b/ng2-components/ng2-activiti-processlist/demo/tslint.json new file mode 100644 index 0000000000..8c48e76469 --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/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-activiti-processlist/demo/typings.json b/ng2-components/ng2-activiti-processlist/demo/typings.json new file mode 100644 index 0000000000..7e0e18568d --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/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-activiti-processlist/i18n/en.json b/ng2-components/ng2-activiti-processlist/i18n/en.json new file mode 100644 index 0000000000..8706fab794 --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/i18n/en.json @@ -0,0 +1,10 @@ +{ + "PROCESSLIST": { + "NONE": "No active processes were found", + "SUMMARY": "Found {{total}} active process instances", + "ERROR": "An error occurred while loading the processes: {{errorMessage}}", + "COLUMN": { + "NAME": "Name" + } + } +} diff --git a/ng2-components/ng2-activiti-processlist/karma-test-shim.js b/ng2-components/ng2-activiti-processlist/karma-test-shim.js new file mode 100644 index 0000000000..8c7ba100a2 --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/karma-test-shim.js @@ -0,0 +1,108 @@ +// 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-alfresco-core': '/base/node_modules/ng2-alfresco-core/dist', + 'ng2-alfresco-datatable': '/base/node_modules/ng2-alfresco-datatable/dist', + 'ng2-translate' : '/base/node_modules/ng2-translate' +}; + +var packages = { + 'app': { main: 'main.js', defaultExtension: 'js' }, + 'rxjs': { defaultExtension: 'js' }, + 'ng2-alfresco-core': { main: 'index.js', defaultExtension: 'js' }, + 'ng2-alfresco-datatable': { main: 'index.js', defaultExtension: 'js' }, + 'ng2-translate': { defaultExtension: 'js' } +}; + +var packageNames = [ + '@angular/common', + '@angular/compiler', + '@angular/core', + '@angular/http', + '@angular/platform-browser', + '@angular/platform-browser-dynamic', + '@angular/router', + '@angular/router-deprecated', + '@angular/testing', + '@angular/upgrade' +]; + +packageNames.forEach(function(pkgName) { + packages[pkgName] = { main: 'index.js', defaultExtension: 'js' }; +}); + +packages['base/dist'] = { + defaultExtension: 'js', + format: 'register', + map: Object.keys(window.__karma__.files).filter(onlyAppFiles).reduce(createPathRecords, {}) +}; + +var config = { + map: map, + packages: packages +}; + +System.config(config); + +System.import('@angular/platform-browser/src/browser/browser_adapter') + .then(function(browser_adapter) { browser_adapter.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-activiti-processlist/karma.conf.js b/ng2-components/ng2-activiti-processlist/karma.conf.js new file mode 100644 index 0000000000..5cd8767851 --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/karma.conf.js @@ -0,0 +1,89 @@ +'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: true}, + {pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: false}, + {pattern: 'node_modules/zone.js/dist/zone.js', included: true, watched: true}, + {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-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-datatable/dist/**/*.html', included: false, served: true, watched: false}, + {pattern: 'node_modules/ng2-alfresco-datatable/dist/**/*.css', included: false, served: true, watched: false}, + {pattern: 'node_modules/ng2-translate/**/*.js', included: false, served: 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', 'coveralls', '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'} + ] + } + }) +}; diff --git a/ng2-components/ng2-activiti-processlist/ng2-activiti-processlist.ts b/ng2-components/ng2-activiti-processlist/ng2-activiti-processlist.ts new file mode 100644 index 0000000000..364a5c8638 --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/ng2-activiti-processlist.ts @@ -0,0 +1,33 @@ +/*! + * @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 { Ng2ActivitiProcesslistComponent } from './src/components/ng2-activiti-processlist.component'; +import { ActivitiProcessService } from './src/services/activiti-process-service.service'; + +// components +export * from './src/components/ng2-activiti-processlist.component'; + +// services +export * from './src/services/activiti-process-service.service'; + +export const ACTIVITI_PROCESSLIST_DIRECTIVES: [any] = [ + Ng2ActivitiProcesslistComponent +]; + +export const ACTIVITI_PROCESSLIST_PROVIDERS: [any] = [ + ActivitiProcessService +]; diff --git a/ng2-components/ng2-activiti-processlist/package.json b/ng2-components/ng2-activiti-processlist/package.json new file mode 100644 index 0000000000..ca982b4f49 --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/package.json @@ -0,0 +1,113 @@ +{ + "keywords": [ + "ng2", + "angular", + "angular2", + "alfresco", + "activiti" + ], + "name": "ng2-activiti-processlist", + "description": "Show active processes from the Activiti BPM suite", + "version": "0.1.0", + "author": "Alfresco Software, Ltd.", + "scripts": { + "clean": "rimraf dist node_modules typings", + "typings": "typings install", + "server": "http-server -c-1 -o -p 8875 .", + "build": "npm run tslint && typings install && rimraf dist && tsc && npm run copytemplates && license-check", + "build:w": "npm run tslint && typings install && rimraf dist && npm run watch-task", + "watch-task": "concurrently \"npm run tsc:w\" \"npm run copytemplates:w\" \"license-check\"", + "tslint": "npm run tslint-src && npm run tslint-root", + "tslint-src": "tslint -c tslint.json src/{,**/}**.ts", + "tslint-root": "tslint -c tslint.json *.ts", + "copytemplates": "npm run copy-html-css && npm run copy-i18n && npm run copy-images", + "copytemplates:w": "concurrently \"npm run copy-html-css:w\" \"npm run copy-images:w\" \"npm run copy-i18n:w\"", + "copy-html-css": "cpx \"./src/**/*.{html,css}\" ./dist/src", + "copy-html-css:w": "cpx \"./src/**/*.{html,css}\" ./dist/src -w", + "copy-i18n": "cpx \"./i18n/**/*.json\" ./dist/i18n", + "copy-i18n:w": "cpx \"./i18n/**/*.json\" ./dist/i18n -w", + "copy-images": "cpx \"./src/**/*.{png,jpg,gif,svg}\" ./dist/src", + "copy-images:w": "cpx \"./src/**/*.{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": "node_modules/.bin/remap-istanbul -i coverage/report/coverage-final.json -o coverage/report -t html", + "coverage": "npm run test && http-server -c-1 -o -p 9875 ./coverage/report", + "prepublish": "npm run build", + "travis": "npm link ng2-alfresco-core ng2-alfresco-datatable" + }, + "repository": { + "type": "git", + "url": "https://github.com/Alfresco/alfresco-ng2-components" + }, + "bugs": { + "url": "https://github.com/Alfresco/alfresco-ng2-components/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", + "ng2-alfresco-core": "0.2.0", + "ng2-alfresco-datatable": "0.2.0" + }, + "devDependencies": { + "angular-cli": "1.0.0-beta.9", + "concurrently": "^2.1.0", + "coveralls": "^2.11.9", + "cpx": "^1.3.1", + "http-server": "0.8.5", + "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-coveralls": "^1.1.2", + "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": "^1.8.10", + "typings": "^1.0.4" + }, + "license-check-config": { + "src": [ + "**/*.js", + "**/*.ts", + "!/**/coverage/**/*", + "!/**/demo/**/*", + "!/**/node_modules/**/*", + "!/**/typings/**/*", + "!*.js" + ], + "path": "assets/license_header.txt", + "blocking": false, + "logInfo": false, + "logError": true + }, + "license": "Apache-2.0", + "contributors": [ + { + "name": "Will Abson", + "email": "will.abson@alfresco.com" + } + ] +} diff --git a/ng2-components/ng2-activiti-processlist/src/assets/activiti-process-service.mock.ts b/ng2-components/ng2-activiti-processlist/src/assets/activiti-process-service.mock.ts new file mode 100644 index 0000000000..92fe2b717e --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/src/assets/activiti-process-service.mock.ts @@ -0,0 +1,49 @@ +/*! + * @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 { Observable } from 'rxjs/Observable'; +import { + ProcessList, + SingleProcessList +} from './activiti-process.model.mock'; +import { ActivitiProcessService } from './../services/activiti-process-service.service'; +import { AlfrescoSettingsService } from 'ng2-alfresco-core'; + +export class ActivitiProcessServiceMock extends ActivitiProcessService { + + getProcessesResult: ProcessList = new SingleProcessList('Example process 1'); + getProcessesReject: boolean = false; + getProcessesRejectError: string = 'Error'; + + constructor( + settings?: AlfrescoSettingsService + ) { + super(settings, null); + } + + getProcesses() { + if (this.getProcessesReject) { + return Observable.throw(this.getProcessesRejectError); + } + return Observable.create(observer => { + observer.next(this.getProcessesResult); + observer.complete(); + }).map((json) => { + return json.data; + }); + } +} diff --git a/ng2-components/ng2-activiti-processlist/src/assets/activiti-process.model.mock.ts b/ng2-components/ng2-activiti-processlist/src/assets/activiti-process.model.mock.ts new file mode 100644 index 0000000000..6eba34a88e --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/src/assets/activiti-process.model.mock.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 { ProcessInstance } from '../models/process-instance'; + +export class ProcessList { + + data: ProcessInstance[]; + size: number; + start: number; + total: number; + + constructor(data?: ProcessInstance[]) { + this.data = data || []; + } +} + +export class SingleProcessList extends ProcessList { + constructor(name?: string) { + let instance = new ProcessInstance(); + instance.id = '123'; + instance.name = name; + super([instance]); + } +} diff --git a/ng2-components/ng2-activiti-processlist/src/assets/translation.service.mock.ts b/ng2-components/ng2-activiti-processlist/src/assets/translation.service.mock.ts new file mode 100644 index 0000000000..023104944a --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/src/assets/translation.service.mock.ts @@ -0,0 +1,37 @@ +/*! + * @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 { Observable } from 'rxjs/Rx'; +import { EventEmitter } from '@angular/core'; + +export interface LangChangeEvent { + lang: string; + translations: any; +} + +export class TranslationMock { + + public onLangChange: EventEmitter = new EventEmitter(); + + public get(key: string|Array, interpolateParams?: Object): Observable { + return Observable.of(key); + } + + addTranslationFolder() { + + } +} diff --git a/ng2-components/ng2-activiti-processlist/src/components/ng2-activiti-processlist.component.html b/ng2-components/ng2-activiti-processlist/src/components/ng2-activiti-processlist.component.html new file mode 100644 index 0000000000..beedb69313 --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/src/components/ng2-activiti-processlist.component.html @@ -0,0 +1,6 @@ +

My Activiti Processes

+ +

{{ 'PROCESSLIST.NONE' | translate }}

+ + diff --git a/ng2-components/ng2-activiti-processlist/src/components/ng2-activiti-processlist.component.spec.ts b/ng2-components/ng2-activiti-processlist/src/components/ng2-activiti-processlist.component.spec.ts new file mode 100644 index 0000000000..e9825c2de7 --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/src/components/ng2-activiti-processlist.component.spec.ts @@ -0,0 +1,67 @@ +/*! + * @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 { HTTP_PROVIDERS } from '@angular/http'; +import {describe, expect, it, inject, beforeEachProviders} from '@angular/core/testing'; +import { TestComponentBuilder } from '@angular/compiler/testing'; +import { + AlfrescoSettingsService, + AlfrescoTranslationService +} from 'ng2-alfresco-core'; +import { Ng2ActivitiProcesslistComponent } from '../../src/components/ng2-activiti-processlist.component'; +import { ActivitiProcessServiceMock } from '../assets/activiti-process-service.mock'; +import { TranslationMock } from './../assets/translation.service.mock'; +import { ActivitiProcessService } from '../services/activiti-process-service.service'; + +describe('ActivitiProcesslistComponent', () => { + + beforeEachProviders(() => { + + return [ + { provide: AlfrescoSettingsService }, + { provide: AlfrescoTranslationService, useClass: TranslationMock }, + { provide: ActivitiProcessService, useClass: ActivitiProcessServiceMock }, + HTTP_PROVIDERS + ]; + }); + + it('should have a valid title', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { + return tcb + .createAsync(Ng2ActivitiProcesslistComponent) + .then((fixture) => { + let element = fixture.nativeElement; + expect(element.querySelector('h1')).toBeDefined(); + expect(element.getElementsByTagName('h1')[0].innerHTML).toEqual('My Activiti Processes'); + }); + })); + + it('should contain a list of processes', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { + let componentHandler = jasmine.createSpyObj('componentHandler', [ + 'upgradeAllRegistered' + ]); + window['componentHandler'] = componentHandler; + return tcb + .createAsync(Ng2ActivitiProcesslistComponent) + .then((fixture) => { + let element = fixture.nativeElement, component = fixture.componentInstance; + component.ngOnInit(); + fixture.detectChanges(); + expect(element.querySelector('table')).toBeDefined(); + expect(element.querySelectorAll('table tbody tr').length).toEqual(1); + }); + })); +}); diff --git a/ng2-components/ng2-activiti-processlist/src/components/ng2-activiti-processlist.component.ts b/ng2-components/ng2-activiti-processlist/src/components/ng2-activiti-processlist.component.ts new file mode 100644 index 0000000000..0dd514bc2a --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/src/components/ng2-activiti-processlist.component.ts @@ -0,0 +1,93 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + Component, + OnInit +} from '@angular/core'; +import { + AlfrescoPipeTranslate, + AlfrescoTranslationService, + CONTEXT_MENU_DIRECTIVES, + CONTEXT_MENU_PROVIDERS +} from 'ng2-alfresco-core'; +import { + ALFRESCO_DATATABLE_DIRECTIVES, + ObjectDataTableAdapter +} from 'ng2-alfresco-datatable'; +import { ActivitiProcessService } from '../services/activiti-process-service.service'; +import { ProcessInstance } from '../models/process-instance'; + +declare let __moduleName: string; + +@Component({ + moduleId: __moduleName, + selector: 'activiti-processlist', + styles: [ + ` + :host h1 { + font-size:22px + } + ` + ], + templateUrl: './ng2-activiti-processlist.component.html', + directives: [ ALFRESCO_DATATABLE_DIRECTIVES, CONTEXT_MENU_DIRECTIVES ], + pipes: [ AlfrescoPipeTranslate ], + providers: [ CONTEXT_MENU_PROVIDERS ] +}) +export class Ng2ActivitiProcesslistComponent implements OnInit { + + errorMessage: string; + processInstances: ProcessInstance[]; + data: ObjectDataTableAdapter; + + constructor ( + private processService: ActivitiProcessService, + private translate: AlfrescoTranslationService + ) { + if (translate !== null) { + translate.addTranslationFolder('node_modules/ng2-activiti-processlist'); + } + } + + ngOnInit() { + this.getProcesses(); + } + + getProcesses() { + this.processService.getProcesses() + .subscribe( + (processInstances) => { + // this.processInstances = processInstances; + this.data = new ObjectDataTableAdapter( + processInstances, + [ + {type: 'text', key: 'id', title: 'Id', sortable: true}, + {type: 'text', key: 'name', title: 'Name', cssClass: 'full-width name-column', sortable: true}, + {type: 'text', key: 'started', title: 'Started', sortable: true}, + {type: 'text', key: 'startedBy.email', title: 'Started By', sortable: true} + ] + ); + }, + error => this.errorMessage = error); + } + + onItemClick(processInstance: ProcessInstance, event: any) { + console.log(processInstance, event); + } + +} diff --git a/ng2-components/ng2-activiti-processlist/src/models/process-instance.ts b/ng2-components/ng2-activiti-processlist/src/models/process-instance.ts new file mode 100644 index 0000000000..1511e557be --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/src/models/process-instance.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 ProcessInstance { + + public businessKey: string; + public ended: any; + public graphicalNotationDefined: boolean; + public id: string; + public name: string; + public processDefinitionCategory: string; + public processDefinitionDeploymentId: string; + public processDefinitionDescription: string; + public processDefinitionId: string; + public processDefinitionKey: string; + public processDefinitionName: string; + public processDefinitionVersion: number; + public startFormDefined: boolean; + public started: string; + public startedBy: any; + public suspended: boolean; + public tenantId: string; + public variables: any; + +} diff --git a/ng2-components/ng2-activiti-processlist/src/services/activiti-process-service.service.spec.ts b/ng2-components/ng2-activiti-processlist/src/services/activiti-process-service.service.spec.ts new file mode 100644 index 0000000000..94b6b660f2 --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/src/services/activiti-process-service.service.spec.ts @@ -0,0 +1,74 @@ +/*! + * @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 { + it, + describe, + expect, + beforeEachProviders, + inject +} from '@angular/core/testing'; +import { + Response, + ResponseOptions, + HTTP_PROVIDERS, + XHRBackend +} from '@angular/http'; +import { MockBackend, MockConnection } from '@angular/http/testing'; +import { AlfrescoSettingsService } from 'ng2-alfresco-core'; +import { ActivitiProcessService } from './activiti-process-service.service'; +import { ProcessInstance } from '../models/process-instance'; + +describe('ActivitiProcessService', () => { + + beforeEachProviders(() => { + return [ + HTTP_PROVIDERS, + { provide: XHRBackend, useClass: MockBackend }, + ActivitiProcessService, + AlfrescoSettingsService + ]; + }); + + it('should be there', inject([ActivitiProcessService], (processService: ActivitiProcessService) => { + expect(typeof processService.getProcesses).toBe('function'); + })); + + it('should get process instances', + inject([ActivitiProcessService, XHRBackend], (processService: ActivitiProcessService, mockBackend: MockBackend) => { + mockBackend.connections.subscribe( + (connection: MockConnection) => { + connection.mockRespond(new Response( + new ResponseOptions({ + body: { + data: [{ + id: 'myprocess:1', + name: 'my process' + }] + } + }))); + }); + + processService.getProcesses().subscribe((instances: ProcessInstance[]) => { + expect(instances.length).toBe(1); + expect(instances[0].id).toBe('myprocess:1'); + expect(instances[0].name).toBe('my process'); + }); + + })); + +}); diff --git a/ng2-components/ng2-activiti-processlist/src/services/activiti-process-service.service.ts b/ng2-components/ng2-activiti-processlist/src/services/activiti-process-service.service.ts new file mode 100644 index 0000000000..3d6161aabe --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/src/services/activiti-process-service.service.ts @@ -0,0 +1,61 @@ +/*! + * @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 { + AlfrescoSettingsService +} from 'ng2-alfresco-core'; +import { ProcessInstance } from '../models/process-instance'; +import { Injectable } from '@angular/core'; +import { Http, Response, RequestOptions, Headers } from '@angular/http'; +import { Observable } from 'rxjs/Observable'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/catch'; + +@Injectable() +export class ActivitiProcessService { + + private processesUrl = 'http://localhost:9999/activiti-app/api/enterprise/process-instances/query'; + + constructor(private alfrescoSettingsService: AlfrescoSettingsService, private http: Http) { + } + + getProcesses(): Observable { + let headers = new Headers(); + headers.append('Content-Type', 'application/json'); + // headers.append('Authorization', 'Basic ' + btoa('admin@app.activiti.com:admin')); + return this.http.post( + this.processesUrl, + '{"page":0,"sort":"created-desc","state":"all"}', + new RequestOptions({ + headers: headers + })) + .map(this.extractData) + .catch(this.handleError); + } + + private extractData(res: Response) { + let body = res.json(); + return body.data || { }; + } + + private handleError(error: any) { + let errMsg = (error.message) ? error.message : + error.status ? `${error.status} - ${error.statusText}` : 'Server error'; + console.error(errMsg); // log to console instead + return Observable.throw(errMsg); + } +} diff --git a/ng2-components/ng2-activiti-processlist/tsconfig.json b/ng2-components/ng2-activiti-processlist/tsconfig.json new file mode 100644 index 0000000000..e4d2ae201a --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/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-activiti-processlist/tslint.json b/ng2-components/ng2-activiti-processlist/tslint.json new file mode 100644 index 0000000000..33220e5038 --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/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-activiti-processlist/typings.json b/ng2-components/ng2-activiti-processlist/typings.json new file mode 100644 index 0000000000..7e0e18568d --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/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-datatable/demo/package.json b/ng2-components/ng2-alfresco-datatable/demo/package.json index 5396ef02ef..00bbf0a050 100644 --- a/ng2-components/ng2-alfresco-datatable/demo/package.json +++ b/ng2-components/ng2-alfresco-datatable/demo/package.json @@ -42,10 +42,7 @@ "material-design-icons": "2.2.3", "material-design-lite": "1.1.3", - "ng2-translate": "2.2.2", - - "ng2-alfresco-datatable": "^0.1.12", - "ng2-alfresco-core": "^0.1.36" + "ng2-activiti-processlist": "^0.1.0" }, "devDependencies": { "browser-sync": "2.10.0",