mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
parent
c5dca890b7
commit
9fb085eb3a
@ -20,16 +20,14 @@ import { LogService } from './log.service';
|
|||||||
import { SettingsService } from './settings.service';
|
import { SettingsService } from './settings.service';
|
||||||
import { StorageService } from './storage.service';
|
import { StorageService } from './storage.service';
|
||||||
import { AlfrescoApiService } from './alfresco-api.service';
|
import { AlfrescoApiService } from './alfresco-api.service';
|
||||||
import { AuthService } from './auth.service';
|
|
||||||
|
|
||||||
/** @deprecated AlfrescoAuthenticationService is deprecated. Use AuthService instead */
|
/** @deprecated AlfrescoAuthenticationService is deprecated. Use AuthService instead */
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AlfrescoAuthenticationService extends AuthService {
|
export class AlfrescoAuthenticationService {
|
||||||
constructor(settingsService: SettingsService,
|
constructor(settingsService: SettingsService,
|
||||||
apiService: AlfrescoApiService,
|
apiService: AlfrescoApiService,
|
||||||
storage: StorageService,
|
storage: StorageService,
|
||||||
logService: LogService) {
|
logService: LogService) {
|
||||||
super(settingsService, apiService, storage, logService);
|
logService.error('ERROR: AlfrescoAuthenticationService is deprecated. Use AuthService instead.');
|
||||||
logService.warn('Warning: AlfrescoAuthenticationService is deprecated. Use AuthService instead.');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,17 +18,15 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { LogService } from './log.service';
|
import { LogService } from './log.service';
|
||||||
import { AuthService } from './auth.service';
|
import { AuthService } from './auth.service';
|
||||||
import { ContentService } from './content.service';
|
|
||||||
import { AlfrescoApiService } from './alfresco-api.service';
|
import { AlfrescoApiService } from './alfresco-api.service';
|
||||||
|
|
||||||
/** @deprecated AlfrescoContentService is deprecated. Use ContentService instead */
|
/** @deprecated AlfrescoContentService is deprecated. Use ContentService instead */
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AlfrescoContentService extends ContentService {
|
export class AlfrescoContentService {
|
||||||
|
|
||||||
constructor(authService: AuthService,
|
constructor(authService: AuthService,
|
||||||
apiService: AlfrescoApiService,
|
apiService: AlfrescoApiService,
|
||||||
logService: LogService) {
|
logService: LogService) {
|
||||||
super(authService, apiService);
|
logService.error('ERROR: AlfrescoContentService is deprecated. Use ContentService instead.');
|
||||||
logService.warn('Warning: AlfrescoContentService is deprecated. Use ContentService instead.');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,15 +16,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { SettingsService } from './settings.service';
|
|
||||||
import { LogService } from './log.service';
|
import { LogService } from './log.service';
|
||||||
|
|
||||||
/** @deprecated AlfrescoSettingsService is deprecated. Use SettingsService instead */
|
/** @deprecated AlfrescoSettingsService is deprecated. Use SettingsService instead */
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AlfrescoSettingsService extends SettingsService {
|
export class AlfrescoSettingsService {
|
||||||
|
|
||||||
constructor(logService: LogService) {
|
constructor(logService: LogService) {
|
||||||
super();
|
logService.error('ERROR: AlfrescoSettingsService is deprecated. Use SettingsService instead.');
|
||||||
logService.warn('Warning: AlfrescoSettingsService is deprecated. Use SettingsService instead.');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,17 +17,15 @@
|
|||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { TranslateService } from 'ng2-translate/ng2-translate';
|
import { TranslateService } from 'ng2-translate/ng2-translate';
|
||||||
import { AlfrescoTranslateService } from './translate.service';
|
|
||||||
import { LogService } from './log.service';
|
import { LogService } from './log.service';
|
||||||
|
|
||||||
/** @deprecated AlfrescoTranslationService is deprecated. Use AlfrescoTranslateService instead */
|
/** @deprecated AlfrescoTranslationService is deprecated. Use AlfrescoTranslateService instead */
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AlfrescoTranslationService extends AlfrescoTranslateService {
|
export class AlfrescoTranslationService {
|
||||||
|
|
||||||
constructor(translate: TranslateService,
|
constructor(translate: TranslateService,
|
||||||
logService: LogService) {
|
logService: LogService) {
|
||||||
super(translate);
|
logService.error('ERROR: AlfrescoTranslationService is deprecated. Use AlfrescoTranslateService instead.');
|
||||||
logService.warn('Warning: AlfrescoTranslationService is deprecated. Use AlfrescoTranslateService instead.');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,32 +16,94 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import * as alfrescoApi from 'alfresco-js-api';
|
|
||||||
import { AlfrescoApi } from 'alfresco-js-api';
|
import { AlfrescoApi } from 'alfresco-js-api';
|
||||||
|
import * as alfrescoApi from 'alfresco-js-api';
|
||||||
|
import { SettingsService } from './settings.service';
|
||||||
|
import { StorageService } from './storage.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AlfrescoApiService {
|
export class AlfrescoApiService {
|
||||||
|
|
||||||
private _instance: AlfrescoApi;
|
private alfrescoApi: AlfrescoApi;
|
||||||
|
|
||||||
|
private provider: string;
|
||||||
|
|
||||||
|
private ticketEcm: string;
|
||||||
|
|
||||||
|
private ticketBpm: string;
|
||||||
|
|
||||||
|
private hostEcm: string;
|
||||||
|
|
||||||
|
private hostBpm: string;
|
||||||
|
|
||||||
|
private contextRoot: string;
|
||||||
|
|
||||||
|
private disableCsrf: boolean;
|
||||||
|
|
||||||
public getInstance(): AlfrescoApi {
|
public getInstance(): AlfrescoApi {
|
||||||
return this._instance;
|
return this.alfrescoApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
public setInstance(value: AlfrescoApi) {
|
constructor(private settingsService: SettingsService,
|
||||||
this._instance = value;
|
private storage: StorageService) {
|
||||||
}
|
|
||||||
|
|
||||||
constructor() {
|
this.provider = this.settingsService.getProviders();
|
||||||
this._instance = <AlfrescoApi>new alfrescoApi({
|
this.ticketEcm = this.getTicketEcm();
|
||||||
provider: 'ALL',
|
this.ticketBpm = this.getTicketBpm();
|
||||||
ticketEcm: null,
|
this.hostEcm = this.settingsService.ecmHost;
|
||||||
ticketBpm: null,
|
this.hostBpm = this.settingsService.bpmHost;
|
||||||
hostEcm: 'http://localhost:8080',
|
this.contextRoot = 'alfresco';
|
||||||
hostBpm: 'http://localhost:9999',
|
this.disableCsrf = false;
|
||||||
contextRoot: 'alfresco',
|
|
||||||
disableCsrf: true
|
this.init();
|
||||||
|
|
||||||
|
settingsService.bpmHostSubject.subscribe((hostBpm) => {
|
||||||
|
this.hostBpm = hostBpm;
|
||||||
|
this.init();
|
||||||
|
});
|
||||||
|
|
||||||
|
settingsService.ecmHostSubject.subscribe((hostEcm) => {
|
||||||
|
this.hostEcm = hostEcm;
|
||||||
|
this.init();
|
||||||
|
});
|
||||||
|
|
||||||
|
settingsService.csrfSubject.subscribe((disableCsrf) => {
|
||||||
|
this.disableCsrf = disableCsrf;
|
||||||
|
this.init();
|
||||||
|
});
|
||||||
|
|
||||||
|
settingsService.providerSubject.subscribe((provider) => {
|
||||||
|
this.provider = provider;
|
||||||
|
this.init();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private init() {
|
||||||
|
this.alfrescoApi = <AlfrescoApi>new alfrescoApi({
|
||||||
|
provider: this.provider,
|
||||||
|
ticketEcm: this.ticketEcm,
|
||||||
|
ticketBpm: this.ticketBpm,
|
||||||
|
hostEcm: this.hostEcm,
|
||||||
|
hostBpm: this.hostBpm,
|
||||||
|
contextRoot: this.contextRoot,
|
||||||
|
disableCsrf: this.disableCsrf
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The method return the ECM ticket stored in the Storage
|
||||||
|
* @returns ticket
|
||||||
|
*/
|
||||||
|
private getTicketEcm(): string {
|
||||||
|
return this.storage.getItem('ticket-ECM');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The method return the BPM ticket stored in the Storage
|
||||||
|
* @returns ticket
|
||||||
|
*/
|
||||||
|
private getTicketBpm(): string {
|
||||||
|
return this.storage.getItem('ticket-BPM');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ describe('AuthService', () => {
|
|||||||
authService.login('fake-username', 'fake-password').subscribe(() => {
|
authService.login('fake-username', 'fake-password').subscribe(() => {
|
||||||
expect(authService.isLoggedIn()).toBe(true);
|
expect(authService.isLoggedIn()).toBe(true);
|
||||||
expect(authService.getTicketBpm()).toBeNull();
|
expect(authService.getTicketBpm()).toBeNull();
|
||||||
expect(authService.alfrescoApi.bpmAuth.isLoggedIn()).toBeFalsy();
|
expect(authService.alfrescoApi.getInstance().bpmAuth.isLoggedIn()).toBeFalsy();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ describe('AuthService', () => {
|
|||||||
authService.login('fake-username', 'fake-password').subscribe(() => {
|
authService.login('fake-username', 'fake-password').subscribe(() => {
|
||||||
expect(authService.isLoggedIn()).toBe(true);
|
expect(authService.isLoggedIn()).toBe(true);
|
||||||
expect(authService.getTicketEcm()).toBeNull();
|
expect(authService.getTicketEcm()).toBeNull();
|
||||||
expect(authService.alfrescoApi.ecmAuth.isLoggedIn()).toBeFalsy();
|
expect(authService.alfrescoApi.getInstance().ecmAuth.isLoggedIn()).toBeFalsy();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -296,19 +296,19 @@ describe('AuthService', () => {
|
|||||||
it('should host ecm url change be reflected in the api configuration', () => {
|
it('should host ecm url change be reflected in the api configuration', () => {
|
||||||
settingsService.ecmHost = '127.99.99.99';
|
settingsService.ecmHost = '127.99.99.99';
|
||||||
|
|
||||||
expect(authService.alfrescoApi.config.hostEcm).toBe('127.99.99.99');
|
expect(authService.alfrescoApi.getInstance().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', () => {
|
||||||
settingsService.bpmHost = '127.99.99.99';
|
settingsService.bpmHost = '127.99.99.99';
|
||||||
|
|
||||||
expect(authService.alfrescoApi.config.hostBpm).toBe('127.99.99.99');
|
expect(authService.alfrescoApi.getInstance().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', () => {
|
||||||
settingsService.setProviders('ECM');
|
settingsService.setProviders('ECM');
|
||||||
|
|
||||||
expect(authService.alfrescoApi.config.provider).toBe('ECM');
|
expect(authService.alfrescoApi.getInstance().config.provider).toBe('ECM');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -19,49 +19,18 @@ import { Injectable } from '@angular/core';
|
|||||||
import { Observable, Subject } from 'rxjs/Rx';
|
import { Observable, Subject } from 'rxjs/Rx';
|
||||||
import { SettingsService } from './settings.service';
|
import { SettingsService } from './settings.service';
|
||||||
import { StorageService } from './storage.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 { LogService } from './log.service';
|
import { LogService } from './log.service';
|
||||||
|
import { AlfrescoApiService } from './alfresco-api.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AuthService {
|
export class AuthService {
|
||||||
|
|
||||||
alfrescoApi: AlfrescoApi;
|
|
||||||
loginSubject: Subject<any> = new Subject<any>();
|
loginSubject: Subject<any> = new Subject<any>();
|
||||||
logoutSubject: Subject<any> = new Subject<any>();
|
logoutSubject: Subject<any> = new Subject<any>();
|
||||||
|
|
||||||
constructor(private settingsService: SettingsService,
|
constructor(private settingsService: SettingsService,
|
||||||
private apiService: AlfrescoApiService,
|
public alfrescoApi: AlfrescoApiService,
|
||||||
private storage: StorageService,
|
private storage: StorageService,
|
||||||
private logService: LogService) {
|
private logService: LogService) {
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,7 +38,7 @@ export class AuthService {
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
isLoggedIn(): boolean {
|
isLoggedIn(): boolean {
|
||||||
return !!this.alfrescoApi.isLoggedIn();
|
return !!this.alfrescoApi.getInstance().isLoggedIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -96,7 +65,7 @@ export class AuthService {
|
|||||||
* @returns {*|Observable<any>}
|
* @returns {*|Observable<any>}
|
||||||
*/
|
*/
|
||||||
private callApiLogin(username: string, password: string) {
|
private callApiLogin(username: string, password: string) {
|
||||||
return this.alfrescoApi.login(username, password);
|
return this.alfrescoApi.getInstance().login(username, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -120,8 +89,8 @@ export class AuthService {
|
|||||||
* @returns {*|Observable<string>|Observable<any>|Promise<T>}
|
* @returns {*|Observable<string>|Observable<any>|Promise<T>}
|
||||||
*/
|
*/
|
||||||
private callApiLogout(): Promise<any> {
|
private callApiLogout(): Promise<any> {
|
||||||
if (this.alfrescoApi) {
|
if (this.alfrescoApi.getInstance()) {
|
||||||
return this.alfrescoApi.logout();
|
return this.alfrescoApi.getInstance().logout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +100,7 @@ export class AuthService {
|
|||||||
removeTicket(): void {
|
removeTicket(): void {
|
||||||
this.storage.removeItem('ticket-ECM');
|
this.storage.removeItem('ticket-ECM');
|
||||||
this.storage.removeItem('ticket-BPM');
|
this.storage.removeItem('ticket-BPM');
|
||||||
this.alfrescoApi.setTicket(undefined, undefined);
|
this.alfrescoApi.getInstance().setTicket(undefined, undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -170,8 +139,8 @@ export class AuthService {
|
|||||||
* The method save the ECM ticket in the Storage
|
* The method save the ECM ticket in the Storage
|
||||||
*/
|
*/
|
||||||
saveTicketEcm(): void {
|
saveTicketEcm(): void {
|
||||||
if (this.alfrescoApi && this.alfrescoApi.getTicketEcm()) {
|
if (this.alfrescoApi.getInstance() && this.alfrescoApi.getInstance().getTicketEcm()) {
|
||||||
this.storage.setItem('ticket-ECM', this.alfrescoApi.getTicketEcm());
|
this.storage.setItem('ticket-ECM', this.alfrescoApi.getInstance().getTicketEcm());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,8 +148,8 @@ export class AuthService {
|
|||||||
* The method save the BPM ticket in the Storage
|
* The method save the BPM ticket in the Storage
|
||||||
*/
|
*/
|
||||||
saveTicketBpm(): void {
|
saveTicketBpm(): void {
|
||||||
if (this.alfrescoApi && this.alfrescoApi.getTicketBpm()) {
|
if (this.alfrescoApi.getInstance() && this.alfrescoApi.getInstance().getTicketBpm()) {
|
||||||
this.storage.setItem('ticket-BPM', this.alfrescoApi.getTicketBpm());
|
this.storage.setItem('ticket-BPM', this.alfrescoApi.getInstance().getTicketBpm());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,14 +157,14 @@ export class AuthService {
|
|||||||
* The method return true if user is logged in on ecm provider
|
* The method return true if user is logged in on ecm provider
|
||||||
*/
|
*/
|
||||||
isEcmLoggedIn() {
|
isEcmLoggedIn() {
|
||||||
return this.alfrescoApi.ecmAuth && !!this.alfrescoApi.ecmAuth.isLoggedIn();
|
return this.alfrescoApi.getInstance().ecmAuth && !!this.alfrescoApi.getInstance().ecmAuth.isLoggedIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The method return true if user is logged in on bpm provider
|
* The method return true if user is logged in on bpm provider
|
||||||
*/
|
*/
|
||||||
isBpmLoggedIn() {
|
isBpmLoggedIn() {
|
||||||
return this.alfrescoApi.bpmAuth && !!this.alfrescoApi.bpmAuth.isLoggedIn();
|
return this.alfrescoApi.getInstance().bpmAuth && !!this.alfrescoApi.getInstance().bpmAuth.isLoggedIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
import { ReflectiveInjector } from '@angular/core';
|
import { ReflectiveInjector } from '@angular/core';
|
||||||
import { AlfrescoApiService } from './alfresco-api.service';
|
import { AlfrescoApiService } from './alfresco-api.service';
|
||||||
import { RenditionsService } from './renditions.service';
|
import { RenditionsService } from './renditions.service';
|
||||||
|
import { SettingsService } from './settings.service';
|
||||||
|
import { StorageService } from './storage.service';
|
||||||
import { LogService } from './log.service';
|
import { LogService } from './log.service';
|
||||||
import { fakeRedition, fakeReditionCreated, fakeReditionsList } from '../assets/renditionsService.mock';
|
import { fakeRedition, fakeReditionCreated, fakeReditionsList } from '../assets/renditionsService.mock';
|
||||||
|
|
||||||
@ -31,6 +33,8 @@ describe('RenditionsService', () => {
|
|||||||
injector = ReflectiveInjector.resolveAndCreate([
|
injector = ReflectiveInjector.resolveAndCreate([
|
||||||
AlfrescoApiService,
|
AlfrescoApiService,
|
||||||
RenditionsService,
|
RenditionsService,
|
||||||
|
SettingsService,
|
||||||
|
StorageService,
|
||||||
LogService
|
LogService
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
@ -38,7 +42,6 @@ describe('RenditionsService', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jasmine.Ajax.install();
|
jasmine.Ajax.install();
|
||||||
service = injector.get(RenditionsService);
|
service = injector.get(RenditionsService);
|
||||||
service.apiService.setInstance(new AlfrescoApi({}));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -60,7 +63,7 @@ describe('RenditionsService', () => {
|
|||||||
|
|
||||||
it('Create redition service should call the server with the ID passed and the asked encoding', (done) => {
|
it('Create redition service should call the server with the ID passed and the asked encoding', (done) => {
|
||||||
service.createRendition('fake-node-id', 'pdf').subscribe((res) => {
|
service.createRendition('fake-node-id', 'pdf').subscribe((res) => {
|
||||||
expect(jasmine.Ajax.requests.mostRecent().url).toBe('http://127.0.0.1:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/renditions');
|
expect(jasmine.Ajax.requests.mostRecent().url).toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/renditions');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ import { DocumentListService } from './../services/document-list.service';
|
|||||||
import {
|
import {
|
||||||
SettingsService,
|
SettingsService,
|
||||||
AuthService,
|
AuthService,
|
||||||
AlfrescoContentService,
|
ContentService,
|
||||||
AlfrescoApiService,
|
AlfrescoApiService,
|
||||||
LogService
|
LogService
|
||||||
} from 'ng2-alfresco-core';
|
} from 'ng2-alfresco-core';
|
||||||
@ -36,7 +36,7 @@ export class DocumentListServiceMock extends DocumentListService {
|
|||||||
constructor(
|
constructor(
|
||||||
settings?: SettingsService,
|
settings?: SettingsService,
|
||||||
authService?: AuthService,
|
authService?: AuthService,
|
||||||
contentService?: AlfrescoContentService,
|
contentService?: ContentService,
|
||||||
apiService?: AlfrescoApiService,
|
apiService?: AlfrescoApiService,
|
||||||
logService?: LogService,
|
logService?: LogService,
|
||||||
) {
|
) {
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<div class="document-list__this-space-is-empty">This folder is empty</div>
|
<div class="document-list__this-space-is-empty">This folder is empty</div>
|
||||||
<div class="document-list__drag-drop">Drag and Drop</div>
|
<div class="document-list__drag-drop">Drag and Drop</div>
|
||||||
<div class="document-list__any-files-here-to-add">any files here to add</div>
|
<div class="document-list__any-files-here-to-add">any files here to add</div>
|
||||||
<img [src]="baseComponentPath + '/../assets/images/empty_doc_lib.svg'" class="document-list__empty_doc_lib">
|
<img [src]="baseComponentPath + '/assets/images/empty_doc_lib.svg'" class="document-list__empty_doc_lib">
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</no-content-template>
|
</no-content-template>
|
||||||
|
@ -41,7 +41,7 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
|
|||||||
baseComponentPath = module.id.replace('/components/document-list.js', '');
|
baseComponentPath = module.id.replace('/components/document-list.js', '');
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
fallbackThubnail: string = this.baseComponentPath + '/../assets/images/ft_ic_miscellaneous.svg';
|
fallbackThubnail: string = this.baseComponentPath + '/assets/images/ft_ic_miscellaneous.svg';
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
navigate: boolean = true;
|
navigate: boolean = true;
|
||||||
@ -120,7 +120,7 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
|
|||||||
private ngZone: NgZone,
|
private ngZone: NgZone,
|
||||||
private translateService: AlfrescoTranslateService) {
|
private translateService: AlfrescoTranslateService) {
|
||||||
|
|
||||||
this.data = new ShareDataTableAdapter(this.documentListService, './..', []);
|
this.data = new ShareDataTableAdapter(this.documentListService, './', []);
|
||||||
|
|
||||||
if (translateService) {
|
if (translateService) {
|
||||||
translateService.addTranslationFolder('ng2-alfresco-documentlist', 'node_modules/ng2-alfresco-documentlist/src');
|
translateService.addTranslationFolder('ng2-alfresco-documentlist', 'node_modules/ng2-alfresco-documentlist/src');
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { NgModule, Component } from '@angular/core';
|
import { NgModule, Component, OnInit } from '@angular/core';
|
||||||
import { BrowserModule } from '@angular/platform-browser';
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||||
|
|
||||||
@ -32,14 +32,14 @@ import { LoginModule } from 'ng2-alfresco-login';
|
|||||||
|
|
||||||
<p style="width:120px;margin: 20px;">
|
<p style="width:120px;margin: 20px;">
|
||||||
<label for="switch1" class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
<label for="switch1" class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
||||||
<input type="checkbox" id="switch1" class="mdl-switch__input" checked
|
<input type="checkbox" id="switch1" class="mdl-switch__input" [checked]="isECM"
|
||||||
(click)="toggleECM(ecm.checked)" #ecm>
|
(click)="toggleECM(ecm.checked)" #ecm>
|
||||||
<span class="mdl-switch__label">ECM</span>
|
<span class="mdl-switch__label">ECM</span>
|
||||||
</label>
|
</label>
|
||||||
</p>
|
</p>
|
||||||
<p style="width:120px;margin: 20px;">
|
<p style="width:120px;margin: 20px;">
|
||||||
<label for="switch2" class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
<label for="switch2" class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
||||||
<input type="checkbox" id="switch2" class="mdl-switch__input"
|
<input type="checkbox" id="switch2" class="mdl-switch__input" [checked]="isBPM"
|
||||||
(click)="toggleBPM(bpm.checked)" #bpm>
|
(click)="toggleBPM(bpm.checked)" #bpm>
|
||||||
<span class="mdl-switch__label">BPM</span>
|
<span class="mdl-switch__label">BPM</span>
|
||||||
</label>
|
</label>
|
||||||
@ -59,14 +59,16 @@ import { LoginModule } from 'ng2-alfresco-login';
|
|||||||
(onSuccess)="mySuccessMethod($event)"
|
(onSuccess)="mySuccessMethod($event)"
|
||||||
(onError)="myErrorMethod($event)"></alfresco-login>`
|
(onError)="myErrorMethod($event)"></alfresco-login>`
|
||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent implements OnInit {
|
||||||
|
|
||||||
ecmHost: string = 'http://localhost:8080';
|
ecmHost: string = 'http://localhost:8080';
|
||||||
bpmHost: string = 'http://localhost:9999';
|
bpmHost: string = 'http://localhost:9999';
|
||||||
ticket: string;
|
ticket: string;
|
||||||
status: string = '';
|
status: string = '';
|
||||||
providers: string = 'ECM';
|
providers: string = 'ALL';
|
||||||
disableCsrf: boolean = false;
|
disableCsrf: boolean = false;
|
||||||
|
isECM: boolean = true;
|
||||||
|
isBPM: boolean = false;
|
||||||
|
|
||||||
constructor(private authService: AuthService,
|
constructor(private authService: AuthService,
|
||||||
private settingsService: SettingsService,
|
private settingsService: SettingsService,
|
||||||
@ -77,6 +79,11 @@ export class AppComponent {
|
|||||||
settingsService.bpmHost = this.bpmHost;
|
settingsService.bpmHost = this.bpmHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.settingsService.setProviders(this.providers);
|
||||||
|
this.initProviders();
|
||||||
|
}
|
||||||
|
|
||||||
updateEcmHost(): void {
|
updateEcmHost(): void {
|
||||||
this.settingsService.ecmHost = this.ecmHost;
|
this.settingsService.ecmHost = this.ecmHost;
|
||||||
}
|
}
|
||||||
@ -95,26 +102,49 @@ export class AppComponent {
|
|||||||
this.status = $event.value;
|
this.status = $event.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleECM(checked) {
|
initProviders() {
|
||||||
if (checked && this.providers === 'BPM') {
|
if (this.providers === 'BPM') {
|
||||||
this.providers = 'ALL';
|
this.isECM = false;
|
||||||
} else if (checked) {
|
this.isBPM = true;
|
||||||
this.providers = 'ECM';
|
} else if (this.providers === 'ECM') {
|
||||||
} else if (!checked && this.providers === 'ALL') {
|
this.isECM = true;
|
||||||
this.providers = 'BPM';
|
this.isBPM = false;
|
||||||
|
} else if (this.providers === 'ALL') {
|
||||||
|
this.isECM = true;
|
||||||
|
this.isBPM = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleBPM(checked) {
|
toggleECM() {
|
||||||
if (checked && this.providers === 'ECM') {
|
this.isECM = !this.isECM;
|
||||||
this.providers = 'ALL';
|
this.settingsService.setProviders(this.updateProvider());
|
||||||
} else if (checked) {
|
|
||||||
this.providers = 'BPM';
|
|
||||||
} else if (!checked && this.providers === 'ALL') {
|
|
||||||
this.providers = 'ECM';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleBPM() {
|
||||||
|
this.isBPM = !this.isBPM;
|
||||||
|
this.settingsService.setProviders(this.updateProvider());
|
||||||
|
}
|
||||||
|
|
||||||
|
updateProvider() {
|
||||||
|
if (this.isBPM && this.isECM) {
|
||||||
|
this.providers = 'ALL';
|
||||||
|
return this.providers;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isECM) {
|
||||||
|
this.providers = 'ECM';
|
||||||
|
return this.providers;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isBPM) {
|
||||||
|
this.providers = 'BPM';
|
||||||
|
return this.providers;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.providers = '';
|
||||||
|
return this.providers;
|
||||||
|
};
|
||||||
|
|
||||||
toggleCSRF() {
|
toggleCSRF() {
|
||||||
this.disableCsrf = !this.disableCsrf;
|
this.disableCsrf = !this.disableCsrf;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
<div class="login-card-wide mdl-card mdl-shadow--4dp">
|
<div class="login-card-wide mdl-card mdl-shadow--4dp">
|
||||||
<form [formGroup]="form" (submit)="onSubmit(form.value, $event)">
|
<form [formGroup]="form" (submit)="onSubmit(form.value, $event)">
|
||||||
<div class="mdl-card__title alfresco-logo">
|
<div class="mdl-card__title alfresco-logo">
|
||||||
<img class="center" [src]="logoImageUrl || baseComponentPath + '/../assets/images/alfresco-logo.svg'" alt="{{'LOGIN.LOGO' | translate }}">
|
<img class="center" [src]="logoImageUrl || baseComponentPath + '/../assets/images/alfresco-logo.svg'"
|
||||||
|
alt="{{'LOGIN.LOGO' | translate }}">
|
||||||
</div>
|
</div>
|
||||||
<div class="mdl-card__supporting-text">
|
<div class="mdl-card__supporting-text">
|
||||||
<div>
|
<div>
|
||||||
|
@ -127,6 +127,7 @@ export class AlfrescoLoginComponent implements OnInit {
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
onValueChanged(data: any) {
|
onValueChanged(data: any) {
|
||||||
|
this.success = false;
|
||||||
this.disableError();
|
this.disableError();
|
||||||
for (let field in this.formError) {
|
for (let field in this.formError) {
|
||||||
if (field) {
|
if (field) {
|
||||||
|
@ -33,15 +33,15 @@ import { LoginModule } from 'ng2-alfresco-login';
|
|||||||
|
|
||||||
<p style="width:120px;margin: 20px;">
|
<p style="width:120px;margin: 20px;">
|
||||||
<label for="switch1" class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
<label for="switch1" class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
||||||
<input type="checkbox" id="switch1" class="mdl-switch__input" checked
|
<input type="checkbox" id="switch1" class="mdl-switch__input" [checked]="isECM"
|
||||||
(click)="toggleECM(ecm.checked)" #ecm>
|
(click)="toggleECM()" #ecm>
|
||||||
<span class="mdl-switch__label">ECM</span>
|
<span class="mdl-switch__label">ECM</span>
|
||||||
</label>
|
</label>
|
||||||
</p>
|
</p>
|
||||||
<p style="width:120px;margin: 20px;">
|
<p style="width:120px;margin: 20px;">
|
||||||
<label for="switch2" class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
<label for="switch2" class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
||||||
<input type="checkbox" id="switch2" class="mdl-switch__input"
|
<input type="checkbox" id="switch2" class="mdl-switch__input" [checked]="isBPM"
|
||||||
(click)="toggleBPM(bpm.checked)" #bpm>
|
(click)="toggleBPM()" #bpm>
|
||||||
<span class="mdl-switch__label">BPM</span>
|
<span class="mdl-switch__label">BPM</span>
|
||||||
</label>
|
</label>
|
||||||
</p>
|
</p>
|
||||||
@ -78,12 +78,14 @@ class UserInfoDemo implements OnInit {
|
|||||||
userToLogin: string = 'admin';
|
userToLogin: string = 'admin';
|
||||||
password: string = 'admin';
|
password: string = 'admin';
|
||||||
loginErrorMessage: string;
|
loginErrorMessage: string;
|
||||||
providers: string = 'BPM';
|
providers: string = 'ALL';
|
||||||
|
|
||||||
private authenticated: boolean;
|
private authenticated: boolean;
|
||||||
private token: any;
|
private token: any;
|
||||||
|
|
||||||
disableCsrf: boolean = false;
|
disableCsrf: boolean = false;
|
||||||
|
isECM: boolean = true;
|
||||||
|
isBPM: boolean = false;
|
||||||
|
|
||||||
constructor(private authService: AuthService,
|
constructor(private authService: AuthService,
|
||||||
private settingsService: SettingsService,
|
private settingsService: SettingsService,
|
||||||
@ -94,6 +96,7 @@ class UserInfoDemo implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.settingsService.setProviders(this.providers);
|
this.settingsService.setProviders(this.providers);
|
||||||
|
this.initProviders();
|
||||||
}
|
}
|
||||||
|
|
||||||
logout() {
|
logout() {
|
||||||
@ -115,33 +118,60 @@ class UserInfoDemo implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
isLoggedIn(): boolean {
|
initProviders() {
|
||||||
return this.authService.isLoggedIn();
|
if (this.providers === 'BPM') {
|
||||||
|
this.isECM = false;
|
||||||
|
this.isBPM = true;
|
||||||
|
} else if (this.providers === 'ECM') {
|
||||||
|
this.isECM = true;
|
||||||
|
this.isBPM = false;
|
||||||
|
} else if (this.providers === 'ALL') {
|
||||||
|
this.isECM = true;
|
||||||
|
this.isBPM = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleECM(checked) {
|
toggleECM() {
|
||||||
if (checked && this.providers === 'BPM') {
|
this.isECM = !this.isECM;
|
||||||
|
this.settingsService.setProviders(this.updateProvider());
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleBPM() {
|
||||||
|
this.isBPM = !this.isBPM;
|
||||||
|
this.settingsService.setProviders(this.updateProvider());
|
||||||
|
}
|
||||||
|
|
||||||
|
updateProvider() {
|
||||||
|
if (this.isBPM && this.isECM) {
|
||||||
this.providers = 'ALL';
|
this.providers = 'ALL';
|
||||||
} else if (checked) {
|
return this.providers;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isECM) {
|
||||||
this.providers = 'ECM';
|
this.providers = 'ECM';
|
||||||
} else {
|
return this.providers;
|
||||||
this.providers = undefined;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
toggleBPM(checked) {
|
if (this.isBPM) {
|
||||||
if (checked && this.providers === 'ECM') {
|
|
||||||
this.providers = 'ALL';
|
|
||||||
} else if (checked) {
|
|
||||||
this.providers = 'BPM';
|
this.providers = 'BPM';
|
||||||
} else {
|
return this.providers;
|
||||||
this.providers = undefined;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
this.providers = '';
|
||||||
|
return this.providers;
|
||||||
|
};
|
||||||
|
|
||||||
toggleCSRF() {
|
toggleCSRF() {
|
||||||
this.disableCsrf = !this.disableCsrf;
|
this.disableCsrf = !this.disableCsrf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateEcmHost(): void {
|
||||||
|
this.settingsService.ecmHost = this.ecmHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateBpmHost(): void {
|
||||||
|
this.settingsService.bpmHost = this.bpmHost;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<div class="demo-card-wide mdl-card">
|
<div class="demo-card-wide mdl-card">
|
||||||
<div class="card-title__option mdl-card__title"
|
<div class="card-title__option mdl-card__title"
|
||||||
id="ecm-background-image"
|
id="ecm-background-image"
|
||||||
[style.background-image]="'url(' + ( ecmBackgroundImage || baseComponentPath + '/../assets/images/ecm-background.png')+')'">
|
[style.background-image]="'url(' + ( ecmBackgroundImage || baseComponentPath + '/assets/images/ecm-background.png')+')'">
|
||||||
<img class="profile-picture"
|
<img class="profile-picture"
|
||||||
id="ecm-user-detail-image"
|
id="ecm-user-detail-image"
|
||||||
alt="ecm-profile-image"
|
alt="ecm-profile-image"
|
||||||
@ -52,7 +52,7 @@
|
|||||||
<div class="demo-card-wide mdl-card">
|
<div class="demo-card-wide mdl-card">
|
||||||
<div class="card-title__option mdl-card__title"
|
<div class="card-title__option mdl-card__title"
|
||||||
id="bpm-background-image"
|
id="bpm-background-image"
|
||||||
[style.background-image]="'url(' + (bpmBackgroundImage || baseComponentPath + '/../assets/images/bpm-background.png')+')'">
|
[style.background-image]="'url(' + (bpmBackgroundImage || baseComponentPath + '/assets/images/bpm-background.png')+')'">
|
||||||
<img class="profile-picture"
|
<img class="profile-picture"
|
||||||
id="bpm-user-detail-image"
|
id="bpm-user-detail-image"
|
||||||
alt="bpm-profile-image"
|
alt="bpm-profile-image"
|
||||||
|
@ -50,7 +50,7 @@ export class UserInfoComponent implements OnInit {
|
|||||||
|
|
||||||
bpmUser: BpmUserModel;
|
bpmUser: BpmUserModel;
|
||||||
|
|
||||||
anonymousImageUrl: string = this.baseComponentPath + '/../assets/images/anonymous.gif';
|
anonymousImageUrl: string = this.baseComponentPath + '/assets/images/anonymous.gif';
|
||||||
|
|
||||||
bpmUserImage: any;
|
bpmUserImage: any;
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ import { BpmUserModel } from '../models/bpm-user.model';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class BpmUserService {
|
export class BpmUserService {
|
||||||
|
|
||||||
constructor(private alfrescoJsApi: AlfrescoApiService,
|
constructor(private apiService: AlfrescoApiService,
|
||||||
private logService: LogService) {
|
private logService: LogService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,13 +38,13 @@ export class BpmUserService {
|
|||||||
* @param userName - the user name
|
* @param userName - the user name
|
||||||
*/
|
*/
|
||||||
getCurrentUserInfo(): Observable<BpmUserModel> {
|
getCurrentUserInfo(): Observable<BpmUserModel> {
|
||||||
return Observable.fromPromise(this.alfrescoJsApi.getInstance().activiti.profileApi.getProfile())
|
return Observable.fromPromise(this.apiService.getInstance().activiti.profileApi.getProfile())
|
||||||
.map((data) => <BpmUserModel> data)
|
.map((data) => <BpmUserModel> data)
|
||||||
.catch(err => this.handleError(err));
|
.catch(err => this.handleError(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
getCurrentUserProfileImage(): string {
|
getCurrentUserProfileImage(): string {
|
||||||
return this.alfrescoJsApi.getInstance().activiti.profileApi.getProfilePictureUrl();
|
return this.apiService.getInstance().activiti.profileApi.getProfilePictureUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user