Migrate from window.console to LogService

This commit is contained in:
Denys Vuika
2017-01-05 21:06:30 +00:00
parent 2d98a04f87
commit d42f41ec00
106 changed files with 1177 additions and 1171 deletions

View File

@@ -19,40 +19,39 @@ import { NgModule, Component } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { CoreModule, SettingsService, AuthService, StorageService } from 'ng2-alfresco-core';
import { CoreModule, SettingsService, AuthService, StorageService, LogService } from 'ng2-alfresco-core';
import { DiagramsModule } from 'ng2-activiti-diagrams';
@Component({
selector: 'alfresco-app-demo',
template: `
<label for="ticket"><b>Insert a valid ticket:</b></label><br>
<input id="ticket" type="text" size="48" (change)="updateTicket()" [(ngModel)]="ticket"><br>
<label for="host"><b>Insert the ip of your Activiti instance:</b></label><br>
<input id="host" type="text" size="48" (change)="updateHost()" [(ngModel)]="host"><br><br>
<div *ngIf="!authenticated" style="color:#FF2323">
Authentication failed to ip {{ host }} with user: admin, admin, you can still try to add a valid ticket to perform
operations.
</div>
<hr>
<label for="ticket"><b>Insert a valid ticket:</b></label><br>
<input id="ticket" type="text" size="48" (change)="updateTicket()" [(ngModel)]="ticket"><br>
<label for="host"><b>Insert the ip of your Activiti instance:</b></label><br>
<input id="host" type="text" size="48" (change)="updateHost()" [(ngModel)]="host"><br><br>
<div *ngIf="!authenticated" style="color:#FF2323">
Authentication failed to ip {{ host }} with user: admin, admin, you can still try to add a valid ticket to perform
operations.
</div>
<hr>
<label for="processDefinitionId"><b>Insert the ProcessDefinitionId:</b></label><br>
<input id="processDefinitionId" size="70" type="text" [(ngModel)]="processDefinitionId">
<activiti-diagram [processDefinitionId]="processDefinitionId"></activiti-diagram>`
<label for="processDefinitionId"><b>Insert the ProcessDefinitionId:</b></label><br>
<input id="processDefinitionId" size="70" type="text" [(ngModel)]="processDefinitionId">
<activiti-diagram [processDefinitionId]="processDefinitionId"></activiti-diagram>
`
})
export class DiagramDemoComponent {
processDefinitionId: string = 'ThirdProcess:1:15053';
authenticated: boolean;
host: string = 'http://localhost:9999';
ticket: string;
constructor(private authService: AuthService,
private settingsService: SettingsService,
private storage: StorageService) {
private storage: StorageService,
private logService: LogService) {
settingsService.bpmHost = this.host;
settingsService.setProviders('BPM');
@@ -77,12 +76,12 @@ export class DiagramDemoComponent {
login() {
this.authService.login('admin', 'admin').subscribe(
ticket => {
console.log(ticket);
this.logService.info(`Logged in with ticket ${ticket}`);
this.ticket = this.authService.getTicketBpm();
this.authenticated = true;
},
error => {
console.log(error);
this.logService.error(error);
this.authenticated = false;
});
}

View File

@@ -16,7 +16,7 @@
*/
import { Component, ElementRef, Input, Output, EventEmitter, SimpleChanges } from '@angular/core';
import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { AlfrescoTranslateService, LogService } from 'ng2-alfresco-core';
import { DiagramsService } from '../services/diagrams.service';
import { DiagramColorService } from '../services/diagram-color.service';
import { RaphaelService } from './raphael/raphael.service';
@@ -57,17 +57,16 @@ export class DiagramComponent {
PADDING_HEIGHT: number = 60;
private diagram: DiagramModel;
private elementRef: ElementRef;
constructor(elementRef: ElementRef,
constructor(private elementRef: ElementRef,
private translateService: AlfrescoTranslateService,
private diagramColorService: DiagramColorService,
private raphaelService: RaphaelService,
private diagramsService: DiagramsService) {
private diagramsService: DiagramsService,
private logService: LogService) {
if (translateService) {
translateService.addTranslationFolder('ng2-activiti-diagrams', 'node_modules/ng2-activiti-diagrams/src');
}
this.elementRef = elementRef;
}
ngOnChanges(changes: SimpleChanges) {
@@ -86,7 +85,7 @@ export class DiagramComponent {
},
(err: any) => {
this.onError.emit(err);
console.log(err);
this.logService.error(err);
}
);
}

View File

@@ -16,6 +16,7 @@
*/
import { Directive, OnInit, ElementRef, Input, Output, EventEmitter } from '@angular/core';
import { LogService } from 'ng2-alfresco-core';
import { Point } from './models/point';
import { RaphaelBase } from './raphael-base';
import { RaphaelService } from './raphael.service';
@@ -43,19 +44,20 @@ export class RaphaelMultilineTextDirective extends RaphaelBase implements OnInit
TEXT_PADDING = 3;
constructor(public elementRef: ElementRef,
raphaelService: RaphaelService) {
raphaelService: RaphaelService,
private logService: LogService) {
super(elementRef, raphaelService);
}
ngOnInit() {
console.log(this.elementRef);
this.logService.log(this.elementRef);
if (this.text === null || this.text === undefined) {
this.text = '';
}
this.draw(this.position, this.text);
}
public draw(position: Point, text: string) {
draw(position: Point, text: string) {
let textPaper = this.paper.text(position.x + this.TEXT_PADDING, position.y + this.TEXT_PADDING, text).attr({
'text-anchor': 'middle',
'font-family': 'Arial',

View File

@@ -16,16 +16,17 @@
*/
import { Injectable } from '@angular/core';
import { AuthService, SettingsService } from 'ng2-alfresco-core';
import { Observable } from 'rxjs/Rx';
import { Response, Http, Headers, RequestOptions } from '@angular/http';
import { AuthService, SettingsService, LogService } from 'ng2-alfresco-core';
@Injectable()
export class DiagramsService {
constructor(private authService: AuthService,
private http: Http,
private settingsService: SettingsService) {
private settingsService: SettingsService,
private logService: LogService) {
}
getProcessDefinitionModel(processDefinitionId: string): Observable<any> {
@@ -53,7 +54,7 @@ export class DiagramsService {
}
private handleError(error: Response) {
console.error(error);
this.logService.error(error);
return Observable.throw(error.json().error || 'Server error');
}
}