From 770049ea162573d5afa1aaefed6131fe5e0a77f7 Mon Sep 17 00:00:00 2001 From: danielhanrahan Date: Tue, 15 Feb 2022 18:02:23 +0000 Subject: Refactor apex-editor frontend build Moved frontend from src/main/resources/webapp to src/main/webapp Moved static resources such as jquery-ui to webapp/dist folder Configured jest to exclude webapp/dist from coverage report Removed unused ZIP file assembly Cleaned up POM Issue-ID: POLICY-3896 Signed-off-by: danielhanrahan Change-Id: Ia006eb94a39586219029866eef94aef38912ad65 --- .../src/main/webapp/js/ApexTaskTab.js | 189 +++++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 gui-editors/gui-editor-apex/src/main/webapp/js/ApexTaskTab.js (limited to 'gui-editors/gui-editor-apex/src/main/webapp/js/ApexTaskTab.js') diff --git a/gui-editors/gui-editor-apex/src/main/webapp/js/ApexTaskTab.js b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexTaskTab.js new file mode 100644 index 0000000..9c79ad4 --- /dev/null +++ b/gui-editors/gui-editor-apex/src/main/webapp/js/ApexTaskTab.js @@ -0,0 +1,189 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020-2021 Nordix Foundation. + * Modifications Copyright (C) 2021 Bell Canada. 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +import {createTable} from "./ApexTable"; +import {ajax_get} from "./ApexAjax"; +import {rightClickMenu_scopePreserver} from "./contextMenu"; +import {apexUtils_removeElement} from "./ApexUtils"; + +function taskTab_reset() { + taskTab_deactivate(); + taskTab_activate(); +} + +function taskTab_activate() { + taskTab_create(); + + const requestURL = window.restRootURL + "/Task/Get?name=&version="; + + ajax_get(requestURL, function(data) { + $("#taskTableBody").find("tr:gt(0)").remove(); + + for (let value of data.messages.message) { + const task = JSON.parse(value).apexTask; + + const taskRow_tr = document.createElement("tr"); + + var taskTableRow = + "" + + task.key.name + ":" + task.key.version + + "" + + "" + + task.taskLogic.logicFlavour + + ""; + + taskTableRow += ""; + for (let fieldEntry of task.inputFields.entry) { + + taskTableRow += + "" + + ""; + } + taskTableRow += "
Field NameField Type/SchemaOptional
" + + fieldEntry.key + + "" + + fieldEntry.value.fieldSchemaKey.name + ":" + fieldEntry.value.fieldSchemaKey.version + + "" + + fieldEntry.value.optional + + "
"; + + taskTableRow += ""; + for (let fieldEntry of task.outputFields.entry) { + + taskTableRow += + "" + + ""; + } + taskTableRow += "
Field NameField Type/SchemaOptional
" + + fieldEntry.key + + "" + + fieldEntry.value.fieldSchemaKey.name + ":" + fieldEntry.value.fieldSchemaKey.version + + "" + + fieldEntry.value.optional + + "
"; + + taskTableRow += ""; + for (let parameterEntry of task.taskParameters.entry) { + + taskTableRow += + "" + + ""; + } + taskTableRow += "
Parameter NameDefault Value
" + + parameterEntry.key + + "" + + parameterEntry.value.defaultValue + + "
"; + + taskTableRow += ""; + for (let contextAlbumReference of task.contextAlbumReference) { + + taskTableRow += + ""; + } + taskTableRow += "
" + + contextAlbumReference.name + ":" + contextAlbumReference.version + + "
"; + + taskRow_tr.innerHTML = taskTableRow; + taskRow_tr.addEventListener('contextmenu', rightClickMenu_scopePreserver("taskTabContent", "Task", task.key.name, task.key.version)); + + $("#taskTableBody").append(taskRow_tr); + + } + }); +} + +function taskTab_deactivate() { + apexUtils_removeElement("taskTabContent"); +} + +function taskTab_create() { + var taskTab = document.getElementById("tasksTab"); + + //Testing purposes + if(taskTab === null) { + taskTab = document.createElement("tasksTab"); + } + + var taskTabContent = document.getElementById("taskTabContent"); + if (taskTabContent != null) { + return + } + + taskTabContent = document.createElement("taskTabContent"); + taskTab.appendChild(taskTabContent); + taskTabContent.setAttribute("id", "taskTabContent"); + taskTabContent.addEventListener('contextmenu', rightClickMenu_scopePreserver("taskTabContent", "Task", null, null)); + + var taskTable = createTable("taskTable"); + taskTabContent.appendChild(taskTable); + + var taskTableHeader = document.createElement("thead"); + taskTable.appendChild(taskTableHeader); + taskTableHeader.setAttribute("id", "taskTableHeader"); + + var taskTableHeaderRow = document.createElement("tr"); + taskTableHeader.appendChild(taskTableHeaderRow); + taskTableHeaderRow.setAttribute("id", "taskTableHeaderRow"); + + var taskTableKeyHeader = document.createElement("th"); + taskTableHeaderRow.appendChild(taskTableKeyHeader); + taskTableKeyHeader.setAttribute("id", "taskTableKeyHeader"); + taskTableKeyHeader.appendChild(document.createTextNode("Task")); + + var taskTableLogicFlavourHeader = document.createElement("th"); + taskTableHeaderRow.appendChild(taskTableLogicFlavourHeader); + taskTableLogicFlavourHeader.setAttribute("id", "taskTableLogicFlavourHeader"); + taskTableLogicFlavourHeader.appendChild(document.createTextNode("Logic Flavour")); + + var taskTableInputFieldHeader = document.createElement("th"); + taskTableHeaderRow.appendChild(taskTableInputFieldHeader); + taskTableInputFieldHeader.setAttribute("id", "taskTableInputFieldHeader"); + taskTableInputFieldHeader.appendChild(document.createTextNode("Input Fields")); + + var taskTableOutputFieldHeader = document.createElement("th"); + taskTableHeaderRow.appendChild(taskTableOutputFieldHeader); + taskTableOutputFieldHeader.setAttribute("id", "taskTableOutputFieldHeader"); + taskTableOutputFieldHeader.appendChild(document.createTextNode("Output Fields")); + + var taskTableParameterHeader = document.createElement("th"); + taskTableHeaderRow.appendChild(taskTableParameterHeader); + taskTableParameterHeader.setAttribute("id", "taskTableParameterHeader"); + taskTableParameterHeader.appendChild(document.createTextNode("Parameters")); + + var taskTableContextReferenceHeader = document.createElement("th"); + taskTableHeaderRow.appendChild(taskTableContextReferenceHeader); + taskTableContextReferenceHeader.setAttribute("id", "taskTableContextReferenceHeader"); + taskTableContextReferenceHeader.appendChild(document.createTextNode("Context Album References")); + + var taskTableBody = document.createElement("tbody"); + taskTable.appendChild(taskTableBody); + taskTable.setAttribute("id", "taskTableBody"); +} + +export { + taskTab_create, + taskTab_reset, + taskTab_activate, + taskTab_deactivate +}; -- cgit 1.2.3-korg