mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
lint login and upload
This commit is contained in:
1
ng2-components/ng2-alfresco-core/.gitignore
vendored
1
ng2-components/ng2-alfresco-core/.gitignore
vendored
@@ -3,3 +3,4 @@ node_modules
|
||||
jspm_packages
|
||||
.idea
|
||||
typings
|
||||
coverage
|
@@ -3,3 +3,4 @@ node_modules
|
||||
jspm_packages
|
||||
.idea
|
||||
typings
|
||||
coverage
|
@@ -1,23 +0,0 @@
|
||||
import { DocumentList } from './src/components/document-list';
|
||||
import { ContentColumn } from './src/components/content-column';
|
||||
import { ContentColumnList } from './src/components/content-column-list';
|
||||
import { ContentAction } from './src/components/content-action';
|
||||
import { ContentActionList } from './src/components/content-action-list';
|
||||
import { FolderActionsService } from './src/services/folder-actions.service';
|
||||
import { DocumentActionsService } from './src/services/document-actions.service';
|
||||
import { AlfrescoService } from './src/services/alfresco.service';
|
||||
export * from './src/components/document-list';
|
||||
export * from './src/components/content-column';
|
||||
export * from './src/components/content-column-list';
|
||||
export * from './src/components/content-action';
|
||||
export * from './src/components/content-action-list';
|
||||
export * from './src/services/folder-actions.service';
|
||||
export * from './src/services/document-actions.service';
|
||||
export * from './src/services/alfresco.service';
|
||||
declare var _default: {
|
||||
directives: (typeof DocumentList | typeof ContentColumn | typeof ContentColumnList | typeof ContentAction | typeof ContentActionList)[];
|
||||
providers: (typeof AlfrescoService | typeof FolderActionsService | typeof DocumentActionsService)[];
|
||||
};
|
||||
export default _default;
|
||||
export declare const DOCUMENT_LIST_DIRECTIVES: [any];
|
||||
export declare const DOCUMENT_LIST_PROVIDERS: [any];
|
@@ -1,11 +0,0 @@
|
||||
import { DocumentList } from './document-list';
|
||||
import { ContentActionModel } from './../models/content-action.model';
|
||||
export declare class ContentActionList {
|
||||
private documentList;
|
||||
constructor(documentList: DocumentList);
|
||||
/**
|
||||
* Registers action handler within the parent document list component.
|
||||
* @param action Action model to register.
|
||||
*/
|
||||
registerAction(action: ContentActionModel): void;
|
||||
}
|
@@ -1,34 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { OnInit, EventEmitter } from 'angular2/core';
|
||||
import { ContentActionList } from './content-action-list';
|
||||
import { DocumentActionsService } from '../services/document-actions.service';
|
||||
import { FolderActionsService } from '../services/folder-actions.service';
|
||||
export declare class ContentAction implements OnInit {
|
||||
private list;
|
||||
private documentActions;
|
||||
private folderActions;
|
||||
title: string;
|
||||
icon: string;
|
||||
handler: string;
|
||||
type: string;
|
||||
target: string;
|
||||
execute: EventEmitter<{}>;
|
||||
constructor(list: ContentActionList, documentActions: DocumentActionsService, folderActions: FolderActionsService);
|
||||
ngOnInit(): void;
|
||||
private getSystemHandler(target, name);
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
import { DocumentList } from './document-list';
|
||||
import { ContentColumnModel } from './../models/content-column.model';
|
||||
export declare class ContentColumnList {
|
||||
private documentList;
|
||||
constructor(documentList: DocumentList);
|
||||
/**
|
||||
* Registers column model within the parent document list component.
|
||||
* @param column Column definition model to register.
|
||||
*/
|
||||
registerColumn(column: ContentColumnModel): void;
|
||||
}
|
@@ -1,30 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { OnInit } from 'angular2/core';
|
||||
import { ContentColumnList } from './content-column-list';
|
||||
export declare class ContentColumn implements OnInit {
|
||||
private list;
|
||||
title: string;
|
||||
/**
|
||||
* Title to be used for screen readers.
|
||||
*/
|
||||
srTitle: string;
|
||||
source: string;
|
||||
cssClass: string;
|
||||
constructor(list: ContentColumnList);
|
||||
ngOnInit(): void;
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export declare class ContentActionModel {
|
||||
icon: string;
|
||||
title: string;
|
||||
handler: ContentActionHandler;
|
||||
type: string;
|
||||
target: string;
|
||||
}
|
||||
export interface ContentActionHandler {
|
||||
(obj: any): any;
|
||||
}
|
@@ -1,22 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export declare class ContentColumnModel {
|
||||
title: string;
|
||||
srTitle: string;
|
||||
source: string;
|
||||
cssClass: string;
|
||||
}
|
@@ -1,61 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export declare class FolderEntity {
|
||||
items: DocumentEntity[];
|
||||
}
|
||||
export declare class DocumentEntity {
|
||||
nodeRef: string;
|
||||
nodeType: string;
|
||||
type: string;
|
||||
mimetype: string;
|
||||
isFolder: boolean;
|
||||
isLink: boolean;
|
||||
fileName: string;
|
||||
displayName: string;
|
||||
status: string;
|
||||
title: string;
|
||||
description: string;
|
||||
author: string;
|
||||
createdOn: string;
|
||||
createdBy: string;
|
||||
createdByUser: string;
|
||||
modifiedOn: string;
|
||||
modifiedBy: string;
|
||||
modifiedByUser: string;
|
||||
lockedBy: string;
|
||||
lockedByUser: string;
|
||||
size: number;
|
||||
version: string;
|
||||
contentUrl: string;
|
||||
webdavUrl: string;
|
||||
actionSet: string;
|
||||
tags: string[];
|
||||
activeWorkflows: string;
|
||||
location: LocationEntity;
|
||||
}
|
||||
export declare class LocationEntity {
|
||||
repositoryId: string;
|
||||
site: string;
|
||||
siteTitle: string;
|
||||
container: string;
|
||||
path: string;
|
||||
file: string;
|
||||
parent: LocationParentEntity;
|
||||
}
|
||||
export declare class LocationParentEntity {
|
||||
nodeRef: string;
|
||||
}
|
@@ -1,13 +0,0 @@
|
||||
import { ContentActionHandler } from '../models/content-action.model';
|
||||
import { AlfrescoService } from './alfresco.service';
|
||||
export declare class DocumentActionsService {
|
||||
private _alfrescoService;
|
||||
private handlers;
|
||||
constructor(_alfrescoService: AlfrescoService);
|
||||
getHandler(key: string): ContentActionHandler;
|
||||
setHandler(key: string, handler: ContentActionHandler): void;
|
||||
private setupActionHandlers();
|
||||
private handleStandardAction1(obj);
|
||||
private handleStandardAction2(obj);
|
||||
private download(obj);
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
import { ContentActionHandler } from '../models/content-action.model';
|
||||
export declare class FolderActionsService {
|
||||
private handlers;
|
||||
constructor();
|
||||
getHandler(key: string): ContentActionHandler;
|
||||
setHandler(key: string, handler: ContentActionHandler): void;
|
||||
private handleStandardAction1(document);
|
||||
private handleStandardAction2(document);
|
||||
}
|
@@ -1,18 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "system",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"sourceMap": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"removeComments": false,
|
||||
"noImplicitAny": false,
|
||||
"declaration": true
|
||||
"declaration": false,
|
||||
"outDir": "dist"
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"typings/main",
|
||||
"typings/main.d.ts"
|
||||
]
|
||||
"dist",
|
||||
"typings/browser.d.ts",
|
||||
"typings/browser",
|
||||
"demo",
|
||||
"src"
|
||||
],
|
||||
"compileOnSave": false
|
||||
}
|
||||
|
15
ng2-components/ng2-alfresco-login/.editorconfig
Normal file
15
ng2-components/ng2-alfresco-login/.editorconfig
Normal file
@@ -0,0 +1,15 @@
|
||||
# http://editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
insert_final_newline = false
|
||||
trim_trailing_whitespace = false
|
1
ng2-components/ng2-alfresco-login/.gitignore
vendored
1
ng2-components/ng2-alfresco-login/.gitignore
vendored
@@ -3,3 +3,4 @@ node_modules
|
||||
jspm_packages
|
||||
.idea
|
||||
typings
|
||||
coverage
|
6
ng2-components/ng2-alfresco-login/.travis.yml
Executable file
6
ng2-components/ng2-alfresco-login/.travis.yml
Executable file
@@ -0,0 +1,6 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- '5'
|
||||
script: npm run coverage
|
||||
# Send coverage data to Coveralls
|
||||
after_script: "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
|
@@ -65,9 +65,10 @@ System.register(['angular2/core', 'ng2-alfresco-login/ng2-alfresco-login', 'angu
|
||||
router_1.RouteConfig([
|
||||
{ path: '/', name: 'Login', component: ng2_alfresco_login_1.AlfrescoLoginComponent, useAsDefault: true }
|
||||
]),
|
||||
__metadata('design:paramtypes', [ng2_alfresco_login_2.AlfrescoAuthenticationService, router_1.Router, services_1.AlfrescoSettingsService])
|
||||
__metadata('design:paramtypes', [(typeof (_a = typeof ng2_alfresco_login_2.AlfrescoAuthenticationService !== 'undefined' && ng2_alfresco_login_2.AlfrescoAuthenticationService) === 'function' && _a) || Object, router_1.Router, (typeof (_b = typeof services_1.AlfrescoSettingsService !== 'undefined' && services_1.AlfrescoSettingsService) === 'function' && _b) || Object])
|
||||
], AppComponent);
|
||||
return AppComponent;
|
||||
var _a, _b;
|
||||
}());
|
||||
exports_1("AppComponent", AppComponent);
|
||||
}
|
||||
|
@@ -1 +1 @@
|
||||
{"version":3,"file":"app.component.js","sourceRoot":"","sources":["app.component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAkBH;gBAEI,sBAAmB,IAAkC,EAClC,MAAa,EACpB,uBAA+C;oBAFxC,SAAI,GAAJ,IAAI,CAA8B;oBAClC,WAAM,GAAN,MAAM,CAAO;oBAE5B,uBAAuB,CAAC,IAAI,GAAG,4BAA4B,CAAC;gBAEhE,CAAC;gBAED,sCAAe,GAAf,UAAgB,MAAM;oBAClB,OAAO,CAAC,GAAG,CAAC,wCAAwC,GAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACvE,CAAC;gBAED,oCAAa,GAAb,UAAc,MAAM;oBAChB,OAAO,CAAC,GAAG,CAAC,sCAAsC,GAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACrE,CAAC;gBAxBL;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,QAAQ;wBAClB,QAAQ,EAAE,yHAAyH;wBACnI,UAAU,EAAE,CAAC,0BAAiB,EAAE,2CAAsB,CAAC;qBAC1D,CAAC;oBAED,oBAAW,CAAC;wBACT,EAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,2CAAsB,EAAE,YAAY,EAAE,IAAI,EAAC;qBACpF,CAAC;;gCAAA;gBAkBF,mBAAC;YAAD,CAAC,AAjBD,IAiBC;YAjBD,uCAiBC,CAAA"}
|
||||
{"version":3,"file":"app.component.js","sourceRoot":"","sources":["app.component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAkBH;gBAEI,sBAAmB,IAAkC,EAClC,MAAa,EACpB,uBAA+C;oBAFxC,SAAI,GAAJ,IAAI,CAA8B;oBAClC,WAAM,GAAN,MAAM,CAAO;oBAE5B,uBAAuB,CAAC,IAAI,GAAG,4BAA4B,CAAC;gBAEhE,CAAC;gBAED,sCAAe,GAAf,UAAgB,MAAM;oBAClB,OAAO,CAAC,GAAG,CAAC,wCAAwC,GAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACvE,CAAC;gBAED,oCAAa,GAAb,UAAc,MAAM;oBAChB,OAAO,CAAC,GAAG,CAAC,sCAAsC,GAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACrE,CAAC;gBAxBL;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,QAAQ;wBAClB,QAAQ,EAAE,yHAAyH;wBACnI,UAAU,EAAE,CAAC,0BAAiB,EAAE,2CAAsB,CAAC;qBAC1D,CAAC;oBAED,oBAAW,CAAC;wBACT,EAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,2CAAsB,EAAE,YAAY,EAAE,IAAI,EAAC;qBACpF,CAAC;;gCAAA;gBAkBF,mBAAC;;YAAD,CAAC,AAjBD,IAiBC;YAjBD,uCAiBC,CAAA"}
|
@@ -1,27 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { AlfrescoLoginComponent } from './src/components/alfresco-login';
|
||||
import { AlfrescoAuthenticationService } from './src/services/alfresco-authentication';
|
||||
export * from './src/components/alfresco-login';
|
||||
export * from './src/services/alfresco-authentication';
|
||||
declare var _default: {
|
||||
directives: typeof AlfrescoLoginComponent[];
|
||||
providers: typeof AlfrescoAuthenticationService[];
|
||||
};
|
||||
export default _default;
|
||||
export declare const ALFRESCO_LOGIN_DIRECTIVES: [any];
|
||||
export declare const ALFRESCO_AUTHENTICATION: [any];
|
@@ -1,37 +0,0 @@
|
||||
System.register(['./src/components/alfresco-login', './src/services/alfresco-authentication'], function(exports_1, context_1) {
|
||||
"use strict";
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
var alfresco_login_1, alfresco_authentication_1;
|
||||
var ALFRESCO_LOGIN_DIRECTIVES, ALFRESCO_AUTHENTICATION;
|
||||
var exportedNames_1 = {
|
||||
'ALFRESCO_LOGIN_DIRECTIVES': true,
|
||||
'ALFRESCO_AUTHENTICATION': true
|
||||
};
|
||||
function exportStar_1(m) {
|
||||
var exports = {};
|
||||
for(var n in m) {
|
||||
if (n !== "default"&& !exportedNames_1.hasOwnProperty(n)) exports[n] = m[n];
|
||||
}
|
||||
exports_1(exports);
|
||||
}
|
||||
return {
|
||||
setters:[
|
||||
function (alfresco_login_1_1) {
|
||||
alfresco_login_1 = alfresco_login_1_1;
|
||||
exportStar_1(alfresco_login_1_1);
|
||||
},
|
||||
function (alfresco_authentication_1_1) {
|
||||
alfresco_authentication_1 = alfresco_authentication_1_1;
|
||||
exportStar_1(alfresco_authentication_1_1);
|
||||
}],
|
||||
execute: function() {
|
||||
exports_1("default",{
|
||||
directives: [alfresco_login_1.AlfrescoLoginComponent],
|
||||
providers: [alfresco_authentication_1.AlfrescoAuthenticationService]
|
||||
});
|
||||
exports_1("ALFRESCO_LOGIN_DIRECTIVES", ALFRESCO_LOGIN_DIRECTIVES = [alfresco_login_1.AlfrescoLoginComponent]);
|
||||
exports_1("ALFRESCO_AUTHENTICATION", ALFRESCO_AUTHENTICATION = [alfresco_authentication_1.AlfrescoAuthenticationService]);
|
||||
}
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=ng2-alfresco-login.js.map
|
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"ng2-alfresco-login.js","sourceRoot":"","sources":["ng2-alfresco-login.ts"],"names":[],"mappings":";;;;QA2Ba,yBAAyB,EACzB,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;YANpC,oBAAe;gBACX,UAAU,EAAE,CAAC,uCAAsB,CAAC;gBACpC,SAAS,EAAE,CAAC,uDAA6B,CAAC;aAC7C,EAAA;YAEY,uCAAA,yBAAyB,GAAU,CAAC,uCAAsB,CAAC,CAAA,CAAC;YAC5D,qCAAA,uBAAuB,GAAU,CAAC,uDAA6B,CAAC,CAAA,CAAC"}
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
@@ -14,8 +14,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {AlfrescoLoginComponent} from './src/components/alfresco-login';
|
||||
import {AlfrescoAuthenticationService} from './src/services/alfresco-authentication';
|
||||
|
||||
import { AlfrescoLoginComponent } from './src/components/alfresco-login';
|
||||
import { AlfrescoAuthenticationService } from './src/services/alfresco-authentication';
|
||||
|
||||
export * from './src/components/alfresco-login';
|
||||
export * from './src/services/alfresco-authentication';
|
||||
@@ -23,7 +24,7 @@ export * from './src/services/alfresco-authentication';
|
||||
export default {
|
||||
directives: [AlfrescoLoginComponent],
|
||||
providers: [AlfrescoAuthenticationService]
|
||||
}
|
||||
};
|
||||
|
||||
export const ALFRESCO_LOGIN_DIRECTIVES: [any] = [AlfrescoLoginComponent];
|
||||
export const ALFRESCO_AUTHENTICATION: [any] = [AlfrescoAuthenticationService];
|
||||
|
@@ -4,7 +4,10 @@
|
||||
"version": "0.1.0",
|
||||
"author": "Alfresco Software, Ltd.",
|
||||
"scripts": {
|
||||
"build": "tslint -c tslint.json **/*.ts && typings install && tsc && license-check",
|
||||
"build": "npm run tslint-test && npm run tslint-src && npm run tslint-root && typings install && rm -rf dist && tsc && license-check",
|
||||
"tslint-test" : "tslint -c tslint.json test/**/*.ts",
|
||||
"tslint-src" : "tslint -c tslint.json src/**/*.ts",
|
||||
"tslint-root" : "tslint -c tslint.json *.ts",
|
||||
"licensecheck": "license-check",
|
||||
"tsc": "tsc",
|
||||
"tsc:w": "tsc -w",
|
||||
@@ -60,8 +63,10 @@
|
||||
},
|
||||
"license-check-config": {
|
||||
"src": [
|
||||
"**/*.js",
|
||||
"**/*.ts",
|
||||
"!/**/*.d.ts",
|
||||
"!/**/coverage/**/*",
|
||||
"!/**/demo/**/*",
|
||||
"!/**/node_modules/**/*",
|
||||
"!/**/typings/**/*"
|
||||
],
|
||||
|
@@ -1,66 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { EventEmitter } from 'angular2/core';
|
||||
import { Router } from 'angular2/router';
|
||||
import { ControlGroup, FormBuilder } from 'angular2/common';
|
||||
import { AlfrescoAuthenticationService } from '../services/alfresco-authentication';
|
||||
import { TranslateService } from 'ng2-translate/ng2-translate';
|
||||
export declare class AlfrescoLoginComponent {
|
||||
private _fb;
|
||||
auth: AlfrescoAuthenticationService;
|
||||
router: Router;
|
||||
method: string;
|
||||
onSuccess: EventEmitter<{}>;
|
||||
onError: EventEmitter<{}>;
|
||||
translate: TranslateService;
|
||||
form: ControlGroup;
|
||||
error: boolean;
|
||||
success: boolean;
|
||||
formError: {
|
||||
[id: string]: string;
|
||||
};
|
||||
private _message;
|
||||
/**
|
||||
* Constructor
|
||||
* @param _fb
|
||||
* @param auth
|
||||
* @param router
|
||||
*/
|
||||
constructor(_fb: FormBuilder, auth: AlfrescoAuthenticationService, router: Router, translate: TranslateService);
|
||||
/**
|
||||
* Method called on submit form
|
||||
* @param value
|
||||
* @param event
|
||||
*/
|
||||
onSubmit(value: any, event: any): void;
|
||||
/**
|
||||
* The method check the error in the form and push the error in the formError object
|
||||
* @param data
|
||||
*/
|
||||
onValueChanged(data: any): void;
|
||||
/**
|
||||
* The method return if a field is valid or not
|
||||
* @param field
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isErrorStyle(field: ControlGroup): boolean;
|
||||
/**
|
||||
* Initial configuration for Multi language
|
||||
* @param translate
|
||||
*/
|
||||
translationInit(translate: TranslateService): void;
|
||||
}
|
@@ -1,174 +0,0 @@
|
||||
System.register(['angular2/core', 'angular2/router', 'angular2/common', '../services/alfresco-authentication', 'ng2-translate/ng2-translate'], function(exports_1, context_1) {
|
||||
"use strict";
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var core_1, router_1, common_1, alfresco_authentication_1, ng2_translate_1;
|
||||
var AlfrescoLoginComponent;
|
||||
return {
|
||||
setters:[
|
||||
function (core_1_1) {
|
||||
core_1 = core_1_1;
|
||||
},
|
||||
function (router_1_1) {
|
||||
router_1 = router_1_1;
|
||||
},
|
||||
function (common_1_1) {
|
||||
common_1 = common_1_1;
|
||||
},
|
||||
function (alfresco_authentication_1_1) {
|
||||
alfresco_authentication_1 = alfresco_authentication_1_1;
|
||||
},
|
||||
function (ng2_translate_1_1) {
|
||||
ng2_translate_1 = ng2_translate_1_1;
|
||||
}],
|
||||
execute: function() {
|
||||
AlfrescoLoginComponent = (function () {
|
||||
/**
|
||||
* Constructor
|
||||
* @param _fb
|
||||
* @param auth
|
||||
* @param router
|
||||
*/
|
||||
function AlfrescoLoginComponent(_fb, auth, router, translate) {
|
||||
var _this = this;
|
||||
this._fb = _fb;
|
||||
this.auth = auth;
|
||||
this.router = router;
|
||||
this.method = 'POST';
|
||||
this.onSuccess = new core_1.EventEmitter();
|
||||
this.onError = new core_1.EventEmitter();
|
||||
this.error = false;
|
||||
this.success = false;
|
||||
this.formError = {
|
||||
'username': '',
|
||||
'password': ''
|
||||
};
|
||||
this.form = this._fb.group({
|
||||
username: ['', common_1.Validators.compose([common_1.Validators.required, common_1.Validators.minLength(4)])],
|
||||
password: ['', common_1.Validators.required]
|
||||
});
|
||||
this._message = {
|
||||
'username': {
|
||||
'required': 'input-required-message',
|
||||
'minlength': 'input-min-message'
|
||||
},
|
||||
'password': {
|
||||
'required': 'input-required-message'
|
||||
}
|
||||
};
|
||||
this.translationInit(translate);
|
||||
this.form.valueChanges.subscribe(function (data) { return _this.onValueChanged(data); });
|
||||
this.onValueChanged(null);
|
||||
}
|
||||
/**
|
||||
* Method called on submit form
|
||||
* @param value
|
||||
* @param event
|
||||
*/
|
||||
AlfrescoLoginComponent.prototype.onSubmit = function (value, event) {
|
||||
var _this = this;
|
||||
this.error = false;
|
||||
if (event) {
|
||||
event.preventDefault();
|
||||
}
|
||||
this.auth.login(this.method, value.username, value.password)
|
||||
.subscribe(function (token) {
|
||||
try {
|
||||
_this.success = true;
|
||||
_this.onSuccess.emit({
|
||||
value: 'Login OK'
|
||||
});
|
||||
_this.router.navigate(['Home']);
|
||||
}
|
||||
catch (error) {
|
||||
console.error(error.message);
|
||||
}
|
||||
}, function (err) {
|
||||
_this.error = true;
|
||||
_this.onError.emit({
|
||||
value: 'Login KO'
|
||||
});
|
||||
console.log(err);
|
||||
_this.success = false;
|
||||
}, function () { return console.log('Login done'); });
|
||||
};
|
||||
/**
|
||||
* The method check the error in the form and push the error in the formError object
|
||||
* @param data
|
||||
*/
|
||||
AlfrescoLoginComponent.prototype.onValueChanged = function (data) {
|
||||
for (var field in this.formError) {
|
||||
this.formError[field] = '';
|
||||
var hasError = this.form.controls[field].errors || (this.form.controls[field].dirty && !this.form.controls[field].valid);
|
||||
if (hasError) {
|
||||
for (var key in this.form.controls[field].errors) {
|
||||
this.formError[field] += this._message[field][key] + '';
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
/**
|
||||
* The method return if a field is valid or not
|
||||
* @param field
|
||||
* @returns {boolean}
|
||||
*/
|
||||
AlfrescoLoginComponent.prototype.isErrorStyle = function (field) {
|
||||
if (componentHandler) {
|
||||
componentHandler.upgradeAllRegistered();
|
||||
}
|
||||
if (field.valid) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Initial configuration for Multi language
|
||||
* @param translate
|
||||
*/
|
||||
AlfrescoLoginComponent.prototype.translationInit = function (translate) {
|
||||
this.translate = translate;
|
||||
var userLang = navigator.language.split('-')[0]; // use navigator lang if available
|
||||
userLang = /(fr|en)/gi.test(userLang) ? userLang : 'en';
|
||||
this.translate.setDefaultLang(userLang);
|
||||
this.translate.use(userLang);
|
||||
};
|
||||
__decorate([
|
||||
core_1.Input(),
|
||||
__metadata('design:type', String)
|
||||
], AlfrescoLoginComponent.prototype, "method", void 0);
|
||||
__decorate([
|
||||
core_1.Output(),
|
||||
__metadata('design:type', Object)
|
||||
], AlfrescoLoginComponent.prototype, "onSuccess", void 0);
|
||||
__decorate([
|
||||
core_1.Output(),
|
||||
__metadata('design:type', Object)
|
||||
], AlfrescoLoginComponent.prototype, "onError", void 0);
|
||||
AlfrescoLoginComponent = __decorate([
|
||||
core_1.Component({
|
||||
selector: 'alfresco-login',
|
||||
moduleId: __moduleName,
|
||||
directives: [router_1.ROUTER_DIRECTIVES, common_1.FORM_DIRECTIVES],
|
||||
templateUrl: './alfresco-login.html',
|
||||
styleUrls: ['./alfresco-login.css'],
|
||||
pipes: [ng2_translate_1.TranslatePipe]
|
||||
}),
|
||||
__metadata('design:paramtypes', [common_1.FormBuilder, alfresco_authentication_1.AlfrescoAuthenticationService, router_1.Router, ng2_translate_1.TranslateService])
|
||||
], AlfrescoLoginComponent);
|
||||
return AlfrescoLoginComponent;
|
||||
}());
|
||||
exports_1("AlfrescoLoginComponent", AlfrescoLoginComponent);
|
||||
}
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=alfresco-login.js.map
|
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"alfresco-login.js","sourceRoot":"","sources":["alfresco-login.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAiCA;gBAgBI;;;;;mBAKG;gBACH,gCAAoB,GAAgB,EACjB,IAAmC,EACnC,MAAc,EACrB,SAA2B;oBAzB3C,iBAsIC;oBAhHuB,QAAG,GAAH,GAAG,CAAa;oBACjB,SAAI,GAAJ,IAAI,CAA+B;oBACnC,WAAM,GAAN,MAAM,CAAQ;oBAvBxB,WAAM,GAAW,MAAM,CAAC;oBACvB,cAAS,GAAG,IAAI,mBAAY,EAAE,CAAC;oBAC/B,YAAO,GAAG,IAAI,mBAAY,EAAE,CAAC;oBAIvC,UAAK,GAAY,KAAK,CAAC;oBACvB,YAAO,GAAY,KAAK,CAAC;oBAmBrB,IAAI,CAAC,SAAS,GAAG;wBACb,UAAU,EAAE,EAAE;wBACd,UAAU,EAAE,EAAE;qBACjB,CAAC;oBAEF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;wBACvB,QAAQ,EAAE,CAAC,EAAE,EAAE,mBAAU,CAAC,OAAO,CA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4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
@@ -14,11 +14,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {Component, Input, Output, EventEmitter} from 'angular2/core';
|
||||
import {Router, ROUTER_DIRECTIVES} from 'angular2/router';
|
||||
import {FORM_DIRECTIVES, ControlGroup, FormBuilder, Validators} from 'angular2/common';
|
||||
import {AlfrescoAuthenticationService} from '../services/alfresco-authentication';
|
||||
import {TranslateService, TranslatePipe} from 'ng2-translate/ng2-translate';
|
||||
|
||||
import { Component, Input, Output, EventEmitter } from 'angular2/core';
|
||||
import { Router, ROUTER_DIRECTIVES } from 'angular2/router';
|
||||
import { FORM_DIRECTIVES, ControlGroup, FormBuilder, Validators } from 'angular2/common';
|
||||
import { AlfrescoAuthenticationService } from '../services/alfresco-authentication';
|
||||
import { TranslateService, TranslatePipe } from 'ng2-translate/ng2-translate';
|
||||
declare let componentHandler;
|
||||
declare let __moduleName: string;
|
||||
|
||||
@@ -32,9 +33,12 @@ declare let __moduleName: string;
|
||||
|
||||
})
|
||||
export class AlfrescoLoginComponent {
|
||||
@Input() method: string = 'POST';
|
||||
@Output() onSuccess = new EventEmitter();
|
||||
@Output() onError = new EventEmitter();
|
||||
@Input()
|
||||
method: string = 'POST';
|
||||
@Output()
|
||||
onSuccess = new EventEmitter();
|
||||
@Output()
|
||||
onError = new EventEmitter();
|
||||
translate: TranslateService;
|
||||
|
||||
form: ControlGroup;
|
||||
@@ -43,8 +47,7 @@ export class AlfrescoLoginComponent {
|
||||
|
||||
formError: { [id: string]: string };
|
||||
|
||||
private _message: { [id:string]:
|
||||
{ [id: string]: string }
|
||||
private _message: { [id: string]: { [id: string]: string }
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -126,15 +129,19 @@ export class AlfrescoLoginComponent {
|
||||
*/
|
||||
onValueChanged(data: any) {
|
||||
for (let field in this.formError) {
|
||||
if (field) {
|
||||
this.formError[field] = '';
|
||||
let hasError = this.form.controls[field].errors || (this.form.controls[field].dirty && !this.form.controls[field].valid);
|
||||
if (hasError) {
|
||||
for (let key in this.form.controls[field].errors) {
|
||||
if (key) {
|
||||
this.formError[field] += this._message[field][key] + '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The method return if a field is valid or not
|
||||
|
@@ -1,59 +0,0 @@
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
import { Http } from 'angular2/http';
|
||||
/**
|
||||
* The AlfrescoAuthenticationService provide the login service and store the token in the localStorage
|
||||
*/
|
||||
export declare class AlfrescoAuthenticationService {
|
||||
http: Http;
|
||||
token: string;
|
||||
private _host;
|
||||
private _baseUrl;
|
||||
/**
|
||||
* Constructor
|
||||
* @param http
|
||||
*/
|
||||
constructor(http: Http);
|
||||
/**
|
||||
* The method return tru if the user is logged in
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isLoggedIn(): boolean;
|
||||
/**
|
||||
* Method to delegate GET or POST login
|
||||
* @param method
|
||||
* @param username
|
||||
* @param password
|
||||
* @returns {Observable<R>|Observable<T>}
|
||||
*/
|
||||
login(method: string, username: string, password: string): Observable<void>;
|
||||
/**
|
||||
* The method provide the login with GET Request
|
||||
* @param username
|
||||
* @param password
|
||||
* @returns {Observable<R>|Observable<T>}
|
||||
*/
|
||||
loginGet(username: string, password: string): Observable<void>;
|
||||
/**
|
||||
* The method provide the login with POST Request
|
||||
* @param username
|
||||
* @param password
|
||||
* @returns {Observable<R>|Observable<T>}
|
||||
*/
|
||||
loginPost(username: string, password: string): Observable<void>;
|
||||
/**
|
||||
* The method save the toke in the localStorage
|
||||
* @param jwt
|
||||
*/
|
||||
saveJwt(jwt: any): void;
|
||||
/**
|
||||
* The method remove the token from the local storage
|
||||
* @returns {Observable<T>}
|
||||
*/
|
||||
logout(): Observable<boolean>;
|
||||
/**
|
||||
* The method write the error in the console browser
|
||||
* @param error
|
||||
* @returns {ErrorObservable}
|
||||
*/
|
||||
private handleError(error);
|
||||
}
|
@@ -1,143 +0,0 @@
|
||||
System.register(['angular2/core', 'rxjs/Rx', 'angular2/http'], function(exports_1, context_1) {
|
||||
"use strict";
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var core_1, Rx_1, http_1;
|
||||
var AlfrescoAuthenticationService;
|
||||
return {
|
||||
setters:[
|
||||
function (core_1_1) {
|
||||
core_1 = core_1_1;
|
||||
},
|
||||
function (Rx_1_1) {
|
||||
Rx_1 = Rx_1_1;
|
||||
},
|
||||
function (http_1_1) {
|
||||
http_1 = http_1_1;
|
||||
}],
|
||||
execute: function() {
|
||||
/**
|
||||
* The AlfrescoAuthenticationService provide the login service and store the token in the localStorage
|
||||
*/
|
||||
AlfrescoAuthenticationService = (function () {
|
||||
/**
|
||||
* Constructor
|
||||
* @param http
|
||||
*/
|
||||
function AlfrescoAuthenticationService(http) {
|
||||
this.http = http;
|
||||
this._host = 'http://192.168.99.100:8080';
|
||||
this._baseUrl = this._host + '/alfresco/service/api/';
|
||||
this.token = localStorage.getItem('token');
|
||||
}
|
||||
/**
|
||||
* The method return tru if the user is logged in
|
||||
* @returns {boolean}
|
||||
*/
|
||||
AlfrescoAuthenticationService.prototype.isLoggedIn = function () {
|
||||
return !!localStorage.getItem('token');
|
||||
};
|
||||
/**
|
||||
* Method to delegate GET or POST login
|
||||
* @param method
|
||||
* @param username
|
||||
* @param password
|
||||
* @returns {Observable<R>|Observable<T>}
|
||||
*/
|
||||
AlfrescoAuthenticationService.prototype.login = function (method, username, password) {
|
||||
if (method === 'GET') {
|
||||
return this.loginGet(username, password);
|
||||
}
|
||||
else if (method === 'POST') {
|
||||
return this.loginPost(username, password);
|
||||
}
|
||||
else {
|
||||
return Rx_1.Observable.throw('Invalid method name the value should be GET or POST');
|
||||
}
|
||||
};
|
||||
/**
|
||||
* The method provide the login with GET Request
|
||||
* @param username
|
||||
* @param password
|
||||
* @returns {Observable<R>|Observable<T>}
|
||||
*/
|
||||
AlfrescoAuthenticationService.prototype.loginGet = function (username, password) {
|
||||
var _this = this;
|
||||
var searchParams = new http_1.URLSearchParams();
|
||||
searchParams.set('u', username);
|
||||
searchParams.set('pw', password);
|
||||
return this.http.get(this._baseUrl + 'login', { search: searchParams })
|
||||
.map(function (res) {
|
||||
var data = JSON.parse(xml2json(res.text(), ' '));
|
||||
_this.token = data.ticket;
|
||||
_this.saveJwt(_this.token);
|
||||
})
|
||||
.catch(this.handleError);
|
||||
};
|
||||
/**
|
||||
* The method provide the login with POST Request
|
||||
* @param username
|
||||
* @param password
|
||||
* @returns {Observable<R>|Observable<T>}
|
||||
*/
|
||||
AlfrescoAuthenticationService.prototype.loginPost = function (username, password) {
|
||||
var _this = this;
|
||||
var credentials = '{ username: ' + username + ', password: ' + password + ' }';
|
||||
var headers = new http_1.Headers();
|
||||
headers.append('Content-Type', 'application/json');
|
||||
return this.http.post(this._baseUrl + 'login', credentials, {
|
||||
headers: headers
|
||||
})
|
||||
.map(function (res) {
|
||||
var response = res.json();
|
||||
_this.token = response.data.ticket;
|
||||
_this.saveJwt(_this.token);
|
||||
})
|
||||
.catch(this.handleError);
|
||||
};
|
||||
/**
|
||||
* The method save the toke in the localStorage
|
||||
* @param jwt
|
||||
*/
|
||||
AlfrescoAuthenticationService.prototype.saveJwt = function (jwt) {
|
||||
if (jwt) {
|
||||
localStorage.setItem('token', jwt);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* The method remove the token from the local storage
|
||||
* @returns {Observable<T>}
|
||||
*/
|
||||
AlfrescoAuthenticationService.prototype.logout = function () {
|
||||
this.token = undefined;
|
||||
localStorage.removeItem('token');
|
||||
return Rx_1.Observable.of(true);
|
||||
};
|
||||
/**
|
||||
* The method write the error in the console browser
|
||||
* @param error
|
||||
* @returns {ErrorObservable}
|
||||
*/
|
||||
AlfrescoAuthenticationService.prototype.handleError = function (error) {
|
||||
console.error(error.json().message);
|
||||
return Rx_1.Observable.throw(error.json().message || 'Server error');
|
||||
};
|
||||
AlfrescoAuthenticationService = __decorate([
|
||||
core_1.Injectable(),
|
||||
__metadata('design:paramtypes', [http_1.Http])
|
||||
], AlfrescoAuthenticationService);
|
||||
return AlfrescoAuthenticationService;
|
||||
}());
|
||||
exports_1("AlfrescoAuthenticationService", AlfrescoAuthenticationService);
|
||||
}
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=alfresco-authentication.js.map
|
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"alfresco-authentication.js","sourceRoot":"","sources":["alfresco-authentication.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;YAsBA;;eAEG;YAEH;gBAMI;;;mBAGG;gBACH,uCAAmB,IAAS;oBAAT,SAAI,GAAJ,IAAI,CAAK;oBAPpB,UAAK,GAAU,4BAA4B,CAAC;oBAC5C,aAAQ,GAAU,IAAI,CAAC,KAAK,GAAG,wBAAwB,CAAC;oBAO5D,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;gBAC/C,CAAC;gBACD;;;mBAGG;gBACH,kDAAU,GAAV;oBACI,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;gBAC3C,CAA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O,CAAC,CAAC;oBACpC,MAAM,CAAC,eAAU,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,IAAI,cAAc,CAAC,CAAC;gBACpE,CAAC;gBA/GL;oBAAC,iBAAU,EAAE;;iDAAA;gBAgHb,oCAAC;YAAD,CAAC,AA/GD,IA+GC;YA/GD,yEA+GC,CAAA"}
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
@@ -14,29 +14,31 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {Injectable} from 'angular2/core';
|
||||
import {Observable} from 'rxjs/Rx';
|
||||
import {Http, Headers, URLSearchParams, Response} from 'angular2/http';
|
||||
|
||||
declare let xml2json:any;
|
||||
import { Injectable } from 'angular2/core';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
import { Http, Headers, URLSearchParams, Response } from 'angular2/http';
|
||||
|
||||
declare let xml2json: any;
|
||||
|
||||
/**
|
||||
* The AlfrescoAuthenticationService provide the login service and store the token in the localStorage
|
||||
*/
|
||||
@Injectable()
|
||||
export class AlfrescoAuthenticationService {
|
||||
token:string;
|
||||
token: string;
|
||||
|
||||
private _host:string = 'http://192.168.99.100:8080';
|
||||
private _baseUrl:string = this._host + '/alfresco/service/api/';
|
||||
private _host: string = 'http://192.168.99.100:8080';
|
||||
private _baseUrl: string = this._host + '/alfresco/service/api/';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param http
|
||||
*/
|
||||
constructor(public http:Http) {
|
||||
constructor(public http: Http) {
|
||||
this.token = localStorage.getItem('token');
|
||||
}
|
||||
|
||||
/**
|
||||
* The method return tru if the user is logged in
|
||||
* @returns {boolean}
|
||||
@@ -52,7 +54,7 @@ export class AlfrescoAuthenticationService {
|
||||
* @param password
|
||||
* @returns {Observable<R>|Observable<T>}
|
||||
*/
|
||||
login(method:string, username:string, password:string) {
|
||||
login(method: string, username: string, password: string) {
|
||||
if (method === 'GET') {
|
||||
return this.loginGet(username, password);
|
||||
} else if (method === 'POST') {
|
||||
@@ -68,13 +70,13 @@ export class AlfrescoAuthenticationService {
|
||||
* @param password
|
||||
* @returns {Observable<R>|Observable<T>}
|
||||
*/
|
||||
loginGet(username:string, password:string) {
|
||||
loginGet(username: string, password: string) {
|
||||
const searchParams = new URLSearchParams();
|
||||
searchParams.set('u', username);
|
||||
searchParams.set('pw', password);
|
||||
|
||||
return this.http.get(this._baseUrl + 'login', {search: searchParams})
|
||||
.map((res:any) => {
|
||||
.map((res: any) => {
|
||||
let data = JSON.parse(xml2json(res.text(), ' '));
|
||||
this.token = data.ticket;
|
||||
this.saveJwt(this.token);
|
||||
@@ -88,7 +90,7 @@ export class AlfrescoAuthenticationService {
|
||||
* @param password
|
||||
* @returns {Observable<R>|Observable<T>}
|
||||
*/
|
||||
loginPost(username:string, password:string) {
|
||||
loginPost(username: string, password: string) {
|
||||
let credentials = '{ username: ' + username + ', password: ' + password + ' }';
|
||||
|
||||
let headers = new Headers();
|
||||
@@ -97,7 +99,7 @@ export class AlfrescoAuthenticationService {
|
||||
return this.http.post(this._baseUrl + 'login', credentials, {
|
||||
headers: headers
|
||||
})
|
||||
.map((res:any) => {
|
||||
.map((res: any) => {
|
||||
let response = res.json();
|
||||
this.token = response.data.ticket;
|
||||
this.saveJwt(this.token);
|
||||
@@ -131,7 +133,7 @@ export class AlfrescoAuthenticationService {
|
||||
* @param error
|
||||
* @returns {ErrorObservable}
|
||||
*/
|
||||
private handleError(error:Response) {
|
||||
private handleError(error: Response) {
|
||||
console.error(error.json().message);
|
||||
return Observable.throw(error.json().message || 'Server error');
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
@@ -15,12 +15,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {provide} from 'angular2/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { provide } from 'angular2/core';
|
||||
|
||||
import {AlfrescoAuthenticationService} from '../../src/services/alfresco-authentication';
|
||||
import { AlfrescoAuthenticationService } from '../../src/services/alfresco-authentication';
|
||||
|
||||
export class AuthenticationMock {
|
||||
|
||||
login(method: string, username: string, password: string) {
|
||||
if (username === 'fake-username' && password === 'fake-password') {
|
||||
return Observable.of(true);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
@@ -15,9 +15,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {provide, EventEmitter} from 'angular2/core';
|
||||
import {LangChangeEvent} from 'ng2-translate/ng2-translate';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { EventEmitter } from 'angular2/core';
|
||||
import { LangChangeEvent } from 'ng2-translate/ng2-translate';
|
||||
|
||||
|
||||
export class TranslationMock {
|
||||
@@ -25,10 +25,11 @@ export class TranslationMock {
|
||||
public onLangChange: EventEmitter<LangChangeEvent> = new EventEmitter<LangChangeEvent>();
|
||||
|
||||
setDefaultLang() {
|
||||
|
||||
console.log('mock');
|
||||
}
|
||||
|
||||
use() {
|
||||
console.log('mock');
|
||||
}
|
||||
|
||||
public get(key: string|Array<string>, interpolateParams?: Object): Observable<string|any> {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
@@ -14,18 +14,27 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS} from 'angular2/platform/testing/browser';
|
||||
import {it, describe, expect, inject, injectAsync, beforeEach, beforeEachProviders, TestComponentBuilder, setBaseTestProviders} from 'angular2/testing';
|
||||
import {Component, provide, Injector, EventEmitter} from 'angular2/core';
|
||||
import {Location, Router, RouteRegistry, ROUTER_PRIMARY_COMPONENT, Route} from 'angular2/router';
|
||||
import {RootRouter} from 'angular2/src/router/router';
|
||||
import {Observable} from 'rxjs/Rx';
|
||||
import {SpyLocation} from 'angular2/src/mock/location_mock';
|
||||
import {dispatchEvent} from 'angular2/src/testing/utils';
|
||||
import {TranslateService, LangChangeEvent} from 'ng2-translate/ng2-translate';
|
||||
import {AlfrescoLoginComponent} from '../../src/components/alfresco-login';
|
||||
import {AuthenticationMock} from '../assets/authentication.service.mock';
|
||||
import {TranslationMock} from '../assets/translation.service.mock';
|
||||
|
||||
import { TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS } from 'angular2/platform/testing/browser';
|
||||
import {
|
||||
it,
|
||||
describe,
|
||||
expect,
|
||||
inject,
|
||||
injectAsync,
|
||||
beforeEach,
|
||||
beforeEachProviders,
|
||||
TestComponentBuilder,
|
||||
setBaseTestProviders
|
||||
} from 'angular2/testing';
|
||||
import { provide } from 'angular2/core';
|
||||
import { Location, Router, RouteRegistry, ROUTER_PRIMARY_COMPONENT, Route } from 'angular2/router';
|
||||
import { RootRouter } from 'angular2/src/router/router';
|
||||
import { SpyLocation } from 'angular2/src/mock/location_mock';
|
||||
import { TranslateService } from 'ng2-translate/ng2-translate';
|
||||
import { AlfrescoLoginComponent } from '../../src/components/alfresco-login';
|
||||
import { AuthenticationMock } from '../assets/authentication.service.mock';
|
||||
import { TranslationMock } from '../assets/translation.service.mock';
|
||||
|
||||
describe('AlfrescoLogin', () => {
|
||||
let authService, location, router;
|
||||
@@ -50,13 +59,14 @@ describe('AlfrescoLogin', () => {
|
||||
location = l;
|
||||
}));
|
||||
|
||||
it('should render `Login` form with all the keys to be translated', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
it('should render `Login` form with all the keys to be translated',
|
||||
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(AlfrescoLoginComponent)
|
||||
.then((fixture) => {
|
||||
let component = fixture.componentInstance;
|
||||
component.isErrorStyle = function () {
|
||||
|
||||
console.log('mock');
|
||||
};
|
||||
|
||||
fixture.detectChanges();
|
||||
@@ -76,7 +86,8 @@ describe('AlfrescoLogin', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should render user and password input fields with default values', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
it('should render user and password input fields with default values',
|
||||
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(AlfrescoLoginComponent)
|
||||
.then((fixture) => {
|
||||
@@ -89,13 +100,14 @@ describe('AlfrescoLogin', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should render min-length error when the username is lower than 4 characters', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
it('should render min-length error when the username is lower than 4 characters',
|
||||
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(AlfrescoLoginComponent)
|
||||
.then((fixture) => {
|
||||
let component = fixture.componentInstance;
|
||||
component.isErrorStyle = function () {
|
||||
|
||||
console.log('mock');
|
||||
};
|
||||
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
@@ -115,13 +127,14 @@ describe('AlfrescoLogin', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should render no errors when the username and password are correct', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
it('should render no errors when the username and password are correct',
|
||||
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(AlfrescoLoginComponent)
|
||||
.then((fixture) => {
|
||||
let component = fixture.componentInstance;
|
||||
component.isErrorStyle = function () {
|
||||
|
||||
console.log('mock');
|
||||
};
|
||||
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
@@ -142,13 +155,14 @@ describe('AlfrescoLogin', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should render the new values after user and password values are changed', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
it('should render the new values after user and password values are changed',
|
||||
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(AlfrescoLoginComponent)
|
||||
.then((fixture) => {
|
||||
let component = fixture.componentInstance;
|
||||
component.isErrorStyle = function () {
|
||||
|
||||
console.log('mock');
|
||||
};
|
||||
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
@@ -163,7 +177,8 @@ describe('AlfrescoLogin', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should navigate to Home route after the login have succeeded ', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
it('should navigate to Home route after the login have succeeded ',
|
||||
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(AlfrescoLoginComponent)
|
||||
.then((fixture) => {
|
||||
@@ -171,7 +186,7 @@ describe('AlfrescoLogin', () => {
|
||||
spyOn(router, 'navigate').and.callThrough();
|
||||
let component = fixture.componentInstance;
|
||||
component.isErrorStyle = function () {
|
||||
|
||||
console.log('mock');
|
||||
};
|
||||
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
@@ -191,15 +206,17 @@ describe('AlfrescoLogin', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should return error with a wrong username ', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
it('should return error with a wrong username ',
|
||||
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(AlfrescoLoginComponent)
|
||||
.then((fixture) => {
|
||||
spyOn(router, 'navigate').and.callThrough();
|
||||
let component = fixture.componentInstance;
|
||||
component.isErrorStyle = function () {
|
||||
|
||||
console.log('mock');
|
||||
};
|
||||
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
|
||||
component.form.controls.username._value = 'fake-wrong-username';
|
||||
@@ -217,15 +234,17 @@ describe('AlfrescoLogin', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should return error with a wrong password ', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
it('should return error with a wrong password ',
|
||||
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(AlfrescoLoginComponent)
|
||||
.then((fixture) => {
|
||||
spyOn(router, 'navigate').and.callThrough();
|
||||
let component = fixture.componentInstance;
|
||||
component.isErrorStyle = function () {
|
||||
|
||||
console.log('mock');
|
||||
};
|
||||
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
|
||||
component.form.controls.username._value = 'fake-username';
|
||||
@@ -243,14 +262,15 @@ describe('AlfrescoLogin', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should return error with a wrong username and password ', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
it('should return error with a wrong username and password ',
|
||||
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(AlfrescoLoginComponent)
|
||||
.then((fixture) => {
|
||||
spyOn(router, 'navigate').and.callThrough();
|
||||
let component = fixture.componentInstance;
|
||||
component.isErrorStyle = function () {
|
||||
|
||||
console.log('mock');
|
||||
};
|
||||
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
@@ -271,14 +291,16 @@ describe('AlfrescoLogin', () => {
|
||||
}));
|
||||
|
||||
|
||||
it('should emit onSuccess event after the login has succeeded', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
it('should emit onSuccess event after the login has succeeded',
|
||||
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(AlfrescoLoginComponent)
|
||||
.then((fixture) => {
|
||||
let component = fixture.componentInstance;
|
||||
component.isErrorStyle = function () {
|
||||
|
||||
console.log('mock');
|
||||
};
|
||||
|
||||
spyOn(component.onSuccess, 'emit');
|
||||
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
@@ -301,14 +323,16 @@ describe('AlfrescoLogin', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should emit onError event after the login has failed', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
it('should emit onError event after the login has failed',
|
||||
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(AlfrescoLoginComponent)
|
||||
.then((fixture) => {
|
||||
let component = fixture.componentInstance;
|
||||
component.isErrorStyle = function () {
|
||||
|
||||
console.log('mock');
|
||||
};
|
||||
|
||||
spyOn(component.onError, 'emit');
|
||||
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
@@ -333,4 +357,3 @@ describe('AlfrescoLogin', () => {
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
@@ -14,11 +14,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {it, describe} from 'angular2/testing';
|
||||
import {provide, Injector} from 'angular2/core';
|
||||
import {Http, HTTP_PROVIDERS, XHRBackend, Response, ResponseOptions} from 'angular2/http';
|
||||
import {MockBackend} from 'angular2/http/testing';
|
||||
import {AlfrescoAuthenticationService} from '../../src/services/alfresco-authentication';
|
||||
|
||||
import { it, describe } from 'angular2/testing';
|
||||
import { provide, Injector } from 'angular2/core';
|
||||
import { Http, HTTP_PROVIDERS, XHRBackend, Response, ResponseOptions } from 'angular2/http';
|
||||
import { MockBackend } from 'angular2/http/testing';
|
||||
import { AlfrescoAuthenticationService } from '../../src/services/alfresco-authentication';
|
||||
|
||||
|
||||
describe('AlfrescoAuthentication', () => {
|
||||
|
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "system",
|
||||
"moduleResolution": "node",
|
||||
"sourceMap": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"removeComments": false,
|
||||
"noImplicitAny": false,
|
||||
"declaration": false
|
||||
},
|
||||
"exclude": [
|
||||
]
|
||||
}
|
@@ -1,26 +1,28 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "system",
|
||||
"moduleResolution": "node",
|
||||
"sourceMap": true,
|
||||
"module": "commonjs",
|
||||
"declaration": false,
|
||||
"removeComments": true,
|
||||
"noLib": false,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"removeComments": false,
|
||||
"sourceMap": true,
|
||||
"allowUnreachableCode": false,
|
||||
"allowUnusedLabels": false,
|
||||
"noImplicitAny": false,
|
||||
"declaration": true
|
||||
"noImplicitReturns": false,
|
||||
"noImplicitUseStrict": false,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"outDir": "dist"
|
||||
},
|
||||
"files":[
|
||||
"node_modules/angular2/typings/browser.d.ts",
|
||||
"typings/browser/ambient/jasmine/index.d.ts",
|
||||
"src/components/alfresco-login.ts",
|
||||
"test/components/alfresco-login.spec.ts",
|
||||
"src/services/alfresco-authentication.ts",
|
||||
"test/services/alfresco-authentication.spec.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"**/node_modules",
|
||||
"**/typings/main",
|
||||
"**/typings/main.d.ts"
|
||||
]
|
||||
"node_modules",
|
||||
"dist",
|
||||
"typings/browser.d.ts",
|
||||
"typings/browser",
|
||||
"demo",
|
||||
"src"
|
||||
],
|
||||
"compileOnSave": false
|
||||
}
|
||||
|
@@ -3,7 +3,6 @@
|
||||
"align": [
|
||||
true,
|
||||
"parameters",
|
||||
"arguments",
|
||||
"statements"
|
||||
],
|
||||
"ban": false,
|
||||
@@ -30,13 +29,12 @@
|
||||
],
|
||||
"member-ordering": [
|
||||
true,
|
||||
"public-before-private",
|
||||
"static-before-instance",
|
||||
"variables-before-functions"
|
||||
],
|
||||
"no-any": false,
|
||||
"no-arg": true,
|
||||
"no-bitwise": true,
|
||||
"no-bitwise": false,
|
||||
"no-conditional-assignment": true,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-console": [
|
||||
|
15
ng2-components/ng2-alfresco-upload/.editorconfig
Normal file
15
ng2-components/ng2-alfresco-upload/.editorconfig
Normal file
@@ -0,0 +1,15 @@
|
||||
# http://editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
insert_final_newline = false
|
||||
trim_trailing_whitespace = false
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
|
@@ -1,44 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { UploadDragAreaComponent } from './src/components/upload-drag-area.component';
|
||||
import { FileDraggableDirective } from './src/directives/file-draggable.directive';
|
||||
import { UploadButtonComponent } from './src/components/upload-button.component';
|
||||
/**
|
||||
* ng2-alfresco-upload, provide components to upload files to alfresco repository.
|
||||
*
|
||||
* Components provided:
|
||||
* - A button to upload files
|
||||
* <alfresco-upload-button [showDialogUpload]="boolean"
|
||||
* [showUdoNotificationBar]="boolean"
|
||||
* [uploadFolders]="boolean"
|
||||
* [multipleFiles]="boolean"
|
||||
* [acceptedFilesType]="string">
|
||||
* </alfresco-upload-button>
|
||||
*
|
||||
* - Drag and drop area to upload files:
|
||||
* <alfresco-upload-drag-area [showDialogUpload]="boolean" ></alfresco-upload-drag-area>
|
||||
*/
|
||||
export * from './src/components/upload-button.component';
|
||||
export * from './src/components/upload-drag-area.component';
|
||||
export * from './src/services/upload.service';
|
||||
export * from './src/directives/file-draggable.directive';
|
||||
declare var _default: {
|
||||
component: (typeof UploadDragAreaComponent | typeof UploadButtonComponent)[];
|
||||
directives: typeof FileDraggableDirective[];
|
||||
};
|
||||
export default _default;
|
||||
export declare const ALFRESCO_ULPOAD_COMPONENT: [any];
|
@@ -1,62 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
System.register(['./src/components/upload-drag-area.component', './src/directives/file-draggable.directive', './src/components/upload-button.component', './src/services/upload.service'], function(exports_1, context_1) {
|
||||
"use strict";
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
var upload_drag_area_component_1, file_draggable_directive_1, upload_button_component_1;
|
||||
var ALFRESCO_ULPOAD_COMPONENT;
|
||||
var exportedNames_1 = {
|
||||
'ALFRESCO_ULPOAD_COMPONENT': true
|
||||
};
|
||||
function exportStar_1(m) {
|
||||
var exports = {};
|
||||
for(var n in m) {
|
||||
if (n !== "default"&& !exportedNames_1.hasOwnProperty(n)) exports[n] = m[n];
|
||||
}
|
||||
exports_1(exports);
|
||||
}
|
||||
return {
|
||||
setters:[
|
||||
function (upload_drag_area_component_1_1) {
|
||||
upload_drag_area_component_1 = upload_drag_area_component_1_1;
|
||||
exportStar_1(upload_drag_area_component_1_1);
|
||||
},
|
||||
function (file_draggable_directive_1_1) {
|
||||
file_draggable_directive_1 = file_draggable_directive_1_1;
|
||||
exportStar_1(file_draggable_directive_1_1);
|
||||
},
|
||||
function (upload_button_component_1_1) {
|
||||
upload_button_component_1 = upload_button_component_1_1;
|
||||
exportStar_1(upload_button_component_1_1);
|
||||
},
|
||||
function (upload_service_1_1) {
|
||||
exportStar_1(upload_service_1_1);
|
||||
}],
|
||||
execute: function() {
|
||||
exports_1("default",{
|
||||
component: [upload_drag_area_component_1.UploadDragAreaComponent, upload_button_component_1.UploadButtonComponent],
|
||||
directives: [file_draggable_directive_1.FileDraggableDirective]
|
||||
});
|
||||
exports_1("ALFRESCO_ULPOAD_COMPONENT", ALFRESCO_ULPOAD_COMPONENT = [
|
||||
upload_drag_area_component_1.UploadDragAreaComponent,
|
||||
upload_button_component_1.UploadButtonComponent,
|
||||
file_draggable_directive_1.FileDraggableDirective
|
||||
]);
|
||||
}
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=ng2-alfresco-upload.js.map
|
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"ng2-alfresco-upload.js","sourceRoot":"","sources":["ng2-alfresco-upload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;QAgCU,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YALtC,oBAAe;gBACX,SAAS,EAAE,CAAC,oDAAuB,EAAE,+CAAqB,CAAC;gBAC3D,UAAU,EAAE,CAAC,iDAAsB,CAAC;aACvC,EAAA;YAEY,uCAAA,yBAAyB,GAAU;gBAC5C,oDAAuB;gBACvB,+CAAqB;gBACrB,iDAAsB;aACzB,CAAA,CAAC"}
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
@@ -15,9 +15,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {UploadDragAreaComponent} from './src/components/upload-drag-area.component';
|
||||
import {FileDraggableDirective} from './src/directives/file-draggable.directive';
|
||||
import {UploadButtonComponent} from './src/components/upload-button.component';
|
||||
import { UploadDragAreaComponent } from './src/components/upload-drag-area.component';
|
||||
import { FileDraggableDirective } from './src/directives/file-draggable.directive';
|
||||
import { UploadButtonComponent } from './src/components/upload-button.component';
|
||||
|
||||
/**
|
||||
* ng2-alfresco-upload, provide components to upload files to alfresco repository.
|
||||
@@ -43,7 +43,7 @@ export * from './src/directives/file-draggable.directive';
|
||||
export default {
|
||||
component: [UploadDragAreaComponent, UploadButtonComponent],
|
||||
directives: [FileDraggableDirective]
|
||||
}
|
||||
};
|
||||
|
||||
export const ALFRESCO_ULPOAD_COMPONENT: [any] = [
|
||||
UploadDragAreaComponent,
|
||||
|
@@ -4,7 +4,10 @@
|
||||
"version": "0.1.0",
|
||||
"author": "Alfresco Software, Ltd.",
|
||||
"scripts": {
|
||||
"build": "tslint -c tslint.json **/*.ts && typings install && tsc && license-check",
|
||||
"build": "npm run tslint-test && npm run tslint-src && npm run tslint-root && typings install && rm -rf dist && tsc && license-check",
|
||||
"tslint-test" : "tslint -c tslint.json test/**/*.ts",
|
||||
"tslint-src" : "tslint -c tslint.json src/**/*.ts",
|
||||
"tslint-root" : "tslint -c tslint.json *.ts",
|
||||
"licensecheck": "license-check",
|
||||
"tsc": "tsc",
|
||||
"tsc:w": "tsc -w",
|
||||
@@ -57,9 +60,12 @@
|
||||
},
|
||||
"license-check-config": {
|
||||
"src": [
|
||||
"**/*.js",
|
||||
"**/*.ts",
|
||||
"!/node_modules/**/*",
|
||||
"!/typings/**/*"
|
||||
"!/**/coverage/**/*",
|
||||
"!/**/demo/**/*",
|
||||
"!/**/node_modules/**/*",
|
||||
"!/**/typings/**/*"
|
||||
],
|
||||
"path": "assets/license_header.txt",
|
||||
"blocking": false,
|
||||
|
@@ -1,48 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { ElementRef } from 'angular2/core';
|
||||
import { FileModel } from '../models/file.model';
|
||||
/**
|
||||
* <file-uploading-dialog [filesUploadingList]="FileModel[]" ></file-uploading-dialog>
|
||||
*
|
||||
* This component is a hideable and minimizable wich contains the list of the uploading
|
||||
* files contained in the filesUploadingList.
|
||||
*
|
||||
* @InputParam {FileModel[]} filesUploadingList - list of the uploading files .
|
||||
*
|
||||
*
|
||||
* @returns {FileUploadingDialogComponent} .
|
||||
*/
|
||||
export declare class FileUploadingDialogComponent {
|
||||
el: ElementRef;
|
||||
filesUploadingList: FileModel[];
|
||||
private _isDialogActive;
|
||||
private _isDialogMinimized;
|
||||
constructor(el: ElementRef);
|
||||
/**
|
||||
* Display and hide the dialog component.
|
||||
*/
|
||||
toggleShowDialog($event: any): void;
|
||||
/**
|
||||
* Display the dialog if hidden.
|
||||
*/
|
||||
showDialog(): void;
|
||||
/**
|
||||
* Minimize and expand the dialog component.
|
||||
*/
|
||||
toggleDialogMinimize($event: any): void;
|
||||
}
|
@@ -4,12 +4,12 @@
|
||||
{{filesUploadingList.length}} {{'FILE_UPLOAD.MESSAGES.COMPLETED' | translate}}
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<div class="minimize-button" [ngClass]="{active: _isDialogMinimized}" (click)="toggleDialogMinimize($event)">
|
||||
<div class="minimize-button" [ngClass]="{active: _isDialogMinimized}" (click)="toggleDialogMinimize()">
|
||||
<i class="material-icons down">keyboard_arrow_down</i>
|
||||
<i class="material-icons up">keyboard_arrow_up</i>
|
||||
</div>
|
||||
|
||||
<div class="close-button" (click)="toggleShowDialog($event)">
|
||||
<div class="close-button" (click)="toggleShowDialog()">
|
||||
<i class="material-icons">clear</i>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -1,101 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
System.register(['angular2/core', './file-uploading-list.component', 'ng2-translate/ng2-translate'], function(exports_1, context_1) {
|
||||
"use strict";
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var core_1, file_uploading_list_component_1, ng2_translate_1;
|
||||
var FileUploadingDialogComponent;
|
||||
return {
|
||||
setters:[
|
||||
function (core_1_1) {
|
||||
core_1 = core_1_1;
|
||||
},
|
||||
function (file_uploading_list_component_1_1) {
|
||||
file_uploading_list_component_1 = file_uploading_list_component_1_1;
|
||||
},
|
||||
function (ng2_translate_1_1) {
|
||||
ng2_translate_1 = ng2_translate_1_1;
|
||||
}],
|
||||
execute: function() {
|
||||
/**
|
||||
* <file-uploading-dialog [filesUploadingList]="FileModel[]" ></file-uploading-dialog>
|
||||
*
|
||||
* This component is a hideable and minimizable wich contains the list of the uploading
|
||||
* files contained in the filesUploadingList.
|
||||
*
|
||||
* @InputParam {FileModel[]} filesUploadingList - list of the uploading files .
|
||||
*
|
||||
*
|
||||
* @returns {FileUploadingDialogComponent} .
|
||||
*/
|
||||
FileUploadingDialogComponent = (function () {
|
||||
function FileUploadingDialogComponent(el) {
|
||||
this.el = el;
|
||||
this._isDialogActive = false;
|
||||
this._isDialogMinimized = false;
|
||||
console.log('FileUploadingDialogComponent constructor', el);
|
||||
}
|
||||
/**
|
||||
* Display and hide the dialog component.
|
||||
*/
|
||||
FileUploadingDialogComponent.prototype.toggleShowDialog = function ($event) {
|
||||
this._isDialogActive = !this._isDialogActive;
|
||||
};
|
||||
/**
|
||||
* Display the dialog if hidden.
|
||||
*/
|
||||
FileUploadingDialogComponent.prototype.showDialog = function () {
|
||||
this._isDialogActive = true;
|
||||
};
|
||||
/**
|
||||
* Minimize and expand the dialog component.
|
||||
*/
|
||||
FileUploadingDialogComponent.prototype.toggleDialogMinimize = function ($event) {
|
||||
this._isDialogMinimized = !this._isDialogMinimized;
|
||||
};
|
||||
__decorate([
|
||||
core_1.Input(),
|
||||
__metadata('design:type', Array)
|
||||
], FileUploadingDialogComponent.prototype, "filesUploadingList", void 0);
|
||||
FileUploadingDialogComponent = __decorate([
|
||||
core_1.Component({
|
||||
selector: 'file-uploading-dialog',
|
||||
moduleId: __moduleName,
|
||||
directives: [file_uploading_list_component_1.FileUploadingListComponent],
|
||||
templateUrl: './file-uploading-dialog.component.html',
|
||||
styleUrls: ['./file-uploading-dialog.component.css'],
|
||||
host: { '[class.dialog-show]': 'toggleShowDialog' },
|
||||
pipes: [ng2_translate_1.TranslatePipe]
|
||||
}),
|
||||
__metadata('design:paramtypes', [core_1.ElementRef])
|
||||
], FileUploadingDialogComponent);
|
||||
return FileUploadingDialogComponent;
|
||||
}());
|
||||
exports_1("FileUploadingDialogComponent", FileUploadingDialogComponent);
|
||||
}
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=file-uploading-dialog.component.js.map
|
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"file-uploading-dialog.component.js","sourceRoot":"","sources":["file-uploading-dialog.component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;;;;YAUH;;;;;;;;;;eAUG;YAUH;gBASI,sCAAmB,EAAc;oBAAd,OAAE,GAAF,EAAE,CAAY;oBAJzB,oBAAe,GAAY,KAAK,CAAC;oBAEjC,uBAAkB,GAAY,KAAK,CAAC;oBAGxC,OAAO,CAAC,GAAG,CAAC,0CAA0C,EAAE,EAAE,CAAC,CAAC;gBAChE,CAAC;gBAED;;mBAEG;gBACH,uDAAgB,GAAhB,UAAiB,MAAM;oBACnB,IAAI,CAAC,eAAe,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC;gBACjD,CAAC;gBAED;;mBAEG;gBACH,iDAAU,GAAV;oBACI,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;gBAChC,CAAC;gBAED;;mBAEG;gBACH,2DAAoB,GAApB,UAAqB,MAAM;oBACvB,IAAI,CAAC,kBAAkB,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC;gBACvD,CAAC;gBA9BD;oBAAC,YAAK,EAAE;;wFAAA;gBAXZ;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,uBAAuB;wBACjC,QAAQ,EAAE,YAAY;wBACtB,UAAU,EAAE,CAAC,0DAA0B,CAAC;wBACxC,WAAW,EAAE,wCAAwC;wBACrD,SAAS,EAAE,CAAC,uCAAuC,CAAC;wBACpD,IAAI,EAAE,EAAC,qBAAqB,EAAE,kBAAkB,EAAC;wBACjD,KAAK,EAAE,CAAC,6BAAa,CAAC;qBACzB,CAAC;;gDAAA;gBAkCF,mCAAC;YAAD,CAAC,AAjCD,IAiCC;YAjCD,uEAiCC,CAAA"}
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
@@ -15,11 +15,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
import {Component, ElementRef, Input} from 'angular2/core';
|
||||
import {FileModel} from '../models/file.model';
|
||||
import {FileUploadingListComponent} from './file-uploading-list.component';
|
||||
import {TranslatePipe} from 'ng2-translate/ng2-translate';
|
||||
import { Component, ElementRef, Input } from 'angular2/core';
|
||||
import { FileModel } from '../models/file.model';
|
||||
import { FileUploadingListComponent } from './file-uploading-list.component';
|
||||
import { TranslatePipe } from 'ng2-translate/ng2-translate';
|
||||
|
||||
declare let __moduleName: string;
|
||||
|
||||
@@ -59,7 +58,7 @@ export class FileUploadingDialogComponent {
|
||||
/**
|
||||
* Display and hide the dialog component.
|
||||
*/
|
||||
toggleShowDialog($event) {
|
||||
toggleShowDialog() {
|
||||
this._isDialogActive = !this._isDialogActive;
|
||||
}
|
||||
|
||||
@@ -73,7 +72,7 @@ export class FileUploadingDialogComponent {
|
||||
/**
|
||||
* Minimize and expand the dialog component.
|
||||
*/
|
||||
toggleDialogMinimize($event) {
|
||||
toggleDialogMinimize() {
|
||||
this._isDialogMinimized = !this._isDialogMinimized;
|
||||
}
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { ElementRef } from 'angular2/core';
|
||||
import { FileModel } from '../models/file.model';
|
||||
/**
|
||||
* <alfresco-file-uploading-list [filesUploadingList]="FileModel[]" ></alfresco-file-uploading-list>
|
||||
*
|
||||
* This component show a list of the uploading files contained in the filesUploadingList.
|
||||
*
|
||||
* @InputParam {FileModel[]} filesUploadingList - list of the uploading files .
|
||||
*
|
||||
*
|
||||
* @returns {FileUploadingListComponent} .
|
||||
*/
|
||||
export declare class FileUploadingListComponent {
|
||||
el: ElementRef;
|
||||
filesUploadingList: FileModel[];
|
||||
constructor(el: ElementRef);
|
||||
/**
|
||||
* Abort the in progress uploading of a specific file.
|
||||
*
|
||||
* @param {string} id - FileModel id of the file to abort.
|
||||
*/
|
||||
abort(id: any): void;
|
||||
}
|
@@ -1,89 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
System.register(['angular2/core', 'ng2-translate/ng2-translate'], function(exports_1, context_1) {
|
||||
"use strict";
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var core_1, ng2_translate_1;
|
||||
var FileUploadingListComponent;
|
||||
return {
|
||||
setters:[
|
||||
function (core_1_1) {
|
||||
core_1 = core_1_1;
|
||||
},
|
||||
function (ng2_translate_1_1) {
|
||||
ng2_translate_1 = ng2_translate_1_1;
|
||||
}],
|
||||
execute: function() {
|
||||
/**
|
||||
* <alfresco-file-uploading-list [filesUploadingList]="FileModel[]" ></alfresco-file-uploading-list>
|
||||
*
|
||||
* This component show a list of the uploading files contained in the filesUploadingList.
|
||||
*
|
||||
* @InputParam {FileModel[]} filesUploadingList - list of the uploading files .
|
||||
*
|
||||
*
|
||||
* @returns {FileUploadingListComponent} .
|
||||
*/
|
||||
FileUploadingListComponent = (function () {
|
||||
function FileUploadingListComponent(el) {
|
||||
this.el = el;
|
||||
console.log('filesUploadingList constructor', el);
|
||||
setInterval(function () {
|
||||
console.log('Check for async update from drag directive');
|
||||
}, 1000);
|
||||
}
|
||||
/**
|
||||
* Abort the in progress uploading of a specific file.
|
||||
*
|
||||
* @param {string} id - FileModel id of the file to abort.
|
||||
*/
|
||||
FileUploadingListComponent.prototype.abort = function (id) {
|
||||
var file = this.filesUploadingList.filter(function (uploadingFileModel) {
|
||||
return uploadingFileModel.id == id;
|
||||
});
|
||||
file[0].setAbort();
|
||||
};
|
||||
__decorate([
|
||||
core_1.Input(),
|
||||
__metadata('design:type', Array)
|
||||
], FileUploadingListComponent.prototype, "filesUploadingList", void 0);
|
||||
FileUploadingListComponent = __decorate([
|
||||
core_1.Component({
|
||||
selector: 'alfresco-file-uploading-list',
|
||||
moduleId: __moduleName,
|
||||
templateUrl: './file-uploading-list.component.html',
|
||||
styleUrls: ['./file-uploading-list.component.css'],
|
||||
pipes: [ng2_translate_1.TranslatePipe]
|
||||
}),
|
||||
__metadata('design:paramtypes', [core_1.ElementRef])
|
||||
], FileUploadingListComponent);
|
||||
return FileUploadingListComponent;
|
||||
}());
|
||||
exports_1("FileUploadingListComponent", FileUploadingListComponent);
|
||||
}
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=file-uploading-list.component.js.map
|
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"file-uploading-list.component.js","sourceRoot":"","sources":["file-uploading-list.component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;YASH;;;;;;;;;eASG;YAQH;gBAKI,oCAAmB,EAAc;oBAAd,OAAE,GAAF,EAAE,CAAY;oBAC7B,OAAO,CAAC,GAAG,CAAC,gCAAgC,EAAE,EAAE,CAAC,CAAC;oBAElD,WAAW,CAAC;wBACR,OAAO,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC;oBAC9D,CAAC,EAAE,IAAI,CAAC,CAAC;gBACb,CAAC;gBAED;;;;mBAIG;gBACH,0CAAK,GAAL,UAAM,EAAE;oBACJ,IAAI,IAAI,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,UAAC,kBAAkB;wBACzD,MAAM,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,CAAC;oBACvC,CAAC,CAAC,CAAC;oBACH,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;gBACvB,CAAC;gBArBD;oBAAC,YAAK,EAAE;;sFAAA;gBATZ;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,8BAA8B;wBACxC,QAAQ,EAAE,YAAY;wBACtB,WAAW,EAAE,sCAAsC;wBACnD,SAAS,EAAE,CAAC,qCAAqC,CAAC;wBAClD,KAAK,EAAE,CAAC,6BAAa,CAAC;qBACzB,CAAC;;8CAAA;gBAyBF,iCAAC;YAAD,CAAC,AAxBD,IAwBC;YAxBD,mEAwBC,CAAA"}
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
@@ -16,9 +16,9 @@
|
||||
*/
|
||||
|
||||
|
||||
import {Component, ElementRef, Input} from 'angular2/core';
|
||||
import {FileModel} from '../models/file.model';
|
||||
import {TranslatePipe} from 'ng2-translate/ng2-translate';
|
||||
import { Component, ElementRef, Input } from 'angular2/core';
|
||||
import { FileModel } from '../models/file.model';
|
||||
import { TranslatePipe } from 'ng2-translate/ng2-translate';
|
||||
|
||||
declare let __moduleName: string;
|
||||
|
||||
@@ -47,9 +47,7 @@ export class FileUploadingListComponent {
|
||||
constructor(public el: ElementRef) {
|
||||
console.log('filesUploadingList constructor', el);
|
||||
|
||||
setInterval(() => {
|
||||
console.log('Check for async update from drag directive');
|
||||
}, 1000);
|
||||
setInterval(() => {console.log('Check for async update from drag directive'); }, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,9 +55,9 @@ export class FileUploadingListComponent {
|
||||
*
|
||||
* @param {string} id - FileModel id of the file to abort.
|
||||
*/
|
||||
abort(id): void {
|
||||
abort(id: string): void {
|
||||
let file = this.filesUploadingList.filter((uploadingFileModel) => {
|
||||
return uploadingFileModel.id == id;
|
||||
return uploadingFileModel.id === id;
|
||||
});
|
||||
file[0].setAbort();
|
||||
}
|
||||
|
@@ -1,75 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { ElementRef } from 'angular2/core';
|
||||
import { FileModel } from '../models/file.model';
|
||||
import { FileUploadingDialogComponent } from './file-uploading-dialog.component';
|
||||
import { TranslateService } from 'ng2-translate/ng2-translate';
|
||||
/**
|
||||
* <alfresco-upload-button [showDialogUpload]="boolean"
|
||||
* [showUdoNotificationBar]="boolean"
|
||||
* [uploadFolders]="boolean"
|
||||
* [multipleFiles]="boolean"
|
||||
* [acceptedFilesType]="string">
|
||||
* </alfresco-upload-button>
|
||||
*
|
||||
* This component, provide a set of buttons to upload files to alfresco.
|
||||
*
|
||||
* @InputParam {boolean} [true] showDialogUpload - hide/show upload dialog.
|
||||
* @InputParam {boolean} [true] showUdoNotificationBar - hide/show notification bar.
|
||||
* @InputParam {boolean} [false] uploadFolders - allow/disallow upload folders (only for chrome).
|
||||
* @InputParam {boolean} [false] multipleFiles - allow/disallow multiple files.
|
||||
* @InputParam {string} [*] acceptedFilesType - array of allowed file extensions.
|
||||
*
|
||||
*
|
||||
* @returns {UploadDragAreaComponent} .
|
||||
*/
|
||||
export declare class UploadButtonComponent {
|
||||
el: ElementRef;
|
||||
private _uploaderService;
|
||||
undoNotificationBar: any;
|
||||
fileUploadingDialogComponent: FileUploadingDialogComponent;
|
||||
showUploadDialog: boolean;
|
||||
showUdoNotificationBar: boolean;
|
||||
uploadFolders: boolean;
|
||||
multipleFiles: boolean;
|
||||
acceptedFilesType: string;
|
||||
uploaddirectory: string;
|
||||
filesUploadingList: FileModel[];
|
||||
translate: TranslateService;
|
||||
constructor(el: ElementRef, translate: TranslateService);
|
||||
/**
|
||||
* Method called when files are dropped in the drag area.
|
||||
*
|
||||
* @param {File[]} files - files dropped in the drag area.
|
||||
*/
|
||||
onFilesAdded($event: any): void;
|
||||
/**
|
||||
* Show undo notification bar.
|
||||
*
|
||||
* @param {FileModel[]} latestFilesAdded - files in the upload queue enriched with status flag and xhr object.
|
||||
*/
|
||||
private _showUndoNotificationBar(latestFilesAdded);
|
||||
/**
|
||||
* Show the upload dialog.
|
||||
*/
|
||||
private _showDialog();
|
||||
/**
|
||||
* Initial configuration for Multi language
|
||||
* @param translate
|
||||
*/
|
||||
translationInit(translate: TranslateService): void;
|
||||
}
|
@@ -1,194 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
System.register(['angular2/core', '../services/upload.service', './file-uploading-dialog.component', 'ng2-translate/ng2-translate'], function(exports_1, context_1) {
|
||||
"use strict";
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var core_1, upload_service_1, file_uploading_dialog_component_1, ng2_translate_1;
|
||||
var UploadButtonComponent;
|
||||
return {
|
||||
setters:[
|
||||
function (core_1_1) {
|
||||
core_1 = core_1_1;
|
||||
},
|
||||
function (upload_service_1_1) {
|
||||
upload_service_1 = upload_service_1_1;
|
||||
},
|
||||
function (file_uploading_dialog_component_1_1) {
|
||||
file_uploading_dialog_component_1 = file_uploading_dialog_component_1_1;
|
||||
},
|
||||
function (ng2_translate_1_1) {
|
||||
ng2_translate_1 = ng2_translate_1_1;
|
||||
}],
|
||||
execute: function() {
|
||||
/**
|
||||
* <alfresco-upload-button [showDialogUpload]="boolean"
|
||||
* [showUdoNotificationBar]="boolean"
|
||||
* [uploadFolders]="boolean"
|
||||
* [multipleFiles]="boolean"
|
||||
* [acceptedFilesType]="string">
|
||||
* </alfresco-upload-button>
|
||||
*
|
||||
* This component, provide a set of buttons to upload files to alfresco.
|
||||
*
|
||||
* @InputParam {boolean} [true] showDialogUpload - hide/show upload dialog.
|
||||
* @InputParam {boolean} [true] showUdoNotificationBar - hide/show notification bar.
|
||||
* @InputParam {boolean} [false] uploadFolders - allow/disallow upload folders (only for chrome).
|
||||
* @InputParam {boolean} [false] multipleFiles - allow/disallow multiple files.
|
||||
* @InputParam {string} [*] acceptedFilesType - array of allowed file extensions.
|
||||
*
|
||||
*
|
||||
* @returns {UploadDragAreaComponent} .
|
||||
*/
|
||||
UploadButtonComponent = (function () {
|
||||
function UploadButtonComponent(el, translate) {
|
||||
this.el = el;
|
||||
this.showUploadDialog = true;
|
||||
this.showUdoNotificationBar = true;
|
||||
this.uploadFolders = false;
|
||||
this.multipleFiles = false;
|
||||
this.acceptedFilesType = '*';
|
||||
this.uploaddirectory = '';
|
||||
this.filesUploadingList = [];
|
||||
console.log('UploadComponent constructor', el);
|
||||
this._uploaderService = new upload_service_1.UploadService({
|
||||
url: 'http://192.168.99.100:8080/alfresco/service/api/upload',
|
||||
withCredentials: true,
|
||||
authToken: btoa('admin:admin'),
|
||||
authTokenPrefix: 'Basic',
|
||||
fieldName: 'filedata',
|
||||
formFields: {
|
||||
siteid: 'swsdp',
|
||||
containerid: 'documentLibrary'
|
||||
}
|
||||
});
|
||||
this.translationInit(translate);
|
||||
}
|
||||
/**
|
||||
* Method called when files are dropped in the drag area.
|
||||
*
|
||||
* @param {File[]} files - files dropped in the drag area.
|
||||
*/
|
||||
UploadButtonComponent.prototype.onFilesAdded = function ($event) {
|
||||
var files = $event.currentTarget.files;
|
||||
if (files.length) {
|
||||
var latestFilesAdded = this._uploaderService.addToQueue(files);
|
||||
this._uploaderService.uploadFilesInTheQueue(this.uploaddirectory);
|
||||
this.filesUploadingList = this._uploaderService.getQueue();
|
||||
if (this.showUploadDialog) {
|
||||
this._showDialog();
|
||||
}
|
||||
if (this.showUdoNotificationBar) {
|
||||
this._showUndoNotificationBar(latestFilesAdded);
|
||||
}
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Show undo notification bar.
|
||||
*
|
||||
* @param {FileModel[]} latestFilesAdded - files in the upload queue enriched with status flag and xhr object.
|
||||
*/
|
||||
UploadButtonComponent.prototype._showUndoNotificationBar = function (latestFilesAdded) {
|
||||
if (componentHandler) {
|
||||
componentHandler.upgradeAllRegistered();
|
||||
}
|
||||
this.undoNotificationBar.nativeElement.MaterialSnackbar.showSnackbar({
|
||||
message: this.translate.get('FILE_UPLOAD.MESSAGES.PROGRESS').value,
|
||||
timeout: 5000,
|
||||
actionHandler: function () {
|
||||
latestFilesAdded.forEach(function (uploadingFileModel) {
|
||||
uploadingFileModel.setAbort();
|
||||
});
|
||||
},
|
||||
actionText: this.translate.get('FILE_UPLOAD.ACTION.UNDO').value
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Show the upload dialog.
|
||||
*/
|
||||
UploadButtonComponent.prototype._showDialog = function () {
|
||||
this.fileUploadingDialogComponent.showDialog();
|
||||
};
|
||||
/**
|
||||
* Initial configuration for Multi language
|
||||
* @param translate
|
||||
*/
|
||||
UploadButtonComponent.prototype.translationInit = function (translate) {
|
||||
this.translate = translate;
|
||||
var userLang = navigator.language.split('-')[0]; // use navigator lang if available
|
||||
userLang = /(fr|en)/gi.test(userLang) ? userLang : 'en';
|
||||
this.translate.setDefaultLang(userLang);
|
||||
this.translate.use(userLang);
|
||||
};
|
||||
__decorate([
|
||||
core_1.ViewChild('undoNotificationBar'),
|
||||
__metadata('design:type', Object)
|
||||
], UploadButtonComponent.prototype, "undoNotificationBar", void 0);
|
||||
__decorate([
|
||||
core_1.ViewChild('fileUploadingDialog'),
|
||||
__metadata('design:type', file_uploading_dialog_component_1.FileUploadingDialogComponent)
|
||||
], UploadButtonComponent.prototype, "fileUploadingDialogComponent", void 0);
|
||||
__decorate([
|
||||
core_1.Input(),
|
||||
__metadata('design:type', Boolean)
|
||||
], UploadButtonComponent.prototype, "showUploadDialog", void 0);
|
||||
__decorate([
|
||||
core_1.Input(),
|
||||
__metadata('design:type', Boolean)
|
||||
], UploadButtonComponent.prototype, "showUdoNotificationBar", void 0);
|
||||
__decorate([
|
||||
core_1.Input(),
|
||||
__metadata('design:type', Boolean)
|
||||
], UploadButtonComponent.prototype, "uploadFolders", void 0);
|
||||
__decorate([
|
||||
core_1.Input(),
|
||||
__metadata('design:type', Boolean)
|
||||
], UploadButtonComponent.prototype, "multipleFiles", void 0);
|
||||
__decorate([
|
||||
core_1.Input(),
|
||||
__metadata('design:type', String)
|
||||
], UploadButtonComponent.prototype, "acceptedFilesType", void 0);
|
||||
__decorate([
|
||||
core_1.Input(),
|
||||
__metadata('design:type', String)
|
||||
], UploadButtonComponent.prototype, "uploaddirectory", void 0);
|
||||
UploadButtonComponent = __decorate([
|
||||
core_1.Component({
|
||||
selector: 'alfresco-upload-button',
|
||||
moduleId: __moduleName,
|
||||
directives: [file_uploading_dialog_component_1.FileUploadingDialogComponent],
|
||||
templateUrl: './upload-button.component.html',
|
||||
styleUrls: ['./upload-button.component.css'],
|
||||
pipes: [ng2_translate_1.TranslatePipe]
|
||||
}),
|
||||
__metadata('design:paramtypes', [core_1.ElementRef, ng2_translate_1.TranslateService])
|
||||
], UploadButtonComponent);
|
||||
return UploadButtonComponent;
|
||||
}());
|
||||
exports_1("UploadButtonComponent", UploadButtonComponent);
|
||||
}
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=upload-button.component.js.map
|
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"upload-button.component.js","sourceRoot":"","sources":["upload-button.component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAYH;;;;;;;;;;;;;;;;;;eAkBG;YASH;gBAgCI,+BAAmB,EAAc,EACrB,SAA2B;oBADpB,OAAE,GAAF,EAAE,CAAY;oBArBjC,qBAAgB,GAAY,IAAI,CAAC;oBAGjC,2BAAsB,GAAY,IAAI,CAAC;oBAGvC,kBAAa,GAAY,KAAK,CAAC;oBAG/B,kBAAa,GAAY,KAAK,CAAC;oBAG/B,sBAAiB,GAAW,GAAG,CAAC;oBAGhC,oBAAe,GAAW,EAAE,CAAC;oBAE7B,uBAAkB,GAAiB,EAAE,CAAC;oBAMlC,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;oBAE/C,IAAI,CAAC,gBAAgB,GAAG,IAAI,8BAAa,CAAC;wBACtC,GAAG,EAAE,wDAAwD;wBAC7D,eAAe,EAAE,IAAI;wBACrB,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC;wBAC9B,eAAe,EAAE,OAAO;wBACx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C7C,SAAS,EAAE,CAAC,+BAA+B,CAAC;wBAC5C,KAAK,EAAE,CAAC,6BAAa,CAAC;qBACzB,CAAC;;yCAAA;gBAkHF,4BAAC;YAAD,CAAC,AAjHD,IAiHC;YAjHD,yDAiHC,CAAA"}
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
@@ -16,13 +16,13 @@
|
||||
*/
|
||||
|
||||
|
||||
import {Component, ViewChild, ElementRef, Input} from 'angular2/core';
|
||||
import {UploadService} from '../services/upload.service';
|
||||
import {FileModel} from '../models/file.model';
|
||||
import {FileUploadingDialogComponent} from './file-uploading-dialog.component';
|
||||
import {TranslateService, TranslatePipe} from 'ng2-translate/ng2-translate';
|
||||
import { Component, ViewChild, ElementRef, Input } from 'angular2/core';
|
||||
import { UploadService } from '../services/upload.service';
|
||||
import { FileModel } from '../models/file.model';
|
||||
import { FileUploadingDialogComponent } from './file-uploading-dialog.component';
|
||||
import { TranslateService, TranslatePipe } from 'ng2-translate/ng2-translate';
|
||||
|
||||
declare let componentHandler;
|
||||
declare let componentHandler: any;
|
||||
declare let __moduleName: string;
|
||||
|
||||
/**
|
||||
@@ -54,10 +54,8 @@ declare let __moduleName: string;
|
||||
})
|
||||
export class UploadButtonComponent {
|
||||
|
||||
private _uploaderService: UploadService;
|
||||
|
||||
@ViewChild('undoNotificationBar')
|
||||
undoNotificationBar;
|
||||
undoNotificationBar: any;
|
||||
|
||||
@ViewChild('fileUploadingDialog')
|
||||
fileUploadingDialogComponent: FileUploadingDialogComponent;
|
||||
@@ -84,6 +82,8 @@ export class UploadButtonComponent {
|
||||
|
||||
translate: TranslateService;
|
||||
|
||||
private _uploaderService: UploadService;
|
||||
|
||||
constructor(public el: ElementRef,
|
||||
translate: TranslateService) {
|
||||
console.log('UploadComponent constructor', el);
|
||||
@@ -108,7 +108,7 @@ export class UploadButtonComponent {
|
||||
*
|
||||
* @param {File[]} files - files dropped in the drag area.
|
||||
*/
|
||||
onFilesAdded($event): void {
|
||||
onFilesAdded($event: any): void {
|
||||
let files = $event.currentTarget.files;
|
||||
if (files.length) {
|
||||
let latestFilesAdded = this._uploaderService.addToQueue(files);
|
||||
@@ -123,35 +123,6 @@ export class UploadButtonComponent {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show undo notification bar.
|
||||
*
|
||||
* @param {FileModel[]} latestFilesAdded - files in the upload queue enriched with status flag and xhr object.
|
||||
*/
|
||||
private _showUndoNotificationBar(latestFilesAdded) {
|
||||
if (componentHandler) {
|
||||
componentHandler.upgradeAllRegistered();
|
||||
}
|
||||
|
||||
this.undoNotificationBar.nativeElement.MaterialSnackbar.showSnackbar({
|
||||
message: this.translate.get('FILE_UPLOAD.MESSAGES.PROGRESS').value,
|
||||
timeout: 5000,
|
||||
actionHandler: function () {
|
||||
latestFilesAdded.forEach((uploadingFileModel) => {
|
||||
uploadingFileModel.setAbort();
|
||||
});
|
||||
},
|
||||
actionText: this.translate.get('FILE_UPLOAD.ACTION.UNDO').value
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the upload dialog.
|
||||
*/
|
||||
private _showDialog(): void {
|
||||
this.fileUploadingDialogComponent.showDialog();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initial configuration for Multi language
|
||||
* @param translate
|
||||
@@ -165,4 +136,33 @@ export class UploadButtonComponent {
|
||||
|
||||
this.translate.use(userLang);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show undo notification bar.
|
||||
*
|
||||
* @param {FileModel[]} latestFilesAdded - files in the upload queue enriched with status flag and xhr object.
|
||||
*/
|
||||
private _showUndoNotificationBar(latestFilesAdded: FileModel[]) {
|
||||
if (componentHandler) {
|
||||
componentHandler.upgradeAllRegistered();
|
||||
}
|
||||
|
||||
this.undoNotificationBar.nativeElement.MaterialSnackbar.showSnackbar({
|
||||
message: this.translate.get('FILE_UPLOAD.MESSAGES.PROGRESS'),
|
||||
timeout: 5000,
|
||||
actionHandler: function () {
|
||||
latestFilesAdded.forEach((uploadingFileModel: FileModel) => {
|
||||
uploadingFileModel.setAbort();
|
||||
});
|
||||
},
|
||||
actionText: this.translate.get('FILE_UPLOAD.ACTION.UNDO')
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the upload dialog.
|
||||
*/
|
||||
private _showDialog(): void {
|
||||
this.fileUploadingDialogComponent.showDialog();
|
||||
}
|
||||
}
|
||||
|
@@ -1,48 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { ElementRef } from 'angular2/core';
|
||||
import { FileModel } from '../models/file.model';
|
||||
import { FileUploadingDialogComponent } from './file-uploading-dialog.component';
|
||||
/**
|
||||
* <alfresco-upload-drag-area [showDialogUpload]="boolean" ></alfresco-upload-drag-area>
|
||||
*
|
||||
* This component, provide a drag and drop are to upload files to alfresco.
|
||||
*
|
||||
* @InputParam {boolean} [true] showDialogUpload - hide/show upload dialog .
|
||||
*
|
||||
*
|
||||
* @returns {UploadDragAreaComponent} .
|
||||
*/
|
||||
export declare class UploadDragAreaComponent {
|
||||
el: ElementRef;
|
||||
private _uploaderService;
|
||||
fileUploadingDialogComponent: FileUploadingDialogComponent;
|
||||
showUploadDialog: boolean;
|
||||
filesUploadingList: FileModel[];
|
||||
uploaddirectory: string;
|
||||
constructor(el: ElementRef);
|
||||
/**
|
||||
* Method called when files are dropped in the drag area.
|
||||
*
|
||||
* @param {File[]} files - files dropped in the drag area.
|
||||
*/
|
||||
onFilesDropped(files: any): void;
|
||||
/**
|
||||
* Show the upload dialog.
|
||||
*/
|
||||
private _showDialog();
|
||||
}
|
@@ -1,124 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
System.register(['angular2/core', '../services/upload.service', './file-uploading-dialog.component', '../directives/file-draggable.directive'], function(exports_1, context_1) {
|
||||
"use strict";
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var core_1, upload_service_1, file_uploading_dialog_component_1, file_draggable_directive_1;
|
||||
var UploadDragAreaComponent;
|
||||
return {
|
||||
setters:[
|
||||
function (core_1_1) {
|
||||
core_1 = core_1_1;
|
||||
},
|
||||
function (upload_service_1_1) {
|
||||
upload_service_1 = upload_service_1_1;
|
||||
},
|
||||
function (file_uploading_dialog_component_1_1) {
|
||||
file_uploading_dialog_component_1 = file_uploading_dialog_component_1_1;
|
||||
},
|
||||
function (file_draggable_directive_1_1) {
|
||||
file_draggable_directive_1 = file_draggable_directive_1_1;
|
||||
}],
|
||||
execute: function() {
|
||||
/**
|
||||
* <alfresco-upload-drag-area [showDialogUpload]="boolean" ></alfresco-upload-drag-area>
|
||||
*
|
||||
* This component, provide a drag and drop are to upload files to alfresco.
|
||||
*
|
||||
* @InputParam {boolean} [true] showDialogUpload - hide/show upload dialog .
|
||||
*
|
||||
*
|
||||
* @returns {UploadDragAreaComponent} .
|
||||
*/
|
||||
UploadDragAreaComponent = (function () {
|
||||
function UploadDragAreaComponent(el) {
|
||||
this.el = el;
|
||||
this.showUploadDialog = true;
|
||||
this.filesUploadingList = [];
|
||||
this.uploaddirectory = '';
|
||||
console.log('UploadComponent constructor', el);
|
||||
this._uploaderService = new upload_service_1.UploadService({
|
||||
url: 'http://192.168.99.100:8080/alfresco/service/api/upload',
|
||||
withCredentials: true,
|
||||
authToken: btoa('admin:admin'),
|
||||
authTokenPrefix: 'Basic',
|
||||
fieldName: 'filedata',
|
||||
formFields: {
|
||||
siteid: 'swsdp',
|
||||
containerid: 'documentLibrary'
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Method called when files are dropped in the drag area.
|
||||
*
|
||||
* @param {File[]} files - files dropped in the drag area.
|
||||
*/
|
||||
UploadDragAreaComponent.prototype.onFilesDropped = function (files) {
|
||||
if (files.length) {
|
||||
this._uploaderService.addToQueue(files);
|
||||
this._uploaderService.uploadFilesInTheQueue(this.uploaddirectory);
|
||||
this.filesUploadingList = this._uploaderService.getQueue();
|
||||
if (this.showUploadDialog) {
|
||||
this._showDialog();
|
||||
}
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Show the upload dialog.
|
||||
*/
|
||||
UploadDragAreaComponent.prototype._showDialog = function () {
|
||||
this.fileUploadingDialogComponent.showDialog();
|
||||
};
|
||||
__decorate([
|
||||
core_1.ViewChild('fileUploadingDialog'),
|
||||
__metadata('design:type', file_uploading_dialog_component_1.FileUploadingDialogComponent)
|
||||
], UploadDragAreaComponent.prototype, "fileUploadingDialogComponent", void 0);
|
||||
__decorate([
|
||||
core_1.Input(),
|
||||
__metadata('design:type', Boolean)
|
||||
], UploadDragAreaComponent.prototype, "showUploadDialog", void 0);
|
||||
__decorate([
|
||||
core_1.Input(),
|
||||
__metadata('design:type', String)
|
||||
], UploadDragAreaComponent.prototype, "uploaddirectory", void 0);
|
||||
UploadDragAreaComponent = __decorate([
|
||||
core_1.Component({
|
||||
selector: 'alfresco-upload-drag-area',
|
||||
moduleId: __moduleName,
|
||||
directives: [file_draggable_directive_1.FileDraggableDirective, file_uploading_dialog_component_1.FileUploadingDialogComponent],
|
||||
templateUrl: './upload-drag-area.component.html',
|
||||
styleUrls: ['./upload-drag-area.component.css']
|
||||
}),
|
||||
__metadata('design:paramtypes', [core_1.ElementRef])
|
||||
], UploadDragAreaComponent);
|
||||
return UploadDragAreaComponent;
|
||||
}());
|
||||
exports_1("UploadDragAreaComponent", UploadDragAreaComponent);
|
||||
}
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=upload-drag-area.component.js.map
|
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"upload-drag-area.component.js","sourceRoot":"","sources":["upload-drag-area.component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAWH;;;;;;;;;eASG;YAQH;gBAeI,iCAAmB,EAAc;oBAAd,OAAE,GAAF,EAAE,CAAY;oBAPjC,qBAAgB,GAAY,IAAI,CAAC;oBAEjC,uBAAkB,GAAiB,EAAE,CAAC;oBAGtC,oBAAe,GAAW,EAAE,CAAC;oBAGzB,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;oBAE/C,IAAI,CA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D,CAAC,AArDD,IAqDC;YArDD,6DAqDC,CAAA"}
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
@@ -15,12 +15,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
import {Component, ViewChild, ElementRef, Input, EventEmitter} from 'angular2/core';
|
||||
import {UploadService} from '../services/upload.service';
|
||||
import {FileModel} from '../models/file.model';
|
||||
import {FileUploadingDialogComponent} from './file-uploading-dialog.component';
|
||||
import {FileDraggableDirective} from '../directives/file-draggable.directive';
|
||||
import { Component, ViewChild, ElementRef, Input } from 'angular2/core';
|
||||
import { UploadService } from '../services/upload.service';
|
||||
import { FileModel } from '../models/file.model';
|
||||
import { FileUploadingDialogComponent } from './file-uploading-dialog.component';
|
||||
import { FileDraggableDirective } from '../directives/file-draggable.directive';
|
||||
|
||||
declare let __moduleName: string;
|
||||
|
||||
@@ -77,7 +76,7 @@ export class UploadDragAreaComponent {
|
||||
*
|
||||
* @param {File[]} files - files dropped in the drag area.
|
||||
*/
|
||||
onFilesDropped(files): void {
|
||||
onFilesDropped(files: File[]): void {
|
||||
if (files.length) {
|
||||
this._uploaderService.addToQueue(files);
|
||||
this._uploaderService.uploadFilesInTheQueue(this.uploaddirectory);
|
||||
|
@@ -1,65 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { ElementRef, EventEmitter } from 'angular2/core';
|
||||
/**
|
||||
* [file-draggable]
|
||||
*
|
||||
* This directive, provide a drag and drop area for files and folders.
|
||||
*
|
||||
* @OutputEvent {EventEmitter} onFilesDropped(File)- event fired fot each file dropped
|
||||
* in the drag and drop area.
|
||||
*
|
||||
*
|
||||
* @returns {FileDraggableDirective} .
|
||||
*/
|
||||
export declare class FileDraggableDirective {
|
||||
el: ElementRef;
|
||||
onFilesDropped: EventEmitter<any>;
|
||||
files: File[];
|
||||
private _inputFocusClass;
|
||||
constructor(el: ElementRef);
|
||||
/**
|
||||
* Method called when files is dropped in the drag and drop area.
|
||||
*
|
||||
* @param {$event} $event - DOM $event.
|
||||
*/
|
||||
private _onDropFiles($event);
|
||||
/**
|
||||
* Travers all the files and folders, and emit an event for each file.
|
||||
*
|
||||
* @param {Object} item - can contains files or folders.
|
||||
*/
|
||||
private _traverseFileTree(item);
|
||||
/**
|
||||
* Change the style of the drag area when a file drag in.
|
||||
*
|
||||
* @param {$event} $event - DOM $event.
|
||||
*/
|
||||
private _onDragEnter($event);
|
||||
/**
|
||||
* Change the style of the drag area when a file drag out.
|
||||
*
|
||||
* @param {$event} $event - DOM $event.
|
||||
*/
|
||||
private _onDragLeave($event);
|
||||
/**
|
||||
* Prevent default and stop propagation of the DOM event.
|
||||
*
|
||||
* @param {$event} $event - DOM $event.
|
||||
*/
|
||||
private _preventDefault($event);
|
||||
}
|
@@ -1,150 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
System.register(['angular2/core'], function(exports_1, context_1) {
|
||||
"use strict";
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var core_1;
|
||||
var FileDraggableDirective;
|
||||
return {
|
||||
setters:[
|
||||
function (core_1_1) {
|
||||
core_1 = core_1_1;
|
||||
}],
|
||||
execute: function() {
|
||||
/**
|
||||
* [file-draggable]
|
||||
*
|
||||
* This directive, provide a drag and drop area for files and folders.
|
||||
*
|
||||
* @OutputEvent {EventEmitter} onFilesDropped(File)- event fired fot each file dropped
|
||||
* in the drag and drop area.
|
||||
*
|
||||
*
|
||||
* @returns {FileDraggableDirective} .
|
||||
*/
|
||||
FileDraggableDirective = (function () {
|
||||
function FileDraggableDirective(el) {
|
||||
this.el = el;
|
||||
this.onFilesDropped = new core_1.EventEmitter();
|
||||
this._inputFocusClass = false;
|
||||
console.log('FileDraggableComponent constructor', el);
|
||||
}
|
||||
/**
|
||||
* Method called when files is dropped in the drag and drop area.
|
||||
*
|
||||
* @param {$event} $event - DOM $event.
|
||||
*/
|
||||
FileDraggableDirective.prototype._onDropFiles = function ($event) {
|
||||
this._preventDefault($event);
|
||||
var items = $event.dataTransfer.items;
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var item = items[i].webkitGetAsEntry();
|
||||
if (item) {
|
||||
this._traverseFileTree(item);
|
||||
}
|
||||
else {
|
||||
var dt = $event.dataTransfer;
|
||||
var files = dt.files;
|
||||
this.onFilesDropped.emit(files);
|
||||
}
|
||||
}
|
||||
this._inputFocusClass = false;
|
||||
};
|
||||
/**
|
||||
* Travers all the files and folders, and emit an event for each file.
|
||||
*
|
||||
* @param {Object} item - can contains files or folders.
|
||||
*/
|
||||
FileDraggableDirective.prototype._traverseFileTree = function (item) {
|
||||
if (item.isFile) {
|
||||
var self_1 = this;
|
||||
item.file(function (file) {
|
||||
self_1.onFilesDropped.emit([file]);
|
||||
});
|
||||
}
|
||||
else {
|
||||
if (item.isDirectory) {
|
||||
var self_2 = this;
|
||||
var dirReader = item.createReader();
|
||||
dirReader.readEntries(function (entries) {
|
||||
for (var i = 0; i < entries.length; i++) {
|
||||
self_2._traverseFileTree(entries[i]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Change the style of the drag area when a file drag in.
|
||||
*
|
||||
* @param {$event} $event - DOM $event.
|
||||
*/
|
||||
FileDraggableDirective.prototype._onDragEnter = function ($event) {
|
||||
this._preventDefault($event);
|
||||
this._inputFocusClass = true;
|
||||
};
|
||||
/**
|
||||
* Change the style of the drag area when a file drag out.
|
||||
*
|
||||
* @param {$event} $event - DOM $event.
|
||||
*/
|
||||
FileDraggableDirective.prototype._onDragLeave = function ($event) {
|
||||
this._preventDefault($event);
|
||||
this._inputFocusClass = false;
|
||||
};
|
||||
/**
|
||||
* Prevent default and stop propagation of the DOM event.
|
||||
*
|
||||
* @param {$event} $event - DOM $event.
|
||||
*/
|
||||
FileDraggableDirective.prototype._preventDefault = function ($event) {
|
||||
$event.stopPropagation();
|
||||
$event.preventDefault();
|
||||
};
|
||||
__decorate([
|
||||
core_1.Output(),
|
||||
__metadata('design:type', core_1.EventEmitter)
|
||||
], FileDraggableDirective.prototype, "onFilesDropped", void 0);
|
||||
FileDraggableDirective = __decorate([
|
||||
core_1.Directive({
|
||||
selector: '[file-draggable]',
|
||||
host: {
|
||||
'(drop)': '_onDropFiles($event)',
|
||||
'(dragenter)': '_onDragEnter($event)',
|
||||
'(dragleave)': '_onDragLeave($event)',
|
||||
'(dragover)': '_preventDefault($event)',
|
||||
'[class.input-focus]': '_inputFocusClass'
|
||||
}
|
||||
}),
|
||||
__metadata('design:paramtypes', [core_1.ElementRef])
|
||||
], FileDraggableDirective);
|
||||
return FileDraggableDirective;
|
||||
}());
|
||||
exports_1("FileDraggableDirective", FileDraggableDirective);
|
||||
}
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=file-draggable.directive.js.map
|
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"file-draggable.directive.js","sourceRoot":"","sources":["file-draggable.directive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;YAIH;;;;;;;;;;eAUG;YAWH;gBASI,gCAAmB,EAAc;oBAAd,OAAE,GAAF,EAAE,CAAY;oBANjC,mBAAc,GAAsB,IAAI,mBAAY,EAAE,CAAC;oBAI/C,qBAAgB,GAAY,KAAK,CAAC;oBAGtC,OAAO,CAAC,GAAG,CAAC,oCAAoC,EAAE,EAAE,CAAC,CAAC;gBAC1D,CAAC;gBAED;;;;mBAIG;gBACK,6CAAY,GAApB,UAAqB,MAAM;oBACvB,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;oBAE7B,IAAI,KAAK,GAAG,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC;oBACtC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;wBACpC,IAAI,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC;wBACvC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;4BACP,IAAI,CAAC,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G,IAAI,CAAC;gBACjC,CAAC;gBAED;;;;mBAIG;gBACK,6CAAY,GAApB,UAAqB,MAAM;oBACvB,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;oBAE7B,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;gBAClC,CAAC;gBAED;;;;mBAIG;gBACK,gDAAe,GAAvB,UAAwB,MAAM;oBAC1B,MAAM,CAAC,eAAe,EAAE,CAAC;oBACzB,MAAM,CAAC,cAAc,EAAE,CAAC;gBAC5B,CAAC;gBAxFD;oBAAC,aAAM,EAAE;;8EAAA;gBAZb;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,kBAAkB;wBAC5B,IAAI,EAAE;4BACF,QAAQ,EAAE,sBAAsB;4BAChC,aAAa,EAAE,sBAAsB;4BACrC,aAAa,EAAE,sBAAsB;4BACrC,YAAY,EAAE,yBAAyB;4BACvC,qBAAqB,EAAE,kBAAkB;yBAC5C;qBACJ,CAAC;;0CAAA;gBA4FF,6BAAC;YAAD,CAAC,AA3FD,IA2FC;YA3FD,2DA2FC,CAAA"}
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Directive, ElementRef, EventEmitter, Output} from 'angular2/core';
|
||||
import { Directive, ElementRef, EventEmitter, Output } from 'angular2/core';
|
||||
|
||||
/**
|
||||
* [file-draggable]
|
||||
@@ -56,12 +56,12 @@ export class FileDraggableDirective {
|
||||
*
|
||||
* @param {$event} $event - DOM $event.
|
||||
*/
|
||||
private _onDropFiles($event): void {
|
||||
_onDropFiles($event: any): void {
|
||||
this._preventDefault($event);
|
||||
|
||||
var items = $event.dataTransfer.items;
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var item = items[i].webkitGetAsEntry();
|
||||
let items = $event.dataTransfer.items;
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
let item = items[i].webkitGetAsEntry();
|
||||
if (item) {
|
||||
this._traverseFileTree(item);
|
||||
} else {
|
||||
@@ -79,18 +79,18 @@ export class FileDraggableDirective {
|
||||
*
|
||||
* @param {Object} item - can contains files or folders.
|
||||
*/
|
||||
private _traverseFileTree(item): void {
|
||||
private _traverseFileTree(item: any): void {
|
||||
if (item.isFile) {
|
||||
let self = this;
|
||||
item.file(function (file) {
|
||||
item.file(function (file: File) {
|
||||
self.onFilesDropped.emit([file]);
|
||||
});
|
||||
} else {
|
||||
if (item.isDirectory) {
|
||||
let self = this;
|
||||
let dirReader = item.createReader();
|
||||
dirReader.readEntries(function (entries) {
|
||||
for (var i = 0; i < entries.length; i++) {
|
||||
dirReader.readEntries(function (entries: any) {
|
||||
for (let i = 0; i < entries.length; i++) {
|
||||
self._traverseFileTree(entries[i]);
|
||||
}
|
||||
});
|
||||
@@ -103,7 +103,7 @@ export class FileDraggableDirective {
|
||||
*
|
||||
* @param {$event} $event - DOM $event.
|
||||
*/
|
||||
private _onDragEnter($event): void {
|
||||
_onDragEnter($event: Event): void {
|
||||
this._preventDefault($event);
|
||||
|
||||
this._inputFocusClass = true;
|
||||
@@ -114,7 +114,7 @@ export class FileDraggableDirective {
|
||||
*
|
||||
* @param {$event} $event - DOM $event.
|
||||
*/
|
||||
private _onDragLeave($event): void {
|
||||
_onDragLeave($event: Event): void {
|
||||
this._preventDefault($event);
|
||||
|
||||
this._inputFocusClass = false;
|
||||
@@ -125,7 +125,7 @@ export class FileDraggableDirective {
|
||||
*
|
||||
* @param {$event} $event - DOM $event.
|
||||
*/
|
||||
private _preventDefault($event): void {
|
||||
_preventDefault($event: Event): void {
|
||||
$event.stopPropagation();
|
||||
$event.preventDefault();
|
||||
}
|
||||
|
@@ -1,63 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* This object represent the status of an uploading file.
|
||||
*
|
||||
*
|
||||
* @returns {FileModel} .
|
||||
*/
|
||||
export declare class FileModel {
|
||||
id: string;
|
||||
status: number;
|
||||
statusText: string;
|
||||
progress: Object;
|
||||
name: string;
|
||||
size: string;
|
||||
response: string;
|
||||
done: boolean;
|
||||
error: boolean;
|
||||
abort: boolean;
|
||||
uploading: boolean;
|
||||
file: any;
|
||||
_xmlHttpRequest: XMLHttpRequest;
|
||||
constructor(file: any);
|
||||
setProgres(progress: any): void;
|
||||
setError(): void;
|
||||
setUploading(): void;
|
||||
setXMLHttpRequest(xmlHttpRequest: XMLHttpRequest): void;
|
||||
/**
|
||||
* Stop the uploading of the file.
|
||||
*/
|
||||
setAbort(): void;
|
||||
/**
|
||||
* Update status of the file when upload finish or is ended.
|
||||
*/
|
||||
onFinished(status: number, statusText: string, response: string): void;
|
||||
/**
|
||||
* Calculate the size of the file in kb,mb and gb.
|
||||
*
|
||||
* @param {number} sizeinbytes - size in bytes of the file.
|
||||
*/
|
||||
private _getFileSize(sizeinbytes);
|
||||
/**
|
||||
* Calculate the size of the file in kb,mb and gb.
|
||||
*
|
||||
* @return {string} - return a unique file uploading id.
|
||||
*/
|
||||
private _generateId();
|
||||
}
|
@@ -1,111 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
System.register([], function(exports_1, context_1) {
|
||||
"use strict";
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
var FileModel;
|
||||
return {
|
||||
setters:[],
|
||||
execute: function() {
|
||||
/**
|
||||
*
|
||||
* This object represent the status of an uploading file.
|
||||
*
|
||||
*
|
||||
* @returns {FileModel} .
|
||||
*/
|
||||
FileModel = (function () {
|
||||
function FileModel(file) {
|
||||
this.done = false;
|
||||
this.error = false;
|
||||
this.abort = false;
|
||||
this.uploading = false;
|
||||
this.file = file;
|
||||
this.id = this._generateId();
|
||||
this.name = file.name;
|
||||
this.size = this._getFileSize(file.size);
|
||||
this.progress = {
|
||||
loaded: 0,
|
||||
total: 0,
|
||||
percent: 0
|
||||
};
|
||||
}
|
||||
FileModel.prototype.setProgres = function (progress) {
|
||||
this.progress = progress;
|
||||
};
|
||||
FileModel.prototype.setError = function () {
|
||||
this.error = true;
|
||||
};
|
||||
FileModel.prototype.setUploading = function () {
|
||||
this.uploading = true;
|
||||
};
|
||||
FileModel.prototype.setXMLHttpRequest = function (xmlHttpRequest) {
|
||||
this._xmlHttpRequest = xmlHttpRequest;
|
||||
};
|
||||
/**
|
||||
* Stop the uploading of the file.
|
||||
*/
|
||||
FileModel.prototype.setAbort = function () {
|
||||
if (!this.done && !this.error) {
|
||||
this.abort = true;
|
||||
this.uploading = false;
|
||||
this._xmlHttpRequest.abort();
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Update status of the file when upload finish or is ended.
|
||||
*/
|
||||
FileModel.prototype.onFinished = function (status, statusText, response) {
|
||||
this.status = status;
|
||||
this.statusText = statusText;
|
||||
this.response = response;
|
||||
this.done = true;
|
||||
this.uploading = false;
|
||||
};
|
||||
/**
|
||||
* Calculate the size of the file in kb,mb and gb.
|
||||
*
|
||||
* @param {number} sizeinbytes - size in bytes of the file.
|
||||
*/
|
||||
FileModel.prototype._getFileSize = function (sizeinbytes) {
|
||||
var fSExt = new Array('Bytes', 'KB', 'MB', 'GB');
|
||||
var size = sizeinbytes;
|
||||
var i = 0;
|
||||
while (size > 900) {
|
||||
size /= 1000;
|
||||
i++;
|
||||
}
|
||||
return Math.round((Math.round(size * 100) / 100)) + ' ' + fSExt[i];
|
||||
};
|
||||
/**
|
||||
* Calculate the size of the file in kb,mb and gb.
|
||||
*
|
||||
* @return {string} - return a unique file uploading id.
|
||||
*/
|
||||
FileModel.prototype._generateId = function () {
|
||||
return 'uploading-file-' + 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
||||
return v.toString(16);
|
||||
});
|
||||
};
|
||||
return FileModel;
|
||||
}());
|
||||
exports_1("FileModel", FileModel);
|
||||
}
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=file.model.js.map
|
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"file.model.js","sourceRoot":"","sources":["file.model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;YAEH;;;;;;eAMG;YACH;gBAeI,mBAAY,IAAS;oBAPrB,SAAI,GAAY,KAAK,CAAC;oBACtB,UAAK,GAAY,KAAK,CAAC;oBACvB,UAAK,GAAY,KAAK,CAAC;oBACvB,cAAS,GAAY,KAAK,CAAC;oBAKvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;oBACjB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;oBAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;oBACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,YAA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,EAAE,IAAI,CAAC,CAAC;oBACjD,IAAI,IAAI,GAAG,WAAW,CAAC;oBACvB,IAAI,CAAC,GAAG,CAAC,CAAC;oBACV,OAAO,IAAI,GAAG,GAAG,EAAE,CAAC;wBAChB,IAAI,IAAI,IAAI,CAAC;wBACb,CAAC,EAAE,CAAC;oBACR,CAAC;oBACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBACvE,CAAC;gBAED;;;;mBAIG;gBACK,+BAAW,GAAnB;oBACI,MAAM,CAAC,iBAAiB,GAAG,sCAAsC,CAAC,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC;wBACtF,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;wBACnE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;oBAC1B,CAAC,CAAC,CAAC;gBACX,CAAC;gBACL,gBAAC;YAAD,CAAC,AA5FD,IA4FC;YA5FD,iCA4FC,CAAA"}
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
@@ -92,7 +92,7 @@ export class FileModel {
|
||||
*
|
||||
* @param {number} sizeinbytes - size in bytes of the file.
|
||||
*/
|
||||
private _getFileSize(sizeinbytes): string {
|
||||
private _getFileSize(sizeinbytes: number): string {
|
||||
let fSExt = new Array('Bytes', 'KB', 'MB', 'GB');
|
||||
let size = sizeinbytes;
|
||||
let i = 0;
|
||||
@@ -110,7 +110,7 @@ export class FileModel {
|
||||
*/
|
||||
private _generateId(): string {
|
||||
return 'uploading-file-' + 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||
let r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
||||
let r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
|
||||
return v.toString(16);
|
||||
});
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
|
||||
import {FileModel} from '../models/file.model';
|
||||
import { FileModel } from '../models/file.model';
|
||||
|
||||
|
||||
/**
|
||||
@@ -60,8 +60,8 @@ export class UploadService {
|
||||
|
||||
for (let file of files) {
|
||||
if (this._isFile(file)) {
|
||||
let uploadingFileModel = new FileModel(file)
|
||||
latestFilesAdded.push(uploadingFileModel)
|
||||
let uploadingFileModel = new FileModel(file);
|
||||
latestFilesAdded.push(uploadingFileModel);
|
||||
this._queue.push(uploadingFileModel);
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,7 @@ export class UploadService {
|
||||
* The method create a new XMLHttpRequest instance if doesn't exist
|
||||
*/
|
||||
private _configureXMLHttpRequest(uploadingFileModel: any) {
|
||||
if (this._xmlHttpRequest == undefined) {
|
||||
if (this._xmlHttpRequest === undefined) {
|
||||
this._xmlHttpRequest = new XMLHttpRequest();
|
||||
this._xmlHttpRequest.upload.onprogress = (e) => {
|
||||
if (e.lengthComputable) {
|
||||
@@ -127,7 +127,7 @@ export class UploadService {
|
||||
uploadFile(uploadingFileModel: any, directory: string): void {
|
||||
let form = new FormData();
|
||||
form.append(this._fieldName, uploadingFileModel.file, uploadingFileModel.name);
|
||||
Object.keys(this._formFields).forEach((key) => {
|
||||
Object.keys(this._formFields).forEach((key: any) => {
|
||||
form.append(key, this._formFields[key]);
|
||||
});
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
@@ -16,12 +16,12 @@
|
||||
*/
|
||||
|
||||
|
||||
import {TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS} from 'angular2/platform/testing/browser';
|
||||
import {it, describe, expect, injectAsync, beforeEachProviders, TestComponentBuilder, setBaseTestProviders} from 'angular2/testing';
|
||||
import {Component, provide, Injector} from 'angular2/core';
|
||||
import {UploadButtonComponent} from '../../../src/components/upload-button.component';
|
||||
import {TranslateService, LangChangeEvent} from 'ng2-translate/ng2-translate';
|
||||
import {TranslationMock} from '../assets/translation.service.mock';
|
||||
import { TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS } from 'angular2/platform/testing/browser';
|
||||
import { it, describe, expect, injectAsync, beforeEachProviders, TestComponentBuilder, setBaseTestProviders } from 'angular2/testing';
|
||||
import { provide } from 'angular2/core';
|
||||
import { UploadButtonComponent } from '../../../src/components/upload-button.component';
|
||||
import { TranslateService } from 'ng2-translate/ng2-translate';
|
||||
import { TranslationMock } from '../assets/translation.service.mock';
|
||||
|
||||
describe('AlfrescoUploadButton', () => {
|
||||
|
||||
@@ -43,7 +43,7 @@ describe('AlfrescoUploadButton', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should render upload-multiple-file button if multipleFiles is true', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
it('should render upload-multiple-file button if multipleFiles=true', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(UploadButtonComponent)
|
||||
.then((fixture) => {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
@@ -15,30 +15,29 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {it, describe, beforeEach, expect} from 'angular2/testing';
|
||||
import {provide, Injector} from 'angular2/core';
|
||||
import {Http, HTTP_PROVIDERS, XHRBackend} from 'angular2/http';
|
||||
import {MockBackend} from 'angular2/http/testing';
|
||||
import {UploadService} from '../../src/services/upload.service';
|
||||
import {FileModel} from '../../src/models/file.model';
|
||||
import { it, describe, beforeEach, expect } from 'angular2/testing';
|
||||
import { UploadService } from '../../src/services/upload.service';
|
||||
import { FileModel } from '../../src/models/file.model';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('AlfrescoUploadService', () => {
|
||||
let service,
|
||||
options,
|
||||
xhr,
|
||||
doneFn,
|
||||
errorFn;
|
||||
let service: UploadService,
|
||||
options: any,
|
||||
xhr: XMLHttpRequest,
|
||||
doneFn: any,
|
||||
errorFn: any;
|
||||
|
||||
beforeEach(() => {
|
||||
jasmine.Ajax.install();
|
||||
|
||||
doneFn = jasmine.createSpy("success");
|
||||
errorFn = jasmine.createSpy("error");
|
||||
doneFn = jasmine.createSpy('success');
|
||||
errorFn = jasmine.createSpy('error');
|
||||
xhr = new XMLHttpRequest();
|
||||
xhr.onreadystatechange = function () {
|
||||
if (this.readyState == this.DONE && this.status == 200) {
|
||||
if (this.readyState === this.DONE && this.status === 200) {
|
||||
doneFn(this.responseText);
|
||||
} else if (this.readyState == this.DONE && this.status == 404) {
|
||||
} else if (this.readyState === this.DONE && this.status === 404) {
|
||||
errorFn(this.responseText);
|
||||
}
|
||||
};
|
||||
@@ -73,7 +72,7 @@ describe('AlfrescoUploadService', () => {
|
||||
});
|
||||
|
||||
it('should add two elements in the queue and returns them', () => {
|
||||
let filesFake = [{name: 'fake-name', size: 10}, {name: 'fake-name2', size: 20} ];
|
||||
let filesFake = [{name: 'fake-name', size: 10}, {name: 'fake-name2', size: 20}];
|
||||
service.addToQueue(filesFake);
|
||||
expect(service.getQueue().length).toEqual(2);
|
||||
});
|
||||
@@ -86,7 +85,7 @@ describe('AlfrescoUploadService', () => {
|
||||
expect(jasmine.Ajax.requests.mostRecent().url).toBe('/some/cool/url');
|
||||
expect(doneFn).not.toHaveBeenCalled();
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
"status": 200,
|
||||
'status': 200,
|
||||
contentType: 'text/plain',
|
||||
responseText: 'File uploaded'
|
||||
});
|
||||
@@ -101,7 +100,7 @@ describe('AlfrescoUploadService', () => {
|
||||
expect(jasmine.Ajax.requests.mostRecent().url).toBe('/some/cool/url');
|
||||
expect(doneFn).not.toHaveBeenCalled();
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
"status": 404,
|
||||
'status': 404,
|
||||
contentType: 'text/plain',
|
||||
responseText: 'Error file uploaded'
|
||||
});
|
||||
@@ -122,13 +121,13 @@ describe('AlfrescoUploadService', () => {
|
||||
service.setXMLHttpRequest(xhr);
|
||||
let filesFake = {name: 'fake-name', size: 10};
|
||||
|
||||
let uploadingFileModel = new FileModel(filesFake)
|
||||
let uploadingFileModel = new FileModel(filesFake);
|
||||
service.uploadFile(uploadingFileModel);
|
||||
|
||||
expect(jasmine.Ajax.requests.mostRecent().url).toBe('/some/cool/url');
|
||||
expect(doneFn).not.toHaveBeenCalled();
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
"status": 200,
|
||||
'status': 200,
|
||||
contentType: 'text/plain',
|
||||
responseText: 'File uploaded'
|
||||
});
|
||||
|
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "system",
|
||||
"moduleResolution": "node",
|
||||
"sourceMap": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"removeComments": false,
|
||||
"noImplicitAny": false,
|
||||
"declaration": false
|
||||
},
|
||||
"exclude": [
|
||||
]
|
||||
}
|
@@ -1,18 +1,28 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "system",
|
||||
"moduleResolution": "node",
|
||||
"sourceMap": true,
|
||||
"module": "commonjs",
|
||||
"declaration": false,
|
||||
"removeComments": true,
|
||||
"noLib": false,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"removeComments": false,
|
||||
"sourceMap": true,
|
||||
"allowUnreachableCode": false,
|
||||
"allowUnusedLabels": false,
|
||||
"noImplicitAny": false,
|
||||
"declaration": true
|
||||
"noImplicitReturns": true,
|
||||
"noImplicitUseStrict": false,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"outDir": "dist"
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"typings/main",
|
||||
"typings/main.d.ts"
|
||||
]
|
||||
"dist",
|
||||
"typings/browser.d.ts",
|
||||
"typings/browser",
|
||||
"demo",
|
||||
"src"
|
||||
],
|
||||
"compileOnSave": false
|
||||
}
|
||||
|
@@ -30,13 +30,12 @@
|
||||
],
|
||||
"member-ordering": [
|
||||
true,
|
||||
"public-before-private",
|
||||
"static-before-instance",
|
||||
"variables-before-functions"
|
||||
],
|
||||
"no-any": false,
|
||||
"no-arg": true,
|
||||
"no-bitwise": true,
|
||||
"no-bitwise": false,
|
||||
"no-conditional-assignment": true,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-console": [
|
||||
|
Reference in New Issue
Block a user