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,
"**/.DS_Store": true,
"**/*.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
Error.stackTraceLimit = Infinity;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
// jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
__karma__.loaded = function() {};

View File

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

View File

@@ -16,7 +16,7 @@
*/
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 { FormGroup, FormBuilder, FormControl } from '@angular/forms';
@@ -43,11 +43,11 @@ export class AnalyticsReportHeatMapComponent implements OnInit {
currentMetricColors: string;
metricType: string;
constructor(private translate: AlfrescoTranslationService,
constructor(private translateService: AlfrescoTranslateService,
private analyticsService: AnalyticsService,
private formBuilder: FormBuilder) {
if (translate) {
translate.addTranslationFolder('ng2-activiti-analytics', 'node_modules/ng2-activiti-analytics/src');
if (translateService) {
translateService.addTranslationFolder('ng2-activiti-analytics', 'node_modules/ng2-activiti-analytics/src');
}
}

View File

@@ -15,15 +15,16 @@
* limitations under the License.
*/
import { DebugElement } from '@angular/core';
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 { AnalyticsService } from '../services/analytics.service';
import { DebugElement } from '@angular/core';
declare let jasmine: any;
describe('Test ng2-activiti-analytics Report list', () => {
describe('AnalyticsReportListComponent', () => {
let reportList = [
{'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 component: any;
let component: AnalyticsReportListComponent;
let fixture: ComponentFixture<AnalyticsReportListComponent>;
let debug: DebugElement;
let element: HTMLElement;
@@ -43,7 +44,7 @@ describe('Test ng2-activiti-analytics Report list', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
CoreModule
CoreModule.forRoot()
],
declarations: [
AnalyticsReportListComponent
@@ -52,6 +53,10 @@ describe('Test ng2-activiti-analytics Report list', () => {
AnalyticsService
]
}).compileComponents();
let translateService = TestBed.get(AlfrescoTranslateService);
spyOn(translateService, 'addTranslationFolder').and.stub();
spyOn(translateService, 'get').and.callFake((key) => { return Observable.of(key); });
}));
beforeEach(() => {

View File

@@ -16,11 +16,9 @@
*/
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 { ReportParametersModel } from '../models/report.model';
import { Observer } from 'rxjs/Observer';
import { Observable } from 'rxjs/Observable';
@Component({
moduleId: module.id,
@@ -46,8 +44,7 @@ export class AnalyticsReportListComponent implements OnInit {
reports: ReportParametersModel[] = [];
constructor(private auth: AlfrescoAuthenticationService,
private analyticsService: AnalyticsService) {
constructor(private analyticsService: AnalyticsService) {
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 {
CoreModule
} from 'ng2-alfresco-core';
import { DebugElement, SimpleChange } from '@angular/core';
import { Observable } from 'rxjs/Rx';
import * as moment from 'moment';
import { CoreModule, AlfrescoTranslateService } from 'ng2-alfresco-core';
import { AnalyticsReportParametersComponent } from '../components/analytics-report-parameters.component';
import { WIDGET_DIRECTIVES } from '../components/widgets/index';
import { AnalyticsService } from '../services/analytics.service';
import { ReportParametersModel } from '../models/report.model';
import * as moment from 'moment';
import { DebugElement, SimpleChange } from '@angular/core';
import * as analyticParamsMock from '../assets/analyticsParamsReportComponent.mock';
declare let jasmine: 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 debug: DebugElement;
let element: HTMLElement;
@@ -44,7 +42,7 @@ describe('Test ng2-analytics-report-parameters Report Parameters ', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
CoreModule
CoreModule.forRoot()
],
declarations: [
AnalyticsReportParametersComponent,
@@ -54,6 +52,15 @@ describe('Test ng2-analytics-report-parameters Report Parameters ', () => {
AnalyticsService
]
}).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(() => {
@@ -62,10 +69,6 @@ describe('Test ng2-analytics-report-parameters Report Parameters ', () => {
debug = fixture.debugElement;
element = fixture.nativeElement;
fixture.detectChanges();
componentHandler = jasmine.createSpyObj('componentHandler', [
'upgradeAllRegistered'
]);
window['componentHandler'] = componentHandler;
});
describe('Rendering tests', () => {
@@ -323,9 +326,9 @@ describe('Test ng2-analytics-report-parameters Report Parameters ', () => {
responseText: analyticParamsMock.reportDefParamProcessDefOptionsApp
});
let appId = 1;
let appId = '1';
component.appId = appId;
component.reportId = 1;
component.reportId = '1';
let change = new SimpleChange(null, appId);
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');
});
component.reportId = 100;
component.reportId = '100';
component.reportParameters = new ReportParametersModel(analyticParamsMock.reportDefParamTask);
component.onProcessDefinitionChanges(analyticParamsMock.fieldProcessDef);

View File

@@ -16,7 +16,7 @@
*/
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 { ReportParametersModel, ReportQuery, ParameterValueModel, ReportParameterDetailsModel } from '../models/report.model';
import { FormGroup, FormBuilder, FormControl } from '@angular/forms';
@@ -70,11 +70,11 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
private paramOpts;
private isEditable: boolean = false;
constructor(private translate: AlfrescoTranslationService,
constructor(private translateService: AlfrescoTranslateService,
private analyticsService: AnalyticsService,
private formBuilder: FormBuilder ) {
if (translate) {
translate.addTranslationFolder('ng2-activiti-analytics', 'node_modules/ng2-activiti-analytics/src');
if (translateService) {
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 {
CoreModule
} from 'ng2-alfresco-core';
import { DebugElement, SimpleChange } from '@angular/core';
import { Observable } from 'rxjs/Rx';
import { CHART_DIRECTIVES } from 'ng2-charts/ng2-charts';
import { CoreModule, AlfrescoTranslateService } from 'ng2-alfresco-core';
import { DiagramsModule } from 'ng2-activiti-diagrams';
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 { AnalyticsReportHeatMapComponent } from '../components/analytics-report-heat-map.component';
import { WIDGET_DIRECTIVES } from '../components/widgets/index';
import { CHART_DIRECTIVES } from 'ng2-charts/ng2-charts';
import { Chart } from '../models/chart.model';
import { AnalyticsService } from '../services/analytics.service';
import { ReportQuery } from '../models/report.model';
import { DebugElement, SimpleChange } from '@angular/core';
import * as analyticMock from '../assets/analyticsComponent.mock';
export const ANALYTICS_DIRECTIVES: any[] = [
@@ -47,7 +46,7 @@ export const ANALYTICS_PROVIDERS: any[] = [
declare let jasmine: any;
declare let mdDateTimePicker: any;
describe('Test ng2-activiti-analytics Report ', () => {
describe('AnalyticsComponent', () => {
let component: any;
let fixture: ComponentFixture<AnalyticsComponent>;
@@ -59,8 +58,8 @@ describe('Test ng2-activiti-analytics Report ', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
CoreModule,
DiagramsModule
CoreModule.forRoot(),
DiagramsModule.forRoot()
],
declarations: [
...ANALYTICS_DIRECTIVES,
@@ -70,6 +69,10 @@ describe('Test ng2-activiti-analytics Report ', () => {
...ANALYTICS_PROVIDERS
]
}).compileComponents();
let translateService = TestBed.get(AlfrescoTranslateService);
spyOn(translateService, 'addTranslationFolder').and.stub();
spyOn(translateService, 'get').and.callFake((key) => { return Observable.of(key); });
}));
beforeEach(() => {

View File

@@ -16,7 +16,7 @@
*/
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 { ReportQuery } from '../models/report.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) {
console.log('AnalyticsComponent');
if (translate) {
translate.addTranslationFolder('ng2-activiti-analytics', 'node_modules/ng2-activiti-analytics/src');
if (translateService) {
translateService.addTranslationFolder('ng2-activiti-analytics', 'node_modules/ng2-activiti-analytics/src');
}
}

View File

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

View File

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

View File

@@ -16,7 +16,7 @@
*/
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 { DiagramColorService } from '../services/diagram-color.service';
import { RaphaelService } from './raphael/raphael.service';
@@ -60,12 +60,12 @@ export class DiagramComponent {
private elementRef: ElementRef;
constructor(elementRef: ElementRef,
private translate: AlfrescoTranslationService,
private translateService: AlfrescoTranslateService,
private diagramColorService: DiagramColorService,
private raphaelService: RaphaelService,
private diagramsService: DiagramsService) {
if (translate) {
translate.addTranslationFolder('ng2-activiti-diagrams', 'node_modules/ng2-activiti-diagrams/src');
if (translateService) {
translateService.addTranslationFolder('ng2-activiti-diagrams', 'node_modules/ng2-activiti-diagrams/src');
}
this.elementRef = elementRef;
}

View File

@@ -16,16 +16,16 @@
*/
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 { Response, Http, Headers, RequestOptions } from '@angular/http';
@Injectable()
export class DiagramsService {
constructor(private authService: AlfrescoAuthenticationService,
constructor(private authService: AuthService,
private http: Http,
private alfrescoSettingsService: AlfrescoSettingsService) {
private alfrescoSettingsService: SettingsService) {
}
getProcessDefinitionModel(processDefinitionId: string): Observable<any> {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -123,7 +123,7 @@ describe('RadioButtonsWidget', () => {
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();
widget.onOptionClick('fake-opt');

View File

@@ -17,7 +17,7 @@
import { Injectable } from '@angular/core';
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 { ExternalContentLink } from '../components/widgets/core/external-content-link';
import { AlfrescoApi } from 'alfresco-js-api';
@@ -28,7 +28,7 @@ export class ActivitiAlfrescoContentService {
static UNKNOWN_ERROR_MESSAGE: string = 'Unknown 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 {
AlfrescoAuthenticationService,
AlfrescoSettingsService,
AlfrescoApiService,
StorageService
} from 'ng2-alfresco-core';
import { EcmModelService } from './ecm-model.service';
import { Observable } from 'rxjs/Rx';
import { FormModel } from '../components/widgets/core/form.model';
import { HttpModule } from '@angular/http';
import { CoreModule } from 'ng2-alfresco-core';
import { EcmModelService } from './ecm-model.service';
import { FormModel } from './../components/widgets/core/form.model';
declare let jasmine: any;
@@ -33,15 +27,13 @@ describe('EcmModelService', () => {
let service: EcmModelService;
beforeAll(() => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpModule],
imports: [
CoreModule.forRoot()
],
providers: [
AlfrescoSettingsService,
AlfrescoApiService,
AlfrescoAuthenticationService,
EcmModelService,
StorageService
EcmModelService
]
});
service = TestBed.get(EcmModelService);

View File

@@ -16,8 +16,8 @@
*/
import { Injectable } from '@angular/core';
import { AlfrescoAuthenticationService, AlfrescoApiService } from 'ng2-alfresco-core';
import { Observable } from 'rxjs/Rx';
import { AlfrescoApiService } from 'ng2-alfresco-core';
import { FormModel } from '../components/widgets/core/form.model';
@Injectable()
@@ -27,8 +27,7 @@ export class EcmModelService {
public static MODEL_NAME: string = 'activitiFormsModel';
public static TYPE_MODEL: string = 'cm:folder';
constructor(private authService: AlfrescoAuthenticationService,
public apiService: AlfrescoApiService) {
constructor(public apiService: AlfrescoApiService) {
}
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 { EcmModelService } from './ecm-model.service';
import { FormDefinitionModel } from '../models/form-definition.model';
import { HttpModule, Response, ResponseOptions } from '@angular/http';
import { Response, ResponseOptions } from '@angular/http';
declare let jasmine: any;
describe('FormService', () => {
let responseBody: any, service: FormService, apiService: AlfrescoApiService;
let responseBody: any;
let service: FormService;
let apiService: AlfrescoApiService;
beforeAll(() => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpModule, CoreModule],
imports: [
CoreModule.forRoot()
],
providers: [
EcmModelService,
AlfrescoApiService,
FormService
]
});

View File

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

View File

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

View File

@@ -15,8 +15,8 @@
* limitations under the License.
*/
import { ReflectiveInjector } from '@angular/core';
import { AlfrescoApi } from 'alfresco-js-api';
import { TestBed } from '@angular/core/testing';
import { CoreModule } from 'ng2-alfresco-core';
import {
formTest,
fakeTaskProcessVariableModels,
@@ -24,41 +24,28 @@ import {
fakeFormJson
} from './assets/widget-visibility.service.mock';
import { WidgetVisibilityService } from './widget-visibility.service';
import {
AlfrescoAuthenticationService,
AlfrescoSettingsService,
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';
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;
describe('WidgetVisibilityService', () => {
let service, injector;
let authenticationService: AlfrescoAuthenticationService;
let apiService: AlfrescoApiService;
let alfrescoApi: AlfrescoApi;
let service: WidgetVisibilityService;
let booleanResult: boolean;
let stubFormWithFields = new FormModel(fakeFormJson);
beforeEach(() => {
injector = ReflectiveInjector.resolveAndCreate([
WidgetVisibilityService,
AlfrescoSettingsService,
AlfrescoApiService,
AlfrescoAuthenticationService,
StorageService
]);
});
beforeEach(() => {
service = injector.get(WidgetVisibilityService);
authenticationService = injector.get(AlfrescoAuthenticationService);
apiService = injector.get(AlfrescoApiService);
alfrescoApi = apiService.getInstance();
TestBed.configureTestingModule({
imports: [
CoreModule.forRoot()
],
providers: [
WidgetVisibilityService
]
});
service = TestBed.get(WidgetVisibilityService);
jasmine.Ajax.install();
});

View File

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

View File

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

View File

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

View File

@@ -15,26 +15,21 @@
* 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 { ProcessFilterRequestRepresentation } from '../models/process-instance-filter.model';
import { ProcessInstanceVariable } from './../models/process-instance-variable.model';
import {
AppDefinitionRepresentationModel,
Comment,
TaskDetailsModel,
User
} from 'ng2-activiti-tasklist';
import { AppDefinitionRepresentationModel, Comment, TaskDetailsModel, User } from 'ng2-activiti-tasklist';
import { FilterProcessRepresentationModel } from '../models/filter-process.model';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
declare var moment: any;
@Injectable()
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
Error.stackTraceLimit = Infinity;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
// jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
__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 { 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 { ActivitiApps } from './activiti-apps.component';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
import { TranslationMock } from './../assets/translation.service.mock';
import { defaultApp, deployedApps, nonDeployedApps } from './../assets/activiti-apps.mock';
describe('ActivitiApps', () => {
@@ -45,10 +43,13 @@ describe('ActivitiApps', () => {
ActivitiApps
],
providers: [
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
ActivitiTaskListService
]
}).compileComponents();
let translateService = TestBed.get(AlfrescoTranslateService);
spyOn(translateService, 'addTranslationFolder').and.stub();
spyOn(translateService, 'get').and.callFake((key) => { return Observable.of(key); });
}));
beforeEach(() => {
@@ -56,8 +57,8 @@ describe('ActivitiApps', () => {
fixture = TestBed.createComponent(ActivitiApps);
component = fixture.componentInstance;
debugElement = fixture.debugElement;
service = fixture.debugElement.injector.get(ActivitiTaskListService);
service = fixture.debugElement.injector.get(ActivitiTaskListService);
getAppsSpy = spyOn(service, 'getDeployedApplications').and.returnValue(Observable.of());
componentHandler = jasmine.createSpyObj('componentHandler', [

View File

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

View File

@@ -15,15 +15,12 @@
* limitations under the License.
*/
import {
CoreModule,
AlfrescoTranslationService
} from 'ng2-alfresco-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 { 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';
declare let jasmine: any;
@@ -33,7 +30,7 @@ const fakeTaskDetail = new TaskDetailsModel({
name: 'fake-check-name'
});
describe('Activiti Checklist Component', () => {
describe('ActivitiChecklist', () => {
let checklistComponent: ActivitiChecklist;
let fixture: ComponentFixture<ActivitiChecklist>;
@@ -42,15 +39,24 @@ describe('Activiti Checklist Component', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [CoreModule],
declarations: [ActivitiChecklist],
imports: [
CoreModule.forRoot()
],
declarations: [
ActivitiChecklist
],
providers: [
{provide: AlfrescoTranslationService, useClass: TranslationMock},
ActivitiTaskListService]
ActivitiTaskListService
]
}).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);
checklistComponent = fixture.componentInstance;
element = fixture.nativeElement;
fixture.detectChanges();
});
}));

View File

@@ -16,7 +16,7 @@
*/
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 { TaskDetailsModel } from '../models/task-details.model';
import { Observer, Observable } from 'rxjs/Rx';
@@ -53,11 +53,11 @@ export class ActivitiChecklist implements OnInit, OnChanges {
* @param auth
* @param translate
*/
constructor(private translate: AlfrescoTranslationService,
constructor(private translateService: AlfrescoTranslateService,
private activitiTaskList: ActivitiTaskListService) {
if (translate) {
translate.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src');
if (translateService) {
translateService.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src');
}
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 { 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 { ActivitiComments } from './activiti-comments.component';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
import { TranslationMock } from './../assets/translation.service.mock';
describe('ActivitiTaskDetails', () => {
describe('ActivitiComments', () => {
let componentHandler: any;
let service: ActivitiTaskListService;
@@ -39,32 +38,32 @@ describe('ActivitiTaskDetails', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
CoreModule,
ActivitiFormModule
CoreModule.forRoot(),
ActivitiFormModule.forRoot()
],
declarations: [
ActivitiComments
],
providers: [
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
ActivitiTaskListService
]
}).compileComponents();
let translateService = TestBed.get(AlfrescoTranslateService);
spyOn(translateService, 'addTranslationFolder').and.stub();
spyOn(translateService, 'get').and.callFake((key) => { return Observable.of(key); });
}));
beforeEach(() => {
fixture = TestBed.createComponent(ActivitiComments);
component = fixture.componentInstance;
service = fixture.debugElement.injector.get(ActivitiTaskListService);
getCommentsSpy = spyOn(service, 'getTaskComments').and.returnValue(Observable.of([{
message: 'Test1'
}, {
message: 'Test2'
}, {
message: 'Test3'
}]));
getCommentsSpy = spyOn(service, 'getTaskComments').and.returnValue(Observable.of([
{ message: 'Test1' },
{ message: 'Test2' },
{ message: 'Test3'}
]));
addCommentSpy = spyOn(service, 'addTaskComment').and.returnValue(Observable.of({id: 123, message: 'Test'}));
componentHandler = jasmine.createSpyObj('componentHandler', [

View File

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

View File

@@ -42,8 +42,8 @@ describe('ActivitiFilters', () => {
});
beforeEach(() => {
let activitiService = new ActivitiTaskListService(null, null);
filterList = new ActivitiFilters(null, null, activitiService);
let activitiService = new ActivitiTaskListService(null);
filterList = new ActivitiFilters(null, activitiService);
});
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 { AlfrescoTranslationService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
import { FilterRepresentationModel } from '../models/filter.model';
import { Observer } from 'rxjs/Observer';
@@ -55,19 +55,12 @@ export class ActivitiFilters implements OnInit, OnChanges {
filters: FilterRepresentationModel [] = [];
/**
* Constructor
* @param auth
* @param translate
* @param activiti
*/
constructor(private auth: AlfrescoAuthenticationService,
private translate: AlfrescoTranslationService,
constructor(private translateService: AlfrescoTranslateService,
public activiti: ActivitiTaskListService) {
this.filter$ = new Observable<FilterRepresentationModel>(observer => this.filterObserver = observer).share();
if (translate) {
translate.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src');
if (translateService) {
translateService.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src');
}
}

View File

@@ -15,15 +15,11 @@
* 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 { User } from '../models/user.model';
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;
@@ -41,7 +37,7 @@ const fakeSecondUser: User = new User({
email: 'fake-involve@mail.com'
});
describe('Activiti People Search', () => {
describe('ActivitiPeopleSearch', () => {
let activitiPeopleSearchComponent: ActivitiPeopleSearch;
let fixture: ComponentFixture<ActivitiPeopleSearch>;
@@ -52,11 +48,18 @@ describe('Activiti People Search', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [CoreModule],
declarations: [ActivitiPeopleSearch],
providers: [
{provide: AlfrescoTranslationService, useClass: TranslationMock}]
imports: [
CoreModule.forRoot()
],
declarations: [
ActivitiPeopleSearch
]
}).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);
activitiPeopleSearchComponent = fixture.componentInstance;
element = fixture.nativeElement;

View File

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

View File

@@ -15,15 +15,12 @@
* limitations under the License.
*/
import {
CoreModule,
AlfrescoTranslationService
} from 'ng2-alfresco-core';
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { Observable } from 'rxjs/Rx';
import { CoreModule, AlfrescoTranslateService } from 'ng2-alfresco-core';
import { ActivitiPeopleService } from '../services/activiti-people.service';
import { ActivitiPeople } from './activiti-people.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';
declare let jasmine: any;
@@ -42,7 +39,7 @@ const fakeUserToInvolve: User = new User({
email: 'fake-involve@mail.com'
});
describe('Activiti People Component', () => {
describe('ActivitiPeople', () => {
let activitiPeopleComponent: ActivitiPeople;
let fixture: ComponentFixture<ActivitiPeople>;
@@ -51,12 +48,21 @@ describe('Activiti People Component', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [CoreModule],
declarations: [ActivitiPeople, ActivitiPeopleSearch],
imports: [
CoreModule.forRoot()
],
declarations: [
ActivitiPeople,
ActivitiPeopleSearch
],
providers: [
{provide: AlfrescoTranslationService, useClass: TranslationMock},
ActivitiPeopleService]
ActivitiPeopleService
]
}).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);
activitiPeopleComponent = fixture.componentInstance;
element = fixture.nativeElement;

View File

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

View File

@@ -15,19 +15,15 @@
* 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 { 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;
describe('Activiti Start Task Component', () => {
describe('ActivitiStartTaskButton', () => {
let activitiStartTaskButton: ActivitiStartTaskButton;
let fixture: ComponentFixture<ActivitiStartTaskButton>;
@@ -37,12 +33,20 @@ describe('Activiti Start Task Component', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [CoreModule],
declarations: [ActivitiStartTaskButton],
imports: [
CoreModule.forRoot()
],
declarations: [
ActivitiStartTaskButton
],
providers: [
{provide: AlfrescoTranslationService, useClass: TranslationMock},
ActivitiTaskListService]
ActivitiTaskListService
]
}).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);
activitiStartTaskButton = fixture.componentInstance;
element = fixture.nativeElement;

View File

@@ -16,7 +16,7 @@
*/
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 { ActivitiTaskListService } from './../services/activiti-tasklist.service';
import { Form } from '../models/form.model';
@@ -54,11 +54,11 @@ export class ActivitiStartTaskButton {
* @param translate
* @param taskService
*/
constructor(private translate: AlfrescoTranslationService,
constructor(private translateService: AlfrescoTranslateService,
private taskService: ActivitiTaskListService) {
if (translate) {
translate.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src');
if (translateService) {
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 { 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 { ActivitiTaskDetails } from './activiti-task-details.component';
import { ActivitiTaskListService } from './../services/activiti-tasklist.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';
describe('ActivitiTaskDetails', () => {
@@ -44,19 +43,22 @@ describe('ActivitiTaskDetails', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
CoreModule,
ActivitiFormModule
CoreModule.forRoot(),
ActivitiFormModule.forRoot()
],
declarations: [
ActivitiTaskDetails
],
providers: [
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
ActivitiTaskListService,
ActivitiPeopleService
],
schemas: [ NO_ERRORS_SCHEMA ]
}).compileComponents();
let translateService = TestBed.get(AlfrescoTranslateService);
spyOn(translateService, 'addTranslationFolder').and.stub();
spyOn(translateService, 'get').and.callFake((key) => { return Observable.of(key); });
}));
beforeEach(() => {

View File

@@ -27,7 +27,7 @@ import {
SimpleChanges,
DebugElement
} from '@angular/core';
import { AlfrescoTranslationService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
import { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
import { TaskDetailsModel } from '../models/task-details.model';
import { User } from '../models/user.model';
@@ -101,13 +101,12 @@ export class ActivitiTaskDetails implements OnInit, OnChanges {
* @param activitiForm Form service
* @param activitiTaskList Task service
*/
constructor(private auth: AlfrescoAuthenticationService,
private translate: AlfrescoTranslationService,
constructor(private translateService: AlfrescoTranslateService,
private activitiForm: FormService,
private activitiTaskList: ActivitiTaskListService) {
if (translate) {
translate.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src');
if (translateService) {
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 { By } from '@angular/platform-browser';
import { AlfrescoTranslationService, CoreModule } from 'ng2-alfresco-core';
import { Observable } from 'rxjs/Rx';
import { CoreModule, AlfrescoTranslateService } from 'ng2-alfresco-core';
import { ActivitiTaskHeader } from './activiti-task-header.component';
import { TranslationMock } from './../assets/translation.service.mock';
import { taskDetailsMock } from './../assets/task-details.mock';
import { TaskDetailsModel } from '../models/task-details.model';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
@@ -36,23 +35,25 @@ describe('ActivitiTaskHeader', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
CoreModule
CoreModule.forRoot()
],
declarations: [
ActivitiTaskHeader
],
providers: [
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
ActivitiTaskListService
]
}).compileComponents();
let translateService = TestBed.get(AlfrescoTranslateService);
spyOn(translateService, 'addTranslationFolder').and.stub();
spyOn(translateService, 'get').and.callFake((key) => { return Observable.of(key); });
}));
beforeEach(() => {
fixture = TestBed.createComponent(ActivitiTaskHeader);
component = fixture.componentInstance;
service = fixture.debugElement.injector.get(ActivitiTaskListService);
service = TestBed.get(ActivitiTaskListService);
component.taskDetails = new TaskDetailsModel(taskDetailsMock);

View File

@@ -16,7 +16,7 @@
*/
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 { ActivitiTaskListService } from './../services/activiti-tasklist.service';
@@ -37,10 +37,10 @@ export class ActivitiTaskHeader {
@Output()
claim: EventEmitter<any> = new EventEmitter<any>();
constructor(private translate: AlfrescoTranslationService,
constructor(private translateService: AlfrescoTranslateService,
private activitiTaskService: ActivitiTaskListService) {
if (translate) {
translate.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src');
if (translateService) {
translateService.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src');
}
}

View File

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

View File

@@ -16,7 +16,7 @@
*/
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 { ActivitiTaskListService } from './../services/activiti-tasklist.service';
import { TaskQueryRequestRepresentationModel } from '../models/filter.model';
@@ -72,10 +72,10 @@ export class ActivitiTaskList implements OnInit, OnChanges {
{type: 'text', key: 'created', title: 'Created', sortable: true}
];
constructor(private translate: AlfrescoTranslationService,
public activiti: ActivitiTaskListService) {
if (translate) {
translate.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src');
constructor(private translateService: AlfrescoTranslateService,
private taskListService: ActivitiTaskListService) {
if (translateService) {
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) {
this.activiti.getTotalTasks(requestNode).subscribe(
this.taskListService.getTotalTasks(requestNode).subscribe(
(res) => {
requestNode.size = res.total;
this.activiti.getTasks(requestNode).subscribe(
this.taskListService.getTasks(requestNode).subscribe(
(response) => {
let instancesRow = this.createDataRow(response);
this.renderInstances(instancesRow);

View File

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

View File

@@ -15,13 +15,8 @@
* limitations under the License.
*/
import { ReflectiveInjector } from '@angular/core';
import {
AlfrescoAuthenticationService,
AlfrescoSettingsService,
AlfrescoApiService,
StorageService
} from 'ng2-alfresco-core';
import { TestBed } from '@angular/core/testing';
import { CoreModule } from 'ng2-alfresco-core';
import { User } from '../models/user.model';
import { ActivitiPeopleService } from './activiti-people.service';
@@ -45,28 +40,18 @@ const fakeInvolveUserList: User[] = [firstInvolvedUser, secondInvolvedUser];
describe('ActivitiPeopleService', () => {
let service, injector, apiService;
let service: ActivitiPeopleService;
beforeEach(() => {
injector = ReflectiveInjector.resolveAndCreate([
AlfrescoSettingsService,
AlfrescoApiService,
AlfrescoAuthenticationService,
ActivitiPeopleService,
StorageService
]);
});
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');
TestBed.configureTestingModule({
imports: [
CoreModule.forRoot()
],
providers: [
ActivitiPeopleService
]
});
service = TestBed.get(ActivitiPeopleService);
});
describe('when user is logged in', () => {

View File

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

View File

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

View File

@@ -16,10 +16,9 @@
*/
import { Injectable } from '@angular/core';
import { AlfrescoAuthenticationService, AlfrescoApiService } from 'ng2-alfresco-core';
import { AlfrescoApiService } from 'ng2-alfresco-core';
import { Observable } from 'rxjs/Rx';
import { FilterRepresentationModel } from '../models/filter.model';
import { TaskQueryRequestRepresentationModel } from '../models/filter.model';
import { FilterRepresentationModel, TaskQueryRequestRepresentationModel } from '../models/filter.model';
import { Comment } from '../models/comment.model';
import { User } from '../models/user.model';
import { TaskDetailsModel } from '../models/task-details.model';
@@ -28,7 +27,7 @@ import { Form } from '../models/form.model';
@Injectable()
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);
}
private callApiTaskFilters(appId?: string) {
callApiTaskFilters(appId?: string) {
if (appId) {
return this.apiService.getInstance().activiti.userFiltersApi.getUserTaskFilters({appId: appId});
} else {

View File

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

View File

@@ -5,7 +5,7 @@
"author": "Alfresco Software, Ltd.",
"scripts": {
"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: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'",

View File

@@ -16,204 +16,18 @@
*/
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Rx';
import { AlfrescoSettingsService } from './AlfrescoSettings.service';
import { SettingsService } from './settings.service';
import { StorageService } from './storage.service';
import { AlfrescoApiService } from './AlfrescoApi.service';
import * as alfrescoApi from 'alfresco-js-api';
import { AlfrescoApi } from 'alfresco-js-api';
import { Subject } from 'rxjs/Subject';
import { AlfrescoApiService } from './alfresco-api.service';
import { AuthService } from './auth.service';
/**
* The AlfrescoAuthenticationService provide the login service and store the ticket in the Storage
*/
/** @deprecated AlfrescoAuthenticationService is deprecated. Use AuthService instead */
@Injectable()
export class AlfrescoAuthenticationService {
alfrescoApi: AlfrescoApi;
public loginSubject: Subject<any> = new Subject<any>();
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');
export class AlfrescoAuthenticationService extends AuthService {
constructor(settingsService: SettingsService,
apiService: AlfrescoApiService,
storage: StorageService) {
super(settingsService, apiService, storage);
console.log('Warning: AlfrescoAuthenticationService is deprecated. Use AuthService instead.');
}
}

View File

@@ -17,30 +17,16 @@
import { Injectable } from '@angular/core';
import { AlfrescoAuthenticationService } from './AlfrescoAuthentication.service';
import { AlfrescoApiService } from './AlfrescoApi.service';
import { AuthService } from './auth.service';
import { ContentService } from './content.service';
import { AlfrescoApiService } from './alfresco-api.service';
/** @deprecated AlfrescoContentService is deprecated. Use ContentService instead */
@Injectable()
export class AlfrescoContentService {
export class AlfrescoContentService extends ContentService {
constructor(public authService: AlfrescoAuthenticationService, 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);
constructor(authService: AuthService, apiService: AlfrescoApiService) {
super(authService, apiService);
console.log('Warning: AlfrescoContentService is deprecated. Use ContentService instead.');
}
}

View File

@@ -16,63 +16,14 @@
*/
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs/Subject';
import { SettingsService } from './settings.service';
/** @deprecated AlfrescoSettingsService is deprecated. Use SettingsService instead */
@Injectable()
export class AlfrescoSettingsService {
export class AlfrescoSettingsService extends 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 = 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;
constructor() {
super();
console.log('Warning: AlfrescoSettingsService is deprecated. Use SettingsService instead.');
}
}

View File

@@ -16,39 +16,16 @@
*/
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Rx';
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()
export class AlfrescoTranslationService {
userLang: string = 'en';
customLoader: AlfrescoTranslationLoader;
export class AlfrescoTranslationService extends AlfrescoTranslateService {
constructor(public translate: TranslateService) {
this.userLang = translate.getBrowserLang() || 'en';
translate.setDefaultLang(this.userLang);
this.customLoader = <AlfrescoTranslationLoader> this.translate.currentLoader;
this.customLoader.init(this.userLang);
constructor(translate: TranslateService) {
super(translate);
console.log('Warning: AlfrescoTranslationService is deprecated. Use AlfrescoTranslateService instead.');
}
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 * as alfrescoApi from 'alfresco-js-api';
import { AlfrescoApi } from 'alfresco-js-api';
@Injectable()
@@ -31,4 +32,16 @@ export class AlfrescoApiService {
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
} from '@angular/router';
import { AlfrescoAuthenticationService } from './AlfrescoAuthentication.service';
import { AuthService } from './auth.service';
@Injectable()
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 {
let url: string = state.url;

View File

@@ -22,11 +22,11 @@ import {
RouterStateSnapshot
} from '@angular/router';
import { AlfrescoAuthenticationService } from './AlfrescoAuthentication.service';
import { AuthService } from './auth.service';
@Injectable()
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 {
let url: string = state.url;

View File

@@ -22,11 +22,11 @@ import {
RouterStateSnapshot
} from '@angular/router';
import { AlfrescoAuthenticationService } from './AlfrescoAuthentication.service';
import { AuthService } from './auth.service';
@Injectable()
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 {
let url: string = state.url;

View File

@@ -16,29 +16,29 @@
*/
import { ReflectiveInjector } from '@angular/core';
import { AlfrescoSettingsService } from './AlfrescoSettings.service';
import { AlfrescoAuthenticationService } from './AlfrescoAuthentication.service';
import { AlfrescoApiService } from './AlfrescoApi.service';
import { SettingsService } from './settings.service';
import { AuthService } from './auth.service';
import { AlfrescoApiService } from './alfresco-api.service';
import { StorageService } from './storage.service';
declare let jasmine: any;
describe('AlfrescoAuthentication', () => {
describe('AuthService', () => {
let injector;
let authService: AlfrescoAuthenticationService;
let settingsService: AlfrescoSettingsService;
let authService: AuthService;
let settingsService: SettingsService;
let storage: StorageService;
beforeEach(() => {
injector = ReflectiveInjector.resolveAndCreate([
AlfrescoSettingsService,
SettingsService,
AlfrescoApiService,
AlfrescoAuthenticationService,
AuthService,
StorageService
]);
authService = injector.get(AlfrescoAuthenticationService);
settingsService = injector.get(AlfrescoSettingsService);
authService = injector.get(AuthService);
settingsService = injector.get(SettingsService);
storage = injector.get(StorageService);
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 { AlfrescoSettingsService } from './AlfrescoSettings.service';
import { AlfrescoAuthenticationService } from './AlfrescoAuthentication.service';
import { AlfrescoContentService } from './AlfrescoContent.service';
import { AlfrescoApiService } from './AlfrescoApi.service';
import { SettingsService } from './settings.service';
import { AuthService } from './auth.service';
import { ContentService } from './content.service';
import { AlfrescoApiService } from './alfresco-api.service';
import { StorageService } from './storage.service';
declare let jasmine: any;
describe('AlfrescoContentService', () => {
describe('ContentService', () => {
let injector, contentService: AlfrescoContentService;
let authService: AlfrescoAuthenticationService;
let settingsService: AlfrescoSettingsService;
let injector, contentService: ContentService;
let authService: AuthService;
let settingsService: SettingsService;
let storage: StorageService;
let node: any;
@@ -37,15 +37,15 @@ describe('AlfrescoContentService', () => {
beforeEach(() => {
injector = ReflectiveInjector.resolveAndCreate([
AlfrescoApiService,
AlfrescoContentService,
AlfrescoAuthenticationService,
AlfrescoSettingsService,
ContentService,
AuthService,
SettingsService,
StorageService
]);
authService = injector.get(AlfrescoAuthenticationService);
settingsService = injector.get(AlfrescoSettingsService);
contentService = injector.get(AlfrescoContentService);
authService = injector.get(AuthService);
settingsService = injector.get(SettingsService);
contentService = injector.get(ContentService);
storage = injector.get(StorageService);
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 './AlfrescoApi.service';
export * from './alfresco-api.service';
export * from './AlfrescoSettings.service';
export * from './AlfrescoTranslationLoader.service';
export * from './AlfrescoTranslation.service';
export * from './AlfrescoAuthentication.service';
export * from './AlfrescoContent.service';
@@ -26,3 +25,9 @@ export * from './renditions.service';
export * from './auth-guard.service';
export * from './auth-guard-ecm.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 { AlfrescoApiService } from './AlfrescoApi.service';
import { AlfrescoApiService } from './alfresco-api.service';
import { RenditionsService } from './renditions.service';
import {
fakeRedition,

View File

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

View File

@@ -15,18 +15,18 @@
* limitations under the License.
*/
import { AlfrescoSettingsService } from './AlfrescoSettings.service';
import { SettingsService } from './settings.service';
describe('AlfrescoSettingsService', () => {
let service: AlfrescoSettingsService;
let service: SettingsService;
beforeEach(() => {
service = new AlfrescoSettingsService();
service = new SettingsService();
});
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', () => {
@@ -37,7 +37,7 @@ describe('AlfrescoSettingsService', () => {
});
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', () => {

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.
*/
import { TranslateLoader } from 'ng2-translate/ng2-translate';
import { AlfrescoTranslationLoader } from '../services/AlfrescoTranslationLoader.service';
import { AlfrescoTranslationService } from '../services/AlfrescoTranslation.service';
import { TranslateModule, TranslateLoader } from 'ng2-translate/ng2-translate';
import { Injector } from '@angular/core';
import { ResponseOptions, Response, XHRBackend, HttpModule } from '@angular/http';
import { MockBackend, MockConnection } from '@angular/http/testing';
import {
TranslateModule
} from 'ng2-translate/ng2-translate';
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"} ' ;
const mockBackendResponse = (connection: MockConnection, response: string) => {
@@ -35,7 +33,7 @@ const mockBackendResponse = (connection: MockConnection, response: string) => {
describe('TranslateLoader', () => {
let injector: Injector;
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 customLoader;
@@ -43,16 +41,16 @@ describe('TranslateLoader', () => {
TestBed.configureTestingModule({
imports: [HttpModule, TranslateModule.forRoot({
provide: TranslateLoader,
useClass: AlfrescoTranslationLoader
useClass: AlfrescoTranslateLoader
})],
providers: [
AlfrescoTranslationService,
AlfrescoTranslateService,
{provide: XHRBackend, useClass: MockBackend}
]
});
injector = getTestBed();
backend = injector.get(XHRBackend);
alfrescoTranslationService = injector.get(AlfrescoTranslationService);
alfrescoTranslationService = injector.get(AlfrescoTranslateService);
backend.connections.subscribe((c: MockConnection) => connection = c);
customLoader = alfrescoTranslationService.translate.currentLoader;
});
@@ -60,7 +58,7 @@ describe('TranslateLoader', () => {
it('should be able to provide any TranslateLoader', () => {
expect(alfrescoTranslationService).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', () => {

View File

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

View File

@@ -15,48 +15,46 @@
* limitations under the License.
*/
import { AlfrescoTranslationService } from '../services/AlfrescoTranslation.service';
import { TranslateLoader } from 'ng2-translate/ng2-translate';
import { AlfrescoTranslationLoader } from '../services/AlfrescoTranslationLoader.service';
import { TranslateModule, TranslateLoader } from 'ng2-translate/ng2-translate';
import { Injector } from '@angular/core';
import { ResponseOptions, Response, XHRBackend, HttpModule } from '@angular/http';
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 { AlfrescoTranslateService } from './translate.service';
import { AlfrescoTranslateLoader } from './translate-loader.service';
const mockBackendResponse = (connection: MockConnection, response: string) => {
connection.mockRespond(new Response(new ResponseOptions({body: response})));
};
describe('AlfrescoTranslationService', () => {
describe('AlfrescoTranslateService', () => {
let injector: Injector;
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.
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpModule, TranslateModule.forRoot({
provide: TranslateLoader,
useClass: AlfrescoTranslationLoader
useClass: AlfrescoTranslateLoader
})],
providers: [
AlfrescoTranslationService,
AlfrescoTranslateService,
{provide: XHRBackend, useClass: MockBackend}
]
});
injector = getTestBed();
backend = injector.get(XHRBackend);
alfrescoTranslationService = injector.get(AlfrescoTranslationService);
alfrescoTranslationService = injector.get(AlfrescoTranslateService);
backend.connections.subscribe((c: MockConnection) => connection = c);
alfrescoTranslationService.addTranslationFolder('fake-name', 'fake-path');
});
it('is defined', () => {
expect(AlfrescoTranslationService).toBeDefined();
expect(alfrescoTranslationService instanceof AlfrescoTranslationService).toBeTruthy();
expect(AlfrescoTranslateService).toBeDefined();
expect(alfrescoTranslationService instanceof AlfrescoTranslateService).toBeTruthy();
});
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';
import { Subject } from 'rxjs/Rx';
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 { DocumentListService } from './../services/document-list.service';
import { ContentActionModel } from './../models/content-action.model';
@@ -157,12 +157,12 @@ export class DocumentList implements OnInit, OnChanges, AfterContentInit {
constructor(
private documentListService: DocumentListService,
private ngZone: NgZone,
private translate: AlfrescoTranslationService) {
private translateService: AlfrescoTranslateService) {
this.data = new ShareDataTableAdapter(this.documentListService, './..', []);
if (translate) {
translate.addTranslationFolder('ng2-alfresco-documentlist', 'node_modules/ng2-alfresco-documentlist/src');
if (translateService) {
translateService.addTranslationFolder('ng2-alfresco-documentlist', 'node_modules/ng2-alfresco-documentlist/src');
}
}

View File

@@ -24,7 +24,7 @@ import {
ViewChild
} from '@angular/core';
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';
declare let dialogPolyfill: any;
@@ -59,10 +59,10 @@ export class DocumentMenuAction implements OnInit {
constructor(
private documentListService: DocumentListService,
private translate: AlfrescoTranslationService) {
private translateService: AlfrescoTranslateService) {
if (translate) {
translate.addTranslationFolder('ng2-alfresco-documentlist', 'node_modules/ng2-alfresco-documentlist/src');
if (translateService) {
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 {
if (response.body && response.body.error.statusCode === ERROR_FOLDER_ALREADY_EXIST) {
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;
}
}

View File

@@ -15,7 +15,7 @@
* 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 { ReflectiveInjector } from '@angular/core';
import { DocumentListService } from './document-list.service';
@@ -26,8 +26,8 @@ describe('DocumentListService', () => {
let injector;
let service: DocumentListService;
let settingsService: AlfrescoSettingsService;
let authService: AlfrescoAuthenticationService;
let settingsService: SettingsService;
let authService: AuthService;
let alfrescoApiService: AlfrescoApiService;
let fakeEntryNode = {
@@ -94,16 +94,16 @@ describe('DocumentListService', () => {
beforeEach(() => {
injector = ReflectiveInjector.resolveAndCreate([
AlfrescoApiService,
AlfrescoAuthenticationService,
AlfrescoSettingsService,
AuthService,
SettingsService,
AlfrescoApiService,
AlfrescoContentService,
ContentService,
DocumentListService,
StorageService
]);
settingsService = injector.get(AlfrescoSettingsService);
authService = injector.get(AlfrescoAuthenticationService);
settingsService = injector.get(SettingsService);
authService = injector.get(AuthService);
alfrescoApiService = injector.get(AlfrescoApiService);
service = injector.get(DocumentListService);
jasmine.Ajax.install();

View File

@@ -19,11 +19,7 @@ import { Injectable } from '@angular/core';
import { Response } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import { NodePaging, MinimalNodeEntity } from 'alfresco-js-api';
import {
AlfrescoAuthenticationService,
AlfrescoContentService,
AlfrescoApiService
} from 'ng2-alfresco-core';
import { AuthService, ContentService, AlfrescoApiService } from 'ng2-alfresco-core';
@Injectable()
export class DocumentListService {
@@ -61,7 +57,9 @@ export class DocumentListService {
'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> {

View File

@@ -23,10 +23,10 @@ import { result, results, folderResult, noResult, errorJson } from './../assets/
import { AlfrescoSearchService } from '../services/alfresco-search.service';
import {
AlfrescoApiService,
AlfrescoSettingsService,
AlfrescoAuthenticationService,
AlfrescoContentService,
AlfrescoTranslationService,
SettingsService,
AuthService,
ContentService,
AlfrescoTranslateService,
CoreModule
} from 'ng2-alfresco-core';
@@ -48,12 +48,12 @@ describe('AlfrescoSearchAutocompleteComponent', () => {
],
declarations: [ AlfrescoSearchAutocompleteComponent ], // declare the test component
providers: [
{provide: AlfrescoTranslationService, useClass: TranslationMock},
{provide: AlfrescoTranslateService, useClass: TranslationMock},
AlfrescoThumbnailService,
AlfrescoSettingsService,
SettingsService,
AlfrescoApiService,
AlfrescoAuthenticationService,
AlfrescoContentService,
AuthService,
ContentService,
AlfrescoSearchService
]
}).compileComponents().then(() => {
@@ -64,7 +64,7 @@ describe('AlfrescoSearchAutocompleteComponent', () => {
}));
it('should setup i18n folder', () => {
let translationService = fixture.debugElement.injector.get(AlfrescoTranslationService);
let translationService = fixture.debugElement.injector.get(AlfrescoTranslateService);
spyOn(translationService, 'addTranslationFolder');
fixture.detectChanges();
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 { AlfrescoTranslateService } from 'ng2-alfresco-core';
import { MinimalNodeEntity } from 'alfresco-js-api';
import { AlfrescoSearchService, SearchOptions } from './../services/alfresco-search.service';
import { AlfrescoThumbnailService } from './../services/alfresco-thumbnail.service';
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
import { MinimalNodeEntity } from 'alfresco-js-api';
@Component({
moduleId: module.id,
@@ -70,14 +70,14 @@ export class AlfrescoSearchAutocompleteComponent implements OnInit, OnChanges {
baseComponentPath: string = module.id.replace('/components/alfresco-search.component.js', '');
constructor(private alfrescoSearchService: AlfrescoSearchService,
private translate: AlfrescoTranslationService,
private alfrescoThumbnailService: AlfrescoThumbnailService) {
constructor(private searchService: AlfrescoSearchService,
private translateService: AlfrescoTranslateService,
private thumbnailService: AlfrescoThumbnailService) {
}
ngOnInit(): void {
if (this.translate) {
this.translate.addTranslationFolder('ng2-alfresco-search', 'node_modules/ng2-alfresco-search/src');
if (this.translateService) {
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
};
if (searchTerm !== null && searchTerm !== '') {
this.alfrescoSearchService
this.searchService
.getNodeQueryResults(searchTerm, searchOpts)
.subscribe(
results => {
@@ -126,7 +126,7 @@ export class AlfrescoSearchAutocompleteComponent implements OnInit, OnChanges {
*/
getMimeTypeIcon(node: MinimalNodeEntity): string {
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);
} else if (node.entry.isFolder) {
return `${this.baseComponentPath}/../assets/images/ft_ic_folder.svg`;
@@ -144,7 +144,7 @@ export class AlfrescoSearchAutocompleteComponent implements OnInit, OnChanges {
*/
getMimeTypeKey(node: MinimalNodeEntity): string {
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 {
return '';
}

View File

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

View File

@@ -17,10 +17,10 @@
import { FormControl, Validators } from '@angular/forms';
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 { SearchTermValidator } from './../forms/search-term-validator';
import { Observable, Subject } from 'rxjs/Rx';
@Component({
moduleId: module.id,
@@ -86,7 +86,7 @@ export class AlfrescoSearchControlComponent implements OnInit, OnDestroy {
private focusSubject = new Subject<FocusEvent>();
constructor(private translate: AlfrescoTranslationService) {
constructor(private translateService: AlfrescoTranslateService) {
this.searchControl = new FormControl(
this.searchTerm,
@@ -103,7 +103,7 @@ export class AlfrescoSearchControlComponent implements OnInit, OnDestroy {
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 {

View File

@@ -25,11 +25,11 @@ import { AlfrescoThumbnailService } from './../services/alfresco-thumbnail.servi
import { TranslationMock } from './../assets/translation.service.mock';
import { AlfrescoSearchService } from '../services/alfresco-search.service';
import {
AlfrescoSettingsService,
SettingsService,
AlfrescoApiService,
AlfrescoAuthenticationService,
AlfrescoContentService,
AlfrescoTranslationService,
AuthService,
ContentService,
AlfrescoTranslateService,
CoreModule,
StorageService
} from 'ng2-alfresco-core';
@@ -107,12 +107,12 @@ describe('AlfrescoSearchComponent', () => {
declarations: [ AlfrescoSearchComponent ], // declare the test component
providers: [
AlfrescoSearchService,
{provide: AlfrescoTranslationService, useClass: TranslationMock},
{provide: AlfrescoTranslateService, useClass: TranslationMock},
AlfrescoThumbnailService,
AlfrescoSettingsService,
SettingsService,
AlfrescoApiService,
AlfrescoAuthenticationService,
AlfrescoContentService,
AuthService,
ContentService,
StorageService
]
}).compileComponents().then(() => {
@@ -140,8 +140,8 @@ describe('AlfrescoSearchComponent', () => {
it('should have a null search term if no query param provided via RouteParams', () => {
let injector = ReflectiveInjector.resolveAndCreate([
AlfrescoSearchService,
AlfrescoAuthenticationService,
AlfrescoSettingsService,
AuthService,
SettingsService,
AlfrescoApiService,
StorageService,
{ provide: ActivatedRoute, useValue: { params: Observable.from([{}]) } }
@@ -152,7 +152,7 @@ describe('AlfrescoSearchComponent', () => {
});
it('should setup i18n folder', () => {
let translationService = fixture.debugElement.injector.get(AlfrescoTranslationService);
let translationService = fixture.debugElement.injector.get(AlfrescoTranslateService);
spyOn(translationService, 'addTranslationFolder');
fixture.detectChanges();
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 { AlfrescoSearchService, SearchOptions } from './../services/alfresco-search.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';
@Component({
@@ -65,15 +65,15 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit {
baseComponentPath: string = module.id.replace('/components/alfresco-search.component.js', '');
constructor(private alfrescoSearchService: AlfrescoSearchService,
private translate: AlfrescoTranslationService,
private _alfrescoThumbnailService: AlfrescoThumbnailService,
constructor(private searchService: AlfrescoSearchService,
private translateService: AlfrescoTranslateService,
private thumbnailService: AlfrescoThumbnailService,
@Optional() private route: ActivatedRoute) {
}
ngOnInit(): void {
if (this.translate !== null) {
this.translate.addTranslationFolder('ng2-alfresco-search', 'node_modules/ng2-alfresco-search/src');
ngOnInit() {
if (this.translateService !== null) {
this.translateService.addTranslationFolder('ng2-alfresco-search', 'node_modules/ng2-alfresco-search/src');
}
if (this.route) {
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']) {
this.searchTerm = changes['searchTerm'].currentValue;
this.displaySearchResults(this.searchTerm);
@@ -99,7 +99,7 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit {
*/
getMimeTypeIcon(node: any): string {
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);
} else if (node.entry.isFolder) {
return `${this.baseComponentPath}/../assets/images/ft_ic_folder.svg`;
@@ -117,7 +117,7 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit {
*/
getMimeTypeKey(node: any): string {
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 {
return '';
}
@@ -127,8 +127,8 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit {
* Loads and displays search results
* @param searchTerm Search query entered by user
*/
private displaySearchResults(searchTerm): void {
if (searchTerm && this.alfrescoSearchService) {
private displaySearchResults(searchTerm) {
if (searchTerm && this.searchService) {
let searchOpts: SearchOptions = {
include: ['path'],
rootNodeId: this.rootNodeId,
@@ -136,7 +136,7 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit {
maxItems: this.maxResults,
orderBy: this.resultSort
};
this.alfrescoSearchService
this.searchService
.getNodeQueryResults(searchTerm, searchOpts)
.subscribe(
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 (node && node.entry) {
this.navigate.emit(node);

View File

@@ -17,7 +17,7 @@
import { ReflectiveInjector } from '@angular/core';
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';
declare let jasmine: any;
@@ -31,9 +31,9 @@ describe('AlfrescoSearchService', () => {
beforeEach(() => {
injector = ReflectiveInjector.resolveAndCreate([
AlfrescoSearchService,
AlfrescoSettingsService,
SettingsService,
AlfrescoApiService,
AlfrescoAuthenticationService,
AuthService,
StorageService
]);
service = injector.get(AlfrescoSearchService);

View File

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

View File

@@ -16,7 +16,7 @@
*/
import { Injectable } from '@angular/core';
import { AlfrescoContentService } from 'ng2-alfresco-core';
import { ContentService } from 'ng2-alfresco-core';
@Injectable()
export class AlfrescoThumbnailService {
@@ -50,7 +50,7 @@ export class AlfrescoThumbnailService {
'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 { TagActionsComponent } from '../components/tag-actions.component';
import { DebugElement } from '@angular/core';
import {
AlfrescoAuthenticationService,
AlfrescoSettingsService,
AlfrescoApiService,
CoreModule
} from 'ng2-alfresco-core';
import { CoreModule } from 'ng2-alfresco-core';
import { TagService } from '../services/tag.service';
declare let jasmine: any;
@@ -38,13 +33,12 @@ describe('Test ng2-alfresco-tag Tag actions list', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
CoreModule
CoreModule.forRoot()
],
declarations: [
TagActionsComponent
],
declarations: [TagActionsComponent],
providers: [
AlfrescoSettingsService,
AlfrescoAuthenticationService,
AlfrescoApiService,
TagService
]
}).compileComponents();

View File

@@ -16,8 +16,7 @@
*/
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
* @param authService
*/
constructor(public authService: AlfrescoAuthenticationService, private tagService: TagService) {
constructor(private tagService: TagService) {
}
ngOnChanges(changes) {

View File

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

View File

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

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