From b2912064b587752a61f90775ad367450fc52a60b Mon Sep 17 00:00:00 2001 From: ske087 Date: Wed, 30 Apr 2025 16:22:07 +0300 Subject: [PATCH] Added Pages --- py_app/app/__pycache__/routes.cpython-311.pyc | Bin 22629 -> 25534 bytes py_app/app/routes.py | 48 +++++- py_app/app/static/script.js | 150 +++++++++++++++++- py_app/app/static/style.css | 59 +++---- py_app/app/templates/create_template.html | 50 ++++++ py_app/app/templates/label_templates.html | 31 ++++ py_app/app/templates/main_page_etichete.html | 24 +++ py_app/app/templates/print_module.html | 10 ++ py_app/app/templates/upload_data.html | 10 ++ 9 files changed, 339 insertions(+), 43 deletions(-) create mode 100644 py_app/app/templates/create_template.html create mode 100644 py_app/app/templates/label_templates.html create mode 100644 py_app/app/templates/print_module.html create mode 100644 py_app/app/templates/upload_data.html diff --git a/py_app/app/__pycache__/routes.cpython-311.pyc b/py_app/app/__pycache__/routes.cpython-311.pyc index 534dcab22a4cb41a3992c009054bccabe86bc88f..b55633986cd332d2e3c220bbf2e3f69d5de22201 100644 GIT binary patch delta 2706 zcmbtVOKcle6n$?z`P5@OzqWFIVA?vdo5T~_0jiMZgHmV(ia;q)p-RE=OcT?w6TNX- zuu_ewkYK^0#fwI&Kv5S(Q4sL)8UnrWy%hfy5>o7RV?&*l^$cVvo}liKm%6 zSNEN{@7y!@z1jX0e{&ZHKJxp$2*$6$_QkQ2*8@T3kA}}8-+8Wo(s{J+Hb&?U+~yGa z-$u8=y<-Q^t4Ap;;(|r%V8WJ6P zMQDnID@C#n7NxKe7wqvm*m1hj6R=X}lXY_g0-iCW8FI;aBiTyqdGzYu4MrEn3+OrRi@ZtJ}Yft(g^R8DQd>483t44c5zCId=8;= zkXvp8r--(>F133|<6=4&Q`wmDTEWjRlT0o@mt7K8B=P^TY^zSC7(B@)<>q4PtHzNp z0CC>MGNy67&haYCn=D&-DK#%jb9phlET!_I{BWWQq=m7!o(Em&9?Z4Hg(O>$^fjQn zQzdF#;}SZTP}zh{H%$}~cshh1&evf3Ai8N%lWiZm4pK3dB3~IIz(@EJ9Fty%7llmT z;l__a1B}|z&Six0G}Pw|20YrZJ3cTsfZ-~-i9TS=#yorqGKK7SLzgr8#n74Q5PWga ze*>2}dkWIZG;7FgRDTTv@-56P(jI6Br-&+z$d_1uPUYhCV&f+5BfKC=VwI@-5{LEo zWgeV1lI_VIg!&qYR1>|ipmb_pa`h|=vxcgJ z;M_n9pzAGsrS>RbR#B$@IPlCwJ>^CtW!!outY^}C%27-dKO~0d5Adii#Jfv~+=V$p zYd8XqA$wp@^$);ReC9W<{o3iZ3u;GL2Pi6be&)_pkN-s$(*<9^DbZR1yuJj=r zE6t9!E31gGP#$v&=kNl$g7ZxNj1Pb*VcUTS*p;PwaaQpzs5y$E~2s#Q=tGar!Luh9~!J?^E)EtU_E;F zmxjFuOZU24+EBg$Le`+$tQ7A#q*SZL2%bIFDzwd}E@g5HPBV{&%1v2OmQxF2q35i1 zXoe^&AtbM)(=c^mMUvip%#yC$OeJ|;UdoXp=L0b)pgi`_i`(m#yiLk#;) z@M`egn1(xb+*x5T<|_!yUmnDCIgv&i$7>j(T@*J=al;hX?L=&x>g~~Rua0{uFiC+) z3Vg(gm_X%f@IN9ca8ScTIv%Pp3{F%K7@9KXM4By*syDWEc&oV>)bNy!rzm`c!bd3l zY3zgmub9OTX*j6kV1@DE{t5y^ksyZ^@!G{ZBC$AHL0~A(6p2P`F;#EZ`pfI5DFKr& VizhL~PvTw1My%Bcnp4Kt{ukwgeJub0 delta 86 zcmdmYobl-fM!w~|yj%=GaQ2B{Mv?hMJ_)8n%o{ZhFtepF1~X`?Z5Csj5Wu9VJXtqx k$7G>+N$wp$wTwVq%*4FeEdDnW9|H@c*#{6&WCs)m03xOpg#Z8m diff --git a/py_app/app/routes.py b/py_app/app/routes.py index fc487b8..ddf48c3 100644 --- a/py_app/app/routes.py +++ b/py_app/app/routes.py @@ -339,4 +339,50 @@ def etichete(): if 'role' not in session or session['role'] not in ['superadmin', 'etichete']: flash('Access denied: Etichete users only.') return redirect(url_for('main.dashboard')) - return render_template('main_page_etichete.html') \ No newline at end of file + return render_template('main_page_etichete.html') + +@bp.route('/upload_data') +def upload_data(): + return render_template('upload_data.html') + +@bp.route('/print_module') +def print_module(): + return render_template('print_module.html') + +@bp.route('/label_templates') +def label_templates(): + return render_template('label_templates.html') + +@bp.route('/create_template') +def create_template(): + return render_template('create_template.html') + +@bp.route('/edit_template/') +def edit_template(template_id): + # Logic for editing a template will go here + return f"Edit template with ID {template_id}" + +@bp.route('/delete_template/', methods=['POST']) +def delete_template(template_id): + # Logic for deleting a template will go here + return f"Delete template with ID {template_id}" + +@bp.route('/get_tables') +def get_tables(): + # Replace with logic to fetch tables from your database + tables = ['table1', 'table2', 'table3'] + return jsonify({'tables': tables}) + +@bp.route('/get_columns') +def get_columns(): + table = request.args.get('table') + # Replace with logic to fetch columns for the selected table + columns = ['column1', 'column2', 'column3'] if table else [] + return jsonify({'columns': columns}) + +@bp.route('/save_template', methods=['POST']) +def save_template(): + data = request.get_json() + # Replace with logic to save the template to the database + print(f"Saving template: {data}") + return jsonify({'message': 'Template saved successfully!'}) \ No newline at end of file diff --git a/py_app/app/static/script.js b/py_app/app/static/script.js index 424542a..449d893 100644 --- a/py_app/app/static/script.js +++ b/py_app/app/static/script.js @@ -158,11 +158,149 @@ document.addEventListener('DOMContentLoaded', () => { alert('Exporting current report as PDF...'); // Add logic to export the current report as PDF }); - - - - - - +}); + +document.addEventListener('DOMContentLoaded', () => { + const templateList = document.getElementById('template-list'); + const createTemplateBtn = document.getElementById('create-template-btn'); + + // Example: Handle the "Create New Template" button click + createTemplateBtn.addEventListener('click', () => { + window.location.href = '/create_template'; + }); + + // Example: Handle the "Edit" and "Delete" buttons + templateList.addEventListener('click', (event) => { + if (event.target.classList.contains('edit-btn')) { + const templateId = event.target.closest('li').dataset.id; + window.location.href = `/edit_template/${templateId}`; + } else if (event.target.classList.contains('delete-btn')) { + const templateId = event.target.closest('li').dataset.id; + if (confirm('Are you sure you want to delete this template?')) { + fetch(`/delete_template/${templateId}`, { method: 'POST' }) + .then(response => response.text()) + .then(data => { + alert(data); + // Optionally, remove the template from the list + event.target.closest('li').remove(); + }); + } + } + }); +}); + + +document.addEventListener('DOMContentLoaded', () => { + const setDimensionsBtn = document.getElementById('set-dimensions-btn'); + const getTablesBtn = document.getElementById('get-tables-btn'); + const tablesContainer = document.getElementById('tables-container'); + const columnsContainer = document.getElementById('columns-container'); + const labelPreview = document.getElementById('label-preview'); + const saveTemplateBtn = document.getElementById('save-template-btn'); + + // Handle setting dimensions + setDimensionsBtn.addEventListener('click', () => { + const width = document.getElementById('label-width').value; + const height = document.getElementById('label-height').value; + + if (width && height) { + alert(`Label dimensions set to ${width}mm x ${height}mm.`); + } else { + alert('Please enter valid dimensions.'); + } + }); + + // Handle fetching database tables + getTablesBtn.addEventListener('click', () => { + fetch('/get_tables') + .then(response => response.json()) + .then(data => { + tablesContainer.innerHTML = '

