mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
Merge branch 'master' into dev-hashraf-auto-ids
* master: Change demo app title #68 add page moving and input param tslint rule withespace type point to dist remove import typings fix demo folder Removed ng-translate code from the core Added ng-translate dependency #9 i18n fixes for columns and actions Fixed column translation problem
This commit is contained in:
commit
ec2158c7ca
@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<base href="/">
|
||||
<title>File Share - Angular 2</title>
|
||||
<title>Demo Application - Angular 2</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css">
|
||||
<link href="node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet">
|
||||
|
@ -30,6 +30,14 @@
|
||||
{
|
||||
"name": "Will Abson",
|
||||
"email": "will.abson@alfresco.com"
|
||||
},
|
||||
{
|
||||
"name": "Eugenio Romano",
|
||||
"email": "eugenio.romano@alfresco.com"
|
||||
},
|
||||
{
|
||||
"name": "Maurizio Vitale",
|
||||
"email": "maurizio.vitale@alfresco.com"
|
||||
}
|
||||
],
|
||||
"keywords": [
|
||||
@ -53,6 +61,7 @@
|
||||
"ng2-alfresco-login": "^0.1.0",
|
||||
"ng2-alfresco-search": "^0.1.2",
|
||||
"ng2-alfresco-upload": "^0.1.0",
|
||||
"ng2-translate": "^1.11.3",
|
||||
"reflect-metadata": "0.1.2",
|
||||
"rxjs": "5.0.0-beta.2",
|
||||
"systemjs": "0.19.26",
|
||||
|
@ -25,7 +25,8 @@
|
||||
'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'
|
||||
'rxjs': 'node_modules/rxjs',
|
||||
'ng2-translate': 'node_modules/ng2-translate'
|
||||
};
|
||||
|
||||
// packages tells the System loader how to load when no filename and/or no extension
|
||||
@ -40,6 +41,7 @@
|
||||
'ng2-alfresco-login': {defaultExtension: 'js'},
|
||||
'ng2-alfresco-search': {defaultExtension: 'js'},
|
||||
'ng2-alfresco-upload': {defaultExtension: 'js'},
|
||||
'ng2-translate': {defaultExtension: 'js'},
|
||||
'rxjs': {defaultExtension: 'js'}
|
||||
};
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "ng2-alfresco-core",
|
||||
"description": "Alfresco Angular 2 Components core",
|
||||
"version": "0.1.19",
|
||||
"version": "0.1.20",
|
||||
"author": "Alfresco Software, Ltd.",
|
||||
"scripts": {
|
||||
"typings": "typings install",
|
||||
@ -53,7 +53,8 @@
|
||||
"reflect-metadata": "0.1.2",
|
||||
"rxjs": "5.0.0-beta.2",
|
||||
"systemjs": "0.19.26",
|
||||
"zone.js": "^0.6.12"
|
||||
"zone.js": "^0.6.12",
|
||||
"ng2-translate": "^1.11.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"angular2": "2.0.0-beta.15"
|
||||
|
@ -15,152 +15,18 @@
|
||||
* 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';
|
||||
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 implements PipeTransform, OnDestroy {
|
||||
value: string = '';
|
||||
lastKey: string;
|
||||
lastParams: any[];
|
||||
onLangChange: EventEmitter<LangChangeEvent>;
|
||||
export class AlfrescoPipeTranslate extends TranslatePipe {
|
||||
|
||||
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();
|
||||
constructor(translate: AlfrescoTranslationService, _ref: ChangeDetectorRef) {
|
||||
super(translate, _ref);
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
import { Injectable } from 'angular2/core';
|
||||
import { Response, Http } from 'angular2/http';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { TranslateLoader } from './AlfrescoTranslationService.service';
|
||||
import { TranslateLoader } from 'ng2-translate/ng2-translate';
|
||||
|
||||
@Injectable()
|
||||
export class AlfrescoTranslationLoader implements TranslateLoader {
|
||||
|
@ -15,87 +15,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Injectable, Optional, EventEmitter } from 'angular2/core';
|
||||
import { Injectable, Optional } from 'angular2/core';
|
||||
import { Http } from 'angular2/http';
|
||||
import { MissingTranslationHandler, TranslateService } from 'ng2-translate/ng2-translate';
|
||||
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<any>;
|
||||
}
|
||||
|
||||
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<any> {
|
||||
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;
|
||||
export class AlfrescoTranslationService extends TranslateService {
|
||||
userLang: string = 'en' ;
|
||||
currentLoader: AlfrescoTranslationLoader;
|
||||
|
||||
/**
|
||||
* An EventEmitter to listen to lang changes events
|
||||
* onLangChange.subscribe((params: LangChangeEvent) => {
|
||||
* // do something
|
||||
* });
|
||||
* @type {ng.EventEmitter<LangChangeEvent>}
|
||||
*/
|
||||
public onLangChange: EventEmitter<LangChangeEvent> = new EventEmitter<LangChangeEvent>();
|
||||
|
||||
private pending: any;
|
||||
private translations: any = {};
|
||||
private defaultLang: string;
|
||||
private langs: Array<string>;
|
||||
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) {
|
||||
constructor(http: Http, currentLoader: AlfrescoTranslationLoader, @Optional() missingTranslationHandler: MissingTranslationHandler) {
|
||||
super(http, currentLoader, missingTranslationHandler);
|
||||
}
|
||||
|
||||
translationInit(name: string = ''): void {
|
||||
@ -113,238 +44,4 @@ export class AlfrescoTranslationService {
|
||||
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<any> {
|
||||
let pending: Observable<any>;
|
||||
// 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<any> {
|
||||
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<string> {
|
||||
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<string>;
|
||||
|
||||
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<string>) => {
|
||||
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<string>, interpolateParams?: Object): Observable<string|any> {
|
||||
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<string>) => {
|
||||
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<string>, 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<any>}
|
||||
*/
|
||||
public reloadLang(lang: string): Observable<any> {
|
||||
this.resetLang(lang);
|
||||
return this.getTranslation(lang);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes inner translation
|
||||
* @param lang
|
||||
*/
|
||||
public resetLang(lang: string): void {
|
||||
this.translations[lang] = undefined;
|
||||
}
|
||||
}
|
||||
|
@ -1,65 +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 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;
|
||||
}
|
||||
|
||||
}
|
@ -110,10 +110,11 @@
|
||||
],
|
||||
"whitespace": [
|
||||
true,
|
||||
"check-branch",
|
||||
"check-decl",
|
||||
"check-operator",
|
||||
"check-separator"
|
||||
"check-branch",
|
||||
"check-operator",
|
||||
"check-separator",
|
||||
"check-type",
|
||||
"check-module"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "ng2-alfresco-documentlist",
|
||||
"description": "Alfresco Angular2 Document List Component",
|
||||
"version": "0.1.4",
|
||||
"version": "0.1.5",
|
||||
"author": "Alfresco Software, Ltd.",
|
||||
"scripts": {
|
||||
"typings": "typings install",
|
||||
|
@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Component, OnInit, Input, Output, EventEmitter} from 'angular2/core';
|
||||
import {Component, OnInit, OnChanges, Input, Output, EventEmitter} from 'angular2/core';
|
||||
import {ContentActionModel} from './../models/content-action.model';
|
||||
import {ContentActionList} from './content-action-list';
|
||||
import {DocumentActionsService} from '../services/document-actions.service';
|
||||
@ -26,7 +26,7 @@ import {ContentActionHandler} from '../models/content-action.model';
|
||||
selector: 'content-action',
|
||||
template: ''
|
||||
})
|
||||
export class ContentAction implements OnInit {
|
||||
export class ContentAction implements OnInit, OnChanges {
|
||||
|
||||
@Input()
|
||||
title: string = 'Action';
|
||||
@ -46,30 +46,39 @@ export class ContentAction implements OnInit {
|
||||
@Output()
|
||||
execute = new EventEmitter();
|
||||
|
||||
model: ContentActionModel;
|
||||
|
||||
constructor(
|
||||
private list: ContentActionList,
|
||||
private documentActions: DocumentActionsService,
|
||||
private folderActions: FolderActionsService) {
|
||||
this.model = new ContentActionModel();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
let model = new ContentActionModel();
|
||||
model.type = this.type;
|
||||
model.title = this.title;
|
||||
model.icon = this.icon;
|
||||
model.target = this.target;
|
||||
this.model = new ContentActionModel({
|
||||
type: this.type,
|
||||
title: this.title,
|
||||
icon: this.icon,
|
||||
target: this.target
|
||||
});
|
||||
|
||||
if (this.handler) {
|
||||
model.handler = this.getSystemHandler(this.target, this.handler);
|
||||
this.model.handler = this.getSystemHandler(this.target, this.handler);
|
||||
} else if (this.execute) {
|
||||
model.handler = (document: any): void => {
|
||||
this.model.handler = (document: any): void => {
|
||||
this.execute.emit({
|
||||
value: document
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
this.list.registerAction(model);
|
||||
this.list.registerAction(this.model);
|
||||
}
|
||||
|
||||
ngOnChanges() {
|
||||
// update localizable properties
|
||||
this.model.title = this.title;
|
||||
}
|
||||
|
||||
private getSystemHandler(target: string, name: string): ContentActionHandler {
|
||||
|
@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, OnInit, Input } from 'angular2/core';
|
||||
import { Component, OnInit, Input, OnChanges } from 'angular2/core';
|
||||
import { ContentColumnList } from './content-column-list';
|
||||
import { ContentColumnModel } from './../models/content-column.model';
|
||||
|
||||
@ -23,7 +23,7 @@ import { ContentColumnModel } from './../models/content-column.model';
|
||||
selector: 'content-column',
|
||||
template: ''
|
||||
})
|
||||
export class ContentColumn implements OnInit {
|
||||
export class ContentColumn implements OnInit, OnChanges {
|
||||
|
||||
@Input()
|
||||
title: string = '';
|
||||
@ -40,22 +40,32 @@ export class ContentColumn implements OnInit {
|
||||
@Input('class')
|
||||
cssClass: string;
|
||||
|
||||
model: ContentColumnModel;
|
||||
|
||||
constructor(private list: ContentColumnList) {
|
||||
this.model = new ContentColumnModel();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
let model = new ContentColumnModel();
|
||||
model.title = this.title;
|
||||
model.srTitle = this.srTitle;
|
||||
model.source = this.source;
|
||||
model.cssClass = this.cssClass;
|
||||
this.model = new ContentColumnModel({
|
||||
title: this.title,
|
||||
srTitle: this.srTitle,
|
||||
source: this.source,
|
||||
cssClass: this.cssClass
|
||||
});
|
||||
|
||||
if (!model.srTitle && model.source === '$thumbnail') {
|
||||
model.srTitle = 'Thumbnail';
|
||||
if (!this.model.srTitle && this.model.source === '$thumbnail') {
|
||||
this.model.srTitle = 'Thumbnail';
|
||||
}
|
||||
|
||||
if (this.list) {
|
||||
this.list.registerColumn(model);
|
||||
this.list.registerColumn(this.model);
|
||||
}
|
||||
}
|
||||
|
||||
ngOnChanges(change) {
|
||||
// update localizable properties
|
||||
this.model.title = this.title;
|
||||
this.model.srTitle = this.srTitle;
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,16 @@ export class ContentActionModel {
|
||||
handler: ContentActionHandler;
|
||||
type: string;
|
||||
target: string;
|
||||
|
||||
constructor(obj?: any) {
|
||||
if (obj) {
|
||||
this.icon = obj.icon;
|
||||
this.title = obj.title;
|
||||
this.handler = obj.handler;
|
||||
this.type = obj.type;
|
||||
this.target = obj.target;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export interface ContentActionHandler {
|
||||
|
@ -20,4 +20,13 @@ export class ContentColumnModel {
|
||||
srTitle: string;
|
||||
source: string;
|
||||
cssClass: string;
|
||||
|
||||
constructor(obj?: any) {
|
||||
if (obj) {
|
||||
this.title = obj.title;
|
||||
this.srTitle = obj.srTitle;
|
||||
this.source = obj.source;
|
||||
this.cssClass = obj.cssClass;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -110,10 +110,11 @@
|
||||
],
|
||||
"whitespace": [
|
||||
true,
|
||||
"check-branch",
|
||||
"check-decl",
|
||||
"check-operator",
|
||||
"check-separator"
|
||||
"check-branch",
|
||||
"check-operator",
|
||||
"check-separator",
|
||||
"check-type",
|
||||
"check-module"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
'ng2-translate': 'node_modules/ng2-translate',
|
||||
'rxjs': 'node_modules/rxjs',
|
||||
'angular2' : 'node_modules/angular2',
|
||||
'ng2-translate' : 'node_modules/ng2-translate',
|
||||
'app': 'dist/src'
|
||||
},
|
||||
packages: {
|
||||
|
@ -17,6 +17,7 @@
|
||||
"es6-promise": "3.0.2",
|
||||
"es6-shim": "0.35.0",
|
||||
"ng2-alfresco-login": "^0.1.0",
|
||||
"ng2-translate": "^1.11.3",
|
||||
"ng2-translate": "^1.11.2",
|
||||
"reflect-metadata": "0.1.2",
|
||||
"rxjs": "5.0.0-beta.2",
|
||||
|
@ -17,13 +17,17 @@ System.config({
|
||||
'ng2-alfresco-core/dist': {
|
||||
defaultExtension: 'js'
|
||||
},
|
||||
'ng2-translate': {
|
||||
defaultExtension: 'js'
|
||||
},
|
||||
'rxjs': {
|
||||
defaultExtension: 'js'
|
||||
}
|
||||
},
|
||||
map: {
|
||||
'ng2-alfresco-core/dist': '/base/node_modules/ng2-alfresco-core/dist',
|
||||
'rxjs': '/base/node_modules/rxjs'
|
||||
'rxjs': '/base/node_modules/rxjs',
|
||||
'ng2-translate' : '/base/node_modules/ng2-translate'
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -18,6 +18,7 @@ module.exports = function (config) {
|
||||
{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-alfresco-core/dist/**/*.js', included: false, served: true, watched: false},
|
||||
{pattern: 'node_modules/ng2-translate/**/*.js', included: false, served: true, watched: false},
|
||||
|
||||
{pattern: 'karma-test-shim.js', included: true, watched: true},
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "ng2-alfresco-login",
|
||||
"description": "Alfresco Angular2 Login Component",
|
||||
"version": "0.1.6",
|
||||
"version": "0.1.7",
|
||||
"author": "Alfresco Software, Ltd.",
|
||||
"scripts": {
|
||||
"typings": "typings install",
|
||||
@ -63,7 +63,8 @@
|
||||
"reflect-metadata": "0.1.2",
|
||||
"rxjs": "5.0.0-beta.2",
|
||||
"systemjs": "0.19.26",
|
||||
"zone.js": "^0.6.12"
|
||||
"zone.js": "^0.6.12",
|
||||
"ng2-translate": "^1.11.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"angular2": "2.0.0-beta.15"
|
||||
|
@ -113,7 +113,9 @@
|
||||
"check-branch",
|
||||
"check-decl",
|
||||
"check-operator",
|
||||
"check-separator"
|
||||
"check-separator",
|
||||
"check-type",
|
||||
"check-module"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -110,10 +110,11 @@
|
||||
],
|
||||
"whitespace": [
|
||||
true,
|
||||
"check-branch",
|
||||
"check-decl",
|
||||
"check-operator",
|
||||
"check-separator"
|
||||
"check-branch",
|
||||
"check-operator",
|
||||
"check-separator",
|
||||
"check-type",
|
||||
"check-module"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ Make sure your systemjs.config has the following configuration:
|
||||
'ng2-alfresco-upload': 'node_modules/ng2-alfresco-upload',
|
||||
'rxjs': 'node_modules/rxjs',
|
||||
'angular2' : 'node_modules/angular2',
|
||||
'ng2-translate': 'node_modules/ng2-translate',
|
||||
'app': 'dist/src'
|
||||
},
|
||||
packages: {
|
||||
|
10
ng2-components/ng2-alfresco-upload/demo/.editorconfig
Normal file
10
ng2-components/ng2-alfresco-upload/demo/.editorconfig
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
root = true
|
||||
|
||||
[{src,scripts}/**.{ts,json,js}]
|
||||
end_of_line = crlf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 4
|
@ -1,5 +1,4 @@
|
||||
node_modules
|
||||
typings/
|
||||
node_modules/
|
||||
.idea
|
||||
coverage
|
||||
dist
|
||||
typings
|
||||
dist/
|
@ -1,21 +1,177 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Raúl Jiménez
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
1. Definitions.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
@ -1,4 +1,4 @@
|
||||
# angular2-testing
|
||||
# angular2-alfresco-upload
|
||||
|
||||
Install:
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Angular 2 Upload</title>
|
||||
<title>Alfresco Angular 2 Upload - Demo</title>
|
||||
<base href="/">
|
||||
|
||||
<!-- Google Material Design Lite -->
|
||||
@ -30,11 +30,12 @@
|
||||
'ng2-alfresco-core': 'node_modules/ng2-alfresco-core',
|
||||
'ng2-alfresco-upload': 'node_modules/ng2-alfresco-upload',
|
||||
'rxjs': 'node_modules/rxjs',
|
||||
'angular2' : 'node_modules/angular2',
|
||||
'app': 'dist/src'
|
||||
'angular2': 'node_modules/angular2',
|
||||
'ng2-translate': 'node_modules/ng2-translate',
|
||||
'src': 'src'
|
||||
},
|
||||
packages: {
|
||||
'app': {
|
||||
'src': {
|
||||
defaultExtension: 'js'
|
||||
},
|
||||
'ng2-alfresco-core': {
|
||||
@ -51,8 +52,7 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
System.import('dist/my-app').catch(console.log.bind(console));
|
||||
System.import('dist/main').catch(console.log.bind(console));
|
||||
</script>
|
||||
|
||||
</head>
|
||||
@ -61,4 +61,4 @@
|
||||
<my-app></my-app>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
@ -1,41 +1,66 @@
|
||||
{
|
||||
"name": "ng2-alfresco-upload-demo",
|
||||
"description": "Alfresco Angular2 Upload Component - Demo",
|
||||
"version": "0.1.0",
|
||||
"author": "Alfresco Software, Ltd.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"postinstall": "npm run build && npm run typings",
|
||||
"typings": "typings install",
|
||||
"start": "rm -rf dist && npm install && npm run server",
|
||||
"server" : "http-server -c-1 -o -p 8875 .",
|
||||
"build": "rm -rf dist && tsc"
|
||||
"name": "ng2-alfresco-upload-demo",
|
||||
"description": "Alfresco Angular2 Upload Component - Demo",
|
||||
"version": "0.1.0",
|
||||
"author": "Alfresco Software, Ltd.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"postinstall": "npm run build && npm run typings",
|
||||
"typings": "typings install",
|
||||
"start": "rm -rf dist && npm install && npm run server",
|
||||
"server": "lite-server",
|
||||
"build": "rm -rf dist && tsc"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Denys Vuika",
|
||||
"email": "denis.vuyka@gmail.com"
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"alfresco-core-rest-api": "^0.1.0",
|
||||
"angular2": "2.0.0-beta.15",
|
||||
"es6-promise": "3.0.2",
|
||||
"es6-shim": "0.35.0",
|
||||
"material-design-icons": "^2.2.3",
|
||||
"material-design-lite": "^1.1.3",
|
||||
"ng2-alfresco-core": "^0.1.6",
|
||||
"ng2-alfresco-upload": "^0.1.0",
|
||||
"reflect-metadata": "0.1.2",
|
||||
"rxjs": "5.0.0-beta.2",
|
||||
"zone.js": "0.6.6"
|
||||
{
|
||||
"name": "Mario Romano",
|
||||
"email": "mario.romano83@gmail.com"
|
||||
},
|
||||
"devDependencies": {
|
||||
"http-server": "0.8.5",
|
||||
"systemjs": "0.19.17",
|
||||
"typescript": "^1.8.10",
|
||||
"typings": "^0.7.12"
|
||||
{
|
||||
"name": "Will Abson",
|
||||
"email": "will.abson@alfresco.com"
|
||||
},
|
||||
"keywords": [
|
||||
"angular2",
|
||||
"typescript"
|
||||
],
|
||||
"publishConfig": {
|
||||
"registry": "http://devproducts.alfresco.me:4873/"
|
||||
{
|
||||
"name": "Eugenio Romano",
|
||||
"email": "eugenio.romano@alfresco.com"
|
||||
},
|
||||
{
|
||||
"name": "Maurizio Vitale",
|
||||
"email": "maurizio.vitale@alfresco.com"
|
||||
}
|
||||
],
|
||||
"keywords": [
|
||||
"ng2",
|
||||
"angular",
|
||||
"angular2",
|
||||
"alfresco"
|
||||
],
|
||||
"dependencies": {
|
||||
"alfresco-core-rest-api": "^0.1.0",
|
||||
"angular2": "2.0.0-beta.15",
|
||||
"es6-shim": "^0.35.0",
|
||||
"material-design-icons": "^2.2.3",
|
||||
"material-design-lite": "^1.1.3",
|
||||
"ng2-alfresco-core": "^0.1.0",
|
||||
"ng2-alfresco-upload": "^0.1.0",
|
||||
"reflect-metadata": "0.1.2",
|
||||
"rxjs": "5.0.0-beta.2",
|
||||
"systemjs": "0.19.26",
|
||||
"zone.js": "0.6.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browser-sync": "^2.10.0",
|
||||
"concurrently": "^2.0.0",
|
||||
"lite-server": "^2.2.0",
|
||||
"typescript": "^1.8.10",
|
||||
"typings": "^0.7.12"
|
||||
},
|
||||
"publishConfig": {
|
||||
"registry": "http://devproducts.alfresco.me:4873/"
|
||||
}
|
||||
}
|
||||
|
@ -1,79 +1,77 @@
|
||||
///<reference path="../node_modules/angular2/typings/browser.d.ts"/>
|
||||
|
||||
/*!
|
||||
* @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 { Component } from 'angular2/core';
|
||||
import { bootstrap } from 'angular2/platform/browser';
|
||||
import { HTTP_PROVIDERS } from 'angular2/http';
|
||||
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({
|
||||
selector: 'my-app',
|
||||
template: `<alfresco-upload-button [showDialogUpload]="true"
|
||||
[showUdoNotificationBar]="true"
|
||||
[uploadFolders]="false"
|
||||
[multipleFiles]="false"
|
||||
(onSuccess)="customMethod($event)">
|
||||
</alfresco-upload-button>
|
||||
|
||||
<br><br>
|
||||
|
||||
<alfresco-upload-button [showDialogUpload]="true"
|
||||
[showUdoNotificationBar]="true"
|
||||
[uploadFolders]="true"
|
||||
[multipleFiles]="false"
|
||||
(onSuccess)="customMethod($event)">
|
||||
</alfresco-upload-button>
|
||||
|
||||
<br><br>
|
||||
|
||||
<alfresco-upload-button [showDialogUpload]="true"
|
||||
[showUdoNotificationBar]="true"
|
||||
[uploadFolders]="false"
|
||||
[multipleFiles]="true"
|
||||
(onSuccess)="customMethod($event)">
|
||||
</alfresco-upload-button>
|
||||
|
||||
<br><br>
|
||||
|
||||
<alfresco-upload-drag-area [showDialogUpload]="true" (onSuccess)="customMethod($event)" >
|
||||
<div style="width: 200px; height: 100px; border: 1px solid #888888">
|
||||
DRAG HERE
|
||||
</div>
|
||||
</alfresco-upload-drag-area>`,
|
||||
directives: [ALFRESCO_ULPOAD_COMPONENTS]
|
||||
})
|
||||
export class MyDemoApp {
|
||||
constructor(alfrescoSettingsService: AlfrescoSettingsService) {
|
||||
alfrescoSettingsService.host = 'http://192.168.99.100:8080';
|
||||
}
|
||||
|
||||
public customMethod(event: Object): void {
|
||||
console.log('File uploaded');
|
||||
}
|
||||
}
|
||||
|
||||
bootstrap(MyDemoApp, [
|
||||
HTTP_PROVIDERS,
|
||||
AlfrescoTranslationService,
|
||||
AlfrescoTranslationLoader,
|
||||
AlfrescoSettingsService,
|
||||
UploadService
|
||||
]);
|
||||
/*!
|
||||
* @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 { Component } from 'angular2/core';
|
||||
import { bootstrap } from 'angular2/platform/browser';
|
||||
import { HTTP_PROVIDERS } from 'angular2/http';
|
||||
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({
|
||||
selector: 'my-app',
|
||||
template: `<alfresco-upload-button [showDialogUpload]="true"
|
||||
[showUdoNotificationBar]="true"
|
||||
[uploadFolders]="false"
|
||||
[multipleFiles]="false"
|
||||
(onSuccess)="customMethod($event)">
|
||||
</alfresco-upload-button>
|
||||
|
||||
<br><br>
|
||||
|
||||
<alfresco-upload-button [showDialogUpload]="true"
|
||||
[showUdoNotificationBar]="true"
|
||||
[uploadFolders]="true"
|
||||
[multipleFiles]="false"
|
||||
(onSuccess)="customMethod($event)">
|
||||
</alfresco-upload-button>
|
||||
|
||||
<br><br>
|
||||
|
||||
<alfresco-upload-button [showDialogUpload]="true"
|
||||
[showUdoNotificationBar]="true"
|
||||
[uploadFolders]="false"
|
||||
[multipleFiles]="true"
|
||||
(onSuccess)="customMethod($event)">
|
||||
</alfresco-upload-button>
|
||||
|
||||
<br><br>
|
||||
|
||||
<alfresco-upload-drag-area [showDialogUpload]="true" (onSuccess)="customMethod($event)" >
|
||||
<div style="width: 200px; height: 100px; border: 1px solid #888888">
|
||||
DRAG HERE
|
||||
</div>
|
||||
</alfresco-upload-drag-area>`,
|
||||
directives: [ALFRESCO_ULPOAD_COMPONENTS]
|
||||
})
|
||||
export class MyDemoApp {
|
||||
constructor(alfrescoSettingsService: AlfrescoSettingsService) {
|
||||
alfrescoSettingsService.host = 'http://192.168.99.100:8080';
|
||||
}
|
||||
|
||||
public customMethod(event: Object): void {
|
||||
console.log('File uploaded');
|
||||
}
|
||||
}
|
||||
|
||||
bootstrap(MyDemoApp, [
|
||||
HTTP_PROVIDERS,
|
||||
AlfrescoTranslationService,
|
||||
AlfrescoTranslationLoader,
|
||||
AlfrescoSettingsService,
|
||||
UploadService
|
||||
]);
|
@ -1,18 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES5",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"sourceMap": true,
|
||||
"removeComments": true,
|
||||
"declaration": true,
|
||||
"outDir": "dist"
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"typings",
|
||||
"dist"
|
||||
]
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "system",
|
||||
"moduleResolution": "node",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"sourceMap": true,
|
||||
"removeComments": true,
|
||||
"declaration": true,
|
||||
"outDir": "dist"
|
||||
},
|
||||
"exclude": [
|
||||
"dist",
|
||||
"node_modules",
|
||||
"typings/main",
|
||||
"typings/main.d.ts"
|
||||
]
|
||||
}
|
||||
|
122
ng2-components/ng2-alfresco-upload/demo/tslint.json
Normal file
122
ng2-components/ng2-alfresco-upload/demo/tslint.json
Normal file
@ -0,0 +1,122 @@
|
||||
{
|
||||
"rules": {
|
||||
"align": [
|
||||
true,
|
||||
"parameters",
|
||||
"arguments",
|
||||
"statements"
|
||||
],
|
||||
"ban": false,
|
||||
"class-name": true,
|
||||
"comment-format": [
|
||||
true,
|
||||
"check-space",
|
||||
"check-lowercase"
|
||||
],
|
||||
"curly": true,
|
||||
"eofline": true,
|
||||
"forin": true,
|
||||
"indent": [
|
||||
true,
|
||||
"spaces"
|
||||
],
|
||||
"interface-name": false,
|
||||
"jsdoc-format": true,
|
||||
"label-position": true,
|
||||
"label-undefined": true,
|
||||
"max-line-length": [
|
||||
true,
|
||||
140
|
||||
],
|
||||
"member-ordering": [
|
||||
true,
|
||||
"public-before-private",
|
||||
"static-before-instance",
|
||||
"variables-before-functions"
|
||||
],
|
||||
"no-any": false,
|
||||
"no-arg": true,
|
||||
"no-bitwise": true,
|
||||
"no-conditional-assignment": true,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-console": [
|
||||
true,
|
||||
"debug",
|
||||
"info",
|
||||
"time",
|
||||
"timeEnd",
|
||||
"trace"
|
||||
],
|
||||
"no-construct": true,
|
||||
"no-constructor-vars": false,
|
||||
"no-debugger": true,
|
||||
"no-duplicate-key": true,
|
||||
"no-duplicate-variable": true,
|
||||
"no-empty": true,
|
||||
"no-eval": true,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": true,
|
||||
"no-require-imports": true,
|
||||
"no-shadowed-variable": true,
|
||||
"no-switch-case-fall-through": true,
|
||||
"no-trailing-whitespace": true,
|
||||
"no-unreachable": true,
|
||||
"no-unused-expression": true,
|
||||
"no-unused-variable": true,
|
||||
"no-use-before-declare": true,
|
||||
"no-var-keyword": true,
|
||||
"no-var-requires": true,
|
||||
"object-literal-sort-keys": false,
|
||||
"one-line": [
|
||||
true,
|
||||
"check-open-brace",
|
||||
"check-catch",
|
||||
"check-else",
|
||||
"check-whitespace"
|
||||
],
|
||||
"quotemark": [
|
||||
true,
|
||||
"single",
|
||||
"avoid-escape"
|
||||
],
|
||||
"radix": true,
|
||||
"semicolon": true,
|
||||
"switch-default": true,
|
||||
"trailing-comma": [
|
||||
true,
|
||||
{
|
||||
"multiline": "never",
|
||||
"singleline": "never"
|
||||
}
|
||||
],
|
||||
"triple-equals": [
|
||||
true,
|
||||
"allow-null-check"
|
||||
],
|
||||
"typedef": false,
|
||||
"typedef-whitespace": [
|
||||
true,
|
||||
{
|
||||
"call-signature": "nospace",
|
||||
"index-signature": "nospace",
|
||||
"parameter": "nospace",
|
||||
"property-declaration": "nospace",
|
||||
"variable-declaration": "nospace"
|
||||
}
|
||||
],
|
||||
"use-strict": false,
|
||||
"variable-name": [
|
||||
true,
|
||||
"check-format",
|
||||
"allow-leading-underscore",
|
||||
"ban-keywords"
|
||||
],
|
||||
"whitespace": [
|
||||
true,
|
||||
"check-branch",
|
||||
"check-decl",
|
||||
"check-operator",
|
||||
"check-separator"
|
||||
]
|
||||
}
|
||||
}
|
@ -1,9 +1,6 @@
|
||||
{
|
||||
"name": "angular2-testing",
|
||||
"dependencies": {},
|
||||
"devDependencies": {},
|
||||
"ambientDependencies": {
|
||||
"es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#4de74cb527395c13ba20b438c3a7a419ad931f1c",
|
||||
"jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#dd638012d63e069f2c99d06ef4dcc9616a943ee4"
|
||||
"jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#d594ef506d1efe2fea15f8f39099d19b39436b71"
|
||||
}
|
||||
}
|
||||
|
@ -17,13 +17,17 @@ System.config({
|
||||
'ng2-alfresco-core/dist': {
|
||||
defaultExtension: 'js'
|
||||
},
|
||||
'ng2-translate': {
|
||||
defaultExtension: 'js'
|
||||
},
|
||||
'rxjs': {
|
||||
defaultExtension: 'js'
|
||||
}
|
||||
},
|
||||
map: {
|
||||
'ng2-alfresco-core/dist': '/base/node_modules/ng2-alfresco-core/dist',
|
||||
'rxjs': '/base/node_modules/rxjs'
|
||||
'rxjs': '/base/node_modules/rxjs',
|
||||
'ng2-translate' : '/base/node_modules/ng2-translate'
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -18,6 +18,7 @@ module.exports = function (config) {
|
||||
{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-alfresco-core/dist/**/*.js', included: false, served: true, watched: false},
|
||||
{pattern: 'node_modules/ng2-translate/**/*.js', included: false, served: true, watched: false},
|
||||
|
||||
{pattern: 'karma-test-shim.js', included: true, watched: true},
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "ng2-alfresco-upload",
|
||||
"description": "Alfresco Angular2 Upload Component",
|
||||
"version": "0.1.9",
|
||||
"version": "0.1.10",
|
||||
"author": "Alfresco Software, Ltd.",
|
||||
"scripts": {
|
||||
"typings": "typings install",
|
||||
@ -55,7 +55,8 @@
|
||||
"reflect-metadata": "0.1.2",
|
||||
"rxjs": "5.0.0-beta.2",
|
||||
"systemjs": "0.19.26",
|
||||
"zone.js": "^0.6.12"
|
||||
"zone.js": "^0.6.12",
|
||||
"ng2-translate": "^1.11.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"angular2": "2.0.0-beta.15"
|
||||
|
@ -34,7 +34,7 @@ describe('AlfrescoUploadButton', () => {
|
||||
});
|
||||
|
||||
it('should render upload-single-file button as default',
|
||||
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
injectAsync([TestComponentBuilder], (tcb:TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(UploadButtonComponent)
|
||||
.then((fixture) => {
|
||||
@ -45,7 +45,7 @@ describe('AlfrescoUploadButton', () => {
|
||||
}));
|
||||
|
||||
it('should render upload-multiple-file button if multipleFiles is true',
|
||||
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
injectAsync([TestComponentBuilder], (tcb:TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(UploadButtonComponent)
|
||||
.then((fixture) => {
|
||||
@ -58,7 +58,7 @@ describe('AlfrescoUploadButton', () => {
|
||||
}));
|
||||
|
||||
it('should render an uploadFolder button if uploadFolder is true',
|
||||
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
injectAsync([TestComponentBuilder], (tcb:TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(UploadButtonComponent)
|
||||
.then((fixture) => {
|
||||
@ -70,7 +70,7 @@ describe('AlfrescoUploadButton', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should call onFilesAdded method', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
it('should call onFilesAdded method', injectAsync([TestComponentBuilder], (tcb:TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(UploadButtonComponent)
|
||||
.then((fixture) => {
|
||||
@ -88,8 +88,8 @@ describe('AlfrescoUploadButton', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should render dialog box with css class show ',
|
||||
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
it('should render dialog box with css class show',
|
||||
injectAsync([TestComponentBuilder], (tcb:TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(UploadButtonComponent)
|
||||
.then((fixture) => {
|
||||
|
@ -111,9 +111,10 @@
|
||||
"whitespace": [
|
||||
true,
|
||||
"check-branch",
|
||||
"check-decl",
|
||||
"check-operator",
|
||||
"check-separator"
|
||||
"check-separator",
|
||||
"check-type",
|
||||
"check-module"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -21,10 +21,7 @@
|
||||
|
||||
<script src="node_modules/pdfjs-dist/build/pdf.js"></script>
|
||||
<script src="node_modules/pdfjs-dist/build/pdf.worker.js"></script>
|
||||
|
||||
<script>
|
||||
PDFJS.workerSrc = 'node_modules/pdfjs-dist/build/pdf.worker.js';
|
||||
</script>
|
||||
<script src="node_modules/pdfjs-dist/web/pdf_viewer.js"></script>
|
||||
|
||||
<script>
|
||||
System.config({
|
||||
@ -35,6 +32,9 @@
|
||||
'app': 'dist/main'
|
||||
},
|
||||
packages: {
|
||||
'pdfjsDistBuildPdf': {
|
||||
defaultExtension: 'js'
|
||||
},
|
||||
'app': {
|
||||
defaultExtension: 'js'
|
||||
},
|
||||
@ -52,6 +52,8 @@
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<ng2-alfresco-viewer><div class="mdl-spinner mdl-js-spinner is-active"></div></ng2-alfresco-viewer>
|
||||
<alfresco-viewer [urlFile]="'localTestFile.pdf'">
|
||||
<div class="mdl-spinner mdl-js-spinner is-active"></div>
|
||||
</alfresco-viewer>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -16,6 +16,6 @@
|
||||
*/
|
||||
|
||||
import {bootstrap} from 'angular2/platform/browser';
|
||||
import {Ng2AlfrescoViewerComponent} from './ng2-alfresco-viewer';
|
||||
import {ViewerComponent} from './ng2-alfresco-viewer';
|
||||
|
||||
bootstrap(Ng2AlfrescoViewerComponent);
|
||||
bootstrap(ViewerComponent);
|
||||
|
@ -15,4 +15,4 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export * from './src/ng2-alfresco-viewer.component';
|
||||
export * from './src/viewer.component';
|
||||
|
@ -1,7 +0,0 @@
|
||||
.button-container {
|
||||
padding: 0 40px;
|
||||
}
|
||||
|
||||
.page-content {
|
||||
background: #3E3E3E;
|
||||
}
|
@ -1,67 +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 { Component } from 'angular2/core';
|
||||
|
||||
declare let PDFJS: any;
|
||||
declare let __moduleName:string;
|
||||
|
||||
@Component({
|
||||
moduleId: __moduleName,
|
||||
selector: 'ng2-alfresco-viewer',
|
||||
templateUrl: './ng2-alfresco-viewer.component.html',
|
||||
styleUrls: ['./ng2-alfresco-viewer.component.css']
|
||||
})
|
||||
export class Ng2AlfrescoViewerComponent {
|
||||
|
||||
nameFile:String;
|
||||
|
||||
constructor() {
|
||||
this.nameFile = 'localTestFile.pdf';
|
||||
|
||||
PDFJS.getDocument('../localTestFile.pdf').then(function getPdfHelloWorld(pdf) {
|
||||
//
|
||||
// Fetch the first page
|
||||
//
|
||||
pdf.getPage(1).then(function (page) {
|
||||
let scale = 1.5;
|
||||
let viewport = page.getViewport(scale);
|
||||
|
||||
//
|
||||
// Prepare canvas using PDF page dimensions
|
||||
//
|
||||
let canvas:any = document.getElementById('the-canvas');
|
||||
if (canvas) {
|
||||
let context = canvas.getContext('2d');
|
||||
canvas.height = viewport.height;
|
||||
canvas.width = viewport.width;
|
||||
|
||||
//
|
||||
// Render PDF page into canvas context
|
||||
//
|
||||
let renderContext = {
|
||||
canvasContext: context,
|
||||
viewport: viewport
|
||||
};
|
||||
page.render(renderContext);
|
||||
}
|
||||
});
|
||||
});
|
||||
console.log('../contructor');
|
||||
}
|
||||
|
||||
}
|
31
ng2-components/ng2-alfresco-viewer/src/viewer.component.css
Normal file
31
ng2-components/ng2-alfresco-viewer/src/viewer.component.css
Normal file
@ -0,0 +1,31 @@
|
||||
.button-container {
|
||||
padding: 0 40px;
|
||||
}
|
||||
|
||||
.page-content {
|
||||
background: #3E3E3E;
|
||||
}
|
||||
|
||||
.previous-page-button {
|
||||
top: 50%;
|
||||
left: 7%;
|
||||
position: fixed;
|
||||
}
|
||||
|
||||
.next-page-button {
|
||||
top: 50%;
|
||||
right: 7%;
|
||||
position: fixed;
|
||||
}
|
||||
|
||||
.left {
|
||||
float: left;
|
||||
}
|
||||
|
||||
#viewer-toolbar-pagination {
|
||||
margin-left: 25%;
|
||||
}
|
||||
|
||||
#viewer-pagenumber-input {
|
||||
width: 30px;
|
||||
}
|
@ -7,13 +7,32 @@
|
||||
|
||||
<!-- File Title -->
|
||||
<span class="mdl-layout-title">{{nameFile}}</span>
|
||||
|
||||
<!-- pagination toolbar start -->
|
||||
<div id="viewer-toolbar-pagination">
|
||||
<div id="viewer-previouspage-button" class="left" (click)="previousPage()">
|
||||
<i class="icon material-icons">keyboard_arrow_left</i>
|
||||
</div>
|
||||
|
||||
<input id="viewer-pagenumber-input" #page
|
||||
(keyup.enter)="inputPage(page.value)" class="left" type="text" pattern="-?[0-9]*(\.[0-9]+)?" value="{{displayPage}}">
|
||||
<span id="viewer-total-pages" class="left">/ {{totalPages}}</span>
|
||||
|
||||
<div id="viewer-nextpage-button" (click)="nextPage()" class="left">
|
||||
<i class="icon material-icons" >keyboard_arrow_right</i>
|
||||
</div>
|
||||
</div>
|
||||
<!-- pagination toolbar end -->
|
||||
|
||||
<span class="vertical-divider"></span>
|
||||
|
||||
<div class="mdl-layout-spacer"></div>
|
||||
|
||||
<!-- Start Navigation -->
|
||||
<nav class="mdl-navigation">
|
||||
<div class="button-container">
|
||||
<button
|
||||
class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored">
|
||||
class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored" (click)="cazzo()">
|
||||
<i id="tt2" class="icon material-icons">print</i>
|
||||
</button>
|
||||
</div>
|
||||
@ -21,14 +40,14 @@
|
||||
<div class="button-container">
|
||||
<button
|
||||
class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored">
|
||||
<i id="tt3" class="icon material-icons">cloud_upload</i>
|
||||
<i id="cloud-upload" class="icon material-icons">cloud_upload</i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="button-container">
|
||||
<button
|
||||
class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored">
|
||||
<i id="tt4" class="icon material-icons">share</i>
|
||||
<i id="share" class="icon material-icons">share</i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@ -56,7 +75,8 @@
|
||||
|
||||
<div class="mdl-grid">
|
||||
<div class="mdl-cell mdl-cell--2-col mdl-cell--hide-tablet mdl-cell--hide-phone"></div>
|
||||
<div class="mdl-color--white mdl-shadow--4dp content mdl-color-text--grey-800 mdl-cell mdl-cell--8-col">
|
||||
<div
|
||||
class="mdl-color--white mdl-shadow--4dp content mdl-color-text--grey-800 mdl-cell mdl-cell--8-col">
|
||||
|
||||
<!-- Start Pdf Canvas -->
|
||||
<div id="canvas-container">
|
||||
@ -64,6 +84,22 @@
|
||||
</div>
|
||||
<!-- End Pdf Canvas -->
|
||||
|
||||
<div class="previous-page-button">
|
||||
<button
|
||||
class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored"
|
||||
(click)="previousPage()">
|
||||
<i class="icon material-icons">keyboard_arrow_left</i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="next-page-button">
|
||||
<button
|
||||
class="mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored"
|
||||
(click)="nextPage()">
|
||||
<i class="icon material-icons">keyboard_arrow_right</i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer class="mdl-mini-footer">
|
@ -17,18 +17,18 @@
|
||||
|
||||
import {describe, expect, it, injectAsync, TestComponentBuilder, setBaseTestProviders} from 'angular2/testing';
|
||||
import {TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS} from 'angular2/platform/testing/browser';
|
||||
import {Ng2AlfrescoViewerComponent} from '../src/ng2-alfresco-viewer.component';
|
||||
import {ViewerComponent} from '../src/viewer.component';
|
||||
|
||||
describe('Basic Example test ng2-alfresco-viewer', () => {
|
||||
setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS);
|
||||
setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS);
|
||||
|
||||
it('Test hello world', injectAsync([TestComponentBuilder], (tcb:TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(Ng2AlfrescoViewerComponent)
|
||||
.then((fixture) => {
|
||||
let element = fixture.nativeElement;
|
||||
expect(element.querySelector('h1')).toBeDefined();
|
||||
expect(element.getElementsByTagName('h1')[0].innerHTML).toEqual('ng2-alfresco-viewer');
|
||||
});
|
||||
}));
|
||||
it('Test hello world', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(ViewerComponent)
|
||||
.then((fixture) => {
|
||||
let element = fixture.nativeElement;
|
||||
expect(element.querySelector('h1')).toBeDefined();
|
||||
expect(element.getElementsByTagName('h1')[0].innerHTML).toEqual('ng2-alfresco-viewer');
|
||||
});
|
||||
}));
|
||||
});
|
108
ng2-components/ng2-alfresco-viewer/src/viewer.component.ts
Normal file
108
ng2-components/ng2-alfresco-viewer/src/viewer.component.ts
Normal file
@ -0,0 +1,108 @@
|
||||
/*!
|
||||
* @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 { Component, Input } from 'angular2/core';
|
||||
|
||||
declare let PDFJS: any;
|
||||
declare let __moduleName: string;
|
||||
|
||||
@Component({
|
||||
moduleId: __moduleName,
|
||||
selector: 'alfresco-viewer',
|
||||
templateUrl: './viewer.component.html',
|
||||
styleUrls: ['./viewer.component.css']
|
||||
})
|
||||
export class ViewerComponent {
|
||||
|
||||
@Input()
|
||||
urlFile: string;
|
||||
|
||||
nameFile: string;
|
||||
|
||||
currentPdf: any;
|
||||
currentPage: number;
|
||||
displayPage: number;
|
||||
totalPages: number;
|
||||
|
||||
ngOnInit() {
|
||||
console.log('A.urlFile ' + this.urlFile);
|
||||
|
||||
this.urlFile = this.urlFile ? this.urlFile : 'localTestFile.pdf';
|
||||
this.nameFile = PDFJS.getFilenameFromUrl(this.loadFile);
|
||||
|
||||
PDFJS.getDocument(this.urlFile).then((pdf) => {
|
||||
this.currentPdf = pdf;
|
||||
this.totalPages = pdf.numPages;
|
||||
this.currentPage = 1;
|
||||
this.displayPage = 1;
|
||||
this.loadPage(this.currentPdf, this.currentPage);
|
||||
});
|
||||
}
|
||||
|
||||
loadPage(pdf: any, numberPage: number) {
|
||||
pdf.getPage(numberPage).then((page) => {
|
||||
|
||||
console.log(page.numPages);
|
||||
|
||||
let scale = 1.5;
|
||||
let viewport = page.getViewport(scale);
|
||||
|
||||
let canvas: any = document.getElementById('the-canvas');
|
||||
|
||||
if (canvas) {
|
||||
let context = canvas.getContext('2d');
|
||||
canvas.height = viewport.height;
|
||||
canvas.width = viewport.width;
|
||||
|
||||
// Render PDF page into canvas context
|
||||
let renderContext = {
|
||||
canvasContext: context,
|
||||
viewport: viewport
|
||||
};
|
||||
|
||||
page.render(renderContext);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
previousPage() {
|
||||
if (this.currentPage > 1) {
|
||||
this.currentPage--;
|
||||
this.displayPage = this.currentPage;
|
||||
this.loadPage(this.currentPdf, this.currentPage);
|
||||
}
|
||||
}
|
||||
|
||||
nextPage() {
|
||||
if (this.currentPage < this.totalPages) {
|
||||
this.currentPage++;
|
||||
this.displayPage = this.currentPage;
|
||||
this.loadPage(this.currentPdf, this.currentPage);
|
||||
}
|
||||
}
|
||||
|
||||
inputPage(page: any) {
|
||||
let pageInput = parseInt(page, 10);
|
||||
|
||||
if (!isNaN(pageInput) && pageInput > 0 && pageInput <= this.totalPages) {
|
||||
this.currentPage = pageInput;
|
||||
this.loadPage(this.currentPdf, this.currentPage);
|
||||
} else {
|
||||
this.displayPage = this.currentPage;
|
||||
}
|
||||
}
|
||||
}
|
@ -113,10 +113,11 @@
|
||||
],
|
||||
"whitespace": [
|
||||
true,
|
||||
"check-branch",
|
||||
"check-decl",
|
||||
"check-operator",
|
||||
"check-separator"
|
||||
"check-branch",
|
||||
"check-operator",
|
||||
"check-separator",
|
||||
"check-type",
|
||||
"check-module"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user