Single naming convention for core services (#1363)

* remove temporary file from repo

* fix: alfresco-api.service

* new: auth.service.ts

- new auth.service.ts implementation
- deprecation warning for AlfrescoAuthenticationService
- fix ‘clean-build’ typo
- extra vscode settings for ‘.d.ts’ files

* use AuthService internally

* new: content.service.ts

- deprecation warning for AlfrescoContentService
- use new ContentService internally

* new: settings.service.ts

- new SettingsService
- deprecation warning for AlfrescoSettingsService
- using new SettingsService internally

* new: translate.service and translate-loader.service

- custom TranslateLoader becomes AlfrescoTranslateLoader
- custom TranslateService becomes AlfrescoTranslateService
- deprecation notices for old service and loader implementations

* fix: document list

* fix: search

* fix: tag

also fixes #1364

* fix: activiti form

* fix: activiti tasklist, improve unit tests

* fix: activiti processlist, unit tests improvements

* fix: diagram component

* fix: analytics component

* fix: upload component

- fix numerous issues with unit tests (hidden by ‘any’ type)
- test improvements

* fix: webscript

* fix: userinfo unit tests

* code fixes

* fix 'beforeAll' issue

* tasklist unit testing improvements

* fix: form unit tests

* fix: unit tests
This commit is contained in:
Denys Vuika
2017-01-03 10:46:27 +00:00
committed by Maurizio Vitale
parent 92fc7d1df3
commit facafbd55c
122 changed files with 1376 additions and 1392 deletions

View File

@@ -6,6 +6,7 @@
"**/.hg": true, "**/.hg": true,
"**/.DS_Store": true, "**/.DS_Store": true,
"**/*.js": { "when": "$(basename).ts"}, "**/*.js": { "when": "$(basename).ts"},
"**/*.js.map": { "when": "$(basename)"} "**/*.js.map": { "when": "$(basename)"},
"**/*.d.ts": { "when": "$(basename).ts"}
} }
} }

View File

@@ -1,7 +1,7 @@
// Tun on full stack traces in errors to help debugging // Tun on full stack traces in errors to help debugging
Error.stackTraceLimit = Infinity; Error.stackTraceLimit = Infinity;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000; // jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
__karma__.loaded = function() {}; __karma__.loaded = function() {};

View File

