diff --git a/demo-shell-ng2/app/app.component.ts b/demo-shell-ng2/app/app.component.ts index 02c5f246e1..8cebbc16f7 100644 --- a/demo-shell-ng2/app/app.component.ts +++ b/demo-shell-ng2/app/app.component.ts @@ -18,14 +18,14 @@ import { Component } from 'angular2/core'; import { ControlGroup, FormBuilder, Validators } from 'angular2/common'; import { Router, RouteConfig, ROUTER_DIRECTIVES } from 'angular2/router'; -import { MDL } from 'ng2-alfresco-core/material'; +import { MDL } from 'ng2-alfresco-core/dist/ng2-alfresco-core'; import { FilesComponent } from './components/files/files.component'; -import { AlfrescoLoginComponent, AlfrescoAuthenticationService } from 'ng2-alfresco-login/ng2-alfresco-login'; +import { AlfrescoLoginComponent, AlfrescoAuthenticationService } from 'ng2-alfresco-login/dist/ng2-alfresco-login'; import { AuthRouterOutlet } from './components/router/AuthRouterOutlet'; -import { AlfrescoSettingsService, AlfrescoTranslationService, AlfrescoPipeTranslate } from 'ng2-alfresco-core/services'; -import { UploadButtonComponent } from 'ng2-alfresco-upload/ng2-alfresco-upload'; +import { AlfrescoSettingsService, AlfrescoTranslationService, AlfrescoPipeTranslate } 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/ng2-alfresco-search'; +import { AlfrescoSearchComponent } from 'ng2-alfresco-search/dist/ng2-alfresco-search'; declare var document: any; diff --git a/demo-shell-ng2/app/components/datatable/datatable-demo.component.ts b/demo-shell-ng2/app/components/datatable/datatable-demo.component.ts index c2b0ddbd15..30a19ecf84 100644 --- a/demo-shell-ng2/app/components/datatable/datatable-demo.component.ts +++ b/demo-shell-ng2/app/components/datatable/datatable-demo.component.ts @@ -16,14 +16,14 @@ */ import { Component } from 'angular2/core'; -import { AlfrescoPipeTranslate } from 'ng2-alfresco-core/services'; +import { AlfrescoPipeTranslate } from 'ng2-alfresco-core/dist/ng2-alfresco-core'; import { ALFRESCO_DATATABLE_DIRECTIVES, ObjectDataTableAdapter, DataSorting, ObjectDataRow, ObjectDataColumn -} from 'ng2-alfresco-datatable/ng2-alfresco-datatable'; +} from 'ng2-alfresco-datatable/dist/ng2-alfresco-datatable'; declare let __moduleName: string; diff --git a/demo-shell-ng2/app/components/files/files.component.ts b/demo-shell-ng2/app/components/files/files.component.ts index 83e7f01ccb..ae5a99b003 100644 --- a/demo-shell-ng2/app/components/files/files.component.ts +++ b/demo-shell-ng2/app/components/files/files.component.ts @@ -20,10 +20,10 @@ import { DOCUMENT_LIST_DIRECTIVES, DOCUMENT_LIST_PROVIDERS, DocumentActionsService -} from 'ng2-alfresco-documentlist/ng2-alfresco-documentlist'; -import { MDL } from 'ng2-alfresco-core/material'; -import { ALFRESCO_ULPOAD_COMPONENT } from 'ng2-alfresco-upload/ng2-alfresco-upload'; -import { AlfrescoPipeTranslate } from 'ng2-alfresco-core/services'; +} from 'ng2-alfresco-documentlist/dist/ng2-alfresco-documentlist'; +import { MDL } from 'ng2-alfresco-core/dist/ng2-alfresco-core'; +import { ALFRESCO_ULPOAD_COMPONENTS } from 'ng2-alfresco-upload/dist/ng2-alfresco-upload'; +import { AlfrescoPipeTranslate } from 'ng2-alfresco-core/dist/ng2-alfresco-core'; declare let __moduleName: string; @@ -31,7 +31,7 @@ declare let __moduleName: string; moduleId: __moduleName, selector: 'files-component', templateUrl: './files.component.html', - directives: [DOCUMENT_LIST_DIRECTIVES, MDL, ALFRESCO_ULPOAD_COMPONENT], + directives: [DOCUMENT_LIST_DIRECTIVES, MDL, ALFRESCO_ULPOAD_COMPONENTS], providers: [DOCUMENT_LIST_PROVIDERS], pipes: [AlfrescoPipeTranslate] }) @@ -58,7 +58,7 @@ export class FilesComponent { alert('Custom folder action for ' + event.value.displayName); } - refreshDirectyory(event: Object) { + refreshDirectyory(event: any) { this.absolutePath = event.value; this.relativePath = this.getRelativeDirectory(this.absolutePath); } diff --git a/demo-shell-ng2/app/components/router/AuthRouterOutlet.ts b/demo-shell-ng2/app/components/router/AuthRouterOutlet.ts index d68e939d22..d1f9f894df 100644 --- a/demo-shell-ng2/app/components/router/AuthRouterOutlet.ts +++ b/demo-shell-ng2/app/components/router/AuthRouterOutlet.ts @@ -16,7 +16,7 @@ */ import { ElementRef, DynamicComponentLoader, Directive, Attribute } from 'angular2/core'; import { Router, RouterOutlet, ComponentInstruction } from 'angular2/router'; -import { AlfrescoAuthenticationService } from 'ng2-alfresco-login/ng2-alfresco-login'; +import { AlfrescoAuthenticationService } from 'ng2-alfresco-login/dist/ng2-alfresco-login'; @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 f2448b3822..fa1bc43c4c 100644 --- a/demo-shell-ng2/app/main.ts +++ b/demo-shell-ng2/app/main.ts @@ -19,9 +19,9 @@ 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/ng2-alfresco-login'; -import { ALFRESCO_CORE_PROVIDERS, AlfrescoTranslationService } from 'ng2-alfresco-core/services'; -import { UploadService } from 'ng2-alfresco-upload/ng2-alfresco-upload'; +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 { UploadService } from 'ng2-alfresco-upload/dist/ng2-alfresco-upload'; bootstrap(AppComponent, [ ROUTER_PROVIDERS, diff --git a/demo-shell-ng2/systemjs.config.js b/demo-shell-ng2/systemjs.config.js index a975ea90ae..4a6ac9eb70 100644 --- a/demo-shell-ng2/systemjs.config.js +++ b/demo-shell-ng2/systemjs.config.js @@ -19,13 +19,12 @@ // map tells the System loader where to look for things var map = { - 'ng2-alfresco-core': 'node_modules/ng2-alfresco-core/dist', - 'ng2-alfresco-datatable': 'node_modules/ng2-alfresco-datatable/dist', - 'ng2-alfresco-documentlist': 'node_modules/ng2-alfresco-documentlist/dist', - 'ng2-alfresco-login': 'node_modules/ng2-alfresco-login/dist', - 'ng2-alfresco-search': 'node_modules/ng2-alfresco-search/dist', - 'ng2-alfresco-upload': 'node_modules/ng2-alfresco-upload/dist', - 'ng2-translate': 'node_modules/ng2-translate', + 'ng2-alfresco-core': 'node_modules/ng2-alfresco-core', + 'ng2-alfresco-datatable': 'node_modules/ng2-alfresco-datatable', + 'ng2-alfresco-documentlist': 'node_modules/ng2-alfresco-documentlist', + 'ng2-alfresco-login': 'node_modules/ng2-alfresco-login', + 'ng2-alfresco-search': 'node_modules/ng2-alfresco-search', + 'ng2-alfresco-upload': 'node_modules/ng2-alfresco-upload', 'rxjs': 'node_modules/rxjs' }; @@ -41,7 +40,6 @@ 'ng2-alfresco-login': {defaultExtension: 'js'}, 'ng2-alfresco-search': {defaultExtension: 'js'}, 'ng2-alfresco-upload': {defaultExtension: 'js'}, - 'ng2-translate': {defaultExtension: 'js'}, 'rxjs': {defaultExtension: 'js'} }; diff --git a/ng2-components/ng2-alfresco-core/.gitignore b/ng2-components/ng2-alfresco-core/.gitignore index 0184de8cd0..ffbd7bdbbe 100644 --- a/ng2-components/ng2-alfresco-core/.gitignore +++ b/ng2-components/ng2-alfresco-core/.gitignore @@ -8,17 +8,8 @@ dist src/**/*.js src/**/*.js.map src/**/*.d.ts - -material.js -material.js.map -material/**/*.js -material/**/*.js.map - -services.js -services.js.map -services/**/*.js -services/**/*.js.map - demo/**/*.js demo/**/*.js.map demo/**/*.d.ts +ng2-alfresco-core.js +ng2-alfresco-core.js.map diff --git a/ng2-components/ng2-alfresco-core/.npmignore b/ng2-components/ng2-alfresco-core/.npmignore index da0fb078c2..71379e3e57 100644 --- a/ng2-components/ng2-alfresco-core/.npmignore +++ b/ng2-components/ng2-alfresco-core/.npmignore @@ -7,8 +7,12 @@ demo/ node_modules typings/ src/ +fonts/ -/ng2-alfresco-upload.ts -/ng2-alfresco-upload.d.ts -/ng2-alfresco-upload.js -/ng2-alfresco-upload.js.map +/.editorconfig +/.travis.yml +/*.js +/*.json +/*.ts +/*.js.map +/.npmignore diff --git a/ng2-components/ng2-alfresco-core/karma.conf.js b/ng2-components/ng2-alfresco-core/karma.conf.js index b179011187..8b13414128 100644 --- a/ng2-components/ng2-alfresco-core/karma.conf.js +++ b/ng2-components/ng2-alfresco-core/karma.conf.js @@ -26,8 +26,7 @@ module.exports = function (config) { {pattern: 'dist/**/*.css', included: true, served: true, watched: true}, // paths to support debugging with source maps in dev tools - {pattern: 'services/**/*.ts', included: false, watched: false}, - {pattern: 'material/**/*.ts', included: false, watched: false}, + {pattern: 'src/**/*.ts', included: false, watched: false}, {pattern: 'dist/**/*.js.map', included: false, watched: false} ], @@ -75,6 +74,6 @@ module.exports = function (config) { ] }, - singleRun: false + singleRun: true }) }; diff --git a/ng2-components/ng2-alfresco-core/material.ts b/ng2-components/ng2-alfresco-core/material.ts deleted file mode 100644 index b168a54bc0..0000000000 --- a/ng2-components/ng2-alfresco-core/material.ts +++ /dev/null @@ -1,18 +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. - */ - -export * from './material/MaterialDesignLiteUpgradeElement'; diff --git a/ng2-components/ng2-alfresco-core/services.ts b/ng2-components/ng2-alfresco-core/ng2-alfresco-core.ts similarity index 58% rename from ng2-components/ng2-alfresco-core/services.ts rename to ng2-components/ng2-alfresco-core/ng2-alfresco-core.ts index ebe5f9d346..2b0c6fddd0 100644 --- a/ng2-components/ng2-alfresco-core/services.ts +++ b/ng2-components/ng2-alfresco-core/ng2-alfresco-core.ts @@ -16,18 +16,18 @@ */ -import {AlfrescoSettingsService} from './services/AlfrescoSettingsService.service'; -import {AlfrescoTranslationLoader} from './services/AlfrescoTranslationLoader.service'; -import {AlfrescoTranslationService} from './services/AlfrescoTranslationService.service'; -import {AlfrescoPipeTranslate} from './services/AlfrescoPipeTranslate.service'; +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'; -export * from './services/AlfrescoSettingsService.service'; -export * from './services/AlfrescoTranslationLoader.service'; -export * from './services/AlfrescoTranslationService.service'; -export * from './services/AlfrescoPipeTranslate.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 { - directives: [], providers: [ AlfrescoSettingsService, AlfrescoTranslationLoader, @@ -42,3 +42,4 @@ export const ALFRESCO_CORE_PROVIDERS: [any] = [ AlfrescoTranslationService, AlfrescoPipeTranslate ]; + diff --git a/ng2-components/ng2-alfresco-core/package.json b/ng2-components/ng2-alfresco-core/package.json index 9068cb4728..9d95509718 100644 --- a/ng2-components/ng2-alfresco-core/package.json +++ b/ng2-components/ng2-alfresco-core/package.json @@ -1,15 +1,14 @@ { "name": "ng2-alfresco-core", "description": "Alfresco Angular 2 Components core", - "version": "0.1.13", + "version": "0.1.17", "author": "Alfresco Software, Ltd.", "scripts": { "typings": "typings install", "start": "npm run test && http-server -c-1 -o -p 8875 .", "build": "npm run tslint && typings install && rm -rf dist && tsc && npm run copytemplates && license-check", - "tslint": "npm run tslint-service && npm run tslint-material && npm run tslint-root", - "tslint-service": "tslint -c tslint.json services/**/*.ts", - "tslint-material": "tslint -c tslint.json material/**/*.ts", + "tslint": "npm run tslint-src && npm run tslint-root", + "tslint-src": "tslint -c tslint.json src/**/*.ts", "tslint-root": "tslint -c tslint.json *.ts", "copytemplates": "npm run copy-html && npm run copy-css && npm run copy-i18n", "copy-html": "copyfiles './src/**/*.html' dist", @@ -51,7 +50,6 @@ "angular2": "2.0.0-beta.15", "es6-module-loader": "^0.17.8", "es6-shim": "^0.35.0", - "ng2-translate": "^1.11.3", "reflect-metadata": "0.1.2", "rxjs": "5.0.0-beta.2", "systemjs": "0.19.26", diff --git a/ng2-components/ng2-alfresco-core/services/AlfrescoPipeTranslate.service.ts b/ng2-components/ng2-alfresco-core/services/AlfrescoPipeTranslate.service.ts deleted file mode 100644 index bc6b17f1f0..0000000000 --- a/ng2-components/ng2-alfresco-core/services/AlfrescoPipeTranslate.service.ts +++ /dev/null @@ -1,32 +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, 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); - } -} diff --git a/ng2-components/ng2-alfresco-core/services/AlfrescoTranslationService.service.ts b/ng2-components/ng2-alfresco-core/services/AlfrescoTranslationService.service.ts deleted file mode 100644 index 6403dc8c38..0000000000 --- a/ng2-components/ng2-alfresco-core/services/AlfrescoTranslationService.service.ts +++ /dev/null @@ -1,45 +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, 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 { - userLang: string = 'en' ; - currentLoader: AlfrescoTranslationLoader; - - constructor(http: Http, currentLoader: AlfrescoTranslationLoader, @Optional() missingTranslationHandler: MissingTranslationHandler) { - super(http, currentLoader, missingTranslationHandler); - } - - translationInit(name: string = ''): void { - let userLang = navigator.language.split('-')[0]; // use navigator lang if available - userLang = /(fr|en)/gi.test(userLang) ? userLang : 'en'; - this.userLang = userLang; - this.setDefaultLang(this.userLang); - this.addComponent(name); - this.use(this.userLang); - } - - addComponent(name: string) { - this.currentLoader.addComponentList(name); - this.getTranslation(this.userLang); - } -} diff --git a/ng2-components/ng2-alfresco-core/material/MaterialDesignLiteUpgradeElement.ts b/ng2-components/ng2-alfresco-core/src/material/MaterialDesignLiteUpgradeElement.ts similarity index 100% rename from ng2-components/ng2-alfresco-core/material/MaterialDesignLiteUpgradeElement.ts rename to ng2-components/ng2-alfresco-core/src/material/MaterialDesignLiteUpgradeElement.ts diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoPipeTranslate.service.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoPipeTranslate.service.ts new file mode 100644 index 0000000000..02a109db98 --- /dev/null +++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoPipeTranslate.service.ts @@ -0,0 +1,166 @@ +/*! + * @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 { PipeTransform, Pipe, Injectable, EventEmitter, OnDestroy, ChangeDetectorRef } from 'angular2/core'; +import { AlfrescoTranslationService, LangChangeEvent } from './AlfrescoTranslationService.service'; +import { isPresent, isArray } from 'angular2/src/facade/lang'; + +@Injectable() +@Pipe({ + name: 'translate', + pure: false // required to update the value when the promise is resolved +}) +export class AlfrescoPipeTranslate implements PipeTransform, OnDestroy { + value: string = ''; + lastKey: string; + lastParams: any[]; + onLangChange: EventEmitter; + + constructor(private translate: AlfrescoTranslationService, private _ref: ChangeDetectorRef) { + } + + /** + * @name equals + * + * @description + * Determines if two objects or two values are equivalent. + * + * Two objects or values are considered equivalent if at least one of the following is true: + * + * * Both objects or values pass `===` comparison. + * * Both objects or values are of the same type and all of their properties are equal by + * comparing them with `equals`. + * + * @param {*} o1 Object or value to compare. + * @param {*} o2 Object or value to compare. + * @returns {boolean} True if arguments are equal. + */ + private equals(o1: any, o2: any): boolean { + if (o1 === o2) { + return true; + } + if (o1 === null || o2 === null) { + return false; + } + if (o1 !== o1 && o2 !== o2) { + return true; + } // NaN === NaN + let t1 = typeof o1, t2 = typeof o2, length: number, key: any, keySet: any; + if (t1 === t2 && t1 === 'object') { + if (isArray(o1)) { + if (!isArray(o2)) { + return false; + } + length = o1.length; + if (length === o2.length) { + for (key = 0; key < length; key++) { + if (!this.equals(o1[key], o2[key])) { + return false; + } + } + return true; + } + } else { + if (isArray(o2)) { + return false; + } + keySet = Object.create(null); + for (key in o1) { + if (key) { + if (!this.equals(o1[key], o2[key])) { + return false; + } + keySet[key] = true; + } + } + for (key in o2) { + if (!(key in keySet) && typeof o2[key] !== 'undefined') { + return false; + } + } + return true; + } + } + return false; + } + + updateValue(key: string, interpolateParams?: Object): void { + this.translate.get(key, interpolateParams).subscribe((res: string) => { + this.value = res ? res : key; + this._ref.markForCheck(); + }); + } + + transform(query: string, ...args: any[]): any { + if (!query || query.length === 0) { + return query; + } + // if we ask another time for the same key, return the last value + if (this.equals(query, this.lastKey) && this.equals(args, this.lastParams)) { + return this.value; + } + + let interpolateParams: Object; + if (args.length && args[0] !== null) { + if (typeof args[0] === 'string' && args[0].length) { + // we accept objects written in the template such as {n:1}, + // which is why we might need to change it to real JSON objects such as {"n":1} + try { + interpolateParams = JSON.parse(args[0].replace(/(['"])?([a-zA-Z0-9_]+)(['"])?:/g, '"$2": ')); + } catch (e) { + throw new SyntaxError(`Wrong parameter in TranslatePipe. Expected a valid Object, received: ${args[0]}`); + } + } else if (typeof args[0] === 'object' && !Array.isArray(args[0])) { + interpolateParams = args[0]; + } + } + + // store the query, in case it changes + this.lastKey = query; + + // store the params, in case they change + this.lastParams = args; + + // set the value + this.updateValue(query, interpolateParams); + + // if there is a subscription to onLangChange, clean it + this._dispose(); + + // subscribe to onLangChange event, in case the language changes + this.onLangChange = this.translate.onLangChange.subscribe((event: LangChangeEvent) => { + this.updateValue(query, interpolateParams); + }); + + return this.value; + } + + /** + * Clean any existing subscription to onLangChange events + * @private + */ + _dispose(): void { + if (isPresent(this.onLangChange)) { + this.onLangChange.unsubscribe(); + this.onLangChange = undefined; + } + } + + ngOnDestroy(): void { + this._dispose(); + } +} diff --git a/ng2-components/ng2-alfresco-core/services/AlfrescoSettingsService.service.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoSettingsService.service.ts similarity index 100% rename from ng2-components/ng2-alfresco-core/services/AlfrescoSettingsService.service.ts rename to ng2-components/ng2-alfresco-core/src/services/AlfrescoSettingsService.service.ts diff --git a/ng2-components/ng2-alfresco-core/services/AlfrescoTranslationLoader.service.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoTranslationLoader.service.ts similarity index 96% rename from ng2-components/ng2-alfresco-core/services/AlfrescoTranslationLoader.service.ts rename to ng2-components/ng2-alfresco-core/src/services/AlfrescoTranslationLoader.service.ts index d3520bfeb9..9cc83c32ea 100644 --- a/ng2-components/ng2-alfresco-core/services/AlfrescoTranslationLoader.service.ts +++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoTranslationLoader.service.ts @@ -18,7 +18,7 @@ import { Injectable } from 'angular2/core'; import { Response, Http } from 'angular2/http'; import { Observable } from 'rxjs/Observable'; -import { TranslateLoader } from 'ng2-translate/ng2-translate'; +import { TranslateLoader } from './AlfrescoTranslationService.service'; @Injectable() export class AlfrescoTranslationLoader implements TranslateLoader { diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoTranslationService.service.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoTranslationService.service.ts new file mode 100644 index 0000000000..a9f9cba646 --- /dev/null +++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoTranslationService.service.ts @@ -0,0 +1,348 @@ +/*! + * @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, EventEmitter } from 'angular2/core'; +import { AlfrescoTranslationLoader } from './AlfrescoTranslationLoader.service'; +import { Http, Response } from 'angular2/http'; +import { Observable } from 'rxjs/Observable'; +import { Observer } from 'rxjs/Observer'; +import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/share'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/merge'; +import 'rxjs/add/operator/toArray'; + +import { Parser } from './translate.parser'; + +export interface LangChangeEvent { + lang: string; + translations: any; +} + +export abstract class MissingTranslationHandler { + /** + * A function that handles missing translations. + * @param key the missing key + * @returns {any} a value or an observable + * If it returns a value, then this value is used. + * If it return an observable, the value returned by this observable will be used (except if the method was "instant"). + * If it doesn't return then the key will be used as a value + */ + abstract handle(key: string): any; +} + +export abstract class TranslateLoader { + abstract getTranslation(lang: string): Observable; +} + +export class TranslateStaticLoader implements TranslateLoader { + constructor(private http: Http, private prefix: string = 'i18n', private suffix: string = '.json') { + } + + /** + * Gets the translations from the server + * @param lang + * @returns {any} + */ + public getTranslation(lang: string): Observable { + return this.http.get(`${this.prefix}/${lang}${this.suffix}`) + .map((res: Response) => res.json()); + } +} + +@Injectable() +export class AlfrescoTranslationService { + /** + * The lang currently used + */ + public currentLang: string = this.defaultLang; + + /** + * An EventEmitter to listen to lang changes events + * onLangChange.subscribe((params: LangChangeEvent) => { + * // do something + * }); + * @type {ng.EventEmitter} + */ + public onLangChange: EventEmitter = new EventEmitter(); + + private pending: any; + private translations: any = {}; + private defaultLang: string; + private langs: Array; + private parser: Parser = new Parser(); + + userLang: string = 'en'; + + /** + * + * @param http The Angular 2 http provider + * @param currentLoader An instance of the loader currently used + * @param missingTranslationHandler A handler for missing translations. + */ + constructor(private http: Http, public currentLoader: AlfrescoTranslationLoader, @Optional() + private missingTranslationHandler: MissingTranslationHandler) { + } + + translationInit(name: string = ''): void { + let userLang = navigator.language.split('-')[0]; // use navigator lang if available + userLang = /(fr|en)/gi.test(userLang) ? userLang : 'en'; + this.userLang = userLang; + this.setDefaultLang(this.userLang); + this.addComponent(name); + this.use(this.userLang); + } + + addComponent(name: string) { + this.currentLoader.addComponentList(name); + this.getTranslation(this.userLang); + } + + /** + * Sets the default language to use as a fallback + * @param lang + */ + public setDefaultLang(lang: string): void { + this.defaultLang = lang; + } + + /** + * Changes the lang currently used + * @param lang + * @returns {Observable<*>} + */ + public use(lang: string): Observable { + let pending: Observable; + // check if this language is available + if (typeof this.translations[lang] === 'undefined') { + // not available, ask for it + pending = this.getTranslation(lang); + } + + if (typeof pending !== 'undefined') { + pending.subscribe((res: any) => { + this.changeLang(lang); + }); + + return pending; + } else { // we have this language, return an Observable + this.changeLang(lang); + + return Observable.of(this.translations[lang]); + } + } + + /** + * Gets an object of translations for a given language with the current loader + * @param lang + * @returns {Observable<*>} + */ + public getTranslation(lang: string): Observable { + this.pending = this.currentLoader.getTranslation(lang).share(); + this.pending.subscribe((res: Object) => { + this.translations[lang] = res; + this.updateLangs(); + }, (err: any) => { + throw err; + }, () => { + this.pending = undefined; + }); + + return this.pending; + } + + /** + * Manually sets an object of translations for a given language + * @param lang + * @param translations + */ + public setTranslation(lang: string, translations: Object): void { + this.translations[lang] = translations; + this.updateLangs(); + } + + /** + * Returns an array of currently available langs + * @returns {any} + */ + public getLangs(): Array { + return this.langs; + } + + /** + * Update the list of available langs + */ + private updateLangs(): void { + this.langs = Object.keys(this.translations); + } + + /** + * Returns the parsed result of the translations + * @param translations + * @param key + * @param interpolateParams + * @returns {any} + */ + private getParsedResult(translations: any, key: any, interpolateParams?: Object): any { + let res: string|Observable; + + if (key instanceof Array) { + let result: any = {}, + observables: boolean = false; + for (let k of key) { + result[k] = this.getParsedResult(translations, k, interpolateParams); + if (typeof result[k].subscribe === 'function') { + observables = true; + } + } + if (observables) { + let mergedObs: any; + for (let k of key) { + let obs = typeof result[k].subscribe === 'function' ? result[k] : Observable.of(result[k]); + if (typeof mergedObs === 'undefined') { + mergedObs = obs; + } else { + mergedObs = mergedObs.merge(obs); + } + } + return mergedObs.toArray().map((arr: Array) => { + let obj: any = {}; + arr.forEach((value: string, index: number) => { + obj[key[index]] = value; + }); + return obj; + }); + } + return result; + } + + if (translations) { + res = this.parser.interpolate(this.parser.getValue(translations, key), interpolateParams); + } + + if (typeof res === 'undefined' && this.defaultLang && this.defaultLang !== this.currentLang) { + res = this.parser.interpolate(this.parser.getValue(this.translations[this.defaultLang], key), interpolateParams); + } + + if (!res && this.missingTranslationHandler) { + res = this.missingTranslationHandler.handle(key); + } + + return res || key; + } + + /** + * Gets the translated value of a key (or an array of keys) + * @param key + * @param interpolateParams + * @returns {any} the translated key, or an object of translated keys + */ + public get(key: string|Array, interpolateParams?: Object): Observable { + if (!key) { + throw new Error('Parameter "key" required'); + } + // check if we are loading a new translation to use + if (this.pending) { + return Observable.create((observer: Observer) => { + let onComplete = (res: string) => { + observer.next(res); + observer.complete(); + }; + this.pending.subscribe((resSub: any) => { + let res = this.getParsedResult(resSub, key, interpolateParams); + if (typeof res.subscribe === 'function') { + res.subscribe(onComplete); + } else { + onComplete(res); + } + }); + }); + } else { + let res = this.getParsedResult(this.translations[this.currentLang], key, interpolateParams); + if (typeof res.subscribe === 'function') { + return res; + } else { + return Observable.of(res); + } + } + } + + /** + * Returns a translation instantly from the internal state of loaded translation. + * All rules regarding the current language, the preferred language of even fallback languages will be used except any promise handling. + * @param key + * @param interpolateParams + * @returns {string} + */ + public instant(key: string|Array, interpolateParams?: Object): string|any { + if (!key) { + throw new Error('Parameter "key" required'); + } + + let res = this.getParsedResult(this.translations[this.currentLang], key, interpolateParams); + if (typeof res.subscribe !== 'undefined') { + if (key instanceof Array) { + let obj: any = {}; + key.forEach((value: string, index: number) => { + obj[key[index]] = key[index]; + }); + return obj; + } + return key; + } else { + return res; + } + } + + /** + * Sets the translated value of a key + * @param key + * @param value + * @param lang + */ + public set(key: string, value: string, lang: string = this.currentLang): void { + this.translations[lang][key] = value; + this.updateLangs(); + } + + /** + * Changes the current lang + * @param lang + */ + private changeLang(lang: string): void { + this.currentLang = lang; + this.onLangChange.emit({lang: lang, translations: this.translations[lang]}); + } + + /** + * Allows to reload the lang file from the file + * @param lang + * @returns {Observable} + */ + public reloadLang(lang: string): Observable { + this.resetLang(lang); + return this.getTranslation(lang); + } + + /** + * Deletes inner translation + * @param lang + */ + public resetLang(lang: string): void { + this.translations[lang] = undefined; + } +} diff --git a/ng2-components/ng2-alfresco-core/src/services/translate.parser.ts b/ng2-components/ng2-alfresco-core/src/services/translate.parser.ts new file mode 100644 index 0000000000..217db9edee --- /dev/null +++ b/ng2-components/ng2-alfresco-core/src/services/translate.parser.ts @@ -0,0 +1,65 @@ +/*! + * @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. + */ + +export class Parser { + templateMatcher: RegExp = /{{\s?([^{}\s]*)\s?}}/g; + + + /** + * Interpolates a string to replace parameters + * "This is a {{ key }}" ==> "This is a value", with params = { key: "value" } + * @param expr + * @param params + * @returns {string} + */ + public interpolate(expr: string, params?: any): string { + if (typeof expr !== 'string' || !params) { + return expr; + } + + return expr.replace(this.templateMatcher, (substring: string, b: string) => { + let r = this.getValue(params, b); + return typeof r !== 'undefined' ? r : substring; + }); + } + + /** + * Gets a value from an object by composed key + * parser.getValue({ key1: { keyA: 'valueI' }}, 'key1.keyA') ==> 'valueI' + * @param target + * @param key + * @returns {string} + */ + public getValue(target: any, key: string): string { + let keys = key.split('.'); + key = ''; + do { + key += keys.shift(); + if (target[key] !== undefined && (typeof target[key] === 'object' || !keys.length)) { + target = target[key]; + key = ''; + } else if (!keys.length) { + target = undefined; + } else { + key += '.'; + } + } while (keys.length); + + return target; + } + +} diff --git a/ng2-components/ng2-alfresco-core/tsconfig.json b/ng2-components/ng2-alfresco-core/tsconfig.json index ad8bb61c75..39deca0930 100644 --- a/ng2-components/ng2-alfresco-core/tsconfig.json +++ b/ng2-components/ng2-alfresco-core/tsconfig.json @@ -21,6 +21,7 @@ "demo", "node_modules", "typings/main", - "typings/main.d.ts" + "typings/main.d.ts", + "dist" ] } diff --git a/ng2-components/ng2-alfresco-datatable/.npmignore b/ng2-components/ng2-alfresco-datatable/.npmignore index 141558843b..71379e3e57 100644 --- a/ng2-components/ng2-alfresco-datatable/.npmignore +++ b/ng2-components/ng2-alfresco-datatable/.npmignore @@ -7,8 +7,12 @@ demo/ node_modules typings/ src/ +fonts/ -/ng2-alfresco-datatable.ts -/ng2-alfresco-datatable.d.ts -/ng2-alfresco-datatable.js -/ng2-alfresco-datatable.js.map +/.editorconfig +/.travis.yml +/*.js +/*.json +/*.ts +/*.js.map +/.npmignore diff --git a/ng2-components/ng2-alfresco-datatable/karma-test-shim.js b/ng2-components/ng2-alfresco-datatable/karma-test-shim.js index 3015aa2876..5544ce9a11 100644 --- a/ng2-components/ng2-alfresco-datatable/karma-test-shim.js +++ b/ng2-components/ng2-alfresco-datatable/karma-test-shim.js @@ -13,10 +13,17 @@ System.config({ defaultExtension: 'js', format: 'register', map: Object.keys(window.__karma__.files).filter(onlyAppFiles).reduce(createPathRecords, {}) + }, + 'ng2-alfresco-core/dist': { + defaultExtension: 'js' + }, + 'rxjs': { + defaultExtension: 'js' } }, map: { - 'ng2-alfresco-core': '/base/dist/node_modules/ng2-alfresco-core' + 'ng2-alfresco-core/dist': '/base/node_modules/ng2-alfresco-core/dist', + 'rxjs': '/base/node_modules/rxjs' } }); diff --git a/ng2-components/ng2-alfresco-datatable/karma.conf.js b/ng2-components/ng2-alfresco-datatable/karma.conf.js index 0459318f82..eda306a666 100644 --- a/ng2-components/ng2-alfresco-datatable/karma.conf.js +++ b/ng2-components/ng2-alfresco-datatable/karma.conf.js @@ -11,11 +11,12 @@ module.exports = function (config) { // paths loaded by Karma {pattern: 'node_modules/angular2/bundles/angular2-polyfills.js', included: true, watched: true}, {pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: true}, - {pattern: 'node_modules/rxjs/bundles/Rx.js', included: true, watched: true}, + {pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false, served: true}, {pattern: 'node_modules/angular2/bundles/angular2.dev.js', included: true, watched: true}, {pattern: 'node_modules/angular2/bundles/testing.dev.js', included: true, watched: true}, {pattern: 'node_modules/angular2/bundles/http.dev.js', included: true, watched: true}, {pattern: 'node_modules/alfresco-core-rest-api/bundle.js', included: true, watched: false}, + {pattern: 'node_modules/ng2-alfresco-core/dist/**/*.js', included: false, served: true, watched: false}, {pattern: 'karma-test-shim.js', included: true, watched: true}, diff --git a/ng2-components/ng2-alfresco-datatable/package.json b/ng2-components/ng2-alfresco-datatable/package.json index 6142cb927a..ca174c6e64 100644 --- a/ng2-components/ng2-alfresco-datatable/package.json +++ b/ng2-components/ng2-alfresco-datatable/package.json @@ -1,7 +1,7 @@ { "name": "ng2-alfresco-datatable", "description": "Alfresco Angular2 DataTable Component", - "version": "0.1.4", + "version": "0.1.5", "author": "Alfresco Software, Ltd.", "scripts": { "typings": "typings install", diff --git a/ng2-components/ng2-alfresco-datatable/tsconfig.json b/ng2-components/ng2-alfresco-datatable/tsconfig.json index 45d37de047..e14b002fcf 100644 --- a/ng2-components/ng2-alfresco-datatable/tsconfig.json +++ b/ng2-components/ng2-alfresco-datatable/tsconfig.json @@ -12,8 +12,10 @@ }, "exclude": [ "demo", + "dist", "node_modules", "typings/main", - "typings/main.d.ts" + "typings/main.d.ts", + "dist" ] } diff --git a/ng2-components/ng2-alfresco-documentlist/.npmignore b/ng2-components/ng2-alfresco-documentlist/.npmignore index e8c0dc4106..71379e3e57 100644 --- a/ng2-components/ng2-alfresco-documentlist/.npmignore +++ b/ng2-components/ng2-alfresco-documentlist/.npmignore @@ -7,8 +7,12 @@ demo/ node_modules typings/ src/ +fonts/ -/ng2-alfresco-documentlist.ts -/ng2-alfresco-documentlist.d.ts -/ng2-alfresco-documentlist.js -/ng2-alfresco-documentlist.js.map +/.editorconfig +/.travis.yml +/*.js +/*.json +/*.ts +/*.js.map +/.npmignore diff --git a/ng2-components/ng2-alfresco-documentlist/karma-test-shim.js b/ng2-components/ng2-alfresco-documentlist/karma-test-shim.js index 3015aa2876..5544ce9a11 100644 --- a/ng2-components/ng2-alfresco-documentlist/karma-test-shim.js +++ b/ng2-components/ng2-alfresco-documentlist/karma-test-shim.js @@ -13,10 +13,17 @@ System.config({ defaultExtension: 'js', format: 'register', map: Object.keys(window.__karma__.files).filter(onlyAppFiles).reduce(createPathRecords, {}) + }, + 'ng2-alfresco-core/dist': { + defaultExtension: 'js' + }, + 'rxjs': { + defaultExtension: 'js' } }, map: { - 'ng2-alfresco-core': '/base/dist/node_modules/ng2-alfresco-core' + 'ng2-alfresco-core/dist': '/base/node_modules/ng2-alfresco-core/dist', + 'rxjs': '/base/node_modules/rxjs' } }); diff --git a/ng2-components/ng2-alfresco-documentlist/karma.conf.js b/ng2-components/ng2-alfresco-documentlist/karma.conf.js index 0459318f82..eda306a666 100644 --- a/ng2-components/ng2-alfresco-documentlist/karma.conf.js +++ b/ng2-components/ng2-alfresco-documentlist/karma.conf.js @@ -11,11 +11,12 @@ module.exports = function (config) { // paths loaded by Karma {pattern: 'node_modules/angular2/bundles/angular2-polyfills.js', included: true, watched: true}, {pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: true}, - {pattern: 'node_modules/rxjs/bundles/Rx.js', included: true, watched: true}, + {pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false, served: true}, {pattern: 'node_modules/angular2/bundles/angular2.dev.js', included: true, watched: true}, {pattern: 'node_modules/angular2/bundles/testing.dev.js', included: true, watched: true}, {pattern: 'node_modules/angular2/bundles/http.dev.js', included: true, watched: true}, {pattern: 'node_modules/alfresco-core-rest-api/bundle.js', included: true, watched: false}, + {pattern: 'node_modules/ng2-alfresco-core/dist/**/*.js', included: false, served: true, watched: false}, {pattern: 'karma-test-shim.js', included: true, watched: true}, diff --git a/ng2-components/ng2-alfresco-documentlist/package.json b/ng2-components/ng2-alfresco-documentlist/package.json index 71ac6aada6..d4b03d4926 100644 --- a/ng2-components/ng2-alfresco-documentlist/package.json +++ b/ng2-components/ng2-alfresco-documentlist/package.json @@ -1,7 +1,7 @@ { "name": "ng2-alfresco-documentlist", "description": "Alfresco Angular2 Document List Component", - "version": "0.1.2", + "version": "0.1.3", "author": "Alfresco Software, Ltd.", "scripts": { "typings": "typings install", diff --git a/ng2-components/ng2-alfresco-documentlist/src/assets/alfresco.service.mock.ts b/ng2-components/ng2-alfresco-documentlist/src/assets/alfresco.service.mock.ts index d66617e19a..f0862e90e1 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/assets/alfresco.service.mock.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/assets/alfresco.service.mock.ts @@ -18,7 +18,7 @@ import {Http} from 'angular2/http'; import {Observable} from 'rxjs/Observable'; import {AlfrescoService} from '../../src/services/alfresco.service'; -import {AlfrescoSettingsService} from 'ng2-alfresco-core/services'; +import {AlfrescoSettingsService} from 'ng2-alfresco-core/dist/ng2-alfresco-core'; export class AlfrescoServiceMock extends AlfrescoService { diff --git a/ng2-components/ng2-alfresco-documentlist/src/services/alfresco.service.ts b/ng2-components/ng2-alfresco-documentlist/src/services/alfresco.service.ts index f9632f72d6..c9432ec4cf 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/services/alfresco.service.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/services/alfresco.service.ts @@ -19,7 +19,7 @@ import { Injectable } from 'angular2/core'; import { Http, Response } from 'angular2/http'; import { Observable } from 'rxjs/Observable'; import { NodePaging, MinimalNodeEntity } from './../models/document-library.model'; -import { AlfrescoSettingsService } from 'ng2-alfresco-core/services'; +import { AlfrescoSettingsService } from 'ng2-alfresco-core/dist/ng2-alfresco-core'; declare let AlfrescoApi: any; diff --git a/ng2-components/ng2-alfresco-documentlist/tsconfig.json b/ng2-components/ng2-alfresco-documentlist/tsconfig.json index 45d37de047..1864a0c029 100644 --- a/ng2-components/ng2-alfresco-documentlist/tsconfig.json +++ b/ng2-components/ng2-alfresco-documentlist/tsconfig.json @@ -14,6 +14,7 @@ "demo", "node_modules", "typings/main", - "typings/main.d.ts" + "typings/main.d.ts", + "dist" ] } diff --git a/ng2-components/ng2-alfresco-login/.npmignore b/ng2-components/ng2-alfresco-login/.npmignore index da0fb078c2..71379e3e57 100644 --- a/ng2-components/ng2-alfresco-login/.npmignore +++ b/ng2-components/ng2-alfresco-login/.npmignore @@ -7,8 +7,12 @@ demo/ node_modules typings/ src/ +fonts/ -/ng2-alfresco-upload.ts -/ng2-alfresco-upload.d.ts -/ng2-alfresco-upload.js -/ng2-alfresco-upload.js.map +/.editorconfig +/.travis.yml +/*.js +/*.json +/*.ts +/*.js.map +/.npmignore diff --git a/ng2-components/ng2-alfresco-login/demo/tsconfig.json b/ng2-components/ng2-alfresco-login/demo/tsconfig.json index d0f08ba4ce..0c6b9dc687 100644 --- a/ng2-components/ng2-alfresco-login/demo/tsconfig.json +++ b/ng2-components/ng2-alfresco-login/demo/tsconfig.json @@ -12,6 +12,7 @@ }, "exclude": [ "node_modules", - "typings" + "typings", + "dist" ] } diff --git a/ng2-components/ng2-alfresco-login/karma-test-shim.js b/ng2-components/ng2-alfresco-login/karma-test-shim.js index 5e1b1f2010..5544ce9a11 100644 --- a/ng2-components/ng2-alfresco-login/karma-test-shim.js +++ b/ng2-components/ng2-alfresco-login/karma-test-shim.js @@ -14,14 +14,16 @@ System.config({ format: 'register', map: Object.keys(window.__karma__.files).filter(onlyAppFiles).reduce(createPathRecords, {}) }, - 'ng2-translate': { - defaultExtension: 'js', - format: 'register' + 'ng2-alfresco-core/dist': { + defaultExtension: 'js' + }, + 'rxjs': { + defaultExtension: 'js' } }, map: { - 'ng2-translate': '/base/node_modules/ng2-translate/bundles', - 'ng2-alfresco-core': '/base/dist/node_modules/ng2-alfresco-core' + 'ng2-alfresco-core/dist': '/base/node_modules/ng2-alfresco-core/dist', + 'rxjs': '/base/node_modules/rxjs' } }); diff --git a/ng2-components/ng2-alfresco-login/karma.conf.js b/ng2-components/ng2-alfresco-login/karma.conf.js index d5ba842eb5..0018f4f76d 100644 --- a/ng2-components/ng2-alfresco-login/karma.conf.js +++ b/ng2-components/ng2-alfresco-login/karma.conf.js @@ -11,13 +11,13 @@ module.exports = function (config) { // paths loaded by Karma {pattern: 'node_modules/angular2/bundles/angular2-polyfills.js', included: true, watched: false}, {pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: false}, - {pattern: 'node_modules/rxjs/bundles/Rx.js', included: true, watched: false}, - {pattern: 'node_modules/angular2/bundles/angular2.dev.js', included: true, watched: false}, - {pattern: 'node_modules/angular2/bundles/testing.dev.js', included: true, watched: false}, - {pattern: 'node_modules/angular2/bundles/http.dev.js', included: true, watched: false}, + { pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false, served: true }, + {pattern: 'node_modules/angular2/bundles/angular2.dev.js', included: true, served: true, watched: false}, + {pattern: 'node_modules/angular2/bundles/testing.dev.js', included: true, served: true, watched: false}, + {pattern: 'node_modules/angular2/bundles/http.dev.js', included: true, served: true, watched: false}, {pattern: 'node_modules/angular2/bundles/router.dev.js', included: true, watched: false}, {pattern: 'node_modules/alfresco-core-rest-api/bundle.js', included: true, watched: false}, - {pattern: 'node_modules/ng2-translate/bundles/ng2-translate.js', included: true, watched: false}, + {pattern: 'node_modules/ng2-alfresco-core/dist/**/*.js', included: false, served: true, watched: false}, {pattern: 'karma-test-shim.js', included: true, watched: true}, diff --git a/ng2-components/ng2-alfresco-login/package.json b/ng2-components/ng2-alfresco-login/package.json index f5416dc0e6..79f6692a28 100644 --- a/ng2-components/ng2-alfresco-login/package.json +++ b/ng2-components/ng2-alfresco-login/package.json @@ -1,7 +1,7 @@ { "name": "ng2-alfresco-login", "description": "Alfresco Angular2 Login Component", - "version": "0.1.4", + "version": "0.1.5", "author": "Alfresco Software, Ltd.", "scripts": { "typings": "typings install", diff --git a/ng2-components/ng2-alfresco-login/src/assets/translation.service.mock.ts b/ng2-components/ng2-alfresco-login/src/assets/translation.service.mock.ts index c6efaceb05..bdcb7efebd 100644 --- a/ng2-components/ng2-alfresco-login/src/assets/translation.service.mock.ts +++ b/ng2-components/ng2-alfresco-login/src/assets/translation.service.mock.ts @@ -17,8 +17,11 @@ import { Observable } from 'rxjs/Observable'; import { EventEmitter } from 'angular2/core'; -import { LangChangeEvent } from 'ng2-translate/ng2-translate'; +export interface LangChangeEvent { + lang: string; + translations: any; +} export class TranslationMock { 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 414e583f3a..4af2a67f6b 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 @@ -31,7 +31,7 @@ import { provide } from 'angular2/core'; import { Location, Router, RouteRegistry, ROUTER_PRIMARY_COMPONENT, Route } from 'angular2/router'; import { RootRouter } from 'angular2/src/router/router'; import { SpyLocation } from 'angular2/src/mock/location_mock'; -import { TranslateService } from 'ng2-translate/ng2-translate'; +import { AlfrescoTranslationService } from 'ng2-alfresco-core/dist/ng2-alfresco-core'; import { AlfrescoLoginComponent } from './alfresco-login.component'; import { AuthenticationMock } from './../assets/authentication.service.mock'; import { TranslationMock } from './../assets/translation.service.mock'; @@ -50,7 +50,7 @@ describe('AlfrescoLogin', () => { provide(Location, {useClass: SpyLocation}), provide(ROUTER_PRIMARY_COMPONENT, {useValue: AlfrescoLoginComponent}), provide(Router, {useClass: RootRouter}), - provide(TranslateService, {useClass: TranslationMock}) + 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 05d296fa96..e427ed1c22 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 @@ -19,7 +19,7 @@ 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/services'; +import { AlfrescoTranslationService, AlfrescoPipeTranslate } from 'ng2-alfresco-core/dist/ng2-alfresco-core'; declare let componentHandler: any; declare let __moduleName: string; diff --git a/ng2-components/ng2-alfresco-login/tsconfig.json b/ng2-components/ng2-alfresco-login/tsconfig.json index ad8bb61c75..39deca0930 100644 --- a/ng2-components/ng2-alfresco-login/tsconfig.json +++ b/ng2-components/ng2-alfresco-login/tsconfig.json @@ -21,6 +21,7 @@ "demo", "node_modules", "typings/main", - "typings/main.d.ts" + "typings/main.d.ts", + "dist" ] } diff --git a/ng2-components/ng2-alfresco-search/.npmignore b/ng2-components/ng2-alfresco-search/.npmignore index 073246c993..71379e3e57 100644 --- a/ng2-components/ng2-alfresco-search/.npmignore +++ b/ng2-components/ng2-alfresco-search/.npmignore @@ -7,8 +7,12 @@ demo/ node_modules typings/ src/ +fonts/ -/ng2-alfresco-search.ts -/ng2-alfresco-search.d.ts -/ng2-alfresco-search.js -/ng2-alfresco-search.js.map +/.editorconfig +/.travis.yml +/*.js +/*.json +/*.ts +/*.js.map +/.npmignore diff --git a/ng2-components/ng2-alfresco-search/karma-test-shim.js b/ng2-components/ng2-alfresco-search/karma-test-shim.js index 3015aa2876..32fe8f197f 100644 --- a/ng2-components/ng2-alfresco-search/karma-test-shim.js +++ b/ng2-components/ng2-alfresco-search/karma-test-shim.js @@ -13,10 +13,13 @@ System.config({ defaultExtension: 'js', format: 'register', map: Object.keys(window.__karma__.files).filter(onlyAppFiles).reduce(createPathRecords, {}) + }, + 'ng2-alfresco-core/dist': { + defaultExtension: 'js' } }, map: { - 'ng2-alfresco-core': '/base/dist/node_modules/ng2-alfresco-core' + 'ng2-alfresco-core/dist': '/base/node_modules/ng2-alfresco-core/dist' } }); diff --git a/ng2-components/ng2-alfresco-search/package.json b/ng2-components/ng2-alfresco-search/package.json index 7e1c0e6329..88cb503eb1 100644 --- a/ng2-components/ng2-alfresco-search/package.json +++ b/ng2-components/ng2-alfresco-search/package.json @@ -1,7 +1,7 @@ { "name": "ng2-alfresco-search", "description": "Alfresco Angular2 Search Component", - "version": "0.1.2", + "version": "0.1.3", "author": "Alfresco Software, Ltd.", "scripts": { "typings": "typings install", 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 index 8cee299e13..c721825747 100644 --- a/ng2-components/ng2-alfresco-search/src/assets/alfresco.service.mock.ts +++ b/ng2-components/ng2-alfresco-search/src/assets/alfresco.service.mock.ts @@ -18,7 +18,7 @@ import {Http} from 'angular2/http'; import {Observable} from 'rxjs/Observable'; -import {AlfrescoSettingsService} from 'ng2-alfresco-core/services'; +import {AlfrescoSettingsService} from 'ng2-alfresco-core/dist/ng2-alfresco-core'; import {AlfrescoService} from './../../src/services/alfresco.service'; export class AlfrescoServiceMock extends AlfrescoService { diff --git a/ng2-components/ng2-alfresco-search/src/services/alfresco.service.ts b/ng2-components/ng2-alfresco-search/src/services/alfresco.service.ts index fbcab05111..68265961f4 100644 --- a/ng2-components/ng2-alfresco-search/src/services/alfresco.service.ts +++ b/ng2-components/ng2-alfresco-search/src/services/alfresco.service.ts @@ -19,7 +19,7 @@ import { Injectable } from 'angular2/core'; import { Http, Response } from 'angular2/http'; import { Observable } from 'rxjs/Observable'; -import { AlfrescoSettingsService } from 'ng2-alfresco-core/services'; +import { AlfrescoSettingsService } from 'ng2-alfresco-core/dist/ng2-alfresco-core'; declare let AlfrescoApi: any; diff --git a/ng2-components/ng2-alfresco-search/tsconfig.json b/ng2-components/ng2-alfresco-search/tsconfig.json index 1a1d552c0a..55e16390d6 100644 --- a/ng2-components/ng2-alfresco-search/tsconfig.json +++ b/ng2-components/ng2-alfresco-search/tsconfig.json @@ -13,6 +13,7 @@ "exclude": [ "node_modules", "typings/main", - "typings/main.d.ts" + "typings/main.d.ts", + "dist" ] } diff --git a/ng2-components/ng2-alfresco-upload/.npmignore b/ng2-components/ng2-alfresco-upload/.npmignore index da0fb078c2..71379e3e57 100644 --- a/ng2-components/ng2-alfresco-upload/.npmignore +++ b/ng2-components/ng2-alfresco-upload/.npmignore @@ -7,8 +7,12 @@ demo/ node_modules typings/ src/ +fonts/ -/ng2-alfresco-upload.ts -/ng2-alfresco-upload.d.ts -/ng2-alfresco-upload.js -/ng2-alfresco-upload.js.map +/.editorconfig +/.travis.yml +/*.js +/*.json +/*.ts +/*.js.map +/.npmignore diff --git a/ng2-components/ng2-alfresco-upload/README.md b/ng2-components/ng2-alfresco-upload/README.md index f0786469b1..8a1cf2d28d 100644 --- a/ng2-components/ng2-alfresco-upload/README.md +++ b/ng2-components/ng2-alfresco-upload/README.md @@ -46,36 +46,36 @@ Make sure your systemjs.config has the following configuration: ```javascript System.config({ - defaultJSExtensions: true, - map: { - 'ng2-alfresco-core': 'node_modules/ng2-alfresco-core/dist', - 'ng2-alfresco-upload': 'node_modules/ng2-alfresco-upload/dist', - 'ng2-translate': 'node_modules/ng2-translate', - 'rxjs': 'node_modules/rxjs', - 'angular2' : 'node_modules/angular2', - 'app': 'dist/src' - }, - packages: { - 'app': { - defaultExtension: 'js' + defaultJSExtensions: true, + map: { + 'ng2-alfresco-core': 'node_modules/ng2-alfresco-core/dist', + 'ng2-alfresco-upload': 'node_modules/ng2-alfresco-upload', + 'ng2-translate': 'node_modules/ng2-translate', + 'rxjs': 'node_modules/rxjs', + 'angular2' : 'node_modules/angular2', + 'app': 'dist/src' }, - 'ng2-alfresco-core': { - defaultExtension: 'js' - }, - 'ng2-alfresco-upload': { - defaultExtension: 'js' - }, - 'ng2-translate': { - defaultExtension: 'js' - }, - 'rxjs': { - defaultExtension: 'js' - }, - 'angular2': { - defaultExtension: 'js' + packages: { + 'app': { + defaultExtension: 'js' + }, + 'ng2-alfresco-core': { + defaultExtension: 'js' + }, + 'ng2-alfresco-upload': { + defaultExtension: 'js' + }, + 'ng2-translate': { + defaultExtension: 'js' + }, + 'rxjs': { + defaultExtension: 'js' + }, + 'angular2': { + defaultExtension: 'js' + } } - } - }); + }); ``` #### Basic usage @@ -98,7 +98,7 @@ import { Component } from 'angular2/core'; import { bootstrap } from 'angular2/platform/browser'; import { HTTP_PROVIDERS } from 'angular2/http'; import { AlfrescoSettingsService, AlfrescoTranslationService, AlfrescoTranslationLoader } from 'ng2-alfresco-core/services'; -import { ALFRESCO_ULPOAD_COMPONENT, UploadService } from 'ng2-alfresco-upload/ng2-alfresco-upload'; +import { ALFRESCO_ULPOAD_COMPONENTS, UploadService } from 'ng2-alfresco-upload/dist/ng2-alfresco-upload'; @Component({ @@ -157,7 +157,7 @@ import { Component } from 'angular2/core'; import { bootstrap } from 'angular2/platform/browser'; import { HTTP_PROVIDERS } from 'angular2/http'; import { AlfrescoSettingsService, AlfrescoTranslationService, AlfrescoTranslationLoader } from 'ng2-alfresco-core/services'; -import { ALFRESCO_ULPOAD_COMPONENT, UploadService } from 'ng2-alfresco-upload/ng2-alfresco-upload'; +import { ALFRESCO_ULPOAD_COMPONENTS, UploadService } from 'ng2-alfresco-upload/dist/ng2-alfresco-upload'; @Component({ diff --git a/ng2-components/ng2-alfresco-upload/demo/index.html b/ng2-components/ng2-alfresco-upload/demo/index.html index 52ca6d00af..a34e472ca0 100644 --- a/ng2-components/ng2-alfresco-upload/demo/index.html +++ b/ng2-components/ng2-alfresco-upload/demo/index.html @@ -27,8 +27,8 @@ System.config({ defaultJSExtensions: true, map: { - 'ng2-alfresco-core': 'node_modules/ng2-alfresco-core/dist', - 'ng2-alfresco-upload': 'node_modules/ng2-alfresco-upload/dist', + 'ng2-alfresco-core': 'node_modules/ng2-alfresco-core', + 'ng2-alfresco-upload': 'node_modules/ng2-alfresco-upload', 'ng2-translate': 'node_modules/ng2-translate', 'rxjs': 'node_modules/rxjs', 'angular2' : 'node_modules/angular2', @@ -56,7 +56,7 @@ } }); - System.import('dist/src/my-app').catch(console.log.bind(console)); + System.import('dist/my-app').catch(console.log.bind(console)); diff --git a/ng2-components/ng2-alfresco-upload/demo/src/my-app.ts b/ng2-components/ng2-alfresco-upload/demo/src/my-app.ts index f1cbe2a99f..fc04ad040b 100644 --- a/ng2-components/ng2-alfresco-upload/demo/src/my-app.ts +++ b/ng2-components/ng2-alfresco-upload/demo/src/my-app.ts @@ -20,8 +20,8 @@ import { Component } from 'angular2/core'; import { bootstrap } from 'angular2/platform/browser'; import { HTTP_PROVIDERS } from 'angular2/http'; -import { AlfrescoSettingsService, AlfrescoTranslationService, AlfrescoTranslationLoader } from 'ng2-alfresco-core/services'; -import { ALFRESCO_ULPOAD_COMPONENT, UploadService } from 'ng2-alfresco-upload/ng2-alfresco-upload'; +import { AlfrescoSettingsService, AlfrescoTranslationService, AlfrescoTranslationLoader } from 'ng2-alfresco-core/dist/ng2-alfresco-core'; +import { ALFRESCO_ULPOAD_COMPONENTS, UploadService } from 'ng2-alfresco-upload/dist/ng2-alfresco-upload'; @Component({ @@ -58,7 +58,7 @@ import { ALFRESCO_ULPOAD_COMPONENT, UploadService } from 'ng2-alfresco-upload/ng DRAG HERE `, - directives: [ALFRESCO_ULPOAD_COMPONENT] + directives: [ALFRESCO_ULPOAD_COMPONENTS] }) export class MyDemoApp { constructor(alfrescoSettingsService: AlfrescoSettingsService) { diff --git a/ng2-components/ng2-alfresco-upload/demo/tsconfig.json b/ng2-components/ng2-alfresco-upload/demo/tsconfig.json index d0f08ba4ce..0c6b9dc687 100644 --- a/ng2-components/ng2-alfresco-upload/demo/tsconfig.json +++ b/ng2-components/ng2-alfresco-upload/demo/tsconfig.json @@ -12,6 +12,7 @@ }, "exclude": [ "node_modules", - "typings" + "typings", + "dist" ] } diff --git a/ng2-components/ng2-alfresco-upload/karma-test-shim.js b/ng2-components/ng2-alfresco-upload/karma-test-shim.js index 5e1b1f2010..d283790f5d 100644 --- a/ng2-components/ng2-alfresco-upload/karma-test-shim.js +++ b/ng2-components/ng2-alfresco-upload/karma-test-shim.js @@ -14,14 +14,16 @@ System.config({ format: 'register', map: Object.keys(window.__karma__.files).filter(onlyAppFiles).reduce(createPathRecords, {}) }, - 'ng2-translate': { - defaultExtension: 'js', - format: 'register' + 'ng2-alfresco-core/dist': { + defaultExtension: 'js' + }, + 'rxjs': { + defaultExtension: 'js' } }, map: { - 'ng2-translate': '/base/node_modules/ng2-translate/bundles', - 'ng2-alfresco-core': '/base/dist/node_modules/ng2-alfresco-core' + 'ng2-alfresco-core/dist': '/base/node_modules/ng2-alfresco-core/dist', + 'rxjs': '/base/node_modules/rxjs' } }); @@ -33,14 +35,13 @@ System.import('angular2/src/platform/browser/browser_adapter') __karma__.start(); }, function(error) { + console.log(error); __karma__.error(error.stack || error); } ); function createPathRecords(pathsMapping, appPath) { // creates local module name mapping to global path with karma's fingerprint in path, e.g.: - // './vg-player/vg-player': - // '/base/dist/vg-player/vg-player.js?f4523daf879cfb7310ef6242682ccf10b2041b3e' var moduleName = './' + resolveKeyPathForMapping('base/dist/', appPath); moduleName = moduleName.replace(/\.js$/, ''); pathsMapping[moduleName] = appPath + '?' + window.__karma__.files[appPath]; @@ -60,7 +61,6 @@ function resolveTestFiles() { .filter(onlySpecFiles) .map(function(moduleName) { // loads all spec files via their global module names (e.g. - // 'base/dist/vg-player/vg-player.spec') return System.import(moduleName); }); } diff --git a/ng2-components/ng2-alfresco-upload/karma.conf.js b/ng2-components/ng2-alfresco-upload/karma.conf.js index 579315e28f..dff754de67 100644 --- a/ng2-components/ng2-alfresco-upload/karma.conf.js +++ b/ng2-components/ng2-alfresco-upload/karma.conf.js @@ -11,13 +11,13 @@ module.exports = function (config) { // paths loaded by Karma {pattern: 'node_modules/angular2/bundles/angular2-polyfills.js', included: true, watched: false}, {pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: false}, - {pattern: 'node_modules/rxjs/bundles/Rx.js', included: true, watched: false}, + {pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false, served: true}, {pattern: 'node_modules/angular2/bundles/angular2.dev.js', included: true, served: true, watched: false}, {pattern: 'node_modules/angular2/bundles/testing.dev.js', included: true, served: true, watched: false}, {pattern: 'node_modules/angular2/bundles/http.dev.js', included: true, served: true, watched: false}, {pattern: 'node_modules/angular2/bundles/router.dev.js', included: true, watched: false}, {pattern: 'node_modules/alfresco-core-rest-api/bundle.js', included: true, watched: false}, - {pattern: 'node_modules/ng2-translate/bundles/ng2-translate.js', included: true, watched: false}, + {pattern: 'node_modules/ng2-alfresco-core/dist/**/*.js', included: false, served: true, watched: false}, {pattern: 'karma-test-shim.js', included: true, watched: true}, @@ -41,7 +41,7 @@ module.exports = function (config) { // level of logging // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG - logLevel: config.LOG_INFO, + logLevel: config.LOG_DEBUG, colors: true, @@ -76,6 +76,6 @@ module.exports = function (config) { ] }, - singleRun: false + singleRun: true }) }; diff --git a/ng2-components/ng2-alfresco-upload/ng2-alfresco-upload.ts b/ng2-components/ng2-alfresco-upload/ng2-alfresco-upload.ts index 2edb8d88f4..19bca39f12 100644 --- a/ng2-components/ng2-alfresco-upload/ng2-alfresco-upload.ts +++ b/ng2-components/ng2-alfresco-upload/ng2-alfresco-upload.ts @@ -18,6 +18,7 @@ import { UploadDragAreaComponent } from './src/components/upload-drag-area.component'; import { FileDraggableDirective } from './src/directives/file-draggable.directive'; import { UploadButtonComponent } from './src/components/upload-button.component'; +import { UploadService } from './src/services/upload.service'; /** * ng2-alfresco-upload, provide components to upload files to alfresco repository. @@ -41,12 +42,20 @@ export * from './src/services/upload.service'; export * from './src/directives/file-draggable.directive'; export default { - component: [UploadDragAreaComponent, UploadButtonComponent], - directives: [FileDraggableDirective] + components: [UploadDragAreaComponent, UploadButtonComponent], + providers: [FileDraggableDirective], + directives: [UploadService] }; -export const ALFRESCO_ULPOAD_COMPONENT: [any] = [ - UploadDragAreaComponent, - UploadButtonComponent, - FileDraggableDirective +export const ALFRESCO_ULPOAD_COMPONENTS: [any] = [ + UploadDragAreaComponent, + UploadButtonComponent +]; + +export const ALFRESCO_ULPOAD_DIRECTIVES: [any] = [ + FileDraggableDirective +]; + +export const ALFRESCO_ULPOAD_SERVICES: [any] = [ + UploadService ]; diff --git a/ng2-components/ng2-alfresco-upload/package.json b/ng2-components/ng2-alfresco-upload/package.json index b3f92e8b0c..a01c3475fe 100644 --- a/ng2-components/ng2-alfresco-upload/package.json +++ b/ng2-components/ng2-alfresco-upload/package.json @@ -1,7 +1,7 @@ { "name": "ng2-alfresco-upload", "description": "Alfresco Angular2 Upload Component", - "version": "0.1.5", + "version": "0.1.8", "author": "Alfresco Software, Ltd.", "scripts": { "typings": "typings install", diff --git a/ng2-components/ng2-alfresco-upload/src/assets/translation.service.mock.ts b/ng2-components/ng2-alfresco-upload/src/assets/translation.service.mock.ts index 354e7a7cbc..4e313a8b01 100644 --- a/ng2-components/ng2-alfresco-upload/src/assets/translation.service.mock.ts +++ b/ng2-components/ng2-alfresco-upload/src/assets/translation.service.mock.ts @@ -17,7 +17,11 @@ import { Observable } from 'rxjs/Observable'; import { EventEmitter } from 'angular2/core'; -import { LangChangeEvent } from 'ng2-translate/ng2-translate'; + +export interface LangChangeEvent { + lang: string; + translations: any; +} export class TranslationMock { diff --git a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.ts b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.ts index e621f0d3f4..294d0541a4 100644 --- a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.ts +++ b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.ts @@ -18,7 +18,7 @@ import { Component, ElementRef, Input } from 'angular2/core'; import { FileModel } from '../models/file.model'; import { FileUploadingListComponent } from './file-uploading-list.component'; -import { AlfrescoPipeTranslate } from 'ng2-alfresco-core/services'; +import { AlfrescoPipeTranslate } from 'ng2-alfresco-core/dist/ng2-alfresco-core'; declare let __moduleName: string; diff --git a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-list.component.ts b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-list.component.ts index 70f6e87fd7..f451a6d2df 100644 --- a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-list.component.ts +++ b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-list.component.ts @@ -18,7 +18,7 @@ import { Component, ElementRef, Input } from 'angular2/core'; import { FileModel } from '../models/file.model'; -import { AlfrescoPipeTranslate } from 'ng2-alfresco-core/services'; +import { AlfrescoPipeTranslate } from 'ng2-alfresco-core/dist/ng2-alfresco-core'; declare let __moduleName: string; 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 36c643af89..2380925626 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 @@ -20,7 +20,7 @@ import { TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS } f import { it, describe, expect, injectAsync, beforeEachProviders, TestComponentBuilder, setBaseTestProviders } from 'angular2/testing'; import { provide } from 'angular2/core'; import { UploadButtonComponent } from './upload-button.component'; -import { TranslateService } from 'ng2-translate/ng2-translate'; +import { AlfrescoTranslationService } from 'ng2-alfresco-core/dist/ng2-alfresco-core'; import { TranslationMock } from '../assets/translation.service.mock'; describe('AlfrescoUploadButton', () => { @@ -29,7 +29,7 @@ describe('AlfrescoUploadButton', () => { beforeEachProviders(() => { return [ - provide(TranslateService, {useClass: TranslationMock}) + provide(AlfrescoTranslationService, {useClass: TranslationMock}) ]; }); diff --git a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.ts b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.ts index 6c2813b01c..12cfa0f29e 100644 --- a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.ts +++ b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.ts @@ -20,7 +20,7 @@ import { Component, ViewChild, ElementRef, Input, Output, EventEmitter } from 'a import { UploadService } from '../services/upload.service'; import { FileModel } from '../models/file.model'; import { FileUploadingDialogComponent } from './file-uploading-dialog.component'; -import { AlfrescoTranslationService, AlfrescoPipeTranslate } from 'ng2-alfresco-core/services'; +import { AlfrescoTranslationService, AlfrescoPipeTranslate } from 'ng2-alfresco-core/dist/ng2-alfresco-core'; import 'rxjs/Rx'; declare let componentHandler: any; diff --git a/ng2-components/ng2-alfresco-upload/src/services/upload.service.ts b/ng2-components/ng2-alfresco-upload/src/services/upload.service.ts index 5897808ad5..9ce6675691 100644 --- a/ng2-components/ng2-alfresco-upload/src/services/upload.service.ts +++ b/ng2-components/ng2-alfresco-upload/src/services/upload.service.ts @@ -20,7 +20,7 @@ import { FileModel } from '../models/file.model'; import { EventEmitter, Injectable } from 'angular2/core'; import { Observable } from 'rxjs/Observable'; import { Response } from 'angular2/http'; -import { AlfrescoSettingsService } from 'ng2-alfresco-core/services'; +import { AlfrescoSettingsService } from 'ng2-alfresco-core/dist/ng2-alfresco-core'; declare let AlfrescoApi: any; diff --git a/ng2-components/ng2-alfresco-upload/tsconfig.json b/ng2-components/ng2-alfresco-upload/tsconfig.json index ad8bb61c75..39deca0930 100644 --- a/ng2-components/ng2-alfresco-upload/tsconfig.json +++ b/ng2-components/ng2-alfresco-upload/tsconfig.json @@ -21,6 +21,7 @@ "demo", "node_modules", "typings/main", - "typings/main.d.ts" + "typings/main.d.ts", + "dist" ] } diff --git a/ng2-components/ng2-alfresco-viewer/.npmignore b/ng2-components/ng2-alfresco-viewer/.npmignore new file mode 100644 index 0000000000..71379e3e57 --- /dev/null +++ b/ng2-components/ng2-alfresco-viewer/.npmignore @@ -0,0 +1,18 @@ +npm-debug.log +.idea + +assets/ +coverage/ +demo/ +node_modules +typings/ +src/ +fonts/ + +/.editorconfig +/.travis.yml +/*.js +/*.json +/*.ts +/*.js.map +/.npmignore diff --git a/ng2-components/ng2-alfresco-viewer/demo/tsconfig.json b/ng2-components/ng2-alfresco-viewer/demo/tsconfig.json index d0f08ba4ce..0c6b9dc687 100644 --- a/ng2-components/ng2-alfresco-viewer/demo/tsconfig.json +++ b/ng2-components/ng2-alfresco-viewer/demo/tsconfig.json @@ -12,6 +12,7 @@ }, "exclude": [ "node_modules", - "typings" + "typings", + "dist" ] } diff --git a/ng2-components/ng2-alfresco-viewer/karma-test-shim.js b/ng2-components/ng2-alfresco-viewer/karma-test-shim.js index bacafb9dd6..f6c75d8ff8 100644 --- a/ng2-components/ng2-alfresco-viewer/karma-test-shim.js +++ b/ng2-components/ng2-alfresco-viewer/karma-test-shim.js @@ -13,14 +13,7 @@ System.config({ defaultExtension: 'js', format: 'register', map: Object.keys(window.__karma__.files).filter(onlyAppFiles).reduce(createPathRecords, {}) - }, - 'ng2-translate': { - defaultExtension: 'js', - format: 'register' } - }, - map: { - 'ng2-translate': '/base/node_modules/ng2-translate/bundles' } }); diff --git a/ng2-components/ng2-alfresco-viewer/karma.conf.js b/ng2-components/ng2-alfresco-viewer/karma.conf.js index a9f2224391..e7ac07406b 100644 --- a/ng2-components/ng2-alfresco-viewer/karma.conf.js +++ b/ng2-components/ng2-alfresco-viewer/karma.conf.js @@ -17,7 +17,6 @@ module.exports = function (config) { {pattern: 'node_modules/angular2/bundles/http.dev.js', included: true, watched: false}, {pattern: 'node_modules/angular2/bundles/router.dev.js', included: true, watched: false}, {pattern: 'node_modules/alfresco-core-rest-api/bundle.js', included: true, watched: false}, - {pattern: 'node_modules/ng2-translate/bundles/ng2-translate.js', included: true, watched: false}, {pattern: 'karma-test-shim.js', included: true, watched: true}, diff --git a/ng2-components/ng2-alfresco-viewer/package.json b/ng2-components/ng2-alfresco-viewer/package.json index 7040c00075..081a9f0208 100644 --- a/ng2-components/ng2-alfresco-viewer/package.json +++ b/ng2-components/ng2-alfresco-viewer/package.json @@ -1,12 +1,12 @@ { - "keywords": [ - "viewer", - "pdf", - "alfresco-component" - ], + "keywords": [ + "viewer", + "pdf", + "alfresco-component" + ], "name": "ng2-alfresco-viewer", "description": "Alfresco documents viewer", - "version": "0.1.1", + "version": "0.1.2", "author": "Eugenio Romano", "scripts": { "typings": "typings install", @@ -42,8 +42,7 @@ "pdfjs-dist": "^1.5.258", "reflect-metadata": "0.1.2", "rxjs": "5.0.0-beta.2", - "zone.js": "^0.6.12", - "ng2-translate": "^1.11.2" + "zone.js": "^0.6.12" }, "peerDependencies": { "angular2": "2.0.0-beta.15" diff --git a/ng2-components/ng2-alfresco-viewer/tsconfig.json b/ng2-components/ng2-alfresco-viewer/tsconfig.json index 1b0bd733c9..6906fda7c5 100644 --- a/ng2-components/ng2-alfresco-viewer/tsconfig.json +++ b/ng2-components/ng2-alfresco-viewer/tsconfig.json @@ -21,6 +21,7 @@ "demo", "node_modules", "typings/main", - "typings/main.d.ts" + "typings/main.d.ts", + "dist" ] }