Commit fa8b52ea by Jhunel Adam Calub

finalize functionality of encode button commit

parent d6146918
......@@ -11,7 +11,9 @@ export class ElementListWidget {
newButton: null,
encodeButton: null,
selectedElement: null,
workers: []
workers: [],
queueIndex: null,
workerId: null
};
constructor(nodeId, containerId) {
......@@ -24,8 +26,8 @@ export class ElementListWidget {
document.body.appendChild(this.global.container);
}
this.workerId = sessionStorage.getItem("user_id");
this.init(nodeId, this.workerId);
this.global.workerId = sessionStorage.getItem("user_id");
this.init(nodeId, this.global.workerId);
}
async init(nodeId, workerId) {
......@@ -110,6 +112,7 @@ export class ElementListWidget {
deselectAll();
elementContainer.classList.add("selected");
this.global.selectedElement = element;
this.global.queueIndex = element.queueIndex; // <-- Update the queueIndex here
this.showExtraDetails(element, elementContainer);
this.global.encodeButton.disabled = false;
this.global.encodeButton.classList.remove("disabled");
......@@ -209,6 +212,7 @@ export class ElementListWidget {
// Retrieve and display the selected element's ID
const elementId = sessionStorage.getItem('selectedElementId');
sessionStorage.setItem("element_id", elementId);
const elementIdDiv = document.createElement('div');
elementIdDiv.textContent = `Element ID: ${elementId}`;
elementIdDiv.classList.add('element-id');
......@@ -230,10 +234,14 @@ export class ElementListWidget {
// Append the DocumentControlWidget
setDocumentControlObject(new DocumentControlWidget());
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) {
......@@ -246,9 +254,23 @@ async function fetchElementsForNode(nodeId) {
return await response.json();
}
/*await createWebGdeInterface(null);
setDocumentControlObject(new DocumentControlWidget());
document.getElementById("input-field-container").appendChild(DOCUMENT_CONTROL_OBJECT.getWidget());*/
async function assignElementToWorker(workerId, nodeId, queueIndex) {
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/"
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";
//this determines if the images will be retrieved from the gfs
export const DOMAIN = "http://52.207.220.74:8080"
export const CONTEXTROOT = "gfs-explorer-ws"
export const GDE_URL = DOMAIN + "/MobileGdeDev/svc/gfs-rest"
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 IS_RETRIEVE_FROM_GFS = "N"
export const DOMAIN = "http://52.207.220.74:8080"
export const CONTEXTROOT = "gfs-explorer-ws"
export const GDE_URL = DOMAIN + "/MobileGdeDev/svc/gfs-rest"
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 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
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 CURRENT_NODE = "Web GDE"
export const BPO_URL = DOMAIN + "/bpo/";
export const CURRENT_NODE = "Mobile_GDE_DEV"
export const ENCODING_PASS = "PASS1"
export const NEXT_NODE = "Complete"
export const EXCEPTION_NODE = "Exception"
export const PDF_EXTENSION = ".pdf"
export const JPG_EXTENSION = ".jpg"
export const PNG_EXTENSION = ".png"
export const REASON_LIST = "Reason1,Reason2,Reason3,Reason4"
export const BPO_URL = DOMAIN + "/bpo/";
export const CURRENT_NODE = "Web_GDE_DEV"
export const ENCODING_PASS = "PASS1"
export const NEXT_NODE = "Complete"
export const EXCEPTION_NODE = "Exception"
export const SHOW_ELEMENT_LIST_VIEWER = "Y"
export const PDF_EXTENSION = ".pdf"
export const JPG_EXTENSION = ".jpg"
export const PNG_EXTENSION = ".png"
export const REASON_LIST = "Reason1,Reason2,Reason3,Reason4"
//KEYCLOAK CONFIG
window.REDIRECT_URL = 'http://auth-server/auth/realms/GFS/protocol/openid-connect/logout?redirect_uri=encodedRedirectUri';
import { createRejectWindow } from '../BPO/rejectElement.js';
import { createReturnWindow } from '../BPO/returnElement.js';
import { goBackToElementListViewer } from '../ElementListWidget/ElementListWidget.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 { BPO_OBJECT, DISPLAY_FIELD_OBJECT, DOCUMENT_CONTROL_OBJECT, IMAGE_VIEWER_OBJECT, INDEXED_DB_STORAGE } from '../globalVariable.js';
export class DocumentControlWidget {
global = {
container: null,
submitBtn: null,
returnBtn: null,
rejectBtn: null
}
constructor() {
this.init();
}
init() {
this.global.container = document.createElement("div");
this.global.container.id = "TiffButtonRight";
this.global.container.classList.add("ctrl-buttons")
this.global.submitBtn = document.createElement("div");
this.global.submitBtn.title = "Submit";
this.global.submitBtn.classList.add("buttonRightClass");
const submitIcon = document.createElement("img");
submitIcon.classList.add("tiffViewerIcons");
submitIcon.src = "." + ROOT_FOLDER + "/documentControlWidget/assets/submit.png";
submitIcon.alt = "Submit";
submitIcon.height = "32";
submitIcon.width = "32";
this.global.returnBtn = document.createElement("div");
this.global.returnBtn.title = "Return";
this.global.returnBtn.classList.add("buttonRightClass");
const returnIcon = document.createElement("img");
returnIcon.classList.add("tiffViewerIcons");
returnIcon.src = "." + ROOT_FOLDER + "/documentControlWidget/assets/return_icon.png";
returnIcon.alt = "Return";
returnIcon.height = "32";
returnIcon.width = "32";
this.global.rejectBtn = document.createElement("div");
this.global.rejectBtn.title = "Reject";
this.global.rejectBtn.classList.add("buttonRightClass");
const rejectIcon = document.createElement("img");
rejectIcon.classList.add("tiffViewerIcons");
rejectIcon.src = "." + ROOT_FOLDER + "/documentControlWidget/assets/reject_icon.png";
rejectIcon.alt = "Reject";
rejectIcon.height = "32";
rejectIcon.width = "32";
this.global.submitBtn.append(submitIcon);
this.global.returnBtn.append(returnIcon);
this.global.rejectBtn.append(rejectIcon);
if(IS_RETRIEVE_FROM_BPO === "Y"){
this.global.container.appendChild(this.global.submitBtn);
this.global.container.appendChild(this.global.returnBtn);
this.global.container.appendChild(this.global.rejectBtn);
} else {
this.global.container.appendChild(this.global.submitBtn);
}
this.addEvenListeners();
}
addEvenListeners() {
this.global.submitBtn.onclick = async (e) => {
let isSuccessful = await submitForm(e);
if (isSuccessful) {
DISPLAY_FIELD_OBJECT.clearForm();
createInfoModal(null, 'ok', 'Form Submitted.');
if (IS_RETRIEVE_FROM_BPO === "Y"){
let response = await completeToNextNode(sessionStorage.getItem("element_id"));
}
}
}
this.global.returnBtn.onclick = (e) => {
createReturnWindow();
}
this.global.rejectBtn.onclick = (e) => {
createRejectWindow();
}
}
getWidget() {
return this.global.container;
}
getSubmitBtn(){
return this.global.submitBtn;
}
getReturnBtn() {
return this.global.returnBtn;
}
getRejectBtn() {
return this.global.rejectBtn;
}
global = {
container: null,
submitBtn: null,
returnBtn: null,
rejectBtn: null
}
constructor() {
this.init();
}
init() {
this.global.container = document.createElement("div");
this.global.container.id = "TiffButtonRight";
this.global.container.classList.add("ctrl-buttons")
this.global.submitBtn = document.createElement("div");
this.global.submitBtn.title = "Submit";
this.global.submitBtn.classList.add("buttonRightClass");
const submitIcon = document.createElement("img");
submitIcon.classList.add("tiffViewerIcons");
submitIcon.src = "." + ROOT_FOLDER + "/documentControlWidget/assets/submit.png";
submitIcon.alt = "Submit";
submitIcon.height = "32";
submitIcon.width = "32";
this.global.returnBtn = document.createElement("div");
this.global.returnBtn.title = "Return";
this.global.returnBtn.classList.add("buttonRightClass");
const returnIcon = document.createElement("img");
returnIcon.classList.add("tiffViewerIcons");
returnIcon.src = "." + ROOT_FOLDER + "/documentControlWidget/assets/return_icon.png";
returnIcon.alt = "Return";
returnIcon.height = "32";
returnIcon.width = "32";
this.global.rejectBtn = document.createElement("div");
this.global.rejectBtn.title = "Reject";
this.global.rejectBtn.classList.add("buttonRightClass");
const rejectIcon = document.createElement("img");
rejectIcon.classList.add("tiffViewerIcons");
rejectIcon.src = "." + ROOT_FOLDER + "/documentControlWidget/assets/reject_icon.png";
rejectIcon.alt = "Reject";
rejectIcon.height = "32";
rejectIcon.width = "32";
this.global.submitBtn.append(submitIcon);
this.global.returnBtn.append(returnIcon);
this.global.rejectBtn.append(rejectIcon);
if (IS_RETRIEVE_FROM_BPO === "Y") {
this.global.container.appendChild(this.global.submitBtn);
this.global.container.appendChild(this.global.returnBtn);
this.global.container.appendChild(this.global.rejectBtn);
} else {
this.global.container.appendChild(this.global.submitBtn);
}
this.addEvenListeners();
}
addEvenListeners() {
this.global.submitBtn.onclick = async (e) => {
let isSuccessful = await submitForm(e);
if (isSuccessful) {
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.');
}
if (IS_RETRIEVE_FROM_BPO === "Y") {
let response = await completeToNextNode(sessionStorage.getItem("element_id"));
}
}
}
this.global.returnBtn.onclick = (e) => {
createReturnWindow();
}
this.global.rejectBtn.onclick = (e) => {
createRejectWindow();
}
}
getWidget() {
return this.global.container;
}
getSubmitBtn() {
return this.global.submitBtn;
}
getReturnBtn() {
return this.global.returnBtn;
}
getRejectBtn() {
return this.global.rejectBtn;
}
}
......@@ -44,24 +44,26 @@ async function initializeWebGDE() {
// UNCOMMENTED BY ADAM 9/25/2023
sessionStorage.setItem("element_id","element1");
<<<<<<< WebGde/WebContent/script.js
/* await createWebGdeInterface(null);*/
setDocumentControlObject(new DocumentControlWidget());
/* 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
if (SHOW_ELEMENT_LIST_VIEWER === "Y") {
/* await createWebGdeInterface(null);*/
setDocumentControlObject(new DocumentControlWidget());
/* document.getElementById("input-field-container").appendChild(DOCUMENT_CONTROL_OBJECT.getWidget());*/
var mainLogInScreenContainer = document.getElementById("logInMainContainer");
mainLogInScreenContainer.remove();
removeLoadingScreen();
var mainLogInScreenContainer = document.getElementById("logInMainContainer");
mainLogInScreenContainer.remove();
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) {
......@@ -142,21 +144,13 @@ export function removeLoadingScreen() {
}
<<<<<<< WebGde/WebContent/script.js
export async function resetGDE() {
// TO-DO
}
function init() {
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