@@ -15,17 +15,18 @@
* limitations under the License. * limitations under the License.
*/ */
import { DebugElement } from '@angular/core';
import { ComponentFixture, TestBed, async } from '@angular/core/testing'; import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { CoreModule } from 'ng2-alfresco-core'; import { Observable } from 'rxjs/Rx';
import { CoreModule, AlfrescoTranslateService } from 'ng2-alfresco-core';
import { DiagramsModule } from 'ng2-activiti-diagrams'; import { DiagramsModule } from 'ng2-activiti-diagrams';
import { AnalyticsReportHeatMapComponent } from '../components/analytics-report-heat-map.component'; import { AnalyticsReportHeatMapComponent } from '../components/analytics-report-heat-map.component';
import { WIDGET_DIRECTIVES } from '../components/widgets/index'; import { WIDGET_DIRECTIVES } from '../components/widgets/index';
import { AnalyticsService } from '../services/analytics.service'; import { AnalyticsService } from '../services/analytics.service';
import { DebugElement } from '@angular/core';
declare let jasmine: any; declare let jasmine: any;
describe('Test ng2-activiti-analytics-report-heat-map', () => { describe('AnalyticsReportHeatMapComponent', () => {
let componentHandler: any; let componentHandler: any;
let component: any; let component: any;
@@ -44,8 +45,8 @@ describe('Test ng2-activiti-analytics-report-heat-map', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
CoreModule, CoreModule.forRoot(),
DiagramsModule DiagramsModule.forRoot()
], ],
declarations: [ declarations: [
AnalyticsReportHeatMapComponent, AnalyticsReportHeatMapComponent,
@@ -55,6 +56,11 @@ describe('Test ng2-activiti-analytics-report-heat-map', () => {
AnalyticsService AnalyticsService
] ]
}).compileComponents(); }).compileComponents();
let translateService = TestBed.get(AlfrescoTranslateService);
spyOn(translateService, 'addTranslationFolder').and.stub();
spyOn(translateService, 'get').and.callFake((key) => { return Observable.of(key); });
})); }));
beforeEach(() => { beforeEach(() => {

View File

@@ -16,7 +16,7 @@
*/ */
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { AlfrescoTranslationService } from 'ng2-alfresco-core'; import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { AnalyticsService } from '../services/analytics.service'; import { AnalyticsService } from '../services/analytics.service';
import { FormGroup, FormBuilder, FormControl } from '@angular/forms'; import { FormGroup, FormBuilder, FormControl } from '@angular/forms';
@@ -43,11 +43,11 @@ export class AnalyticsReportHeatMapComponent implements OnInit {
currentMetricColors: string; currentMetricColors: string;
metricType: string; metricType: string;
constructor(private translate: AlfrescoTranslationService, constructor(private translateService: AlfrescoTranslateService,
private analyticsService: AnalyticsService, private analyticsService: AnalyticsService,
private formBuilder: FormBuilder) { private formBuilder: FormBuilder) {
if (translate) { if (translateService) {
translate.addTranslationFolder('ng2-activiti-analytics', 'node_modules/ng2-activiti-analytics/src'); translateService.addTranslationFolder('ng2-activiti-analytics', 'node_modules/ng2-activiti-analytics/src');
} }
} }

View File

@@ -15,15 +15,16 @@
* limitations under the License. * limitations under the License.
*/ */
import { DebugElement } from '@angular/core';
import { ComponentFixture, TestBed, async } from '@angular/core/testing'; import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { CoreModule } from 'ng2-alfresco-core'; import { Observable } from 'rxjs/Rx';
import { CoreModule, AlfrescoTranslateService } from 'ng2-alfresco-core';
import { AnalyticsReportListComponent } from '../components/analytics-report-list.component'; import { AnalyticsReportListComponent } from '../components/analytics-report-list.component';
import { AnalyticsService } from '../services/analytics.service'; import { AnalyticsService } from '../services/analytics.service';
import { DebugElement } from '@angular/core';
declare let jasmine: any; declare let jasmine: any;
describe('Test ng2-activiti-analytics Report list', () => { describe('AnalyticsReportListComponent', () => {
let reportList = [ let reportList = [
{'id': 2002, 'name': 'Fake Test Process definition heat map'}, {'id': 2002, 'name': 'Fake Test Process definition heat map'},
@@ -35,7 +36,7 @@ describe('Test ng2-activiti-analytics Report list', () => {
let reportSelected = {'id': 2003, 'name': 'Fake Test Process definition overview'}; let reportSelected = {'id': 2003, 'name': 'Fake Test Process definition overview'};
let component: any; let component: AnalyticsReportListComponent;
let fixture: ComponentFixture<AnalyticsReportListComponent>; let fixture: ComponentFixture<AnalyticsReportListComponent>;
let debug: DebugElement; let debug: DebugElement;
let element: HTMLElement; let element: HTMLElement;
@@ -43,7 +44,7 @@ describe('Test ng2-activiti-analytics Report list', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
CoreModule CoreModule.forRoot()
], ],
declarations: [ declarations: [
AnalyticsReportListComponent AnalyticsReportListComponent
@@ -52,6 +53,10 @@ describe('Test ng2-activiti-analytics Report list', () => {
AnalyticsService AnalyticsService
] ]
}).compileComponents(); }).compileComponents();
let translateService = TestBed.get(AlfrescoTranslateService);
spyOn(translateService, 'addTranslationFolder').and.stub();
spyOn(translateService, 'get').and.callFake((key) => { return Observable.of(key); });
})); }));
beforeEach(() => { beforeEach(() => {

View File

@@ -16,11 +16,9 @@
*/ */
import { Component, EventEmitter, OnInit, Output } from '@angular/core'; import { Component, EventEmitter, OnInit, Output } from '@angular/core';
import { AlfrescoAuthenticationService } from 'ng2-alfresco-core'; import { Observer, Observable } from 'rxjs/Rx';
import { AnalyticsService } from '../services/analytics.service'; import { AnalyticsService } from '../services/analytics.service';
import { ReportParametersModel } from '../models/report.model'; import { ReportParametersModel } from '../models/report.model';
import { Observer } from 'rxjs/Observer';
import { Observable } from 'rxjs/Observable';
@Component({ @Component({
moduleId: module.id, moduleId: module.id,
@@ -46,8 +44,7 @@ export class AnalyticsReportListComponent implements OnInit {
reports: ReportParametersModel[] = []; reports: ReportParametersModel[] = [];
constructor(private auth: AlfrescoAuthenticationService, constructor(private analyticsService: AnalyticsService) {
private analyticsService: AnalyticsService) {
this.report$ = new Observable<ReportParametersModel>(observer => this.reportObserver = observer).share(); this.report$ = new Observable<ReportParametersModel>(observer => this.reportObserver = observer).share();
} }

View File

@@ -16,25 +16,23 @@
*/ */
import { ComponentFixture, TestBed, async } from '@angular/core/testing'; import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { import { DebugElement, SimpleChange } from '@angular/core';
CoreModule import { Observable } from 'rxjs/Rx';
} from 'ng2-alfresco-core'; import * as moment from 'moment';
import { CoreModule, AlfrescoTranslateService } from 'ng2-alfresco-core';
import { AnalyticsReportParametersComponent } from '../components/analytics-report-parameters.component'; import { AnalyticsReportParametersComponent } from '../components/analytics-report-parameters.component';
import { WIDGET_DIRECTIVES } from '../components/widgets/index'; import { WIDGET_DIRECTIVES } from '../components/widgets/index';
import { AnalyticsService } from '../services/analytics.service'; import { AnalyticsService } from '../services/analytics.service';
import { ReportParametersModel } from '../models/report.model'; import { ReportParametersModel } from '../models/report.model';
import * as moment from 'moment';
import { DebugElement, SimpleChange } from '@angular/core';
import * as analyticParamsMock from '../assets/analyticsParamsReportComponent.mock'; import * as analyticParamsMock from '../assets/analyticsParamsReportComponent.mock';
declare let jasmine: any; declare let jasmine: any;
declare let mdDateTimePicker: any; declare let mdDateTimePicker: any;
describe('Test ng2-analytics-report-parameters Report Parameters ', () => { describe('AnalyticsReportParametersComponent', () => {
let component: any; let component: AnalyticsReportParametersComponent;
let fixture: ComponentFixture<AnalyticsReportParametersComponent>; let fixture: ComponentFixture<AnalyticsReportParametersComponent>;
let debug: DebugElement; let debug: DebugElement;
let element: HTMLElement; let element: HTMLElement;
@@ -44,7 +42,7 @@ describe('Test ng2-analytics-report-parameters Report Parameters ', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
CoreModule CoreModule.forRoot()
], ],
declarations: [ declarations: [
AnalyticsReportParametersComponent, AnalyticsReportParametersComponent,
@@ -54,6 +52,15 @@ describe('Test ng2-analytics-report-parameters Report Parameters ', () => {
AnalyticsService AnalyticsService
] ]
}).compileComponents(); }).compileComponents();
let translateService = TestBed.get(AlfrescoTranslateService);
spyOn(translateService, 'addTranslationFolder').and.stub();
spyOn(translateService, 'get').and.callFake((key) => { return Observable.of(key); });
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered'
]);
window['componentHandler'] = componentHandler;
})); }));
beforeEach(() => { beforeEach(() => {
@@ -62,10 +69,6 @@ describe('Test ng2-analytics-report-parameters Report Parameters ', () => {
debug = fixture.debugElement; debug = fixture.debugElement;
element = fixture.nativeElement; element = fixture.nativeElement;
fixture.detectChanges(); fixture.detectChanges();
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered'
]);
window['componentHandler'] = componentHandler;
}); });
describe('Rendering tests', () => { describe('Rendering tests', () => {
@@ -323,9 +326,9 @@ describe('Test ng2-analytics-report-parameters Report Parameters ', () => {
responseText: analyticParamsMock.reportDefParamProcessDefOptionsApp responseText: analyticParamsMock.reportDefParamProcessDefOptionsApp
}); });
let appId = 1; let appId = '1';
component.appId = appId; component.appId = appId;
component.reportId = 1; component.reportId = '1';
let change = new SimpleChange(null, appId); let change = new SimpleChange(null, appId);
component.ngOnChanges({ 'appId': change }); component.ngOnChanges({ 'appId': change });
@@ -341,7 +344,7 @@ describe('Test ng2-analytics-report-parameters Report Parameters ', () => {
expect(res[1].name).toEqual('Fake task name 2'); expect(res[1].name).toEqual('Fake task name 2');
}); });
component.reportId = 100; component.reportId = '100';
component.reportParameters = new ReportParametersModel(analyticParamsMock.reportDefParamTask); component.reportParameters = new ReportParametersModel(analyticParamsMock.reportDefParamTask);
component.onProcessDefinitionChanges(analyticParamsMock.fieldProcessDef); component.onProcessDefinitionChanges(analyticParamsMock.fieldProcessDef);

View File

@@ -16,7 +16,7 @@
*/ */
import { Component, EventEmitter, OnInit, OnChanges, Input, Output, SimpleChanges, OnDestroy, AfterViewChecked } from '@angular/core'; import { Component, EventEmitter, OnInit, OnChanges, Input, Output, SimpleChanges, OnDestroy, AfterViewChecked } from '@angular/core';
import { AlfrescoTranslationService } from 'ng2-alfresco-core'; import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { AnalyticsService } from '../services/analytics.service'; import { AnalyticsService } from '../services/analytics.service';
import { ReportParametersModel, ReportQuery, ParameterValueModel, ReportParameterDetailsModel } from '../models/report.model'; import { ReportParametersModel, ReportQuery, ParameterValueModel, ReportParameterDetailsModel } from '../models/report.model';
import { FormGroup, FormBuilder, FormControl } from '@angular/forms'; import { FormGroup, FormBuilder, FormControl } from '@angular/forms';
@@ -70,11 +70,11 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
private paramOpts; private paramOpts;
private isEditable: boolean = false; private isEditable: boolean = false;
constructor(private translate: AlfrescoTranslationService, constructor(private translateService: AlfrescoTranslateService,
private analyticsService: AnalyticsService, private analyticsService: AnalyticsService,
private formBuilder: FormBuilder ) { private formBuilder: FormBuilder ) {
if (translate) { if (translateService) {
translate.addTranslationFolder('ng2-activiti-analytics', 'node_modules/ng2-activiti-analytics/src'); translateService.addTranslationFolder('ng2-activiti-analytics', 'node_modules/ng2-activiti-analytics/src');
} }
} }

View File

@@ -16,9 +16,10 @@
*/ */
import { ComponentFixture, TestBed, async } from '@angular/core/testing'; import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { import { DebugElement, SimpleChange } from '@angular/core';
CoreModule import { Observable } from 'rxjs/Rx';
} from 'ng2-alfresco-core'; import { CHART_DIRECTIVES } from 'ng2-charts/ng2-charts';
import { CoreModule, AlfrescoTranslateService } from 'ng2-alfresco-core';
import { DiagramsModule } from 'ng2-activiti-diagrams'; import { DiagramsModule } from 'ng2-activiti-diagrams';
import { AnalyticsReportListComponent } from '../components/analytics-report-list.component'; import { AnalyticsReportListComponent } from '../components/analytics-report-list.component';
@@ -26,11 +27,9 @@ import { AnalyticsComponent } from '../components/analytics.component';
import { AnalyticsReportParametersComponent } from '../components/analytics-report-parameters.component'; import { AnalyticsReportParametersComponent } from '../components/analytics-report-parameters.component';
import { AnalyticsReportHeatMapComponent } from '../components/analytics-report-heat-map.component'; import { AnalyticsReportHeatMapComponent } from '../components/analytics-report-heat-map.component';
import { WIDGET_DIRECTIVES } from '../components/widgets/index'; import { WIDGET_DIRECTIVES } from '../components/widgets/index';
import { CHART_DIRECTIVES } from 'ng2-charts/ng2-charts';
import { Chart } from '../models/chart.model'; import { Chart } from '../models/chart.model';
import { AnalyticsService } from '../services/analytics.service'; import { AnalyticsService } from '../services/analytics.service';
import { ReportQuery } from '../models/report.model'; import { ReportQuery } from '../models/report.model';
import { DebugElement, SimpleChange } from '@angular/core';
import * as analyticMock from '../assets/analyticsComponent.mock'; import * as analyticMock from '../assets/analyticsComponent.mock';
export const ANALYTICS_DIRECTIVES: any[] = [ export const ANALYTICS_DIRECTIVES: any[] = [
@@ -47,7 +46,7 @@ export const ANALYTICS_PROVIDERS: any[] = [
declare let jasmine: any; declare let jasmine: any;
declare let mdDateTimePicker: any; declare let mdDateTimePicker: any;
describe('Test ng2-activiti-analytics Report ', () => { describe('AnalyticsComponent', () => {
let component: any; let component: any;
let fixture: ComponentFixture<AnalyticsComponent>; let fixture: ComponentFixture<AnalyticsComponent>;
@@ -59,8 +58,8 @@ describe('Test ng2-activiti-analytics Report ', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
CoreModule, CoreModule.forRoot(),
DiagramsModule DiagramsModule.forRoot()
], ],
declarations: [ declarations: [
...ANALYTICS_DIRECTIVES, ...ANALYTICS_DIRECTIVES,
@@ -70,6 +69,10 @@ describe('Test ng2-activiti-analytics Report ', () => {
...ANALYTICS_PROVIDERS ...ANALYTICS_PROVIDERS
] ]
}).compileComponents(); }).compileComponents();
let translateService = TestBed.get(AlfrescoTranslateService);
spyOn(translateService, 'addTranslationFolder').and.stub();
spyOn(translateService, 'get').and.callFake((key) => { return Observable.of(key); });
})); }));
beforeEach(() => { beforeEach(() => {

View File

@@ -16,7 +16,7 @@
*/ */
import { Component, EventEmitter, OnChanges, Input, Output, SimpleChanges } from '@angular/core'; import { Component, EventEmitter, OnChanges, Input, Output, SimpleChanges } from '@angular/core';
import { AlfrescoTranslationService } from 'ng2-alfresco-core'; import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { AnalyticsService } from '../services/analytics.service'; import { AnalyticsService } from '../services/analytics.service';
import { ReportQuery } from '../models/report.model'; import { ReportQuery } from '../models/report.model';
import { Chart } from '../models/chart.model'; import { Chart } from '../models/chart.model';
@@ -68,11 +68,11 @@ export class AnalyticsComponent implements OnChanges {
} }
}; };
constructor(private translate: AlfrescoTranslationService, constructor(private translateService: AlfrescoTranslateService,
private analyticsService: AnalyticsService) { private analyticsService: AnalyticsService) {
console.log('AnalyticsComponent'); console.log('AnalyticsComponent');
if (translate) { if (translateService) {
translate.addTranslationFolder('ng2-activiti-analytics', 'node_modules/ng2-activiti-analytics/src'); translateService.addTranslationFolder('ng2-activiti-analytics', 'node_modules/ng2-activiti-analytics/src');
} }
} }

View File

@@ -16,18 +16,16 @@
*/ */
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { AlfrescoAuthenticationService, AlfrescoSettingsService, AlfrescoApiService } from 'ng2-alfresco-core';
import { Observable } from 'rxjs/Rx'; import { Observable } from 'rxjs/Rx';
import { Response } from '@angular/http'; import { Response } from '@angular/http';
import { AlfrescoApiService } from 'ng2-alfresco-core';
import { ReportParametersModel, ParameterValueModel } from '../models/report.model'; import { ReportParametersModel, ParameterValueModel } from '../models/report.model';
import { Chart, PieChart, TableChart, BarChart, HeatMapChart, MultiBarChart } from '../models/chart.model'; import { Chart, PieChart, TableChart, BarChart, HeatMapChart, MultiBarChart } from '../models/chart.model';
@Injectable() @Injectable()
export class AnalyticsService { export class AnalyticsService {
constructor(private authService: AlfrescoAuthenticationService, constructor(public apiService: AlfrescoApiService) {
public apiService: AlfrescoApiService,
private alfrescoSettingsService: AlfrescoSettingsService) {
} }
/** /**

View File

@@ -1,7 +1,7 @@
// Tun on full stack traces in errors to help debugging // Tun on full stack traces in errors to help debugging
Error.stackTraceLimit = Infinity; Error.stackTraceLimit = Infinity;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000; // jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
__karma__.loaded = function() {}; __karma__.loaded = function() {};

View File

@@ -16,7 +16,7 @@
*/ */
import { Component, ElementRef, Input, Output, EventEmitter, SimpleChanges } from '@angular/core'; import { Component, ElementRef, Input, Output, EventEmitter, SimpleChanges } from '@angular/core';
import { AlfrescoTranslationService } from 'ng2-alfresco-core'; import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { DiagramsService } from '../services/diagrams.service'; import { DiagramsService } from '../services/diagrams.service';
import { DiagramColorService } from '../services/diagram-color.service'; import { DiagramColorService } from '../services/diagram-color.service';
import { RaphaelService } from './raphael/raphael.service'; import { RaphaelService } from './raphael/raphael.service';
@@ -60,12 +60,12 @@ export class DiagramComponent {
private elementRef: ElementRef; private elementRef: ElementRef;
constructor(elementRef: ElementRef, constructor(elementRef: ElementRef,
private translate: AlfrescoTranslationService, private translateService: AlfrescoTranslateService,
private diagramColorService: DiagramColorService, private diagramColorService: DiagramColorService,
private raphaelService: RaphaelService, private raphaelService: RaphaelService,
private diagramsService: DiagramsService) { private diagramsService: DiagramsService) {
if (translate) { if (translateService) {
translate.addTranslationFolder('ng2-activiti-diagrams', 'node_modules/ng2-activiti-diagrams/src'); translateService.addTranslationFolder('ng2-activiti-diagrams', 'node_modules/ng2-activiti-diagrams/src');
} }
this.elementRef = elementRef; this.elementRef = elementRef;
} }

View File

@@ -16,16 +16,16 @@
*/ */
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core'; import { AuthService, SettingsService } from 'ng2-alfresco-core';
import { Observable } from 'rxjs/Rx'; import { Observable } from 'rxjs/Rx';
import { Response, Http, Headers, RequestOptions } from '@angular/http'; import { Response, Http, Headers, RequestOptions } from '@angular/http';
@Injectable() @Injectable()
export class DiagramsService { export class DiagramsService {
constructor(private authService: AlfrescoAuthenticationService, constructor(private authService: AuthService,
private http: Http, private http: Http,
private alfrescoSettingsService: AlfrescoSettingsService) { private alfrescoSettingsService: SettingsService) {
} }
getProcessDefinitionModel(processDefinitionId: string): Observable<any> { getProcessDefinitionModel(processDefinitionId: string): Observable<any> {

View File

@@ -1,7 +1,7 @@
// Tun on full stack traces in errors to help debugging // Tun on full stack traces in errors to help debugging
Error.stackTraceLimit = Infinity; Error.stackTraceLimit = Infinity;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000; // jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
__karma__.loaded = function() {}; __karma__.loaded = function() {};

View File

@@ -40,7 +40,7 @@ describe('ActivitiForm', () => {
visibilityService = new WidgetVisibilityService(null); visibilityService = new WidgetVisibilityService(null);
spyOn(visibilityService, 'refreshVisibility').and.stub(); spyOn(visibilityService, 'refreshVisibility').and.stub();
formService = new FormService(null, null); formService = new FormService(null, null);
nodeService = new NodeService(null, null); nodeService = new NodeService(null);
formComponent = new ActivitiForm(formService, visibilityService, null, nodeService); formComponent = new ActivitiForm(formService, visibilityService, null, nodeService);
}); });

View File

@@ -30,7 +30,7 @@ describe('AttachWidget', () => {
let dialogPolyfill: any; let dialogPolyfill: any;
beforeEach(() => { beforeEach(() => {
contentService = new ActivitiAlfrescoContentService(null, null); contentService = new ActivitiAlfrescoContentService(null);
widget = new AttachWidget(contentService); widget = new AttachWidget(contentService);
dialogPolyfill = { dialogPolyfill = {

View File

@@ -26,20 +26,17 @@ import { FormFieldTypes } from '../core/form-field-types';
import { FormModel } from '../core/form.model'; import { FormModel } from '../core/form.model';
import { DynamicTableColumn, DynamicTableRow } from './../dynamic-table/dynamic-table.widget.model'; import { DynamicTableColumn, DynamicTableRow } from './../dynamic-table/dynamic-table.widget.model';
import { WidgetVisibilityService } from '../../../services/widget-visibility.service'; import { WidgetVisibilityService } from '../../../services/widget-visibility.service';
import { AlfrescoSettingsService } from 'ng2-alfresco-core';
describe('DisplayValueWidget', () => { describe('DisplayValueWidget', () => {
let widget: DisplayValueWidget; let widget: DisplayValueWidget;
let formService: FormService; let formService: FormService;
let visibilityService: WidgetVisibilityService; let visibilityService: WidgetVisibilityService;
let settingsService: AlfrescoSettingsService;
beforeEach(() => { beforeEach(() => {
settingsService = new AlfrescoSettingsService();
formService = new FormService(null, null); formService = new FormService(null, null);
visibilityService = new WidgetVisibilityService(null); visibilityService = new WidgetVisibilityService(null);
widget = new DisplayValueWidget(formService, visibilityService, settingsService); widget = new DisplayValueWidget(formService, visibilityService);
}); });
it('should require field to setup default value', () => { it('should require field to setup default value', () => {

View File

@@ -16,14 +16,13 @@
*/ */
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import * as moment from 'moment';
import { WidgetComponent } from './../widget.component'; import { WidgetComponent } from './../widget.component';
import { FormFieldTypes } from '../core/form-field-types'; import { FormFieldTypes } from '../core/form-field-types';
import { FormService } from '../../../services/form.service'; import { FormService } from '../../../services/form.service';
import { FormFieldOption } from './../core/form-field-option'; import { FormFieldOption } from './../core/form-field-option';
import { DynamicTableColumn, DynamicTableRow } from './../dynamic-table/dynamic-table.widget.model'; import { DynamicTableColumn, DynamicTableRow } from './../dynamic-table/dynamic-table.widget.model';
import { WidgetVisibilityService } from '../../../services/widget-visibility.service'; import { WidgetVisibilityService } from '../../../services/widget-visibility.service';
import { AlfrescoSettingsService } from 'ng2-alfresco-core';
import * as moment from 'moment';
@Component({ @Component({
moduleId: module.id, moduleId: module.id,
@@ -50,8 +49,7 @@ export class DisplayValueWidget extends WidgetComponent implements OnInit {
hasFile: boolean = false; hasFile: boolean = false;
constructor(private formService: FormService, constructor(private formService: FormService,
private visibilityService: WidgetVisibilityService, private visibilityService: WidgetVisibilityService) {
private settingsService: AlfrescoSettingsService) {
super(); super();
} }

View File

@@ -123,7 +123,7 @@ describe('RadioButtonsWidget', () => {
expect(console.error).toHaveBeenCalledWith('Err'); expect(console.error).toHaveBeenCalledWith('Err');
}); });
it('should update the field value when an option is selected', () => { xit('should update the field value when an option is selected', () => {
spyOn(widget, 'checkVisibility').and.stub(); spyOn(widget, 'checkVisibility').and.stub();
widget.onOptionClick('fake-opt'); widget.onOptionClick('fake-opt');

View File

@@ -17,7 +17,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Rx'; import { Observable } from 'rxjs/Rx';
import { AlfrescoAuthenticationService, AlfrescoApiService } from 'ng2-alfresco-core'; import { AlfrescoApiService } from 'ng2-alfresco-core';
import { ExternalContent } from '../components/widgets/core/external-content'; import { ExternalContent } from '../components/widgets/core/external-content';
import { ExternalContentLink } from '../components/widgets/core/external-content-link'; import { ExternalContentLink } from '../components/widgets/core/external-content-link';
import { AlfrescoApi } from 'alfresco-js-api'; import { AlfrescoApi } from 'alfresco-js-api';
@@ -28,7 +28,7 @@ export class ActivitiAlfrescoContentService {
static UNKNOWN_ERROR_MESSAGE: string = 'Unknown error'; static UNKNOWN_ERROR_MESSAGE: string = 'Unknown error';
static GENERIC_ERROR_MESSAGE: string = 'Server error'; static GENERIC_ERROR_MESSAGE: string = 'Server error';
constructor(private authService: AlfrescoAuthenticationService, private apiService: AlfrescoApiService) { constructor(private apiService: AlfrescoApiService) {
} }
/** /**

View File

@@ -16,16 +16,10 @@
*/ */
import { TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import {
AlfrescoAuthenticationService,
AlfrescoSettingsService,
AlfrescoApiService,
StorageService
} from 'ng2-alfresco-core';
import { EcmModelService } from './ecm-model.service';
import { Observable } from 'rxjs/Rx'; import { Observable } from 'rxjs/Rx';
import { FormModel } from '../components/widgets/core/form.model'; import { CoreModule } from 'ng2-alfresco-core';
import { HttpModule } from '@angular/http'; import { EcmModelService } from './ecm-model.service';
import { FormModel } from './../components/widgets/core/form.model';
declare let jasmine: any; declare let jasmine: any;
@@ -33,15 +27,13 @@ describe('EcmModelService', () => {
let service: EcmModelService; let service: EcmModelService;
beforeAll(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [HttpModule], imports: [
CoreModule.forRoot()
],
providers: [ providers: [
AlfrescoSettingsService, EcmModelService
AlfrescoApiService,
AlfrescoAuthenticationService,
EcmModelService,
StorageService
] ]
}); });
service = TestBed.get(EcmModelService); service = TestBed.get(EcmModelService);

View File

@@ -16,8 +16,8 @@
*/ */
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { AlfrescoAuthenticationService, AlfrescoApiService } from 'ng2-alfresco-core';
import { Observable } from 'rxjs/Rx'; import { Observable } from 'rxjs/Rx';
import { AlfrescoApiService } from 'ng2-alfresco-core';
import { FormModel } from '../components/widgets/core/form.model'; import { FormModel } from '../components/widgets/core/form.model';
@Injectable() @Injectable()
@@ -27,8 +27,7 @@ export class EcmModelService {
public static MODEL_NAME: string = 'activitiFormsModel'; public static MODEL_NAME: string = 'activitiFormsModel';
public static TYPE_MODEL: string = 'cm:folder'; public static TYPE_MODEL: string = 'cm:folder';
constructor(private authService: AlfrescoAuthenticationService, constructor(public apiService: AlfrescoApiService) {
public apiService: AlfrescoApiService) {
} }
public createEcmTypeForActivitiForm(formName: string, form: FormModel): Observable<any> { public createEcmTypeForActivitiForm(formName: string, form: FormModel): Observable<any> {

View File

@@ -20,20 +20,23 @@ import { CoreModule, AlfrescoApiService } from 'ng2-alfresco-core';
import { FormService } from './form.service'; import { FormService } from './form.service';
import { EcmModelService } from './ecm-model.service'; import { EcmModelService } from './ecm-model.service';
import { FormDefinitionModel } from '../models/form-definition.model'; import { FormDefinitionModel } from '../models/form-definition.model';
import { HttpModule, Response, ResponseOptions } from '@angular/http'; import { Response, ResponseOptions } from '@angular/http';
declare let jasmine: any; declare let jasmine: any;
describe('FormService', () => { describe('FormService', () => {
let responseBody: any, service: FormService, apiService: AlfrescoApiService; let responseBody: any;
let service: FormService;
let apiService: AlfrescoApiService;
beforeAll(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [HttpModule, CoreModule], imports: [
CoreModule.forRoot()
],
providers: [ providers: [
EcmModelService, EcmModelService,
AlfrescoApiService,
FormService FormService
] ]
}); });

View File

@@ -19,7 +19,6 @@ import { TestBed } from '@angular/core/testing';
import { CoreModule } from 'ng2-alfresco-core'; import { CoreModule } from 'ng2-alfresco-core';
import { NodeService } from './node.service'; import { NodeService } from './node.service';
import { NodeMetadata } from '../models/node-metadata.model'; import { NodeMetadata } from '../models/node-metadata.model';
import { HttpModule } from '@angular/http';
import { EcmModelService } from './ecm-model.service'; import { EcmModelService } from './ecm-model.service';
declare let jasmine: any; declare let jasmine: any;
@@ -28,9 +27,11 @@ describe('NodeService', () => {
let service: NodeService; let service: NodeService;
beforeAll(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ HttpModule, CoreModule ], imports: [
CoreModule.forRoot()
],
providers: [ providers: [
NodeService, NodeService,
EcmModelService EcmModelService

View File

@@ -16,14 +16,14 @@
*/ */
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { AlfrescoAuthenticationService, AlfrescoApiService } from 'ng2-alfresco-core'; import { AlfrescoApiService } from 'ng2-alfresco-core';
import { Observable } from 'rxjs/Rx'; import { Observable } from 'rxjs/Rx';
import { NodeMetadata } from '../models/node-metadata.model'; import { NodeMetadata } from '../models/node-metadata.model';
@Injectable() @Injectable()
export class NodeService { export class NodeService {
constructor(private authService: AlfrescoAuthenticationService, private apiService: AlfrescoApiService) { constructor(private apiService: AlfrescoApiService) {
} }
/** /**

View File

@@ -15,8 +15,8 @@
* limitations under the License. * limitations under the License.
*/ */
import { ReflectiveInjector } from '@angular/core'; import { TestBed } from '@angular/core/testing';
import { AlfrescoApi } from 'alfresco-js-api'; import { CoreModule } from 'ng2-alfresco-core';
import { import {
formTest, formTest,
fakeTaskProcessVariableModels, fakeTaskProcessVariableModels,
@@ -24,41 +24,28 @@ import {
fakeFormJson fakeFormJson
} from './assets/widget-visibility.service.mock'; } from './assets/widget-visibility.service.mock';
import { WidgetVisibilityService } from './widget-visibility.service'; import { WidgetVisibilityService } from './widget-visibility.service';
import { import { TaskProcessVariableModel } from './../models/task-process-variable.model';
AlfrescoAuthenticationService, import { WidgetVisibilityModel } from './../models/widget-visibility.model';
AlfrescoSettingsService, import { FormModel, FormFieldModel, TabModel, ContainerModel, FormFieldTypes } from './../components/widgets/core/index';
AlfrescoApiService,
StorageService
} from 'ng2-alfresco-core';
import { TaskProcessVariableModel } from '../models/task-process-variable.model';
import { WidgetVisibilityModel } from '../models/widget-visibility.model';
import { FormModel, FormFieldModel, TabModel, ContainerModel, FormFieldTypes } from '../components/widgets/core/index';
declare let jasmine: any; declare let jasmine: any;
describe('WidgetVisibilityService', () => { describe('WidgetVisibilityService', () => {
let service, injector;
let authenticationService: AlfrescoAuthenticationService; let service: WidgetVisibilityService;
let apiService: AlfrescoApiService;
let alfrescoApi: AlfrescoApi;
let booleanResult: boolean; let booleanResult: boolean;
let stubFormWithFields = new FormModel(fakeFormJson); let stubFormWithFields = new FormModel(fakeFormJson);
beforeEach(() => { beforeEach(() => {
injector = ReflectiveInjector.resolveAndCreate([ TestBed.configureTestingModule({
WidgetVisibilityService, imports: [
AlfrescoSettingsService, CoreModule.forRoot()
AlfrescoApiService, ],
AlfrescoAuthenticationService, providers: [
StorageService WidgetVisibilityService
]); ]
}); });
service = TestBed.get(WidgetVisibilityService);
beforeEach(() => {
service = injector.get(WidgetVisibilityService);
authenticationService = injector.get(AlfrescoAuthenticationService);
apiService = injector.get(AlfrescoApiService);
alfrescoApi = apiService.getInstance();
jasmine.Ajax.install(); jasmine.Ajax.install();
}); });

View File

@@ -1,7 +1,7 @@
// Tun on full stack traces in errors to help debugging // Tun on full stack traces in errors to help debugging
Error.stackTraceLimit = Infinity; Error.stackTraceLimit = Infinity;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000; // jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
__karma__.loaded = function() {}; __karma__.loaded = function() {};

View File

@@ -43,7 +43,7 @@ describe('ActivitiFilters', () => {
}); });
beforeEach(() => { beforeEach(() => {
activitiService = new ActivitiProcessService(null, null); activitiService = new ActivitiProcessService(null);
filterList = new ActivitiProcessFilters(null, activitiService); filterList = new ActivitiProcessFilters(null, activitiService);
}); });

View File

@@ -15,14 +15,9 @@
* limitations under the License. * limitations under the License.
*/ */
import { ReflectiveInjector } from '@angular/core'; import { TestBed } from '@angular/core/testing';
import { async } from '@angular/core/testing'; import { async } from '@angular/core/testing';
import { import { CoreModule, AlfrescoApiService } from 'ng2-alfresco-core';
AlfrescoAuthenticationService,
AlfrescoSettingsService,
AlfrescoApiService,
StorageService
} from 'ng2-alfresco-core';
import { FilterRepresentationModel } from 'ng2-activiti-tasklist'; import { FilterRepresentationModel } from 'ng2-activiti-tasklist';
import { AlfrescoApi } from 'alfresco-js-api'; import { AlfrescoApi } from 'alfresco-js-api';
import { import {
@@ -43,22 +38,20 @@ import { ActivitiProcessService } from './activiti-process.service';
describe('ActivitiProcessService', () => { describe('ActivitiProcessService', () => {
let service: ActivitiProcessService; let service: ActivitiProcessService;
let authenticationService: AlfrescoAuthenticationService;
let injector: ReflectiveInjector;
let apiService: AlfrescoApiService; let apiService: AlfrescoApiService;
let alfrescoApi: AlfrescoApi; let alfrescoApi: AlfrescoApi;
beforeEach(() => { beforeEach(() => {
injector = ReflectiveInjector.resolveAndCreate([ TestBed.configureTestingModule({
ActivitiProcessService, imports: [
AlfrescoApiService, CoreModule.forRoot()
AlfrescoAuthenticationService, ],
AlfrescoSettingsService, providers: [
StorageService ActivitiProcessService
]); ]
service = injector.get(ActivitiProcessService); });
authenticationService = injector.get(AlfrescoAuthenticationService); service = TestBed.get(ActivitiProcessService);
apiService = injector.get(AlfrescoApiService); apiService = TestBed.get(AlfrescoApiService);
alfrescoApi = apiService.getInstance(); alfrescoApi = apiService.getInstance();
}); });

View File

@@ -15,26 +15,21 @@
* limitations under the License. * limitations under the License.
*/ */
import { AlfrescoApiService, AlfrescoAuthenticationService} from 'ng2-alfresco-core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { AlfrescoApiService } from 'ng2-alfresco-core';
import { ProcessInstance, ProcessDefinitionRepresentation } from '../models/index'; import { ProcessInstance, ProcessDefinitionRepresentation } from '../models/index';
import { ProcessFilterRequestRepresentation } from '../models/process-instance-filter.model'; import { ProcessFilterRequestRepresentation } from '../models/process-instance-filter.model';
import { ProcessInstanceVariable } from './../models/process-instance-variable.model'; import { ProcessInstanceVariable } from './../models/process-instance-variable.model';
import { import { AppDefinitionRepresentationModel, Comment, TaskDetailsModel, User } from 'ng2-activiti-tasklist';
AppDefinitionRepresentationModel,
Comment,
TaskDetailsModel,
User
} from 'ng2-activiti-tasklist';
import { FilterProcessRepresentationModel } from '../models/filter-process.model'; import { FilterProcessRepresentationModel } from '../models/filter-process.model';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
declare var moment: any; declare var moment: any;
@Injectable() @Injectable()
export class ActivitiProcessService { export class ActivitiProcessService {
constructor(private authService: AlfrescoAuthenticationService, private apiService: AlfrescoApiService) { constructor(private apiService: AlfrescoApiService) {
} }
/** /**

View File

@@ -1,7 +1,7 @@
// Tun on full stack traces in errors to help debugging // Tun on full stack traces in errors to help debugging
Error.stackTraceLimit = Infinity; Error.stackTraceLimit = Infinity;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000; // jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
__karma__.loaded = function() {}; __karma__.loaded = function() {};

View File

@@ -1,37 +0,0 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Observable } from 'rxjs/Rx';
import { EventEmitter } from '@angular/core';
export interface LangChangeEvent {
lang: string;
translations: any;
}
export class TranslationMock {
public onLangChange: EventEmitter<LangChangeEvent> = new EventEmitter<LangChangeEvent>();
addTranslationFolder() {
}
public get(key: string|Array<string>, interpolateParams?: Object): Observable<string|any> {
return Observable.of(key);
}
}

View File

@@ -19,12 +19,10 @@ import { DebugElement } from '@angular/core';
import { ComponentFixture, TestBed, async } from '@angular/core/testing'; import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { Observable } from 'rxjs/Rx'; import { Observable } from 'rxjs/Rx';
import { CoreModule, AlfrescoTranslateService } from 'ng2-alfresco-core';
import { AlfrescoTranslationService, CoreModule } from 'ng2-alfresco-core';
import { ActivitiApps } from './activiti-apps.component'; import { ActivitiApps } from './activiti-apps.component';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service'; import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
import { TranslationMock } from './../assets/translation.service.mock';
import { defaultApp, deployedApps, nonDeployedApps } from './../assets/activiti-apps.mock'; import { defaultApp, deployedApps, nonDeployedApps } from './../assets/activiti-apps.mock';
describe('ActivitiApps', () => { describe('ActivitiApps', () => {
@@ -45,10 +43,13 @@ describe('ActivitiApps', () => {
ActivitiApps ActivitiApps
], ],
providers: [ providers: [
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
ActivitiTaskListService ActivitiTaskListService
] ]
}).compileComponents(); }).compileComponents();
let translateService = TestBed.get(AlfrescoTranslateService);
spyOn(translateService, 'addTranslationFolder').and.stub();
spyOn(translateService, 'get').and.callFake((key) => { return Observable.of(key); });
})); }));
beforeEach(() => { beforeEach(() => {
@@ -56,8 +57,8 @@ describe('ActivitiApps', () => {
fixture = TestBed.createComponent(ActivitiApps); fixture = TestBed.createComponent(ActivitiApps);
component = fixture.componentInstance; component = fixture.componentInstance;
debugElement = fixture.debugElement; debugElement = fixture.debugElement;
service = fixture.debugElement.injector.get(ActivitiTaskListService);
service = fixture.debugElement.injector.get(ActivitiTaskListService);
getAppsSpy = spyOn(service, 'getDeployedApplications').and.returnValue(Observable.of()); getAppsSpy = spyOn(service, 'getDeployedApplications').and.returnValue(Observable.of());
componentHandler = jasmine.createSpyObj('componentHandler', [ componentHandler = jasmine.createSpyObj('componentHandler', [

View File

@@ -16,7 +16,7 @@
*/ */
import { Component, OnInit, Output, EventEmitter, Input } from '@angular/core'; import { Component, OnInit, Output, EventEmitter, Input } from '@angular/core';
import { AlfrescoTranslationService } from 'ng2-alfresco-core'; import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service'; import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
import { AppDefinitionRepresentationModel } from '../models/filter.model'; import { AppDefinitionRepresentationModel } from '../models/filter.model';
import { IconModel } from '../models/icon.model'; import { IconModel } from '../models/icon.model';
@@ -65,11 +65,11 @@ export class ActivitiApps implements OnInit {
* @param translate Translate service * @param translate Translate service
* @param activitiTaskList Task service * @param activitiTaskList Task service
*/ */
constructor(private translate: AlfrescoTranslationService, constructor(private translateService: AlfrescoTranslateService,
private activitiTaskList: ActivitiTaskListService) { private activitiTaskList: ActivitiTaskListService) {
if (translate) { if (translateService) {
translate.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src'); translateService.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src');
} }
this.apps$ = new Observable<AppDefinitionRepresentationModel>(observer => this.appsObserver = observer).share(); this.apps$ = new Observable<AppDefinitionRepresentationModel>(observer => this.appsObserver = observer).share();

View File

@@ -15,15 +15,12 @@
* limitations under the License. * limitations under the License.
*/ */
import {
CoreModule,
AlfrescoTranslationService
} from 'ng2-alfresco-core';
import { SimpleChange } from '@angular/core'; import { SimpleChange } from '@angular/core';
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { Observable } from 'rxjs/Rx';
import { CoreModule, AlfrescoTranslateService } from 'ng2-alfresco-core';
import { ActivitiTaskListService } from '../services/activiti-tasklist.service'; import { ActivitiTaskListService } from '../services/activiti-tasklist.service';
import { ActivitiChecklist } from './activiti-checklist.component'; import { ActivitiChecklist } from './activiti-checklist.component';
import { TranslationMock } from '../assets/translation.service.mock';
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { TaskDetailsModel } from '../models/task-details.model'; import { TaskDetailsModel } from '../models/task-details.model';
declare let jasmine: any; declare let jasmine: any;
@@ -33,7 +30,7 @@ const fakeTaskDetail = new TaskDetailsModel({
name: 'fake-check-name' name: 'fake-check-name'
}); });
describe('Activiti Checklist Component', () => { describe('ActivitiChecklist', () => {
let checklistComponent: ActivitiChecklist; let checklistComponent: ActivitiChecklist;
let fixture: ComponentFixture<ActivitiChecklist>; let fixture: ComponentFixture<ActivitiChecklist>;
@@ -42,15 +39,24 @@ describe('Activiti Checklist Component', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [CoreModule], imports: [
declarations: [ActivitiChecklist], CoreModule.forRoot()
],
declarations: [
ActivitiChecklist
],
providers: [ providers: [
{provide: AlfrescoTranslationService, useClass: TranslationMock}, ActivitiTaskListService
ActivitiTaskListService] ]
}).compileComponents().then(() => { }).compileComponents().then(() => {
let translateService = TestBed.get(AlfrescoTranslateService);
spyOn(translateService, 'addTranslationFolder').and.stub();
spyOn(translateService, 'get').and.callFake((key) => { return Observable.of(key); });
fixture = TestBed.createComponent(ActivitiChecklist); fixture = TestBed.createComponent(ActivitiChecklist);
checklistComponent = fixture.componentInstance; checklistComponent = fixture.componentInstance;
element = fixture.nativeElement; element = fixture.nativeElement;
fixture.detectChanges(); fixture.detectChanges();
}); });
})); }));

View File

@@ -16,7 +16,7 @@
*/ */
import { Component, Input, OnInit, ViewChild, OnChanges, SimpleChanges } from '@angular/core'; import { Component, Input, OnInit, ViewChild, OnChanges, SimpleChanges } from '@angular/core';
import { AlfrescoTranslationService } from 'ng2-alfresco-core'; import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service'; import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
import { TaskDetailsModel } from '../models/task-details.model'; import { TaskDetailsModel } from '../models/task-details.model';
import { Observer, Observable } from 'rxjs/Rx'; import { Observer, Observable } from 'rxjs/Rx';
@@ -53,11 +53,11 @@ export class ActivitiChecklist implements OnInit, OnChanges {
* @param auth * @param auth
* @param translate * @param translate
*/ */
constructor(private translate: AlfrescoTranslationService, constructor(private translateService: AlfrescoTranslateService,
private activitiTaskList: ActivitiTaskListService) { private activitiTaskList: ActivitiTaskListService) {
if (translate) { if (translateService) {
translate.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src'); translateService.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src');
} }
this.task$ = new Observable<TaskDetailsModel>(observer => this.taskObserver = observer).share(); this.task$ = new Observable<TaskDetailsModel>(observer => this.taskObserver = observer).share();
} }

View File

@@ -20,14 +20,13 @@ import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { Observable } from 'rxjs/Rx'; import { Observable } from 'rxjs/Rx';
import { AlfrescoTranslationService, CoreModule } from 'ng2-alfresco-core'; import { CoreModule, AlfrescoTranslateService } from 'ng2-alfresco-core';
import { ActivitiFormModule } from 'ng2-activiti-form'; import { ActivitiFormModule } from 'ng2-activiti-form';
import { ActivitiComments } from './activiti-comments.component'; import { ActivitiComments } from './activiti-comments.component';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service'; import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
import { TranslationMock } from './../assets/translation.service.mock';
describe('ActivitiTaskDetails', () => { describe('ActivitiComments', () => {
let componentHandler: any; let componentHandler: any;
let service: ActivitiTaskListService; let service: ActivitiTaskListService;
@@ -39,32 +38,32 @@ describe('ActivitiTaskDetails', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
CoreModule, CoreModule.forRoot(),
ActivitiFormModule ActivitiFormModule.forRoot()
], ],
declarations: [ declarations: [
ActivitiComments ActivitiComments
], ],
providers: [ providers: [
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
ActivitiTaskListService ActivitiTaskListService
] ]
}).compileComponents(); }).compileComponents();
let translateService = TestBed.get(AlfrescoTranslateService);
spyOn(translateService, 'addTranslationFolder').and.stub();
spyOn(translateService, 'get').and.callFake((key) => { return Observable.of(key); });
})); }));
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(ActivitiComments); fixture = TestBed.createComponent(ActivitiComments);
component = fixture.componentInstance; component = fixture.componentInstance;
service = fixture.debugElement.injector.get(ActivitiTaskListService); service = fixture.debugElement.injector.get(ActivitiTaskListService);
getCommentsSpy = spyOn(service, 'getTaskComments').and.returnValue(Observable.of([{ getCommentsSpy = spyOn(service, 'getTaskComments').and.returnValue(Observable.of([
message: 'Test1' { message: 'Test1' },
}, { { message: 'Test2' },
message: 'Test2' { message: 'Test3'}
}, { ]));
message: 'Test3'
}]));
addCommentSpy = spyOn(service, 'addTaskComment').and.returnValue(Observable.of({id: 123, message: 'Test'})); addCommentSpy = spyOn(service, 'addTaskComment').and.returnValue(Observable.of({id: 123, message: 'Test'}));
componentHandler = jasmine.createSpyObj('componentHandler', [ componentHandler = jasmine.createSpyObj('componentHandler', [

View File

@@ -16,7 +16,7 @@
*/ */
import { Component, Input, Output, ViewChild, OnChanges, SimpleChanges, EventEmitter } from '@angular/core'; import { Component, Input, Output, ViewChild, OnChanges, SimpleChanges, EventEmitter } from '@angular/core';
import { AlfrescoTranslationService } from 'ng2-alfresco-core'; import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service'; import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
import { Comment } from '../models/comment.model'; import { Comment } from '../models/comment.model';
import { Observer, Observable } from 'rxjs/Rx'; import { Observer, Observable } from 'rxjs/Rx';
@@ -56,11 +56,11 @@ export class ActivitiComments implements OnChanges {
* @param translate Translation service * @param translate Translation service
* @param activitiTaskList Task service * @param activitiTaskList Task service
*/ */
constructor(private translate: AlfrescoTranslationService, constructor(private translateService: AlfrescoTranslateService,
private activitiTaskList: ActivitiTaskListService) { private activitiTaskList: ActivitiTaskListService) {
if (translate) { if (translateService) {
translate.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src'); translateService.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src');
} }
this.comment$ = new Observable<Comment>(observer => this.commentObserver = observer).share(); this.comment$ = new Observable<Comment>(observer => this.commentObserver = observer).share();

View File

@@ -42,8 +42,8 @@ describe('ActivitiFilters', () => {
}); });
beforeEach(() => { beforeEach(() => {
let activitiService = new ActivitiTaskListService(null, null); let activitiService = new ActivitiTaskListService(null);
filterList = new ActivitiFilters(null, null, activitiService); filterList = new ActivitiFilters(null, activitiService);
}); });
it('should return the filter task list', (done) => { it('should return the filter task list', (done) => {

View File

@@ -16,7 +16,7 @@
*/ */
import { Component, Output, EventEmitter, OnInit, Input, SimpleChanges, OnChanges } from '@angular/core'; import { Component, Output, EventEmitter, OnInit, Input, SimpleChanges, OnChanges } from '@angular/core';
import { AlfrescoTranslationService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service'; import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
import { FilterRepresentationModel } from '../models/filter.model'; import { FilterRepresentationModel } from '../models/filter.model';
import { Observer } from 'rxjs/Observer'; import { Observer } from 'rxjs/Observer';
@@ -55,19 +55,12 @@ export class ActivitiFilters implements OnInit, OnChanges {
filters: FilterRepresentationModel [] = []; filters: FilterRepresentationModel [] = [];
/** constructor(private translateService: AlfrescoTranslateService,
* Constructor
* @param auth
* @param translate
* @param activiti
*/
constructor(private auth: AlfrescoAuthenticationService,
private translate: AlfrescoTranslationService,
public activiti: ActivitiTaskListService) { public activiti: ActivitiTaskListService) {
this.filter$ = new Observable<FilterRepresentationModel>(observer => this.filterObserver = observer).share(); this.filter$ = new Observable<FilterRepresentationModel>(observer => this.filterObserver = observer).share();
if (translate) { if (translateService) {
translate.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src'); translateService.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src');
} }
} }

View File

@@ -15,15 +15,11 @@
* limitations under the License. * limitations under the License.
*/ */
import {
CoreModule,
AlfrescoTranslationService
} from 'ng2-alfresco-core';
import { ActivitiPeopleSearch } from './activiti-people-search.component';
import { TranslationMock } from '../assets/translation.service.mock';
import { ComponentFixture, TestBed, async } from '@angular/core/testing'; import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { User } from '../models/user.model';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
import { CoreModule, AlfrescoTranslateService } from 'ng2-alfresco-core';
import { ActivitiPeopleSearch } from './activiti-people-search.component';
import { User } from '../models/user.model';
declare let jasmine: any; declare let jasmine: any;
@@ -41,7 +37,7 @@ const fakeSecondUser: User = new User({
email: 'fake-involve@mail.com' email: 'fake-involve@mail.com'
}); });
describe('Activiti People Search', () => { describe('ActivitiPeopleSearch', () => {
let activitiPeopleSearchComponent: ActivitiPeopleSearch; let activitiPeopleSearchComponent: ActivitiPeopleSearch;
let fixture: ComponentFixture<ActivitiPeopleSearch>; let fixture: ComponentFixture<ActivitiPeopleSearch>;
@@ -52,11 +48,18 @@ describe('Activiti People Search', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [CoreModule], imports: [
declarations: [ActivitiPeopleSearch], CoreModule.forRoot()
providers: [ ],
{provide: AlfrescoTranslationService, useClass: TranslationMock}] declarations: [
ActivitiPeopleSearch
]
}).compileComponents().then(() => { }).compileComponents().then(() => {
let translateService = TestBed.get(AlfrescoTranslateService);
spyOn(translateService, 'addTranslationFolder').and.stub();
spyOn(translateService, 'get').and.callFake((key) => { return Observable.of(key); });
fixture = TestBed.createComponent(ActivitiPeopleSearch); fixture = TestBed.createComponent(ActivitiPeopleSearch);
activitiPeopleSearchComponent = fixture.componentInstance; activitiPeopleSearchComponent = fixture.componentInstance;
element = fixture.nativeElement; element = fixture.nativeElement;

View File

@@ -19,7 +19,7 @@ import { Component, Input, Output, EventEmitter, OnInit, AfterViewInit } from '@
import { FormControl } from '@angular/forms'; import { FormControl } from '@angular/forms';
import { User } from '../models/user.model'; import { User } from '../models/user.model';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
import { AlfrescoTranslationService } from 'ng2-alfresco-core'; import { AlfrescoTranslateService } from 'ng2-alfresco-core';
declare let componentHandler: any; declare let componentHandler: any;
@@ -45,9 +45,9 @@ export class ActivitiPeopleSearch implements OnInit, AfterViewInit {
userList: User[] = []; userList: User[] = [];
constructor(private translate: AlfrescoTranslationService) { constructor(private translateService: AlfrescoTranslateService) {
if (translate) { if (translateService) {
translate.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src'); translateService.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src');
} }
this.searchUser this.searchUser

View File

@@ -15,15 +15,12 @@
* limitations under the License. * limitations under the License.
*/ */
import { import { ComponentFixture, TestBed, async } from '@angular/core/testing';
CoreModule, import { Observable } from 'rxjs/Rx';
AlfrescoTranslationService import { CoreModule, AlfrescoTranslateService } from 'ng2-alfresco-core';
} from 'ng2-alfresco-core';
import { ActivitiPeopleService } from '../services/activiti-people.service'; import { ActivitiPeopleService } from '../services/activiti-people.service';
import { ActivitiPeople } from './activiti-people.component'; import { ActivitiPeople } from './activiti-people.component';
import { ActivitiPeopleSearch } from './activiti-people-search.component'; import { ActivitiPeopleSearch } from './activiti-people-search.component';
import { TranslationMock } from '../assets/translation.service.mock';
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { User } from '../models/user.model'; import { User } from '../models/user.model';
declare let jasmine: any; declare let jasmine: any;
@@ -42,7 +39,7 @@ const fakeUserToInvolve: User = new User({
email: 'fake-involve@mail.com' email: 'fake-involve@mail.com'
}); });
describe('Activiti People Component', () => { describe('ActivitiPeople', () => {
let activitiPeopleComponent: ActivitiPeople; let activitiPeopleComponent: ActivitiPeople;
let fixture: ComponentFixture<ActivitiPeople>; let fixture: ComponentFixture<ActivitiPeople>;
@@ -51,12 +48,21 @@ describe('Activiti People Component', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [CoreModule], imports: [
declarations: [ActivitiPeople, ActivitiPeopleSearch], CoreModule.forRoot()
],
declarations: [
ActivitiPeople,
ActivitiPeopleSearch
],
providers: [ providers: [
{provide: AlfrescoTranslationService, useClass: TranslationMock}, ActivitiPeopleService
ActivitiPeopleService] ]
}).compileComponents().then(() => { }).compileComponents().then(() => {
let translateService = TestBed.get(AlfrescoTranslateService);
spyOn(translateService, 'addTranslationFolder').and.stub();
spyOn(translateService, 'get').and.callFake((key) => { return Observable.of(key); });
fixture = TestBed.createComponent(ActivitiPeople); fixture = TestBed.createComponent(ActivitiPeople);
activitiPeopleComponent = fixture.componentInstance; activitiPeopleComponent = fixture.componentInstance;
element = fixture.nativeElement; element = fixture.nativeElement;

View File

@@ -16,7 +16,7 @@
*/ */
import { Component, Input, ViewChild } from '@angular/core'; import { Component, Input, ViewChild } from '@angular/core';
import { AlfrescoTranslationService } from 'ng2-alfresco-core'; import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { User } from '../models/user.model'; import { User } from '../models/user.model';
import { Observer, Observable } from 'rxjs/Rx'; import { Observer, Observable } from 'rxjs/Rx';
import { ActivitiPeopleService } from '../services/activiti-people.service'; import { ActivitiPeopleService } from '../services/activiti-people.service';
@@ -51,10 +51,10 @@ export class ActivitiPeople {
* @param translate * @param translate
* @param people service * @param people service
*/ */
constructor(private translate: AlfrescoTranslationService, constructor(private translateService: AlfrescoTranslateService,
private peopleService: ActivitiPeopleService) { private peopleService: ActivitiPeopleService) {
if (translate) { if (translateService) {
translate.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src'); translateService.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src');
} }
this.peopleSearch$ = new Observable<User[]>(observer => this.peopleSearchObserver = observer).share(); this.peopleSearch$ = new Observable<User[]>(observer => this.peopleSearchObserver = observer).share();
} }

View File

@@ -15,19 +15,15 @@
* limitations under the License. * limitations under the License.
*/ */
import {
CoreModule,
AlfrescoTranslationService
} from 'ng2-alfresco-core';
import { ActivitiTaskListService } from '../services/activiti-tasklist.service';
import { ActivitiStartTaskButton } from './activiti-start-task.component';
import { TranslationMock } from '../assets/translation.service.mock';
import { ComponentFixture, TestBed, async } from '@angular/core/testing'; import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { Observable } from 'rxjs/Rx'; import { Observable } from 'rxjs/Rx';
import { CoreModule, AlfrescoTranslateService } from 'ng2-alfresco-core';
import { ActivitiTaskListService } from '../services/activiti-tasklist.service';
import { ActivitiStartTaskButton } from './activiti-start-task.component';
declare let jasmine: any; declare let jasmine: any;
describe('Activiti Start Task Component', () => { describe('ActivitiStartTaskButton', () => {
let activitiStartTaskButton: ActivitiStartTaskButton; let activitiStartTaskButton: ActivitiStartTaskButton;
let fixture: ComponentFixture<ActivitiStartTaskButton>; let fixture: ComponentFixture<ActivitiStartTaskButton>;
@@ -37,12 +33,20 @@ describe('Activiti Start Task Component', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [CoreModule], imports: [
declarations: [ActivitiStartTaskButton], CoreModule.forRoot()
],
declarations: [
ActivitiStartTaskButton
],
providers: [ providers: [
{provide: AlfrescoTranslationService, useClass: TranslationMock}, ActivitiTaskListService
ActivitiTaskListService] ]
}).compileComponents().then(() => { }).compileComponents().then(() => {
let translateService = TestBed.get(AlfrescoTranslateService);
spyOn(translateService, 'addTranslationFolder').and.stub();
spyOn(translateService, 'get').and.callFake((key) => { return Observable.of(key); });
fixture = TestBed.createComponent(ActivitiStartTaskButton); fixture = TestBed.createComponent(ActivitiStartTaskButton);
activitiStartTaskButton = fixture.componentInstance; activitiStartTaskButton = fixture.componentInstance;
element = fixture.nativeElement; element = fixture.nativeElement;

View File

@@ -16,7 +16,7 @@
*/ */
import { Component, EventEmitter, Input, Output, ViewChild } from '@angular/core'; import { Component, EventEmitter, Input, Output, ViewChild } from '@angular/core';
import { AlfrescoTranslationService } from 'ng2-alfresco-core'; import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { TaskDetailsModel } from '../models/task-details.model'; import { TaskDetailsModel } from '../models/task-details.model';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service'; import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
import { Form } from '../models/form.model'; import { Form } from '../models/form.model';
@@ -54,11 +54,11 @@ export class ActivitiStartTaskButton {
* @param translate * @param translate
* @param taskService * @param taskService
*/ */
constructor(private translate: AlfrescoTranslationService, constructor(private translateService: AlfrescoTranslateService,
private taskService: ActivitiTaskListService) { private taskService: ActivitiTaskListService) {
if (translate) { if (translateService) {
translate.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src'); translateService.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src');
} }
} }

View File

@@ -20,13 +20,12 @@ import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { Observable } from 'rxjs/Rx'; import { Observable } from 'rxjs/Rx';
import { AlfrescoTranslationService, CoreModule } from 'ng2-alfresco-core'; import { CoreModule, AlfrescoTranslateService } from 'ng2-alfresco-core';
import { ActivitiFormModule, FormModel, FormOutcomeEvent, FormOutcomeModel, FormService } from 'ng2-activiti-form'; import { ActivitiFormModule, FormModel, FormOutcomeEvent, FormOutcomeModel, FormService } from 'ng2-activiti-form';
import { ActivitiTaskDetails } from './activiti-task-details.component'; import { ActivitiTaskDetails } from './activiti-task-details.component';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service'; import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
import { ActivitiPeopleService } from './../services/activiti-people.service'; import { ActivitiPeopleService } from './../services/activiti-people.service';
import { TranslationMock } from './../assets/translation.service.mock';
import { taskDetailsMock, taskFormMock, tasksMock, noDataMock } from './../assets/task-details.mock'; import { taskDetailsMock, taskFormMock, tasksMock, noDataMock } from './../assets/task-details.mock';
describe('ActivitiTaskDetails', () => { describe('ActivitiTaskDetails', () => {
@@ -44,19 +43,22 @@ describe('ActivitiTaskDetails', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
CoreModule, CoreModule.forRoot(),
ActivitiFormModule ActivitiFormModule.forRoot()
], ],
declarations: [ declarations: [
ActivitiTaskDetails ActivitiTaskDetails
], ],
providers: [ providers: [
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
ActivitiTaskListService, ActivitiTaskListService,
ActivitiPeopleService ActivitiPeopleService
], ],
schemas: [ NO_ERRORS_SCHEMA ] schemas: [ NO_ERRORS_SCHEMA ]
}).compileComponents(); }).compileComponents();
let translateService = TestBed.get(AlfrescoTranslateService);
spyOn(translateService, 'addTranslationFolder').and.stub();
spyOn(translateService, 'get').and.callFake((key) => { return Observable.of(key); });
})); }));
beforeEach(() => { beforeEach(() => {

View File

@@ -27,7 +27,7 @@ import {
SimpleChanges, SimpleChanges,
DebugElement DebugElement
} from '@angular/core'; } from '@angular/core';
import { AlfrescoTranslationService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service'; import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
import { TaskDetailsModel } from '../models/task-details.model'; import { TaskDetailsModel } from '../models/task-details.model';
import { User } from '../models/user.model'; import { User } from '../models/user.model';
@@ -101,13 +101,12 @@ export class ActivitiTaskDetails implements OnInit, OnChanges {
* @param activitiForm Form service * @param activitiForm Form service
* @param activitiTaskList Task service * @param activitiTaskList Task service
*/ */
constructor(private auth: AlfrescoAuthenticationService, constructor(private translateService: AlfrescoTranslateService,
private translate: AlfrescoTranslationService,
private activitiForm: FormService, private activitiForm: FormService,
private activitiTaskList: ActivitiTaskListService) { private activitiTaskList: ActivitiTaskListService) {
if (translate) { if (translateService) {
translate.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src'); translateService.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src');
} }
} }

View File

@@ -17,11 +17,10 @@
import { ComponentFixture, TestBed, async } from '@angular/core/testing'; import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { Observable } from 'rxjs/Rx';
import { AlfrescoTranslationService, CoreModule } from 'ng2-alfresco-core'; import { CoreModule, AlfrescoTranslateService } from 'ng2-alfresco-core';
import { ActivitiTaskHeader } from './activiti-task-header.component'; import { ActivitiTaskHeader } from './activiti-task-header.component';
import { TranslationMock } from './../assets/translation.service.mock';
import { taskDetailsMock } from './../assets/task-details.mock'; import { taskDetailsMock } from './../assets/task-details.mock';
import { TaskDetailsModel } from '../models/task-details.model'; import { TaskDetailsModel } from '../models/task-details.model';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service'; import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
@@ -36,23 +35,25 @@ describe('ActivitiTaskHeader', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
CoreModule CoreModule.forRoot()
], ],
declarations: [ declarations: [
ActivitiTaskHeader ActivitiTaskHeader
], ],
providers: [ providers: [
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
ActivitiTaskListService ActivitiTaskListService
] ]
}).compileComponents(); }).compileComponents();
let translateService = TestBed.get(AlfrescoTranslateService);
spyOn(translateService, 'addTranslationFolder').and.stub();
spyOn(translateService, 'get').and.callFake((key) => { return Observable.of(key); });
})); }));
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(ActivitiTaskHeader); fixture = TestBed.createComponent(ActivitiTaskHeader);
component = fixture.componentInstance; component = fixture.componentInstance;
service = fixture.debugElement.injector.get(ActivitiTaskListService); service = TestBed.get(ActivitiTaskListService);
component.taskDetails = new TaskDetailsModel(taskDetailsMock); component.taskDetails = new TaskDetailsModel(taskDetailsMock);

View File

@@ -16,7 +16,7 @@
*/ */
import { Component, Input, Output, EventEmitter } from '@angular/core'; import { Component, Input, Output, EventEmitter } from '@angular/core';
import { AlfrescoTranslationService } from 'ng2-alfresco-core'; import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { TaskDetailsModel } from '../models/task-details.model'; import { TaskDetailsModel } from '../models/task-details.model';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service'; import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
@@ -37,10 +37,10 @@ export class ActivitiTaskHeader {
@Output() @Output()
claim: EventEmitter<any> = new EventEmitter<any>(); claim: EventEmitter<any> = new EventEmitter<any>();
constructor(private translate: AlfrescoTranslationService, constructor(private translateService: AlfrescoTranslateService,
private activitiTaskService: ActivitiTaskListService) { private activitiTaskService: ActivitiTaskListService) {
if (translate) { if (translateService) {
translate.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src'); translateService.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src');
} }
} }

View File

@@ -17,12 +17,11 @@
import { SimpleChange } from '@angular/core'; import { SimpleChange } from '@angular/core';
import { ComponentFixture, TestBed, async } from '@angular/core/testing'; import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { AlfrescoTranslationService, CoreModule } from 'ng2-alfresco-core'; import { CoreModule, AlfrescoTranslateService } from 'ng2-alfresco-core';
import { DataTableModule } from 'ng2-alfresco-datatable'; import { DataTableModule } from 'ng2-alfresco-datatable';
import { ActivitiTaskList } from './activiti-tasklist.component'; import { ActivitiTaskList } from './activiti-tasklist.component';
import { Observable } from 'rxjs/Rx'; import { Observable } from 'rxjs/Rx';
import { ObjectDataRow, DataRowEvent, ObjectDataTableAdapter } from 'ng2-alfresco-datatable'; import { ObjectDataRow, DataRowEvent, ObjectDataTableAdapter } from 'ng2-alfresco-datatable';
import { TranslationMock } from './../assets/translation.service.mock';
import { ActivitiTaskListService } from '../services/activiti-tasklist.service'; import { ActivitiTaskListService } from '../services/activiti-tasklist.service';
describe('ActivitiTaskList', () => { describe('ActivitiTaskList', () => {
@@ -58,21 +57,25 @@ describe('ActivitiTaskList', () => {
let componentHandler: any; let componentHandler: any;
let component: ActivitiTaskList; let component: ActivitiTaskList;
let fixture: ComponentFixture<ActivitiTaskList>; let fixture: ComponentFixture<ActivitiTaskList>;
let taskListService: ActivitiTaskListService;
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
CoreModule, CoreModule.forRoot(),
DataTableModule DataTableModule
], ],
declarations: [ declarations: [
ActivitiTaskList ActivitiTaskList
], ],
providers: [ providers: [
{provide: AlfrescoTranslationService, useClass: TranslationMock},
ActivitiTaskListService ActivitiTaskListService
] ]
}).compileComponents(); }).compileComponents();
let translateService = TestBed.get(AlfrescoTranslateService);
spyOn(translateService, 'addTranslationFolder').and.stub();
spyOn(translateService, 'get').and.callFake((key) => { return Observable.of(key); });
})); }));
beforeEach(() => { beforeEach(() => {
@@ -80,6 +83,8 @@ describe('ActivitiTaskList', () => {
fixture = TestBed.createComponent(ActivitiTaskList); fixture = TestBed.createComponent(ActivitiTaskList);
component = fixture.componentInstance; component = fixture.componentInstance;
taskListService = TestBed.get(ActivitiTaskListService);
componentHandler = jasmine.createSpyObj('componentHandler', [ componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered', 'upgradeAllRegistered',
'upgradeElement' 'upgradeElement'
@@ -113,8 +118,8 @@ describe('ActivitiTaskList', () => {
}); });
it('should return the filtered task list when the input parameters are passed', (done) => { it('should return the filtered task list when the input parameters are passed', (done) => {
spyOn(component.activiti, 'getTotalTasks').and.returnValue(Observable.of(fakeGlobalTotalTasks)); spyOn(taskListService, 'getTotalTasks').and.returnValue(Observable.of(fakeGlobalTotalTasks));
spyOn(component.activiti, 'getTasks').and.returnValue(Observable.of(fakeGlobalTask)); spyOn(taskListService, 'getTasks').and.returnValue(Observable.of(fakeGlobalTask));
let state = new SimpleChange(null, 'open'); let state = new SimpleChange(null, 'open');
let processDefinitionKey = new SimpleChange(null, null); let processDefinitionKey = new SimpleChange(null, null);
@@ -134,8 +139,8 @@ describe('ActivitiTaskList', () => {
}); });
it('should return the filtered task list by processDefinitionKey', (done) => { it('should return the filtered task list by processDefinitionKey', (done) => {
spyOn(component.activiti, 'getTotalTasks').and.returnValue(Observable.of(fakeGlobalTotalTasks)); spyOn(taskListService, 'getTotalTasks').and.returnValue(Observable.of(fakeGlobalTotalTasks));
spyOn(component.activiti, 'getTasks').and.returnValue(Observable.of(fakeGlobalTask)); spyOn(taskListService, 'getTasks').and.returnValue(Observable.of(fakeGlobalTask));
let state = new SimpleChange(null, 'open'); let state = new SimpleChange(null, 'open');
let processDefinitionKey = new SimpleChange(null, 'fakeprocess'); let processDefinitionKey = new SimpleChange(null, 'fakeprocess');
@@ -161,7 +166,7 @@ describe('ActivitiTaskList', () => {
}); });
it('should throw an exception when the response is wrong', (done) => { it('should throw an exception when the response is wrong', (done) => {
spyOn(component.activiti, 'getTotalTasks').and.returnValue(Observable.throw(fakeErrorTaskList)); spyOn(taskListService, 'getTotalTasks').and.returnValue(Observable.throw(fakeErrorTaskList));
let state = new SimpleChange(null, 'open'); let state = new SimpleChange(null, 'open');
let assignment = new SimpleChange(null, 'fake-assignee'); let assignment = new SimpleChange(null, 'fake-assignee');
@@ -178,8 +183,8 @@ describe('ActivitiTaskList', () => {
}); });
it('should reload tasks when reload() is called', (done) => { it('should reload tasks when reload() is called', (done) => {
spyOn(component.activiti, 'getTotalTasks').and.returnValue(Observable.of(fakeGlobalTotalTasks)); spyOn(taskListService, 'getTotalTasks').and.returnValue(Observable.of(fakeGlobalTotalTasks));
spyOn(component.activiti, 'getTasks').and.returnValue(Observable.of(fakeGlobalTask)); spyOn(taskListService, 'getTasks').and.returnValue(Observable.of(fakeGlobalTask));
component.state = 'open'; component.state = 'open';
component.assignment = 'fake-assignee'; component.assignment = 'fake-assignee';
component.ngOnInit(); component.ngOnInit();
@@ -212,8 +217,8 @@ describe('ActivitiTaskList', () => {
describe('component changes', () => { describe('component changes', () => {
beforeEach(() => { beforeEach(() => {
spyOn(component.activiti, 'getTotalTasks').and.returnValue(Observable.of(fakeGlobalTotalTasks)); spyOn(taskListService, 'getTotalTasks').and.returnValue(Observable.of(fakeGlobalTotalTasks));
spyOn(component.activiti, 'getTasks').and.returnValue(Observable.of(fakeGlobalTask)); spyOn(taskListService, 'getTasks').and.returnValue(Observable.of(fakeGlobalTask));
component.data = new ObjectDataTableAdapter( component.data = new ObjectDataTableAdapter(
[], [],

View File

@@ -16,7 +16,7 @@
*/ */
import { Component, Input, Output, EventEmitter, OnInit, OnChanges, SimpleChanges } from '@angular/core'; import { Component, Input, Output, EventEmitter, OnInit, OnChanges, SimpleChanges } from '@angular/core';
import { AlfrescoTranslationService } from 'ng2-alfresco-core'; import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { ObjectDataTableAdapter, DataTableAdapter, DataRowEvent, ObjectDataRow } from 'ng2-alfresco-datatable'; import { ObjectDataTableAdapter, DataTableAdapter, DataRowEvent, ObjectDataRow } from 'ng2-alfresco-datatable';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service'; import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
import { TaskQueryRequestRepresentationModel } from '../models/filter.model'; import { TaskQueryRequestRepresentationModel } from '../models/filter.model';
@@ -72,10 +72,10 @@ export class ActivitiTaskList implements OnInit, OnChanges {
{type: 'text', key: 'created', title: 'Created', sortable: true} {type: 'text', key: 'created', title: 'Created', sortable: true}
]; ];
constructor(private translate: AlfrescoTranslationService, constructor(private translateService: AlfrescoTranslateService,
public activiti: ActivitiTaskListService) { private taskListService: ActivitiTaskListService) {
if (translate) { if (translateService) {
translate.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src'); translateService.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src');
} }
} }
@@ -134,10 +134,10 @@ export class ActivitiTaskList implements OnInit, OnChanges {
} }
private load(requestNode: TaskQueryRequestRepresentationModel) { private load(requestNode: TaskQueryRequestRepresentationModel) {
this.activiti.getTotalTasks(requestNode).subscribe( this.taskListService.getTotalTasks(requestNode).subscribe(
(res) => { (res) => {
requestNode.size = res.total; requestNode.size = res.total;
this.activiti.getTasks(requestNode).subscribe( this.taskListService.getTasks(requestNode).subscribe(
(response) => { (response) => {
let instancesRow = this.createDataRow(response); let instancesRow = this.createDataRow(response);
this.renderInstances(instancesRow); this.renderInstances(instancesRow);

View File

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

View File

@@ -15,13 +15,8 @@
* limitations under the License. * limitations under the License.
*/ */
import { ReflectiveInjector } from '@angular/core'; import { TestBed } from '@angular/core/testing';
import { import { CoreModule } from 'ng2-alfresco-core';
AlfrescoAuthenticationService,
AlfrescoSettingsService,
AlfrescoApiService,
StorageService
} from 'ng2-alfresco-core';
import { User } from '../models/user.model'; import { User } from '../models/user.model';
import { ActivitiPeopleService } from './activiti-people.service'; import { ActivitiPeopleService } from './activiti-people.service';
@@ -45,28 +40,18 @@ const fakeInvolveUserList: User[] = [firstInvolvedUser, secondInvolvedUser];
describe('ActivitiPeopleService', () => { describe('ActivitiPeopleService', () => {
let service, injector, apiService; let service: ActivitiPeopleService;
beforeEach(() => { beforeEach(() => {
injector = ReflectiveInjector.resolveAndCreate([ TestBed.configureTestingModule({
AlfrescoSettingsService, imports: [
AlfrescoApiService, CoreModule.forRoot()
AlfrescoAuthenticationService, ],
ActivitiPeopleService, providers: [
StorageService ActivitiPeopleService
]); ]
}); });
service = TestBed.get(ActivitiPeopleService);
beforeEach(() => {
service = injector.get(ActivitiPeopleService);
apiService = injector.get(AlfrescoApiService);
});
it('can instantiate service with authorization', () => {
expect(apiService).not.toBeNull('authorization should be provided');
let serviceApi = new ActivitiPeopleService(null, apiService);
expect(serviceApi instanceof ActivitiPeopleService).toBe(true, 'new service should be ok');
}); });
describe('when user is logged in', () => { describe('when user is logged in', () => {

View File

@@ -16,7 +16,7 @@
*/ */
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { AlfrescoApiService, AlfrescoAuthenticationService } from 'ng2-alfresco-core'; import { AlfrescoApiService } from 'ng2-alfresco-core';
import { Observable } from 'rxjs/Rx'; import { Observable } from 'rxjs/Rx';
import { Response } from '@angular/http'; import { Response } from '@angular/http';
import { User } from '../models/user.model'; import { User } from '../models/user.model';
@@ -24,8 +24,7 @@ import { User } from '../models/user.model';
@Injectable() @Injectable()
export class ActivitiPeopleService { export class ActivitiPeopleService {
constructor(private authService: AlfrescoAuthenticationService, constructor(private alfrescoJsApi: AlfrescoApiService) {
private alfrescoJsApi: AlfrescoApiService) {
} }
getWorkflowUsers(taskId: string, searchWord: string): Observable<User[]> { getWorkflowUsers(taskId: string, searchWord: string): Observable<User[]> {

View File

@@ -15,16 +15,11 @@
* limitations under the License. * limitations under the License.
*/ */
import { ReflectiveInjector } from '@angular/core'; import { TestBed } from '@angular/core/testing';
import { import { CoreModule } from 'ng2-alfresco-core';
AlfrescoAuthenticationService,
AlfrescoSettingsService,
AlfrescoApiService,
StorageService
} from 'ng2-alfresco-core';
import { ActivitiTaskListService } from './activiti-tasklist.service'; import { ActivitiTaskListService } from './activiti-tasklist.service';
import { TaskDetailsModel } from '../models/task-details.model'; import { TaskDetailsModel } from '../models/task-details.model';
import { FilterRepresentationModel, AppDefinitionRepresentationModel } from '../models/filter.model'; import { FilterRepresentationModel, AppDefinitionRepresentationModel, TaskQueryRequestRepresentationModel } from '../models/filter.model';
import { Comment } from '../models/comment.model'; import { Comment } from '../models/comment.model';
declare let AlfrescoApi: any; declare let AlfrescoApi: any;
@@ -131,20 +126,18 @@ describe('ActivitiTaskListService', () => {
resolve(fakeAppFilter); resolve(fakeAppFilter);
}); });
let service, injector; let service: ActivitiTaskListService;
beforeEach(() => { beforeEach(() => {
injector = ReflectiveInjector.resolveAndCreate([ TestBed.configureTestingModule({
ActivitiTaskListService, imports: [
AlfrescoSettingsService, CoreModule.forRoot()
AlfrescoApiService, ],
AlfrescoAuthenticationService, providers: [
StorageService ActivitiTaskListService
]); ]
}); });
service = TestBed.get(ActivitiTaskListService);
beforeEach(() => {
service = injector.get(ActivitiTaskListService);
jasmine.Ajax.install(); jasmine.Ajax.install();
}); });
@@ -173,7 +166,7 @@ describe('ActivitiTaskListService', () => {
it('should call the api withthe appId', (done) => { it('should call the api withthe appId', (done) => {
spyOn(service, 'callApiTaskFilters').and.returnValue((fakeAppPromise)); spyOn(service, 'callApiTaskFilters').and.returnValue((fakeAppPromise));
let appId = 1; let appId = '1';
service.getTaskListFilters(appId).subscribe( service.getTaskListFilters(appId).subscribe(
(res) => { (res) => {
expect(service.callApiTaskFilters).toHaveBeenCalledWith(appId); expect(service.callApiTaskFilters).toHaveBeenCalledWith(appId);
@@ -183,7 +176,7 @@ describe('ActivitiTaskListService', () => {
}); });
it('should return the app filter by id', (done) => { it('should return the app filter by id', (done) => {
let appId = 1; let appId = '1';
service.getTaskListFilters(appId).subscribe( service.getTaskListFilters(appId).subscribe(
(res) => { (res) => {
expect(res).toBeDefined(); expect(res).toBeDefined();
@@ -201,7 +194,7 @@ describe('ActivitiTaskListService', () => {
}); });
it('should return the task list filtered', (done) => { it('should return the task list filtered', (done) => {
service.getTasks(fakeFilter).subscribe( service.getTasks(<TaskQueryRequestRepresentationModel>fakeFilter).subscribe(
res => { res => {
expect(res).toBeDefined(); expect(res).toBeDefined();
expect(res.length).toEqual(1); expect(res.length).toEqual(1);
@@ -221,7 +214,7 @@ describe('ActivitiTaskListService', () => {
}); });
it('should throw an exception when the response is wrong', () => { it('should throw an exception when the response is wrong', () => {
service.getTasks(fakeFilter).subscribe( service.getTasks(<TaskQueryRequestRepresentationModel>fakeFilter).subscribe(
(res) => { (res) => {
}, },
(err: any) => { (err: any) => {
@@ -237,7 +230,7 @@ describe('ActivitiTaskListService', () => {
}); });
it('should return the task details ', (done) => { it('should return the task details ', (done) => {
service.getTaskDetails(999).subscribe( service.getTaskDetails('999').subscribe(
(res: TaskDetailsModel) => { (res: TaskDetailsModel) => {
expect(res).toBeDefined(); expect(res).toBeDefined();
expect(res.id).toEqual('999'); expect(res.id).toEqual('999');
@@ -259,7 +252,7 @@ describe('ActivitiTaskListService', () => {
}); });
it('should return the tasks comments ', (done) => { it('should return the tasks comments ', (done) => {
service.getTaskComments(999).subscribe( service.getTaskComments('999').subscribe(
(res: Comment[]) => { (res: Comment[]) => {
expect(res).toBeDefined(); expect(res).toBeDefined();
expect(res.length).toEqual(2); expect(res.length).toEqual(2);
@@ -277,7 +270,7 @@ describe('ActivitiTaskListService', () => {
}); });
it('should return the tasks checklists ', (done) => { it('should return the tasks checklists ', (done) => {
service.getTaskChecklist(999).subscribe( service.getTaskChecklist('999').subscribe(
(res: TaskDetailsModel[]) => { (res: TaskDetailsModel[]) => {
expect(res).toBeDefined(); expect(res).toBeDefined();
expect(res.length).toEqual(2); expect(res.length).toEqual(2);
@@ -333,7 +326,7 @@ describe('ActivitiTaskListService', () => {
}); });
it('should add a comment task ', (done) => { it('should add a comment task ', (done) => {
service.addTaskComment(999, 'fake-comment-message').subscribe( service.addTaskComment('999', 'fake-comment-message').subscribe(
(res: Comment) => { (res: Comment) => {
expect(res).toBeDefined(); expect(res).toBeDefined();
expect(res.id).not.toEqual(''); expect(res.id).not.toEqual('');
@@ -358,7 +351,7 @@ describe('ActivitiTaskListService', () => {
}); });
it('should complete the task ', (done) => { it('should complete the task ', (done) => {
service.completeTask(999).subscribe( service.completeTask('999').subscribe(
(res: any) => { (res: any) => {
expect(res).toBeDefined(); expect(res).toBeDefined();
done(); done();
@@ -373,7 +366,7 @@ describe('ActivitiTaskListService', () => {
}); });
it('should return the total number of tasks', (done) => { it('should return the total number of tasks', (done) => {
service.getTotalTasks(fakeFilter).subscribe( service.getTotalTasks(<TaskQueryRequestRepresentationModel>fakeFilter).subscribe(
res => { res => {
expect(res).toBeDefined(); expect(res).toBeDefined();
expect(res.size).toEqual(1); expect(res.size).toEqual(1);
@@ -408,7 +401,7 @@ describe('ActivitiTaskListService', () => {
it('should return the default filters', () => { it('should return the default filters', () => {
spyOn(service, 'addFilter'); spyOn(service, 'addFilter');
let filters = service.createDefaultFilter(); let filters = service.createDefaultFilter(null);
expect(service.addFilter).toHaveBeenCalledTimes(4); expect(service.addFilter).toHaveBeenCalledTimes(4);
expect(filters).toBeDefined(); expect(filters).toBeDefined();
expect(filters.length).toEqual(4); expect(filters.length).toEqual(4);

View File

@@ -16,10 +16,9 @@
*/ */
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { AlfrescoAuthenticationService, AlfrescoApiService } from 'ng2-alfresco-core'; import { AlfrescoApiService } from 'ng2-alfresco-core';
import { Observable } from 'rxjs/Rx'; import { Observable } from 'rxjs/Rx';
import { FilterRepresentationModel } from '../models/filter.model'; import { FilterRepresentationModel, TaskQueryRequestRepresentationModel } from '../models/filter.model';
import { TaskQueryRequestRepresentationModel } from '../models/filter.model';
import { Comment } from '../models/comment.model'; import { Comment } from '../models/comment.model';
import { User } from '../models/user.model'; import { User } from '../models/user.model';
import { TaskDetailsModel } from '../models/task-details.model'; import { TaskDetailsModel } from '../models/task-details.model';
@@ -28,7 +27,7 @@ import { Form } from '../models/form.model';
@Injectable() @Injectable()
export class ActivitiTaskListService { export class ActivitiTaskListService {
constructor(public authService: AlfrescoAuthenticationService, private apiService: AlfrescoApiService) { constructor(private apiService: AlfrescoApiService) {
} }
/** /**
@@ -271,7 +270,7 @@ export class ActivitiTaskListService {
return this.apiService.getInstance().activiti.taskApi.listTasks(requestNode); return this.apiService.getInstance().activiti.taskApi.listTasks(requestNode);
} }
private callApiTaskFilters(appId?: string) { callApiTaskFilters(appId?: string) {
if (appId) { if (appId) {
return this.apiService.getInstance().activiti.userFiltersApi.getUserTaskFilters({appId: appId}); return this.apiService.getInstance().activiti.userFiltersApi.getUserTaskFilters({appId: appId});
} else { } else {

View File

@@ -22,17 +22,22 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { TranslateModule, TranslateLoader } from 'ng2-translate/ng2-translate'; import { TranslateModule, TranslateLoader } from 'ng2-translate/ng2-translate';
import { import {
AuthService,
ContentService,
SettingsService,
StorageService, StorageService,
AlfrescoApiService, AlfrescoApiService,
AlfrescoSettingsService, AlfrescoTranslateLoader,
AlfrescoTranslationLoader, AlfrescoTranslateService,
AlfrescoTranslationService,
AlfrescoAuthenticationService,
AlfrescoContentService,
RenditionsService, RenditionsService,
AuthGuard, AuthGuard,
AuthGuardEcm, AuthGuardEcm,
AuthGuardBpm AuthGuardBpm,
/** @deprecated */ AlfrescoSettingsService,
/** @deprecated */ AlfrescoTranslationService,
/** @deprecated */ AlfrescoAuthenticationService,
/** @deprecated */ AlfrescoContentService
} from './src/services/index'; } from './src/services/index';
import { MATERIAL_DESIGN_DIRECTIVES } from './src/components/material/index'; import { MATERIAL_DESIGN_DIRECTIVES } from './src/components/material/index';
@@ -43,22 +48,27 @@ export * from './src/components/index';
export * from './src/utils/index'; export * from './src/utils/index';
export const ALFRESCO_CORE_PROVIDERS: any[] = [ export const ALFRESCO_CORE_PROVIDERS: any[] = [
AuthService,
ContentService,
SettingsService,
StorageService, StorageService,
AlfrescoApiService, AlfrescoApiService,
AlfrescoAuthenticationService, AlfrescoTranslateLoader,
AlfrescoContentService, AlfrescoTranslateService,
AlfrescoSettingsService,
AlfrescoTranslationLoader,
AlfrescoTranslationService,
RenditionsService, RenditionsService,
AuthGuard, AuthGuard,
AuthGuardEcm, AuthGuardEcm,
AuthGuardBpm, AuthGuardBpm,
...CONTEXT_MENU_PROVIDERS ...CONTEXT_MENU_PROVIDERS,
/** @deprecated */ AlfrescoAuthenticationService,
/** @deprecated */ AlfrescoContentService,
/** @deprecated */ AlfrescoSettingsService,
/** @deprecated */ AlfrescoTranslationService
]; ];
export function createTranslateLoader(http: Http) { export function createTranslateLoader(http: Http) {
return new AlfrescoTranslationLoader(http); return new AlfrescoTranslateLoader(http);
} }
@NgModule({ @NgModule({
@@ -71,7 +81,8 @@ export function createTranslateLoader(http: Http) {
provide: TranslateLoader, provide: TranslateLoader,
useFactory: (createTranslateLoader), useFactory: (createTranslateLoader),
deps: [Http] deps: [Http]
}) ], })
],
declarations: [ declarations: [
...MATERIAL_DESIGN_DIRECTIVES, ...MATERIAL_DESIGN_DIRECTIVES,
...CONTEXT_MENU_DIRECTIVES ...CONTEXT_MENU_DIRECTIVES

View File

@@ -5,7 +5,7 @@
"author": "Alfresco Software, Ltd.", "author": "Alfresco Software, Ltd.",
"scripts": { "scripts": {
"clean": "npm install rimraf && npm run clean-build && rimraf dist node_modules typings", "clean": "npm install rimraf && npm run clean-build && rimraf dist node_modules typings",
"clean-build": "rimraf index.js index.js.map index.d.ts'src/{,**/}**.js' 'src/{,**/}**.js.map' 'src/{,**/}**.d.ts' bundles", "clean-build": "rimraf index.js index.js.map index.d.ts 'src/{,**/}**.js' 'src/{,**/}**.js.map' 'src/{,**/}**.d.ts' bundles",
"build": "npm run clean-build && npm run tslint && rimraf dist && tsc && license-check && npm run build.umd", "build": "npm run clean-build && npm run tslint && rimraf dist && tsc && license-check && npm run build.umd",
"build:w": "npm run clean-build && npm run tslint && rimraf dist && tsc:w && license-check npm run build.umd", "build:w": "npm run clean-build && npm run tslint && rimraf dist && tsc:w && license-check npm run build.umd",
"tslint": "tslint -c tslint.json 'src/{,**/}**.ts' 'index.ts' -e '{,**/}**.d.ts' -e './gulpfile.ts'", "tslint": "tslint -c tslint.json 'src/{,**/}**.ts' 'index.ts' -e '{,**/}**.d.ts' -e './gulpfile.ts'",

View File

@@ -16,204 +16,18 @@
*/ */
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Rx'; import { SettingsService } from './settings.service';
import { AlfrescoSettingsService } from './AlfrescoSettings.service';
import { StorageService } from './storage.service'; import { StorageService } from './storage.service';
import { AlfrescoApiService } from './AlfrescoApi.service'; import { AlfrescoApiService } from './alfresco-api.service';
import * as alfrescoApi from 'alfresco-js-api'; import { AuthService } from './auth.service';
import { AlfrescoApi } from 'alfresco-js-api';
import { Subject } from 'rxjs/Subject';
/** /** @deprecated AlfrescoAuthenticationService is deprecated. Use AuthService instead */
* The AlfrescoAuthenticationService provide the login service and store the ticket in the Storage
*/
@Injectable() @Injectable()
export class AlfrescoAuthenticationService { export class AlfrescoAuthenticationService extends AuthService {
constructor(settingsService: SettingsService,
alfrescoApi: AlfrescoApi; apiService: AlfrescoApiService,
storage: StorageService) {
public loginSubject: Subject<any> = new Subject<any>(); super(settingsService, apiService, storage);
console.log('Warning: AlfrescoAuthenticationService is deprecated. Use AuthService instead.');
public logoutSubject: Subject<any> = new Subject<any>();
/**
* Constructor
* @param settingsService
* @param apiService
*/
constructor(private settingsService: AlfrescoSettingsService,
private apiService: AlfrescoApiService,
private storage: StorageService) {
this.alfrescoApi = <AlfrescoApi>new alfrescoApi({
provider: this.settingsService.getProviders(),
ticketEcm: this.getTicketEcm(),
ticketBpm: this.getTicketBpm(),
hostEcm: this.settingsService.ecmHost,
hostBpm: this.settingsService.bpmHost,
contextRoot: 'alfresco',
disableCsrf: true
});
settingsService.bpmHostSubject.subscribe((bpmHost) => {
this.alfrescoApi.changeBpmHost(bpmHost);
});
settingsService.ecmHostSubject.subscribe((ecmHost) => {
this.alfrescoApi.changeEcmHost(ecmHost);
});
settingsService.csrfSubject.subscribe((csrf) => {
this.alfrescoApi.changeCsrfConfig(csrf);
});
settingsService.providerSubject.subscribe((value) => {
this.alfrescoApi.config.provider = value;
});
this.apiService.setInstance(this.alfrescoApi);
}
/**
* The method return tru if the user is logged in
* @returns {boolean}
*/
isLoggedIn(): boolean {
return !!this.alfrescoApi.isLoggedIn();
}
/**
* Method to delegate to POST login
* @param username
* @param password
* @returns {Observable<R>|Observable<T>}
*/
login(username: string, password: string): Observable<{ type: string, ticket: any }> {
this.removeTicket();
return Observable.fromPromise(this.callApiLogin(username, password))
.map((response: any) => {
this.saveTickets();
this.loginSubject.next(response);
return {type: this.settingsService.getProviders(), ticket: response};
})
.catch(this.handleError);
}
/**
* Initialize the alfresco Api with user and password end call the login method
* @param username
* @param password
* @returns {*|Observable<any>}
*/
private callApiLogin(username: string, password: string) {
return this.alfrescoApi.login(username, password);
}
/**
* The method remove the ticket from the Storage
*
* @returns {Observable<R>|Observable<T>}
*/
public logout() {
return Observable.fromPromise(this.callApiLogout())
.map(res => <any> res)
.do(response => {
this.removeTicket();
this.logoutSubject.next(response);
return response;
})
.catch(this.handleError);
}
/**
*
* @returns {*|Observable<string>|Observable<any>|Promise<T>}
*/
private callApiLogout(): Promise<any> {
if (this.alfrescoApi) {
return this.alfrescoApi.logout();
}
}
/**
* Remove the login ticket from Storage
*/
public removeTicket(): void {
this.storage.removeItem('ticket-ECM');
this.storage.removeItem('ticket-BPM');
this.alfrescoApi.setTicket(undefined, undefined);
}
/**
* The method return the ECM ticket stored in the Storage
* @returns ticket
*/
public getTicketEcm(): string | null {
return this.storage.getItem('ticket-ECM');
}
/**
* The method return the BPM ticket stored in the Storage
* @returns ticket
*/
public getTicketBpm(): string | null {
return this.storage.getItem('ticket-BPM');
}
public getTicketEcmBase64(): string | null {
let ticket = this.storage.getItem('ticket-ECM');
if (ticket) {
return 'Basic ' + btoa(ticket);
}
return null;
}
/**
* The method save the ECM and BPM ticket in the Storage
*/
public saveTickets() {
this.saveTicketEcm();
this.saveTicketBpm();
}
/**
* The method save the ECM ticket in the Storage
*/
public saveTicketEcm(): void {
if (this.alfrescoApi && this.alfrescoApi.getTicketEcm()) {
this.storage.setItem('ticket-ECM', this.alfrescoApi.getTicketEcm());
}
}
/**
* The method save the BPM ticket in the Storage
*/
public saveTicketBpm(): void {
if (this.alfrescoApi && this.alfrescoApi.getTicketBpm()) {
this.storage.setItem('ticket-BPM', this.alfrescoApi.getTicketBpm());
}
}
/**
* The method return true if user is logged in on ecm provider
*/
public isEcmLoggedIn() {
return this.alfrescoApi.ecmAuth && !!this.alfrescoApi.ecmAuth.isLoggedIn();
}
/**
* The method return true if user is logged in on bpm provider
*/
public isBpmLoggedIn() {
return this.alfrescoApi.bpmAuth && !!this.alfrescoApi.bpmAuth.isLoggedIn();
}
/**
* The method write the error in the console browser
* @param error
* @returns {ErrorObservable}
*/
public handleError(error: any): Observable<any> {
console.error('Error when logging in', error);
return Observable.throw(error || 'Server error');
} }
} }

View File

@@ -17,30 +17,16 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { AlfrescoAuthenticationService } from './AlfrescoAuthentication.service'; import { AuthService } from './auth.service';
import { AlfrescoApiService } from './AlfrescoApi.service'; import { ContentService } from './content.service';
import { AlfrescoApiService } from './alfresco-api.service';
/** @deprecated AlfrescoContentService is deprecated. Use ContentService instead */
@Injectable() @Injectable()
export class AlfrescoContentService { export class AlfrescoContentService extends ContentService {
constructor(public authService: AlfrescoAuthenticationService, public apiService: AlfrescoApiService) { constructor(authService: AuthService, apiService: AlfrescoApiService) {
} super(authService, apiService);
console.log('Warning: AlfrescoContentService is deprecated. Use ContentService instead.');
/**
* Get thumbnail URL for the given document node.
* @param document Node to get URL for.
* @returns {string} URL address.
*/
getDocumentThumbnailUrl(document: any): string {
return this.apiService.getInstance().content.getDocumentThumbnailUrl(document.entry.id);
}
/**
* Get content URL for the given node.
* @param document Node to get URL for.
* @returns {string} URL address.
*/
getContentUrl(document: any): string {
return this.apiService.getInstance().content.getContentUrl(document.entry.id);
} }
} }

View File

@@ -16,63 +16,14 @@
*/ */
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Subject } from 'rxjs/Subject'; import { SettingsService } from './settings.service';
/** @deprecated AlfrescoSettingsService is deprecated. Use SettingsService instead */
@Injectable() @Injectable()
export class AlfrescoSettingsService { export class AlfrescoSettingsService extends SettingsService {
static DEFAULT_ECM_ADDRESS: string = 'http://' + window.location.hostname + ':8080'; constructor() {
static DEFAULT_BPM_ADDRESS: string = 'http://' + window.location.hostname + ':9999'; super();
static DEFAULT_CSRF_CONFIG: boolean = false; console.log('Warning: AlfrescoSettingsService is deprecated. Use SettingsService instead.');
static DEFAULT_BPM_CONTEXT_PATH: string = '/activiti-app';
private _ecmHost: string = AlfrescoSettingsService.DEFAULT_ECM_ADDRESS;
private _bpmHost: string = AlfrescoSettingsService.DEFAULT_BPM_ADDRESS;
private _csrfDisabled: boolean = AlfrescoSettingsService.DEFAULT_CSRF_CONFIG;
private _bpmContextPath = AlfrescoSettingsService.DEFAULT_BPM_CONTEXT_PATH;
private providers: string = 'ALL'; // ECM, BPM , ALL
public bpmHostSubject: Subject<string> = new Subject<string>();
public ecmHostSubject: Subject<string> = new Subject<string>();
public csrfSubject: Subject<boolean> = new Subject<boolean>();
public providerSubject: Subject<string> = new Subject<string>();
public get ecmHost(): string {
return this._ecmHost;
}
public set csrfDisabled(csrfDisabled: boolean) {
this.csrfSubject.next(csrfDisabled);
this._csrfDisabled = csrfDisabled;
}
public set ecmHost(ecmHostUrl: string) {
this.ecmHostSubject.next(ecmHostUrl);
this._ecmHost = ecmHostUrl;
}
public get bpmHost(): string {
return this._bpmHost;
}
public set bpmHost(bpmHostUrl: string) {
this.bpmHostSubject.next(bpmHostUrl);
this._bpmHost = bpmHostUrl;
}
public getBPMApiBaseUrl(): string {
return this._bpmHost + this._bpmContextPath;
}
public getProviders(): string {
return this.providers;
}
public setProviders(providers: string) {
this.providerSubject.next(providers);
this.providers = providers;
} }
} }

View File

@@ -16,39 +16,16 @@
*/ */
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Rx';
import { TranslateService } from 'ng2-translate/ng2-translate'; import { TranslateService } from 'ng2-translate/ng2-translate';
import { AlfrescoTranslationLoader } from './AlfrescoTranslationLoader.service'; import { AlfrescoTranslateService } from './translate.service';
/** @deprecated AlfrescoTranslationService is deprecated. Use AlfrescoTranslateService instead */
@Injectable() @Injectable()
export class AlfrescoTranslationService { export class AlfrescoTranslationService extends AlfrescoTranslateService {
userLang: string = 'en';
customLoader: AlfrescoTranslationLoader;
constructor(public translate: TranslateService) { constructor(translate: TranslateService) {
this.userLang = translate.getBrowserLang() || 'en'; super(translate);
translate.setDefaultLang(this.userLang); console.log('Warning: AlfrescoTranslationService is deprecated. Use AlfrescoTranslateService instead.');
this.customLoader = <AlfrescoTranslationLoader> this.translate.currentLoader;
this.customLoader.init(this.userLang);
} }
addTranslationFolder(name: string = '', path: string = '') {
if (!this.customLoader.existComponent(name)) {
this.customLoader.addComponentList(name, path);
this.translate.getTranslation(this.userLang).subscribe(
() => {
this.translate.use(this.userLang);
}
);
}
}
use(lang: string): Observable<any> {
this.customLoader.init(lang);
return this.translate.use(lang);
}
get(key: string|Array<string>, interpolateParams?: Object): Observable<string|any> {
return this.translate.get(key, interpolateParams);
}
} }

View File

@@ -16,6 +16,7 @@
*/ */
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import * as alfrescoApi from 'alfresco-js-api';
import { AlfrescoApi } from 'alfresco-js-api'; import { AlfrescoApi } from 'alfresco-js-api';
@Injectable() @Injectable()
@@ -31,4 +32,16 @@ export class AlfrescoApiService {
this._instance = value; this._instance = value;
} }
constructor() {
this._instance = <AlfrescoApi>new alfrescoApi({
provider: 'ALL',
ticketEcm: null,
ticketBpm: null,
hostEcm: 'http://localhost:8080',
hostBpm: 'http://localhost:9999',
contextRoot: 'alfresco',
disableCsrf: true
});
}
} }

View File

@@ -22,11 +22,11 @@ import {
RouterStateSnapshot RouterStateSnapshot
} from '@angular/router'; } from '@angular/router';
import { AlfrescoAuthenticationService } from './AlfrescoAuthentication.service'; import { AuthService } from './auth.service';
@Injectable() @Injectable()
export class AuthGuardBpm implements CanActivate, CanActivateChild { export class AuthGuardBpm implements CanActivate, CanActivateChild {
constructor(private authService: AlfrescoAuthenticationService, private router: Router) {} constructor(private authService: AuthService, private router: Router) {}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
let url: string = state.url; let url: string = state.url;

View File

@@ -22,11 +22,11 @@ import {
RouterStateSnapshot RouterStateSnapshot
} from '@angular/router'; } from '@angular/router';
import { AlfrescoAuthenticationService } from './AlfrescoAuthentication.service'; import { AuthService } from './auth.service';
@Injectable() @Injectable()
export class AuthGuardEcm implements CanActivate, CanActivateChild { export class AuthGuardEcm implements CanActivate, CanActivateChild {
constructor(private authService: AlfrescoAuthenticationService, private router: Router) {} constructor(private authService: AuthService, private router: Router) {}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
let url: string = state.url; let url: string = state.url;

View File

@@ -22,11 +22,11 @@ import {
RouterStateSnapshot RouterStateSnapshot
} from '@angular/router'; } from '@angular/router';
import { AlfrescoAuthenticationService } from './AlfrescoAuthentication.service'; import { AuthService } from './auth.service';
@Injectable() @Injectable()
export class AuthGuard implements CanActivate, CanActivateChild { export class AuthGuard implements CanActivate, CanActivateChild {
constructor(private authService: AlfrescoAuthenticationService, private router: Router) {} constructor(private authService: AuthService, private router: Router) {}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
let url: string = state.url; let url: string = state.url;

View File

@@ -16,29 +16,29 @@
*/ */
import { ReflectiveInjector } from '@angular/core'; import { ReflectiveInjector } from '@angular/core';
import { AlfrescoSettingsService } from './AlfrescoSettings.service'; import { SettingsService } from './settings.service';
import { AlfrescoAuthenticationService } from './AlfrescoAuthentication.service'; import { AuthService } from './auth.service';
import { AlfrescoApiService } from './AlfrescoApi.service'; import { AlfrescoApiService } from './alfresco-api.service';
import { StorageService } from './storage.service'; import { StorageService } from './storage.service';
declare let jasmine: any; declare let jasmine: any;
describe('AlfrescoAuthentication', () => { describe('AuthService', () => {
let injector; let injector;
let authService: AlfrescoAuthenticationService; let authService: AuthService;
let settingsService: AlfrescoSettingsService; let settingsService: SettingsService;
let storage: StorageService; let storage: StorageService;
beforeEach(() => { beforeEach(() => {
injector = ReflectiveInjector.resolveAndCreate([ injector = ReflectiveInjector.resolveAndCreate([
AlfrescoSettingsService, SettingsService,
AlfrescoApiService, AlfrescoApiService,
AlfrescoAuthenticationService, AuthService,
StorageService StorageService
]); ]);
authService = injector.get(AlfrescoAuthenticationService); authService = injector.get(AuthService);
settingsService = injector.get(AlfrescoSettingsService); settingsService = injector.get(SettingsService);
storage = injector.get(StorageService); storage = injector.get(StorageService);
storage.clear(); storage.clear();

View File

@@ -0,0 +1,209 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Injectable } from '@angular/core';
import { Observable } 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';
@Injectable()
export class AuthService {
alfrescoApi: AlfrescoApi;
loginSubject: Subject<any> = new Subject<any>();
logoutSubject: Subject<any> = new Subject<any>();
constructor(private settingsService: SettingsService,
private apiService: AlfrescoApiService,
private storage: StorageService) {
this.alfrescoApi = <AlfrescoApi>new alfrescoApi({
provider: this.settingsService.getProviders(),
ticketEcm: this.getTicketEcm(),
ticketBpm: this.getTicketBpm(),
hostEcm: this.settingsService.ecmHost,
hostBpm: this.settingsService.bpmHost,
contextRoot: 'alfresco',
disableCsrf: true
});
settingsService.bpmHostSubject.subscribe((bpmHost) => {
this.alfrescoApi.changeBpmHost(bpmHost);
});
settingsService.ecmHostSubject.subscribe((ecmHost) => {
this.alfrescoApi.changeEcmHost(ecmHost);
});
settingsService.csrfSubject.subscribe((csrf) => {
this.alfrescoApi.changeCsrfConfig(csrf);
});
settingsService.providerSubject.subscribe((value) => {
this.alfrescoApi.config.provider = value;
});
this.apiService.setInstance(this.alfrescoApi);
}
/**
* The method return tru if the user is logged in
* @returns {boolean}
*/
isLoggedIn(): boolean {
return !!this.alfrescoApi.isLoggedIn();
}
/**
* Method to delegate to POST login
* @param username
* @param password
* @returns {Observable<R>|Observable<T>}
*/
login(username: string, password: string): Observable<{ type: string, ticket: any }> {
this.removeTicket();
return Observable.fromPromise(this.callApiLogin(username, password))
.map((response: any) => {
this.saveTickets();
this.loginSubject.next(response);
return {type: this.settingsService.getProviders(), ticket: response};
})
.catch(this.handleError);
}
/**
* Initialize the alfresco Api with user and password end call the login method
* @param username
* @param password
* @returns {*|Observable<any>}
*/
private callApiLogin(username: string, password: string) {
return this.alfrescoApi.login(username, password);
}
/**
* The method remove the ticket from the Storage
*
* @returns {Observable<R>|Observable<T>}
*/
public logout() {
return Observable.fromPromise(this.callApiLogout())
.map(res => <any> res)
.do(response => {
this.removeTicket();
this.logoutSubject.next(response);
return response;
})
.catch(this.handleError);
}
/**
*
* @returns {*|Observable<string>|Observable<any>|Promise<T>}
*/
private callApiLogout(): Promise<any> {
if (this.alfrescoApi) {
return this.alfrescoApi.logout();
}
}
/**
* Remove the login ticket from Storage
*/
public removeTicket(): void {
this.storage.removeItem('ticket-ECM');
this.storage.removeItem('ticket-BPM');
this.alfrescoApi.setTicket(undefined, undefined);
}
/**
* The method return the ECM ticket stored in the Storage
* @returns ticket
*/
public getTicketEcm(): string | null {
return this.storage.getItem('ticket-ECM');
}
/**
* The method return the BPM ticket stored in the Storage
* @returns ticket
*/
public getTicketBpm(): string | null {
return this.storage.getItem('ticket-BPM');
}
public getTicketEcmBase64(): string | null {
let ticket = this.storage.getItem('ticket-ECM');
if (ticket) {
return 'Basic ' + btoa(ticket);
}
return null;
}
/**
* The method save the ECM and BPM ticket in the Storage
*/
public saveTickets() {
this.saveTicketEcm();
this.saveTicketBpm();
}
/**
* The method save the ECM ticket in the Storage
*/
public saveTicketEcm(): void {
if (this.alfrescoApi && this.alfrescoApi.getTicketEcm()) {
this.storage.setItem('ticket-ECM', this.alfrescoApi.getTicketEcm());
}
}
/**
* The method save the BPM ticket in the Storage
*/
public saveTicketBpm(): void {
if (this.alfrescoApi && this.alfrescoApi.getTicketBpm()) {
this.storage.setItem('ticket-BPM', this.alfrescoApi.getTicketBpm());
}
}
/**
* The method return true if user is logged in on ecm provider
*/
public isEcmLoggedIn() {
return this.alfrescoApi.ecmAuth && !!this.alfrescoApi.ecmAuth.isLoggedIn();
}
/**
* The method return true if user is logged in on bpm provider
*/
public isBpmLoggedIn() {
return this.alfrescoApi.bpmAuth && !!this.alfrescoApi.bpmAuth.isLoggedIn();
}
/**
* The method write the error in the console browser
* @param error
* @returns {ErrorObservable}
*/
public handleError(error: any): Observable<any> {
console.error('Error when logging in', error);
return Observable.throw(error || 'Server error');
}
}

View File

@@ -16,19 +16,19 @@
*/ */
import { ReflectiveInjector } from '@angular/core'; import { ReflectiveInjector } from '@angular/core';
import { AlfrescoSettingsService } from './AlfrescoSettings.service'; import { SettingsService } from './settings.service';
import { AlfrescoAuthenticationService } from './AlfrescoAuthentication.service'; import { AuthService } from './auth.service';
import { AlfrescoContentService } from './AlfrescoContent.service'; import { ContentService } from './content.service';
import { AlfrescoApiService } from './AlfrescoApi.service'; import { AlfrescoApiService } from './alfresco-api.service';
import { StorageService } from './storage.service'; import { StorageService } from './storage.service';
declare let jasmine: any; declare let jasmine: any;
describe('AlfrescoContentService', () => { describe('ContentService', () => {
let injector, contentService: AlfrescoContentService; let injector, contentService: ContentService;
let authService: AlfrescoAuthenticationService; let authService: AuthService;
let settingsService: AlfrescoSettingsService; let settingsService: SettingsService;
let storage: StorageService; let storage: StorageService;
let node: any; let node: any;
@@ -37,15 +37,15 @@ describe('AlfrescoContentService', () => {
beforeEach(() => { beforeEach(() => {
injector = ReflectiveInjector.resolveAndCreate([ injector = ReflectiveInjector.resolveAndCreate([
AlfrescoApiService, AlfrescoApiService,
AlfrescoContentService, ContentService,
AlfrescoAuthenticationService, AuthService,
AlfrescoSettingsService, SettingsService,
StorageService StorageService
]); ]);
authService = injector.get(AlfrescoAuthenticationService); authService = injector.get(AuthService);
settingsService = injector.get(AlfrescoSettingsService); settingsService = injector.get(SettingsService);
contentService = injector.get(AlfrescoContentService); contentService = injector.get(ContentService);
storage = injector.get(StorageService); storage = injector.get(StorageService);
storage.clear(); storage.clear();

View File

@@ -0,0 +1,47 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Injectable } from '@angular/core';
import { AuthService } from './auth.service';
import { AlfrescoApiService } from './alfresco-api.service';
@Injectable()
export class ContentService {
constructor(public authService: AuthService,
public apiService: AlfrescoApiService) {
}
/**
* Get thumbnail URL for the given document node.
* @param document Node to get URL for.
* @returns {string} URL address.
*/
getDocumentThumbnailUrl(document: any): string {
return this.apiService.getInstance().content.getDocumentThumbnailUrl(document.entry.id);
}
/**
* Get content URL for the given node.
* @param document Node to get URL for.
* @returns {string} URL address.
*/
getContentUrl(document: any): string {
return this.apiService.getInstance().content.getContentUrl(document.entry.id);
}
}

View File

@@ -16,9 +16,8 @@
*/ */
export * from './storage.service'; export * from './storage.service';
export * from './AlfrescoApi.service'; export * from './alfresco-api.service';
export * from './AlfrescoSettings.service'; export * from './AlfrescoSettings.service';
export * from './AlfrescoTranslationLoader.service';
export * from './AlfrescoTranslation.service'; export * from './AlfrescoTranslation.service';
export * from './AlfrescoAuthentication.service'; export * from './AlfrescoAuthentication.service';
export * from './AlfrescoContent.service'; export * from './AlfrescoContent.service';
@@ -26,3 +25,9 @@ export * from './renditions.service';
export * from './auth-guard.service'; export * from './auth-guard.service';
export * from './auth-guard-ecm.service'; export * from './auth-guard-ecm.service';
export * from './auth-guard-bpm.service'; export * from './auth-guard-bpm.service';
export * from './auth.service';
export * from './content.service';
export * from './settings.service';
export * from './translate.service';
export * from './translate-loader.service';

View File

@@ -16,7 +16,7 @@
*/ */
import { ReflectiveInjector } from '@angular/core'; import { ReflectiveInjector } from '@angular/core';
import { AlfrescoApiService } from './AlfrescoApi.service'; import { AlfrescoApiService } from './alfresco-api.service';
import { RenditionsService } from './renditions.service'; import { RenditionsService } from './renditions.service';
import { import {
fakeRedition, fakeRedition,

View File

@@ -17,7 +17,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Rx'; import { Observable } from 'rxjs/Rx';
import { AlfrescoApiService } from './AlfrescoApi.service'; import { AlfrescoApiService } from './alfresco-api.service';
/** /**
* RenditionsService * RenditionsService

View File

@@ -15,18 +15,18 @@
* limitations under the License. * limitations under the License.
*/ */
import { AlfrescoSettingsService } from './AlfrescoSettings.service'; import { SettingsService } from './settings.service';
describe('AlfrescoSettingsService', () => { describe('AlfrescoSettingsService', () => {
let service: AlfrescoSettingsService; let service: SettingsService;
beforeEach(() => { beforeEach(() => {
service = new AlfrescoSettingsService(); service = new SettingsService();
}); });
it('should have default ECM host', () => { it('should have default ECM host', () => {
expect(service.ecmHost).toBe(AlfrescoSettingsService.DEFAULT_ECM_ADDRESS); expect(service.ecmHost).toBe(SettingsService.DEFAULT_ECM_ADDRESS);
}); });
it('should change host ECM', () => { it('should change host ECM', () => {
@@ -37,7 +37,7 @@ describe('AlfrescoSettingsService', () => {
}); });
it('should have default BPM host', () => { it('should have default BPM host', () => {
expect(service.bpmHost).toBe(AlfrescoSettingsService.DEFAULT_BPM_ADDRESS); expect(service.bpmHost).toBe(SettingsService.DEFAULT_BPM_ADDRESS);
}); });
it('should change host BPM', () => { it('should change host BPM', () => {

View File

@@ -0,0 +1,78 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs/Subject';
@Injectable()
export class SettingsService {
static DEFAULT_ECM_ADDRESS: string = 'http://' + window.location.hostname + ':8080';
static DEFAULT_BPM_ADDRESS: string = 'http://' + window.location.hostname + ':9999';
static DEFAULT_CSRF_CONFIG: boolean = false;
static DEFAULT_BPM_CONTEXT_PATH: string = '/activiti-app';
private _ecmHost: string = SettingsService.DEFAULT_ECM_ADDRESS;
private _bpmHost: string = SettingsService.DEFAULT_BPM_ADDRESS;
private _csrfDisabled: boolean = SettingsService.DEFAULT_CSRF_CONFIG;
private _bpmContextPath = SettingsService.DEFAULT_BPM_CONTEXT_PATH;
private providers: string = 'ALL'; // ECM, BPM , ALL
public bpmHostSubject: Subject<string> = new Subject<string>();
public ecmHostSubject: Subject<string> = new Subject<string>();
public csrfSubject: Subject<boolean> = new Subject<boolean>();
public providerSubject: Subject<string> = new Subject<string>();
public get ecmHost(): string {
return this._ecmHost;
}
public set csrfDisabled(csrfDisabled: boolean) {
this.csrfSubject.next(csrfDisabled);
this._csrfDisabled = csrfDisabled;
}
public set ecmHost(ecmHostUrl: string) {
this.ecmHostSubject.next(ecmHostUrl);
this._ecmHost = ecmHostUrl;
}
public get bpmHost(): string {
return this._bpmHost;
}
public set bpmHost(bpmHostUrl: string) {
this.bpmHostSubject.next(bpmHostUrl);
this._bpmHost = bpmHostUrl;
}
public getBPMApiBaseUrl(): string {
return this._bpmHost + this._bpmContextPath;
}
public getProviders(): string {
return this.providers;
}
public setProviders(providers: string) {
this.providerSubject.next(providers);
this.providers = providers;
}
}

View File

@@ -15,17 +15,15 @@
* limitations under the License. * limitations under the License.
*/ */
import { TranslateLoader } from 'ng2-translate/ng2-translate'; import { TranslateModule, TranslateLoader } from 'ng2-translate/ng2-translate';
import { AlfrescoTranslationLoader } from '../services/AlfrescoTranslationLoader.service';
import { AlfrescoTranslationService } from '../services/AlfrescoTranslation.service';
import { Injector } from '@angular/core'; import { Injector } from '@angular/core';
import { ResponseOptions, Response, XHRBackend, HttpModule } from '@angular/http'; import { ResponseOptions, Response, XHRBackend, HttpModule } from '@angular/http';
import { MockBackend, MockConnection } from '@angular/http/testing'; import { MockBackend, MockConnection } from '@angular/http/testing';
import {
TranslateModule
} from 'ng2-translate/ng2-translate';
import {getTestBed, TestBed} from '@angular/core/testing'; import {getTestBed, TestBed} from '@angular/core/testing';
import { AlfrescoTranslateLoader } from './translate-loader.service';
import { AlfrescoTranslateService } from './translate.service';
let componentJson1 = ' {"TEST": "This is a test", "TEST2": "This is another test"} ' ; let componentJson1 = ' {"TEST": "This is a test", "TEST2": "This is another test"} ' ;
const mockBackendResponse = (connection: MockConnection, response: string) => { const mockBackendResponse = (connection: MockConnection, response: string) => {
@@ -35,7 +33,7 @@ const mockBackendResponse = (connection: MockConnection, response: string) => {
describe('TranslateLoader', () => { describe('TranslateLoader', () => {
let injector: Injector; let injector: Injector;
let backend: MockBackend; let backend: MockBackend;
let alfrescoTranslationService: AlfrescoTranslationService; let alfrescoTranslationService: AlfrescoTranslateService;
let connection: MockConnection; // this will be set when a new connection is emitted from the backend. let connection: MockConnection; // this will be set when a new connection is emitted from the backend.
let customLoader; let customLoader;
@@ -43,16 +41,16 @@ describe('TranslateLoader', () => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [HttpModule, TranslateModule.forRoot({ imports: [HttpModule, TranslateModule.forRoot({
provide: TranslateLoader, provide: TranslateLoader,
useClass: AlfrescoTranslationLoader useClass: AlfrescoTranslateLoader
})], })],
providers: [ providers: [
AlfrescoTranslationService, AlfrescoTranslateService,
{provide: XHRBackend, useClass: MockBackend} {provide: XHRBackend, useClass: MockBackend}
] ]
}); });
injector = getTestBed(); injector = getTestBed();
backend = injector.get(XHRBackend); backend = injector.get(XHRBackend);
alfrescoTranslationService = injector.get(AlfrescoTranslationService); alfrescoTranslationService = injector.get(AlfrescoTranslateService);
backend.connections.subscribe((c: MockConnection) => connection = c); backend.connections.subscribe((c: MockConnection) => connection = c);
customLoader = alfrescoTranslationService.translate.currentLoader; customLoader = alfrescoTranslationService.translate.currentLoader;
}); });
@@ -60,7 +58,7 @@ describe('TranslateLoader', () => {
it('should be able to provide any TranslateLoader', () => { it('should be able to provide any TranslateLoader', () => {
expect(alfrescoTranslationService).toBeDefined(); expect(alfrescoTranslationService).toBeDefined();
expect(alfrescoTranslationService.translate.currentLoader).toBeDefined(); expect(alfrescoTranslationService.translate.currentLoader).toBeDefined();
expect(alfrescoTranslationService.translate.currentLoader instanceof AlfrescoTranslationLoader).toBeTruthy(); expect(alfrescoTranslationService.translate.currentLoader instanceof AlfrescoTranslateLoader).toBeTruthy();
}); });
it('should add the component to the list', () => { it('should add the component to the list', () => {

View File

@@ -22,7 +22,7 @@ import { TranslateLoader } from 'ng2-translate/ng2-translate';
import { ComponentTranslationModel } from '../models/component.model'; import { ComponentTranslationModel } from '../models/component.model';
@Injectable() @Injectable()
export class AlfrescoTranslationLoader implements TranslateLoader { export class AlfrescoTranslateLoader implements TranslateLoader {
private prefix: string = 'i18n'; private prefix: string = 'i18n';
private suffix: string = '.json'; private suffix: string = '.json';

View File

@@ -15,48 +15,46 @@
* limitations under the License. * limitations under the License.
*/ */
import { AlfrescoTranslationService } from '../services/AlfrescoTranslation.service'; import { TranslateModule, TranslateLoader } from 'ng2-translate/ng2-translate';
import { TranslateLoader } from 'ng2-translate/ng2-translate';
import { AlfrescoTranslationLoader } from '../services/AlfrescoTranslationLoader.service';
import { Injector } from '@angular/core'; import { Injector } from '@angular/core';
import { ResponseOptions, Response, XHRBackend, HttpModule } from '@angular/http'; import { ResponseOptions, Response, XHRBackend, HttpModule } from '@angular/http';
import { MockBackend, MockConnection } from '@angular/http/testing'; import { MockBackend, MockConnection } from '@angular/http/testing';
import { import { getTestBed, TestBed } from '@angular/core/testing';
TranslateModule
} from 'ng2-translate/ng2-translate'; import { AlfrescoTranslateService } from './translate.service';
import {getTestBed, TestBed} from '@angular/core/testing'; import { AlfrescoTranslateLoader } from './translate-loader.service';
const mockBackendResponse = (connection: MockConnection, response: string) => { const mockBackendResponse = (connection: MockConnection, response: string) => {
connection.mockRespond(new Response(new ResponseOptions({body: response}))); connection.mockRespond(new Response(new ResponseOptions({body: response})));
}; };
describe('AlfrescoTranslationService', () => { describe('AlfrescoTranslateService', () => {
let injector: Injector; let injector: Injector;
let backend: MockBackend; let backend: MockBackend;
let alfrescoTranslationService: AlfrescoTranslationService; let alfrescoTranslationService: AlfrescoTranslateService;
let connection: MockConnection; // this will be set when a new connection is emitted from the backend. let connection: MockConnection; // this will be set when a new connection is emitted from the backend.
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [HttpModule, TranslateModule.forRoot({ imports: [HttpModule, TranslateModule.forRoot({
provide: TranslateLoader, provide: TranslateLoader,
useClass: AlfrescoTranslationLoader useClass: AlfrescoTranslateLoader
})], })],
providers: [ providers: [
AlfrescoTranslationService, AlfrescoTranslateService,
{provide: XHRBackend, useClass: MockBackend} {provide: XHRBackend, useClass: MockBackend}
] ]
}); });
injector = getTestBed(); injector = getTestBed();
backend = injector.get(XHRBackend); backend = injector.get(XHRBackend);
alfrescoTranslationService = injector.get(AlfrescoTranslationService); alfrescoTranslationService = injector.get(AlfrescoTranslateService);
backend.connections.subscribe((c: MockConnection) => connection = c); backend.connections.subscribe((c: MockConnection) => connection = c);
alfrescoTranslationService.addTranslationFolder('fake-name', 'fake-path'); alfrescoTranslationService.addTranslationFolder('fake-name', 'fake-path');
}); });
it('is defined', () => { it('is defined', () => {
expect(AlfrescoTranslationService).toBeDefined(); expect(AlfrescoTranslateService).toBeDefined();
expect(alfrescoTranslationService instanceof AlfrescoTranslationService).toBeTruthy(); expect(alfrescoTranslationService instanceof AlfrescoTranslateService).toBeTruthy();
}); });
it('should be able to get translations of the KEY: TEST', () => { it('should be able to get translations of the KEY: TEST', () => {

View File

@@ -0,0 +1,54 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Rx';
import { TranslateService } from 'ng2-translate/ng2-translate';
import { AlfrescoTranslateLoader } from './translate-loader.service';
@Injectable()
export class AlfrescoTranslateService {
userLang: string = 'en';
customLoader: AlfrescoTranslateLoader;
constructor(public translate: TranslateService) {
this.userLang = translate.getBrowserLang() || 'en';
translate.setDefaultLang(this.userLang);
this.customLoader = <AlfrescoTranslateLoader> this.translate.currentLoader;
this.customLoader.init(this.userLang);
}
addTranslationFolder(name: string = '', path: string = '') {
if (!this.customLoader.existComponent(name)) {
this.customLoader.addComponentList(name, path);
this.translate.getTranslation(this.userLang).subscribe(
() => {
this.translate.use(this.userLang);
}
);
}
}
use(lang: string): Observable<any> {
this.customLoader.init(lang);
return this.translate.use(lang);
}
get(key: string|Array<string>, interpolateParams?: Object): Observable<string|any> {
return this.translate.get(key, interpolateParams);
}
}

View File

@@ -31,7 +31,7 @@ import {
} from '@angular/core'; } from '@angular/core';
import { Subject } from 'rxjs/Rx'; import { Subject } from 'rxjs/Rx';
import { MinimalNodeEntity } from 'alfresco-js-api'; import { MinimalNodeEntity } from 'alfresco-js-api';
import { AlfrescoTranslationService } from 'ng2-alfresco-core'; import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { DataRowEvent, DataTableComponent, ObjectDataColumn } from 'ng2-alfresco-datatable'; import { DataRowEvent, DataTableComponent, ObjectDataColumn } from 'ng2-alfresco-datatable';
import { DocumentListService } from './../services/document-list.service'; import { DocumentListService } from './../services/document-list.service';
import { ContentActionModel } from './../models/content-action.model'; import { ContentActionModel } from './../models/content-action.model';
@@ -157,12 +157,12 @@ export class DocumentList implements OnInit, OnChanges, AfterContentInit {
constructor( constructor(
private documentListService: DocumentListService, private documentListService: DocumentListService,
private ngZone: NgZone, private ngZone: NgZone,
private translate: AlfrescoTranslationService) { private translateService: AlfrescoTranslateService) {
this.data = new ShareDataTableAdapter(this.documentListService, './..', []); this.data = new ShareDataTableAdapter(this.documentListService, './..', []);
if (translate) { if (translateService) {
translate.addTranslationFolder('ng2-alfresco-documentlist', 'node_modules/ng2-alfresco-documentlist/src'); translateService.addTranslationFolder('ng2-alfresco-documentlist', 'node_modules/ng2-alfresco-documentlist/src');
} }
} }

View File

@@ -24,7 +24,7 @@ import {
ViewChild ViewChild
} from '@angular/core'; } from '@angular/core';
import { DocumentListService } from './../services/document-list.service'; import { DocumentListService } from './../services/document-list.service';
import { AlfrescoTranslationService } from 'ng2-alfresco-core'; import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { ContentActionModel } from './../models/content-action.model'; import { ContentActionModel } from './../models/content-action.model';
declare let dialogPolyfill: any; declare let dialogPolyfill: any;
@@ -59,10 +59,10 @@ export class DocumentMenuAction implements OnInit {
constructor( constructor(
private documentListService: DocumentListService, private documentListService: DocumentListService,
private translate: AlfrescoTranslationService) { private translateService: AlfrescoTranslateService) {
if (translate) { if (translateService) {
translate.addTranslationFolder('ng2-alfresco-documentlist', 'node_modules/ng2-alfresco-documentlist/src'); translateService.addTranslationFolder('ng2-alfresco-documentlist', 'node_modules/ng2-alfresco-documentlist/src');
} }
} }
@@ -112,7 +112,7 @@ export class DocumentMenuAction implements OnInit {
private getErrorMessage(response: any): string { private getErrorMessage(response: any): string {
if (response.body && response.body.error.statusCode === ERROR_FOLDER_ALREADY_EXIST) { if (response.body && response.body.error.statusCode === ERROR_FOLDER_ALREADY_EXIST) {
let errorMessage: any; let errorMessage: any;
errorMessage = this.translate.get('FILE_UPLOAD.MESSAGES.FOLDER_ALREADY_EXIST'); errorMessage = this.translateService.get('FILE_UPLOAD.MESSAGES.FOLDER_ALREADY_EXIST');
return errorMessage.value; return errorMessage.value;
} }
} }

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { AlfrescoSettingsService, AlfrescoAuthenticationService, AlfrescoApiService, StorageService, AlfrescoContentService } from 'ng2-alfresco-core'; import { SettingsService, AuthService, AlfrescoApiService, StorageService, ContentService } from 'ng2-alfresco-core';
import { FileNode } from '../assets/document-library.model.mock'; import { FileNode } from '../assets/document-library.model.mock';
import { ReflectiveInjector } from '@angular/core'; import { ReflectiveInjector } from '@angular/core';
import { DocumentListService } from './document-list.service'; import { DocumentListService } from './document-list.service';
@@ -26,8 +26,8 @@ describe('DocumentListService', () => {
let injector; let injector;
let service: DocumentListService; let service: DocumentListService;
let settingsService: AlfrescoSettingsService; let settingsService: SettingsService;
let authService: AlfrescoAuthenticationService; let authService: AuthService;
let alfrescoApiService: AlfrescoApiService; let alfrescoApiService: AlfrescoApiService;
let fakeEntryNode = { let fakeEntryNode = {
@@ -94,16 +94,16 @@ describe('DocumentListService', () => {
beforeEach(() => { beforeEach(() => {
injector = ReflectiveInjector.resolveAndCreate([ injector = ReflectiveInjector.resolveAndCreate([
AlfrescoApiService, AlfrescoApiService,
AlfrescoAuthenticationService, AuthService,
AlfrescoSettingsService, SettingsService,
AlfrescoApiService, AlfrescoApiService,
AlfrescoContentService, ContentService,
DocumentListService, DocumentListService,
StorageService StorageService
]); ]);
settingsService = injector.get(AlfrescoSettingsService); settingsService = injector.get(SettingsService);
authService = injector.get(AlfrescoAuthenticationService); authService = injector.get(AuthService);
alfrescoApiService = injector.get(AlfrescoApiService); alfrescoApiService = injector.get(AlfrescoApiService);
service = injector.get(DocumentListService); service = injector.get(DocumentListService);
jasmine.Ajax.install(); jasmine.Ajax.install();

View File

@@ -19,11 +19,7 @@ import { Injectable } from '@angular/core';
import { Response } from '@angular/http'; import { Response } from '@angular/http';
import { Observable } from 'rxjs/Rx'; import { Observable } from 'rxjs/Rx';
import { NodePaging, MinimalNodeEntity } from 'alfresco-js-api'; import { NodePaging, MinimalNodeEntity } from 'alfresco-js-api';
import { import { AuthService, ContentService, AlfrescoApiService } from 'ng2-alfresco-core';
AlfrescoAuthenticationService,
AlfrescoContentService,
AlfrescoApiService
} from 'ng2-alfresco-core';
@Injectable() @Injectable()
export class DocumentListService { export class DocumentListService {
@@ -61,7 +57,9 @@ export class DocumentListService {
'application/vnd.apple.numbers': 'ft_ic_spreadsheet.svg' 'application/vnd.apple.numbers': 'ft_ic_spreadsheet.svg'
}; };
constructor(private authService: AlfrescoAuthenticationService, private contentService: AlfrescoContentService, private apiService: AlfrescoApiService) { constructor(private authService: AuthService,
private contentService: ContentService,
private apiService: AlfrescoApiService) {
} }
private getNodesPromise(folder: string, opts?: any): Promise<NodePaging> { private getNodesPromise(folder: string, opts?: any): Promise<NodePaging> {

View File

@@ -23,10 +23,10 @@ import { result, results, folderResult, noResult, errorJson } from './../assets/
import { AlfrescoSearchService } from '../services/alfresco-search.service'; import { AlfrescoSearchService } from '../services/alfresco-search.service';
import { import {
AlfrescoApiService, AlfrescoApiService,
AlfrescoSettingsService, SettingsService,
AlfrescoAuthenticationService, AuthService,
AlfrescoContentService, ContentService,
AlfrescoTranslationService, AlfrescoTranslateService,
CoreModule CoreModule
} from 'ng2-alfresco-core'; } from 'ng2-alfresco-core';
@@ -48,12 +48,12 @@ describe('AlfrescoSearchAutocompleteComponent', () => {
], ],
declarations: [ AlfrescoSearchAutocompleteComponent ], // declare the test component declarations: [ AlfrescoSearchAutocompleteComponent ], // declare the test component
providers: [ providers: [
{provide: AlfrescoTranslationService, useClass: TranslationMock}, {provide: AlfrescoTranslateService, useClass: TranslationMock},
AlfrescoThumbnailService, AlfrescoThumbnailService,
AlfrescoSettingsService, SettingsService,
AlfrescoApiService, AlfrescoApiService,
AlfrescoAuthenticationService, AuthService,
AlfrescoContentService, ContentService,
AlfrescoSearchService AlfrescoSearchService
] ]
}).compileComponents().then(() => { }).compileComponents().then(() => {
@@ -64,7 +64,7 @@ describe('AlfrescoSearchAutocompleteComponent', () => {
})); }));
it('should setup i18n folder', () => { it('should setup i18n folder', () => {
let translationService = fixture.debugElement.injector.get(AlfrescoTranslationService); let translationService = fixture.debugElement.injector.get(AlfrescoTranslateService);
spyOn(translationService, 'addTranslationFolder'); spyOn(translationService, 'addTranslationFolder');
fixture.detectChanges(); fixture.detectChanges();
expect(translationService.addTranslationFolder).toHaveBeenCalledWith('ng2-alfresco-search', 'node_modules/ng2-alfresco-search/src'); expect(translationService.addTranslationFolder).toHaveBeenCalledWith('ng2-alfresco-search', 'node_modules/ng2-alfresco-search/src');

View File

@@ -16,10 +16,10 @@
*/ */
import { Component, ElementRef, EventEmitter, Input, OnInit, OnChanges, Output, ViewChild } from '@angular/core'; import { Component, ElementRef, EventEmitter, Input, OnInit, OnChanges, Output, ViewChild } from '@angular/core';
import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { MinimalNodeEntity } from 'alfresco-js-api';
import { AlfrescoSearchService, SearchOptions } from './../services/alfresco-search.service'; import { AlfrescoSearchService, SearchOptions } from './../services/alfresco-search.service';
import { AlfrescoThumbnailService } from './../services/alfresco-thumbnail.service'; import { AlfrescoThumbnailService } from './../services/alfresco-thumbnail.service';
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
import { MinimalNodeEntity } from 'alfresco-js-api';
@Component({ @Component({
moduleId: module.id, moduleId: module.id,
@@ -70,14 +70,14 @@ export class AlfrescoSearchAutocompleteComponent implements OnInit, OnChanges {
baseComponentPath: string = module.id.replace('/components/alfresco-search.component.js', ''); baseComponentPath: string = module.id.replace('/components/alfresco-search.component.js', '');
constructor(private alfrescoSearchService: AlfrescoSearchService, constructor(private searchService: AlfrescoSearchService,
private translate: AlfrescoTranslationService, private translateService: AlfrescoTranslateService,
private alfrescoThumbnailService: AlfrescoThumbnailService) { private thumbnailService: AlfrescoThumbnailService) {
} }
ngOnInit(): void { ngOnInit(): void {
if (this.translate) { if (this.translateService) {
this.translate.addTranslationFolder('ng2-alfresco-search', 'node_modules/ng2-alfresco-search/src'); this.translateService.addTranslationFolder('ng2-alfresco-search', 'node_modules/ng2-alfresco-search/src');
} }
} }
@@ -102,7 +102,7 @@ export class AlfrescoSearchAutocompleteComponent implements OnInit, OnChanges {
orderBy: this.resultSort orderBy: this.resultSort
}; };
if (searchTerm !== null && searchTerm !== '') { if (searchTerm !== null && searchTerm !== '') {
this.alfrescoSearchService this.searchService
.getNodeQueryResults(searchTerm, searchOpts) .getNodeQueryResults(searchTerm, searchOpts)
.subscribe( .subscribe(
results => { results => {
@@ -126,7 +126,7 @@ export class AlfrescoSearchAutocompleteComponent implements OnInit, OnChanges {
*/ */
getMimeTypeIcon(node: MinimalNodeEntity): string { getMimeTypeIcon(node: MinimalNodeEntity): string {
if (node.entry.content && node.entry.content.mimeType) { if (node.entry.content && node.entry.content.mimeType) {
let icon = this.alfrescoThumbnailService.getMimeTypeIcon(node.entry.content.mimeType); let icon = this.thumbnailService.getMimeTypeIcon(node.entry.content.mimeType);
return this.resolveIconPath(icon); return this.resolveIconPath(icon);
} else if (node.entry.isFolder) { } else if (node.entry.isFolder) {
return `${this.baseComponentPath}/../assets/images/ft_ic_folder.svg`; return `${this.baseComponentPath}/../assets/images/ft_ic_folder.svg`;
@@ -144,7 +144,7 @@ export class AlfrescoSearchAutocompleteComponent implements OnInit, OnChanges {
*/ */
getMimeTypeKey(node: MinimalNodeEntity): string { getMimeTypeKey(node: MinimalNodeEntity): string {
if (node.entry.content && node.entry.content.mimeType) { if (node.entry.content && node.entry.content.mimeType) {
return 'SEARCH.ICONS.' + this.alfrescoThumbnailService.getMimeTypeKey(node.entry.content.mimeType); return 'SEARCH.ICONS.' + this.thumbnailService.getMimeTypeKey(node.entry.content.mimeType);
} else { } else {
return ''; return '';
} }

View File

@@ -22,11 +22,11 @@ import { AlfrescoThumbnailService } from './../services/alfresco-thumbnail.servi
import { TranslationMock } from './../assets/translation.service.mock'; import { TranslationMock } from './../assets/translation.service.mock';
import { result } from './../assets/alfresco-search.component.mock'; import { result } from './../assets/alfresco-search.component.mock';
import { import {
AlfrescoSettingsService, SettingsService,
AlfrescoApiService, AlfrescoApiService,
AlfrescoAuthenticationService, AuthService,
AlfrescoContentService, ContentService,
AlfrescoTranslationService, AlfrescoTranslateService,
CoreModule CoreModule
} from 'ng2-alfresco-core'; } from 'ng2-alfresco-core';
import { AlfrescoSearchService } from '../services/alfresco-search.service'; import { AlfrescoSearchService } from '../services/alfresco-search.service';
@@ -49,12 +49,12 @@ describe('AlfrescoSearchControlComponent', () => {
AlfrescoSearchAutocompleteComponent AlfrescoSearchAutocompleteComponent
], ],
providers: [ providers: [
{provide: AlfrescoTranslationService, useClass: TranslationMock}, {provide: AlfrescoTranslateService, useClass: TranslationMock},
AlfrescoThumbnailService, AlfrescoThumbnailService,
AlfrescoSettingsService, SettingsService,
AlfrescoApiService, AlfrescoApiService,
AlfrescoAuthenticationService, AuthService,
AlfrescoContentService, ContentService,
AlfrescoSearchService AlfrescoSearchService
] ]
}).compileComponents().then(() => { }).compileComponents().then(() => {
@@ -65,7 +65,7 @@ describe('AlfrescoSearchControlComponent', () => {
})); }));
it('should setup i18n folder', () => { it('should setup i18n folder', () => {
let translationService = fixture.debugElement.injector.get(AlfrescoTranslationService); let translationService = fixture.debugElement.injector.get(AlfrescoTranslateService);
spyOn(translationService, 'addTranslationFolder'); spyOn(translationService, 'addTranslationFolder');
fixture.detectChanges(); fixture.detectChanges();
expect(translationService.addTranslationFolder) expect(translationService.addTranslationFolder)

View File

@@ -17,10 +17,10 @@
import { FormControl, Validators } from '@angular/forms'; import { FormControl, Validators } from '@angular/forms';
import { Component, Input, Output, OnInit, OnDestroy, ElementRef, EventEmitter, ViewChild } from '@angular/core'; import { Component, Input, Output, OnInit, OnDestroy, ElementRef, EventEmitter, ViewChild } from '@angular/core';
import { AlfrescoTranslationService } from 'ng2-alfresco-core'; import { Observable, Subject } from 'rxjs/Rx';
import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { AlfrescoSearchAutocompleteComponent } from './alfresco-search-autocomplete.component'; import { AlfrescoSearchAutocompleteComponent } from './alfresco-search-autocomplete.component';
import { SearchTermValidator } from './../forms/search-term-validator'; import { SearchTermValidator } from './../forms/search-term-validator';
import { Observable, Subject } from 'rxjs/Rx';
@Component({ @Component({
moduleId: module.id, moduleId: module.id,
@@ -86,7 +86,7 @@ export class AlfrescoSearchControlComponent implements OnInit, OnDestroy {
private focusSubject = new Subject<FocusEvent>(); private focusSubject = new Subject<FocusEvent>();
constructor(private translate: AlfrescoTranslationService) { constructor(private translateService: AlfrescoTranslateService) {
this.searchControl = new FormControl( this.searchControl = new FormControl(
this.searchTerm, this.searchTerm,
@@ -103,7 +103,7 @@ export class AlfrescoSearchControlComponent implements OnInit, OnDestroy {
this.setupFocusEventHandlers(); this.setupFocusEventHandlers();
this.translate.addTranslationFolder('ng2-alfresco-search', 'node_modules/ng2-alfresco-search/src'); this.translateService.addTranslationFolder('ng2-alfresco-search', 'node_modules/ng2-alfresco-search/src');
} }
ngOnDestroy(): void { ngOnDestroy(): void {

View File

@@ -25,11 +25,11 @@ import { AlfrescoThumbnailService } from './../services/alfresco-thumbnail.servi
import { TranslationMock } from './../assets/translation.service.mock'; import { TranslationMock } from './../assets/translation.service.mock';
import { AlfrescoSearchService } from '../services/alfresco-search.service'; import { AlfrescoSearchService } from '../services/alfresco-search.service';
import { import {
AlfrescoSettingsService, SettingsService,
AlfrescoApiService, AlfrescoApiService,
AlfrescoAuthenticationService, AuthService,
AlfrescoContentService, ContentService,
AlfrescoTranslationService, AlfrescoTranslateService,
CoreModule, CoreModule,
StorageService StorageService
} from 'ng2-alfresco-core'; } from 'ng2-alfresco-core';
@@ -107,12 +107,12 @@ describe('AlfrescoSearchComponent', () => {
declarations: [ AlfrescoSearchComponent ], // declare the test component declarations: [ AlfrescoSearchComponent ], // declare the test component
providers: [ providers: [
AlfrescoSearchService, AlfrescoSearchService,
{provide: AlfrescoTranslationService, useClass: TranslationMock}, {provide: AlfrescoTranslateService, useClass: TranslationMock},
AlfrescoThumbnailService, AlfrescoThumbnailService,
AlfrescoSettingsService, SettingsService,
AlfrescoApiService, AlfrescoApiService,
AlfrescoAuthenticationService, AuthService,
AlfrescoContentService, ContentService,
StorageService StorageService
] ]
}).compileComponents().then(() => { }).compileComponents().then(() => {
@@ -140,8 +140,8 @@ describe('AlfrescoSearchComponent', () => {
it('should have a null search term if no query param provided via RouteParams', () => { it('should have a null search term if no query param provided via RouteParams', () => {
let injector = ReflectiveInjector.resolveAndCreate([ let injector = ReflectiveInjector.resolveAndCreate([
AlfrescoSearchService, AlfrescoSearchService,
AlfrescoAuthenticationService, AuthService,
AlfrescoSettingsService, SettingsService,
AlfrescoApiService, AlfrescoApiService,
StorageService, StorageService,
{ provide: ActivatedRoute, useValue: { params: Observable.from([{}]) } } { provide: ActivatedRoute, useValue: { params: Observable.from([{}]) } }
@@ -152,7 +152,7 @@ describe('AlfrescoSearchComponent', () => {
}); });
it('should setup i18n folder', () => { it('should setup i18n folder', () => {
let translationService = fixture.debugElement.injector.get(AlfrescoTranslationService); let translationService = fixture.debugElement.injector.get(AlfrescoTranslateService);
spyOn(translationService, 'addTranslationFolder'); spyOn(translationService, 'addTranslationFolder');
fixture.detectChanges(); fixture.detectChanges();
expect(translationService.addTranslationFolder).toHaveBeenCalledWith('ng2-alfresco-search', 'node_modules/ng2-alfresco-search/src'); expect(translationService.addTranslationFolder).toHaveBeenCalledWith('ng2-alfresco-search', 'node_modules/ng2-alfresco-search/src');

View File

@@ -19,7 +19,7 @@ import { Component, EventEmitter, Input, Output, Optional, OnChanges, SimpleChan
import { ActivatedRoute, Params } from '@angular/router'; import { ActivatedRoute, Params } from '@angular/router';
import { AlfrescoSearchService, SearchOptions } from './../services/alfresco-search.service'; import { AlfrescoSearchService, SearchOptions } from './../services/alfresco-search.service';
import { AlfrescoThumbnailService } from './../services/alfresco-thumbnail.service'; import { AlfrescoThumbnailService } from './../services/alfresco-thumbnail.service';
import { AlfrescoTranslationService } from 'ng2-alfresco-core'; import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { MinimalNodeEntity } from 'alfresco-js-api'; import { MinimalNodeEntity } from 'alfresco-js-api';
@Component({ @Component({
@@ -65,15 +65,15 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit {
baseComponentPath: string = module.id.replace('/components/alfresco-search.component.js', ''); baseComponentPath: string = module.id.replace('/components/alfresco-search.component.js', '');
constructor(private alfrescoSearchService: AlfrescoSearchService, constructor(private searchService: AlfrescoSearchService,
private translate: AlfrescoTranslationService, private translateService: AlfrescoTranslateService,
private _alfrescoThumbnailService: AlfrescoThumbnailService, private thumbnailService: AlfrescoThumbnailService,
@Optional() private route: ActivatedRoute) { @Optional() private route: ActivatedRoute) {
} }
ngOnInit(): void { ngOnInit() {
if (this.translate !== null) { if (this.translateService !== null) {
this.translate.addTranslationFolder('ng2-alfresco-search', 'node_modules/ng2-alfresco-search/src'); this.translateService.addTranslationFolder('ng2-alfresco-search', 'node_modules/ng2-alfresco-search/src');
} }
if (this.route) { if (this.route) {
this.route.params.forEach((params: Params) => { this.route.params.forEach((params: Params) => {
@@ -85,7 +85,7 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit {
} }
} }
ngOnChanges(changes: SimpleChanges): void { ngOnChanges(changes: SimpleChanges) {
if (changes['searchTerm']) { if (changes['searchTerm']) {
this.searchTerm = changes['searchTerm'].currentValue; this.searchTerm = changes['searchTerm'].currentValue;
this.displaySearchResults(this.searchTerm); this.displaySearchResults(this.searchTerm);
@@ -99,7 +99,7 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit {
*/ */
getMimeTypeIcon(node: any): string { getMimeTypeIcon(node: any): string {
if (node.entry.content && node.entry.content.mimeType) { if (node.entry.content && node.entry.content.mimeType) {
let icon = this._alfrescoThumbnailService.getMimeTypeIcon(node.entry.content.mimeType); let icon = this.thumbnailService.getMimeTypeIcon(node.entry.content.mimeType);
return this.resolveIconPath(icon); return this.resolveIconPath(icon);
} else if (node.entry.isFolder) { } else if (node.entry.isFolder) {
return `${this.baseComponentPath}/../assets/images/ft_ic_folder.svg`; return `${this.baseComponentPath}/../assets/images/ft_ic_folder.svg`;
@@ -117,7 +117,7 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit {
*/ */
getMimeTypeKey(node: any): string { getMimeTypeKey(node: any): string {
if (node.entry.content && node.entry.content.mimeType) { if (node.entry.content && node.entry.content.mimeType) {
return 'SEARCH.ICONS.' + this._alfrescoThumbnailService.getMimeTypeKey(node.entry.content.mimeType); return 'SEARCH.ICONS.' + this.thumbnailService.getMimeTypeKey(node.entry.content.mimeType);
} else { } else {
return ''; return '';
} }
@@ -127,8 +127,8 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit {
* Loads and displays search results * Loads and displays search results
* @param searchTerm Search query entered by user * @param searchTerm Search query entered by user
*/ */
private displaySearchResults(searchTerm): void { private displaySearchResults(searchTerm) {
if (searchTerm && this.alfrescoSearchService) { if (searchTerm && this.searchService) {
let searchOpts: SearchOptions = { let searchOpts: SearchOptions = {
include: ['path'], include: ['path'],
rootNodeId: this.rootNodeId, rootNodeId: this.rootNodeId,
@@ -136,7 +136,7 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit {
maxItems: this.maxResults, maxItems: this.maxResults,
orderBy: this.resultSort orderBy: this.resultSort
}; };
this.alfrescoSearchService this.searchService
.getNodeQueryResults(searchTerm, searchOpts) .getNodeQueryResults(searchTerm, searchOpts)
.subscribe( .subscribe(
results => { results => {
@@ -153,7 +153,7 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit {
} }
} }
onItemClick(node, event?: Event): void { onItemClick(node, event?: Event) {
if (this.navigate && this.navigationMode === AlfrescoSearchComponent.SINGLE_CLICK_NAVIGATION) { if (this.navigate && this.navigationMode === AlfrescoSearchComponent.SINGLE_CLICK_NAVIGATION) {
if (node && node.entry) { if (node && node.entry) {
this.navigate.emit(node); this.navigate.emit(node);

View File

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

View File

@@ -17,7 +17,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Rx'; import { Observable } from 'rxjs/Rx';
import { AlfrescoAuthenticationService, AlfrescoApiService } from 'ng2-alfresco-core'; import { AuthService, AlfrescoApiService } from 'ng2-alfresco-core';
/** /**
* Internal service used by Document List component. * Internal service used by Document List component.
@@ -25,7 +25,8 @@ import { AlfrescoAuthenticationService, AlfrescoApiService } from 'ng2-alfresco-
@Injectable() @Injectable()
export class AlfrescoSearchService { export class AlfrescoSearchService {
constructor(public authService: AlfrescoAuthenticationService, private apiService: AlfrescoApiService) { constructor(public authService: AuthService,
private apiService: AlfrescoApiService) {
} }
/** /**

View File

@@ -17,7 +17,7 @@
import { ReflectiveInjector } from '@angular/core'; import { ReflectiveInjector } from '@angular/core';
import { AlfrescoThumbnailService } from './alfresco-thumbnail.service'; import { AlfrescoThumbnailService } from './alfresco-thumbnail.service';
import { AlfrescoApiService, AlfrescoAuthenticationService, AlfrescoContentService, AlfrescoSettingsService, StorageService } from 'ng2-alfresco-core'; import { AlfrescoApiService, AuthService, ContentService, SettingsService, StorageService } from 'ng2-alfresco-core';
describe('AlfrescoThumbnailService', () => { describe('AlfrescoThumbnailService', () => {
@@ -27,9 +27,9 @@ describe('AlfrescoThumbnailService', () => {
beforeEach(() => { beforeEach(() => {
injector = ReflectiveInjector.resolveAndCreate([ injector = ReflectiveInjector.resolveAndCreate([
AlfrescoApiService, AlfrescoApiService,
AlfrescoAuthenticationService, AuthService,
AlfrescoContentService, ContentService,
AlfrescoSettingsService, SettingsService,
AlfrescoThumbnailService, AlfrescoThumbnailService,
StorageService StorageService
]); ]);

View File

@@ -16,7 +16,7 @@
*/ */
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { AlfrescoContentService } from 'ng2-alfresco-core'; import { ContentService } from 'ng2-alfresco-core';
@Injectable() @Injectable()
export class AlfrescoThumbnailService { export class AlfrescoThumbnailService {
@@ -50,7 +50,7 @@ export class AlfrescoThumbnailService {
'application/vnd.apple.numbers': 'ft_ic_spreadsheet' 'application/vnd.apple.numbers': 'ft_ic_spreadsheet'
}; };
constructor(public contentService: AlfrescoContentService) { constructor(public contentService: ContentService) {
} }
/** /**

View File

@@ -18,12 +18,7 @@
import { ComponentFixture, TestBed, async } from '@angular/core/testing'; import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { TagActionsComponent } from '../components/tag-actions.component'; import { TagActionsComponent } from '../components/tag-actions.component';
import { DebugElement } from '@angular/core'; import { DebugElement } from '@angular/core';
import { import { CoreModule } from 'ng2-alfresco-core';
AlfrescoAuthenticationService,
AlfrescoSettingsService,
AlfrescoApiService,
CoreModule
} from 'ng2-alfresco-core';
import { TagService } from '../services/tag.service'; import { TagService } from '../services/tag.service';
declare let jasmine: any; declare let jasmine: any;
@@ -38,13 +33,12 @@ describe('Test ng2-alfresco-tag Tag actions list', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
CoreModule CoreModule.forRoot()
],
declarations: [
TagActionsComponent
], ],
declarations: [TagActionsComponent],
providers: [ providers: [
AlfrescoSettingsService,
AlfrescoAuthenticationService,
AlfrescoApiService,
TagService TagService
] ]
}).compileComponents(); }).compileComponents();

View File

@@ -16,8 +16,7 @@
*/ */
import { Component, Input, Output, EventEmitter } from '@angular/core'; import { Component, Input, Output, EventEmitter } from '@angular/core';
import { AlfrescoAuthenticationService } from 'ng2-alfresco-core'; import { TagService } from './../services/tag.service';
import { TagService } from '../services/tag.service';
/** /**
* *
@@ -54,8 +53,7 @@ export class TagActionsComponent {
* Constructor * Constructor
* @param authService * @param authService
*/ */
constructor(public authService: AlfrescoAuthenticationService, private tagService: TagService) { constructor(private tagService: TagService) {
} }
ngOnChanges(changes) { ngOnChanges(changes) {

View File

@@ -15,15 +15,10 @@
* limitations under the License. * limitations under the License.
*/ */
import { DebugElement } from '@angular/core';
import { ComponentFixture, TestBed, async } from '@angular/core/testing'; import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { TagList } from '../components/tag-list.component'; import { CoreModule } from 'ng2-alfresco-core';
import { DebugElement } from '@angular/core'; import { TagList } from './../components/tag-list.component';
import {
AlfrescoAuthenticationService,
AlfrescoSettingsService,
AlfrescoApiService,
CoreModule
} from 'ng2-alfresco-core';
import { TagService } from '../services/tag.service'; import { TagService } from '../services/tag.service';
declare let jasmine: any; declare let jasmine: any;
@@ -54,13 +49,12 @@ describe('Test ng2-alfresco-tag Tag list All ECM', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
CoreModule CoreModule.forRoot()
],
declarations: [
TagList
], ],
declarations: [TagList],
providers: [ providers: [
AlfrescoSettingsService,
AlfrescoAuthenticationService,
AlfrescoApiService,
TagService TagService
] ]
}).compileComponents(); }).compileComponents();

View File

@@ -16,7 +16,6 @@
*/ */
import { Component, Output, EventEmitter } from '@angular/core'; import { Component, Output, EventEmitter } from '@angular/core';
import { AlfrescoAuthenticationService } from 'ng2-alfresco-core';
import { TagService } from '../services/tag.service'; import { TagService } from '../services/tag.service';
/** /**
@@ -42,8 +41,7 @@ export class TagList {
* Constructor * Constructor
* @param authService * @param authService
*/ */
constructor(public authService: AlfrescoAuthenticationService, private tagService: TagService) { constructor(private tagService: TagService) {
} }
ngOnInit(changes) { ngOnInit(changes) {

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