From cdb7a0a35993e8e34de3af2fd91eb8f638d24b67 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Fri, 27 May 2016 12:55:39 +0100 Subject: [PATCH] #103 moved auth service to core library --- demo-shell-ng2/app/app.component.ts | 8 ++++++-- .../app/components/router/AuthRouterOutlet.ts | 5 +++-- demo-shell-ng2/app/main.ts | 5 +---- .../ng2-alfresco-core/ng2-alfresco-core.ts | 13 +++---------- .../alfresco-authentication.service.spec.ts | 2 +- .../src/services/alfresco-authentication.service.ts | 2 -- .../ng2-alfresco-login/ng2-alfresco-login.ts | 8 -------- .../src/assets/authentication.service.mock.ts | 3 +-- .../src/components/alfresco-login.component.ts | 9 +++++++-- 9 files changed, 22 insertions(+), 33 deletions(-) rename ng2-components/{ng2-alfresco-login => ng2-alfresco-core}/src/services/alfresco-authentication.service.spec.ts (98%) rename ng2-components/{ng2-alfresco-login => ng2-alfresco-core}/src/services/alfresco-authentication.service.ts (99%) diff --git a/demo-shell-ng2/app/app.component.ts b/demo-shell-ng2/app/app.component.ts index 84ab4357e0..9d598ca02f 100644 --- a/demo-shell-ng2/app/app.component.ts +++ b/demo-shell-ng2/app/app.component.ts @@ -20,9 +20,13 @@ import { ControlGroup, FormBuilder, Validators } from 'angular2/common'; import { Router, RouteConfig, ROUTER_DIRECTIVES } from 'angular2/router'; import { MDL } from 'ng2-alfresco-core/dist/ng2-alfresco-core'; import { FilesComponent } from './components/files/files.component'; -import { AlfrescoAuthenticationService } from 'ng2-alfresco-login/dist/ng2-alfresco-login'; import { AuthRouterOutlet } from './components/router/AuthRouterOutlet'; -import { AlfrescoSettingsService, AlfrescoTranslationService, AlfrescoPipeTranslate } from 'ng2-alfresco-core/dist/ng2-alfresco-core'; +import { + AlfrescoSettingsService, + AlfrescoTranslationService, + AlfrescoPipeTranslate, + AlfrescoAuthenticationService +} from 'ng2-alfresco-core/dist/ng2-alfresco-core'; import { UploadButtonComponent } from 'ng2-alfresco-upload/dist/ng2-alfresco-upload'; import { DataTableDemoComponent } from './components/datatable/datatable-demo.component'; import { AlfrescoSearchComponent } from 'ng2-alfresco-search/dist/ng2-alfresco-search'; diff --git a/demo-shell-ng2/app/components/router/AuthRouterOutlet.ts b/demo-shell-ng2/app/components/router/AuthRouterOutlet.ts index d1f9f894df..68ee80db66 100644 --- a/demo-shell-ng2/app/components/router/AuthRouterOutlet.ts +++ b/demo-shell-ng2/app/components/router/AuthRouterOutlet.ts @@ -1,4 +1,4 @@ -/** +/*! * @license * Copyright 2016 Alfresco Software, Ltd. * @@ -14,9 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import { ElementRef, DynamicComponentLoader, Directive, Attribute } from 'angular2/core'; import { Router, RouterOutlet, ComponentInstruction } from 'angular2/router'; -import { AlfrescoAuthenticationService } from 'ng2-alfresco-login/dist/ng2-alfresco-login'; +import { AlfrescoAuthenticationService } from 'ng2-alfresco-core/dist/ng2-alfresco-core'; @Directive({selector: 'auth-router-outlet'}) export class AuthRouterOutlet extends RouterOutlet { diff --git a/demo-shell-ng2/app/main.ts b/demo-shell-ng2/app/main.ts index fa1bc43c4c..12ede3fa45 100644 --- a/demo-shell-ng2/app/main.ts +++ b/demo-shell-ng2/app/main.ts @@ -19,15 +19,12 @@ import { bootstrap } from 'angular2/platform/browser'; import { AppComponent } from './app.component'; import { ROUTER_PROVIDERS } from 'angular2/router'; import { HTTP_PROVIDERS } from 'angular2/http'; -import { ALFRESCO_AUTHENTICATION } from 'ng2-alfresco-login/dist/ng2-alfresco-login'; -import { ALFRESCO_CORE_PROVIDERS, AlfrescoTranslationService } from 'ng2-alfresco-core/dist/ng2-alfresco-core'; +import { ALFRESCO_CORE_PROVIDERS } from 'ng2-alfresco-core/dist/ng2-alfresco-core'; import { UploadService } from 'ng2-alfresco-upload/dist/ng2-alfresco-upload'; bootstrap(AppComponent, [ ROUTER_PROVIDERS, HTTP_PROVIDERS, - AlfrescoTranslationService, - ALFRESCO_AUTHENTICATION, ALFRESCO_CORE_PROVIDERS, UploadService ]); diff --git a/ng2-components/ng2-alfresco-core/ng2-alfresco-core.ts b/ng2-components/ng2-alfresco-core/ng2-alfresco-core.ts index 2b0c6fddd0..dc27be574c 100644 --- a/ng2-components/ng2-alfresco-core/ng2-alfresco-core.ts +++ b/ng2-components/ng2-alfresco-core/ng2-alfresco-core.ts @@ -15,28 +15,21 @@ * limitations under the License. */ - import {AlfrescoSettingsService} from './src/services/AlfrescoSettingsService.service'; import {AlfrescoTranslationLoader} from './src/services/AlfrescoTranslationLoader.service'; import {AlfrescoTranslationService} from './src/services/AlfrescoTranslationService.service'; import {AlfrescoPipeTranslate} from './src/services/AlfrescoPipeTranslate.service'; +import { AlfrescoAuthenticationService } from './src/services/alfresco-authentication.service'; export * from './src/services/AlfrescoSettingsService.service'; export * from './src/services/AlfrescoTranslationLoader.service'; export * from './src/services/AlfrescoTranslationService.service'; export * from './src/services/AlfrescoPipeTranslate.service'; export * from './src/material/MaterialDesignLiteUpgradeElement'; - -export default { - providers: [ - AlfrescoSettingsService, - AlfrescoTranslationLoader, - AlfrescoTranslationService, - AlfrescoPipeTranslate - ] -}; +export * from './src/services/alfresco-authentication.service'; export const ALFRESCO_CORE_PROVIDERS: [any] = [ + AlfrescoAuthenticationService, AlfrescoSettingsService, AlfrescoTranslationLoader, AlfrescoTranslationService, diff --git a/ng2-components/ng2-alfresco-login/src/services/alfresco-authentication.service.spec.ts b/ng2-components/ng2-alfresco-core/src/services/alfresco-authentication.service.spec.ts similarity index 98% rename from ng2-components/ng2-alfresco-login/src/services/alfresco-authentication.service.spec.ts rename to ng2-components/ng2-alfresco-core/src/services/alfresco-authentication.service.spec.ts index d64fa309da..9dbf52f627 100644 --- a/ng2-components/ng2-alfresco-login/src/services/alfresco-authentication.service.spec.ts +++ b/ng2-components/ng2-alfresco-core/src/services/alfresco-authentication.service.spec.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { it, describe } from 'angular2/testing'; +import { it, describe, beforeEach } from 'angular2/testing'; import { provide, Injector } from 'angular2/core'; import { Http, HTTP_PROVIDERS, XHRBackend, Response, ResponseOptions } from 'angular2/http'; import { MockBackend } from 'angular2/http/testing'; diff --git a/ng2-components/ng2-alfresco-login/src/services/alfresco-authentication.service.ts b/ng2-components/ng2-alfresco-core/src/services/alfresco-authentication.service.ts similarity index 99% rename from ng2-components/ng2-alfresco-login/src/services/alfresco-authentication.service.ts rename to ng2-components/ng2-alfresco-core/src/services/alfresco-authentication.service.ts index ecb103ca6c..995301feb0 100644 --- a/ng2-components/ng2-alfresco-login/src/services/alfresco-authentication.service.ts +++ b/ng2-components/ng2-alfresco-core/src/services/alfresco-authentication.service.ts @@ -19,8 +19,6 @@ import { Injectable } from 'angular2/core'; import { Observable } from 'rxjs/Rx'; import { Http, Headers, Response } from 'angular2/http'; -declare let xml2json: any; - /** * The AlfrescoAuthenticationService provide the login service and store the token in the localStorage */ diff --git a/ng2-components/ng2-alfresco-login/ng2-alfresco-login.ts b/ng2-components/ng2-alfresco-login/ng2-alfresco-login.ts index da45908916..a6ffab0341 100644 --- a/ng2-components/ng2-alfresco-login/ng2-alfresco-login.ts +++ b/ng2-components/ng2-alfresco-login/ng2-alfresco-login.ts @@ -16,15 +16,7 @@ */ import { AlfrescoLoginComponent } from './src/components/alfresco-login.component'; -import { AlfrescoAuthenticationService } from './src/services/alfresco-authentication.service'; export * from './src/components/alfresco-login.component'; -export * from './src/services/alfresco-authentication.service'; - -export default { - directives: [AlfrescoLoginComponent], - providers: [AlfrescoAuthenticationService] -}; export const ALFRESCO_LOGIN_DIRECTIVES: [any] = [AlfrescoLoginComponent]; -export const ALFRESCO_AUTHENTICATION: [any] = [AlfrescoAuthenticationService]; diff --git a/ng2-components/ng2-alfresco-login/src/assets/authentication.service.mock.ts b/ng2-components/ng2-alfresco-login/src/assets/authentication.service.mock.ts index 26ad202112..ff46c1dd67 100644 --- a/ng2-components/ng2-alfresco-login/src/assets/authentication.service.mock.ts +++ b/ng2-components/ng2-alfresco-login/src/assets/authentication.service.mock.ts @@ -17,8 +17,7 @@ import { Observable } from 'rxjs/Observable'; import { provide } from 'angular2/core'; - -import { AlfrescoAuthenticationService } from './../services/alfresco-authentication.service'; +import { AlfrescoAuthenticationService } from 'ng2-alfresco-core/dist/ng2-alfresco-core'; export class AuthenticationMock { 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 dcd15cd9db..8bace16d24 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 @@ -18,8 +18,12 @@ import { Component, Output, EventEmitter } from 'angular2/core'; import { Router, ROUTER_DIRECTIVES } from 'angular2/router'; import { FORM_DIRECTIVES, ControlGroup, FormBuilder, Validators } from 'angular2/common'; -import { AlfrescoAuthenticationService } from './../services/alfresco-authentication.service'; -import { AlfrescoTranslationService, AlfrescoPipeTranslate } from 'ng2-alfresco-core/dist/ng2-alfresco-core'; +import { + AlfrescoTranslationService, + AlfrescoPipeTranslate, + AlfrescoAuthenticationService +} from 'ng2-alfresco-core/dist/ng2-alfresco-core'; + declare let componentHandler: any; declare let __moduleName: string; @@ -52,6 +56,7 @@ export class AlfrescoLoginComponent { * @param _fb * @param auth * @param router + * @param translate */ constructor(private _fb: FormBuilder, public auth: AlfrescoAuthenticationService,