#46 upload component

This commit is contained in:
Mario Romano
2016-05-05 18:23:38 +01:00
parent 5b6cd9c927
commit f6cfef905b
75 changed files with 2413 additions and 302 deletions

View File

@@ -0,0 +1,115 @@
.file-dialog {
display: none;
-webkit-box-shadow: 0 2px 8px 0 rgba(0, 0, 0, .2);
box-shadow: 0 2px 8px 0 rgba(0, 0, 0, .2);
-webkit-border-radius: 2px;
border-radius: 2px;
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
-webkit-transition-delay: 0s;
transition-delay: 0s;
opacity: 1;
-webkit-transition: transform .15s cubic-bezier(0.4, 0.0, 1, 1), opacity .15s cubic-bezier(0.4, 0.0, 1, 1), visibility 0ms linear .15s;
transition: transform .15s cubic-bezier(0.4, 0.0, 1, 1), opacity .15s cubic-bezier(0.4, 0.0, 1, 1), visibility 0ms linear .15s;
bottom: 0px;
left: auto;
max-height: 350px;
overflow: visible;
right: 24px;
position: absolute;
}
.file-dialog .header {
width: 900px;
background-color: #0c79bf;
border: 1px transparent solid;
-moz-border-radius-topleft: 2px;
-webkit-border-top-left-radius: 2px;
border-top-left-radius: 2px;
-moz-border-radius-topright: 2px;
-webkit-border-top-right-radius: 2px;
border-top-right-radius: 2px;
bottom: 0px;
color: white;
font-size: 14px;
height: 52px;
line-height: 52px;
padding: 0px 10px 0px 10px;
}
.file-dialog .header .title {
float: left;
min-width: 200px;
color: white;
}
.file-dialog .header .buttons {
float: right;
padding: 10px 10px 10px 10px;
text-align: center;
color: white;
font-size: 14px;
opacity: 0.5;
}
.file-dialog .header .close-button {
cursor: pointer;
float: left;
height: 35px;
width: 35px;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
border: 1px solid transparent;
}
.file-dialog .header .close-button:hover {
border: 1px solid white;
opacity: 1.0;
}
.file-dialog .header .minimize-button {
cursor: pointer;
float: left;
height: 35px;
width: 35px;
margin-right: 10px;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
border: 1px solid transparent;
}
.up {
display: none;
}
.down {
display: block;
}
.active .up {
display: block;
}
.active .down {
display: none;
}
.file-dialog .header .minimize-button:hover {
border: 1px solid white;
opacity: 1.0;
}
.file-dialog .body-dialog {
float: left;
height: 100%;
width: 100%;
margin-top: -4px;
border-bottom: 1px solid #C0C0C0;
border-right: 1px solid #C0C0C0;
border-left: 1px solid #C0C0C0;
max-height: 200px;
overflow-y: auto;
}

View File