Select a Table:

'; + data.tables.forEach(table => { + const button = document.createElement('button'); + button.textContent = table; + button.classList.add('btn'); + button.addEventListener('click', () => fetchColumns(table)); + tablesContainer.appendChild(button); + }); + }) + .catch(error => console.error('Error fetching tables:', error)); + }); + + // Fetch columns for a selected table + function fetchColumns(table) { + fetch(`/get_columns?table=${table}`) + .then(response => response.json()) + .then(data => { + columnsContainer.innerHTML = '

Select Columns:

'; + data.columns.forEach(column => { + const checkbox = document.createElement('input'); + checkbox.type = 'checkbox'; + checkbox.value = column; + checkbox.id = `column-${column}`; + const label = document.createElement('label'); + label.textContent = column; + label.htmlFor = `column-${column}`; + columnsContainer.appendChild(checkbox); + columnsContainer.appendChild(label); + columnsContainer.appendChild(document.createElement('br')); + + // Update label preview on checkbox change + checkbox.addEventListener('change', updateLabelPreview); + }); + }) + .catch(error => console.error('Error fetching columns:', error)); + } + + // Update the label preview + function updateLabelPreview() { + const selectedColumns = Array.from(columnsContainer.querySelectorAll('input[type="checkbox"]:checked')) + .map(checkbox => checkbox.value); + + labelPreview.innerHTML = '

