Started rocket backend

This commit is contained in:
2024-08-10 20:24:26 +02:00
parent 07ae4c4118
commit e37a57ea81
13 changed files with 188 additions and 167 deletions

View File

@@ -1,4 +1,4 @@
{# vim: set filetype=html #}
{# vim: set filetype=html :#}
<!DOCTYPE html>
<!--
This file is part of Inventory.
@@ -17,14 +17,6 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Inventory - {% block pagename %}{% endblock pagename %}</title>
<script type="text/javascript">
let caller = "";
document.getElementsByClassName('mdl').forEach((btn) => {
btn.addEventListener('click', (event) => {
caller = btn.id;
});
});
</script>
{% block script %}{% endblock script %}
</head>
@@ -68,10 +60,10 @@
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form>
<form id="create-table" method="post">
<div class="mb-3">
<label for="new_table_name" class="form-label">Name</label>
<input type="text" class="form-control" id="new_table_name" aria-describedby="new_table_name_label">
<input type="text" class="form-control" id="name" aria-describedby="new_table_name_label">
<div id="new_table_name_label" class="form-text">Name of the new table</div>
</div>
<div class="mb-3">
@@ -81,7 +73,7 @@
<div class="form-text" id="field_index"><strong>1</strong></div>
</div>
<div class="col-auto">
<label for="field_name" class="form-label">Column name</label>
<label for="fields" class="form-label">Column name</label>
<input type="text" class="form-control" id="field_name" aria-describedby="field_name_label">
</div>
<div class="col-auto">
@@ -172,7 +164,7 @@
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5">Edit filter on <div id="modal_caller"></div></h1>
<h1 class="modal-title fs-5">Edit filter on <span id="modal_caller"></span></h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">

View File

@@ -1,147 +0,0 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta name="author" content="Johannes Randerath" />
<meta charset="utf-8" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Inventory</title>
</head>
<body>
<nav class='navbar navbar-expand-lg bg-body bg-body-tertiary'>
<div class='container-fluid'>
<a class='navbar-brand' href='#'>Inventory</a>
<button class='navbar-toggler' type='button' data-bs-toggle='collapse' data-bs-target='#navbarSupportedContent' aria-controls='navbarSupportedContent' aria-expanded='false' aria-label='Toggle navigation'>
<span class='navbar-toggler-icon'></span>
</button>
<div class='collapse navbar-collapse' id='navbarSupportedContent'>
<ul class='navbar-nav me-auto mb-2 mb-lg-0'>
<li class='nav-item dropdown'>
<a class='nav-link dropdown-toggle' role='button' data-bs-toggle='dropdown' aria-expanded='false'>
Choose Table
</a>
</li>
<li class="nav-item">
<a class="nav-link" role="button" data-bs-toggle="modal" data-bs-target="#new_table">
<i class="bi bi-plus-lg"></i>
</a>
</li>
<li class="nav-item">
<a class="nav-link" role="button" data-bs-toggle="modal" data-bs-target="#import_table">
<i class="bi bi-folder2-open"></i>
</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="accordion" id="my_tables">
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#first" aria-expanded="false" aria-controls="first">
First
</button>
</h2>
<div id="first" class="accordion-collapse collapse" data-bs-parent="#my_tables">
<div class="accordion-body">
<h3>Name of first table <a class="btn btn-primary" href="table.html">Open</a></h3>
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>name</th>
<th>...</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>one</td>
<td>...</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Modals -->
<!-- Create new table -->
<div class="modal fade" id="new_table" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5">New table</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form>
<div class="mb-3">
<label for="new_table_name" class="form-label">Name</label>
<input type="text" class="form-control" id="new_table_name" aria-describedby="new_table_name_label">
<div id="new_table_name_label" class="form-text">Name of the new table</div>
</div>
<div class="mb-3">
<div class="row" id="columns">
<div class="col-auto align-bottom me-1">
<label for="field_index" class="form-label">#</label>
<div class="form-text" id="field_index"><strong>1</strong></div>
</div>
<div class="col-auto">
<label for="field_name" class="form-label">Column name</label>
<input type="text" class="form-control" id="field_name" aria-describedby="field_name_label">
</div>
<div class="col-auto">
<label for="field_name" class="form-label">Data type</label>
<select class="form-select" aria-label="data type">
<option value="text" selected>Text</option>
<option value="number">Number</option>
<option value="date">Date</option>
</select>
</div>
</div>
<div id="dynamic_columns">
<!-- Columns added using plus button -->
</div>
<div class="row justify-content-center mb-3 mt-3">
<div class="col-auto">
<button class="btn btn-primary" type="button" onclick="add_column()"><i class="bi bi-plus-lg"></i></button>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" data-bs-dismiss="modal" type="button">Close</button>
<button class="btn btn-primary" type="button" onclick="create_table()">Create</button>
</form>
</div>
</div>
</div>
</div>
<!-- Import new table -->
<div class="modal fade" id="import_table" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5">Import new table</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button class="btn btn-secondary" data-bs-dismiss="modal" type="button">Close</button>
<button class="btn btn-primary" type="button">Import</button>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
</body>
</html>

36
templates/home.html.tera Normal file
View File

@@ -0,0 +1,36 @@
{# vim: set filetype=html: #}
{% extends "base" %}
{% block body %}
<div class="accordion" id="my_tables">
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#first" aria-expanded="false" aria-controls="first">
First
</button>
</h2>
<div id="first" class="accordion-collapse collapse" data-bs-parent="#my_tables">
<div class="accordion-body">
<h3>Name of first table <a class="btn btn-primary" href="table.html">Open</a></h3>
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>name</th>
<th>...</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>one</td>
<td>...</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
{% endblock body %}

View File

@@ -5,6 +5,7 @@
{% block script %}
<script type="text/javascript">
let ncol = 1;
let edit_mode = false;
document.addEventListener("DOMContentLoaded", (event) => {
for (let row of document.getElementById("content_table").getElementsByTagName('tbody')[0].rows) {
let createClickHandler = function(r) {
@@ -20,15 +21,30 @@
document.getElementById('dynamic_columns').innerHTML += "<div class='row mt-3' id='columns'><div class='col-auto align-bottom'><div class='form-text me-1' id='field_index'><strong>" + ncol + "</strong></div></div><div class='col-auto'><input type='text' class='form-control' id='field_name' aria-describedby='field_name_label'></div><div class='col-auto'><select class='form-select' aria-label='data type'><option value='text' selected>Text</option><option value='number'>Number</option><option value='date'>Date</option></select></div></div>"
}
function create_table() {
let form = document.getElementById('create-table');
form.submit();
document.getElementById('dynamic_columns').innerHTML = "";
ncol = 1;
}
function set_modal_target(modal_target) {
document.getElementById('modal_caller').innerHTML = modal_target;
}
function toggle_edit_tname() {
let span = document.getElementById('tname');
if (!edit_mode) {
span.innerHTML = "<form><input type='text' class='form-control' id='tname_edit' value='{{ tname }}' /><button class='btn btn-success' type='submit'><i class='bi bi-check'></i></button></form>";
edit_mode = true;
} else {
span.innerHTML = '{{ tname }}';
edit_mode = false;
}
}
</script>
{% endblock script %}
{% block body %}
<div class="row justify-content-between">
<div class="col-auto">
<h1>Inventory table <button class="btn" type="button"><i class="bi bi-pencil"></i></button></h1>
<h1><div class='input-group'><span id="tname">{{ tname }}</span><button class="btn" type="button" onclick="toggle_edit_tname();"><i class="bi bi-pencil"></i></button></div></h1>
</div>
<div class="col-auto">
<div class="btn-toolbar mt-2" role="toolbar">
@@ -76,7 +92,7 @@
</div>
<div class="col-auto">
<div class="btn-toolbar">
<button class="btn p-0 me-2" type="button" data-jr-column="{{ column }}" data-bs-toggle="modal" data-bs-target="#filter"><i class="bi bi-filter"></i></button>
<button class="btn p-0 me-2" type="button" data-bs-toggle="modal" data-bs-target="#filter" onclick="set_modal_target('{{ column }}');"><i class="bi bi-filter"></i></button>
<button class="btn p-0" type="button" onclick="console.log('click');"><i class="bi bi-sort-down"></i></button>
</div>
</div>