mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
uploader create Folder porting new Api
This commit is contained in:
@@ -155,7 +155,9 @@ class DocumentListDemo implements OnInit {
|
||||
private documentActions: DocumentActionsService) {
|
||||
|
||||
alfrescoSettingsService.host = this.host;
|
||||
|
||||
if (this.authService.getTicket()) {
|
||||
this.token = this.authService.getTicket();
|
||||
}
|
||||
translation.addTranslationFolder();
|
||||
documentActions.setHandler('my-handler', this.myDocumentActionHandler.bind(this));
|
||||
}
|
||||
|
@@ -83,8 +83,8 @@ export class MyDemoApp implements OnInit {
|
||||
constructor(private authService: AlfrescoAuthenticationService, private alfrescoSettingsService: AlfrescoSettingsService) {
|
||||
alfrescoSettingsService.host = this.host;
|
||||
|
||||
if (this.authService.getToken()) {
|
||||
this.token = this.authService.getToken();
|
||||
if (this.authService.getTicket()) {
|
||||
this.token = this.authService.getTicket();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ export class MyDemoApp implements OnInit {
|
||||
}
|
||||
|
||||
login() {
|
||||
this.authService.login('admin', 'admin').subscribe(
|
||||
this.authService.login('admin', 'admin', ['ECM']).subscribe(
|
||||
token => {
|
||||
console.log(token);
|
||||
this.token = token;
|
||||
|
@@ -87,13 +87,13 @@ describe('AlfrescoUploadService', () => {
|
||||
service.setOptions(empty);
|
||||
expect(service.getUrl()).toEqual('/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children');
|
||||
let formFields: Object = {};
|
||||
expect(service.getFormFileds()).toEqual(formFields);
|
||||
expect(service.getFormFields()).toEqual(formFields);
|
||||
});
|
||||
|
||||
it('should show the option passed as input', () => {
|
||||
service.setOptions(options);
|
||||
expect(service.getUrl()).toEqual('/some/cool/url');
|
||||
expect(service.getFormFileds()).toEqual({
|
||||
expect(service.getFormFields()).toEqual({
|
||||
siteid: 'fakeSite',
|
||||
containerid: 'fakeFolder'
|
||||
});
|
||||
|
@@ -14,8 +14,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
import { EventEmitter, Injectable } from '@angular/core';
|
||||
import { Response } from '@angular/http';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
@@ -33,8 +31,6 @@ declare let AlfrescoApi: any;
|
||||
*/
|
||||
@Injectable()
|
||||
export class UploadService {
|
||||
private _url: string = '/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children';
|
||||
|
||||
private _formFields: Object = {};
|
||||
|
||||
private _queue: FileModel[] = [];
|
||||
@@ -61,31 +57,15 @@ export class UploadService {
|
||||
*
|
||||
*/
|
||||
public setOptions(options: any): void {
|
||||
this._url = options.url || this._url;
|
||||
this._formFields = options.formFields != null ? options.formFields : this._formFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the host
|
||||
* @returns {string}
|
||||
*/
|
||||
public getHost(): string {
|
||||
return this.settings.host;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the url
|
||||
* @returns {string}
|
||||
*/
|
||||
public getUrl(): string {
|
||||
return this._url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the form fields
|
||||
* @returns {Object}
|
||||
*/
|
||||
public getFormFileds(): Object {
|
||||
public getFormFields(): Object {
|
||||
return this._formFields;
|
||||
}
|
||||
|
||||
@@ -121,7 +101,7 @@ export class UploadService {
|
||||
});
|
||||
filesToUpload.forEach((uploadingFileModel) => {
|
||||
uploadingFileModel.setUploading();
|
||||
this.authService.alfrescoApi.
|
||||
this.authService.getAlfrescoApi().
|
||||
upload.uploadFile(uploadingFileModel.file, directory)
|
||||
.on('progress', (progress: any) => {
|
||||
uploadingFileModel.setProgres(progress);
|
||||
@@ -175,15 +155,7 @@ export class UploadService {
|
||||
* @param name - the folder name
|
||||
*/
|
||||
createFolder(relativePath: string, name: string) {
|
||||
console.log('Directory created' + name);
|
||||
let apiInstance = new AlfrescoApi.NodesApi(this._alfrescoClient);
|
||||
let nodeId = '-root-';
|
||||
let nodeBody = {
|
||||
'name': name,
|
||||
'nodeType': 'cm:folder',
|
||||
'relativePath': relativePath
|
||||
};
|
||||
return Observable.fromPromise(apiInstance.addNode(nodeId, nodeBody))
|
||||
return Observable.fromPromise(this.authService.getAlfrescoApi().node.createFolder(name, relativePath))
|
||||
.map(res => {
|
||||
return res;
|
||||
})
|
||||
|
Reference in New Issue
Block a user