/*! * @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 { DebugElement, 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, ActivitiProcessFilters, ActivitiProcessInstanceDetails, ActivitiProcessInstanceListComponent, ActivitiStartProcessInstance, ProcessInstance } from 'ng2-activiti-processlist'; import { AlfrescoAuthenticationService, SettingsService, StorageService } from 'ng2-alfresco-core'; import { ObjectDataTableAdapter } from 'ng2-alfresco-datatable'; const currentProcessIdNew = '__NEW__'; @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

Process Variables

Start Process

`, styles: [` header { min-height: 48px; } h2 { font-size: 14px; line-height: 20px; margin: 10px 0; } `] }) class MyDemoApp implements OnInit { authenticated: boolean; host: string = 'http://localhost:9999'; ticket: string; @ViewChild('tabmain') tabMain: DebugElement; @ViewChild('tabheader') tabHeader: DebugElement; @ViewChild(ActivitiProcessFilters) activitiprocessfilter: ActivitiProcessFilters; @ViewChild(ActivitiProcessInstanceListComponent) activitiprocesslist: ActivitiProcessInstanceListComponent; @ViewChild(ActivitiProcessInstanceDetails) activitiprocessdetails: ActivitiProcessInstanceDetails; @ViewChild(ActivitiStartProcessInstance) activitiStartProcess: ActivitiStartProcessInstance; @Input() appId: number; processFilter: any; currentProcessInstanceId: string; dataProcesses: ObjectDataTableAdapter; constructor(private authService: AlfrescoAuthenticationService, private settingsService: SettingsService, private storage: StorageService) { 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', sortable: true, cssClass: 'hidden'} ] ); } public updateTicket(): void { this.storage.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'); } navigateStartProcess() { this.currentProcessInstanceId = currentProcessIdNew; } onStartProcessInstance(instance: ProcessInstance) { this.currentProcessInstanceId = instance.id; this.activitiStartProcess.reset(); } isStartProcessMode() { return this.currentProcessInstanceId === currentProcessIdNew; } onProcessFilterClick(event: any) { this.processFilter = event; } onSuccessProcessFilterList(event: any) { this.processFilter = this.activitiprocessfilter.getCurrentFilter(); } onSuccessProcessList(event: any) { this.currentProcessInstanceId = this.activitiprocesslist.getCurrentId(); } 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, ActivitiTaskListModule.forRoot() ], declarations: [MyDemoApp], bootstrap: [MyDemoApp] }) export class AppModule { } platformBrowserDynamic().bootstrapModule(AppModule);