";
- for (var c=n.firstChild; c; c=c.nextSibling)
- s += asXml(c);
- s += ""+n.nodeName+">";
- }
- else
- s += "/>";
- }
- else if (n.nodeType == 3)
- s += n.nodeValue;
- else if (n.nodeType == 4)
- s += "";
- return s;
- };
- for (var c=node.firstChild; c; c=c.nextSibling)
- s += asXml(c);
- }
- return s;
- },
- escape: function(txt) {
- return txt.replace(/[\\]/g, "\\\\")
- .replace(/[\"]/g, '\\"')
- .replace(/[\n]/g, '\\n')
- .replace(/[\r]/g, '\\r');
- },
- removeWhite: function(e) {
- e.normalize();
- for (var n = e.firstChild; n; ) {
- if (n.nodeType == 3) { // text node
- if (!n.nodeValue.match(/[^ \f\n\r\t\v]/)) { // pure whitespace text node
- var nxt = n.nextSibling;
- e.removeChild(n);
- n = nxt;
- }
- else
- n = n.nextSibling;
- }
- else if (n.nodeType == 1) { // element node
- X.removeWhite(n);
- n = n.nextSibling;
- }
- else // any other node
- n = n.nextSibling;
- }
- return e;
- }
- };
- xml = parseXml(xml);
- if (xml.nodeType == 9) // document node
- xml = xml.documentElement;
- var json = X.toJson(X.toObj(X.removeWhite(xml)), xml.nodeName, "\t");
- return "{\n" + tab + (tab ? json.replace(/\t/g, tab) : json.replace(/\t|\n/g, "")) + "\n}";
-}
\ No newline at end of file
diff --git a/ng2-components/ng2-alfresco-login/demo/app/main.d.ts b/ng2-components/ng2-alfresco-login/demo/app/main.d.ts
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/ng2-components/ng2-alfresco-login/demo/app/main.js b/ng2-components/ng2-alfresco-login/demo/app/main.js
deleted file mode 100644
index a0327a1a04..0000000000
--- a/ng2-components/ng2-alfresco-login/demo/app/main.js
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * @license
- * Copyright 2016 Alfresco Software, Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-System.register(['angular2/platform/browser', './app.component', 'ng2-alfresco-login/ng2-alfresco-login', 'angular2/router', 'angular2/core', 'angular2/http', 'ng2-translate/ng2-translate', 'ng2-alfresco-core/services'], function(exports_1, context_1) {
- "use strict";
- var __moduleName = context_1 && context_1.id;
- var browser_1, app_component_1, ng2_alfresco_login_1, router_1, core_1, http_1, http_2, ng2_translate_1, services_1;
- return {
- setters:[
- function (browser_1_1) {
- browser_1 = browser_1_1;
- },
- function (app_component_1_1) {
- app_component_1 = app_component_1_1;
- },
- function (ng2_alfresco_login_1_1) {
- ng2_alfresco_login_1 = ng2_alfresco_login_1_1;
- },
- function (router_1_1) {
- router_1 = router_1_1;
- },
- function (core_1_1) {
- core_1 = core_1_1;
- },
- function (http_1_1) {
- http_1 = http_1_1;
- http_2 = http_1_1;
- },
- function (ng2_translate_1_1) {
- ng2_translate_1 = ng2_translate_1_1;
- },
- function (services_1_1) {
- services_1 = services_1_1;
- }],
- execute: function() {
- browser_1.bootstrap(app_component_1.AppComponent, [
- router_1.ROUTER_PROVIDERS,
- http_2.HTTP_PROVIDERS,
- core_1.provide(ng2_translate_1.TranslateLoader, {
- useFactory: function (http) { return new ng2_translate_1.TranslateStaticLoader(http, 'node_modules/ng2-alfresco-login/i18n', '.json'); },
- deps: [http_1.Http]
- }),
- // use TranslateService here, and not TRANSLATE_PROVIDERS (which will define a default TranslateStaticLoader)
- ng2_translate_1.TranslateService,
- ng2_alfresco_login_1.ALFRESCO_AUTHENTICATION,
- services_1.ALFRESCO_CORE_PROVIDERS
- ]);
- }
- }
-});
-//# sourceMappingURL=main.js.map
\ No newline at end of file
diff --git a/ng2-components/ng2-alfresco-login/demo/app/main.js.map b/ng2-components/ng2-alfresco-login/demo/app/main.js.map
deleted file mode 100644
index 9d22f1889b..0000000000
--- a/ng2-components/ng2-alfresco-login/demo/app/main.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"main.js","sourceRoot":"","sources":["main.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAYH,mBAAS,CAAC,4BAAY,EAAE;gBACpB,yBAAgB;gBAChB,qBAAc;gBACd,cAAO,CAAC,+BAAe,EAAE;oBACrB,UAAU,EAAE,UAAC,IAAU,IAAK,OAAA,IAAI,qCAAqB,CAAC,IAAI,EAAE,sCAAsC,EAAE,OAAO,CAAC,EAAhF,CAAgF;oBAC5G,IAAI,EAAE,CAAC,WAAI,CAAC;iBACf,CAAC;gBACF,6GAA6G;gBAC7G,gCAAgB;gBAChB,4CAAuB;gBACvB,kCAAuB;aAC1B,CAAC,CAAC"}
\ No newline at end of file
diff --git a/ng2-components/ng2-alfresco-login/demo/index.html b/ng2-components/ng2-alfresco-login/demo/index.html
index 95689fedfd..225bfa70dc 100644
--- a/ng2-components/ng2-alfresco-login/demo/index.html
+++ b/ng2-components/ng2-alfresco-login/demo/index.html
@@ -1,7 +1,8 @@
-
+
+
- Alfresco Login Component Demo
-
+
+ Angular 2 Testing
@@ -16,23 +17,19 @@
-
-
-
-
-
-
-
-
-
+ System.import('dist/src/my-app').catch(console.log.bind(console));
+
+
+
-Loading...
+
+
+
diff --git a/ng2-components/ng2-alfresco-login/demo/package.json b/ng2-components/ng2-alfresco-login/demo/package.json
index 938ae77f40..f23dee9952 100644
--- a/ng2-components/ng2-alfresco-login/demo/package.json
+++ b/ng2-components/ng2-alfresco-login/demo/package.json
@@ -1,29 +1,34 @@
{
- "name": "angular2-quickstart",
- "version": "1.0.0",
+ "name": "ng2-alfresco-login-demo",
+ "description": "Alfresco Angular2 Login Component - Demo",
+ "version": "0.1.0",
+ "author": "Alfresco Software, Ltd.",
+ "main": "index.js",
"scripts": {
- "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
- "lite": "lite-server",
- "postinstall": "typings install",
- "tsc": "tsc",
- "tsc:w": "tsc -w",
- "typings": "typings"
+ "postinstall": "npm run typings && npm link ng2-alfresco-login",
+ "typings": "typings install",
+ "start": "npm run test && http-server -c-1 -o -p 8875 .",
+ "build": "rm -rf dist && tsc",
+ "pretest": "npm install && npm run build"
},
- "license": "ISC",
+ "license": "MIT",
"dependencies": {
- "angular2": "2.0.0-beta.16",
- "systemjs": "0.19.26",
- "es6-shim": "^0.35.0",
+ "angular2": "2.0.0-beta.13",
+ "es6-promise": "3.0.2",
+ "es6-shim": "0.35.0",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
- "zone.js": "0.6.12",
- "ng2-translate": "^1.11.2",
- "material-design-lite": "^1.1.3"
+ "zone.js": "0.6.6",
+ "ng2-translate": "^1.11.2"
},
"devDependencies": {
- "concurrently": "^2.0.0",
- "lite-server": "^2.2.0",
- "typescript": "^1.8.10",
- "typings":"^0.8.1"
- }
-}
\ No newline at end of file
+ "http-server": "0.8.5",
+ "systemjs": "0.19.17",
+ "typescript": "1.7.5",
+ "typings": "0.6.8"
+ },
+ "keywords": [
+ "angular2",
+ "typescript"
+ ]
+}
diff --git a/ng2-components/ng2-alfresco-login/demo/app/app.component.ts b/ng2-components/ng2-alfresco-login/demo/src/components/my-login.component.ts
similarity index 58%
rename from ng2-components/ng2-alfresco-login/demo/app/app.component.ts
rename to ng2-components/ng2-alfresco-login/demo/src/components/my-login.component.ts
index 76194a1279..03fd96fec7 100644
--- a/ng2-components/ng2-alfresco-login/demo/app/app.component.ts
+++ b/ng2-components/ng2-alfresco-login/demo/src/components/my-login.component.ts
@@ -1,3 +1,5 @@
+///
+
/**
* @license
* Copyright 2016 Alfresco Software, Ltd.
@@ -15,15 +17,15 @@
* limitations under the License.
*/
-import {Component} from 'angular2/core';
-import {AlfrescoLoginComponent} from 'ng2-alfresco-login/ng2-alfresco-login';
-import {Router, RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';
-import {AlfrescoSettingsService} from 'ng2-alfresco-core/services';
-import {AlfrescoAuthenticationService} from 'ng2-alfresco-login/ng2-alfresco-login';
+import { Component } from 'angular2/core';
+import { AlfrescoLoginComponent } from 'ng2-alfresco-login/ng2-alfresco-login';
+import { Router, RouteConfig, ROUTER_DIRECTIVES } from 'angular2/router';
+import { AlfrescoSettingsService } from 'ng2-alfresco-core/services';
+import { AlfrescoAuthenticationService } from 'ng2-alfresco-login/ng2-alfresco-login';
@Component({
- selector: 'my-app',
+ selector: 'my-login',
template: '',
directives: [ROUTER_DIRECTIVES, AlfrescoLoginComponent]
})
@@ -31,21 +33,21 @@ import {AlfrescoAuthenticationService} from 'ng2-alfresco-login/ng2-alfresco-log
@RouteConfig([
{path: '/', name: 'Login', component: AlfrescoLoginComponent, useAsDefault: true}
])
-export class AppComponent {
+export class MyLoginComponent {
- constructor(public auth:AlfrescoAuthenticationService,
- public router:Router,
- alfrescoSettingsService:AlfrescoSettingsService) {
+ constructor(public auth: AlfrescoAuthenticationService,
+ public router: Router,
+ alfrescoSettingsService: AlfrescoSettingsService) {
alfrescoSettingsService.host = 'http://192.168.99.100:8080';
}
mySuccessMethod($event) {
- console.log('Success Login EventEmitt called with: '+$event.value);
+ console.log('Success Login EventEmitt called with: ' + $event.value);
}
myErrorMethod($event) {
- console.log('Error Login EventEmitt called with: '+$event.value);
+ console.log('Error Login EventEmitt called with: ' + $event.value);
}
-}
\ No newline at end of file
+}
diff --git a/ng2-components/ng2-alfresco-login/demo/app/main.ts b/ng2-components/ng2-alfresco-login/demo/src/my-app.ts
similarity index 87%
rename from ng2-components/ng2-alfresco-login/demo/app/main.ts
rename to ng2-components/ng2-alfresco-login/demo/src/my-app.ts
index b90f93814c..058bdcb66f 100644
--- a/ng2-components/ng2-alfresco-login/demo/app/main.ts
+++ b/ng2-components/ng2-alfresco-login/demo/src/my-app.ts
@@ -16,16 +16,16 @@
*/
import {bootstrap} from 'angular2/platform/browser';
-import {AppComponent} from './app.component';
+import {MyLoginComponent} from './components/my-login.component';
import {ALFRESCO_AUTHENTICATION} from 'ng2-alfresco-login/ng2-alfresco-login';
import {ROUTER_PROVIDERS} from 'angular2/router';
import {provide} from 'angular2/core';
import {Http} from 'angular2/http';
import {HTTP_PROVIDERS} from 'angular2/http';
-import {TRANSLATE_PROVIDERS, TranslateService, TranslateLoader, TranslateStaticLoader} from 'ng2-translate/ng2-translate';
+import {TranslateService, TranslateLoader, TranslateStaticLoader} from 'ng2-translate/ng2-translate';
import {ALFRESCO_CORE_PROVIDERS} from 'ng2-alfresco-core/services';
-bootstrap(AppComponent, [
+bootstrap(MyLoginComponent, [
ROUTER_PROVIDERS,
HTTP_PROVIDERS,
provide(TranslateLoader, {
diff --git a/ng2-components/ng2-alfresco-login/demo/tsconfig.json b/ng2-components/ng2-alfresco-login/demo/tsconfig.json
index 2f3531e7b9..d0f08ba4ce 100644
--- a/ng2-components/ng2-alfresco-login/demo/tsconfig.json
+++ b/ng2-components/ng2-alfresco-login/demo/tsconfig.json
@@ -1,18 +1,17 @@
{
"compilerOptions": {
- "target": "es5",
- "module": "system",
+ "target": "ES5",
+ "module": "commonjs",
"moduleResolution": "node",
- "sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
- "removeComments": false,
- "noImplicitAny": false,
- "declaration": true
+ "sourceMap": true,
+ "removeComments": true,
+ "declaration": true,
+ "outDir": "dist"
},
"exclude": [
"node_modules",
- "typings/main",
- "typings/main.d.ts"
+ "typings"
]
}
diff --git a/ng2-components/ng2-alfresco-login/demo/typings.json b/ng2-components/ng2-alfresco-login/demo/typings.json
index 8d5672dbcf..39a2ebcc56 100644
--- a/ng2-components/ng2-alfresco-login/demo/typings.json
+++ b/ng2-components/ng2-alfresco-login/demo/typings.json
@@ -1,6 +1,9 @@
{
- "ambientDependencies": {
- "es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#7de6c3dd94feaeb21f20054b9f30d5dabc5efabd",
- "jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#5c182b9af717f73146399c2485f70f1e2ac0ff2b"
- }
+ "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"
+ }
}
diff --git a/ng2-components/ng2-alfresco-login/karma.conf.js b/ng2-components/ng2-alfresco-login/karma.conf.js
index f717fb9d8d..d5ba842eb5 100644
--- a/ng2-components/ng2-alfresco-login/karma.conf.js
+++ b/ng2-components/ng2-alfresco-login/karma.conf.js
@@ -75,6 +75,6 @@ module.exports = function (config) {
]
},
- singleRun: false
+ singleRun: true
})
};
diff --git a/ng2-components/ng2-alfresco-login/package.json b/ng2-components/ng2-alfresco-login/package.json
index c0b4a86e12..c96f4118c6 100644
--- a/ng2-components/ng2-alfresco-login/package.json
+++ b/ng2-components/ng2-alfresco-login/package.json
@@ -8,13 +8,15 @@
"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-test && npm run tslint-src && npm run tslint-root",
+ "tslint": "npm run tslint-test && npm run tslint-src && npm run tslint-root && npm run tslint-demo",
"tslint-test": "tslint -c tslint.json test/**/*.ts",
"tslint-src": "tslint -c tslint.json src/**/*.ts",
+ "tslint-demo": "tslint -c tslint.json demo/**/*.ts",
"tslint-root": "tslint -c tslint.json *.ts",
- "copytemplates": "npm run copy-html && npm run copy-css",
+ "copytemplates": "npm run copy-html && npm run copy-css && npm run copy-i18n",
"copy-html": "copyfiles './src/**/*.html' dist",
"copy-css": "copyfiles './src/**/*.css' dist",
+ "copy-i18n": "copyfiles './i18n/**/*.json' dist",
"licensecheck": "license-check",
"tsc": "tsc",
"pretest": "npm run build",
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 14eff08af3..71def92e00 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
@@ -20,154 +20,154 @@ import { Router, ROUTER_DIRECTIVES } from 'angular2/router';
import { FORM_DIRECTIVES, ControlGroup, FormBuilder, Validators } from 'angular2/common';
import { AlfrescoAuthenticationService } from './../services/alfresco-authentication.service';
import { TranslateService, TranslatePipe } from 'ng2-translate/ng2-translate';
-declare let componentHandler;
+declare let componentHandler: any;
declare let __moduleName: string;
@Component({
- selector: 'alfresco-login',
- moduleId: __moduleName,
- directives: [ROUTER_DIRECTIVES, FORM_DIRECTIVES],
- templateUrl: './alfresco-login.component.html',
- styleUrls: ['./alfresco-login.component.css'],
- pipes: [TranslatePipe]
+ selector: 'alfresco-login',
+ moduleId: __moduleName,
+ directives: [ROUTER_DIRECTIVES, FORM_DIRECTIVES],
+ templateUrl: './alfresco-login.component.html',
+ styleUrls: ['./alfresco-login.component.css'],
+ pipes: [TranslatePipe]
})
export class AlfrescoLoginComponent {
- @Output()
- onSuccess = new EventEmitter();
- @Output()
- onError = new EventEmitter();
- translate: TranslateService;
+ @Output()
+ onSuccess = new EventEmitter();
+ @Output()
+ onError = new EventEmitter();
+ translate: TranslateService;
- form: ControlGroup;
- error: boolean = false;
- success: boolean = false;
+ form: ControlGroup;
+ error: boolean = false;
+ success: boolean = false;
- formError: { [id: string]: string };
+ formError: { [id: string]: string };
- private _message: { [id: string]: { [id: string]: string }
- };
-
- /**
- * Constructor
- * @param _fb
- * @param auth
- * @param router
- */
- constructor(private _fb: FormBuilder,
- public auth: AlfrescoAuthenticationService,
- public router: Router,
- translate: TranslateService) {
-
- this.formError = {
- 'username': '',
- 'password': ''
+ private _message: { [id: string]: { [id: string]: string }
};
- this.form = this._fb.group({
- username: ['', Validators.compose([Validators.required, Validators.minLength(4)])],
- password: ['', Validators.required]
- });
+ /**
+ * Constructor
+ * @param _fb
+ * @param auth
+ * @param router
+ */
+ constructor(private _fb: FormBuilder,
+ public auth: AlfrescoAuthenticationService,
+ public router: Router,
+ translate: TranslateService) {
- this._message = {
- 'username': {
- 'required': 'LOGIN.MESSAGES.USERNAME-REQUIRED',
- 'minlength': 'LOGIN.MESSAGES.USERNAME-MIN'
- },
- 'password': {
- 'required': 'LOGIN.MESSAGES.PASSWORD-REQUIRED'
- }
- };
- this.translationInit(translate);
+ this.formError = {
+ 'username': '',
+ 'password': ''
+ };
- this.form.valueChanges.subscribe(data => this.onValueChanged(data));
+ this.form = this._fb.group({
+ username: ['', Validators.compose([Validators.required, Validators.minLength(4)])],
+ password: ['', Validators.required]
+ });
- this.onValueChanged(null);
- }
-
- /**
- * Method called on submit form
- * @param value
- * @param event
- */
- onSubmit(value: any, event) {
- this.error = false;
- if (event) {
- event.preventDefault();
- }
- this.auth.login(value.username, value.password)
- .subscribe(
- (token: any) => {
- try {
- this.success = true;
- this.onSuccess.emit({
- value: 'Login OK'
- });
- this.router.navigate(['Home']);
- } catch (error) {
- console.error(error.message);
- }
-
- },
- (err: any) => {
- this.error = true;
- this.onError.emit({
- value: 'Login KO'
- });
- console.log(err);
- this.success = false;
- },
- () => console.log('Login done')
- );
- }
-
- /**
- * The method check the error in the form and push the error in the formError object
- * @param data
- */
- onValueChanged(data: any) {
- for (let field in this.formError) {
- if (field) {
- this.formError[field] = '';
- let hasError = this.form.controls[field].errors || (this.form.controls[field].dirty && !this.form.controls[field].valid);
- if (hasError) {
- for (let key in this.form.controls[field].errors) {
- if (key) {
- this.formError[field] += this._message[field][key] + '';
+ this._message = {
+ 'username': {
+ 'required': 'LOGIN.MESSAGES.USERNAME-REQUIRED',
+ 'minlength': 'LOGIN.MESSAGES.USERNAME-MIN'
+ },
+ 'password': {
+ 'required': 'LOGIN.MESSAGES.PASSWORD-REQUIRED'
}
- }
+ };
+ this.translationInit(translate);
+
+ this.form.valueChanges.subscribe(data => this.onValueChanged(data));
+
+ this.onValueChanged(null);
+ }
+
+ /**
+ * Method called on submit form
+ * @param value
+ * @param event
+ */
+ onSubmit(value: any, event) {
+ this.error = false;
+ if (event) {
+ event.preventDefault();
}
- }
+ this.auth.login(value.username, value.password)
+ .subscribe(
+ (token: any) => {
+ try {
+ this.success = true;
+ this.onSuccess.emit({
+ value: 'Login OK'
+ });
+ this.router.navigate(['Home']);
+ } catch (error) {
+ console.error(error.message);
+ }
+
+ },
+ (err: any) => {
+ this.error = true;
+ this.onError.emit({
+ value: 'Login KO'
+ });
+ console.log(err);
+ this.success = false;
+ },
+ () => console.log('Login done')
+ );
}
- }
- /**
- * The method return if a field is valid or not
- * @param field
- * @returns {boolean}
- */
- isErrorStyle(field: ControlGroup) {
- if (componentHandler) {
- componentHandler.upgradeAllRegistered();
+ /**
+ * The method check the error in the form and push the error in the formError object
+ * @param data
+ */
+ onValueChanged(data: any) {
+ for (let field in this.formError) {
+ if (field) {
+ this.formError[field] = '';
+ let hasError = this.form.controls[field].errors || (this.form.controls[field].dirty && !this.form.controls[field].valid);
+ if (hasError) {
+ for (let key in this.form.controls[field].errors) {
+ if (key) {
+ this.formError[field] += this._message[field][key] + '';
+ }
+ }
+ }
+ }
+ }
}
- if (field.valid) {
- return false;
- } else {
- return true;
+
+ /**
+ * The method return if a field is valid or not
+ * @param field
+ * @returns {boolean}
+ */
+ isErrorStyle(field: ControlGroup) {
+ if (typeof componentHandler !== 'undefined') {
+ componentHandler.upgradeAllRegistered();
+ }
+ if (field.valid) {
+ return false;
+ } else {
+ return true;
+ }
}
- }
- /**
- * Initial configuration for Multi language
- * @param translate
- */
- translationInit(translate: TranslateService) {
- this.translate = translate;
- let userLang = navigator.language.split('-')[0]; // use navigator lang if available
- userLang = /(fr|en)/gi.test(userLang) ? userLang : 'en';
+ /**
+ * Initial configuration for Multi language
+ * @param translate
+ */
+ translationInit(translate: TranslateService) {
+ this.translate = translate;
+ let userLang = navigator.language.split('-')[0]; // use navigator lang if available
+ userLang = /(fr|en)/gi.test(userLang) ? userLang : 'en';
- this.translate.setDefaultLang(userLang);
+ this.translate.setDefaultLang(userLang);
- this.translate.use(userLang);
- }
+ this.translate.use(userLang);
+ }
}
diff --git a/ng2-components/ng2-alfresco-upload/.gitignore b/ng2-components/ng2-alfresco-upload/.gitignore
index 17e27059f5..06a7f7934f 100644
--- a/ng2-components/ng2-alfresco-upload/.gitignore
+++ b/ng2-components/ng2-alfresco-upload/.gitignore
@@ -7,5 +7,9 @@ coverage
dist
src/**/*.js
src/**/*.js.map
+src/**/*.d.ts
+demo/**/*.js
+demo/**/*.js.map
+demo/**/*.d.ts
ng2-alfresco-upload.js
ng2-alfresco-upload.js.map
diff --git a/ng2-components/ng2-alfresco-upload/demo/.gitignore b/ng2-components/ng2-alfresco-upload/demo/.gitignore
new file mode 100644
index 0000000000..d728305c75
--- /dev/null
+++ b/ng2-components/ng2-alfresco-upload/demo/.gitignore
@@ -0,0 +1,5 @@
+node_modules
+.idea
+coverage
+dist
+typings
\ No newline at end of file
diff --git a/ng2-components/ng2-alfresco-upload/demo/LICENSE b/ng2-components/ng2-alfresco-upload/demo/LICENSE
new file mode 100644
index 0000000000..059fc6c668
--- /dev/null
+++ b/ng2-components/ng2-alfresco-upload/demo/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2016 Raúl Jiménez
+
+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:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+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.
diff --git a/ng2-components/ng2-alfresco-upload/demo/README.md b/ng2-components/ng2-alfresco-upload/demo/README.md
new file mode 100644
index 0000000000..9f87666579
--- /dev/null
+++ b/ng2-components/ng2-alfresco-upload/demo/README.md
@@ -0,0 +1,13 @@
+# angular2-testing
+
+Install:
+
+```
+npm install
+```
+
+Run the project:
+
+```
+npm start
+```
\ No newline at end of file
diff --git a/ng2-components/ng2-alfresco-upload/demo/demo.html b/ng2-components/ng2-alfresco-upload/demo/demo.html
deleted file mode 100644
index 7b1ddc3455..0000000000
--- a/ng2-components/ng2-alfresco-upload/demo/demo.html
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ng2-components/ng2-alfresco-upload/demo/index.html b/ng2-components/ng2-alfresco-upload/demo/index.html
new file mode 100644
index 0000000000..cbb462b986
--- /dev/null
+++ b/ng2-components/ng2-alfresco-upload/demo/index.html
@@ -0,0 +1,67 @@
+
+
+
+
+ Angular 2 Upload
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ng2-components/ng2-alfresco-upload/demo/package.json b/ng2-components/ng2-alfresco-upload/demo/package.json
new file mode 100644
index 0000000000..0b20919e95
--- /dev/null
+++ b/ng2-components/ng2-alfresco-upload/demo/package.json
@@ -0,0 +1,35 @@
+{
+ "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 && npm link ng2-alfresco-upload && npm link ng2-alfresco-core",
+ "typings": "typings install",
+ "start": "rm -rf dist && npm install && http-server -c-1 -o -p 8875 .",
+ "build": "rm -rf dist && tsc"
+ },
+ "license": "MIT",
+ "dependencies": {
+ "angular2": "2.0.0-beta.13",
+ "es6-promise": "3.0.2",
+ "es6-shim": "0.35.0",
+ "reflect-metadata": "0.1.2",
+ "rxjs": "5.0.0-beta.2",
+ "zone.js": "0.6.6",
+ "ng2-translate": "^1.11.2",
+ "material-design-icons": "^2.2.3",
+ "material-design-lite": "^1.1.3"
+ },
+ "devDependencies": {
+ "http-server": "0.8.5",
+ "systemjs": "0.19.17",
+ "typescript": "1.7.5",
+ "typings": "0.6.8"
+ },
+ "keywords": [
+ "angular2",
+ "typescript"
+ ]
+}
diff --git a/ng2-components/ng2-alfresco-login/demo/app/home.component.ts b/ng2-components/ng2-alfresco-upload/demo/src/components/my-demo.component.ts
similarity index 51%
rename from ng2-components/ng2-alfresco-login/demo/app/home.component.ts
rename to ng2-components/ng2-alfresco-upload/demo/src/components/my-demo.component.ts
index 0f0f9c94c2..da206ea2a0 100644
--- a/ng2-components/ng2-alfresco-login/demo/app/home.component.ts
+++ b/ng2-components/ng2-alfresco-upload/demo/src/components/my-demo.component.ts
@@ -1,3 +1,5 @@
+///
+
/**
* @license
* Copyright 2016 Alfresco Software, Ltd.
@@ -15,13 +17,18 @@
* limitations under the License.
*/
-import {Component} from 'angular2/core';
+import { Component } from 'angular2/core';
+import { ALFRESCO_ULPOAD_COMPONENT } from 'ng2-alfresco-upload/dist/ng2-alfresco-upload';
@Component({
- selector: 'home',
- template: 'Welcome'
+ selector: 'my-demo',
+ template: `
+ `,
+ directives: [ALFRESCO_ULPOAD_COMPONENT]
})
+export class MyDemoComponent {
-export class HomeComponent {
-
-}
\ No newline at end of file
+}
diff --git a/ng2-components/ng2-alfresco-upload/demo/src/my-app.ts b/ng2-components/ng2-alfresco-upload/demo/src/my-app.ts
new file mode 100644
index 0000000000..e5cdfbba1a
--- /dev/null
+++ b/ng2-components/ng2-alfresco-upload/demo/src/my-app.ts
@@ -0,0 +1,40 @@
+/**
+ * @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, provide } from 'angular2/core';
+import { bootstrap } from 'angular2/platform/browser';
+import { HTTP_PROVIDERS } from 'angular2/http';
+import { MyDemoComponent } from "./components/my-demo.component";
+import { TranslateLoader, TranslateService } from 'ng2-translate/ng2-translate';
+import { AlfrescoTranslationLoader } from 'ng2-alfresco-core/services';
+
+@Component({
+ selector: 'my-app',
+ template: '',
+ directives: [MyDemoComponent]
+})
+class VgDemo {
+ constructor() {
+
+ }
+}
+
+bootstrap(VgDemo, [
+ HTTP_PROVIDERS,
+ provide(TranslateLoader, {useClass: AlfrescoTranslationLoader}),
+ TranslateService
+]);
diff --git a/ng2-components/ng2-alfresco-upload/demo/tsconfig.json b/ng2-components/ng2-alfresco-upload/demo/tsconfig.json
new file mode 100644
index 0000000000..d0f08ba4ce
--- /dev/null
+++ b/ng2-components/ng2-alfresco-upload/demo/tsconfig.json
@@ -0,0 +1,17 @@
+{
+ "compilerOptions": {
+ "target": "ES5",
+ "module": "commonjs",
+ "moduleResolution": "node",
+ "emitDecoratorMetadata": true,
+ "experimentalDecorators": true,
+ "sourceMap": true,
+ "removeComments": true,
+ "declaration": true,
+ "outDir": "dist"
+ },
+ "exclude": [
+ "node_modules",
+ "typings"
+ ]
+}
diff --git a/ng2-components/ng2-alfresco-upload/demo/typings.json b/ng2-components/ng2-alfresco-upload/demo/typings.json
new file mode 100644
index 0000000000..39a2ebcc56
--- /dev/null
+++ b/ng2-components/ng2-alfresco-upload/demo/typings.json
@@ -0,0 +1,9 @@
+{
+ "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"
+ }
+}
diff --git a/ng2-components/ng2-alfresco-upload/package.json b/ng2-components/ng2-alfresco-upload/package.json
index b4bb37f32c..9b2fabb1c5 100644
--- a/ng2-components/ng2-alfresco-upload/package.json
+++ b/ng2-components/ng2-alfresco-upload/package.json
@@ -12,9 +12,10 @@
"tslint-test": "tslint -c tslint.json test/**/*.ts",
"tslint-src": "tslint -c tslint.json src/**/*.ts",
"tslint-root": "tslint -c tslint.json *.ts",
- "copytemplates": "npm run copy-html && npm run copy-css",
+ "copytemplates": "npm run copy-html && npm run copy-css && npm run copy-i18n",
"copy-html": "copyfiles './src/**/*.html' dist",
"copy-css": "copyfiles './src/**/*.css' dist",
+ "copy-i18n": "copyfiles './i18n/**/*.json' dist",
"licensecheck": "license-check",
"tsc": "tsc",
"pretest": "npm run build",
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 4ab392801e..b375d65c0a 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
@@ -16,11 +16,12 @@
*/
-import { Component, ViewChild, ElementRef, Input, Output, EventEmitter } from 'angular2/core';
+import { Component, ViewChild, ElementRef, Input, Output, EventEmitter, Optional } from 'angular2/core';
import { UploadService } from '../services/upload.service';
import { FileModel } from '../models/file.model';
import { FileUploadingDialogComponent } from './file-uploading-dialog.component';
import { TranslateService, TranslatePipe } from 'ng2-translate/ng2-translate';
+import 'rxjs/Rx';
declare let componentHandler: any;
declare let __moduleName: string;
@@ -88,7 +89,7 @@ export class UploadButtonComponent {
private _uploaderService: UploadService;
constructor(public el: ElementRef,
- translate: TranslateService) {
+ @Optional() translate: TranslateService) {
console.log('UploadComponent constructor', el);
this._uploaderService = new UploadService({
@@ -103,7 +104,9 @@ export class UploadButtonComponent {
}
});
- this.translationInit(translate);
+ if (translate) {
+ this.translationInit(translate);
+ }
}
/**
diff --git a/ng2-components/ng2-alfresco-viewer/.gitignore b/ng2-components/ng2-alfresco-viewer/.gitignore
index f902001d8e..b8553684da 100644
--- a/ng2-components/ng2-alfresco-viewer/.gitignore
+++ b/ng2-components/ng2-alfresco-viewer/.gitignore
@@ -7,3 +7,7 @@ coverage
dist
src/**/*.js
src/**/*.js.map
+src/**/*.d.ts
+demo/**/*.js
+demo/**/*.js.map
+demo/**/*.d.ts
diff --git a/ng2-components/ng2-alfresco-viewer/package.json b/ng2-components/ng2-alfresco-viewer/package.json
index 6c9b62472c..79c1f2f00e 100644
--- a/ng2-components/ng2-alfresco-viewer/package.json
+++ b/ng2-components/ng2-alfresco-viewer/package.json
@@ -17,9 +17,10 @@
"tslint-test": "tslint -c tslint.json test/**/*.ts",
"tslint-src": "tslint -c tslint.json src/**/*.ts",
"tslint-root": "tslint -c tslint.json *.ts",
- "copytemplates": "npm run copy-html && npm run copy-css",
+ "copytemplates": "npm run copy-html && npm run copy-css && npm run copy-i18n",
"copy-html": "copyfiles './src/**/*.html' dist",
"copy-css": "copyfiles './src/**/*.css' dist",
+ "copy-i18n": "copyfiles './i18n/**/*.json' dist",
"licensecheck": "license-check",
"tsc": "tsc",
"pretest": "npm run build",