+ Authentication failed to ip {{ ecmHost }} with user: admin, admin
+
+
+ Authentication successfull to ip {{ ecmHost }} with user: admin, admin, your token is {{ token }}
+
`
+})
+class MyDemoApp {
+ authenticated: boolean = false;
+
+ ecmHost: string = 'http://127.0.0.1:8080';
+
+ token: string;
+
+ constructor(public alfrescoAuthenticationService: AlfrescoAuthenticationService,
+ private alfrescoSettingsService: AlfrescoSettingsService) {
+
+ alfrescoSettingsService.ecmHost = this.ecmHost;
+ alfrescoSettingsService.setProviders('ECM');
+ }
+
+ ngOnInit() {
+ this.login();
+ }
+
+ login() {
+ this.alfrescoAuthenticationService.login('admin', 'admin').subscribe(
+ token => {
+ this.token = token.ticket;
+ this.authenticated = true;
+ },
+ error => {
+ console.log(error);
+ this.authenticated = false;
+ });
+ }
+}
+bootstrap(MyDemoApp, [
+ HTTP_PROVIDERS,
+ ALFRESCO_CORE_PROVIDERS
+]);
+
+```
+
+
## Build from sources
Alternatively you can build component from sources with the following commands:
diff --git a/ng2-components/ng2-alfresco-core/karma.conf.js b/ng2-components/ng2-alfresco-core/karma.conf.js
index e2485314bf..92702df655 100644
--- a/ng2-components/ng2-alfresco-core/karma.conf.js
+++ b/ng2-components/ng2-alfresco-core/karma.conf.js
@@ -4,7 +4,7 @@ module.exports = function (config) {
var configuration = {
basePath: '.',
- frameworks: ['jasmine'],
+ frameworks: ['jasmine-ajax', 'jasmine'],
files: [
// paths loaded by Karma
@@ -64,6 +64,7 @@ module.exports = function (config) {
plugins: [
'karma-jasmine',
'karma-coverage',
+ 'karma-jasmine-ajax',
'karma-chrome-launcher',
'karma-mocha-reporter',
'karma-jasmine-html-reporter'
diff --git a/ng2-components/ng2-alfresco-core/package.json b/ng2-components/ng2-alfresco-core/package.json
index 7d067d44e8..13b6aafb1c 100644
--- a/ng2-components/ng2-alfresco-core/package.json
+++ b/ng2-components/ng2-alfresco-core/package.json
@@ -55,7 +55,7 @@
"alfresco"
],
"dependencies": {
- "alfresco-js-api": "^0.2.0",
+ "alfresco-js-api": "^0.3.0",
"@angular/common": "2.0.0-rc.3",
"@angular/compiler": "2.0.0-rc.3",
"@angular/core": "2.0.0-rc.3",
@@ -87,6 +87,7 @@
"karma-coverage": "1.0.0",
"karma-coveralls": "1.1.2",
"karma-jasmine": "1.0.2",
+ "karma-jasmine-ajax": "^0.1.13",
"karma-jasmine-html-reporter": "0.2.0",
"karma-mocha-reporter": "2.0.3",
"license-check": "1.1.5",
diff --git a/ng2-components/ng2-alfresco-core/src/factory/AuthenticationFactory.ts b/ng2-components/ng2-alfresco-core/src/factory/AuthenticationFactory.ts
deleted file mode 100644
index 6034a7e750..0000000000
--- a/ng2-components/ng2-alfresco-core/src/factory/AuthenticationFactory.ts
+++ /dev/null
@@ -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 { AbstractAuthentication } from '../interface/authentication.interface';
-import { AlfrescoAuthenticationBPM } from '../services/AlfrescoAuthenticationBPM.service';
-import { AlfrescoAuthenticationECM } from '../services/AlfrescoAuthenticationECM.service';
-import { Http } from '@angular/http';
-import { AlfrescoSettingsService } from '../services/AlfrescoSettingsService.service';
-
-
-export class AuthenticationFactory {
-
- public static createAuth(alfrescoSettingsService: AlfrescoSettingsService,
- http: Http,
- type: string): AbstractAuthentication {
- if (type === 'ECM') {
- return new AlfrescoAuthenticationECM(alfrescoSettingsService, http);
- } else if (type === 'BPM') {
- return new AlfrescoAuthenticationBPM(alfrescoSettingsService, http);
- }
- return null;
- }
-}
diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.spec.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.spec.ts
new file mode 100644
index 0000000000..34e9ccf2f6
--- /dev/null
+++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.spec.ts
@@ -0,0 +1,327 @@
+/*!
+ * @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 {it, describe, beforeEach, afterEach} from '@angular/core/testing';
+import {ReflectiveInjector, provide} from '@angular/core';
+import {AlfrescoSettingsService} from './AlfrescoSettings.service';
+import {AlfrescoAuthenticationService} from './AlfrescoAuthentication.service';
+
+declare var AlfrescoApi: any;
+declare let jasmine: any;
+
+describe('AlfrescoAuthentication', () => {
+ let injector, authService;
+
+ beforeEach(() => {
+ injector = ReflectiveInjector.resolveAndCreate([
+ provide(AlfrescoSettingsService, {useClass: AlfrescoSettingsService}),
+ AlfrescoAuthenticationService
+ ]);
+
+ let store = {};
+
+ spyOn(localStorage, 'getItem').and.callFake(function (key) {
+ return store[key];
+ });
+ spyOn(localStorage, 'setItem').and.callFake(function (key, value) {
+ return store[key] = value + '';
+ });
+ spyOn(localStorage, 'clear').and.callFake(function () {
+ store = {};
+ });
+ spyOn(localStorage, 'removeItem').and.callFake(function (key) {
+ delete store[key];
+ });
+ spyOn(localStorage, 'key').and.callFake(function (i) {
+ let keys = Object.keys(store);
+ return keys[i] || null;
+ });
+
+ jasmine.Ajax.install();
+ });
+
+ afterEach(() => {
+ jasmine.Ajax.uninstall();
+ });
+
+ describe('when the setting is ECM', () => {
+
+ beforeEach(() => {
+ authService = injector.get(AlfrescoAuthenticationService);
+ authService.alfrescoSetting.setProviders('ECM');
+ });
+
+ it('should return an ECM ticket after the login done', (done) => {
+ authService.login('fake-username', 'fake-password').subscribe(() => {
+ expect(authService.isLoggedIn()).toBe(true);
+ expect(authService.getTicketEcm()).toEqual('fake-post-ticket');
+ done();
+ });
+
+ jasmine.Ajax.requests.mostRecent().respondWith({
+ 'status': 201,
+ contentType: 'application/json',
+ responseText: JSON.stringify({'entry': {'id': 'fake-post-ticket', 'userId': 'admin'}})
+ });
+ });
+
+ it('should return ticket undefined when the credentials are wrong', (done) => {
+ authService.login('fake-wrong-username', 'fake-wrong-password').subscribe(
+ (res) => {
+ },
+ (err: any) => {
+ expect(authService.isLoggedIn()).toBe(false);
+ expect(authService.getTicketEcm()).toBe(null);
+ done();
+ });
+
+ jasmine.Ajax.requests.mostRecent().respondWith({
+ 'status': 403,
+ contentType: 'application/json',
+ responseText: JSON.stringify({
+ 'error': {
+ 'errorKey': 'Login failed',
+ 'statusCode': 403,
+ 'briefSummary': '05150009 Login failed',
+ 'stackTrace': 'For security reasons the stack trace is no longer displayed, but the property is kept for previous versions.',
+ 'descriptionURL': 'https://api-explorer.alfresco.com'
+ }
+ })
+ });
+ });
+
+ it('should login in the ECM if no provider are defined calling the login', (done) => {
+ authService.login('fake-username', 'fake-password').subscribe(() => {
+ done();
+ });
+
+ jasmine.Ajax.requests.mostRecent().respondWith({
+ 'status': 201,
+ contentType: 'application/json',
+ responseText: JSON.stringify({'entry': {'id': 'fake-post-ticket', 'userId': 'admin'}})
+ });
+ });
+
+ it('should return a ticket undefined after logout', (done) => {
+ authService.login('fake-username', 'fake-password').subscribe(() => {
+ authService.logout().subscribe(() => {
+ expect(authService.isLoggedIn()).toBe(false);
+ expect(authService.getTicketEcm()).toBe(null);
+ done();
+ });
+
+ jasmine.Ajax.requests.mostRecent().respondWith({
+ 'status': 204
+ });
+ });
+
+ jasmine.Ajax.requests.mostRecent().respondWith({
+ 'status': 201,
+ contentType: 'application/json',
+ responseText: JSON.stringify({'entry': {'id': 'fake-post-ticket', 'userId': 'admin'}})
+ });
+ });
+
+ it('should return false if the user is not logged in', () => {
+ expect(authService.isLoggedIn()).toBe(false);
+ });
+ });
+
+ describe('when the setting is BPM', () => {
+
+ beforeEach(() => {
+ authService = injector.get(AlfrescoAuthenticationService);
+ authService.alfrescoSetting.setProviders('BPM');
+ });
+
+ it('should return an BPM ticket after the login done', (done) => {
+ authService.login('fake-username', 'fake-password').subscribe(() => {
+ expect(authService.isLoggedIn()).toBe(true);
+ expect(authService.getTicketBpm()).toEqual('Basic ZmFrZS11c2VybmFtZTpmYWtlLXBhc3N3b3Jk');
+ done();
+ });
+
+ jasmine.Ajax.requests.mostRecent().respondWith({
+ 'status': 200
+ });
+ });
+
+ it('should return ticket undefined when the credentials are wrong', (done) => {
+ authService.login('fake-wrong-username', 'fake-wrong-password').subscribe(
+ (res) => {
+ },
+ (err: any) => {
+ expect(authService.isLoggedIn()).toBe(false);
+ expect(authService.getTicketBpm()).toBe(null);
+ done();
+ });
+
+ jasmine.Ajax.requests.mostRecent().respondWith({
+ 'status': 403
+ });
+ });
+
+ it('should return a ticket undefined after logout', (done) => {
+ authService.login('fake-username', 'fake-password').subscribe(() => {
+ authService.logout().subscribe(() => {
+ expect(authService.isLoggedIn()).toBe(false);
+ expect(authService.getTicketBpm()).toBe(null);
+ done();
+ });
+
+ jasmine.Ajax.requests.mostRecent().respondWith({
+ 'status': 200
+ });
+ });
+
+ jasmine.Ajax.requests.mostRecent().respondWith({
+ 'status': 200
+ });
+ });
+
+ it('should return an error when the logout return error', (done) => {
+ authService.logout().subscribe(
+ (res) => {
+ },
+ (err: any) => {
+ expect(err).toBeDefined();
+ expect(authService.getTicketBpm()).toBe(null);
+ done();
+ });
+
+ jasmine.Ajax.requests.mostRecent().respondWith({
+ 'status': 403
+ });
+ });
+ });
+
+ describe('Setting service change should reflect in the api', () => {
+
+ beforeEach(() => {
+ authService = injector.get(AlfrescoAuthenticationService);
+ authService.alfrescoSetting.setProviders('ALL');
+ });
+
+ it('should host ecm url change be reflected in the api configuration', () => {
+ authService.alfrescoSetting.ecmHost = '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', () => {
+ authService.alfrescoSetting.bpmHost = '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', () => {
+ authService.alfrescoSetting.setProviders('ECM');
+
+ expect(authService.getAlfrescoApi().config.provider).toBe('ECM');
+ });
+
+ });
+
+ describe('when the setting is both ECM and BPM ', () => {
+
+ beforeEach(() => {
+ authService = injector.get(AlfrescoAuthenticationService);
+ authService.providers = 'ALL';
+ });
+
+ it('should return both ECM and BPM tickets after the login done', (done) => {
+ authService.login('fake-username', 'fake-password').subscribe(() => {
+ expect(authService.isLoggedIn()).toBe(true);
+ expect(authService.getTicketEcm()).toEqual('fake-post-ticket');
+ expect(authService.getTicketBpm()).toEqual('Basic ZmFrZS11c2VybmFtZTpmYWtlLXBhc3N3b3Jk');
+ done();
+ });
+
+ jasmine.Ajax.requests.at(0).respondWith({
+ 'status': 201,
+ contentType: 'application/json',
+ responseText: JSON.stringify({'entry': {'id': 'fake-post-ticket', 'userId': 'admin'}})
+ });
+
+ jasmine.Ajax.requests.at(1).respondWith({
+ 'status': 200
+ });
+ });
+
+ it('should return login fail if only ECM call fail', (done) => {
+ authService.login('fake-username', 'fake-password').subscribe(
+ (res) => {
+ },
+ (err: any) => {
+ expect(authService.isLoggedIn()).toBe(false);
+ expect(authService.getTicketEcm()).toBe(null);
+ expect(authService.getTicketBpm()).toBe(null);
+ done();
+ });
+
+ jasmine.Ajax.requests.at(0).respondWith({
+ 'status': 403
+ });
+
+ jasmine.Ajax.requests.at(1).respondWith({
+ 'status': 200
+ });
+ });
+
+ it('should return login fail if only BPM call fail', (done) => {
+ authService.login('fake-username', 'fake-password').subscribe(
+ (res) => {
+ },
+ (err: any) => {
+ expect(authService.isLoggedIn()).toBe(false);
+ expect(authService.getTicketEcm()).toBe(null);
+ expect(authService.getTicketBpm()).toBe(null);
+ done();
+ });
+
+ jasmine.Ajax.requests.at(0).respondWith({
+ 'status': 201,
+ contentType: 'application/json',
+ responseText: JSON.stringify({'entry': {'id': 'fake-post-ticket', 'userId': 'admin'}})
+ });
+
+ jasmine.Ajax.requests.at(1).respondWith({
+ 'status': 403
+ });
+ });
+
+ it('should return ticket undefined when the credentials are wrong', (done) => {
+ authService.login('fake-username', 'fake-password').subscribe(
+ (res) => {
+ },
+ (err: any) => {
+ expect(authService.isLoggedIn()).toBe(false);
+ expect(authService.getTicketEcm()).toBe(null);
+ expect(authService.getTicketBpm()).toBe(null);
+ done();
+ });
+
+ jasmine.Ajax.requests.at(0).respondWith({
+ 'status': 403
+ });
+
+ jasmine.Ajax.requests.at(1).respondWith({
+ 'status': 403
+ });
+ });
+ });
+});
diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.ts
new file mode 100644
index 0000000000..ba92bff800
--- /dev/null
+++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthentication.service.ts
@@ -0,0 +1,195 @@
+/*!
+ * @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 {AlfrescoSettingsService} from './AlfrescoSettings.service';
+
+declare let AlfrescoApi: any;
+
+/**
+ * The AlfrescoAuthenticationService provide the login service and store the ticket in the localStorage
+ */
+@Injectable()
+export class AlfrescoAuthenticationService {
+
+ alfrescoApi: any;
+
+ /**A
+ * Constructor
+ * @param alfrescoSetting
+ */
+ constructor(public alfrescoSetting: AlfrescoSettingsService) {
+ this.alfrescoApi = new AlfrescoApi({
+ provider: this.alfrescoSetting.getProviders(),
+ ticketEcm: this.getTicketEcm(),
+ ticketBpm: this.getTicketBpm(),
+ hostEcm: this.alfrescoSetting.ecmHost,
+ hostBpm: this.alfrescoSetting.bpmHost
+ });
+
+ alfrescoSetting.bpmHostSubject.subscribe((bpmHost) => {
+ this.alfrescoApi.changeBpmHost(bpmHost);
+ });
+
+ alfrescoSetting.ecmHostSubject.subscribe((ecmHost) => {
+ this.alfrescoApi.changeEcmHost(ecmHost);
+ });
+
+ alfrescoSetting.providerSubject.subscribe((value) => {
+ this.alfrescoApi.config.provider = value;
+ });
+ }
+
+ /**
+ * 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|Observable}
+ */
+ login(username: string, password: string) {
+ return Observable.fromPromise(this.callApiLogin(username, password))
+ .map((response: any) => {
+ this.saveTickets();
+ return {type: this.alfrescoSetting.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}
+ */
+ private callApiLogin(username: string, password: string) {
+ return this.alfrescoApi.login(username, password);
+ }
+
+ /**
+ * The method remove the ticket from the local storage
+ *
+ * @returns {Observable|Observable}
+ */
+ public logout() {
+ return Observable.fromPromise(this.callApiLogout())
+ .map(res => res)
+ .do(response => {
+ this.removeTicket();
+ return response;
+ })
+ .catch(this.handleError);
+ }
+
+ /**
+ *
+ * @returns {*|Observable|Observable|Promise}
+ */
+ private callApiLogout(): Promise {
+ if (this.alfrescoApi) {
+ return this.alfrescoApi.logout();
+ }
+ }
+
+ /**
+ * Remove the login ticket from localStorage
+ */
+ public removeTicket(): void {
+ localStorage.removeItem('ticket-ECM');
+ localStorage.removeItem('ticket-BPM');
+ }
+
+ /**
+ * The method return the ECM ticket stored in the localStorage
+ * @returns ticket
+ */
+ public getTicketEcm(): string {
+ if (localStorage.getItem('ticket-ECM')) {
+ return localStorage.getItem('ticket-ECM');
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * The method return the BPM ticket stored in the localStorage
+ * @returns ticket
+ */
+ public getTicketBpm(): string {
+ if (localStorage.getItem('ticket-BPM')) {
+ return localStorage.getItem('ticket-BPM');
+ } else {
+ return null;
+ }
+ }
+
+ public getTicketEcmBase64(): string {
+ if (localStorage.getItem('ticket-ECM')) {
+ return 'Basic ' + btoa(localStorage.getItem('ticket-ECM'));
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * The method save the ECM and BPM ticket in the localStorage
+ */
+ public saveTickets() {
+ this.saveTicketEcm();
+ this.saveTicketBpm();
+ }
+
+ /**
+ * The method save the ECM ticket in the localStorage
+ */
+ public saveTicketEcm(): void {
+ if (this.alfrescoApi) {
+ localStorage.setItem('ticket-ECM', this.alfrescoApi.getTicketEcm());
+ }
+ }
+
+ /**
+ * The method save the BPM ticket in the localStorage
+ */
+ public saveTicketBpm(): void {
+ if (this.alfrescoApi) {
+ localStorage.setItem('ticket-BPM', this.alfrescoApi.getTicketBpm());
+ }
+ }
+
+ /**
+ * The method write the error in the console browser
+ * @param error
+ * @returns {ErrorObservable}
+ */
+ public handleError(error: any): Observable {
+ console.error('Error when logging in', error);
+ return Observable.throw(error || 'Server error');
+ }
+
+ getAlfrescoApi(): any {
+ return this.alfrescoApi;
+ }
+}
diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationBPM.service.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationBPM.service.ts
deleted file mode 100644
index 31d3013637..0000000000
--- a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationBPM.service.ts
+++ /dev/null
@@ -1,116 +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 { AbstractAuthentication } from '../interface/authentication.interface';
-import { Http, Headers, RequestOptions } from '@angular/http';
-import { Observable } from 'rxjs/Rx';
-import { AlfrescoAuthenticationBase } from './AlfrescoAuthenticationBase.service';
-import { AlfrescoSettingsService } from './AlfrescoSettingsService.service';
-
-export class AlfrescoAuthenticationBPM extends AlfrescoAuthenticationBase implements AbstractAuthentication {
-
- TYPE: string = 'BPM';
-
- constructor(alfrescoSetting: AlfrescoSettingsService,
- http: Http) {
- super(alfrescoSetting, http);
- }
-
- getHost(): string {
- return this.alfrescoSetting.bpmHost;
- }
-
- /**
- * Perform a login on behalf of the user and store the ticket returned
- *
- * @param username
- * @param password
- * @returns {Observable|Observable}
- */
- login(username: string, password: string): Observable {
- return Observable.fromPromise(this.apiActivitiLogin(username, password))
- .map((response: any) => {
- return {
- type: this.TYPE,
- ticket: 'Basic ' + btoa(`${username}:${password}`)
- };
- })
- .catch(this.handleError);
- }
-
- /**
- * Delete the current login ticket from the server
- *
- * @returns {Observable|Observable}
- */
- logout() {
- return Observable.fromPromise(this.apiActivitiLogout())
- .map(res => res)
- .do(response => {
- this.removeTicket(this.TYPE);
- })
- .catch(this.handleError);
- }
-
- /**
- * The method return true if the user is logged in
- * @returns {boolean}
- */
- isLoggedIn(): boolean {
- return !!this.getTicket();
- }
-
- private apiActivitiLogin(username: string, password: string) {
- let url = this.alfrescoSetting.getBPMApiBaseUrl() + '/app/authentication';
- let headers = new Headers({
- 'Content-Type': 'application/x-www-form-urlencoded'
- });
- let options = new RequestOptions({headers: headers});
- let data = 'j_username='
- + encodeURIComponent(username)
- + '&j_password='
- + encodeURIComponent(password)
- + '&_spring_security_remember_me=true&submit=Login';
-
- return this.http
- .post(url, data, options).toPromise();
- }
-
- private apiActivitiLogout() {
- let url = this.alfrescoSetting.getBPMApiBaseUrl() + '/app/logout';
- return this.http.get(url).toPromise();
- }
-
- /**
- * The method return the ticket stored in the localStorage
- * @returns ticket
- */
- public getTicket(): string {
- return localStorage.getItem(`ticket-${this.TYPE}`);
- }
-
- /**
- * The method save the ticket in the localStorage
- * @param ticket
- */
- public saveTicket(ticket: string): void {
- if (ticket) {
- super.saveTicket(this.TYPE, ticket);
- }
- }
-
-}
diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationBase.service.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationBase.service.ts
deleted file mode 100644
index 2aa3ffd7c5..0000000000
--- a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationBase.service.ts
+++ /dev/null
@@ -1,64 +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 { Http, Response } from '@angular/http';
-import { AlfrescoSettingsService } from './AlfrescoSettingsService.service';
-import { Observable } from 'rxjs/Rx';
-
-declare let AlfrescoApi: any;
-
-export class AlfrescoAuthenticationBase {
-
- alfrescoApi: any;
-
-
- /**
- * Constructor
- * @param alfrescoSettingsService
- */
- constructor(public alfrescoSetting: AlfrescoSettingsService,
- public http: Http) {
- }
-
- /**
- * The method save the toke in the localStorage
- * @param ticket
- */
- public saveTicket(provider: string, ticket: string): void {
- if (ticket) {
- localStorage.setItem(`ticket-${provider}`, ticket);
- }
- }
-
- /**
- * Remove the login ticket from localStorage
- */
- public removeTicket(provider: string): void {
- localStorage.removeItem(`ticket-${provider}`);
- }
-
- /**
- * The method write the error in the console browser
- * @param error
- * @returns {ErrorObservable}
- */
- public handleError(error: Response): Observable {
- console.error('Error when logging in', error);
- return Observable.throw(error || 'Server error');
- }
-
-}
diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationECM.service.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationECM.service.ts
deleted file mode 100644
index 39c735eeb9..0000000000
--- a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationECM.service.ts
+++ /dev/null
@@ -1,137 +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 { AbstractAuthentication } from '../interface/authentication.interface';
-import { Observable } from 'rxjs/Rx';
-import { Http } from '@angular/http';
-import { AlfrescoAuthenticationBase } from './AlfrescoAuthenticationBase.service';
-import { AlfrescoSettingsService } from './AlfrescoSettingsService.service';
-
-declare let AlfrescoApi: any;
-
-export class AlfrescoAuthenticationECM extends AlfrescoAuthenticationBase implements AbstractAuthentication {
-
- TYPE: string = 'ECM';
-
- alfrescoApi: any;
-
- /**
- * Constructor
- * @param alfrescoSetting
- * @param http
- */
- constructor(alfrescoSetting: AlfrescoSettingsService,
- http: Http) {
- super(alfrescoSetting, http);
-
- if (!this.isLoggedIn()) {
- this.alfrescoApi = new AlfrescoApi({
- host: this.getHost()
- });
- } else {
- this.alfrescoApi = new AlfrescoApi({
- ticket: this.getTicket(),
- host: this.getHost()
- });
- }
- }
-
- getHost(): string {
- return this.alfrescoSetting.ecmHost;
- }
-
- /**
- * The method return tru if the user is logged in
- * @returns {boolean}
- */
- isLoggedIn(): boolean {
- return !!this.getTicket();
- }
-
- /**
- * Method to delegate to POST login
- * @param username
- * @param password
- * @returns {Observable|Observable}
- */
- login(username: string, password: string) {
-
- return Observable.fromPromise(this.callApiLogin(username, password))
- .map((response: any) => {
- return {type: this.TYPE, ticket: response};
- })
- .catch(this.handleError);
- }
-
- /**
- * Initialize the alfresco Api with user and password end call the login method
- * @param username
- * @param password
- * @returns {*|Observable}
- */
- private callApiLogin(username: string, password: string) {
- this.alfrescoApi = new AlfrescoApi({
- username: username,
- password: password,
- host: this.getHost()
- });
- return this.alfrescoApi.login();
- }
-
- /**
- * The method remove the ticket from the local storage
- *
- * @returns {Observable|Observable}
- */
- public logout() {
- return Observable.fromPromise(this.callApiLogout())
- .map(res => res)
- .do(response => {
- this.removeTicket(this.TYPE);
- return response;
- })
- .catch(this.handleError);
- }
-
- /**
- *
- * @returns {*|Observable|Observable|Promise}
- */
- private callApiLogout(): Promise {
- return this.alfrescoApi.logout();
- }
-
-
- /**
- * The method return the ticket stored in the localStorage
- * @returns ticket
- */
- public getTicket(): string {
- return localStorage.getItem(`ticket-${this.TYPE}`);
- }
-
- /**
- * The method save the ticket in the localStorage
- * @param ticket
- */
- public saveTicket(ticket): void {
- if (ticket) {
- super.saveTicket(this.TYPE, ticket);
- }
- }
-
-}
diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationService.service.spec.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationService.service.spec.ts
deleted file mode 100644
index deadd5ed57..0000000000
--- a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationService.service.spec.ts
+++ /dev/null
@@ -1,460 +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 { it, describe } from '@angular/core/testing';
-import { ReflectiveInjector, provide } from '@angular/core';
-import { AlfrescoSettingsService } from './AlfrescoSettingsService.service';
-import { AlfrescoAuthenticationService } from './AlfrescoAuthenticationService.service';
-import { AlfrescoAuthenticationECM } from './AlfrescoAuthenticationECM.service';
-import { AlfrescoAuthenticationBPM } from './AlfrescoAuthenticationBPM.service';
-import { XHRBackend, HTTP_PROVIDERS } from '@angular/http';
-import { MockBackend } from '@angular/http/testing';
-
-declare var AlfrescoApi: any;
-
-describe('AlfrescoAuthentication', () => {
- let injector,
- fakePromiseECM,
- fakePromiseBPM,
- service;
-
- fakePromiseECM = new Promise(function (resolve, reject) {
- resolve(
- 'fake-post-ticket-ECM'
- );
- reject({
- response: {
- error: 'fake-error'
- }
- });
- });
-
- fakePromiseBPM = new Promise(function (resolve, reject) {
- resolve({
- status: 'fake-post-ticket-BPM'
- });
- reject({
- response: {
- error: 'fake-error'
- }
- });
- });
-
- beforeEach(() => {
- injector = ReflectiveInjector.resolveAndCreate([
- HTTP_PROVIDERS,
- provide(XHRBackend, {useClass: MockBackend}),
- provide(AlfrescoSettingsService, {useClass: AlfrescoSettingsService}),
- AlfrescoAuthenticationService
- ]);
-
- let store = {};
-
- spyOn(localStorage, 'getItem').and.callFake(function (key) {
- return store[key];
- });
- spyOn(localStorage, 'setItem').and.callFake(function (key, value) {
- return store[key] = value + '';
- });
- spyOn(localStorage, 'clear').and.callFake(function () {
- store = {};
- });
- spyOn(localStorage, 'removeItem').and.callFake(function (key) {
- delete store[key];
- });
- spyOn(localStorage, 'key').and.callFake(function (i) {
- let keys = Object.keys(store);
- return keys[i] || null;
- });
-
- // service = injector.get(AlfrescoAuthenticationService);
- });
-
- describe('when the setting is ECM', () => {
-
- it('should create an AlfrescoAuthenticationECM instance', (done) => {
- let providers = ['ECM'];
-
- let alfSetting = injector.get(AlfrescoSettingsService);
- alfSetting.providers = providers;
-
- service = injector.get(AlfrescoAuthenticationService);
- spyOn(AlfrescoAuthenticationECM.prototype, 'callApiLogin').and.returnValue(fakePromiseECM);
-
- service.login('fake-username', 'fake-password', providers)
- .subscribe(() => {
- expect(service.isLoggedIn(providers[0])).toBe(true);
- expect(service.providersInstance).toBeDefined();
- expect(service.providersInstance.length).toBe(1);
- expect(service.providersInstance[0].TYPE).toEqual(providers[0]);
- done();
- }
- );
- });
-
- it('should return an ECM ticket after the login done', (done) => {
- let providers = ['ECM'];
- let alfSetting = injector.get(AlfrescoSettingsService);
- alfSetting.providers = providers;
-
- service = injector.get(AlfrescoAuthenticationService);
- spyOn(AlfrescoAuthenticationECM.prototype, 'callApiLogin').and.returnValue(fakePromiseECM);
-
- service.login('fake-username', 'fake-password', providers)
- .subscribe(() => {
- expect(service.isLoggedIn(providers[0])).toBe(true);
- expect(service.getTicket(providers[0])).toEqual('fake-post-ticket-ECM');
- done();
- }
- );
- });
-
- it('should return ticket undefined when the credentials are wrong', (done) => {
- let providers = ['ECM'];
- let alfSetting = injector.get(AlfrescoSettingsService);
- alfSetting.providers = providers;
-
- service = injector.get(AlfrescoAuthenticationService);
- spyOn(AlfrescoAuthenticationECM.prototype, 'callApiLogin')
- .and.returnValue(Promise.reject('fake invalid credentials'));
-
- service.login('fake-wrong-username', 'fake-wrong-password', providers)
- .subscribe(
- (res) => {
- done();
- },
- (err: any) => {
- expect(service.isLoggedIn(providers[0])).toBe(false);
- expect(service.getTicket(providers[0])).toBeUndefined();
- done();
- }
- );
- });
-
- it('should return an error if no provider are defined calling the login', (done) => {
- let providers = [];
- let alfSetting = injector.get(AlfrescoSettingsService);
- alfSetting.providers = providers;
-
- service = injector.get(AlfrescoAuthenticationService);
- service.login('fake-username', 'fake-password', providers)
- .subscribe(
- (res) => {
- done();
- },
- (err: any) => {
- expect(err).toBeDefined();
- expect(err).toEqual('No providers defined');
- done();
- }
- );
- });
-
- it('should return an error if an empty provider are defined calling the login', (done) => {
- let providers = [''];
- let alfSetting = injector.get(AlfrescoSettingsService);
- alfSetting.providers = providers;
-
- service = injector.get(AlfrescoAuthenticationService);
- service.login('fake-username', 'fake-password', providers)
- .subscribe(
- (res) => {
- done();
- },
- (err: any) => {
- expect(err).toBeDefined();
- expect(err.message).toEqual('Wrong provider defined');
- done();
- }
- );
- });
-
- it('should return a ticket undefined after logout', (done) => {
- let providers = ['ECM'];
- let alfSetting = injector.get(AlfrescoSettingsService);
- alfSetting.providers = providers;
-
- service = injector.get(AlfrescoAuthenticationService);
- localStorage.setItem('ticket-ECM', 'fake-post-ticket-ECM');
- service.createProviderInstance(providers);
- spyOn(AlfrescoAuthenticationECM.prototype, 'callApiLogout').and.returnValue(fakePromiseECM);
-
- service.logout()
- .subscribe(() => {
- expect(service.isLoggedIn(providers[0])).toBe(false);
- expect(service.getTicket(providers[0])).toBeUndefined();
- expect(localStorage.getItem('ticket-ECM')).toBeUndefined();
- done();
- }
- );
- });
-
- it('should logout only for if the provider is loggedin', (done) => {
- let providers = ['BPM', 'ECM'];
- let alfSetting = injector.get(AlfrescoSettingsService);
- alfSetting.providers = providers;
-
- service = injector.get(AlfrescoAuthenticationService);
- localStorage.setItem('ticket-ECM', 'fake-post-ticket-ECM');
- service.createProviderInstance(providers);
- spyOn(AlfrescoAuthenticationECM.prototype, 'callApiLogout').and.returnValue(fakePromiseECM);
- service.performeSaveTicket('ECM', 'fake-ticket-ECM');
- service.logout()
- .subscribe(() => {
- expect(service.isLoggedIn(providers[0])).toBe(false);
- expect(service.getTicket(providers[0])).toBeUndefined();
- expect(localStorage.getItem('ticket-ECM')).toBeUndefined();
- done();
- }
- );
- });
-
-
-
- it('should return an error if no provider are defined calling the logout', (done) => {
- let providers = [];
- let alfSetting = injector.get(AlfrescoSettingsService);
- alfSetting.providers = providers;
-
- service = injector.get(AlfrescoAuthenticationService);
- service.logout()
- .subscribe(
- (res) => {
- done();
- },
- (err: any) => {
- expect(err).toBeDefined();
- expect(err).toEqual('No providers defined');
- done();
- }
- );
- });
-
- it('should return false if the user is not logged in', () => {
- let providers = ['ECM'];
- expect(service.isLoggedIn(providers[0])).toBe(false);
- });
- });
-
- describe('when the setting is BPM', () => {
-
- it('should create an AlfrescoAuthenticationBPM instance', (done) => {
- let providers = ['BPM'];
- let alfSetting = injector.get(AlfrescoSettingsService);
- alfSetting.providers = providers;
-
- service = injector.get(AlfrescoAuthenticationService);
- spyOn(AlfrescoAuthenticationBPM.prototype, 'apiActivitiLogin').and.returnValue(fakePromiseBPM);
-
- service.login('fake-username', 'fake-password', providers)
- .subscribe(() => {
- expect(service.isLoggedIn(providers[0])).toBe(true);
- expect(service.providersInstance).toBeDefined();
- expect(service.providersInstance.length).toBe(1);
- expect(service.providersInstance[0].TYPE).toEqual(providers[0]);
- done();
- }
- );
- });
-
- it('should return an BPM ticket after the login done', (done) => {
- let providers = ['BPM'];
- let alfSetting = injector.get(AlfrescoSettingsService);
- alfSetting.providers = providers;
-
- service = injector.get(AlfrescoAuthenticationService);
- spyOn(AlfrescoAuthenticationBPM.prototype, 'apiActivitiLogin').and.returnValue(fakePromiseBPM);
-
- let username = 'fake-username';
- let password = 'fake-password';
- let token = 'Basic ' + btoa(`${username}:${password}`);
-
- service.login(username, password, providers)
- .subscribe(() => {
- expect(service.isLoggedIn(providers[0])).toBe(true);
- expect(service.getTicket(providers[0])).toEqual(token);
- done();
- }
- );
- });
-
- it('should return ticket undefined when the credentials are wrong', (done) => {
- let providers = ['BPM'];
- let alfSetting = injector.get(AlfrescoSettingsService);
- alfSetting.providers = providers;
-
- service = injector.get(AlfrescoAuthenticationService);
- spyOn(AlfrescoAuthenticationBPM.prototype, 'apiActivitiLogin').and.returnValue(Promise.reject('fake invalid credentials'));
-
- service.login('fake-wrong-username', 'fake-wrong-password', providers)
- .subscribe(
- (res) => {
- done();
- },
- (err: any) => {
- expect(service.isLoggedIn(providers[0])).toBe(false);
- expect(service.getTicket(providers[0])).toBeUndefined();
- done();
- }
- );
- });
-
- it('should return a ticket undefined after logout', (done) => {
- let providers = ['BPM'];
- let alfSetting = injector.get(AlfrescoSettingsService);
- alfSetting.providers = providers;
-
- service = injector.get(AlfrescoAuthenticationService);
- localStorage.setItem('ticket-BPM', 'fake-post-ticket-BPM');
- service.createProviderInstance(providers);
- spyOn(AlfrescoAuthenticationBPM.prototype, 'apiActivitiLogout').and.returnValue(fakePromiseBPM);
-
- service.logout()
- .subscribe(() => {
- expect(service.isLoggedIn(providers[0])).toBe(false);
- expect(service.getTicket(providers[0])).toBeUndefined();
- expect(localStorage.getItem('ticket-BPM')).toBeUndefined();
- done();
- }
- );
- });
-
- it('should throw an error when the logout return error', (done) => {
- let providers = ['BPM'];
- let alfSetting = injector.get(AlfrescoSettingsService);
- alfSetting.providers = providers;
-
- service = injector.get(AlfrescoAuthenticationService);
- localStorage.setItem('ticket-BPM', 'fake-post-ticket-BPM');
- service.createProviderInstance(providers);
- spyOn(AlfrescoAuthenticationBPM.prototype, 'apiActivitiLogout').and.returnValue(Promise.reject('fake logout error'));
-
- service.logout()
- .subscribe(
- (res) => {
- done();
- },
- (err: any) => {
- expect(err).toBeDefined();
- expect(err.message).toEqual('fake logout error');
- expect(localStorage.getItem('ticket-BPM')).toEqual('fake-post-ticket-BPM');
- done();
- }
- );
- });
-
-
- });
-
- describe('when the setting is both ECM and BPM ', () => {
-
- it('should create both instances', (done) => {
- let providers = ['ECM', 'BPM'];
- let alfSetting = injector.get(AlfrescoSettingsService);
- alfSetting.providers = providers;
-
- service = injector.get(AlfrescoAuthenticationService);
- spyOn(AlfrescoAuthenticationECM.prototype, 'callApiLogin').and.returnValue(fakePromiseECM);
- spyOn(AlfrescoAuthenticationBPM.prototype, 'apiActivitiLogin').and.returnValue(fakePromiseBPM);
-
- service.login('fake-username', 'fake-password', providers)
- .subscribe(() => {
- expect(service.isLoggedIn(providers[0])).toBe(true);
- expect(service.isLoggedIn(providers[1])).toBe(true);
- expect(service.providersInstance).toBeDefined();
- expect(service.providersInstance.length).toBe(2);
- expect(service.providersInstance[0].TYPE).toEqual(providers[0]);
- expect(service.providersInstance[1].TYPE).toEqual(providers[1]);
- done();
- }
- );
- });
-
- it('should return both ECM and BPM tickets after the login done', (done) => {
- let providers = ['ECM', 'BPM'];
- let alfSetting = injector.get(AlfrescoSettingsService);
- alfSetting.providers = providers;
-
- service = injector.get(AlfrescoAuthenticationService);
- spyOn(AlfrescoAuthenticationECM.prototype, 'callApiLogin').and.returnValue(fakePromiseECM);
- spyOn(AlfrescoAuthenticationBPM.prototype, 'apiActivitiLogin').and.returnValue(fakePromiseBPM);
-
- let username = 'fake-username';
- let password = 'fake-password';
- let bpmToken = 'Basic ' + btoa(`${username}:${password}`);
-
- service.login(username, password, providers)
- .subscribe(() => {
- expect(service.isLoggedIn(providers[0])).toBe(true);
- expect(service.isLoggedIn(providers[1])).toBe(true);
- expect(service.getTicket(providers[0])).toEqual('fake-post-ticket-ECM');
- expect(service.getTicket(providers[1])).toEqual(bpmToken);
- done();
- }
- );
- });
-
- it('should return ticket undefined when the credentials are correct for the ECM login but wrong for the BPM login', (done) => {
- let providers = ['ECM', 'BPM'];
- let alfSetting = injector.get(AlfrescoSettingsService);
- alfSetting.providers = providers;
-
- service = injector.get(AlfrescoAuthenticationService);
- spyOn(AlfrescoAuthenticationECM.prototype, 'callApiLogin').and.returnValue(fakePromiseECM);
- spyOn(AlfrescoAuthenticationBPM.prototype, 'apiActivitiLogin').and.returnValue(Promise.reject('fake invalid credentials'));
-
- service.login('fake-username', 'fake-password', providers)
- .subscribe(
- (res) => {
- done();
- },
- (err: any) => {
- expect(service.isLoggedIn(providers[0])).toBe(false);
- expect(service.getTicket(providers[0])).toBeUndefined();
- expect(service.isLoggedIn(providers[1])).toBe(false);
- expect(service.getTicket(providers[1])).toBeUndefined();
- done();
- }
- );
- });
-
- it('should return ticket undefined when the credentials are correct for the BPM login but wrong for the ECM login', (done) => {
- let providers = ['ECM', 'BPM'];
- let alfSetting = injector.get(AlfrescoSettingsService);
- alfSetting.providers = providers;
-
- service = injector.get(AlfrescoAuthenticationService);
- spyOn(AlfrescoAuthenticationECM.prototype, 'callApiLogin')
- .and.returnValue(Promise.reject('fake invalid credentials'));
- spyOn(AlfrescoAuthenticationBPM.prototype, 'apiActivitiLogin').and.returnValue(fakePromiseBPM);
-
- service.login('fake-username', 'fake-password', providers)
- .subscribe(
- (res) => {
- done();
- },
- (err: any) => {
- expect(service.isLoggedIn(providers[0])).toBe(false);
- expect(service.getTicket(providers[0])).toBeUndefined();
- expect(service.isLoggedIn(providers[1])).toBe(false);
- expect(service.getTicket(providers[1])).toBeUndefined();
- done();
- }
- );
- });
- });
-});
diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationService.service.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationService.service.ts
deleted file mode 100644
index cb66572d1a..0000000000
--- a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationService.service.ts
+++ /dev/null
@@ -1,205 +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 { Injectable } from '@angular/core';
-import { Observable } from 'rxjs/Rx';
-import { Http } from '@angular/http';
-import { AlfrescoSettingsService } from './AlfrescoSettingsService.service';
-import { AuthenticationFactory } from '../factory/AuthenticationFactory';
-import { AbstractAuthentication } from '../interface/authentication.interface';
-import { AlfrescoAuthenticationBase } from './AlfrescoAuthenticationBase.service';
-
-declare let AlfrescoApi: any;
-
-/**
- * The AlfrescoAuthenticationService provide the login service and store the ticket in the localStorage
- */
-@Injectable()
-export class AlfrescoAuthenticationService extends AlfrescoAuthenticationBase {
-
- private providersInstance: AbstractAuthentication[] = [];
-
- /**
- * Constructor
- * @param settingsService
- * @param http
- */
- constructor(settingsService: AlfrescoSettingsService,
- http: Http) {
- super(settingsService, http);
- if (settingsService) {
- this.createProviderInstance(settingsService.getProviders());
- }
- }
-
- /**
- * Method to delegate to POST login
- * @param username
- * @param password
- * @param providers
- * @returns {Observable|Observable}
- */
- login(username: string, password: string, providers: string []): Observable {
- localStorage.clear();
- if (providers.length === 0) {
- return Observable.throw('No providers defined');
- } else {
- return this.performeLogin(username, password, providers);
- }
- }
-
- /**
- * Perform a login on behalf of the user for the different provider instance
- *
- * @param username
- * @param password
- * @param providers
- * @returns {Observable|Observable}
- */
- private performeLogin(username: string, password: string, providers: string []): Observable {
- let observableBatch = [];
- providers.forEach((provider) => {
- let auth: AbstractAuthentication = this.findProviderInstance(provider);
- if (auth) {
- observableBatch.push(auth.login(username, password));
- } else {
- observableBatch.push(Observable.throw('Wrong provider defined'));
- }
- });
- return Observable.create(observer => {
- Observable.forkJoin(observableBatch).subscribe(
- (response: any[]) => {
- response.forEach((res) => {
- this.performeSaveTicket(res.type, res.ticket);
- });
- observer.next(response);
- },
- (err: any) => {
- observer.error(new Error(err));
- });
- });
- }
-
- /**
- * The method return true if the user is logged in
- * @returns {boolean}
- */
- isLoggedIn(type: string = 'ECM'): boolean {
- let auth: AbstractAuthentication = this.findProviderInstance(type);
- if (auth) {
- return auth.isLoggedIn();
- }
- return false;
- }
-
- getAlfrescoApi(): any {
- return this.findProviderInstance('ECM').alfrescoApi;
- }
-
- /**
- * Return the ticket stored in the localStorage of the specific provider type
- * @param type
- */
- public getTicket(type: string = 'ECM'): string {
- let auth: AbstractAuthentication = this.findProviderInstance(type);
- if (auth) {
- return auth.getTicket();
- }
- return '';
- }
-
- /**
- * Save the token calling the method of the specific provider type
- * @param type - providerName
- * @param ticket
- */
- private performeSaveTicket(type: string, ticket: string) {
- let auth: AbstractAuthentication = this.findProviderInstance(type);
- if (auth) {
- auth.saveTicket(ticket);
- }
- }
-
- /**
- * The method remove the ticket from the local storage
- * @returns {Observable}
- */
- public logout(): Observable {
- if (this.providersInstance.length === 0) {
- return Observable.throw('No providers defined');
- } else {
- return this.performLogout();
- }
- }
-
- /**
- * Perform a logout on behalf of the user for the different provider instance
- *
- * @returns {Observable|Observable}
- */
- private performLogout(): Observable {
- let observableBatch = [];
- this.providersInstance.forEach((authInstance) => {
- if (authInstance.isLoggedIn()) {
- observableBatch.push(authInstance.logout());
- }
- });
- return Observable.create(observer => {
- Observable.forkJoin(observableBatch).subscribe(
- (response: any[]) => {
- observer.next(response);
- },
- (err: any) => {
- observer.error(new Error(err));
- });
- });
- }
-
- /**
- * Create the provider instance using a Factory
- * @param providers - list of the providers like ECM BPM
- */
- public createProviderInstance(providers: string []): void {
- if (this.providersInstance.length === 0) {
- providers.forEach((provider) => {
- let authInstance: AbstractAuthentication = AuthenticationFactory.createAuth(
- this.alfrescoSetting, this.http, provider);
- if (authInstance) {
- this.providersInstance.push(authInstance);
- }
- });
- }
- }
-
- /**
- * Find the provider by type and return it
- * @param type
- * @returns {AbstractAuthentication}
- */
- private findProviderInstance(type: string): AbstractAuthentication {
- let auth: AbstractAuthentication = null;
- if (this.providersInstance && this.providersInstance.length !== 0) {
- this.providersInstance.forEach((provider) => {
- if (provider.TYPE === type.toUpperCase()) {
- auth = provider;
- }
- });
- }
- return auth;
- }
-
-}
diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoContentService.service.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoContent.service.ts
similarity index 98%
rename from ng2-components/ng2-alfresco-core/src/services/AlfrescoContentService.service.ts
rename to ng2-components/ng2-alfresco-core/src/services/AlfrescoContent.service.ts
index 98327e6d66..4e91c639ff 100644
--- a/ng2-components/ng2-alfresco-core/src/services/AlfrescoContentService.service.ts
+++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoContent.service.ts
@@ -17,7 +17,7 @@
import { Injectable } from '@angular/core';
-import { AlfrescoAuthenticationService } from './AlfrescoAuthenticationService.service';
+import { AlfrescoAuthenticationService } from './AlfrescoAuthentication.service';
@Injectable()
export class AlfrescoContentService {
diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoContent.spec.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoContent.spec.ts
new file mode 100644
index 0000000000..922f976d63
--- /dev/null
+++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoContent.spec.ts
@@ -0,0 +1,61 @@
+/*!
+ * @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 {describe, it, beforeEach} from '@angular/core/testing';
+import {ReflectiveInjector} from '@angular/core';
+import {AlfrescoSettingsService} from './AlfrescoSettings.service';
+import {AlfrescoAuthenticationService} from './AlfrescoAuthentication.service';
+import {AlfrescoContentService} from './AlfrescoContent.service';
+
+describe('AlfrescoContentService', () => {
+
+ let injector, contentService: AlfrescoContentService, authService: AlfrescoAuthenticationService, node;
+
+ const nodeId = 'fake-node-id';
+
+ beforeEach(() => {
+ injector = ReflectiveInjector.resolveAndCreate([
+ AlfrescoContentService,
+ AlfrescoAuthenticationService,
+ AlfrescoSettingsService
+ ]);
+ spyOn(localStorage, 'getItem').and.callFake(function (key) {
+ return 'myTicket';
+ });
+
+ contentService = injector.get(AlfrescoContentService);
+ authService = injector.get(AlfrescoAuthenticationService);
+ authService.login('fake-username', 'fake-password');
+
+ node = {
+ entry: {
+ id: nodeId
+ }
+ };
+ });
+
+ it('should return a valid content URL', () => {
+ expect(contentService.getContentUrl(node)).toBe('http://localhost:8080/alfresco/api/' +
+ '-default-/public/alfresco/versions/1/nodes/fake-node-id/content?attachment=false&alf_ticket=myTicket');
+ });
+
+ it('should return a valid thumbnail URL', () => {
+ expect(contentService.getDocumentThumbnailUrl(node))
+ .toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco' +
+ '/versions/1/nodes/fake-node-id/renditions/doclib/content?attachment=false&alf_ticket=myTicket');
+ });
+});
diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoContentService.spec.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoContentService.spec.ts
deleted file mode 100644
index ddb31efa85..0000000000
--- a/ng2-components/ng2-alfresco-core/src/services/AlfrescoContentService.spec.ts
+++ /dev/null
@@ -1,69 +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 { describe, it, beforeEach } from '@angular/core/testing';
-import { ReflectiveInjector } from '@angular/core';
-import { AlfrescoSettingsService } from './AlfrescoSettingsService.service';
-import { AlfrescoAuthenticationService } from './AlfrescoAuthenticationService.service';
-import { AlfrescoContentService } from './AlfrescoContentService.service';
-import { HTTP_PROVIDERS } from '@angular/http';
-
-describe('AlfrescoContentService', () => {
-
- let injector, service: AlfrescoContentService, authService: AlfrescoAuthenticationService;
- const nodeId = 'blah';
- let DEFAULT_CONTEXT_PATH: string = '/alfresco';
- let DEFAULT_BASE_API_PATH: string = '/api/-default-/public/alfresco/versions/1';
-
- beforeEach(() => {
- injector = ReflectiveInjector.resolveAndCreate([
- HTTP_PROVIDERS,
- AlfrescoContentService,
- AlfrescoAuthenticationService,
- AlfrescoSettingsService
- ]);
- spyOn(localStorage, 'getItem').and.callFake(function (key) {
- return 'myTicket';
- });
- service = injector.get(AlfrescoContentService);
- authService = injector.get(AlfrescoAuthenticationService);
- });
-
- it('should return a valid content URL', () => {
- expect(service.getContentUrl({
- entry: {
- id: nodeId
- }
- })).toBe(
- AlfrescoSettingsService.DEFAULT_ECM_ADDRESS + DEFAULT_CONTEXT_PATH +
- DEFAULT_BASE_API_PATH + '/nodes/' + nodeId + '/content' +
- '?attachment=false&alf_ticket=' + authService.getTicket()
- );
- });
-
- it('should return a valid thumbnail URL', () => {
- expect(service.getDocumentThumbnailUrl({
- entry: {
- id: nodeId
- }
- })).toBe(
- AlfrescoSettingsService.DEFAULT_ECM_ADDRESS + DEFAULT_CONTEXT_PATH +
- DEFAULT_BASE_API_PATH + '/nodes/' + nodeId + '/renditions/doclib/content' +
- '?attachment=false&alf_ticket=' + authService.getTicket()
- );
- });
-});
diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoPipeTranslate.service.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoPipeTranslate.service.ts
index 0901f3182e..12ba8b9b7f 100644
--- a/ng2-components/ng2-alfresco-core/src/services/AlfrescoPipeTranslate.service.ts
+++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoPipeTranslate.service.ts
@@ -17,7 +17,7 @@
import { Injectable, ChangeDetectorRef, Pipe } from '@angular/core';
import { TranslatePipe } from 'ng2-translate/ng2-translate';
-import { AlfrescoTranslationService } from './AlfrescoTranslationService.service';
+import { AlfrescoTranslationService } from './AlfrescoTranslation.service';
@Injectable()
@Pipe({
diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoSettingsService.service.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoSettings.service.ts
similarity index 68%
rename from ng2-components/ng2-alfresco-core/src/services/AlfrescoSettingsService.service.ts
rename to ng2-components/ng2-alfresco-core/src/services/AlfrescoSettings.service.ts
index d3567beb5b..aa2d876107 100644
--- a/ng2-components/ng2-alfresco-core/src/services/AlfrescoSettingsService.service.ts
+++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoSettings.service.ts
@@ -16,6 +16,7 @@
*/
import { Injectable } from '@angular/core';
+import { Subject } from 'rxjs/Subject';
@Injectable()
export class AlfrescoSettingsService {
@@ -23,50 +24,47 @@ export class AlfrescoSettingsService {
static DEFAULT_ECM_ADDRESS: string = 'http://' + window.location.hostname + ':8080';
static DEFAULT_BPM_ADDRESS: string = 'http://' + window.location.hostname + ':9999';
- static DEFAULT_ECM_CONTEXT_PATH: string = '/alfresco';
static DEFAULT_BPM_CONTEXT_PATH: string = '/activiti-app';
- static DEFAULT_ECM_BASE_API_PATH: string = '/api/-default-/public/alfresco/versions/1';
-
private _ecmHost: string = AlfrescoSettingsService.DEFAULT_ECM_ADDRESS;
private _bpmHost: string = AlfrescoSettingsService.DEFAULT_BPM_ADDRESS;
- private _ecmContextPath = AlfrescoSettingsService.DEFAULT_ECM_CONTEXT_PATH;
private _bpmContextPath = AlfrescoSettingsService.DEFAULT_BPM_CONTEXT_PATH;
- private _apiECMBasePath: string = AlfrescoSettingsService.DEFAULT_ECM_BASE_API_PATH;
+ private providers: string = 'ALL'; // ECM, BPM , ALL
- private providers: string[] = ['ECM', 'BPM'];
+ bpmHostSubject: Subject = new Subject();
+ ecmHostSubject: Subject = new Subject();
+ providerSubject: Subject = new Subject();
public get ecmHost(): string {
return this._ecmHost;
}
- public set ecmHost(value: string) {
- this._ecmHost = value;
+ public set ecmHost(ecmHostUrl: string) {
+ this.ecmHostSubject.next(ecmHostUrl);
+ this._ecmHost = ecmHostUrl;
}
public get bpmHost(): string {
return this._bpmHost;
}
- public set bpmHost(value: string) {
- this._bpmHost = value;
+ public set bpmHost(bpmHostUrl: string) {
+ this.bpmHostSubject.next(bpmHostUrl);
+ this._bpmHost = bpmHostUrl;
}
public getBPMApiBaseUrl(): string {
return this._bpmHost + this._bpmContextPath;
}
- public getECMApiBaseUrl(): string {
- return this._ecmHost + this._ecmContextPath + this._apiECMBasePath;
- }
-
- public getProviders(): string [] {
+ public getProviders(): string {
return this.providers;
}
- public setProviders(providers: string []) {
+ public setProviders(providers: string) {
+ this.providerSubject.next(providers);
this.providers = providers;
}
}
diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoSettingsService.spec.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoSettings.spec.ts
similarity index 95%
rename from ng2-components/ng2-alfresco-core/src/services/AlfrescoSettingsService.spec.ts
rename to ng2-components/ng2-alfresco-core/src/services/AlfrescoSettings.spec.ts
index 96fc5a1745..6b83975c23 100644
--- a/ng2-components/ng2-alfresco-core/src/services/AlfrescoSettingsService.spec.ts
+++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoSettings.spec.ts
@@ -16,7 +16,7 @@
*/
import { describe, it, beforeEach } from '@angular/core/testing';
-import { AlfrescoSettingsService } from './AlfrescoSettingsService.service';
+import { AlfrescoSettingsService } from './AlfrescoSettings.service';
describe('AlfrescoSettingsService', () => {
diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoTranslationService.service.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoTranslation.service.ts
similarity index 100%
rename from ng2-components/ng2-alfresco-core/src/services/AlfrescoTranslationService.service.ts
rename to ng2-components/ng2-alfresco-core/src/services/AlfrescoTranslation.service.ts
diff --git a/ng2-components/ng2-alfresco-core/src/services/index.ts b/ng2-components/ng2-alfresco-core/src/services/index.ts
index bdde5bffd4..7c013a4b4c 100644
--- a/ng2-components/ng2-alfresco-core/src/services/index.ts
+++ b/ng2-components/ng2-alfresco-core/src/services/index.ts
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-export * from './AlfrescoSettingsService.service';
+export * from './AlfrescoSettings.service';
export * from './AlfrescoTranslationLoader.service';
-export * from './AlfrescoTranslationService.service';
+export * from './AlfrescoTranslation.service';
export * from './AlfrescoPipeTranslate.service';
-export * from './AlfrescoAuthenticationService.service';
-export * from './AlfrescoContentService.service';
+export * from './AlfrescoAuthentication.service';
+export * from './AlfrescoContent.service';
diff --git a/ng2-components/ng2-alfresco-core/tslint.json b/ng2-components/ng2-alfresco-core/tslint.json
index dde69dd07e..23d636b1eb 100644
--- a/ng2-components/ng2-alfresco-core/tslint.json
+++ b/ng2-components/ng2-alfresco-core/tslint.json
@@ -24,7 +24,7 @@
"label-undefined": true,
"max-line-length": [
true,
- 140
+ 180
],
"member-ordering": [
true,
diff --git a/ng2-components/ng2-alfresco-datatable/tslint.json b/ng2-components/ng2-alfresco-datatable/tslint.json
index 828c3d4f6c..85e9df53c1 100644
--- a/ng2-components/ng2-alfresco-datatable/tslint.json
+++ b/ng2-components/ng2-alfresco-datatable/tslint.json
@@ -1,121 +1,121 @@
{
- "rules": {
- "align": [
- true,
- "parameters",
- "statements"
- ],
- "ban": false,
- "class-name": true,
- "comment-format": [
- true,
- "check-space"
- ],
- "curly": true,
- "eofline": true,
- "forin": true,
- "indent": [
- true,
- "spaces"
- ],
- "interface-name": false,
- "jsdoc-format": true,
- "label-position": true,
- "label-undefined": true,
- "max-line-length": [
- true,
- 140
- ],
- "member-ordering": [
- true,
- "static-before-instance",
- "variables-before-functions"
- ],
- "no-any": false,
- "no-arg": true,
- "no-bitwise": false,
- "no-conditional-assignment": true,
- "no-consecutive-blank-lines": false,
- "no-console": [
- true,
- "debug",
- "info",
- "time",
- "timeEnd",
- "trace"
- ],
- "no-construct": true,
- "no-constructor-vars": false,
- "no-debugger": true,
- "no-duplicate-key": true,
- "no-duplicate-variable": true,
- "no-empty": false,
- "no-eval": true,
- "no-inferrable-types": false,
- "no-internal-module": true,
- "no-require-imports": true,
- "no-shadowed-variable": true,
- "no-switch-case-fall-through": true,
- "no-trailing-whitespace": true,
- "no-unreachable": true,
- "no-unused-expression": true,
- "no-unused-variable": true,
- "no-use-before-declare": true,
- "no-var-keyword": true,
- "no-var-requires": true,
- "object-literal-sort-keys": false,
- "one-line": [
- true,
- "check-open-brace",
- "check-catch",
- "check-else",
- "check-whitespace"
- ],
- "quotemark": [
- true,
- "single",
- "avoid-escape"
- ],
- "radix": true,
- "semicolon": true,
- "switch-default": true,
- "trailing-comma": [
- true,
- {
- "multiline": "never",
- "singleline": "never"
- }
- ],
- "triple-equals": [
- true,
- "allow-null-check"
- ],
- "typedef": false,
- "typedef-whitespace": [
- true,
- {
- "call-signature": "nospace",
- "index-signature": "nospace",
- "parameter": "nospace",
- "property-declaration": "nospace",
- "variable-declaration": "nospace"
- }
- ],
- "use-strict": false,
- "variable-name": [
- true,
- "check-format",
- "allow-leading-underscore",
- "ban-keywords"
- ],
- "whitespace": [
- true,
- "check-branch",
- "check-operator",
- "check-separator",
- "check-type",
- "check-module",
- "check-decl"
- ]
- }
+ "rules": {
+ "align": [
+ true,
+ "parameters",
+ "statements"
+ ],
+ "ban": false,
+ "class-name": true,
+ "comment-format": [
+ true,
+ "check-space"
+ ],
+ "curly": true,
+ "eofline": true,
+ "forin": true,
+ "indent": [
+ true,
+ "spaces"
+ ],
+ "interface-name": false,
+ "jsdoc-format": true,
+ "label-position": true,
+ "label-undefined": true,
+ "max-line-length": [
+ true,
+ 180
+ ],
+ "member-ordering": [
+ true,
+ "static-before-instance",
+ "variables-before-functions"
+ ],
+ "no-any": false,
+ "no-arg": true,
+ "no-bitwise": false,
+ "no-conditional-assignment": true,
+ "no-consecutive-blank-lines": false,
+ "no-console": [
+ true,
+ "debug",
+ "info",
+ "time",
+ "timeEnd",
+ "trace"
+ ],
+ "no-construct": true,
+ "no-constructor-vars": false,
+ "no-debugger": true,
+ "no-duplicate-key": true,
+ "no-duplicate-variable": true,
+ "no-empty": false,
+ "no-eval": true,
+ "no-inferrable-types": false,
+ "no-internal-module": true,
+ "no-require-imports": true,
+ "no-shadowed-variable": true,
+ "no-switch-case-fall-through": true,
+ "no-trailing-whitespace": true,
+ "no-unreachable": true,
+ "no-unused-expression": true,
+ "no-unused-variable": true,
+ "no-use-before-declare": true,
+ "no-var-keyword": true,
+ "no-var-requires": true,
+ "object-literal-sort-keys": false,
+ "one-line": [
+ true,
+ "check-open-brace",
+ "check-catch",
+ "check-else",
+ "check-whitespace"
+ ],
+ "quotemark": [
+ true,
+ "single",
+ "avoid-escape"
+ ],
+ "radix": true,
+ "semicolon": true,
+ "switch-default": true,
+ "trailing-comma": [
+ true,
+ {
+ "multiline": "never",
+ "singleline": "never"
+ }
+ ],
+ "triple-equals": [
+ true,
+ "allow-null-check"
+ ],
+ "typedef": false,
+ "typedef-whitespace": [
+ true,
+ {
+ "call-signature": "nospace",
+ "index-signature": "nospace",
+ "parameter": "nospace",
+ "property-declaration": "nospace",
+ "variable-declaration": "nospace"
+ }
+ ],
+ "use-strict": false,
+ "variable-name": [
+ true,
+ "check-format",
+ "allow-leading-underscore",
+ "ban-keywords"
+ ],
+ "whitespace": [
+ true,
+ "check-branch",
+ "check-operator",
+ "check-separator",
+ "check-type",
+ "check-module",
+ "check-decl"
+ ]
+ }
}
diff --git a/ng2-components/ng2-alfresco-documentlist/demo/package.json b/ng2-components/ng2-alfresco-documentlist/demo/package.json
index 019fe149f3..f436990778 100644
--- a/ng2-components/ng2-alfresco-documentlist/demo/package.json
+++ b/ng2-components/ng2-alfresco-documentlist/demo/package.json
@@ -36,7 +36,7 @@
"material-design-icons": "2.2.3",
"material-design-lite": "1.1.3",
"ng2-translate": "2.2.2",
- "alfresco-js-api": "^0.2.0",
+ "alfresco-js-api": "^0.3.0",
"ng2-alfresco-core": "^0.2.0",
"ng2-alfresco-documentlist": "^0.2.0",
"ng2-alfresco-datatable": "^0.2.0"
diff --git a/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts b/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts
index d3893bdaaf..1cdf4bdd0d 100644
--- a/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts
+++ b/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts
@@ -144,17 +144,16 @@ class DocumentListDemo implements OnInit {
authenticated: boolean;
ecmHost: string = 'http://devproducts-platform.alfresco.me';
- // ecmHost: string = 'http://127.0.0.1:8080';
token: string;
constructor(
private authService: AlfrescoAuthenticationService,
- private alfrescoSettingsService: AlfrescoSettingsService,
+ private settingsService: AlfrescoSettingsService,
translation: AlfrescoTranslationService,
private documentActions: DocumentActionsService) {
- alfrescoSettingsService.ecmHost = this.ecmHost;
+ settingsService.ecmHost = this.ecmHost;
if (this.authService.getTicket()) {
this.token = this.authService.getTicket();
}
@@ -167,7 +166,7 @@ class DocumentListDemo implements OnInit {
}
public updateHost(): void {
- this.alfrescoSettingsService.ecmHost = this.ecmHost;
+ this.settingsService.ecmHost = this.ecmHost;
this.login();
}
@@ -190,7 +189,7 @@ class DocumentListDemo implements OnInit {
}
login() {
- this.authService.login('admin', 'admin', ['ECM']).subscribe(
+ this.authService.login('admin', 'admin').subscribe(
token => {
console.log(token);
this.token = token;
diff --git a/ng2-components/ng2-alfresco-documentlist/package.json b/ng2-components/ng2-alfresco-documentlist/package.json
index d70e6ee051..d1b88a967f 100644
--- a/ng2-components/ng2-alfresco-documentlist/package.json
+++ b/ng2-components/ng2-alfresco-documentlist/package.json
@@ -72,7 +72,7 @@
"ng2-translate": "2.2.2",
"ng2-alfresco-core": "0.2.0",
"ng2-alfresco-datatable": "0.2.0",
- "alfresco-js-api": "0.2.0"
+ "alfresco-js-api": "^0.3.0"
},
"peerDependencies": {
"material-design-icons": "^2.2.3",
diff --git a/ng2-components/ng2-alfresco-documentlist/tslint.json b/ng2-components/ng2-alfresco-documentlist/tslint.json
index 828c3d4f6c..b57f9928d2 100644
--- a/ng2-components/ng2-alfresco-documentlist/tslint.json
+++ b/ng2-components/ng2-alfresco-documentlist/tslint.json
@@ -24,7 +24,7 @@
"label-undefined": true,
"max-line-length": [
true,
- 140
+ 180
],
"member-ordering": [
true,
diff --git a/ng2-components/ng2-alfresco-login/README.md b/ng2-components/ng2-alfresco-login/README.md
index a28b703fb8..681854ace8 100644
--- a/ng2-components/ng2-alfresco-login/README.md
+++ b/ng2-components/ng2-alfresco-login/README.md
@@ -83,7 +83,7 @@ Also make sure you include these dependencies in your .html page:
## Basic usage
```html
-
+
```
Example of an App that use Alfresco login component :
@@ -105,7 +105,7 @@ import {
selector: 'my-app',
template: '
',
@@ -141,18 +141,17 @@ bootstrap(AppComponent, [
| onSuccess | The event is emitted when the login is done |
| onError | The event is emitted when the login fails |
+Attribute | Description |
+--- | --- |
+`onSuccess` | The event is emitted when the login is done |
+`onError` | The event is emitted when the login fails |
+
#### Options
-**providers**: { string[] } optional) default ECM.
+Attribute | Options | Default | Description | Mandatory
+--- | --- | --- | --- | ---
+`providers` | *string* | ECM | Possible valid value are ECM, BPM or ALL. The default behaviour of this component will logged in only in the ECM . If you want log in in both system the correct value to use is ALL |
-Using the providers attribute, you can specify in which system
-(ECM or BPM) you want to be logged in.
-By selecting one of the options only the relative components will be
- accesible. For instance if you activate the ECM login then only the
- ECM component will be visible,same behaviour for BPM selection.
-You can also specify ECM and BPM, in this case both system components
- are accessible.
-
## Custom logo and background
diff --git a/ng2-components/ng2-alfresco-login/demo/package.json b/ng2-components/ng2-alfresco-login/demo/package.json
index 7a1298cd44..52977b3140 100644
--- a/ng2-components/ng2-alfresco-login/demo/package.json
+++ b/ng2-components/ng2-alfresco-login/demo/package.json
@@ -66,7 +66,7 @@
"material-design-lite": "1.1.3",
"ng2-translate": "2.2.2",
- "alfresco-js-api": "^0.2.0",
+ "alfresco-js-api": "^0.3.0",
"ng2-alfresco-core": "^0.1.36",
"ng2-alfresco-login": "file:../"
},
diff --git a/ng2-components/ng2-alfresco-login/demo/src/main.ts b/ng2-components/ng2-alfresco-login/demo/src/main.ts
index 83ec4d1ac6..318d25a2f3 100644
--- a/ng2-components/ng2-alfresco-login/demo/src/main.ts
+++ b/ng2-components/ng2-alfresco-login/demo/src/main.ts
@@ -62,15 +62,15 @@ export class AppComponent {
public status: string = '';
- public providers: string [] = ['ECM'];
+ public providers: string = 'ECM';
constructor(public auth: AlfrescoAuthenticationService,
- private alfrescoSettingsService: AlfrescoSettingsService) {
- alfrescoSettingsService.ecmHost = this.ecmHost;
+ private settingsService: AlfrescoSettingsService) {
+ settingsService.ecmHost = this.ecmHost;
}
public updateHost(): void {
- this.alfrescoSettingsService.ecmHost = this.ecmHost;
+ this.settingsService.ecmHost = this.ecmHost;
}
mySuccessMethod($event) {
@@ -84,18 +84,22 @@ export class AppComponent {
}
toggleECM(checked) {
- if (checked) {
- this.providers[0] = 'ECM';
+ if (checked && this.providers === 'BPM') {
+ this.providers = 'ALL';
+ } else if (checked) {
+ this.providers = 'ECM';
} else {
- this.providers[0] = '';
+ this.providers = undefined;
}
}
toggleBPM(checked) {
- if (checked) {
- this.providers[1] = 'BPM';
+ if (checked && this.providers === 'ECM') {
+ this.providers = 'ALL';
+ } else if (checked) {
+ this.providers = 'BPM';
} else {
- this.providers[1] = '';
+ this.providers = undefined;
}
}
}
diff --git a/ng2-components/ng2-alfresco-login/package.json b/ng2-components/ng2-alfresco-login/package.json
index 0a565f500d..bd87cb02f7 100644
--- a/ng2-components/ng2-alfresco-login/package.json
+++ b/ng2-components/ng2-alfresco-login/package.json
@@ -75,7 +75,7 @@
"zone.js": "0.6.12",
"ng2-translate": "2.2.2",
"ng2-alfresco-core": "0.2.0",
- "alfresco-js-api": "^0.2.0",
+ "alfresco-js-api": "^0.3.0",
"coveralls": "^2.11.9"
},
"devDependencies": {
diff --git a/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.spec.ts b/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.spec.ts
index 8c8432c156..9d39107f0c 100644
--- a/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.spec.ts
+++ b/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.spec.ts
@@ -23,7 +23,7 @@ import {
beforeEach,
beforeEachProviders
} from '@angular/core/testing';
-import { AlfrescoAuthenticationService } from 'ng2-alfresco-core';
+import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core';
import { TestComponentBuilder } from '@angular/compiler/testing';
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
import { AlfrescoLoginComponent } from './alfresco-login.component';
@@ -38,6 +38,7 @@ describe('AlfrescoLogin', () => {
beforeEachProviders(() => {
return [
{ provide: AlfrescoAuthenticationService, useClass: AuthenticationMock },
+ AlfrescoSettingsService,
{ provide: AlfrescoTranslationService, useClass: TranslationMock }
];
});
diff --git a/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.ts b/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.ts
index 52b71610a2..a0a67a46b2 100644
--- a/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.ts
+++ b/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.ts
@@ -15,12 +15,13 @@
* limitations under the License.
*/
-import { Component, Input, Output, EventEmitter } from '@angular/core';
-import { FORM_DIRECTIVES, ControlGroup, FormBuilder, Validators } from '@angular/common';
+import {Component, Input, Output, EventEmitter} from '@angular/core';
+import {FORM_DIRECTIVES, ControlGroup, FormBuilder, Validators} from '@angular/common';
import {
AlfrescoTranslationService,
AlfrescoPipeTranslate,
- AlfrescoAuthenticationService
+ AlfrescoAuthenticationService,
+ AlfrescoSettingsService
} from 'ng2-alfresco-core';
declare let componentHandler: any;
@@ -48,7 +49,7 @@ export class AlfrescoLoginComponent {
backgroundImageUrl: string;
@Input()
- providers: string [] ;
+ providers: string ;
@Output()
onSuccess = new EventEmitter();
@@ -67,11 +68,13 @@ export class AlfrescoLoginComponent {
/**
* Constructor
* @param _fb
- * @param auth
+ * @param authService
+ * @param settingsService
* @param translate
*/
constructor(private _fb: FormBuilder,
- public auth: AlfrescoAuthenticationService,
+ public authService: AlfrescoAuthenticationService,
+ public settingsService: AlfrescoSettingsService,
private translate: AlfrescoTranslationService) {
this.formError = {
@@ -79,7 +82,7 @@ export class AlfrescoLoginComponent {
'password': ''
};
- this.form = this._fb.group({
+ this.form = this._fb.group({
username: ['', Validators.compose([Validators.required, Validators.minLength(4)])],
password: ['', Validators.required]
});
@@ -104,12 +107,15 @@ export class AlfrescoLoginComponent {
* @param value
* @param event
*/
- onSubmit(value: any, event) {
+ onSubmit(value: any, event: any) {
this.error = false;
if (event) {
event.preventDefault();
}
- this.auth.login(value.username, value.password, this.providers)
+
+ this.settingsService.setProviders(this.providers);
+
+ this.authService.login(value.username, value.password)
.subscribe(
(token: any) => {
this.success = true;
diff --git a/ng2-components/ng2-alfresco-login/tslint.json b/ng2-components/ng2-alfresco-login/tslint.json
index d9374e0015..85e9df53c1 100644
--- a/ng2-components/ng2-alfresco-login/tslint.json
+++ b/ng2-components/ng2-alfresco-login/tslint.json
@@ -24,7 +24,7 @@
"label-undefined": true,
"max-line-length": [
true,
- 140
+ 180
],
"member-ordering": [
true,
diff --git a/ng2-components/ng2-alfresco-search/demo/package.json b/ng2-components/ng2-alfresco-search/demo/package.json
index 8050d2c17e..fb97aa08b5 100644
--- a/ng2-components/ng2-alfresco-search/demo/package.json
+++ b/ng2-components/ng2-alfresco-search/demo/package.json
@@ -66,7 +66,7 @@
"material-design-icons": "2.2.3",
"material-design-lite": "1.1.3",
- "alfresco-js-api": "^0.2.0",
+ "alfresco-js-api": "^0.3.0",
"ng2-alfresco-core": "^0.1.36",
"ng2-alfresco-search": "^0.1.25"
},
diff --git a/ng2-components/ng2-alfresco-search/demo/src/main.ts b/ng2-components/ng2-alfresco-search/demo/src/main.ts
index 506d26513b..fdffb9c8e1 100644
--- a/ng2-components/ng2-alfresco-search/demo/src/main.ts
+++ b/ng2-components/ng2-alfresco-search/demo/src/main.ts
@@ -63,16 +63,16 @@ class SearchDemo implements OnInit {
token: string;
constructor(private authService: AlfrescoAuthenticationService,
- private alfrescoSettingsService: AlfrescoSettingsService,
+ private settingsService: AlfrescoSettingsService,
translation: AlfrescoTranslationService) {
- alfrescoSettingsService.ecmHost = this.ecmHost;
+ settingsService.ecmHost = this.ecmHost;
translation.addTranslationFolder();
}
public updateHost(): void {
- this.alfrescoSettingsService.ecmHost = this.ecmHost;
+ this.settingsService.ecmHost = this.ecmHost;
this.login();
}
@@ -81,7 +81,7 @@ class SearchDemo implements OnInit {
}
login() {
- this.authService.login('admin', 'admin', ['ECM']).subscribe(
+ this.authService.login('admin', 'admin').subscribe(
token => {
console.log(token);
this.token = token;
diff --git a/ng2-components/ng2-alfresco-search/package.json b/ng2-components/ng2-alfresco-search/package.json
index 18d3a755da..3da16d4ed9 100644
--- a/ng2-components/ng2-alfresco-search/package.json
+++ b/ng2-components/ng2-alfresco-search/package.json
@@ -71,7 +71,7 @@
"zone.js": "0.6.12",
"ng2-translate": "2.2.2",
"material-design-lite": "1.1.3",
- "alfresco-js-api": "^0.2.0",
+ "alfresco-js-api": "^0.3.0",
"ng2-alfresco-core": "0.2.0"
},
"peerDependencies": {
diff --git a/ng2-components/ng2-alfresco-search/src/assets/alfresco.service.mock.ts b/ng2-components/ng2-alfresco-search/src/assets/alfresco.service.mock.ts
deleted file mode 100644
index cba51e6585..0000000000
--- a/ng2-components/ng2-alfresco-search/src/assets/alfresco.service.mock.ts
+++ /dev/null
@@ -1,41 +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 {
- AlfrescoAuthenticationService
-} from 'ng2-alfresco-core';
-import {AlfrescoSearchService} from './../../src/services/alfresco-search.service';
-
-export class AlfrescoServiceMock extends AlfrescoSearchService {
-
- _folderToReturn: any = {};
-
- constructor(
- authService: AlfrescoAuthenticationService = null
- ) {
- super(authService);
- }
-
- getFolder(folder: string) {
- return Observable.create(observer => {
- observer.next(this._folderToReturn);
- observer.complete();
- });
- }
-}
diff --git a/ng2-components/ng2-alfresco-search/tslint.json b/ng2-components/ng2-alfresco-search/tslint.json
index 828c3d4f6c..0a34e57fec 100644
--- a/ng2-components/ng2-alfresco-search/tslint.json
+++ b/ng2-components/ng2-alfresco-search/tslint.json
@@ -24,7 +24,7 @@
"label-undefined": true,
"max-line-length": [
true,
- 140
+ 180
],
"member-ordering": [
true,
diff --git a/ng2-components/ng2-alfresco-upload/demo/package.json b/ng2-components/ng2-alfresco-upload/demo/package.json
index 12080cca71..bd6b9e2c9c 100644
--- a/ng2-components/ng2-alfresco-upload/demo/package.json
+++ b/ng2-components/ng2-alfresco-upload/demo/package.json
@@ -66,7 +66,7 @@
"material-design-icons": "2.2.3",
"material-design-lite": "1.1.3",
- "alfresco-js-api": "^0.2.0",
+ "alfresco-js-api": "^0.3.0",
"ng2-alfresco-core": "^0.1.36",
"ng2-alfresco-upload": "^0.1.49"
},
diff --git a/ng2-components/ng2-alfresco-upload/demo/src/main.ts b/ng2-components/ng2-alfresco-upload/demo/src/main.ts
index a9d7dc92cb..6f75c98ffe 100644
--- a/ng2-components/ng2-alfresco-upload/demo/src/main.ts
+++ b/ng2-components/ng2-alfresco-upload/demo/src/main.ts
@@ -80,8 +80,8 @@ export class MyDemoApp implements OnInit {
token: string;
- constructor(private authService: AlfrescoAuthenticationService, private alfrescoSettingsService: AlfrescoSettingsService) {
- alfrescoSettingsService.ecmHost = this.ecmHost;
+ constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) {
+ settingsService.ecmHost = this.ecmHost;
if (this.authService.getTicket()) {
this.token = this.authService.getTicket();
@@ -93,7 +93,7 @@ export class MyDemoApp implements OnInit {
}
public updateHost(): void {
- this.alfrescoSettingsService.ecmHost = this.ecmHost;
+ this.settingsService.ecmHost = this.ecmHost;
this.login();
}
@@ -106,7 +106,7 @@ export class MyDemoApp implements OnInit {
}
login() {
- this.authService.login('admin', 'admin', ['ECM']).subscribe(
+ this.authService.login('admin', 'admin').subscribe(
token => {
console.log(token);
this.token = token;
diff --git a/ng2-components/ng2-alfresco-upload/package.json b/ng2-components/ng2-alfresco-upload/package.json
index bbc11604b5..4a746c8342 100644
--- a/ng2-components/ng2-alfresco-upload/package.json
+++ b/ng2-components/ng2-alfresco-upload/package.json
@@ -71,7 +71,7 @@
"rxjs": "5.0.0-beta.6",
"zone.js": "0.6.12",
"ng2-translate": "2.2.2",
- "alfresco-js-api": "^0.2.0",
+ "alfresco-js-api": "^0.3.0",
"ng2-alfresco-core": "0.2.0"
},
"peerDependencies": {
diff --git a/ng2-components/ng2-alfresco-upload/src/assets/AlfrescoSettingsService.service.mock.ts b/ng2-components/ng2-alfresco-upload/src/assets/AlfrescoSettingsService.service.mock.ts
deleted file mode 100644
index 354b652ed8..0000000000
--- a/ng2-components/ng2-alfresco-upload/src/assets/AlfrescoSettingsService.service.mock.ts
+++ /dev/null
@@ -1,36 +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 { Injectable } from '@angular/core';
-
-@Injectable()
-export class AlfrescoSettingsServiceMock {
-
- static DEFAULT_HOST_ADDRESS: string = 'fakehost';
-
- private providers: string[] = ['ECM', 'BPM'];
-
- private _host: string = AlfrescoSettingsServiceMock.DEFAULT_HOST_ADDRESS;
-
- public get ecmHost(): string {
- return this._host;
- }
-
- getProviders(): string [] {
- return this.providers;
- }
-}
diff --git a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.spec.ts b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.spec.ts
index 8d30847464..25081c240b 100644
--- a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.spec.ts
+++ b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.spec.ts
@@ -21,8 +21,8 @@ import { UploadButtonComponent } from './upload-button.component';
import { AlfrescoTranslationService, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
import { TranslationMock } from '../assets/translation.service.mock';
import { UploadService } from '../services/upload.service';
-import { AlfrescoSettingsServiceMock } from '../assets/AlfrescoSettingsService.service.mock';
import { HTTP_PROVIDERS } from '@angular/http';
+
declare var AlfrescoApi: any;
describe('AlfrescoUploadButton', () => {
@@ -69,7 +69,7 @@ describe('AlfrescoUploadButton', () => {
beforeEachProviders(() => {
return [
HTTP_PROVIDERS,
- { provide: AlfrescoSettingsService, useClass: AlfrescoSettingsServiceMock },
+ AlfrescoSettingsService,
AlfrescoAuthenticationService,
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
UploadService
diff --git a/ng2-components/ng2-alfresco-upload/src/components/upload-drag-area.component.spec.ts b/ng2-components/ng2-alfresco-upload/src/components/upload-drag-area.component.spec.ts
index 51030ab9bc..d90e49f0f9 100644
--- a/ng2-components/ng2-alfresco-upload/src/components/upload-drag-area.component.spec.ts
+++ b/ng2-components/ng2-alfresco-upload/src/components/upload-drag-area.component.spec.ts
@@ -19,7 +19,6 @@ import { describe, expect, it, inject, beforeEach, beforeEachProviders } from '@
import { TestComponentBuilder } from '@angular/compiler/testing';
import { UploadDragAreaComponent } from './upload-drag-area.component';
import { AlfrescoTranslationService, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
-import { AlfrescoSettingsServiceMock } from '../assets/AlfrescoSettingsService.service.mock';
import { TranslationMock } from '../assets/translation.service.mock';
import { UploadService } from '../services/upload.service';
import { HTTP_PROVIDERS } from '@angular/http';
@@ -38,7 +37,7 @@ describe('AlfrescoUploadDragArea', () => {
beforeEachProviders(() => {
return [
HTTP_PROVIDERS,
- { provide: AlfrescoSettingsService, useClass: AlfrescoSettingsServiceMock },
+ AlfrescoSettingsService,
AlfrescoAuthenticationService,
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
UploadService
diff --git a/ng2-components/ng2-alfresco-upload/src/services/upload.service.spec.ts b/ng2-components/ng2-alfresco-upload/src/services/upload.service.spec.ts
index 91b7b35abe..b0b220c4e5 100644
--- a/ng2-components/ng2-alfresco-upload/src/services/upload.service.spec.ts
+++ b/ng2-components/ng2-alfresco-upload/src/services/upload.service.spec.ts
@@ -16,11 +16,9 @@
*/
import { it, describe, inject, beforeEach, beforeEachProviders } from '@angular/core/testing';
+import { EventEmitter } from '@angular/core';
import { UploadService } from './upload.service';
import { AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
-import { AlfrescoSettingsServiceMock } from '../assets/AlfrescoSettingsService.service.mock';
-import { HTTP_PROVIDERS } from '@angular/http';
-import { EventEmitter } from '@angular/core';
declare let AlfrescoApi: any;
declare let jasmine: any;
@@ -40,9 +38,8 @@ describe('AlfrescoUploadService', () => {
beforeEachProviders(() => {
return [
- HTTP_PROVIDERS,
- { provide: AlfrescoSettingsService, useClass: AlfrescoSettingsServiceMock },
- { provide: AlfrescoAuthenticationService, useClass: AlfrescoAuthenticationService },
+ AlfrescoSettingsService,
+ AlfrescoAuthenticationService,
UploadService
];
});
@@ -88,7 +85,7 @@ describe('AlfrescoUploadService', () => {
service.uploadFilesInTheQueue('fake-dir', emitter);
let request = jasmine.Ajax.requests.mostRecent();
- expect(request.url).toBe('fakehost/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children');
+ expect(request.url).toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children');
expect(request.method).toBe('POST');
jasmine.Ajax.requests.mostRecent().respondWith({
@@ -110,7 +107,7 @@ describe('AlfrescoUploadService', () => {
service.addToQueue(filesFake);
service.uploadFilesInTheQueue('', emitter);
expect(jasmine.Ajax.requests.mostRecent().url)
- .toBe('fakehost/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children');
+ .toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children');
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 404,
contentType: 'text/plain',
diff --git a/ng2-components/ng2-alfresco-upload/tslint.json b/ng2-components/ng2-alfresco-upload/tslint.json
index d9374e0015..85e9df53c1 100644
--- a/ng2-components/ng2-alfresco-upload/tslint.json
+++ b/ng2-components/ng2-alfresco-upload/tslint.json
@@ -24,7 +24,7 @@
"label-undefined": true,
"max-line-length": [
true,
- 140
+ 180
],
"member-ordering": [
true,
diff --git a/ng2-components/ng2-alfresco-viewer/demo/package.json b/ng2-components/ng2-alfresco-viewer/demo/package.json
index a5f07f4844..68b9db6bbc 100644
--- a/ng2-components/ng2-alfresco-viewer/demo/package.json
+++ b/ng2-components/ng2-alfresco-viewer/demo/package.json
@@ -40,7 +40,7 @@
"ng2-alfresco-core": "^0.2.0",
"ng2-translate": "2.2.2",
- "alfresco-js-api": "^0.2.0",
+ "alfresco-js-api": "^0.3.0",
"ng2-alfresco-viewer" : "file:../"
},
"devDependencies": {
diff --git a/ng2-components/ng2-alfresco-viewer/demo/src/main.ts b/ng2-components/ng2-alfresco-viewer/demo/src/main.ts
index 169ab30808..6515dec983 100644
--- a/ng2-components/ng2-alfresco-viewer/demo/src/main.ts
+++ b/ng2-components/ng2-alfresco-viewer/demo/src/main.ts
@@ -57,9 +57,9 @@ class MyDemoApp {
token: string;
constructor(private authService: AlfrescoAuthenticationService,
- private alfrescoSettingsService: AlfrescoSettingsService) {
+ private settingsService: AlfrescoSettingsService) {
- alfrescoSettingsService.ecmHost = this.ecmHost;
+ settingsService.ecmHost = this.ecmHost;
if (this.authService.getTicket()) {
this.token = this.authService.getTicket();
}
@@ -70,7 +70,7 @@ class MyDemoApp {
}
public updateHost(): void {
- this.alfrescoSettingsService.ecmHost = this.ecmHost;
+ this.settingsService.ecmHost = this.ecmHost;
this.login();
}
@@ -79,7 +79,7 @@ class MyDemoApp {
}
login() {
- this.authService.login('admin', 'admin', ['ECM']).subscribe(
+ this.authService.login('admin', 'admin').subscribe(
token => {
console.log(token);
this.token = token;
diff --git a/ng2-components/ng2-alfresco-viewer/package.json b/ng2-components/ng2-alfresco-viewer/package.json
index 773d73227b..00a8f82423 100644
--- a/ng2-components/ng2-alfresco-viewer/package.json
+++ b/ng2-components/ng2-alfresco-viewer/package.json
@@ -61,7 +61,7 @@
"ng2-alfresco-core": "0.2.0",
"ng2-translate": "2.2.2",
- "alfresco-js-api": "^0.2.0",
+ "alfresco-js-api": "^0.3.0",
"systemjs": "0.19.27",
"core-js": "2.4.0",
diff --git a/ng2-components/ng2-alfresco-viewer/src/assets/AlfrescoSettingsService.service.mock.ts b/ng2-components/ng2-alfresco-viewer/src/assets/AlfrescoSettingsService.service.mock.ts
deleted file mode 100644
index 354b652ed8..0000000000
--- a/ng2-components/ng2-alfresco-viewer/src/assets/AlfrescoSettingsService.service.mock.ts
+++ /dev/null
@@ -1,36 +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 { Injectable } from '@angular/core';
-
-@Injectable()
-export class AlfrescoSettingsServiceMock {
-
- static DEFAULT_HOST_ADDRESS: string = 'fakehost';
-
- private providers: string[] = ['ECM', 'BPM'];
-
- private _host: string = AlfrescoSettingsServiceMock.DEFAULT_HOST_ADDRESS;
-
- public get ecmHost(): string {
- return this._host;
- }
-
- getProviders(): string [] {
- return this.providers;
- }
-}
diff --git a/ng2-components/ng2-alfresco-viewer/src/pdfViewer.component.spec.ts b/ng2-components/ng2-alfresco-viewer/src/pdfViewer.component.spec.ts
index eb1452f403..70daa5cdc2 100644
--- a/ng2-components/ng2-alfresco-viewer/src/pdfViewer.component.spec.ts
+++ b/ng2-components/ng2-alfresco-viewer/src/pdfViewer.component.spec.ts
@@ -23,20 +23,16 @@ import {PDFJSmock} from './assets/PDFJS.mock';
import {PDFViewermock} from './assets/PDFViewer.mock';
import {EventMock} from './assets/event.mock';
-import {HTTP_PROVIDERS} from '@angular/http';
-import {AlfrescoSettingsServiceMock} from '../src/assets/AlfrescoSettingsService.service.mock';
-import {AlfrescoAuthenticationService, AlfrescoSettingsService} from 'ng2-alfresco-core';
+import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core';
describe('PdfViewer', () => {
let pdfComponentFixture, element, component;
-
beforeEachProviders(() => {
return [
- HTTP_PROVIDERS,
- {provide: AlfrescoSettingsService, useClass: AlfrescoSettingsServiceMock},
- {provide: AlfrescoAuthenticationService, useClass: AlfrescoAuthenticationService}
+ AlfrescoSettingsService,
+ AlfrescoAuthenticationService
];
});
diff --git a/ng2-components/ng2-alfresco-viewer/src/viewer.component.spec.ts b/ng2-components/ng2-alfresco-viewer/src/viewer.component.spec.ts
index 8f2a9295be..a54433b541 100644
--- a/ng2-components/ng2-alfresco-viewer/src/viewer.component.spec.ts
+++ b/ng2-components/ng2-alfresco-viewer/src/viewer.component.spec.ts
@@ -15,338 +15,216 @@
* limitations under the License.
*/
-import { describe, expect, it, inject, beforeEachProviders } from '@angular/core/testing';
-import { TestComponentBuilder } from '@angular/compiler/testing';
-import { ViewerComponent } from './viewer.component';
-import { EventMock } from './assets/event.mock';
-import { HTTP_PROVIDERS } from '@angular/http';
-import { AlfrescoSettingsServiceMock } from '../src/assets/AlfrescoSettingsService.service.mock';
-import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core';
+import {describe, expect, it, inject, beforeEachProviders, beforeEach} from '@angular/core/testing';
+import {TestComponentBuilder} from '@angular/compiler/testing';
+import {ViewerComponent} from './viewer.component';
+import {EventMock} from './assets/event.mock';
+import {AlfrescoAuthenticationService, AlfrescoSettingsService} from 'ng2-alfresco-core';
- describe('ViewerComponent', () => {
+describe('ViewerComponent', () => {
- beforeEachProviders(() => {
- return [
- HTTP_PROVIDERS,
- {provide: AlfrescoSettingsService, useClass: AlfrescoSettingsServiceMock},
- {provide: AlfrescoAuthenticationService, useClass: AlfrescoAuthenticationService}
- ];
- });
+ let viewerComponentFixture, element, component;
- describe('View', () => {
- it('shadow overlay should be present if is overlay mode', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
- return tcb
- .createAsync(ViewerComponent)
- .then((fixture) => {
- let element = fixture.nativeElement;
- let component = fixture.componentInstance;
- component.urlFile = 'fake-url-file';
- component.overlayMode = true;
+ beforeEachProviders(() => {
+ return [
+ AlfrescoSettingsService,
+ AlfrescoAuthenticationService
+ ];
+ });
- fixture.detectChanges();
+ beforeEach(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
+ return tcb
+ .createAsync(ViewerComponent)
+ .then(fixture => {
+ viewerComponentFixture = fixture;
+ element = viewerComponentFixture.nativeElement;
+ component = viewerComponentFixture.componentInstance;
- expect(element.querySelector('#viewer-shadow-transparent')).not.toBeNull();
- });
- }));
+ component.urlFile = 'fake-url-file';
+ component.overlayMode = true;
- it('header should be present if is overlay mode', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
- return tcb
- .createAsync(ViewerComponent)
- .then((fixture) => {
- let element = fixture.nativeElement;
- let component = fixture.componentInstance;
- component.urlFile = 'fake-url-file';
- component.overlayMode = true;
+ viewerComponentFixture.detectChanges();
+ });
+ }));
- fixture.detectChanges();
+ describe('View', () => {
+ it('shadow overlay should be present if is overlay mode', () => {
+ expect(element.querySelector('#viewer-shadow-transparent')).not.toBeNull();
+ });
- expect(element.querySelector('header')).not.toBeNull();
- });
- }));
+ it('header should be present if is overlay mode', () => {
+ expect(element.querySelector('header')).not.toBeNull();
+ });
+ it('header should be NOT be present if is not overlay mode', () => {
+ component.overlayMode = false;
- it('header should be NOT be present if is not overlay mode', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
- return tcb
- .createAsync(ViewerComponent)
- .then((fixture) => {
- let element = fixture.nativeElement;
- let component = fixture.componentInstance;
- component.urlFile = 'fake-url-file';
- component.overlayMode = false;
+ viewerComponentFixture.detectChanges();
- fixture.detectChanges();
+ expect(element.querySelector('header')).toBeNull();
+ });
- expect(element.querySelector('header')).toBeNull();
- });
- }));
+ it('Name File should be present if is overlay mode ', () => {
+ component.urlFile = 'http://localhost:9876/fake-url-file.pdf';
+ component.overlayMode = true;
- it('Name File should be present if is overlay mode ', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
- return tcb
- .createAsync(ViewerComponent)
- .then((fixture) => {
- let element = fixture.nativeElement;
- let component = fixture.componentInstance;
- component.urlFile = 'http://localhost:9876/fake-url-file.pdf';
- component.overlayMode = true;
+ component.ngOnChanges().then(() => {
+ viewerComponentFixture.detectChanges();
+ expect(element.querySelector('#viewer-name-file').innerHTML).toEqual('fake-url-file.pdf');
+ });
+ });
- component.ngOnChanges().then(() => {
- fixture.detectChanges();
- expect(element.querySelector('#viewer-name-file').innerHTML).toEqual('fake-url-file.pdf');
- });
- });
- }));
+ it('Close button should be present if overlay mode', () => {
+ component.urlFile = 'fake-url-file';
+ component.overlayMode = true;
- /* tslint:disable:max-line-length */
- it('should pick up filename from the fileName property when specified', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
- return tcb
- .createAsync(ViewerComponent)
- .then((fixture) => {
- let element = fixture.nativeElement;
- let component = fixture.componentInstance;
- component.urlFile = 'http://localhost:9876/fake-url-file.pdf';
- component.fileName = 'My Example.pdf';
+ viewerComponentFixture.detectChanges();
- component.ngOnChanges().then(() => {
- fixture.detectChanges();
- expect(element.querySelector('#viewer-name-file').innerHTML).toEqual('My Example.pdf');
- });
- });
- }));
+ expect(element.querySelector('#viewer-close-button')).not.toBeNull();
+ });
- it('Close button should be present if overlay mode', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
- return tcb
- .createAsync(ViewerComponent)
- .then((fixture) => {
- let element = fixture.nativeElement;
- let component = fixture.componentInstance;
- component.urlFile = 'fake-url-file';
- component.overlayMode = true;
+ it('Close button should be not present if is not overlay mode', () => {
+ component.urlFile = 'fake-url-file';
+ component.overlayMode = false;
- fixture.detectChanges();
+ viewerComponentFixture.detectChanges();
- expect(element.querySelector('#viewer-close-button')).not.toBeNull();
- });
- }));
+ expect(element.querySelector('#viewer-close-button')).toBeNull();
+ });
- it('Close button should be not present if is not overlay mode', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
- return tcb
- .createAsync(ViewerComponent)
- .then((fixture) => {
- let element = fixture.nativeElement;
- let component = fixture.componentInstance;
- component.urlFile = 'fake-url-file';
- component.overlayMode = false;
+ it('Click on close button should hide the viewer', () => {
+ component.urlFile = 'fake-url-file';
+ component.overlayMode = true;
- fixture.detectChanges();
+ viewerComponentFixture.detectChanges();
+ element.querySelector('#viewer-close-button').click();
+ viewerComponentFixture.detectChanges();
+ expect(element.querySelector('#viewer-main-container')).toBeNull();
- expect(element.querySelector('#viewer-close-button')).toBeNull();
- });
- }));
+ });
+ it('Esc button should not hide the viewerls if is not overlay mode', () => {
+ component.overlayMode = false;
- it('Click on close button should hide the viewer', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
- return tcb
- .createAsync(ViewerComponent)
- .then((fixture) => {
- let element = fixture.nativeElement;
- let component = fixture.componentInstance;
- component.urlFile = 'fake-url-file';
- component.overlayMode = true;
+ component.urlFile = 'fake-url-file';
- fixture.detectChanges();
- element.querySelector('#viewer-close-button').click();
- fixture.detectChanges();
- expect(element.querySelector('#viewer-main-container')).toBeNull();
- });
- }));
+ viewerComponentFixture.detectChanges();
+ EventMock.keyDown(27);
+ viewerComponentFixture.detectChanges();
+ expect(element.querySelector('#viewer-main-container')).not.toBeNull();
+ });
- it('Esc button should not hide the viewerls if is not overlay mode', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
- return tcb
- .createAsync(ViewerComponent)
- .then((fixture) => {
- let element = fixture.nativeElement;
- let component = fixture.componentInstance;
- component.overlayMode = false;
+ it('Esc button should hide the viewer', () => {
+ component.urlFile = 'fake-url-file';
+ component.overlayMode = true;
- component.urlFile = 'fake-url-file';
+ viewerComponentFixture.detectChanges();
+ EventMock.keyDown(27);
+ viewerComponentFixture.detectChanges();
+ expect(element.querySelector('#viewer-main-container')).toBeNull();
+ });
- fixture.detectChanges();
- EventMock.keyDown(27);
- fixture.detectChanges();
- expect(element.querySelector('#viewer-main-container')).not.toBeNull();
- });
- }));
+ });
- it('Esc button should hide the viewer', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
- return tcb
- .createAsync(ViewerComponent)
- .then((fixture) => {
- let element = fixture.nativeElement;
- let component = fixture.componentInstance;
- component.urlFile = 'fake-url-file';
- component.overlayMode = true;
+ describe('Attribute', () => {
+ it('Url File should be mandatory', () => {
+ component.showViewer = true;
+ component.urlFile = undefined;
- fixture.detectChanges();
- EventMock.keyDown(27);
- fixture.detectChanges();
- expect(element.querySelector('#viewer-main-container')).toBeNull();
- });
- }));
- });
+ expect(() => {
+ component.ngOnChanges();
+ }).toThrow();
+ });
- describe('Attribute', () => {
- it('Url File should be mandatory', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
- return tcb
- .createAsync(ViewerComponent)
- .then((fixture) => {
- let component = fixture.componentInstance;
- component.showViewer = true;
+ it('showViewer default value should be true', () => {
+ expect(component.showViewer).toBe(true);
+ });
- expect(() => {
- component.ngOnChanges();
- }).toThrow();
- });
- }));
+ it('if showViewer value is false the viewer should be hide', () => {
+ component.urlFile = 'fake-url-file';
+ component.showViewer = false;
- it('showViewer default value should be true', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
- return tcb
- .createAsync(ViewerComponent)
- .then((fixture) => {
- let component = fixture.componentInstance;
+ viewerComponentFixture.detectChanges();
+ expect(element.querySelector('#viewer-main-container')).toBeNull();
+ });
+ });
- expect(component.showViewer).toBe(true);
- });
- }));
+ describe('Extension Type Test', () => {
+ it('if extension file is a pdf the pdf viewer should be loaded', (done) => {
+ component.urlFile = 'fake-url-file.pdf';
- it('if showViewer value is false the viewer should be hide', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
- return tcb
- .createAsync(ViewerComponent)
- .then((fixture) => {
- let component = fixture.componentInstance;
- let element = fixture.nativeElement;
- component.urlFile = 'fake-url-file';
- component.showViewer = false;
+ component.ngOnChanges().then(() => {
+ viewerComponentFixture.detectChanges();
+ expect(element.querySelector('pdf-viewer')).not.toBeNull();
+ done();
+ });
+ });
- fixture.detectChanges();
- expect(element.querySelector('#viewer-main-container')).toBeNull();
- });
- }));
- });
+ it('if extension file is a image the img viewer should be loaded', (done) => {
+ component.urlFile = 'fake-url-file.png';
- /* tslint:disable:max-line-length */
- describe('Extension Type Test', () => {
- it('if extension file is a pdf the pdf viewer should be loaded', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
- return tcb
- .createAsync(ViewerComponent)
- .then((fixture) => {
- let component = fixture.componentInstance;
- let element = fixture.nativeElement;
- component.urlFile = 'fake-url-file.pdf';
+ component.ngOnChanges().then(() => {
+ viewerComponentFixture.detectChanges();
+ expect(element.querySelector('#viewer-image')).not.toBeNull();
+ done();
+ });
+ });
- component.ngOnChanges().then(() => {
- fixture.detectChanges();
- expect(element.querySelector('pdf-viewer')).not.toBeNull();
- });
- });
- }));
+ it('if extension file is a not supported the not supported div should be loaded', (done) => {
+ component.urlFile = 'fake-url-file.unsupported';
- /* tslint:disable:max-line-length */
- it('if extension file is a image the img viewer should be loaded', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
- return tcb
- .createAsync(ViewerComponent)
- .then((fixture) => {
- let component = fixture.componentInstance;
- let element = fixture.nativeElement;
- component.urlFile = 'fake-url-file.png';
+ component.ngOnChanges().then(() => {
+ viewerComponentFixture.detectChanges();
+ expect(element.querySelector('not-supported-format')).not.toBeNull();
+ done();
+ });
+ });
+ });
- component.ngOnChanges().then(() => {
- fixture.detectChanges();
- expect(element.querySelector('#viewer-image')).not.toBeNull();
- });
- });
- }));
+ describe('MimeType handling', () => {
+ it('should display a PDF file identified by mimetype when the filename has no extension', (done) => {
+ component.urlFile = 'content';
+ component.mimeType = 'application/pdf';
- /* tslint:disable:max-line-length */
- it('if extension file is a not supported the not supported div should be loaded', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
- return tcb
- .createAsync(ViewerComponent)
- .then((fixture) => {
- let component = fixture.componentInstance;
- let element = fixture.nativeElement;
- component.urlFile = 'fake-url-file.unsupported';
+ component.ngOnChanges().then(() => {
+ viewerComponentFixture.detectChanges();
+ expect(element.querySelector('pdf-viewer')).not.toBeNull();
+ done();
+ });
- component.ngOnChanges().then(() => {
- fixture.detectChanges();
- expect(element.querySelector('not-supported-format')).not.toBeNull();
- });
- });
- }));
- });
+ });
- /* tslint:disable:max-line-length */
- describe('MimeType handling', () => {
- it('should display a PDF file identified by mimetype when the filename has no extension', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
- return tcb
- .createAsync(ViewerComponent)
- .then((fixture) => {
- let component = fixture.componentInstance;
- let element = fixture.nativeElement;
- component.urlFile = 'content';
- component.mimeType = 'application/pdf';
+ it('should display a PDF file identified by mimetype when the file extension is wrong', (done) => {
+ component.urlFile = 'content.bin';
+ component.mimeType = 'application/pdf';
- component.ngOnChanges().then(() => {
- fixture.detectChanges();
- expect(element.querySelector('pdf-viewer')).not.toBeNull();
- });
- });
- }));
+ component.ngOnChanges().then(() => {
+ viewerComponentFixture.detectChanges();
+ expect(element.querySelector('pdf-viewer')).not.toBeNull();
+ done();
+ });
+ });
- it('should display a PDF file identified by mimetype when the file extension is wrong', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
- return tcb
- .createAsync(ViewerComponent)
- .then((fixture) => {
- let component = fixture.componentInstance;
- let element = fixture.nativeElement;
- component.urlFile = 'content.bin';
- component.mimeType = 'application/pdf';
+ it('should display an image file identified by mimetype when the filename has no extension', (done) => {
+ component.urlFile = 'content';
+ component.mimeType = 'image/png';
- component.ngOnChanges().then(() => {
- fixture.detectChanges();
- expect(element.querySelector('pdf-viewer')).not.toBeNull();
- });
- });
- }));
+ component.ngOnChanges().then(() => {
+ viewerComponentFixture.detectChanges();
+ expect(element.querySelector('#viewer-image')).not.toBeNull();
+ done();
+ });
+ });
- it('should display an image file identified by mimetype when the filename has no extension', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
- return tcb
- .createAsync(ViewerComponent)
- .then((fixture) => {
- let component = fixture.componentInstance;
- let element = fixture.nativeElement;
- component.urlFile = 'content';
- component.mimeType = 'image/png';
+ it('should display a image file identified by mimetype when the file extension is wrong', (done) => {
+ component.urlFile = 'content.bin';
+ component.mimeType = 'image/png';
- component.ngOnChanges().then(() => {
- fixture.detectChanges();
- expect(element.querySelector('#viewer-image')).not.toBeNull();
- });
- });
- }));
-
- it('should display a image file identified by mimetype when the file extension is wrong', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
- return tcb
- .createAsync(ViewerComponent)
- .then((fixture) => {
- let component = fixture.componentInstance;
- let element = fixture.nativeElement;
- component.urlFile = 'content.bin';
- component.mimeType = 'image/png';
-
- component.ngOnChanges().then(() => {
- fixture.detectChanges();
- expect(element.querySelector('#viewer-image')).not.toBeNull();
- });
- });
- }));
- });
- });
+ component.ngOnChanges().then(() => {
+ viewerComponentFixture.detectChanges();
+ expect(element.querySelector('#viewer-image')).not.toBeNull();
+ done();
+ });
+ });
+ });
+});
diff --git a/ng2-components/ng2-alfresco-viewer/tslint.json b/ng2-components/ng2-alfresco-viewer/tslint.json
index 828c3d4f6c..0a34e57fec 100644
--- a/ng2-components/ng2-alfresco-viewer/tslint.json
+++ b/ng2-components/ng2-alfresco-viewer/tslint.json
@@ -24,7 +24,7 @@
"label-undefined": true,
"max-line-length": [
true,
- 140
+ 180
],
"member-ordering": [
true,
diff --git a/ng2-components/ng2-alfresco-webscript/README.md b/ng2-components/ng2-alfresco-webscript/README.md
index b5285e2e89..398491efaa 100644
--- a/ng2-components/ng2-alfresco-webscript/README.md
+++ b/ng2-components/ng2-alfresco-webscript/README.md
@@ -56,7 +56,7 @@ The following component needs to be added to your systemjs.config:
- ng2-translate
- ng2-alfresco-core
-- ng2-alfresco-datatable
+- ng2-alfresco-dataĆtable
Please refer to the following example to have an idea of how your systemjs.config should look like :
diff --git a/ng2-components/ng2-alfresco-webscript/demo/package.json b/ng2-components/ng2-alfresco-webscript/demo/package.json
index fc638bf45a..f4443bec01 100644
--- a/ng2-components/ng2-alfresco-webscript/demo/package.json
+++ b/ng2-components/ng2-alfresco-webscript/demo/package.json
@@ -37,7 +37,7 @@
"material-design-icons": "2.2.3",
"material-design-lite": "1.1.3",
- "alfresco-js-api": "^0.2.0",
+ "alfresco-js-api": "^0.3.0",
"ng2-translate": "2.2.2",
"ng2-alfresco-core": "^0.2.0",
diff --git a/ng2-components/ng2-alfresco-webscript/demo/src/main.ts b/ng2-components/ng2-alfresco-webscript/demo/src/main.ts
index d7dbd363d9..1d554e2da7 100644
--- a/ng2-components/ng2-alfresco-webscript/demo/src/main.ts
+++ b/ng2-components/ng2-alfresco-webscript/demo/src/main.ts
@@ -34,9 +34,9 @@ import { WEBSCRIPTCOMPONENT } from 'ng2-alfresco-webscript';
-
+
- Authentication failed to ip {{ host }} with user: admin, admin, you can still try to add a valid token to perform
+ Authentication failed to ip {{ ecmHost }} with user: admin, admin, you can still try to add a valid token to perform
operations.
@@ -76,9 +76,11 @@ class WebscriptDemo implements OnInit {
token: string;
constructor(private authService: AlfrescoAuthenticationService,
- private alfrescoSettingsService: AlfrescoSettingsService) {
+ private settingsService: AlfrescoSettingsService) {
+
+ settingsService.ecmHost = this.ecmHost;
+ settingsService.setProviders('ECM');
- alfrescoSettingsService.ecmHost = this.ecmHost;
if (this.authService.getTicket()) {
this.token = this.authService.getTicket();
}
@@ -89,7 +91,7 @@ class WebscriptDemo implements OnInit {
}
public updateHost(): void {
- this.alfrescoSettingsService.ecmHost = this.ecmHost;
+ this.settingsService.ecmHost = this.ecmHost;
this.login();
}
@@ -98,7 +100,7 @@ class WebscriptDemo implements OnInit {
}
login() {
- this.authService.login('admin', 'admin', ['ECM']).subscribe(
+ this.authService.login('admin', 'admin').subscribe(
token => {
console.log(token);
this.token = token;
diff --git a/ng2-components/ng2-alfresco-webscript/package.json b/ng2-components/ng2-alfresco-webscript/package.json
index 388bdc25fc..a8eed53ab5 100644
--- a/ng2-components/ng2-alfresco-webscript/package.json
+++ b/ng2-components/ng2-alfresco-webscript/package.json
@@ -44,7 +44,7 @@
"@angular/upgrade": "2.0.0-rc.3",
"systemjs": "0.19.27",
"core-js": "^2.4.0",
- "alfresco-js-api": "^0.2.0",
+ "alfresco-js-api": "^0.3.0",
"ng2-translate": "2.2.2",
"ng2-alfresco-core": "^0.2.0",
diff --git a/ng2-components/ng2-alfresco-webscript/src/assets/AlfrescoSettingsService.service.mock.ts b/ng2-components/ng2-alfresco-webscript/src/assets/AlfrescoSettingsService.service.mock.ts
deleted file mode 100644
index 354b652ed8..0000000000
--- a/ng2-components/ng2-alfresco-webscript/src/assets/AlfrescoSettingsService.service.mock.ts
+++ /dev/null
@@ -1,36 +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 { Injectable } from '@angular/core';
-
-@Injectable()
-export class AlfrescoSettingsServiceMock {
-
- static DEFAULT_HOST_ADDRESS: string = 'fakehost';
-
- private providers: string[] = ['ECM', 'BPM'];
-
- private _host: string = AlfrescoSettingsServiceMock.DEFAULT_HOST_ADDRESS;
-
- public get ecmHost(): string {
- return this._host;
- }
-
- getProviders(): string [] {
- return this.providers;
- }
-}
diff --git a/ng2-components/ng2-alfresco-webscript/src/webscript.component.spec.ts b/ng2-components/ng2-alfresco-webscript/src/webscript.component.spec.ts
index c9ca176f3c..bdade46782 100644
--- a/ng2-components/ng2-alfresco-webscript/src/webscript.component.spec.ts
+++ b/ng2-components/ng2-alfresco-webscript/src/webscript.component.spec.ts
@@ -18,8 +18,6 @@
import { describe, expect, it, inject, beforeEachProviders, beforeEach, afterEach, xit } from '@angular/core/testing';
import { TestComponentBuilder } from '@angular/compiler/testing';
import { WebscriptComponent } from '../src/webscript.component';
-import { AlfrescoSettingsServiceMock } from '../src/assets/AlfrescoSettingsService.service.mock';
-import { HTTP_PROVIDERS } from '@angular/http';
import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core';
@@ -31,9 +29,8 @@ describe('Test ng2-alfresco-webscript', () => {
beforeEachProviders(() => {
return [
- HTTP_PROVIDERS,
- {provide: AlfrescoSettingsService, useClass: AlfrescoSettingsServiceMock},
- {provide: AlfrescoAuthenticationService, useClass: AlfrescoAuthenticationService}
+ AlfrescoSettingsService,
+ AlfrescoAuthenticationService
];
});
@@ -88,7 +85,7 @@ describe('Test ng2-alfresco-webscript', () => {
component.ngOnChanges().then(() => {
webscriptComponentFixture.detectChanges();
let request = jasmine.Ajax.requests.mostRecent();
- expect(request.url).toBe('fakehost/alfresco/service/sample/folder/Company%20Home');
+ expect(request.url).toBe('http://localhost:8080/alfresco/service/sample/folder/Company%20Home');
done();
});
diff --git a/scripts/README.md b/scripts/README.md
index a3a4f48b7b..37889a212a 100644
--- a/scripts/README.md
+++ b/scripts/README.md
@@ -41,4 +41,10 @@ in the demo shell:
./start-linked.sh
```
+* If you want to build all your local component:
+
+```sh
+./npm-buid-alll.sh
+```
+
For development environment configuration please refer to [project docs](demo-shell-ng2/README.md).
\ No newline at end of file
diff --git a/scripts/npm-check.sh b/scripts/npm-check.sh
new file mode 100755
index 0000000000..6f6d1cbf1e
--- /dev/null
+++ b/scripts/npm-check.sh
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+npm install -g npm-check
+
+echo 'start' > ../check-dependecies.log
+
+for PACKAGE in \
+ ng2-activiti-form \
+ ng2-activiti-processlist \
+ ng2-activiti-tasklist \
+ ng2-alfresco-core \
+ ng2-alfresco-datatable \
+ ng2-alfresco-documentlist \
+ ng2-alfresco-login \
+ ng2-alfresco-search \
+ ng2-alfresco-upload \
+ ng2-alfresco-viewer \
+ ng2-alfresco-webscript
+do
+ echo "====== Check component: ${PACKAGE} ====="
+ cd "$DIR/../ng2-components/${PACKAGE}"
+ echo "====== Check component: ${PACKAGE} =====" >> ../../check-dependecies.log
+ npm-check >> ../../check-dependecies.log
+done
+
+cd "$DIR/../demo-shell-ng2"
+echo "====== Check component: ${PACKAGE} =====" >> ../check-dependecies.log
+npm-check >> ../check-dependecies.log
+
+echo "====== You can find the log in the file check-dependecies.log in the main root====="
+
+
+cd ${DIR}