mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[ACS-5571] Remove unused WebScript component (#8752)
* ACS-5571 Remove unused WebScript component * [ACS-5571] revert wrong file deletion
This commit is contained in:
parent
22da251c02
commit
7cef7a2688
@ -137,7 +137,6 @@
|
||||
"waypoint",
|
||||
"waypoints",
|
||||
"webm",
|
||||
"webscript",
|
||||
"Whitespaces",
|
||||
"xdescribe",
|
||||
"xsrf",
|
||||
|
@ -322,7 +322,6 @@ for more information about installing and using the source code.
|
||||
| [Version List component](content-services/components/version-list.component.md)  | Displays the version history of a node in a Version Manager component. | [Source](../lib/content-services/src/lib/version-manager/version-list.component.ts) |
|
||||
| [Version Manager Component](content-services/components/version-manager.component.md)  | Displays the version history of a node with the ability to upload a new version. | [Source](../lib/content-services/src/lib/version-manager/version-manager.component.ts) |
|
||||
| [Version Upload component](content-services/components/version-upload.component.md)  | Displays the new version's minor/major changes and the optional comment of a node in a Version Manager component. | [Source](../lib/content-services/src/lib/version-manager/version-upload.component.ts) |
|
||||
| [Webscript component](content-services/components/webscript.component.md) | Provides access to Webscript features. | [Source](../lib/content-services/src/lib/webscript/webscript.component.ts) |
|
||||
|
||||
### Directives
|
||||
|
||||
|
@ -1,185 +0,0 @@
|
||||
---
|
||||
Title: Webscript component
|
||||
Added: v2.0.0
|
||||
Status: Active
|
||||
Last reviewed: 2018-11-14
|
||||
---
|
||||
|
||||
# [Webscript component](../../../lib/content-services/src/lib/webscript/webscript.component.ts "Defined in webscript.component.ts")
|
||||
|
||||
Provides access to Webscript features.
|
||||
|
||||
## Contents
|
||||
|
||||
- [Basic usage](#basic-usage)
|
||||
- [Class members](#class-members)
|
||||
- [Properties](#properties)
|
||||
- [Events](#events)
|
||||
- [Details](#details)
|
||||
- [Webscript View HTML example](#webscript-view-html-example)
|
||||
- [Webscript View DATATABLE example](#webscript-view-datatable-example)
|
||||
- [Webscript View JSON example](#webscript-view-json-example)
|
||||
|
||||
## Basic usage
|
||||
|
||||
```html
|
||||
<adf-webscript-get
|
||||
[scriptPath]="string"
|
||||
[scriptArgs]="Object"
|
||||
[contextRoot]="string"
|
||||
[servicePath]="string"
|
||||
[showData]="boolean"
|
||||
[contentType]="JSON | HTML | DATATABLE | TEXT"
|
||||
(success)= "logData($event)">
|
||||
</adf-webscript-get>
|
||||
```
|
||||
|
||||
Another example:
|
||||
|
||||
**app.component.html**
|
||||
|
||||
```html
|
||||
<adf-webscript-get
|
||||
[scriptPath]="scriptPath"
|
||||
[scriptArgs]="scriptArgs"
|
||||
[contextRoot]="contextRoot"
|
||||
[servicePath]="servicePath"
|
||||
[contentType]="'HTML'">
|
||||
</adf-webscript-get>
|
||||
```
|
||||
|
||||
**app.component.ts**
|
||||
|
||||
```ts
|
||||
export class AppComponent {
|
||||
scriptPath: string = 'sample/folder/Company%20Home';
|
||||
contextRoot: string = 'alfresco';
|
||||
servicePath: string = 'service';
|
||||
}
|
||||
```
|
||||
|
||||
## Class members
|
||||
|
||||
### Properties
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| ---- | ---- | ------------- | ----------- |
|
||||
| contentType | `string` | "TEXT" | Content type to interpret the data received from the webscript. Can be "JSON" , "HTML" , "DATATABLE" or "TEXT" |
|
||||
| contextRoot | `string` | "alfresco" | Path where the application is deployed |
|
||||
| scriptArgs | `any` | | Arguments to pass to the webscript. |
|
||||
| scriptPath | `string` | | (required) Path to the webscript (as defined by webscript). |
|
||||
| servicePath | `string` | "service" | Path that the webscript service is mapped to. |
|
||||
| showData | `boolean` | true | Toggles whether to show or hide the data. |
|
||||
|
||||
### Events
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ---- | ----------- |
|
||||
| success | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<any>` | Emitted when the operation succeeds. You can get the plain data from the webscript through the **success** event parameter and use it as you need in your application. |
|
||||
|
||||
## Details
|
||||
|
||||
### Webscript View HTML example
|
||||
|
||||
This sample demonstrates how to implement a [Webscript component](webscript.component.md) that renders the HTML contents that come from a webscript
|
||||
This sample Web Scripts reside in your Alfresco Server. You can access the folder webscript here:
|
||||
|
||||
`http://localhost:8080/alfresco/service/sample/folder/Company%20Home`
|
||||
|
||||
```html
|
||||
<adf-webscript-get
|
||||
[scriptPath]="scriptPath"
|
||||
[contextRoot]="'alfresco'"
|
||||
[servicePath]="'service'";
|
||||
[scriptPath]="'Sample/folder/Company%20Home'"
|
||||
[contentType]="'HTML'">
|
||||
</adf-webscript-get>
|
||||
```
|
||||
|
||||

|
||||
|
||||
### Webscript View DATATABLE example
|
||||
|
||||
This sample demonstrates how to implement a [Webscript component](webscript.component.md) that renders the JSON contents that come from a webscript
|
||||
|
||||
`http://localhost:8080/alfresco/service/sample/folder/DATATABLE`
|
||||
|
||||
```html
|
||||
<adf-webscript-get
|
||||
[scriptPath]="scriptPath"
|
||||
[contextRoot]="'alfresco'"
|
||||
[servicePath]="'service'";
|
||||
[scriptPath]="'Sample/folder/DATATABLE'"
|
||||
[contentType]="'DATATABLE'">
|
||||
</adf-webscript-get>
|
||||
```
|
||||
|
||||
If you want to show the result from a webscript inside a
|
||||
[datatable component](../../core/components/datatable.component.md)
|
||||
you have to return the data structure below (subdivided into data and
|
||||
schema) from the GET method of the webscript:
|
||||
|
||||
```ts
|
||||
data: [],
|
||||
schema: []
|
||||
```
|
||||
|
||||
Here is an example:
|
||||
|
||||
```ts
|
||||
data: [
|
||||
{id: 1, name: 'Name 1'},
|
||||
{id: 2, name: 'Name 2'}
|
||||
],
|
||||
schema: [{
|
||||
type: 'text',
|
||||
key: 'id',
|
||||
title: 'Id',
|
||||
sortable: true
|
||||
}, {
|
||||
type: 'text',
|
||||
key: 'name',
|
||||
title: 'Name',
|
||||
sortable: true
|
||||
}]
|
||||
```
|
||||
|
||||
Alternatively, you can send just the array data and the component will create a schema for you:
|
||||
|
||||
```ts
|
||||
data: [
|
||||
{id: 1, name: 'Name 1'},
|
||||
{id: 2, name: 'Name 2'}
|
||||
]]
|
||||
```
|
||||
|
||||
This will render the following table:
|
||||
|
||||

|
||||
|
||||
### Webscript View JSON example
|
||||
|
||||
This sample demonstrates how to implement a [Webscript component](webscript.component.md) that renders the JSON contents that come from a webscript.
|
||||
This sample webscript resides in your Alfresco Server. You can access the folder webscript here:
|
||||
|
||||
`http://localhost:8080/alfresco/service/sample/folder/JSON%EXAMPLE`
|
||||
|
||||
```html
|
||||
<adf-webscript-get
|
||||
[scriptPath]="scriptPath"
|
||||
[contextRoot]="'alfresco'"
|
||||
[servicePath]="'service'";
|
||||
[scriptPath]="'Sample/folder/JSON_EXAMPLE'"
|
||||
[contentType]="'HTML'"
|
||||
[showData]="false"
|
||||
(success)="logDataExample($event)">
|
||||
</adf-webscript-get>
|
||||
```
|
||||
|
||||
You can get the plain data from the webscript through the **success** event parameter and use it as you need in your application
|
||||
|
||||
```ts
|
||||
logDataExample(data) {
|
||||
console.log('Your webscript data is here' + data);
|
||||
}
|
||||
```
|
@ -23,7 +23,6 @@ import { CoreModule, SearchTextModule, provideTranslations } from '@alfresco/adf
|
||||
import { MaterialModule } from './material.module';
|
||||
|
||||
import { TagModule } from './tag/tag.module';
|
||||
import { WebScriptModule } from './webscript/webscript.module';
|
||||
import { DocumentListModule } from './document-list/document-list.module';
|
||||
import { UploadModule } from './upload/upload.module';
|
||||
import { SearchModule } from './search/search.module';
|
||||
@ -59,7 +58,6 @@ import { ContentAuthLoaderService } from './auth-loader/content-auth-loader.serv
|
||||
CoreModule,
|
||||
TagModule,
|
||||
CommonModule,
|
||||
WebScriptModule,
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
DialogModule,
|
||||
@ -94,7 +92,6 @@ import { ContentAuthLoaderService } from './auth-loader/content-auth-loader.serv
|
||||
exports: [
|
||||
ContentPipeModule,
|
||||
TagModule,
|
||||
WebScriptModule,
|
||||
DocumentListModule,
|
||||
ContentUserInfoModule,
|
||||
UploadModule,
|
||||
|
@ -268,9 +268,6 @@
|
||||
"ERROR": "خطأ في التحميل"
|
||||
}
|
||||
},
|
||||
"WEBSCRIPT": {
|
||||
"ERROR": "تعذر إتمام الإجراء. شارك هذه الرسالة مع فريق تكنولوجيا المعلومات لديك: حدث خطأ أثناء إلغاء تسلسل{{data}} كـ {{contentType}}"
|
||||
},
|
||||
"SEARCH": {
|
||||
"CONTROL": {},
|
||||
"BUTTON": {
|
||||
|
@ -268,9 +268,6 @@
|
||||
"ERROR": "Chyba při nahrávání"
|
||||
}
|
||||
},
|
||||
"WEBSCRIPT": {
|
||||
"ERROR": "Akci nelze dokončit. Sdělte oddělení IT následující zprávu: Chyba při deserializaci „{{data}}“ ({{contentType}})."
|
||||
},
|
||||
"SEARCH": {
|
||||
"CONTROL": {},
|
||||
"BUTTON": {
|
||||
|
@ -268,9 +268,6 @@
|
||||
"ERROR": "Uploadfejl"
|
||||
}
|
||||
},
|
||||
"WEBSCRIPT": {
|
||||
"ERROR": "Handlingen kunne ikke fuldføres. Giv følgende meddelelse til din it-afdeling: Fejl under deserialisering af {{data}} som {{contentType}}"
|
||||
},
|
||||
"SEARCH": {
|
||||
"CONTROL": {},
|
||||
"BUTTON": {
|
||||
|
@ -268,9 +268,6 @@
|
||||
"ERROR": "Fehler beim Hochladen"
|
||||
}
|
||||
},
|
||||
"WEBSCRIPT": {
|
||||
"ERROR": "Vorgang konnte nicht durchgeführt werden. Geben Sie diese Meldung an Ihr IT-Team weiter: Fehler bei Deserialisierung von {{data}} als {{contentType}}"
|
||||
},
|
||||
"SEARCH": {
|
||||
"CONTROL": {},
|
||||
"BUTTON": {
|
||||
|
@ -268,9 +268,6 @@
|
||||
"ERROR": "Upload error"
|
||||
}
|
||||
},
|
||||
"WEBSCRIPT": {
|
||||
"ERROR": "Couldn't complete the action. Share this message with your IT Team: Error during the deserialization of {{data}} as {{contentType}}"
|
||||
},
|
||||
"SEARCH": {
|
||||
"CONTROL": {},
|
||||
"BUTTON": {
|
||||
|
@ -268,9 +268,6 @@
|
||||
"ERROR": "Error de carga"
|
||||
}
|
||||
},
|
||||
"WEBSCRIPT": {
|
||||
"ERROR": "No se ha podido finalizar la acción. Comparta este mensaje con el equipo de TI: Error durante la deserialización {{data}} como {{contentType}}"
|
||||
},
|
||||
"SEARCH": {
|
||||
"CONTROL": {},
|
||||
"BUTTON": {
|
||||
|
@ -268,9 +268,6 @@
|
||||
"ERROR": "Latausvirhe"
|
||||
}
|
||||
},
|
||||
"WEBSCRIPT": {
|
||||
"ERROR": "Toiminnon suorittaminen ei onnistu. Ilmoita IT-tuelle seuraava ilmoitus: kohteen {{data}} sarjoituksen poistamisessa muotoon {{contentType}} tapahtui virhe"
|
||||
},
|
||||
"SEARCH": {
|
||||
"CONTROL": {},
|
||||
"BUTTON": {
|
||||
|
@ -268,9 +268,6 @@
|
||||
"ERROR": "Erreur d'importation"
|
||||
}
|
||||
},
|
||||
"WEBSCRIPT": {
|
||||
"ERROR": "Impossible de terminer l'action. Transférez le message suivant au service informatique : erreur pendant la désérialisation de {{data}} en tant que {{contentType}}"
|
||||
},
|
||||
"SEARCH": {
|
||||
"CONTROL": {},
|
||||
"BUTTON": {
|
||||
|
@ -268,9 +268,6 @@
|
||||
"ERROR": "Carica errore"
|
||||
}
|
||||
},
|
||||
"WEBSCRIPT": {
|
||||
"ERROR": "Impossibile completare l'azione. Condividi il messaggio con il team IT: Errore durante la deserializzazione di {{data}} come {{contentType}}"
|
||||
},
|
||||
"SEARCH": {
|
||||
"CONTROL": {},
|
||||
"BUTTON": {
|
||||
|
@ -268,9 +268,6 @@
|
||||
"ERROR": "アップロードエラー"
|
||||
}
|
||||
},
|
||||
"WEBSCRIPT": {
|
||||
"ERROR": "処理を完了できませんでした。次のメッセージを IT 担当者に伝えてください: {{data}} を {{contentType}} としてシリアル化解除中にエラーが発生しました"
|
||||
},
|
||||
"SEARCH": {
|
||||
"CONTROL": {},
|
||||
"BUTTON": {
|
||||
|
@ -268,9 +268,6 @@
|
||||
"ERROR": "Opplastingsfeil"
|
||||
}
|
||||
},
|
||||
"WEBSCRIPT": {
|
||||
"ERROR": "Kan ikke fullføre handlingen. Del denne meldingen med IT-teamet: Feil under deserialisering av {{data}} som {{contentType}}"
|
||||
},
|
||||
"SEARCH": {
|
||||
"CONTROL": {},
|
||||
"BUTTON": {
|
||||
|
@ -268,9 +268,6 @@
|
||||
"ERROR": "Uploadfout"
|
||||
}
|
||||
},
|
||||
"WEBSCRIPT": {
|
||||
"ERROR": "Kan de actie niet voltooien. Geef het volgende bericht door aan het IT-team: Fout bij de deserialisatie van {{data}} als {{contentType}}"
|
||||
},
|
||||
"SEARCH": {
|
||||
"CONTROL": {},
|
||||
"BUTTON": {
|
||||
|
@ -268,9 +268,6 @@
|
||||
"ERROR": "Błąd przesyłania"
|
||||
}
|
||||
},
|
||||
"WEBSCRIPT": {
|
||||
"ERROR": "Nie można wykonać czynności. Udostępnij zespołowi IT następujący komunikat: Błąd podczas deserializacji {{data}} jako {{contentType}}."
|
||||
},
|
||||
"SEARCH": {
|
||||
"CONTROL": {},
|
||||
"BUTTON": {
|
||||
|
@ -268,9 +268,6 @@
|
||||
"ERROR": "Erro ao carregar"
|
||||
}
|
||||
},
|
||||
"WEBSCRIPT": {
|
||||
"ERROR": "Não foi possível concluir a ação. Compartilhe esta mensagem com a Equipe de TI: Erro durante a desserialização de {{data}} como {{contentType}}"
|
||||
},
|
||||
"SEARCH": {
|
||||
"CONTROL": {},
|
||||
"BUTTON": {
|
||||
|
@ -268,9 +268,6 @@
|
||||
"ERROR": "Ошибка загрузки"
|
||||
}
|
||||
},
|
||||
"WEBSCRIPT": {
|
||||
"ERROR": "Не удалось выполнить действие. Покажите IT-специалистам следующее сообщение: ошибка во время десериализации {{data}} в виде {{contentType}}"
|
||||
},
|
||||
"SEARCH": {
|
||||
"CONTROL": {},
|
||||
"BUTTON": {
|
||||
|
@ -268,9 +268,6 @@
|
||||
"ERROR": "Uppladdningsfel"
|
||||
}
|
||||
},
|
||||
"WEBSCRIPT": {
|
||||
"ERROR": "Kunde inte slutföra åtgärden. Dela det här meddelandet med din IT-avdelning: Fel under deserialisering av {{data}} som {{contentType}}"
|
||||
},
|
||||
"SEARCH": {
|
||||
"CONTROL": {},
|
||||
"BUTTON": {
|
||||
|
@ -268,9 +268,6 @@
|
||||
"ERROR": "上传错误"
|
||||
}
|
||||
},
|
||||
"WEBSCRIPT": {
|
||||
"ERROR": "无法完成该操作。将此信息告知您的 IT 团队:将 {{data}} 反序列化为 {{contentType}} 过程中出错"
|
||||
},
|
||||
"SEARCH": {
|
||||
"CONTROL": {},
|
||||
"BUTTON": {
|
||||
|
@ -1,18 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export * from './public-api';
|
@ -1,20 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export * from './webscript.component';
|
||||
|
||||
export * from './webscript.module';
|
@ -1,16 +0,0 @@
|
||||
<div *ngIf="showData">
|
||||
<div *ngIf="contentType === 'JSON'" id="webscript-data-JSON">{{data | json}}</div>
|
||||
<div *ngIf="contentType === 'HTML'" id="webscript-data-HTML" [innerHTML]="data"></div>
|
||||
<div *ngIf="contentType === 'TEXT'" id="webscript-data-TEXT">{{data}}</div>
|
||||
<div *ngIf="isDataTableContent()">
|
||||
<adf-datatable id="webscript-datatable-wrapper" [data]="data"></adf-datatable>
|
||||
<div>
|
||||
<div *ngIf="showError" id="error">{{'WEBSCRIPT.ERROR' | translate: {
|
||||
data: data,
|
||||
contentType: contentType
|
||||
}
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -1,196 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* 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 { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { AppConfigService } from '@alfresco/adf-core';
|
||||
import { WebscriptComponent } from './webscript.component';
|
||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('WebscriptComponent', () => {
|
||||
let component: WebscriptComponent;
|
||||
let fixture: ComponentFixture<WebscriptComponent>;
|
||||
let element: HTMLElement;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ContentTestingModule]
|
||||
});
|
||||
const appConfig: AppConfigService = TestBed.inject(AppConfigService);
|
||||
appConfig.config.ecmHost = 'http://localhost:9876/ecm';
|
||||
|
||||
fixture = TestBed.createComponent(WebscriptComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
||||
element = fixture.nativeElement;
|
||||
component = fixture.componentInstance;
|
||||
component.scriptPath = 'fakePath';
|
||||
component.showData = true;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
describe('View', () => {
|
||||
it('html wrapper should be present', () => {
|
||||
expect(element.querySelector('#webscript-html-wrapper')).toBeDefined();
|
||||
});
|
||||
|
||||
it('wrapper should be hide if showData is false', () => {
|
||||
expect(element.querySelector('#webscript-html-wrapper')).toBeDefined();
|
||||
});
|
||||
|
||||
it('JSON datatable wrapper should be present', () => {
|
||||
expect(element.querySelector('#webscript-json-wrapper')).toBeDefined();
|
||||
});
|
||||
|
||||
it('plain text datatable wrapper should be present', () => {
|
||||
expect(element.querySelector('#webscript-plaintext-wrapper')).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Content tests', () => {
|
||||
beforeEach(() => {
|
||||
jasmine.Ajax.install();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
it('url should be the one configured by the input param', (done) => {
|
||||
component.scriptPath = 'sample/folder/Company%20Home';
|
||||
|
||||
component.ngOnChanges().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(jasmine.Ajax.requests.mostRecent().url).toContain('/ecm/alfresco/service/sample/folder/Company%20Home');
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'text/plain',
|
||||
responseText: '<div></div>'
|
||||
});
|
||||
});
|
||||
|
||||
it('TEXT response should be displayed', (done) => {
|
||||
component.scriptPath = 'sample/folder/Company%20Home';
|
||||
component.contentType = 'TEXT';
|
||||
|
||||
component.ngOnChanges().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#webscript-data-TEXT').innerHTML).toBe('text test');
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'text/html',
|
||||
responseText: 'text test'
|
||||
});
|
||||
});
|
||||
|
||||
it('JSON response should be displayed', (done) => {
|
||||
component.scriptPath = 'sample/folder/Company%20Home';
|
||||
component.contentType = 'JSON';
|
||||
|
||||
component.ngOnChanges().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(JSON.parse(element.querySelector('#webscript-data-JSON').innerHTML)[0].name).toBe('Name 1');
|
||||
expect(JSON.parse(element.querySelector('#webscript-data-JSON').innerHTML)[1].name).toBe('Name 2');
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: [
|
||||
{ id: 1, name: 'Name 1' },
|
||||
{ id: 2, name: 'Name 2' }
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
it('datatable response should be displayed', (done) => {
|
||||
// reset MDL handler
|
||||
window['componentHandler'] = null;
|
||||
|
||||
component.scriptPath = 'sample/folder/Company%20Home';
|
||||
component.contentType = 'DATATABLE';
|
||||
|
||||
component.ngOnChanges().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#webscript-datatable-wrapper').innerHTML).toBeDefined();
|
||||
done();
|
||||
});
|
||||
|
||||
const dataTable = {
|
||||
data: [
|
||||
{ id: 1, name: 'Name 1' },
|
||||
{ id: 2, name: 'Name 2' }
|
||||
],
|
||||
schema: [
|
||||
{
|
||||
type: 'text',
|
||||
key: 'id',
|
||||
title: 'Id',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
key: 'name',
|
||||
title: 'Name',
|
||||
sortable: true
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: dataTable
|
||||
});
|
||||
});
|
||||
|
||||
it('datatable response should be displayed also if no schema is provided', (done) => {
|
||||
// reset MDL handler
|
||||
window['componentHandler'] = null;
|
||||
|
||||
component.scriptPath = 'sample/folder/Company%20Home';
|
||||
component.contentType = 'DATATABLE';
|
||||
|
||||
component.ngOnChanges().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#webscript-datatable-wrapper').innerHTML).toBeDefined();
|
||||
done();
|
||||
});
|
||||
|
||||
const dataTable = {
|
||||
data: [
|
||||
{ id: 1, name: 'Name 1' },
|
||||
{ id: 2, name: 'Name 2' }
|
||||
]
|
||||
};
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: dataTable
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -1,137 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* 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, AlfrescoApiService, LogService } from '@alfresco/adf-core';
|
||||
import { Component, EventEmitter, Input, OnChanges, Output } from '@angular/core';
|
||||
import { WebscriptApi } from '@alfresco/js-api';
|
||||
|
||||
/**
|
||||
* @deprecated Webscript component has never been turned into a product and has no UI/UX and no use cases in ACA/ADW/ACC.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'adf-webscript-get',
|
||||
templateUrl: './webscript.component.html'
|
||||
})
|
||||
export class WebscriptComponent implements OnChanges {
|
||||
|
||||
_webscriptApi: WebscriptApi;
|
||||
get webscriptApi(): WebscriptApi {
|
||||
this._webscriptApi = this._webscriptApi ?? new WebscriptApi(this.apiService.getInstance());
|
||||
return this._webscriptApi;
|
||||
}
|
||||
|
||||
/** (required) Path to the webscript (as defined by webscript). */
|
||||
@Input()
|
||||
scriptPath: string;
|
||||
|
||||
/** Arguments to pass to the webscript. */
|
||||
@Input()
|
||||
scriptArgs: any;
|
||||
|
||||
/** Toggles whether to show or hide the data. */
|
||||
@Input()
|
||||
showData: boolean = true;
|
||||
|
||||
/** Path where the application is deployed */
|
||||
@Input()
|
||||
contextRoot: string = 'alfresco';
|
||||
|
||||
/** Path that the webscript service is mapped to. */
|
||||
@Input()
|
||||
servicePath: string = 'service';
|
||||
|
||||
/**
|
||||
* Content type to interpret the data received from the webscript.
|
||||
* Can be "JSON" , "HTML" , "DATATABLE" or "TEXT"
|
||||
*/
|
||||
@Input()
|
||||
contentType: string = 'TEXT';
|
||||
|
||||
/**
|
||||
* Emitted when the operation succeeds. You can get the plain data from
|
||||
* the webscript through the **success** event parameter and use it as you
|
||||
* need in your application.
|
||||
*/
|
||||
@Output()
|
||||
success = new EventEmitter();
|
||||
|
||||
data: any = undefined;
|
||||
showError: boolean = false;
|
||||
|
||||
constructor(private apiService: AlfrescoApiService,
|
||||
private logService: LogService) {
|
||||
}
|
||||
|
||||
ngOnChanges() {
|
||||
if (this.showData) {
|
||||
this.clean();
|
||||
}
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
this.webscriptApi.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(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* show the data in a ng2-alfresco-datatable
|
||||
*
|
||||
* @param data data
|
||||
* @returns the data as datatable
|
||||
*/
|
||||
showDataAsDataTable(data: any) {
|
||||
const 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';
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* 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 { CoreModule } from '@alfresco/adf-core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
|
||||
import { MaterialModule } from '../material.module';
|
||||
import { WebscriptComponent } from './webscript.component';
|
||||
|
||||
/**
|
||||
* @deprecated Webscript component has never been turned into a product and has no UI/UX and no use cases in ACA/ADW/ACC.
|
||||
*/
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
MaterialModule,
|
||||
CoreModule
|
||||
],
|
||||
exports: [
|
||||
WebscriptComponent
|
||||
],
|
||||
declarations: [
|
||||
WebscriptComponent
|
||||
]
|
||||
})
|
||||
export class WebScriptModule {}
|
@ -17,7 +17,6 @@
|
||||
|
||||
export * from './lib/directives/index';
|
||||
export * from './lib/tag/index';
|
||||
export * from './lib/webscript/index';
|
||||
export * from './lib/document-list/index';
|
||||
export * from './lib/content-user-info/index';
|
||||
export * from './lib/upload/index';
|
||||
|
Loading…
x
Reference in New Issue
Block a user