diff --git a/cspell.json b/cspell.json index f71962e5a1f..02c1c1e8012 100644 --- a/cspell.json +++ b/cspell.json @@ -137,7 +137,6 @@ "waypoint", "waypoints", "webm", - "webscript", "Whitespaces", "xdescribe", "xsrf", diff --git a/docs/README.md b/docs/README.md index b7ee1612141..fdf2a4e32e5 100644 --- a/docs/README.md +++ b/docs/README.md @@ -322,7 +322,6 @@ for more information about installing and using the source code. | [Version List component](content-services/components/version-list.component.md) ![Experimental](docassets/images/ExperimentalIcon.png) | 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) ![Experimental](docassets/images/ExperimentalIcon.png) | 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) ![Experimental](docassets/images/ExperimentalIcon.png) | 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 diff --git a/docs/content-services/components/webscript.component.md b/docs/content-services/components/webscript.component.md deleted file mode 100644 index b01c7e57d67..00000000000 --- a/docs/content-services/components/webscript.component.md +++ /dev/null @@ -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 - - -``` - -Another example: - -**app.component.html** - -```html - - -``` - -**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)`` | 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 - - -``` - -![Custom columns](../../docassets/images/HTML.png) - -### 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 - - -``` - -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: - -![Custom columns](../../docassets/images/datatable.png) - -### 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 - - -``` - -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); -} -``` diff --git a/lib/content-services/src/lib/content.module.ts b/lib/content-services/src/lib/content.module.ts index e0dc05eef0d..3b7dbd4cc69 100644 --- a/lib/content-services/src/lib/content.module.ts +++ b/lib/content-services/src/lib/content.module.ts @@ -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, diff --git a/lib/content-services/src/lib/i18n/ar.json b/lib/content-services/src/lib/i18n/ar.json index d398329d7df..1506518f5ce 100644 --- a/lib/content-services/src/lib/i18n/ar.json +++ b/lib/content-services/src/lib/i18n/ar.json @@ -268,9 +268,6 @@ "ERROR": "خطأ في التحميل" } }, - "WEBSCRIPT": { - "ERROR": "تعذر إتمام الإجراء. شارك هذه الرسالة مع فريق تكنولوجيا المعلومات لديك: حدث خطأ أثناء إلغاء تسلسل{{data}} كـ {{contentType}}" - }, "SEARCH": { "CONTROL": {}, "BUTTON": { diff --git a/lib/content-services/src/lib/i18n/cs.json b/lib/content-services/src/lib/i18n/cs.json index 53f035b7bb1..84ebb27ee77 100644 --- a/lib/content-services/src/lib/i18n/cs.json +++ b/lib/content-services/src/lib/i18n/cs.json @@ -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": { diff --git a/lib/content-services/src/lib/i18n/da.json b/lib/content-services/src/lib/i18n/da.json index 0b6443d15fc..d7528f7fffd 100644 --- a/lib/content-services/src/lib/i18n/da.json +++ b/lib/content-services/src/lib/i18n/da.json @@ -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": { diff --git a/lib/content-services/src/lib/i18n/de.json b/lib/content-services/src/lib/i18n/de.json index 10e358d91d4..04d0fffce40 100644 --- a/lib/content-services/src/lib/i18n/de.json +++ b/lib/content-services/src/lib/i18n/de.json @@ -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": { diff --git a/lib/content-services/src/lib/i18n/en.json b/lib/content-services/src/lib/i18n/en.json index bc7b075e262..0e41436f955 100644 --- a/lib/content-services/src/lib/i18n/en.json +++ b/lib/content-services/src/lib/i18n/en.json @@ -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": { diff --git a/lib/content-services/src/lib/i18n/es.json b/lib/content-services/src/lib/i18n/es.json index 94fcffd2942..1fa28efc131 100644 --- a/lib/content-services/src/lib/i18n/es.json +++ b/lib/content-services/src/lib/i18n/es.json @@ -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": { diff --git a/lib/content-services/src/lib/i18n/fi.json b/lib/content-services/src/lib/i18n/fi.json index 18eb2a47cca..dc178597228 100644 --- a/lib/content-services/src/lib/i18n/fi.json +++ b/lib/content-services/src/lib/i18n/fi.json @@ -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": { diff --git a/lib/content-services/src/lib/i18n/fr.json b/lib/content-services/src/lib/i18n/fr.json index 5c57ad61a3f..5c97a782f31 100644 --- a/lib/content-services/src/lib/i18n/fr.json +++ b/lib/content-services/src/lib/i18n/fr.json @@ -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": { diff --git a/lib/content-services/src/lib/i18n/it.json b/lib/content-services/src/lib/i18n/it.json index d16a5f823a4..c5f555a52e8 100644 --- a/lib/content-services/src/lib/i18n/it.json +++ b/lib/content-services/src/lib/i18n/it.json @@ -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": { diff --git a/lib/content-services/src/lib/i18n/ja.json b/lib/content-services/src/lib/i18n/ja.json index 4e04e6b27a5..0a8e372699c 100644 --- a/lib/content-services/src/lib/i18n/ja.json +++ b/lib/content-services/src/lib/i18n/ja.json @@ -268,9 +268,6 @@ "ERROR": "アップロードエラー" } }, - "WEBSCRIPT": { - "ERROR": "処理を完了できませんでした。次のメッセージを IT 担当者に伝えてください: {{data}} を {{contentType}} としてシリアル化解除中にエラーが発生しました" - }, "SEARCH": { "CONTROL": {}, "BUTTON": { diff --git a/lib/content-services/src/lib/i18n/nb.json b/lib/content-services/src/lib/i18n/nb.json index 71ada26d9b4..80f5462ab4c 100644 --- a/lib/content-services/src/lib/i18n/nb.json +++ b/lib/content-services/src/lib/i18n/nb.json @@ -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": { diff --git a/lib/content-services/src/lib/i18n/nl.json b/lib/content-services/src/lib/i18n/nl.json index 5dd9179e4e7..876d230814a 100644 --- a/lib/content-services/src/lib/i18n/nl.json +++ b/lib/content-services/src/lib/i18n/nl.json @@ -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": { diff --git a/lib/content-services/src/lib/i18n/pl.json b/lib/content-services/src/lib/i18n/pl.json index e1d41750af5..c67ae3e13f6 100644 --- a/lib/content-services/src/lib/i18n/pl.json +++ b/lib/content-services/src/lib/i18n/pl.json @@ -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": { diff --git a/lib/content-services/src/lib/i18n/pt-BR.json b/lib/content-services/src/lib/i18n/pt-BR.json index c70e5713acb..0cf8770fd82 100644 --- a/lib/content-services/src/lib/i18n/pt-BR.json +++ b/lib/content-services/src/lib/i18n/pt-BR.json @@ -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": { diff --git a/lib/content-services/src/lib/i18n/ru.json b/lib/content-services/src/lib/i18n/ru.json index 285fd5251ff..ce09e0c6a26 100644 --- a/lib/content-services/src/lib/i18n/ru.json +++ b/lib/content-services/src/lib/i18n/ru.json @@ -268,9 +268,6 @@ "ERROR": "Ошибка загрузки" } }, - "WEBSCRIPT": { - "ERROR": "Не удалось выполнить действие. Покажите IT-специалистам следующее сообщение: ошибка во время десериализации {{data}} в виде {{contentType}}" - }, "SEARCH": { "CONTROL": {}, "BUTTON": { diff --git a/lib/content-services/src/lib/i18n/sv.json b/lib/content-services/src/lib/i18n/sv.json index 0b86d4206ee..94aa283dd0d 100644 --- a/lib/content-services/src/lib/i18n/sv.json +++ b/lib/content-services/src/lib/i18n/sv.json @@ -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": { diff --git a/lib/content-services/src/lib/i18n/zh-CN.json b/lib/content-services/src/lib/i18n/zh-CN.json index ae8cdce8d49..4ceb79981f0 100644 --- a/lib/content-services/src/lib/i18n/zh-CN.json +++ b/lib/content-services/src/lib/i18n/zh-CN.json @@ -268,9 +268,6 @@ "ERROR": "上传错误" } }, - "WEBSCRIPT": { - "ERROR": "无法完成该操作。将此信息告知您的 IT 团队:将 {{data}} 反序列化为 {{contentType}} 过程中出错" - }, "SEARCH": { "CONTROL": {}, "BUTTON": { diff --git a/lib/content-services/src/lib/webscript/index.ts b/lib/content-services/src/lib/webscript/index.ts deleted file mode 100644 index e58e5c1c414..00000000000 --- a/lib/content-services/src/lib/webscript/index.ts +++ /dev/null @@ -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'; diff --git a/lib/content-services/src/lib/webscript/public-api.ts b/lib/content-services/src/lib/webscript/public-api.ts deleted file mode 100644 index 83c2aaed587..00000000000 --- a/lib/content-services/src/lib/webscript/public-api.ts +++ /dev/null @@ -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'; diff --git a/lib/content-services/src/lib/webscript/webscript.component.html b/lib/content-services/src/lib/webscript/webscript.component.html deleted file mode 100644 index fe53b3ddfe1..00000000000 --- a/lib/content-services/src/lib/webscript/webscript.component.html +++ /dev/null @@ -1,16 +0,0 @@ -
-
{{data | json}}
-
-
{{data}}
-
- -
-
{{'WEBSCRIPT.ERROR' | translate: { - data: data, - contentType: contentType - } - }} -
-
-
-
diff --git a/lib/content-services/src/lib/webscript/webscript.component.spec.ts b/lib/content-services/src/lib/webscript/webscript.component.spec.ts deleted file mode 100644 index a397a3aacc8..00000000000 --- a/lib/content-services/src/lib/webscript/webscript.component.spec.ts +++ /dev/null @@ -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; - 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: '
' - }); - }); - - 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 - }); - }); - }); -}); diff --git a/lib/content-services/src/lib/webscript/webscript.component.ts b/lib/content-services/src/lib/webscript/webscript.component.ts deleted file mode 100644 index e78f2836904..00000000000 --- a/lib/content-services/src/lib/webscript/webscript.component.ts +++ /dev/null @@ -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((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'; - } -} diff --git a/lib/content-services/src/lib/webscript/webscript.module.ts b/lib/content-services/src/lib/webscript/webscript.module.ts deleted file mode 100644 index 1d82727585f..00000000000 --- a/lib/content-services/src/lib/webscript/webscript.module.ts +++ /dev/null @@ -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 {} diff --git a/lib/content-services/src/public-api.ts b/lib/content-services/src/public-api.ts index 645ee260917..b9447dce146 100644 --- a/lib/content-services/src/public-api.ts +++ b/lib/content-services/src/public-api.ts @@ -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';