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');
}
......
...@@ -20,14 +20,15 @@ export const IS_RETRIEVE_FROM_GFS = "N" ...@@ -20,14 +20,15 @@ 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 PDF_EXTENSION = ".pdf"
export const JPG_EXTENSION = ".jpg" export const JPG_EXTENSION = ".jpg"
......
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';
...@@ -60,7 +61,7 @@ export class DocumentControlWidget { ...@@ -60,7 +61,7 @@ export class DocumentControlWidget {
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);
...@@ -78,8 +79,15 @@ export class DocumentControlWidget { ...@@ -78,8 +79,15 @@ export class DocumentControlWidget {
if (isSuccessful) { if (isSuccessful) {
DISPLAY_FIELD_OBJECT.clearForm(); DISPLAY_FIELD_OBJECT.clearForm();
if (SHOW_ELEMENT_LIST_VIEWER === "Y") {
console.log("PUMASOK DITO");
createInfoModal(goBackToElementListViewer, 'ok', 'Form Submitted.');
} else {
createInfoModal(null, 'ok', 'Form Submitted.'); createInfoModal(null, 'ok', 'Form Submitted.');
if (IS_RETRIEVE_FROM_BPO === "Y"){ }
if (IS_RETRIEVE_FROM_BPO === "Y") {
let response = await completeToNextNode(sessionStorage.getItem("element_id")); let response = await completeToNextNode(sessionStorage.getItem("element_id"));
} }
} }
...@@ -99,7 +107,7 @@ export class DocumentControlWidget { ...@@ -99,7 +107,7 @@ export class DocumentControlWidget {
return this.global.container; return this.global.container;
} }
getSubmitBtn(){ getSubmitBtn() {
return this.global.submitBtn; return this.global.submitBtn;
} }
......
...@@ -54,13 +54,13 @@ export function createModal(okButtonAction, popupTitleText) { ...@@ -54,13 +54,13 @@ export function createModal(okButtonAction, popupTitleText) {
backdropContainer.appendChild(popupContainer); backdropContainer.appendChild(popupContainer);
document.body.appendChild(backdropContainer); document.body.appendChild(backdropContainer);
document.getElementById("popupContainer").style.display = "block"; document.getElementById("popupContainer").style.display = "block";
document.getElementById("okButton").addEventListener("click", function () { document.getElementById("okButton").addEventListener("click", function() {
document.getElementById("backdropContainer").style.display = "none"; document.getElementById("backdropContainer").style.display = "none";
if (typeof okButtonAction === "function") { if (typeof okButtonAction === "function") {
okButtonAction(); okButtonAction();
} }
}); });
document.getElementById("cancelButton").addEventListener("click", function () { document.getElementById("cancelButton").addEventListener("click", function() {
document.getElementById("backdropContainer").remove(); document.getElementById("backdropContainer").remove();
}); });
} }
...@@ -126,9 +126,11 @@ export function createInfoModal(okButtonAction, buttonTxt, popupTitleText) { ...@@ -126,9 +126,11 @@ export function createInfoModal(okButtonAction, buttonTxt, popupTitleText) {
backdropContainer.appendChild(popupContainer); backdropContainer.appendChild(popupContainer);
document.body.appendChild(backdropContainer); document.body.appendChild(backdropContainer);
document.getElementById("popupContainer").style.display = "block"; document.getElementById("popupContainer").style.display = "block";
document.getElementById("okButton").addEventListener("click", function () { document.getElementById("okButton").addEventListener("click", function() {
console.log("OK Button clicked!"); // This will let you know the button was clicked
document.getElementById("backdropContainer").style.display = "none"; document.getElementById("backdropContainer").style.display = "none";
if (typeof okButtonAction === "function") { if (typeof okButtonAction === "function") {
console.log("YES");
okButtonAction(); okButtonAction();
} }
}); });
......
...@@ -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());*/
=======
var mainLogInScreenContainer = document.getElementById("logInMainContainer");
mainLogInScreenContainer.remove();
removeLoadingScreen();
new ElementListWidget('Web_GDE_DEV', 'containerId');
} else {
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());
>>>>>>> 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');
} }
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