diff --git a/ng2-components/ng2-alfresco-core/.gitignore b/ng2-components/ng2-alfresco-core/.gitignore index 5b9865affb..8ef2c4d294 100644 --- a/ng2-components/ng2-alfresco-core/.gitignore +++ b/ng2-components/ng2-alfresco-core/.gitignore @@ -3,3 +3,4 @@ node_modules jspm_packages .idea typings +coverage \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-documentlist/.gitignore b/ng2-components/ng2-alfresco-documentlist/.gitignore index 5b9865affb..8ef2c4d294 100644 --- a/ng2-components/ng2-alfresco-documentlist/.gitignore +++ b/ng2-components/ng2-alfresco-documentlist/.gitignore @@ -3,3 +3,4 @@ node_modules jspm_packages .idea typings +coverage \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.d.ts b/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.d.ts deleted file mode 100644 index 3dea91ed0b..0000000000 --- a/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.d.ts +++ /dev/null @@ -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]; diff --git a/ng2-components/ng2-alfresco-documentlist/package.json b/ng2-components/ng2-alfresco-documentlist/package.json index b07e2b2eda..86245ac0e6 100644 --- a/ng2-components/ng2-alfresco-documentlist/package.json +++ b/ng2-components/ng2-alfresco-documentlist/package.json @@ -1,53 +1,53 @@ { - "name": "ng2-alfresco-documentlist", - "description": "Alfresco Angular2 Document List Component", - "version": "0.1.0", - "author": "Alfresco Software, Ltd.", - "scripts": { - "build": "typings install && tsc", - "tsc": "tsc", - "tsc:w": "tsc -w", - "typings": "typings", - "test": "live-server --open=index.html --entry-file=test/ --mount=/ng2-alfresco-core:../ng2-alfresco-core", - "test:w": "concurrently \"npm run tsc:w\" \"npm run test\" " - }, - "repository": { - "type": "git", - "url": "https://github.com/Alfresco/dev-platform-webcomponents.git" - }, - "bugs": { - "url": "https://github.com/Alfresco/dev-platform-webcomponents/issues" - }, - "license": "Apache-2.0", - "contributors": [ - { - "name": "Denys Vuika", - "email": "denis.vuyka@gmail.com" - } - ], - "keywords": [ - "ng2", - "angular", - "angular2", - "alfresco" - ], - "dependencies": { - "angular2": "2.0.0-beta.15", - "systemjs": "0.19.26", - "es6-shim": "^0.35.0", - "reflect-metadata": "0.1.2", - "rxjs": "5.0.0-beta.2", - "zone.js": "0.6.10" - }, - "peerDependencies": { - "angular2": "2.0.0-beta.15" - }, - "devDependencies": { - "typescript": "^1.8.10", - "typings": "^0.7.12", - "jasmine-core": "2.4.1", - "xo": "^0.14.0", - "live-server": "^0.9.2", - "concurrently": "^2.0.0" + "name": "ng2-alfresco-documentlist", + "description": "Alfresco Angular2 Document List Component", + "version": "0.1.0", + "author": "Alfresco Software, Ltd.", + "scripts": { + "build": "typings install && tsc", + "tsc": "tsc", + "tsc:w": "tsc -w", + "typings": "typings", + "test": "live-server --open=index.html --entry-file=test/ --mount=/ng2-alfresco-core:../ng2-alfresco-core", + "test:w": "concurrently \"npm run tsc:w\" \"npm run test\" " + }, + "repository": { + "type": "git", + "url": "https://github.com/Alfresco/dev-platform-webcomponents.git" + }, + "bugs": { + "url": "https://github.com/Alfresco/dev-platform-webcomponents/issues" + }, + "license": "Apache-2.0", + "contributors": [ + { + "name": "Denys Vuika", + "email": "denis.vuyka@gmail.com" } + ], + "keywords": [ + "ng2", + "angular", + "angular2", + "alfresco" + ], + "dependencies": { + "angular2": "2.0.0-beta.15", + "systemjs": "0.19.26", + "es6-shim": "^0.35.0", + "reflect-metadata": "0.1.2", + "rxjs": "5.0.0-beta.2", + "zone.js": "0.6.10" + }, + "peerDependencies": { + "angular2": "2.0.0-beta.15" + }, + "devDependencies": { + "typescript": "^1.8.10", + "typings": "^0.7.12", + "jasmine-core": "2.4.1", + "xo": "^0.14.0", + "live-server": "^0.9.2", + "concurrently": "^2.0.0" + } } diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/content-action-list.d.ts b/ng2-components/ng2-alfresco-documentlist/src/components/content-action-list.d.ts deleted file mode 100644 index 64ef51d777..0000000000 --- a/ng2-components/ng2-alfresco-documentlist/src/components/content-action-list.d.ts +++ /dev/null @@ -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; -} diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/content-action.d.ts b/ng2-components/ng2-alfresco-documentlist/src/components/content-action.d.ts deleted file mode 100644 index 471fd24868..0000000000 --- a/ng2-components/ng2-alfresco-documentlist/src/components/content-action.d.ts +++ /dev/null @@ -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); -} diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/content-column-list.d.ts b/ng2-components/ng2-alfresco-documentlist/src/components/content-column-list.d.ts deleted file mode 100644 index 2a4647642d..0000000000 --- a/ng2-components/ng2-alfresco-documentlist/src/components/content-column-list.d.ts +++ /dev/null @@ -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; -} diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/content-column.d.ts b/ng2-components/ng2-alfresco-documentlist/src/components/content-column.d.ts deleted file mode 100644 index 01afac2694..0000000000 --- a/ng2-components/ng2-alfresco-documentlist/src/components/content-column.d.ts +++ /dev/null @@ -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; -} diff --git a/ng2-components/ng2-alfresco-documentlist/src/models/content-action.model.d.ts b/ng2-components/ng2-alfresco-documentlist/src/models/content-action.model.d.ts deleted file mode 100644 index 07934ea6a8..0000000000 --- a/ng2-components/ng2-alfresco-documentlist/src/models/content-action.model.d.ts +++ /dev/null @@ -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; -} diff --git a/ng2-components/ng2-alfresco-documentlist/src/models/content-column.model.d.ts b/ng2-components/ng2-alfresco-documentlist/src/models/content-column.model.d.ts deleted file mode 100644 index aa9147c959..0000000000 --- a/ng2-components/ng2-alfresco-documentlist/src/models/content-column.model.d.ts +++ /dev/null @@ -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; -} diff --git a/ng2-components/ng2-alfresco-documentlist/src/models/document-library.model.d.ts b/ng2-components/ng2-alfresco-documentlist/src/models/document-library.model.d.ts deleted file mode 100644 index e89fae80df..0000000000 --- a/ng2-components/ng2-alfresco-documentlist/src/models/document-library.model.d.ts +++ /dev/null @@ -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; -} diff --git a/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.d.ts b/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.d.ts deleted file mode 100644 index 0ea74e377c..0000000000 --- a/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.d.ts +++ /dev/null @@ -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); -} diff --git a/ng2-components/ng2-alfresco-documentlist/src/services/folder-actions.service.d.ts b/ng2-components/ng2-alfresco-documentlist/src/services/folder-actions.service.d.ts deleted file mode 100644 index 2ff0984b2c..0000000000 --- a/ng2-components/ng2-alfresco-documentlist/src/services/folder-actions.service.d.ts +++ /dev/null @@ -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); -} diff --git a/ng2-components/ng2-alfresco-documentlist/tsconfig.json b/ng2-components/ng2-alfresco-documentlist/tsconfig.json index 2f3531e7b9..6d3b696912 100644 --- a/ng2-components/ng2-alfresco-documentlist/tsconfig.json +++ b/ng2-components/ng2-alfresco-documentlist/tsconfig.json @@ -1,18 +1,23 @@ { - "compilerOptions": { - "target": "es5", - "module": "system", - "moduleResolution": "node", - "sourceMap": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "removeComments": false, - "noImplicitAny": false, - "declaration": true - }, - "exclude": [ - "node_modules", - "typings/main", - "typings/main.d.ts" - ] + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "moduleResolution": "node", + "sourceMap": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "removeComments": false, + "noImplicitAny": false, + "declaration": false, + "outDir": "dist" + }, + "exclude": [ + "node_modules", + "dist", + "typings/browser.d.ts", + "typings/browser", + "demo", + "src" + ], + "compileOnSave": false } diff --git a/ng2-components/ng2-alfresco-login/.editorconfig b/ng2-components/ng2-alfresco-login/.editorconfig new file mode 100644 index 0000000000..f1cc3ad329 --- /dev/null +++ b/ng2-components/ng2-alfresco-login/.editorconfig @@ -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 diff --git a/ng2-components/ng2-alfresco-login/.gitignore b/ng2-components/ng2-alfresco-login/.gitignore index 5b9865affb..8ef2c4d294 100644 --- a/ng2-components/ng2-alfresco-login/.gitignore +++ b/ng2-components/ng2-alfresco-login/.gitignore @@ -3,3 +3,4 @@ node_modules jspm_packages .idea typings +coverage \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-login/.travis.yml b/ng2-components/ng2-alfresco-login/.travis.yml new file mode 100755 index 0000000000..37844eeed9 --- /dev/null +++ b/ng2-components/ng2-alfresco-login/.travis.yml @@ -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" diff --git a/ng2-components/ng2-alfresco-login/assets/license_header.txt b/ng2-components/ng2-alfresco-login/assets/license_header.txt index 5cae403293..83fd1531a3 100644 --- a/ng2-components/ng2-alfresco-login/assets/license_header.txt +++ b/ng2-components/ng2-alfresco-login/assets/license_header.txt @@ -1,4 +1,4 @@ -/** +/*! * @license * Copyright 2016 Alfresco Software, Ltd. * diff --git a/ng2-components/ng2-alfresco-login/demo/app/app.component.js b/ng2-components/ng2-alfresco-login/demo/app/app.component.js index 27ac07a7ab..a42d4dbff2 100644 --- a/ng2-components/ng2-alfresco-login/demo/app/app.component.js +++ b/ng2-components/ng2-alfresco-login/demo/app/app.component.js @@ -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); } diff --git a/ng2-components/ng2-alfresco-login/demo/app/app.component.js.map b/ng2-components/ng2-alfresco-login/demo/app/app.component.js.map index b85f492b9f..e5f6ac0790 100644 --- a/ng2-components/ng2-alfresco-login/demo/app/app.component.js.map +++ b/ng2-components/ng2-alfresco-login/demo/app/app.component.js.map @@ -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"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-login/ng2-alfresco-login.d.ts b/ng2-components/ng2-alfresco-login/ng2-alfresco-login.d.ts deleted file mode 100644 index f733fd5ba2..0000000000 --- a/ng2-components/ng2-alfresco-login/ng2-alfresco-login.d.ts +++ /dev/null @@ -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]; diff --git a/ng2-components/ng2-alfresco-login/ng2-alfresco-login.js b/ng2-components/ng2-alfresco-login/ng2-alfresco-login.js deleted file mode 100644 index 48473eb095..0000000000 --- a/ng2-components/ng2-alfresco-login/ng2-alfresco-login.js +++ /dev/null @@ -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 \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-login/ng2-alfresco-login.js.map b/ng2-components/ng2-alfresco-login/ng2-alfresco-login.js.map deleted file mode 100644 index c35d46677d..0000000000 --- a/ng2-components/ng2-alfresco-login/ng2-alfresco-login.js.map +++ /dev/null @@ -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"} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-login/ng2-alfresco-login.ts b/ng2-components/ng2-alfresco-login/ng2-alfresco-login.ts index 07932a4a3c..7bb9944efa 100644 --- a/ng2-components/ng2-alfresco-login/ng2-alfresco-login.ts +++ b/ng2-components/ng2-alfresco-login/ng2-alfresco-login.ts @@ -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]; diff --git a/ng2-components/ng2-alfresco-login/package.json b/ng2-components/ng2-alfresco-login/package.json index af3372db23..cbc2faef97 100644 --- a/ng2-components/ng2-alfresco-login/package.json +++ b/ng2-components/ng2-alfresco-login/package.json @@ -1,73 +1,78 @@ { - "name": "ng2-alfresco-login", - "description": "Alfresco Angular2 Login Component", - "version": "0.1.0", - "author": "Alfresco Software, Ltd.", - "scripts": { - "build": "tslint -c tslint.json **/*.ts && typings install && tsc && license-check", - "licensecheck": "license-check", - "tsc": "tsc", - "tsc:w": "tsc -w", - "typings": "typings", - "test": "live-server --open=index.html --entry-file=test/ --mount=/ng2-alfresco-core:../ng2-alfresco-core", - "test:w": "concurrently \"npm run tsc:w\" \"npm run test\" " + "name": "ng2-alfresco-login", + "description": "Alfresco Angular2 Login Component", + "version": "0.1.0", + "author": "Alfresco Software, Ltd.", + "scripts": { + "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", + "typings": "typings", + "test": "live-server --open=index.html --entry-file=test/ --mount=/ng2-alfresco-core:../ng2-alfresco-core", + "test:w": "concurrently \"npm run tsc:w\" \"npm run test\" " + }, + "repository": { + "type": "git", + "url": "https://github.com/Alfresco/dev-platform-webcomponents.git" + }, + "bugs": { + "url": "https://github.com/Alfresco/dev-platform-webcomponents/issues" + }, + "license": "Apache-2.0", + "contributors": [ + { + "name": "Denys Vuika", + "email": "denis.vuyka@gmail.com" }, - "repository": { - "type": "git", - "url": "https://github.com/Alfresco/dev-platform-webcomponents.git" - }, - "bugs": { - "url": "https://github.com/Alfresco/dev-platform-webcomponents/issues" - }, - "license": "Apache-2.0", - "contributors": [ - { - "name": "Denys Vuika", - "email": "denis.vuyka@gmail.com" - }, - { - "name": "Maurizio Vitale", - "email": "maurizio.vitale84@gmail.com" - } - ], - "keywords": [ - "ng2", - "angular", - "angular2", - "alfresco" - ], - "dependencies": { - "angular2": "2.0.0-beta.15", - "systemjs": "0.19.26", - "es6-shim": "^0.35.0", - "reflect-metadata": "0.1.2", - "rxjs": "5.0.0-beta.2", - "zone.js": "0.6.10", - "ng2-translate": "^1.11.2" - }, - "peerDependencies": { - "angular2": "2.0.0-beta.15", - "ng2-alfresco-core": "0.1.0" - }, - "devDependencies": { - "jasmine-core": "2.4.1", - "live-server": "^0.9.2", - "typescript": "^1.8.10", - "typings": "^0.7.12", - "license-check": "^1.0.4", - "tslint": "^3.8.1", - "concurrently": "^2.0.0" - }, - "license-check-config": { - "src": [ - "**/*.ts", - "!/**/*.d.ts", - "!/**/node_modules/**/*", - "!/**/typings/**/*" - ], - "path": "assets/license_header.txt", - "blocking": false, - "logInfo": false, - "logError": true + { + "name": "Maurizio Vitale", + "email": "maurizio.vitale84@gmail.com" } + ], + "keywords": [ + "ng2", + "angular", + "angular2", + "alfresco" + ], + "dependencies": { + "angular2": "2.0.0-beta.15", + "systemjs": "0.19.26", + "es6-shim": "^0.35.0", + "reflect-metadata": "0.1.2", + "rxjs": "5.0.0-beta.2", + "zone.js": "0.6.10", + "ng2-translate": "^1.11.2" + }, + "peerDependencies": { + "angular2": "2.0.0-beta.15", + "ng2-alfresco-core": "0.1.0" + }, + "devDependencies": { + "jasmine-core": "2.4.1", + "live-server": "^0.9.2", + "typescript": "^1.8.10", + "typings": "^0.7.12", + "license-check": "^1.0.4", + "tslint": "^3.8.1", + "concurrently": "^2.0.0" + }, + "license-check-config": { + "src": [ + "**/*.js", + "**/*.ts", + "!/**/coverage/**/*", + "!/**/demo/**/*", + "!/**/node_modules/**/*", + "!/**/typings/**/*" + ], + "path": "assets/license_header.txt", + "blocking": false, + "logInfo": false, + "logError": true + } } diff --git a/ng2-components/ng2-alfresco-login/src/components/alfresco-login.d.ts b/ng2-components/ng2-alfresco-login/src/components/alfresco-login.d.ts deleted file mode 100644 index f9bffde9f6..0000000000 --- a/ng2-components/ng2-alfresco-login/src/components/alfresco-login.d.ts +++ /dev/null @@ -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; -} diff --git a/ng2-components/ng2-alfresco-login/src/components/alfresco-login.js b/ng2-components/ng2-alfresco-login/src/components/alfresco-login.js deleted file mode 100644 index d530ac8ed0..0000000000 --- a/ng2-components/ng2-alfresco-login/src/components/alfresco-login.js +++ /dev/null @@ -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 \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-login/src/components/alfresco-login.js.map b/ng2-components/ng2-alfresco-login/src/components/alfresco-login.js.map deleted file mode 100644 index 4a78407a5b..0000000000 --- a/ng2-components/ng2-alfresco-login/src/components/alfresco-login.js.map +++ /dev/null @@ -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,EAA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B,CAAC;wBACnC,KAAK,EAAE,CAAC,6BAAa,CAAC;qBAEzB,CAAC;;0CAAA;gBAuIF,6BAAC;YAAD,CAAC,AAtID,IAsIC;YAtID,2DAsIC,CAAA"} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-login/src/components/alfresco-login.ts b/ng2-components/ng2-alfresco-login/src/components/alfresco-login.ts index f64ec7bd43..9712c0270a 100644 --- a/ng2-components/ng2-alfresco-login/src/components/alfresco-login.ts +++ b/ng2-components/ng2-alfresco-login/src/components/alfresco-login.ts @@ -1,4 +1,4 @@ -/** +/*! * @license * Copyright 2016 Alfresco Software, Ltd. * @@ -14,155 +14,162 @@ * 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; @Component({ - selector: 'alfresco-login', - moduleId: __moduleName, - directives: [ROUTER_DIRECTIVES, FORM_DIRECTIVES], - templateUrl: './alfresco-login.html', - styleUrls: ['./alfresco-login.css'], - pipes: [TranslatePipe] + selector: 'alfresco-login', + moduleId: __moduleName, + directives: [ROUTER_DIRECTIVES, FORM_DIRECTIVES], + templateUrl: './alfresco-login.html', + styleUrls: ['./alfresco-login.css'], + pipes: [TranslatePipe] }) export class AlfrescoLoginComponent { - @Input() method: string = 'POST'; - @Output() onSuccess = new EventEmitter(); - @Output() onError = new EventEmitter(); - translate: TranslateService; + @Input() + method: string = 'POST'; + @Output() + onSuccess = new EventEmitter(); + @Output() + onError = new EventEmitter(); + translate: TranslateService; - form: ControlGroup; - error: boolean = false; - success: boolean = false; + form: ControlGroup; + error: boolean = false; + success: boolean = false; - formError: { [id: string]: string }; + formError: { [id: string]: string }; - private _message: { [id:string]: - { [id: string]: string } + private _message: { [id: string]: { [id: string]: string } + }; + + /** + * Constructor + * @param _fb + * @param auth + * @param router + */ + constructor(private _fb: FormBuilder, + public auth: AlfrescoAuthenticationService, + public router: Router, + translate: TranslateService) { + + this.formError = { + 'username': '', + 'password': '' }; - /** - * Constructor - * @param _fb - * @param auth - * @param router - */ - constructor(private _fb: FormBuilder, - public auth: AlfrescoAuthenticationService, - public router: Router, - translate: TranslateService) { + this.form = this._fb.group({ + username: ['', Validators.compose([Validators.required, Validators.minLength(4)])], + password: ['', Validators.required] + }); - this.formError = { - 'username': '', - 'password': '' - }; + this._message = { + 'username': { + 'required': 'input-required-message', + 'minlength': 'input-min-message' + }, + 'password': { + 'required': 'input-required-message' + } + }; + this.translationInit(translate); - this.form = this._fb.group({ - username: ['', Validators.compose([Validators.required, Validators.minLength(4)])], - password: ['', Validators.required] - }); + this.form.valueChanges.subscribe(data => this.onValueChanged(data)); - this._message = { - 'username': { - 'required': 'input-required-message', - 'minlength': 'input-min-message' - }, - 'password': { - 'required': 'input-required-message' + this.onValueChanged(null); + } + + /** + * Method called on submit form + * @param value + * @param event + */ + onSubmit(value: any, event) { + this.error = false; + if (event) { + event.preventDefault(); + } + this.auth.login(this.method, value.username, value.password) + .subscribe( + (token: any) => { + try { + this.success = true; + this.onSuccess.emit({ + value: 'Login OK' + }); + this.router.navigate(['Home']); + } catch (error) { + console.error(error.message); + } + + }, + (err: any) => { + this.error = true; + this.onError.emit({ + value: 'Login KO' + }); + console.log(err); + this.success = false; + }, + () => console.log('Login done') + ); + } + + /** + * The method check the error in the form and push the error in the formError object + * @param data + */ + onValueChanged(data: any) { + for (let field in this.formError) { + if (field) { + this.formError[field] = ''; + let hasError = this.form.controls[field].errors || (this.form.controls[field].dirty && !this.form.controls[field].valid); + if (hasError) { + for (let key in this.form.controls[field].errors) { + if (key) { + this.formError[field] += this._message[field][key] + ''; } - }; - this.translationInit(translate); - - this.form.valueChanges.subscribe(data => this.onValueChanged(data)); - - this.onValueChanged(null); - } - - /** - * Method called on submit form - * @param value - * @param event - */ - onSubmit(value: any, event) { - this.error = false; - if (event) { - event.preventDefault(); + } } - this.auth.login(this.method, value.username, value.password) - .subscribe( - (token: any) => { - try { - this.success = true; - this.onSuccess.emit({ - value: 'Login OK' - }); - this.router.navigate(['Home']); - } catch (error) { - console.error(error.message); - } - - }, - (err: any) => { - this.error = true; - this.onError.emit({ - value: 'Login KO' - }); - console.log(err); - this.success = false; - }, - () => console.log('Login done') - ); + } } + } - /** - * The method check the error in the form and push the error in the formError object - * @param data - */ - onValueChanged(data: any) { - for (let field in this.formError) { - 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) { - this.formError[field] += this._message[field][key] + ''; - } - } - } + /** + * The method return if a field is valid or not + * @param field + * @returns {boolean} + */ + isErrorStyle(field: ControlGroup) { + if (componentHandler) { + componentHandler.upgradeAllRegistered(); } - - /** - * The method return if a field is valid or not - * @param field - * @returns {boolean} - */ - isErrorStyle(field: ControlGroup) { - if (componentHandler) { - componentHandler.upgradeAllRegistered(); - } - if (field.valid) { - return false; - } else { - return true; - } + if (field.valid) { + return false; + } else { + return true; } + } - /** - * Initial configuration for Multi language - * @param translate - */ - translationInit(translate: TranslateService) { - this.translate = translate; - let userLang = navigator.language.split('-')[0]; // use navigator lang if available - userLang = /(fr|en)/gi.test(userLang) ? userLang : 'en'; + /** + * Initial configuration for Multi language + * @param translate + */ + translationInit(translate: TranslateService) { + this.translate = translate; + let userLang = navigator.language.split('-')[0]; // use navigator lang if available + userLang = /(fr|en)/gi.test(userLang) ? userLang : 'en'; - this.translate.setDefaultLang(userLang); + this.translate.setDefaultLang(userLang); - this.translate.use(userLang); - } + this.translate.use(userLang); + } } diff --git a/ng2-components/ng2-alfresco-login/src/services/alfresco-authentication.d.ts b/ng2-components/ng2-alfresco-login/src/services/alfresco-authentication.d.ts deleted file mode 100644 index e414d200c7..0000000000 --- a/ng2-components/ng2-alfresco-login/src/services/alfresco-authentication.d.ts +++ /dev/null @@ -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|Observable} - */ - login(method: string, username: string, password: string): Observable; - /** - * The method provide the login with GET Request - * @param username - * @param password - * @returns {Observable|Observable} - */ - loginGet(username: string, password: string): Observable; - /** - * The method provide the login with POST Request - * @param username - * @param password - * @returns {Observable|Observable} - */ - loginPost(username: string, password: string): Observable; - /** - * 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} - */ - logout(): Observable; - /** - * The method write the error in the console browser - * @param error - * @returns {ErrorObservable} - */ - private handleError(error); -} diff --git a/ng2-components/ng2-alfresco-login/src/services/alfresco-authentication.js b/ng2-components/ng2-alfresco-login/src/services/alfresco-authentication.js deleted file mode 100644 index 7a6b295c5d..0000000000 --- a/ng2-components/ng2-alfresco-login/src/services/alfresco-authentication.js +++ /dev/null @@ -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|Observable} - */ - 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|Observable} - */ - 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|Observable} - */ - 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} - */ - 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 \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-login/src/services/alfresco-authentication.js.map b/ng2-components/ng2-alfresco-login/src/services/alfresco-authentication.js.map deleted file mode 100644 index 54e8c05dc2..0000000000 --- a/ng2-components/ng2-alfresco-login/src/services/alfresco-authentication.js.map +++ /dev/null @@ -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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BAGG;gBACH,8CAAM,GAAN;oBACI,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;oBACvB,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;oBAEjC,MAAM,CAAC,eAAU,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;gBAC/B,CAAC;gBAED;;;;mBAIG;gBACK,mDAAW,GAAnB,UAAoB,KAAc;oBAC9B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,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"} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-login/src/services/alfresco-authentication.ts b/ng2-components/ng2-alfresco-login/src/services/alfresco-authentication.ts index cacc9cb3b4..c78303d07c 100644 --- a/ng2-components/ng2-alfresco-login/src/services/alfresco-authentication.ts +++ b/ng2-components/ng2-alfresco-login/src/services/alfresco-authentication.ts @@ -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|Observable} */ - 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|Observable} */ - 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,16 +90,16 @@ export class AlfrescoAuthenticationService { * @param password * @returns {Observable|Observable} */ - loginPost(username:string, password:string) { + loginPost(username: string, password: string) { let credentials = '{ username: ' + username + ', password: ' + password + ' }'; let headers = new Headers(); headers.append('Content-Type', 'application/json'); return this.http.post(this._baseUrl + 'login', credentials, { - headers: headers - }) - .map((res:any) => { + headers: headers + }) + .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'); } diff --git a/ng2-components/ng2-alfresco-login/test/assets/authentication.service.mock.ts b/ng2-components/ng2-alfresco-login/test/assets/authentication.service.mock.ts index f216d93cf9..f6c4732714 100644 --- a/ng2-components/ng2-alfresco-login/test/assets/authentication.service.mock.ts +++ b/ng2-components/ng2-alfresco-login/test/assets/authentication.service.mock.ts @@ -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); diff --git a/ng2-components/ng2-alfresco-login/test/assets/translation.service.mock.ts b/ng2-components/ng2-alfresco-login/test/assets/translation.service.mock.ts index 35ada2db31..c6efaceb05 100644 --- a/ng2-components/ng2-alfresco-login/test/assets/translation.service.mock.ts +++ b/ng2-components/ng2-alfresco-login/test/assets/translation.service.mock.ts @@ -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 = new EventEmitter(); setDefaultLang() { - + console.log('mock'); } use() { + console.log('mock'); } public get(key: string|Array, interpolateParams?: Object): Observable { @@ -37,4 +38,4 @@ export class TranslationMock { } return Observable.of(key); } -} \ No newline at end of file +} diff --git a/ng2-components/ng2-alfresco-login/test/components/alfresco-login.spec.ts b/ng2-components/ng2-alfresco-login/test/components/alfresco-login.spec.ts index c55364532c..6b31ad0580 100644 --- a/ng2-components/ng2-alfresco-login/test/components/alfresco-login.spec.ts +++ b/ng2-components/ng2-alfresco-login/test/components/alfresco-login.spec.ts @@ -1,4 +1,4 @@ -/** +/*! * @license * Copyright 2016 Alfresco Software, Ltd. * @@ -14,323 +14,346 @@ * 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; + let authService, location, router; - setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS); + setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS); - beforeEachProviders(() => { - authService = new AuthenticationMock(); + beforeEachProviders(() => { + authService = new AuthenticationMock(); - return [ - authService.getProviders(), - RouteRegistry, - provide(Location, {useClass: SpyLocation}), - provide(ROUTER_PRIMARY_COMPONENT, {useValue: AlfrescoLoginComponent}), - provide(Router, {useClass: RootRouter}), - provide(TranslateService, {useClass: TranslationMock}) - ]; - }); + return [ + authService.getProviders(), + RouteRegistry, + provide(Location, {useClass: SpyLocation}), + provide(ROUTER_PRIMARY_COMPONENT, {useValue: AlfrescoLoginComponent}), + provide(Router, {useClass: RootRouter}), + provide(TranslateService, {useClass: TranslationMock}) + ]; + }); - beforeEach(inject([Router, Location], (r, l) => { - router = r; - location = l; + beforeEach(inject([Router, Location], (r, l) => { + router = r; + location = l; + })); + + 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(); + + let element = fixture.nativeElement; + + expect(element.querySelector('h2').innerText).toEqual('login'); + + expect(element.querySelector('[for="username"]')).toBeDefined(); + expect(element.querySelector('[for="username"]').innerText).toEqual('username'); + expect(element.querySelector('#username-error').innerText).toEqual('input-required-message'); + + expect(element.querySelector('[for="password"]')).toBeDefined(); + expect(element.querySelector('[for="password"]').innerText).toEqual('password'); + expect(element.querySelector('#password-required').innerText).toEqual('input-required-message'); + + }); })); - 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 () { - - }; - - fixture.detectChanges(); - - let element = fixture.nativeElement; - - expect(element.querySelector('h2').innerText).toEqual('login'); - - expect(element.querySelector('[for="username"]')).toBeDefined(); - expect(element.querySelector('[for="username"]').innerText).toEqual('username'); - expect(element.querySelector('#username-error').innerText).toEqual('input-required-message'); - - expect(element.querySelector('[for="password"]')).toBeDefined(); - expect(element.querySelector('[for="password"]').innerText).toEqual('password'); - expect(element.querySelector('#password-required').innerText).toEqual('input-required-message'); - - }); + it('should render user and password input fields with default values', + injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { + return tcb + .createAsync(AlfrescoLoginComponent) + .then((fixture) => { + let element = fixture.nativeElement; + expect(element.querySelector('form')).toBeDefined(); + expect(element.querySelector('input[type="password"]')).toBeDefined(); + expect(element.querySelector('input[type="text"]')).toBeDefined(); + expect(element.querySelector('input[type="password"]').value).toEqual(''); + expect(element.querySelector('input[type="text"]').value).toEqual(''); + }); })); - it('should render user and password input fields with default values', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { - return tcb - .createAsync(AlfrescoLoginComponent) - .then((fixture) => { - let element = fixture.nativeElement; - expect(element.querySelector('form')).toBeDefined(); - expect(element.querySelector('input[type="password"]')).toBeDefined(); - expect(element.querySelector('input[type="text"]')).toBeDefined(); - expect(element.querySelector('input[type="password"]').value).toEqual(''); - expect(element.querySelector('input[type="text"]').value).toEqual(''); - }); + 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; + + component.form.controls.username._value = 'us'; + + fixture.detectChanges(); + + component.onValueChanged(); + + fixture.detectChanges(); + + expect(component.formError).toBeDefined(true); + expect(component.formError.username).toBeDefined(true); + expect(component.formError.username).toEqual('input-min-message'); + expect(compiled.querySelector('#username-error').innerText).toEqual('input-min-message'); + }); })); - 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 () { + 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; - let compiled = fixture.debugElement.nativeElement; + component.form.controls.username._value = 'fake-user'; + component.form.controls.password._value = 'fake-password'; - component.form.controls.username._value = 'us'; + fixture.detectChanges(); - fixture.detectChanges(); + component.onValueChanged(); - component.onValueChanged(); + fixture.detectChanges(); - fixture.detectChanges(); - - expect(component.formError).toBeDefined(true); - expect(component.formError.username).toBeDefined(true); - expect(component.formError.username).toEqual('input-min-message'); - expect(compiled.querySelector('#username-error').innerText).toEqual('input-min-message'); - }); + expect(component.formError).toBeDefined(true); + expect(component.formError.username).toEqual(''); + expect(component.formError.password).toEqual(''); + expect(compiled.querySelector('#login-error')).toBeNull(); + }); })); - 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 () { + 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; + component.form.controls.username._value = 'my username'; + component.form.controls.password._value = 'my password'; - let compiled = fixture.debugElement.nativeElement; + fixture.detectChanges(); + component.onValueChanged(); - component.form.controls.username._value = 'fake-user'; - component.form.controls.password._value = 'fake-password'; - - fixture.detectChanges(); - - component.onValueChanged(); - - fixture.detectChanges(); - - expect(component.formError).toBeDefined(true); - expect(component.formError.username).toEqual(''); - expect(component.formError.password).toEqual(''); - expect(compiled.querySelector('#login-error')).toBeNull(); - }); + expect(compiled.querySelector('input[type="password"]').value).toEqual('my password'); + expect(compiled.querySelector('input[type="text"]').value).toEqual('my username'); + }); })); - 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 () { + it('should navigate to Home route after the login have succeeded ', + injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { + return tcb + .createAsync(AlfrescoLoginComponent) + .then((fixture) => { + router.config([new Route({path: '/home', name: 'Home', component: AlfrescoLoginComponent})]); + spyOn(router, 'navigate').and.callThrough(); + let component = fixture.componentInstance; + component.isErrorStyle = function () { + console.log('mock'); + }; - }; + let compiled = fixture.debugElement.nativeElement; - let compiled = fixture.debugElement.nativeElement; - component.form.controls.username._value = 'my username'; - component.form.controls.password._value = 'my password'; + component.form.controls.username._value = 'fake-username'; + component.form.controls.password._value = 'fake-password'; - fixture.detectChanges(); - component.onValueChanged(); + fixture.detectChanges(); + component.onValueChanged(); - expect(compiled.querySelector('input[type="password"]').value).toEqual('my password'); - expect(compiled.querySelector('input[type="text"]').value).toEqual('my username'); - }); + compiled.querySelector('button').click(); + + fixture.detectChanges(); + + expect(component.error).toBe(false); + expect(router.navigate).toHaveBeenCalledWith(['Home']); + }); })); - it('should navigate to Home route after the login have succeeded ', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { - return tcb - .createAsync(AlfrescoLoginComponent) - .then((fixture) => { - router.config([new Route({path: '/home', name: 'Home', component: AlfrescoLoginComponent})]); - spyOn(router, 'navigate').and.callThrough(); - let component = fixture.componentInstance; - component.isErrorStyle = function () { + 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; - let compiled = fixture.debugElement.nativeElement; + component.form.controls.username._value = 'fake-wrong-username'; + component.form.controls.password._value = 'fake-password'; - component.form.controls.username._value = 'fake-username'; - component.form.controls.password._value = 'fake-password'; + fixture.detectChanges(); + component.onValueChanged(); - fixture.detectChanges(); - component.onValueChanged(); + compiled.querySelector('button').click(); - compiled.querySelector('button').click(); + fixture.detectChanges(); - fixture.detectChanges(); - - expect(component.error).toBe(false); - expect(router.navigate).toHaveBeenCalledWith(['Home']); - }); + expect(fixture.componentInstance.error).toBe(true); + expect(compiled.querySelector('#login-error').innerText).toEqual('login-error-message'); + }); })); - 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 () { + 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; + let compiled = fixture.debugElement.nativeElement; - component.form.controls.username._value = 'fake-wrong-username'; - component.form.controls.password._value = 'fake-password'; + component.form.controls.username._value = 'fake-username'; + component.form.controls.password._value = 'fake-wrong-password'; - fixture.detectChanges(); - component.onValueChanged(); + fixture.detectChanges(); + component.onValueChanged(); - compiled.querySelector('button').click(); + compiled.querySelector('button').click(); - fixture.detectChanges(); + fixture.detectChanges(); - expect(fixture.componentInstance.error).toBe(true); - expect(compiled.querySelector('#login-error').innerText).toEqual('login-error-message'); - }); + expect(fixture.componentInstance.error).toBe(true); + expect(compiled.querySelector('#login-error').innerText).toEqual('login-error-message'); + }); })); - 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 () { + 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; + let compiled = fixture.debugElement.nativeElement; - component.form.controls.username._value = 'fake-username'; - component.form.controls.password._value = 'fake-wrong-password'; + component.form.controls.username._value = 'fake-wrong-username'; + component.form.controls.password._value = 'fake-wrong-password'; - fixture.detectChanges(); - component.onValueChanged(); + fixture.detectChanges(); + component.onValueChanged(); - compiled.querySelector('button').click(); + compiled.querySelector('button').click(); - fixture.detectChanges(); + fixture.detectChanges(); - expect(fixture.componentInstance.error).toBe(true); - expect(compiled.querySelector('#login-error').innerText).toEqual('login-error-message'); - }); - })); - - 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 () { - - }; - - let compiled = fixture.debugElement.nativeElement; - - component.form.controls.username._value = 'fake-wrong-username'; - component.form.controls.password._value = 'fake-wrong-password'; - - fixture.detectChanges(); - component.onValueChanged(); - - compiled.querySelector('button').click(); - - fixture.detectChanges(); - - expect(fixture.componentInstance.error).toBe(true); - expect(compiled.querySelector('#login-error').innerText).toEqual('login-error-message'); - }); + expect(fixture.componentInstance.error).toBe(true); + expect(compiled.querySelector('#login-error').innerText).toEqual('login-error-message'); + }); })); - 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 () { + 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'); + spyOn(component.onSuccess, 'emit'); - let compiled = fixture.debugElement.nativeElement; + let compiled = fixture.debugElement.nativeElement; - component.form.controls.username._value = 'fake-username'; - component.form.controls.password._value = 'fake-password'; + component.form.controls.username._value = 'fake-username'; + component.form.controls.password._value = 'fake-password'; - fixture.detectChanges(); - component.onValueChanged(); + fixture.detectChanges(); + component.onValueChanged(); - let nativeElement = fixture.nativeElement; - let button = nativeElement.querySelector('button'); - button.dispatchEvent(new Event('click')); + let nativeElement = fixture.nativeElement; + let button = nativeElement.querySelector('button'); + button.dispatchEvent(new Event('click')); - fixture.detectChanges(); + fixture.detectChanges(); - expect(fixture.componentInstance.error).toBe(false); - expect(compiled.querySelector('#login-success').innerHTML).toEqual('login-success-message'); - expect(component.onSuccess.emit).toHaveBeenCalledWith({value: 'Login OK'}); - }); + expect(fixture.componentInstance.error).toBe(false); + expect(compiled.querySelector('#login-success').innerHTML).toEqual('login-success-message'); + expect(component.onSuccess.emit).toHaveBeenCalledWith({value: 'Login OK'}); + }); })); - 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 () { + 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'); + spyOn(component.onError, 'emit'); - let compiled = fixture.debugElement.nativeElement; + let compiled = fixture.debugElement.nativeElement; - component.form.controls.username._value = 'fake-wrong-username'; - component.form.controls.password._value = 'fake-password'; + component.form.controls.username._value = 'fake-wrong-username'; + component.form.controls.password._value = 'fake-password'; - fixture.detectChanges(); - component.onValueChanged(); + fixture.detectChanges(); + component.onValueChanged(); - // trigger the click - let nativeElement = fixture.nativeElement; - let button = nativeElement.querySelector('button'); - button.dispatchEvent(new Event('click')); + // trigger the click + let nativeElement = fixture.nativeElement; + let button = nativeElement.querySelector('button'); + button.dispatchEvent(new Event('click')); - fixture.detectChanges(); + fixture.detectChanges(); - expect(fixture.componentInstance.error).toBe(true); - expect(compiled.querySelector('#login-error').innerText).toEqual('login-error-message'); - expect(component.onError.emit).toHaveBeenCalledWith({value: 'Login KO'}); - }); + expect(fixture.componentInstance.error).toBe(true); + expect(compiled.querySelector('#login-error').innerText).toEqual('login-error-message'); + expect(component.onError.emit).toHaveBeenCalledWith({value: 'Login KO'}); + }); })); }); - diff --git a/ng2-components/ng2-alfresco-login/test/services/alfresco-authentication.spec.ts b/ng2-components/ng2-alfresco-login/test/services/alfresco-authentication.spec.ts index 5054717dbc..4b5edcef32 100644 --- a/ng2-components/ng2-alfresco-login/test/services/alfresco-authentication.spec.ts +++ b/ng2-components/ng2-alfresco-login/test/services/alfresco-authentication.spec.ts @@ -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', () => { @@ -81,12 +82,12 @@ describe('AlfrescoAuthentication', () => { service.token = ''; service.login('POST', 'fakeUser', 'fakePassword') .subscribe(() => { - expect(service.isLoggedIn()).toBe(true); - expect(service.token).toEqual('fake-post-token'); - expect(localStorage.getItem('token')).toBeDefined(); - expect(localStorage.getItem('token')).toEqual('fake-post-token'); - } - ); + expect(service.isLoggedIn()).toBe(true); + expect(service.token).toEqual('fake-post-token'); + expect(localStorage.getItem('token')).toBeDefined(); + expect(localStorage.getItem('token')).toEqual('fake-post-token'); + } + ); }); it('should return false and token undefined on log out', () => { @@ -94,11 +95,11 @@ describe('AlfrescoAuthentication', () => { localStorage.setItem('token', 'fake-token'); service.logout() .subscribe(() => { - expect(service.isLoggedIn()).toBe(false); - expect(service.token).not.toBeDefined(); - expect(localStorage.getItem('token')).not.toBeDefined(); - } - ); + expect(service.isLoggedIn()).toBe(false); + expect(service.token).not.toBeDefined(); + expect(localStorage.getItem('token')).not.toBeDefined(); + } + ); }); it('should return no error if method value is GET', () => { diff --git a/ng2-components/ng2-alfresco-login/test/tsconfig.json b/ng2-components/ng2-alfresco-login/test/tsconfig.json deleted file mode 100644 index 9f1af2fc60..0000000000 --- a/ng2-components/ng2-alfresco-login/test/tsconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "module": "system", - "moduleResolution": "node", - "sourceMap": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "removeComments": false, - "noImplicitAny": false, - "declaration": false - }, - "exclude": [ - ] -} diff --git a/ng2-components/ng2-alfresco-login/tsconfig.json b/ng2-components/ng2-alfresco-login/tsconfig.json index dfa6d35f88..f2ce3750e5 100644 --- a/ng2-components/ng2-alfresco-login/tsconfig.json +++ b/ng2-components/ng2-alfresco-login/tsconfig.json @@ -1,26 +1,28 @@ { - "compilerOptions": { - "target": "es5", - "module": "system", - "moduleResolution": "node", - "sourceMap": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "removeComments": false, - "noImplicitAny": false, - "declaration": true - }, - "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" - ] + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "declaration": false, + "removeComments": true, + "noLib": false, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "sourceMap": true, + "allowUnreachableCode": false, + "allowUnusedLabels": false, + "noImplicitAny": false, + "noImplicitReturns": false, + "noImplicitUseStrict": false, + "noFallthroughCasesInSwitch": true, + "outDir": "dist" + }, + "exclude": [ + "node_modules", + "dist", + "typings/browser.d.ts", + "typings/browser", + "demo", + "src" + ], + "compileOnSave": false } diff --git a/ng2-components/ng2-alfresco-login/tslint.json b/ng2-components/ng2-alfresco-login/tslint.json index ce80085e69..e13980d341 100644 --- a/ng2-components/ng2-alfresco-login/tslint.json +++ b/ng2-components/ng2-alfresco-login/tslint.json @@ -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": [ diff --git a/ng2-components/ng2-alfresco-upload/.editorconfig b/ng2-components/ng2-alfresco-upload/.editorconfig new file mode 100644 index 0000000000..f1cc3ad329 --- /dev/null +++ b/ng2-components/ng2-alfresco-upload/.editorconfig @@ -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 diff --git a/ng2-components/ng2-alfresco-upload/assets/license_header.txt b/ng2-components/ng2-alfresco-upload/assets/license_header.txt index 5cae403293..83fd1531a3 100644 --- a/ng2-components/ng2-alfresco-upload/assets/license_header.txt +++ b/ng2-components/ng2-alfresco-upload/assets/license_header.txt @@ -1,4 +1,4 @@ -/** +/*! * @license * Copyright 2016 Alfresco Software, Ltd. * diff --git a/ng2-components/ng2-alfresco-upload/ng2-alfresco-upload.d.ts b/ng2-components/ng2-alfresco-upload/ng2-alfresco-upload.d.ts deleted file mode 100644 index 6781e73186..0000000000 --- a/ng2-components/ng2-alfresco-upload/ng2-alfresco-upload.d.ts +++ /dev/null @@ -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 - * - * - * - * - Drag and drop area to upload files: - * - */ -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]; diff --git a/ng2-components/ng2-alfresco-upload/ng2-alfresco-upload.js b/ng2-components/ng2-alfresco-upload/ng2-alfresco-upload.js deleted file mode 100644 index f2c46f56d0..0000000000 --- a/ng2-components/ng2-alfresco-upload/ng2-alfresco-upload.js +++ /dev/null @@ -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 \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-upload/ng2-alfresco-upload.js.map b/ng2-components/ng2-alfresco-upload/ng2-alfresco-upload.js.map deleted file mode 100644 index b6336745f6..0000000000 --- a/ng2-components/ng2-alfresco-upload/ng2-alfresco-upload.js.map +++ /dev/null @@ -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"} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-upload/ng2-alfresco-upload.ts b/ng2-components/ng2-alfresco-upload/ng2-alfresco-upload.ts index ddf42d11e5..2edb8d88f4 100644 --- a/ng2-components/ng2-alfresco-upload/ng2-alfresco-upload.ts +++ b/ng2-components/ng2-alfresco-upload/ng2-alfresco-upload.ts @@ -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. @@ -41,12 +41,12 @@ export * from './src/services/upload.service'; export * from './src/directives/file-draggable.directive'; export default { - component: [UploadDragAreaComponent, UploadButtonComponent], - directives: [FileDraggableDirective] -} + component: [UploadDragAreaComponent, UploadButtonComponent], + directives: [FileDraggableDirective] +}; export const ALFRESCO_ULPOAD_COMPONENT: [any] = [ - UploadDragAreaComponent, - UploadButtonComponent, - FileDraggableDirective + UploadDragAreaComponent, + UploadButtonComponent, + FileDraggableDirective ]; diff --git a/ng2-components/ng2-alfresco-upload/package.json b/ng2-components/ng2-alfresco-upload/package.json index 92651777f6..6337019ddb 100644 --- a/ng2-components/ng2-alfresco-upload/package.json +++ b/ng2-components/ng2-alfresco-upload/package.json @@ -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, diff --git a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.d.ts b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.d.ts deleted file mode 100644 index f0ab37abb3..0000000000 --- a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.d.ts +++ /dev/null @@ -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'; -/** - * - * - * 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; -} diff --git a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.html b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.html index d010a449c1..e6ae76dcb7 100644 --- a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.html +++ b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.html @@ -4,12 +4,12 @@ {{filesUploadingList.length}} {{'FILE_UPLOAD.MESSAGES.COMPLETED' | translate}}
-
+
keyboard_arrow_down keyboard_arrow_up
-
+
clear
diff --git a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.js b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.js deleted file mode 100644 index 388d020ac1..0000000000 --- a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.js +++ /dev/null @@ -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() { - /** - * - * - * 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 \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.js.map b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.js.map deleted file mode 100644 index 5a29b87c41..0000000000 --- a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.js.map +++ /dev/null @@ -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"} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.ts b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.ts index b03f998331..fa843adb89 100644 --- a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.ts +++ b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.ts @@ -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; } -} \ No newline at end of file +} diff --git a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-list.component.d.ts b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-list.component.d.ts deleted file mode 100644 index 4571bae346..0000000000 --- a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-list.component.d.ts +++ /dev/null @@ -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'; -/** - * - * - * 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; -} diff --git a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-list.component.js b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-list.component.js deleted file mode 100644 index 0ccfb42bae..0000000000 --- a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-list.component.js +++ /dev/null @@ -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() { - /** - * - * - * 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 \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-list.component.js.map b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-list.component.js.map deleted file mode 100644 index 7a5ba7c5ed..0000000000 --- a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-list.component.js.map +++ /dev/null @@ -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"} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-list.component.ts b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-list.component.ts index 9644b57940..2c32cc965b 100644 --- a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-list.component.ts +++ b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-list.component.ts @@ -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(); } diff --git a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.d.ts b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.d.ts deleted file mode 100644 index a4802e75ae..0000000000 --- a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.d.ts +++ /dev/null @@ -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'; -/** - * - * - * - * 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; -} diff --git a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.js b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.js deleted file mode 100644 index 5ea2ef5b5a..0000000000 --- a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.js +++ /dev/null @@ -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() { - /** - * - * - * - * 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 \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.js.map b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.js.map deleted file mode 100644 index a1570f31b8..0000000000 --- a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"upload-button.component.js","sourceRoot":"","sources":["upload-button.component.ts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AW,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,QAAQ,GAAG,IAAI,CAAC;oBAExD,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;oBAExC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;gBACjC,CAAC;gBA5GD;oBAAC,gBAAS,CAAC,qBAAqB,CAAC;;kFAAA;gBAGjC;oBAAC,gBAAS,CAAC,qBAAqB,CAAC;;2FAAA;gBAGjC;oBAAC,YAAK,EAAE;;+EAAA;gBAGR;oBAAC,YAAK,EAAE;;qFAAA;gBAGR;oBAAC,YAAK,EAAE;;4EAAA;gBAGR;oBAAC,YAAK,EAAE;;4EAAA;gBAGR;oBAAC,YAAK,EAAE;;gFAAA;gBAGR;oBAAC,YAAK,EAAE;;8EAAA;gBAjCZ;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,wBAAwB;wBAClC,QAAQ,EAAE,YAAY;wBACtB,UAAU,EAAE,CAAC,8DAA4B,CAAC;wBAC1C,WAAW,EAAE,gCAAgC;wBAC7C,SAAS,EAAE,CAAC,+BAA+B,CAAC;wBAC5C,KAAK,EAAE,CAAC,6BAAa,CAAC;qBACzB,CAAC;;yCAAA;gBAkHF,4BAAC;YAAD,CAAC,AAjHD,IAiHC;YAjHD,yDAiHC,CAAA"} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.ts b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.ts index 0b6888c1cc..d37be0ef2e 100644 --- a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.ts +++ b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.ts @@ -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(); + } } diff --git a/ng2-components/ng2-alfresco-upload/src/components/upload-drag-area.component.d.ts b/ng2-components/ng2-alfresco-upload/src/components/upload-drag-area.component.d.ts deleted file mode 100644 index 9de45adfd8..0000000000 --- a/ng2-components/ng2-alfresco-upload/src/components/upload-drag-area.component.d.ts +++ /dev/null @@ -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'; -/** - * - * - * 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(); -} diff --git a/ng2-components/ng2-alfresco-upload/src/components/upload-drag-area.component.js b/ng2-components/ng2-alfresco-upload/src/components/upload-drag-area.component.js deleted file mode 100644 index baf9847884..0000000000 --- a/ng2-components/ng2-alfresco-upload/src/components/upload-drag-area.component.js +++ /dev/null @@ -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() { - /** - * - * - * 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 \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-upload/src/components/upload-drag-area.component.js.map b/ng2-components/ng2-alfresco-upload/src/components/upload-drag-area.component.js.map deleted file mode 100644 index 12e24b3317..0000000000 --- a/ng2-components/ng2-alfresco-upload/src/components/upload-drag-area.component.js.map +++ /dev/null @@ -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,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;wBACxB,SAAS,EAAE,UAAU;wBACrB,UAAU,EAAE;4BACR,MAAM,EAAE,OAAO;4BACf,WAAW,EAAE,iBAAiB;yBACjC;qBACJ,CAAC,CAAC;gBACP,CAAC;gBAED;;;;mBAIG;gBACH,gDAAc,GAAd,UAAe,KAAK;oBAChB,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;wBACf,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;wBACxC,IAAI,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;wBAClE,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC;wBAC3D,EAAE,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;4BACxB,IAAI,CAAC,WAAW,EAAE,CAAC;wBACvB,CAAC;oBACL,CAAC;gBACL,CAAC;gBAED;;mBAEG;gBACK,6CAAW,GAAnB;oBACI,IAAI,CAAC,4BAA4B,CAAC,UAAU,EAAE,CAAC;gBACnD,CAAC;gBAhDD;oBAAC,gBAAS,CAAC,qBAAqB,CAAC;;6FAAA;gBAGjC;oBAAC,YAAK,EAAE;;iFAAA;gBAKR;oBAAC,YAAK,EAAE;;gFAAA;gBAnBZ;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,2BAA2B;wBACrC,QAAQ,EAAE,YAAY;wBACtB,UAAU,EAAE,CAAC,iDAAsB,EAAE,8DAA4B,CAAC;wBAClE,WAAW,EAAE,mCAAmC;wBAChD,SAAS,EAAE,CAAC,kCAAkC,CAAC;qBAClD,CAAC;;2CAAA;gBAsDF,8BAAC;YAAD,CAAC,AArDD,IAqDC;YArDD,6DAqDC,CAAA"} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-upload/src/components/upload-drag-area.component.ts b/ng2-components/ng2-alfresco-upload/src/components/upload-drag-area.component.ts index 20b00626e6..204b72f8aa 100644 --- a/ng2-components/ng2-alfresco-upload/src/components/upload-drag-area.component.ts +++ b/ng2-components/ng2-alfresco-upload/src/components/upload-drag-area.component.ts @@ -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; @@ -35,63 +34,63 @@ declare let __moduleName: string; * @returns {UploadDragAreaComponent} . */ @Component({ - selector: 'alfresco-upload-drag-area', - moduleId: __moduleName, - directives: [FileDraggableDirective, FileUploadingDialogComponent], - templateUrl: './upload-drag-area.component.html', - styleUrls: ['./upload-drag-area.component.css'] + selector: 'alfresco-upload-drag-area', + moduleId: __moduleName, + directives: [FileDraggableDirective, FileUploadingDialogComponent], + templateUrl: './upload-drag-area.component.html', + styleUrls: ['./upload-drag-area.component.css'] }) export class UploadDragAreaComponent { - private _uploaderService: UploadService; + private _uploaderService: UploadService; - @ViewChild('fileUploadingDialog') - fileUploadingDialogComponent: FileUploadingDialogComponent; + @ViewChild('fileUploadingDialog') + fileUploadingDialogComponent: FileUploadingDialogComponent; - @Input() - showUploadDialog: boolean = true; + @Input() + showUploadDialog: boolean = true; - filesUploadingList: FileModel [] = []; + filesUploadingList: FileModel [] = []; - @Input() - uploaddirectory: string = ''; + @Input() + uploaddirectory: string = ''; - constructor(public el: ElementRef) { - console.log('UploadComponent constructor', el); + constructor(public el: ElementRef) { + console.log('UploadComponent constructor', el); - this._uploaderService = new 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._uploaderService = new 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. + */ + onFilesDropped(files: File[]): void { + if (files.length) { + this._uploaderService.addToQueue(files); + this._uploaderService.uploadFilesInTheQueue(this.uploaddirectory); + this.filesUploadingList = this._uploaderService.getQueue(); + if (this.showUploadDialog) { + this._showDialog(); + } } + } - /** - * Method called when files are dropped in the drag area. - * - * @param {File[]} files - files dropped in the drag area. - */ - onFilesDropped(files): void { - 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. - */ - private _showDialog(): void { - this.fileUploadingDialogComponent.showDialog(); - } + /** + * Show the upload dialog. + */ + private _showDialog(): void { + this.fileUploadingDialogComponent.showDialog(); + } } diff --git a/ng2-components/ng2-alfresco-upload/src/directives/file-draggable.directive.d.ts b/ng2-components/ng2-alfresco-upload/src/directives/file-draggable.directive.d.ts deleted file mode 100644 index 890df1e2a5..0000000000 --- a/ng2-components/ng2-alfresco-upload/src/directives/file-draggable.directive.d.ts +++ /dev/null @@ -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; - 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); -} diff --git a/ng2-components/ng2-alfresco-upload/src/directives/file-draggable.directive.js b/ng2-components/ng2-alfresco-upload/src/directives/file-draggable.directive.js deleted file mode 100644 index e991801429..0000000000 --- a/ng2-components/ng2-alfresco-upload/src/directives/file-draggable.directive.js +++ /dev/null @@ -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 \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-upload/src/directives/file-draggable.directive.js.map b/ng2-components/ng2-alfresco-upload/src/directives/file-draggable.directive.js.map deleted file mode 100644 index d548c27d53..0000000000 --- a/ng2-components/ng2-alfresco-upload/src/directives/file-draggable.directive.js.map +++ /dev/null @@ -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,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AAC,CAAC,CAAC,CAAC,CAAC;gCACvC,CAAC;4BACL,CAAC,CAAC,CAAC;wBACP,CAAC;oBACL,CAAC;gBACL,CAAC;gBAED;;;;mBAIG;gBACK,6CAAY,GAApB,UAAqB,MAAM;oBACvB,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;oBAE7B,IAAI,CAAC,gBAAgB,GAAG,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"} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-upload/src/directives/file-draggable.directive.ts b/ng2-components/ng2-alfresco-upload/src/directives/file-draggable.directive.ts index a678113b86..b315b7c450 100644 --- a/ng2-components/ng2-alfresco-upload/src/directives/file-draggable.directive.ts +++ b/ng2-components/ng2-alfresco-upload/src/directives/file-draggable.directive.ts @@ -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,8 +125,8 @@ export class FileDraggableDirective { * * @param {$event} $event - DOM $event. */ - private _preventDefault($event): void { + _preventDefault($event: Event): void { $event.stopPropagation(); $event.preventDefault(); } -} \ No newline at end of file +} diff --git a/ng2-components/ng2-alfresco-upload/src/models/file.model.d.ts b/ng2-components/ng2-alfresco-upload/src/models/file.model.d.ts deleted file mode 100644 index 844920fbab..0000000000 --- a/ng2-components/ng2-alfresco-upload/src/models/file.model.d.ts +++ /dev/null @@ -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(); -} diff --git a/ng2-components/ng2-alfresco-upload/src/models/file.model.js b/ng2-components/ng2-alfresco-upload/src/models/file.model.js deleted file mode 100644 index 28161f7442..0000000000 --- a/ng2-components/ng2-alfresco-upload/src/models/file.model.js +++ /dev/null @@ -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 \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-upload/src/models/file.model.js.map b/ng2-components/ng2-alfresco-upload/src/models/file.model.js.map deleted file mode 100644 index 897a491263..0000000000 --- a/ng2-components/ng2-alfresco-upload/src/models/file.model.js.map +++ /dev/null @@ -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,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBACzC,IAAI,CAAC,QAAQ,GAAG;wBACZ,MAAM,EAAE,CAAC;wBACT,KAAK,EAAE,CAAC;wBACR,OAAO,EAAE,CAAC;qBACb,CAAC;gBACN,CAAC;gBAED,8BAAU,GAAV,UAAW,QAAa;oBACpB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;gBAC7B,CAAC;gBAED,4BAAQ,GAAR;oBACI,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;gBACtB,CAAC;gBAED,gCAAY,GAAZ;oBACI,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;gBAC1B,CAAC;gBAED,qCAAiB,GAAjB,UAAkB,cAA8B;oBAC5C,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;gBAC1C,CAAC;gBAED;;mBAEG;gBACH,4BAAQ,GAAR;oBACI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAA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G,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"} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-upload/src/models/file.model.ts b/ng2-components/ng2-alfresco-upload/src/models/file.model.ts index f910d1fa97..7d6d35508e 100644 --- a/ng2-components/ng2-alfresco-upload/src/models/file.model.ts +++ b/ng2-components/ng2-alfresco-upload/src/models/file.model.ts @@ -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); }); } diff --git a/ng2-components/ng2-alfresco-upload/src/services/upload.service.ts b/ng2-components/ng2-alfresco-upload/src/services/upload.service.ts index 1f81f095b8..eed977db3c 100644 --- a/ng2-components/ng2-alfresco-upload/src/services/upload.service.ts +++ b/ng2-components/ng2-alfresco-upload/src/services/upload.service.ts @@ -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]); }); diff --git a/ng2-components/ng2-alfresco-upload/test/components/upload-button.component.spec.ts b/ng2-components/ng2-alfresco-upload/test/components/upload-button.component.spec.ts index d86d9e3d02..fd045aa4b6 100644 --- a/ng2-components/ng2-alfresco-upload/test/components/upload-button.component.spec.ts +++ b/ng2-components/ng2-alfresco-upload/test/components/upload-button.component.spec.ts @@ -1,4 +1,4 @@ -/** +/*! * @license * Copyright 2016 Alfresco Software, Ltd. * @@ -16,87 +16,87 @@ */ -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', () => { - setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS); + setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS); - beforeEachProviders(() => { - return [ - provide(TranslateService, {useClass: TranslationMock}) - ]; - }); + beforeEachProviders(() => { + return [ + provide(TranslateService, {useClass: TranslationMock}) + ]; + }); - it('should render upload-single-file button as default', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { - return tcb - .createAsync(UploadButtonComponent) - .then((fixture) => { - let compiled = fixture.debugElement.nativeElement; - fixture.detectChanges(); - expect(compiled.querySelector('#upload-single-file')).toBeDefined(); - }); - })); + it('should render upload-single-file button as default', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { + return tcb + .createAsync(UploadButtonComponent) + .then((fixture) => { + let compiled = fixture.debugElement.nativeElement; + fixture.detectChanges(); + expect(compiled.querySelector('#upload-single-file')).toBeDefined(); + }); + })); - it('should render upload-multiple-file button if multipleFiles is true', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { - return tcb - .createAsync(UploadButtonComponent) - .then((fixture) => { - let component = fixture.componentInstance; - component.multipleFiles = true; - let compiled = fixture.debugElement.nativeElement; - fixture.detectChanges(); - expect(compiled.querySelector('#upload-multiple-files')).toBeDefined(); - }); - })); + it('should render upload-multiple-file button if multipleFiles=true', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { + return tcb + .createAsync(UploadButtonComponent) + .then((fixture) => { + let component = fixture.componentInstance; + component.multipleFiles = true; + let compiled = fixture.debugElement.nativeElement; + fixture.detectChanges(); + expect(compiled.querySelector('#upload-multiple-files')).toBeDefined(); + }); + })); - it('should render an uploadFolder button if uploadFolder is true', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { - return tcb - .createAsync(UploadButtonComponent) - .then((fixture) => { - let component = fixture.componentInstance; - component.uploadFolder = true; - let compiled = fixture.debugElement.nativeElement; - fixture.detectChanges(); - expect(compiled.querySelector('#uploadFolder')).toBeDefined(); - }); - })); + it('should render an uploadFolder button if uploadFolder is true', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { + return tcb + .createAsync(UploadButtonComponent) + .then((fixture) => { + let component = fixture.componentInstance; + component.uploadFolder = true; + let compiled = fixture.debugElement.nativeElement; + fixture.detectChanges(); + expect(compiled.querySelector('#uploadFolder')).toBeDefined(); + }); + })); - it('should call onFilesAdded method', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { - return tcb - .createAsync(UploadButtonComponent) - .then((fixture) => { - let component = fixture.componentInstance; - component.onFilesAdded = jasmine.createSpy('onFilesAdded'); + it('should call onFilesAdded method', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { + return tcb + .createAsync(UploadButtonComponent) + .then((fixture) => { + let component = fixture.componentInstance; + component.onFilesAdded = jasmine.createSpy('onFilesAdded'); - fixture.detectChanges(); + fixture.detectChanges(); - let fakeEvent = { - currentTarget: {files: [{name: 'fake-name', size: 10}]} - }; + let fakeEvent = { + currentTarget: {files: [{name: 'fake-name', size: 10}]} + }; - component.onFilesAdded(fakeEvent); - expect(component.onFilesAdded).toHaveBeenCalledWith(fakeEvent); - }); - })); + component.onFilesAdded(fakeEvent); + expect(component.onFilesAdded).toHaveBeenCalledWith(fakeEvent); + }); + })); - it('should render dialog box with css class show ', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { - return tcb - .createAsync(UploadButtonComponent) - .then((fixture) => { - let component = fixture.componentInstance; - fixture.detectChanges(); - let compiled = fixture.debugElement.nativeElement; + it('should render dialog box with css class show ', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { + return tcb + .createAsync(UploadButtonComponent) + .then((fixture) => { + let component = fixture.componentInstance; + fixture.detectChanges(); + let compiled = fixture.debugElement.nativeElement; - component._showDialog(); - fixture.detectChanges(); - expect(compiled.querySelector('.file-dialog').getAttribute('class')).toEqual('file-dialog show'); - }); - })); + component._showDialog(); + fixture.detectChanges(); + expect(compiled.querySelector('.file-dialog').getAttribute('class')).toEqual('file-dialog show'); + }); + })); }); diff --git a/ng2-components/ng2-alfresco-upload/test/services/upload.service.spec.ts b/ng2-components/ng2-alfresco-upload/test/services/upload.service.spec.ts index a2eb311813..1c820ae3ba 100644 --- a/ng2-components/ng2-alfresco-upload/test/services/upload.service.spec.ts +++ b/ng2-components/ng2-alfresco-upload/test/services/upload.service.spec.ts @@ -1,4 +1,4 @@ -/** +/*! * @license * Copyright 2016 Alfresco Software, Ltd. * @@ -15,124 +15,123 @@ * 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(); + beforeEach(() => { + jasmine.Ajax.install(); - doneFn = jasmine.createSpy("success"); - errorFn = jasmine.createSpy("error"); - xhr = new XMLHttpRequest(); - xhr.onreadystatechange = function () { - if (this.readyState == this.DONE && this.status == 200) { - doneFn(this.responseText); - } else if (this.readyState == this.DONE && this.status == 404) { - errorFn(this.responseText); - } - }; - xhr.abort = jasmine.createSpy('abort'); + doneFn = jasmine.createSpy('success'); + errorFn = jasmine.createSpy('error'); + xhr = new XMLHttpRequest(); + xhr.onreadystatechange = function () { + if (this.readyState === this.DONE && this.status === 200) { + doneFn(this.responseText); + } else if (this.readyState === this.DONE && this.status === 404) { + errorFn(this.responseText); + } + }; + xhr.abort = jasmine.createSpy('abort'); - options = { - url: '/some/cool/url', - withCredentials: true, - authToken: btoa('fakeadmin:fakeadmin'), - authTokenPrefix: 'Basic', - fieldName: 'fakeFileData', - formFields: { - siteid: 'fakeSite', - containerid: 'fakeFolder' - } - }; - service = new UploadService(options); + options = { + url: '/some/cool/url', + withCredentials: true, + authToken: btoa('fakeadmin:fakeadmin'), + authTokenPrefix: 'Basic', + fieldName: 'fakeFileData', + formFields: { + siteid: 'fakeSite', + containerid: 'fakeFolder' + } + }; + service = new UploadService(options); + }); + + afterEach(() => { + jasmine.Ajax.uninstall(); + }); + + it('should return an empty queue if no elements are added', () => { + expect(service.getQueue().length).toEqual(0); + }); + + it('should add an element in the queue and returns it', () => { + let filesFake = [{name: 'fake-name', size: 10}]; + service.addToQueue(filesFake); + expect(service.getQueue().length).toEqual(1); + }); + + it('should add two elements in the queue and returns them', () => { + let filesFake = [{name: 'fake-name', size: 10}, {name: 'fake-name2', size: 20}]; + service.addToQueue(filesFake); + expect(service.getQueue().length).toEqual(2); + }); + + it('should make XHR done request after the file is added in the queue', () => { + service.setXMLHttpRequest(xhr); + let filesFake = [{name: 'fake-name', size: 10}]; + service.addToQueue(filesFake); + service.uploadFilesInTheQueue(''); + expect(jasmine.Ajax.requests.mostRecent().url).toBe('/some/cool/url'); + expect(doneFn).not.toHaveBeenCalled(); + jasmine.Ajax.requests.mostRecent().respondWith({ + 'status': 200, + contentType: 'text/plain', + responseText: 'File uploaded' }); + expect(doneFn).toHaveBeenCalledWith('File uploaded'); + }); - afterEach(() => { - jasmine.Ajax.uninstall(); + it('should make XHR error request after an error occur', () => { + service.setXMLHttpRequest(xhr); + let filesFake = [{name: 'fake-name', size: 10}]; + service.addToQueue(filesFake); + service.uploadFilesInTheQueue(''); + expect(jasmine.Ajax.requests.mostRecent().url).toBe('/some/cool/url'); + expect(doneFn).not.toHaveBeenCalled(); + jasmine.Ajax.requests.mostRecent().respondWith({ + 'status': 404, + contentType: 'text/plain', + responseText: 'Error file uploaded' }); + expect(errorFn).toHaveBeenCalledWith('Error file uploaded'); + }); - it('should return an empty queue if no elements are added', () => { - expect(service.getQueue().length).toEqual(0); - }); - - it('should add an element in the queue and returns it', () => { - let filesFake = [{name: 'fake-name', size: 10}]; - service.addToQueue(filesFake); - expect(service.getQueue().length).toEqual(1); - }); - - it('should add two elements in the queue and returns them', () => { - let filesFake = [{name: 'fake-name', size: 10}, {name: 'fake-name2', size: 20} ]; - service.addToQueue(filesFake); - expect(service.getQueue().length).toEqual(2); - }); - - it('should make XHR done request after the file is added in the queue', () => { - service.setXMLHttpRequest(xhr); - let filesFake = [{name: 'fake-name', size: 10}]; - service.addToQueue(filesFake); - service.uploadFilesInTheQueue(''); - expect(jasmine.Ajax.requests.mostRecent().url).toBe('/some/cool/url'); - expect(doneFn).not.toHaveBeenCalled(); - jasmine.Ajax.requests.mostRecent().respondWith({ - "status": 200, - contentType: 'text/plain', - responseText: 'File uploaded' - }); - expect(doneFn).toHaveBeenCalledWith('File uploaded'); - }); - - it('should make XHR error request after an error occur', () => { - service.setXMLHttpRequest(xhr); - let filesFake = [{name: 'fake-name', size: 10}]; - service.addToQueue(filesFake); - service.uploadFilesInTheQueue(''); - expect(jasmine.Ajax.requests.mostRecent().url).toBe('/some/cool/url'); - expect(doneFn).not.toHaveBeenCalled(); - jasmine.Ajax.requests.mostRecent().respondWith({ - "status": 404, - contentType: 'text/plain', - responseText: 'Error file uploaded' - }); - expect(errorFn).toHaveBeenCalledWith('Error file uploaded'); - }); - - it('should make XHR abort request after the xhr abort is called', () => { - service.setXMLHttpRequest(xhr); - let filesFake = [{name: 'fake-name', size: 10}]; - service.addToQueue(filesFake); - service.uploadFilesInTheQueue(''); - let file = service.getQueue(); - file[0].setAbort(); - expect(xhr.abort).toHaveBeenCalled(); - }); - - it('should make XHR done request after the file is upload', () => { - service.setXMLHttpRequest(xhr); - let filesFake = {name: 'fake-name', size: 10}; - - 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, - contentType: 'text/plain', - responseText: 'File uploaded' - }); - expect(doneFn).toHaveBeenCalledWith('File uploaded'); + it('should make XHR abort request after the xhr abort is called', () => { + service.setXMLHttpRequest(xhr); + let filesFake = [{name: 'fake-name', size: 10}]; + service.addToQueue(filesFake); + service.uploadFilesInTheQueue(''); + let file = service.getQueue(); + file[0].setAbort(); + expect(xhr.abort).toHaveBeenCalled(); + }); + + it('should make XHR done request after the file is upload', () => { + service.setXMLHttpRequest(xhr); + let filesFake = {name: 'fake-name', size: 10}; + + 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, + contentType: 'text/plain', + responseText: 'File uploaded' }); + expect(doneFn).toHaveBeenCalledWith('File uploaded'); + }); }); diff --git a/ng2-components/ng2-alfresco-upload/test/tsconfig.json b/ng2-components/ng2-alfresco-upload/test/tsconfig.json deleted file mode 100644 index 9f1af2fc60..0000000000 --- a/ng2-components/ng2-alfresco-upload/test/tsconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "module": "system", - "moduleResolution": "node", - "sourceMap": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "removeComments": false, - "noImplicitAny": false, - "declaration": false - }, - "exclude": [ - ] -} diff --git a/ng2-components/ng2-alfresco-upload/tsconfig.json b/ng2-components/ng2-alfresco-upload/tsconfig.json index 10ac8b1494..d1413d432d 100644 --- a/ng2-components/ng2-alfresco-upload/tsconfig.json +++ b/ng2-components/ng2-alfresco-upload/tsconfig.json @@ -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 } diff --git a/ng2-components/ng2-alfresco-upload/tslint.json b/ng2-components/ng2-alfresco-upload/tslint.json index ce80085e69..4078d39a26 100644 --- a/ng2-components/ng2-alfresco-upload/tslint.json +++ b/ng2-components/ng2-alfresco-upload/tslint.json @@ -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": [