Commit d5ad37b7 by Owen Ryan Ang

Camera Capture

parent 61a2542d
...@@ -6,8 +6,9 @@ ...@@ -6,8 +6,9 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes> <attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
......
export function imageCapture(key) {
// Call Android function via javaScript interface
window.ImageCaptureInterface.captureImage(key);
}
\ No newline at end of file
export function processCapture(key) {
const form = document.getElementById('fields');
const img = document.getElementById('zz');
const thumb = document.getElementById('thumbnail');
const filename = document.getElementById('fname');
const x = document.getElementsByClassName('x')[0];
const filenameString = generateMediaFileName(sessionStorage.getItem('user_id'));;
// Create hidden inputs for fname and file content
const hiddenFnameInput = document.createElement('input');
hiddenFnameInput.setAttribute('id', `${key}`);
hiddenFnameInput.setAttribute('type', 'hidden');
hiddenFnameInput.setAttribute('name', 'hidden_fname');
form.appendChild(hiddenFnameInput);
const hiddenFileContentInput = document.createElement('input');
hiddenFileContentInput.setAttribute('id', `${key}`);
hiddenFileContentInput.setAttribute('type', 'hidden');
hiddenFileContentInput.setAttribute('name', 'hidden_file_content');
form.appendChild(hiddenFileContentInput);
img.style.display = 'inline';
thumb.style.display = 'none';
filename.textContent = filenameString;
filename.style.display = 'inline';
// Set the hidden inputs when a file is selected
hiddenFnameInput.value = filenameString;
hiddenFnameInput.display = '';
hiddenFileContentInput.value = img.value; // This will store the base64-encoded content of the file
hiddenFileContentInput.display = '';
document.getElementById('buttonsContainer-video').style.display = 'none';
x.style.display = 'block';
x.style.position = 'absolute';
document.getElementsByClassName('x')[0].addEventListener('click', () => {
img.style.display = 'none';
thumb.style.display = 'none';
x.style.display = 'none';
filename.style.display = 'none';
document.getElementById('buttonsContainer-video').style.display = 'flex';
// Clear the hidden fields
hiddenFnameInput.display = 'none';
hiddenFnameInput.value = '';
hiddenFileContentInput.display = 'none';
hiddenFileContentInput.value = '';
});
}
function generateMediaFileName(userId) {
// Get the current timestamp
const now = new Date();
const year = now.getFullYear();
const month = String(now.getMonth() + 1).padStart(2, '0');
const day = String(now.getDate()).padStart(2, '0');
const hours = String(now.getHours()).padStart(2, '0');
const minutes = String(now.getMinutes()).padStart(2, '0');
const seconds = String(now.getSeconds()).padStart(2, '0');
// Combine the parts to create the filename
const timestamp = `${year}${month}${day}${hours}${minutes}${seconds}`;
const fileName = `${userId}_${timestamp}.jpeg`;
return fileName;
}
\ No newline at end of file
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
box-sizing: border-box; box-sizing: border-box;
} }
.text-style { .text-style {
color: white; color: white;
text-align: center; text-align: center;
......
import { GFS_URL } from "../config.js";
export const urlFileUpload = GFS_URL + "/upload-file";
export const uploadDirectory = "C:\\Users\\oang\\Desktop\\Mobile GDE\\test for upload"
import { uploadDirectory, urlFileUpload } from "./config.js";
export const uploadFile = async (file, projectCode) => {
const fileNameInput = generateFormattedString(projectCode);
const directoryInput = uploadDirectory;
const fileName = fileNameInput.trim();
const directory = directoryInput.trim();
if (fileName === '' || directory === '') {
console.log("Please enter a valid file name and directory.");
return;
}
const formData = new FormData();
formData.append('file', file);
formData.append('fileName', fileName);
formData.append('directory', directory);
fetch(urlFileUpload, {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
console.log('File uploaded successfully:', data);
})
.catch(error => {
console.error('Error uploading file:', error);
});
}
function generateFormattedString(projectCode) {
// Get the current date and time
const currentDate = new Date();
// Format the date and time components
const year = currentDate.getFullYear();
const month = String(currentDate.getMonth() + 1).padStart(2, '0'); // Month is zero-based, so add 1 and pad with '0' if needed
const date = String(currentDate.getDate()).padStart(2, '0'); // Pad with '0' if needed
const hours = String(currentDate.getHours()).padStart(2, '0');
const minutes = String(currentDate.getMinutes()).padStart(2, '0');
const seconds = String(currentDate.getSeconds()).padStart(2, '0');
const milliseconds = String(currentDate.getMilliseconds()).padStart(3, '0'); // Milliseconds are padded with '0' up to 3 digits
// Combine the formatted components into the final string
const formattedString = `${projectCode}_${year}${month}${date}_${hours}${minutes}${seconds}${milliseconds}`;
return formattedString;
}
import { getUrlCompleteToNextNode } from "../BPO/bpoService.js"; import { getUrlCompleteToNextNode } from "../BPO/bpoService.js";
import { saveForm } from "../DataInputWidget/generateFields.js"; import { saveForm } from "../DataInputWidget/generateFields.js";
import { checkValidValues, validateInput } from "../DataInputWidget/validateInput.js"; import { checkValidValues, validateInput } from "../DataInputWidget/validateInput.js";
import { uploadFile } from "../FileUpload/fileUpload.js";
import { global_end_time, saveMetrics, stopMetricCapture, setGlobalEndTime, interval } from "../captureMetrics/captureMetrics.js"; import { global_end_time, saveMetrics, stopMetricCapture, setGlobalEndTime, interval } from "../captureMetrics/captureMetrics.js";
import { createInfoModal } from "../genericPopup/genericPopup.js"; import { createInfoModal } from "../genericPopup/genericPopup.js";
import { Settings } from "./XMLWriter/Global.js"; import { Settings } from "./XMLWriter/Global.js";
import { WriteForm } from "./XMLWriter/XML_Saver.js"; import { WriteForm } from "./XMLWriter/XML_Saver.js";
import { PROJECT_CODE } from "./config.js";
export const submitForm = async (e) => { export const submitForm = async (e) => {
try { try {
setGlobalEndTime(new Date().toLocaleString()); setGlobalEndTime(new Date().toLocaleString());
const Form = document.getElementById("fields"); const Form = document.getElementById("fields");
const { elements } = Form const { elements } = Form
let error = false; let error = false;
let errorMsg = null; let errorMsg = null;
let doctype; let doctype;
let section; let section;
// Validate all elements again // Validate all elements again
for (let element of elements) { for (let element of elements) {
if (element.style.display === 'none') continue if (element.style.display === 'none') continue
const { id, value, type } = element const { id, value, type } = element
const { valid } = validateInput(id, value) const { valid } = validateInput(id, value)
// Skip submit button // Skip submit button
if (type === 'submit') continue if (type === 'button') continue
if (id === 'DocType') { if (type === 'submit') continue
doctype = element.options[element.selectedIndex].text; // Handle file uploads
continue; if (type === 'file') {
} const fileInput = element;
if (id === 'Section') { const files = fileInput.files;
section = element.options[element.selectedIndex].text; if (files.length > 0) {
continue; const file = files[0];
} uploadFile(file, PROJECT_CODE);
}
}
if (id === 'DocType') {
doctype = element.options[element.selectedIndex].text;
continue;
}
if (id === 'Section') {
section = element.options[element.selectedIndex].text;
continue;
}
var { isValidValue, errMsg } = checkValidValues(id, value); var { isValidValue, errMsg } = checkValidValues(id, value);
if (typeof errMsg !== "undefined") { if (typeof errMsg !== "undefined") {
errorMsg = errMsg; errorMsg = errMsg;
} }
// Update display of input field if input is not valid // Update display of input field if input is not valid
if (!valid) { if (!valid) {
error = true error = true
if (type === 'select-one') { if (type === 'select-one') {
continue continue
} }
const field = document.getElementById(id) const field = document.getElementById(id)
const newEvent = new Event('focusout') const newEvent = new Event('focusout')
field.dispatchEvent(newEvent) field.dispatchEvent(newEvent)
} }
if (!isValidValue) { if (!isValidValue) {
error = true error = true
const field = document.getElementById(id); const field = document.getElementById(id);
field.classList.remove('input-valid'); field.classList.remove('input-valid');
field.classList.add('input-invalid'); field.classList.add('input-invalid');
field.select(); field.select();
} }
} }
// Update display of dropdown field if input is not valid // Update display of dropdown field if input is not valid
const dropdowns = $('.dropdown-input').select2(); const dropdowns = $('.dropdown-input').select2();
for (let dropdown of dropdowns) { for (let dropdown of dropdowns) {
const newEvent = new Event('select2:close') const newEvent = new Event('select2:close')
dropdown.dispatchEvent(newEvent) dropdown.dispatchEvent(newEvent)
} }
if (error) { if (error) {
if (errorMsg !== null) { if (errorMsg !== null) {
createInfoModal(null, 'OK',errorMsg); createInfoModal(null, 'OK', errorMsg);
} else { } else {
createInfoModal(null, 'OK', 'Invalid or Missing data on highlighted fields!'); createInfoModal(null, 'OK', 'Invalid or Missing data on highlighted fields!');
} }
return false return false
} }
else { else {
const metrics = stopMetricCapture(); const metrics = stopMetricCapture();
await WriteForm(e, metrics, doctype, section); await WriteForm(e, metrics, doctype, section);
saveForm(sessionStorage.getItem("display_counter")); saveForm(sessionStorage.getItem("display_counter"));
} }
return true return true
} catch (err) { } catch (err) {
console.log(err) console.log(err)
return false return false
} }
} }
export async function completeToNextNode(elementId) { export async function completeToNextNode(elementId) {
let requestJSON = { let requestJSON = {
"productionOutputUnits": { "productionOutputUnits": {
"keystroke": { "keystroke": {
"outputCount": 0, "outputCount": 0,
"errorCount": 0 "errorCount": 0
} }
} }
}; };
let response = await fetch(getUrlCompleteToNextNode(elementId), { let response = await fetch(getUrlCompleteToNextNode(elementId), {
method: "POST", method: "POST",
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify(requestJSON) body: JSON.stringify(requestJSON)
}); });
return response; return response;
} }
...@@ -38,9 +38,9 @@ export const HIGH_LIGHT_SCHEMA = "./WebGde-Widgets/sample_schema/dbSchema_anno. ...@@ -38,9 +38,9 @@ export const HIGH_LIGHT_SCHEMA = "./WebGde-Widgets/sample_schema/dbSchema_anno.
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://3.86.35.226:8080" export const DOMAIN = "http://3.84.219.51:8080"
export const CONTEXTROOT = "gfs-explorer-ws" export const CONTEXTROOT = "gfs-explorer-ws"
export const GFS_URL = "http://3.86.35.226:8080" + "/MobileGde/svc/gfs-rest" export const GFS_URL = "http://3.84.219.51:8080" + "/MobileGde/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"
...@@ -51,7 +51,7 @@ export const INVALID_KEYS = "F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,PrintScreen ...@@ -51,7 +51,7 @@ export const INVALID_KEYS = "F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,PrintScreen
export const IS_RETRIEVE_FROM_BPO = "Y" 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 = "http://3.86.35.226:8080/bpo/" export const BPO_URL = "http://3.84.219.51:8080/bpo/"
export const CURRENT_NODE = "Mobile_GDE_DEV" export const CURRENT_NODE = "Mobile_GDE_DEV"
export const ENCODING_PASS = "PASS1" export const ENCODING_PASS = "PASS1"
export const NEXT_NODE = "Complete" export const NEXT_NODE = "Complete"
......
import { displayField } from "./WebGde-Widgets/DataInputWidget/displayFieldClass.js"; import { displayField } from "./WebGde-Widgets/DataInputWidget/displayFieldClass.js";
import { fetchSchema } from "./WebGde-Widgets/DataInputWidget/fetchSchema.js"; import { fetchSchema } from "./WebGde-Widgets/DataInputWidget/fetchSchema.js";
import { schema } from "./WebGde-Widgets/DataInputWidget/generateFields.js";
// import { DocumentControlWidget } from "./WebGde-Widgets/documentControlWidget/documentControlWidget.js"; // import { DocumentControlWidget } from "./WebGde-Widgets/documentControlWidget/documentControlWidget.js";
import { INDEXED_DB_STORAGE, HIGHLIGHT_OBJECT, IMAGE_VIEWER_OBJECT, INDEXED_DB_NAME, INDEXED_DB_TBL_NAME, setIndexedDBStorage, setHighlightObject, setImageViewerObject, setBPOObject, BPO_OBJECT, DISPLAY_FIELD_OBJECT, setDisplayFieldObject, activateGDE, setDocumentControlObject, DOCUMENT_CONTROL_OBJECT, IS_GDE_ACTIVATED } from "./WebGde-Widgets/globalVariable.js"; import { INDEXED_DB_STORAGE, HIGHLIGHT_OBJECT, IMAGE_VIEWER_OBJECT, INDEXED_DB_NAME, INDEXED_DB_TBL_NAME, setIndexedDBStorage, setHighlightObject, setImageViewerObject, setBPOObject, BPO_OBJECT, DISPLAY_FIELD_OBJECT, setDisplayFieldObject, activateGDE, setDocumentControlObject, DOCUMENT_CONTROL_OBJECT, IS_GDE_ACTIVATED } from "./WebGde-Widgets/globalVariable.js";
...@@ -13,7 +14,7 @@ export async function startApplication(){ ...@@ -13,7 +14,7 @@ export async function startApplication(){
} }
async function initializeWebGDE(){ async function initializeWebGDE(){
sessionStorage.setItem('user_id','worker1')
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());
...@@ -101,4 +102,49 @@ export function removeLoadingScreen() { ...@@ -101,4 +102,49 @@ export function removeLoadingScreen() {
function init(){ function init(){
console.log("Application Started"); console.log("Application Started");
} }
\ No newline at end of file
function testFunction(){
try {
let doctype;
let section;
const Form = document.getElementById("fields");
const { elements } = Form
for (let element of elements) {
if (element.style.display === 'none') continue
const { id, value, type } = element
if (id === 'DocType') {
doctype = element.options[element.selectedIndex].text;
continue;
}
if (id === 'Section') {
section = element.options[element.selectedIndex].text;
continue;
}
}
var Frm= document.getElementById("fields");
var Nodes=Frm.elements;
// const myArray = Object.values(metrics);
const lookup = schema[doctype][section]
localStorage.setItem("submit", "1");
if (true) {
let fields = {};
for (var i=0;i<Nodes.length;i++) {
if (Nodes[i].style.display === 'none') continue
let fid = Nodes[i].id;
if (fid == 'DocType' || fid == 'Section' || fid == '' || fid == "submitButton") continue
if (Nodes[i].type === 'button' || Nodes[i].type === 'submit') continue; // Skip elements of type "button" and "submit"
fields[Object.keys(lookup[fid]).includes('aka') ? lookup[fid].aka.replace("field", "") : fid] = Nodes[i].value;
console.log(Nodes[i].id + ": "+Nodes[i].value);
}
// await createOutputXml(fields, myArray, doctype, section);
}
}catch{
console.log("error");
}
}
window.testFunction = testFunction;
\ No newline at end of file
...@@ -8,24 +8,32 @@ ...@@ -8,24 +8,32 @@
font-style: normal; font-style: normal;
} }
.remove-button {
display: inline-block;
padding: 2px 6px;
background-color: red;
color: white;
font-size: 12px;
cursor: pointer;
border-radius: 50%;
margin-left: 5px;
}
.field-header { .field-header {
color: white; color: white;
text-align: center; text-align: center;
} }
h1 { h1 {
margin: 10px; display: none;
} }
h2 { h2 {
margin-top: 10px; display: none;
margin-bottom: 10px;
} }
h3 { h3 {
margin-bottom: 10px; display: none;
color: white;
text-align: center;
} }
.web-gde-container { .web-gde-container {
...@@ -64,9 +72,11 @@ h3 { ...@@ -64,9 +72,11 @@ h3 {
margin: 2vh; margin: 2vh;
} }
#zz, #thumbnail { #zz,
#thumbnail {
margin-top: 5px; margin-top: 5px;
} }
#pause { #pause {
background: no-repeat center/75% url("./WebGde-Widgets/resources/pause_icon.png"); background: no-repeat center/75% url("./WebGde-Widgets/resources/pause_icon.png");
height: 3vh; height: 3vh;
...@@ -254,7 +264,6 @@ input[type=text] { ...@@ -254,7 +264,6 @@ input[type=text] {
input[type=checkbox], input[type=checkbox],
input[type=radio] { input[type=radio] {
margin-right: 8px; margin-right: 8px;
} }
.dropdown-content { .dropdown-content {
...@@ -266,12 +275,12 @@ input[type=radio] { ...@@ -266,12 +275,12 @@ input[type=radio] {
.radio-like-checkbox { .radio-like-checkbox {
display: flex; display: flex;
padding: 5px; padding: 3px;
} }
.checkbox { .checkbox {
display: flex; display: flex;
padding: 5px; padding: 3px;
} }
.dash { .dash {
...@@ -285,10 +294,40 @@ input[type=radio] { ...@@ -285,10 +294,40 @@ input[type=radio] {
flex-direction: column; flex-direction: column;
width: 100%; width: 100%;
padding: 4px; padding: 4px;
/* padding-bottom: 10px;
padding-top: 20px; */
border: thin solid #555; border: thin solid #555;
position: relative;
height: 100%;
align-items: center;
}
.x {
display: none;
position: absolute;
top: 15px;
left: 7px;
padding: 2px 6px;
background-color: red;
color: white;
font-size: inherit;
cursor: pointer;
border-radius: 50%;
margin-left: 5px;
}
/* Style for the video element (thumbnail) */
video#thumbnail {
display: none;
width: 100%;
height: 100%;
object-fit: cover;
}
/* Style for the image element (thumbnail) */
img#zz {
display: none;
width: 100%;
height: 100%;
object-fit: cover;
} }
input[type=file]::file-selector-button { input[type=file]::file-selector-button {
...@@ -310,8 +349,9 @@ input[type=file] { ...@@ -310,8 +349,9 @@ input[type=file] {
} }
input[type=button] { input[type=button] {
width: 100%;
padding: 5px 10px 5px 10px; padding: 5px 10px 5px 10px;
margin: 4px;
border: none; border: none;
outline: none; outline: none;
border-radius: 2px; border-radius: 2px;
...@@ -381,6 +421,11 @@ textarea { ...@@ -381,6 +421,11 @@ textarea {
height: 103px; height: 103px;
} }
.buttonsContainer {
display: flex;
flex-direction: column;
width: 100%;
}
.ctrl-buttons { .ctrl-buttons {
background-color: transparent !important; background-color: transparent !important;
...@@ -388,6 +433,18 @@ textarea { ...@@ -388,6 +433,18 @@ textarea {
justify-content: space-evenly !important; justify-content: space-evenly !important;
} }
span#filename {
text-overflow: ellipsis;
width: 90%;
overflow: hidden;
align-self: center;
}
.filename-container {
overflow: hidden;
justify-content: space-between;
width: 100%;
}
.ctrl-buttons .buttonRightClass { .ctrl-buttons .buttonRightClass {
margin: 1vh; margin: 1vh;
...@@ -408,9 +465,7 @@ textarea { ...@@ -408,9 +465,7 @@ textarea {
text-align: center; text-align: center;
} }
#butt .genericPopup {
.genericPopup {
background-color: #000000a1; background-color: #000000a1;
display: -webkit-inline-box; display: -webkit-inline-box;
width: 100%; width: 100%;
...@@ -466,9 +521,6 @@ textarea { ...@@ -466,9 +521,6 @@ textarea {
padding: 4px 0px 5px 8px; padding: 4px 0px 5px 8px;
text-align: left; text-align: left;
} }
/* LOader css */ /* LOader css */
.modal-container { .modal-container {
display: block; display: block;
...@@ -499,7 +551,6 @@ textarea { ...@@ -499,7 +551,6 @@ textarea {
} }
@keyframes mulShdSpin { @keyframes mulShdSpin {
0%, 0%,
100% { 100% {
box-shadow: 0em -2.6em 0em 0em #ffffff, 1.8em -1.8em 0 0em rgba(255, 255, 255, 0.2), 2.5em 0em 0 0em rgba(255, 255, 255, 0.2), 1.75em 1.75em 0 0em rgba(255, 255, 255, 0.2), 0em 2.5em 0 0em rgba(255, 255, 255, 0.2), -1.8em 1.8em 0 0em rgba(255, 255, 255, 0.2), -2.6em 0em 0 0em rgba(255, 255, 255, 0.5), -1.8em -1.8em 0 0em rgba(255, 255, 255, 0.7); box-shadow: 0em -2.6em 0em 0em #ffffff, 1.8em -1.8em 0 0em rgba(255, 255, 255, 0.2), 2.5em 0em 0 0em rgba(255, 255, 255, 0.2), 1.75em 1.75em 0 0em rgba(255, 255, 255, 0.2), 0em 2.5em 0 0em rgba(255, 255, 255, 0.2), -1.8em 1.8em 0 0em rgba(255, 255, 255, 0.2), -2.6em 0em 0 0em rgba(255, 255, 255, 0.5), -1.8em -1.8em 0 0em rgba(255, 255, 255, 0.7);
...@@ -561,14 +612,10 @@ textarea { ...@@ -561,14 +612,10 @@ textarea {
color: red; color: red;
} }
@media only screen and (orientation: portrait) { @media only screen and (orientation: portrait) {
* { * {
-webkit-font-smoothing: auto; -webkit-font-smoothing: auto;
font-size: 16px; font-size: 17px;
letter-spacing: 0.1em; letter-spacing: 0.1em;
text-rendering: optimizeLegibility; text-rendering: optimizeLegibility;
font-weight: normal; font-weight: normal;
...@@ -577,18 +624,15 @@ textarea { ...@@ -577,18 +624,15 @@ textarea {
} }
h1 { h1 {
margin: 0px; display: none;
} }
h2 { h2 {
margin-top: 10px; display: none;
margin-bottom: 10px;
} }
h3 { h3 {
/* margin-bottom: 20px; */ display: none;
color: white;
text-align: center;
} }
.web-gde-container { .web-gde-container {
...@@ -610,15 +654,25 @@ textarea { ...@@ -610,15 +654,25 @@ textarea {
background-image: linear-gradient(to bottom, #23569f, #00a8c0); background-image: linear-gradient(to bottom, #23569f, #00a8c0);
} }
.remove-button {
display: inline-block;
padding: 2px 6px;
background-color: red;
color: white;
font-size: 16px;
cursor: pointer;
border-radius: 50%;
margin-left: 5px;
}
#input-field-container { #input-field-container {
/* height : 600px;
width : 400px; */
height: 100%; height: 100%;
width: 100%; width: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
overflow: auto; overflow: auto;
background-image: linear-gradient(to bottom, #23569f, #00a8c0); background-image: linear-gradient(to bottom, #23569f, #00a8c0);
justify-content: space-between;
} }
.dash { .dash {
...@@ -633,7 +687,7 @@ textarea { ...@@ -633,7 +687,7 @@ textarea {
flex-direction: column; flex-direction: column;
border: none; border: none;
outline: none; outline: none;
padding: 0px 5px 10px 4px; padding: 0px 4px 20px 4px;
flex-wrap: nowrap; flex-wrap: nowrap;
} }
...@@ -646,33 +700,28 @@ textarea { ...@@ -646,33 +700,28 @@ textarea {
flex-direction: column; flex-direction: column;
width: 100%; width: 100%;
padding: 20px; padding: 20px;
/* padding-bottom: 10px;
padding-top: 20px; */
border-radius: 2px; border-radius: 2px;
border: 2px dashed #555; border: solid;
color: #444; border-width: thin;
border-color: gray;
cursor: pointer; cursor: pointer;
align-items: center;
} }
#fields { #fields {
/* margin: 17px; */
margin-left: 17px; margin-left: 17px;
margin-right: 17px; margin-right: 17px;
padding: 18px; padding: 18px;
border-radius: 25px; border-radius: 15px;
width: auto;
height: auto;
background-color: white; background-color: white;
overflow-y: auto; overflow-y: auto;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
flex: unset;
max-height: 100vh;
border-style: solid; border-style: solid;
border-width: thin; border-width: thin;
border-color: #446397; border-color: #446397;
/* box-shadow: 0px 0px 1px 1px rgba(0, 0, 0, 0.75) inset;
-webkit-box-shadow: 0px 0px 1px 1px rgba(0, 0, 0, 0.75) inset;
-moz-box-shadow: 0px 0px 1px 1px rgba(0, 0, 0, 0.75) inset; */
} }
#fields>div { #fields>div {
...@@ -702,8 +751,7 @@ textarea { ...@@ -702,8 +751,7 @@ textarea {
} }
@media only screen and (max-width: 430px) { @media only screen and (max-width: 530px) {
.date-range { .date-range {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
...@@ -717,22 +765,15 @@ textarea { ...@@ -717,22 +765,15 @@ textarea {
} }
} }
.dash { .dash {
display: unset; display: unset;
align-self: center; align-self: center;
padding: 6px; padding: 6px;
} }
.date-range { .date-range {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
/* padding: 20px 0px 20px 0px; */
/* border-style: solid;
border-width: thin;
border-color: gray;
background-color: #e7e7e7; */
} }
.dateContainer { .dateContainer {
...@@ -740,7 +781,7 @@ textarea { ...@@ -740,7 +781,7 @@ textarea {
} }
label { label {
font-size: 14px; font-size: 16px;
font-weight: 700; font-weight: 700;
} }
...@@ -769,7 +810,8 @@ textarea { ...@@ -769,7 +810,8 @@ textarea {
overflow-x: clip; overflow-x: clip;
flex-wrap: nowrap; flex-wrap: nowrap;
flex-grow: 1; flex-grow: 1;
border-radius: 2px border-radius: 2px;
padding: 1px;
} }
.input-invalid { .input-invalid {
...@@ -801,20 +843,20 @@ textarea { ...@@ -801,20 +843,20 @@ textarea {
input[type=checkbox], input[type=checkbox],
input[type=radio] { input[type=radio] {
width: 16px; width: 20px;
height: 19px; height: 20px;
margin-right: 15px; margin-right: 15px;
margin-top: 1px;
} }
.radio-like-checkbox { .radio-like-checkbox {
display: flex; display: flex;
padding: 5px; padding: 3px;
} }
.checkbox { .checkbox {
display: flex; display: flex;
padding: 5px; padding: 3px;
} }
input[type=file]::file-selector-button { input[type=file]::file-selector-button {
...@@ -822,9 +864,6 @@ textarea { ...@@ -822,9 +864,6 @@ textarea {
border-radius: 2px; border-radius: 2px;
border: none; border: none;
outline: none; outline: none;
/* border-style: solid;
border-width: thin;
border-color: gray; */
background-color: #00a8c0; background-color: #00a8c0;
color: white; color: white;
} }
...@@ -842,6 +881,7 @@ textarea { ...@@ -842,6 +881,7 @@ textarea {
input[type=button] { input[type=button] {
width: 100%; width: 100%;
padding: 5px; padding: 5px;
margin: unset;
border: none; border: none;
outline: none; outline: none;
border-radius: 2px; border-radius: 2px;
...@@ -870,7 +910,6 @@ textarea { ...@@ -870,7 +910,6 @@ textarea {
padding: 20px; padding: 20px;
} }
#text-area { #text-area {
width: 91%; width: 91%;
font-size: 11px; font-size: 11px;
...@@ -883,3 +922,10 @@ textarea { ...@@ -883,3 +922,10 @@ textarea {
} }
@media only screen and (max-width: 1100px) {
.date-range {
display: flex;
flex-direction: column;
justify-content: space-between;
}
}
\ No newline at end of file
...@@ -8,6 +8,7 @@ import java.io.IOException; ...@@ -8,6 +8,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.TimeZone; import java.util.TimeZone;
...@@ -298,16 +299,39 @@ public class GDEWebServices { ...@@ -298,16 +299,39 @@ public class GDEWebServices {
public Response uploadFile(@FormDataParam("file") InputStream fileInputStream, public Response uploadFile(@FormDataParam("file") InputStream fileInputStream,
@FormDataParam("fileName") String fileName, @FormDataParam("fileName") String fileName,
@FormDataParam("directory") String directory) { @FormDataParam("directory") String directory) {
String filePath = directory + File.separator + fileName; // Sanitize the file name and directory path
try { String sanitizedFileName = sanitizeFileName(fileName);
Files.copy(fileInputStream, new File(filePath).toPath()); String sanitizedDirectory = sanitizeDirectory(directory);
JSONObject responseJson = new JSONObject();
responseJson.put("status", 200); // Create the final directory path
return Response.ok(responseJson.toString()).build(); String finalDirectory = sanitizedDirectory;
} catch (IOException e) {
// TODO Auto-generated catch block try {
e.printStackTrace(); // Create the directory if it doesn't exist
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); File directoryFile = new File(finalDirectory);
} if (!directoryFile.exists()) {
directoryFile.mkdirs();
}
// Save the file in the specified directory
Files.copy(fileInputStream, Paths.get(finalDirectory, sanitizedFileName));
JSONObject responseJson = new JSONObject();
responseJson.put("status", 200);
return Response.ok(responseJson.toString()).build();
} catch (IOException e) {
e.printStackTrace();
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
private String sanitizeDirectory(String directory) {
// Remove directory traversal sequences
return directory.replaceAll("\\.\\.", "");
}
private String sanitizeFileName(String fileName) {
// Remove special characters, spaces, and directory separators
return fileName.replaceAll("[^a-zA-Z0-9.-]", "_");
} }
} }
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