mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
Merge pull request #668 from Alfresco/dev-denys-dts
AlfrescoApiService, code improvements
This commit is contained in:
@@ -20,8 +20,9 @@
|
|||||||
'ng2-activiti-form': 'node_modules/ng2-activiti-form/dist',
|
'ng2-activiti-form': 'node_modules/ng2-activiti-form/dist',
|
||||||
'ng2-alfresco-viewer': 'node_modules/ng2-alfresco-viewer/dist',
|
'ng2-alfresco-viewer': 'node_modules/ng2-alfresco-viewer/dist',
|
||||||
'ng2-alfresco-webscript': 'node_modules/ng2-alfresco-webscript/dist',
|
'ng2-alfresco-webscript': 'node_modules/ng2-alfresco-webscript/dist',
|
||||||
'ng2-activiti-processlist': 'node_modules/ng2-activiti-processlist/dist',
|
'ng2-activiti-tasklist': 'node_modules/ng2-activiti-tasklist/dist',
|
||||||
'ng2-activiti-tasklist': 'node_modules/ng2-activiti-tasklist/dist'
|
'alfresco-js-api': 'node_modules/alfresco-js-api/dist',
|
||||||
|
'ng2-activiti-processlist': 'node_modules/ng2-activiti-processlist/dist'
|
||||||
};
|
};
|
||||||
// packages tells the System loader how to load when no filename and/or no extension
|
// packages tells the System loader how to load when no filename and/or no extension
|
||||||
var packages = {
|
var packages = {
|
||||||
@@ -41,7 +42,8 @@
|
|||||||
'ng2-activiti-form': { main: 'index.js', defaultExtension: 'js'},
|
'ng2-activiti-form': { main: 'index.js', defaultExtension: 'js'},
|
||||||
'ng2-activiti-processlist': { main: 'index.js', defaultExtension: 'js'},
|
'ng2-activiti-processlist': { main: 'index.js', defaultExtension: 'js'},
|
||||||
'ng2-activiti-tasklist': { main: 'index.js', defaultExtension: 'js'},
|
'ng2-activiti-tasklist': { main: 'index.js', defaultExtension: 'js'},
|
||||||
'ng2-alfresco-webscript': { main: 'index.js', defaultExtension: 'js'}
|
'ng2-alfresco-webscript': { main: 'index.js', defaultExtension: 'js'},
|
||||||
|
'alfresco-js-api': { main: 'alfresco-js-api.js', defaultExtension: 'js'}
|
||||||
};
|
};
|
||||||
var ngPackageNames = [
|
var ngPackageNames = [
|
||||||
'common',
|
'common',
|
||||||
|
@@ -65,7 +65,7 @@
|
|||||||
"rxjs": "5.0.0-beta.6",
|
"rxjs": "5.0.0-beta.6",
|
||||||
"zone.js": "0.6.12",
|
"zone.js": "0.6.12",
|
||||||
"ng2-translate": "2.2.2",
|
"ng2-translate": "2.2.2",
|
||||||
"ng2-alfresco-core": "0.3.0"
|
"ng2-alfresco-core": "^0.3.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"material-design-icons": "^2.2.3",
|
"material-design-icons": "^2.2.3",
|
||||||
@@ -83,7 +83,6 @@
|
|||||||
"karma-jasmine": "1.0.2",
|
"karma-jasmine": "1.0.2",
|
||||||
"karma-jasmine-ajax": "0.1.13",
|
"karma-jasmine-ajax": "0.1.13",
|
||||||
"karma-jasmine-html-reporter": "0.2.0",
|
"karma-jasmine-html-reporter": "0.2.0",
|
||||||
"karma-jasmine-ajax": "0.1.13",
|
|
||||||
"karma-mocha-reporter": "2.0.3",
|
"karma-mocha-reporter": "2.0.3",
|
||||||
"license-check": "1.1.5",
|
"license-check": "1.1.5",
|
||||||
"remap-istanbul": "0.6.3",
|
"remap-istanbul": "0.6.3",
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { it, inject, describe, expect, beforeEach, beforeEachProviders, afterEach } from '@angular/core/testing';
|
import { it, inject, describe, expect, beforeEach, beforeEachProviders, afterEach } from '@angular/core/testing';
|
||||||
import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core';
|
import { AlfrescoAuthenticationService, AlfrescoSettingsService, AlfrescoApiService } from 'ng2-alfresco-core';
|
||||||
import { HTTP_PROVIDERS, Response, ResponseOptions } from '@angular/http';
|
import { HTTP_PROVIDERS, Response, ResponseOptions } from '@angular/http';
|
||||||
import { FormService } from './form.service';
|
import { FormService } from './form.service';
|
||||||
import { EcmModelService } from './ecm-model.service';
|
import { EcmModelService } from './ecm-model.service';
|
||||||
@@ -32,6 +32,7 @@ describe('FormService', () => {
|
|||||||
return [
|
return [
|
||||||
FormService,
|
FormService,
|
||||||
AlfrescoSettingsService,
|
AlfrescoSettingsService,
|
||||||
|
AlfrescoApiService,
|
||||||
AlfrescoAuthenticationService,
|
AlfrescoAuthenticationService,
|
||||||
EcmModelService,
|
EcmModelService,
|
||||||
HTTP_PROVIDERS,
|
HTTP_PROVIDERS,
|
||||||
|
@@ -70,7 +70,9 @@ export class NodeService {
|
|||||||
relativePath: path
|
relativePath: path
|
||||||
};
|
};
|
||||||
|
|
||||||
return Observable.fromPromise(this.authService.getAlfrescoApi().nodes.addNode('-root-', body, {}));
|
// TODO: requires update to alfresco-js-api typings
|
||||||
|
let apiService: any = this.authService.getAlfrescoApi();
|
||||||
|
return Observable.fromPromise(apiService.nodes.addNode('-root-', body, {}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private generateUuid() {
|
private generateUuid() {
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { it, describe, expect, beforeEachProviders, beforeEach, inject } from '@angular/core/testing';
|
import { it, describe, expect, beforeEachProviders, beforeEach, inject } from '@angular/core/testing';
|
||||||
import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core';
|
import { AlfrescoAuthenticationService, AlfrescoSettingsService, AlfrescoApiService } from 'ng2-alfresco-core';
|
||||||
import { ActivitiProcessService } from './activiti-process.service';
|
import { ActivitiProcessService } from './activiti-process.service';
|
||||||
// import { ProcessInstance } from '../models/process-instance';
|
// import { ProcessInstance } from '../models/process-instance';
|
||||||
|
|
||||||
@@ -28,6 +28,7 @@ describe('ActivitiProcessService', () => {
|
|||||||
return [
|
return [
|
||||||
ActivitiProcessService,
|
ActivitiProcessService,
|
||||||
AlfrescoSettingsService,
|
AlfrescoSettingsService,
|
||||||
|
AlfrescoApiService,
|
||||||
AlfrescoAuthenticationService
|
AlfrescoAuthenticationService
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import { it, describe, inject, beforeEach, beforeEachProviders } from '@angular/core/testing';
|
import { it, describe, inject, beforeEach, beforeEachProviders } from '@angular/core/testing';
|
||||||
import { ActivitiTaskListService } from './activiti-tasklist.service';
|
import { ActivitiTaskListService } from './activiti-tasklist.service';
|
||||||
import { AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
import { AlfrescoSettingsService, AlfrescoAuthenticationService, AlfrescoApiService } from 'ng2-alfresco-core';
|
||||||
import { TaskDetailsModel } from '../models/task-details.model';
|
import { TaskDetailsModel } from '../models/task-details.model';
|
||||||
import { Comment } from '../models/comment.model';
|
import { Comment } from '../models/comment.model';
|
||||||
|
|
||||||
@@ -96,6 +96,7 @@ describe('ActivitiTaskListService', () => {
|
|||||||
return [
|
return [
|
||||||
ActivitiTaskListService,
|
ActivitiTaskListService,
|
||||||
AlfrescoSettingsService,
|
AlfrescoSettingsService,
|
||||||
|
AlfrescoApiService,
|
||||||
AlfrescoAuthenticationService
|
AlfrescoAuthenticationService
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
AlfrescoApiService,
|
||||||
AlfrescoSettingsService,
|
AlfrescoSettingsService,
|
||||||
AlfrescoTranslationLoader,
|
AlfrescoTranslationLoader,
|
||||||
AlfrescoTranslationService,
|
AlfrescoTranslationService,
|
||||||
@@ -31,6 +32,7 @@ export * from './src/components/index';
|
|||||||
export * from './src/utils/index';
|
export * from './src/utils/index';
|
||||||
|
|
||||||
export const ALFRESCO_CORE_PROVIDERS: [any] = [
|
export const ALFRESCO_CORE_PROVIDERS: [any] = [
|
||||||
|
AlfrescoApiService,
|
||||||
AlfrescoAuthenticationService,
|
AlfrescoAuthenticationService,
|
||||||
AlfrescoContentService,
|
AlfrescoContentService,
|
||||||
AlfrescoSettingsService,
|
AlfrescoSettingsService,
|
||||||
|
@@ -0,0 +1,34 @@
|
|||||||
|
/*!
|
||||||
|
* @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 { AlfrescoJsApi } from 'alfresco-js-api';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class AlfrescoApiService {
|
||||||
|
|
||||||
|
private _instance: AlfrescoJsApi;
|
||||||
|
|
||||||
|
public getInstance(): AlfrescoJsApi {
|
||||||
|
return this._instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public setInstance(value: AlfrescoJsApi) {
|
||||||
|
this._instance = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -15,23 +15,30 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {it, describe, beforeEach, afterEach} from '@angular/core/testing';
|
import { it, describe, beforeEach, afterEach } from '@angular/core/testing';
|
||||||
import {ReflectiveInjector, provide} from '@angular/core';
|
import { ReflectiveInjector } from '@angular/core';
|
||||||
import {AlfrescoSettingsService} from './AlfrescoSettings.service';
|
import { AlfrescoSettingsService } from './AlfrescoSettings.service';
|
||||||
import {AlfrescoAuthenticationService} from './AlfrescoAuthentication.service';
|
import { AlfrescoAuthenticationService } from './AlfrescoAuthentication.service';
|
||||||
|
import { AlfrescoApiService } from './AlfrescoApi.service';
|
||||||
|
|
||||||
declare var AlfrescoApi: any;
|
declare var AlfrescoApi: any;
|
||||||
declare let jasmine: any;
|
declare let jasmine: any;
|
||||||
|
|
||||||
describe('AlfrescoAuthentication', () => {
|
describe('AlfrescoAuthentication', () => {
|
||||||
let injector, authService;
|
let injector;
|
||||||
|
let authService: AlfrescoAuthenticationService;
|
||||||
|
let settingsService: AlfrescoSettingsService;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
injector = ReflectiveInjector.resolveAndCreate([
|
injector = ReflectiveInjector.resolveAndCreate([
|
||||||
provide(AlfrescoSettingsService, {useClass: AlfrescoSettingsService}),
|
AlfrescoSettingsService,
|
||||||
|
AlfrescoApiService,
|
||||||
AlfrescoAuthenticationService
|
AlfrescoAuthenticationService
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
authService = injector.get(AlfrescoAuthenticationService);
|
||||||
|
settingsService = injector.get(AlfrescoSettingsService);
|
||||||
|
|
||||||
let store = {};
|
let store = {};
|
||||||
|
|
||||||
spyOn(localStorage, 'getItem').and.callFake(function (key) {
|
spyOn(localStorage, 'getItem').and.callFake(function (key) {
|
||||||
@@ -61,8 +68,7 @@ describe('AlfrescoAuthentication', () => {
|
|||||||
describe('when the setting is ECM', () => {
|
describe('when the setting is ECM', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
authService = injector.get(AlfrescoAuthenticationService);
|
settingsService.setProviders('ECM');
|
||||||
authService.alfrescoSetting.setProviders('ECM');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return an ECM ticket after the login done', (done) => {
|
it('should return an ECM ticket after the login done', (done) => {
|
||||||
@@ -144,8 +150,7 @@ describe('AlfrescoAuthentication', () => {
|
|||||||
describe('when the setting is BPM', () => {
|
describe('when the setting is BPM', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
authService = injector.get(AlfrescoAuthenticationService);
|
settingsService.setProviders('BPM');
|
||||||
authService.alfrescoSetting.setProviders('BPM');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return an BPM ticket after the login done', (done) => {
|
it('should return an BPM ticket after the login done', (done) => {
|
||||||
@@ -212,24 +217,23 @@ describe('AlfrescoAuthentication', () => {
|
|||||||
describe('Setting service change should reflect in the api', () => {
|
describe('Setting service change should reflect in the api', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
authService = injector.get(AlfrescoAuthenticationService);
|
settingsService.setProviders('ALL');
|
||||||
authService.alfrescoSetting.setProviders('ALL');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should host ecm url change be reflected in the api configuration', () => {
|
it('should host ecm url change be reflected in the api configuration', () => {
|
||||||
authService.alfrescoSetting.ecmHost = '127.99.99.99';
|
settingsService.ecmHost = '127.99.99.99';
|
||||||
|
|
||||||
expect(authService.getAlfrescoApi().config.hostEcm).toBe('127.99.99.99');
|
expect(authService.getAlfrescoApi().config.hostEcm).toBe('127.99.99.99');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should host bpm url change be reflected in the api configuration', () => {
|
it('should host bpm url change be reflected in the api configuration', () => {
|
||||||
authService.alfrescoSetting.bpmHost = '127.99.99.99';
|
settingsService.bpmHost = '127.99.99.99';
|
||||||
|
|
||||||
expect(authService.getAlfrescoApi().config.hostBpm).toBe('127.99.99.99');
|
expect(authService.getAlfrescoApi().config.hostBpm).toBe('127.99.99.99');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should host bpm provider change be reflected in the api configuration', () => {
|
it('should host bpm provider change be reflected in the api configuration', () => {
|
||||||
authService.alfrescoSetting.setProviders('ECM');
|
settingsService.setProviders('ECM');
|
||||||
|
|
||||||
expect(authService.getAlfrescoApi().config.provider).toBe('ECM');
|
expect(authService.getAlfrescoApi().config.provider).toBe('ECM');
|
||||||
});
|
});
|
||||||
@@ -239,8 +243,7 @@ describe('AlfrescoAuthentication', () => {
|
|||||||
describe('when the setting is both ECM and BPM ', () => {
|
describe('when the setting is both ECM and BPM ', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
authService = injector.get(AlfrescoAuthenticationService);
|
settingsService.setProviders('ALL');
|
||||||
authService.providers = 'ALL';
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return both ECM and BPM tickets after the login done', (done) => {
|
it('should return both ECM and BPM tickets after the login done', (done) => {
|
||||||
|
@@ -15,11 +15,13 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Injectable} from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import {Observable} from 'rxjs/Rx';
|
import { Observable } from 'rxjs/Rx';
|
||||||
import {AlfrescoSettingsService} from './AlfrescoSettings.service';
|
import { AlfrescoSettingsService } from './AlfrescoSettings.service';
|
||||||
|
import { AlfrescoApiService } from './AlfrescoApi.service';
|
||||||
|
import { AlfrescoJsApi } from 'alfresco-js-api';
|
||||||
|
|
||||||
declare let AlfrescoApi: any;
|
declare var AlfrescoApi: AlfrescoJsApi;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The AlfrescoAuthenticationService provide the login service and store the ticket in the localStorage
|
* The AlfrescoAuthenticationService provide the login service and store the ticket in the localStorage
|
||||||
@@ -27,32 +29,37 @@ declare let AlfrescoApi: any;
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class AlfrescoAuthenticationService {
|
export class AlfrescoAuthenticationService {
|
||||||
|
|
||||||
alfrescoApi: any;
|
alfrescoApi: AlfrescoJsApi;
|
||||||
|
|
||||||
/**A
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param alfrescoSetting
|
* @param settingsService
|
||||||
|
* @param apiService
|
||||||
*/
|
*/
|
||||||
constructor(public alfrescoSetting: AlfrescoSettingsService) {
|
constructor(private settingsService: AlfrescoSettingsService,
|
||||||
|
private apiService: AlfrescoApiService) {
|
||||||
this.alfrescoApi = new AlfrescoApi({
|
this.alfrescoApi = new AlfrescoApi({
|
||||||
provider: this.alfrescoSetting.getProviders(),
|
provider: this.settingsService.getProviders(),
|
||||||
ticketEcm: this.getTicketEcm(),
|
ticketEcm: this.getTicketEcm(),
|
||||||
ticketBpm: this.getTicketBpm(),
|
ticketBpm: this.getTicketBpm(),
|
||||||
hostEcm: this.alfrescoSetting.ecmHost,
|
hostEcm: this.settingsService.ecmHost,
|
||||||
hostBpm: this.alfrescoSetting.bpmHost
|
hostBpm: this.settingsService.bpmHost,
|
||||||
|
contextRoot: 'alfresco'
|
||||||
});
|
});
|
||||||
|
|
||||||
alfrescoSetting.bpmHostSubject.subscribe((bpmHost) => {
|
settingsService.bpmHostSubject.subscribe((bpmHost) => {
|
||||||
this.alfrescoApi.changeBpmHost(bpmHost);
|
this.alfrescoApi.changeBpmHost(bpmHost);
|
||||||
});
|
});
|
||||||
|
|
||||||
alfrescoSetting.ecmHostSubject.subscribe((ecmHost) => {
|
settingsService.ecmHostSubject.subscribe((ecmHost) => {
|
||||||
this.alfrescoApi.changeEcmHost(ecmHost);
|
this.alfrescoApi.changeEcmHost(ecmHost);
|
||||||
});
|
});
|
||||||
|
|
||||||
alfrescoSetting.providerSubject.subscribe((value) => {
|
settingsService.providerSubject.subscribe((value) => {
|
||||||
this.alfrescoApi.config.provider = value;
|
this.alfrescoApi.config.provider = value;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.apiService.setInstance(this.alfrescoApi);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,11 +76,11 @@ export class AlfrescoAuthenticationService {
|
|||||||
* @param password
|
* @param password
|
||||||
* @returns {Observable<R>|Observable<T>}
|
* @returns {Observable<R>|Observable<T>}
|
||||||
*/
|
*/
|
||||||
login(username: string, password: string) {
|
login(username: string, password: string): Observable<{ type: string, ticket: any }> {
|
||||||
return Observable.fromPromise(this.callApiLogin(username, password))
|
return Observable.fromPromise(this.callApiLogin(username, password))
|
||||||
.map((response: any) => {
|
.map((response: any) => {
|
||||||
this.saveTickets();
|
this.saveTickets();
|
||||||
return {type: this.alfrescoSetting.getProviders(), ticket: response};
|
return {type: this.settingsService.getProviders(), ticket: response};
|
||||||
})
|
})
|
||||||
.catch(this.handleError);
|
.catch(this.handleError);
|
||||||
}
|
}
|
||||||
@@ -189,7 +196,7 @@ export class AlfrescoAuthenticationService {
|
|||||||
return Observable.throw(error || 'Server error');
|
return Observable.throw(error || 'Server error');
|
||||||
}
|
}
|
||||||
|
|
||||||
getAlfrescoApi(): any {
|
getAlfrescoApi(): AlfrescoJsApi {
|
||||||
return this.alfrescoApi;
|
return this.alfrescoApi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,6 +20,7 @@ import {ReflectiveInjector} from '@angular/core';
|
|||||||
import {AlfrescoSettingsService} from './AlfrescoSettings.service';
|
import {AlfrescoSettingsService} from './AlfrescoSettings.service';
|
||||||
import {AlfrescoAuthenticationService} from './AlfrescoAuthentication.service';
|
import {AlfrescoAuthenticationService} from './AlfrescoAuthentication.service';
|
||||||
import {AlfrescoContentService} from './AlfrescoContent.service';
|
import {AlfrescoContentService} from './AlfrescoContent.service';
|
||||||
|
import { AlfrescoApiService } from './AlfrescoApi.service';
|
||||||
|
|
||||||
describe('AlfrescoContentService', () => {
|
describe('AlfrescoContentService', () => {
|
||||||
|
|
||||||
@@ -29,6 +30,7 @@ describe('AlfrescoContentService', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
injector = ReflectiveInjector.resolveAndCreate([
|
injector = ReflectiveInjector.resolveAndCreate([
|
||||||
|
AlfrescoApiService,
|
||||||
AlfrescoContentService,
|
AlfrescoContentService,
|
||||||
AlfrescoAuthenticationService,
|
AlfrescoAuthenticationService,
|
||||||
AlfrescoSettingsService
|
AlfrescoSettingsService
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
export * from './AlfrescoApi.service';
|
||||||
export * from './AlfrescoSettings.service';
|
export * from './AlfrescoSettings.service';
|
||||||
export * from './AlfrescoTranslationLoader.service';
|
export * from './AlfrescoTranslationLoader.service';
|
||||||
export * from './AlfrescoTranslation.service';
|
export * from './AlfrescoTranslation.service';
|
||||||
|
@@ -30,6 +30,7 @@ import {
|
|||||||
HostListener
|
HostListener
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { Subject } from 'rxjs/Rx';
|
import { Subject } from 'rxjs/Rx';
|
||||||
|
import { MinimalNodeEntity } from 'alfresco-js-api';
|
||||||
import {
|
import {
|
||||||
CONTEXT_MENU_DIRECTIVES,
|
CONTEXT_MENU_DIRECTIVES,
|
||||||
AlfrescoTranslationService
|
AlfrescoTranslationService
|
||||||
@@ -43,7 +44,6 @@ import {
|
|||||||
} from 'ng2-alfresco-datatable';
|
} from 'ng2-alfresco-datatable';
|
||||||
|
|
||||||
import { DocumentListService } from './../services/document-list.service';
|
import { DocumentListService } from './../services/document-list.service';
|
||||||
import { MinimalNodeEntity } from './../models/document-library.model';
|
|
||||||
import { ContentActionModel } from './../models/content-action.model';
|
import { ContentActionModel } from './../models/content-action.model';
|
||||||
import {
|
import {
|
||||||
ShareDataTableAdapter,
|
ShareDataTableAdapter,
|
||||||
|
@@ -24,7 +24,8 @@ import {
|
|||||||
import {
|
import {
|
||||||
AlfrescoSettingsService,
|
AlfrescoSettingsService,
|
||||||
AlfrescoAuthenticationService,
|
AlfrescoAuthenticationService,
|
||||||
AlfrescoContentService
|
AlfrescoContentService,
|
||||||
|
AlfrescoApiService
|
||||||
} from 'ng2-alfresco-core';
|
} from 'ng2-alfresco-core';
|
||||||
import { FileNode } from '../assets/document-library.model.mock';
|
import { FileNode } from '../assets/document-library.model.mock';
|
||||||
import { ReflectiveInjector } from '@angular/core';
|
import { ReflectiveInjector } from '@angular/core';
|
||||||
@@ -42,6 +43,7 @@ describe('DocumentListService', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
injector = ReflectiveInjector.resolveAndCreate([
|
injector = ReflectiveInjector.resolveAndCreate([
|
||||||
HTTP_PROVIDERS,
|
HTTP_PROVIDERS,
|
||||||
|
AlfrescoApiService,
|
||||||
AlfrescoAuthenticationService,
|
AlfrescoAuthenticationService,
|
||||||
AlfrescoSettingsService
|
AlfrescoSettingsService
|
||||||
]);
|
]);
|
||||||
|
@@ -18,14 +18,12 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Response } from '@angular/http';
|
import { Response } from '@angular/http';
|
||||||
import { Observable } from 'rxjs/Rx';
|
import { Observable } from 'rxjs/Rx';
|
||||||
import { NodePaging, MinimalNodeEntity } from './../models/document-library.model';
|
import { AlfrescoJsApi, NodePaging, MinimalNodeEntity } from 'alfresco-js-api';
|
||||||
import {
|
import {
|
||||||
AlfrescoAuthenticationService,
|
AlfrescoAuthenticationService,
|
||||||
AlfrescoContentService
|
AlfrescoContentService
|
||||||
} from 'ng2-alfresco-core';
|
} from 'ng2-alfresco-core';
|
||||||
|
|
||||||
declare let AlfrescoApi: any;
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class DocumentListService {
|
export class DocumentListService {
|
||||||
|
|
||||||
@@ -66,11 +64,11 @@ export class DocumentListService {
|
|||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private getAlfrescoApi() {
|
private getAlfrescoApi(): AlfrescoJsApi {
|
||||||
return this.authService.getAlfrescoApi();
|
return this.authService.getAlfrescoApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
private getNodesPromise(folder: string, opts?: any) {
|
private getNodesPromise(folder: string, opts?: any): Promise<NodePaging> {
|
||||||
let nodeId = '-root-';
|
let nodeId = '-root-';
|
||||||
let params: any = {
|
let params: any = {
|
||||||
relativePath: folder,
|
relativePath: folder,
|
||||||
@@ -86,11 +84,11 @@ export class DocumentListService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.getAlfrescoApi().node.getNodeChildren(nodeId, params);
|
return this.getAlfrescoApi().nodes.getNodeChildren(nodeId, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteNode(nodeId: string) {
|
deleteNode(nodeId: string): Observable<any> {
|
||||||
return Observable.fromPromise(this.getAlfrescoApi().node.deleteNode(nodeId));
|
return Observable.fromPromise(this.getAlfrescoApi().nodes.deleteNode(nodeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -22,6 +22,7 @@ import { AlfrescoThumbnailService } from './../services/alfresco-thumbnail.servi
|
|||||||
import { TranslationMock } from './../assets/translation.service.mock';
|
import { TranslationMock } from './../assets/translation.service.mock';
|
||||||
import { AlfrescoSearchService } from '../services/alfresco-search.service';
|
import { AlfrescoSearchService } from '../services/alfresco-search.service';
|
||||||
import {
|
import {
|
||||||
|
AlfrescoApiService,
|
||||||
AlfrescoSettingsService,
|
AlfrescoSettingsService,
|
||||||
AlfrescoAuthenticationService,
|
AlfrescoAuthenticationService,
|
||||||
AlfrescoContentService,
|
AlfrescoContentService,
|
||||||
@@ -68,6 +69,7 @@ describe('AlfrescoSearchAutocompleteComponent', () => {
|
|||||||
{provide: AlfrescoTranslationService, useClass: TranslationMock},
|
{provide: AlfrescoTranslationService, useClass: TranslationMock},
|
||||||
AlfrescoThumbnailService,
|
AlfrescoThumbnailService,
|
||||||
AlfrescoSettingsService,
|
AlfrescoSettingsService,
|
||||||
|
AlfrescoApiService,
|
||||||
AlfrescoAuthenticationService,
|
AlfrescoAuthenticationService,
|
||||||
AlfrescoContentService,
|
AlfrescoContentService,
|
||||||
AlfrescoSearchService
|
AlfrescoSearchService
|
||||||
|
@@ -21,7 +21,12 @@ import { TestComponentBuilder } from '@angular/compiler/testing';
|
|||||||
import { AlfrescoSearchControlComponent } from './alfresco-search-control.component';
|
import { AlfrescoSearchControlComponent } from './alfresco-search-control.component';
|
||||||
import { AlfrescoThumbnailService } from './../services/alfresco-thumbnail.service';
|
import { AlfrescoThumbnailService } from './../services/alfresco-thumbnail.service';
|
||||||
import { TranslationMock } from './../assets/translation.service.mock';
|
import { TranslationMock } from './../assets/translation.service.mock';
|
||||||
import { AlfrescoSettingsService, AlfrescoAuthenticationService, AlfrescoContentService, AlfrescoTranslationService
|
import {
|
||||||
|
AlfrescoSettingsService,
|
||||||
|
AlfrescoApiService,
|
||||||
|
AlfrescoAuthenticationService,
|
||||||
|
AlfrescoContentService,
|
||||||
|
AlfrescoTranslationService
|
||||||
} from 'ng2-alfresco-core';
|
} from 'ng2-alfresco-core';
|
||||||
import { AlfrescoSearchService } from '../services/alfresco-search.service';
|
import { AlfrescoSearchService } from '../services/alfresco-search.service';
|
||||||
|
|
||||||
@@ -36,6 +41,7 @@ describe('AlfrescoSearchControlComponent', () => {
|
|||||||
provide(AlfrescoTranslationService, {useClass: TranslationMock}),
|
provide(AlfrescoTranslationService, {useClass: TranslationMock}),
|
||||||
AlfrescoThumbnailService,
|
AlfrescoThumbnailService,
|
||||||
AlfrescoSettingsService,
|
AlfrescoSettingsService,
|
||||||
|
AlfrescoApiService,
|
||||||
AlfrescoAuthenticationService,
|
AlfrescoAuthenticationService,
|
||||||
AlfrescoContentService
|
AlfrescoContentService
|
||||||
];
|
];
|
||||||
|
@@ -24,6 +24,7 @@ import { TranslationMock } from './../assets/translation.service.mock';
|
|||||||
import { AlfrescoSearchService } from '../services/alfresco-search.service';
|
import { AlfrescoSearchService } from '../services/alfresco-search.service';
|
||||||
import {
|
import {
|
||||||
AlfrescoSettingsService,
|
AlfrescoSettingsService,
|
||||||
|
AlfrescoApiService,
|
||||||
AlfrescoAuthenticationService,
|
AlfrescoAuthenticationService,
|
||||||
AlfrescoContentService,
|
AlfrescoContentService,
|
||||||
AlfrescoTranslationService
|
AlfrescoTranslationService
|
||||||
@@ -70,6 +71,7 @@ describe('AlfrescoSearchComponent', () => {
|
|||||||
{provide: AlfrescoTranslationService, useClass: TranslationMock},
|
{provide: AlfrescoTranslationService, useClass: TranslationMock},
|
||||||
AlfrescoThumbnailService,
|
AlfrescoThumbnailService,
|
||||||
AlfrescoSettingsService,
|
AlfrescoSettingsService,
|
||||||
|
AlfrescoApiService,
|
||||||
AlfrescoAuthenticationService,
|
AlfrescoAuthenticationService,
|
||||||
AlfrescoContentService
|
AlfrescoContentService
|
||||||
];
|
];
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import { it, describe, beforeEach, inject, beforeEachProviders } from '@angular/core/testing';
|
import { it, describe, beforeEach, inject, beforeEachProviders } from '@angular/core/testing';
|
||||||
import { AlfrescoSearchService } from './alfresco-search.service';
|
import { AlfrescoSearchService } from './alfresco-search.service';
|
||||||
import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core';
|
import { AlfrescoAuthenticationService, AlfrescoSettingsService, AlfrescoApiService } from 'ng2-alfresco-core';
|
||||||
|
|
||||||
declare let jasmine: any;
|
declare let jasmine: any;
|
||||||
|
|
||||||
@@ -58,6 +58,7 @@ describe('AlfrescoSearchService', () => {
|
|||||||
return [
|
return [
|
||||||
AlfrescoSearchService,
|
AlfrescoSearchService,
|
||||||
AlfrescoSettingsService,
|
AlfrescoSettingsService,
|
||||||
|
AlfrescoApiService,
|
||||||
AlfrescoAuthenticationService
|
AlfrescoAuthenticationService
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
@@ -17,14 +17,21 @@
|
|||||||
|
|
||||||
import { describe, expect, it, inject, beforeEach, beforeEachProviders } from '@angular/core/testing';
|
import { describe, expect, it, inject, beforeEach, beforeEachProviders } from '@angular/core/testing';
|
||||||
import { TestComponentBuilder } from '@angular/compiler/testing';
|
import { TestComponentBuilder } from '@angular/compiler/testing';
|
||||||
import { FileUploadingDialogComponent } from './file-uploading-dialog.component';
|
|
||||||
import { FileModel } from '../models/file.model';
|
|
||||||
import { AlfrescoTranslationService, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
|
||||||
import { TranslationMock } from '../assets/translation.service.mock';
|
|
||||||
import { UploadService } from '../services/upload.service';
|
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { HTTP_PROVIDERS } from '@angular/http';
|
import { HTTP_PROVIDERS } from '@angular/http';
|
||||||
|
|
||||||
|
import {
|
||||||
|
AlfrescoTranslationService,
|
||||||
|
AlfrescoSettingsService,
|
||||||
|
AlfrescoAuthenticationService,
|
||||||
|
AlfrescoApiService
|
||||||
|
} from 'ng2-alfresco-core';
|
||||||
|
|
||||||
|
import { FileUploadingDialogComponent } from './file-uploading-dialog.component';
|
||||||
|
import { FileModel } from '../models/file.model';
|
||||||
|
import { TranslationMock } from '../assets/translation.service.mock';
|
||||||
|
import { UploadService } from '../services/upload.service';
|
||||||
|
|
||||||
describe('FileUploadDialog', () => {
|
describe('FileUploadDialog', () => {
|
||||||
|
|
||||||
let componentFixture;
|
let componentFixture;
|
||||||
@@ -33,6 +40,7 @@ describe('FileUploadDialog', () => {
|
|||||||
beforeEachProviders(() => {
|
beforeEachProviders(() => {
|
||||||
return [
|
return [
|
||||||
HTTP_PROVIDERS,
|
HTTP_PROVIDERS,
|
||||||
|
AlfrescoApiService,
|
||||||
AlfrescoSettingsService,
|
AlfrescoSettingsService,
|
||||||
AlfrescoAuthenticationService,
|
AlfrescoAuthenticationService,
|
||||||
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
|
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
|
||||||
|
@@ -17,11 +17,18 @@
|
|||||||
|
|
||||||
import { describe, expect, it, inject, beforeEach, beforeEachProviders } from '@angular/core/testing';
|
import { describe, expect, it, inject, beforeEach, beforeEachProviders } from '@angular/core/testing';
|
||||||
import { TestComponentBuilder } from '@angular/compiler/testing';
|
import { TestComponentBuilder } from '@angular/compiler/testing';
|
||||||
|
import { HTTP_PROVIDERS } from '@angular/http';
|
||||||
|
|
||||||
|
import {
|
||||||
|
AlfrescoTranslationService,
|
||||||
|
AlfrescoSettingsService,
|
||||||
|
AlfrescoAuthenticationService,
|
||||||
|
AlfrescoApiService
|
||||||
|
} from 'ng2-alfresco-core';
|
||||||
|
|
||||||
import { UploadButtonComponent } from './upload-button.component';
|
import { UploadButtonComponent } from './upload-button.component';
|
||||||
import { AlfrescoTranslationService, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
|
||||||
import { TranslationMock } from '../assets/translation.service.mock';
|
import { TranslationMock } from '../assets/translation.service.mock';
|
||||||
import { UploadService } from '../services/upload.service';
|
import { UploadService } from '../services/upload.service';
|
||||||
import { HTTP_PROVIDERS } from '@angular/http';
|
|
||||||
|
|
||||||
declare var AlfrescoApi: any;
|
declare var AlfrescoApi: any;
|
||||||
|
|
||||||
@@ -71,6 +78,7 @@ describe('AlfrescoUploadButton', () => {
|
|||||||
HTTP_PROVIDERS,
|
HTTP_PROVIDERS,
|
||||||
AlfrescoSettingsService,
|
AlfrescoSettingsService,
|
||||||
AlfrescoAuthenticationService,
|
AlfrescoAuthenticationService,
|
||||||
|
AlfrescoApiService,
|
||||||
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
|
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
|
||||||
UploadService
|
UploadService
|
||||||
];
|
];
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
import { describe, expect, it, inject, beforeEach, beforeEachProviders } from '@angular/core/testing';
|
import { describe, expect, it, inject, beforeEach, beforeEachProviders } from '@angular/core/testing';
|
||||||
import { TestComponentBuilder } from '@angular/compiler/testing';
|
import { TestComponentBuilder } from '@angular/compiler/testing';
|
||||||
import { UploadDragAreaComponent } from './upload-drag-area.component';
|
import { UploadDragAreaComponent } from './upload-drag-area.component';
|
||||||
import { AlfrescoTranslationService, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
import { AlfrescoTranslationService, AlfrescoSettingsService, AlfrescoAuthenticationService, AlfrescoApiService } from 'ng2-alfresco-core';
|
||||||
import { TranslationMock } from '../assets/translation.service.mock';
|
import { TranslationMock } from '../assets/translation.service.mock';
|
||||||
import { UploadService } from '../services/upload.service';
|
import { UploadService } from '../services/upload.service';
|
||||||
import { HTTP_PROVIDERS } from '@angular/http';
|
import { HTTP_PROVIDERS } from '@angular/http';
|
||||||
@@ -39,6 +39,7 @@ describe('AlfrescoUploadDragArea', () => {
|
|||||||
HTTP_PROVIDERS,
|
HTTP_PROVIDERS,
|
||||||
AlfrescoSettingsService,
|
AlfrescoSettingsService,
|
||||||
AlfrescoAuthenticationService,
|
AlfrescoAuthenticationService,
|
||||||
|
AlfrescoApiService,
|
||||||
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
|
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
|
||||||
UploadService
|
UploadService
|
||||||
];
|
];
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
import { it, describe, inject, beforeEach, beforeEachProviders } from '@angular/core/testing';
|
import { it, describe, inject, beforeEach, beforeEachProviders } from '@angular/core/testing';
|
||||||
import { EventEmitter } from '@angular/core';
|
import { EventEmitter } from '@angular/core';
|
||||||
import { UploadService } from './upload.service';
|
import { UploadService } from './upload.service';
|
||||||
import { AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
import { AlfrescoSettingsService, AlfrescoApiService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
||||||
|
|
||||||
declare let AlfrescoApi: any;
|
declare let AlfrescoApi: any;
|
||||||
declare let jasmine: any;
|
declare let jasmine: any;
|
||||||
@@ -39,14 +39,16 @@ describe('AlfrescoUploadService', () => {
|
|||||||
beforeEachProviders(() => {
|
beforeEachProviders(() => {
|
||||||
return [
|
return [
|
||||||
AlfrescoSettingsService,
|
AlfrescoSettingsService,
|
||||||
|
AlfrescoApiService,
|
||||||
AlfrescoAuthenticationService,
|
AlfrescoAuthenticationService,
|
||||||
UploadService
|
UploadService
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(inject([UploadService], (uploadService: UploadService) => {
|
beforeEach( inject([UploadService, AlfrescoApiService], (uploadService: UploadService, apiService: AlfrescoApiService) => {
|
||||||
jasmine.Ajax.install();
|
jasmine.Ajax.install();
|
||||||
service = uploadService;
|
service = uploadService;
|
||||||
|
apiService.setInstance(new AlfrescoApi({}));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@@ -85,7 +87,7 @@ describe('AlfrescoUploadService', () => {
|
|||||||
service.uploadFilesInTheQueue('fake-dir', emitter);
|
service.uploadFilesInTheQueue('fake-dir', emitter);
|
||||||
|
|
||||||
let request = jasmine.Ajax.requests.mostRecent();
|
let request = jasmine.Ajax.requests.mostRecent();
|
||||||
expect(request.url).toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children?autoRename=true');
|
expect(request.url).toBe('http://127.0.0.1:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children?autoRename=true');
|
||||||
expect(request.method).toBe('POST');
|
expect(request.method).toBe('POST');
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
@@ -107,7 +109,7 @@ describe('AlfrescoUploadService', () => {
|
|||||||
service.addToQueue(filesFake);
|
service.addToQueue(filesFake);
|
||||||
service.uploadFilesInTheQueue('', emitter);
|
service.uploadFilesInTheQueue('', emitter);
|
||||||
expect(jasmine.Ajax.requests.mostRecent().url)
|
expect(jasmine.Ajax.requests.mostRecent().url)
|
||||||
.toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children?autoRename=true');
|
.toBe('http://127.0.0.1:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children?autoRename=true');
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
'status': 404,
|
'status': 404,
|
||||||
|
@@ -19,7 +19,7 @@ import { EventEmitter, Injectable } from '@angular/core';
|
|||||||
import { Response } from '@angular/http';
|
import { Response } from '@angular/http';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { Observer } from 'rxjs/Observer';
|
import { Observer } from 'rxjs/Observer';
|
||||||
import { AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
import { AlfrescoApiService } from 'ng2-alfresco-core';
|
||||||
import { FileModel } from '../models/file.model';
|
import { FileModel } from '../models/file.model';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,7 +44,7 @@ export class UploadService {
|
|||||||
filesUpload$: Observable<FileModel[]>;
|
filesUpload$: Observable<FileModel[]>;
|
||||||
totalCompleted$: Observable<any>;
|
totalCompleted$: Observable<any>;
|
||||||
|
|
||||||
constructor(private authService: AlfrescoAuthenticationService) {
|
constructor(private apiService: AlfrescoApiService) {
|
||||||
this.filesUpload$ = new Observable<FileModel[]>(observer => this.filesUploadObserverProgressBar = observer).share();
|
this.filesUpload$ = new Observable<FileModel[]>(observer => this.filesUploadObserverProgressBar = observer).share();
|
||||||
this.totalCompleted$ = new Observable<number>(observer => this.totalCompletedObserver = observer).share();
|
this.totalCompleted$ = new Observable<number>(observer => this.totalCompletedObserver = observer).share();
|
||||||
}
|
}
|
||||||
@@ -105,7 +105,7 @@ export class UploadService {
|
|||||||
filesToUpload.forEach((uploadingFileModel: FileModel) => {
|
filesToUpload.forEach((uploadingFileModel: FileModel) => {
|
||||||
uploadingFileModel.setUploading();
|
uploadingFileModel.setUploading();
|
||||||
|
|
||||||
let promiseUpload = this.authService.getAlfrescoApi().upload.uploadFile(uploadingFileModel.file, directory, null, null, opts)
|
let promiseUpload = this.apiService.getInstance().upload.uploadFile(uploadingFileModel.file, directory, null, null, opts)
|
||||||
.on('progress', (progress: any) => {
|
.on('progress', (progress: any) => {
|
||||||
uploadingFileModel.setProgres(progress);
|
uploadingFileModel.setProgres(progress);
|
||||||
this.updateFileListStream(this.queue);
|
this.updateFileListStream(this.queue);
|
||||||
@@ -174,7 +174,7 @@ export class UploadService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private callApiCreateFolder(relativePath: string, name: string) {
|
private callApiCreateFolder(relativePath: string, name: string) {
|
||||||
return this.authService.getAlfrescoApi().node.createFolder(name, relativePath);
|
return this.apiService.getInstance().nodes.createFolder(name, relativePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -19,24 +19,30 @@ import { describe, expect, it, inject, beforeEachProviders, beforeEach, afterEac
|
|||||||
import { TestComponentBuilder } from '@angular/compiler/testing';
|
import { TestComponentBuilder } from '@angular/compiler/testing';
|
||||||
import { ViewerComponent } from './viewer.component';
|
import { ViewerComponent } from './viewer.component';
|
||||||
import { EventMock } from '../assets/event.mock';
|
import { EventMock } from '../assets/event.mock';
|
||||||
import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core';
|
import { AlfrescoAuthenticationService, AlfrescoSettingsService, AlfrescoApiService } from 'ng2-alfresco-core';
|
||||||
import { RenderingQueueServices } from '../services/rendering-queue.services';
|
import { RenderingQueueServices } from '../services/rendering-queue.services';
|
||||||
|
|
||||||
declare let jasmine: any;
|
declare let jasmine: any;
|
||||||
|
declare let AlfrescoApi: any;
|
||||||
|
|
||||||
describe('ViewerComponent', () => {
|
describe('ViewerComponent', () => {
|
||||||
|
|
||||||
let viewerComponentFixture, element, component;
|
let viewerComponentFixture, element, component;
|
||||||
|
let apiService: AlfrescoApiService;
|
||||||
|
|
||||||
beforeEachProviders(() => {
|
beforeEachProviders(() => {
|
||||||
return [
|
return [
|
||||||
|
AlfrescoApiService,
|
||||||
AlfrescoSettingsService,
|
AlfrescoSettingsService,
|
||||||
AlfrescoAuthenticationService,
|
AlfrescoAuthenticationService,
|
||||||
RenderingQueueServices
|
RenderingQueueServices
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
beforeEach(inject([TestComponentBuilder, AlfrescoApiService], (tcb: TestComponentBuilder, api: AlfrescoApiService) => {
|
||||||
|
apiService = api;
|
||||||
|
apiService.setInstance(new AlfrescoApi({}));
|
||||||
|
|
||||||
return tcb
|
return tcb
|
||||||
.createAsync(ViewerComponent)
|
.createAsync(ViewerComponent)
|
||||||
.then(fixture => {
|
.then(fixture => {
|
||||||
@@ -160,27 +166,16 @@ describe('ViewerComponent', () => {
|
|||||||
}).not.toThrow();
|
}).not.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('If FileNodeId is present the node api should be called', (done) => {
|
it('If FileNodeId is present the node api should be called', (/*done*/) => {
|
||||||
component.showViewer = true;
|
component.showViewer = true;
|
||||||
component.fileNodeId = 'file-node-id';
|
component.fileNodeId = 'file-node-id';
|
||||||
component.urlFile = undefined;
|
component.urlFile = undefined;
|
||||||
|
|
||||||
jasmine.Ajax.stubRequest(
|
let alfrescoApi = apiService.getInstance();
|
||||||
'http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/file-node-id'
|
spyOn(alfrescoApi.nodes, 'getNodeInfo').and.stub();
|
||||||
).andReturn({
|
|
||||||
status: 200,
|
|
||||||
responseText: '{"entry":{"isFile":true,"createdByUser":{"id":"admin","displayName":"Administrator"},' +
|
|
||||||
'"modifiedAt":"2016-08-05T23:08:22.730+0000","nodeType":"cm:content","content":' +
|
|
||||||
'{"mimeType":"application/pdf","mimeTypeName":"Adobe PDF Document","sizeInBytes":' +
|
|
||||||
'381778,"encoding":"UTF-8"},"parentId":"8f2105b4-daaf-4874-9e8a-2152569d109b","createdAt":"2016-08-05T23:08:22.730+0000","isFolder":false,' +
|
|
||||||
'"modifiedByUser":{"id":"admin","displayName":"Administrator"},"name":"content.pdf","id":' +
|
|
||||||
'"b8bd4c81-6f2e-4ec2-9c4d-30c97cf42bc8"}}'
|
|
||||||
});
|
|
||||||
|
|
||||||
component.ngOnChanges().then(() => {
|
component.ngOnChanges();
|
||||||
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('nodes/file-node-id')).toBe(true);
|
expect(alfrescoApi.nodes.getNodeInfo).toHaveBeenCalledWith(component.fileNodeId);
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('showViewer default value should be true', () => {
|
it('showViewer default value should be true', () => {
|
||||||
|
@@ -21,7 +21,8 @@ import { ImgViewerComponent } from './imgViewer.component';
|
|||||||
import { MediaPlayerComponent } from './mediaPlayer.component';
|
import { MediaPlayerComponent } from './mediaPlayer.component';
|
||||||
import { NotSupportedFormat } from './notSupportedFormat.component';
|
import { NotSupportedFormat } from './notSupportedFormat.component';
|
||||||
import { DOCUMENT } from '@angular/platform-browser';
|
import { DOCUMENT } from '@angular/platform-browser';
|
||||||
import { AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
|
||||||
|
import { AlfrescoApiService } from 'ng2-alfresco-core';
|
||||||
|
|
||||||
declare let __moduleName: string;
|
declare let __moduleName: string;
|
||||||
|
|
||||||
@@ -64,7 +65,9 @@ export class ViewerComponent {
|
|||||||
|
|
||||||
loaded: boolean = false;
|
loaded: boolean = false;
|
||||||
|
|
||||||
constructor(private authService: AlfrescoAuthenticationService, private element: ElementRef, @Inject(DOCUMENT) private document) {
|
constructor(private apiService: AlfrescoApiService,
|
||||||
|
private element: ElementRef,
|
||||||
|
@Inject(DOCUMENT) private document) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes) {
|
ngOnChanges(changes) {
|
||||||
@@ -75,6 +78,7 @@ export class ViewerComponent {
|
|||||||
throw new Error('Attribute urlFile or fileNodeId is required');
|
throw new Error('Attribute urlFile or fileNodeId is required');
|
||||||
}
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
let alfrescoApi = this.apiService.getInstance();
|
||||||
if (this.urlFile) {
|
if (this.urlFile) {
|
||||||
let filenameFromUrl = this.getFilenameFromUrl(this.urlFile);
|
let filenameFromUrl = this.getFilenameFromUrl(this.urlFile);
|
||||||
this.displayName = filenameFromUrl ? filenameFromUrl : '';
|
this.displayName = filenameFromUrl ? filenameFromUrl : '';
|
||||||
@@ -82,10 +86,10 @@ export class ViewerComponent {
|
|||||||
this.urlFileContent = this.urlFile;
|
this.urlFileContent = this.urlFile;
|
||||||
resolve();
|
resolve();
|
||||||
} else if (this.fileNodeId) {
|
} else if (this.fileNodeId) {
|
||||||
this.authService.getAlfrescoApi().nodes.getNodeInfo(this.fileNodeId).then((data) => {
|
alfrescoApi.nodes.getNodeInfo(this.fileNodeId).then((data: MinimalNodeEntryEntity) => {
|
||||||
this.mimeType = data.content.mimeType;
|
this.mimeType = data.content.mimeType;
|
||||||
this.displayName = data.name;
|
this.displayName = data.name;
|
||||||
this.urlFileContent = this.authService.getAlfrescoApi().content.getContentUrl(data.id);
|
this.urlFileContent = alfrescoApi.content.getContentUrl(data.id);
|
||||||
this.loaded = true;
|
this.loaded = true;
|
||||||
resolve();
|
resolve();
|
||||||
}, function (error) {
|
}, function (error) {
|
||||||
|
@@ -19,7 +19,7 @@ import { describe, expect, it, inject, beforeEachProviders, beforeEach, afterEac
|
|||||||
import { TestComponentBuilder } from '@angular/compiler/testing';
|
import { TestComponentBuilder } from '@angular/compiler/testing';
|
||||||
import { WebscriptComponent } from '../src/webscript.component';
|
import { WebscriptComponent } from '../src/webscript.component';
|
||||||
|
|
||||||
import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core';
|
import { AlfrescoAuthenticationService, AlfrescoSettingsService, AlfrescoApiService } from 'ng2-alfresco-core';
|
||||||
|
|
||||||
declare let jasmine: any;
|
declare let jasmine: any;
|
||||||
|
|
||||||
@@ -30,6 +30,7 @@ describe('Test ng2-alfresco-webscript', () => {
|
|||||||
beforeEachProviders(() => {
|
beforeEachProviders(() => {
|
||||||
return [
|
return [
|
||||||
AlfrescoSettingsService,
|
AlfrescoSettingsService,
|
||||||
|
AlfrescoApiService,
|
||||||
AlfrescoAuthenticationService
|
AlfrescoAuthenticationService
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user