/*! * @license * Copyright 2019 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 { ObjectDataTableAdapter } from '@alfresco/adf-core'; import { AlfrescoApiService, LogService } from '@alfresco/adf-core'; import { Component, EventEmitter, Input, OnChanges, Output } from '@angular/core'; /** * { this.apiService.getInstance().webScript.executeWebScript('GET', this.scriptPath, this.scriptArgs, this.contextRoot, this.servicePath).then((webScriptData) => { this.data = webScriptData; if (this.showData) { if (this.contentType === 'DATATABLE') { this.data = this.showDataAsDataTable(webScriptData); } } this.success.emit(this.data); resolve(); }, (error) => { this.logService.log('Error' + error); reject(); }); }); } /** * show the data in a ng2-alfresco-datatable * * @param data * * @returns the data as datatable */ showDataAsDataTable(data: any) { let datatableData: any = null; try { if (!data.schema) { data.schema = ObjectDataTableAdapter.generateSchema(data.data); } if (data.schema && data.schema.length > 0) { this.data = new ObjectDataTableAdapter(data.data, data.schema); } } catch (error) { this.logService.error('error during the cast as datatable'); } return datatableData; } clean() { this.data = undefined; } isDataTableContent() { return this.contentType === 'DATATABLE'; } }