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",
|
||||
"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"
|
||||
"name": "ng2-alfresco-documentlist",
|
||||
"description": "Alfresco Angular2 Document List 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"
|
||||
}
|
||||
],
|
||||
"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
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
@ -1,78 +1,78 @@
|
||||
{
|
||||
"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"
|
||||
"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\" "
|
||||
},
|
||||
{
|
||||
"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/**/*"
|
||||
"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"
|
||||
}
|
||||
],
|
||||
"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",
|
||||
"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
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
@ -1,75 +1,75 @@
|
||||
{
|
||||
"name": "ng2-alfresco-upload",
|
||||
"description": "Alfresco Angular2 Upload 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/ ",
|
||||
"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": "Mario Romano",
|
||||
"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/**/*"
|
||||
"name": "ng2-alfresco-upload",
|
||||
"description": "Alfresco Angular2 Upload 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/ ",
|
||||
"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": "Mario Romano",
|
||||
"email": "mario.romano83@gmail.com"
|
||||
}
|
||||
],
|
||||
"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",
|
||||
"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} .
|
||||
*/
|
||||
@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'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
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'
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the upload dialog.
|
||||
*/
|
||||
private _showDialog(): void {
|
||||
this.fileUploadingDialogComponent.showDialog();
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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,YAAO,GAAP,OAAO,CAAK;oBAVxB,YAAO,GAAW,MAAM,CAAC;oBACzB,qBAAgB,GAAW,OAA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E1C,IAAI,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,CAAC;oBAClD,kBAAkB,CAAC,iBAAiB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;oBAE3D,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;oBACzD,IAAI,CAAC,eAAe,CAAC,eAAe,GAAG,IAAI,CAAC,gBAAgB,CAAC;oBAE7D,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;wBAClB,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC,eAAe,EAAK,IAAI,CAAC,gBAAgB,SAAI,IAAI,CAAC,UAAY,CAAC,CAAC;oBAC1G,CAAC;oBAED,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACpC,CAAC;gBAED;;;;mBAIG;gBACH,gCAAQ,GAAR;oBACI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;gBACvB,CAAC;gBAED;;;;mBAIG;gBACK,+BAAO,GAAf,UAAgB,IAAS;oBACrB,MAAM,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,IAAI,YAAY,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC/E,CAAC;gBAED;;;mBAGG;gBACI,yCAAiB,GAAxB,UAAyB,GAAmB;oBACxC,IAAI,CAAC,eAAe,GAAG,GAAG,CAAC;gBAC/B,CAAC;gBACL,oBAAC;YAAD,CAAC,AAlJD,IAkJC;YAlJD,yCAkJC,CAAA"}
|
@ -124,7 +124,7 @@ export class UploadService {
|
||||
* @param {FileModel} - files to be uploaded.
|
||||
*
|
||||
*/
|
||||
uploadFile(uploadingFileModel: any, directory: string): void {
|
||||
uploadFile(uploadingFileModel: FileModel, directory?: string): void {
|
||||
let form = new FormData();
|
||||
form.append(this._fieldName, uploadingFileModel.file, uploadingFileModel.name);
|
||||
Object.keys(this._formFields).forEach((key: any) => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
@ -15,20 +15,20 @@
|
||||
* 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 {
|
||||
|
||||
public onLangChange: EventEmitter<LangChangeEvent> = new EventEmitter<LangChangeEvent>();
|
||||
|
||||
setDefaultLang() {
|
||||
|
||||
console.log('mock');
|
||||
}
|
||||
|
||||
use() {
|
||||
console.log('mock');
|
||||
}
|
||||
|
||||
public get(key: string|Array<string>, interpolateParams?: Object): Observable<string|any> {
|
||||
@ -37,4 +37,4 @@ export class TranslationMock {
|
||||
}
|
||||
return Observable.of(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*!
|
||||
* @license
|
||||
* 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, setBaseTestProviders} from 'angular2/testing';
|
||||
import {Component} from 'angular2/core';
|
||||
import {FileUploadingDialogComponent} from '../../../src/components/file-uploading-dialog.component';
|
||||
import { it, describe, expect, injectAsync, TestComponentBuilder } from 'angular2/testing';
|
||||
import { FileUploadingDialogComponent } from '../../src/components/file-uploading-dialog.component';
|
||||
|
||||
describe('FileUploadDialog', () => {
|
||||
|
||||
//setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS);
|
||||
|
||||
it('should render dialog box with css class show', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(FileUploadingDialogComponent)
|
||||
|
@ -19,84 +19,88 @@
|
||||
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';
|
||||
import { UploadButtonComponent } from '../../src/components/upload-button.component';
|
||||
|
||||
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=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');
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
|
@ -22,116 +22,116 @@ import { FileModel } from '../../src/models/file.model';
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('AlfrescoUploadService', () => {
|
||||
let service: UploadService,
|
||||
options: any,
|
||||
xhr: XMLHttpRequest,
|
||||
doneFn: any,
|
||||
errorFn: any;
|
||||
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);
|
||||
});
|
||||
|
||||
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'
|
||||
options = {
|
||||
url: '/some/cool/url',
|
||||
withCredentials: true,
|
||||
authToken: btoa('fakeadmin:fakeadmin'),
|
||||
authTokenPrefix: 'Basic',
|
||||
fieldName: 'fakeFileData',
|
||||
formFields: {
|
||||
siteid: 'fakeSite',
|
||||
containerid: 'fakeFolder'
|
||||
}
|
||||
};
|
||||
service = new UploadService(options);
|
||||
});
|
||||
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'
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
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'
|
||||
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');
|
||||
});
|
||||
expect(doneFn).toHaveBeenCalledWith('File uploaded');
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -3,7 +3,6 @@
|
||||
"align": [
|
||||
true,
|
||||
"parameters",
|
||||
"arguments",
|
||||
"statements"
|
||||
],
|
||||
"ban": false,
|
||||
|
Loading…
x
Reference in New Issue
Block a user