Label Preview:

'; + selectedColumns.forEach(column => { + const div = document.createElement('div'); + div.textContent = column; + labelPreview.appendChild(div); + }); + } + + // Handle saving the template + saveTemplateBtn.addEventListener('click', () => { + const selectedColumns = Array.from(columnsContainer.querySelectorAll('input[type="checkbox"]:checked')) + .map(checkbox => checkbox.value); + + if (selectedColumns.length === 0) { + alert('Please select at least one column for the label.'); + return; + } + + const width = document.getElementById('label-width').value; + const height = document.getElementById('label-height').value; + + if (!width || !height) { + alert('Please set the label dimensions.'); + return; + } + + const templateData = { + width, + height, + columns: selectedColumns + }; + + fetch('/save_template', { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(templateData) + }) + .then(response => response.json()) + .then(data => { + alert(data.message); + }) + .catch(error => console.error('Error saving template:', error)); + }); }); \ No newline at end of file diff --git a/py_app/app/static/style.css b/py_app/app/static/style.css index b82cd27..a694b56 100644 --- a/py_app/app/static/style.css +++ b/py_app/app/static/style.css @@ -561,47 +561,22 @@ body.dark-mode .scan-table tr:nth-child(odd) { /* Dashboard container */ .dashboard-container { display: flex; - flex-wrap: wrap; /* Allow wrapping to the next row if needed */ + flex-wrap: wrap; /* Allow cards to wrap to the next row if needed */ justify-content: space-between; /* Distribute cards evenly */ gap: 20px; /* Add spacing between the cards */ margin: 20px auto; /* Center the container */ max-width: 1200px; /* Optional: Limit the maximum width of the container */ } -/* Full-width card for the dashboard */ -.dashboard-full-width-card { - flex: 0 0 100%; /* Take up the full width of the container */ - text-align: center; - padding: 20px; - border-radius: 5px; - box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); - transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease; -} - /* Individual cards for the dashboard */ .dashboard-card { - flex: 1 1 calc(25% - 20px); /* Ensure cards are evenly distributed */ - padding: 20px; - border-radius: 5px; - box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); - text-align: center; - transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease; -} - -/* Light mode styles for dashboard cards */ -body.light-mode .dashboard-card, -body.light-mode .dashboard-full-width-card { - background: #fff; - color: #000; + flex: 1 1 calc(33.333% - 20px); /* Each card takes 1/3 of the row, minus the gap */ border: 1px solid #ddd; -} - -/* Dark mode styles for dashboard cards */ -body.dark-mode .dashboard-card, -body.dark-mode .dashboard-full-width-card { - background: #1e1e1e; - color: #fff; - border: 1px solid #444; + border-radius: 8px; + padding: 16px; + text-align: center; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + background-color: #fff; } /* Ensure cards have consistent height */ @@ -630,15 +605,27 @@ body.dark-mode .dashboard-full-width-card { background-color: #0056b3; } +/* Dark mode styles for dashboard cards */ +body.dark-mode .dashboard-card { + background-color: #333; /* Dark background color */ + color: #fff; /* Light text color */ + border: 1px solid #444; /* Subtle border for dark mode */ +} + +body.dark-mode .dashboard-card .btn { + background-color: #555; /* Darker button background */ + color: #fff; /* Light button text */ +} + +body.dark-mode .dashboard-card .btn:hover { + background-color: #777; /* Slightly lighter button background on hover */ +} + /* Responsive design for smaller screens */ @media (max-width: 768px) { .dashboard-card { flex: 1 1 100%; /* Stack cards vertically on smaller screens */ } - - .dashboard-full-width-card { - flex: 1 1 100%; /* Ensure the full-width card spans the entire width */ - } } /* Style for the export description label */ diff --git a/py_app/app/templates/create_template.html b/py_app/app/templates/create_template.html new file mode 100644 index 0000000..7574426 --- /dev/null +++ b/py_app/app/templates/create_template.html @@ -0,0 +1,50 @@ +{% extends "base.html" %} + +{% block title %}Create Template{% endblock %} + +{% block content %} + +
+ +
+

