mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
Update from development branch
This commit is contained in:
@@ -24,7 +24,7 @@
|
|||||||
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
||||||
|
|
||||||
<script src="/app/js/xml2json.js"></script>
|
<script src="/app/js/xml2json.js"></script>
|
||||||
<script src="node_modules/alfresco-js-api/bundle.js"></script>
|
<script src="node_modules/alfresco-js-api/dist/alfresco-js-api.js"></script>
|
||||||
|
|
||||||
<script src="node_modules/pdfjs-dist/build/pdf.js"></script>
|
<script src="node_modules/pdfjs-dist/build/pdf.js"></script>
|
||||||
<script src="node_modules/pdfjs-dist/build/pdf.worker.js"></script>
|
<script src="node_modules/pdfjs-dist/build/pdf.worker.js"></script>
|
||||||
|
@@ -75,7 +75,7 @@
|
|||||||
"pdfjs-dist": "1.5.258",
|
"pdfjs-dist": "1.5.258",
|
||||||
"flag-icon-css": "2.3.0",
|
"flag-icon-css": "2.3.0",
|
||||||
|
|
||||||
"alfresco-js-api": "^0.1.0",
|
"alfresco-js-api": "0.2.0",
|
||||||
"ng2-alfresco-core": "0.2.0",
|
"ng2-alfresco-core": "0.2.0",
|
||||||
"ng2-alfresco-datatable": "0.2.0",
|
"ng2-alfresco-datatable": "0.2.0",
|
||||||
"ng2-alfresco-documentlist": "0.2.0",
|
"ng2-alfresco-documentlist": "0.2.0",
|
||||||
|
@@ -15,6 +15,7 @@ var map = {
|
|||||||
var packages = {
|
var packages = {
|
||||||
'app': { main: 'main.js', defaultExtension: 'js' },
|
'app': { main: 'main.js', defaultExtension: 'js' },
|
||||||
'rxjs': { defaultExtension: 'js' },
|
'rxjs': { defaultExtension: 'js' },
|
||||||
|
'alfresco-js-api' : { main: 'alfresco-js-api.js', defaultExtension: 'js' },
|
||||||
'ng2-translate': { defaultExtension: 'js' }
|
'ng2-translate': { defaultExtension: 'js' }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -11,10 +11,13 @@ module.exports = function (config) {
|
|||||||
{pattern: 'node_modules/reflect-metadata/Reflect.js', included: true, watched: true},
|
{pattern: 'node_modules/reflect-metadata/Reflect.js', included: true, watched: true},
|
||||||
{pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: false},
|
{pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: false},
|
||||||
{pattern: 'node_modules/zone.js/dist/zone.js', included: true, watched: true},
|
{pattern: 'node_modules/zone.js/dist/zone.js', included: true, watched: true},
|
||||||
|
{pattern: 'node_modules/zone.js/dist/async-test.js', included: true, watched: true},
|
||||||
|
|
||||||
{pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false},
|
{pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false},
|
||||||
{pattern: 'node_modules/rxjs/**/*.map', included: false, watched: false},
|
{pattern: 'node_modules/rxjs/**/*.map', included: false, watched: false},
|
||||||
{pattern: 'node_modules/@angular/**/*.js', included: false, watched: false},
|
{pattern: 'node_modules/@angular/**/*.js', included: false, watched: false},
|
||||||
{pattern: 'node_modules/@angular/**/*.map', included: false, watched: false},
|
{pattern: 'node_modules/@angular/**/*.map', included: false, watched: false},
|
||||||
|
{pattern: 'node_modules/alfresco-js-api/dist/alfresco-js-api.js', included: true, watched: false},
|
||||||
|
|
||||||
{pattern: 'karma-test-shim.js', included: true, watched: true},
|
{pattern: 'karma-test-shim.js', included: true, watched: true},
|
||||||
|
|
||||||
|
@@ -6,19 +6,15 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"clean": "rimraf dist node_modules typings",
|
"clean": "rimraf dist node_modules typings",
|
||||||
"typings": "typings install",
|
"typings": "typings install",
|
||||||
"build": "npm run tslint && typings install && rimraf dist && tsc && npm run copytemplates && license-check",
|
"build": "npm run tslint && typings install && rimraf dist && tsc && license-check",
|
||||||
|
"build:w": "npm run tslint && typings install && rimraf dist && npm run watch-task",
|
||||||
|
"watch-task": "concurrently \"npm run tsc:w\" \"license-check\"",
|
||||||
"tslint": "npm run tslint-src && npm run tslint-root",
|
"tslint": "npm run tslint-src && npm run tslint-root",
|
||||||
"tslint-src": "tslint -c tslint.json src/{,**/}**.ts",
|
"tslint-src": "tslint -c tslint.json src/{,**/}**.ts",
|
||||||
"tslint-root": "tslint -c tslint.json *.ts",
|
"tslint-root": "tslint -c tslint.json *.ts",
|
||||||
"copytemplates": "npm run copy-html-css && npm run copy-i18n",
|
|
||||||
"copy-html-css": "cpx \"./src/**/*.{html,css}\" ./dist/src",
|
|
||||||
"copy-html-css:w": "cpx \"./src/**/*.{html,css}\" ./dist/src -w",
|
|
||||||
"copy-i18n": "cpx \"./i18n/**/*.json\" ./dist/i18n",
|
|
||||||
"copy-i18n:w": "cpx \"./i18n/**/*.json\" ./dist/i18n -w",
|
|
||||||
"copy-images": "cpx \"./src/**/*.{png,jpg,gif,svg}\" ./dist/src",
|
|
||||||
"copy-images:w": "cpx \"./src/**/*.{png,jpg,gif,svg}\" ./dist/src -w",
|
|
||||||
"licensecheck": "license-check",
|
"licensecheck": "license-check",
|
||||||
"tsc": "tsc",
|
"tsc": "tsc",
|
||||||
|
"tsc:w": "tsc -w",
|
||||||
"pretest": "npm run build",
|
"pretest": "npm run build",
|
||||||
"test": "karma start karma.conf.js --reporters mocha,coverage --single-run",
|
"test": "karma start karma.conf.js --reporters mocha,coverage --single-run",
|
||||||
"test-browser": "karma start karma.conf.js --reporters kjhtml ",
|
"test-browser": "karma start karma.conf.js --reporters kjhtml ",
|
||||||
@@ -45,6 +41,10 @@
|
|||||||
{
|
{
|
||||||
"name": "Mario Romano",
|
"name": "Mario Romano",
|
||||||
"email": "mario.romano83@gmail.com"
|
"email": "mario.romano83@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Eugenio Romano",
|
||||||
|
"email": "eugenio.romano@alfresco.com"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -54,6 +54,7 @@
|
|||||||
"alfresco"
|
"alfresco"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"alfresco-js-api": "^0.2.0",
|
||||||
"@angular/common": "2.0.0-rc.3",
|
"@angular/common": "2.0.0-rc.3",
|
||||||
"@angular/compiler": "2.0.0-rc.3",
|
"@angular/compiler": "2.0.0-rc.3",
|
||||||
"@angular/core": "2.0.0-rc.3",
|
"@angular/core": "2.0.0-rc.3",
|
||||||
@@ -69,8 +70,7 @@
|
|||||||
"reflect-metadata": "0.1.3",
|
"reflect-metadata": "0.1.3",
|
||||||
"rxjs": "5.0.0-beta.6",
|
"rxjs": "5.0.0-beta.6",
|
||||||
"zone.js": "0.6.12",
|
"zone.js": "0.6.12",
|
||||||
"ng2-translate": "2.2.2",
|
"ng2-translate": "2.2.2"
|
||||||
"rimraf": "2.5.2"
|
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"material-design-icons": "^2.2.3",
|
"material-design-icons": "^2.2.3",
|
||||||
@@ -90,6 +90,7 @@
|
|||||||
"karma-mocha-reporter": "2.0.3",
|
"karma-mocha-reporter": "2.0.3",
|
||||||
"license-check": "1.1.5",
|
"license-check": "1.1.5",
|
||||||
"remap-istanbul": "0.6.3",
|
"remap-istanbul": "0.6.3",
|
||||||
|
"rimraf": "2.5.2",
|
||||||
"traceur": "0.0.91",
|
"traceur": "0.0.91",
|
||||||
"tslint": "3.8.1",
|
"tslint": "3.8.1",
|
||||||
"typescript": "1.8.10",
|
"typescript": "1.8.10",
|
||||||
|
@@ -0,0 +1,35 @@
|
|||||||
|
/*!
|
||||||
|
* @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 AlfrescoApiMock {
|
||||||
|
|
||||||
|
login(username: string, password: string) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
resolve('TICKET_4479f4d3bb155195879bfbb8d5206f433488a1b1');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
logout() {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
resolve('logout');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
changeConfig() {
|
||||||
|
}
|
||||||
|
}
|
@@ -19,6 +19,7 @@ import { Observable } from 'rxjs/Rx';
|
|||||||
|
|
||||||
export interface AbstractAuthentication {
|
export interface AbstractAuthentication {
|
||||||
TYPE: string;
|
TYPE: string;
|
||||||
|
alfrescoApi: any;
|
||||||
|
|
||||||
login(username: string, password: string): Observable<any>;
|
login(username: string, password: string): Observable<any>;
|
||||||
|
|
||||||
@@ -26,8 +27,7 @@ export interface AbstractAuthentication {
|
|||||||
|
|
||||||
isLoggedIn(): boolean ;
|
isLoggedIn(): boolean ;
|
||||||
|
|
||||||
getToken(): string;
|
getTicket(): string;
|
||||||
|
|
||||||
saveToken(): void;
|
|
||||||
|
|
||||||
|
saveTicket(ticket: any): void;
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,6 @@ import { AlfrescoSettingsService } from './AlfrescoSettingsService.service';
|
|||||||
export class AlfrescoAuthenticationBPM extends AlfrescoAuthenticationBase implements AbstractAuthentication {
|
export class AlfrescoAuthenticationBPM extends AlfrescoAuthenticationBase implements AbstractAuthentication {
|
||||||
|
|
||||||
TYPE: string = 'BPM';
|
TYPE: string = 'BPM';
|
||||||
private token: string;
|
|
||||||
|
|
||||||
constructor(private alfrescoSettingsService: AlfrescoSettingsService,
|
constructor(private alfrescoSettingsService: AlfrescoSettingsService,
|
||||||
private http: Http) {
|
private http: Http) {
|
||||||
@@ -41,9 +40,8 @@ export class AlfrescoAuthenticationBPM extends AlfrescoAuthenticationBase implem
|
|||||||
login(username: string, password: string): Observable<any> {
|
login(username: string, password: string): Observable<any> {
|
||||||
return Observable.fromPromise(this.apiActivitiLogin(username, password))
|
return Observable.fromPromise(this.apiActivitiLogin(username, password))
|
||||||
.map((response: any) => {
|
.map((response: any) => {
|
||||||
this.token = response.status;
|
this.saveTicket(response.status);
|
||||||
return this.token;
|
return response.status;
|
||||||
// return {name: this.TYPE, token: response.status};
|
|
||||||
})
|
})
|
||||||
.catch(this.handleError);
|
.catch(this.handleError);
|
||||||
}
|
}
|
||||||
@@ -57,7 +55,7 @@ export class AlfrescoAuthenticationBPM extends AlfrescoAuthenticationBase implem
|
|||||||
return Observable.fromPromise(this.apiActivitiLogout())
|
return Observable.fromPromise(this.apiActivitiLogout())
|
||||||
.map(res => <any> res)
|
.map(res => <any> res)
|
||||||
.do(response => {
|
.do(response => {
|
||||||
this.removeToken(this.TYPE);
|
this.removeTicket(this.TYPE);
|
||||||
})
|
})
|
||||||
.catch(this.handleError);
|
.catch(this.handleError);
|
||||||
}
|
}
|
||||||
@@ -67,7 +65,7 @@ export class AlfrescoAuthenticationBPM extends AlfrescoAuthenticationBase implem
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
isLoggedIn(): boolean {
|
isLoggedIn(): boolean {
|
||||||
return !!this.getToken();
|
return !!this.getTicket();
|
||||||
}
|
}
|
||||||
|
|
||||||
private apiActivitiLogin(username: string, password: string) {
|
private apiActivitiLogin(username: string, password: string) {
|
||||||
@@ -91,17 +89,17 @@ export class AlfrescoAuthenticationBPM extends AlfrescoAuthenticationBase implem
|
|||||||
return this.http.get(url).toPromise();
|
return this.http.get(url).toPromise();
|
||||||
}
|
}
|
||||||
|
|
||||||
public getToken (): string {
|
public getTicket(): string {
|
||||||
return localStorage.getItem(`token-${this.TYPE}`);
|
return localStorage.getItem(`ticket-${this.TYPE}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The method save the toke in the localStorage
|
* The method save the ticket in the localStorage
|
||||||
* @param token
|
* @param ticket
|
||||||
*/
|
*/
|
||||||
public saveToken(): void {
|
public saveTicket(ticket): void {
|
||||||
if (this.token) {
|
if (ticket) {
|
||||||
super.saveToken(this.TYPE, this.token);
|
super.saveTicket(this.TYPE, ticket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -23,6 +23,8 @@ declare let AlfrescoApi: any;
|
|||||||
|
|
||||||
export class AlfrescoAuthenticationBase {
|
export class AlfrescoAuthenticationBase {
|
||||||
|
|
||||||
|
alfrescoApi: any;
|
||||||
|
|
||||||
private _authUrl: string = '/alfresco/api/-default-/public/authentication/versions/1';
|
private _authUrl: string = '/alfresco/api/-default-/public/authentication/versions/1';
|
||||||
private alfrescoSetting: AlfrescoSettingsService;
|
private alfrescoSetting: AlfrescoSettingsService;
|
||||||
/**
|
/**
|
||||||
@@ -40,19 +42,19 @@ export class AlfrescoAuthenticationBase {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The method save the toke in the localStorage
|
* The method save the toke in the localStorage
|
||||||
* @param token
|
* @param ticket
|
||||||
*/
|
*/
|
||||||
public saveToken(provider:string, token: string): void {
|
public saveTicket(provider:string, ticket: string): void {
|
||||||
if (token) {
|
if (ticket) {
|
||||||
localStorage.setItem(`token-${provider}`, token);
|
localStorage.setItem(`ticket-${provider}`, ticket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the login token from localStorage
|
* Remove the login ticket from localStorage
|
||||||
*/
|
*/
|
||||||
public removeToken(provider:string): void {
|
public removeTicket(provider:string): void {
|
||||||
localStorage.removeItem(`token-${provider}`);
|
localStorage.removeItem(`ticket-${provider}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -26,84 +26,97 @@ declare let AlfrescoApi: any;
|
|||||||
export class AlfrescoAuthenticationECM extends AlfrescoAuthenticationBase implements AbstractAuthentication {
|
export class AlfrescoAuthenticationECM extends AlfrescoAuthenticationBase implements AbstractAuthentication {
|
||||||
|
|
||||||
TYPE: string = 'ECM';
|
TYPE: string = 'ECM';
|
||||||
private token: string;
|
|
||||||
|
|
||||||
|
alfrescoApi: any;
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param alfrescoSettingsService
|
||||||
|
*/
|
||||||
constructor(private alfrescoSettingsService: AlfrescoSettingsService,
|
constructor(private alfrescoSettingsService: AlfrescoSettingsService,
|
||||||
private http: Http) {
|
private http: Http) {
|
||||||
super(alfrescoSettingsService, http);
|
super(alfrescoSettingsService, http);
|
||||||
|
|
||||||
|
if (!this.isLoggedIn) {
|
||||||
|
this.alfrescoApi = new AlfrescoApi({
|
||||||
|
host: this.getBaseUrl()
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.alfrescoApi = new AlfrescoApi({
|
||||||
|
ticket: this.getTicket(),
|
||||||
|
host: this.getBaseUrl()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getBaseUrl(): string {
|
||||||
|
return this.alfrescoSettingsService.host;
|
||||||
|
}
|
||||||
|
|
||||||
|
getAlfrescoApi(): any {
|
||||||
|
return this.alfrescoApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform a login on behalf of the user and store the ticket returned
|
* The method return tru if the user is logged in
|
||||||
*
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
isLoggedIn(): boolean {
|
||||||
|
return !!this.getTicket();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to delegate to POST login
|
||||||
* @param username
|
* @param username
|
||||||
* @param password
|
* @param password
|
||||||
* @returns {Observable<R>|Observable<T>}
|
* @returns {Observable<R>|Observable<T>}
|
||||||
*/
|
*/
|
||||||
login(username: string, password: string): Observable<any> {
|
login(username: string, password: string) {
|
||||||
return Observable.fromPromise(this.getCreateTicketPromise(username, password))
|
this.alfrescoApi = new AlfrescoApi({
|
||||||
.map((response: any) => {
|
username: username,
|
||||||
this.token = response.entry.id;
|
password: password,
|
||||||
return this.token;
|
host: this.getBaseUrl()
|
||||||
// return {name: this.TYPE, token: response.entry.id};
|
});
|
||||||
|
|
||||||
|
return Observable.fromPromise(this.alfrescoApi.login())
|
||||||
|
.map(res => <any> res)
|
||||||
|
.do(response => {
|
||||||
|
this.saveTicket(response);
|
||||||
|
return response;
|
||||||
})
|
})
|
||||||
.catch(this.handleError);
|
.catch(this.handleError);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete the current login ticket from the server
|
* The method remove the ticket from the local storage
|
||||||
*
|
*
|
||||||
* @returns {Observable<R>|Observable<T>}
|
* @returns {Observable<R>|Observable<T>}
|
||||||
*/
|
*/
|
||||||
logout() {
|
public logout() {
|
||||||
return Observable.fromPromise(this.getDeleteTicketPromise())
|
return Observable.fromPromise(this.alfrescoApi.logout())
|
||||||
.map(res => <any> res)
|
.map(res => <any> res)
|
||||||
.do(response => {
|
.do(response => {
|
||||||
this.removeToken(this.TYPE);
|
this.removeTicket(this.TYPE);
|
||||||
|
return response;
|
||||||
})
|
})
|
||||||
.catch(this.handleError);
|
.catch(this.handleError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The method return true if the user is logged in
|
* The method return the ticket stored in the localStorage
|
||||||
* @returns {boolean}
|
* @returns ticket
|
||||||
*/
|
*/
|
||||||
isLoggedIn(): boolean {
|
public getTicket(): string {
|
||||||
return !!this.getToken();
|
return localStorage.getItem(`ticket-${this.TYPE}`);
|
||||||
}
|
|
||||||
|
|
||||||
private getAlfrescoClient() {
|
|
||||||
return AlfrescoApi.getClientWithTicket(this.getBaseUrl(), this.getToken());
|
|
||||||
}
|
|
||||||
|
|
||||||
private getCreateTicketPromise(username: string, password: string) {
|
|
||||||
let apiInstance = new AlfrescoApi.Auth.AuthenticationApi(this.getAlfrescoClient());
|
|
||||||
let loginRequest = new AlfrescoApi.Auth.LoginRequest();
|
|
||||||
loginRequest.userId = username;
|
|
||||||
loginRequest.password = password;
|
|
||||||
return apiInstance.createTicket(loginRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
private getDeleteTicketPromise() {
|
|
||||||
let apiInstance = new AlfrescoApi.Auth.AuthenticationApi(this.getAlfrescoClient());
|
|
||||||
return apiInstance.deleteTicket();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The method return the token stored in the localStorage
|
* The method save the ticket in the localStorage
|
||||||
* @param token
|
* @param ticket
|
||||||
*/
|
*/
|
||||||
public getToken (): string {
|
public saveTicket(ticket): void {
|
||||||
return localStorage.getItem(`token-${this.TYPE}`);
|
if (ticket) {
|
||||||
}
|
super.saveTicket(this.TYPE, ticket);
|
||||||
|
|
||||||
/**
|
|
||||||
* The method save the toke in the localStorage
|
|
||||||
* @param token
|
|
||||||
*/
|
|
||||||
public saveToken(): void {
|
|
||||||
if (this.token) {
|
|
||||||
super.saveToken(this.TYPE, this.token);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -36,7 +36,7 @@ describe('AlfrescoAuthentication', () => {
|
|||||||
resolve({
|
resolve({
|
||||||
entry: {
|
entry: {
|
||||||
userId: 'fake-username',
|
userId: 'fake-username',
|
||||||
id: 'fake-post-token-ECM'
|
id: 'fake-post-ticket-ECM'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
reject({
|
reject({
|
||||||
@@ -48,7 +48,7 @@ describe('AlfrescoAuthentication', () => {
|
|||||||
|
|
||||||
fakePromiseBPM = new Promise(function (resolve, reject) {
|
fakePromiseBPM = new Promise(function (resolve, reject) {
|
||||||
resolve({
|
resolve({
|
||||||
status: 'fake-post-token-BPM'
|
status: 'fake-post-ticket-BPM'
|
||||||
});
|
});
|
||||||
reject({
|
reject({
|
||||||
response: {
|
response: {
|
||||||
@@ -109,7 +109,7 @@ describe('AlfrescoAuthentication', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return an ECM token after the login done', (done) => {
|
it('should return an ECM ticket after the login done', (done) => {
|
||||||
let providers = ['ECM'];
|
let providers = ['ECM'];
|
||||||
let alfSetting = injector.get(AlfrescoSettingsService);
|
let alfSetting = injector.get(AlfrescoSettingsService);
|
||||||
alfSetting.providers = providers;
|
alfSetting.providers = providers;
|
||||||
@@ -120,13 +120,13 @@ describe('AlfrescoAuthentication', () => {
|
|||||||
service.login('fake-username', 'fake-password', providers)
|
service.login('fake-username', 'fake-password', providers)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
expect(service.isLoggedIn(providers[0])).toBe(true);
|
expect(service.isLoggedIn(providers[0])).toBe(true);
|
||||||
expect(service.getToken(providers[0])).toEqual('fake-post-token-ECM');
|
expect(service.getTicket(providers[0])).toEqual('fake-post-ticket-ECM');
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return token undefined when the credentials are wrong', (done) => {
|
it('should return ticket undefined when the credentials are wrong', (done) => {
|
||||||
let providers = ['ECM'];
|
let providers = ['ECM'];
|
||||||
let alfSetting = injector.get(AlfrescoSettingsService);
|
let alfSetting = injector.get(AlfrescoSettingsService);
|
||||||
alfSetting.providers = providers;
|
alfSetting.providers = providers;
|
||||||
@@ -142,7 +142,7 @@ describe('AlfrescoAuthentication', () => {
|
|||||||
},
|
},
|
||||||
(err: any) => {
|
(err: any) => {
|
||||||
expect(service.isLoggedIn(providers[0])).toBe(false);
|
expect(service.isLoggedIn(providers[0])).toBe(false);
|
||||||
expect(service.getToken(providers[0])).toBeUndefined();
|
expect(service.getTicket(providers[0])).toBeUndefined();
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -186,21 +186,21 @@ describe('AlfrescoAuthentication', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a token undefined after logout', (done) => {
|
it('should return a ticket undefined after logout', (done) => {
|
||||||
let providers = ['ECM'];
|
let providers = ['ECM'];
|
||||||
let alfSetting = injector.get(AlfrescoSettingsService);
|
let alfSetting = injector.get(AlfrescoSettingsService);
|
||||||
alfSetting.providers = providers;
|
alfSetting.providers = providers;
|
||||||
|
|
||||||
service = injector.get(AlfrescoAuthenticationService);
|
service = injector.get(AlfrescoAuthenticationService);
|
||||||
localStorage.setItem('token-ECM', 'fake-post-token-ECM');
|
localStorage.setItem('ticket-ECM', 'fake-post-ticket-ECM');
|
||||||
service.createProviderInstance(providers);
|
service.createProviderInstance(providers);
|
||||||
spyOn(AlfrescoAuthenticationECM.prototype, 'getDeleteTicketPromise').and.returnValue(fakePromiseECM);
|
spyOn(AlfrescoAuthenticationECM.prototype, 'getDeleteTicketPromise').and.returnValue(fakePromiseECM);
|
||||||
|
|
||||||
service.logout()
|
service.logout()
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
expect(service.isLoggedIn(providers[0])).toBe(false);
|
expect(service.isLoggedIn(providers[0])).toBe(false);
|
||||||
expect(service.getToken(providers[0])).toBeUndefined();
|
expect(service.getTicket(providers[0])).toBeUndefined();
|
||||||
expect(localStorage.getItem('token-ECM')).toBeUndefined();
|
expect(localStorage.getItem('ticket-ECM')).toBeUndefined();
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -252,7 +252,7 @@ describe('AlfrescoAuthentication', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return an BPM token after the login done', (done) => {
|
it('should return an BPM ticket after the login done', (done) => {
|
||||||
let providers = ['BPM'];
|
let providers = ['BPM'];
|
||||||
let alfSetting = injector.get(AlfrescoSettingsService);
|
let alfSetting = injector.get(AlfrescoSettingsService);
|
||||||
alfSetting.providers = providers;
|
alfSetting.providers = providers;
|
||||||
@@ -263,13 +263,13 @@ describe('AlfrescoAuthentication', () => {
|
|||||||
service.login('fake-username', 'fake-password', providers)
|
service.login('fake-username', 'fake-password', providers)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
expect(service.isLoggedIn(providers[0])).toBe(true);
|
expect(service.isLoggedIn(providers[0])).toBe(true);
|
||||||
expect(service.getToken(providers[0])).toEqual('fake-post-token-BPM');
|
expect(service.getTicket(providers[0])).toEqual('fake-post-ticket-BPM');
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return token undefined when the credentials are wrong', (done) => {
|
it('should return ticket undefined when the credentials are wrong', (done) => {
|
||||||
let providers = ['BPM'];
|
let providers = ['BPM'];
|
||||||
let alfSetting = injector.get(AlfrescoSettingsService);
|
let alfSetting = injector.get(AlfrescoSettingsService);
|
||||||
alfSetting.providers = providers;
|
alfSetting.providers = providers;
|
||||||
@@ -284,27 +284,27 @@ describe('AlfrescoAuthentication', () => {
|
|||||||
},
|
},
|
||||||
(err: any) => {
|
(err: any) => {
|
||||||
expect(service.isLoggedIn(providers[0])).toBe(false);
|
expect(service.isLoggedIn(providers[0])).toBe(false);
|
||||||
expect(service.getToken(providers[0])).toBeUndefined();
|
expect(service.getTicket(providers[0])).toBeUndefined();
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a token undefined after logout', (done) => {
|
it('should return a ticket undefined after logout', (done) => {
|
||||||
let providers = ['BPM'];
|
let providers = ['BPM'];
|
||||||
let alfSetting = injector.get(AlfrescoSettingsService);
|
let alfSetting = injector.get(AlfrescoSettingsService);
|
||||||
alfSetting.providers = providers;
|
alfSetting.providers = providers;
|
||||||
|
|
||||||
service = injector.get(AlfrescoAuthenticationService);
|
service = injector.get(AlfrescoAuthenticationService);
|
||||||
localStorage.setItem('token-BPM', 'fake-post-token-BPM');
|
localStorage.setItem('ticket-BPM', 'fake-post-ticket-BPM');
|
||||||
service.createProviderInstance(providers);
|
service.createProviderInstance(providers);
|
||||||
spyOn(AlfrescoAuthenticationBPM.prototype, 'apiActivitiLogout').and.returnValue(fakePromiseBPM);
|
spyOn(AlfrescoAuthenticationBPM.prototype, 'apiActivitiLogout').and.returnValue(fakePromiseBPM);
|
||||||
|
|
||||||
service.logout()
|
service.logout()
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
expect(service.isLoggedIn(providers[0])).toBe(false);
|
expect(service.isLoggedIn(providers[0])).toBe(false);
|
||||||
expect(service.getToken(providers[0])).toBeUndefined();
|
expect(service.getTicket(providers[0])).toBeUndefined();
|
||||||
expect(localStorage.getItem('token-BPM')).toBeUndefined();
|
expect(localStorage.getItem('ticket-BPM')).toBeUndefined();
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -316,7 +316,7 @@ describe('AlfrescoAuthentication', () => {
|
|||||||
alfSetting.providers = providers;
|
alfSetting.providers = providers;
|
||||||
|
|
||||||
service = injector.get(AlfrescoAuthenticationService);
|
service = injector.get(AlfrescoAuthenticationService);
|
||||||
localStorage.setItem('token-BPM', 'fake-post-token-BPM');
|
localStorage.setItem('ticket-BPM', 'fake-post-ticket-BPM');
|
||||||
service.createProviderInstance(providers);
|
service.createProviderInstance(providers);
|
||||||
spyOn(AlfrescoAuthenticationBPM.prototype, 'apiActivitiLogout').and.returnValue(Promise.reject('fake logout error'));
|
spyOn(AlfrescoAuthenticationBPM.prototype, 'apiActivitiLogout').and.returnValue(Promise.reject('fake logout error'));
|
||||||
|
|
||||||
@@ -328,7 +328,7 @@ describe('AlfrescoAuthentication', () => {
|
|||||||
(err: any) => {
|
(err: any) => {
|
||||||
expect(err).toBeDefined();
|
expect(err).toBeDefined();
|
||||||
expect(err.message).toEqual('fake logout error');
|
expect(err.message).toEqual('fake logout error');
|
||||||
expect(localStorage.getItem('token-BPM')).toEqual('fake-post-token-BPM');
|
expect(localStorage.getItem('ticket-BPM')).toEqual('fake-post-ticket-BPM');
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -361,7 +361,7 @@ describe('AlfrescoAuthentication', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return both ECM and BPM tokens after the login done', (done) => {
|
it('should return both ECM and BPM tickets after the login done', (done) => {
|
||||||
let providers = ['ECM', 'BPM'];
|
let providers = ['ECM', 'BPM'];
|
||||||
let alfSetting = injector.get(AlfrescoSettingsService);
|
let alfSetting = injector.get(AlfrescoSettingsService);
|
||||||
alfSetting.providers = providers;
|
alfSetting.providers = providers;
|
||||||
@@ -374,14 +374,14 @@ describe('AlfrescoAuthentication', () => {
|
|||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
expect(service.isLoggedIn(providers[0])).toBe(true);
|
expect(service.isLoggedIn(providers[0])).toBe(true);
|
||||||
expect(service.isLoggedIn(providers[1])).toBe(true);
|
expect(service.isLoggedIn(providers[1])).toBe(true);
|
||||||
expect(service.getToken(providers[0])).toEqual('fake-post-token-ECM');
|
expect(service.getTicket(providers[0])).toEqual('fake-post-ticket-ECM');
|
||||||
expect(service.getToken(providers[1])).toEqual('fake-post-token-BPM');
|
expect(service.getTicket(providers[1])).toEqual('fake-post-ticket-BPM');
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return token undefined when the credentials are correct for the ECM login but wrong for the BPM login', (done) => {
|
it('should return ticket undefined when the credentials are correct for the ECM login but wrong for the BPM login', (done) => {
|
||||||
let providers = ['ECM', 'BPM'];
|
let providers = ['ECM', 'BPM'];
|
||||||
let alfSetting = injector.get(AlfrescoSettingsService);
|
let alfSetting = injector.get(AlfrescoSettingsService);
|
||||||
alfSetting.providers = providers;
|
alfSetting.providers = providers;
|
||||||
@@ -397,15 +397,15 @@ describe('AlfrescoAuthentication', () => {
|
|||||||
},
|
},
|
||||||
(err: any) => {
|
(err: any) => {
|
||||||
expect(service.isLoggedIn(providers[0])).toBe(false);
|
expect(service.isLoggedIn(providers[0])).toBe(false);
|
||||||
expect(service.getToken(providers[0])).toBeUndefined();
|
expect(service.getTicket(providers[0])).toBeUndefined();
|
||||||
expect(service.isLoggedIn(providers[1])).toBe(false);
|
expect(service.isLoggedIn(providers[1])).toBe(false);
|
||||||
expect(service.getToken(providers[1])).toBeUndefined();
|
expect(service.getTicket(providers[1])).toBeUndefined();
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return token undefined when the credentials are correct for the BPM login but wrong for the ECM login', (done) => {
|
it('should return ticket undefined when the credentials are correct for the BPM login but wrong for the ECM login', (done) => {
|
||||||
let providers = ['ECM', 'BPM'];
|
let providers = ['ECM', 'BPM'];
|
||||||
let alfSetting = injector.get(AlfrescoSettingsService);
|
let alfSetting = injector.get(AlfrescoSettingsService);
|
||||||
alfSetting.providers = providers;
|
alfSetting.providers = providers;
|
||||||
@@ -422,9 +422,9 @@ describe('AlfrescoAuthentication', () => {
|
|||||||
},
|
},
|
||||||
(err: any) => {
|
(err: any) => {
|
||||||
expect(service.isLoggedIn(providers[0])).toBe(false);
|
expect(service.isLoggedIn(providers[0])).toBe(false);
|
||||||
expect(service.getToken(providers[0])).toBeUndefined();
|
expect(service.getTicket(providers[0])).toBeUndefined();
|
||||||
expect(service.isLoggedIn(providers[1])).toBe(false);
|
expect(service.isLoggedIn(providers[1])).toBe(false);
|
||||||
expect(service.getToken(providers[1])).toBeUndefined();
|
expect(service.getTicket(providers[1])).toBeUndefined();
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@@ -26,7 +26,7 @@ import { AlfrescoAuthenticationBase } from './AlfrescoAuthenticationBase.service
|
|||||||
declare let AlfrescoApi: any;
|
declare let AlfrescoApi: any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The AlfrescoAuthenticationService provide the login service and store the token in the localStorage
|
* The AlfrescoAuthenticationService provide the login service and store the ticket in the localStorage
|
||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AlfrescoAuthenticationService extends AlfrescoAuthenticationBase {
|
export class AlfrescoAuthenticationService extends AlfrescoAuthenticationBase {
|
||||||
@@ -78,10 +78,6 @@ export class AlfrescoAuthenticationService extends AlfrescoAuthenticationBase {
|
|||||||
return Observable.create(observer => {
|
return Observable.create(observer => {
|
||||||
Observable.forkJoin(observableBatch).subscribe(
|
Observable.forkJoin(observableBatch).subscribe(
|
||||||
(response: any[]) => {
|
(response: any[]) => {
|
||||||
this.performeSaveToken();
|
|
||||||
/*response.forEach((res) => {
|
|
||||||
this.performeSaveToken(res.name, res.token);
|
|
||||||
});*/
|
|
||||||
observer.next(response);
|
observer.next(response);
|
||||||
},
|
},
|
||||||
(err: any) => {
|
(err: any) => {
|
||||||
@@ -91,7 +87,7 @@ export class AlfrescoAuthenticationService extends AlfrescoAuthenticationBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The method return tru if the user is logged in
|
* The method return true if the user is logged in
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
isLoggedIn(type: string = 'ECM'): boolean {
|
isLoggedIn(type: string = 'ECM'): boolean {
|
||||||
@@ -102,36 +98,24 @@ export class AlfrescoAuthenticationService extends AlfrescoAuthenticationBase {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getAlfrescoApi(): any {
|
||||||
|
return this.findProviderInstance('ECM').alfrescoApi;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the token stored in the localStorage of the specific provider type
|
* Return the ticket stored in the localStorage of the specific provider type
|
||||||
* @param token
|
* @param ticket
|
||||||
*/
|
*/
|
||||||
public getToken(type: string = 'ECM'): string {
|
public getTicket(type: string = 'ECM'): string {
|
||||||
let auth: AbstractAuthentication = this.findProviderInstance(type);
|
let auth: AbstractAuthentication = this.findProviderInstance(type);
|
||||||
if (auth) {
|
if (auth) {
|
||||||
return auth.getToken();
|
return auth.getTicket();
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save the token calling the method of the specific provider type
|
* The method remove the ticket from the local storage
|
||||||
* @param providerName
|
|
||||||
* @param token
|
|
||||||
*/
|
|
||||||
private performeSaveToken() {
|
|
||||||
/* let auth: AbstractAuthentication = this.findProviderInstance(type);
|
|
||||||
if (auth) {
|
|
||||||
auth.saveToken();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
this.providersInstance.forEach((authInstance) => {
|
|
||||||
authInstance.saveToken();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The method remove the token from the local storage
|
|
||||||
* @returns {Observable<T>}
|
* @returns {Observable<T>}
|
||||||
*/
|
*/
|
||||||
public logout(): Observable<string> {
|
public logout(): Observable<string> {
|
||||||
@@ -190,7 +174,7 @@ export class AlfrescoAuthenticationService extends AlfrescoAuthenticationBase {
|
|||||||
let auth: AbstractAuthentication = null;
|
let auth: AbstractAuthentication = null;
|
||||||
if (this.providersInstance && this.providersInstance.length !== 0) {
|
if (this.providersInstance && this.providersInstance.length !== 0) {
|
||||||
this.providersInstance.forEach((provider) => {
|
this.providersInstance.forEach((provider) => {
|
||||||
if (provider.TYPE === type) {
|
if (provider.TYPE === type.toUpperCase()) {
|
||||||
auth = provider;
|
auth = provider;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -18,15 +18,11 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { AlfrescoAuthenticationService } from './AlfrescoAuthenticationService.service';
|
import { AlfrescoAuthenticationService } from './AlfrescoAuthenticationService.service';
|
||||||
import { AlfrescoSettingsService } from './AlfrescoSettingsService.service';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AlfrescoContentService {
|
export class AlfrescoContentService {
|
||||||
|
|
||||||
constructor(
|
constructor(private authService: AlfrescoAuthenticationService) {
|
||||||
private settings: AlfrescoSettingsService,
|
|
||||||
private authService: AlfrescoAuthenticationService
|
|
||||||
) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,9 +30,8 @@ export class AlfrescoContentService {
|
|||||||
* @param document Node to get URL for.
|
* @param document Node to get URL for.
|
||||||
* @returns {string} URL address.
|
* @returns {string} URL address.
|
||||||
*/
|
*/
|
||||||
getDocumentThumbnailUrl(document: any) {
|
getDocumentThumbnailUrl(document: any): string {
|
||||||
return this.settings.getApiBaseUrl() + '/nodes/' + document.entry.id +
|
return this.authService.alfrescoApi.content.getDocumentThumbnailUrl(document.entry.id);
|
||||||
'/renditions/doclib/content' + '?attachment=false&alf_ticket=' + this.authService.getToken();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,8 +39,7 @@ export class AlfrescoContentService {
|
|||||||
* @param document Node to get URL for.
|
* @param document Node to get URL for.
|
||||||
* @returns {string} URL address.
|
* @returns {string} URL address.
|
||||||
*/
|
*/
|
||||||
getContentUrl(document: any) {
|
getContentUrl(document: any): string {
|
||||||
return this.settings.getApiBaseUrl() + '/nodes/' + document.entry.id +
|
return this.authService.alfrescoApi.content.getContentUrl(document.entry.id);
|
||||||
'/content' + '?attachment=false&alf_ticket=' + this.authService.getToken();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,6 +26,8 @@ describe('AlfrescoContentService', () => {
|
|||||||
|
|
||||||
let injector, service: AlfrescoContentService, authService: AlfrescoAuthenticationService;
|
let injector, service: AlfrescoContentService, authService: AlfrescoAuthenticationService;
|
||||||
const nodeId = 'blah';
|
const nodeId = 'blah';
|
||||||
|
let DEFAULT_CONTEXT_PATH: string = '/alfresco';
|
||||||
|
let DEFAULT_BASE_API_PATH: string = '/api/-default-/public/alfresco/versions/1';
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
injector = ReflectiveInjector.resolveAndCreate([
|
injector = ReflectiveInjector.resolveAndCreate([
|
||||||
@@ -35,7 +37,7 @@ describe('AlfrescoContentService', () => {
|
|||||||
AlfrescoSettingsService
|
AlfrescoSettingsService
|
||||||
]);
|
]);
|
||||||
spyOn(localStorage, 'getItem').and.callFake(function (key) {
|
spyOn(localStorage, 'getItem').and.callFake(function (key) {
|
||||||
return 'myToken';
|
return 'myTicket';
|
||||||
});
|
});
|
||||||
service = injector.get(AlfrescoContentService);
|
service = injector.get(AlfrescoContentService);
|
||||||
authService = injector.get(AlfrescoAuthenticationService);
|
authService = injector.get(AlfrescoAuthenticationService);
|
||||||
@@ -47,9 +49,9 @@ describe('AlfrescoContentService', () => {
|
|||||||
id: nodeId
|
id: nodeId
|
||||||
}
|
}
|
||||||
})).toBe(
|
})).toBe(
|
||||||
AlfrescoSettingsService.DEFAULT_HOST_ADDRESS + AlfrescoSettingsService.DEFAULT_CONTEXT_PATH +
|
AlfrescoSettingsService.DEFAULT_HOST_ADDRESS + DEFAULT_CONTEXT_PATH +
|
||||||
AlfrescoSettingsService.DEFAULT_BASE_API_PATH + '/nodes/' + nodeId + '/content' +
|
DEFAULT_BASE_API_PATH + '/nodes/' + nodeId + '/content' +
|
||||||
'?attachment=false&alf_ticket=' + authService.getToken()
|
'?attachment=false&alf_ticket=' + authService.getTicket()
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -59,9 +61,9 @@ describe('AlfrescoContentService', () => {
|
|||||||
id: nodeId
|
id: nodeId
|
||||||
}
|
}
|
||||||
})).toBe(
|
})).toBe(
|
||||||
AlfrescoSettingsService.DEFAULT_HOST_ADDRESS + AlfrescoSettingsService.DEFAULT_CONTEXT_PATH +
|
AlfrescoSettingsService.DEFAULT_HOST_ADDRESS + DEFAULT_CONTEXT_PATH +
|
||||||
AlfrescoSettingsService.DEFAULT_BASE_API_PATH + '/nodes/' + nodeId + '/renditions/doclib/content' +
|
DEFAULT_BASE_API_PATH + '/nodes/' + nodeId + '/renditions/doclib/content' +
|
||||||
'?attachment=false&alf_ticket=' + authService.getToken()
|
'?attachment=false&alf_ticket=' + authService.getTicket()
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -37,11 +37,4 @@ describe('AlfrescoSettingsService', () => {
|
|||||||
expect(service.host).toBe(address);
|
expect(service.host).toBe(address);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should format api url', () => {
|
|
||||||
let address = 'http://192.168.0.1';
|
|
||||||
let expectedUrl =
|
|
||||||
`${address}${AlfrescoSettingsService.DEFAULT_CONTEXT_PATH}${AlfrescoSettingsService.DEFAULT_BASE_API_PATH}`;
|
|
||||||
service.host = address;
|
|
||||||
expect(service.getApiBaseUrl()).toBe(expectedUrl);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@@ -40,7 +40,6 @@
|
|||||||
"zone.js": "0.6.12",
|
"zone.js": "0.6.12",
|
||||||
"license-check": "1.1.5",
|
"license-check": "1.1.5",
|
||||||
|
|
||||||
"rimraf": "2.5.2",
|
|
||||||
"material-design-icons": "2.2.3",
|
"material-design-icons": "2.2.3",
|
||||||
"material-design-lite": "1.1.3",
|
"material-design-lite": "1.1.3",
|
||||||
"ng2-translate": "2.2.2",
|
"ng2-translate": "2.2.2",
|
||||||
@@ -51,6 +50,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"browser-sync": "2.10.0",
|
"browser-sync": "2.10.0",
|
||||||
"concurrently": "2.0.0",
|
"concurrently": "2.0.0",
|
||||||
|
"rimraf": "2.5.2",
|
||||||
"tslint": "3.8.1",
|
"tslint": "3.8.1",
|
||||||
"typescript": "1.8.10",
|
"typescript": "1.8.10",
|
||||||
"typings": "1.0.4",
|
"typings": "1.0.4",
|
||||||
|
@@ -67,7 +67,6 @@
|
|||||||
"reflect-metadata": "0.1.3",
|
"reflect-metadata": "0.1.3",
|
||||||
"rxjs": "5.0.0-beta.6",
|
"rxjs": "5.0.0-beta.6",
|
||||||
"zone.js": "0.6.12",
|
"zone.js": "0.6.12",
|
||||||
"rimraf": "2.5.2",
|
|
||||||
"ng2-translate": "2.2.2",
|
"ng2-translate": "2.2.2",
|
||||||
"ng2-alfresco-core": "0.2.0"
|
"ng2-alfresco-core": "0.2.0"
|
||||||
},
|
},
|
||||||
@@ -89,6 +88,7 @@
|
|||||||
"karma-mocha-reporter": "2.0.3",
|
"karma-mocha-reporter": "2.0.3",
|
||||||
"license-check": "1.1.5",
|
"license-check": "1.1.5",
|
||||||
"remap-istanbul": "0.6.3",
|
"remap-istanbul": "0.6.3",
|
||||||
|
"rimraf": "2.5.2",
|
||||||
"traceur": "0.0.91",
|
"traceur": "0.0.91",
|
||||||
"tslint": "3.8.1",
|
"tslint": "3.8.1",
|
||||||
"typescript": "1.8.10",
|
"typescript": "1.8.10",
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
||||||
|
|
||||||
<!-- Additional Alfresco libraries -->
|
<!-- Additional Alfresco libraries -->
|
||||||
<script src="node_modules/alfresco-js-api/bundle.js"></script>
|
<script src="node_modules/alfresco-js-api/dist/alfresco-js-api.js"></script>
|
||||||
|
|
||||||
<script src="systemjs.config.js"></script>
|
<script src="systemjs.config.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
@@ -33,19 +33,17 @@
|
|||||||
"reflect-metadata": "0.1.3",
|
"reflect-metadata": "0.1.3",
|
||||||
"rxjs": "5.0.0-beta.6",
|
"rxjs": "5.0.0-beta.6",
|
||||||
"zone.js": "0.6.12",
|
"zone.js": "0.6.12",
|
||||||
|
|
||||||
"rimraf": "2.5.2",
|
|
||||||
"material-design-icons": "2.2.3",
|
"material-design-icons": "2.2.3",
|
||||||
"material-design-lite": "1.1.3",
|
"material-design-lite": "1.1.3",
|
||||||
"ng2-translate": "2.2.2",
|
"ng2-translate": "2.2.2",
|
||||||
|
"alfresco-js-api": "^0.2.0",
|
||||||
"alfresco-js-api": "^0.1.0",
|
"ng2-alfresco-core": "^0.2.0",
|
||||||
"ng2-alfresco-core": "^0.1.36",
|
"ng2-alfresco-documentlist": "^0.2.0",
|
||||||
"ng2-alfresco-documentlist": "^0.1.34",
|
"ng2-alfresco-datatable": "^0.2.0"
|
||||||
"ng2-alfresco-datatable": "^0.1.17"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"concurrently": "2.0.0",
|
"concurrently": "2.0.0",
|
||||||
|
"rimraf": "2.5.2",
|
||||||
"tslint": "3.8.1",
|
"tslint": "3.8.1",
|
||||||
"typescript": "1.8.10",
|
"typescript": "1.8.10",
|
||||||
"typings": "1.0.4",
|
"typings": "1.0.4",
|
||||||
|
@@ -46,7 +46,7 @@ import {
|
|||||||
operations.
|
operations.
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="container">
|
<div class="container" *ngIf="authenticated">
|
||||||
|
|
||||||
<alfresco-document-list-breadcrumb
|
<alfresco-document-list-breadcrumb
|
||||||
[currentFolderPath]="currentPath"
|
[currentFolderPath]="currentPath"
|
||||||
@@ -155,11 +155,9 @@ class DocumentListDemo implements OnInit {
|
|||||||
private documentActions: DocumentActionsService) {
|
private documentActions: DocumentActionsService) {
|
||||||
|
|
||||||
alfrescoSettingsService.host = this.host;
|
alfrescoSettingsService.host = this.host;
|
||||||
|
if (this.authService.getTicket()) {
|
||||||
if (this.authService.getToken()) {
|
this.token = this.authService.getTicket();
|
||||||
this.token = this.authService.getToken();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
translation.addTranslationFolder();
|
translation.addTranslationFolder();
|
||||||
documentActions.setHandler('my-handler', this.myDocumentActionHandler.bind(this));
|
documentActions.setHandler('my-handler', this.myDocumentActionHandler.bind(this));
|
||||||
}
|
}
|
||||||
@@ -177,7 +175,7 @@ class DocumentListDemo implements OnInit {
|
|||||||
this.login();
|
this.login();
|
||||||
}
|
}
|
||||||
|
|
||||||
myDocumentActionHandler(obj: any) {
|
myDocumentActionHandler() {
|
||||||
window.alert('my custom action handler');
|
window.alert('my custom action handler');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,6 +193,7 @@ class DocumentListDemo implements OnInit {
|
|||||||
this.authService.login('admin', 'admin', ['ECM']).subscribe(
|
this.authService.login('admin', 'admin', ['ECM']).subscribe(
|
||||||
token => {
|
token => {
|
||||||
console.log(token);
|
console.log(token);
|
||||||
|
this.token = token;
|
||||||
this.authenticated = true;
|
this.authenticated = true;
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
"label-undefined": true,
|
"label-undefined": true,
|
||||||
"max-line-length": [
|
"max-line-length": [
|
||||||
true,
|
true,
|
||||||
140
|
180
|
||||||
],
|
],
|
||||||
"member-ordering": [
|
"member-ordering": [
|
||||||
true,
|
true,
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"watch": [
|
"watch": [
|
||||||
"node_modules/ng2-alfresco-datatable/dist/**/*.{html,htm,css,js}",
|
"node_modules/ng2-alfresco-datatable/dist/**/*.{html,htm,css,js}",
|
||||||
|
"node_modules/ng2-alfresco-core/dist/**/*.{html,htm,css,js}",
|
||||||
"node_modules/ng2-alfresco-documentlist/dist/**/*.{html,htm,css,js}"
|
"node_modules/ng2-alfresco-documentlist/dist/**/*.{html,htm,css,js}"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@@ -18,6 +18,7 @@ module.exports = function (config) {
|
|||||||
{pattern: 'node_modules/ng2-alfresco-core/dist/**/*.js', included: false, served: true, watched: false},
|
{pattern: 'node_modules/ng2-alfresco-core/dist/**/*.js', included: false, served: true, watched: false},
|
||||||
{pattern: 'node_modules/ng2-alfresco-datatable/dist/**/*.js', included: false, served: true, watched: false},
|
{pattern: 'node_modules/ng2-alfresco-datatable/dist/**/*.js', included: false, served: true, watched: false},
|
||||||
{pattern: 'node_modules/ng2-translate/**/*.js', included: false, served: true, watched: false},
|
{pattern: 'node_modules/ng2-translate/**/*.js', included: false, served: true, watched: false},
|
||||||
|
{pattern: 'node_modules/alfresco-js-api/dist/alfresco-js-api.js', included: true, watched: false},
|
||||||
|
|
||||||
{pattern: 'karma-test-shim.js', included: true, watched: true},
|
{pattern: 'karma-test-shim.js', included: true, watched: true},
|
||||||
|
|
||||||
|
@@ -48,6 +48,10 @@
|
|||||||
{
|
{
|
||||||
"name": "Mario Romano",
|
"name": "Mario Romano",
|
||||||
"email": "mario.romano83@gmail.com"
|
"email": "mario.romano83@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Eugenio Romano",
|
||||||
|
"email": "eugenio.romano@alfresco.com"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -72,11 +76,10 @@
|
|||||||
"reflect-metadata": "0.1.3",
|
"reflect-metadata": "0.1.3",
|
||||||
"rxjs": "5.0.0-beta.6",
|
"rxjs": "5.0.0-beta.6",
|
||||||
"zone.js": "0.6.12",
|
"zone.js": "0.6.12",
|
||||||
"rimraf": "2.5.2",
|
|
||||||
"ng2-translate": "2.2.2",
|
"ng2-translate": "2.2.2",
|
||||||
"ng2-alfresco-core": "0.2.0",
|
"ng2-alfresco-core": "0.2.0",
|
||||||
"ng2-alfresco-datatable": "0.2.0",
|
"ng2-alfresco-datatable": "0.2.0",
|
||||||
"alfresco-js-api": "^0.1.0"
|
"alfresco-js-api": "0.2.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"material-design-icons": "^2.2.3",
|
"material-design-icons": "^2.2.3",
|
||||||
@@ -96,6 +99,7 @@
|
|||||||
"karma-jasmine-html-reporter": "0.2.0",
|
"karma-jasmine-html-reporter": "0.2.0",
|
||||||
"license-check": "1.1.5",
|
"license-check": "1.1.5",
|
||||||
"remap-istanbul": "0.6.3",
|
"remap-istanbul": "0.6.3",
|
||||||
|
"rimraf": "2.5.2",
|
||||||
"traceur": "0.0.91",
|
"traceur": "0.0.91",
|
||||||
"tslint": "3.8.1",
|
"tslint": "3.8.1",
|
||||||
"typescript": "1.8.10",
|
"typescript": "1.8.10",
|
||||||
|
@@ -36,7 +36,7 @@ export class DocumentListServiceMock extends DocumentListService {
|
|||||||
authService?: AlfrescoAuthenticationService,
|
authService?: AlfrescoAuthenticationService,
|
||||||
contentService?: AlfrescoContentService
|
contentService?: AlfrescoContentService
|
||||||
) {
|
) {
|
||||||
super(settings, authService, contentService);
|
super(authService, contentService);
|
||||||
}
|
}
|
||||||
|
|
||||||
getFolder(folder: string) {
|
getFolder(folder: string) {
|
||||||
|
@@ -39,7 +39,7 @@ describe('DocumentActionsService', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
documentListService = new DocumentListServiceMock();
|
documentListService = new DocumentListServiceMock();
|
||||||
contentService = new AlfrescoContentService(null, null);
|
contentService = new AlfrescoContentService(null);
|
||||||
service = new DocumentActionsService(documentListService, contentService);
|
service = new DocumentActionsService(documentListService, contentService);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -48,8 +48,8 @@ describe('DocumentListService', () => {
|
|||||||
|
|
||||||
settingsService = injector.get(AlfrescoSettingsService);
|
settingsService = injector.get(AlfrescoSettingsService);
|
||||||
authService = injector.get(AlfrescoAuthenticationService);
|
authService = injector.get(AlfrescoAuthenticationService);
|
||||||
contentService = new AlfrescoContentService(settingsService, authService);
|
contentService = new AlfrescoContentService(authService);
|
||||||
service = new DocumentListService(settingsService, authService, contentService);
|
service = new DocumentListService(authService, contentService);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should require node to get thumbnail url', () => {
|
it('should require node to get thumbnail url', () => {
|
||||||
@@ -57,7 +57,7 @@ describe('DocumentListService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should require content service to get thumbnail url', () => {
|
it('should require content service to get thumbnail url', () => {
|
||||||
service = new DocumentListService(settingsService, authService, null);
|
service = new DocumentListService(authService, null);
|
||||||
let file = new FileNode();
|
let file = new FileNode();
|
||||||
expect(service.getDocumentThumbnailUrl(file)).toBeNull();
|
expect(service.getDocumentThumbnailUrl(file)).toBeNull();
|
||||||
});
|
});
|
||||||
|
@@ -20,7 +20,6 @@ import { Response } from '@angular/http';
|
|||||||
import { Observable } from 'rxjs/Rx';
|
import { Observable } from 'rxjs/Rx';
|
||||||
import { NodePaging, MinimalNodeEntity } from './../models/document-library.model';
|
import { NodePaging, MinimalNodeEntity } from './../models/document-library.model';
|
||||||
import {
|
import {
|
||||||
AlfrescoSettingsService,
|
|
||||||
AlfrescoAuthenticationService,
|
AlfrescoAuthenticationService,
|
||||||
AlfrescoContentService
|
AlfrescoContentService
|
||||||
} from 'ng2-alfresco-core';
|
} from 'ng2-alfresco-core';
|
||||||
@@ -62,19 +61,16 @@ export class DocumentListService {
|
|||||||
};
|
};
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private settings: AlfrescoSettingsService,
|
|
||||||
private authService: AlfrescoAuthenticationService,
|
private authService: AlfrescoAuthenticationService,
|
||||||
private contentService: AlfrescoContentService
|
private contentService: AlfrescoContentService
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private getAlfrescoClient() {
|
private getAlfrescoApi() {
|
||||||
return AlfrescoApi.getClientWithTicket(this.settings.getApiBaseUrl(), this.authService.getToken());
|
return this.authService.getAlfrescoApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
private getNodesPromise(folder: string, opts?: any) {
|
private getNodesPromise(folder: string, opts?: any) {
|
||||||
let alfrescoClient = this.getAlfrescoClient();
|
|
||||||
let apiInstance = new AlfrescoApi.Core.NodesApi(alfrescoClient);
|
|
||||||
let nodeId = '-root-';
|
let nodeId = '-root-';
|
||||||
let params: any = {
|
let params: any = {
|
||||||
relativePath: folder,
|
relativePath: folder,
|
||||||
@@ -90,23 +86,20 @@ export class DocumentListService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return apiInstance.getNodeChildren(nodeId, params);
|
return this.getAlfrescoApi().node.getNodeChildren(nodeId, params);
|
||||||
}
|
}
|
||||||
deleteNode(nodeId: string) {
|
|
||||||
let client = this.getAlfrescoClient();
|
deleteNode(nodeId: string) {
|
||||||
let nodesApi = new AlfrescoApi.Core.NodesApi(client);
|
return Observable.fromPromise(this.getAlfrescoApi().node.deleteNode(nodeId));
|
||||||
let opts = {};
|
|
||||||
return Observable.fromPromise(nodesApi.deleteNode(nodeId, opts));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: rename to 'getFolderContent'
|
|
||||||
/**
|
/**
|
||||||
* Gets the folder node with the content.
|
* Gets the folder node with the content.
|
||||||
* @param folder Path to folder.
|
* @param folder Path to folder.
|
||||||
* @param opts Options
|
* @param opts Options.
|
||||||
* @returns {Observable<NodePaging>} Folder entity.
|
* @returns {Observable<NodePaging>} Folder entity.
|
||||||
*/
|
*/
|
||||||
getFolder(folder: string, opts?: any): Observable<NodePaging> {
|
getFolder(folder: string, opts?: any) {
|
||||||
return Observable.fromPromise(this.getNodesPromise(folder, opts))
|
return Observable.fromPromise(this.getNodesPromise(folder, opts))
|
||||||
.map(res => <NodePaging> res)
|
.map(res => <NodePaging> res)
|
||||||
// .do(data => console.log('Node data', data)) // eyeball results in the console
|
// .do(data => console.log('Node data', data)) // eyeball results in the console
|
||||||
@@ -118,7 +111,7 @@ export class DocumentListService {
|
|||||||
* @param node Node to get URL for.
|
* @param node Node to get URL for.
|
||||||
* @returns {string} URL address.
|
* @returns {string} URL address.
|
||||||
*/
|
*/
|
||||||
getDocumentThumbnailUrl(node: MinimalNodeEntity): string {
|
getDocumentThumbnailUrl(node: MinimalNodeEntity) {
|
||||||
if (node && this.contentService) {
|
if (node && this.contentService) {
|
||||||
return this.contentService.getDocumentThumbnailUrl(node);
|
return this.contentService.getDocumentThumbnailUrl(node);
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
||||||
|
|
||||||
<!-- Additional Alfresco libraries -->
|
<!-- Additional Alfresco libraries -->
|
||||||
<script src="node_modules/alfresco-js-api/bundle.js"></script>
|
<script src="node_modules/alfresco-js-api/dist/alfresco-js-api.js"></script>
|
||||||
|
|
||||||
<script src="systemjs.config.js"></script>
|
<script src="systemjs.config.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
"typings": "typings install",
|
"typings": "typings install",
|
||||||
"postinstall": "npm run typings && npm run build",
|
"postinstall": "npm run typings && npm run build",
|
||||||
"start": "concurrently \"npm run build:w\" \"npm run server\" ",
|
"start": "concurrently \"npm run build:w\" \"npm run server\" ",
|
||||||
"server": "wsrv -o -l -s",
|
"server": "wsrv -o -s -l",
|
||||||
"build": "npm run tslint && rimraf dist && tsc",
|
"build": "npm run tslint && rimraf dist && tsc",
|
||||||
"build:w": "npm run tslint && rimraf dist && tsc -w",
|
"build:w": "npm run tslint && rimraf dist && tsc -w",
|
||||||
"tslint": "npm run tslint-src && npm run tslint-root",
|
"tslint": "npm run tslint-src && npm run tslint-root",
|
||||||
@@ -62,17 +62,17 @@
|
|||||||
"rxjs": "5.0.0-beta.6",
|
"rxjs": "5.0.0-beta.6",
|
||||||
"zone.js": "0.6.12",
|
"zone.js": "0.6.12",
|
||||||
|
|
||||||
"rimraf": "2.5.2",
|
|
||||||
"material-design-icons": "2.2.3",
|
"material-design-icons": "2.2.3",
|
||||||
"material-design-lite": "1.1.3",
|
"material-design-lite": "1.1.3",
|
||||||
"ng2-translate": "2.2.2",
|
"ng2-translate": "2.2.2",
|
||||||
|
|
||||||
"alfresco-js-api": "^0.1.0",
|
"alfresco-js-api": "^0.2.0",
|
||||||
"ng2-alfresco-core": "^0.1.36",
|
"ng2-alfresco-core": "^0.1.36",
|
||||||
"ng2-alfresco-login": "^0.1.29"
|
"ng2-alfresco-login": "file:../"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"concurrently": "^2.0.0",
|
"concurrently": "^2.0.0",
|
||||||
|
"rimraf": "2.5.2",
|
||||||
"tslint": "^3.8.1",
|
"tslint": "^3.8.1",
|
||||||
"typescript": "^1.8.10",
|
"typescript": "^1.8.10",
|
||||||
"typings": "^1.0.4",
|
"typings": "^1.0.4",
|
||||||
|
@@ -28,18 +28,21 @@ import {
|
|||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-app',
|
selector: 'my-app',
|
||||||
template: `<label for="token"><b>Insert the ip of your Alfresco instance:</b></label><br>
|
template: `
|
||||||
|
<label for="token"><b>Insert the ip of your Alfresco instance:</b></label><br>
|
||||||
<input id="token" type="text" size="48" (change)="updateHost()" [(ngModel)]="host"><br><br>
|
<input id="token" type="text" size="48" (change)="updateHost()" [(ngModel)]="host"><br><br>
|
||||||
<div style="border-radius: 8px; position: absolute; background-color: papayawhip; color: cadetblue; left: 10px; top: 120px; z-index: 1;">
|
<div style="border-radius: 8px; position: absolute; background-color: papayawhip; color: cadetblue; left: 10px; top: 120px; z-index: 1;">
|
||||||
<p style="width:120px;margin: 20px;">
|
<p style="width:120px;margin: 20px;">
|
||||||
<label for="switch1" class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
<label for="switch1" class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
||||||
<input type="checkbox" id="switch1" class="mdl-switch__input" checked (click)="toggleECM(ecm.checked)" #ecm>
|
<input type="checkbox" id="switch1" class="mdl-switch__input" checked
|
||||||
|
(click)="toggleECM(ecm.checked)" #ecm>
|
||||||
<span class="mdl-switch__label">ECM</span>
|
<span class="mdl-switch__label">ECM</span>
|
||||||
</label>
|
</label>
|
||||||
</p>
|
</p>
|
||||||
<p style="width:120px;margin: 20px;">
|
<p style="width:120px;margin: 20px;">
|
||||||
<label for="switch2" class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
<label for="switch2" class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
||||||
<input type="checkbox" id="switch2" class="mdl-switch__input" (click)="toggleBPM(bpm.checked)" #bpm>
|
<input type="checkbox" id="switch2" class="mdl-switch__input"
|
||||||
|
(click)="toggleBPM(bpm.checked)" #bpm>
|
||||||
<span class="mdl-switch__label">BPM</span>
|
<span class="mdl-switch__label">BPM</span>
|
||||||
</label>
|
</label>
|
||||||
</p>
|
</p>
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
"label-undefined": true,
|
"label-undefined": true,
|
||||||
"max-line-length": [
|
"max-line-length": [
|
||||||
true,
|
true,
|
||||||
140
|
180
|
||||||
],
|
],
|
||||||
"member-ordering": [
|
"member-ordering": [
|
||||||
true,
|
true,
|
||||||
|
6
ng2-components/ng2-alfresco-login/demo/wsrv-config.json
Normal file
6
ng2-components/ng2-alfresco-login/demo/wsrv-config.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"watch": [
|
||||||
|
"node_modules/ng2-alfresco-core/dist/**/*.{html,htm,css,js}",
|
||||||
|
"node_modules/ng2-alfresco-login/dist/**/*.{html,htm,css,js}"
|
||||||
|
]
|
||||||
|
}
|
@@ -80,10 +80,9 @@
|
|||||||
"reflect-metadata": "0.1.3",
|
"reflect-metadata": "0.1.3",
|
||||||
"rxjs": "5.0.0-beta.6",
|
"rxjs": "5.0.0-beta.6",
|
||||||
"zone.js": "0.6.12",
|
"zone.js": "0.6.12",
|
||||||
"rimraf": "2.5.2",
|
|
||||||
"ng2-translate": "2.2.2",
|
"ng2-translate": "2.2.2",
|
||||||
"ng2-alfresco-core": "0.2.0",
|
"ng2-alfresco-core": "0.2.0",
|
||||||
"alfresco-js-api": "^0.1.0",
|
"alfresco-js-api": "^0.2.0",
|
||||||
"coveralls": "^2.11.9"
|
"coveralls": "^2.11.9"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -100,6 +99,7 @@
|
|||||||
"karma-jasmine-html-reporter": "0.2.0",
|
"karma-jasmine-html-reporter": "0.2.0",
|
||||||
"license-check": "1.1.5",
|
"license-check": "1.1.5",
|
||||||
"remap-istanbul": "0.6.3",
|
"remap-istanbul": "0.6.3",
|
||||||
|
"rimraf": "2.5.2",
|
||||||
"traceur": "0.0.91",
|
"traceur": "0.0.91",
|
||||||
"tslint": "3.8.1",
|
"tslint": "3.8.1",
|
||||||
"typescript": "1.8.10",
|
"typescript": "1.8.10",
|
||||||
|
@@ -92,7 +92,6 @@ export class AlfrescoLoginComponent {
|
|||||||
|
|
||||||
this.form.valueChanges.subscribe(data => this.onValueChanged(data));
|
this.form.valueChanges.subscribe(data => this.onValueChanged(data));
|
||||||
|
|
||||||
// this.onValueChanged(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
||||||
|
|
||||||
<!-- Additional Alfresco libraries -->
|
<!-- Additional Alfresco libraries -->
|
||||||
<script src="node_modules/alfresco-js-api/bundle.js"></script>
|
<script src="node_modules/alfresco-js-api/dist/alfresco-js-api.js"></script>
|
||||||
|
|
||||||
<script src="systemjs.config.js"></script>
|
<script src="systemjs.config.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
@@ -6,10 +6,10 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"clean": "rimraf dist node_modules typings",
|
"clean": "rimraf dist node_modules typings",
|
||||||
"postinstall": "npm run typings && npm run build",
|
|
||||||
"typings": "typings install",
|
"typings": "typings install",
|
||||||
|
"postinstall": "npm run typings && npm run build",
|
||||||
"start": "concurrently \"npm run build:w\" \"npm run server\" ",
|
"start": "concurrently \"npm run build:w\" \"npm run server\" ",
|
||||||
"server": "wsrv -o -l -s",
|
"server": "wsrv -o -s -l",
|
||||||
"build": "npm run tslint && rimraf dist && tsc",
|
"build": "npm run tslint && rimraf dist && tsc",
|
||||||
"build:w": "npm run tslint && rimraf dist && tsc -w",
|
"build:w": "npm run tslint && rimraf dist && tsc -w",
|
||||||
"tslint": "npm run tslint-src && npm run tslint-root",
|
"tslint": "npm run tslint-src && npm run tslint-root",
|
||||||
@@ -62,17 +62,17 @@
|
|||||||
"rxjs": "5.0.0-beta.6",
|
"rxjs": "5.0.0-beta.6",
|
||||||
"zone.js": "0.6.12",
|
"zone.js": "0.6.12",
|
||||||
|
|
||||||
"rimraf": "2.5.2",
|
|
||||||
"ng2-translate": "2.2.2",
|
"ng2-translate": "2.2.2",
|
||||||
"material-design-icons": "2.2.3",
|
"material-design-icons": "2.2.3",
|
||||||
"material-design-lite": "1.1.3",
|
"material-design-lite": "1.1.3",
|
||||||
|
|
||||||
"alfresco-js-api": "^0.1.0",
|
"alfresco-js-api": "^0.2.0",
|
||||||
"ng2-alfresco-core": "^0.1.36",
|
"ng2-alfresco-core": "^0.1.36",
|
||||||
"ng2-alfresco-search": "^0.1.21"
|
"ng2-alfresco-search": "^0.1.25"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"concurrently": "2.0.0",
|
"concurrently": "2.0.0",
|
||||||
|
"rimraf": "2.5.2",
|
||||||
"tslint": "3.8.1",
|
"tslint": "3.8.1",
|
||||||
"typescript": "1.8.10",
|
"typescript": "1.8.10",
|
||||||
"typings": "1.0.4",
|
"typings": "1.0.4",
|
||||||
|
@@ -41,7 +41,7 @@ import {
|
|||||||
operations.
|
operations.
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="container" >
|
<div class="container" *ngIf="authenticated">
|
||||||
<alfresco-search-control [searchTerm]="searchTerm"
|
<alfresco-search-control [searchTerm]="searchTerm"
|
||||||
(searchChange)="searchTermChange($event);"></alfresco-search-control>
|
(searchChange)="searchTermChange($event);"></alfresco-search-control>
|
||||||
<alfresco-search [searchTerm]="searchTerm"></alfresco-search>
|
<alfresco-search [searchTerm]="searchTerm"></alfresco-search>
|
||||||
@@ -67,17 +67,10 @@ class SearchDemo implements OnInit {
|
|||||||
translation: AlfrescoTranslationService) {
|
translation: AlfrescoTranslationService) {
|
||||||
|
|
||||||
alfrescoSettingsService.host = this.host;
|
alfrescoSettingsService.host = this.host;
|
||||||
if (this.authService.getToken()) {
|
|
||||||
this.token = this.authService.getToken();
|
|
||||||
}
|
|
||||||
|
|
||||||
translation.addTranslationFolder();
|
translation.addTranslationFolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateToken(): void {
|
|
||||||
localStorage.setItem('token', this.token);
|
|
||||||
}
|
|
||||||
|
|
||||||
public updateHost(): void {
|
public updateHost(): void {
|
||||||
this.alfrescoSettingsService.host = this.host;
|
this.alfrescoSettingsService.host = this.host;
|
||||||
this.login();
|
this.login();
|
||||||
@@ -88,9 +81,10 @@ class SearchDemo implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
login() {
|
login() {
|
||||||
this.authService.login('admin', 'admin').subscribe(
|
this.authService.login('admin', 'admin', ['ECM']).subscribe(
|
||||||
token => {
|
token => {
|
||||||
console.log(token);
|
console.log(token);
|
||||||
|
this.token = token;
|
||||||
this.authenticated = true;
|
this.authenticated = true;
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
|
7
ng2-components/ng2-alfresco-search/demo/wsrv-config.json
Normal file
7
ng2-components/ng2-alfresco-search/demo/wsrv-config.json
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"watch": [
|
||||||
|
"node_modules/ng2-alfresco-core/dist/**/*.{html,htm,css,js}",
|
||||||
|
"node_modules/ng2-alfresco-search/dist/**/*.{html,htm,css,js}",
|
||||||
|
"node_modules/ng2-alfresco-viewer/dist/**/*.{html,htm,css,js}"
|
||||||
|
]
|
||||||
|
}
|
@@ -16,7 +16,7 @@ module.exports = function (config) {
|
|||||||
{pattern: 'node_modules/@angular/**/*.map', included: false, watched: false},
|
{pattern: 'node_modules/@angular/**/*.map', included: false, watched: false},
|
||||||
|
|
||||||
{pattern: 'node_modules/material-design-lite/material.min.js', included: true, watched: false},
|
{pattern: 'node_modules/material-design-lite/material.min.js', included: true, watched: false},
|
||||||
{pattern: 'node_modules/alfresco-js-api/bundle.js', included: true, watched: false},
|
{pattern: 'node_modules/alfresco-js-api/dist/alfresco-js-api.js', included: true, watched: false},
|
||||||
|
|
||||||
{pattern: 'node_modules/ng2-alfresco-core/dist/**/*.js', included: false, served: 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: 'node_modules/ng2-translate/**/*.js', included: false, served: true, watched: false},
|
||||||
|
@@ -48,6 +48,10 @@
|
|||||||
{
|
{
|
||||||
"name": "Denys Vuika",
|
"name": "Denys Vuika",
|
||||||
"email": "denys.vuika@alfresco.com"
|
"email": "denys.vuika@alfresco.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Eugenio Romano",
|
||||||
|
"email": "eugenio.romano@alfresco.com"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -72,10 +76,9 @@
|
|||||||
"reflect-metadata": "0.1.3",
|
"reflect-metadata": "0.1.3",
|
||||||
"rxjs": "5.0.0-beta.6",
|
"rxjs": "5.0.0-beta.6",
|
||||||
"zone.js": "0.6.12",
|
"zone.js": "0.6.12",
|
||||||
"rimraf": "2.5.2",
|
|
||||||
"ng2-translate": "2.2.2",
|
"ng2-translate": "2.2.2",
|
||||||
"material-design-lite": "1.1.3",
|
"material-design-lite": "1.1.3",
|
||||||
"alfresco-js-api": "^0.1.0",
|
"alfresco-js-api": "^0.2.0",
|
||||||
"ng2-alfresco-core": "0.2.0"
|
"ng2-alfresco-core": "0.2.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
@@ -95,6 +98,7 @@
|
|||||||
"karma-mocha-reporter": "2.0.3",
|
"karma-mocha-reporter": "2.0.3",
|
||||||
"karma-jasmine-html-reporter": "0.2.0",
|
"karma-jasmine-html-reporter": "0.2.0",
|
||||||
"license-check": "1.1.5",
|
"license-check": "1.1.5",
|
||||||
|
"rimraf": "2.5.2",
|
||||||
"remap-istanbul": "0.6.3",
|
"remap-istanbul": "0.6.3",
|
||||||
"traceur": "0.0.91",
|
"traceur": "0.0.91",
|
||||||
"tslint": "3.8.1",
|
"tslint": "3.8.1",
|
||||||
|
@@ -18,7 +18,6 @@
|
|||||||
import {Observable} from 'rxjs/Rx';
|
import {Observable} from 'rxjs/Rx';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AlfrescoSettingsService,
|
|
||||||
AlfrescoAuthenticationService
|
AlfrescoAuthenticationService
|
||||||
} from 'ng2-alfresco-core';
|
} from 'ng2-alfresco-core';
|
||||||
import {AlfrescoSearchService} from './../../src/services/alfresco-search.service';
|
import {AlfrescoSearchService} from './../../src/services/alfresco-search.service';
|
||||||
@@ -28,10 +27,9 @@ export class AlfrescoServiceMock extends AlfrescoSearchService {
|
|||||||
_folderToReturn: any = {};
|
_folderToReturn: any = {};
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
settings: AlfrescoSettingsService = null,
|
|
||||||
authService: AlfrescoAuthenticationService = null
|
authService: AlfrescoAuthenticationService = null
|
||||||
) {
|
) {
|
||||||
super(settings, authService);
|
super(authService);
|
||||||
}
|
}
|
||||||
|
|
||||||
getFolder(folder: string) {
|
getFolder(folder: string) {
|
||||||
|
@@ -26,6 +26,6 @@ describe('AlfrescoSearchService', () => {
|
|||||||
let service: AlfrescoSearchService;
|
let service: AlfrescoSearchService;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
service = new AlfrescoSearchService(null, null);
|
service = new AlfrescoSearchService(null);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -19,7 +19,6 @@ import { Injectable } from '@angular/core';
|
|||||||
import { Observable } from 'rxjs/Rx';
|
import { Observable } from 'rxjs/Rx';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AlfrescoSettingsService,
|
|
||||||
AlfrescoAuthenticationService
|
AlfrescoAuthenticationService
|
||||||
} from 'ng2-alfresco-core';
|
} from 'ng2-alfresco-core';
|
||||||
|
|
||||||
@@ -31,23 +30,17 @@ declare let AlfrescoApi: any;
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class AlfrescoSearchService {
|
export class AlfrescoSearchService {
|
||||||
|
|
||||||
constructor(private settings: AlfrescoSettingsService,
|
constructor(private authService: AlfrescoAuthenticationService) {
|
||||||
private authService: AlfrescoAuthenticationService) {
|
|
||||||
}
|
|
||||||
|
|
||||||
private getAlfrescoClient() {
|
|
||||||
return AlfrescoApi.getClientWithTicket(this.settings.getApiBaseUrl(), this.authService.getToken());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private getSearchNodesPromise(term: string) {
|
private getSearchNodesPromise(term: string) {
|
||||||
let apiInstance = new AlfrescoApi.Core.SearchApi(this.getAlfrescoClient());
|
|
||||||
let nodeId = '-root-';
|
let nodeId = '-root-';
|
||||||
let opts = {
|
let opts = {
|
||||||
include: ['path'],
|
include: ['path'],
|
||||||
rootNodeId: nodeId,
|
rootNodeId: nodeId,
|
||||||
nodeType: 'cm:content'
|
nodeType: 'cm:content'
|
||||||
};
|
};
|
||||||
return apiInstance.liveSearchNodes(term, opts);
|
return this.authService.getAlfrescoApi().search.liveSearchNodes(term, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -20,8 +20,6 @@ import {
|
|||||||
AlfrescoContentService
|
AlfrescoContentService
|
||||||
} from 'ng2-alfresco-core';
|
} from 'ng2-alfresco-core';
|
||||||
|
|
||||||
declare let AlfrescoApi: any;
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AlfrescoThumbnailService {
|
export class AlfrescoThumbnailService {
|
||||||
|
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
||||||
|
|
||||||
<!-- Additional Alfresco libraries -->
|
<!-- Additional Alfresco libraries -->
|
||||||
<script src="node_modules/alfresco-js-api/bundle.js"></script>
|
<script src="node_modules/alfresco-js-api/dist/alfresco-js-api.js"></script>
|
||||||
|
|
||||||
<script src="systemjs.config.js"></script>
|
<script src="systemjs.config.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
@@ -62,17 +62,17 @@
|
|||||||
"rxjs": "5.0.0-beta.6",
|
"rxjs": "5.0.0-beta.6",
|
||||||
"zone.js": "0.6.12",
|
"zone.js": "0.6.12",
|
||||||
|
|
||||||
"rimraf": "2.5.2",
|
|
||||||
"ng2-translate": "2.2.2",
|
"ng2-translate": "2.2.2",
|
||||||
"material-design-icons": "2.2.3",
|
"material-design-icons": "2.2.3",
|
||||||
"material-design-lite": "1.1.3",
|
"material-design-lite": "1.1.3",
|
||||||
|
|
||||||
"alfresco-js-api": "^0.1.0",
|
"alfresco-js-api": "^0.2.0",
|
||||||
"ng2-alfresco-core": "^0.1.36",
|
"ng2-alfresco-core": "^0.1.36",
|
||||||
"ng2-alfresco-upload": "^0.1.49"
|
"ng2-alfresco-upload": "^0.1.49"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"concurrently": "2.0.0",
|
"concurrently": "2.0.0",
|
||||||
|
"rimraf": "2.5.2",
|
||||||
"tslint": "3.8.1",
|
"tslint": "3.8.1",
|
||||||
"typescript": "1.8.10",
|
"typescript": "1.8.10",
|
||||||
"typings": "1.0.4",
|
"typings": "1.0.4",
|
||||||
|
@@ -83,8 +83,8 @@ export class MyDemoApp implements OnInit {
|
|||||||
constructor(private authService: AlfrescoAuthenticationService, private alfrescoSettingsService: AlfrescoSettingsService) {
|
constructor(private authService: AlfrescoAuthenticationService, private alfrescoSettingsService: AlfrescoSettingsService) {
|
||||||
alfrescoSettingsService.host = this.host;
|
alfrescoSettingsService.host = this.host;
|
||||||
|
|
||||||
if (this.authService.getToken()) {
|
if (this.authService.getTicket()) {
|
||||||
this.token = this.authService.getToken();
|
this.token = this.authService.getTicket();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,9 +106,10 @@ export class MyDemoApp implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
login() {
|
login() {
|
||||||
this.authService.login('admin', 'admin').subscribe(
|
this.authService.login('admin', 'admin', ['ECM']).subscribe(
|
||||||
token => {
|
token => {
|
||||||
console.log(token);
|
console.log(token);
|
||||||
|
this.token = token;
|
||||||
this.authenticated = true;
|
this.authenticated = true;
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
|
6
ng2-components/ng2-alfresco-upload/demo/wsrv-config.json
Normal file
6
ng2-components/ng2-alfresco-upload/demo/wsrv-config.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"watch": [
|
||||||
|
"node_modules/ng2-alfresco-core/dist/**/*.{html,htm,css,js}",
|
||||||
|
"node_modules/ng2-alfresco-upload/dist/**/*.{html,htm,css,js}"
|
||||||
|
]
|
||||||
|
}
|
@@ -19,6 +19,7 @@ module.exports = function (config) {
|
|||||||
{pattern: 'node_modules/material-design-lite/material.min.js', included: true, watched: false},
|
{pattern: 'node_modules/material-design-lite/material.min.js', included: true, watched: false},
|
||||||
{pattern: 'node_modules/ng2-alfresco-core/dist/**/*.js', included: false, served: 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: 'node_modules/ng2-translate/**/*.js', included: false, served: true, watched: false},
|
||||||
|
{pattern: 'node_modules/alfresco-js-api/dist/alfresco-js-api.js', included: true, watched: false},
|
||||||
|
|
||||||
{pattern: 'karma-test-shim.js', included: true, watched: true},
|
{pattern: 'karma-test-shim.js', included: true, watched: true},
|
||||||
|
|
||||||
|
@@ -75,9 +75,8 @@
|
|||||||
"reflect-metadata": "0.1.3",
|
"reflect-metadata": "0.1.3",
|
||||||
"rxjs": "5.0.0-beta.6",
|
"rxjs": "5.0.0-beta.6",
|
||||||
"zone.js": "0.6.12",
|
"zone.js": "0.6.12",
|
||||||
"rimraf": "2.5.2",
|
|
||||||
"ng2-translate": "2.2.2",
|
"ng2-translate": "2.2.2",
|
||||||
"alfresco-js-api": "^0.1.0",
|
"alfresco-js-api": "^0.2.0",
|
||||||
"ng2-alfresco-core": "0.2.0"
|
"ng2-alfresco-core": "0.2.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
@@ -100,6 +99,7 @@
|
|||||||
"karma-mocha-reporter": "2.0.3",
|
"karma-mocha-reporter": "2.0.3",
|
||||||
"license-check": "1.1.5",
|
"license-check": "1.1.5",
|
||||||
"remap-istanbul": "0.6.3",
|
"remap-istanbul": "0.6.3",
|
||||||
|
"rimraf": "2.5.2",
|
||||||
"traceur": "0.0.91",
|
"traceur": "0.0.91",
|
||||||
"tslint": "3.8.1",
|
"tslint": "3.8.1",
|
||||||
"typescript": "1.8.10",
|
"typescript": "1.8.10",
|
||||||
|
@@ -25,8 +25,7 @@ export class UploadServiceMock extends UploadService {
|
|||||||
filesUpload$: Observable<any>;
|
filesUpload$: Observable<any>;
|
||||||
totalCompleted$: Observable<number>;
|
totalCompleted$: Observable<number>;
|
||||||
|
|
||||||
constructor(settings: AlfrescoSettingsService,
|
constructor(settings: AlfrescoSettingsService, authService: AlfrescoAuthenticationService) {
|
||||||
authService: AlfrescoAuthenticationService) {
|
|
||||||
super(settings, authService);
|
super(settings, authService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -82,7 +82,6 @@ export class UploadButtonComponent {
|
|||||||
constructor(public el: ElementRef,
|
constructor(public el: ElementRef,
|
||||||
private _uploaderService: UploadService,
|
private _uploaderService: UploadService,
|
||||||
translate: AlfrescoTranslationService) {
|
translate: AlfrescoTranslationService) {
|
||||||
console.log('UploadComponent constructor', el);
|
|
||||||
|
|
||||||
let formFields = this.createFormFields();
|
let formFields = this.createFormFields();
|
||||||
this._uploaderService.setOptions(formFields);
|
this._uploaderService.setOptions(formFields);
|
||||||
|
@@ -31,8 +31,7 @@ let errorFn = jasmine.createSpy('error');
|
|||||||
|
|
||||||
class MockUploadService extends UploadService {
|
class MockUploadService extends UploadService {
|
||||||
|
|
||||||
constructor(settings: AlfrescoSettingsService,
|
constructor(settings: AlfrescoSettingsService, authService: AlfrescoAuthenticationService) {
|
||||||
authService: AlfrescoAuthenticationService) {
|
|
||||||
super(settings, authService);
|
super(settings, authService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,13 +87,13 @@ describe('AlfrescoUploadService', () => {
|
|||||||
service.setOptions(empty);
|
service.setOptions(empty);
|
||||||
expect(service.getUrl()).toEqual('/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children');
|
expect(service.getUrl()).toEqual('/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children');
|
||||||
let formFields: Object = {};
|
let formFields: Object = {};
|
||||||
expect(service.getFormFileds()).toEqual(formFields);
|
expect(service.getFormFields()).toEqual(formFields);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show the option passed as input', () => {
|
it('should show the option passed as input', () => {
|
||||||
service.setOptions(options);
|
service.setOptions(options);
|
||||||
expect(service.getUrl()).toEqual('/some/cool/url');
|
expect(service.getUrl()).toEqual('/some/cool/url');
|
||||||
expect(service.getFormFileds()).toEqual({
|
expect(service.getFormFields()).toEqual({
|
||||||
siteid: 'fakeSite',
|
siteid: 'fakeSite',
|
||||||
containerid: 'fakeFolder'
|
containerid: 'fakeFolder'
|
||||||
});
|
});
|
||||||
|
@@ -14,17 +14,13 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
import { EventEmitter, Injectable } from '@angular/core';
|
import { EventEmitter, Injectable } from '@angular/core';
|
||||||
import { Response } from '@angular/http';
|
import { Response } from '@angular/http';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { Observer } from 'rxjs/Observer';
|
import { Observer } from 'rxjs/Observer';
|
||||||
import { AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
import { AlfrescoAuthenticationService} from 'ng2-alfresco-core';
|
||||||
import { FileModel } from '../models/file.model';
|
import { FileModel } from '../models/file.model';
|
||||||
|
|
||||||
declare let AlfrescoApi: any;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* UploadService keep the queue of the file to upload and uploads them.
|
* UploadService keep the queue of the file to upload and uploads them.
|
||||||
@@ -33,29 +29,21 @@ declare let AlfrescoApi: any;
|
|||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UploadService {
|
export class UploadService {
|
||||||
private _url: string = '/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children';
|
|
||||||
|
|
||||||
private _method: string = 'POST';
|
private formFields: Object = {};
|
||||||
private _fieldName: string = 'filedata';
|
private queue: FileModel[] = [];
|
||||||
private _formFields: Object = {};
|
|
||||||
|
|
||||||
private _queue: FileModel[] = [];
|
private filesUploadObserverProgressBar: Observer<FileModel[]>;
|
||||||
|
private totalCompletedObserver: Observer<number>;
|
||||||
filesUpload$: Observable<FileModel[]>;
|
|
||||||
totalCompleted$: Observable<any>;
|
|
||||||
private _filesUploadObserver: Observer<FileModel[]>;
|
|
||||||
private _totalCompletedObserver: Observer<number>;
|
|
||||||
|
|
||||||
private _alfrescoClient: any;
|
|
||||||
|
|
||||||
public totalCompleted: number = 0;
|
public totalCompleted: number = 0;
|
||||||
|
|
||||||
constructor(private settings: AlfrescoSettingsService,
|
filesUpload$: Observable<FileModel[]>;
|
||||||
private authService: AlfrescoAuthenticationService) {
|
totalCompleted$: Observable<any>;
|
||||||
console.log('UploadService constructor');
|
|
||||||
this.filesUpload$ = new Observable<FileModel[]>(observer => this._filesUploadObserver = observer).share();
|
constructor(private authService: AlfrescoAuthenticationService) {
|
||||||
this.totalCompleted$ = new Observable<number>(observer => this._totalCompletedObserver = observer).share();
|
this.filesUpload$ = new Observable<FileModel[]>(observer => this.filesUploadObserverProgressBar = observer).share();
|
||||||
this._alfrescoClient = this.getAlfrescoClient();
|
this.totalCompleted$ = new Observable<number>(observer => this.totalCompletedObserver = observer).share();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,40 +53,16 @@ export class UploadService {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public setOptions(options: any): void {
|
public setOptions(options: any): void {
|
||||||
this._url = options.url || this._url;
|
this.formFields = options.formFields != null ? options.formFields : this.formFields;
|
||||||
this._formFields = options.formFields != null ? options.formFields : this._formFields;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the host
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
public getHost(): string {
|
|
||||||
return this.settings.host;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the url
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
public getUrl(): string {
|
|
||||||
return this._url;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the form fields
|
* Get the form fields
|
||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
public getFormFileds(): Object {
|
public getFormFields(): Object {
|
||||||
return this._formFields;
|
return this.formFields;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the alfresco client
|
|
||||||
* @returns {AlfrescoApi.ApiClient}
|
|
||||||
*/
|
|
||||||
private getAlfrescoClient() {
|
|
||||||
return AlfrescoApi.getClientWithTicket(this.settings.getApiBaseUrl(), this.authService.getToken());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -112,12 +76,12 @@ export class UploadService {
|
|||||||
let latestFilesAdded: FileModel[] = [];
|
let latestFilesAdded: FileModel[] = [];
|
||||||
|
|
||||||
for (let file of files) {
|
for (let file of files) {
|
||||||
if (this._isFile(file)) {
|
if (this.isFile(file)) {
|
||||||
let uploadingFileModel = new FileModel(file);
|
let uploadingFileModel = new FileModel(file);
|
||||||
latestFilesAdded.push(uploadingFileModel);
|
latestFilesAdded.push(uploadingFileModel);
|
||||||
this._queue.push(uploadingFileModel);
|
this.queue.push(uploadingFileModel);
|
||||||
if (this._filesUploadObserver) {
|
if (this.filesUploadObserverProgressBar) {
|
||||||
this._filesUploadObserver.next(this._queue);
|
this.filesUploadObserverProgressBar.next(this.queue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,92 +92,48 @@ export class UploadService {
|
|||||||
* Pick all the files in the queue that are not been uploaded yet and upload it into the directory folder.
|
* Pick all the files in the queue that are not been uploaded yet and upload it into the directory folder.
|
||||||
*/
|
*/
|
||||||
public uploadFilesInTheQueue(directory: string, elementEmit: EventEmitter<any>): void {
|
public uploadFilesInTheQueue(directory: string, elementEmit: EventEmitter<any>): void {
|
||||||
let filesToUpload = this._queue.filter((uploadingFileModel) => {
|
let filesToUpload = this.queue.filter((uploadingFileModel) => {
|
||||||
return !uploadingFileModel.uploading && !uploadingFileModel.done && !uploadingFileModel.abort && !uploadingFileModel.error;
|
return !uploadingFileModel.uploading && !uploadingFileModel.done && !uploadingFileModel.abort && !uploadingFileModel.error;
|
||||||
});
|
});
|
||||||
|
|
||||||
filesToUpload.forEach((uploadingFileModel) => {
|
filesToUpload.forEach((uploadingFileModel) => {
|
||||||
uploadingFileModel.setUploading();
|
uploadingFileModel.setUploading();
|
||||||
this.uploadFile(uploadingFileModel, directory, elementEmit);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
let _filesUploadObserverProgressBar = this.filesUploadObserverProgressBar;
|
||||||
* Create an XMLHttpRequest and return it
|
let _queue = this.queue;
|
||||||
* @returns {XMLHttpRequest}
|
|
||||||
*/
|
|
||||||
createXMLHttpRequestInstance(uploadingFileModel: any, elementEmit: EventEmitter<any>) {
|
|
||||||
let xmlHttpRequest = new XMLHttpRequest();
|
|
||||||
xmlHttpRequest.upload.onprogress = (e) => {
|
|
||||||
if (e.lengthComputable) {
|
|
||||||
let percent = Math.round(e.loaded / e.total * 100);
|
|
||||||
uploadingFileModel.setProgres({
|
|
||||||
total: e.total,
|
|
||||||
loaded: e.loaded,
|
|
||||||
percent: percent
|
|
||||||
});
|
|
||||||
if (this._filesUploadObserver) {
|
|
||||||
this._filesUploadObserver.next(this._queue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
xmlHttpRequest.upload.onabort = (e) => {
|
this.authService.getAlfrescoApi().
|
||||||
|
upload.uploadFile(uploadingFileModel.file, directory)
|
||||||
|
.on('progress', (progress: any) => {
|
||||||
|
uploadingFileModel.setProgres(progress);
|
||||||
|
if (_filesUploadObserverProgressBar) {
|
||||||
|
_filesUploadObserverProgressBar.next(_queue);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.on('abort', () => {
|
||||||
uploadingFileModel.setAbort();
|
uploadingFileModel.setAbort();
|
||||||
};
|
})
|
||||||
|
.on('error', () => {
|
||||||
xmlHttpRequest.upload.onerror = (e) => {
|
|
||||||
uploadingFileModel.setError();
|
uploadingFileModel.setError();
|
||||||
};
|
})
|
||||||
|
.on('success', (data: any) => {
|
||||||
xmlHttpRequest.onreadystatechange = () => {
|
|
||||||
if (xmlHttpRequest.readyState === XMLHttpRequest.DONE) {
|
|
||||||
elementEmit.emit({
|
elementEmit.emit({
|
||||||
value: 'File uploaded'
|
value: 'File uploaded'
|
||||||
});
|
});
|
||||||
uploadingFileModel.onFinished(
|
uploadingFileModel.onFinished(
|
||||||
xmlHttpRequest.status,
|
data.status,
|
||||||
xmlHttpRequest.statusText,
|
data.statusText,
|
||||||
xmlHttpRequest.response
|
data.response
|
||||||
);
|
);
|
||||||
this._filesUploadObserver.next(this._queue);
|
|
||||||
|
_filesUploadObserverProgressBar.next(_queue);
|
||||||
if (!uploadingFileModel.abort && !uploadingFileModel.error) {
|
if (!uploadingFileModel.abort && !uploadingFileModel.error) {
|
||||||
if (this._totalCompletedObserver) {
|
if (this.totalCompletedObserver) {
|
||||||
this._totalCompletedObserver.next(++this.totalCompleted);
|
this.totalCompletedObserver.next(++this.totalCompleted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
return xmlHttpRequest;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Upload a file into the directory folder, and enrich it with the xhr.
|
|
||||||
*
|
|
||||||
* @param {FileModel} - files to be uploaded.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
uploadFile(uploadingFileModel: FileModel, directory: string, elementEmit: EventEmitter<any>): void {
|
|
||||||
// Configure HTTP basic authorization: basicAuth
|
|
||||||
let basicAuth = this._alfrescoClient.authentications['basicAuth'];
|
|
||||||
|
|
||||||
let form = new FormData();
|
|
||||||
form.append(this._fieldName, uploadingFileModel.file, uploadingFileModel.name);
|
|
||||||
Object.keys(this._formFields).forEach((key: any) => {
|
|
||||||
form.append(key, this._formFields[key]);
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
form.append('relativePath', directory);
|
|
||||||
|
|
||||||
let xmlHttpRequest = this.createXMLHttpRequestInstance(uploadingFileModel, elementEmit);
|
|
||||||
uploadingFileModel._xmlHttpRequest = xmlHttpRequest;
|
|
||||||
|
|
||||||
xmlHttpRequest.open(this._method, this.getHost() + this.getUrl(), true);
|
|
||||||
let authToken = btoa(basicAuth.username + ':' + basicAuth.password);
|
|
||||||
if (authToken) {
|
|
||||||
xmlHttpRequest.setRequestHeader('Authorization', `${basicAuth.type} ${authToken}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
xmlHttpRequest.send(form);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -222,7 +142,7 @@ export class UploadService {
|
|||||||
* @return {FileModel[]} - files in the upload queue.
|
* @return {FileModel[]} - files in the upload queue.
|
||||||
*/
|
*/
|
||||||
getQueue(): FileModel[] {
|
getQueue(): FileModel[] {
|
||||||
return this._queue;
|
return this.queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -230,7 +150,7 @@ export class UploadService {
|
|||||||
*
|
*
|
||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
*/
|
*/
|
||||||
private _isFile(file: any): boolean {
|
private isFile(file: any): boolean {
|
||||||
return file !== null && (file instanceof Blob || (file.name && file.size));
|
return file !== null && (file instanceof Blob || (file.name && file.size));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,15 +159,7 @@ export class UploadService {
|
|||||||
* @param name - the folder name
|
* @param name - the folder name
|
||||||
*/
|
*/
|
||||||
createFolder(relativePath: string, name: string) {
|
createFolder(relativePath: string, name: string) {
|
||||||
console.log('Directory created' + name);
|
return Observable.fromPromise(this.authService.getAlfrescoApi().node.createFolder(name, relativePath))
|
||||||
let apiInstance = new AlfrescoApi.NodesApi(this._alfrescoClient);
|
|
||||||
let nodeId = '-root-';
|
|
||||||
let nodeBody = {
|
|
||||||
'name': name,
|
|
||||||
'nodeType': 'cm:folder',
|
|
||||||
'relativePath': relativePath
|
|
||||||
};
|
|
||||||
return Observable.fromPromise(apiInstance.addNode(nodeId, nodeBody))
|
|
||||||
.map(res => {
|
.map(res => {
|
||||||
return res;
|
return res;
|
||||||
})
|
})
|
||||||
|
BIN
ng2-components/ng2-alfresco-viewer/demo/localImg.jpg
Normal file
BIN
ng2-components/ng2-alfresco-viewer/demo/localImg.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 MiB |
@@ -9,7 +9,7 @@
|
|||||||
"typings": "typings install",
|
"typings": "typings install",
|
||||||
"postinstall": "npm run typings && npm run build",
|
"postinstall": "npm run typings && npm run build",
|
||||||
"start": "concurrently \"npm run build:w\" \"npm run server\" ",
|
"start": "concurrently \"npm run build:w\" \"npm run server\" ",
|
||||||
"server": "wsrv -o -l -s",
|
"server": "wsrv -o -s -l",
|
||||||
"build": "npm run tslint && rimraf dist && tsc",
|
"build": "npm run tslint && rimraf dist && tsc",
|
||||||
"build:w": "npm run tslint && rimraf dist && tsc -w",
|
"build:w": "npm run tslint && rimraf dist && tsc -w",
|
||||||
"tslint": "npm run tslint-src && npm run tslint-root",
|
"tslint": "npm run tslint-src && npm run tslint-root",
|
||||||
@@ -34,15 +34,15 @@
|
|||||||
"rxjs": "5.0.0-beta.6",
|
"rxjs": "5.0.0-beta.6",
|
||||||
"zone.js": "0.6.12",
|
"zone.js": "0.6.12",
|
||||||
|
|
||||||
"rimraf": "2.5.2",
|
|
||||||
"material-design-icons": "2.2.3",
|
"material-design-icons": "2.2.3",
|
||||||
"material-design-lite": "1.1.3",
|
"material-design-lite": "1.1.3",
|
||||||
"pdfjs-dist": "1.5.258",
|
"pdfjs-dist": "1.5.258",
|
||||||
|
|
||||||
"ng2-alfresco-viewer": "^0.1.32"
|
"ng2-alfresco-viewer" : "file:../"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"concurrently": "2.0.0",
|
"concurrently": "2.0.0",
|
||||||
|
"rimraf": "2.5.2",
|
||||||
"tslint": "3.8.1",
|
"tslint": "3.8.1",
|
||||||
"typescript": "1.8.10",
|
"typescript": "1.8.10",
|
||||||
"typings": "1.0.4",
|
"typings": "1.0.4",
|
||||||
|
6
ng2-components/ng2-alfresco-viewer/demo/wsrv-config.json
Normal file
6
ng2-components/ng2-alfresco-viewer/demo/wsrv-config.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"watch": [
|
||||||
|
"node_modules/ng2-alfresco-core/dist/**/*.{html,htm,css,js}",
|
||||||
|
"node_modules/ng2-alfresco-viewer/dist/**/*.{html,htm,css,js}"
|
||||||
|
]
|
||||||
|
}
|
@@ -68,7 +68,6 @@
|
|||||||
"reflect-metadata": "0.1.3",
|
"reflect-metadata": "0.1.3",
|
||||||
"rxjs": "5.0.0-beta.6",
|
"rxjs": "5.0.0-beta.6",
|
||||||
"zone.js": "0.6.12",
|
"zone.js": "0.6.12",
|
||||||
"rimraf": "2.5.2",
|
|
||||||
"pdfjs-dist": "1.5.258"
|
"pdfjs-dist": "1.5.258"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
@@ -92,6 +91,7 @@
|
|||||||
"karma-mocha-reporter": "2.0.3",
|
"karma-mocha-reporter": "2.0.3",
|
||||||
"license-check": "1.1.5",
|
"license-check": "1.1.5",
|
||||||
"remap-istanbul": "0.6.3",
|
"remap-istanbul": "0.6.3",
|
||||||
|
"rimraf": "2.5.2",
|
||||||
"traceur": "0.0.91",
|
"traceur": "0.0.91",
|
||||||
"tslint": "3.8.1",
|
"tslint": "3.8.1",
|
||||||
"typescript": "1.8.10",
|
"typescript": "1.8.10",
|
||||||
|
@@ -107,8 +107,6 @@ import { EventMock } from './assets/event.mock';
|
|||||||
let component = fixture.componentInstance;
|
let component = fixture.componentInstance;
|
||||||
component.urlFile = 'fake-url-file';
|
component.urlFile = 'fake-url-file';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
EventMock.keyDown(27);
|
EventMock.keyDown(27);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
Reference in New Issue
Block a user