mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-10-08 14:51:32 +00:00
fix upload demo and inject uploadservice
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
|
||||
import { Component, ViewChild, ElementRef, Input, Output, EventEmitter, Optional } from 'angular2/core';
|
||||
import { Component, ViewChild, ElementRef, Input, Output, EventEmitter } from 'angular2/core';
|
||||
import { UploadService } from '../services/upload.service';
|
||||
import { FileModel } from '../models/file.model';
|
||||
import { FileUploadingDialogComponent } from './file-uploading-dialog.component';
|
||||
@@ -89,17 +89,16 @@ export class UploadButtonComponent {
|
||||
|
||||
translate: AlfrescoTranslationService;
|
||||
|
||||
private _uploaderService: UploadService;
|
||||
|
||||
constructor(public el: ElementRef,
|
||||
@Optional() translate: AlfrescoTranslationService) {
|
||||
private _uploaderService: UploadService,
|
||||
translate: AlfrescoTranslationService) {
|
||||
console.log('UploadComponent constructor', el);
|
||||
|
||||
let site = this.getSiteId();
|
||||
let container = this.getContainerId();
|
||||
|
||||
this._uploaderService = new UploadService({
|
||||
fieldName: 'filedata',
|
||||
this._uploaderService.setOptions({
|
||||
formFields: {
|
||||
siteid: site,
|
||||
containerid: container
|
||||
|
@@ -42,8 +42,6 @@ declare let __moduleName: string;
|
||||
})
|
||||
export class UploadDragAreaComponent {
|
||||
|
||||
private _uploaderService: UploadService;
|
||||
|
||||
@ViewChild('fileUploadingDialog')
|
||||
fileUploadingDialogComponent: FileUploadingDialogComponent;
|
||||
|
||||
@@ -61,13 +59,14 @@ export class UploadDragAreaComponent {
|
||||
@Output()
|
||||
onSuccess = new EventEmitter();
|
||||
|
||||
constructor(public el: ElementRef) {
|
||||
constructor(public el: ElementRef,
|
||||
private _uploaderService: UploadService) {
|
||||
console.log('UploadComponent constructor', el);
|
||||
|
||||
let site = this.getSiteId();
|
||||
let container = this.getContainerId();
|
||||
|
||||
this._uploaderService = new UploadService({
|
||||
this._uploaderService.setOptions({
|
||||
fieldName: 'filedata',
|
||||
formFields: {
|
||||
siteid: site,
|
||||
|
@@ -17,9 +17,10 @@
|
||||
|
||||
|
||||
import { FileModel } from '../models/file.model';
|
||||
import { EventEmitter } from 'angular2/core';
|
||||
import { EventEmitter, Injectable } from 'angular2/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Response } from 'angular2/http';
|
||||
import { AlfrescoSettingsService } from 'ng2-alfresco-core/services';
|
||||
|
||||
declare let AlfrescoApi: any;
|
||||
|
||||
@@ -29,27 +30,37 @@ declare let AlfrescoApi: any;
|
||||
*
|
||||
* @returns {UploadService} .
|
||||
*/
|
||||
@Injectable()
|
||||
export class UploadService {
|
||||
private _host: string = 'http://192.168.99.100:8080';
|
||||
private _baseUrlPath: string = '/alfresco/api/-default-/public/alfresco/versions/1';
|
||||
private _url: string = '/alfresco/service/api/upload';
|
||||
|
||||
private _method: string = 'POST';
|
||||
private _fieldName: string = 'file';
|
||||
private _fieldName: string = 'filedata';
|
||||
private _formFields: Object = {};
|
||||
|
||||
private _queue: FileModel[] = [];
|
||||
|
||||
private _alfrescoClient: any;
|
||||
|
||||
constructor(private options: any) {
|
||||
constructor(private settings: AlfrescoSettingsService) {
|
||||
console.log('UploadService constructor');
|
||||
|
||||
if (settings) {
|
||||
this._host = settings.host;
|
||||
}
|
||||
this._alfrescoClient = this.getAlfrescoClient();
|
||||
}
|
||||
|
||||
this._host = options.host || this._host;
|
||||
/**
|
||||
* Configure the service
|
||||
*
|
||||
* @param {Object} - options to init the object
|
||||
*
|
||||
*/
|
||||
public setOptions(options: any): void {
|
||||
this._baseUrlPath = options.baseUrlPath || this._baseUrlPath;
|
||||
this._fieldName = options.fieldName != null ? options.fieldName : this._fieldName;
|
||||
this._formFields = options.formFields != null ? options.formFields : this._formFields;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user