From d79da08a02e7bf7750205db8b0794c1c8155beaf Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Mon, 5 Sep 2016 19:44:33 +0200 Subject: [PATCH] typescript examples in readme --- ng2-components/ng2-alfresco-tag/README.md | 215 ++++++++++++++++++ .../ng2-alfresco-tag/demo/src/main.ts | 5 +- 2 files changed, 216 insertions(+), 4 deletions(-) diff --git a/ng2-components/ng2-alfresco-tag/README.md b/ng2-components/ng2-alfresco-tag/README.md index 5bf9f8f6d5..19644d416c 100644 --- a/ng2-components/ng2-alfresco-tag/README.md +++ b/ng2-components/ng2-alfresco-tag/README.md @@ -88,14 +88,229 @@ In this component are present three different tags : ##### alfresco-tag-node-actions-list +```html + +``` + +```ts +import { Component, OnInit, Input } from '@angular/core'; +import { bootstrap } from '@angular/platform-browser-dynamic'; +import { HTTP_PROVIDERS } from '@angular/http'; + +import { + ALFRESCO_CORE_PROVIDERS, + AlfrescoSettingsService, + AlfrescoAuthenticationService +} from 'ng2-alfresco-core'; + +import { TAGCOMPONENT, TAGSERVICES } from 'ng2-alfresco-tag'; + +@Component({ + selector: 'alfresco-tag-demo', + template: ` +
+ +
+ `, + directives: [TAGCOMPONENT, CONTEXT_MENU_DIRECTIVES], + providers: [TAGSERVICES] +}) +class TagDemo implements OnInit { + + @Input() + nodeId: string = '74cd8a96-8a21-47e5-9b3b-a1b3e296787d'; + + authenticated: boolean; + + ecmHost: string = 'http://127.0.0.1:8080'; + + ticket: string; + + constructor(private authService: AlfrescoAuthenticationService, + private settingsService: AlfrescoSettingsService) { + settingsService.ecmHost = this.ecmHost; + settingsService.setProviders('ECM'); + } + + ngOnInit() { + this.login(); + } + + login() { + this.authService.login('admin', 'admin').subscribe( + ticket => { + this.authenticated = true; + }, + error => { + this.authenticated = false; + }); + } + + public updateHost(): void { + this.settingsService.ecmHost = this.ecmHost; + this.login(); + } + + logData(data) { + console.log(data); + } +} +bootstrap(TagDemo, [ + HTTP_PROVIDERS, + ALFRESCO_CORE_PROVIDERS +]); +``` + + ![Custom columns](docs/assets/tag3.png) ##### alfresco-tag-node-list +```html + +``` + +```ts +import { Component, OnInit, Input } from '@angular/core'; +import { bootstrap } from '@angular/platform-browser-dynamic'; +import { HTTP_PROVIDERS } from '@angular/http'; + +import { + ALFRESCO_CORE_PROVIDERS, + AlfrescoSettingsService, + AlfrescoAuthenticationService +} from 'ng2-alfresco-core'; + +import { TAGCOMPONENT, TAGSERVICES } from 'ng2-alfresco-tag'; + +@Component({ + selector: 'alfresco-tag-demo', + template: ` +
+ +
+ `, + directives: [TAGCOMPONENT, CONTEXT_MENU_DIRECTIVES], + providers: [TAGSERVICES] +}) +class TagDemo implements OnInit { + + @Input() + nodeId: string = '74cd8a96-8a21-47e5-9b3b-a1b3e296787d'; + + authenticated: boolean; + + ecmHost: string = 'http://127.0.0.1:8080'; + + ticket: string; + + constructor(private authService: AlfrescoAuthenticationService, + private settingsService: AlfrescoSettingsService) { + settingsService.ecmHost = this.ecmHost; + settingsService.setProviders('ECM'); + } + + ngOnInit() { + this.login(); + } + + login() { + this.authService.login('admin', 'admin').subscribe( + ticket => { + this.authenticated = true; + }, + error => { + this.authenticated = false; + }); + } + + public updateHost(): void { + this.settingsService.ecmHost = this.ecmHost; + this.login(); + } + + logData(data) { + console.log(data); + } +} +bootstrap(TagDemo, [ + HTTP_PROVIDERS, + ALFRESCO_CORE_PROVIDERS +]); +``` + ![Custom columns](docs/assets/tag1.png) ##### alfresco-tag-list +```html + +``` + +```ts +import { Component, OnInit, Input } from '@angular/core'; +import { bootstrap } from '@angular/platform-browser-dynamic'; +import { HTTP_PROVIDERS } from '@angular/http'; + +import { + ALFRESCO_CORE_PROVIDERS, + AlfrescoSettingsService, + AlfrescoAuthenticationService +} from 'ng2-alfresco-core'; + +import { TAGCOMPONENT, TAGSERVICES } from 'ng2-alfresco-tag'; + +@Component({ + selector: 'alfresco-tag-demo', + template: ` +
+ +
+ `, + directives: [TAGCOMPONENT, CONTEXT_MENU_DIRECTIVES], + providers: [TAGSERVICES] +}) +class TagDemo implements OnInit { + + authenticated: boolean; + + ecmHost: string = 'http://127.0.0.1:8080'; + + constructor(private authService: AlfrescoAuthenticationService, + private settingsService: AlfrescoSettingsService) { + settingsService.ecmHost = this.ecmHost; + settingsService.setProviders('ECM'); + } + + ngOnInit() { + this.login(); + } + + login() { + this.authService.login('admin', 'admin').subscribe( + ticket => { + this.authenticated = true; + }, + error => { + this.authenticated = false; + }); + } + + public updateHost(): void { + this.settingsService.ecmHost = this.ecmHost; + this.login(); + } + + logData(data) { + console.log(data); + } +} +bootstrap(TagDemo, [ + HTTP_PROVIDERS, + ALFRESCO_CORE_PROVIDERS +]); +``` + ![Custom columns](docs/assets/tag2.png) diff --git a/ng2-components/ng2-alfresco-tag/demo/src/main.ts b/ng2-components/ng2-alfresco-tag/demo/src/main.ts index 2e1241c0ff..14f5f22d1a 100644 --- a/ng2-components/ng2-alfresco-tag/demo/src/main.ts +++ b/ng2-components/ng2-alfresco-tag/demo/src/main.ts @@ -22,8 +22,7 @@ import { HTTP_PROVIDERS } from '@angular/http'; import { ALFRESCO_CORE_PROVIDERS, AlfrescoSettingsService, - AlfrescoAuthenticationService, - CONTEXT_MENU_DIRECTIVES + AlfrescoAuthenticationService } from 'ng2-alfresco-core'; import { TAGCOMPONENT, TAGSERVICES } from 'ng2-alfresco-tag'; @@ -61,8 +60,6 @@ class TagDemo implements OnInit { @Input() nodeId: string = '74cd8a96-8a21-47e5-9b3b-a1b3e296787d'; - currentPath: string = '/'; - authenticated: boolean; ecmHost: string = 'http://127.0.0.1:8080';