mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
lint login and upload
This commit is contained in:
parent
6654563469
commit
6b99e49498
15
ng2-components/ng2-alfresco-core/.editorconfig
Normal file
15
ng2-components/ng2-alfresco-core/.editorconfig
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# http://editorconfig.org
|
||||||
|
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
insert_final_newline = false
|
||||||
|
trim_trailing_whitespace = false
|
6
ng2-components/ng2-alfresco-core/.travis.yml
Executable file
6
ng2-components/ng2-alfresco-core/.travis.yml
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
language: node_js
|
||||||
|
node_js:
|
||||||
|
- '5'
|
||||||
|
script: npm run coverage
|
||||||
|
# Send coverage data to Coveralls
|
||||||
|
after_script: "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
|
16
ng2-components/ng2-alfresco-core/assets/license_header.txt
Normal file
16
ng2-components/ng2-alfresco-core/assets/license_header.txt
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/*!
|
||||||
|
* @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.
|
||||||
|
*/
|
15
ng2-components/ng2-alfresco-documentlist/.editorconfig
Normal file
15
ng2-components/ng2-alfresco-documentlist/.editorconfig
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# http://editorconfig.org
|
||||||
|
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
insert_final_newline = false
|
||||||
|
trim_trailing_whitespace = false
|
6
ng2-components/ng2-alfresco-documentlist/.travis.yml
Executable file
6
ng2-components/ng2-alfresco-documentlist/.travis.yml
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
language: node_js
|
||||||
|
node_js:
|
||||||
|
- '5'
|
||||||
|
script: npm run coverage
|
||||||
|
# Send coverage data to Coveralls
|
||||||
|
after_script: "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
|
@ -0,0 +1,16 @@
|
|||||||
|
/*!
|
||||||
|
* @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.
|
||||||
|
*/
|
@ -1,53 +1,73 @@
|
|||||||
{
|
{
|
||||||
"name": "ng2-alfresco-documentlist",
|
"name": "ng2-alfresco-documentlist",
|
||||||
"description": "Alfresco Angular2 Document List Component",
|
"description": "Alfresco Angular2 Document List Component",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"author": "Alfresco Software, Ltd.",
|
"author": "Alfresco Software, Ltd.",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "typings install && tsc",
|
"build": "npm run tslint-test && npm run tslint-src && npm run tslint-root && typings install && rm -rf dist && tsc && license-check",
|
||||||
"tsc": "tsc",
|
"tslint-test": "tslint -c tslint.json test/**/*.ts",
|
||||||
"tsc:w": "tsc -w",
|
"tslint-src": "tslint -c tslint.json src/**/*.ts",
|
||||||
"typings": "typings",
|
"tslint-root": "tslint -c tslint.json *.ts",
|
||||||
"test": "live-server --open=index.html --entry-file=test/ --mount=/ng2-alfresco-core:../ng2-alfresco-core",
|
"licensecheck": "license-check",
|
||||||
"test:w": "concurrently \"npm run tsc:w\" \"npm run test\" "
|
"tsc": "tsc",
|
||||||
},
|
"tsc:w": "tsc -w",
|
||||||
"repository": {
|
"typings": "typings",
|
||||||
"type": "git",
|
"test": "live-server --open=index.html --entry-file=test/ --mount=/ng2-alfresco-core:../ng2-alfresco-core",
|
||||||
"url": "https://github.com/Alfresco/dev-platform-webcomponents.git"
|
"test:w": "concurrently \"npm run tsc:w\" \"npm run test\" "
|
||||||
},
|
},
|
||||||
"bugs": {
|
"repository": {
|
||||||
"url": "https://github.com/Alfresco/dev-platform-webcomponents/issues"
|
"type": "git",
|
||||||
},
|
"url": "https://github.com/Alfresco/dev-platform-webcomponents.git"
|
||||||
"license": "Apache-2.0",
|
},
|
||||||
"contributors": [
|
"bugs": {
|
||||||
{
|
"url": "https://github.com/Alfresco/dev-platform-webcomponents/issues"
|
||||||
"name": "Denys Vuika",
|
},
|
||||||
"email": "denis.vuyka@gmail.com"
|
"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",
|
||||||
|
"license-check": "^1.0.4",
|
||||||
|
"tslint": "^3.8.1"
|
||||||
|
},
|
||||||
|
"license-check-config": {
|
||||||
|
"src": [
|
||||||
|
"**/*.js",
|
||||||
|
"**/*.ts",
|
||||||
|
"!/**/coverage/**/*",
|
||||||
|
"!/**/demo/**/*",
|
||||||
|
"!/**/node_modules/**/*",
|
||||||
|
"!/**/typings/**/*"
|
||||||
|
],
|
||||||
|
"path": "assets/license_header.txt",
|
||||||
|
"blocking": false,
|
||||||
|
"logInfo": false,
|
||||||
|
"logError": true
|
||||||
}
|
}
|
||||||
],
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
120
ng2-components/ng2-alfresco-documentlist/tslint.json
Normal file
120
ng2-components/ng2-alfresco-documentlist/tslint.json
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
{
|
||||||
|
"rules": {
|
||||||
|
"align": [
|
||||||
|
true,
|
||||||
|
"parameters",
|
||||||
|
"statements"
|
||||||
|
],
|
||||||
|
"ban": false,
|
||||||
|
"class-name": true,
|
||||||
|
"comment-format": [
|
||||||
|
true,
|
||||||
|
"check-space",
|
||||||
|
"check-lowercase"
|
||||||
|
],
|
||||||
|
"curly": true,
|
||||||
|
"eofline": true,
|
||||||
|
"forin": true,
|
||||||
|
"indent": [
|
||||||
|
true,
|
||||||
|
"spaces"
|
||||||
|
],
|
||||||
|
"interface-name": false,
|
||||||
|
"jsdoc-format": true,
|
||||||
|
"label-position": true,
|
||||||
|
"label-undefined": true,
|
||||||
|
"max-line-length": [
|
||||||
|
true,
|
||||||
|
140
|
||||||
|
],
|
||||||
|
"member-ordering": [
|
||||||
|
true,
|
||||||
|
"static-before-instance",
|
||||||
|
"variables-before-functions"
|
||||||
|
],
|
||||||
|
"no-any": false,
|
||||||
|
"no-arg": true,
|
||||||
|
"no-bitwise": false,
|
||||||
|
"no-conditional-assignment": true,
|
||||||
|
"no-consecutive-blank-lines": false,
|
||||||
|
"no-console": [
|
||||||
|
true,
|
||||||
|
"debug",
|
||||||
|
"info",
|
||||||
|
"time",
|
||||||
|
"timeEnd",
|
||||||
|
"trace"
|
||||||
|
],
|
||||||
|
"no-construct": true,
|
||||||
|
"no-constructor-vars": false,
|
||||||
|
"no-debugger": true,
|
||||||
|
"no-duplicate-key": true,
|
||||||
|
"no-duplicate-variable": true,
|
||||||
|
"no-empty": true,
|
||||||
|
"no-eval": true,
|
||||||
|
"no-inferrable-types": false,
|
||||||
|
"no-internal-module": true,
|
||||||
|
"no-require-imports": true,
|
||||||
|
"no-shadowed-variable": true,
|
||||||
|
"no-switch-case-fall-through": true,
|
||||||
|
"no-trailing-whitespace": true,
|
||||||
|
"no-unreachable": true,
|
||||||
|
"no-unused-expression": true,
|
||||||
|
"no-unused-variable": true,
|
||||||
|
"no-use-before-declare": true,
|
||||||
|
"no-var-keyword": true,
|
||||||
|
"no-var-requires": true,
|
||||||
|
"object-literal-sort-keys": false,
|
||||||
|
"one-line": [
|
||||||
|
true,
|
||||||
|
"check-open-brace",
|
||||||
|
"check-catch",
|
||||||
|
"check-else",
|
||||||
|
"check-whitespace"
|
||||||
|
],
|
||||||
|
"quotemark": [
|
||||||
|
true,
|
||||||
|
"single",
|
||||||
|
"avoid-escape"
|
||||||
|
],
|
||||||
|
"radix": true,
|
||||||
|
"semicolon": true,
|
||||||
|
"switch-default": true,
|
||||||
|
"trailing-comma": [
|
||||||
|
true,
|
||||||
|
{
|
||||||
|
"multiline": "never",
|
||||||
|
"singleline": "never"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"triple-equals": [
|
||||||
|
true,
|
||||||
|
"allow-null-check"
|
||||||
|
],
|
||||||
|
"typedef": false,
|
||||||
|
"typedef-whitespace": [
|
||||||
|
true,
|
||||||
|
{
|
||||||
|
"call-signature": "nospace",
|
||||||
|
"index-signature": "nospace",
|
||||||
|
"parameter": "nospace",
|
||||||
|
"property-declaration": "nospace",
|
||||||
|
"variable-declaration": "nospace"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"use-strict": false,
|
||||||
|
"variable-name": [
|
||||||
|
true,
|
||||||
|
"check-format",
|
||||||
|
"allow-leading-underscore",
|
||||||
|
"ban-keywords"
|
||||||
|
],
|
||||||
|
"whitespace": [
|
||||||
|
true,
|
||||||
|
"check-branch",
|
||||||
|
"check-decl",
|
||||||
|
"check-operator",
|
||||||
|
"check-separator"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,7 @@ root = true
|
|||||||
[*]
|
[*]
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 2
|
indent_size = 4
|
||||||
end_of_line = lf
|
end_of_line = lf
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
|
@ -1,78 +1,78 @@
|
|||||||
{
|
{
|
||||||
"name": "ng2-alfresco-login",
|
"name": "ng2-alfresco-login",
|
||||||
"description": "Alfresco Angular2 Login Component",
|
"description": "Alfresco Angular2 Login Component",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"author": "Alfresco Software, Ltd.",
|
"author": "Alfresco Software, Ltd.",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "npm run tslint-test && npm run tslint-src && npm run tslint-root && typings install && rm -rf dist && 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-test": "tslint -c tslint.json test/**/*.ts",
|
||||||
"tslint-src" : "tslint -c tslint.json src/**/*.ts",
|
"tslint-src": "tslint -c tslint.json src/**/*.ts",
|
||||||
"tslint-root" : "tslint -c tslint.json *.ts",
|
"tslint-root": "tslint -c tslint.json *.ts",
|
||||||
"licensecheck": "license-check",
|
"licensecheck": "license-check",
|
||||||
"tsc": "tsc",
|
"tsc": "tsc",
|
||||||
"tsc:w": "tsc -w",
|
"tsc:w": "tsc -w",
|
||||||
"typings": "typings",
|
"typings": "typings",
|
||||||
"test": "live-server --open=index.html --entry-file=test/ --mount=/ng2-alfresco-core:../ng2-alfresco-core",
|
"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\" "
|
"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": {
|
||||||
"name": "Maurizio Vitale",
|
"type": "git",
|
||||||
"email": "maurizio.vitale84@gmail.com"
|
"url": "https://github.com/Alfresco/dev-platform-webcomponents.git"
|
||||||
}
|
},
|
||||||
],
|
"bugs": {
|
||||||
"keywords": [
|
"url": "https://github.com/Alfresco/dev-platform-webcomponents/issues"
|
||||||
"ng2",
|
},
|
||||||
"angular",
|
"license": "Apache-2.0",
|
||||||
"angular2",
|
"contributors": [
|
||||||
"alfresco"
|
{
|
||||||
],
|
"name": "Denys Vuika",
|
||||||
"dependencies": {
|
"email": "denis.vuyka@gmail.com"
|
||||||
"angular2": "2.0.0-beta.15",
|
},
|
||||||
"systemjs": "0.19.26",
|
{
|
||||||
"es6-shim": "^0.35.0",
|
"name": "Maurizio Vitale",
|
||||||
"reflect-metadata": "0.1.2",
|
"email": "maurizio.vitale84@gmail.com"
|
||||||
"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",
|
"keywords": [
|
||||||
"blocking": false,
|
"ng2",
|
||||||
"logInfo": false,
|
"angular",
|
||||||
"logError": true
|
"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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ root = true
|
|||||||
[*]
|
[*]
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 2
|
indent_size = 4
|
||||||
end_of_line = lf
|
end_of_line = lf
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
|
@ -1,75 +1,75 @@
|
|||||||
{
|
{
|
||||||
"name": "ng2-alfresco-upload",
|
"name": "ng2-alfresco-upload",
|
||||||
"description": "Alfresco Angular2 Upload Component",
|
"description": "Alfresco Angular2 Upload Component",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"author": "Alfresco Software, Ltd.",
|
"author": "Alfresco Software, Ltd.",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "npm run tslint-test && npm run tslint-src && npm run tslint-root && typings install && rm -rf dist && 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-test": "tslint -c tslint.json test/**/*.ts",
|
||||||
"tslint-src" : "tslint -c tslint.json src/**/*.ts",
|
"tslint-src": "tslint -c tslint.json src/**/*.ts",
|
||||||
"tslint-root" : "tslint -c tslint.json *.ts",
|
"tslint-root": "tslint -c tslint.json *.ts",
|
||||||
"licensecheck": "license-check",
|
"licensecheck": "license-check",
|
||||||
"tsc": "tsc",
|
"tsc": "tsc",
|
||||||
"tsc:w": "tsc -w",
|
"tsc:w": "tsc -w",
|
||||||
"typings": "typings",
|
"typings": "typings",
|
||||||
"test": "live-server --open=index.html --entry-file=test/ ",
|
"test": "live-server --open=index.html --entry-file=test/ ",
|
||||||
"test:w": "concurrently \"npm run tsc:w\" \"npm run test\" "
|
"test:w": "concurrently \"npm run tsc:w\" \"npm run test\" "
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/Alfresco/dev-platform-webcomponents.git"
|
"url": "https://github.com/Alfresco/dev-platform-webcomponents.git"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/Alfresco/dev-platform-webcomponents/issues"
|
"url": "https://github.com/Alfresco/dev-platform-webcomponents/issues"
|
||||||
},
|
},
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
{
|
{
|
||||||
"name": "Mario Romano",
|
"name": "Mario Romano",
|
||||||
"email": "mario.romano83@gmail.com"
|
"email": "mario.romano83@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"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"coveralls": "^2.11.9",
|
|
||||||
"jasmine-ajax": "^3.2.0",
|
|
||||||
"jasmine-core": "2.4.1",
|
|
||||||
"license-check": "^1.0.4",
|
|
||||||
"live-server": "^0.9.2",
|
|
||||||
"tslint": "^3.8.1",
|
|
||||||
"typescript": "^1.8.10",
|
|
||||||
"typings": "^0.7.12",
|
|
||||||
"concurrently": "^2.0.0"
|
|
||||||
},
|
|
||||||
"license-check-config": {
|
|
||||||
"src": [
|
|
||||||
"**/*.js",
|
|
||||||
"**/*.ts",
|
|
||||||
"!/**/coverage/**/*",
|
|
||||||
"!/**/demo/**/*",
|
|
||||||
"!/**/node_modules/**/*",
|
|
||||||
"!/**/typings/**/*"
|
|
||||||
],
|
],
|
||||||
"path": "assets/license_header.txt",
|
"keywords": [
|
||||||
"blocking": false,
|
"ng2",
|
||||||
"logInfo": false,
|
"angular",
|
||||||
"logError": true
|
"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"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"coveralls": "^2.11.9",
|
||||||
|
"jasmine-ajax": "^3.2.0",
|
||||||
|
"jasmine-core": "2.4.1",
|
||||||
|
"license-check": "^1.0.4",
|
||||||
|
"live-server": "^0.9.2",
|
||||||
|
"tslint": "^3.8.1",
|
||||||
|
"typescript": "^1.8.10",
|
||||||
|
"typings": "^0.7.12",
|
||||||
|
"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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,63 +34,63 @@ declare let __moduleName: string;
|
|||||||
* @returns {UploadDragAreaComponent} .
|
* @returns {UploadDragAreaComponent} .
|
||||||
*/
|
*/
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'alfresco-upload-drag-area',
|
selector: 'alfresco-upload-drag-area',
|
||||||
moduleId: __moduleName,
|
moduleId: __moduleName,
|
||||||
directives: [FileDraggableDirective, FileUploadingDialogComponent],
|
directives: [FileDraggableDirective, FileUploadingDialogComponent],
|
||||||
templateUrl: './upload-drag-area.component.html',
|
templateUrl: './upload-drag-area.component.html',
|
||||||
styleUrls: ['./upload-drag-area.component.css']
|
styleUrls: ['./upload-drag-area.component.css']
|
||||||
})
|
})
|
||||||
export class UploadDragAreaComponent {
|
export class UploadDragAreaComponent {
|
||||||
|
|
||||||
private _uploaderService: UploadService;
|
private _uploaderService: UploadService;
|
||||||
|
|
||||||
@ViewChild('fileUploadingDialog')
|
@ViewChild('fileUploadingDialog')
|
||||||
fileUploadingDialogComponent: FileUploadingDialogComponent;
|
fileUploadingDialogComponent: FileUploadingDialogComponent;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
showUploadDialog: boolean = true;
|
showUploadDialog: boolean = true;
|
||||||
|
|
||||||
filesUploadingList: FileModel [] = [];
|
filesUploadingList: FileModel [] = [];
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
uploaddirectory: string = '';
|
uploaddirectory: string = '';
|
||||||
|
|
||||||
constructor(public el: ElementRef) {
|
constructor(public el: ElementRef) {
|
||||||
console.log('UploadComponent constructor', el);
|
console.log('UploadComponent constructor', el);
|
||||||
|
|
||||||
this._uploaderService = new UploadService({
|
this._uploaderService = new UploadService({
|
||||||
url: 'http://192.168.99.100:8080/alfresco/service/api/upload',
|
url: 'http://192.168.99.100:8080/alfresco/service/api/upload',
|
||||||
withCredentials: true,
|
withCredentials: true,
|
||||||
authToken: btoa('admin:admin'),
|
authToken: btoa('admin:admin'),
|
||||||
authTokenPrefix: 'Basic',
|
authTokenPrefix: 'Basic',
|
||||||
fieldName: 'filedata',
|
fieldName: 'filedata',
|
||||||
formFields: {
|
formFields: {
|
||||||
siteid: 'swsdp',
|
siteid: 'swsdp',
|
||||||
containerid: 'documentLibrary'
|
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the upload dialog.
|
* Method called when files are dropped in the drag area.
|
||||||
*/
|
*
|
||||||
private _showDialog(): void {
|
* @param {File[]} files - files dropped in the drag area.
|
||||||
this.fileUploadingDialogComponent.showDialog();
|
*/
|
||||||
}
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the upload dialog.
|
||||||
|
*/
|
||||||
|
private _showDialog(): void {
|
||||||
|
this.fileUploadingDialogComponent.showDialog();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,76 +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 { FileModel } from '../models/file.model';
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* UploadService keep the queue of the file to upload and uploads them.
|
|
||||||
*
|
|
||||||
* @returns {UploadService} .
|
|
||||||
*/
|
|
||||||
export declare class UploadService {
|
|
||||||
private options;
|
|
||||||
private _url;
|
|
||||||
private _method;
|
|
||||||
private _authTokenPrefix;
|
|
||||||
private _authToken;
|
|
||||||
private _fieldName;
|
|
||||||
private _formFields;
|
|
||||||
private _withCredentials;
|
|
||||||
private _xmlHttpRequest;
|
|
||||||
private _queue;
|
|
||||||
constructor(options: any);
|
|
||||||
/**
|
|
||||||
* Add files to the uploading queue to be uploaded.
|
|
||||||
*
|
|
||||||
* @param {File[]} - files to add to the upload queue.
|
|
||||||
*
|
|
||||||
* return {FileModel[]} - return the file added to the queue in this call.
|
|
||||||
*/
|
|
||||||
addToQueue(files: any[]): FileModel[];
|
|
||||||
/**
|
|
||||||
* Pick all the files in the queue that are not been uploaded yet and upload it into the directory folder.
|
|
||||||
*/
|
|
||||||
uploadFilesInTheQueue(directory: string): void;
|
|
||||||
/**
|
|
||||||
* The method create a new XMLHttpRequest instance if doesn't exist
|
|
||||||
*/
|
|
||||||
private _configureXMLHttpRequest(uploadingFileModel);
|
|
||||||
/**
|
|
||||||
* Upload a file into the directory folder, and enrich it with the xhr.
|
|
||||||
*
|
|
||||||
* @param {FileModel} - files to be uploaded.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
uploadFile(uploadingFileModel: any, directory: string): void;
|
|
||||||
/**
|
|
||||||
* Return all the files in the uploading queue.
|
|
||||||
*
|
|
||||||
* @return {FileModel[]} - files in the upload queue.
|
|
||||||
*/
|
|
||||||
getQueue(): FileModel[];
|
|
||||||
/**
|
|
||||||
* Check if an item is a file.
|
|
||||||
*
|
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
private _isFile(file);
|
|
||||||
/**
|
|
||||||
* Set XMLHttpRequest method
|
|
||||||
* @param xhr
|
|
||||||
*/
|
|
||||||
setXMLHttpRequest(xhr: XMLHttpRequest): void;
|
|
||||||
}
|
|
@ -1,166 +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(['../models/file.model'], function(exports_1, context_1) {
|
|
||||||
"use strict";
|
|
||||||
var __moduleName = context_1 && context_1.id;
|
|
||||||
var file_model_1;
|
|
||||||
var UploadService;
|
|
||||||
return {
|
|
||||||
setters:[
|
|
||||||
function (file_model_1_1) {
|
|
||||||
file_model_1 = file_model_1_1;
|
|
||||||
}],
|
|
||||||
execute: function() {
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* UploadService keep the queue of the file to upload and uploads them.
|
|
||||||
*
|
|
||||||
* @returns {UploadService} .
|
|
||||||
*/
|
|
||||||
UploadService = (function () {
|
|
||||||
function UploadService(options) {
|
|
||||||
this.options = options;
|
|
||||||
this._method = 'POST';
|
|
||||||
this._authTokenPrefix = 'Basic';
|
|
||||||
this._authToken = undefined;
|
|
||||||
this._fieldName = 'file';
|
|
||||||
this._formFields = {};
|
|
||||||
this._queue = [];
|
|
||||||
console.log('UploadService constructor');
|
|
||||||
this._withCredentials = options.withCredentials != null ? options.withCredentials : this._withCredentials;
|
|
||||||
this._url = options.url != null ? options.url : this._url;
|
|
||||||
this._authTokenPrefix = options.authTokenPrefix != null ? options.authTokenPrefix : this._authTokenPrefix;
|
|
||||||
this._authToken = options.authToken != null ? options.authToken : this._authToken;
|
|
||||||
this._fieldName = options.fieldName != null ? options.fieldName : this._fieldName;
|
|
||||||
this._formFields = options.formFields != null ? options.formFields : this._formFields;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Add files to the uploading queue to be uploaded.
|
|
||||||
*
|
|
||||||
* @param {File[]} - files to add to the upload queue.
|
|
||||||
*
|
|
||||||
* return {FileModel[]} - return the file added to the queue in this call.
|
|
||||||
*/
|
|
||||||
UploadService.prototype.addToQueue = function (files) {
|
|
||||||
var latestFilesAdded = [];
|
|
||||||
for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
|
|
||||||
var file = files_1[_i];
|
|
||||||
if (this._isFile(file)) {
|
|
||||||
var uploadingFileModel = new file_model_1.FileModel(file);
|
|
||||||
latestFilesAdded.push(uploadingFileModel);
|
|
||||||
this._queue.push(uploadingFileModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return latestFilesAdded;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Pick all the files in the queue that are not been uploaded yet and upload it into the directory folder.
|
|
||||||
*/
|
|
||||||
UploadService.prototype.uploadFilesInTheQueue = function (directory) {
|
|
||||||
var _this = this;
|
|
||||||
var filesToUpload = this._queue.filter(function (uploadingFileModel) {
|
|
||||||
return !uploadingFileModel.uploading && !uploadingFileModel.done && !uploadingFileModel.abort && !uploadingFileModel.error;
|
|
||||||
});
|
|
||||||
filesToUpload.forEach(function (uploadingFileModel) {
|
|
||||||
uploadingFileModel.setUploading();
|
|
||||||
_this.uploadFile(uploadingFileModel, directory);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
;
|
|
||||||
/**
|
|
||||||
* The method create a new XMLHttpRequest instance if doesn't exist
|
|
||||||
*/
|
|
||||||
UploadService.prototype._configureXMLHttpRequest = function (uploadingFileModel) {
|
|
||||||
var _this = this;
|
|
||||||
if (this._xmlHttpRequest == undefined) {
|
|
||||||
this._xmlHttpRequest = new XMLHttpRequest();
|
|
||||||
this._xmlHttpRequest.upload.onprogress = function (e) {
|
|
||||||
if (e.lengthComputable) {
|
|
||||||
var percent = Math.round(e.loaded / e.total * 100);
|
|
||||||
uploadingFileModel.setProgres({
|
|
||||||
total: e.total,
|
|
||||||
loaded: e.loaded,
|
|
||||||
percent: percent
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
this._xmlHttpRequest.upload.onabort = function (e) {
|
|
||||||
uploadingFileModel.setAbort();
|
|
||||||
};
|
|
||||||
this._xmlHttpRequest.upload.onerror = function (e) {
|
|
||||||
uploadingFileModel.setError();
|
|
||||||
};
|
|
||||||
this._xmlHttpRequest.onreadystatechange = function () {
|
|
||||||
if (_this._xmlHttpRequest.readyState === XMLHttpRequest.DONE) {
|
|
||||||
uploadingFileModel.onFinished(_this._xmlHttpRequest.status, _this._xmlHttpRequest.statusText, _this._xmlHttpRequest.response);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Upload a file into the directory folder, and enrich it with the xhr.
|
|
||||||
*
|
|
||||||
* @param {FileModel} - files to be uploaded.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
UploadService.prototype.uploadFile = function (uploadingFileModel, directory) {
|
|
||||||
var _this = this;
|
|
||||||
var form = new FormData();
|
|
||||||
form.append(this._fieldName, uploadingFileModel.file, uploadingFileModel.name);
|
|
||||||
Object.keys(this._formFields).forEach(function (key) {
|
|
||||||
form.append(key, _this._formFields[key]);
|
|
||||||
});
|
|
||||||
form.append('uploaddirectory', directory);
|
|
||||||
this._configureXMLHttpRequest(uploadingFileModel);
|
|
||||||
uploadingFileModel.setXMLHttpRequest(this._xmlHttpRequest);
|
|
||||||
this._xmlHttpRequest.open(this._method, this._url, true);
|
|
||||||
this._xmlHttpRequest.withCredentials = this._withCredentials;
|
|
||||||
if (this._authToken) {
|
|
||||||
this._xmlHttpRequest.setRequestHeader('Authorization', this._authTokenPrefix + " " + this._authToken);
|
|
||||||
}
|
|
||||||
this._xmlHttpRequest.send(form);
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Return all the files in the uploading queue.
|
|
||||||
*
|
|
||||||
* @return {FileModel[]} - files in the upload queue.
|
|
||||||
*/
|
|
||||||
UploadService.prototype.getQueue = function () {
|
|
||||||
return this._queue;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Check if an item is a file.
|
|
||||||
*
|
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
UploadService.prototype._isFile = function (file) {
|
|
||||||
return file !== null && (file instanceof Blob || (file.name && file.size));
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Set XMLHttpRequest method
|
|
||||||
* @param xhr
|
|
||||||
*/
|
|
||||||
UploadService.prototype.setXMLHttpRequest = function (xhr) {
|
|
||||||
this._xmlHttpRequest = xhr;
|
|
||||||
};
|
|
||||||
return UploadService;
|
|
||||||
}());
|
|
||||||
exports_1("UploadService", UploadService);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=upload.service.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"upload.service.js","sourceRoot":"","sources":["upload.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;YAMH;;;;;eAKG;YACH;gBAYI,uBAAoB,OAAY;oBAAZ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
*/
|
||||||
uploadFile(uploadingFileModel: any, directory: string): void {
|
uploadFile(uploadingFileModel: FileModel, directory?: string): void {
|
||||||
let form = new FormData();
|
let form = new FormData();
|
||||||
form.append(this._fieldName, uploadingFileModel.file, uploadingFileModel.name);
|
form.append(this._fieldName, uploadingFileModel.file, uploadingFileModel.name);
|
||||||
Object.keys(this._formFields).forEach((key: any) => {
|
Object.keys(this._formFields).forEach((key: any) => {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*!
|
||||||
* @license
|
* @license
|
||||||
* Copyright 2016 Alfresco Software, Ltd.
|
* Copyright 2016 Alfresco Software, Ltd.
|
||||||
*
|
*
|
||||||
@ -15,20 +15,20 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Observable} from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import {provide, EventEmitter} from 'angular2/core';
|
import { EventEmitter } from 'angular2/core';
|
||||||
import {LangChangeEvent} from 'ng2-translate/ng2-translate';
|
import { LangChangeEvent } from 'ng2-translate/ng2-translate';
|
||||||
|
|
||||||
|
|
||||||
export class TranslationMock {
|
export class TranslationMock {
|
||||||
|
|
||||||
public onLangChange: EventEmitter<LangChangeEvent> = new EventEmitter<LangChangeEvent>();
|
public onLangChange: EventEmitter<LangChangeEvent> = new EventEmitter<LangChangeEvent>();
|
||||||
|
|
||||||
setDefaultLang() {
|
setDefaultLang() {
|
||||||
|
console.log('mock');
|
||||||
}
|
}
|
||||||
|
|
||||||
use() {
|
use() {
|
||||||
|
console.log('mock');
|
||||||
}
|
}
|
||||||
|
|
||||||
public get(key: string|Array<string>, interpolateParams?: Object): Observable<string|any> {
|
public get(key: string|Array<string>, interpolateParams?: Object): Observable<string|any> {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*!
|
||||||
* @license
|
* @license
|
||||||
* Copyright 2016 Alfresco Software, Ltd.
|
* Copyright 2016 Alfresco Software, Ltd.
|
||||||
*
|
*
|
||||||
@ -16,15 +16,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
import {TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS} from 'angular2/platform/testing/browser';
|
import { it, describe, expect, injectAsync, TestComponentBuilder } from 'angular2/testing';
|
||||||
import {it, describe, expect, injectAsync, TestComponentBuilder, setBaseTestProviders} from 'angular2/testing';
|
import { FileUploadingDialogComponent } from '../../src/components/file-uploading-dialog.component';
|
||||||
import {Component} from 'angular2/core';
|
|
||||||
import {FileUploadingDialogComponent} from '../../../src/components/file-uploading-dialog.component';
|
|
||||||
|
|
||||||
describe('FileUploadDialog', () => {
|
describe('FileUploadDialog', () => {
|
||||||
|
|
||||||
//setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS);
|
|
||||||
|
|
||||||
it('should render dialog box with css class show', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
it('should render dialog box with css class show', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||||
return tcb
|
return tcb
|
||||||
.createAsync(FileUploadingDialogComponent)
|
.createAsync(FileUploadingDialogComponent)
|
||||||
|
@ -19,84 +19,88 @@
|
|||||||
import { TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS } from 'angular2/platform/testing/browser';
|
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 { it, describe, expect, injectAsync, beforeEachProviders, TestComponentBuilder, setBaseTestProviders } from 'angular2/testing';
|
||||||
import { provide } from 'angular2/core';
|
import { provide } from 'angular2/core';
|
||||||
import { UploadButtonComponent } from '../../../src/components/upload-button.component';
|
|
||||||
import { TranslateService } from 'ng2-translate/ng2-translate';
|
import { TranslateService } from 'ng2-translate/ng2-translate';
|
||||||
import { TranslationMock } from '../assets/translation.service.mock';
|
import { TranslationMock } from '../assets/translation.service.mock';
|
||||||
|
import { UploadButtonComponent } from '../../src/components/upload-button.component';
|
||||||
|
|
||||||
describe('AlfrescoUploadButton', () => {
|
describe('AlfrescoUploadButton', () => {
|
||||||
|
|
||||||
setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS);
|
setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS);
|
||||||
|
|
||||||
beforeEachProviders(() => {
|
beforeEachProviders(() => {
|
||||||
return [
|
return [
|
||||||
provide(TranslateService, {useClass: TranslationMock})
|
provide(TranslateService, {useClass: TranslationMock})
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render upload-single-file button as default', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
it('should render upload-single-file button as default',
|
||||||
return tcb
|
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||||
.createAsync(UploadButtonComponent)
|
return tcb
|
||||||
.then((fixture) => {
|
.createAsync(UploadButtonComponent)
|
||||||
let compiled = fixture.debugElement.nativeElement;
|
.then((fixture) => {
|
||||||
fixture.detectChanges();
|
let compiled = fixture.debugElement.nativeElement;
|
||||||
expect(compiled.querySelector('#upload-single-file')).toBeDefined();
|
fixture.detectChanges();
|
||||||
});
|
expect(compiled.querySelector('#upload-single-file')).toBeDefined();
|
||||||
}));
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
it('should render upload-multiple-file button if multipleFiles=true', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
it('should render upload-multiple-file button if multipleFiles=true',
|
||||||
return tcb
|
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||||
.createAsync(UploadButtonComponent)
|
return tcb
|
||||||
.then((fixture) => {
|
.createAsync(UploadButtonComponent)
|
||||||
let component = fixture.componentInstance;
|
.then((fixture) => {
|
||||||
component.multipleFiles = true;
|
let component = fixture.componentInstance;
|
||||||
let compiled = fixture.debugElement.nativeElement;
|
component.multipleFiles = true;
|
||||||
fixture.detectChanges();
|
let compiled = fixture.debugElement.nativeElement;
|
||||||
expect(compiled.querySelector('#upload-multiple-files')).toBeDefined();
|
fixture.detectChanges();
|
||||||
});
|
expect(compiled.querySelector('#upload-multiple-files')).toBeDefined();
|
||||||
}));
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
it('should render an uploadFolder button if uploadFolder is true', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
it('should render an uploadFolder button if uploadFolder is true',
|
||||||
return tcb
|
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||||
.createAsync(UploadButtonComponent)
|
return tcb
|
||||||
.then((fixture) => {
|
.createAsync(UploadButtonComponent)
|
||||||
let component = fixture.componentInstance;
|
.then((fixture) => {
|
||||||
component.uploadFolder = true;
|
let component = fixture.componentInstance;
|
||||||
let compiled = fixture.debugElement.nativeElement;
|
component.uploadFolder = true;
|
||||||
fixture.detectChanges();
|
let compiled = fixture.debugElement.nativeElement;
|
||||||
expect(compiled.querySelector('#uploadFolder')).toBeDefined();
|
fixture.detectChanges();
|
||||||
});
|
expect(compiled.querySelector('#uploadFolder')).toBeDefined();
|
||||||
}));
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
it('should call onFilesAdded method', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
it('should call onFilesAdded method', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||||
return tcb
|
return tcb
|
||||||
.createAsync(UploadButtonComponent)
|
.createAsync(UploadButtonComponent)
|
||||||
.then((fixture) => {
|
.then((fixture) => {
|
||||||
let component = fixture.componentInstance;
|
let component = fixture.componentInstance;
|
||||||
component.onFilesAdded = jasmine.createSpy('onFilesAdded');
|
component.onFilesAdded = jasmine.createSpy('onFilesAdded');
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
let fakeEvent = {
|
let fakeEvent = {
|
||||||
currentTarget: {files: [{name: 'fake-name', size: 10}]}
|
currentTarget: {files: [{name: 'fake-name', size: 10}]}
|
||||||
};
|
};
|
||||||
|
|
||||||
component.onFilesAdded(fakeEvent);
|
component.onFilesAdded(fakeEvent);
|
||||||
expect(component.onFilesAdded).toHaveBeenCalledWith(fakeEvent);
|
expect(component.onFilesAdded).toHaveBeenCalledWith(fakeEvent);
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should render dialog box with css class show ', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
it('should render dialog box with css class show ',
|
||||||
return tcb
|
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||||
.createAsync(UploadButtonComponent)
|
return tcb
|
||||||
.then((fixture) => {
|
.createAsync(UploadButtonComponent)
|
||||||
let component = fixture.componentInstance;
|
.then((fixture) => {
|
||||||
fixture.detectChanges();
|
let component = fixture.componentInstance;
|
||||||
let compiled = fixture.debugElement.nativeElement;
|
fixture.detectChanges();
|
||||||
|
let compiled = fixture.debugElement.nativeElement;
|
||||||
|
|
||||||
component._showDialog();
|
component._showDialog();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(compiled.querySelector('.file-dialog').getAttribute('class')).toEqual('file-dialog show');
|
expect(compiled.querySelector('.file-dialog').getAttribute('class')).toEqual('file-dialog show');
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -22,116 +22,116 @@ import { FileModel } from '../../src/models/file.model';
|
|||||||
declare let jasmine: any;
|
declare let jasmine: any;
|
||||||
|
|
||||||
describe('AlfrescoUploadService', () => {
|
describe('AlfrescoUploadService', () => {
|
||||||
let service: UploadService,
|
let service: UploadService,
|
||||||
options: any,
|
options: any,
|
||||||
xhr: XMLHttpRequest,
|
xhr: XMLHttpRequest,
|
||||||
doneFn: any,
|
doneFn: any,
|
||||||
errorFn: any;
|
errorFn: any;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jasmine.Ajax.install();
|
jasmine.Ajax.install();
|
||||||
|
|
||||||
doneFn = jasmine.createSpy('success');
|
doneFn = jasmine.createSpy('success');
|
||||||
errorFn = jasmine.createSpy('error');
|
errorFn = jasmine.createSpy('error');
|
||||||
xhr = new XMLHttpRequest();
|
xhr = new XMLHttpRequest();
|
||||||
xhr.onreadystatechange = function () {
|
xhr.onreadystatechange = function () {
|
||||||
if (this.readyState === this.DONE && this.status === 200) {
|
if (this.readyState === this.DONE && this.status === 200) {
|
||||||
doneFn(this.responseText);
|
doneFn(this.responseText);
|
||||||
} else if (this.readyState === this.DONE && this.status === 404) {
|
} else if (this.readyState === this.DONE && this.status === 404) {
|
||||||
errorFn(this.responseText);
|
errorFn(this.responseText);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
xhr.abort = jasmine.createSpy('abort');
|
xhr.abort = jasmine.createSpy('abort');
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
url: '/some/cool/url',
|
url: '/some/cool/url',
|
||||||
withCredentials: true,
|
withCredentials: true,
|
||||||
authToken: btoa('fakeadmin:fakeadmin'),
|
authToken: btoa('fakeadmin:fakeadmin'),
|
||||||
authTokenPrefix: 'Basic',
|
authTokenPrefix: 'Basic',
|
||||||
fieldName: 'fakeFileData',
|
fieldName: 'fakeFileData',
|
||||||
formFields: {
|
formFields: {
|
||||||
siteid: 'fakeSite',
|
siteid: 'fakeSite',
|
||||||
containerid: 'fakeFolder'
|
containerid: 'fakeFolder'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
service = new UploadService(options);
|
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');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should make XHR error request after an error occur', () => {
|
afterEach(() => {
|
||||||
service.setXMLHttpRequest(xhr);
|
jasmine.Ajax.uninstall();
|
||||||
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', () => {
|
it('should return an empty queue if no elements are added', () => {
|
||||||
service.setXMLHttpRequest(xhr);
|
expect(service.getQueue().length).toEqual(0);
|
||||||
let filesFake = [{name: 'fake-name', size: 10}];
|
});
|
||||||
service.addToQueue(filesFake);
|
|
||||||
service.uploadFilesInTheQueue('');
|
it('should add an element in the queue and returns it', () => {
|
||||||
let file = service.getQueue();
|
let filesFake = [{name: 'fake-name', size: 10}];
|
||||||
file[0].setAbort();
|
service.addToQueue(filesFake);
|
||||||
expect(xhr.abort).toHaveBeenCalled();
|
expect(service.getQueue().length).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should make XHR done request after the file is upload', () => {
|
it('should add two elements in the queue and returns them', () => {
|
||||||
service.setXMLHttpRequest(xhr);
|
let filesFake = [{name: 'fake-name', size: 10}, {name: 'fake-name2', size: 20}];
|
||||||
let filesFake = {name: 'fake-name', size: 10};
|
service.addToQueue(filesFake);
|
||||||
|
expect(service.getQueue().length).toEqual(2);
|
||||||
let uploadingFileModel = new FileModel(filesFake);
|
});
|
||||||
service.uploadFile(uploadingFileModel);
|
|
||||||
|
it('should make XHR done request after the file is added in the queue', () => {
|
||||||
expect(jasmine.Ajax.requests.mostRecent().url).toBe('/some/cool/url');
|
service.setXMLHttpRequest(xhr);
|
||||||
expect(doneFn).not.toHaveBeenCalled();
|
let filesFake = [{name: 'fake-name', size: 10}];
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
service.addToQueue(filesFake);
|
||||||
'status': 200,
|
service.uploadFilesInTheQueue('');
|
||||||
contentType: 'text/plain',
|
expect(jasmine.Ajax.requests.mostRecent().url).toBe('/some/cool/url');
|
||||||
responseText: 'File uploaded'
|
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');
|
||||||
});
|
});
|
||||||
expect(doneFn).toHaveBeenCalledWith('File uploaded');
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
"align": [
|
"align": [
|
||||||
true,
|
true,
|
||||||
"parameters",
|
"parameters",
|
||||||
"arguments",
|
|
||||||
"statements"
|
"statements"
|
||||||
],
|
],
|
||||||
"ban": false,
|
"ban": false,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user