Dimensions

+

Set the dimensions of the label template:

+
+ + + + + + + +
+
+ + +
+

Get Database Headers

+

Retrieve column names from a selected database table:

+ +
+ +
+
+ +
+
+
+ + +
+ +
+

Interactive Label Preview

+

Preview the label with selected headers:

+
+ +
+ +
+
+ +{% endblock %} \ No newline at end of file diff --git a/py_app/app/templates/label_templates.html b/py_app/app/templates/label_templates.html new file mode 100644 index 0000000..846f0d3 --- /dev/null +++ b/py_app/app/templates/label_templates.html @@ -0,0 +1,31 @@ +{% extends "base.html" %} + +{% block title %}Label Templates{% endblock %} + +{% block content %} +
+
+

Manage Label Templates

+

This page will allow users to manage and configure label templates.

+ + +
+

List of Label Templates

+

Below is the list of existing label templates:

+
    + +
  • + Template 1 + + +
  • +
  • + Template 2 + + +
  • +
+ +
+
+{% endblock %} \ No newline at end of file diff --git a/py_app/app/templates/main_page_etichete.html b/py_app/app/templates/main_page_etichete.html index 94cadba..e2c55fd 100644 --- a/py_app/app/templates/main_page_etichete.html +++ b/py_app/app/templates/main_page_etichete.html @@ -6,5 +6,29 @@

Modul Etichete

Aceasta este pagina pentru gestionarea etichetelor.

+ + +
+ +
+

Upload Data

+

Upload data into the database for label management.

+ Go to Upload Data +
+ + +
+

Launch Print Module

+

Access the print module to print labels.

+ Launch Print Module +
+ + +
+

Manage Label Templates

+

Manage and configure label templates.

+ Manage Templates +
+
{% endblock %} \ No newline at end of file diff --git a/py_app/app/templates/print_module.html b/py_app/app/templates/print_module.html new file mode 100644 index 0000000..1974a9b --- /dev/null +++ b/py_app/app/templates/print_module.html @@ -0,0 +1,10 @@ +{% extends "base.html" %} + +{% block title %}Print Module{% endblock %} + +{% block content %} + +{% endblock %} \ No newline at end of file diff --git a/py_app/app/templates/upload_data.html b/py_app/app/templates/upload_data.html new file mode 100644 index 0000000..7e46a4e --- /dev/null +++ b/py_app/app/templates/upload_data.html @@ -0,0 +1,10 @@ +{% extends "base.html" %} + +{% block title %}Upload Data{% endblock %} + +{% block content %} +
+

Upload Data

+

This page will allow users to upload data into the database.

+
+{% endblock %} \ No newline at end of file