mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
fix translate
This commit is contained in:
@@ -18,13 +18,11 @@
|
|||||||
import { Component } from 'angular2/core';
|
import { Component } from 'angular2/core';
|
||||||
import { ControlGroup, FormBuilder, Validators } from 'angular2/common';
|
import { ControlGroup, FormBuilder, Validators } from 'angular2/common';
|
||||||
import { Router, RouteConfig, ROUTER_DIRECTIVES } from 'angular2/router';
|
import { Router, RouteConfig, ROUTER_DIRECTIVES } from 'angular2/router';
|
||||||
import { AlfrescoAuthenticationService } from 'ng2-alfresco-login/ng2-alfresco-login';
|
|
||||||
import { MDL } from 'ng2-alfresco-core/material';
|
import { MDL } from 'ng2-alfresco-core/material';
|
||||||
import { FilesComponent } from './components/files/files.component';
|
import { FilesComponent } from './components/files/files.component';
|
||||||
import { AlfrescoLoginComponent } from 'ng2-alfresco-login/ng2-alfresco-login';
|
import { AlfrescoLoginComponent, AlfrescoAuthenticationService } from 'ng2-alfresco-login/ng2-alfresco-login';
|
||||||
import { AuthRouterOutlet } from './components/router/AuthRouterOutlet';
|
import { AuthRouterOutlet } from './components/router/AuthRouterOutlet';
|
||||||
import { AlfrescoSettingsService } from 'ng2-alfresco-core/services';
|
import { AlfrescoSettingsService, AlfrescoTranslationService, AlfrescoPipeTranslate } from 'ng2-alfresco-core/services';
|
||||||
import { TranslateService, TranslatePipe } from 'ng2-translate/ng2-translate';
|
|
||||||
import { UploadButtonComponent } from 'ng2-alfresco-upload/ng2-alfresco-upload';
|
import { UploadButtonComponent } from 'ng2-alfresco-upload/ng2-alfresco-upload';
|
||||||
import { DataTableDemoComponent } from './components/datatable/datatable-demo.component';
|
import { DataTableDemoComponent } from './components/datatable/datatable-demo.component';
|
||||||
import { AlfrescoSearchComponent } from 'ng2-alfresco-search/ng2-alfresco-search';
|
import { AlfrescoSearchComponent } from 'ng2-alfresco-search/ng2-alfresco-search';
|
||||||
@@ -35,7 +33,7 @@ declare var document: any;
|
|||||||
selector: 'my-app',
|
selector: 'my-app',
|
||||||
templateUrl: 'app/app.component.html',
|
templateUrl: 'app/app.component.html',
|
||||||
directives: [ROUTER_DIRECTIVES, AuthRouterOutlet, MDL],
|
directives: [ROUTER_DIRECTIVES, AuthRouterOutlet, MDL],
|
||||||
pipes: [TranslatePipe]
|
pipes: [AlfrescoPipeTranslate]
|
||||||
})
|
})
|
||||||
@RouteConfig([
|
@RouteConfig([
|
||||||
{path: '/home', name: 'Home', component: FilesComponent},
|
{path: '/home', name: 'Home', component: FilesComponent},
|
||||||
@@ -52,7 +50,7 @@ export class AppComponent {
|
|||||||
constructor(private _fb: FormBuilder,
|
constructor(private _fb: FormBuilder,
|
||||||
public auth: AlfrescoAuthenticationService,
|
public auth: AlfrescoAuthenticationService,
|
||||||
public router: Router,
|
public router: Router,
|
||||||
translate: TranslateService,
|
translate: AlfrescoTranslationService,
|
||||||
alfrescoSettingsService: AlfrescoSettingsService) {
|
alfrescoSettingsService: AlfrescoSettingsService) {
|
||||||
alfrescoSettingsService.host = 'http://192.168.99.100:8080';
|
alfrescoSettingsService.host = 'http://192.168.99.100:8080';
|
||||||
|
|
||||||
@@ -60,7 +58,7 @@ export class AppComponent {
|
|||||||
searchTerm: ['', Validators.compose([Validators.required, Validators.minLength(3)])]
|
searchTerm: ['', Validators.compose([Validators.required, Validators.minLength(3)])]
|
||||||
});
|
});
|
||||||
|
|
||||||
this.translationInit(translate);
|
translate.translationInit('');
|
||||||
}
|
}
|
||||||
|
|
||||||
isActive(instruction: any[]): boolean {
|
isActive(instruction: any[]): boolean {
|
||||||
@@ -83,18 +81,6 @@ export class AppComponent {
|
|||||||
this.translate.use(lang);
|
this.translate.use(lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
translationInit(translate: TranslateService) {
|
|
||||||
this.translate = translate;
|
|
||||||
let userLang = navigator.language.split('-')[0]; // use navigator lang if available
|
|
||||||
userLang = /(fr|en)/gi.test(userLang) ? userLang : 'en';
|
|
||||||
|
|
||||||
this.translate.setDefaultLang('en');
|
|
||||||
|
|
||||||
this.translate.currentLoader.addComponentList('');
|
|
||||||
this.translate.getTranslation(userLang);
|
|
||||||
this.translate.use(userLang);
|
|
||||||
}
|
|
||||||
|
|
||||||
hideDrawer() {
|
hideDrawer() {
|
||||||
// todo: workaround for drawer closing
|
// todo: workaround for drawer closing
|
||||||
document.querySelector('.mdl-layout').MaterialLayout.toggleDrawer();
|
document.querySelector('.mdl-layout').MaterialLayout.toggleDrawer();
|
||||||
|
@@ -16,8 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component } from 'angular2/core';
|
import { Component } from 'angular2/core';
|
||||||
import {TranslatePipe} from 'ng2-translate/ng2-translate';
|
import { AlfrescoPipeTranslate } from 'ng2-alfresco-core/services';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ALFRESCO_DATATABLE_DIRECTIVES,
|
ALFRESCO_DATATABLE_DIRECTIVES,
|
||||||
ObjectDataTableAdapter, DataSorting
|
ObjectDataTableAdapter, DataSorting
|
||||||
@@ -30,7 +29,7 @@ declare let __moduleName:string;
|
|||||||
selector: 'datatable-demo',
|
selector: 'datatable-demo',
|
||||||
templateUrl: './datatable-demo.component.html',
|
templateUrl: './datatable-demo.component.html',
|
||||||
directives: [ALFRESCO_DATATABLE_DIRECTIVES],
|
directives: [ALFRESCO_DATATABLE_DIRECTIVES],
|
||||||
pipes: [TranslatePipe]
|
pipes: [AlfrescoPipeTranslate]
|
||||||
})
|
})
|
||||||
export class DataTableDemoComponent {
|
export class DataTableDemoComponent {
|
||||||
data: ObjectDataTableAdapter;
|
data: ObjectDataTableAdapter;
|
||||||
|
@@ -23,7 +23,7 @@ import {
|
|||||||
} from 'ng2-alfresco-documentlist/ng2-alfresco-documentlist';
|
} from 'ng2-alfresco-documentlist/ng2-alfresco-documentlist';
|
||||||
import { MDL } from 'ng2-alfresco-core/material';
|
import { MDL } from 'ng2-alfresco-core/material';
|
||||||
import { ALFRESCO_ULPOAD_COMPONENT } from 'ng2-alfresco-upload/ng2-alfresco-upload';
|
import { ALFRESCO_ULPOAD_COMPONENT } from 'ng2-alfresco-upload/ng2-alfresco-upload';
|
||||||
import { TranslatePipe } from 'ng2-translate/ng2-translate';
|
import { AlfrescoPipeTranslate } from 'ng2-alfresco-core/services';
|
||||||
|
|
||||||
declare let __moduleName: string;
|
declare let __moduleName: string;
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ declare let __moduleName: string;
|
|||||||
templateUrl: './files.component.html',
|
templateUrl: './files.component.html',
|
||||||
directives: [DOCUMENT_LIST_DIRECTIVES, MDL, ALFRESCO_ULPOAD_COMPONENT],
|
directives: [DOCUMENT_LIST_DIRECTIVES, MDL, ALFRESCO_ULPOAD_COMPONENT],
|
||||||
providers: [DOCUMENT_LIST_PROVIDERS],
|
providers: [DOCUMENT_LIST_PROVIDERS],
|
||||||
pipes: [TranslatePipe]
|
pipes: [AlfrescoPipeTranslate]
|
||||||
})
|
})
|
||||||
export class FilesComponent {
|
export class FilesComponent {
|
||||||
breadcrumb: boolean = false;
|
breadcrumb: boolean = false;
|
||||||
|
@@ -24,11 +24,9 @@ export class AuthRouterOutlet extends RouterOutlet {
|
|||||||
publicRoutes: Array<string>;
|
publicRoutes: Array<string>;
|
||||||
private router: Router;
|
private router: Router;
|
||||||
|
|
||||||
constructor(
|
constructor(_elementRef: ElementRef, _loader: DynamicComponentLoader,
|
||||||
_elementRef: ElementRef, _loader: DynamicComponentLoader,
|
|
||||||
_parentRouter: Router, @Attribute('name') nameAttr: string,
|
_parentRouter: Router, @Attribute('name') nameAttr: string,
|
||||||
private authentication: AlfrescoAuthenticationService
|
private authentication: AlfrescoAuthenticationService) {
|
||||||
) {
|
|
||||||
super(_elementRef, _loader, _parentRouter, nameAttr);
|
super(_elementRef, _loader, _parentRouter, nameAttr);
|
||||||
|
|
||||||
this.router = _parentRouter;
|
this.router = _parentRouter;
|
||||||
|
@@ -19,17 +19,13 @@ import { bootstrap } from 'angular2/platform/browser';
|
|||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
import { ROUTER_PROVIDERS } from 'angular2/router';
|
import { ROUTER_PROVIDERS } from 'angular2/router';
|
||||||
import { HTTP_PROVIDERS } from 'angular2/http';
|
import { HTTP_PROVIDERS } from 'angular2/http';
|
||||||
import { TranslateLoader, TranslateService } from 'ng2-translate/ng2-translate';
|
|
||||||
import { ALFRESCO_AUTHENTICATION } from 'ng2-alfresco-login/ng2-alfresco-login';
|
import { ALFRESCO_AUTHENTICATION } from 'ng2-alfresco-login/ng2-alfresco-login';
|
||||||
import { ALFRESCO_CORE_PROVIDERS } from 'ng2-alfresco-core/services';
|
import { ALFRESCO_CORE_PROVIDERS, AlfrescoTranslationService } from 'ng2-alfresco-core/services';
|
||||||
import { AlfrescoTranslationLoader } from 'ng2-alfresco-core/services';
|
|
||||||
import { provide } from 'angular2/core';
|
|
||||||
|
|
||||||
bootstrap(AppComponent, [
|
bootstrap(AppComponent, [
|
||||||
ROUTER_PROVIDERS,
|
ROUTER_PROVIDERS,
|
||||||
HTTP_PROVIDERS,
|
HTTP_PROVIDERS,
|
||||||
provide(TranslateLoader, {useClass: AlfrescoTranslationLoader}),
|
AlfrescoTranslationService,
|
||||||
TranslateService,
|
|
||||||
ALFRESCO_AUTHENTICATION,
|
ALFRESCO_AUTHENTICATION,
|
||||||
ALFRESCO_CORE_PROVIDERS
|
ALFRESCO_CORE_PROVIDERS
|
||||||
]);
|
]);
|
||||||
|
@@ -53,7 +53,6 @@
|
|||||||
"ng2-alfresco-login": "^0.1.0",
|
"ng2-alfresco-login": "^0.1.0",
|
||||||
"ng2-alfresco-search": "^0.1.1",
|
"ng2-alfresco-search": "^0.1.1",
|
||||||
"ng2-alfresco-upload": "^0.1.0",
|
"ng2-alfresco-upload": "^0.1.0",
|
||||||
"ng2-translate": "^1.11.2",
|
|
||||||
"reflect-metadata": "0.1.2",
|
"reflect-metadata": "0.1.2",
|
||||||
"rxjs": "5.0.0-beta.2",
|
"rxjs": "5.0.0-beta.2",
|
||||||
"systemjs": "0.19.26",
|
"systemjs": "0.19.26",
|
||||||
|
@@ -19,11 +19,10 @@
|
|||||||
|
|
||||||
// map tells the System loader where to look for things
|
// map tells the System loader where to look for things
|
||||||
var map = {
|
var map = {
|
||||||
'ng2-uploader': 'node_modules/ng2-uploader',
|
'ng2-alfresco-core': 'node_modules/ng2-alfresco-core/dist',
|
||||||
'ng2-alfresco-core': 'node_modules/ng2-alfresco-core',
|
|
||||||
'ng2-alfresco-datatable': 'node_modules/ng2-alfresco-datatable/dist',
|
'ng2-alfresco-datatable': 'node_modules/ng2-alfresco-datatable/dist',
|
||||||
'ng2-alfresco-documentlist': 'node_modules/ng2-alfresco-documentlist/dist',
|
'ng2-alfresco-documentlist': 'node_modules/ng2-alfresco-documentlist/dist',
|
||||||
'ng2-alfresco-login': 'node_modules/ng2-alfresco-login',
|
'ng2-alfresco-login': 'node_modules/ng2-alfresco-login/dist',
|
||||||
'ng2-alfresco-search': 'node_modules/ng2-alfresco-search/dist',
|
'ng2-alfresco-search': 'node_modules/ng2-alfresco-search/dist',
|
||||||
'ng2-alfresco-upload': 'node_modules/ng2-alfresco-upload/dist',
|
'ng2-alfresco-upload': 'node_modules/ng2-alfresco-upload/dist',
|
||||||
'ng2-translate': 'node_modules/ng2-translate',
|
'ng2-translate': 'node_modules/ng2-translate',
|
||||||
@@ -36,7 +35,6 @@
|
|||||||
format: 'register',
|
format: 'register',
|
||||||
defaultExtension: 'js'
|
defaultExtension: 'js'
|
||||||
},
|
},
|
||||||
'ng2-uploader': {defaultExtension: 'js'},
|
|
||||||
'ng2-alfresco-core': {defaultExtension: 'js'},
|
'ng2-alfresco-core': {defaultExtension: 'js'},
|
||||||
'ng2-alfresco-datatable': {defaultExtension: 'js'},
|
'ng2-alfresco-datatable': {defaultExtension: 'js'},
|
||||||
'ng2-alfresco-documentlist': {defaultExtension: 'js'},
|
'ng2-alfresco-documentlist': {defaultExtension: 'js'},
|
||||||
|
14
ng2-components/ng2-alfresco-core/.npmignore
Normal file
14
ng2-components/ng2-alfresco-core/.npmignore
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
npm-debug.log
|
||||||
|
.idea
|
||||||
|
|
||||||
|
assets/
|
||||||
|
coverage/
|
||||||
|
demo/
|
||||||
|
node_modules
|
||||||
|
typings/
|
||||||
|
src/
|
||||||
|
|
||||||
|
/ng2-alfresco-upload.ts
|
||||||
|
/ng2-alfresco-upload.d.ts
|
||||||
|
/ng2-alfresco-upload.js
|
||||||
|
/ng2-alfresco-upload.js.map
|
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "ng2-alfresco-core",
|
"name": "ng2-alfresco-core",
|
||||||
"description": "Alfresco Angular 2 Components core",
|
"description": "Alfresco Angular 2 Components core",
|
||||||
"version": "0.1.11",
|
"version": "0.1.12",
|
||||||
"author": "Alfresco Software, Ltd.",
|
"author": "Alfresco Software, Ltd.",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"typings": "typings install",
|
"typings": "typings install",
|
||||||
|
@@ -16,20 +16,29 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
import {AlfrescoSettingsService} from './services/AlfrescoSettingsService';
|
import {AlfrescoSettingsService} from './services/AlfrescoSettingsService.service';
|
||||||
import {AlfrescoTranslationLoader} from './services/AlfrescoTranslationService';
|
import {AlfrescoTranslationLoader} from './services/AlfrescoTranslationLoader.service';
|
||||||
export * from './services/AlfrescoSettingsService';
|
import {AlfrescoTranslationService} from './services/AlfrescoTranslationService.service';
|
||||||
export * from './services/AlfrescoTranslationService';
|
import {AlfrescoPipeTranslate} from './services/AlfrescoPipeTranslate.service';
|
||||||
|
|
||||||
|
export * from './services/AlfrescoSettingsService.service';
|
||||||
|
export * from './services/AlfrescoTranslationLoader.service';
|
||||||
|
export * from './services/AlfrescoTranslationService.service';
|
||||||
|
export * from './services/AlfrescoPipeTranslate.service';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
directives: [],
|
directives: [],
|
||||||
providers: [
|
providers: [
|
||||||
AlfrescoSettingsService,
|
AlfrescoSettingsService,
|
||||||
AlfrescoTranslationLoader
|
AlfrescoTranslationLoader,
|
||||||
|
AlfrescoTranslationService,
|
||||||
|
AlfrescoPipeTranslate
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ALFRESCO_CORE_PROVIDERS: [any] = [
|
export const ALFRESCO_CORE_PROVIDERS: [any] = [
|
||||||
AlfrescoSettingsService,
|
AlfrescoSettingsService,
|
||||||
AlfrescoTranslationLoader
|
AlfrescoTranslationLoader,
|
||||||
|
AlfrescoTranslationService,
|
||||||
|
AlfrescoPipeTranslate
|
||||||
];
|
];
|
||||||
|
@@ -0,0 +1,32 @@
|
|||||||
|
/*!
|
||||||
|
* @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, ChangeDetectorRef, Pipe } from 'angular2/core';
|
||||||
|
import { TranslatePipe } from 'ng2-translate/ng2-translate';
|
||||||
|
import { AlfrescoTranslationService } from './AlfrescoTranslationService.service';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
@Pipe({
|
||||||
|
name: 'translate',
|
||||||
|
pure: false // required to update the value when the promise is resolved
|
||||||
|
})
|
||||||
|
export class AlfrescoPipeTranslate extends TranslatePipe {
|
||||||
|
|
||||||
|
constructor(translate: AlfrescoTranslationService, _ref: ChangeDetectorRef) {
|
||||||
|
super(translate, _ref);
|
||||||
|
}
|
||||||
|
}
|
@@ -16,9 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from 'angular2/core';
|
import { Injectable } from 'angular2/core';
|
||||||
import { Http, Response } from 'angular2/http';
|
import { Response, Http } from 'angular2/http';
|
||||||
import { TranslateLoader } from 'ng2-translate/ng2-translate';
|
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
|
import { TranslateLoader } from 'ng2-translate/ng2-translate';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AlfrescoTranslationLoader implements TranslateLoader {
|
export class AlfrescoTranslationLoader implements TranslateLoader {
|
||||||
@@ -49,7 +49,7 @@ export class AlfrescoTranslationLoader implements TranslateLoader {
|
|||||||
translations.forEach((translate) => {
|
translations.forEach((translate) => {
|
||||||
multiLanguage += JSON.stringify(translate);
|
multiLanguage += JSON.stringify(translate);
|
||||||
});
|
});
|
||||||
observer.next(JSON.parse(multiLanguage.replace(/}{/g, '', '')));
|
observer.next(JSON.parse(multiLanguage.replace(/}{/g, ',')));
|
||||||
observer.next(multiLanguage);
|
observer.next(multiLanguage);
|
||||||
observer.complete();
|
observer.complete();
|
||||||
});
|
});
|
@@ -0,0 +1,41 @@
|
|||||||
|
/*!
|
||||||
|
* @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, Optional } from 'angular2/core';
|
||||||
|
import { Http } from 'angular2/http';
|
||||||
|
import { MissingTranslationHandler, TranslateService } from 'ng2-translate/ng2-translate';
|
||||||
|
import { AlfrescoTranslationLoader } from './AlfrescoTranslationLoader.service';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class AlfrescoTranslationService extends TranslateService {
|
||||||
|
|
||||||
|
currentLoader: AlfrescoTranslationLoader;
|
||||||
|
|
||||||
|
constructor(http: Http, currentLoader: AlfrescoTranslationLoader, @Optional() missingTranslationHandler: MissingTranslationHandler) {
|
||||||
|
super(http, currentLoader, missingTranslationHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
translationInit(path: string): void {
|
||||||
|
let userLang = navigator.language.split('-')[0]; // use navigator lang if available
|
||||||
|
userLang = /(fr|en)/gi.test(userLang) ? userLang : 'en';
|
||||||
|
|
||||||
|
this.setDefaultLang(userLang);
|
||||||
|
this.currentLoader.addComponentList(path);
|
||||||
|
this.getTranslation(userLang);
|
||||||
|
this.use(userLang);
|
||||||
|
}
|
||||||
|
}
|
14
ng2-components/ng2-alfresco-login/.npmignore
Normal file
14
ng2-components/ng2-alfresco-login/.npmignore
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
npm-debug.log
|
||||||
|
.idea
|
||||||
|
|
||||||
|
assets/
|
||||||
|
coverage/
|
||||||
|
demo/
|
||||||
|
node_modules
|
||||||
|
typings/
|
||||||
|
src/
|
||||||
|
|
||||||
|
/ng2-alfresco-upload.ts
|
||||||
|
/ng2-alfresco-upload.d.ts
|
||||||
|
/ng2-alfresco-upload.js
|
||||||
|
/ng2-alfresco-upload.js.map
|
@@ -20,19 +20,14 @@ import {MyLoginComponent} from './components/my-login.component';
|
|||||||
import {ALFRESCO_AUTHENTICATION} from 'ng2-alfresco-login/ng2-alfresco-login';
|
import {ALFRESCO_AUTHENTICATION} from 'ng2-alfresco-login/ng2-alfresco-login';
|
||||||
import {ROUTER_PROVIDERS} from 'angular2/router';
|
import {ROUTER_PROVIDERS} from 'angular2/router';
|
||||||
import {provide} from 'angular2/core';
|
import {provide} from 'angular2/core';
|
||||||
import {Http} from 'angular2/http';
|
|
||||||
import {HTTP_PROVIDERS} from 'angular2/http';
|
import {HTTP_PROVIDERS} from 'angular2/http';
|
||||||
import {TranslateService, TranslateLoader, TranslateStaticLoader} from 'ng2-translate/ng2-translate';
|
import {TranslateService, TranslateLoader} from 'ng2-translate/ng2-translate';
|
||||||
import {ALFRESCO_CORE_PROVIDERS} from 'ng2-alfresco-core/services';
|
import {ALFRESCO_CORE_PROVIDERS, AlfrescoTranslationService} from 'ng2-alfresco-core/services';
|
||||||
|
|
||||||
bootstrap(MyLoginComponent, [
|
bootstrap(MyLoginComponent, [
|
||||||
ROUTER_PROVIDERS,
|
ROUTER_PROVIDERS,
|
||||||
HTTP_PROVIDERS,
|
HTTP_PROVIDERS,
|
||||||
provide(TranslateLoader, {
|
provide(TranslateLoader, {useClass: AlfrescoTranslationService}),
|
||||||
useFactory: (http: Http) => new TranslateStaticLoader(http, 'node_modules/ng2-alfresco-login/i18n', '.json'),
|
|
||||||
deps: [Http]
|
|
||||||
}),
|
|
||||||
// use TranslateService here, and not TRANSLATE_PROVIDERS (which will define a default TranslateStaticLoader)
|
|
||||||
TranslateService,
|
TranslateService,
|
||||||
ALFRESCO_AUTHENTICATION,
|
ALFRESCO_AUTHENTICATION,
|
||||||
ALFRESCO_CORE_PROVIDERS
|
ALFRESCO_CORE_PROVIDERS
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "ng2-alfresco-login",
|
"name": "ng2-alfresco-login",
|
||||||
"description": "Alfresco Angular2 Login Component",
|
"description": "Alfresco Angular2 Login Component",
|
||||||
"version": "0.1.3",
|
"version": "0.1.4",
|
||||||
"author": "Alfresco Software, Ltd.",
|
"author": "Alfresco Software, Ltd.",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"typings": "typings install",
|
"typings": "typings install",
|
||||||
@@ -57,13 +57,13 @@
|
|||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"angular2": "2.0.0-beta.15",
|
"angular2": "2.0.0-beta.15",
|
||||||
"systemjs": "0.19.26",
|
|
||||||
"es6-shim": "^0.35.0",
|
|
||||||
"es6-module-loader": "^0.17.8",
|
"es6-module-loader": "^0.17.8",
|
||||||
|
"es6-shim": "^0.35.0",
|
||||||
|
"ng2-alfresco-core": "^0.1.7",
|
||||||
"reflect-metadata": "0.1.2",
|
"reflect-metadata": "0.1.2",
|
||||||
"rxjs": "5.0.0-beta.2",
|
"rxjs": "5.0.0-beta.2",
|
||||||
"zone.js": "^0.6.12",
|
"systemjs": "0.19.26",
|
||||||
"ng2-translate": "^1.11.2"
|
"zone.js": "^0.6.12"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"angular2": "2.0.0-beta.15"
|
"angular2": "2.0.0-beta.15"
|
||||||
|
@@ -19,7 +19,7 @@ import { Component, Output, EventEmitter } from 'angular2/core';
|
|||||||
import { Router, ROUTER_DIRECTIVES } from 'angular2/router';
|
import { Router, ROUTER_DIRECTIVES } from 'angular2/router';
|
||||||
import { FORM_DIRECTIVES, ControlGroup, FormBuilder, Validators } from 'angular2/common';
|
import { FORM_DIRECTIVES, ControlGroup, FormBuilder, Validators } from 'angular2/common';
|
||||||
import { AlfrescoAuthenticationService } from './../services/alfresco-authentication.service';
|
import { AlfrescoAuthenticationService } from './../services/alfresco-authentication.service';
|
||||||
import { TranslateService, TranslatePipe } from 'ng2-translate/ng2-translate';
|
import { AlfrescoTranslationService, AlfrescoPipeTranslate } from 'ng2-alfresco-core/services';
|
||||||
declare let componentHandler: any;
|
declare let componentHandler: any;
|
||||||
declare let __moduleName: string;
|
declare let __moduleName: string;
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ declare let __moduleName: string;
|
|||||||
directives: [ROUTER_DIRECTIVES, FORM_DIRECTIVES],
|
directives: [ROUTER_DIRECTIVES, FORM_DIRECTIVES],
|
||||||
templateUrl: './alfresco-login.component.html',
|
templateUrl: './alfresco-login.component.html',
|
||||||
styleUrls: ['./alfresco-login.component.css'],
|
styleUrls: ['./alfresco-login.component.css'],
|
||||||
pipes: [TranslatePipe]
|
pipes: [AlfrescoPipeTranslate]
|
||||||
|
|
||||||
})
|
})
|
||||||
export class AlfrescoLoginComponent {
|
export class AlfrescoLoginComponent {
|
||||||
@@ -37,7 +37,6 @@ export class AlfrescoLoginComponent {
|
|||||||
onSuccess = new EventEmitter();
|
onSuccess = new EventEmitter();
|
||||||
@Output()
|
@Output()
|
||||||
onError = new EventEmitter();
|
onError = new EventEmitter();
|
||||||
translate: TranslateService;
|
|
||||||
|
|
||||||
form: ControlGroup;
|
form: ControlGroup;
|
||||||
error: boolean = false;
|
error: boolean = false;
|
||||||
@@ -57,7 +56,7 @@ export class AlfrescoLoginComponent {
|
|||||||
constructor(private _fb: FormBuilder,
|
constructor(private _fb: FormBuilder,
|
||||||
public auth: AlfrescoAuthenticationService,
|
public auth: AlfrescoAuthenticationService,
|
||||||
public router: Router,
|
public router: Router,
|
||||||
translate: TranslateService) {
|
private translate: AlfrescoTranslationService) {
|
||||||
|
|
||||||
this.formError = {
|
this.formError = {
|
||||||
'username': '',
|
'username': '',
|
||||||
@@ -79,6 +78,8 @@ export class AlfrescoLoginComponent {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
translate.translationInit('node_modules/ng2-alfresco-login');
|
||||||
|
|
||||||
this.form.valueChanges.subscribe(data => this.onValueChanged(data));
|
this.form.valueChanges.subscribe(data => this.onValueChanged(data));
|
||||||
|
|
||||||
this.onValueChanged(null);
|
this.onValueChanged(null);
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "ng2-alfresco-upload",
|
"name": "ng2-alfresco-upload",
|
||||||
"description": "Alfresco Angular2 Upload Component",
|
"description": "Alfresco Angular2 Upload Component",
|
||||||
"version": "0.1.2",
|
"version": "0.1.3",
|
||||||
"author": "Alfresco Software, Ltd.",
|
"author": "Alfresco Software, Ltd.",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"typings": "typings install",
|
"typings": "typings install",
|
||||||
@@ -51,7 +51,6 @@
|
|||||||
"es6-module-loader": "^0.17.8",
|
"es6-module-loader": "^0.17.8",
|
||||||
"es6-shim": "^0.35.0",
|
"es6-shim": "^0.35.0",
|
||||||
"ng2-alfresco-core": "^0.1.0",
|
"ng2-alfresco-core": "^0.1.0",
|
||||||
"ng2-translate": "^1.11.2",
|
|
||||||
"reflect-metadata": "0.1.2",
|
"reflect-metadata": "0.1.2",
|
||||||
"rxjs": "5.0.0-beta.2",
|
"rxjs": "5.0.0-beta.2",
|
||||||
"systemjs": "0.19.26",
|
"systemjs": "0.19.26",
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
import { Component, ElementRef, Input } from 'angular2/core';
|
import { Component, ElementRef, Input } from 'angular2/core';
|
||||||
import { FileModel } from '../models/file.model';
|
import { FileModel } from '../models/file.model';
|
||||||
import { FileUploadingListComponent } from './file-uploading-list.component';
|
import { FileUploadingListComponent } from './file-uploading-list.component';
|
||||||
import { TranslatePipe } from 'ng2-translate/ng2-translate';
|
import { AlfrescoPipeTranslate } from 'ng2-alfresco-core/services';
|
||||||
|
|
||||||
declare let __moduleName: string;
|
declare let __moduleName: string;
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ declare let __moduleName: string;
|
|||||||
templateUrl: './file-uploading-dialog.component.html',
|
templateUrl: './file-uploading-dialog.component.html',
|
||||||
styleUrls: ['./file-uploading-dialog.component.css'],
|
styleUrls: ['./file-uploading-dialog.component.css'],
|
||||||
host: {'[class.dialog-show]': 'toggleShowDialog'},
|
host: {'[class.dialog-show]': 'toggleShowDialog'},
|
||||||
pipes: [TranslatePipe]
|
pipes: [AlfrescoPipeTranslate]
|
||||||
})
|
})
|
||||||
export class FileUploadingDialogComponent {
|
export class FileUploadingDialogComponent {
|
||||||
|
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
import { Component, ElementRef, Input } from 'angular2/core';
|
import { Component, ElementRef, Input } from 'angular2/core';
|
||||||
import { FileModel } from '../models/file.model';
|
import { FileModel } from '../models/file.model';
|
||||||
import { TranslatePipe } from 'ng2-translate/ng2-translate';
|
import { AlfrescoPipeTranslate } from 'ng2-alfresco-core/services';
|
||||||
|
|
||||||
declare let __moduleName: string;
|
declare let __moduleName: string;
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ declare let __moduleName: string;
|
|||||||
moduleId: __moduleName,
|
moduleId: __moduleName,
|
||||||
templateUrl: './file-uploading-list.component.html',
|
templateUrl: './file-uploading-list.component.html',
|
||||||
styleUrls: ['./file-uploading-list.component.css'],
|
styleUrls: ['./file-uploading-list.component.css'],
|
||||||
pipes: [TranslatePipe]
|
pipes: [AlfrescoPipeTranslate]
|
||||||
})
|
})
|
||||||
export class FileUploadingListComponent {
|
export class FileUploadingListComponent {
|
||||||
|
|
||||||
|
@@ -20,7 +20,7 @@ import { Component, ViewChild, ElementRef, Input, Output, EventEmitter, Optional
|
|||||||
import { UploadService } from '../services/upload.service';
|
import { UploadService } from '../services/upload.service';
|
||||||
import { FileModel } from '../models/file.model';
|
import { FileModel } from '../models/file.model';
|
||||||
import { FileUploadingDialogComponent } from './file-uploading-dialog.component';
|
import { FileUploadingDialogComponent } from './file-uploading-dialog.component';
|
||||||
import { TranslateService, TranslatePipe } from 'ng2-translate/ng2-translate';
|
import { AlfrescoTranslationService, AlfrescoPipeTranslate } from 'ng2-alfresco-core/services';
|
||||||
import 'rxjs/Rx';
|
import 'rxjs/Rx';
|
||||||
|
|
||||||
declare let componentHandler: any;
|
declare let componentHandler: any;
|
||||||
@@ -51,7 +51,7 @@ declare let __moduleName: string;
|
|||||||
directives: [FileUploadingDialogComponent],
|
directives: [FileUploadingDialogComponent],
|
||||||
templateUrl: './upload-button.component.html',
|
templateUrl: './upload-button.component.html',
|
||||||
styleUrls: ['./upload-button.component.css'],
|
styleUrls: ['./upload-button.component.css'],
|
||||||
pipes: [TranslatePipe]
|
pipes: [AlfrescoPipeTranslate]
|
||||||
})
|
})
|
||||||
export class UploadButtonComponent {
|
export class UploadButtonComponent {
|
||||||
|
|
||||||
@@ -87,12 +87,12 @@ export class UploadButtonComponent {
|
|||||||
|
|
||||||
filesUploadingList: FileModel [] = [];
|
filesUploadingList: FileModel [] = [];
|
||||||
|
|
||||||
translate: TranslateService;
|
translate: AlfrescoTranslationService;
|
||||||
|
|
||||||
private _uploaderService: UploadService;
|
private _uploaderService: UploadService;
|
||||||
|
|
||||||
constructor(public el: ElementRef,
|
constructor(public el: ElementRef,
|
||||||
@Optional() translate: TranslateService) {
|
@Optional() translate: AlfrescoTranslationService) {
|
||||||
console.log('UploadComponent constructor', el);
|
console.log('UploadComponent constructor', el);
|
||||||
|
|
||||||
let site = this.getSiteId();
|
let site = this.getSiteId();
|
||||||
@@ -106,9 +106,7 @@ export class UploadButtonComponent {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (translate) {
|
translate.translationInit('node_modules/ng2-alfresco-upload');
|
||||||
this.translationInit(translate);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -131,21 +129,6 @@ export class UploadButtonComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Initial configuration for Multi language
|
|
||||||
* @param translate
|
|
||||||
*/
|
|
||||||
translationInit(translate: TranslateService) {
|
|
||||||
this.translate = translate;
|
|
||||||
let userLang = navigator.language.split('-')[0]; // use navigator lang if available
|
|
||||||
userLang = /(fr|en)/gi.test(userLang) ? userLang : 'en';
|
|
||||||
|
|
||||||
this.translate.setDefaultLang(userLang);
|
|
||||||
this.translate.currentLoader.addComponentList('node_modules/ng2-alfresco-upload');
|
|
||||||
this.translate.getTranslation(userLang);
|
|
||||||
this.translate.use(userLang);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show undo notification bar.
|
* Show undo notification bar.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user