@@ -0,0 +1,28 @@
/**
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ElementRef } from 'angular2/core';
import { FileModel } from '../models/file.model';
export declare class FileUploadingDialogComponent {
el: ElementRef;
filesUploadingList: FileModel[];
_isDialogActive: boolean;
_isDialogMinimized: boolean;
constructor(el: ElementRef);
toggleDialog($event: any): void;
showDialog(): void;
toggleDialogMinimize($event: any): void;
}

View File

@@ -0,0 +1,20 @@
<div class="file-dialog" [ngClass]="{show: _isDialogActive}">
<div class="header">
<div class="title">
{{filesUploadingList.length}} uploads complete
</div>
<div class="buttons">
<div class="minimize-button" [ngClass]="{active: _isDialogMinimized}" (click)="toggleDialogMinimize($event)">
<i class="material-icons down">keyboard_arrow_down</i>
<i class="material-icons up">keyboard_arrow_up</i>
</div>
<div class="close-button" (click)="toggleDialog($event)">
<i class="material-icons">clear</i>
</div>
</div>
</div>
<div class="body-dialog" [ngClass]="{hide: _isDialogMinimized}">
<alfresco-file-uploading-list [filesUploadingList]="filesUploadingList"></alfresco-file-uploading-list>
</div>
</div>

View File

@@ -0,0 +1,77 @@
/**
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
System.register(['angular2/core', './file-uploading-list.component'], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1, file_uploading_list_component_1;
var FileUploadingDialogComponent;
return {
setters:[
function (core_1_1) {
core_1 = core_1_1;
},
function (file_uploading_list_component_1_1) {
file_uploading_list_component_1 = file_uploading_list_component_1_1;
}],
execute: function() {
FileUploadingDialogComponent = (function () {
function FileUploadingDialogComponent(el) {
this.el = el;
this._isDialogActive = false;
this._isDialogMinimized = false;
console.log('FileUploadingDialogComponent constructor', el);
}
FileUploadingDialogComponent.prototype.toggleDialog = function ($event) {
this._isDialogActive = !this._isDialogActive;
};
FileUploadingDialogComponent.prototype.showDialog = function () {
this._isDialogActive = true;
};
FileUploadingDialogComponent.prototype.toggleDialogMinimize = function ($event) {
this._isDialogMinimized = !this._isDialogMinimized;
};
__decorate([
core_1.Input(),
__metadata('design:type', Array)
], FileUploadingDialogComponent.prototype, "filesUploadingList", void 0);
FileUploadingDialogComponent = __decorate([
core_1.Component({
selector: 'file-uploading-dialog',
moduleId: __moduleName,
directives: [file_uploading_list_component_1.FileUploadingListComponent],
templateUrl: './file-uploading-dialog.component.html',
styleUrls: ['./file-uploading-dialog.component.css'],
host: { '[class.dialog-show]': 'toggleDialog' }
}),
__metadata('design:paramtypes', [core_1.ElementRef])
], FileUploadingDialogComponent);
return FileUploadingDialogComponent;
}());
exports_1("FileUploadingDialogComponent", FileUploadingDialogComponent);
}
}
});
//# sourceMappingURL=file-uploading-dialog.component.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"file-uploading-dialog.component.js","sourceRoot":"","sources":["file-uploading-dialog.component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;YAiBH;gBASI,sCAAmB,EAAa;oBAAb,OAAE,GAAF,EAAE,CAAW;oBAJhC,oBAAe,GAAW,KAAK,CAAC;oBAEhC,uBAAkB,GAAW,KAAK,CAAC;oBAG/B,OAAO,CAAC,GAAG,CAAC,0CAA0C,EAAE,EAAE,CAAC,CAAC;gBAChE,CAAC;gBAED,mDAAY,GAAZ,UAAa,MAAM;oBACf,IAAI,CAAC,eAAe,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC;gBACjD,CAAC;gBAED,iDAAU,GAAV;oBACI,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;gBAChC,CAAC;gBAED,2DAAoB,GAApB,UAAqB,MAAM;oBACvB,IAAI,CAAC,kBAAkB,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC;gBACvD,CAAC;gBArBD;oBAAC,YAAK,EAAE;;wFAAA;gBAVZ;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,uBAAuB;wBACjC,QAAQ,EAAE,YAAY;wBACtB,UAAU,EAAE,CAAC,0DAA0B,CAAC;wBACxC,WAAW,EAAE,wCAAwC;wBACrD,SAAS,EAAE,CAAC,uCAAuC,CAAC;wBACpD,IAAI,EAAE,EAAC,qBAAqB,EAAE,cAAc,EAAC;qBAChD,CAAC;;gDAAA;gBAyBF,mCAAC;YAAD,CAAC,AAxBD,IAwBC;YAxBD,uEAwBC,CAAA"}

View File

@@ -0,0 +1,57 @@
/**
* @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 {Component, ElementRef, Input} from 'angular2/core';
import {FileModel} from '../models/file.model';
import {FileUploadingListComponent} from './file-uploading-list.component';
declare let __moduleName:string;
@Component({
selector: 'file-uploading-dialog',
moduleId: __moduleName,
directives: [FileUploadingListComponent],
templateUrl: './file-uploading-dialog.component.html',
styleUrls: ['./file-uploading-dialog.component.css'],
host: {'[class.dialog-show]': 'toggleDialog'}
})
export class FileUploadingDialogComponent {
@Input()
filesUploadingList:FileModel [];
_isDialogActive:boolean = false;
_isDialogMinimized:boolean = false;
constructor(public el:ElementRef) {
console.log('FileUploadingDialogComponent constructor', el);
}
toggleDialog($event) {
this._isDialogActive = !this._isDialogActive;
}
showDialog() {
this._isDialogActive = true;
}
toggleDialogMinimize($event) {
this._isDialogMinimized = !this._isDialogMinimized;
}
}

View File

@@ -0,0 +1,8 @@
.mdl-data-table {
width: 100%;
border: 0px;
}
.cursor {
cursor: pointer;
}

View File

@@ -0,0 +1,24 @@
/**
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ElementRef } from 'angular2/core';
import { FileModel } from '../models/file.model';
export declare class FileUploadingListComponent {
el: ElementRef;
filesUploadingList: FileModel[];
constructor(el: ElementRef);
abort(id: any): void;
}

View File

@@ -0,0 +1,22 @@
<table class="mdl-data-table mdl-js-data-table mdl-shadow--2dp">
<tbody>
<tr *ngFor="#file of filesUploadingList">
<td class="mdl-data-table__cell--non-numeric">{{file.name}}</td>
<td _ngcontent-hvq-3="">
<div _ngcontent-hvq-3="" class="mdl-progress mdl-js-progress is-upgraded" id="{{file.id}}"
data-upgraded=",MaterialProgress">
<div class="progressbar bar bar1" style="width: {{file.progress.percent}}%;"></div>
<div class="bufferbar bar bar2" style="width: 100%;"></div>
<div class="auxbar bar bar3" style="width: 0%;"></div>
</div>
</td>
<td class="mdl-data-table__cell--non-numeric">{{file.size}}</td>
<td>
<span *ngIf="file.done && !file.abort"><i class="material-icons">done</i></span>
<span *ngIf="file.uploading" (click)="abort(file.id)" class="cursor" ><i class="material-icons">play_arrow</i></span>
<span *ngIf="file.abort"><i class="material-icons">remove_circle</i></span>
<span *ngIf="!file.abort && !file.uploading && !file.done"><i class="material-icons">pause</i></span>
</td>
</tr>
</tbody>
</table>

View File

@@ -0,0 +1,70 @@
/**
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
System.register(['angular2/core'], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1;
var FileUploadingListComponent;
return {
setters:[
function (core_1_1) {
core_1 = core_1_1;
}],
execute: function() {
FileUploadingListComponent = (function () {
function FileUploadingListComponent(el) {
this.el = el;
console.log('filesUploadingList constructor', el);
setInterval(function () {
console.log('Check for async update from drag directive');
}, 1000);
}
FileUploadingListComponent.prototype.abort = function (id) {
var file = this.filesUploadingList.filter(function (uploadingFileModel) {
return uploadingFileModel.id == id;
});
file[0].setAbort();
};
__decorate([
core_1.Input(),
__metadata('design:type', Array)
], FileUploadingListComponent.prototype, "filesUploadingList", void 0);
FileUploadingListComponent = __decorate([
core_1.Component({
selector: 'alfresco-file-uploading-list',
moduleId: __moduleName,
templateUrl: './file-uploading-list.component.html',
styleUrls: ['./file-uploading-list.component.css']
}),
__metadata('design:paramtypes', [core_1.ElementRef])
], FileUploadingListComponent);
return FileUploadingListComponent;
}());
exports_1("FileUploadingListComponent", FileUploadingListComponent);
}
}
});
//# sourceMappingURL=file-uploading-list.component.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"file-uploading-list.component.js","sourceRoot":"","sources":["file-uploading-list.component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;YAcH;gBAKI,oCAAmB,EAAa;oBAAb,OAAE,GAAF,EAAE,CAAW;oBAC5B,OAAO,CAAC,GAAG,CAAC,gCAAgC,EAAE,EAAE,CAAC,CAAC;oBAElD,WAAW,CAAC;wBACR,OAAO,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC;oBAC9D,CAAC,EAAE,IAAI,CAAC,CAAC;gBACb,CAAC;gBAED,0CAAK,GAAL,UAAM,EAAE;oBACJ,IAAI,IAAI,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,UAAC,kBAAkB;wBACzD,MAAM,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,CAAC;oBACvC,CAAC,CAAC,CAAC;oBACH,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;gBACvB,CAAC;gBAhBD;oBAAC,YAAK,EAAE;;sFAAA;gBARZ;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,8BAA8B;wBACxC,QAAQ,EAAE,YAAY;wBACtB,WAAW,EAAE,sCAAsC;wBACnD,SAAS,EAAE,CAAC,qCAAqC,CAAC;qBACrD,CAAC;;8CAAA;gBAoBF,iCAAC;YAAD,CAAC,AAnBD,IAmBC;YAnBD,mEAmBC,CAAA"}

View File

@@ -0,0 +1,49 @@
/**
* @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 {Component, ElementRef, Input} from 'angular2/core';
import {FileModel} from '../models/file.model';
declare let __moduleName:string;
@Component({
selector: 'alfresco-file-uploading-list',
moduleId: __moduleName,
templateUrl: './file-uploading-list.component.html',
styleUrls: ['./file-uploading-list.component.css']
})
export class FileUploadingListComponent {
@Input()
filesUploadingList:FileModel [];
constructor(public el:ElementRef) {
console.log('filesUploadingList constructor', el);
setInterval(() => {
console.log('Check for async update from drag directive');
}, 1000);
}
abort(id):void {
let file = this.filesUploadingList.filter((uploadingFileModel) => {
return uploadingFileModel.id == id;
});
file[0].setAbort();
}
}

View File

@@ -0,0 +1,35 @@
.mdl-button--file input {
cursor: pointer;
height: 100%;
right: 0;
opacity: 0;
position: absolute;
top: 0;
width: 300px;
z-index: 4;
}
.mdl-textfield--file .mdl-textfield__input {
box-sizing: border-box;
width: calc(100% - 32px);
}
.mdl-textfield--file .mdl-button--file {
right: 0;
}
.upload-border {
vertical-align: middle;
color: #555;
padding: 20px;
max-height: 300px;
overflow-y: auto;
display: inline-block;
border: 3px dashed #555;
text-align: center;
}
.input-focus {
color: #2196F3;
border: 3px dashed #2196F3;
}

View File

@@ -0,0 +1,31 @@
/**
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ElementRef } from 'angular2/core';
import { FileModel } from '../models/file.model';
import { FileUploadingDialogComponent } from './file-uploading-dialog.component';
export declare class UploadComponent {
el: ElementRef;
private _uploaderService;
method: string;
undoNotificationBar: any;
fileUploadingDialogComponent: FileUploadingDialogComponent;
filesUploadingList: FileModel[];
constructor(el: ElementRef);
onFilesAdded(files: any): void;
showUndoNotificationBar(latestFilesAdded: any): void;
showDialog(): void;
}

View File

@@ -0,0 +1,52 @@
<br>
<!--upload buttons-->
<form>
<div class="mdl-button mdl-js-button mdl-button--raised mdl-button--file">
<i class="material-icons">file_upload</i> Upload<input file-select type="file" name="uploadFiles" id="uploadFiles"
multiple="multiple"
accept=".jpg,.gif,.png,.svg,.mp4"
(onFilesAdded)="onFilesAdded($event)"
#uploadFiles>
</div>
<br><br>
<div class="mdl-button mdl-js-button mdl-button--raised mdl-button--file">
<i class="material-icons">file_upload</i> Upload Folder<input file-select type="file" name="uploadFiles" id="uploadFolder"
multiple="multiple"
accept=".jpg,.gif,.png,.svg"
(onFilesAdded)="onFilesAdded($event)"
webkitdirectory directory
multiple #uploadFiles>
</div>
<br><br>
<div file-draggable id='UploadBorder' class="upload-border" (onFilesAdded)="onFilesAdded($event)"
dropzone="" webkitdropzone="copy file:image/png file:image/gif file:image/jpeg" #droparea>
Drop Area
</div>
</form>
<!--show dialog-->
<br>
<button type="button" (click)="showDialog($event)" class="mdl-button mdl-js-button mdl-button--raised show-modal">Show
Dialog
</button>
<file-uploading-dialog [filesUploadingList]="filesUploadingList" #fileUploadingDialog></file-uploading-dialog>
<!--show snackbar-->
<div id="demo-snackbar-example" class="mdl-js-snackbar mdl-snackbar" #undoNotificationBar>
<div class="mdl-snackbar__text"></div>
<button class="mdl-snackbar__action" type="button"></button>
</div>
<br>
<br>

View File

@@ -0,0 +1,122 @@
/**
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
System.register(['angular2/core', '../services/upload.service', './file-uploading-dialog.component', '../directives/file-select.directive', '../directives/file-draggable.directive'], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1, upload_service_1, file_uploading_dialog_component_1, file_select_directive_1, file_draggable_directive_1;
var UploadComponent;
return {
setters:[
function (core_1_1) {
core_1 = core_1_1;
},
function (upload_service_1_1) {
upload_service_1 = upload_service_1_1;
},
function (file_uploading_dialog_component_1_1) {
file_uploading_dialog_component_1 = file_uploading_dialog_component_1_1;
},
function (file_select_directive_1_1) {
file_select_directive_1 = file_select_directive_1_1;
},
function (file_draggable_directive_1_1) {
file_draggable_directive_1 = file_draggable_directive_1_1;
}],
execute: function() {
UploadComponent = (function () {
function UploadComponent(el) {
this.el = el;
this.method = 'GET';
this.filesUploadingList = [];
console.log('UploadComponent constructor', el);
this._uploaderService = new upload_service_1.UploadService({
url: 'http://192.168.99.100:8080/alfresco/service/api/upload',
withCredentials: true,
authToken: btoa('admin:admin'),
authTokenPrefix: 'Basic',
fieldName: 'filedata',
formFields: {
siteid: 'swsdp',
containerid: 'documentLibrary'
}
});
}
UploadComponent.prototype.onFilesAdded = function (files) {
var latestFilesAdded = [];
if (componentHandler) {
componentHandler.upgradeAllRegistered();
}
if (files.length) {
latestFilesAdded = this._uploaderService.addToQueue(files);
this.filesUploadingList = this._uploaderService.getQueue();
this.showDialog();
this.showUndoNotificationBar(latestFilesAdded);
}
};
UploadComponent.prototype.showUndoNotificationBar = function (latestFilesAdded) {
this.snackbarContainer.nativeElement.MaterialSnackbar.showSnackbar({
message: 'Upload in progress...',
timeout: 5000,
actionHandler: function () {
latestFilesAdded.forEach(function (uploadingFileModel) {
uploadingFileModel.setAbort();
});
},
actionText: 'Undo'
});
};
UploadComponent.prototype.showDialog = function () {
this.fileUploadingDialogComponent.showDialog();
};
__decorate([
core_1.Input(),
__metadata('design:type', String)
], UploadComponent.prototype, "method", void 0);
__decorate([
core_1.ViewChild('undoNotificationBar'),
__metadata('design:type', Object)
], UploadComponent.prototype, "undoNotificationBar", void 0);
__decorate([
core_1.ViewChild('fileUploadingDialog'),
__metadata('design:type', file_uploading_dialog_component_1.FileUploadingDialogComponent)
], UploadComponent.prototype, "fileUploadingDialogComponent", void 0);
UploadComponent = __decorate([
core_1.Component({
selector: 'alfresco-upload',
moduleId: __moduleName,
directives: [file_select_directive_1.FileSelectDirective, file_draggable_directive_1.FileDraggableDirective, file_uploading_dialog_component_1.FileUploadingDialogComponent],
templateUrl: './upload.component.html',
styleUrls: ['./upload.component.css']
}),
__metadata('design:paramtypes', [core_1.ElementRef])
], UploadComponent);
return UploadComponent;
}());
exports_1("UploadComponent", UploadComponent);
}
}
});
//# sourceMappingURL=upload.component.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"upload.component.js","sourceRoot":"","sources":["upload.component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBH;gBAeI,yBAAmB,EAAa;oBAAb,OAAE,GAAF,EAAE,CAAW;oBAVhC,WAAM,GAAU,KAAK,CAAC;oBAQtB,uBAAkB,GAAgB,EAAE,CAAC;oBAGjC,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;oBAE/C,IAAI,CAAC,gBAAgB,GAAG,IAAI,8BAAa,CAAC;wBACtC,GAAG,EAAE,wDAAwD;wBAC7D,eAAe,EAAE,IAAI;wBACrB,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC;wBAC9B,eAAe,EAAE,OAAO;wBACxB,SAAS,EAAE,UAAU;wBACrB,UAAU,EAAE;4BACR,MAAM,EAAE,OAAO;4BACf,WAAW,EAAE,iBAAiB;yBACjC;qBACJ,CAAC,CAAC;gBACP,CAAC;gBAED,sCAAY,GAAZ,UAAa,KAAK;oBACd,IAAI,gBAAgB,GAAgB,EAAE,CAAC;oBACvC,EAAE,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC;wBACnB,gBAAgB,CAAC,oBAAoB,EAAE,CAAC;oBAC5C,CAAC;oBAED,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;wBACf,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;wBAC3D,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC;wBAC3D,IAAI,CAAC,UAAU,EAAE,CAAC;wBAClB,IAAI,CAAC,uBAAuB,CAAC,gBAAgB,CAAC,CAAC;oBACnD,CAAC;gBACL,CAAC;gBAED,iDAAuB,GAAvB,UAAwB,gBAAgB;oBACpC,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,gBAAgB,CAAC,YAAY,CAAC;wBAC/D,OAAO,EAAE,uBAAuB;wBAChC,OAAO,EAAE,IAAI;wBACb,aAAa,EAAE;4BACX,gBAAgB,CAAC,OAAO,CAAC,UAAC,kBAAkB;gCACxC,kBAAkB,CAAC,QAAQ,EAAE,CAAC;4BAClC,CAAC,CAAC,CAAC;wBACP,CAAC;wBACD,UAAU,EAAE,MAAM;qBACrB,CAAC,CAAC;gBACP,CAAC;gBAED,oCAAU,GAAV;oBACI,IAAI,CAAC,4BAA4B,CAAC,UAAU,EAAE,CAAC;gBACnD,CAAC;gBAxDD;oBAAC,YAAK,EAAE;;+DAAA;gBAGR;oBAAC,gBAAS,CAAC,qBAAqB,CAAC;;4EAAA;gBAGjC;oBAAC,gBAAS,CAAC,qBAAqB,CAAC;;qFAAA;gBAjBrC;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,iBAAiB;wBAC3B,QAAQ,EAAE,YAAY;wBACtB,UAAU,EAAE,CAAC,2CAAmB,EAAE,iDAAsB,EAAE,8DAA4B,CAAC;wBACvF,WAAW,EAAE,yBAAyB;wBACtC,SAAS,EAAE,CAAC,wBAAwB,CAAC;qBACxC,CAAC;;mCAAA;gBA8DF,sBAAC;YAAD,CAAC,AA7DD,IA6DC;YA7DD,6CA6DC,CAAA"}

View File

@@ -0,0 +1,98 @@
/**
* @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 {Component, Input, ViewChild, ElementRef} from 'angular2/core';
import {UploadService} from '../services/upload.service';
import {FileModel} from '../models/file.model';
import {FileUploadingDialogComponent} from './file-uploading-dialog.component';
import {FileSelectDirective} from '../directives/file-select.directive';
import {FileDraggableDirective} from '../directives/file-draggable.directive';
declare let componentHandler;
declare let dialogPolyfill;
declare let __moduleName:string;
@Component({
selector: 'alfresco-upload',
moduleId: __moduleName,
directives: [FileSelectDirective, FileDraggableDirective, FileUploadingDialogComponent],
templateUrl: './upload.component.html',
styleUrls: ['./upload.component.css']
})
export class UploadComponent {
private _uploaderService:UploadService;
@Input()
method:string = 'GET';
@ViewChild('undoNotificationBar')
undoNotificationBar;
@ViewChild('fileUploadingDialog')
fileUploadingDialogComponent:FileUploadingDialogComponent;
filesUploadingList:FileModel [] = [];
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'
}
});
}
onFilesAdded(files):void {
let latestFilesAdded:FileModel [] = [];
if (componentHandler) {
componentHandler.upgradeAllRegistered();
}
if (files.length) {
latestFilesAdded = this._uploaderService.addToQueue(files);
this.filesUploadingList = this._uploaderService.getQueue();
this.showDialog();
this.showUndoNotificationBar(latestFilesAdded);
}
}
showUndoNotificationBar(latestFilesAdded){
this.snackbarContainer.nativeElement.MaterialSnackbar.showSnackbar({
message: 'Upload in progress...',
timeout: 5000,
actionHandler: function () {
latestFilesAdded.forEach((uploadingFileModel) => {
uploadingFileModel.setAbort();
});
},
actionText: 'Undo'
});
}
showDialog():void {
this.fileUploadingDialogComponent.showDialog();
}
}