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

@ -17,13 +17,7 @@
import { Component } from '@angular/core';
import { Router } from '@angular/router';
import {
AlfrescoTranslationService,
AuthService,
SettingsService,
StorageService
} from 'ng2-alfresco-core';
import { AlfrescoTranslateService, AuthService, SettingsService, StorageService, LogService } from 'ng2-alfresco-core';
declare var document: any;
@ -38,22 +32,23 @@ export class AppComponent {
ecmHost: string = 'http://' + window.location.hostname + ':8080';
bpmHost: string = 'http://' + window.location.hostname + ':9999';
constructor(public authService: AuthService,
public router: Router,
public settingsService: SettingsService,
private translate: AlfrescoTranslationService,
private storage: StorageService) {
constructor(private authService: AuthService,
private router: Router,
private settingsService: SettingsService,
private translateService: AlfrescoTranslateService,
private storage: StorageService,
private logService: LogService) {
this.setEcmHost();
this.setBpmHost();
this.setProvider();
if (translate) {
if (translateService) {
if (process.env.ENV === 'production') {
translate.addTranslationFolder('custom', 'i18n/custom-translation');
translate.addTranslationFolder('ng2-alfresco-login', 'i18n/custom-translation/alfresco-login');
translateService.addTranslationFolder('custom', 'i18n/custom-translation');
translateService.addTranslationFolder('ng2-alfresco-login', 'i18n/custom-translation/alfresco-login');
} else {
translate.addTranslationFolder('custom', 'custom-translation');
translate.addTranslationFolder('ng2-alfresco-login', 'custom-translation/alfresco-login');
translateService.addTranslationFolder('custom', 'custom-translation');
translateService.addTranslationFolder('ng2-alfresco-login', 'custom-translation/alfresco-login');
}
}
}
@ -84,7 +79,7 @@ export class AppComponent {
if (error && error.response && error.response.status === 401) {
this.navigateToLogin();
} else {
console.error('An unknown error occurred while logging out', error);
this.logService.error('An unknown error occurred while logging out', error);
this.navigateToLogin();
}
}
@ -107,7 +102,7 @@ export class AppComponent {
}
changeLanguage(lang: string) {
this.translate.use(lang);
this.translateService.use(lang);
this.hideDrawer();
}

View File

@ -18,6 +18,7 @@
import { Component, OnInit } from '@angular/core';
import { Http } from '@angular/http';
import { ObjectDataTableAdapter } from 'ng2-alfresco-datatable';
import { LogService } from 'ng2-alfresco-core';
@Component({
selector: 'about-page',
@ -27,31 +28,31 @@ export class AboutComponent implements OnInit {
data: ObjectDataTableAdapter;
constructor(private http: Http) {
constructor(private http: Http,
private logService: LogService) {
}
ngOnInit() {
this.http.get('/versions.json').subscribe(response => {
var regexp = new RegExp("^(ng2-activiti|ng2-alfresco|alfresco-)", 'g');
let regexp = new RegExp('^(ng2-activiti|ng2-alfresco|alfresco-)', 'g');
var alfrescoPackages = Object.keys(response.json().dependencies).filter(function (val) {
console.log(val);
let alfrescoPackages = Object.keys(response.json().dependencies).filter((val) => {
this.logService.log(val);
return regexp.test(val);
});
let alfrescoPackagesTableRappresentation = [];
alfrescoPackages.forEach((val) => {
console.log(response.json().dependencies[val]);
this.logService.log(response.json().dependencies[val]);
alfrescoPackagesTableRappresentation.push({name: val, version: response.json().dependencies[val].version});
});
console.log(alfrescoPackagesTableRappresentation);
this.logService.log(alfrescoPackagesTableRappresentation);
this.data = new ObjectDataTableAdapter(alfrescoPackagesTableRappresentation, [
{type: 'text', key: 'name', title: 'Name', sortable: true},
{type: 'text', key: 'version', title: 'Version', sortable: true}
]);
});
}
}

View File

@ -17,7 +17,7 @@
import { Component, OnInit, Optional, ViewChild } from '@angular/core';
import { ActivatedRoute, Params, Router } from '@angular/router';
import { AuthService } from 'ng2-alfresco-core';
import { AuthService, LogService } from 'ng2-alfresco-core';
import {
DocumentActionsService,
DocumentList,
@ -49,8 +49,9 @@ export class FilesComponent implements OnInit {
documentList: DocumentList;
constructor(private documentActions: DocumentActionsService,
public authService: AuthService,
private authService: AuthService,
private formService: FormService,
private logService: LogService,
private router: Router,
@Optional() private route: ActivatedRoute) {
documentActions.setHandler('my-handler', this.myDocumentActionHandler.bind(this));
@ -109,10 +110,10 @@ export class FilesComponent implements OnInit {
if (this.authService.isBpmLoggedIn()) {
this.formService.getProcessDefinitions().subscribe(
defs => this.setupBpmActions(defs || []),
err => console.log(err)
err => this.logService.error(err)
);
} else {
console.log('You are not logged in');
this.logService.warn('You are not logged in to BPM');
}
}

View File

@ -18,7 +18,7 @@
import { Component, ViewChild, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { Validators } from '@angular/forms';
import { StorageService } from 'ng2-alfresco-core';
import { StorageService, LogService } from 'ng2-alfresco-core';
@Component({
selector: 'login-demo',
@ -38,7 +38,9 @@ export class LoginDemoComponent implements OnInit {
isECM: boolean = true;
isBPM: boolean = false;
constructor(public router: Router, private storage: StorageService) {
constructor(private router: Router,
private storage: StorageService,
private logService: LogService) {
this.customValidation = {
username: ['', Validators.compose([Validators.required, Validators.minLength(4)])],
password: ['', Validators.required]
@ -75,7 +77,7 @@ export class LoginDemoComponent implements OnInit {
}
onError($event) {
console.log($event);
this.logService.error($event);
}
toggleECM() {

View File

@ -16,7 +16,7 @@
*/
import { Component } from '@angular/core';
import { SettingsService, StorageService } from 'ng2-alfresco-core';
import { SettingsService, StorageService, LogService } from 'ng2-alfresco-core';
@Component({
selector: 'alfresco-setting-demo',
@ -28,24 +28,31 @@ export class SettingComponent {
ecmHost: string;
bpmHost: string;
constructor(public settingsService: SettingsService,
private storage: StorageService) {
constructor(private settingsService: SettingsService,
private storage: StorageService,
private logService: LogService) {
this.ecmHost = this.settingsService.ecmHost;
this.bpmHost = this.settingsService.bpmHost;
}
public onChangeECMHost(event: KeyboardEvent): void {
console.log((<HTMLInputElement>event.target).value);
this.ecmHost = (<HTMLInputElement>event.target).value;
this.settingsService.ecmHost = this.ecmHost;
this.storage.setItem(`ecmHost`, this.ecmHost);
let value = (<HTMLInputElement>event.target).value.trim();
if (value) {
this.logService.info(`ECM host: ${value}`);
this.ecmHost = value;
this.settingsService.ecmHost = value;
this.storage.setItem(`ecmHost`, value);
}
}
public onChangeBPMHost(event: KeyboardEvent): void {
console.log((<HTMLInputElement>event.target).value);
this.bpmHost = (<HTMLInputElement>event.target).value;
this.settingsService.bpmHost = this.bpmHost;
this.storage.setItem(`bpmHost`, this.bpmHost);
let value = (<HTMLInputElement>event.target).value.trim();
if (value) {
this.logService.info(`BPM host: ${value}`);
this.bpmHost = value;
this.settingsService.bpmHost = value;
this.storage.setItem(`bpmHost`, value);
}
}
}

View File

@ -16,42 +16,41 @@
*/
import { Component } from '@angular/core';
import { LogService } from 'ng2-alfresco-core';
@Component({
selector: 'alfresco-webscript-demo',
template: `
<label for="script-path"><b>Insert a scriptPath</b></label><br>
<input id="script-path" type="text" size="48" [(ngModel)]="scriptPath"><br>
<label for="context-root"><b>Insert a contextRoot</b></label><br>
<input id="context-root" type="text" size="48" [(ngModel)]="contextRoot"><br>
<label for="service-path"><b>Insert a servicePath</b></label><br>
<input id="service-path" type="text" size="48" [(ngModel)]="servicePath"><br>
<alfresco-webscript-get [scriptPath]="scriptPath"
<alfresco-webscript-get
[scriptPath]="scriptPath"
[scriptArgs]="scriptArgs"
[contextRoot]="contextRoot"
[servicePath]="servicePath"
[contentType]="'HTML'"
(onSuccess)= "logData($event)"></alfresco-webscript-get>
(onSuccess)= "logData($event)">
</alfresco-webscript-get>
`
})
export class WebscriptComponent {
currentPath: string = '/';
authenticated: boolean;
host: string = 'http://127.0.0.1:8080';
scriptPath: string = 'sample/folder/Company%20Home';
contextRoot: string = 'alfresco';
servicePath: string = 'service';
scriptArgs: string = '';
constructor(private logService: LogService) {
}
logData(data) {
console.log(data);
this.logService.log(data);
}
}

View File

@ -18,7 +18,7 @@
import { NgModule, Component, OnInit } 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 { AnalyticsModule } from 'ng2-activiti-analytics';
@Component({
@ -45,24 +45,22 @@ import { AnalyticsModule } from 'ng2-activiti-analytics';
<activiti-analytics [appId]="appId" *ngIf="report" [reportId]="report.id"></activiti-analytics>
</div>
</div>
</div>`
</div>
`
})
export class AnalyticsDemoComponent implements OnInit {
appId: number;
report: any;
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');
@ -91,12 +89,12 @@ export class AnalyticsDemoComponent implements OnInit {
login() {
this.authService.login('admin', 'admin').subscribe(
ticket => {
console.log(ticket);
this.logService.log(ticket);
this.ticket = this.authService.getTicketBpm();
this.authenticated = true;
},
error => {
console.log(error);
this.logService.error(error);
this.authenticated = false;
});
}

View File

@ -17,6 +17,7 @@
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
import { Observer, Observable } from 'rxjs/Rx';
import { LogService } from 'ng2-alfresco-core';
import { AnalyticsService } from '../services/analytics.service';
import { ReportParametersModel } from '../models/report.model';
@ -44,8 +45,8 @@ export class AnalyticsReportListComponent implements OnInit {
reports: ReportParametersModel[] = [];
constructor(private analyticsService: AnalyticsService) {
constructor(private analyticsService: AnalyticsService,
private logService: LogService) {
this.report$ = new Observable<ReportParametersModel>(observer => this.reportObserver = observer).share();
}
@ -82,7 +83,7 @@ export class AnalyticsReportListComponent implements OnInit {
},
(err: any) => {
this.onError.emit(err);
console.log(err);
this.logService.error(err);
}
);
}

View File

@ -16,11 +16,11 @@
*/
import { Component, EventEmitter, OnInit, OnChanges, Input, Output, SimpleChanges, OnDestroy, AfterViewChecked } from '@angular/core';
import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { AnalyticsService } from '../services/analytics.service';
import { ReportParametersModel, ReportQuery, ParameterValueModel, ReportParameterDetailsModel } from '../models/report.model';
import { FormGroup, FormBuilder, FormControl } from '@angular/forms';
import * as moment from 'moment';
import { AlfrescoTranslateService, LogService } from 'ng2-alfresco-core';
import { AnalyticsService } from '../services/analytics.service';
import { ReportParametersModel, ReportQuery, ParameterValueModel, ReportParameterDetailsModel } from '../models/report.model';
declare var componentHandler;
@ -72,7 +72,8 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
constructor(private translateService: AlfrescoTranslateService,
private analyticsService: AnalyticsService,
private formBuilder: FormBuilder ) {
private formBuilder: FormBuilder,
private logService: LogService) {
if (translateService) {
translateService.addTranslationFolder('ng2-activiti-analytics', 'node_modules/ng2-activiti-analytics/src');
}
@ -148,7 +149,7 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
}
},
(err: any) => {
console.log(err);
this.logService.error(err);
this.onError.emit(err);
}
);
@ -162,7 +163,7 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
this.onSuccessParamOpt.emit(opts);
},
(err: any) => {
console.log(err);
this.logService.error(err);
this.onError.emit(err);
}
);
@ -233,7 +234,7 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
this.onEdit.emit(this.reportParameters.name);
},
(err: any) => {
console.log(err);
this.logService.error(err);
this.onError.emit(err);
}
);

View File

@ -16,7 +16,7 @@
*/
import { Component, EventEmitter, OnChanges, Input, Output, SimpleChanges } from '@angular/core';
import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { AlfrescoTranslateService, LogService } from 'ng2-alfresco-core';
import { AnalyticsService } from '../services/analytics.service';
import { ReportQuery } from '../models/report.model';
import { Chart } from '../models/chart.model';
@ -71,8 +71,9 @@ export class AnalyticsComponent implements OnChanges {
};
constructor(private translateService: AlfrescoTranslateService,
private analyticsService: AnalyticsService) {
console.log('AnalyticsComponent');
private analyticsService: AnalyticsService,
private logService: LogService) {
logService.info('AnalyticsComponent');
if (translateService) {
translateService.addTranslationFolder('ng2-activiti-analytics', 'node_modules/ng2-activiti-analytics/src');
}
@ -91,7 +92,7 @@ export class AnalyticsComponent implements OnChanges {
},
(err: any) => {
this.onError.emit(err);
console.log(err);
this.logService.error(err);
}
);
}

View File

@ -18,14 +18,15 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Rx';
import { Response } from '@angular/http';
import { AlfrescoApiService } from 'ng2-alfresco-core';
import { AlfrescoApiService, LogService } from 'ng2-alfresco-core';
import { ReportParametersModel, ParameterValueModel } from '../models/report.model';
import { Chart, PieChart, TableChart, BarChart, HeatMapChart, MultiBarChart, DetailsTableChart } from '../models/chart.model';
@Injectable()
export class AnalyticsService {
constructor(public apiService: AlfrescoApiService) {
constructor(private apiService: AlfrescoApiService,
private logService: LogService) {
}
/**
@ -170,21 +171,21 @@ export class AnalyticsService {
}).catch(this.handleError);
}
public createDefaultReports(): Observable<any> {
createDefaultReports(): Observable<any> {
return Observable.fromPromise(this.apiService.getInstance().activiti.reportApi.createDefaultReports())
.map(this.toJson)
.catch(this.handleError);
}
public updateReport(reportId: number, name: string): Observable<any> {
updateReport(reportId: number, name: string): Observable<any> {
return Observable.fromPromise(this.apiService.getInstance().activiti.reportApi.updateReport(reportId, name))
.map((res: any) => {
console.log('upload');
this.logService.info('upload');
}).catch(this.handleError);
}
private handleError(error: Response) {
console.error(error);
this.logService.error(error);
return Observable.throw(error.json().error || 'Server error');
}

View File

@ -19,7 +19,7 @@ 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({
@ -37,22 +37,21 @@ import { DiagramsModule } from 'ng2-activiti-diagrams';
<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>`
<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');
}
}

View File

@ -18,7 +18,7 @@
import { NgModule, Component, OnInit } 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 { ActivitiFormModule } from 'ng2-activiti-form';
@Component({
@ -36,22 +36,21 @@ import { ActivitiFormModule } from 'ng2-activiti-form';
<label for="taskId"><b>Insert the taskId:</b></label><br>
<input id="taskId" size="10" type="text" [(ngModel)]="taskId">
<activiti-form [taskId]="taskId"></activiti-form>`
<activiti-form [taskId]="taskId"></activiti-form>
`
})
export class FormDemoComponent implements OnInit {
taskId: number;
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');
@ -76,12 +75,12 @@ export class FormDemoComponent implements OnInit {
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

@ -17,6 +17,7 @@
import { Observable } from 'rxjs/Rx';
import { SimpleChange } from '@angular/core';
import { LogService } from 'ng2-alfresco-core';
import { ActivitiForm } from './activiti-form.component';
import { FormModel, FormOutcomeModel, FormFieldModel, FormOutcomeEvent, FormFieldTypes } from './widgets/index';
import { FormService } from './../services/form.service';
@ -30,6 +31,7 @@ describe('ActivitiForm', () => {
let formComponent: ActivitiForm;
let visibilityService: WidgetVisibilityService;
let nodeService: NodeService;
let logService: LogService;
beforeEach(() => {
componentHandler = jasmine.createSpyObj('componentHandler', [
@ -37,11 +39,12 @@ describe('ActivitiForm', () => {
]);
window['componentHandler'] = componentHandler;
visibilityService = new WidgetVisibilityService(null);
logService = new LogService();
visibilityService = new WidgetVisibilityService(null, logService);
spyOn(visibilityService, 'refreshVisibility').and.stub();
formService = new FormService(null, null);
formService = new FormService(null, null, logService);
nodeService = new NodeService(null);
formComponent = new ActivitiForm(formService, visibilityService, null, nodeService);
formComponent = new ActivitiForm(formService, visibilityService, null, nodeService, logService);
});
it('should upgrade MDL content on view checked', () => {
@ -560,13 +563,6 @@ describe('ActivitiForm', () => {
expect(formService.completeTaskForm).not.toHaveBeenCalled();
});
it('should log error to console by default', () => {
const error = 'Error';
spyOn(console, 'log').and.stub();
formComponent.handleError(error);
expect(console.log).toHaveBeenCalledWith(error);
});
it('should complete form form and raise corresponding event', () => {
spyOn(formService, 'completeTaskForm').and.callFake(() => {
return Observable.create(observer => {

View File

@ -15,14 +15,8 @@
* limitations under the License.
*/
import {
Component,
OnInit, AfterViewChecked, OnChanges,
SimpleChanges,
Input,
Output,
EventEmitter
} from '@angular/core';
import { Component, OnInit, AfterViewChecked, OnChanges, SimpleChanges, Input, Output, EventEmitter } from '@angular/core';
import { LogService } from 'ng2-alfresco-core';
import { EcmModelService } from './../services/ecm-model.service';
import { FormService } from './../services/form.service';
import { NodeService } from './../services/node.service';
@ -149,9 +143,10 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
debugMode: boolean = false;
constructor(protected formService: FormService,
public visibilityService: WidgetVisibilityService,
protected visibilityService: WidgetVisibilityService,
private ecmModelService: EcmModelService,
private nodeService: NodeService) {
private nodeService: NodeService,
private logService: LogService) {
}
hasForm(): boolean {
@ -357,7 +352,6 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
id => {
this.formService.getFormDefinitionById(id).subscribe(
form => {
// console.log('Get Form By Form definition Name', form);
this.form = this.parseForm(form);
this.formLoaded.emit(this.form);
},
@ -405,7 +399,7 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
}
handleError(err: any): any {
console.log(err);
this.logService.error(err);
this.onError.emit(err);
}

View File

@ -15,17 +15,8 @@
* limitations under the License.
*/
import {
Component,
AfterViewChecked, OnChanges,
SimpleChanges,
Input,
ViewChild,
ElementRef,
Output,
EventEmitter
} from '@angular/core';
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
import { Component, AfterViewChecked, OnChanges, SimpleChanges, Input, ViewChild, ElementRef, Output, EventEmitter } from '@angular/core';
import { AlfrescoTranslateService, LogService } from 'ng2-alfresco-core';
import { ActivitiForm } from './activiti-form.component';
import { FormService } from './../services/form.service';
import { WidgetVisibilityService } from './../services/widget-visibility.service';
@ -74,10 +65,11 @@ export class ActivitiStartForm extends ActivitiForm implements AfterViewChecked,
@ViewChild('outcomesContainer', {})
outcomesContainer: ElementRef = null;
constructor(private translate: AlfrescoTranslationService,
constructor(private translate: AlfrescoTranslateService,
formService: FormService,
visibilityService: WidgetVisibilityService) {
super(formService, visibilityService, null, null);
visibilityService: WidgetVisibilityService,
logService: LogService) {
super(formService, visibilityService, null, null, logService);
if (this.translate) {
this.translate.addTranslationFolder('ng2-activiti-form', 'node_modules/ng2-activiti-form/src');

View File

@ -16,6 +16,7 @@
*/
import { Observable } from 'rxjs/Rx';
import { LogServiceMock } from 'ng2-alfresco-core';
import { AttachWidget } from './attach.widget';
import { ActivitiAlfrescoContentService } from '../../../services/activiti-alfresco.service';
import { FormFieldModel } from './../core/form-field.model';
@ -28,10 +29,12 @@ describe('AttachWidget', () => {
let widget: AttachWidget;
let contentService: ActivitiAlfrescoContentService;
let dialogPolyfill: any;
let logService: LogServiceMock;
beforeEach(() => {
contentService = new ActivitiAlfrescoContentService(null);
widget = new AttachWidget(contentService);
logService = new LogServiceMock();
contentService = new ActivitiAlfrescoContentService(null, logService);
widget = new AttachWidget(contentService, logService);
dialogPolyfill = {
registerDialog(obj: any) {
@ -268,9 +271,9 @@ describe('AttachWidget', () => {
Observable.throw(error)
);
spyOn(console, 'log').and.stub();
spyOn(logService, 'error').and.stub();
widget.getExternalContentNodes();
expect(console.log).toHaveBeenCalledWith(error);
expect(logService.error).toHaveBeenCalledWith(error);
});
it('should register dialog via polyfill', () => {

View File

@ -16,6 +16,7 @@
*/
import { Component, OnInit, Input, Output, EventEmitter, ViewChild } from '@angular/core';
import { LogService } from 'ng2-alfresco-core';
import { WidgetComponent } from './../widget.component';
import { ActivitiAlfrescoContentService } from '../../../services/activiti-alfresco.service';
import { ExternalContent } from '../core/external-content';
@ -49,7 +50,8 @@ export class AttachWidget extends WidgetComponent implements OnInit {
@ViewChild('dialog')
dialog: any;
constructor(private contentService: ActivitiAlfrescoContentService) {
constructor(private contentService: ActivitiAlfrescoContentService,
private logService: LogService) {
super();
}
@ -97,7 +99,7 @@ export class AttachWidget extends WidgetComponent implements OnInit {
this.contentService.getAlfrescoNodes(this.selectedFolderAccountId, this.selectedFolderPathId)
.subscribe(
nodes => this.selectedFolderNodes = nodes,
error => this.handleError(error)
error => this.logService.error(error)
);
}

View File

@ -16,7 +16,7 @@
*/
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { CoreModule } from 'ng2-alfresco-core';
import { CoreModule, LogServiceMock } from 'ng2-alfresco-core';
import { Observable } from 'rxjs/Rx';
import { DisplayValueWidget } from './display-value.widget';
import { FormService } from '../../../services/form.service';
@ -32,11 +32,13 @@ describe('DisplayValueWidget', () => {
let widget: DisplayValueWidget;
let formService: FormService;
let visibilityService: WidgetVisibilityService;
let logService: LogServiceMock;
beforeEach(() => {
formService = new FormService(null, null);
visibilityService = new WidgetVisibilityService(null);
widget = new DisplayValueWidget(formService, visibilityService);
logService = new LogServiceMock();
formService = new FormService(null, null, logService);
visibilityService = new WidgetVisibilityService(null, logService);
widget = new DisplayValueWidget(formService, visibilityService, logService);
});
it('should require field to setup default value', () => {
@ -390,7 +392,7 @@ describe('DisplayValueWidget', () => {
Observable.throw(error)
);
spyOn(console, 'log').and.stub();
spyOn(logService, 'error').and.stub();
let form = new FormModel({taskId: '<id>'});
@ -406,7 +408,7 @@ describe('DisplayValueWidget', () => {
});
widget.ngOnInit();
expect(formService.getRestFieldValues).toHaveBeenCalled();
expect(console.log).toHaveBeenCalledWith(error);
expect(logService.error).toHaveBeenCalledWith(error);
expect(widget.value).toBe('100');
});

View File

@ -17,6 +17,7 @@
import { Component, OnInit } from '@angular/core';
import * as moment from 'moment';
import { LogService } from 'ng2-alfresco-core';
import { WidgetComponent } from './../widget.component';
import { FormFieldTypes } from '../core/form-field-types';
import { FormService } from '../../../services/form.service';
@ -49,7 +50,8 @@ export class DisplayValueWidget extends WidgetComponent implements OnInit {
hasFile: boolean = false;
constructor(private formService: FormService,
private visibilityService: WidgetVisibilityService) {
private visibilityService: WidgetVisibilityService,
private logService: LogService) {
super();
}
@ -182,7 +184,7 @@ export class DisplayValueWidget extends WidgetComponent implements OnInit {
this.visibilityService.refreshVisibility(this.field.form);
},
error => {
console.log(error);
this.logService.error(error);
this.value = this.field.value;
}
);
@ -204,7 +206,7 @@ export class DisplayValueWidget extends WidgetComponent implements OnInit {
this.visibilityService.refreshVisibility(this.field.form);
},
error => {
console.log(error);
this.logService.error(error);
this.value = this.field.value;
}
);

View File

@ -15,14 +15,14 @@
* limitations under the License.
*/
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { Observable } from 'rxjs/Rx';
import { CoreModule } from 'ng2-alfresco-core';
import { FormService } from '../../../services/form.service';
import { DropdownWidget } from './dropdown.widget';
import { FormModel } from './../core/form.model';
import { FormFieldModel } from './../core/form-field.model';
import { FormFieldOption } from './../core/form-field-option';
import { CoreModule } from 'ng2-alfresco-core';
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { EcmModelService } from '../../../services/ecm-model.service';
import { WidgetVisibilityService } from '../../../services/widget-visibility.service';
@ -33,9 +33,9 @@ describe('DropdownWidget', () => {
let visibilityService: WidgetVisibilityService;
beforeEach(() => {
formService = new FormService(null, null);
visibilityService = new WidgetVisibilityService(null);
widget = new DropdownWidget(formService, visibilityService);
formService = new FormService(null, null, null);
visibilityService = new WidgetVisibilityService(null, null);
widget = new DropdownWidget(formService, visibilityService, null);
widget.field = new FormFieldModel(new FormModel());
});
@ -74,12 +74,6 @@ describe('DropdownWidget', () => {
expect(formService.getRestFieldValues).toHaveBeenCalledWith(taskId, fieldId);
});
it('should log error to console by default', () => {
spyOn(console, 'error').and.stub();
widget.handleError('Err');
expect(console.error).toHaveBeenCalledWith('Err');
});
it('should preserve empty option when loading fields', () => {
let restFieldValue: FormFieldOption = <FormFieldOption> { id: '1', name: 'Option1' };
spyOn(formService, 'getRestFieldValues').and.returnValue(

View File

@ -16,6 +16,7 @@
*/
import { Component, OnInit } from '@angular/core';
import { LogService } from 'ng2-alfresco-core';
import { FormService } from '../../../services/form.service';
import { WidgetComponent } from './../widget.component';
import { FormFieldOption } from './../core/form-field-option';
@ -30,7 +31,8 @@ import { WidgetVisibilityService } from '../../../services/widget-visibility.ser
export class DropdownWidget extends WidgetComponent implements OnInit {
constructor(private formService: FormService,
private visibilityService: WidgetVisibilityService) {
private visibilityService: WidgetVisibilityService,
private logService: LogService) {
super();
}
@ -97,7 +99,7 @@ export class DropdownWidget extends WidgetComponent implements OnInit {
}
handleError(error: any) {
console.error(error);
this.logService.error(error);
}
}

View File

@ -15,6 +15,7 @@
* limitations under the License.
*/
import { LogServiceMock } from 'ng2-alfresco-core';
import { DynamicTableWidget } from './dynamic-table.widget';
import { DynamicTableModel, DynamicTableRow, DynamicTableColumn } from './dynamic-table.widget.model';
import { FormModel, FormFieldTypes } from './../core/index';
@ -25,11 +26,13 @@ describe('DynamicTableWidget', () => {
let widget: DynamicTableWidget;
let table: DynamicTableModel;
let visibilityService: WidgetVisibilityService;
let logService: LogServiceMock;
beforeEach(() => {
logService = new LogServiceMock();
table = new DynamicTableModel(null);
visibilityService = new WidgetVisibilityService(null);
widget = new DynamicTableWidget(null, visibilityService);
visibilityService = new WidgetVisibilityService(null, logService);
widget = new DynamicTableWidget(null, visibilityService, logService);
widget.content = table;
});
@ -192,13 +195,13 @@ describe('DynamicTableWidget', () => {
});
it('should require table to save changes', () => {
spyOn(console, 'log').and.stub();
spyOn(logService, 'error').and.stub();
widget.editMode = true;
widget.content = null;
widget.onSaveChanges();
expect(widget.editMode).toBeFalsy();
expect(console.log).toHaveBeenCalledWith(widget.ERROR_MODEL_NOT_FOUND);
expect(logService.error).toHaveBeenCalledWith(widget.ERROR_MODEL_NOT_FOUND);
});
it('should cancel changes', () => {

View File

@ -16,6 +16,7 @@
*/
import { Component, ElementRef, OnInit } from '@angular/core';
import { LogService } from 'ng2-alfresco-core';
import { WidgetComponent } from './../widget.component';
import { DynamicTableModel, DynamicTableRow, DynamicTableColumn } from './dynamic-table.widget.model';
import { WidgetVisibilityService } from '../../../services/widget-visibility.service';
@ -36,7 +37,8 @@ export class DynamicTableWidget extends WidgetComponent implements OnInit {
editRow: DynamicTableRow = null;
constructor(private elementRef: ElementRef,
private visibilityService: WidgetVisibilityService) {
private visibilityService: WidgetVisibilityService,
private logService: LogService) {
super();
}
@ -136,7 +138,7 @@ export class DynamicTableWidget extends WidgetComponent implements OnInit {
}
this.content.flushValue();
} else {
this.handleError(this.ERROR_MODEL_NOT_FOUND);
this.logService.error(this.ERROR_MODEL_NOT_FOUND);
}
this.editMode = false;
}

View File

@ -39,7 +39,7 @@ describe('DropdownEditorComponent', () => {
let row: DynamicTableRow;
beforeEach(() => {
formService = new FormService(null, null);
formService = new FormService(null, null, null);
row = <DynamicTableRow> { value: { dropdown: 'one' } };
column = <DynamicTableColumn> {
@ -56,7 +56,7 @@ describe('DropdownEditorComponent', () => {
table.rows.push(row);
table.columns.push(column);
component = new DropdownEditorComponent(formService);
component = new DropdownEditorComponent(formService, null);
component.table = table;
component.row = row;
component.column = column;

View File

@ -16,6 +16,7 @@
*/
import { Component, Input, OnInit } from '@angular/core';
import { LogService } from 'ng2-alfresco-core';
import { DynamicTableModel, DynamicTableRow, DynamicTableColumn, DynamicTableColumnOption } from './../../dynamic-table.widget.model';
import { FormService } from './../../../../../services/form.service';
@ -39,7 +40,9 @@ export class DropdownEditorComponent implements OnInit {
@Input()
column: DynamicTableColumn;
constructor(private formService: FormService) {}
constructor(private formService: FormService,
private logService: LogService) {
}
ngOnInit() {
let field = this.table.field;
@ -98,6 +101,6 @@ export class DropdownEditorComponent implements OnInit {
}
handleError(error: any) {
console.error(error);
this.logService.error(error);
}
}

View File

@ -36,7 +36,7 @@ describe('FunctionalGroupWidget', () => {
]);
window['componentHandler'] = componentHandler;
formService = new FormService(null, null);
formService = new FormService(null, null, null);
elementRef = new ElementRef(null);
widget = new FunctionalGroupWidget(formService, elementRef);
widget.field = new FormFieldModel(new FormModel());

View File

@ -36,7 +36,7 @@ describe('PeopleWidget', () => {
]);
window['componentHandler'] = componentHandler;
formService = new FormService(null, null);
formService = new FormService(null, null, null);
elementRef = new ElementRef(null);
widget = new PeopleWidget(formService, elementRef);
widget.field = new FormFieldModel(new FormModel());

View File

@ -15,13 +15,14 @@
* limitations under the License.
*/
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { Observable } from 'rxjs/Rx';
import { CoreModule, LogServiceMock } from 'ng2-alfresco-core';
import { FormService } from '../../../services/form.service';
import { RadioButtonsWidget } from './radio-buttons.widget';
import { FormModel } from './../core/form.model';
import { FormFieldModel } from './../core/form-field.model';
import { CoreModule } from 'ng2-alfresco-core';
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { EcmModelService } from '../../../services/ecm-model.service';
import { WidgetVisibilityService } from '../../../services/widget-visibility.service';
import { FormFieldTypes } from '../core/form-field-types';
@ -33,11 +34,13 @@ describe('RadioButtonsWidget', () => {
let formService: FormService;
let widget: RadioButtonsWidget;
let visibilityService: WidgetVisibilityService;
let logService: LogServiceMock;
beforeEach(() => {
formService = new FormService(null, null);
visibilityService = new WidgetVisibilityService(null);
widget = new RadioButtonsWidget(formService, visibilityService);
logService = new LogServiceMock();
formService = new FormService(null, null, logService);
visibilityService = new WidgetVisibilityService(null, logService);
widget = new RadioButtonsWidget(formService, visibilityService, logService);
widget.field = new FormFieldModel(new FormModel(), { restUrl: '<url>' });
});
@ -118,9 +121,9 @@ describe('RadioButtonsWidget', () => {
});
it('should log error to console by default', () => {
spyOn(console, 'error').and.stub();
spyOn(logService, 'error').and.stub();
widget.handleError('Err');
expect(console.error).toHaveBeenCalledWith('Err');
expect(logService.error).toHaveBeenCalledWith('Err');
});
xit('should update the field value when an option is selected', () => {

View File

@ -16,6 +16,7 @@
*/
import { Component, OnInit } from '@angular/core';
import { LogService } from 'ng2-alfresco-core';
import { WidgetComponent } from './../widget.component';
import { FormService } from '../../../services/form.service';
import { FormFieldOption } from './../core/form-field-option';
@ -30,7 +31,8 @@ import { WidgetVisibilityService } from '../../../services/widget-visibility.ser
export class RadioButtonsWidget extends WidgetComponent implements OnInit {
constructor(private formService: FormService,
private visibilityService: WidgetVisibilityService) {
private visibilityService: WidgetVisibilityService,
private logService: LogService) {
super();
}
@ -84,7 +86,7 @@ export class RadioButtonsWidget extends WidgetComponent implements OnInit {
}
handleError(error: any) {
console.error(error);
this.logService.error(error);
}
}

View File

@ -15,14 +15,15 @@
* limitations under the License.
*/
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { Observable } from 'rxjs/Rx';
import { CoreModule, LogServiceMock } from 'ng2-alfresco-core';
import { TypeaheadWidget } from './typeahead.widget';
import { FormService } from '../../../services/form.service';
import { FormModel } from '../core/form.model';
import { FormFieldModel } from '../core/form-field.model';
import { FormFieldOption } from '../core/form-field-option';
import { CoreModule } from 'ng2-alfresco-core';
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { EcmModelService } from '../../../services/ecm-model.service';
import { WidgetVisibilityService } from '../../../services/widget-visibility.service';
import { FormFieldTypes } from '../core/form-field-types';
@ -32,11 +33,13 @@ describe('TypeaheadWidget', () => {
let formService: FormService;
let widget: TypeaheadWidget;
let visibilityService: WidgetVisibilityService;
let logService: LogServiceMock;
beforeEach(() => {
formService = new FormService(null, null);
visibilityService = new WidgetVisibilityService(null);
widget = new TypeaheadWidget(formService, visibilityService);
logService = new LogServiceMock();
formService = new FormService(null, null, logService);
visibilityService = new WidgetVisibilityService(null, logService);
widget = new TypeaheadWidget(formService, visibilityService, logService);
widget.field = new FormFieldModel(new FormModel({ taskId: 'task-id' }));
});
@ -73,7 +76,7 @@ describe('TypeaheadWidget', () => {
});
const err = 'Error';
spyOn(formService, 'getRestFieldValues').and.returnValue(Observable.throw(err));
spyOn(widget, 'handleError').and.callThrough();
spyOn(widget, 'handleError').and.stub();
widget.ngOnInit();
@ -94,7 +97,7 @@ describe('TypeaheadWidget', () => {
});
const err = 'Error';
spyOn(formService, 'getRestFieldValuesByProcessId').and.returnValue(Observable.throw(err));
spyOn(widget, 'handleError').and.callThrough();
spyOn(widget, 'handleError').and.stub();
widget.ngOnInit();
@ -102,12 +105,6 @@ describe('TypeaheadWidget', () => {
expect(widget.handleError).toHaveBeenCalledWith(err);
});
it('should log error to console by default', () => {
spyOn(console, 'error').and.stub();
widget.handleError('Err');
expect(console.error).toHaveBeenCalledWith('Err');
});
it('should show popup on key up', () => {
spyOn(widget, 'getOptions').and.returnValue([{}, {}]);

View File

@ -16,6 +16,7 @@
*/
import { Component, OnInit } from '@angular/core';
import { LogService } from 'ng2-alfresco-core';
import { FormService } from './../../../services/form.service';
import { WidgetComponent } from './../widget.component';
import { FormFieldOption } from './../core/form-field-option';
@ -35,7 +36,8 @@ export class TypeaheadWidget extends WidgetComponent implements OnInit {
options: FormFieldOption[] = [];
constructor(private formService: FormService,
private visibilityService: WidgetVisibilityService) {
private visibilityService: WidgetVisibilityService,
private logService: LogService) {
super();
}
@ -153,7 +155,7 @@ export class TypeaheadWidget extends WidgetComponent implements OnInit {
}
handleError(error: any) {
console.error(error);
this.logService.error(error);
}
checkVisibility() {

View File

@ -26,8 +26,8 @@ describe('UploadWidget', () => {
let formService: FormService;
beforeEach(() => {
formService = new FormService(null, null);
widget = new UploadWidget(formService);
formService = new FormService(null, null, null);
widget = new UploadWidget(formService, null);
});
it('should setup with field data', () => {

View File

@ -16,6 +16,7 @@
*/
import { Component, OnInit } from '@angular/core';
import { LogService } from 'ng2-alfresco-core';
import { WidgetComponent } from './../widget.component';
import { FormService } from '../../../services/form.service';
@ -31,7 +32,8 @@ export class UploadWidget extends WidgetComponent implements OnInit {
fileName: string;
displayText: string;
constructor(private formService: FormService) {
constructor(private formService: FormService,
private logService: LogService) {
super();
}
@ -60,16 +62,14 @@ export class UploadWidget extends WidgetComponent implements OnInit {
onFileChanged(event: any) {
let files = event.target.files;
if (files && files.length > 0) {
let file = files[0];
this.formService.createTemporaryRawRelatedContent(file)
.subscribe((response: any) => {
console.log(response);
this.logService.info(response);
this.field.value = [response];
this.field.json.value = [response];
}, (error: any) => {
console.error(error);
this.logService.error(error);
window.alert('Error uploading file. See console output for more details.');
});
}

View File

@ -111,11 +111,4 @@ export class WidgetComponent implements AfterViewInit {
}
return null;
}
protected handleError(error: any) {
if (error) {
console.log(error);
}
}
}

View File

@ -17,7 +17,7 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Rx';
import { AlfrescoApiService } from 'ng2-alfresco-core';
import { AlfrescoApiService, LogService } from 'ng2-alfresco-core';
import { ExternalContent } from '../components/widgets/core/external-content';
import { ExternalContentLink } from '../components/widgets/core/external-content-link';
import { AlfrescoApi } from 'alfresco-js-api';
@ -28,7 +28,8 @@ export class ActivitiAlfrescoContentService {
static UNKNOWN_ERROR_MESSAGE: string = 'Unknown error';
static GENERIC_ERROR_MESSAGE: string = 'Server error';
constructor(private apiService: AlfrescoApiService) {
constructor(private apiService: AlfrescoApiService,
private logService: LogService) {
}
/**
@ -85,7 +86,7 @@ export class ActivitiAlfrescoContentService {
errMsg = (error.message) ? error.message :
error.status ? `${error.status} - ${error.statusText}` : ActivitiAlfrescoContentService.GENERIC_ERROR_MESSAGE;
}
console.error(errMsg);
this.logService.error(errMsg);
return Observable.throw(errMsg);
}
}

View File

@ -17,7 +17,7 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Rx';
import { AlfrescoApiService } from 'ng2-alfresco-core';
import { AlfrescoApiService, LogService } from 'ng2-alfresco-core';
import { FormModel } from '../components/widgets/core/form.model';
@Injectable()
@ -27,7 +27,8 @@ export class EcmModelService {
public static MODEL_NAME: string = 'activitiFormsModel';
public static TYPE_MODEL: string = 'cm:folder';
constructor(public apiService: AlfrescoApiService) {
constructor(private apiService: AlfrescoApiService,
private logService: LogService) {
}
public createEcmTypeForActivitiForm(formName: string, form: FormModel): Observable<any> {
@ -62,10 +63,10 @@ export class EcmModelService {
return Observable.create(observer => {
this.createEcmModel(EcmModelService.MODEL_NAME, EcmModelService.MODEL_NAMESPACE).subscribe(
model => {
console.log('model created', model);
this.logService.info('model created', model);
this.activeEcmModel(EcmModelService.MODEL_NAME).subscribe(
modelActive => {
console.log('model active', modelActive);
this.logService.info('model active', modelActive);
this.createEcmTypeWithProperties(formName, form).subscribe(typeCreated => {
observer.next(typeCreated);
observer.complete();
@ -83,7 +84,7 @@ export class EcmModelService {
return Observable.create(observer => {
this.searchEcmType(formName, EcmModelService.MODEL_NAME).subscribe(
ecmType => {
console.log('custom types', ecmType);
this.logService.info('custom types', ecmType);
if (!ecmType) {
this.createEcmTypeWithProperties(formName, form).subscribe(typeCreated => {
observer.next(typeCreated);
@ -103,10 +104,10 @@ export class EcmModelService {
return Observable.create(observer => {
this.createEcmType(formName, EcmModelService.MODEL_NAME, EcmModelService.TYPE_MODEL).subscribe(
typeCreated => {
console.log('type Created', typeCreated);
this.logService.info('type Created', typeCreated);
this.addPropertyToAType(EcmModelService.MODEL_NAME, formName, form).subscribe(
properyAdded => {
console.log('property Added', properyAdded);
this.logService.info('property Added', properyAdded);
observer.next(typeCreated);
observer.complete();
},
@ -196,6 +197,6 @@ export class EcmModelService {
}
handleError(err: any): any {
console.log(err);
this.logService.error(err);
}
}

View File

@ -16,7 +16,7 @@
*/
import { TestBed } from '@angular/core/testing';
import { CoreModule, AlfrescoApiService } from 'ng2-alfresco-core';
import { CoreModule, AlfrescoApiService, LogService, LogServiceMock } from 'ng2-alfresco-core';
import { FormService } from './form.service';
import { EcmModelService } from './ecm-model.service';
import { FormDefinitionModel } from '../models/form-definition.model';
@ -29,6 +29,7 @@ describe('FormService', () => {
let responseBody: any;
let service: FormService;
let apiService: AlfrescoApiService;
let logService: LogService;
beforeEach(() => {
TestBed.configureTestingModule({
@ -37,11 +38,13 @@ describe('FormService', () => {
],
providers: [
EcmModelService,
FormService
FormService,
{ provide: LogService, useClass: LogServiceMock }
]
});
service = TestBed.get(FormService);
apiService = TestBed.get(AlfrescoApiService);
logService = TestBed.get(LogService);
});
beforeEach(() => {
@ -270,34 +273,34 @@ describe('FormService', () => {
});
it('should handle error with generic message', () => {
spyOn(console, 'error').and.stub();
spyOn(logService, 'error').and.stub();
service.handleError(null);
expect(console.error).toHaveBeenCalledWith(FormService.UNKNOWN_ERROR_MESSAGE);
expect(logService.error).toHaveBeenCalledWith(FormService.UNKNOWN_ERROR_MESSAGE);
});
it('should handle error with error message', () => {
spyOn(console, 'error').and.stub();
spyOn(logService, 'error').and.stub();
const message = '<error>';
service.handleError({message: message});
expect(console.error).toHaveBeenCalledWith(message);
expect(logService.error).toHaveBeenCalledWith(message);
});
it('should handle error with detailed message', () => {
spyOn(console, 'error').and.stub();
spyOn(logService, 'error').and.stub();
service.handleError({
status: '400',
statusText: 'Bad request'
});
expect(console.error).toHaveBeenCalledWith('400 - Bad request');
expect(logService.error).toHaveBeenCalledWith('400 - Bad request');
});
it('should handle error with generic message', () => {
spyOn(console, 'error').and.stub();
spyOn(logService, 'error').and.stub();
service.handleError({});
expect(console.error).toHaveBeenCalledWith(FormService.GENERIC_ERROR_MESSAGE);
expect(logService.error).toHaveBeenCalledWith(FormService.GENERIC_ERROR_MESSAGE);
});
it('should get all the forms with modelType=2', (done) => {

View File

@ -17,7 +17,7 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Rx';
import { AlfrescoApiService } from 'ng2-alfresco-core';
import { AlfrescoApiService, LogService } from 'ng2-alfresco-core';
import { FormValues } from './../components/widgets/core/index';
import { FormDefinitionModel } from '../models/form-definition.model';
import { EcmModelService } from './ecm-model.service';
@ -31,7 +31,8 @@ export class FormService {
static GENERIC_ERROR_MESSAGE: string = 'Server error';
constructor(private ecmModelService: EcmModelService,
private apiService: AlfrescoApiService) {
private apiService: AlfrescoApiService,
private logService: LogService) {
}
/**
@ -271,11 +272,10 @@ export class FormService {
if (xhr.status === 200) {
let json = JSON.parse(xhr.response);
let data: GroupModel[] = (json.data || []).map(item => <GroupModel> item);
// console.log(json);
observer.next(data);
observer.complete();
} else {
console.error(xhr.response);
this.logService.error(xhr.response);
Observable.throw(new Error(xhr.response));
}
}
@ -303,11 +303,10 @@ export class FormService {
if (xhr.status === 200) {
let json = JSON.parse(xhr.response);
let data: GroupUserModel[] = (json.data || []).map(item => <GroupUserModel> item);
// console.log(json);
observer.next(data);
observer.complete();
} else {
console.error(xhr.response);
this.logService.error(xhr.response);
Observable.throw(new Error(xhr.response));
}
}
@ -354,7 +353,7 @@ export class FormService {
errMsg = (error.message) ? error.message :
error.status ? `${error.status} - ${error.statusText}` : FormService.GENERIC_ERROR_MESSAGE;
}
console.error(errMsg);
this.logService.error(errMsg);
return Observable.throw(errMsg);
}
}

View File

@ -17,24 +17,19 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Rx';
import { AlfrescoApiService } from 'ng2-alfresco-core';
import {
FormModel,
FormFieldModel,
TabModel,
ContainerModel,
ContainerColumnModel
} from '../components/widgets/core/index';
import * as moment from 'moment';
import { AlfrescoApiService, LogService } from 'ng2-alfresco-core';
import { FormModel, FormFieldModel, TabModel, ContainerModel, ContainerColumnModel } from '../components/widgets/core/index';
import { WidgetVisibilityModel } from '../models/widget-visibility.model';
import { TaskProcessVariableModel } from '../models/task-process-variable.model';
import * as moment from 'moment';
@Injectable()
export class WidgetVisibilityService {
private processVarList: TaskProcessVariableModel[];
constructor(private apiService: AlfrescoApiService) {
constructor(private apiService: AlfrescoApiService,
private logService: LogService) {
}
public refreshVisibility(form: FormModel) {
@ -201,7 +196,7 @@ export class WidgetVisibilityService {
case 'or-not':
return previousValue || !newValue;
default:
console.error('NO valid operation! wrong op request : ' + logicOp);
this.logService.error('NO valid operation! wrong op request : ' + logicOp);
break;
}
}
@ -225,7 +220,7 @@ export class WidgetVisibilityService {
case '!empty':
return leftValue ? leftValue !== '' : false;
default:
console.error('NO valid operation!');
this.logService.error('NO valid operation!');
break;
}
return;
@ -250,7 +245,7 @@ export class WidgetVisibilityService {
}
private handleError() {
console.error('Error while performing a call');
this.logService.error('Error while performing a call');
return Observable.throw('Error while performing a call - Server error');
}
}

View File

@ -19,7 +19,7 @@ import { DebugElement, Input, NgModule, Component, OnInit, ViewChild } from '@an
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 { CoreModule, LogService } from 'ng2-alfresco-core';
import {
ActivitiProcessListModule,
ActivitiProcessFilters,
@ -162,7 +162,8 @@ class MyDemoApp implements OnInit {
constructor(private authService: AuthService,
private settingsService: SettingsService,
private storage: StorageService) {
private storage: StorageService,
private logService: LogService) {
settingsService.bpmHost = this.host;
settingsService.setProviders('BPM');
@ -195,12 +196,12 @@ class MyDemoApp implements OnInit {
login() {
this.authService.login('admin', 'admin').subscribe(
ticket => {
console.log(ticket);
this.logService.log(ticket);
this.ticket = this.authService.getTicketBpm();
this.authenticated = true;
},
error => {
console.log(error);
this.logService.error(error);
this.authenticated = false;
});
}

View File

@ -44,7 +44,7 @@ describe('ActivitiFilters', () => {
beforeEach(() => {
activitiService = new ActivitiProcessService(null);
filterList = new ActivitiProcessFilters(null, activitiService);
filterList = new ActivitiProcessFilters(null, activitiService, null);
});
it('should return the filter task list', (done) => {

View File

@ -16,10 +16,10 @@
*/
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 'ng2-activiti-tasklist';
import { Observable, Observer } from 'rxjs/Rx';
import { AlfrescoTranslateService, LogService } from 'ng2-alfresco-core';
import { FilterRepresentationModel } from 'ng2-activiti-tasklist';
import { ActivitiProcessService } from './../services/activiti-process.service';
declare let componentHandler: any;
@ -53,8 +53,9 @@ export class ActivitiProcessFilters implements OnInit, OnChanges {
filters: FilterRepresentationModel [] = [];
constructor(private translate: AlfrescoTranslationService,
private activiti: ActivitiProcessService) {
constructor(private translate: AlfrescoTranslateService,
private activiti: ActivitiProcessService,
private logService: LogService) {
this.filter$ = new Observable<FilterRepresentationModel>(observer => this.filterObserver = observer).share();
if (translate) {
@ -111,7 +112,7 @@ export class ActivitiProcessFilters implements OnInit, OnChanges {
this.onSuccess.emit(res);
},
(err) => {
console.log(err);
this.logService.error(err);
this.onError.emit(err);
}
);
@ -128,7 +129,7 @@ export class ActivitiProcessFilters implements OnInit, OnChanges {
this.selectFirstFilter();
},
(err) => {
console.log(err);
this.logService.error(err);
this.onError.emit(err);
});
}

View File

@ -20,7 +20,7 @@ import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { Observable } from 'rxjs/Rx';
import { AlfrescoTranslationService, CoreModule } from 'ng2-alfresco-core';
import { AlfrescoTranslateService, CoreModule } from 'ng2-alfresco-core';
import { ActivitiFormModule, FormModel, FormService } from 'ng2-activiti-form';
import { ActivitiTaskListModule } from 'ng2-activiti-tasklist';
@ -50,7 +50,7 @@ describe('ActivitiProcessInstanceDetails', () => {
ActivitiProcessInstanceDetails
],
providers: [
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
{ provide: AlfrescoTranslateService, useClass: TranslationMock },
ActivitiProcessService
],
schemas: [ NO_ERRORS_SCHEMA ]

View File

@ -16,7 +16,7 @@
*/
import { Component, Input, ViewChild, Output, EventEmitter, OnChanges, SimpleChanges } from '@angular/core';
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
import { AlfrescoTranslateService, LogService } from 'ng2-alfresco-core';
import { ActivitiProcessService } from './../services/activiti-process.service';
import { ActivitiProcessInstanceHeader } from './activiti-process-instance-header.component';
import { ActivitiProcessInstanceTasks } from './activiti-process-instance-tasks.component';
@ -60,8 +60,9 @@ export class ActivitiProcessInstanceDetails implements OnChanges {
* @param translate Translation service
* @param activitiProcess Process service
*/
constructor(private translate: AlfrescoTranslationService,
private activitiProcess: ActivitiProcessService) {
constructor(private translate: AlfrescoTranslateService,
private activitiProcess: ActivitiProcessService,
private logService: LogService) {
if (translate) {
translate.addTranslationFolder('ng2-activiti-processlist', 'node_modules/ng2-activiti-processlist/src');
@ -110,7 +111,7 @@ export class ActivitiProcessInstanceDetails implements OnChanges {
(data) => {
this.processCancelled.emit(data);
}, (err) => {
console.error(err);
this.logService.error(err);
});
}
}

View File

@ -16,7 +16,7 @@
*/
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
import { AlfrescoTranslateService, LogService } from 'ng2-alfresco-core';
import { ProcessInstance } from '../models/process-instance.model';
import { DatePipe } from '@angular/common';
@ -36,7 +36,8 @@ export class ActivitiProcessInstanceHeader {
@Output()
onError: EventEmitter<any> = new EventEmitter<any>();
constructor(private translate: AlfrescoTranslationService) {
constructor(private translate: AlfrescoTranslateService,
private logService: LogService) {
if (translate) {
translate.addTranslationFolder('ng2-activiti-processlist', 'node_modules/ng2-activiti-processlist/src');
@ -57,7 +58,7 @@ export class ActivitiProcessInstanceHeader {
try {
return datePipe.transform(value, format);
} catch (err) {
console.error(`ProcessListInstanceHeader: error parsing date ${value} to format ${format}`);
this.logService.error(`ProcessListInstanceHeader: error parsing date ${value} to format ${format}`);
}
}

View File

@ -16,11 +16,11 @@
*/
import { Component, Input, OnInit, ViewChild, Output, EventEmitter, OnChanges, SimpleChanges } from '@angular/core';
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
import { DatePipe } from '@angular/common';
import { Observable, Observer } from 'rxjs/Rx';
import { AlfrescoTranslateService, LogService } from 'ng2-alfresco-core';
import { ActivitiProcessService } from './../services/activiti-process.service';
import { TaskDetailsModel } from 'ng2-activiti-tasklist';
import { Observable, Observer } from 'rxjs/Rx';
import { DatePipe } from '@angular/common';
import { ProcessInstance } from '../models/process-instance.model';
declare let componentHandler: any;
@ -67,8 +67,9 @@ export class ActivitiProcessInstanceTasks implements OnInit, OnChanges {
@ViewChild('taskdetails')
taskdetails: any;
constructor(private translate: AlfrescoTranslationService,
private activitiProcess: ActivitiProcessService) {
constructor(private translate: AlfrescoTranslateService,
private activitiProcess: ActivitiProcessService,
private logService: LogService) {
if (translate) {
translate.addTranslationFolder('ng2-activiti-processlist', 'node_modules/ng2-activiti-processlist/src');
}
@ -108,7 +109,7 @@ export class ActivitiProcessInstanceTasks implements OnInit, OnChanges {
});
},
(err) => {
console.log(err);
this.logService.error(err);
}
);
} else {
@ -126,7 +127,7 @@ export class ActivitiProcessInstanceTasks implements OnInit, OnChanges {
});
},
(err) => {
console.log(err);
this.logService.error(err);
}
);
} else {
@ -152,7 +153,7 @@ export class ActivitiProcessInstanceTasks implements OnInit, OnChanges {
try {
return datePipe.transform(value, format);
} catch (err) {
console.error(`ProcessListInstanceTask: error parsing date ${value} to format ${format}`);
this.logService.error(`ProcessListInstanceTask: error parsing date ${value} to format ${format}`);
}
}

View File

@ -25,7 +25,7 @@ import {
ActivitiApps,
ActivitiTaskList
} from 'ng2-activiti-tasklist';
import { CoreModule } from 'ng2-alfresco-core';
import { CoreModule, LogService } from 'ng2-alfresco-core';
import { AuthService, SettingsService, StorageService } from 'ng2-alfresco-core';
import { ObjectDataTableAdapter } from 'ng2-alfresco-datatable';
@ -146,7 +146,8 @@ class MyDemoApp implements OnInit {
constructor(private authService: AuthService,
private settingsService: SettingsService,
private storage: StorageService) {
private storage: StorageService,
private logService: LogService) {
settingsService.bpmHost = this.host;
settingsService.setProviders('BPM');
@ -179,12 +180,12 @@ class MyDemoApp implements OnInit {
login() {
this.authService.login('admin', 'admin').subscribe(
ticket => {
console.log(ticket);
this.logService.info(ticket);
this.ticket = this.authService.getTicketBpm();
this.authenticated = true;
},
error => {
console.log(error);
this.logService.error(error);
this.authenticated = false;
});
}

View File

@ -16,10 +16,10 @@
*/
import { Component, Input, OnInit, ViewChild, OnChanges, SimpleChanges } from '@angular/core';
import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { Observer, Observable } from 'rxjs/Rx';
import { AlfrescoTranslateService, LogService } from 'ng2-alfresco-core';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
import { TaskDetailsModel } from '../models/task-details.model';
import { Observer, Observable } from 'rxjs/Rx';
declare let dialogPolyfill: any;
@ -54,7 +54,8 @@ export class ActivitiChecklist implements OnInit, OnChanges {
* @param translate
*/
constructor(private translateService: AlfrescoTranslateService,
private activitiTaskList: ActivitiTaskListService) {
private activitiTaskList: ActivitiTaskListService,
private logService: LogService) {
if (translateService) {
translateService.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src');
@ -86,7 +87,7 @@ export class ActivitiChecklist implements OnInit, OnChanges {
});
},
(err) => {
console.log(err);
this.logService.error(err);
}
);
} else {
@ -110,7 +111,7 @@ export class ActivitiChecklist implements OnInit, OnChanges {
this.checklist.push(res);
},
(err) => {
console.log(err);
this.logService.error(err);
}
);

View File

@ -24,6 +24,7 @@ import { FilterRepresentationModel } from '../models/filter.model';
describe('ActivitiFilters', () => {
let filterList: ActivitiFilters;
let activitiService: ActivitiTaskListService;
let fakeGlobalFilter = [];
fakeGlobalFilter.push(new FilterRepresentationModel({name: 'FakeInvolvedTasks', filter: { state: 'open', assignment: 'fake-involved'}}));
@ -42,12 +43,12 @@ describe('ActivitiFilters', () => {
});
beforeEach(() => {
let activitiService = new ActivitiTaskListService(null);
filterList = new ActivitiFilters(null, activitiService);
activitiService = new ActivitiTaskListService(null, null);
filterList = new ActivitiFilters(null, activitiService, null);
});
it('should return the filter task list', (done) => {
spyOn(filterList.activiti, 'getTaskListFilters').and.returnValue(Observable.fromPromise(fakeGlobalFilterPromise));
spyOn(activitiService, 'getTaskListFilters').and.returnValue(Observable.fromPromise(fakeGlobalFilterPromise));
const appId = '1';
let change = new SimpleChange(null, appId);
filterList.ngOnChanges({ 'appId': change });
@ -70,14 +71,14 @@ describe('ActivitiFilters', () => {
resolve({});
});
spyOn(filterList.activiti, 'getDeployedApplications').and.returnValue(Observable.fromPromise(fakeDeployedApplicationsPromise));
spyOn(filterList.activiti, 'getTaskListFilters').and.returnValue(Observable.fromPromise(fakeGlobalFilterPromise));
spyOn(activitiService, 'getDeployedApplications').and.returnValue(Observable.fromPromise(fakeDeployedApplicationsPromise));
spyOn(activitiService, 'getTaskListFilters').and.returnValue(Observable.fromPromise(fakeGlobalFilterPromise));
let change = new SimpleChange(null, 'test');
filterList.ngOnChanges({ 'appName': change });
filterList.onSuccess.subscribe((res) => {
let deployApp: any = filterList.activiti.getDeployedApplications;
let deployApp: any = activitiService.getDeployedApplications;
expect(deployApp.calls.count()).toEqual(1);
expect(res).toBeDefined();
done();
@ -87,7 +88,7 @@ describe('ActivitiFilters', () => {
});
it('should emit an error with a bad response', (done) => {
spyOn(filterList.activiti, 'getTaskListFilters').and.returnValue(Observable.fromPromise(fakeErrorFilterPromise));
spyOn(activitiService, 'getTaskListFilters').and.returnValue(Observable.fromPromise(fakeErrorFilterPromise));
const appId = '1';
let change = new SimpleChange(null, appId);
@ -102,7 +103,7 @@ describe('ActivitiFilters', () => {
});
it('should emit an error with a bad response', (done) => {
spyOn(filterList.activiti, 'getDeployedApplications').and.returnValue(Observable.fromPromise(fakeErrorFilterPromise));
spyOn(activitiService, 'getDeployedApplications').and.returnValue(Observable.fromPromise(fakeErrorFilterPromise));
const appId = 'fake-app';
let change = new SimpleChange(null, appId);

View File

@ -16,11 +16,10 @@
*/
import { Component, Output, EventEmitter, OnInit, Input, SimpleChanges, OnChanges } from '@angular/core';
import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { Observer, Observable } from 'rxjs/Rx';
import { AlfrescoTranslateService, LogService } from 'ng2-alfresco-core';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
import { FilterRepresentationModel } from '../models/filter.model';
import { Observer } from 'rxjs/Observer';
import { Observable } from 'rxjs/Observable';
declare let componentHandler: any;
@ -56,7 +55,8 @@ export class ActivitiFilters implements OnInit, OnChanges {
filters: FilterRepresentationModel [] = [];
constructor(private translateService: AlfrescoTranslateService,
public activiti: ActivitiTaskListService) {
private activiti: ActivitiTaskListService,
private logService: LogService) {
this.filter$ = new Observable<FilterRepresentationModel>(observer => this.filterObserver = observer).share();
if (translateService) {
@ -113,7 +113,7 @@ export class ActivitiFilters implements OnInit, OnChanges {
this.onSuccess.emit(res);
},
(err) => {
console.log(err);
this.logService.error(err);
this.onError.emit(err);
}
);
@ -130,7 +130,7 @@ export class ActivitiFilters implements OnInit, OnChanges {
this.selectFirstFilter();
},
(err) => {
console.log(err);
this.logService.error(err);
this.onError.emit(err);
});
}

View File

@ -17,7 +17,7 @@
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { Observable } from 'rxjs/Rx';
import { CoreModule, AlfrescoTranslateService } from 'ng2-alfresco-core';
import { CoreModule, AlfrescoTranslateService, LogService } from 'ng2-alfresco-core';
import { ActivitiPeopleService } from '../services/activiti-people.service';
import { ActivitiPeople } from './activiti-people.component';
import { ActivitiPeopleSearch } from './activiti-people-search.component';
@ -45,6 +45,7 @@ describe('ActivitiPeople', () => {
let fixture: ComponentFixture<ActivitiPeople>;
let element: HTMLElement;
let componentHandler;
let logService: LogService;
beforeEach(async(() => {
TestBed.configureTestingModule({
@ -59,6 +60,8 @@ describe('ActivitiPeople', () => {
ActivitiPeopleService
]
}).compileComponents().then(() => {
logService = TestBed.get(LogService);
let translateService = TestBed.get(AlfrescoTranslateService);
spyOn(translateService, 'addTranslationFolder').and.stub();
spyOn(translateService, 'get').and.callFake((key) => { return Observable.of(key); });
@ -216,9 +219,8 @@ describe('ActivitiPeople', () => {
});
it('should log error message when search fails', async(() => {
console.log = jasmine.createSpy('log');
activitiPeopleComponent.peopleSearch$.subscribe(() => {
expect(console.log).toHaveBeenCalledWith('Could not load users');
expect(logService.error).toHaveBeenCalledWith('Could not load users');
});
activitiPeopleComponent.searchUser('fake-search');
jasmine.Ajax.requests.mostRecent().respondWith({

View File

@ -16,9 +16,9 @@
*/
import { Component, Input, ViewChild } from '@angular/core';
import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { User } from '../models/user.model';
import { Observer, Observable } from 'rxjs/Rx';
import { AlfrescoTranslateService, LogService } from 'ng2-alfresco-core';
import { User } from '../models/user.model';
import { ActivitiPeopleService } from '../services/activiti-people.service';
declare let dialogPolyfill: any;
@ -52,7 +52,8 @@ export class ActivitiPeople {
* @param people service
*/
constructor(private translateService: AlfrescoTranslateService,
private peopleService: ActivitiPeopleService) {
private peopleService: ActivitiPeopleService,
private logService: LogService) {
if (translateService) {
translateService.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src');
}
@ -79,14 +80,14 @@ export class ActivitiPeople {
this.peopleService.getWorkflowUsers(this.taskId, searchedWord)
.subscribe((users) => {
this.peopleSearchObserver.next(users);
}, error => console.log('Could not load users'));
}, error => this.logService.error('Could not load users'));
}
involveUser(user: User) {
this.peopleService.involveUserWithTask(this.taskId, user.id.toString())
.subscribe(() => {
this.people.push(user);
}, error => console.error('Impossible to involve user with task'));
}, error => this.logService.error('Impossible to involve user with task'));
}
removeInvolvedUser(user: User) {
@ -95,7 +96,7 @@ export class ActivitiPeople {
this.people = this.people.filter((involvedUser) => {
return involvedUser.id !== user.id;
});
}, error => console.error('Impossible to remove involved user from task'));
}, error => this.logService.error('Impossible to remove involved user from task'));
}
getDisplayUser(user: User): string {

View File

@ -16,7 +16,7 @@
*/
import { Component, EventEmitter, Input, Output, ViewChild } from '@angular/core';
import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { AlfrescoTranslateService, LogService } from 'ng2-alfresco-core';
import { TaskDetailsModel } from '../models/task-details.model';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
import { Form } from '../models/form.model';
@ -55,7 +55,8 @@ export class ActivitiStartTaskButton {
* @param taskService
*/
constructor(private translateService: AlfrescoTranslateService,
private taskService: ActivitiTaskListService) {
private taskService: ActivitiTaskListService,
private logService: LogService) {
if (translateService) {
translateService.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src');
@ -77,7 +78,7 @@ export class ActivitiStartTaskButton {
},
(err) => {
window.alert('An error occurred while trying to add the task');
console.log(err);
this.logService.error(err);
}
);
}
@ -112,7 +113,7 @@ export class ActivitiStartTaskButton {
},
(err) => {
window.alert('An error occurred while trying to get the forms');
console.log(err);
this.logService.error(err);
});
}

View File

@ -15,19 +15,8 @@
* limitations under the License.
*/
import {
Component,
Input,
OnInit,
ViewChild,
Output,
EventEmitter,
TemplateRef,
OnChanges,
SimpleChanges,
DebugElement
} from '@angular/core';
import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { Component, Input, OnInit, ViewChild, Output, EventEmitter, TemplateRef, OnChanges, SimpleChanges, DebugElement} from '@angular/core';
import { AlfrescoTranslateService, LogService } from 'ng2-alfresco-core';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
import { TaskDetailsModel } from '../models/task-details.model';
import { User } from '../models/user.model';
@ -103,7 +92,8 @@ export class ActivitiTaskDetails implements OnInit, OnChanges {
*/
constructor(private translateService: AlfrescoTranslateService,
private activitiForm: FormService,
private activitiTaskList: ActivitiTaskListService) {
private activitiTaskList: ActivitiTaskListService,
private logService: LogService) {
if (translateService) {
translateService.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src');
@ -201,7 +191,7 @@ export class ActivitiTaskDetails implements OnInit, OnChanges {
this.reset();
}
}, (error) => {
console.error(error);
this.logService.error(error);
this.onError.emit(error);
});
}

View File

@ -16,7 +16,7 @@
*/
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { AlfrescoTranslateService, LogService } from 'ng2-alfresco-core';
import { TaskDetailsModel } from '../models/task-details.model';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
@ -38,7 +38,8 @@ export class ActivitiTaskHeader {
claim: EventEmitter<any> = new EventEmitter<any>();
constructor(private translateService: AlfrescoTranslateService,
private activitiTaskService: ActivitiTaskListService) {
private activitiTaskService: ActivitiTaskListService,
private logService: LogService) {
if (translateService) {
translateService.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src');
}
@ -55,7 +56,7 @@ export class ActivitiTaskHeader {
claimTask(taskId: string) {
this.activitiTaskService.claimTask(taskId).subscribe(
(res: any) => {
console.log('Task claimed');
this.logService.info('Task claimed');
this.claim.emit(taskId);
});
}

View File

@ -16,7 +16,7 @@
*/
import { Component, Input, Output, EventEmitter, OnInit, OnChanges, SimpleChanges } from '@angular/core';
import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { AlfrescoTranslateService, LogService } from 'ng2-alfresco-core';
import { ObjectDataTableAdapter, DataTableAdapter, DataRowEvent, ObjectDataRow } from 'ng2-alfresco-datatable';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
import { TaskQueryRequestRepresentationModel } from '../models/filter.model';
@ -73,7 +73,8 @@ export class ActivitiTaskList implements OnInit, OnChanges {
];
constructor(private translateService: AlfrescoTranslateService,
private taskListService: ActivitiTaskListService) {
private taskListService: ActivitiTaskListService,
private logService: LogService) {
if (translateService) {
translateService.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src');
}
@ -144,11 +145,11 @@ export class ActivitiTaskList implements OnInit, OnChanges {
this.selectFirst();
this.onSuccess.emit(response);
}, (error) => {
console.error(error);
this.logService.error(error);
this.onError.emit(error);
});
}, (err) => {
console.error(err);
this.logService.error(err);
this.onError.emit(err);
});
}

View File

@ -24,7 +24,7 @@ describe('NoTaskDetailsTemplateComponent', () => {
let detailsComponent: ActivitiTaskDetails;
beforeEach(() => {
detailsComponent = new ActivitiTaskDetails(null, null, null);
detailsComponent = new ActivitiTaskDetails(null, null, null, null);
component = new NoTaskDetailsTemplateComponent(detailsComponent);
});

View File

@ -16,7 +16,7 @@
*/
import { Injectable } from '@angular/core';
import { AlfrescoApiService } from 'ng2-alfresco-core';
import { AlfrescoApiService, LogService } from 'ng2-alfresco-core';
import { Observable } from 'rxjs/Rx';
import { Response } from '@angular/http';
import { User } from '../models/user.model';
@ -24,7 +24,8 @@ import { User } from '../models/user.model';
@Injectable()
export class ActivitiPeopleService {
constructor(private alfrescoJsApi: AlfrescoApiService) {
constructor(private alfrescoJsApi: AlfrescoApiService,
private logService: LogService) {
}
getWorkflowUsers(taskId: string, searchWord: string): Observable<User[]> {
@ -64,9 +65,7 @@ export class ActivitiPeopleService {
* @returns {ErrorObservable}
*/
private handleError(error: Response) {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console
console.error(error);
this.logService.error(error);
return Observable.throw(error || 'Server error');
}
}

View File

@ -16,8 +16,8 @@
*/
import { Injectable } from '@angular/core';
import { AlfrescoApiService } from 'ng2-alfresco-core';
import { Observable } from 'rxjs/Rx';
import { AlfrescoApiService, LogService } from 'ng2-alfresco-core';
import { FilterRepresentationModel, TaskQueryRequestRepresentationModel } from '../models/filter.model';
import { Comment } from '../models/comment.model';
import { User } from '../models/user.model';
@ -27,7 +27,8 @@ import { Form } from '../models/form.model';
@Injectable()
export class ActivitiTaskListService {
constructor(private apiService: AlfrescoApiService) {
constructor(private apiService: AlfrescoApiService,
private logService: LogService) {
}
/**
@ -311,7 +312,7 @@ export class ActivitiTaskListService {
}
private handleError(error: any) {
console.error(error);
this.logService.error(error);
return Observable.throw(error || 'Server error');
}

View File

@ -33,7 +33,7 @@ import {
AuthGuard,
AuthGuardEcm,
AuthGuardBpm,
LogService,
LogService, LogServiceMock,
/** @deprecated */ AlfrescoSettingsService,
/** @deprecated */ AlfrescoTranslationService,
@ -49,7 +49,7 @@ export * from './src/components/index';
export * from './src/utils/index';
export const ALFRESCO_CORE_PROVIDERS: any[] = [
LogService,
LogService, LogServiceMock,
AuthService,
ContentService,
SettingsService,
@ -69,8 +69,8 @@ export const ALFRESCO_CORE_PROVIDERS: any[] = [
/** @deprecated */ AlfrescoTranslationService
];
export function createTranslateLoader(http: Http) {
return new AlfrescoTranslateLoader(http);
export function createTranslateLoader(http: Http, logService: LogService) {
return new AlfrescoTranslateLoader(http, logService);
}
@NgModule({
@ -82,7 +82,7 @@ export function createTranslateLoader(http: Http) {
TranslateModule.forRoot({
provide: TranslateLoader,
useFactory: (createTranslateLoader),
deps: [Http]
deps: [Http, LogService]
})
],
declarations: [

View File

@ -16,6 +16,7 @@
*/
import { Injectable } from '@angular/core';
import { LogService } from './log.service';
import { SettingsService } from './settings.service';
import { StorageService } from './storage.service';
import { AlfrescoApiService } from './alfresco-api.service';
@ -26,8 +27,9 @@ import { AuthService } from './auth.service';
export class AlfrescoAuthenticationService extends AuthService {
constructor(settingsService: SettingsService,
apiService: AlfrescoApiService,
storage: StorageService) {
super(settingsService, apiService, storage);
console.log('Warning: AlfrescoAuthenticationService is deprecated. Use AuthService instead.');
storage: StorageService,
logService: LogService) {
super(settingsService, apiService, storage, logService);
logService.warn('Warning: AlfrescoAuthenticationService is deprecated. Use AuthService instead.');
}
}

View File

@ -16,7 +16,7 @@
*/
import { Injectable } from '@angular/core';
import { LogService } from './log.service';
import { AuthService } from './auth.service';
import { ContentService } from './content.service';
import { AlfrescoApiService } from './alfresco-api.service';
@ -25,8 +25,10 @@ import { AlfrescoApiService } from './alfresco-api.service';
@Injectable()
export class AlfrescoContentService extends ContentService {
constructor(authService: AuthService, apiService: AlfrescoApiService) {
constructor(authService: AuthService,
apiService: AlfrescoApiService,
logService: LogService) {
super(authService, apiService);
console.log('Warning: AlfrescoContentService is deprecated. Use ContentService instead.');
logService.warn('Warning: AlfrescoContentService is deprecated. Use ContentService instead.');
}
}

View File

@ -17,13 +17,14 @@
import { Injectable } from '@angular/core';
import { SettingsService } from './settings.service';
import { LogService } from './log.service';
/** @deprecated AlfrescoSettingsService is deprecated. Use SettingsService instead */
@Injectable()
export class AlfrescoSettingsService extends SettingsService {
constructor() {
constructor(logService: LogService) {
super();
console.log('Warning: AlfrescoSettingsService is deprecated. Use SettingsService instead.');
logService.warn('Warning: AlfrescoSettingsService is deprecated. Use SettingsService instead.');
}
}

View File

@ -18,14 +18,16 @@
import { Injectable } from '@angular/core';
import { TranslateService } from 'ng2-translate/ng2-translate';
import { AlfrescoTranslateService } from './translate.service';
import { LogService } from './log.service';
/** @deprecated AlfrescoTranslationService is deprecated. Use AlfrescoTranslateService instead */
@Injectable()
export class AlfrescoTranslationService extends AlfrescoTranslateService {
constructor(translate: TranslateService) {
constructor(translate: TranslateService,
logService: LogService) {
super(translate);
console.log('Warning: AlfrescoTranslationService is deprecated. Use AlfrescoTranslateService instead.');
logService.warn('Warning: AlfrescoTranslationService is deprecated. Use AlfrescoTranslateService instead.');
}
}

View File

@ -20,6 +20,7 @@ import { SettingsService } from './settings.service';
import { AuthService } from './auth.service';
import { AlfrescoApiService } from './alfresco-api.service';
import { StorageService } from './storage.service';
import { LogService } from './log.service';
declare let jasmine: any;
@ -34,7 +35,8 @@ describe('AuthService', () => {
SettingsService,
AlfrescoApiService,
AuthService,
StorageService
StorageService,
LogService
]);
authService = injector.get(AuthService);

View File

@ -16,13 +16,13 @@
*/
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Rx';
import { Observable, Subject } from 'rxjs/Rx';
import { SettingsService } from './settings.service';
import { StorageService } from './storage.service';
import { AlfrescoApiService } from './alfresco-api.service';
import * as alfrescoApi from 'alfresco-js-api';
import { AlfrescoApi } from 'alfresco-js-api';
import { Subject } from 'rxjs/Subject';
import { LogService } from './log.service';
@Injectable()
export class AuthService {
@ -33,7 +33,8 @@ export class AuthService {
constructor(private settingsService: SettingsService,
private apiService: AlfrescoApiService,
private storage: StorageService) {
private storage: StorageService,
private logService: LogService) {
this.alfrescoApi = <AlfrescoApi>new alfrescoApi({
provider: this.settingsService.getProviders(),
ticketEcm: this.getTicketEcm(),
@ -103,7 +104,7 @@ export class AuthService {
*
* @returns {Observable<R>|Observable<T>}
*/
public logout() {
logout() {
return Observable.fromPromise(this.callApiLogout())
.map(res => <any> res)
.do(response => {
@ -127,7 +128,7 @@ export class AuthService {
/**
* Remove the login ticket from Storage
*/
public removeTicket(): void {
removeTicket(): void {
this.storage.removeItem('ticket-ECM');
this.storage.removeItem('ticket-BPM');
this.alfrescoApi.setTicket(undefined, undefined);
@ -137,7 +138,7 @@ export class AuthService {
* The method return the ECM ticket stored in the Storage
* @returns ticket
*/
public getTicketEcm(): string | null {
getTicketEcm(): string | null {
return this.storage.getItem('ticket-ECM');
}
@ -145,11 +146,11 @@ export class AuthService {
* The method return the BPM ticket stored in the Storage
* @returns ticket
*/
public getTicketBpm(): string | null {
getTicketBpm(): string | null {
return this.storage.getItem('ticket-BPM');
}
public getTicketEcmBase64(): string | null {
getTicketEcmBase64(): string | null {
let ticket = this.storage.getItem('ticket-ECM');
if (ticket) {
return 'Basic ' + btoa(ticket);
@ -160,7 +161,7 @@ export class AuthService {
/**
* The method save the ECM and BPM ticket in the Storage
*/
public saveTickets() {
saveTickets() {
this.saveTicketEcm();
this.saveTicketBpm();
}
@ -168,7 +169,7 @@ export class AuthService {
/**
* The method save the ECM ticket in the Storage
*/
public saveTicketEcm(): void {
saveTicketEcm(): void {
if (this.alfrescoApi && this.alfrescoApi.getTicketEcm()) {
this.storage.setItem('ticket-ECM', this.alfrescoApi.getTicketEcm());
}
@ -177,7 +178,7 @@ export class AuthService {
/**
* The method save the BPM ticket in the Storage
*/
public saveTicketBpm(): void {
saveTicketBpm(): void {
if (this.alfrescoApi && this.alfrescoApi.getTicketBpm()) {
this.storage.setItem('ticket-BPM', this.alfrescoApi.getTicketBpm());
}
@ -186,14 +187,14 @@ export class AuthService {
/**
* The method return true if user is logged in on ecm provider
*/
public isEcmLoggedIn() {
isEcmLoggedIn() {
return this.alfrescoApi.ecmAuth && !!this.alfrescoApi.ecmAuth.isLoggedIn();
}
/**
* The method return true if user is logged in on bpm provider
*/
public isBpmLoggedIn() {
isBpmLoggedIn() {
return this.alfrescoApi.bpmAuth && !!this.alfrescoApi.bpmAuth.isLoggedIn();
}
@ -202,8 +203,8 @@ export class AuthService {
* @param error
* @returns {ErrorObservable}
*/
public handleError(error: any): Observable<any> {
console.error('Error when logging in', error);
handleError(error: any): Observable<any> {
this.logService.error('Error when logging in', error);
return Observable.throw(error || 'Server error');
}
}

View File

@ -21,6 +21,7 @@ import { AuthService } from './auth.service';
import { ContentService } from './content.service';
import { AlfrescoApiService } from './alfresco-api.service';
import { StorageService } from './storage.service';
import { LogService } from './log.service';
declare let jasmine: any;
@ -40,7 +41,8 @@ describe('ContentService', () => {
ContentService,
AuthService,
SettingsService,
StorageService
StorageService,
LogService
]);
authService = injector.get(AuthService);

View File

@ -21,7 +21,7 @@ import { Injectable } from '@angular/core';
export class LogService {
get assert(): (message?: any, ...optionalParams: any[]) => void {
return console.error.bind(console);
return console.assert.bind(console);
}
get error(): (message?: any, ...optionalParams: any[]) => void {
@ -29,11 +29,11 @@ export class LogService {
}
get group(): (message?: any, ...optionalParams: any[]) => void {
return console.error.bind(console);
return console.group.bind(console);
}
get groupEnd(): (message?: any, ...optionalParams: any[]) => void {
return console.error.bind(console);
return console.groupEnd.bind(console);
}
get info(): (message?: any, ...optionalParams: any[]) => void {
@ -49,3 +49,15 @@ export class LogService {
}
}
export class LogServiceMock {
assert(message?: any, ...optionalParams: any[]) {}
error(message?: any, ...optionalParams: any[]) {}
group(message?: any, ...optionalParams: any[]) {}
groupEnd(message?: any, ...optionalParams: any[]) {}
info(message?: any, ...optionalParams: any[]) {}
log(message?: any, ...optionalParams: any[]) {}
warn(message?: any, ...optionalParams: any[]) {}
}

View File

@ -18,11 +18,8 @@
import { ReflectiveInjector } from '@angular/core';
import { AlfrescoApiService } from './alfresco-api.service';
import { RenditionsService } from './renditions.service';
import {
fakeRedition,
fakeReditionCreated,
fakeReditionsList
} from '../assets/renditionsService.mock';
import { LogService } from './log.service';
import { fakeRedition, fakeReditionCreated, fakeReditionsList } from '../assets/renditionsService.mock';
declare let jasmine: any;
declare let AlfrescoApi: any;
@ -33,7 +30,8 @@ describe('RenditionsService', () => {
beforeEach(() => {
injector = ReflectiveInjector.resolveAndCreate([
AlfrescoApiService,
RenditionsService
RenditionsService,
LogService
]);
});

View File

@ -18,6 +18,7 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Rx';
import { AlfrescoApiService } from './alfresco-api.service';
import { LogService } from './log.service';
/**
* RenditionsService
@ -27,7 +28,8 @@ import { AlfrescoApiService } from './alfresco-api.service';
@Injectable()
export class RenditionsService {
constructor(private apiService: AlfrescoApiService) {
constructor(private apiService: AlfrescoApiService,
private logService: LogService) {
}
@ -75,7 +77,7 @@ export class RenditionsService {
}
private handleError(error: any): Observable<any> {
console.error(error);
this.logService.error(error);
return Observable.throw(error || 'Server error');
}
}

View File

@ -23,6 +23,7 @@ import {getTestBed, TestBed} from '@angular/core/testing';
import { AlfrescoTranslateLoader } from './translate-loader.service';
import { AlfrescoTranslateService } from './translate.service';
import { LogService } from './log.service';
let componentJson1 = ' {"TEST": "This is a test", "TEST2": "This is another test"} ' ;
@ -39,12 +40,16 @@ describe('TranslateLoader', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpModule, TranslateModule.forRoot({
imports: [
HttpModule,
TranslateModule.forRoot({
provide: TranslateLoader,
useClass: AlfrescoTranslateLoader
})],
})
],
providers: [
AlfrescoTranslateService,
LogService,
{provide: XHRBackend, useClass: MockBackend}
]
});

View File

@ -17,9 +17,10 @@
import { Injectable } from '@angular/core';
import { Response, Http } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import { Observable } from 'rxjs/Rx';
import { TranslateLoader } from 'ng2-translate/ng2-translate';
import { ComponentTranslationModel } from '../models/component.model';
import { LogService } from './log.service';
@Injectable()
export class AlfrescoTranslateLoader implements TranslateLoader {
@ -29,7 +30,8 @@ export class AlfrescoTranslateLoader implements TranslateLoader {
private _componentList: ComponentTranslationModel[] = [];
private queue: string [][] = [];
constructor(private http: Http) {
constructor(private http: Http,
private logService: LogService) {
}
addComponentList(nameInput: string, pathInput: string) {
@ -95,7 +97,7 @@ export class AlfrescoTranslateLoader implements TranslateLoader {
observer.complete();
},
(err: any) => {
console.error(err);
this.logService.error(err);
});
} else {
let fullTranslation = this.getFullTranslationJSON(lang);

View File

@ -23,6 +23,7 @@ import { getTestBed, TestBed } from '@angular/core/testing';
import { AlfrescoTranslateService } from './translate.service';
import { AlfrescoTranslateLoader } from './translate-loader.service';
import { LogService } from './log.service';
const mockBackendResponse = (connection: MockConnection, response: string) => {
connection.mockRespond(new Response(new ResponseOptions({body: response})));
@ -36,12 +37,16 @@ describe('AlfrescoTranslateService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpModule, TranslateModule.forRoot({
imports: [
HttpModule,
TranslateModule.forRoot({
provide: TranslateLoader,
useClass: AlfrescoTranslateLoader
})],
})
],
providers: [
AlfrescoTranslateService,
LogService,
{provide: XHRBackend, useClass: MockBackend}
]
});

View File

@ -17,13 +17,7 @@
import { DatePipe } from '@angular/common';
import { ObjectUtils } from 'ng2-alfresco-core';
import {
DataTableAdapter,
DataRow,
DataColumn,
DataSorting
} from './datatable-adapter';
import { DataTableAdapter, DataRow, DataColumn, DataSorting } from './datatable-adapter';
// Simple implementation of the DataTableAdapter interface.
export class ObjectDataTableAdapter implements DataTableAdapter {

View File

@ -19,7 +19,7 @@ import { NgModule, Component, OnInit, ViewChild } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { DocumentListModule, DocumentList, DocumentActionsService } from 'ng2-alfresco-documentlist';
import { CoreModule, StorageService, SettingsService, AuthService, AlfrescoTranslationService } from 'ng2-alfresco-core';
import { CoreModule, StorageService, SettingsService, AuthService, AlfrescoTranslateService, LogService } from 'ng2-alfresco-core';
@Component({
selector: 'alfresco-app-demo',
@ -129,9 +129,10 @@ class DocumentListDemo implements OnInit {
constructor(private authService: AuthService,
private settingsService: SettingsService,
private translateService: AlfrescoTranslationService,
private translateService: AlfrescoTranslateService,
private documentActions: DocumentActionsService,
private storage: StorageService) {
private storage: StorageService,
private logService: LogService) {
settingsService.ecmHost = this.ecmHost;
settingsService.setProviders('ECM');
@ -174,13 +175,13 @@ class DocumentListDemo implements OnInit {
login() {
this.authService.login('admin', 'admin').subscribe(
ticket => {
console.log(ticket);
this.logService.info(ticket);
this.ticket = this.authService.getTicketEcm();
this.authenticated = true;
this.documentList.reload();
},
error => {
console.log(error);
this.logService.error(error);
this.authenticated = false;
});
}

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { Observable } from 'rxjs/Observable';
import { Observable } from 'rxjs/Rx';
import { NodePaging } from './../models/document-library.model';
import { PageNode } from './document-library.model.mock';
import { DocumentListService } from './../services/document-list.service';
@ -23,7 +23,8 @@ import {
SettingsService,
AuthService,
AlfrescoContentService,
AlfrescoApiService
AlfrescoApiService,
LogService
} from 'ng2-alfresco-core';
export class DocumentListServiceMock extends DocumentListService {
@ -36,9 +37,10 @@ export class DocumentListServiceMock extends DocumentListService {
settings?: SettingsService,
authService?: AuthService,
contentService?: AlfrescoContentService,
apiService?: AlfrescoApiService
apiService?: AlfrescoApiService,
logService?: LogService,
) {
super(authService, contentService, apiService);
super(authService, contentService, apiService, logService);
}
getFolder(folder: string) {

View File

@ -16,7 +16,7 @@
*/
import { Component, Input, Output, EventEmitter, ViewChild } from '@angular/core';
import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { AlfrescoTranslateService, LogService } from 'ng2-alfresco-core';
import { MinimalNodeEntity } from 'alfresco-js-api';
import { DocumentListService } from './../services/document-list.service';
import { ContentActionModel } from './../models/content-action.model';
@ -51,9 +51,9 @@ export class DocumentMenuAction {
folderName: string = '';
constructor(
private documentListService: DocumentListService,
private translateService: AlfrescoTranslateService) {
constructor(private documentListService: DocumentListService,
private translateService: AlfrescoTranslateService,
private logService: LogService) {
if (translateService) {
translateService.addTranslationFolder('ng2-alfresco-documentlist', 'node_modules/ng2-alfresco-documentlist/src');
@ -66,7 +66,7 @@ export class DocumentMenuAction {
.subscribe(
(res: MinimalNodeEntity) => {
this.folderName = '';
console.log(res.entry);
this.logService.info(res.entry);
this.success.emit({node: res.entry});
},
error => {
@ -74,10 +74,10 @@ export class DocumentMenuAction {
if (errorMessagePlaceholder) {
this.message = this.formatString(errorMessagePlaceholder, [name]);
this.error.emit({message: this.message});
console.log(this.message);
this.logService.error(this.message);
} else {
this.error.emit(error);
console.log(error);
this.logService.error(error);
}
}
);

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { SettingsService, AuthService, AlfrescoApiService, StorageService, ContentService } from 'ng2-alfresco-core';
import { SettingsService, AuthService, AlfrescoApiService, StorageService, ContentService, LogService, LogServiceMock } from 'ng2-alfresco-core';
import { FileNode } from '../assets/document-library.model.mock';
import { ReflectiveInjector } from '@angular/core';
import { DocumentListService } from './document-list.service';
@ -99,7 +99,8 @@ describe('DocumentListService', () => {
AlfrescoApiService,
ContentService,
DocumentListService,
StorageService
StorageService,
{ provide: LogService, useClass: LogServiceMock }
]);
settingsService = injector.get(SettingsService);
@ -151,7 +152,7 @@ describe('DocumentListService', () => {
});
});
it('should emit an error when the folder already exist', () => {
xit('should emit an error when the folder already exist', () => {
service.createFolder('fake-name', 'fake-path').subscribe(
res => {

View File

@ -19,7 +19,7 @@ import { Injectable } from '@angular/core';
import { Response } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import { NodePaging, MinimalNodeEntity, MinimalNodeEntryEntity } from 'alfresco-js-api';
import { AuthService, ContentService, AlfrescoApiService } from 'ng2-alfresco-core';
import { AuthService, ContentService, AlfrescoApiService, LogService } from 'ng2-alfresco-core';
@Injectable()
export class DocumentListService {
@ -59,7 +59,8 @@ export class DocumentListService {
constructor(private authService: AuthService,
private contentService: ContentService,
private apiService: AlfrescoApiService) {
private apiService: AlfrescoApiService,
private logService: LogService) {
}
private getNodesPromise(folder: string, opts?: any): Promise<NodePaging> {
@ -114,7 +115,6 @@ export class DocumentListService {
getFolder(folder: string, opts?: any) {
return Observable.fromPromise(this.getNodesPromise(folder, opts))
.map(res => <NodePaging> res)
// .do(data => console.log('Node data', data)) // eyeball results in the console
.catch(this.handleError);
}
@ -149,7 +149,7 @@ export class DocumentListService {
private handleError(error: Response) {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console
console.error(error);
this.logService.error(error);
return Observable.throw(error || 'Server error');
}
}

View File

@ -19,7 +19,7 @@ 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 { LoginModule } from 'ng2-alfresco-login';
@Component({
@ -61,41 +61,37 @@ import { LoginModule } from 'ng2-alfresco-login';
})
export class AppComponent {
public ecmHost: string = 'http://localhost:8080';
ecmHost: string = 'http://localhost:8080';
bpmHost: string = 'http://localhost:9999';
ticket: string;
status: string = '';
providers: string = 'ECM';
disableCsrf: boolean = false;
public bpmHost: string = 'http://localhost:9999';
public ticket: string;
public status: string = '';
public providers: string = 'ECM';
public disableCsrf: boolean = false;
constructor(public authService: AuthService,
constructor(private authService: AuthService,
private settingsService: SettingsService,
private storage: StorageService) {
private storage: StorageService,
private logService: LogService) {
settingsService.ecmHost = this.ecmHost;
settingsService.bpmHost = this.bpmHost;
}
public updateEcmHost(): void {
updateEcmHost(): void {
this.settingsService.ecmHost = this.ecmHost;
}
public updateBpmHost(): void {
updateBpmHost(): void {
this.settingsService.bpmHost = this.bpmHost;
}
mySuccessMethod($event) {
console.log('Success Login EventEmitt called with: ' + $event.value);
this.logService.info('Success Login EventEmitt called with: ' + $event.value);
this.status = $event.value;
}
myErrorMethod($event) {
console.log('Error Login EventEmitt called with: ' + $event.value);
this.logService.error('Error Login EventEmitt called with: ' + $event.value);
this.status = $event.value;
}

View File

@ -17,13 +17,8 @@
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { DebugElement } from '@angular/core';
import {
AuthService,
SettingsService,
AlfrescoApiService,
CoreModule
} from 'ng2-alfresco-core';
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
import { AuthService, CoreModule } from 'ng2-alfresco-core';
import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { AlfrescoLoginComponent } from './alfresco-login.component';
import { AuthenticationMock } from './../assets/authentication.service.mock';
import { TranslationMock } from './../assets/translation.service.mock';
@ -39,15 +34,12 @@ describe('AlfrescoLogin', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
CoreModule
CoreModule.forRoot()
],
declarations: [AlfrescoLoginComponent],
providers: [
SettingsService,
AuthService,
AlfrescoApiService,
{provide: AuthService, useClass: AuthenticationMock},
{provide: AlfrescoTranslationService, useClass: TranslationMock}
{provide: AlfrescoTranslateService, useClass: TranslationMock}
]
}).compileComponents();
}));

View File

@ -17,11 +17,7 @@
import { Component, Input, Output, EventEmitter, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import {
AlfrescoTranslationService,
AuthService,
SettingsService
} from 'ng2-alfresco-core';
import { AlfrescoTranslateService, AuthService, SettingsService, LogService } from 'ng2-alfresco-core';
import { FormSubmitEvent } from '../models/form-submit-event.model';
declare let componentHandler: any;
@ -79,11 +75,14 @@ export class AlfrescoLoginComponent implements OnInit {
* @param translate
*/
constructor(private _fb: FormBuilder,
public authService: AuthService,
public settingsService: SettingsService,
private translate: AlfrescoTranslationService) {
private authService: AuthService,
private settingsService: SettingsService,
private translateService: AlfrescoTranslateService,
private logService: LogService) {
translate.addTranslationFolder('ng2-alfresco-login', 'node_modules/ng2-alfresco-login/src');
if (translateService) {
translateService.addTranslationFolder('ng2-alfresco-login', 'node_modules/ng2-alfresco-login/src');
}
this.initFormError();
this.initFormFieldsMessages();
@ -160,9 +159,9 @@ export class AlfrescoLoginComponent implements OnInit {
this.enableError();
this.errorMsg = 'LOGIN.MESSAGES.LOGIN-ERROR-CREDENTIALS';
this.onError.emit(err);
console.log(err);
this.logService.error(err);
},
() => console.log('Login done')
() => this.logService.info('Login done')
);
}
@ -175,7 +174,7 @@ export class AlfrescoLoginComponent implements OnInit {
this.errorMsg = 'LOGIN.MESSAGES.LOGIN-ERROR-PROVIDERS';
this.enableError();
let messageProviders: any;
messageProviders = this.translate.get(this.errorMsg);
messageProviders = this.translateService.get(this.errorMsg);
this.onError.emit(messageProviders.value);
return false;
}

View File

@ -19,7 +19,7 @@ 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, LogService } from 'ng2-alfresco-core';
import { SearchModule } from 'ng2-alfresco-search';
import {
@ -50,16 +50,14 @@ import {
class SearchDemo implements OnInit {
authenticated: boolean;
public searchTerm: string = 'test';
public ecmHost: string = 'http://localhost:8080';
searchTerm: string = 'test';
ecmHost: string = 'http://localhost:8080';
ticket: string;
constructor(private authService: AuthService,
private settingsService: SettingsService,
translation: AlfrescoTranslationService) {
translation: AlfrescoTranslationService,
private logService: LogService) {
settingsService.ecmHost = this.ecmHost;
settingsService.setProviders('ECM');
@ -79,18 +77,18 @@ class SearchDemo implements OnInit {
login() {
this.authService.login('admin', 'admin').subscribe(
ticket => {
console.log(ticket);
this.logService.info(ticket);
this.ticket = this.authService.getTicketEcm();
this.authenticated = true;
},
error => {
console.log(error);
this.logService.error(error);
this.authenticated = false;
});
}
searchTermChange(event) {
console.log('Search term changed', event);
this.logService.info('Search term changed', event);
this.searchTerm = event.value;
}
}

View File

@ -28,10 +28,10 @@ import {
SettingsService,
AlfrescoApiService,
AuthService,
ContentService,
AlfrescoTranslateService,
CoreModule,
StorageService
StorageService,
LogService
} from 'ng2-alfresco-core';
describe('AlfrescoSearchComponent', () => {
@ -102,18 +102,13 @@ describe('AlfrescoSearchComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
CoreModule
CoreModule.forRoot()
],
declarations: [ AlfrescoSearchComponent ], // declare the test component
providers: [
AlfrescoSearchService,
{provide: AlfrescoTranslateService, useClass: TranslationMock},
AlfrescoThumbnailService,
SettingsService,
AlfrescoApiService,
AuthService,
ContentService,
StorageService
AlfrescoThumbnailService
]
}).compileComponents().then(() => {
fixture = TestBed.createComponent(AlfrescoSearchComponent);
@ -123,9 +118,7 @@ describe('AlfrescoSearchComponent', () => {
}));
it('should not have a search term by default', () => {
let search = new AlfrescoSearchComponent(null, null, null, null);
expect(search).toBeDefined();
expect(search.searchTerm).toBe('');
expect(component.searchTerm).toBe('');
});
it('should take the provided search term from query param provided via RouteParams', () => {
@ -144,6 +137,7 @@ describe('AlfrescoSearchComponent', () => {
SettingsService,
AlfrescoApiService,
StorageService,
LogService,
{ provide: ActivatedRoute, useValue: { params: Observable.from([{}]) } }
]);
let search = new AlfrescoSearchComponent(injector.get(AlfrescoSearchService), null, null, injector.get(ActivatedRoute));

View File

@ -17,7 +17,7 @@
import { ReflectiveInjector } from '@angular/core';
import { AlfrescoSearchService } from './alfresco-search.service';
import { AuthService, SettingsService, AlfrescoApiService, StorageService } from 'ng2-alfresco-core';
import { AuthService, SettingsService, AlfrescoApiService, StorageService, LogService } from 'ng2-alfresco-core';
import { fakeApi, fakeSearch, fakeError } from '../assets/alfresco-search.service.mock';
declare let jasmine: any;
@ -34,7 +34,8 @@ describe('AlfrescoSearchService', () => {
SettingsService,
AlfrescoApiService,
AuthService,
StorageService
StorageService,
LogService
]);
service = injector.get(AlfrescoSearchService);
apiService = injector.get(AlfrescoApiService);

View File

@ -17,7 +17,7 @@
import { ReflectiveInjector } from '@angular/core';
import { AlfrescoThumbnailService } from './alfresco-thumbnail.service';
import { AlfrescoApiService, AuthService, ContentService, SettingsService, StorageService } from 'ng2-alfresco-core';
import { AlfrescoApiService, AuthService, ContentService, SettingsService, StorageService, LogService } from 'ng2-alfresco-core';
describe('AlfrescoThumbnailService', () => {
@ -31,7 +31,8 @@ describe('AlfrescoThumbnailService', () => {
ContentService,
SettingsService,
AlfrescoThumbnailService,
StorageService
StorageService,
LogService
]);
service = injector.get(AlfrescoThumbnailService);

View File

@ -19,7 +19,7 @@ import { NgModule, Component, Input, OnInit } 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 { TagModule } from 'ng2-alfresco-tag';
@Component({
@ -54,14 +54,13 @@ class TagDemo implements OnInit {
nodeId: string = '74cd8a96-8a21-47e5-9b3b-a1b3e296787d';
authenticated: boolean;
ecmHost: string = 'http://127.0.0.1:8080';
ticket: string;
constructor(private authService: AuthService,
private settingsService: SettingsService,
private storage: StorageService) {
private storage: StorageService,
private logService: LogService) {
settingsService.ecmHost = this.ecmHost;
settingsService.setProviders('ECM');
@ -78,12 +77,12 @@ class TagDemo implements OnInit {
login() {
this.authService.login('admin', 'admin').subscribe(
ticket => {
console.log(ticket);
this.logService.info(ticket);
this.ticket = this.authService.getTicketEcm();
this.authenticated = true;
},
error => {
console.log(error);
this.logService.error(error);
this.authenticated = false;
});
}
@ -98,7 +97,7 @@ class TagDemo implements OnInit {
}
logData(data) {
console.log(data);
this.logService.info(data);
}
}

View File

@ -17,7 +17,7 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Rx';
import { AlfrescoApiService } from 'ng2-alfresco-core';
import { AlfrescoApiService, LogService } from 'ng2-alfresco-core';
/**
* @returns {TagService} .
@ -31,7 +31,8 @@ export class TagService {
* Constructor
* @param apiService
*/
constructor(private apiService: AlfrescoApiService) {
constructor(private apiService: AlfrescoApiService,
private logService: LogService) {
}
getTagsByNodeId(nodeId: string): any {
@ -59,7 +60,7 @@ export class TagService {
}
private handleError(error: any) {
console.error(error);
this.logService.error(error);
return Observable.throw(error || 'Server error');
}
}

View File

@ -19,7 +19,7 @@ import { NgModule, Component, OnInit } 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 { UploadModule } from 'ng2-alfresco-upload';
@Component({
@ -103,19 +103,18 @@ import { UploadModule } from 'ng2-alfresco-upload';
})
export class MyDemoApp implements OnInit {
public ecmHost: string = 'http://localhost:8080';
ecmHost: string = 'http://localhost:8080';
authenticated: boolean;
multipleFileUpload: boolean = false;
folderUpload: boolean = false;
acceptedFilesTypeShow: boolean = false;
versioning: boolean = false;
ticket: string;
constructor(private authService: AuthService,
private settingsService: SettingsService,
private storage: StorageService) {
private storage: StorageService,
private logService: LogService) {
settingsService.ecmHost = this.ecmHost;
settingsService.setProviders('ECM');
@ -124,32 +123,32 @@ export class MyDemoApp implements OnInit {
}
}
public updateTicket(): void {
updateTicket(): void {
this.storage.setItem('ticket-ECM', this.ticket);
}
public updateHost(): void {
updateHost(): void {
this.settingsService.ecmHost = this.ecmHost;
this.login();
}
public customMethod(event: Object): void {
console.log('File uploaded');
customMethod(event: Object): void {
this.logService.info('File uploaded');
}
public ngOnInit(): void {
ngOnInit(): void {
this.login();
}
login() {
this.authService.login('admin', 'admin').subscribe(
ticket => {
console.log(ticket);
this.logService.info(ticket);
this.ticket = this.authService.getTicketEcm();
this.authenticated = true;
},
error => {
console.log(error);
this.logService.error(error);
this.authenticated = false;
});
}

View File

@ -17,7 +17,7 @@
import { Component, ViewChild, ElementRef, Input, Output, EventEmitter } from '@angular/core';
import 'rxjs/Rx';
import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { AlfrescoTranslateService, LogService } from 'ng2-alfresco-core';
import { UploadService } from '../services/upload.service';
import { FileModel } from '../models/file.model';
@ -88,9 +88,10 @@ export class UploadButtonComponent {
@Output()
createFolder = new EventEmitter();
constructor(public el: ElementRef,
constructor(private el: ElementRef,
private uploadService: UploadService,
private translateService: AlfrescoTranslateService) {
private translateService: AlfrescoTranslateService,
private logService: LogService) {
if (translateService) {
translateService.addTranslationFolder('ng2-alfresco-upload', 'node_modules/ng2-alfresco-upload/src');
}
@ -141,7 +142,7 @@ export class UploadButtonComponent {
this._showErrorNotificationBar(errorMessage);
}
}
console.log(error);
this.logService.error(error);
}
);
});

View File

@ -16,9 +16,8 @@
*/
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { EventEmitter } from '@angular/core';
import { DebugElement } from '@angular/core';
import { AlfrescoTranslateService, CoreModule } from 'ng2-alfresco-core';
import { EventEmitter, DebugElement } from '@angular/core';
import { AlfrescoTranslateService, CoreModule, LogService } from 'ng2-alfresco-core';
import { UploadDragAreaComponent } from './upload-drag-area.component';
import { TranslationMock } from '../assets/translation.service.mock';
@ -31,6 +30,7 @@ describe('UploadDragAreaComponent', () => {
let debug: DebugElement;
let element: HTMLElement;
let uploadService: UploadService;
let logService: LogService;
beforeEach(async(() => {
TestBed.configureTestingModule({
@ -48,6 +48,7 @@ describe('UploadDragAreaComponent', () => {
}));
beforeEach(() => {
logService = TestBed.get(LogService);
fixture = TestBed.createComponent(UploadDragAreaComponent);
uploadService = TestBed.get(UploadService);
@ -64,12 +65,12 @@ describe('UploadDragAreaComponent', () => {
it('should show an folder non supported error in console when the file type is empty', () => {
component.showUdoNotificationBar = false;
spyOn(console, 'error');
spyOn(logService, 'error');
let fileFake = new File([''], 'folder-fake', {type: ''});
component.onFilesDropped([fileFake]);
expect(console.error).toHaveBeenCalledWith('FILE_UPLOAD.MESSAGES.FOLDER_NOT_SUPPORTED');
expect(logService.error).toHaveBeenCalledWith('FILE_UPLOAD.MESSAGES.FOLDER_NOT_SUPPORTED');
});
it('should show an folder non supported error in the notification bar when the file type is empty', () => {

View File

@ -16,8 +16,8 @@
*/
import { Component, ViewChild, Input, Output, EventEmitter } from '@angular/core';
import { AlfrescoTranslateService, LogService } from 'ng2-alfresco-core';
import { UploadService } from '../services/upload.service';
import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { FileModel } from '../models/file.model';
declare let componentHandler: any;
@ -62,7 +62,8 @@ export class UploadDragAreaComponent {
onSuccess = new EventEmitter();
constructor(private uploadService: UploadService,
private translateService: AlfrescoTranslateService) {
private translateService: AlfrescoTranslateService,
private logService: LogService) {
if (translateService) {
translateService.addTranslationFolder('ng2-alfresco-upload', 'node_modules/ng2-alfresco-upload/src');
}
@ -93,7 +94,7 @@ export class UploadDragAreaComponent {
if (this.showUdoNotificationBar) {
this.showErrorNotificationBar(errorMessage.value);
} else {
console.error(errorMessage.value);
this.logService.error(errorMessage.value);
}
}
}
@ -156,7 +157,7 @@ export class UploadDragAreaComponent {
if (this.showUdoNotificationBar) {
this.showErrorNotificationBar(errorMessage);
} else {
console.error(errorMessage);
this.logService.error(errorMessage);
}
}

View File

@ -226,7 +226,6 @@ describe('UploadService', () => {
service.addToQueue(filesFake);
service.uploadFilesInTheQueue('-root-', '', emitter);
console.log(jasmine.Ajax.requests.mostRecent().url);
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('autoRename=true')).toBe(false);
expect(jasmine.Ajax.requests.mostRecent().params.has('majorVersion')).toBe(true);
});

View File

@ -17,9 +17,8 @@
import { EventEmitter, Injectable } from '@angular/core';
import { Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import { Observer } from 'rxjs/Observer';
import { AlfrescoApiService } from 'ng2-alfresco-core';
import { Observer, Observable } from 'rxjs/Rx';
import { AlfrescoApiService, LogService } from 'ng2-alfresco-core';
import { FileModel } from '../models/file.model';
/**
@ -33,18 +32,16 @@ export class UploadService {
private formFields: Object = {};
private queue: FileModel[] = [];
private versioning: boolean = false;
private filesUploadObserverProgressBar: Observer<FileModel[]>;
private totalCompletedObserver: Observer<number>;
public totalCompleted: number = 0;
totalCompleted: number = 0;
filesUpload$: Observable<FileModel[]>;
totalCompleted$: Observable<any>;
constructor(private apiService: AlfrescoApiService) {
constructor(private apiService: AlfrescoApiService,
private logService: LogService) {
this.filesUpload$ = new Observable<FileModel[]>(observer => this.filesUploadObserverProgressBar = observer).share();
this.totalCompleted$ = new Observable<number>(observer => this.totalCompletedObserver = observer).share();
}
@ -56,7 +53,7 @@ export class UploadService {
* @param {boolean} - versioning true to indicate that a major version should be created
*
*/
public setOptions(options: any, versioning: boolean): void {
setOptions(options: any, versioning: boolean): void {
this.formFields = options.formFields != null ? options.formFields : this.formFields;
this.versioning = versioning != null ? versioning : this.versioning;
}
@ -87,7 +84,7 @@ export class UploadService {
/**
* Pick all the files in the queue that are not been uploaded yet and upload it into the directory folder.
*/
public uploadFilesInTheQueue(rootId: string, directory: string, elementEmit: EventEmitter<any>): void {
uploadFilesInTheQueue(rootId: string, directory: string, elementEmit: EventEmitter<any>): void {
let filesToUpload = this.queue.filter((uploadingFileModel) => {
return !uploadingFileModel.uploading && !uploadingFileModel.done && !uploadingFileModel.abort && !uploadingFileModel.error;
});
@ -169,7 +166,7 @@ export class UploadService {
.map(res => {
return res;
})
.do(data => console.log('Node data', data)) // eyeball results in the console
.do(data => this.logService.info('Node data', data)) // eyeball results in the console
.catch(this.handleError);
}
@ -185,7 +182,7 @@ export class UploadService {
private handleError(error: Response) {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console
console.error(error);
this.logService.error(error);
return Observable.throw(error || 'Server error');
}

View File

@ -19,9 +19,8 @@ import { NgModule, Component, OnInit } from '@angular/core';
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 { CoreModule, AuthService, SettingsService, LogService } from 'ng2-alfresco-core';
import { LoginModule } from 'ng2-alfresco-login';
import { AuthService, SettingsService } from 'ng2-alfresco-core';
@Component({
selector: 'alfresco-app-demo',
@ -74,26 +73,21 @@ import { AuthService, SettingsService } from 'ng2-alfresco-core';
})
class UserInfoDemo implements OnInit {
public ecmHost: string = 'http://localhost:8080';
public bpmHost: string = 'http://localhost:9999';
public userToLogin: string = 'admin';
public password: string = 'admin';
public loginErrorMessage: string;
public providers: string = 'BPM';
ecmHost: string = 'http://localhost:8080';
bpmHost: string = 'http://localhost:9999';
userToLogin: string = 'admin';
password: string = 'admin';
loginErrorMessage: string;
providers: string = 'BPM';
private authenticated: boolean;
private token: any;
public disableCsrf: boolean = false;
disableCsrf: boolean = false;
constructor(private authService: AuthService,
private settingsService: SettingsService) {
private settingsService: SettingsService,
private logService: LogService) {
settingsService.ecmHost = this.ecmHost;
settingsService.bpmHost = this.bpmHost;
}
@ -110,12 +104,12 @@ class UserInfoDemo implements OnInit {
this.settingsService.setProviders(this.providers);
this.authService.login(user, password).subscribe(
token => {
console.log(token);
this.logService.info(token);
this.token = token;
this.authenticated = true;
},
error => {
console.log(error);
this.logService.error(error);
this.authenticated = false;
this.loginErrorMessage = error;
});

View File

@ -15,10 +15,10 @@
* limitations under the License.
*/
import { AlfrescoApiService } from 'ng2-alfresco-core';
import { Injectable } from '@angular/core';
import { Response } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import { AlfrescoApiService, LogService } from 'ng2-alfresco-core';
import { BpmUserModel } from '../models/bpm-user.model';
/**
*
@ -29,7 +29,8 @@ import { BpmUserModel } from '../models/bpm-user.model';
@Injectable()
export class BpmUserService {
constructor(private alfrescoJsApi: AlfrescoApiService) {
constructor(private alfrescoJsApi: AlfrescoApiService,
private logService: LogService) {
}
/**
@ -54,7 +55,7 @@ export class BpmUserService {
private handleError(error: Response) {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console
console.error(error);
this.logService.error(error);
return Observable.throw(error || 'Server error');
}

Some files were not shown because too many files have changed in this diff Show More