Commit fa8b52ea by Jhunel Adam Calub

finalize functionality of encode button commit

parent d6146918
...@@ -11,7 +11,9 @@ export class ElementListWidget { ...@@ -11,7 +11,9 @@ export class ElementListWidget {
newButton: null, newButton: null,
encodeButton: null, encodeButton: null,
selectedElement: null, selectedElement: null,
workers: [] workers: [],
queueIndex: null,
workerId: null
}; };
constructor(nodeId, containerId) { constructor(nodeId, containerId) {
...@@ -24,8 +26,8 @@ export class ElementListWidget { ...@@ -24,8 +26,8 @@ export class ElementListWidget {
document.body.appendChild(this.global.container); document.body.appendChild(this.global.container);
} }
this.workerId = sessionStorage.getItem("user_id"); this.global.workerId = sessionStorage.getItem("user_id");
this.init(nodeId, this.workerId); this.init(nodeId, this.global.workerId);
} }
async init(nodeId, workerId) { async init(nodeId, workerId) {
...@@ -110,6 +112,7 @@ export class ElementListWidget { ...@@ -110,6 +112,7 @@ export class ElementListWidget {
deselectAll(); deselectAll();
elementContainer.classList.add("selected"); elementContainer.classList.add("selected");
this.global.selectedElement = element; this.global.selectedElement = element;
this.global.queueIndex = element.queueIndex; // <-- Update the queueIndex here
this.showExtraDetails(element, elementContainer); this.showExtraDetails(element, elementContainer);
this.global.encodeButton.disabled = false; this.global.encodeButton.disabled = false;
this.global.encodeButton.classList.remove("disabled"); this.global.encodeButton.classList.remove("disabled");
...@@ -209,6 +212,7 @@ export class ElementListWidget { ...@@ -209,6 +212,7 @@ export class ElementListWidget {
// Retrieve and display the selected element's ID // Retrieve and display the selected element's ID
const elementId = sessionStorage.getItem('selectedElementId'); const elementId = sessionStorage.getItem('selectedElementId');
sessionStorage.setItem("element_id", elementId);
const elementIdDiv = document.createElement('div'); const elementIdDiv = document.createElement('div');
elementIdDiv.textContent = `Element ID: ${elementId}`; elementIdDiv.textContent = `Element ID: ${elementId}`;
elementIdDiv.classList.add('element-id'); elementIdDiv.classList.add('element-id');
...@@ -230,10 +234,14 @@ export class ElementListWidget { ...@@ -230,10 +234,14 @@ export class ElementListWidget {
// Append the DocumentControlWidget // Append the DocumentControlWidget
setDocumentControlObject(new DocumentControlWidget()); setDocumentControlObject(new DocumentControlWidget());
inputContainer.appendChild(DOCUMENT_CONTROL_OBJECT.getWidget()); inputContainer.appendChild(DOCUMENT_CONTROL_OBJECT.getWidget());
}
// Call assignElementToWorker to assign the selected element to the current worker
const assignResponse = await assignElementToWorker(this.global.workerId, this.nodeId, this.global.queueIndex);
if (!assignResponse.successful) {
console.error('Failed to assign element to worker:', assignResponse);
return;
}
}
} }
async function fetchWorkersForNode(nodeId) { async function fetchWorkersForNode(nodeId) {
...@@ -246,9 +254,23 @@ async function fetchElementsForNode(nodeId) { ...@@ -246,9 +254,23 @@ async function fetchElementsForNode(nodeId) {
return await response.json(); return await response.json();
} }
/*await createWebGdeInterface(null);
setDocumentControlObject(new DocumentControlWidget()); async function assignElementToWorker(workerId, nodeId, queueIndex) {
document.getElementById("input-field-container").appendChild(DOCUMENT_CONTROL_OBJECT.getWidget());*/ const response = await fetch(`${API_ROOT}/workers/${workerId}/nodes/${nodeId}/elements/${queueIndex}`);
return await response.json();
}
export function goBackToElementListViewer() {
const webGdeElement = document.querySelector('.web-gde-container');
if (webGdeElement) {
webGdeElement.remove(); // This will remove the element and its children
} else {
console.warn("Element with class 'web-gde-container' not found.");
}
// Reinstantiate and reinitialize the ElementListWidget
new ElementListWidget('Web_GDE_DEV', 'containerId');
}
......
...@@ -4,36 +4,37 @@ export const INPUT_FOLDER = "./input/" ...@@ -4,36 +4,37 @@ export const INPUT_FOLDER = "./input/"
export const OUTPUT_FILES = "../../output/" export const OUTPUT_FILES = "../../output/"
export const METRIC_FILES = "../../metrics/" export const METRIC_FILES = "../../metrics/"
export const HIGH_LIGHT_SCHEMA = "./WebGde-Widgets/sample_schema/dbSchema_anno.xlsx" export const HIGH_LIGHT_SCHEMA = "./WebGde-Widgets/sample_schema/dbSchema_anno.xlsx"
export const ROOT_FOLDER = "/WebGde-Widgets"; export const ROOT_FOLDER = "/WebGde-Widgets";
//this determines if the images will be retrieved from the gfs //this determines if the images will be retrieved from the gfs
export const DOMAIN = "http://52.207.220.74:8080" export const DOMAIN = "http://52.207.220.74:8080"
export const CONTEXTROOT = "gfs-explorer-ws" export const CONTEXTROOT = "gfs-explorer-ws"
export const GDE_URL = DOMAIN + "/MobileGdeDev/svc/gfs-rest" export const GDE_URL = DOMAIN + "/MobileGdeDev/svc/gfs-rest"
export const FOLDER_URL = DOMAIN + "/" + CONTEXTROOT + "/svc/gfs-rest/get-folder?parentPath=/Users/" export const FOLDER_URL = DOMAIN + "/" + CONTEXTROOT + "/svc/gfs-rest/get-folder?parentPath=/Users/"
export const DOWNLOAD_URL = DOMAIN + "/" + CONTEXTROOT + "/svc/gfs-rest/get-download-link" export const DOWNLOAD_URL = DOMAIN + "/" + CONTEXTROOT + "/svc/gfs-rest/get-download-link"
export const IS_RETRIEVE_FROM_GFS = "N" export const IS_RETRIEVE_FROM_GFS = "N"
export const INVALID_KEYS = "F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,PrintScreen,ScrollLock,Pause,PageUp,PageDown,Insert,Delete,Control" export const INVALID_KEYS = "F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,PrintScreen,ScrollLock,Pause,PageUp,PageDown,Insert,Delete,Control"
//BPO CONFIG //BPO CONFIG
export const IS_RETRIEVE_FROM_BPO = "N" export const IS_RETRIEVE_FROM_BPO = "Y"
// export const BPO_URL = "http://35.171.20.94:8080/bpo-sqa/" // export const BPO_URL = "http://35.171.20.94:8080/bpo-sqa/"
// export const CURRENT_NODE = "Web GDE" // export const CURRENT_NODE = "Web GDE"
export const BPO_URL = DOMAIN + "/bpo/"; export const BPO_URL = DOMAIN + "/bpo/";
export const CURRENT_NODE = "Mobile_GDE_DEV" export const CURRENT_NODE = "Web_GDE_DEV"
export const ENCODING_PASS = "PASS1" export const ENCODING_PASS = "PASS1"
export const NEXT_NODE = "Complete" export const NEXT_NODE = "Complete"
export const EXCEPTION_NODE = "Exception" export const EXCEPTION_NODE = "Exception"
export const SHOW_ELEMENT_LIST_VIEWER = "Y"
export const PDF_EXTENSION = ".pdf"
export const JPG_EXTENSION = ".jpg" export const PDF_EXTENSION = ".pdf"
export const PNG_EXTENSION = ".png" export const JPG_EXTENSION = ".jpg"
export const PNG_EXTENSION = ".png"
export const REASON_LIST = "Reason1,Reason2,Reason3,Reason4"
export const REASON_LIST = "Reason1,Reason2,Reason3,Reason4"
//KEYCLOAK CONFIG //KEYCLOAK CONFIG
window.REDIRECT_URL = 'http://auth-server/auth/realms/GFS/protocol/openid-connect/logout?redirect_uri=encodedRedirectUri'; window.REDIRECT_URL = 'http://auth-server/auth/realms/GFS/protocol/openid-connect/logout?redirect_uri=encodedRedirectUri';
import { createRejectWindow } from '../BPO/rejectElement.js'; import { createRejectWindow } from '../BPO/rejectElement.js';
import { createReturnWindow } from '../BPO/returnElement.js'; import { createReturnWindow } from '../BPO/returnElement.js';
import { goBackToElementListViewer } from '../ElementListWidget/ElementListWidget.js';
import { completeToNextNode, submitForm } from '../Submit/submit.js'; import { completeToNextNode, submitForm } from '../Submit/submit.js';
import { IS_RETRIEVE_FROM_BPO, ROOT_FOLDER } from '../config.js'; import { IS_RETRIEVE_FROM_BPO, ROOT_FOLDER, SHOW_ELEMENT_LIST_VIEWER } from '../config.js';
import { createInfoModal } from '../genericPopup/genericPopup.js'; import { createInfoModal } from '../genericPopup/genericPopup.js';
import { BPO_OBJECT, DISPLAY_FIELD_OBJECT, DOCUMENT_CONTROL_OBJECT, IMAGE_VIEWER_OBJECT, INDEXED_DB_STORAGE } from '../globalVariable.js'; import { BPO_OBJECT, DISPLAY_FIELD_OBJECT, DOCUMENT_CONTROL_OBJECT, IMAGE_VIEWER_OBJECT, INDEXED_DB_STORAGE } from '../globalVariable.js';
export class DocumentControlWidget { export class DocumentControlWidget {
global = { global = {
container: null, container: null,
submitBtn: null, submitBtn: null,
returnBtn: null, returnBtn: null,
rejectBtn: null rejectBtn: null
} }
constructor() { constructor() {
this.init(); this.init();
} }
init() { init() {
this.global.container = document.createElement("div"); this.global.container = document.createElement("div");
this.global.container.id = "TiffButtonRight"; this.global.container.id = "TiffButtonRight";
this.global.container.classList.add("ctrl-buttons") this.global.container.classList.add("ctrl-buttons")
this.global.submitBtn = document.createElement("div"); this.global.submitBtn = document.createElement("div");
this.global.submitBtn.title = "Submit"; this.global.submitBtn.title = "Submit";
this.global.submitBtn.classList.add("buttonRightClass"); this.global.submitBtn.classList.add("buttonRightClass");
const submitIcon = document.createElement("img"); const submitIcon = document.createElement("img");
submitIcon.classList.add("tiffViewerIcons"); submitIcon.classList.add("tiffViewerIcons");
submitIcon.src = "." + ROOT_FOLDER + "/documentControlWidget/assets/submit.png"; submitIcon.src = "." + ROOT_FOLDER + "/documentControlWidget/assets/submit.png";
submitIcon.alt = "Submit"; submitIcon.alt = "Submit";
submitIcon.height = "32"; submitIcon.height = "32";
submitIcon.width = "32"; submitIcon.width = "32";
this.global.returnBtn = document.createElement("div"); this.global.returnBtn = document.createElement("div");
this.global.returnBtn.title = "Return"; this.global.returnBtn.title = "Return";
this.global.returnBtn.classList.add("buttonRightClass"); this.global.returnBtn.classList.add("buttonRightClass");
const returnIcon = document.createElement("img"); const returnIcon = document.createElement("img");
returnIcon.classList.add("tiffViewerIcons"); returnIcon.classList.add("tiffViewerIcons");
returnIcon.src = "." + ROOT_FOLDER + "/documentControlWidget/assets/return_icon.png"; returnIcon.src = "." + ROOT_FOLDER + "/documentControlWidget/assets/return_icon.png";
returnIcon.alt = "Return"; returnIcon.alt = "Return";
returnIcon.height = "32"; returnIcon.height = "32";
returnIcon.width = "32"; returnIcon.width = "32";
this.global.rejectBtn = document.createElement("div"); this.global.rejectBtn = document.createElement("div");
this.global.rejectBtn.title = "Reject"; this.global.rejectBtn.title = "Reject";
this.global.rejectBtn.classList.add("buttonRightClass"); this.global.rejectBtn.classList.add("buttonRightClass");
const rejectIcon = document.createElement("img"); const rejectIcon = document.createElement("img");
rejectIcon.classList.add("tiffViewerIcons"); rejectIcon.classList.add("tiffViewerIcons");
rejectIcon.src = "." + ROOT_FOLDER + "/documentControlWidget/assets/reject_icon.png"; rejectIcon.src = "." + ROOT_FOLDER + "/documentControlWidget/assets/reject_icon.png";
rejectIcon.alt = "Reject"; rejectIcon.alt = "Reject";
rejectIcon.height = "32"; rejectIcon.height = "32";
rejectIcon.width = "32"; rejectIcon.width = "32";
this.global.submitBtn.append(submitIcon); this.global.submitBtn.append(submitIcon);
this.global.returnBtn.append(returnIcon); this.global.returnBtn.append(returnIcon);
this.global.rejectBtn.append(rejectIcon); this.global.rejectBtn.append(rejectIcon);
if(IS_RETRIEVE_FROM_BPO === "Y"){ if (IS_RETRIEVE_FROM_BPO === "Y") {
this.global.container.appendChild(this.global.submitBtn); this.global.container.appendChild(this.global.submitBtn);
this.global.container.appendChild(this.global.returnBtn); this.global.container.appendChild(this.global.returnBtn);
this.global.container.appendChild(this.global.rejectBtn); this.global.container.appendChild(this.global.rejectBtn);
} else { } else {
this.global.container.appendChild(this.global.submitBtn); this.global.container.appendChild(this.global.submitBtn);
} }
this.addEvenListeners(); this.addEvenListeners();
} }
addEvenListeners() { addEvenListeners() {
this.global.submitBtn.onclick = async (e) => { this.global.submitBtn.onclick = async (e) => {
let isSuccessful = await submitForm(e); let isSuccessful = await submitForm(e);
if (isSuccessful) { if (isSuccessful) {
DISPLAY_FIELD_OBJECT.clearForm(); DISPLAY_FIELD_OBJECT.clearForm();
createInfoModal(null, 'ok', 'Form Submitted.');
if (IS_RETRIEVE_FROM_BPO === "Y"){ if (SHOW_ELEMENT_LIST_VIEWER === "Y") {
let response = await completeToNextNode(sessionStorage.getItem("element_id")); console.log("PUMASOK DITO");
} createInfoModal(goBackToElementListViewer, 'ok', 'Form Submitted.');
} } else {
} createInfoModal(null, 'ok', 'Form Submitted.');
}
this.global.returnBtn.onclick = (e) => {
createReturnWindow(); if (IS_RETRIEVE_FROM_BPO === "Y") {
} let response = await completeToNextNode(sessionStorage.getItem("element_id"));
}
this.global.rejectBtn.onclick = (e) => { }
createRejectWindow(); }
}
this.global.returnBtn.onclick = (e) => {
} createReturnWindow();
}
getWidget() {
return this.global.container; this.global.rejectBtn.onclick = (e) => {
} createRejectWindow();
}
getSubmitBtn(){
return this.global.submitBtn; }
}
getWidget() {
getReturnBtn() { return this.global.container;
return this.global.returnBtn; }
}
getSubmitBtn() {
getRejectBtn() { return this.global.submitBtn;
return this.global.rejectBtn; }
}
getReturnBtn() {
return this.global.returnBtn;
}
getRejectBtn() {
return this.global.rejectBtn;
}
} }
...@@ -44,24 +44,26 @@ async function initializeWebGDE() { ...@@ -44,24 +44,26 @@ async function initializeWebGDE() {
// UNCOMMENTED BY ADAM 9/25/2023 // UNCOMMENTED BY ADAM 9/25/2023
sessionStorage.setItem("element_id","element1");
<<<<<<< WebGde/WebContent/script.js if (SHOW_ELEMENT_LIST_VIEWER === "Y") {
/* await createWebGdeInterface(null);*/ /* await createWebGdeInterface(null);*/
setDocumentControlObject(new DocumentControlWidget()); setDocumentControlObject(new DocumentControlWidget());
/* document.getElementById("input-field-container").appendChild(DOCUMENT_CONTROL_OBJECT.getWidget());*/ /* document.getElementById("input-field-container").appendChild(DOCUMENT_CONTROL_OBJECT.getWidget());*/
=======
await createWebGdeInterface(null);
setDocumentControlObject(new DocumentControlWidget());
document.getElementById("input-field-container").appendChild(DOCUMENT_CONTROL_OBJECT.getWidget());
>>>>>>> WebGde/WebContent/script.js
var mainLogInScreenContainer = document.getElementById("logInMainContainer"); var mainLogInScreenContainer = document.getElementById("logInMainContainer");
mainLogInScreenContainer.remove(); mainLogInScreenContainer.remove();
removeLoadingScreen(); removeLoadingScreen();
// new ElementListWidget('Web_GDE_DEV', 'containerId'); new ElementListWidget('Web_GDE_DEV', 'containerId');
} else {
await createWebGdeInterface(null);
setDocumentControlObject(new DocumentControlWidget());
document.getElementById("input-field-container").appendChild(DOCUMENT_CONTROL_OBJECT.getWidget());
var mainLogInScreenContainer = document.getElementById("logInMainContainer");
mainLogInScreenContainer.remove();
removeLoadingScreen();
}
} }
export async function createWebGdeInterface(GDEContainer) { export async function createWebGdeInterface(GDEContainer) {
...@@ -142,21 +144,13 @@ export function removeLoadingScreen() { ...@@ -142,21 +144,13 @@ export function removeLoadingScreen() {
} }
<<<<<<< WebGde/WebContent/script.js
export async function resetGDE() { export async function resetGDE() {
// TO-DO // TO-DO
} }
function init() { function init() {
console.log("Application Started"); console.log("Application Started");
=======
export async function resetGDE(){
// TO-DO
}
function init(){
console.log("Application Started");
>>>>>>> WebGde/WebContent/script.js
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment