diff --git a/BROWSER-SUPPORT.md b/BROWSER-SUPPORT.md index 81fc161283..1b5bd199a3 100644 --- a/BROWSER-SUPPORT.md +++ b/BROWSER-SUPPORT.md @@ -39,13 +39,12 @@ ADF (demo shell) imports by default the following set of recommended polyfills: - - + diff --git a/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts b/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts index 19fcc8b356..012fb544a9 100644 --- a/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts +++ b/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts @@ -19,7 +19,6 @@ import { Component, AfterViewChecked, ViewChild, Input } from '@angular/core'; import { AppDefinitionRepresentationModel, FilterRepresentationModel, - UserTaskFilterRepresentationModel, ActivitiApps, ActivitiTaskList } from 'ng2-activiti-tasklist'; @@ -153,7 +152,7 @@ export class ActivitiDemoComponent implements AfterViewChecked { this.activititasklist.reload(); } - onSuccessTaskList(event: UserTaskFilterRepresentationModel) { + onSuccessTaskList(event: FilterRepresentationModel) { this.currentTaskId = this.activititasklist.getCurrentTaskId(); } diff --git a/demo-shell-ng2/app/img/admin.jpeg b/demo-shell-ng2/app/img/admin.jpeg deleted file mode 100644 index 0efd7dbd02..0000000000 Binary files a/demo-shell-ng2/app/img/admin.jpeg and /dev/null differ diff --git a/demo-shell-ng2/app/img/anonymous.gif b/demo-shell-ng2/app/img/anonymous.gif deleted file mode 100644 index e1b58fa57d..0000000000 Binary files a/demo-shell-ng2/app/img/anonymous.gif and /dev/null differ diff --git a/demo-shell-ng2/app/img/background.jpg b/demo-shell-ng2/app/img/background.jpg deleted file mode 100644 index 792f58a231..0000000000 Binary files a/demo-shell-ng2/app/img/background.jpg and /dev/null differ diff --git a/demo-shell-ng2/app/img/blank.gif b/demo-shell-ng2/app/img/blank.gif deleted file mode 100644 index e565824aaf..0000000000 Binary files a/demo-shell-ng2/app/img/blank.gif and /dev/null differ diff --git a/demo-shell-ng2/app/img/checklist.svg b/demo-shell-ng2/app/img/checklist.svg deleted file mode 100644 index 603b46fef5..0000000000 --- a/demo-shell-ng2/app/img/checklist.svg +++ /dev/null @@ -1,782 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/demo-shell-ng2/app/img/completed.svg b/demo-shell-ng2/app/img/completed.svg deleted file mode 100644 index 84f75fa8a2..0000000000 --- a/demo-shell-ng2/app/img/completed.svg +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - diff --git a/demo-shell-ng2/app/img/createvisit.jpg b/demo-shell-ng2/app/img/createvisit.jpg deleted file mode 100644 index 7505e347e4..0000000000 Binary files a/demo-shell-ng2/app/img/createvisit.jpg and /dev/null differ diff --git a/demo-shell-ng2/app/img/users.png b/demo-shell-ng2/app/img/users.png deleted file mode 100644 index b1cca051a4..0000000000 Binary files a/demo-shell-ng2/app/img/users.png and /dev/null differ diff --git a/demo-shell-ng2/app/img/visit.jpg b/demo-shell-ng2/app/img/visit.jpg deleted file mode 100644 index b07d287404..0000000000 Binary files a/demo-shell-ng2/app/img/visit.jpg and /dev/null differ diff --git a/demo-shell-ng2/app/img/visitor.jpg b/demo-shell-ng2/app/img/visitor.jpg deleted file mode 100644 index 813426332c..0000000000 Binary files a/demo-shell-ng2/app/img/visitor.jpg and /dev/null differ diff --git a/demo-shell-ng2/i18n/en.json b/demo-shell-ng2/i18n/en.json index 1a35a1e670..1993786440 100644 --- a/demo-shell-ng2/i18n/en.json +++ b/demo-shell-ng2/i18n/en.json @@ -57,7 +57,7 @@ "LOGIN-SUCCESS": "Login successful" }, "BUTTON": { - "LOGIN": "MARIO" + "LOGIN": "Login" }, "ACTION": { "HELP": "NEED HELP?", diff --git a/demo-shell-ng2/package.json b/demo-shell-ng2/package.json index 74ba38c520..1a8aaf5904 100644 --- a/demo-shell-ng2/package.json +++ b/demo-shell-ng2/package.json @@ -87,7 +87,7 @@ "ng2-alfresco-datatable": "0.3.2", "ng2-alfresco-documentlist": "0.3.2", "ng2-alfresco-login": "0.3.2", - "ng2-alfresco-search": "0.3.2", + "ng2-alfresco-search": "0.3.3", "ng2-alfresco-upload": "0.3.2", "ng2-alfresco-viewer": "0.3.2", "ng2-activiti-form": "0.3.3", diff --git a/ng2-components/README.md b/ng2-components/README.md index b31c28df84..4d8702dd16 100644 --- a/ng2-components/README.md +++ b/ng2-components/README.md @@ -76,7 +76,7 @@ npm run build:w ``` -3. Move inside the demo folder and link the component to the local node_modules folder. +3. From another terminal move inside the demo sub folder and link the component to the local node_modules folder. ```sh cd demo diff --git a/ng2-components/ng2-activiti-analytics/.npmignore b/ng2-components/ng2-activiti-analytics/.npmignore index 16ba3e61e5..c5ca623298 100644 --- a/ng2-components/ng2-activiti-analytics/.npmignore +++ b/ng2-components/ng2-activiti-analytics/.npmignore @@ -1,7 +1,6 @@ npm-debug.log .idea -assets/ coverage/ node_modules typings/ diff --git a/ng2-components/ng2-activiti-analytics/README.md b/ng2-components/ng2-activiti-analytics/README.md index ad7db61552..166bf6e17c 100644 --- a/ng2-components/ng2-activiti-analytics/README.md +++ b/ng2-components/ng2-activiti-analytics/README.md @@ -1,4 +1,35 @@ # Activiti Analytics Component for Angular 2 +

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

## Prerequisites @@ -7,98 +38,228 @@ necessary configuration, see this [page](https://github.com/Alfresco/alfresco-ng ## Install -```sh -npm install --save ng2-activiti-analytics -``` +Follow the 3 steps below: -#### Ng2-Charts +1. Npm -```sh -npm install ng2-charts chart.js --save -``` + ```sh + npm install ng2-activiti-analytics --save + ``` -Also make sure you include these dependencies in your `index.html` file: +2. Html -```html + Include these dependencies in your index.html page: + + ```html + + -``` + -#### Moment - -```sh -npm install moment --save -``` - -Also make sure you include these dependencies in your `index.html` file: - -```html + -``` - -#### Material Design Date picker - -```sh -npm install md-date-time-picker --save -``` - -Also make sure you include these dependencies in your `index.html` file: - -```html + -``` + + -#### Material Design Lite + + + + -The style of this component is based on [material design](https://getmdl.io/), so if you want to visualize it correctly you have to add the material -design dependency to your project: + + + -```sh -npm install --save material-design-icons material-design-lite -``` + + + + -Also make sure you include these dependencies in your `index.html` file: + + + + -```html - - - - -``` + + + + + ``` + +3. SystemJs + + Add the following components to your systemjs.config.js file: + + - moment + - ng2-charts + - ng2-translate + - alfresco-js-api + - ng2-alfresco-core + - ng2-activiti-diagrams + - ng2-activiti-analytics + + Please refer to the following example file: [systemjs.config.js](demo/systemjs + .config.js) . ## Basic usage example Activiti Analytics List + The component shows the list of all the available reports + ```html ``` +Usage example of this component : + +**main.ts** +```ts + +import { NgModule, Component } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { CoreModule, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; +import { AnalyticsModule } from 'ng2-activiti-analytics'; + +@Component({ + selector: 'activiti-analytics-demo', + template: ` +
+
+
+ +
+
+
` +}) + +export class AnalyticsDemoComponent { + + constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) { + settingsService.bpmHost = 'http://localhost:9999'; + + this.authService.login('admin', 'admin').subscribe( + ticket => { + console.log(ticket); + }, + error => { + console.log(error); + }); + } +} + +@NgModule({ + imports: [ + BrowserModule, + CoreModule.forRoot(), + AnalyticsModule + ], + declarations: [ AnalyticsDemoComponent ], + bootstrap: [ AnalyticsDemoComponent ] +}) +export class AppModule { } + +platformBrowserDynamic().bootstrapModule(AppModule); + + +``` + #### Events -**onSuccess**: The event is emitted when the report list are loaded
-**onError**: The event is emitted when an error occur during the loading
-**reportClick**: The event is emitted when the report in the list is selected
+ +| Name | Description | +| --- | --- | +|`onSuccess`| The event is emitted when the report list are loaded | +|`onError`| The event is emitted when an error occur during the loading | +|`reportClick`| The event is emitted when the report in the list is selected | #### Options + No options. ## Basic usage example Activiti Analytics + The component shows the charts related to the reportId passed as input + ```html ``` +Example of an App that use Activiti Analytics component : + +**main.ts** +```ts + +import { NgModule, Component } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { CoreModule, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; +import { AnalyticsModule } from 'ng2-activiti-analytics'; + +@Component({ + selector: 'activiti-analytics-demo', + template: ` +
+
+
+ +
+
+
` +}) + +export class AnalyticsDemoComponent { + + constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) { + settingsService.bpmHost = 'http://localhost:9999'; + + this.authService.login('admin', 'admin').subscribe( + ticket => { + console.log(ticket); + }, + error => { + console.log(error); + }); + } +} + +@NgModule({ + imports: [ + BrowserModule, + CoreModule.forRoot(), + AnalyticsModule + ], + declarations: [ AnalyticsDemoComponent ], + bootstrap: [ AnalyticsDemoComponent ] +}) +export class AppModule { } + +platformBrowserDynamic().bootstrapModule(AppModule); + + +``` + #### Events -**onSuccess**: The event is emitted when the report parameters are loaded
-**onError**: The event is emitted when an error occur during the loading
+ +| Name | Description | +| --- | --- | +|`onSuccess` | The event is emitted when the report parameters are loaded | +|`onError` | The event is emitted when an error occur during the loading | #### Options -**appId**: The application id
-**reportId**: The report id
-**debug**: Flag to enable or disable the Form values in the console log
+ +| Name | Description | +| --- | --- | +|`appId` | The application id | +|`reportId` | The report id | +|`debug` | Flag to enable or disable the Form values in the console log | ## Build from sources Alternatively you can build component from sources with the following commands: + ```sh npm install npm run build @@ -110,7 +271,7 @@ npm run build $ npm run build:w ``` -### Running unit tests +## Running unit tests ```sh npm test @@ -130,3 +291,27 @@ before performing unit testing. ```sh npm run coverage ``` + +## Demo + +If you want have a demo of how the component works, please check the demo folder : + +```sh +cd demo +npm install +npm start +``` + +## 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 | + +## License + +[Apache Version 2.0](https://github.com/Alfresco/alfresco-ng2-components/blob/master/LICENSE) diff --git a/ng2-components/ng2-activiti-analytics/demo/index.html b/ng2-components/ng2-activiti-analytics/demo/index.html index 8d5e80fe31..05273a659d 100644 --- a/ng2-components/ng2-activiti-analytics/demo/index.html +++ b/ng2-components/ng2-activiti-analytics/demo/index.html @@ -6,40 +6,54 @@ Alfresco Angular 2 Activiti Analytics - Demo + + + + + + + + + + + + - - - + + + + + + + + + + + + + - - - - - - - - - + - + diff --git a/ng2-components/ng2-activiti-analytics/demo/package.json b/ng2-components/ng2-activiti-analytics/demo/package.json index 2b61ee35e2..f831c48cc3 100644 --- a/ng2-components/ng2-activiti-analytics/demo/package.json +++ b/ng2-components/ng2-activiti-analytics/demo/package.json @@ -37,29 +37,32 @@ "@angular/http": "2.0.0", "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", - "@angular/upgrade": "2.0.0", - "@types/node": "^6.0.42", "core-js": "^2.4.1", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.12", "systemjs": "0.19.27", "zone.js": "^0.6.23", - "md-date-time-picker": "^2.2.0", - "raphael": "^2.2.6", + + "intl": "1.2.4", + "dialog-polyfill": "^0.4.3", + "element.scrollintoviewifneeded-polyfill": "^1.0.1", "material-design-icons": "2.2.3", "material-design-lite": "1.2.1", + + "chart.js": "^2.1.4", + "md-date-time-picker": "^2.2.0", + "ng2-charts": "1.1.0", + "moment": "2.15.1", + "raphael": "^2.2.6", + "ng2-translate": "2.5.0", "alfresco-js-api": "^0.3.0", - "ng2-alfresco-core": "^0.3.0", - "ng2-activiti-diagrams": "^0.3.0", - "ng2-activiti-analytics": "^0.3.0", - "chart.js": "^2.1.4", - "moment": "2.15.1", - "md-date-time-picker": "^2.2.0", - "ng2-charts": "1.1.0" + "ng2-alfresco-core": "0.3.2", + "ng2-activiti-diagrams": "0.3.3", + "ng2-activiti-analytics": "^0.3.0" }, "devDependencies": { + "@types/node": "^6.0.42", "@types/core-js": "^0.9.32", "@types/jasmine": "^2.2.33", "concurrently": "^2.2.0", @@ -68,4 +71,4 @@ "typescript": "^2.0.3", "wsrv": "^0.1.5" } -} \ No newline at end of file +} diff --git a/ng2-components/ng2-activiti-analytics/demo/src/main.ts b/ng2-components/ng2-activiti-analytics/demo/src/main.ts index 9afbee493b..b897f7cb7b 100644 --- a/ng2-components/ng2-activiti-analytics/demo/src/main.ts +++ b/ng2-components/ng2-activiti-analytics/demo/src/main.ts @@ -15,16 +15,25 @@ * limitations under the License. */ -import { NgModule, Component } from '@angular/core'; +import { NgModule, Component, OnInit } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; - -import { CoreModule } from 'ng2-alfresco-core'; +import { CoreModule, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; import { AnalyticsModule } from 'ng2-activiti-analytics'; @Component({ - selector: 'activiti-analytics-demo', + selector: 'alfresco-app-demo', template: ` +
+
+
+

+
+ Authentication failed to ip {{ host }} with user: admin, admin, you can still try to add a valid ticket to perform + operations. +
+
+

@@ -39,14 +48,56 @@ import { AnalyticsModule } from 'ng2-activiti-analytics';
` }) -export class AnalyticsDemoComponent { +export class AnalyticsDemoComponent implements OnInit { appId: number; + report: any; + authenticated: boolean; + + host: string = 'http://localhost:9999'; + + ticket: string; + + constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) { + settingsService.bpmHost = this.host; + settingsService.setProviders('BPM'); + + if (this.authService.getTicketBpm()) { + this.ticket = this.authService.getTicketBpm(); + } + } + onReportClick(event: any) { this.report = event; } + + public updateTicket(): void { + localStorage.setItem('ticket-BPM', this.ticket); + } + + public updateHost(): void { + this.settingsService.bpmHost = this.host; + this.login(); + } + + public ngOnInit(): void { + this.login(); + } + + login() { + this.authService.login('admin', 'admin').subscribe( + ticket => { + console.log(ticket); + this.ticket = this.authService.getTicketBpm(); + this.authenticated = true; + }, + error => { + console.log(error); + this.authenticated = false; + }); + } } @NgModule({ @@ -55,9 +106,10 @@ export class AnalyticsDemoComponent { CoreModule.forRoot(), AnalyticsModule ], - declarations: [ AnalyticsDemoComponent ], - bootstrap: [ AnalyticsDemoComponent ] + declarations: [AnalyticsDemoComponent], + bootstrap: [AnalyticsDemoComponent] }) -export class AppModule { } +export class AppModule { +} platformBrowserDynamic().bootstrapModule(AppModule); diff --git a/ng2-components/ng2-activiti-analytics/package.json b/ng2-components/ng2-activiti-analytics/package.json index 211d73bf08..86e2311b07 100644 --- a/ng2-components/ng2-activiti-analytics/package.json +++ b/ng2-components/ng2-activiti-analytics/package.json @@ -48,42 +48,48 @@ "@angular/http": "2.0.0", "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", - "@angular/upgrade": "2.0.0", - "@types/node": "^6.0.42", - "alfresco-js-api": "^0.3.0", - "moment": "2.15.1", - "chart.js": "^2.1.4", "core-js": "^2.4.1", - "md-date-time-picker": "^2.2.0", - "ng2-alfresco-core": "0.3.2", - "ng2-activiti-diagrams": "0.3.3", - "ng2-charts": "1.1.0", - "ng2-translate": "2.5.0", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.12", "systemjs": "0.19.27", - "zone.js": "^0.6.23" + "zone.js": "^0.6.23", + + "intl": "1.2.4", + "dialog-polyfill": "^0.4.3", + "element.scrollintoviewifneeded-polyfill": "^1.0.1", + "material-design-icons": "2.2.3", + "material-design-lite": "1.2.1", + + "chart.js": "^2.1.4", + "md-date-time-picker": "^2.2.0", + "ng2-charts": "1.1.0", + "moment": "2.15.1", + "raphael": "^2.2.6", + + "alfresco-js-api": "^0.3.0", + "ng2-translate": "2.5.0", + "ng2-alfresco-core": "0.3.2", + "ng2-activiti-diagrams": "0.3.3" }, "devDependencies": { + "@types/node": "^6.0.42", "@types/core-js": "^0.9.32", "@types/jasmine": "^2.2.33", "concurrently": "^2.2.0", - "cpx": "^1.3.1", - "jasmine-ajax": "^3.2.0", + "cpx": "1.3.1", "jasmine-core": "2.4.1", - "karma": "~0.13.22", - "karma-chrome-launcher": "~1.0.1", - "karma-coverage": "^1.0.0", - "karma-jasmine": "~1.0.2", + "karma": "0.13.22", + "karma-chrome-launcher": "1.0.1", + "karma-coverage": "1.0.0", + "karma-jasmine": "1.0.2", "karma-jasmine-ajax": "^0.1.13", - "karma-jasmine-html-reporter": "^0.2.0", - "karma-mocha-reporter": "^2.0.3", - "license-check": "^1.0.4", - "remap-istanbul": "^0.6.3", + "karma-mocha-reporter": "2.0.3", + "karma-jasmine-html-reporter": "0.2.0", + "license-check": "1.1.5", + "remap-istanbul": "0.6.3", "rimraf": "2.5.2", - "traceur": "^0.0.91", - "tslint": "^3.8.1", + "traceur": "0.0.91", + "tslint": "3.15.1", "typescript": "^2.0.3", "wsrv": "^0.1.5" }, diff --git a/ng2-components/ng2-activiti-diagrams/.npmignore b/ng2-components/ng2-activiti-diagrams/.npmignore index 16ba3e61e5..c5ca623298 100644 --- a/ng2-components/ng2-activiti-diagrams/.npmignore +++ b/ng2-components/ng2-activiti-diagrams/.npmignore @@ -1,7 +1,6 @@ npm-debug.log .idea -assets/ coverage/ node_modules typings/ diff --git a/ng2-components/ng2-activiti-diagrams/README.md b/ng2-components/ng2-activiti-diagrams/README.md index 051beeca29..5192d5647a 100644 --- a/ng2-components/ng2-activiti-diagrams/README.md +++ b/ng2-components/ng2-activiti-diagrams/README.md @@ -1,4 +1,35 @@ # Activiti Diagrams Component for Angular 2 +

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

## Prerequisites @@ -7,71 +38,137 @@ necessary configuration, see this [page](https://github.com/Alfresco/alfresco-ng ## Install -```sh -npm install --save ng2-activiti-diagrams -``` +Follow the 3 steps below: +1. Npm -### Dependencies + ```sh + npm install ng2-activiti-diagrams --save + ``` -Add the following dependency to your index.html: +2. Html -```html - -``` + Include these dependencies in your index.html page: -The following component needs to be added to your `systemjs.config.js` file: + ```html -- [ng2-alfresco-core](https://www.npmjs.com/package/ng2-alfresco-core) - -#### raphael - -```sh -npm install raphael --save -``` - -Also make sure you include these dependencies in your `index.html` file: - -```html + -``` + + -#### Material Design Lite + + + + -The style of this component is based on [material design](https://getmdl.io/), so if you want to visualize it correctly you have to add the material -design dependency to your project: + + + -```sh -npm install --save material-design-icons material-design-lite -``` + + + + -Also make sure you include these dependencies in your `index.html` file: + + + + -```html - - - - -``` + + + + + + ``` + +3. SystemJs + + Add the following components to your systemjs.config.js file: + + - ng2-translat + - ng2-alfresco-core + - alfresco-js-api + - ng2-activiti-diagrams + - raphael + + Please refer to the following example file: [systemjs.config.js](demo/systemjs + .config.js) . ## Basic usage example Activiti Diagrams -The component shows the diagram of the input process. + +This component shows the diagram of a process. + ```html ``` -#### Events -**onSuccess**: The event is emitted when the diagrams element are loaded +Usage example of this component : -**onError**: The event is emitted when the an error occur during the loading +**main.ts** +```ts + +import { NgModule, Component } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; + +import { CoreModule, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; +import { DiagramsModule } from 'ng2-activiti-diagrams'; + +@Component({ + selector: 'activiti-diagrams-demo', + template: `` +}) + +export class DiagramDemoComponent { + + constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) { + settingsService.bpmHost = 'http://localhost:9999'; + + this.authService.login('admin', 'admin').subscribe( + ticket => { + console.log(ticket); + }, + error => { + console.log(error); + }); + } +} + +@NgModule({ + imports: [ + BrowserModule, + CoreModule.forRoot(), + DiagramsModule + ], + declarations: [ DiagramDemoComponent ], + bootstrap: [ DiagramDemoComponent ] +}) +export class AppModule { } + +platformBrowserDynamic().bootstrapModule(AppModule); + +``` + +#### Events + +| Name | Description | +| --- | --- | +| `onSuccess` | The event is emitted when the diagrams element are loaded | +| `onError` | The event is emitted when the an error occur during the loading | #### Options -**metricPercentages** The array that contains the percentage of the time for each element + +| Name | Description | +| --- | --- | +| `metricPercentage` | The array that contains the percentage of the time for each element | ## Build from sources Alternatively you can build component from sources with the following commands: + ```sh npm install npm run build @@ -83,7 +180,7 @@ npm run build $ npm run build:w ``` -### Running unit tests +## Running unit tests ```sh npm test @@ -103,3 +200,27 @@ before performing unit testing. ```sh npm run coverage ``` + +## Demo + +If you want have a demo of how the component works, please check the demo folder : + +```sh +cd demo +npm install +npm start +``` + +## 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 | + +## License + +[Apache Version 2.0](https://github.com/Alfresco/alfresco-ng2-components/blob/master/LICENSE) \ No newline at end of file diff --git a/ng2-components/ng2-activiti-diagrams/demo/index.html b/ng2-components/ng2-activiti-diagrams/demo/index.html index 96d17103f3..78a50121bb 100644 --- a/ng2-components/ng2-activiti-diagrams/demo/index.html +++ b/ng2-components/ng2-activiti-diagrams/demo/index.html @@ -6,23 +6,35 @@ Alfresco Angular 2 Activiti Diagrams - Demo + + + + + - - + + + + + + + + + + + + + - - - - -``` +2. Html -You must separately install the following libraries for your application: - -- [ng2-translate](https://github.com/ocombe/ng2-translate) -- [ng2-alfresco-core](https://www.npmjs.com/package/ng2-alfresco-core) + Include these dependencies in your index.html page: -```sh -npm install --save ng2-translate ng2-alfresco-core -``` + ```html -#### Material Design Lite + + -The style of this component is based on [material design](https://getmdl.io/), so if you want to visualize it correctly you have to add the material -design dependency to your project: + + + + -```sh -npm install --save material-design-icons material-design-lite -``` + + + + -Also make sure you include these dependencies in your `index.html` file: + + + -```html - - - - -``` -#### Dialogs Polyfill + + + + -To make the dialog working with all the browser you have to add the dialog polyfill to you project: + + + + -```sh -npm install --save dialog-polyfill -``` + + + + + ``` -Also make sure you include these dependencies in your `index.html` file: +3. SystemJs -```html - - - - -``` + Add the following components to your systemjs.config.js file: + + - moment + - ng2-translate + - ng2-alfresco-core + - alfresco-js-api + - ng2-activiti-form + + Please refer to the following example file: [systemjs.config.js](demo/systemjs + .config.js) . ## Basic usage examples +The component shows a Form from Activiti + +```html + +``` + +Usage example of this component : + +**main.ts** +```ts + +import { NgModule, Component } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { CoreModule, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; +import { ActivitiFormModule } from 'ng2-activiti-form'; + +@Component({ + selector: 'activiti-app-demo', + template: `` +}) + +export class FormDemoComponent { + + constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) { + settingsService.bpmHost = 'http://localhost:9999'; + + this.authService.login('admin', 'admin').subscribe( + ticket => { + console.log(ticket); + }, + error => { + console.log(error); + }); + } +} + +@NgModule({ + imports: [ + BrowserModule, + CoreModule.forRoot(), + ActivitiFormModule.forRoot() + ], + declarations: [FormDemoComponent], + bootstrap: [FormDemoComponent] +}) +export class AppModule { +} + +platformBrowserDynamic().bootstrapModule(AppModule); + + +``` + ### Display form instance by task id ```html @@ -138,42 +224,38 @@ The recommended set of properties can be found in the following table: | Name | Type | Default | Description | | --- | --- | --- | --- | -| taskId | string | | Task id to fetch corresponding form and values. | -| formId | string | | The id of the form definition to load and display with custom values. | -| formName | string | | Name of hte form definition to load and display with custom values. | -| data | `FormValues` | | Custom form values map to be used with the rendered form. | -| showTitle | boolean | true | Toggle rendering of the form title. | -| showCompleteButton | boolean | true | Toggle rendering of the `Complete` outcome button. | -| showSaveButton | boolean | true | Toggle rendering of the `Save` outcome button. | -| showDebugButton | boolean | false | Toggle debug options. | -| readOnly | boolean | false | Toggle readonly state of the form. Enforces all form widgets render readonly if enabled. | -| showRefreshButton | boolean | true | Toggle rendering of the `Refresh` button. | -| saveMetadata | boolean | false | Store the value of the form as metadata. | -| path | string | | Path of the folder where to store the metadata. | -| nameNode (optional) | string | true | Name to assign to the new node where the metadata are stored. | +| `taskId` | string | | Task id to fetch corresponding form and values. | +| `formId` | string | | The id of the form definition to load and display with custom values. | +| `formName` | string | | Name of hte form definition to load and display with custom values. | +| `data` | FormValues | | Custom form values map to be used with the rendered form. | +| `showTitle` | boolean | true | Toggle rendering of the form title. | +| `showCompleteButton` | boolean | true | Toggle rendering of the `Complete` outcome button. | +| `showSaveButton` | boolean | true | Toggle rendering of the `Save` outcome button. | +| `showDebugButton` | boolean | false | Toggle debug options. | +| `readOnly` | boolean | false | Toggle readonly state of the form. Enforces all form widgets render readonly if enabled. | +| `showRefreshButton` | boolean | true | Toggle rendering of the `Refresh` button. | +| `saveMetadata` | boolean | false | Store the value of the form as metadata. | +| `path` | string | | Path of the folder where to store the metadata. | +| `nameNode` (optional) | string | true | Name to assign to the new node where the metadata are stored. | - - * {path} string - path of the folder where the to store the metadata - * - * {nameNode} string (optional) - name of the node stored, if not defined the node will be sotred with an uuid as name #### Advanced properties The following properties are for complex customisation purposes: | Name | Type | Default | Description | | --- | --- | --- | --- | -| form | `FormModel` | | Underlying form model instance. | -| debugMode | boolean | false | Toggle debug mode, allows displaying additional data for development and debugging purposes. | +| `form` | FormModel | | Underlying form model instance. | +| `debugMode` | boolean | false | Toggle debug mode, allows displaying additional data for development and debugging purposes. | ### Events | Name | Description | | --- | --- | -| formLoaded | Invoked when form is loaded or reloaded. | -| formSaved | Invoked when form is submitted with `Save` or custom outcomes. | -| formCompleted | Invoked when form is submitted with `Complete` outcome. | -| executeOutcome | Invoked when any outcome is executed, default behaviour can be prevented via `event.preventDefault()` | -| onError | Invoked at any error | +| `formLoaded` | Invoked when form is loaded or reloaded. | +| `formSaved` | Invoked when form is submitted with `Save` or custom outcomes. | +| `formCompleted` | Invoked when form is submitted with `Complete` outcome. | +| `executeOutcome` | Invoked when any outcome is executed, default behaviour can be prevented via `event.preventDefault()` | +| `onError` | Invoked at any error | All `form*` events receive an instance of the `FormModel` as event argument for ease of development: @@ -242,46 +324,11 @@ There are two additional functions that can be of a great value when controlling **Please note that if `event.preventDefault()` is not called then default outcome behaviour will also be executed after your custom code.** -## Supported form widgets - -Form renderer provides support for all basic widgets: - -- [x] Tabs -- [x] Text -- [x] Multiline Text -- [x] Number -- [x] Checkbox -- [x] Date -- Dropdown - * [x] Manual - * [x] REST service -- [x] Typeahead -- [x] Amount -- Radio buttons - * [x] Manual - * [x] REST service -- [x] People -- [x] Group of People -- [x] Dynamic Table -- [x] Hyperlink -- Header - * [x] Plain header - * [x] Collapsible header -- [x] Attach file ** -- [x] Display value -- [x] Display text - -** Files may be uploaded from a user's device if the file source selected is -'Local file' or 'All sources' and 'link to files' is not selected. Alternatively -you can link to files in a configured Alfresco repository by selecting this source -explicitly from the list and making sure that 'link to files' is selected. Copying -files from Alfresco into Activiti via the control (no linking) is not currently -supported, nor is allowing the user to choose between more than one source. - ## Build from sources Alternatively you can build component from sources with the following commands: + ```sh npm install npm run build @@ -293,7 +340,7 @@ npm run build $ npm run build:w ``` -### Running unit tests +## Running unit tests ```sh npm test @@ -313,3 +360,27 @@ before performing unit testing. ```sh npm run coverage ``` + +## Demo + +If you want have a demo of how the component works, please check the demo folder : + +```sh +cd demo +npm install +npm start +``` + +## 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 | + +## License + +[Apache Version 2.0](https://github.com/Alfresco/alfresco-ng2-components/blob/master/LICENSE) diff --git a/ng2-components/ng2-activiti-form/demo/.gitignore b/ng2-components/ng2-activiti-form/demo/.gitignore new file mode 100644 index 0000000000..25beca4c27 --- /dev/null +++ b/ng2-components/ng2-activiti-form/demo/.gitignore @@ -0,0 +1,6 @@ +node_modules +.idea +coverage +dist +typings +!systemjs.config.js diff --git a/ng2-components/ng2-activiti-form/demo/.npmignore b/ng2-components/ng2-activiti-form/demo/.npmignore new file mode 100644 index 0000000000..c51c008259 --- /dev/null +++ b/ng2-components/ng2-activiti-form/demo/.npmignore @@ -0,0 +1,3 @@ +node_modules +dist +typings \ No newline at end of file diff --git a/ng2-components/ng2-activiti-form/demo/README.md b/ng2-components/ng2-activiti-form/demo/README.md new file mode 100644 index 0000000000..3ff7a9b658 --- /dev/null +++ b/ng2-components/ng2-activiti-form/demo/README.md @@ -0,0 +1,13 @@ +# Activiti Form demo + +Install: + +``` +npm install +``` + +Run the project: + +``` +npm start +``` \ No newline at end of file diff --git a/ng2-components/ng2-activiti-form/demo/index.html b/ng2-components/ng2-activiti-form/demo/index.html new file mode 100644 index 0000000000..e56ebeef76 --- /dev/null +++ b/ng2-components/ng2-activiti-form/demo/index.html @@ -0,0 +1,55 @@ + + + + + + Alfresco Angular 2 Activiti Form - Demo + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-activiti-form/demo/package.json b/ng2-components/ng2-activiti-form/demo/package.json new file mode 100644 index 0000000000..f89a397641 --- /dev/null +++ b/ng2-components/ng2-activiti-form/demo/package.json @@ -0,0 +1,70 @@ +{ + "name": "ng2-activiti-form-demo", + "description": "Alfresco Activiti Form Component - Demo", + "version": "0.1.0", + "author": "Alfresco Software, Ltd.", + "main": "index.js", + "scripts": { + "clean": "npm install rimraf && rimraf dist node_modules typings dist", + "postinstall": "npm run build", + "start": "npm run build && concurrently \"npm run tsc:w\" \"npm run server\" ", + "server": "wsrv -o -s -l", + "build": "npm run tslint && rimraf dist && tsc", + "build:w": "npm run tslint && rimraf dist && tsc -w", + "tsc": "tsc", + "tsc:w": "tsc -w", + "tslint": "tslint -c tslint.json *.ts && tslint -c tslint.json src/{,**/}**.ts" + }, + "license": "Apache-2.0", + "contributors": [ + { + "name": "Mario Romano", + "email": "mario.romano@alfresco.com" + } + ], + "keywords": [ + "ng2", + "angular", + "angular2", + "activiti", + "activiti-form" + ], + "dependencies": { + "@angular/common": "2.0.0", + "@angular/compiler": "2.0.0", + "@angular/core": "2.0.0", + "@angular/forms": "2.0.0", + "@angular/http": "2.0.0", + "@angular/platform-browser": "2.0.0", + "@angular/platform-browser-dynamic": "2.0.0", + "core-js": "^2.4.1", + "reflect-metadata": "^0.1.3", + "rxjs": "5.0.0-beta.12", + "systemjs": "0.19.27", + "zone.js": "^0.6.23", + + "intl": "1.2.4", + "dialog-polyfill": "^0.4.3", + "element.scrollintoviewifneeded-polyfill": "^1.0.1", + "material-design-icons": "2.2.3", + "material-design-lite": "1.2.1", + + "moment": "2.15.1", + "md-date-time-picker": "^2.2.0", + + "ng2-translate": "2.5.0", + "alfresco-js-api": "^0.3.0", + "ng2-alfresco-core": "0.3.2", + "ng2-activiti-form": "^0.3.0" + }, + "devDependencies": { + "@types/node": "^6.0.42", + "@types/core-js": "^0.9.32", + "@types/jasmine": "^2.2.33", + "concurrently": "^2.2.0", + "rimraf": "2.5.2", + "tslint": "^3.8.1", + "typescript": "^2.0.3", + "wsrv": "^0.1.5" + } +} diff --git a/ng2-components/ng2-activiti-form/demo/src/main.ts b/ng2-components/ng2-activiti-form/demo/src/main.ts new file mode 100644 index 0000000000..ea35ad17b1 --- /dev/null +++ b/ng2-components/ng2-activiti-form/demo/src/main.ts @@ -0,0 +1,100 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NgModule, Component, OnInit } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { CoreModule, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; +import { ActivitiFormModule } from 'ng2-activiti-form'; + +@Component({ + selector: 'alfresco-app-demo', + template: ` +
+
+
+

+
+ Authentication failed to ip {{ host }} with user: admin, admin, you can still try to add a valid ticket to perform + operations. +
+
+ +
+ + ` +}) + +export class FormDemoComponent implements OnInit { + + taskId: number; + + authenticated: boolean; + + host: string = 'http://localhost:9999'; + + ticket: string; + + constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) { + settingsService.bpmHost = this.host; + settingsService.setProviders('BPM'); + + if (this.authService.getTicketBpm()) { + this.ticket = this.authService.getTicketBpm(); + } + } + + public updateTicket(): void { + localStorage.setItem('ticket-BPM', this.ticket); + } + + public updateHost(): void { + this.settingsService.bpmHost = this.host; + this.login(); + } + + public ngOnInit(): void { + this.login(); + } + + login() { + this.authService.login('admin', 'admin').subscribe( + ticket => { + console.log(ticket); + this.ticket = this.authService.getTicketBpm(); + this.authenticated = true; + }, + error => { + console.log(error); + this.authenticated = false; + }); + } +} + +@NgModule({ + imports: [ + BrowserModule, + CoreModule.forRoot(), + ActivitiFormModule.forRoot() + ], + declarations: [FormDemoComponent], + bootstrap: [FormDemoComponent] +}) +export class AppModule { +} + +platformBrowserDynamic().bootstrapModule(AppModule); diff --git a/ng2-components/ng2-activiti-form/demo/systemjs.config.js b/ng2-components/ng2-activiti-form/demo/systemjs.config.js new file mode 100644 index 0000000000..3860ed6679 --- /dev/null +++ b/ng2-components/ng2-activiti-form/demo/systemjs.config.js @@ -0,0 +1,48 @@ +/** + * System configuration for Angular 2 samples + * Adjust as necessary for your application needs. + */ +(function (global) { + System.config({ + paths: { + // paths serve as alias + 'npm:': 'node_modules/' + }, + // map tells the System loader where to look for things + map: { + // our app is within the app folder + app: 'dist', + // angular bundles + '@angular/core': 'npm:@angular/core/bundles/core.umd.js', + '@angular/common': 'npm:@angular/common/bundles/common.umd.js', + '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js', + '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js', + '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js', + '@angular/http': 'npm:@angular/http/bundles/http.umd.js', + '@angular/router': 'npm:@angular/router/bundles/router.umd.js', + '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js', + // other libraries + 'rxjs': 'npm:rxjs', + 'moment': 'npm:moment/min/moment.min.js', + 'ng2-translate': 'npm:ng2-translate', + 'alfresco-js-api': 'npm:alfresco-js-api/dist', + 'ng2-alfresco-core': 'npm:ng2-alfresco-core/dist', + 'ng2-activiti-form': 'npm:ng2-activiti-form/dist' + }, + // packages tells the System loader how to load when no filename and/or no extension + packages: { + app: { + main: './main.js', + defaultExtension: 'js' + }, + rxjs: { + defaultExtension: 'js' + }, + 'ng2-translate': { defaultExtension: 'js' }, + 'ng2-charts': { main: 'ng2-charts.js', defaultExtension: 'js'}, + 'alfresco-js-api': { main: './alfresco-js-api.js', defaultExtension: 'js'}, + 'ng2-alfresco-core': { main: './index.js', defaultExtension: 'js'}, + 'ng2-activiti-form': { main: './index.js', defaultExtension: 'js'} + } + }); +})(this); diff --git a/ng2-components/ng2-activiti-form/demo/tsconfig.json b/ng2-components/ng2-activiti-form/demo/tsconfig.json new file mode 100644 index 0000000000..7be35bfec8 --- /dev/null +++ b/ng2-components/ng2-activiti-form/demo/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "sourceMap": true, + "removeComments": true, + "declaration": true, + "noLib": false, + "allowUnreachableCode": false, + "allowUnusedLabels": false, + "noImplicitAny": false, + "noImplicitReturns": false, + "noImplicitUseStrict": false, + "noFallthroughCasesInSwitch": true, + "outDir": "dist", + "types": ["core-js", "jasmine", "node"] + }, + "exclude": [ + "demo", + "node_modules", + "dist" + ] +} diff --git a/ng2-components/ng2-activiti-form/demo/tslint.json b/ng2-components/ng2-activiti-form/demo/tslint.json new file mode 100644 index 0000000000..8c9703b9de --- /dev/null +++ b/ng2-components/ng2-activiti-form/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, + 180 + ], + "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": true, + "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-form/package.json b/ng2-components/ng2-activiti-form/package.json index f2df68ed03..c1abfd65dd 100644 --- a/ng2-components/ng2-activiti-form/package.json +++ b/ng2-components/ng2-activiti-form/package.json @@ -52,23 +52,27 @@ "@angular/http": "2.0.0", "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", - "@angular/upgrade": "2.0.0", - "@types/node": "^6.0.42", "core-js": "^2.4.1", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.12", "systemjs": "0.19.27", "zone.js": "^0.6.23", - "ng2-translate": "2.5.0", + "intl": "1.2.4", + "dialog-polyfill": "^0.4.3", + "element.scrollintoviewifneeded-polyfill": "^1.0.1", + "material-design-icons": "2.2.3", + "material-design-lite": "1.2.1", + "moment": "2.15.1", "md-date-time-picker": "^2.2.0", + "ng2-translate": "2.5.0", "alfresco-js-api": "^0.3.0", "ng2-alfresco-core": "0.3.2" }, "devDependencies": { + "@types/node": "^6.0.42", "@types/core-js": "^0.9.32", "@types/jasmine": "^2.2.33", "concurrently": "^2.2.0", diff --git a/ng2-components/ng2-activiti-processlist/.npmignore b/ng2-components/ng2-activiti-processlist/.npmignore new file mode 100644 index 0000000000..c5ca623298 --- /dev/null +++ b/ng2-components/ng2-activiti-processlist/.npmignore @@ -0,0 +1,15 @@ +npm-debug.log +.idea + +coverage/ +node_modules +typings/ +fonts/ + +/.editorconfig +/.travis.yml +/*.js +/*.json +/*.ts +/*.js.map +/.npmignore diff --git a/ng2-components/ng2-activiti-processlist/README.md b/ng2-components/ng2-activiti-processlist/README.md index 85227b0a49..be0d6f1308 100644 --- a/ng2-components/ng2-activiti-processlist/README.md +++ b/ng2-components/ng2-activiti-processlist/README.md @@ -1,4 +1,35 @@ -# Activiti Task List Component for Angular 2 +# Activiti Process List Component for Angular 2 +

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

Displays lists of process instances both active and completed, using any defined process filter, and render details of any chosen instance. @@ -10,49 +41,70 @@ necessary configuration [prerequisites](https://github.com/Alfresco/alfresco-ng2 ## Install -```sh -npm install --save ng2-activiti-processlist -``` +Follow the 3 steps below: -### Dependencies +1. Npm -Add the following dependency to your index.html: + ```sh + npm install ng2-activiti-processlist --save + ``` -```html - -``` +2. Html -You must separately install the following libraries for your application: + Include these dependencies in your index.html page: -- [ng2-translate](https://github.com/ocombe/ng2-translate) -- [ng2-alfresco-core](https://www.npmjs.com/package/ng2-alfresco-core) -- [ng2-alfresco-datatable](https://www.npmjs.com/package/ng2-alfresco-datatable) -- [ng2-activiti-tasklist](https://www.npmjs.com/package/ng2-activiti-tasklist) + ```html + + -```sh -npm install --save ng2-translate ng2-alfresco-core ng2-alfresco-datatable ng2-activiti-tasklist -``` + + + + -#### Material Design Lite + + + + -The style of this component is based on [material design](https://getmdl.io/), so if you want to visualize it correctly you have to add the material -design dependency to your project: + + + -```sh -npm install --save material-design-icons material-design-lite -``` + + + + -Also make sure you include these dependencies in your `index.html` file: + + + + -```html - - - - -``` + + + + -## Usage + ``` + +3. SystemJs + + Add the following components to your systemjs.config.js file: + + - ng2-translate + - alfresco-js-api + - ng2-alfresco-core + - ng2-activiti-form + - ng2-alfresco-datatable + - ng2-activiti-tasklist + - ng2-activiti-processlist + + Please refer to the following example file: [systemjs.config.js](demo/systemjs + .config.js) . + +## Basic usage ### Activiti Process Instance List @@ -62,33 +114,102 @@ This component renders a list containing all the process instances matched by th ``` +Usage example of this component : + +**main.ts** +```ts + +import { NgModule, Component } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { FilterRepresentationModel } from 'ng2-activiti-tasklist'; +import { CoreModule } from 'ng2-alfresco-core'; +import { ActivitiProcessListModule } from 'ng2-activiti-processlist'; +import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core'; +import { ObjectDataTableAdapter, DataSorting } from 'ng2-alfresco-datatable'; + +@Component({ + selector: 'alfresco-app-demo', + template: `` +}) +class MyDemoApp { + + dataProcesses: ObjectDataTableAdapter; + + filterRepresentationModel: FilterRepresentationModel; + + constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) { + settingsService.bpmHost = 'http://localhost:9999'; + + this.authService.login('admin', 'admin').subscribe( + ticket => { + console.log(ticket); + }, + error => { + console.log(error); + }); + + this.dataProcesses = new ObjectDataTableAdapter([], [ + {type: 'text', key: 'name', title: 'Name', cssClass: 'full-width name-column', sortable: true}, + {type: 'text', key: 'started', title: 'Started', cssClass: 'hidden', sortable: true} + ] + ); + this.dataProcesses.setSorting(new DataSorting('started', 'desc')); + + this.filterRepresentationModel = new FilterRepresentationModel({ + appId: '3003', + filter: { + processDefinitionKey: null, + name: null, + state: 'running', + sort: 'created-desc' + } + }); + } +} + +@NgModule({ + imports: [ + BrowserModule, + CoreModule.forRoot(), + ActivitiProcessListModule + ], + declarations: [MyDemoApp], + bootstrap: [MyDemoApp] +}) +export class AppModule { +} + +platformBrowserDynamic().bootstrapModule(AppModule); + + +``` + #### Options -**filter**: { FilterModel } (required) FilterModel object that -is passed to the process instance list API to filter the returned list. +| Name | Description | +| --- | --- | +|`filter`| { UserProcessInstanceFilterRepresentationModel } (required) UserProcessInstanceFilterRepresentationModel object that is passed to the process instance list API to filter the returned list. | Example: ```json { - "id": 4, - "name": "Running Processes", - "recent": false, - "icon": "glyphicon-align-left", - "filter": { - "appDefinitionId": "1", - "sort": "created-desc", - "name": "", - "state": "open", - "page": "0", - "size": "25" - }, - "appId": 1001 + appId: '3003', + filter:{ + processDefinitionKey: null, + name:null, + state:'running', + sort: 'created-desc' + } } ``` -**schemaColumn**: {any} List of columns to display in the process instances datatable +| Name | Description | +| --- | --- | +|`schemaColumn`| {any} List of columns to display in the process instances datatable | Example: @@ -122,17 +243,20 @@ process instances are displayed in the list. #### Options -- **`appId`**: Display filters available to the current user for the application with the specified ID -- **`appName`**: Display filters available to the current user for the application with the specified name +| Name | Description | +| --- | --- | +| `appId` | Display filters available to the current user for the application with the specified ID | +| `appName` | Display filters available to the current user for the application with the specified name | If both `appId` and `appName` are specified then `appName` will take precedence and `appId` will be ignored. #### Events -- **`onSuccess`**: Emitted when the list of filters hase been successfully loaded from the server -- **`onError`**: Emitted when an error occurred fetching the list of process instance filters, or fetching the -list of deployed applications when an app name was specified. -- **`filterClick`**: Emitted when the user selects a filter from the list +| Name | Description | +| --- | --- | +| `onSuccess` | Emitted when the list of filters hase been successfully loaded from the server | +| `onError` | Emitted when an error occurs | +| `ilterClick` | Emitted when the user selects a filter from the list | ### Start Process Button component @@ -145,7 +269,10 @@ to specify some basic details needed to start a new process instance. #### Options -- **`appId`**: Limit the list of processes which can be started to those contained in the specified app + +| Name | Description | +| --- | --- | +| `appId` | Limit the list of processes which can be started to those contained in the specified app | #### Events @@ -161,12 +288,18 @@ This component displays detailed information on a specified process instance #### Options -- **`processInstanceId`** (required): The numeric ID of the process instance to display + +| Name | Description | +| --- | --- | +| `processInstanceId` | (required): The numeric ID of the process instance to display | #### Events -- **`processCancelledEmitter`**: Emitted when the current process is cancelled by the user from within the component -- **`taskFormCompletedEmitter`**: Emitted when the form associated with an active task is completed from within the component + +| Name | Description | +| --- | --- | +| `processCancelledEmitter` | Emitted when the current process is cancelled by the user from within the component | +| `taskFormCompletedEmitter` | Emitted when the form associated with an active task is completed from within the component | ### Process Instance Details Header component @@ -178,11 +311,17 @@ This is a sub-component of the process details component, which renders some gen #### Options -- **`processInstance`** (required): Full details of the process instance to display information about + +| Name | Description | +| --- | --- | +| `processInstance` | (required): Full details of the process instance to display information about | #### Events -- **`processCancelled`**: Emitted when the Cancel Process button shown by the component is clicked + +| Name | Description | +| --- | --- | +| `processCancelled` | Emitted when the Cancel Process button shown by the component is clicked | ### Process Instance Tasks component @@ -194,12 +333,17 @@ Lists both the active and completed tasks associated with a particular process i #### Options -- **`processInstanceId`** (required): The numeric ID of the process instance to display tasks for -- **`showRefreshButton`** (default: `true`): Whether to show a refresh button next to the list of tasks to allow this to be updated from the server + +| Name | Description | +| --- | --- | +| `processInstanceId` | (required): The numeric ID of the process instance to display tasks for | +| `showRefreshButton` | (default: `true`): Whether to show a refresh button next to the list of tasks to allow this to be updated from the server | #### Events -- **`taskFormCompletedEmitter`**: Emitted when the form associated with an active task is completed from within the component +| Name | Description | +| --- | --- | +| `taskFormCompletedEmitter` | Emitted when the form associated with an active task is completed from within the component | ### Process Instance Comments component @@ -211,7 +355,10 @@ Displays comments associated with a particular process instances and allows the #### Options -- **`processInstanceId`** (required): The numeric ID of the process instance to display comments for + +| Name | Description | +| --- | --- | +| `processInstanceId` | (required): The numeric ID of the process instance to display comments for | #### Events @@ -221,6 +368,7 @@ No events are emitted by this component Alternatively you can build component from sources with the following commands: + ```sh npm install npm run build @@ -232,7 +380,7 @@ npm run build $ npm run build:w ``` -### Running unit tests +## Running unit tests ```sh npm test @@ -251,4 +399,28 @@ before performing unit testing. ```sh npm run coverage -``` \ No newline at end of file +``` + +## Demo + +If you want have a demo of how the component works, please check the demo folder : + +```sh +cd demo +npm install +npm start +``` + +## 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 | + +## License + +[Apache Version 2.0](https://github.com/Alfresco/alfresco-ng2-components/blob/master/LICENSE) diff --git a/ng2-components/ng2-activiti-processlist/demo/index.html b/ng2-components/ng2-activiti-processlist/demo/index.html index 1fe571c84c..fe525218aa 100644 --- a/ng2-components/ng2-activiti-processlist/demo/index.html +++ b/ng2-components/ng2-activiti-processlist/demo/index.html @@ -1,34 +1,55 @@ - - - - ng2-activiti-processlist Angular 2 - + + + + + Alfresco Angular 2 Activiti Process - Demo + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + - - - - - - - - - - - - -
-
- + + - - diff --git a/ng2-components/ng2-activiti-processlist/demo/package.json b/ng2-components/ng2-activiti-processlist/demo/package.json index 029062ca9d..70773dc2d1 100644 --- a/ng2-components/ng2-activiti-processlist/demo/package.json +++ b/ng2-components/ng2-activiti-processlist/demo/package.json @@ -6,11 +6,11 @@ "main": "index.js", "scripts": { "clean": "npm install rimraf && rimraf dist node_modules typings dist", - "postinstall": "npm run typings && npm run build", + "postinstall": "npm run build", "start": "npm run build && concurrently \"npm run tsc:w\" \"npm run server\" ", "server": "wsrv -o -s -l", - "build": "npm run tslint && rimraf dist && npm run tsc", - "build:w": "npm run tslint && rimraf dist && npm run tsc:w", + "build": "npm run tslint && rimraf dist && tsc", + "build:w": "npm run tslint && rimraf dist && tsc -w", "tsc": "tsc", "tsc:w": "tsc -w", "tslint": "tslint -c tslint.json *.ts && tslint -c tslint.json src/{,**/}**.ts" @@ -30,25 +30,30 @@ "@angular/http": "2.0.0", "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", - "@angular/upgrade": "2.0.0", - "@types/node": "^6.0.42", "core-js": "^2.4.1", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.12", "systemjs": "0.19.27", "zone.js": "^0.6.23", + "intl": "1.2.4", + "dialog-polyfill": "^0.4.3", + "element.scrollintoviewifneeded-polyfill": "^1.0.1", "material-design-icons": "2.2.3", "material-design-lite": "1.2.1", + "moment": "2.15.1", + "md-date-time-picker": "^2.2.0", + + "ng2-translate": "2.5.0", "alfresco-js-api": "^0.3.0", + "ng2-activiti-tasklist": "0.3.3", "ng2-alfresco-core": "0.3.2", "ng2-alfresco-datatable": "0.3.2", - "ng2-activiti-processlist": "^0.3.0", - "ng2-activiti-tasklist": "0.3.3" + "ng2-activiti-processlist": "^0.3.0" }, "devDependencies": { + "@types/node": "^6.0.42", "@types/core-js": "^0.9.32", "@types/jasmine": "^2.2.33", "concurrently": "^2.2.0", diff --git a/ng2-components/ng2-activiti-processlist/demo/src/main.ts b/ng2-components/ng2-activiti-processlist/demo/src/main.ts index f6f5f52a6c..252ab72fcf 100644 --- a/ng2-components/ng2-activiti-processlist/demo/src/main.ts +++ b/ng2-components/ng2-activiti-processlist/demo/src/main.ts @@ -12,94 +12,221 @@ * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { NgModule, Component, OnInit } from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; -import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; - -import { CoreModule } from 'ng2-alfresco-core'; -import { ActivitiProcessListModule } from 'ng2-activiti-processlist'; -import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core'; - -@Component({ - selector: 'my-app', - template: `
-
-
-

-
- Authentication failed to ip {{ bpmHost }} with user: admin, admin, you can still try to add a valid token to perform - operations. -
-
-
-
-
-
-
-
-
- -
` -}) -class MyDemoApp implements OnInit { - - authenticated: boolean; - bpmHost: string = 'http://127.0.0.1:9999'; - token: string; - - constructor( - private authService: AlfrescoAuthenticationService, - private settingsService: AlfrescoSettingsService - ) { - console.log('constructor'); - - settingsService.setProviders('BPM'); - settingsService.bpmHost = this.bpmHost; - - if (this.authService.getTicketBpm()) { - this.token = this.authService.getTicketBpm(); - } - } - - ngOnInit() { - this.login(); - } - - public updateToken(): void { - localStorage.setItem('token', this.token); - } - - public updateHost(): void { - this.settingsService.bpmHost = this.bpmHost; - this.login(); - } - - login() { - this.authService.login('admin', 'admin').subscribe( - token => { - console.log(token); - this.token = token; - this.authenticated = true; - }, - error => { + * limitations under the License. + */ + +import { Input, NgModule, Component, OnInit, ViewChild } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { AppDefinitionRepresentationModel, ActivitiTaskListModule } from 'ng2-activiti-tasklist'; +import { CoreModule } from 'ng2-alfresco-core'; +import { ActivitiProcessListModule } from 'ng2-activiti-processlist'; +import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core'; +import { ObjectDataTableAdapter, DataSorting } from 'ng2-alfresco-datatable'; + +@Component({ + selector: 'alfresco-app-demo', + template: ` +
+
+
+

+
+ Authentication failed to ip {{ host }} with user: admin, admin, you can still try to add a valid ticket to perform + operations. +
+
+ +
+ +
+ + + + +
+ +
+ + + +
+
+ +
+
+ + + +
+
+
+
+
+ Process Filters + + +
+
+ Process List + +
+
+ Process Details + +
+
+
+
+
+ +
+
+` +}) +class MyDemoApp implements OnInit { + + authenticated: boolean; + + host: string = 'http://localhost:9999'; + + ticket: string; + + @ViewChild('tabmain') + tabMain: any; + + @ViewChild('tabheader') + tabHeader: any; + + @ViewChild('activitiprocessfilter') + activitiprocessfilter: any; + + @ViewChild('activitiprocesslist') + activitiprocesslist: any; + + @ViewChild('activitiprocessdetails') + activitiprocessdetails: any; + + @Input() + appId: number; + + processFilter: any; + + currentProcessInstanceId: string; + + dataProcesses: ObjectDataTableAdapter; + + constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) { + settingsService.bpmHost = this.host; + settingsService.setProviders('BPM'); + + if (this.authService.getTicketBpm()) { + this.ticket = this.authService.getTicketBpm(); + } + + this.dataProcesses = new ObjectDataTableAdapter( + [], + [ + {type: 'text', key: 'name', title: 'Name', cssClass: 'full-width name-column', sortable: true}, + {type: 'text', key: 'started', title: 'Started', cssClass: 'hidden', sortable: true} + ] + ); + this.dataProcesses.setSorting(new DataSorting('started', 'desc')); + } + + public updateTicket(): void { + localStorage.setItem('ticket-BPM', this.ticket); + } + + public updateHost(): void { + this.settingsService.bpmHost = this.host; + this.login(); + } + + public ngOnInit(): void { + this.login(); + } + + login() { + this.authService.login('admin', 'admin').subscribe( + ticket => { + console.log(ticket); + this.ticket = this.authService.getTicketBpm(); + this.authenticated = true; + }, + error => { console.log(error); this.authenticated = false; }); } + + onAppClick(app: AppDefinitionRepresentationModel) { + this.appId = app.id; + + this.processFilter = null; + this.currentProcessInstanceId = null; + + this.changeTab('apps', 'processes'); + } + + onProcessFilterClick(event: any) { + this.processFilter = event; + } + + onSuccessProcessFilterList(event: any) { + this.processFilter = this.activitiprocessfilter.getCurrentFilter(); + } + + onSuccessProcessList(event: any) { + this.currentProcessInstanceId = this.activitiprocesslist.getCurrentProcessId(); + } + + onProcessRowClick(processInstanceId) { + this.currentProcessInstanceId = processInstanceId; + } + + processCancelled(data: any) { + this.currentProcessInstanceId = null; + this.activitiprocesslist.reload(); + } + + changeTab(origin: string, destination: string) { + this.tabMain.nativeElement.children[origin].classList.remove('is-active'); + this.tabMain.nativeElement.children[destination].classList.add('is-active'); + + this.tabHeader.nativeElement.children[`${origin}-header`].classList.remove('is-active'); + this.tabHeader.nativeElement.children[`${destination}-header`].classList.add('is-active'); + } + } @NgModule({ imports: [ BrowserModule, CoreModule.forRoot(), - ActivitiProcessListModule + ActivitiProcessListModule, + ActivitiTaskListModule.forRoot() ], - declarations: [ MyDemoApp ], - bootstrap: [ MyDemoApp ] + declarations: [MyDemoApp], + bootstrap: [MyDemoApp] }) -export class AppModule { } +export class AppModule { +} platformBrowserDynamic().bootstrapModule(AppModule); diff --git a/ng2-components/ng2-activiti-processlist/demo/systemjs.config.js b/ng2-components/ng2-activiti-processlist/demo/systemjs.config.js index 55fb299154..f1fe243137 100644 --- a/ng2-components/ng2-activiti-processlist/demo/systemjs.config.js +++ b/ng2-components/ng2-activiti-processlist/demo/systemjs.config.js @@ -27,7 +27,9 @@ 'alfresco-js-api': 'npm:alfresco-js-api/dist', 'ng2-alfresco-core': 'npm:ng2-alfresco-core/dist', 'ng2-alfresco-datatable': 'npm:ng2-alfresco-datatable/dist', - 'ng2-activiti-tasklist': 'npm:ng2-activiti-tasklist/dist' + 'ng2-activiti-form': 'npm:ng2-activiti-form/dist', + 'ng2-activiti-tasklist': 'npm:ng2-activiti-tasklist/dist', + 'ng2-activiti-processlist': 'npm:ng2-activiti-processlist/dist' }, // packages tells the System loader how to load when no filename and/or no extension packages: { @@ -42,7 +44,9 @@ 'alfresco-js-api': { main: './alfresco-js-api.js', defaultExtension: 'js'}, 'ng2-alfresco-core': { main: './index.js', defaultExtension: 'js'}, 'ng2-alfresco-datatable': { main: './index.js', defaultExtension: 'js'}, - 'ng2-activiti-tasklist': { main: './index.js', defaultExtension: 'js'} + 'ng2-activiti-form': { main: './index.js', defaultExtension: 'js'}, + 'ng2-activiti-tasklist': { main: './index.js', defaultExtension: 'js'}, + 'ng2-activiti-processlist': { main: './index.js', defaultExtension: 'js'} } }); })(this); diff --git a/ng2-components/ng2-activiti-processlist/package.json b/ng2-components/ng2-activiti-processlist/package.json index f5d01b1880..3264887bec 100644 --- a/ng2-components/ng2-activiti-processlist/package.json +++ b/ng2-components/ng2-activiti-processlist/package.json @@ -51,21 +51,29 @@ "@angular/http": "2.0.0", "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", - "@angular/upgrade": "2.0.0", - "@types/node": "^6.0.42", - "alfresco-js-api": "^0.3.0", "core-js": "^2.4.1", - "ng2-activiti-tasklist": "0.3.3", - "ng2-alfresco-core": "0.3.2", - "ng2-alfresco-datatable": "0.3.2", - "ng2-translate": "2.5.0", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.12", "systemjs": "0.19.27", - "zone.js": "^0.6.23" + "zone.js": "^0.6.23", + + "intl": "1.2.4", + "dialog-polyfill": "^0.4.3", + "element.scrollintoviewifneeded-polyfill": "^1.0.1", + "material-design-icons": "2.2.3", + "material-design-lite": "1.2.1", + + "moment": "2.15.1", + "md-date-time-picker": "^2.2.0", + + "ng2-translate": "2.5.0", + "alfresco-js-api": "^0.3.0", + "ng2-activiti-tasklist": "0.3.3", + "ng2-alfresco-core": "0.3.2", + "ng2-alfresco-datatable": "0.3.2" }, "devDependencies": { + "@types/node": "^6.0.42", "@types/core-js": "^0.9.32", "@types/jasmine": "^2.2.33", "concurrently": "^2.2.0", 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 index e8890a20c7..9519380532 100644 --- 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 @@ -15,11 +15,11 @@ * limitations under the License. */ -import { UserProcessInstanceFilterRepresentationModel } from '../models/filter.model'; +import { FilterRepresentationModel } from 'ng2-activiti-tasklist'; export var fakeFilters = { size: 0, total: 0, start: 0, - data: [new UserProcessInstanceFilterRepresentationModel({ + data: [new FilterRepresentationModel({ 'name': 'Running', 'appId': '22', 'recent': true, @@ -30,14 +30,14 @@ export var fakeFilters = { export var fakeEmptyFilters = { size: 0, total: 0, start: 0, - data: [ ] + data: [] }; export var fakeApi = { activiti: { userFiltersApi: { getUserProcessInstanceFilters: (filterOpts) => Promise.resolve({}), - createUserProcessInstanceFilter: (filter: UserProcessInstanceFilterRepresentationModel) => Promise.resolve(filter) + createUserProcessInstanceFilter: (filter: FilterRepresentationModel) => Promise.resolve(filter) } } }; diff --git a/ng2-components/ng2-activiti-processlist/src/components/activiti-comments.component.ts b/ng2-components/ng2-activiti-processlist/src/components/activiti-comments.component.ts index b9294d69ef..29683e609a 100644 --- a/ng2-components/ng2-activiti-processlist/src/components/activiti-comments.component.ts +++ b/ng2-components/ng2-activiti-processlist/src/components/activiti-comments.component.ts @@ -18,7 +18,7 @@ import { Component, Input, OnInit, ViewChild, OnChanges, SimpleChanges } from '@angular/core'; import { AlfrescoTranslationService } from 'ng2-alfresco-core'; import { ActivitiProcessService } from './../services/activiti-process.service'; -import { Comment } from '../models/comment.model'; +import { Comment } from 'ng2-activiti-tasklist'; import { Observer } from 'rxjs/Observer'; import { Observable } from 'rxjs/Observable'; diff --git a/ng2-components/ng2-activiti-processlist/src/components/activiti-filters.component.ts b/ng2-components/ng2-activiti-processlist/src/components/activiti-filters.component.ts index 4b8dd6f8ae..05a0a77504 100644 --- a/ng2-components/ng2-activiti-processlist/src/components/activiti-filters.component.ts +++ b/ng2-components/ng2-activiti-processlist/src/components/activiti-filters.component.ts @@ -18,7 +18,7 @@ import { Component, Output, EventEmitter, OnInit, Input, OnChanges, SimpleChanges } from '@angular/core'; import { AlfrescoTranslationService } from 'ng2-alfresco-core'; import { ActivitiProcessService } from './../services/activiti-process.service'; -import { FilterRepresentationModel } from '../models/filter.model'; +import { FilterRepresentationModel } from 'ng2-activiti-tasklist'; import { Observable, Observer } from 'rxjs/Rx'; declare let componentHandler: any; diff --git a/ng2-components/ng2-activiti-processlist/src/components/activiti-process-instance-tasks.component.ts b/ng2-components/ng2-activiti-processlist/src/components/activiti-process-instance-tasks.component.ts index ab088157b0..90e9d21fe5 100644 --- a/ng2-components/ng2-activiti-processlist/src/components/activiti-process-instance-tasks.component.ts +++ b/ng2-components/ng2-activiti-processlist/src/components/activiti-process-instance-tasks.component.ts @@ -18,7 +18,7 @@ import { Component, Input, OnInit, ViewChild, Output, EventEmitter } from '@angular/core'; import { AlfrescoTranslationService } from 'ng2-alfresco-core'; import { ActivitiProcessService } from './../services/activiti-process.service'; -import { TaskDetailsModel } from '../models/task-details.model'; +import { TaskDetailsModel } from 'ng2-activiti-tasklist'; import { Observable, Observer } from 'rxjs/Rx'; import { DatePipe } from '@angular/common'; diff --git a/ng2-components/ng2-activiti-processlist/src/components/activiti-processlist.component.ts b/ng2-components/ng2-activiti-processlist/src/components/activiti-processlist.component.ts index f56e0e2a99..2146a0a345 100644 --- a/ng2-components/ng2-activiti-processlist/src/components/activiti-processlist.component.ts +++ b/ng2-components/ng2-activiti-processlist/src/components/activiti-processlist.component.ts @@ -15,17 +15,17 @@ * limitations under the License. */ -import {Component, OnInit, Input, Output, EventEmitter, OnChanges, SimpleChanges } from '@angular/core'; +import { Component, OnInit, Input, Output, EventEmitter, OnChanges, SimpleChanges } from '@angular/core'; import { AlfrescoTranslationService } from 'ng2-alfresco-core'; import { ObjectDataTableAdapter, DataRowEvent, DataTableAdapter, ObjectDataRow } from 'ng2-alfresco-datatable'; +import { TaskQueryRequestRepresentationModel, FilterRepresentationModel } from 'ng2-activiti-tasklist'; import { ActivitiProcessService } from '../services/activiti-process.service'; -import { UserProcessInstanceFilterRepresentationModel, TaskQueryRequestRepresentationModel } from '../models/filter.model'; @Component({ moduleId: module.id, selector: 'activiti-process-instance-list', styles: [ - ` + ` :host h1 { font-size:22px } @@ -36,7 +36,7 @@ import { UserProcessInstanceFilterRepresentationModel, TaskQueryRequestRepresent export class ActivitiProcessInstanceListComponent implements OnInit, OnChanges { @Input() - filter: UserProcessInstanceFilterRepresentationModel; + filter: FilterRepresentationModel; @Input() data: DataTableAdapter; @@ -60,7 +60,7 @@ export class ActivitiProcessInstanceListComponent implements OnInit, OnChanges { {type: 'text', key: 'startedBy.email', title: 'Started By', sortable: true} ]; - constructor (private processService: ActivitiProcessService, private translate: AlfrescoTranslationService) { + constructor(private processService: ActivitiProcessService, private translate: AlfrescoTranslationService) { if (translate !== null) { translate.addTranslationFolder('node_modules/ng2-activiti-processlist/src'); } @@ -192,12 +192,14 @@ export class ActivitiProcessInstanceListComponent implements OnInit, OnChanges { return tasks; } - private convertProcessInstanceToTaskQuery(processFilter: UserProcessInstanceFilterRepresentationModel) { - let requestNode = {appDefinitionId: processFilter.appId, + private convertProcessInstanceToTaskQuery(processFilter: FilterRepresentationModel) { + let requestNode = { + appDefinitionId: processFilter.appId, processDefinitionKey: processFilter.filter.processDefinitionKey, text: processFilter.filter.name, state: processFilter.filter.state, - sort: processFilter.filter.sort}; + sort: processFilter.filter.sort + }; return new TaskQueryRequestRepresentationModel(requestNode); } } diff --git a/ng2-components/ng2-activiti-processlist/src/models/comment.model.ts b/ng2-components/ng2-activiti-processlist/src/models/comment.model.ts deleted file mode 100644 index d275e7ca1e..0000000000 --- a/ng2-components/ng2-activiti-processlist/src/models/comment.model.ts +++ /dev/null @@ -1,38 +0,0 @@ -/*! - * @license - * Copyright 2016 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * - * Comment submitted against a process - * - * @returns {Comment} . - */ -import { User } from './user.model'; - -export class Comment { - id: number; - message: string; - created: string; - createdBy: User; - - constructor(id: number, message: string, created: string, createdBy: User) { - this.id = id; - this.message = message; - this.created = created; - this.createdBy = createdBy; - } -} diff --git a/ng2-components/ng2-activiti-processlist/src/models/filter.model.ts b/ng2-components/ng2-activiti-processlist/src/models/filter.model.ts deleted file mode 100644 index e54579410b..0000000000 --- a/ng2-components/ng2-activiti-processlist/src/models/filter.model.ts +++ /dev/null @@ -1,157 +0,0 @@ -/*! - * @license - * Copyright 2016 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * - * This object represent the app definition. - * - * - * @returns {AppDefinitionRepresentationModel} . - */ -export class AppDefinitionRepresentationModel { - defaultAppId: string; - deploymentId: string; - name: string; - description: string; - theme: string; - icon: string; - id: number; - modelId: number; - tenantId: number; - - constructor(obj?: any) { - this.defaultAppId = obj && obj.defaultAppId || null; - this.deploymentId = obj && obj.deploymentId || false; - this.name = obj && obj.name || null; - this.description = obj && obj.description || null; - this.theme = obj && obj.theme || null; - this.icon = obj && obj.icon || null; - this.id = obj && obj.id; - this.modelId = obj && obj.modelId; - this.tenantId = obj && obj.tenantId; - } -} - -/** - * - * This object represent the filter. - * - * - * @returns {FilterRepresentationModel} . - */ -export class FilterRepresentationModel { - id: number; - appId: string; - name: string; - recent: boolean; - icon: string; - filter: FilterParamRepresentationModel; - index: number; - - constructor(obj?: any) { - this.appId = obj && obj.appId || null; - this.name = obj && obj.name || null; - this.recent = obj && obj.recent || false; - this.icon = obj && obj.icon || null; - this.filter = new FilterParamRepresentationModel(obj.filter); - this.index = obj && obj.index; - } -} - -/** - * - * This object represent the parameters of a filter. - * - * - * @returns {FilterParamRepresentationModel} . - */ -export class FilterParamRepresentationModel { - processDefinitionId: string; - processDefinitionKey: string; - name: string; - state: string; - sort: string; - - constructor(obj?: any) { - this.processDefinitionId = obj && obj.processDefinitionId || null; - this.processDefinitionKey = obj && obj.processDefinitionKey || null; - this.name = obj && obj.name || null; - this.state = obj && obj.state || null; - this.sort = obj && obj.sort || null; - } -} - -export class UserProcessInstanceFilterRepresentationModel extends FilterRepresentationModel { - public filter: ProcessInstanceFilterRepresentation; - constructor(obj?: any) { - super(obj); - this.filter = new ProcessInstanceFilterRepresentation(obj.filter); - } -} - -export class ProcessInstanceFilterRepresentation extends FilterParamRepresentationModel { - constructor(obj?: any) { - super(obj); - } -} - -export class UserTaskFilterRepresentationModel extends FilterRepresentationModel { - public filter: TaskFilterRepresentationModel; - constructor(obj?: any) { - super(obj); - this.filter = new TaskFilterRepresentationModel(obj.filter); - } -} - -export class TaskFilterRepresentationModel extends FilterParamRepresentationModel { - assignment: string; - dueAfter: Date; - dueBefore: Date; - - constructor(obj?: any) { - super(obj); - this.assignment = obj && obj.assignment || null; - this.dueAfter = obj && obj.dueAfter || null; - this.dueBefore = obj && obj.dueBefore || null; - } -} - -export class TaskQueryRequestRepresentationModel { - appDefinitionId: string; - processInstanceId: string; - processDefinitionId: string; - processDefinitionKey: string; - text: string; - assignment: string; - state: string; - sort: string; - page: number; - size: number; - - constructor(obj?: any) { - this.appDefinitionId = obj && obj.appDefinitionId || null; - this.processInstanceId = obj && obj.processInstanceId || null; - this.processDefinitionId = obj && obj.processDefinitionId || null; - this.processDefinitionKey = obj && obj.processDefinitionKey || null; - this.text = obj && obj.text || null; - this.assignment = obj && obj.assignment || null; - this.state = obj && obj.state || null; - this.sort = obj && obj.sort || null; - this.page = obj && obj.page || 0; - this.size = obj && obj.size || 25; - } -} diff --git a/ng2-components/ng2-activiti-processlist/src/models/task-details.model.ts b/ng2-components/ng2-activiti-processlist/src/models/task-details.model.ts deleted file mode 100644 index 0b13c30c15..0000000000 --- a/ng2-components/ng2-activiti-processlist/src/models/task-details.model.ts +++ /dev/null @@ -1,92 +0,0 @@ -/*! - * @license - * Copyright 2016 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * - * This object represent the details of a task. - * - * - * @returns {TaskDetailsModel} . - */ -import { User } from './user.model'; - -export class TaskDetailsModel { - id: string; - name: string; - assignee: User; - priority: number; - adhocTaskCanBeReassigned: number; - category: string; - created: string; - description: string; - dueDate: string; - duration: string; - endDate: string; - executionId: string; - formKey: string; - initiatorCanCompleteTask: boolean = false; - managerOfCandidateGroup: boolean = false; - memberOfCandidateGroup: boolean = false; - memberOfCandidateUsers: boolean = false; - involvedPeople: User []; - parentTaskId: string; - parentTaskName: string; - processDefinitionCategory: string; - processDefinitionDeploymentId: string; - processDefinitionDescription: string; - processDefinitionId: string; - processDefinitionKey: string; - processDefinitionName: string; - processDefinitionVersion: number = 0; - processInstanceId: string; - processInstanceName: string; - processInstanceStartUserId: string; - taskDefinitionKey: string; - - constructor(obj: any) { - this.id = obj.id; - this.name = obj.name; - this.priority = obj.priority; - this.assignee = new User(obj.assignee.id, obj.assignee.email, obj.assignee.firstName, obj.assignee.lastName); - this.adhocTaskCanBeReassigned = obj.adhocTaskCanBeReassigned; - this.created = obj.created; - this.description = obj.description; - this.dueDate = obj.dueDate; - this.duration = obj.duration; - this.endDate = obj.endDate; - this.executionId = obj.executionId; - this.formKey = obj.formKey; - this.initiatorCanCompleteTask = obj.initiatorCanCompleteTask; - this.managerOfCandidateGroup = obj.managerOfCandidateGroup; - this.memberOfCandidateGroup = obj.memberOfCandidateGroup; - this.memberOfCandidateUsers = obj.memberOfCandidateUsers; - this.involvedPeople = obj.involvedPeople; - this.parentTaskId = obj.parentTaskId; - this.parentTaskName = obj.parentTaskName; - this.processDefinitionCategory = obj.processDefinitionCategory; - this.processDefinitionDeploymentId = obj.processDefinitionDeploymentId; - this.processDefinitionDescription = obj.processDefinitionDescription; - this.processDefinitionId = obj.processDefinitionId; - this.processDefinitionKey = obj.processDefinitionKey; - this.processDefinitionName = obj.processDefinitionName; - this.processDefinitionVersion = obj.processDefinitionVersion; - this.processInstanceId = obj.processInstanceId; - this.processInstanceName = obj.processInstanceName; - this.processInstanceStartUserId = obj.processInstanceStartUserId; - this.taskDefinitionKey = obj.taskDefinitionKey; - } -} diff --git a/ng2-components/ng2-activiti-processlist/src/models/user.model.ts b/ng2-components/ng2-activiti-processlist/src/models/user.model.ts deleted file mode 100644 index 6d21ad4e0b..0000000000 --- a/ng2-components/ng2-activiti-processlist/src/models/user.model.ts +++ /dev/null @@ -1,38 +0,0 @@ -/*! - * @license - * Copyright 2016 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * - * This object represent the user. - * - * - * @returns {User} . - */ - -export class User { - id: number; - email: string; - firstName: string; - lastName: string; - - constructor(id: number, email: string, firstName: string, lastName: string) { - this.id = id; - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } -} diff --git a/ng2-components/ng2-activiti-processlist/src/services/activiti-process.service.ts b/ng2-components/ng2-activiti-processlist/src/services/activiti-process.service.ts index 57cc765830..7446afd5f8 100644 --- a/ng2-components/ng2-activiti-processlist/src/services/activiti-process.service.ts +++ b/ng2-components/ng2-activiti-processlist/src/services/activiti-process.service.ts @@ -15,13 +15,11 @@ * limitations under the License. */ -import {AlfrescoAuthenticationService} from 'ng2-alfresco-core'; -import {ProcessInstance} from '../models/process-instance'; -import {TaskQueryRequestRepresentationModel, UserProcessInstanceFilterRepresentationModel} from '../models/filter.model'; -import {User} from '../models/user.model'; -import {Comment} from '../models/comment.model'; -import {Injectable} from '@angular/core'; -import {Observable} from 'rxjs/Observable'; +import { AlfrescoAuthenticationService } from 'ng2-alfresco-core'; +import { ProcessInstance } from '../models/process-instance'; +import { User, Comment, FilterRepresentationModel, TaskQueryRequestRepresentationModel } from 'ng2-activiti-tasklist'; +import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs/Observable'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/catch'; @@ -61,9 +59,9 @@ export class ActivitiProcessService { } : {}; return Observable.fromPromise(this.callApiGetUserProcessInstanceFilters(filterOpts)) .map((response: any) => { - let filters: UserProcessInstanceFilterRepresentationModel[] = []; - response.data.forEach((filter: UserProcessInstanceFilterRepresentationModel) => { - let filterModel = new UserProcessInstanceFilterRepresentationModel(filter); + let filters: FilterRepresentationModel[] = []; + response.data.forEach((filter: FilterRepresentationModel) => { + let filterModel = new FilterRepresentationModel(filter); filters.push(filterModel); }); if (response && response.data && response.data.length === 0) { @@ -77,10 +75,10 @@ export class ActivitiProcessService { /** * Create and return the default filters * @param appId - * @returns {UserProcessInstanceFilterRepresentationModel[]} + * @returns {FilterRepresentationModel[]} */ - private createDefaultFilters(appId: string): UserProcessInstanceFilterRepresentationModel[] { - let filters: UserProcessInstanceFilterRepresentationModel[] = []; + private createDefaultFilters(appId: string): FilterRepresentationModel[] { + let filters: FilterRepresentationModel[] = []; let involvedTasksFilter = this.getRunningFilterInstance(appId); this.addFilter(involvedTasksFilter); @@ -100,10 +98,10 @@ export class ActivitiProcessService { /** * Return a static Running filter instance * @param appId - * @returns {UserProcessInstanceFilterRepresentationModel} + * @returns {FilterRepresentationModel} */ - private getRunningFilterInstance(appId: string): UserProcessInstanceFilterRepresentationModel { - return new UserProcessInstanceFilterRepresentationModel({ + private getRunningFilterInstance(appId: string): FilterRepresentationModel { + return new FilterRepresentationModel({ 'name': 'Running', 'appId': appId, 'recent': true, @@ -115,10 +113,10 @@ export class ActivitiProcessService { /** * Return a static Completed filter instance * @param appId - * @returns {UserProcessInstanceFilterRepresentationModel} + * @returns {FilterRepresentationModel} */ - private getCompletedFilterInstance(appId: string): UserProcessInstanceFilterRepresentationModel { - return new UserProcessInstanceFilterRepresentationModel({ + private getCompletedFilterInstance(appId: string): FilterRepresentationModel { + return new FilterRepresentationModel({ 'name': 'Completed', 'appId': appId, 'recent': false, @@ -130,10 +128,10 @@ export class ActivitiProcessService { /** * Return a static All filter instance * @param appId - * @returns {UserProcessInstanceFilterRepresentationModel} + * @returns {FilterRepresentationModel} */ - private getAllFilterInstance(appId: string): UserProcessInstanceFilterRepresentationModel { - return new UserProcessInstanceFilterRepresentationModel({ + private getAllFilterInstance(appId: string): FilterRepresentationModel { + return new FilterRepresentationModel({ 'name': 'All', 'appId': appId, 'recent': true, @@ -144,13 +142,13 @@ export class ActivitiProcessService { /** * Add a filter - * @param filter - UserProcessInstanceFilterRepresentationModel - * @returns {UserProcessInstanceFilterRepresentationModel} + * @param filter - FilterRepresentationModel + * @returns {FilterRepresentationModel} */ - addFilter(filter: UserProcessInstanceFilterRepresentationModel): Observable { + addFilter(filter: FilterRepresentationModel): Observable { return Observable.fromPromise(this.callApiAddFilter(filter)) .map(res => res) - .map((response: UserProcessInstanceFilterRepresentationModel) => { + .map((response: FilterRepresentationModel) => { return response; }).catch(this.handleError); } @@ -187,8 +185,12 @@ export class ActivitiProcessService { .map((response: any) => { let comments: Comment[] = []; response.data.forEach((comment) => { - let user = new User( - comment.createdBy.id, comment.createdBy.email, comment.createdBy.firstName, comment.createdBy.lastName); + let user = new User({ + id: comment.createdBy.id, + email: comment.createdBy.email, + firstName: comment.createdBy.firstName, + lastName: comment.createdBy.lastName + }); comments.push(new Comment(comment.id, comment.message, comment.created, user)); }); return comments; @@ -203,7 +205,7 @@ export class ActivitiProcessService { */ addProcessInstanceComment(id: string, message: string): Observable { return Observable.fromPromise( - this.authService.getAlfrescoApi().activiti.commentsApi.addProcessInstanceComment({message: message}, id) + this.authService.getAlfrescoApi().activiti.commentsApi.addProcessInstanceComment({message: message}, id) ) .map(res => res) .map((response: Comment) => { @@ -251,7 +253,7 @@ export class ActivitiProcessService { return this.authService.getAlfrescoApi().activiti.userFiltersApi.getUserProcessInstanceFilters(filterOpts); } - private callApiAddFilter(filter: UserProcessInstanceFilterRepresentationModel) { + private callApiAddFilter(filter: FilterRepresentationModel) { return this.authService.getAlfrescoApi().activiti.userFiltersApi.createUserProcessInstanceFilter(filter); } diff --git a/ng2-components/ng2-activiti-tasklist/.npmignore b/ng2-components/ng2-activiti-tasklist/.npmignore index 16ba3e61e5..c5ca623298 100644 --- a/ng2-components/ng2-activiti-tasklist/.npmignore +++ b/ng2-components/ng2-activiti-tasklist/.npmignore @@ -1,7 +1,6 @@ npm-debug.log .idea -assets/ coverage/ node_modules typings/ diff --git a/ng2-components/ng2-activiti-tasklist/README.md b/ng2-components/ng2-activiti-tasklist/README.md index b37d316aaf..e8db244743 100644 --- a/ng2-components/ng2-activiti-tasklist/README.md +++ b/ng2-components/ng2-activiti-tasklist/README.md @@ -1,105 +1,224 @@ # Activiti Task List Component for Angular 2 +

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

+ +Displays lists of process instances both active and completed, using any defined process filter, and +render details of any chosen instance. + ## Prerequisites Before you start using this development framework, make sure you have installed all required software and done all the -necessary configuration, see this [page](https://github.com/Alfresco/alfresco-ng2-components/blob/master/PREREQUISITES.md). +necessary configuration [prerequisites](https://github.com/Alfresco/alfresco-ng2-components/blob/master/PREREQUISITES.md). ## Install -```sh -npm install --save ng2-activiti-tasklist -``` +Follow the 3 steps below: -### Dependencies +1. Npm -Add the following dependency to your index.html: + ```sh + npm install ng2-activiti-tasklist --save + ``` -```html - -``` +2. Html -You must separately install the following libraries for your application: + Include these dependencies in your index.html page: -- [ng2-translate](https://github.com/ocombe/ng2-translate) -- [ng2-alfresco-core](https://www.npmjs.com/package/ng2-alfresco-core) -- [ng2-alfresco-datatable](https://www.npmjs.com/package/ng2-alfresco-datatable) + ```html + + -```sh -npm install --save ng2-translate ng2-alfresco-core ng2-alfresco-datatable -``` + + + + -#### Material Design Lite + + + + -The style of this component is based on [material design](https://getmdl.io/), so if you want to visualize it correctly you have to add the material -design dependency to your project: + + + -```sh -npm install --save material-design-icons material-design-lite -``` + + + + -Also make sure you include these dependencies in your `index.html` file: + + + + -```html - - - - -``` -#### Dialogs Polyfill + + + + -To make the dialog working with all the browser you have to add the dialog polyfill to you project: + ``` -```sh -npm install --save dialog-polyfill -``` +3. SystemJs -Also make sure you include these dependencies in your `index.html` file: + Add the following components to your systemjs.config.js file: -```html - - - - -``` + - ng2-translate + - alfresco-js-api + - ng2-alfresco-core + - ng2-activiti-form + - ng2-alfresco-datatable + - ng2-activiti-tasklist + + Please refer to the following example file: [systemjs.config.js](demo/systemjs + .config.js) . ## Basic usage example Activiti Task List -The component shows the list of all the tasks filter by the -FilterParamModel passed in input. + +The component shows the list of all the tasks filter by the FilterParamRepresentationModel passed in input. + ```html ``` +Usage example of this component : + +**main.ts** +```ts + +import { NgModule, Component } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { FilterRepresentationModel, ActivitiTaskListModule } from 'ng2-activiti-tasklist'; +import { CoreModule } from 'ng2-alfresco-core'; +import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core'; +import { ObjectDataTableAdapter, DataSorting } from 'ng2-alfresco-datatable'; + +@Component({ + selector: 'alfresco-app-demo', + template: `` +}) +class MyDemoApp { + + dataTasks: ObjectDataTableAdapter; + + filterRepresentationModel: FilterRepresentationModel; + + constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) { + settingsService.bpmHost = 'http://localhost:9999'; + + this.authService.login('admin', 'admin').subscribe( + ticket => { + console.log(ticket); + }, + error => { + console.log(error); + }); + + this.dataTasks = new ObjectDataTableAdapter([], [ + {type: 'text', key: 'name', title: 'Name', cssClass: 'full-width name-column', sortable: true}, + {type: 'text', key: 'started', title: 'Started', cssClass: 'hidden', sortable: true} + ] + ); + this.dataTasks.setSorting(new DataSorting('started', 'desc')); + + this.filterRepresentationModel = new FilterRepresentationModel({ + appId: '3003', + filter: { + processDefinitionKey: null, + assignment: 'involved', + name: null, + state: 'running', + sort: 'created-desc' + } + }); + } +} + +@NgModule({ + imports: [ + BrowserModule, + CoreModule.forRoot(), + ActivitiTaskListModule.forRoot() + ], + declarations: [MyDemoApp], + bootstrap: [MyDemoApp] +}) +export class AppModule { +} + +platformBrowserDynamic().bootstrapModule(AppModule); + + +``` + #### Events -**onSuccess**: The event is emitted when the task list is loaded -**rowClick**: The event is emitted when the task in the list is -clicked
+ +| Name | Description | +| --- | --- | +| `onSuccess` | The event is emitted when the task list is loaded | +| `rowClick` | The event is emitted when the task in the list is clicked | #### Options -**taskFilter**: { FilterParamModel } required) FilterParamModel object that -is passed to the task list API to filter the task list. +| Name | Description | +| --- | --- | +| `taskFilter` | { FilterParamRepresentationModel } required) FilterParamRepresentationModel object that is passed to the task list API to filter the task list. | + Example: + ```json { - "appDefinitionId": "1", - "processDefinitionId": "1533", - "sort": "created-desc", - "text": "", - "state": "open", - "assignment": "involved", - "page": "0", - "size": "25" + appId: '3003', + filter:{ + processDefinitionKey: null, + name:null, + assignment: 'involved', + state:'running', + sort: 'created-desc' + } } ``` -**schemaColumn**: { any[] } optional) JSON object that represent -the number and the type of the columns that you want show + +| Name | Description | +| --- | --- | +| `schemaColumn` | { any[] } optional) JSON object that represent the number and the type of the columns that you want show | + Example: + ```json [ {type: 'text', key: 'id', title: 'Id'}, @@ -110,31 +229,34 @@ Example: ``` ## Basic usage example Activiti Task Details + The component shows the details of the task id passed in input + ```html ``` #### Events + | Name | Description | | --- | --- | -| **formLoaded** | Invoked when form is loaded or reloaded. | -| **formSaved** | Invoked when form is submitted with `Save` or custom outcomes. | -| **formCompleted** | Invoked when form is submitted with `Complete` outcome. | -| **executeOutcome** | Invoked when any outcome is executed, default behaviour can be prevented via `event.preventDefault()` | -| **onError** | Invoked at any error | +| `formLoaded` | Invoked when form is loaded or reloaded. | +| `formSaved` | Invoked when form is submitted with `Save` or custom outcomes. | +| `formCompleted` | Invoked when form is submitted with `Complete` outcome. | +| `executeOutcome` | Invoked when any outcome is executed, default behaviour can be prevented via `event.preventDefault()` | +| `onError` | Invoked at any error | #### Options | Name | Type | Required | Description | | --- | --- | --- | --- | -| **taskId** | {string} | required | The id of the task details that we are asking for. | -| **showNextTask** | {boolean} | optional | Automatically render the next one, when the task is completed. | -| **showFormTitle** | {boolean} | optional | Toggle rendering of the form title. | -| **readOnlyForm** | {boolean} | optional | Toggle readonly state of the form. Enforces all form widgets render readonly if enabled. | -| **showFormRefreshButton** | {boolean} | optional | Toggle rendering of the `Refresh` button. | -| **showFormSaveButton** | {boolean} | optional | Toggle rendering of the `Save` outcome button. | -| **showFormCompleteButton** | {boolean} | optional | Toggle rendering of the Form `Complete` outcome button | +| `taskId` | {string} | required | The id of the task details that we are asking for. | +| `showNextTask` | {boolean} | optional | Automatically render the next one, when the task is completed. | +| `showFormTitle` | {boolean} | optional | Toggle rendering of the form title. | +| `readOnlyForm` | {boolean} | optional | Toggle readonly state of the form. Enforces all form widgets render readonly if enabled. | +| `showFormRefreshButton` | {boolean} | optional | Toggle rendering of the `Refresh` button. | +| `showFormSaveButton` | {boolean} | optional | Toggle rendering of the `Save` outcome button. | +| `showFormCompleteButton` | {boolean} | optional | Toggle rendering of the Form `Complete` outcome button | ### Custom 'empty Activiti Task Details' template @@ -157,6 +279,7 @@ This can be changed by adding the following custom html template: ``` ## Basic usage example Activiti Filter + The component shows all the available filters. ```html @@ -164,16 +287,20 @@ The component shows all the available filters. ``` #### Events -**filterClick**: The event is emitted when the filter in the list is - clicked + +| Name | Description | +| --- | --- | +| `filterClick` | The event is emitted when the filter in the list is clicked | #### Options + No options ## Build from sources Alternatively you can build component from sources with the following commands: + ```sh npm install npm run build @@ -185,7 +312,7 @@ npm run build $ npm run build:w ``` -### Running unit tests +## Running unit tests ```sh npm test @@ -205,3 +332,27 @@ before performing unit testing. ```sh npm run coverage ``` + +## Demo + +If you want have a demo of how the component works, please check the demo folder : + +```sh +cd demo +npm install +npm start +``` + +## 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 | + +## License + +[Apache Version 2.0](https://github.com/Alfresco/alfresco-ng2-components/blob/master/LICENSE) diff --git a/ng2-components/ng2-activiti-tasklist/demo/index.html b/ng2-components/ng2-activiti-tasklist/demo/index.html index 19590ff9e8..eff28149d9 100644 --- a/ng2-components/ng2-activiti-tasklist/demo/index.html +++ b/ng2-components/ng2-activiti-tasklist/demo/index.html @@ -2,18 +2,38 @@ - Angular 2 TaskList - Demo + + Alfresco Angular 2 Activiti Tasks - Demo + + + + + + + + - - + + + + + + + + + + + + + @@ -24,9 +44,12 @@ + + + - + diff --git a/ng2-components/ng2-activiti-tasklist/demo/package.json b/ng2-components/ng2-activiti-tasklist/demo/package.json index 33953f8e14..594c00a386 100644 --- a/ng2-components/ng2-activiti-tasklist/demo/package.json +++ b/ng2-components/ng2-activiti-tasklist/demo/package.json @@ -23,25 +23,29 @@ "@angular/http": "2.0.0", "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", - "@angular/upgrade": "2.0.0", - "@types/node": "^6.0.42", "core-js": "^2.4.1", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.12", "systemjs": "0.19.27", "zone.js": "^0.6.23", + "intl": "1.2.4", + "dialog-polyfill": "^0.4.3", + "element.scrollintoviewifneeded-polyfill": "^1.0.1", "material-design-icons": "2.2.3", "material-design-lite": "1.2.1", - "ng2-translate": "2.5.0", + "moment": "2.15.1", + "md-date-time-picker": "^2.2.0", + + "ng2-translate": "2.5.0", "alfresco-js-api": "^0.3.0", - "ng2-alfresco-datatable": "^0.3.0", - "ng2-alfresco-core": "^0.3.0", - "ng2-activiti-tasklist": "0.3.3" + "ng2-alfresco-core": "0.3.2", + "ng2-alfresco-datatable": "0.3.2", + "ng2-activiti-tasklist": "^0.3.3" }, "devDependencies": { + "@types/node": "^6.0.42", "@types/core-js": "^0.9.32", "@types/jasmine": "^2.2.33", "concurrently": "^2.2.0", diff --git a/ng2-components/ng2-activiti-tasklist/demo/src/main.ts b/ng2-components/ng2-activiti-tasklist/demo/src/main.ts index 78f34a7513..0653dd4c1e 100644 --- a/ng2-components/ng2-activiti-tasklist/demo/src/main.ts +++ b/ng2-components/ng2-activiti-tasklist/demo/src/main.ts @@ -15,79 +15,166 @@ * limitations under the License. */ -import { NgModule, Component, OnInit, ViewChild } from '@angular/core'; +import { Input, NgModule, Component, OnInit, ViewChild } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; - +import { + ActivitiTaskListModule, + AppDefinitionRepresentationModel, + FilterRepresentationModel, + ActivitiApps, + ActivitiTaskList +} from 'ng2-activiti-tasklist'; import { CoreModule } from 'ng2-alfresco-core'; -import { DataTableModule } from 'ng2-alfresco-datatable'; -import { ActivitiTaskListModule } from 'ng2-activiti-tasklist'; - import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core'; +import { ObjectDataTableAdapter, DataSorting } from 'ng2-alfresco-datatable'; @Component({ - selector: 'activiti-tasklist-demo', - template: `
-
-
-

-
- Authentication failed to ip {{ bpmHost }} with user: admin, admin, you can still try to add a valid token to perform - operations. -
-
-
- Task Filters - - Tasks - - Task Details - -
`, - styles: [ - ':host > .container {padding: 10px}', - '.p-10 { padding: 10px; }' - ] -}) -class ActivitiTaskListDemo implements OnInit { + selector: 'alfresco-app-demo', + template: ` +
+
+
+

+
+ Authentication failed to ip {{ host }} with user: admin, admin, you can still try to add a valid ticket to perform + operations. +
+
- @ViewChild('activititasklist') - activititasklist: any; +
+ +
+ + + + +
+ +
+ + + +
+
+ +
+
+ + + +
+
+
+
+ Task Filters + + +
+
+ Task List + +
+
+ Task Details + +
+
+
+
+ +
+
+` +}) +class MyDemoApp implements OnInit { + + authenticated: boolean; + + host: string = 'http://localhost:9999'; + + ticket: string; + + @ViewChild('activitiapps') + activitiapps: ActivitiApps; + + @ViewChild('tabmain') + tabMain: any; + + @ViewChild('tabheader') + tabHeader: any; + + @ViewChild('activitifilter') + activitifilter: any; @ViewChild('activitidetails') activitidetails: any; - bpmHost: string = 'http://127.0.0.1:9999'; + @ViewChild('activititasklist') + activititasklist: ActivitiTaskList; - token: string; + @Input() + appId: number; - authenticated: boolean; - - schemaColumn: any [] = []; + layoutType: string; currentTaskId: string; + taskSchemaColumns: any [] = []; + taskFilter: any; - constructor(private authService: AlfrescoAuthenticationService, - private settingsService: AlfrescoSettingsService) { - this.settingsService.setProviders('BPM'); + dataTasks: ObjectDataTableAdapter; + + constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) { + settingsService.bpmHost = this.host; + settingsService.setProviders('BPM'); + + if (this.authService.getTicketBpm()) { + this.ticket = this.authService.getTicketBpm(); + } + + this.dataTasks = new ObjectDataTableAdapter( + [], + [ + {type: 'text', key: 'name', title: 'Name', cssClass: 'full-width name-column', sortable: true}, + {type: 'text', key: 'started', title: 'Started', cssClass: 'hidden', sortable: true} + ] + ); + this.dataTasks.setSorting(new DataSorting('started', 'desc')); } - ngOnInit() { - this.login(); + public updateTicket(): void { + localStorage.setItem('ticket-BPM', this.ticket); + } - this.schemaColumn = [ - {type: 'text', key: 'name', title: 'Name', cssClass: 'full-width name-column', sortable: true} - ]; + public updateHost(): void { + this.settingsService.bpmHost = this.host; + this.login(); + } + + public ngOnInit(): void { + this.login(); } login() { this.authService.login('admin', 'admin').subscribe( - token => { - console.log(token); - this.token = token; + ticket => { + console.log(ticket); + this.ticket = this.authService.getTicketBpm(); this.authenticated = true; }, error => { @@ -96,27 +183,57 @@ class ActivitiTaskListDemo implements OnInit { }); } - onFilterClick(event: any) { - this.taskFilter = event; - this.activititasklist.load(this.taskFilter); + onAppClick(app: AppDefinitionRepresentationModel) { + this.appId = app.id; + + this.changeTab('apps', 'tasks'); } - onRowClick(taskId) { - this.currentTaskId = taskId; - this.activitidetails.loadDetails(this.currentTaskId); + onTaskFilterClick(event: FilterRepresentationModel) { + this.taskFilter = event; } + + onSuccessTaskFilterList(event: any) { + this.taskFilter = this.activitifilter.getCurrentFilter(); + } + + onStartTaskSuccess(event: any) { + this.activititasklist.reload(); + } + + onSuccessTaskList(event: FilterRepresentationModel) { + this.currentTaskId = this.activititasklist.getCurrentTaskId(); + } + + onTaskRowClick(taskId) { + this.currentTaskId = taskId; + } + + onFormCompleted(form) { + this.activititasklist.load(this.taskFilter); + this.currentTaskId = null; + } + + changeTab(origin: string, destination: string) { + this.tabMain.nativeElement.children[origin].classList.remove('is-active'); + this.tabMain.nativeElement.children[destination].classList.add('is-active'); + + this.tabHeader.nativeElement.children[`${origin}-header`].classList.remove('is-active'); + this.tabHeader.nativeElement.children[`${destination}-header`].classList.add('is-active'); + } + } @NgModule({ imports: [ BrowserModule, CoreModule.forRoot(), - DataTableModule, - ActivitiTaskListModule + ActivitiTaskListModule.forRoot() ], - declarations: [ ActivitiTaskListDemo ], - bootstrap: [ ActivitiTaskListDemo ] + declarations: [MyDemoApp], + bootstrap: [MyDemoApp] }) -export class AppModule { } +export class AppModule { +} platformBrowserDynamic().bootstrapModule(AppModule); diff --git a/ng2-components/ng2-activiti-tasklist/demo/systemjs.config.js b/ng2-components/ng2-activiti-tasklist/demo/systemjs.config.js index 4c66d6b975..eae9e94ae9 100644 --- a/ng2-components/ng2-activiti-tasklist/demo/systemjs.config.js +++ b/ng2-components/ng2-activiti-tasklist/demo/systemjs.config.js @@ -26,7 +26,9 @@ 'ng2-translate': 'npm:ng2-translate', 'alfresco-js-api': 'npm:alfresco-js-api/dist', 'ng2-alfresco-core': 'npm:ng2-alfresco-core/dist', - 'ng2-activiti-form': 'npm:ng2-activiti-form/dist' + 'ng2-alfresco-datatable': 'npm:ng2-alfresco-datatable/dist', + 'ng2-activiti-form': 'npm:ng2-activiti-form/dist', + 'ng2-activiti-tasklist': 'npm:ng2-activiti-tasklist/dist' }, // packages tells the System loader how to load when no filename and/or no extension packages: { @@ -41,7 +43,8 @@ 'alfresco-js-api': { main: './alfresco-js-api.js', defaultExtension: 'js'}, 'ng2-alfresco-core': { main: './index.js', defaultExtension: 'js'}, 'ng2-alfresco-datatable': { main: './index.js', defaultExtension: 'js'}, - 'ng2-activiti-form': { main: './index.js', defaultExtension: 'js'} + 'ng2-activiti-form': { main: './index.js', defaultExtension: 'js'}, + 'ng2-activiti-tasklist': { main: './index.js', defaultExtension: 'js'} } }); })(this); diff --git a/ng2-components/ng2-activiti-tasklist/index.ts b/ng2-components/ng2-activiti-tasklist/index.ts index 3e4263e937..a7f9116871 100644 --- a/ng2-components/ng2-activiti-tasklist/index.ts +++ b/ng2-components/ng2-activiti-tasklist/index.ts @@ -38,7 +38,7 @@ import { export * from './src/components/index'; export * from './src/services/activiti-tasklist.service'; -export * from './src/models/filter.model'; +export * from './src/models/index'; export const ACTIVITI_TASKLIST_DIRECTIVES: any[] = [ NoTaskDetailsTemplateComponent, diff --git a/ng2-components/ng2-activiti-tasklist/package.json b/ng2-components/ng2-activiti-tasklist/package.json index 87fbf34d15..86e0e43ece 100644 --- a/ng2-components/ng2-activiti-tasklist/package.json +++ b/ng2-components/ng2-activiti-tasklist/package.json @@ -55,21 +55,29 @@ "@angular/http": "2.0.0", "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", - "@angular/upgrade": "2.0.0", - "@types/node": "^6.0.42", - "alfresco-js-api": "^0.3.0", "core-js": "^2.4.1", - "ng2-activiti-form": "0.3.3", - "ng2-alfresco-core": "0.3.2", - "ng2-alfresco-datatable": "0.3.2", - "ng2-translate": "2.5.0", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.12", "systemjs": "0.19.27", - "zone.js": "^0.6.23" + "zone.js": "^0.6.23", + + "intl": "1.2.4", + "dialog-polyfill": "^0.4.3", + "element.scrollintoviewifneeded-polyfill": "^1.0.1", + "material-design-icons": "2.2.3", + "material-design-lite": "1.2.1", + + "moment": "2.15.1", + "md-date-time-picker": "^2.2.0", + + "ng2-translate": "2.5.0", + "alfresco-js-api": "^0.3.0", + "ng2-activiti-form": "0.3.3", + "ng2-alfresco-core": "0.3.2", + "ng2-alfresco-datatable": "0.3.2" }, "devDependencies": { + "@types/node": "^6.0.42", "@types/core-js": "^0.9.32", "@types/jasmine": "^2.2.33", "concurrently": "^2.2.0", diff --git a/ng2-components/ng2-activiti-tasklist/src/components/activiti-comments.component.spec.ts b/ng2-components/ng2-activiti-tasklist/src/components/activiti-comments.component.spec.ts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/ng2-components/ng2-activiti-tasklist/src/components/activiti-tasklist.component.spec.ts b/ng2-components/ng2-activiti-tasklist/src/components/activiti-tasklist.component.spec.ts index 93d967de73..bb7bfed213 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/activiti-tasklist.component.spec.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/activiti-tasklist.component.spec.ts @@ -18,7 +18,7 @@ import { SimpleChange } from '@angular/core'; import { ActivitiTaskList } from './activiti-tasklist.component'; import { ActivitiTaskListService } from '../services/activiti-tasklist.service'; -import { UserTaskFilterRepresentationModel } from '../models/filter.model'; +import { FilterRepresentationModel } from '../models/filter.model'; import { Observable } from 'rxjs/Rx'; import { ObjectDataRow, DataRowEvent, ObjectDataTableAdapter } from 'ng2-alfresco-datatable'; @@ -98,7 +98,7 @@ describe('ActivitiTaskList', () => { it('should return the filtered task list when the taskFilter is passed', (done) => { spyOn(taskList.activiti, 'getTotalTasks').and.returnValue(Observable.fromPromise(fakeGlobalTotalTasksPromise)); spyOn(taskList.activiti, 'getTasks').and.returnValue(Observable.fromPromise(fakeGlobalTaskPromise)); - taskList.taskFilter = new UserTaskFilterRepresentationModel({filter: { state: 'open', assignment: 'fake-assignee'}}); + taskList.taskFilter = new FilterRepresentationModel({filter: { state: 'open', assignment: 'fake-assignee'}}); taskList.onSuccess.subscribe( (res) => { expect(res).toBeDefined(); @@ -120,7 +120,7 @@ describe('ActivitiTaskList', () => { it('should throw an exception when the response is wrong', (done) => { spyOn(taskList.activiti, 'getTotalTasks').and.returnValue(Observable.fromPromise(fakeErrorTaskPromise)); - taskList.taskFilter = new UserTaskFilterRepresentationModel({filter: { state: 'open', assignment: 'fake-assignee'}}); + taskList.taskFilter = new FilterRepresentationModel({filter: { state: 'open', assignment: 'fake-assignee'}}); taskList.onError.subscribe( (err) => { expect(err).toBeDefined(); @@ -133,7 +133,7 @@ describe('ActivitiTaskList', () => { it('should reload tasks when reload() is called', (done) => { spyOn(taskList.activiti, 'getTotalTasks').and.returnValue(Observable.fromPromise(fakeGlobalTotalTasksPromise)); spyOn(taskList.activiti, 'getTasks').and.returnValue(Observable.fromPromise(fakeGlobalTaskPromise)); - taskList.taskFilter = new UserTaskFilterRepresentationModel({filter: { state: 'open', assignment: 'fake-assignee'}}); + taskList.taskFilter = new FilterRepresentationModel({filter: { state: 'open', assignment: 'fake-assignee'}}); taskList.ngOnInit(); taskList.onSuccess.subscribe( (res) => { expect(res).toBeDefined(); @@ -164,7 +164,7 @@ describe('ActivitiTaskList', () => { it('should reload task list by filter on binding changes', () => { spyOn(taskList, 'load').and.stub(); - const taskFilter = new UserTaskFilterRepresentationModel({filter: { state: 'open', assignment: 'fake-assignee'}}); + const taskFilter = new FilterRepresentationModel({filter: { state: 'open', assignment: 'fake-assignee'}}); let change = new SimpleChange(null, taskFilter); taskList.ngOnChanges({ 'taskFilter': change }); diff --git a/ng2-components/ng2-activiti-tasklist/src/components/activiti-tasklist.component.ts b/ng2-components/ng2-activiti-tasklist/src/components/activiti-tasklist.component.ts index b67cec102b..2b0c2d8c4b 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/activiti-tasklist.component.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/activiti-tasklist.component.ts @@ -19,7 +19,7 @@ import { Component, Input, Output, EventEmitter, OnInit, OnChanges, SimpleChange import { AlfrescoTranslationService } from 'ng2-alfresco-core'; import { ObjectDataTableAdapter, DataTableAdapter, DataRowEvent, ObjectDataRow } from 'ng2-alfresco-datatable'; import { ActivitiTaskListService } from './../services/activiti-tasklist.service'; -import { UserTaskFilterRepresentationModel, TaskQueryRequestRepresentationModel } from '../models/filter.model'; +import { FilterRepresentationModel, TaskQueryRequestRepresentationModel } from '../models/filter.model'; declare let componentHandler: any; @@ -32,7 +32,7 @@ declare let componentHandler: any; export class ActivitiTaskList implements OnInit, OnChanges { @Input() - taskFilter: UserTaskFilterRepresentationModel; + taskFilter: FilterRepresentationModel; @Input() data: DataTableAdapter; @@ -191,13 +191,15 @@ export class ActivitiTaskList implements OnInit, OnChanges { return tasks; } - private convertTaskUserToTaskQuery(userTask: UserTaskFilterRepresentationModel) { - let requestNode = {appDefinitionId: userTask.appId, + private convertTaskUserToTaskQuery(userTask: FilterRepresentationModel) { + let requestNode = { + appDefinitionId: userTask.appId, processDefinitionId: userTask.filter.processDefinitionId, text: userTask.filter.name, assignment: userTask.filter.assignment, state: userTask.filter.state, - sort: userTask.filter.sort}; + sort: userTask.filter.sort + }; return new TaskQueryRequestRepresentationModel(requestNode); } } diff --git a/ng2-components/ng2-activiti-tasklist/src/models/filter.model.ts b/ng2-components/ng2-activiti-tasklist/src/models/filter.model.ts index e54579410b..72fd681bcd 100644 --- a/ng2-components/ng2-activiti-tasklist/src/models/filter.model.ts +++ b/ng2-components/ng2-activiti-tasklist/src/models/filter.model.ts @@ -85,6 +85,9 @@ export class FilterParamRepresentationModel { name: string; state: string; sort: string; + assignment: string; + dueAfter: Date; + dueBefore: Date; constructor(obj?: any) { this.processDefinitionId = obj && obj.processDefinitionId || null; @@ -92,38 +95,6 @@ export class FilterParamRepresentationModel { this.name = obj && obj.name || null; this.state = obj && obj.state || null; this.sort = obj && obj.sort || null; - } -} - -export class UserProcessInstanceFilterRepresentationModel extends FilterRepresentationModel { - public filter: ProcessInstanceFilterRepresentation; - constructor(obj?: any) { - super(obj); - this.filter = new ProcessInstanceFilterRepresentation(obj.filter); - } -} - -export class ProcessInstanceFilterRepresentation extends FilterParamRepresentationModel { - constructor(obj?: any) { - super(obj); - } -} - -export class UserTaskFilterRepresentationModel extends FilterRepresentationModel { - public filter: TaskFilterRepresentationModel; - constructor(obj?: any) { - super(obj); - this.filter = new TaskFilterRepresentationModel(obj.filter); - } -} - -export class TaskFilterRepresentationModel extends FilterParamRepresentationModel { - assignment: string; - dueAfter: Date; - dueBefore: Date; - - constructor(obj?: any) { - super(obj); this.assignment = obj && obj.assignment || null; this.dueAfter = obj && obj.dueAfter || null; this.dueBefore = obj && obj.dueBefore || null; diff --git a/demo-shell-ng2/app/services/notification.service.ts b/ng2-components/ng2-activiti-tasklist/src/models/index.ts similarity index 64% rename from demo-shell-ng2/app/services/notification.service.ts rename to ng2-components/ng2-activiti-tasklist/src/models/index.ts index d93a12144b..2d3fb08a48 100644 --- a/demo-shell-ng2/app/services/notification.service.ts +++ b/ng2-components/ng2-activiti-tasklist/src/models/index.ts @@ -15,17 +15,8 @@ * limitations under the License. */ -import { Injectable } from '@angular/core'; -import { Subject } from 'rxjs/Subject'; - -@Injectable() -export class NotificationService { - - notificationsdSource = new Subject(); - - notifications = this.notificationsdSource.asObservable(); - - sendNotification(message: string) { - this.notificationsdSource.next(message); - } -} +export * from './comment.model'; +export * from './filter.model'; +export * from './icon.model'; +export * from './user.model'; +export * from './task-details.model'; diff --git a/ng2-components/ng2-activiti-tasklist/src/services/activiti-tasklist.service.spec.ts b/ng2-components/ng2-activiti-tasklist/src/services/activiti-tasklist.service.spec.ts index fe51682459..b25120ce93 100644 --- a/ng2-components/ng2-activiti-tasklist/src/services/activiti-tasklist.service.spec.ts +++ b/ng2-components/ng2-activiti-tasklist/src/services/activiti-tasklist.service.spec.ts @@ -23,7 +23,7 @@ import { } from 'ng2-alfresco-core'; import { ActivitiTaskListService } from './activiti-tasklist.service'; import { TaskDetailsModel } from '../models/task-details.model'; -import { UserTaskFilterRepresentationModel, AppDefinitionRepresentationModel } from '../models/filter.model'; +import { FilterRepresentationModel, AppDefinitionRepresentationModel } from '../models/filter.model'; import { Comment } from '../models/comment.model'; declare let AlfrescoApi: any; @@ -415,13 +415,13 @@ describe('ActivitiTaskListService', () => { }); it('should add a filter ', (done) => { - let filterFake = new UserTaskFilterRepresentationModel({ + let filterFake = new FilterRepresentationModel({ name: 'FakeNameFilter', assignment: 'fake-assignement' }); service.addFilter(filterFake).subscribe( - (res: UserTaskFilterRepresentationModel) => { + (res: FilterRepresentationModel) => { expect(res).toBeDefined(); expect(res.id).not.toEqual(''); expect(res.name).toEqual('FakeNameFilter'); diff --git a/ng2-components/ng2-activiti-tasklist/src/services/activiti-tasklist.service.ts b/ng2-components/ng2-activiti-tasklist/src/services/activiti-tasklist.service.ts index a87b5ac354..05411845f8 100644 --- a/ng2-components/ng2-activiti-tasklist/src/services/activiti-tasklist.service.ts +++ b/ng2-components/ng2-activiti-tasklist/src/services/activiti-tasklist.service.ts @@ -18,7 +18,7 @@ import {Injectable} from '@angular/core'; import {AlfrescoAuthenticationService} from 'ng2-alfresco-core'; import {Observable} from 'rxjs/Rx'; -import {UserTaskFilterRepresentationModel} from '../models/filter.model'; +import {FilterRepresentationModel} from '../models/filter.model'; import {TaskQueryRequestRepresentationModel} from '../models/filter.model'; import {Comment} from '../models/comment.model'; import {User} from '../models/user.model'; @@ -52,9 +52,9 @@ export class ActivitiTaskListService { getTaskListFilters(appId?: string): Observable { return Observable.fromPromise(this.callApiTaskFilters(appId)) .map((response: any) => { - let filters: UserTaskFilterRepresentationModel[] = []; - response.data.forEach((filter: UserTaskFilterRepresentationModel) => { - let filterModel = new UserTaskFilterRepresentationModel(filter); + let filters: FilterRepresentationModel[] = []; + response.data.forEach((filter: FilterRepresentationModel) => { + let filterModel = new FilterRepresentationModel(filter); filters.push(filterModel); }); if (response && response.data && response.data.length === 0) { @@ -127,10 +127,10 @@ export class ActivitiTaskListService { /** * Create and return the default filters * @param appId - * @returns {UserTaskFilterRepresentationModel[]} + * @returns {FilterRepresentationModel[]} */ - createDefaultFilter(appId: string): UserTaskFilterRepresentationModel[] { - let filters: UserTaskFilterRepresentationModel[] = []; + createDefaultFilter(appId: string): FilterRepresentationModel[] { + let filters: FilterRepresentationModel[] = []; let involvedTasksFilter = this.getInvolvedTasksFilterInstance(appId); this.addFilter(involvedTasksFilter); @@ -166,13 +166,13 @@ export class ActivitiTaskListService { /** * Add a filter - * @param filter - UserTaskFilterRepresentationModel - * @returns {UserTaskFilterRepresentationModel} + * @param filter - FilterRepresentationModel + * @returns {FilterRepresentationModel} */ - addFilter(filter: UserTaskFilterRepresentationModel): Observable { + addFilter(filter: FilterRepresentationModel): Observable { return Observable.fromPromise(this.callApiAddFilter(filter)) .map(res => res) - .map((response: UserTaskFilterRepresentationModel) => { + .map((response: FilterRepresentationModel) => { return response; }).catch(this.handleError); } @@ -256,7 +256,7 @@ export class ActivitiTaskListService { return this.authService.getAlfrescoApi().activiti.taskApi.addSubtask(task.parentTaskId, task); } - private callApiAddFilter(filter: UserTaskFilterRepresentationModel) { + private callApiAddFilter(filter: FilterRepresentationModel) { return this.authService.getAlfrescoApi().activiti.userFiltersApi.createUserTaskFilter(filter); } @@ -280,10 +280,10 @@ export class ActivitiTaskListService { /** * Return a static Involved filter instance * @param appId - * @returns {UserTaskFilterRepresentationModel} + * @returns {FilterRepresentationModel} */ - getInvolvedTasksFilterInstance(appId: string): UserTaskFilterRepresentationModel { - return new UserTaskFilterRepresentationModel({ + getInvolvedTasksFilterInstance(appId: string): FilterRepresentationModel { + return new FilterRepresentationModel({ 'name': 'Involved Tasks', 'appId': appId, 'recent': false, @@ -295,10 +295,10 @@ export class ActivitiTaskListService { /** * Return a static My task filter instance * @param appId - * @returns {UserTaskFilterRepresentationModel} + * @returns {FilterRepresentationModel} */ - getMyTasksFilterInstance(appId: string): UserTaskFilterRepresentationModel { - return new UserTaskFilterRepresentationModel({ + getMyTasksFilterInstance(appId: string): FilterRepresentationModel { + return new FilterRepresentationModel({ 'name': 'My Tasks', 'appId': appId, 'recent': false, @@ -310,10 +310,10 @@ export class ActivitiTaskListService { /** * Return a static Queued filter instance * @param appId - * @returns {UserTaskFilterRepresentationModel} + * @returns {FilterRepresentationModel} */ - getQueuedTasksFilterInstance(appId: string): UserTaskFilterRepresentationModel { - return new UserTaskFilterRepresentationModel({ + getQueuedTasksFilterInstance(appId: string): FilterRepresentationModel { + return new FilterRepresentationModel({ 'name': 'Queued Tasks', 'appId': appId, 'recent': false, @@ -325,10 +325,10 @@ export class ActivitiTaskListService { /** * Return a static Completed filter instance * @param appId - * @returns {UserTaskFilterRepresentationModel} + * @returns {FilterRepresentationModel} */ - getCompletedTasksFilterInstance(appId: string): UserTaskFilterRepresentationModel { - return new UserTaskFilterRepresentationModel({ + getCompletedTasksFilterInstance(appId: string): FilterRepresentationModel { + return new FilterRepresentationModel({ 'name': 'Completed Tasks', 'appId': appId, 'recent': true, diff --git a/ng2-components/ng2-alfresco-core/.npmignore b/ng2-components/ng2-alfresco-core/.npmignore index a38d07049e..85ed1df8ce 100644 --- a/ng2-components/ng2-alfresco-core/.npmignore +++ b/ng2-components/ng2-alfresco-core/.npmignore @@ -1,7 +1,6 @@ npm-debug.log .idea -assets/ coverage/ demo/ node_modules diff --git a/ng2-components/ng2-alfresco-core/README.md b/ng2-components/ng2-alfresco-core/README.md index a828f4c977..459deca8b3 100644 --- a/ng2-components/ng2-alfresco-core/README.md +++ b/ng2-components/ng2-alfresco-core/README.md @@ -15,11 +15,23 @@ npm downloads + + license + + + alfresco component + + + angular 2 + + + typescript + + + node version +

-Core library for other ng2-alfresco components. -This should be added as a dependency for any project using the components. - ## Prerequisites Before you start using this development framework, make sure you have installed all required software and done all the @@ -55,8 +67,6 @@ npm install --save ng2-alfresco-core Provides access to initialized **AlfrescoJSApi** instance. ```ts -import { OnInit } from '@angular/core'; -import { AlfrescoApiService } from 'ng2-alfresco-core'; export class MyComponent implements OnInit { @@ -125,38 +135,44 @@ export class MyComponent implements OnInit { The authentication service is used inside the [login component](../ng2-alfresco-login) and is possible to find there an example of how to use it. ```ts -import { Component } from '@angular/core'; -import { bootstrap } from '@angular/platform-browser-dynamic'; -import { HTTP_PROVIDERS } from '@angular/http'; - -import { - ALFRESCO_CORE_PROVIDERS, - AlfrescoSettingsService, - AlfrescoAuthenticationService -} from 'ng2-alfresco-core'; +import { NgModule, Component } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { CoreModule, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; @Component({ - selector: 'my-app', + selector: 'alfresco-app-demo', template: `
Authentication failed to ip {{ ecmHost }} with user: admin, admin
- Authentication successfull to ip {{ ecmHost }} with user: admin, admin, your token is {{ token }} +
ECM
+ Authentication successfull to ip {{ ecmHost }} with user: admin, admin
+ your token is {{ tokenEcm }}
+
BPM
+ Authentication successfull to ip {{ bpmHost }} with user: admin, admin
+ your token is {{ tokenBpm }}
` }) class MyDemoApp { authenticated: boolean = false; - ecmHost: string = 'http://127.0.0.1:8080'; + public ecmHost: string = 'http://localhost:8080'; - token: string; + public bpmHost: string = 'http://localhost:9999'; + + tokenBpm: string; + + tokenEcm: string; constructor(public alfrescoAuthenticationService: AlfrescoAuthenticationService, private alfrescoSettingsService: AlfrescoSettingsService) { alfrescoSettingsService.ecmHost = this.ecmHost; - alfrescoSettingsService.setProviders('ECM'); + alfrescoSettingsService.bpmHost = this.bpmHost; + + alfrescoSettingsService.setProviders('ALL'); } ngOnInit() { @@ -166,7 +182,8 @@ class MyDemoApp { login() { this.alfrescoAuthenticationService.login('admin', 'admin').subscribe( token => { - this.token = token.ticket; + this.tokenBpm = this.alfrescoAuthenticationService.getTicketBpm(); + this.tokenEcm = this.alfrescoAuthenticationService.getTicketEcm(); this.authenticated = true; }, error => { @@ -175,11 +192,19 @@ class MyDemoApp { }); } } -bootstrap(MyDemoApp, [ - HTTP_PROVIDERS, - ALFRESCO_CORE_PROVIDERS -]); +@NgModule({ + imports: [ + BrowserModule, + CoreModule.forRoot() + ], + declarations: [MyDemoApp], + bootstrap: [MyDemoApp] +}) +export class AppModule { +} + +platformBrowserDynamic().bootstrapModule(AppModule); ``` #### Renditions Service @@ -198,10 +223,53 @@ npm install npm run build ``` -### Additional scripts +## Build from sources -- `npm run build:w` builds the files and keep watching for changes -- `npm test` runs unit tests -- `npm run test-browser` runs unit tests in browser. This task rebuilds all the code, runs tslint, license checks and other quality check tools +Alternatively you can build component from sources with the following commands: + + +```sh +npm install +npm run build +``` + +### Build the files and keep watching for changes + +```sh +$ npm run build:w +``` + +## Running unit tests + +```sh +npm test +``` + +### Running unit tests in browser + +```sh +npm test-browser +``` + +This task rebuilds all the code, runs tslint, license checks and other quality check tools before performing unit testing. -- `npm run coverage` runs code coverage report + +### Code coverage + +```sh +npm run coverage +``` + +## 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 | + +## License + +[Apache Version 2.0](https://github.com/Alfresco/alfresco-ng2-components/blob/master/LICENSE) \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-core/package.json b/ng2-components/ng2-alfresco-core/package.json index 9fbd740b28..bd054a68e1 100644 --- a/ng2-components/ng2-alfresco-core/package.json +++ b/ng2-components/ng2-alfresco-core/package.json @@ -53,6 +53,8 @@ "alfresco" ], "dependencies": { + "@angular/router": "3.0.0", + "@angular/upgrade": "2.0.0", "@angular/common": "2.0.0", "@angular/compiler": "2.0.0", "@angular/core": "2.0.0", @@ -60,18 +62,23 @@ "@angular/http": "2.0.0", "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", - "@angular/upgrade": "2.0.0", - "@types/node": "^6.0.42", - "alfresco-js-api": "^0.3.0", "core-js": "^2.4.1", - "ng2-translate": "2.5.0", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.12", "systemjs": "0.19.27", - "zone.js": "^0.6.23" + "zone.js": "^0.6.23", + + "ng2-translate": "2.5.0", + "alfresco-js-api": "^0.3.0", + + "intl": "1.2.4", + "dialog-polyfill": "^0.4.3", + "element.scrollintoviewifneeded-polyfill": "^1.0.1", + "material-design-icons": "2.2.3", + "material-design-lite": "1.2.1" }, "devDependencies": { + "@types/node": "^6.0.42", "@types/core-js": "^0.9.32", "@types/jasmine": "^2.2.33", "cpx": "1.3.1", @@ -86,7 +93,6 @@ "karma-mocha-reporter": "2.0.3", "license-check": "1.1.5", "remap-istanbul": "0.6.3", - "rimraf": "2.5.2", "traceur": "0.0.91", "tslint": "3.15.1", "typescript": "^2.0.3", diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.ts index 90064f06ef..c91adc4258 100644 --- a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.ts +++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.ts @@ -21,6 +21,8 @@ import { AlfrescoSettingsService } from './AlfrescoSettings.service'; import { AlfrescoApiService } from './AlfrescoApi.service'; import * as alfrescoApi from 'alfresco-js-api'; import { AlfrescoApi } from 'alfresco-js-api'; +import { Subject } from 'rxjs/Subject'; + /** * The AlfrescoAuthenticationService provide the login service and store the ticket in the localStorage */ @@ -29,6 +31,10 @@ export class AlfrescoAuthenticationService { alfrescoApi: AlfrescoApi; + public loginSubject: Subject = new Subject(); + + public logoutSubject: Subject = new Subject(); + /** * Constructor * @param settingsService @@ -84,6 +90,7 @@ export class AlfrescoAuthenticationService { return Observable.fromPromise(this.callApiLogin(username, password)) .map((response: any) => { this.saveTickets(); + this.loginSubject.next(response); return {type: this.settingsService.getProviders(), ticket: response}; }) .catch(this.handleError); @@ -105,10 +112,11 @@ export class AlfrescoAuthenticationService { * @returns {Observable|Observable} */ public logout() { + this.removeTicket(); return Observable.fromPromise(this.callApiLogout()) .map(res => res) .do(response => { - this.removeTicket(); + this.logoutSubject.next(response); return response; }) .catch(this.handleError); diff --git a/ng2-components/ng2-alfresco-datatable/.npmignore b/ng2-components/ng2-alfresco-datatable/.npmignore index 16ba3e61e5..c5ca623298 100644 --- a/ng2-components/ng2-alfresco-datatable/.npmignore +++ b/ng2-components/ng2-alfresco-datatable/.npmignore @@ -1,7 +1,6 @@ npm-debug.log .idea -assets/ coverage/ node_modules typings/ diff --git a/ng2-components/ng2-alfresco-datatable/README.md b/ng2-components/ng2-alfresco-datatable/README.md index d533f275cc..60f33a654d 100644 --- a/ng2-components/ng2-alfresco-datatable/README.md +++ b/ng2-components/ng2-alfresco-datatable/README.md @@ -34,96 +34,133 @@ ## Prerequisites -Before you start using this development framework, make sure you have installed all required software and done all the +Before you start using this development framework, make sure you have installed all required software and done all the necessary configuration, see this [page](https://github.com/Alfresco/alfresco-ng2-components/blob/master/PREREQUISITES.md). ## Install -```sh -npm install --save ng2-alfresco-datatable -``` +Follow the 3 steps below: -### Dependencies +1. Npm -You must separately install the following libraries for your application: - -- [ng2-translate](https://github.com/ocombe/ng2-translate) -- [ng2-alfresco-core](https://www.npmjs.com/package/ng2-alfresco-core) + ```sh + npm install ng2-alfresco-datatable --save + ``` -```sh -npm install --save ng2-translate ng2-alfresco-core -``` +2. Html -#### Material Design Lite + Include these dependencies in your index.html page: -The style of this component is based on [material design](https://getmdl.io/), so if you want to visualize it correctly you have to add the material -design dependency to your project: + ```html -```sh -npm install --save material-design-icons material-design-lite -``` + + + + -Also make sure you include these dependencies in your `index.html` file: + + + -```html - - - - -``` + + + + + + + + + + + + + + + + ``` + +3. SystemJs + + Add the following components to your systemjs.config.js file: + + - ng2-translate + - alfresco-js-api + - ng2-alfresco-core + - ng2-alfresco-datatable + + Please refer to the following example file: [systemjs.config.js](demo/systemjs + .config.js) . ## Basic usage example +Usage example of this component : **my.component.ts** ```ts + +import { NgModule, Component } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { CoreModule } from 'ng2-alfresco-core'; +import { DataTableModule } from 'ng2-alfresco-datatable'; +import { ObjectDataTableAdapter } from 'ng2-alfresco-datatable'; import { Component } from '@angular/core'; -import { - CONTEXT_MENU_DIRECTIVES, - CONTEXT_MENU_PROVIDERS -} from 'ng2-alfresco-core'; -import { - ALFRESCO_DATATABLE_DIRECTIVES, - ObjectDataTableAdapter -} from 'ng2-alfresco-datatable'; +import { CONTEXT_MENU_DIRECTIVES, CONTEXT_MENU_PROVIDERS } from 'ng2-alfresco-core'; +import { ALFRESCO_DATATABLE_DIRECTIVES, ObjectDataTableAdapter } from 'ng2-alfresco-datatable'; @Component({ - selector: 'my-view', + selector: 'alfresco-app-demo', template: ` `, directives: [ALFRESCO_DATATABLE_DIRECTIVES, CONTEXT_MENU_DIRECTIVES], providers: [CONTEXT_MENU_PROVIDERS] }) -export class MyView { +export class DataTableDemo { data: ObjectDataTableAdapter; constructor() { this.data = new ObjectDataTableAdapter( // data [ - { id: 1, name: 'Name 1' }, - { id: 2, name: 'Name 2' } + {id: 1, name: 'Name 1'}, + {id: 2, name: 'Name 2'} ], // schema [ - { - type: 'text', - key: 'id', - title: 'Id', - sortable: true + { + type: 'text', + key: 'id', + title: 'Id', + sortable: true }, - { - type: 'text', - key: 'name', - title: 'Name', - cssClass: 'full-width', - sortable: true + { + type: 'text', + key: 'name', + title: 'Name', + cssClass: 'full-width', + sortable: true } ] ); } } + +@NgModule({ + imports: [ + BrowserModule, + CoreModule.forRoot(), + DataTableModule + ], + declarations: [DataTableDemo], + bootstrap: [DataTableDemo] +}) +export class AppModule { +} + +platformBrowserDynamic().bootstrapModule(AppModule); + + ``` ![DataTable demo](docs/assets/datatable-demo.png) @@ -132,10 +169,10 @@ export class MyView { | Name | Type | Default | Description | --- | --- | --- | --- | -| data | DataTableAdapter | instance of **ObjectDataTableAdapter** | data source | -| multiselect | boolean | false | Toggles multiple row selection, renders checkboxes at the beginning of each row | -| actions | boolean | false | Toggles data actions column | -| fallbackThubnail | string | | Fallback image for row ehre thubnail is missing| +| `data` | DataTableAdapter | instance of **ObjectDataTableAdapter** | data source | +| `multiselect` | boolean | false | Toggles multiple row selection, renders checkboxes at the beginning of each row | +| `actions` | boolean | false | Toggles data actions column | +| `fallbackThubnail` | string | | Fallback image for row ehre thubnail is missing| ### Events @@ -366,6 +403,7 @@ let data = new ObjectDataTableAdapter( ``` ## Generate schema + Is possible to auto generate your schema if you have only the data row ```ts @@ -397,11 +435,11 @@ let schema = ObjectDataTableAdapter.generateSchema(data); ``` - ## Build from sources Alternatively you can build component from sources with the following commands: + ```sh npm install npm run build @@ -412,8 +450,8 @@ npm run build ```sh $ npm run build:w ``` - -### Running unit tests + +## Running unit tests ```sh npm test @@ -425,11 +463,35 @@ npm test npm test-browser ``` -This task rebuilds all the code, runs tslint, license checks and other quality check tools -before performing unit testing. +This task rebuilds all the code, runs tslint, license checks and other quality check tools +before performing unit testing. ### Code coverage ```sh npm run coverage ``` + +## Demo + +If you want have a demo of how the component works, please check the demo folder : + +```sh +cd demo +npm install +npm start +``` + +## 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 | + +## License + +[Apache Version 2.0](https://github.com/Alfresco/alfresco-ng2-components/blob/master/LICENSE) \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-datatable/demo/index.html b/ng2-components/ng2-alfresco-datatable/demo/index.html index c32a86e1e9..c9a7a00b04 100644 --- a/ng2-components/ng2-alfresco-datatable/demo/index.html +++ b/ng2-components/ng2-alfresco-datatable/demo/index.html @@ -26,7 +26,7 @@ - + diff --git a/ng2-components/ng2-alfresco-datatable/demo/package.json b/ng2-components/ng2-alfresco-datatable/demo/package.json index 8f52bb1a96..f378ca4bc4 100644 --- a/ng2-components/ng2-alfresco-datatable/demo/package.json +++ b/ng2-components/ng2-alfresco-datatable/demo/package.json @@ -29,25 +29,25 @@ "@angular/http": "2.0.0", "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", - "@angular/upgrade": "2.0.0", - "@types/node": "^6.0.42", "core-js": "^2.4.1", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.12", "systemjs": "0.19.27", "zone.js": "^0.6.23", - "license-check": "1.1.5", + "intl": "1.2.4", + "dialog-polyfill": "^0.4.3", + "element.scrollintoviewifneeded-polyfill": "^1.0.1", + "material-design-icons": "2.2.3", + "material-design-lite": "1.2.1", "ng2-translate": "2.5.0", + "alfresco-js-api": "^0.3.0", "ng2-alfresco-core": "0.3.2", - "ng2-alfresco-datatable": "0.3.2", - - "material-design-icons": "2.2.3", - "material-design-lite": "1.2.1" + "ng2-alfresco-datatable": "0.3.2" }, "devDependencies": { + "@types/node": "^6.0.42", "@types/core-js": "^0.9.32", "@types/jasmine": "^2.2.33", "concurrently": "^2.2.0", diff --git a/ng2-components/ng2-alfresco-datatable/demo/src/main.ts b/ng2-components/ng2-alfresco-datatable/demo/src/main.ts index 98cd125fbe..8b9daed126 100644 --- a/ng2-components/ng2-alfresco-datatable/demo/src/main.ts +++ b/ng2-components/ng2-alfresco-datatable/demo/src/main.ts @@ -30,7 +30,7 @@ import { } from 'ng2-alfresco-datatable'; @Component({ - selector: 'alfresco-datatable-demo', + selector: 'alfresco-app-demo', template: `
diff --git a/ng2-components/ng2-alfresco-datatable/package.json b/ng2-components/ng2-alfresco-datatable/package.json index 178f79c6d9..8966f4749f 100644 --- a/ng2-components/ng2-alfresco-datatable/package.json +++ b/ng2-components/ng2-alfresco-datatable/package.json @@ -51,20 +51,24 @@ "@angular/http": "2.0.0", "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", - "@angular/upgrade": "2.0.0", - "@types/node": "^6.0.42", "core-js": "^2.4.1", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.12", "systemjs": "0.19.27", "zone.js": "^0.6.23", - "alfresco-js-api": "^0.3.0", + "intl": "1.2.4", + "dialog-polyfill": "^0.4.3", + "element.scrollintoviewifneeded-polyfill": "^1.0.1", + "material-design-icons": "2.2.3", + "material-design-lite": "1.2.1", + "ng2-translate": "2.5.0", + "alfresco-js-api": "^0.3.0", "ng2-alfresco-core": "0.3.2" }, "devDependencies": { + "@types/node": "^6.0.42", "@types/core-js": "^0.9.32", "@types/jasmine": "^2.2.33", "concurrently": "^2.2.0", diff --git a/ng2-components/ng2-alfresco-documentlist/.npmignore b/ng2-components/ng2-alfresco-documentlist/.npmignore index 16ba3e61e5..c5ca623298 100644 --- a/ng2-components/ng2-alfresco-documentlist/.npmignore +++ b/ng2-components/ng2-alfresco-documentlist/.npmignore @@ -1,7 +1,6 @@ npm-debug.log .idea -assets/ coverage/ node_modules typings/ diff --git a/ng2-components/ng2-alfresco-documentlist/README.md b/ng2-components/ng2-alfresco-documentlist/README.md index 5d0880d7c9..738bd97733 100644 --- a/ng2-components/ng2-alfresco-documentlist/README.md +++ b/ng2-components/ng2-alfresco-documentlist/README.md @@ -34,49 +34,63 @@ ## Prerequisites -Before you start using this development framework, make sure you have installed all required software and done all the -necessary configuration, see this [page](https://github.com/Alfresco/alfresco-ng2-components/blob/master/PREREQUISITES.md). +Before you start using this development framework, make sure you have installed all required software and done all the +necessary configuration [prerequisites](https://github.com/Alfresco/alfresco-ng2-components/blob/master/PREREQUISITES.md). ## Install -```sh -npm install --save ng2-alfresco-documentlist -``` +Follow the 3 steps below: -### Dependencies +1. Npm -Add the following dependency to your index.html: + ```sh + npm install ng2-alfresco-documentlist --save + ``` -```html - -``` +2. Html -The following component needs to be added to your `systemjs.config.js` file: + Include these dependencies in your index.html page: -- [ng2-translate](https://github.com/ocombe/ng2-translate) -- [ng2-alfresco-core](https://www.npmjs.com/package/ng2-alfresco-core) -- [ng2-alfresco-datatable](https://www.npmjs.com/package/ng2-alfresco-datatable) + ```html -You can get more details in the -[example implementation](https://github.com/Alfresco/alfresco-ng2-components/blob/master/ng2-components/ng2-alfresco-documentlist/demo/systemjs.config.js). + + + + -#### Material Design Lite + + + -The style of this component is based on [material design](https://getmdl.io/), so if you want to visualize it correctly you have to add the material -design dependency to your project: + + + + -```sh -npm install --save material-design-icons material-design-lite -``` + + + + -Also make sure you include these dependencies in your `index.html` file: + + + + -```html - - - - -``` + ``` + +3. SystemJs + + Add the following components to your systemjs.config.js file: + + - ng2-translate + - alfresco-js-api + - ng2-alfresco-core + - ng2-alfresco-datatable + - ng2-alfresco-documentlist + + Please refer to the following example file: [systemjs.config.js](demo/systemjs + .config.js) . ## Basic usage @@ -91,28 +105,88 @@ Also make sure you include these dependencies in your `index.html` file: ``` +Usage example of this component : + +**main.ts** +```ts + +import { NgModule, Component, ViewChild } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { CoreModule } from 'ng2-alfresco-core'; +import { DataTableModule } from 'ng2-alfresco-datatable'; +import { DocumentListModule, DocumentList } from 'ng2-alfresco-documentlist'; +import { AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; + +@Component({ + selector: 'alfresco-app-demo', + template: ` + ` +}) +class DocumentListDemo { + + @ViewChild(DocumentList) + documentList: DocumentList; + + constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) { + settingsService.ecmHost = 'http://localhost:8080'; + + this.authService.login('admin', 'admin').subscribe( + ticket => { + console.log(ticket); + this.documentList.reload(); + }, + error => { + console.log(error); + }); + } +} + +@NgModule({ + imports: [ + BrowserModule, + CoreModule.forRoot(), + DataTableModule, + DocumentListModule.forRoot() + ], + declarations: [DocumentListDemo], + bootstrap: [DocumentListDemo] +}) +export class AppModule { +} + +platformBrowserDynamic().bootstrapModule(AppModule); + + +``` + ### Properties | Name | Type | Default | Description | | --- | --- | --- | --- | -| navigate | boolean | true | Toggles navigation to folder content or file preview | -| navigationMode | string (click\|dblclick) | dblclick | User interaction for folder navigation or file preview | -| thumbnails | boolean | false | Show document thumbnails rather than icons | -| fallbackThubnail | string | | Fallback image for row ehre thubnail is missing| -| multiselect | boolean | false | Toggles multiselect mode | -| contentActions | boolean | false | Toggles content actions for each row | -| contextMenuActions | boolean | false | Toggles context menus for each row | -| rowFilter | `RowFilter` | | Custom row filter, [see more](#custom-row-filter). -| imageResolver | `ImageResolver` | | Custom image resolver, [see more](#custom-image-resolver). +| `navigate` | boolean | true | Toggles navigation to folder content or file preview | +| `navigationMode` | string (click\|dblclick) | dblclick | User interaction for folder navigation or file preview | +| `thumbnails` | boolean | false | Show document thumbnails rather than icons | +| `fallbackThubnail` | string | | Fallback image for row ehre thubnail is missing| +| `multiselect` | boolean | false | Toggles multiselect mode | +| `contentActions` | boolean | false | Toggles content actions for each row | +| `contextMenuActions` | boolean | false | Toggles context menus for each row | +| `rowFilter` | `RowFilter` | | Custom row filter, [see more](#custom-row-filter). +| `imageResolver` | `ImageResolver` | | Custom image resolver, [see more](#custom-image-resolver). ### Events | Name | Description | | --- | --- | -| nodeClick | Emitted when user clicks the node | -| nodeDblClick | Emitted when user double-clicks the node | -| folderChange | Emitted upon display folder changed | -| preview | Emitted when document preview is requested either with single or double click | +| `nodeClick` | Emitted when user clicks the node | +| `nodeDblClick` | Emitted when user double-clicks the node | +| `folderChange` | Emitted upon display folder changed | +| `preview` | Emitted when document preview is requested either with single or double click | _For a complete example source code please refer to @@ -204,13 +278,13 @@ HTML attributes: | Name | Type | Default | Description | --- | --- | --- | --- | -| title | string | | Column title | -| sr-title | string | | Screen reader title, used only when `title` is empty | -| key | string | | Column source key, example: `createdByUser.displayName` | -| sortable | boolean | false | Toggle sorting ability via column header clicks | -| class | string | | CSS class list, example: `full-width ellipsis-cell` | -| type | string | text | Column type, text\|date\|number | -| format | string | | Value format pattern | +| `title` | string | | Column title | +| `sr-title` | string | | Screen reader title, used only when `title` is empty | +| `key` | string | | Column source key, example: `createdByUser.displayName` | +| `sortable` | boolean | false | Toggle sorting ability via column header clicks | +| `class`| string | | CSS class list, example: `full-width ellipsis-cell` | +| `type` | string | text | Column type, text\|date\|number | +| `format` | string | | Value format pattern | For `date` column type the [DatePipe](https://angular.io/docs/ts/latest/api/common/DatePipe-class.html) formatting is used. For a full list of available `format` values please refer to [DatePipe](https://angular.io/docs/ts/latest/api/common/DatePipe-class.html) documentation. @@ -660,7 +734,8 @@ by means of custom application service. ## Build from sources -You can build component from sources with the following commands: +Alternatively you can build component from sources with the following commands: + ```sh npm install @@ -672,8 +747,8 @@ npm run build ```sh $ npm run build:w ``` - -### Running unit tests + +## Running unit tests ```sh npm test @@ -685,11 +760,35 @@ npm test npm test-browser ``` -This task rebuilds all the code, runs tslint, license checks and other quality check tools -before performing unit testing. +This task rebuilds all the code, runs tslint, license checks and other quality check tools +before performing unit testing. ### Code coverage ```sh npm run coverage ``` + +## Demo + +If you want have a demo of how the component works, please check the demo folder : + +```sh +cd demo +npm install +npm start +``` + +## 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 | + +## License + +[Apache Version 2.0](https://github.com/Alfresco/alfresco-ng2-components/blob/master/LICENSE) \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-documentlist/demo/index.html b/ng2-components/ng2-alfresco-documentlist/demo/index.html index 8d2c80e4b8..46982ae396 100644 --- a/ng2-components/ng2-alfresco-documentlist/demo/index.html +++ b/ng2-components/ng2-alfresco-documentlist/demo/index.html @@ -31,7 +31,7 @@ - + diff --git a/ng2-components/ng2-alfresco-documentlist/demo/package.json b/ng2-components/ng2-alfresco-documentlist/demo/package.json index f2f4226a1e..41a540314d 100644 --- a/ng2-components/ng2-alfresco-documentlist/demo/package.json +++ b/ng2-components/ng2-alfresco-documentlist/demo/package.json @@ -24,25 +24,26 @@ "@angular/http": "2.0.0", "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", - "@angular/upgrade": "2.0.0", - "@types/node": "^6.0.42", "core-js": "^2.4.1", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.12", "systemjs": "0.19.27", "zone.js": "^0.6.23", - "material-design-icons": "2.2.3", - "material-design-lite": "1.1.3", - "ng2-translate": "2.5.0", "intl": "1.2.4", + "dialog-polyfill": "^0.4.3", + "element.scrollintoviewifneeded-polyfill": "^1.0.1", + "material-design-icons": "2.2.3", + "material-design-lite": "1.2.1", + + "ng2-translate": "2.5.0", "alfresco-js-api": "^0.3.0", - "ng2-alfresco-core": "^0.3.0", - "ng2-alfresco-documentlist": "^0.3.0", - "ng2-alfresco-datatable": "^0.3.0" + "ng2-alfresco-core": "0.3.2", + "ng2-alfresco-datatable": "0.3.2", + "ng2-alfresco-documentlist": "^0.3.0" }, "devDependencies": { + "@types/node": "^6.0.42", "@types/core-js": "^0.9.32", "@types/jasmine": "^2.2.33", "concurrently": "^2.2.0", diff --git a/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts b/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts index cd7259ee9f..a094e8b144 100644 --- a/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts +++ b/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts @@ -15,13 +15,12 @@ * limitations under the License. */ - -import { NgModule, Component, OnInit } from '@angular/core'; +import { NgModule, Component, OnInit, ViewChild } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { CoreModule } from 'ng2-alfresco-core'; import { DataTableModule } from 'ng2-alfresco-datatable'; -import { DocumentListModule } from 'ng2-alfresco-documentlist'; +import { DocumentListModule, DocumentList } from 'ng2-alfresco-documentlist'; import { AlfrescoSettingsService, @@ -32,7 +31,7 @@ import { import { DocumentActionsService } from 'ng2-alfresco-documentlist'; @Component({ - selector: 'alfresco-documentlist-demo', + selector: 'alfresco-app-demo', template: `

@@ -142,11 +141,16 @@ import { DocumentActionsService } from 'ng2-alfresco-documentlist'; class DocumentListDemo implements OnInit { currentPath: string = '/'; + authenticated: boolean = false; - ecmHost: string = 'http://devproducts-platform.alfresco.me'; + + ecmHost: string = 'http://localhost:8080'; ticket: string; + @ViewChild(DocumentList) + documentList: DocumentList; + constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService, translation: AlfrescoTranslationService, private documentActions: DocumentActionsService) { @@ -194,6 +198,7 @@ class DocumentListDemo implements OnInit { console.log(ticket); this.ticket = this.authService.getTicketEcm(); this.authenticated = true; + this.documentList.reload(); }, error => { console.log(error); diff --git a/ng2-components/ng2-alfresco-documentlist/package.json b/ng2-components/ng2-alfresco-documentlist/package.json index 93290cb4c4..0de3b16bfb 100644 --- a/ng2-components/ng2-alfresco-documentlist/package.json +++ b/ng2-components/ng2-alfresco-documentlist/package.json @@ -59,21 +59,25 @@ "@angular/http": "2.0.0", "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", - "@angular/upgrade": "2.0.0", - "@types/node": "^6.0.42", - "@types/node": "^6.0.42", - "alfresco-js-api": "^0.3.1", "core-js": "^2.4.1", - "ng2-alfresco-core": "0.3.2", - "ng2-alfresco-datatable": "0.3.2", - "ng2-translate": "2.5.0", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.12", "systemjs": "0.19.27", - "zone.js": "^0.6.23" + "zone.js": "^0.6.23", + + "intl": "1.2.4", + "dialog-polyfill": "^0.4.3", + "element.scrollintoviewifneeded-polyfill": "^1.0.1", + "material-design-icons": "2.2.3", + "material-design-lite": "1.2.1", + + "ng2-translate": "2.5.0", + "alfresco-js-api": "^0.3.0", + "ng2-alfresco-core": "0.3.2", + "ng2-alfresco-datatable": "0.3.2" }, "devDependencies": { + "@types/node": "^6.0.42", "@types/core-js": "^0.9.32", "@types/jasmine": "^2.2.33", "concurrently": "^2.2.0", diff --git a/ng2-components/ng2-alfresco-login/.npmignore b/ng2-components/ng2-alfresco-login/.npmignore index 16ba3e61e5..c5ca623298 100644 --- a/ng2-components/ng2-alfresco-login/.npmignore +++ b/ng2-components/ng2-alfresco-login/.npmignore @@ -1,7 +1,6 @@ npm-debug.log .idea -assets/ coverage/ node_modules typings/ diff --git a/ng2-components/ng2-alfresco-login/README.md b/ng2-components/ng2-alfresco-login/README.md index 38dfda9135..1735cbcfc2 100644 --- a/ng2-components/ng2-alfresco-login/README.md +++ b/ng2-components/ng2-alfresco-login/README.md @@ -1,4 +1,5 @@ -# Alfresco Login Component for Angular 2 +# Alfresco Core Component for Angular 2 +

travis
@@ -31,91 +32,99 @@
   </a>
 </p>
 
-### Node
-To correctly use this component check that on your machine is running Node version 5.0.0 or higher.
+## Prerequisites
+
+Before you start using this development framework, make sure you have installed all required software and done all the
+necessary configuration, see this [page](https://github.com/Alfresco/alfresco-ng2-components/blob/master/PREREQUISITES.md).
 
 ## Install
 
-```sh
-npm install --save ng2-alfresco-login
-```
+Follow the 3 steps below:
 
-Components included:
+1. Npm
 
-* Alfresco Login Component
-* Alfresco Authentication Service
+    ```sh
+    npm install ng2-alfresco-login --save
+    ```
 
-## Dependencies
+2. Html
 
-Add the following dependency to your index.html:
+    Include these dependencies in your index.html page:
 
-```html
-<script src="node_modules/alfresco-js-api/dist/alfresco-js-api.js"></script>
-```
+    ```html
 
-The following component needs to be added to your systemjs.config: 
+    <!-- Google Material Design Lite -->
+    <link rel="stylesheet" href="node_modules/material-design-lite/material.min.css">
+    <script src="node_modules/material-design-lite/material.min.js"></script>
+    <link rel="stylesheet" href="node_modules/material-design-icons/iconfont/material-icons.css">
 
-- ng2-translate
-- ng2-alfresco-core
-- ng2-alfresco-login
+    <!-- Polyfill(s) for Safari (pre-10.x) -->
+    <script src="node_modules/intl/dist/Intl.min.js"></script>
+    <script src="node_modules/intl/locale-data/jsonp/en.js"></script>
 
-Please refer to the following example to have an idea of how your systemjs.config should look like :
+    <!-- Polyfill(s) for older browsers -->
+    <script src="node_modules/core-js/client/shim.min.js"></script>
+    <script src="//cdnjs.cloudflare.com/ajax/libs/dom4/1.8.3/dom4.js"></script>
+    <script src="node_modules/element.scrollintoviewifneeded-polyfill/index.js"></script>
 
-https://github.com/Alfresco/alfresco-ng2-components/blob/master/ng2-components/ng2-alfresco-login/demo/systemjs.config.js
+    <!-- Polyfill(s) for dialogs -->
+    <script src="node_modules/dialog-polyfill/dialog-polyfill.js"></script>
+    <link rel="stylesheet" type="text/css" href="node_modules/dialog-polyfill/dialog-polyfill.css" />
+    <style>._dialog_overlay { position: static !important; } </style>
 
-## Style
-The style of this component is based on material design, so if you want to visualize it correctly you have to add the material
-design dependency to your project:
+    <!-- Modules  -->
+    <script src="node_modules/zone.js/dist/zone.js"></script>
+    <script src="node_modules/reflect-metadata/Reflect.js"></script>
+    <script src="node_modules/systemjs/dist/system.src.js"></script>
+    ```
 
-```sh
-npm install --save material-design-icons material-design-lite
-```
+3. SystemJs
 
-Also make sure you include these dependencies in your .html page:
+    Add the following components to your systemjs.config.js file:
 
-```html
-<!-- Google Material Design Lite -->
-<link rel="stylesheet" href="node_modules/material-design-lite/material.min.css">
-<script src="node_modules/material-design-lite/material.min.js"></script>
-<link rel="stylesheet" href="node_modules/material-design-icons/iconfont/material-icons.css">
-```
+    - ng2-translate
+    - ng2-alfresco-core
+    - alfresco-js-api
+    - ng2-alfresco-login
+
+    Please refer to the following example file: [systemjs.config.js](demo/systemjs
+    .config.js) .
 
 ## Basic usage
 
+This component allow to authenticate to Alfresco One and Alfresco Activiti.
+
 ```html
 <alfresco-login [providers]=" ``` -Example of an App that use Alfresco login component : +Usage example of this component : **main.ts** ```ts -import { Component } from '@angular/core'; -import { bootstrap } from '@angular/platform-browser-dynamic'; -import { AlfrescoLoginComponent } from 'ng2-alfresco-login'; -import { HTTP_PROVIDERS } from '@angular/http'; -import { - ALFRESCO_CORE_PROVIDERS, - AlfrescoSettingsService, - AlfrescoAuthenticationService -} from 'ng2-alfresco-core'; +import { NgModule, Component } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; + +import { CoreModule, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; +import { LoginModule } from 'ng2-alfresco-login'; @Component({ selector: 'my-app', - template: ' - - ', - directives: [AlfrescoLoginComponent] + template: ` + + ` }) export class AppComponent { constructor(public auth: AlfrescoAuthenticationService, - alfrescoSettingsService: AlfrescoSettingsService) { - alfrescoSettingsService.host = 'http://myalfrescoip'; + private settingsService: AlfrescoSettingsService) { + settingsService.ecmHost = 'http://localhost:8080/'; + settingsService.bpmHost = 'http://localhost:9999/'; } mySuccessMethod($event) { @@ -125,33 +134,41 @@ export class AppComponent { myErrorMethod($event) { console.log('Error Login EventEmitt called with: ' + $event.value); } - } -bootstrap(AppComponent, [ - HTTP_PROVIDERS, - ALFRESCO_CORE_PROVIDERS -]); +@NgModule({ + imports: [ + BrowserModule, + CoreModule.forRoot(), + LoginModule + ], + declarations: [ AppComponent ], + bootstrap: [ AppComponent ] +}) +export class AppModule { } + +platformBrowserDynamic().bootstrapModule(AppModule); ``` + #### Events | Name | Description | | --- | --- | -| onSuccess | The event is emitted when the login is done | -| onError | The event is emitted when the login fails | +| `onSuccess` | The event is emitted when the login is done | +| `onError` | The event is emitted when the login fails | -Attribute | Description | ---- | --- | -`onSuccess` | The event is emitted when the login is done | -`onError` | The event is emitted when the login fails | +| Name | Description | +| --- | --- | +| `onSuccess` | The event is emitted when the login is done | +| `onError` | The event is emitted when the login fails | #### Options -Attribute | Options | Default | Description | Mandatory ---- | --- | --- | --- | --- -`providers` | *string* | ECM | Possible valid value are ECM, BPM or ALL. The default behaviour of this component will logged in only in the ECM . If you want log in in both system the correct value to use is ALL | -`disableCsrf` | *boolean* | false | To prevent the CSRF Token from been submitted. Only for Activiti call | +| Name | Options | Default | Description | Mandatory +| --- | --- | --- | --- | --- +| `providers` | *string* | ECM | Possible valid value are ECM, BPM or ALL. The default behaviour of this component will logged in only in the ECM . If you want log in in both system the correct value to use is ALL | +| `disableCsrf` | *boolean* | false | To prevent the CSRF Token from been submitted. Only for Activiti call | ## Custom logo and background @@ -179,6 +196,7 @@ Alternatively you can bind to your component properties and provide values dynam ``` #### Customize Validation rules + If needed it is possible customize the validation rules of the login form. You can add/modify the default rules of the login form. @@ -294,6 +312,16 @@ npm install npm start ``` +## 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 | + ## License [Apache Version 2.0](https://github.com/Alfresco/alfresco-ng2-components/blob/master/LICENSE) diff --git a/ng2-components/ng2-alfresco-login/demo/index.html b/ng2-components/ng2-alfresco-login/demo/index.html index 574e0f1ca0..919ff26850 100644 --- a/ng2-components/ng2-alfresco-login/demo/index.html +++ b/ng2-components/ng2-alfresco-login/demo/index.html @@ -11,10 +11,20 @@ - + + + + + + + + + + + @@ -27,7 +37,7 @@ - + diff --git a/ng2-components/ng2-alfresco-login/demo/package.json b/ng2-components/ng2-alfresco-login/demo/package.json index 091fdfc9cd..7703bd22bf 100644 --- a/ng2-components/ng2-alfresco-login/demo/package.json +++ b/ng2-components/ng2-alfresco-login/demo/package.json @@ -52,25 +52,26 @@ "@angular/http": "2.0.0", "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", - "@angular/upgrade": "2.0.0", - "@types/node": "^6.0.42", "core-js": "^2.4.1", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.12", "systemjs": "0.19.27", "zone.js": "^0.6.23", - "md-date-time-picker": "^2.2.0", - "moment": "2.15.1", + + "intl": "1.2.4", + "dialog-polyfill": "^0.4.3", + "element.scrollintoviewifneeded-polyfill": "^1.0.1", "material-design-icons": "2.2.3", "material-design-lite": "1.2.1", - "ng2-translate": "2.5.0", + "ng2-translate": "2.5.0", "alfresco-js-api": "^0.3.0", - "ng2-alfresco-core": "^0.3.0", + "ng2-alfresco-core": "0.3.2", + "ng2-alfresco-datatable": "0.3.2", "ng2-alfresco-login": "^0.3.2" }, "devDependencies": { + "@types/node": "^6.0.42", "@types/core-js": "^0.9.32", "@types/jasmine": "^2.2.33", "concurrently": "^2.2.0", diff --git a/ng2-components/ng2-alfresco-login/demo/src/main.ts b/ng2-components/ng2-alfresco-login/demo/src/main.ts index 7f61445730..32efb23b7f 100644 --- a/ng2-components/ng2-alfresco-login/demo/src/main.ts +++ b/ng2-components/ng2-alfresco-login/demo/src/main.ts @@ -23,11 +23,13 @@ import { CoreModule, AlfrescoSettingsService, AlfrescoAuthenticationService } fr import { LoginModule } from 'ng2-alfresco-login'; @Component({ - selector: 'my-app', + selector: 'alfresco-app-demo', template: ` -
-

+
+ ECM Host:
+ BPM Host:

{{ status }}
- ` + ` }) export class AppComponent { - public ecmHost: string = 'http://devproducts-platform.alfresco.me'; + public ecmHost: string = 'http://localhost:8080'; + + public bpmHost: string = 'http://localhost:9999'; public ticket: string; @@ -59,15 +71,22 @@ export class AppComponent { public providers: string = 'ECM'; + public disableCsrf: boolean = false; + constructor(public auth: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) { settingsService.ecmHost = this.ecmHost; + settingsService.bpmHost = this.bpmHost; } - public updateHost(): void { + public updateEcmHost(): void { this.settingsService.ecmHost = this.ecmHost; } + public updateBpmHost(): void { + this.settingsService.bpmHost = this.bpmHost; + } + mySuccessMethod($event) { console.log('Success Login EventEmitt called with: ' + $event.value); this.status = $event.value; @@ -83,8 +102,8 @@ export class AppComponent { this.providers = 'ALL'; } else if (checked) { this.providers = 'ECM'; - } else { - this.providers = undefined; + } else if (!checked && this.providers === 'ALL') { + this.providers = 'BPM'; } } @@ -93,10 +112,14 @@ export class AppComponent { this.providers = 'ALL'; } else if (checked) { this.providers = 'BPM'; - } else { - this.providers = undefined; + } else if (!checked && this.providers === 'ALL') { + this.providers = 'ECM'; } } + + toggleCSRF() { + this.disableCsrf = !this.disableCsrf; + } } @NgModule({ @@ -105,8 +128,8 @@ export class AppComponent { CoreModule.forRoot(), LoginModule ], - declarations: [ AppComponent ], - bootstrap: [ AppComponent ] + declarations: [AppComponent], + bootstrap: [AppComponent] }) export class AppModule { } diff --git a/ng2-components/ng2-alfresco-login/demo/systemjs.config.js b/ng2-components/ng2-alfresco-login/demo/systemjs.config.js index d63ad584b3..17ce0975de 100644 --- a/ng2-components/ng2-alfresco-login/demo/systemjs.config.js +++ b/ng2-components/ng2-alfresco-login/demo/systemjs.config.js @@ -38,7 +38,7 @@ defaultExtension: 'js' }, 'ng2-translate': { defaultExtension: 'js' }, - 'alfresco-js-api': { main: './alfresco-js-api.js', defaultExtension: 'js'} + 'alfresco-js-api': { main: './alfresco-js-api.js', defaultExtension: 'js'}, 'ng2-alfresco-core': { main: './index.js', defaultExtension: 'js'}, 'ng2-alfresco-login': { main: './index.js', defaultExtension: 'js'} } diff --git a/ng2-components/ng2-alfresco-login/package.json b/ng2-components/ng2-alfresco-login/package.json index cfd52e4606..0a0d23978b 100644 --- a/ng2-components/ng2-alfresco-login/package.json +++ b/ng2-components/ng2-alfresco-login/package.json @@ -63,20 +63,24 @@ "@angular/http": "2.0.0", "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", - "@angular/upgrade": "2.0.0", - "@types/node": "^6.0.42", "core-js": "^2.4.1", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.12", "systemjs": "0.19.27", "zone.js": "^0.6.23", + "intl": "1.2.4", + "dialog-polyfill": "^0.4.3", + "element.scrollintoviewifneeded-polyfill": "^1.0.1", + "material-design-icons": "2.2.3", + "material-design-lite": "1.2.1", + "ng2-translate": "2.5.0", - "ng2-alfresco-core": "0.3.2", - "alfresco-js-api": "^0.3.0" + "alfresco-js-api": "^0.3.0", + "ng2-alfresco-core": "0.3.2" }, "devDependencies": { + "@types/node": "^6.0.42", "@types/core-js": "^0.9.32", "@types/jasmine": "^2.2.33", "concurrently": "^2.2.0", diff --git a/ng2-components/ng2-alfresco-search/.npmignore b/ng2-components/ng2-alfresco-search/.npmignore index 16ba3e61e5..c5ca623298 100644 --- a/ng2-components/ng2-alfresco-search/.npmignore +++ b/ng2-components/ng2-alfresco-search/.npmignore @@ -1,7 +1,6 @@ npm-debug.log .idea -assets/ coverage/ node_modules typings/ diff --git a/ng2-components/ng2-alfresco-search/README.md b/ng2-components/ng2-alfresco-search/README.md index f451cd7ced..4092139241 100644 --- a/ng2-components/ng2-alfresco-search/README.md +++ b/ng2-components/ng2-alfresco-search/README.md @@ -32,59 +32,63 @@

-### Node -To correctly use this component check that on your machine is running Node version 5.0.0 or higher. +## Prerequisites + +Before you start using this development framework, make sure you have installed all required software and done all the +necessary configuration, see this [page](https://github.com/Alfresco/alfresco-ng2-components/blob/master/PREREQUISITES.md). ## Install -```sh -npm install --save ng2-alfresco-core ng2-alfresco-search -``` +Follow the 3 steps below: -Components included: +1. Npm -- [Search control](#search-control) -- [Search results](#search-results) + ```sh + npm install ng2-alfresco-search --save + ``` -### Search control +2. Html -This component displays a search box on the page, which the user can use to enter a search query. It is decoupled from -the related [search results](#search-results) component which performs a query and displays results. + Include these dependencies in your index.html page: -#### Dependencies + ```html -Add the following dependency to your index.html: + + + + -```html - -``` + + + -The following component needs to be added to your systemjs.config: + + + + -- ng2-translate -- ng2-alfresco-core -- ng2-alfresco-search + + + + -Please refer to the following example to have an idea of how your systemjs.config should look like : + + + + + ``` -https://github.com/Alfresco/alfresco-ng2-components/blob/master/ng2-components/ng2-alfresco-search/demo/systemjs.config.js +3. SystemJs -#### Style -The style of this component is based on material design, so if you want to visualize it correctly you have to add the material -design dependency to your project: + Add the following components to your systemjs.config.js file: -```sh -npm install --save material-design-icons material-design-lite -``` + - ng2-translate + - ng2-alfresco-core + - alfresco-js-api + - ng2-alfresco-search -Also make sure you include these dependencies in your .html page: - -```html - - - - -``` + Please refer to the following example file: [systemjs.config.js](demo/systemjs + .config.js) . #### Basic usage @@ -102,132 +106,70 @@ but instead the component could emit an event to be consumed upstream, or it cou results component embedded inside the same component. ```ts -import { Component, OnInit } from '@angular/core'; -import { bootstrap } from '@angular/platform-browser-dynamic'; -import { HTTP_PROVIDERS } from '@angular/http'; -import { - ALFRESCO_CORE_PROVIDERS, - AlfrescoSettingsService, - AlfrescoAuthenticationService, - AlfrescoTranslationService -} from 'ng2-alfresco-core'; -import { - ALFRESCO_SEARCH_DIRECTIVES -} from 'ng2-alfresco-search'; +import { NgModule, Component } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { CoreModule } from 'ng2-alfresco-core'; +import { SearchModule } from 'ng2-alfresco-search'; +import { AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; @Component({ - selector: 'alfresco-search-demo', - template: ` - - -
- Authentication failed to ip {{ host }} -
- `, - directives: [ALFRESCO_SEARCH_DIRECTIVES] + selector: 'alfresco-app-demo', + template: `` }) -class SearchDemo implements OnInit { +class SearchDemo { - public searchTerm: string = 'test'; + constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) { + settingsService.ecmHost = 'http://localhost:8080'; - authenticated: boolean; - - host: string = 'http://myalfrescoip'; - - constructor( - private authService: AlfrescoAuthenticationService, - settings: AlfrescoSettingsService, - translation: AlfrescoTranslationService) { - - settings.host = this.host; - translation.addTranslationFolder(); + this.authService.login('admin', 'admin').subscribe( + ticket => { + console.log(ticket); + }, + error => { + console.log(error); + }); } - - onSearchChange(event) { - console.log('Search term changed', event); - this.searchTerm = event.value; - } - - onSearchSubmit(event) { - console.log('Search submitted', event); - } - - ngOnInit() { - this.login(); - } - - login() { - this.authService.login('admin', 'admin').subscribe(token => { - this.authenticated = true; - }); - } - } -bootstrap(SearchDemo, [ - HTTP_PROVIDERS, - ALFRESCO_CORE_PROVIDERS -]); +@NgModule({ + imports: [ + BrowserModule, + CoreModule.forRoot(), + SearchModule + ], + declarations: [SearchDemo], + bootstrap: [SearchDemo] +}) +export class AppModule { +} + +platformBrowserDynamic().bootstrapModule(AppModule); ``` #### Events -**searchChange**: Emitted when the search term is changed. The search term is provided in the 'value' property of the returned object. If the term is at less than three characters in length then the term is truncated to an empty string.
-**searchSubmit**: Emitted when the search form is submitted. The search term is provided in the 'value' property of the returned object.
-**fileSelect**: Emitted when a file item from the list of find-as-you-type results is selected
-**expand**: Emitted when the expanded state of the control changes based on focus events and the content of the input control +| Name | Description | +| --- | --- | +| `searchChange` | Emitted when the search term is changed. The search term is provided in the 'value' property of the returned object. If the term is at less than three characters in length then the term is truncated to an empty string. | +| `searchSubmit` | Emitted when the search form is submitted. The search term is provided in the 'value' property of the returned object. | +| `fileSelect` | Emitted when a file item from the list of find-as-you-type results is selected | +| `expand` | Emitted when the expanded state of the control changes based on focus events and the content of the input control | #### Options -**searchTerm**: {string} (optional) default "". Search term to pre-populate the field with
-**inputType**: {string} (optional) default "text". Type of the input field to render, e.g. "search" or "text" (default)
-**expandable** {boolean} (optional) default true. Whether to use an expanding search control, if false then a regular input is used.
-**autocomplete** {boolean} (optional) default true. Whether the browser should offer field auto-completion for the input field to the user.
-**liveSearchEnabled** {boolean} (optional) default true. Whether find-as-you-type suggestions should be offered for matching content items. Set to false to disable.
-**liveSearchRoot** {boolean} (optional) default "-root-". NodeRef or node name where the search should start.
-**liveSearchResultType** {boolean} (optional) default (none). Node type to filter live search results by, e.g. 'cm:content'.
-**liveSearchMaxResults** {boolean} (optional) default 5. Maximum number of results to show in the live search.
-**liveSearchResultSort** {boolean} (optional) default (none). Criteria to sort live search results by, must be one of "name" , "modifiedAt" or "createdAt" +| Name | Type | Optional | Default | Description | +| --- | --- | --- | --- | --- | +| `searchTerm` | {string} | (optional) | "" | Search term to pre-populate the field with | +| `inputType` | {string} | (optional) | "text" | Type of the input field to render, e.g. "search" or "text" (default) | +| `expandable` | {boolean} | (optional) | true | Whether to use an expanding search control, if false then a regular input is used. | +| `autocomplet` | {boolean} | (optional) | true | Whether the browser should offer field auto-completion for the input field to the user. | +| `liveSearchEnabled` | {boolean} | (optional) | true | Whether find-as-you-type suggestions should be offered for matching content items. Set to false to disable. | +| `liveSearchRoot` | {boolean} | (optional) | "-root-" | NodeRef or node name where the search should start. | +| `liveSearchResultType` | {boolean} | (optional) | (none) | Node type to filter live search results by, e.g. 'cm:content'. | +| `liveSearchMaxResults` | {boolean} | (optional) | 5 | Maximum number of results to show in the live search. | +| `iveSearchResultSort` | {boolean} | (optional) | (none) | Criteria to sort live search results by, must be one of "name" , "modifiedAt" or "createdAt" | -### Search results - -This component displays the results of a search to the user. - -#### Dependencies - -Add the following dependency to your index.html: - -```html - -``` - -The following component needs to be added to your systemjs.config: - -- ng2-translate -- ng2-alfresco-core -- ng2-alfresco-search - -Please refer to the following example to have an idea of how your systemjs.config should look like : - -https://github.com/Alfresco/alfresco-ng2-components/blob/master/ng2-components/ng2-alfresco-search/demo/systemjs.config.js - -#### Style -The style of this component is based on material design, so if you want to visualize it correctly you have to add the material -design dependency to your project: - -```sh -npm install --save material-design-icons material-design-lite -``` - -Also make sure you include these dependencies in your .html page: - -```html - - - - -``` - -#### Basic usage +#### Basic usage Search results ```html @@ -238,157 +180,121 @@ search term. If no router is present on the page of if the router does not provi results page will be shown. ```ts -import { Component, OnInit } from '@angular/core'; -import { bootstrap } from '@angular/platform-browser-dynamic'; -import { HTTP_PROVIDERS } from '@angular/http'; - -import { - ALFRESCO_CORE_PROVIDERS, - AlfrescoSettingsService, - AlfrescoAuthenticationService, - AlfrescoTranslationService -} from 'ng2-alfresco-core'; - -import { - ALFRESCO_SEARCH_DIRECTIVES -} from 'ng2-alfresco-search'; +import { NgModule, Component } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { CoreModule } from 'ng2-alfresco-core'; +import { SearchModule } from 'ng2-alfresco-search'; +import { AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; @Component({ - selector: 'alfresco-search-demo', - template: ` - -
- Authentication failed to ip {{ host }} -
- `, - directives: [ALFRESCO_SEARCH_DIRECTIVES] -}) -class SearchDemo implements OnInit { - - public searchTerm: string = 'test'; - - authenticated: boolean; - - host: string = 'http://192.168.99.101:8080'; - - constructor( - private authService: AlfrescoAuthenticationService, - settings: AlfrescoSettingsService, - translation: AlfrescoTranslationService) { - - settings.host = this.host; - translation.addTranslationFolder(); - } - - ngOnInit() { - this.login(); - } - - login() { - this.authService.login('admin', 'admin').subscribe(token => { - this.authenticated = true; - }); - } - -} - -bootstrap(SearchDemo, [ - HTTP_PROVIDERS, - ALFRESCO_CORE_PROVIDERS -]); -``` - -Example of an component that displays search results, taking the search term from a `@Input` property provided by the container. - -When the input is updated by the application, the search control will run a new search and display the results. - -```ts -import { Component } from '@angular/core'; -import { bootstrap } from '@angular/platform-browser-dynamic'; -import { HTTP_PROVIDERS } from '@angular/http'; -import { - ALFRESCO_CORE_PROVIDERS -} from 'ng2-alfresco-core'; -import { - ALFRESCO_SEARCH_DIRECTIVES -} from 'ng2-alfresco-search'; - -@Component({ - selector: 'alfresco-search-demo', - template: ` - - `, - directives: [ALFRESCO_SEARCH_DIRECTIVES] + selector: 'alfresco-app-demo', + template: `` }) class SearchDemo { - @Input() - searchTerm: string = ''; - constructor() { + + constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) { + settingsService.ecmHost = 'http://localhost:8080'; + + this.authService.login('admin', 'admin').subscribe( + ticket => { + console.log(ticket); + }, + error => { + console.log(error); + }); } } -bootstrap(SearchDemo, [ - HTTP_PROVIDERS, - ALFRESCO_CORE_PROVIDERS -]); +@NgModule({ + imports: [ + BrowserModule, + CoreModule.forRoot(), + SearchModule + ], + declarations: [SearchDemo], + bootstrap: [SearchDemo] +}) +export class AppModule { +} + +platformBrowserDynamic().bootstrapModule(AppModule); ``` #### Events -**preview**: Emitted when a file result is clicked/selected
-**resultsLoad**: Emitted when search results have fully loaded +| Name | Description | +| --- | --- | +| `preview` | Emitted when a file result is clicked/selected | +| `resultsLoad` | Emitted when search results have fully loaded | #### Options -**searchTerm**: {string} (optional) default "". Search term to use when executing the search. Updating this value will -run a new search and update the results.
-**rootNodeId** {boolean} (optional) default "-root-". NodeRef or node name where the search should start.
-**resultType** {boolean} (optional) default (none). Node type to filter search results by, e.g. 'cm:content'.
-**maxResults** {boolean} (optional) default 20. Maximum number of results to show in the search.
-**resultSort** {boolean} (optional) default (none). Criteria to sort search results by, must be one of "name" , "modifiedAt" or "createdAt" +| Name | Type | Optional | Default | Description | +| --- | --- | --- | --- | --- | +| `searchTerm` | {string} | (optional) | "" | Search term to use when executing the search. Updating this value will run a new search and update the results | +| `rootNodeId` | {boolean} | (optional) | "-root-" | NodeRef or node name where the search should start. | +| `resultType` | {boolean} | (optional) | (none) | Node type to filter search results by, e.g. 'cm:content'. | +| `maxResults` | {boolean} | (optional) | 20 | Maximum number of results to show in the search. | +| `resultSort` | {boolean} | (optional) | (none) | Criteria to sort search results by, must be one of "name" , "modifiedAt" or "createdAt" | -## Build from sources +### Build from sources -Alternatively you can build the component from source with the following commands: + Alternatively you can build component from sources with the following commands: -```sh -npm install -npm run build -``` -##Build the files and keep watching for changes + ```sh + npm install + npm run build + ``` - ```sh - $ npm run build:w - ``` - -## Running unit tests + ### Build the files and keep watching for changes -```sh -npm test -``` + ```sh + $ npm run build:w + ``` -## Running unit tests in browser + ## Running unit tests -```sh -npm test-browser -``` + ```sh + npm test + ``` -This task rebuilds all the code, runs tslint, license checks and other quality check tools -before performing unit testing. + ### Running unit tests in browser -## Code coverage + ```sh + npm test-browser + ``` -```sh -npm run coverage -``` + This task rebuilds all the code, runs tslint, license checks and other quality check tools + before performing unit testing. -## Demo + ### Code coverage -The `demo` folder contains a complete app with both components running on a single page and linked together: + ```sh + npm run coverage + ``` -```sh -cd demo -npm install -npm start -``` + ## Demo + + If you want have a demo of how the component works, please check the demo folder : + + ```sh + cd demo + npm install + npm start + ``` + +## 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 | + + ## License + + [Apache Version 2.0](https://github.com/Alfresco/alfresco-ng2-components/blob/master/LICENSE) \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-search/demo/index.html b/ng2-components/ng2-alfresco-search/demo/index.html index f6b743299f..d7fe291524 100644 --- a/ng2-components/ng2-alfresco-search/demo/index.html +++ b/ng2-components/ng2-alfresco-search/demo/index.html @@ -10,9 +10,21 @@ - + + + + + + + + + + + + + @@ -26,7 +38,7 @@
- +
diff --git a/ng2-components/ng2-alfresco-search/demo/package.json b/ng2-components/ng2-alfresco-search/demo/package.json index 4dc4b84fcf..cc47615972 100644 --- a/ng2-components/ng2-alfresco-search/demo/package.json +++ b/ng2-components/ng2-alfresco-search/demo/package.json @@ -45,6 +45,7 @@ "alfresco" ], "dependencies": { + "@angular/router": "3.0.0", "@angular/common": "2.0.0", "@angular/compiler": "2.0.0", "@angular/core": "2.0.0", @@ -52,24 +53,25 @@ "@angular/http": "2.0.0", "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", - "@angular/upgrade": "2.0.0", - "@types/node": "^6.0.42", "core-js": "^2.4.1", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.12", "systemjs": "0.19.27", "zone.js": "^0.6.23", - "ng2-translate": "2.5.0", + "intl": "1.2.4", + "dialog-polyfill": "^0.4.3", + "element.scrollintoviewifneeded-polyfill": "^1.0.1", "material-design-icons": "2.2.3", "material-design-lite": "1.2.1", + "ng2-translate": "2.5.0", "alfresco-js-api": "^0.3.0", - "ng2-alfresco-core": "^0.3.0", + "ng2-alfresco-core": "0.3.2", "ng2-alfresco-search": "^0.3.0" }, "devDependencies": { + "@types/node": "^6.0.42", "@types/core-js": "^0.9.32", "@types/jasmine": "^2.2.33", "concurrently": "^2.2.0", diff --git a/ng2-components/ng2-alfresco-search/demo/src/main.ts b/ng2-components/ng2-alfresco-search/demo/src/main.ts index 631bc6d216..df8ea13e5f 100644 --- a/ng2-components/ng2-alfresco-search/demo/src/main.ts +++ b/ng2-components/ng2-alfresco-search/demo/src/main.ts @@ -28,9 +28,8 @@ import { AlfrescoTranslationService } from 'ng2-alfresco-core'; - @Component({ - selector: 'alfresco-search-demo', + selector: 'alfresco-app-demo', template: `


@@ -54,7 +53,7 @@ class SearchDemo implements OnInit { public searchTerm: string = 'test'; - public ecmHost: string = 'http://devproducts-platform.alfresco.me'; + public ecmHost: string = 'http://localhost:8080'; ticket: string; diff --git a/ng2-components/ng2-alfresco-search/package.json b/ng2-components/ng2-alfresco-search/package.json index 894ceab888..0064b4657f 100644 --- a/ng2-components/ng2-alfresco-search/package.json +++ b/ng2-components/ng2-alfresco-search/package.json @@ -52,6 +52,7 @@ "alfresco" ], "dependencies": { + "@types/node": "^6.0.42", "@angular/common": "2.0.0", "@angular/compiler": "2.0.0", "@angular/core": "2.0.0", @@ -60,19 +61,24 @@ "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", "@angular/router": "3.0.0", - "@angular/upgrade": "2.0.0", - "@types/node": "^6.0.42", "core-js": "^2.4.1", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.12", "systemjs": "0.19.27", "zone.js": "^0.6.23", + "intl": "1.2.4", + "dialog-polyfill": "^0.4.3", + "element.scrollintoviewifneeded-polyfill": "^1.0.1", + "material-design-icons": "2.2.3", + "material-design-lite": "1.2.1", + "ng2-translate": "2.5.0", "alfresco-js-api": "^0.3.0", "ng2-alfresco-core": "0.3.2" }, "devDependencies": { + "@types/node": "^6.0.42", "@types/core-js": "^0.9.32", "@types/jasmine": "^2.2.33", "concurrently": "^2.2.0", diff --git a/ng2-components/ng2-alfresco-tag/.npmignore b/ng2-components/ng2-alfresco-tag/.npmignore new file mode 100644 index 0000000000..c5ca623298 --- /dev/null +++ b/ng2-components/ng2-alfresco-tag/.npmignore @@ -0,0 +1,15 @@ +npm-debug.log +.idea + +coverage/ +node_modules +typings/ +fonts/ + +/.editorconfig +/.travis.yml +/*.js +/*.json +/*.ts +/*.js.map +/.npmignore diff --git a/ng2-components/ng2-alfresco-tag/README.md b/ng2-components/ng2-alfresco-tag/README.md index a7519e00ea..2e989d0983 100644 --- a/ng2-components/ng2-alfresco-tag/README.md +++ b/ng2-components/ng2-alfresco-tag/README.md @@ -1,4 +1,5 @@ # Alfresco Tag Component for Angular 2 +

travis
@@ -31,52 +32,64 @@
   </a>
 </p>
 
-### Node
-To correctly use this component check that on your machine is running Node version 5.0.0 or higher.
+## Prerequisites
+
+Before you start using this development framework, make sure you have installed all required software and done all the
+necessary configuration [prerequisites](https://github.com/Alfresco/alfresco-ng2-components/blob/master/PREREQUISITES.md).
 
 ## Install
 
-```sh
-npm install --save ng2-alfresco-tag
-```
+Follow the 3 steps below:
 
-Components included:
+1. Npm
 
-* Alfresco Tag Component
+    ```sh
+    npm install ng2-alfresco-tag --save
+    ```
 
-#### Dependencies
+2. Html
 
-Add the following dependency to your index.html:
+    Include these dependencies in your index.html page:
 
-```html
-<script src="node_modules/alfresco-js-api/dist/alfresco-js-api.js"></script>
-```
+    ```html
 
-The following component needs to be added to your systemjs.config: 
+      <!-- Google Material Design Lite -->
+      <link rel="stylesheet" href="node_modules/material-design-lite/material.min.css">
+      <script src="node_modules/material-design-lite/material.min.js"></script>
+      <link rel="stylesheet" href="node_modules/material-design-icons/iconfont/material-icons.css">
 
-- ng2-translate
-- ng2-alfresco-core
+      <!-- Polyfill(s) for Safari (pre-10.x) -->
+      <script src="node_modules/intl/dist/Intl.min.js"></script>
+      <script src="node_modules/intl/locale-data/jsonp/en.js"></script>
 
-Please refer to the following example to have an idea of how your systemjs.config should look like :
+      <!-- Polyfill(s) for older browsers -->
+      <script src="node_modules/core-js/client/shim.min.js"></script>
+      <script src="//cdnjs.cloudflare.com/ajax/libs/dom4/1.8.3/dom4.js"></script>
+      <script src="node_modules/element.scrollintoviewifneeded-polyfill/index.js"></script>
 
-https://github.com/Alfresco/alfresco-ng2-components/blob/master/ng2-components/ng2-alfresco-tag/demo/systemjs.config.js
+      <!-- Polyfill(s) for dialogs -->
+      <script src="node_modules/dialog-polyfill/dialog-polyfill.js"></script>
+      <link rel="stylesheet" type="text/css" href="node_modules/dialog-polyfill/dialog-polyfill.css" />
+      <style>._dialog_overlay { position: static !important; } </style>
 
-#### Style
-The style of this component is based on material design, so if you want to visualize it correctly you have to add the material
-design dependency to your project:
+      <!-- Modules  -->
+      <script src="node_modules/zone.js/dist/zone.js"></script>
+      <script src="node_modules/reflect-metadata/Reflect.js"></script>
+      <script src="node_modules/systemjs/dist/system.src.js"></script>
 
-```sh
-npm install --save material-design-icons material-design-lite
-```
+    ```
 
-Also make sure you include these dependencies in your .html page:
+3. SystemJs
 
-```html
-<!-- Google Material Design Lite -->
-<link rel="stylesheet" href="node_modules/material-design-lite/material.min.css">
-<script src="node_modules/material-design-lite/material.min.js"></script>
-<link rel="stylesheet" href="node_modules/material-design-icons/iconfont/material-icons.css">
-```
+    Add the following components to your systemjs.config.js file:
+
+    - ng2-translate
+    - alfresco-js-api
+    - ng2-alfresco-core
+    - ng2-alfresco-tag
+
+    Please refer to the following example file: [systemjs.config.js](demo/systemjs
+    .config.js) .
 
 #### Basic usage
 
@@ -93,70 +106,45 @@ In this component are present three different tags :
 ```  
 
 ```ts
-import { Component, OnInit, Input } from - -

- `, - directives: [TAGCOMPONENT], - providers: [TAGSERVICES] + selector: 'alfresco-app-demo', + template: ` + ` }) -class TagDemo implements OnInit { +class TagDemo { - @Input() - nodeId: string = '74cd8a96-8a21-47e5-9b3b-a1b3e296787d'; + constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) { + settingsService.ecmHost = 'http://localhost:8080'; - authenticated: boolean; - - ecmHost: string = 'http://127.0.0.1:8080'; - - ticket: string; - - constructor(private authService: AlfrescoAuthenticationService, - private settingsService: AlfrescoSettingsService) { - settingsService.ecmHost = this.ecmHost; - settingsService.setProviders('ECM'); - } - - ngOnInit() { - this.login(); - } - - login() { this.authService.login('admin', 'admin').subscribe( ticket => { - this.authenticated = true; + console.log(ticket); }, error => { - this.authenticated = false; + console.log(error); }); } - - public updateHost(): void { - this.settingsService.ecmHost = this.ecmHost; - this.login(); - } - - logData(data) { - console.log(data); - } } -bootstrap(TagDemo, [ - HTTP_PROVIDERS, - ALFRESCO_CORE_PROVIDERS -]); + +@NgModule({ + imports: [ + BrowserModule, + CoreModule.forRoot(), + TagModule + ], + declarations: [ TagDemo ], + bootstrap: [ TagDemo ] +}) +export class AppModule { } + +platformBrowserDynamic().bootstrapModule(AppModule); ``` ### Options @@ -174,71 +162,45 @@ Attribute | Options | Default | Description | Mandatory ``` ```ts -import { Component, OnInit, Input } from '@angular/core'; -import { bootstrap } from '@angular/platform-browser-dynamic'; -import { HTTP_PROVIDERS } from '@angular/http'; -import { - ALFRESCO_CORE_PROVIDERS, - AlfrescoSettingsService, - AlfrescoAuthenticationService -} from 'ng2-alfresco-core'; +import { NgModule, Component } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; -import { TAGCOMPONENT, TAGSERVICES } from 'ng2-alfresco-tag'; +import { CoreModule, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; +import { TagModule } from 'ng2-alfresco-tag'; @Component({ - selector: 'alfresco-tag-demo', - template: ` -
- -
- `, - directives: [TAGCOMPONENT], - providers: [TAGSERVICES] + selector: 'alfresco-app-demo', + template: ` + ` }) -class TagDemo implements OnInit { +class TagDemo { - @Input() - nodeId: string = '74cd8a96-8a21-47e5-9b3b-a1b3e296787d'; + constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) { + settingsService.ecmHost = 'http://localhost:8080'; - authenticated: boolean; - - ecmHost: string = 'http://127.0.0.1:8080'; - - ticket: string; - - constructor(private authService: AlfrescoAuthenticationService, - private settingsService: AlfrescoSettingsService) { - settingsService.ecmHost = this.ecmHost; - settingsService.setProviders('ECM'); - } - - ngOnInit() { - this.login(); - } - - login() { this.authService.login('admin', 'admin').subscribe( ticket => { - this.authenticated = true; + console.log(ticket); }, error => { - this.authenticated = false; + console.log(error); }); } - - public updateHost(): void { - this.settingsService.ecmHost = this.ecmHost; - this.login(); - } - - logData(data) { - console.log(data); - } } -bootstrap(TagDemo, [ - HTTP_PROVIDERS, - ALFRESCO_CORE_PROVIDERS -]); + +@NgModule({ + imports: [ + BrowserModule, + CoreModule.forRoot(), + TagModule + ], + declarations: [ TagDemo ], + bootstrap: [ TagDemo ] +}) +export class AppModule { } + +platformBrowserDynamic().bootstrapModule(AppModule); ``` ### Options @@ -256,102 +218,81 @@ Attribute | Options | Default | Description | Mandatory ``` ```ts -import { Component, OnInit, Input } from '@angular/core'; -import { bootstrap } from '@angular/platform-browser-dynamic'; -import { HTTP_PROVIDERS } from '@angular/http'; -import { - ALFRESCO_CORE_PROVIDERS, - AlfrescoSettingsService, - AlfrescoAuthenticationService -} from 'ng2-alfresco-core'; +import { NgModule, Component } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; -import { TAGCOMPONENT, TAGSERVICES } from 'ng2-alfresco-tag'; +import { CoreModule, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; +import { TagModule } from 'ng2-alfresco-tag'; @Component({ - selector: 'alfresco-tag-demo', - template: ` -
- -
- `, - directives: [TAGCOMPONENT], - providers: [TAGSERVICES] + selector: 'alfresco-app-demo', + template: `` }) -class TagDemo implements OnInit { +class TagDemo { - authenticated: boolean; + constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) { + settingsService.ecmHost = 'http://localhost:8080'; - ecmHost: string = 'http://127.0.0.1:8080'; - - constructor(private authService: AlfrescoAuthenticationService, - private settingsService: AlfrescoSettingsService) { - settingsService.ecmHost = this.ecmHost; - settingsService.setProviders('ECM'); - } - - ngOnInit() { - this.login(); - } - - login() { this.authService.login('admin', 'admin').subscribe( ticket => { - this.authenticated = true; + console.log(ticket); }, error => { - this.authenticated = false; + console.log(error); }); } - - public updateHost(): void { - this.settingsService.ecmHost = this.ecmHost; - this.login(); - } - - logData(data) { - console.log(data); - } } -bootstrap(TagDemo, [ - HTTP_PROVIDERS, - ALFRESCO_CORE_PROVIDERS -]); + +@NgModule({ + imports: [ + BrowserModule, + CoreModule.forRoot(), + TagModule + ], + declarations: [ TagDemo ], + bootstrap: [ TagDemo ] +}) +export class AppModule { } + +platformBrowserDynamic().bootstrapModule(AppModule); ``` ![Custom columns](docs/assets/tag2.png) ## Build from sources + Alternatively you can build component from sources with the following commands: - - + + ```sh npm install npm run build ``` -##Build the files and keep watching for changes +### Build the files and keep watching for changes ```sh -npm run build:w +$ npm run build:w ``` - + ## Running unit tests ```sh npm test ``` -## Running unit tests in browser +### Running unit tests in browser ```sh npm test-browser ``` -This task rebuilds all the code, runs tslint, license checks and other quality check tools -before performing unit testing. +This task rebuilds all the code, runs tslint, license checks and other quality check tools +before performing unit testing. -## Code coverage +### Code coverage ```sh npm run coverage @@ -367,3 +308,16 @@ npm install npm start ``` +## 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 | + +## License + +[Apache Version 2.0](https://github.com/Alfresco/alfresco-ng2-components/blob/master/LICENSE) diff --git a/ng2-components/ng2-alfresco-tag/demo/index.html b/ng2-components/ng2-alfresco-tag/demo/index.html index 309e792adc..c32e19e790 100644 --- a/ng2-components/ng2-alfresco-tag/demo/index.html +++ b/ng2-components/ng2-alfresco-tag/demo/index.html @@ -11,10 +11,21 @@ - + + + + + + + + + + + + @@ -30,7 +41,7 @@ - + diff --git a/ng2-components/ng2-alfresco-tag/demo/package.json b/ng2-components/ng2-alfresco-tag/demo/package.json index b0d28b7a37..f697f228ff 100644 --- a/ng2-components/ng2-alfresco-tag/demo/package.json +++ b/ng2-components/ng2-alfresco-tag/demo/package.json @@ -7,13 +7,12 @@ "scripts": { "clean": "npm install rimraf && rimraf dist node_modules typings dist", "postinstall": "npm run build", - "start": "concurrently \"npm run build:w\" \"npm run server\" ", + "start": "npm run build && concurrently \"npm run tsc:w\" \"npm run server\" ", "server": "wsrv -o -s -l", - "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" + "build": "npm run tslint && rimraf dist && npm run tsc", + "tsc": "tsc", + "tsc:w": "tsc -w", + "tslint": "tslint -c tslint.json *.ts && tslint -c tslint.json src/{,**/}**.ts" }, "license": "Apache-2.0", "dependencies": { @@ -24,24 +23,25 @@ "@angular/http": "2.0.0", "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", - "@angular/upgrade": "2.0.0", - "@types/node": "^6.0.42", "core-js": "^2.4.1", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.12", "systemjs": "0.19.27", "zone.js": "^0.6.23", + "intl": "1.2.4", + "dialog-polyfill": "^0.4.3", + "element.scrollintoviewifneeded-polyfill": "^1.0.1", "material-design-icons": "2.2.3", "material-design-lite": "1.2.1", - "ng2-translate": "2.5.0", + "ng2-translate": "2.5.0", "alfresco-js-api": "^0.3.0", - "ng2-alfresco-core": "^0.3.0", + "ng2-alfresco-core": "0.3.2", "ng2-alfresco-tag": "0.3.2" }, "devDependencies": { + "@types/node": "^6.0.42", "@types/core-js": "^0.9.32", "@types/jasmine": "^2.2.33", "concurrently": "^2.2.0", diff --git a/ng2-components/ng2-alfresco-tag/demo/src/main.ts b/ng2-components/ng2-alfresco-tag/demo/src/main.ts index 8af97cc33a..519b1f1271 100644 --- a/ng2-components/ng2-alfresco-tag/demo/src/main.ts +++ b/ng2-components/ng2-alfresco-tag/demo/src/main.ts @@ -23,7 +23,7 @@ import { CoreModule, AlfrescoSettingsService, AlfrescoAuthenticationService } fr import { TagModule } from 'ng2-alfresco-tag'; @Component({ - selector: 'alfresco-tag-demo', + selector: 'alfresco-app-demo', template: `

diff --git a/ng2-components/ng2-alfresco-tag/package.json b/ng2-components/ng2-alfresco-tag/package.json index 2ce0aa24be..effcb41108 100644 --- a/ng2-components/ng2-alfresco-tag/package.json +++ b/ng2-components/ng2-alfresco-tag/package.json @@ -38,19 +38,24 @@ "@angular/http": "2.0.0", "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", - "@angular/upgrade": "2.0.0", - "@types/node": "^6.0.42", - "alfresco-js-api": "^0.3.0", "core-js": "^2.4.1", - "ng2-alfresco-core": "0.3.2", - "ng2-translate": "2.5.0", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.12", "systemjs": "0.19.27", - "zone.js": "^0.6.23" + "zone.js": "^0.6.23", + + "intl": "1.2.4", + "dialog-polyfill": "^0.4.3", + "element.scrollintoviewifneeded-polyfill": "^1.0.1", + "material-design-icons": "2.2.3", + "material-design-lite": "1.2.1", + + "ng2-translate": "2.5.0", + "alfresco-js-api": "^0.3.0", + "ng2-alfresco-core": "0.3.2" }, "devDependencies": { + "@types/node": "^6.0.42", "@types/core-js": "^0.9.32", "@types/jasmine": "^2.2.33", "concurrently": "^2.2.0", diff --git a/ng2-components/ng2-alfresco-upload/.npmignore b/ng2-components/ng2-alfresco-upload/.npmignore index 16ba3e61e5..c5ca623298 100644 --- a/ng2-components/ng2-alfresco-upload/.npmignore +++ b/ng2-components/ng2-alfresco-upload/.npmignore @@ -1,7 +1,6 @@ npm-debug.log .idea -assets/ coverage/ node_modules typings/ diff --git a/ng2-components/ng2-alfresco-upload/README.md b/ng2-components/ng2-alfresco-upload/README.md index cf8538a4a6..a5f3ea9cef 100644 --- a/ng2-components/ng2-alfresco-upload/README.md +++ b/ng2-components/ng2-alfresco-upload/README.md @@ -1,4 +1,5 @@ # Alfresco Upload Component for Angular 2 +

travis
@@ -31,57 +32,65 @@
   </a>
 </p>
 
-### Node
-To correctly use this component check that on your machine is running Node version 5.0.0 or higher.
+## Prerequisites
+
+Before you start using this development framework, make sure you have installed all required software and done all the
+necessary configuration [prerequisites](https://github.com/Alfresco/alfresco-ng2-components/blob/master/PREREQUISITES.md).
 
 ## Install
 
-```sh
-npm install --save ng2-alfresco-upload
-```
+Follow the 3 steps below:
 
-Components included:
+1. Npm
 
-- [Upload button](#upload-button)
-- [Drag and Drop](#drag-and-drop)
+    ```sh
+    npm install ng2-alfresco-upload --save
+    ```
 
-### Upload button
-This component, provide a buttons to upload files to alfresco.
+2. Html
 
-#### Dependencies
+    Include these dependencies in your index.html page:
 
-Add the following dependency to your index.html:
+    ```html
 
-```html
-<script src="node_modules/alfresco-js-api/bundle.js"></script>
-```
+      <!-- Google Material Design Lite -->
+      <link rel="stylesheet" href="node_modules/material-design-lite/material.min.css">
+      <script src="node_modules/material-design-lite/material.min.js"></script>
+      <link rel="stylesheet" href="node_modules/material-design-icons/iconfont/material-icons.css">
 
-The following component needs to be added to your systemjs.config: 
+      <!-- Polyfill(s) for Safari (pre-10.x) -->
+      <script src="node_modules/intl/dist/Intl.min.js"></script>
+      <script src="node_modules/intl/locale-data/jsonp/en.js"></script>
 
-- ng2-translate
-- ng2-alfresco-core
-- ng2-alfresco-upload
+      <!-- Polyfill(s) for older browsers -->
+      <script src="node_modules/core-js/client/shim.min.js"></script>
+      <script src="//cdnjs.cloudflare.com/ajax/libs/dom4/1.8.3/dom4.js"></script>
+      <script src="node_modules/element.scrollintoviewifneeded-polyfill/index.js"></script>
 
-Please refer to the following example to have an idea of how your systemjs.config should look like :
+      <!-- Polyfill(s) for dialogs -->
+      <script src="node_modules/dialog-polyfill/dialog-polyfill.js"></script>
+      <link rel="stylesheet" type="text/css" href="node_modules/dialog-polyfill/dialog-polyfill.css" />
+      <style>._dialog_overlay { position: static !important; } </style>
 
-https://github.com/Alfresco/alfresco-ng2-components/blob/master/ng2-components/ng2-alfresco-upload/demo/systemjs.config.js
+      <!-- Modules  -->
+      <script src="node_modules/zone.js/dist/zone.js"></script>
+      <script src="node_modules/reflect-metadata/Reflect.js"></script>
+      <script src="node_modules/systemjs/dist/system.src.js"></script>
 
-#### Style
-The style of this component is based on material design, so if you want to visualize it correctly you have to add the material
-design dependency to your project:
+    ```
 
-```sh
-npm install --save material-design-icons material-design-lite
-```
+3. SystemJs
 
-Also make sure you include these dependencies in your .html page:
+    Add the following components to your systemjs.config.js file:
+
+    - ng2-translate
+    - alfresco-js-api
+    - ng2-alfresco-core
+    - ng2-alfresco-upload
+
+    Please refer to the following example file: [systemjs.config.js](demo/systemjs
+    .config.js) .
 
-```html
-<!-- Google Material Design Lite -->
-<link rel="stylesheet" href="node_modules/material-design-lite/material.min.css">
-<script src="node_modules/material-design-lite/material.min.js"></script>
-<link rel="stylesheet" href="node_modules/material-design-icons/iconfont/material-icons.css">
-```
 
 #### Basic usage
 
@@ -101,41 +110,53 @@ Also make sure you include these dependencies in your .html page:
 Example of an App that declares upload button component :
 
 ```ts
-import { Component, OnInit } from + (onSuccess)="onSuccess($event)"> - `, - directives: [ALFRESCO_ULPOAD_COMPONENTS] + ` }) export class MyDemoApp { - constructor(alfrescoSettingsService: AlfrescoSettingsService) { - alfrescoSettingsService.host = 'http://myalfrescoip'; + + constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) { + settingsService.ecmHost = 'http://localhost:8080'; + + this.authService.login('admin', 'admin').subscribe( + ticket => { + console.log(ticket); + }, + error => { + console.log(error); + }); } - public customMethod(event: Object): void { + public onSuccess(event: Object): void { console.log('File uploaded'); } } -bootstrap(MyDemoApp, [ - HTTP_PROVIDERS, - ALFRESCO_CORE_PROVIDERS, - UploadService -]); +@NgModule({ + imports: [ + BrowserModule, + CoreModule.forRoot(), + UploadModule.forRoot() + ], + declarations: [ MyDemoApp ], + bootstrap: [ MyDemoApp ] +}) +export class AppModule { } + +platformBrowserDynamic().bootstrapModule(AppModule); ``` #### Events @@ -169,40 +190,52 @@ This component, provide a drag and drop are to upload files to alfresco. Example of an App that declares upload drag and drop component : ```ts -import { Component, OnInit } from '@angular/core'; -import { bootstrap } from '@angular/platform-browser-dynamic'; -import { HTTP_PROVIDERS } from '@angular/http'; -import { - ALFRESCO_CORE_PROVIDERS, - AlfrescoSettingsService -} from 'ng2-alfresco-core'; -import { ALFRESCO_ULPOAD_COMPONENTS, UploadService } from 'ng2-alfresco-upload'; +import { NgModule, Component } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { CoreModule, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; +import { UploadModule } from 'ng2-alfresco-upload'; @Component({ - selector: 'my-app', + selector: 'alfresco-app-demo', template: `

- `, - directives: [ALFRESCO_ULPOAD_COMPONENTS] + ` }) export class MyDemoApp { - constructor(alfrescoSettingsService: AlfrescoSettingsService) { - alfrescoSettingsService.host = 'http://myalfrescoip'; + + constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) { + settingsService.ecmHost = 'http://localhost:8080'; + + this.authService.login('admin', 'admin').subscribe( + ticket => { + console.log(ticket); + }, + error => { + console.log(error); + }); } - public customMethod(event: Object): void { + public onSuccess(event: Object): void { console.log('File uploaded'); } } -bootstrap(MyDemoApp, [ - HTTP_PROVIDERS, - ALFRESCO_CORE_PROVIDERS, - UploadService -]); +@NgModule({ + imports: [ + BrowserModule, + CoreModule.forRoot(), + UploadModule.forRoot() + ], + declarations: [ MyDemoApp ], + bootstrap: [ MyDemoApp ] +}) +export class AppModule { } + +platformBrowserDynamic().bootstrapModule(AppModule); ``` @@ -232,6 +265,7 @@ with upload button or drag & drop area components. This component should ``` ## Build from sources + Alternatively you can build component from sources with the following commands: @@ -240,28 +274,28 @@ npm install npm run build ``` -##Build the files and keep watching for changes +### Build the files and keep watching for changes ```sh -npm run build:w +$ npm run build:w ``` - + ## Running unit tests ```sh npm test ``` -## Running unit tests in browser +### Running unit tests in browser ```sh npm test-browser ``` -This task rebuilds all the code, runs tslint, license checks and other quality check tools -before performing unit testing. +This task rebuilds all the code, runs tslint, license checks and other quality check tools +before performing unit testing. -## Code coverage +### Code coverage ```sh npm run coverage @@ -276,3 +310,17 @@ cd demo npm install npm start ``` + +## 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 | + +## License + +[Apache Version 2.0](https://github.com/Alfresco/alfresco-ng2-components/blob/master/LICENSE) \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-upload/demo/index.html b/ng2-components/ng2-alfresco-upload/demo/index.html index 0de5abaeda..d788c42269 100644 --- a/ng2-components/ng2-alfresco-upload/demo/index.html +++ b/ng2-components/ng2-alfresco-upload/demo/index.html @@ -8,14 +8,25 @@ - + - + + + + + + + + + + + + @@ -28,7 +39,7 @@ - + diff --git a/ng2-components/ng2-alfresco-upload/demo/package.json b/ng2-components/ng2-alfresco-upload/demo/package.json index 4c4fcd6494..a110f66fba 100644 --- a/ng2-components/ng2-alfresco-upload/demo/package.json +++ b/ng2-components/ng2-alfresco-upload/demo/package.json @@ -52,24 +52,25 @@ "@angular/http": "2.0.0", "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", - "@angular/upgrade": "2.0.0" - "@types/node": "^6.0.42", , "core-js": "^2.4.1", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.12", "systemjs": "0.19.27", "zone.js": "^0.6.23", - "ng2-translate": "2.5.0", + "intl": "1.2.4", + "dialog-polyfill": "^0.4.3", + "element.scrollintoviewifneeded-polyfill": "^1.0.1", "material-design-icons": "2.2.3", "material-design-lite": "1.2.1", + "ng2-translate": "2.5.0", "alfresco-js-api": "^0.3.0", - "ng2-alfresco-core": "^0.3.0", + "ng2-alfresco-core": "0.3.2", "ng2-alfresco-upload": "^0.3.0" }, "devDependencies": { + "@types/node": "^6.0.42", "@types/core-js": "^0.9.32", "@types/jasmine": "^2.2.33", "concurrently": "^2.2.0", diff --git a/ng2-components/ng2-alfresco-upload/demo/src/main.ts b/ng2-components/ng2-alfresco-upload/demo/src/main.ts index 0169851cd1..51ea3cf502 100644 --- a/ng2-components/ng2-alfresco-upload/demo/src/main.ts +++ b/ng2-components/ng2-alfresco-upload/demo/src/main.ts @@ -23,7 +23,7 @@ import { CoreModule, AlfrescoSettingsService, AlfrescoAuthenticationService } fr import { UploadModule } from 'ng2-alfresco-upload'; @Component({ - selector: 'my-app', + selector: 'alfresco-app-demo', template: `


@@ -69,7 +69,6 @@ import { UploadModule } from 'ng2-alfresco-upload';

-

travis
@@ -11,8 +12,8 @@
   <a href= Coverage Status - - npm downloads + + npm downloads license @@ -31,78 +32,130 @@

-### Node -To correctly use this component check that on your machine is running Node version 5.0.0 or higher. - - ## Prerequisites Before you start using this development framework, make sure you have installed all required software and done all the -necessary configuration, see this [page](https://github.com/Alfresco/alfresco-ng2-components/blob/master/PREREQUISITES.md). +necessary configuration [prerequisites](https://github.com/Alfresco/alfresco-ng2-components/blob/master/PREREQUISITES.md). -## Installation +## Install -```bash -npm install ng2-alfresco-userinfo --save -``` -## Dependencies +Follow the 3 steps below: -Add the following dependency to your index.html: -```html - -``` - -You must separately install the following libraries for your application: - -- [ng2-translate](https://github.com/ocombe/ng2-translate) -- [ng2-alfresco-core](https://www.npmjs.com/package/ng2-alfresco-core) +1. Npm -```sh -npm install --save ng2-translate ng2-alfresco-core -``` - -#### Material Design Lite + ```sh + npm install ng2-alfresco-userinfo --save + ``` -The style of this component is based on [material design](https://getmdl.io/), so if you want to visualize it correctly you have to add the material -design dependency to your project: +2. Html -```sh -npm install --save material-design-icons material-design-lite -``` + Include these dependencies in your index.html page: -Also make sure you include these dependencies in your `index.html` file: + ```html -```html - - - - -``` - -## Example + + + + + + + + + + + + + + + + + + + + + + + + + ``` + +3. SystemJs + + Add the following components to your systemjs.config.js file: + + - ng2-translate + - alfresco-js-api + - ng2-alfresco-core + - ng2-alfresco-userinfo + + Please refer to the following example file: [systemjs.config.js](demo/systemjs + .config.js) . ## Basic usage ```html - - + ``` ### Properties | Name | Type | Default | Description | | --- | --- | --- | --- | -| ecmBackgroundImage | string | | Custom path for the background banner image for ECM users | -| bpmBackgroundImage | string | | Custom path for the background banner image for BPM users | -| menuOpenType | string | bottom-right | Custom choice for opening menu bottom right or bottom left | -| fallBackThumbnailImage | string | image at ng2-alfresco-userinfo/src/img/anonymous.gif | Fallback image for profile when thubnail is missing| +| `ecmBackgroundImage` | string | ng2-alfresco-userinfo/src/img/orangeBanner.gif | Custom path for the background banner image for ECM users | +| `bpmBackgroundImage` | string | ng2-alfresco-userinfo/src/img/blueBanner.gif | Custom path for the background banner image for BPM users | +| `menuOpenType` | string | right | Custom choice for opening menu bottom : `right` or `left` | +| `fallBackThumbnailImage` | string | ng2-alfresco-userinfo/src/img/anonymous.gif | Fallback image for profile when thubnail is missing| This will show a round icon with user and on click some user information are showed. If user is logged in with ECM and BPM the ECM image will be showed. +## Build from sources + +Alternatively you can build component from sources with the following commands: + + +```sh +npm install +npm run build +``` + +### Build the files and keep watching for changes + +```sh +$ npm run build:w +``` + +## Running unit tests + +```sh +npm test +``` + +### Running unit tests in browser + +```sh +npm test-browser +``` + +This task rebuilds all the code, runs tslint, license checks and other quality check tools +before performing unit testing. + +### Code coverage + +```sh +npm run coverage +``` + +## Demo + +If you want have a demo of how the component works, please check the demo folder : + +```sh +cd demo +npm install +npm start +``` + ## NPM scripts | Command | Description | @@ -113,10 +166,6 @@ If user is logged in with ECM and BPM the ECM image will be showed. | npm run test-browser | Run unit tests in the browser | npm run coverage | Run unit tests and display code coverage report | -## History +## License -For detailed changelog, check [Releases](https://github.com/alfresco/ng2-alfresco-userinfo/releases). - -## Contributors - -[Contributors](https://github.com/alfresco/ng2-alfresco-userinfo/graphs/contributors) \ No newline at end of file +[Apache Version 2.0](https://github.com/Alfresco/alfresco-ng2-components/blob/master/LICENSE) \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-userinfo/demo/index.html b/ng2-components/ng2-alfresco-userinfo/demo/index.html index 21b9bde5ee..837414bba8 100644 --- a/ng2-components/ng2-alfresco-userinfo/demo/index.html +++ b/ng2-components/ng2-alfresco-userinfo/demo/index.html @@ -8,12 +8,22 @@ - - - + + + + + + + + + + + + + @@ -26,7 +36,7 @@ - + diff --git a/ng2-components/ng2-alfresco-userinfo/demo/package.json b/ng2-components/ng2-alfresco-userinfo/demo/package.json index 89001b7434..b43e6c1f48 100644 --- a/ng2-components/ng2-alfresco-userinfo/demo/package.json +++ b/ng2-components/ng2-alfresco-userinfo/demo/package.json @@ -5,11 +5,12 @@ "author": "Alfresco Software, Ltd.", "main": "index.js", "scripts": { - "clean": "rimraf dist node_modules", + "clean": "npm install rimraf && rimraf dist node_modules typings dist", "postinstall": "npm run build", "start": "npm run build && concurrently \"npm run tsc:w\" \"npm run server\" ", "server": "wsrv -o -s -l", "build": "npm run tslint && rimraf dist && npm run tsc", + "build:w": "npm run tslint && rimraf dist && npm run tsc:w", "tsc": "tsc", "tsc:w": "tsc -w", "tslint": "tslint -c tslint.json *.ts && tslint -c tslint.json src/{,**/}**.ts" @@ -23,24 +24,26 @@ "@angular/http": "2.0.0", "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", - "@angular/upgrade": "2.0.0", - "@types/node": "^6.0.42", "core-js": "^2.4.1", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.12", "systemjs": "0.19.27", "zone.js": "^0.6.23", + "intl": "1.2.4", + "dialog-polyfill": "^0.4.3", + "element.scrollintoviewifneeded-polyfill": "^1.0.1", "material-design-icons": "2.2.3", "material-design-lite": "1.2.1", - "ng2-translate": "2.5.0", + "ng2-translate": "2.5.0", "alfresco-js-api": "^0.3.0", - "ng2-alfresco-core": "^0.3.0", - "ng2-alfresco-userinfo": "0.3.2" + "ng2-alfresco-core": "0.3.2", + "ng2-alfresco-userinfo": "0.3.2", + "ng2-alfresco-login": "^0.3.2" }, "devDependencies": { + "@types/node": "^6.0.42", "@types/core-js": "^0.9.32", "@types/jasmine": "^2.2.33", "concurrently": "^2.2.0", diff --git a/ng2-components/ng2-alfresco-userinfo/demo/src/main.ts b/ng2-components/ng2-alfresco-userinfo/demo/src/main.ts index cb56b38c7b..a0eee66354 100644 --- a/ng2-components/ng2-alfresco-userinfo/demo/src/main.ts +++ b/ng2-components/ng2-alfresco-userinfo/demo/src/main.ts @@ -20,45 +20,53 @@ import { BrowserModule } from '@angular/platform-browser'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { UserInfoComponentModule } from 'ng2-alfresco-userinfo'; import { CoreModule } from 'ng2-alfresco-core'; - +import { LoginModule } from 'ng2-alfresco-login'; import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core'; @Component({ - selector: 'alfresco-userinfo-demo', - template: `

START DEMO USERINFO

-
-

- -

-

- -

+ selector: 'alfresco-app-demo', + template: ` +
+ ECM Host:
+ BPM Host:
+
+ +

+ +

+

+ +

+

+ +

+

+ +

+
+ {{ status }} +
+ + +
+
-
- -
-

-
-

- Username - -

-

- Password - -

- -
- {{loginErrorMessage}} - `, + + + `, styles: [ ':host > .container {padding: 10px}', '.p-10 { padding: 10px; }' @@ -66,80 +74,93 @@ import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfr }) class UserInfoDemo implements OnInit { - public userToLogin: string = 'admin'; - public password: string = 'admin'; - public loginErrorMessage: string; - public providers: string = 'BPM'; - private authenticated: boolean; - private token: any; + public ecmHost: string = 'http://localhost:8080'; - constructor(private authService: AlfrescoAuthenticationService, - private settingsService: AlfrescoSettingsService) { - } + public bpmHost: string = 'http://localhost:9999'; - ngOnInit() { + public userToLogin: string = 'admin'; + + public password: string = 'admin'; + + public loginErrorMessage: string; + + public providers: string = 'BPM'; + + private authenticated: boolean; + + private token: any; + + public disableCsrf: boolean = false; + + constructor(private authService: AlfrescoAuthenticationService, + private settingsService: AlfrescoSettingsService) { + settingsService.ecmHost = this.ecmHost; + settingsService.bpmHost = this.bpmHost; + } + + ngOnInit() { this.settingsService.setProviders(this.providers); - } + } - attemptLogin() { - this.loginErrorMessage = ''; - this.login(this.userToLogin, this.password); - } + logout() { + this.authService.logout(); + } - logout() { - this.authService.logout(); - } + login(user, password) { + this.settingsService.setProviders(this.providers); + this.authService.login(user, password).subscribe( + token => { + console.log(token); + this.token = token; + this.authenticated = true; + }, + error => { + console.log(error); + this.authenticated = false; + this.loginErrorMessage = error; + }); + } - login(user, password) { - this.settingsService.setProviders(this.providers); - this.authService.login(user, password).subscribe( - token => { - console.log(token); - this.token = token; - this.authenticated = true; - }, - error => { - console.log(error); - this.authenticated = false; - this.loginErrorMessage = error; - }); - } + isLoggedIn(): boolean { + return this.authService.isLoggedIn(); + } - isLoggedIn(): boolean { - return this.authService.isLoggedIn(); - } + toggleECM(checked) { + if (checked && this.providers === 'BPM') { + this.providers = 'ALL'; + } else if (checked) { + this.providers = 'ECM'; + } else { + this.providers = undefined; + } + } - toggleECM(checked) { - if (checked && this.providers === 'BPM') { - this.providers = 'ALL'; - } else if (checked) { - this.providers = 'ECM'; - } else { - this.providers = undefined; - } - } - - toggleBPM(checked) { - if (checked && this.providers === 'ECM') { - this.providers = 'ALL'; - } else if (checked) { - this.providers = 'BPM'; - } else { - this.providers = undefined; - } - } + toggleBPM(checked) { + if (checked && this.providers === 'ECM') { + this.providers = 'ALL'; + } else if (checked) { + this.providers = 'BPM'; + } else { + this.providers = undefined; + } + } + toggleCSRF() { + this.disableCsrf = !this.disableCsrf; + } } @NgModule({ imports: [ BrowserModule, CoreModule.forRoot(), - UserInfoComponentModule.forRoot() + UserInfoComponentModule.forRoot(), + LoginModule ], - declarations: [ UserInfoDemo ], - bootstrap: [ UserInfoDemo ] + declarations: [UserInfoDemo], + bootstrap: [UserInfoDemo] }) -export class AppModule { } +export class AppModule { +} platformBrowserDynamic().bootstrapModule(AppModule); diff --git a/ng2-components/ng2-alfresco-userinfo/demo/systemjs.config.js b/ng2-components/ng2-alfresco-userinfo/demo/systemjs.config.js index 8ccc6d9aea..485f49580e 100644 --- a/ng2-components/ng2-alfresco-userinfo/demo/systemjs.config.js +++ b/ng2-components/ng2-alfresco-userinfo/demo/systemjs.config.js @@ -26,7 +26,8 @@ 'ng2-translate': 'npm:ng2-translate', 'alfresco-js-api': 'npm:alfresco-js-api/dist', 'ng2-alfresco-core': 'npm:ng2-alfresco-core/dist', - 'ng2-alfresco-userinfo': 'npm:ng2-alfresco-userinfo/dist' + 'ng2-alfresco-userinfo': 'npm:ng2-alfresco-userinfo/dist', + 'ng2-alfresco-login': 'npm:ng2-alfresco-login/dist' }, // packages tells the System loader how to load when no filename and/or no extension packages: { @@ -38,10 +39,10 @@ defaultExtension: 'js' }, 'ng2-translate': { defaultExtension: 'js' }, - 'ng2-alfresco-core': { main: './index.js', defaultExtension: 'js'}, 'ng2-alfresco-userinfo': { main: './index.js', defaultExtension: 'js'}, - 'alfresco-js-api': { main: './alfresco-js-api.js', defaultExtension: 'js'} + 'alfresco-js-api': { main: './alfresco-js-api.js', defaultExtension: 'js'}, + 'ng2-alfresco-login': { main: './index.js', defaultExtension: 'js'} } }); })(this); diff --git a/ng2-components/ng2-alfresco-userinfo/package.json b/ng2-components/ng2-alfresco-userinfo/package.json index 302a0b705b..165419d510 100644 --- a/ng2-components/ng2-alfresco-userinfo/package.json +++ b/ng2-components/ng2-alfresco-userinfo/package.json @@ -3,8 +3,6 @@ "description": "Alfresco User Info component", "version": "0.3.2", "author": "Alfresco Software, Ltd.", - "main": "./dist/index.js", - "typings": "./dist/index.d.ts", "scripts": { "clean": "npm install rimraf && rimraf dist node_modules typings", "build": "npm run tslint && rimraf dist && tsc && npm run copy-dist && license-check", @@ -23,6 +21,8 @@ "prepublish": "npm run build", "travis": "npm link ng2-alfresco-core" }, + "main": "./dist/index.js", + "typings": "./dist/index.d.ts", "repository": { "type": "git", "url": "https://github.com/Alfresco/alfresco-ng2-components.git" @@ -38,20 +38,24 @@ "@angular/http": "2.0.0", "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", - "@angular/upgrade": "2.0.0", - "@types/node": "^6.0.42", "core-js": "^2.4.1", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.12", "systemjs": "0.19.27", "zone.js": "^0.6.23", - "alfresco-js-api": "^0.3.0", + "intl": "1.2.4", + "dialog-polyfill": "^0.4.3", + "element.scrollintoviewifneeded-polyfill": "^1.0.1", + "material-design-icons": "2.2.3", + "material-design-lite": "1.2.1", + "ng2-translate": "2.5.0", + "alfresco-js-api": "^0.3.0", "ng2-alfresco-core": "0.3.2" }, "devDependencies": { + "@types/node": "^6.0.42", "@types/core-js": "^0.9.32", "@types/jasmine": "^2.2.33", "concurrently": "^2.2.0", diff --git a/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.html b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.html index 394c9aac6f..753230730e 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.html +++ b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.html @@ -1,4 +1,4 @@ -
+
{ let userInfoComp: UserInfoComponent; let fixture: ComponentFixture; let element: HTMLElement; - let stubSetting: AlfrescoSettingsService; + let stubAuthService: AlfrescoAuthenticationService; let stubContent: AlfrescoContentService; + let componentHandler; beforeEach(async(() => { + componentHandler = jasmine.createSpyObj('componentHandler', ['upgradeAllRegistered', 'upgradeElement']); + window['componentHandler'] = componentHandler; TestBed.configureTestingModule({ imports: [CoreModule], declarations: [UserInfoComponent], providers: [EcmUserService, BpmUserService, - AlfrescoSettingsService, + AlfrescoAuthenticationService, {provide: AlfrescoTranslationService, useClass: TranslationMock} ] }).compileComponents().then(() => { @@ -135,9 +138,10 @@ describe('User info component', () => { describe('when user is logged on ecm', () => { beforeEach(() => { - stubSetting = fixture.debugElement.injector.get(AlfrescoSettingsService); + stubAuthService = fixture.debugElement.injector.get(AlfrescoAuthenticationService); stubContent = fixture.debugElement.injector.get(AlfrescoContentService); - spyOn(stubSetting, 'getProviders').and.returnValue('ECM'); + spyOn(stubAuthService, 'isEcmLoggedIn').and.returnValue(true); + spyOn(stubAuthService, 'isLoggedIn').and.returnValue(true); }); beforeEach(() => { @@ -150,7 +154,8 @@ describe('User info component', () => { describe('and has image', () => { - beforeEach(() => { + beforeEach(async(() => { + spyOn(stubContent, 'getContentUrl').and.returnValue('src/assets/ecmImg.gif'); fixture.detectChanges(); jasmine.Ajax.requests.mostRecent().respondWith({ status: 200, @@ -166,41 +171,33 @@ describe('User info component', () => { } } }); - }); + fixture.whenStable().then(() => { + fixture.detectChanges(); + }); + })); it('should show ecm only last name when user first name is null ', async(() => { - spyOn(stubContent, 'getContentUrl').and.returnValue('src/assets/ecmImg.gif'); - fixture.whenStable().then(() => { - userInfoComp.ecmUser.firstName = null; - fixture.detectChanges(); - expect(element.querySelector('#userinfo_container')).toBeDefined(); - expect(element.querySelector('#ecm-username')).toBeDefined(); - expect(element.querySelector('#ecm-username').textContent).not.toContain('fake-ecm-first-name'); - }); + userInfoComp.ecmUser.firstName = null; + fixture.detectChanges(); + expect(element.querySelector('#userinfo_container')).toBeDefined(); + expect(element.querySelector('#ecm-username')).toBeDefined(); + expect(element.querySelector('#ecm-username').textContent).not.toContain('fake-ecm-first-name'); })); it('should get the ecm current user image from the service', async(() => { - spyOn(stubContent, 'getContentUrl').and.returnValue('src/assets/ecmImg.gif'); - fixture.whenStable().then(() => { - fixture.detectChanges(); - expect(element.querySelector('#userinfo_container')).toBeDefined(); - expect(element.querySelector('#logged-user-img')).toBeDefined(); - expect(element.querySelector('#logged-user-img').getAttribute('src')).toEqual('src/assets/ecmImg.gif'); - }); + expect(element.querySelector('#userinfo_container')).toBeDefined(); + expect(element.querySelector('#logged-user-img')).toBeDefined(); + expect(element.querySelector('#logged-user-img').getAttribute('src')).toEqual('src/assets/ecmImg.gif'); })); it('should get the ecm user informations from the service', async(() => { - spyOn(stubContent, 'getContentUrl').and.returnValue('src/assets/ecmImg.gif'); - fixture.whenStable().then(() => { - fixture.detectChanges(); - expect(element.querySelector('#userinfo_container')).toBeDefined(); - expect(element.querySelector('#ecm_username')).toBeDefined(); - expect(element.querySelector('#ecm_title')).toBeDefined(); - expect(element.querySelector('#ecm-user-detail-image')).toBeDefined(); - expect(element.querySelector('#ecm-user-detail-image').getAttribute('src')).toEqual('src/assets/ecmImg.gif'); - expect(element.querySelector('#ecm-full-name').textContent).toContain('fake-ecm-first-name fake-ecm-last-name'); - expect(element.querySelector('#ecm-job-title').textContent).toContain('USER_PROFILE.LABELS.ECM.JOB_TITLE'); - }); + expect(element.querySelector('#userinfo_container')).toBeDefined(); + expect(element.querySelector('#ecm_username')).toBeDefined(); + expect(element.querySelector('#ecm_title')).toBeDefined(); + expect(element.querySelector('#ecm-user-detail-image')).toBeDefined(); + expect(element.querySelector('#ecm-user-detail-image').getAttribute('src')).toEqual('src/assets/ecmImg.gif'); + expect(element.querySelector('#ecm-full-name').textContent).toContain('fake-ecm-first-name fake-ecm-last-name'); + expect(element.querySelector('#ecm-job-title').textContent).toContain('USER_PROFILE.LABELS.ECM.JOB_TITLE'); })); }); @@ -208,6 +205,7 @@ describe('User info component', () => { beforeEach(async(() => { userInfoComp.anonymousImageUrl = userInfoComp.anonymousImageUrl.replace('/base/dist', ''); + spyOn(stubContent, 'getContentUrl').and.returnValue('wrongImage.gif'); fixture.detectChanges(); jasmine.Ajax.requests.mostRecent().respondWith({ status: 200, @@ -244,8 +242,9 @@ describe('User info component', () => { let fakeBpmUserForTest; beforeEach(() => { - stubSetting = fixture.debugElement.injector.get(AlfrescoSettingsService); - spyOn(stubSetting, 'getProviders').and.returnValue('BPM'); + stubAuthService = fixture.debugElement.injector.get(AlfrescoAuthenticationService); + spyOn(stubAuthService, 'isBpmLoggedIn').and.returnValue(true); + spyOn(stubAuthService, 'isLoggedIn').and.returnValue(true); jasmine.Ajax.install(); fakeBpmUserForTest = fakeBpmUser; }); @@ -324,9 +323,11 @@ describe('User info component', () => { describe('when user is logged on bpm and ecm', () => { beforeEach(async(() => { - stubSetting = fixture.debugElement.injector.get(AlfrescoSettingsService); + stubAuthService = fixture.debugElement.injector.get(AlfrescoAuthenticationService); stubContent = fixture.debugElement.injector.get(AlfrescoContentService); - spyOn(stubSetting, 'getProviders').and.returnValue('ALL'); + spyOn(stubAuthService, 'isEcmLoggedIn').and.returnValue(true); + spyOn(stubAuthService, 'isBpmLoggedIn').and.returnValue(true); + spyOn(stubAuthService, 'isLoggedIn').and.returnValue(true); spyOn(stubContent, 'getContentUrl').and.returnValue('src/assets/ecmImg.gif'); userInfoComp.anonymousImageUrl = userInfoComp.anonymousImageUrl.replace('/base/dist', ''); jasmine.Ajax.install(); diff --git a/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.ts b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.ts index 422c23987a..51b326d9c7 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.ts +++ b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.ts @@ -15,12 +15,14 @@ * limitations under the License. */ -import { Component, OnInit, Input } from '@angular/core'; +import { Component, OnInit, Input, AfterViewChecked } from '@angular/core'; import { EcmUserModel } from './../models/ecm-user.model'; import { BpmUserModel } from './../models/bpm-user.model'; import { EcmUserService } from './../services/ecm-user.service'; import { BpmUserService } from './../services/bpm-user.service'; -import { AlfrescoSettingsService, AlfrescoTranslationService } from 'ng2-alfresco-core'; +import { AlfrescoTranslationService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; + +declare let componentHandler: any; @Component({ selector: 'ng2-alfresco-userinfo', @@ -28,8 +30,7 @@ import { AlfrescoSettingsService, AlfrescoTranslationService } from 'ng2-alfresc styleUrls: ['./user-info.component.css'], templateUrl: './user-info.component.html' }) - -export class UserInfoComponent implements OnInit { +export class UserInfoComponent implements AfterViewChecked, OnInit { @Input() ecmBackgroundImage: string; @@ -46,23 +47,50 @@ export class UserInfoComponent implements OnInit { private baseComponentPath = module.id.replace('components/user-info.component.js', ''); ecmUser: EcmUserModel; + bpmUser: BpmUserModel; + anonymousImageUrl: string = this.baseComponentPath + 'img/anonymous.gif'; + bpmUserImage: any; + ecmUserImage: any; constructor(private ecmUserService: EcmUserService, private bpmUserService: BpmUserService, - public setting: AlfrescoSettingsService, + private authService: AlfrescoAuthenticationService, private translate: AlfrescoTranslationService) { if (translate) { translate.addTranslationFolder('node_modules/ng2-alfresco-userinfo/src'); } + + authService.loginSubject.subscribe((response) => { + this.getUserInfo(); + }); + } + + ngAfterViewChecked() { + // workaround for MDL issues with dynamic components + if (componentHandler) { + componentHandler.upgradeAllRegistered(); + } } ngOnInit() { - if (this.setting.getProviders() === 'ECM' || - this.setting.getProviders() === 'ALL') { + this.getUserInfo(); + } + + getUserInfo() { + this.getEcmUserInfo(); + this.getBpmUserInfo(); + } + + isLoggedIn() { + return this.authService.isLoggedIn(); + } + + getEcmUserInfo(): void { + if (this.authService.isEcmLoggedIn()) { this.ecmUserService.getCurrentUserInfo() .subscribe((res) => { this.ecmUser = res; @@ -70,9 +98,10 @@ export class UserInfoComponent implements OnInit { } ); } + } - if (this.setting.getProviders() === 'BPM' || - this.setting.getProviders() === 'ALL') { + getBpmUserInfo(): void { + if (this.authService.isBpmLoggedIn()) { this.bpmUserService.getCurrentUserInfo() .subscribe((res) => { this.bpmUser = res; diff --git a/ng2-components/ng2-alfresco-viewer/.npmignore b/ng2-components/ng2-alfresco-viewer/.npmignore index 5b61c3a72d..5fc4cf8597 100644 --- a/ng2-components/ng2-alfresco-viewer/.npmignore +++ b/ng2-components/ng2-alfresco-viewer/.npmignore @@ -2,7 +2,6 @@ npm-debug.log .idea demo/localTestFile.pdf -assets/ coverage/ node_modules typings/ diff --git a/ng2-components/ng2-alfresco-viewer/README.md b/ng2-components/ng2-alfresco-viewer/README.md index dd408ffabe..e7e46063c9 100644 --- a/ng2-components/ng2-alfresco-viewer/README.md +++ b/ng2-components/ng2-alfresco-viewer/README.md @@ -1,4 +1,5 @@ # Alfresco File Viewer Component for Angular 2 +

travis
@@ -31,47 +32,72 @@
   </a>
 </p>
 
-### Node
-To correctly use this component check that on your machine is running Node version 5.0.0 or higher.
+## Prerequisites
+
+Before you start using this development framework, make sure you have installed all required software and done all the
+necessary configuration [prerequisites](https://github.com/Alfresco/alfresco-ng2-components/blob/master/PREREQUISITES.md).
 
 ## Install
 
-```sh
-npm install --save ng2-alfresco-viewer
-```
+Follow the 3 steps below:
 
-#### Dependencies
+1. Npm
 
-Add the following dependency to your index.html:
+    ```sh
+    npm install ng2-alfresco-viewer --save
+    ```
 
-```html
-<script src="node_modules/pdfjs-dist/build/pdf.js"></script>
-<script src="node_modules/pdfjs-dist/build/pdf.worker.js"></script>
-<script src="node_modules/pdfjs-dist/web/pdf_viewer.js"></script>
-<script src="node_modules/alfresco-js-api/dist/alfresco-js-api.js"></script>
-```
+2. Html
 
-The following component needs to be added to your systemjs.config: 
+    Include these dependencies in your index.html page:
 
-- ng2-translate
-- ng2-alfresco-core
+    ```html
 
-#### Style
-The style of this component is based on material design, so if you want to visualize it correctly you have to add the material
-design dependency to your project:
+    <!-- Google Material Design Lite -->
+    <link rel="stylesheet" href="node_modules/material-design-lite/material.min.css">
+    <script src="node_modules/material-design-lite/material.min.js"></script>
+    <link rel="stylesheet" href="node_modules/material-design-icons/iconfont/material-icons.css">
 
-```sh
-npm install --save material-design-icons material-design-lite
-```
+    <!-- Polyfill(s) for Safari (pre-10.x) -->
+    <script src="node_modules/intl/dist/Intl.min.js"></script>
+    <script src="node_modules/intl/locale-data/jsonp/en.js"></script>
 
-Also make sure you include these dependencies in your .html page:
+    <!-- Polyfill(s) for older browsers -->
+    <script src="node_modules/core-js/client/shim.min.js"></script>
+    <script src="//cdnjs.cloudflare.com/ajax/libs/dom4/1.8.3/dom4.js"></script>
+    <script src="node_modules/element.scrollintoviewifneeded-polyfill/index.js"></script>
 
-```html
-<!-- Google Material Design Lite -->
-<link rel="stylesheet" href="node_modules/material-design-lite/material.min.css">
-<script src="node_modules/material-design-lite/material.min.js"></script>
-<link rel="stylesheet" href="node_modules/material-design-icons/iconfont/material-icons.css">
-```
+    <!-- Polyfill(s) for dialogs -->
+    <script src="node_modules/dialog-polyfill/dialog-polyfill.js"></script>
+    <link rel="stylesheet" type="text/css" href="node_modules/dialog-polyfill/dialog-polyfill.css" />
+    <style>._dialog_overlay { position: static !important; } </style>
+
+    <!-- Modules  -->
+    <script src="node_modules/zone.js/dist/zone.js"></script>
+    <script src="node_modules/reflect-metadata/Reflect.js"></script>
+    <script src="node_modules/systemjs/dist/system.src.js"></script>
+
+    <!-- Polyfill(s) for pdf support -->
+    <script src="node_modules/pdfjs-dist/web/compatibility.js"></script>
+
+    <script src="node_modules/pdfjs-dist/build/pdf.js"></script>
+    <script src="node_modules/pdfjs-dist/build/pdf.worker.js"></script>
+    <script src="node_modules/pdfjs-dist/web/pdf_viewer.js"></script>
+
+
+    ```
+
+3. SystemJs
+
+    Add the following components to your systemjs.config.js file:
+
+    - ng2-translate
+    - alfresco-js-api
+    - ng2-alfresco-core
+    - ng2-alfresco-viewer
+
+    Please refer to the following example file: [systemjs.config.js](demo/systemjs
+    .config.js) .
 
 #### Basic usage with node id
 
@@ -82,28 +108,46 @@ Also make sure you include these dependencies in your .html page:
 Example of an App that declares the file viewer component :
 
 ```ts
-import { Component } from + selector: 'alfresco-app-demo', + template: `

- `, - directives: [VIEWERCOMPONENT] + ` }) class MyDemoApp { - fileNodeId: any; - - constructor() { - this.fileNodeId = '09469a81-1ed9-4caa-a5df-8362fc3d096f'; + constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) { + settingsService.ecmHost = 'http://localhost:8080'; + + this.authService.login('admin', 'admin').subscribe( + ticket => { + console.log(ticket); + }, + error => { + console.log(error); + }); } } -bootstrap(MyDemoApp, [ - VIEWERCOMPONENT -]); + +@NgModule({ + imports: [ + BrowserModule, + CoreModule.forRoot(), + ViewerModule.forRoot() + ], + declarations: [ MyDemoApp ], + bootstrap: [ MyDemoApp ] +}) +export class AppModule { } + +platformBrowserDynamic().bootstrapModule(AppModule); + ``` #### Basic usage with urlFile @@ -115,25 +159,45 @@ bootstrap(MyDemoApp, [ Example of an App that declares the file viewer component : ```ts -import { Component } from '@angular/core'; -import { bootstrap } from '@angular/platform-browser-dynamic'; -import { VIEWERCOMPONENT } from 'ng2-alfresco-viewer'; +import { NgModule, Component } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { CoreModule, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; +import { ViewerModule } from 'ng2-alfresco-viewer'; @Component({ - selector: 'my-app', - template: ` + selector: 'alfresco-app-demo', + template: `
-
`, - directives: [VIEWERCOMPONENT] +
` }) class MyDemoApp { - constructor() { - console.log('constructor'); + + constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) { + settingsService.ecmHost = 'http://localhost:8080'; + + this.authService.login('admin', 'admin').subscribe( + ticket => { + console.log(ticket); + }, + error => { + console.log(error); + }); } } -bootstrap(MyDemoApp, [ - VIEWERCOMPONENT -]); + +@NgModule({ + imports: [ + BrowserModule, + CoreModule.forRoot(), + ViewerModule.forRoot() + ], + declarations: [ MyDemoApp ], + bootstrap: [ MyDemoApp ] +}) +export class AppModule { } + +platformBrowserDynamic().bootstrapModule(AppModule); ``` #### Options @@ -157,26 +221,28 @@ Text | pdf ## Build from sources + Alternatively you can build component from sources with the following commands: + ```sh npm install npm run build ``` -##Build the files and keep watching for changes +### Build the files and keep watching for changes + +```sh +$ npm run build:w +``` - ```sh - $ npm run build:w - ``` - ## Running unit tests ```sh npm test ``` -## Running unit tests in browser +### Running unit tests in browser ```sh npm test-browser @@ -185,7 +251,7 @@ npm test-browser This task rebuilds all the code, runs tslint, license checks and other quality check tools before performing unit testing. -## Code coverage +### Code coverage ```sh npm run coverage @@ -201,25 +267,17 @@ npm install npm start ``` +## NPM scripts -## History +| 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 | -For detailed changelog, check [Releases](https://github.com/alfresco/ng2-alfresco-viewer/releases). +## License -## Contributors +[Apache Version 2.0](https://github.com/Alfresco/alfresco-ng2-components/blob/master/LICENSE) -[Contributors](https://github.com/alfresco/ng2-alfresco-viewer/graphs/contributors) - - -[npm-image]: https://badge.fury.io/js/ng2-alfresco-viewer.svg -[npm-url]: https://npmjs.org/package/ng2-alfresco-viewer -[travis-image]: https://travis-ci.org/alfresco/ng2-alfresco-viewer.svg?branch=master -[travis-url]: https://travis-ci.org/alfresco/ng2-alfresco-viewer -[daviddm-image]: https://david-dm.org/alfresco/ng2-alfresco-viewer.svg?theme=shields.io -[daviddm-url]: https://david-dm.org/alfresco/ng2-alfresco-viewer -[coveralls-image]: https://coveralls.io/repos/alfresco/ng2-alfresco-viewer/badge.svg -[coveralls-url]: https://coveralls.io/r/alfresco/ng2-alfresco-viewer -[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-alfresco-viewer/demo/index.html b/ng2-components/ng2-alfresco-viewer/demo/index.html index 6c6cb39409..86aea902df 100644 --- a/ng2-components/ng2-alfresco-viewer/demo/index.html +++ b/ng2-components/ng2-alfresco-viewer/demo/index.html @@ -10,14 +10,28 @@ - + + + + + + + + + + + + + + + @@ -29,7 +43,7 @@ - + diff --git a/ng2-components/ng2-alfresco-viewer/demo/package.json b/ng2-components/ng2-alfresco-viewer/demo/package.json index 23d7a464e6..f99da35efc 100644 --- a/ng2-components/ng2-alfresco-viewer/demo/package.json +++ b/ng2-components/ng2-alfresco-viewer/demo/package.json @@ -24,25 +24,27 @@ "@angular/http": "2.0.0", "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", - "@angular/upgrade": "2.0.0", - "@types/node": "^6.0.42", "core-js": "^2.4.1", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.12", "systemjs": "0.19.27", "zone.js": "^0.6.23", + "intl": "1.2.4", + "dialog-polyfill": "^0.4.3", + "element.scrollintoviewifneeded-polyfill": "^1.0.1", "material-design-icons": "2.2.3", "material-design-lite": "1.2.1", - "pdfjs-dist": "1.5.258", "ng2-translate": "2.5.0", - "ng2-alfresco-core": "^0.3.0", "alfresco-js-api": "^0.3.0", - "ng2-alfresco-viewer": "0.3.2" + "ng2-alfresco-core": "0.3.2", + "ng2-alfresco-viewer": "0.3.2", + + "pdfjs-dist": "1.5.404" }, "devDependencies": { + "@types/node": "^6.0.42", "@types/core-js": "^0.9.32", "@types/jasmine": "^2.2.33", "concurrently": "^2.2.0", diff --git a/ng2-components/ng2-alfresco-viewer/demo/src/main.ts b/ng2-components/ng2-alfresco-viewer/demo/src/main.ts index ec2ea9b2b6..26796f0ac3 100644 --- a/ng2-components/ng2-alfresco-viewer/demo/src/main.ts +++ b/ng2-components/ng2-alfresco-viewer/demo/src/main.ts @@ -22,7 +22,7 @@ import { CoreModule, AlfrescoSettingsService, AlfrescoAuthenticationService } fr import { ViewerModule } from 'ng2-alfresco-viewer'; @Component({ - selector: 'my-app', + selector: 'alfresco-app-demo', template: `

@@ -33,16 +33,21 @@ import { ViewerModule } from 'ng2-alfresco-viewer'; operations.

-
- -
-
-
` + + File node id: +
+ +
+
+
` }) class MyDemoApp { + + fileNodeId: string; + authenticated: boolean; ecmHost: string = 'http://127.0.0.1:8080'; diff --git a/ng2-components/ng2-alfresco-viewer/package.json b/ng2-components/ng2-alfresco-viewer/package.json index 7e320d2ea2..7e3c140efb 100644 --- a/ng2-components/ng2-alfresco-viewer/package.json +++ b/ng2-components/ng2-alfresco-viewer/package.json @@ -53,20 +53,25 @@ "@angular/http": "2.0.0", "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", - "@angular/router": "3.0.0", - "@angular/upgrade": "2.0.0", - "@types/node": "^6.0.42", "core-js": "^2.4.1", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.12", "systemjs": "0.19.27", "zone.js": "^0.6.23", + + "intl": "1.2.4", + "dialog-polyfill": "^0.4.3", + "element.scrollintoviewifneeded-polyfill": "^1.0.1", + "material-design-icons": "2.2.3", + "material-design-lite": "1.2.1", + "ng2-translate": "2.5.0", "alfresco-js-api": "^0.3.0", "ng2-alfresco-core": "0.3.2", "pdfjs-dist": "1.5.404" }, "devDependencies": { + "@types/node": "^6.0.42", "@types/core-js": "^0.9.32", "@types/jasmine": "^2.2.33", "concurrently": "^2.2.0", diff --git a/ng2-components/ng2-alfresco-webscript/.npmignore b/ng2-components/ng2-alfresco-webscript/.npmignore new file mode 100644 index 0000000000..c5ca623298 --- /dev/null +++ b/ng2-components/ng2-alfresco-webscript/.npmignore @@ -0,0 +1,15 @@ +npm-debug.log +.idea + +coverage/ +node_modules +typings/ +fonts/ + +/.editorconfig +/.travis.yml +/*.js +/*.json +/*.ts +/*.js.map +/.npmignore diff --git a/ng2-components/ng2-alfresco-webscript/README.md b/ng2-components/ng2-alfresco-webscript/README.md index 8f2ec302d5..4f86f12016 100644 --- a/ng2-components/ng2-alfresco-webscript/README.md +++ b/ng2-components/ng2-alfresco-webscript/README.md @@ -1,4 +1,5 @@ # Alfresco Webscript Component for Angular 2 +

travis
@@ -14,56 +15,81 @@
   <a href= npm downloads + + license + + + alfresco component + + + angular 2 + + + typescript + + + node version +

-### Node -To correctly use this component check that on your machine is running Node version 5.0.0 or higher. +## Prerequisites + +Before you start using this development framework, make sure you have installed all required software and done all the +necessary configuration [prerequisites](https://github.com/Alfresco/alfresco-ng2-components/blob/master/PREREQUISITES.md). ## Install -```sh -npm install --save ng2-alfresco-webscript -``` +Follow the 3 steps below: -Components included: +1. Npm -* Alfresco Webscript Component + ```sh + npm install ng2-alfresco-webscript --save + ``` -#### Dependencies +2. Html -Add the following dependency to your index.html: + Include these dependencies in your index.html page: -```html - -``` + ```html -The following component needs to be added to your systemjs.config: + + + + -- ng2-translate -- ng2-alfresco-core -- ng2-alfresco-datatable + + + -Please refer to the following example to have an idea of how your systemjs.config should look like : + + + + -https://github.com/Alfresco/alfresco-ng2-components/blob/master/ng2-components/ng2-alfresco-webscript/demo/systemjs.config.js + + + + -#### Style -The style of this component is based on material design, so if you want to visualize it correctly you have to add the material -design dependency to your project: + + + + -```sh -npm install --save material-design-icons material-design-lite -``` + ``` -Also make sure you include these dependencies in your .html page: +3. SystemJs -```html - - - - -``` + Add the following components to your systemjs.config.js file: + - ng2-translate + - alfresco-js-api + - ng2-alfresco-core + - ng2-alfresco-datatable + + Please refer to the following example file: [systemjs.config.js](demo/systemjs + .config.js) . #### Basic usage @@ -83,47 +109,57 @@ Example of an App that use Alfresco webscript component : main.ts ```ts -import { Component } from '@angular/core'; -import { bootstrap } from '@angular/platform-browser-dynamic'; -import { HTTP_PROVIDERS } from '@angular/http'; - -import { - ALFRESCO_CORE_PROVIDERS, - AlfrescoSettingsService, - AlfrescoAuthenticationService -} from 'ng2-alfresco-core'; - -import { WEBSCRIPTCOMPONENT } from 'ng2-alfresco-webscript'; +import { NgModule, Component } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { CoreModule, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; +import { DataTableModule } from 'ng2-alfresco-datatable'; +import { WebScriptModule } from 'ng2-alfresco-webscript'; @Component({ - selector: 'my-app', - template: ` - - `, - directives: [WEBSCRIPTCOMPONENT] + + ` }) -export class AppComponent { +class WebscriptDemo { scriptPath: string = 'sample/folder/Company%20Home'; contextRoot: string = 'alfresco'; servicePath: string = 'service'; - - constructor(public auth: AlfrescoAuthenticationService, - alfrescoSettingsService: AlfrescoSettingsService) { - alfrescoSettingsService.host = 'http://myalfrescoip'; + + constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) { + settingsService.ecmHost = 'http://localhost:8080'; + + this.authService.login('admin', 'admin').subscribe( + ticket => { + console.log(ticket); + }, + error => { + console.log(error); + }); } } -bootstrap(AppComponent, [ - HTTP_PROVIDERS, - ALFRESCO_CORE_PROVIDERS -]); +@NgModule({ + imports: [ + BrowserModule, + CoreModule.forRoot(), + DataTableModule, + WebScriptModule + ], + declarations: [ WebscriptDemo ], + bootstrap: [ WebscriptDemo ] +}) +export class AppModule { } + +platformBrowserDynamic().bootstrapModule(AppModule); ``` @@ -246,36 +282,37 @@ You can get the plain data from the webscript through the **onSuccess** event pa ## Build from sources + Alternatively you can build component from sources with the following commands: - - + + ```sh npm install npm run build ``` -##Build the files and keep watching for changes +### Build the files and keep watching for changes ```sh -npm run build:w +$ npm run build:w ``` - + ## Running unit tests ```sh npm test ``` -## Running unit tests in browser +### Running unit tests in browser ```sh npm test-browser ``` -This task rebuilds all the code, runs tslint, license checks and other quality check tools -before performing unit testing. +This task rebuilds all the code, runs tslint, license checks and other quality check tools +before performing unit testing. -## Code coverage +### Code coverage ```sh npm run coverage @@ -291,3 +328,16 @@ npm install npm start ``` +## 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 | + +## License + +[Apache Version 2.0](https://github.com/Alfresco/alfresco-ng2-components/blob/master/LICENSE) diff --git a/ng2-components/ng2-alfresco-webscript/demo/index.html b/ng2-components/ng2-alfresco-webscript/demo/index.html index ec2facc018..e274c4debe 100644 --- a/ng2-components/ng2-alfresco-webscript/demo/index.html +++ b/ng2-components/ng2-alfresco-webscript/demo/index.html @@ -11,17 +11,25 @@ - + + + + + + + + + + + + - - -