Added license notices to every source file

This commit is contained in:
Johannes Randerath 2024-08-28 23:29:32 +02:00
parent 0c2c428ce4
commit c7ec089d06
98 changed files with 879 additions and 1882 deletions

3
.env~
View File

@ -1,3 +0,0 @@
R_DATABASES_URL=mysql://inventur:noiqC3OlFGVlRmU8KVPtyzVBLj4W9bbQhnu1zJ5cF75FH4JM2luhI2fvp5YXlTAuKr0Ayw2ZiUGfzortQ0GxqEQ5ICfEQgJtNfto@localhost:3306/inventur
ROCKET_SECRET_KEY=xT0JL6E1W4P+DNh0bRecNwsgtk0QfJ62t5zxe920s00=
ROCKET_CLIENT_SECRET=2vftRCu1WhaFezVoFgsNDlx66XOASBmX

3
.gitignore vendored
View File

@ -184,3 +184,6 @@ cython_debug/
.env .env
/private/ /private/
Rocket.toml Rocket.toml
# For emacs
**/*~
**/.#*

View File

@ -1,3 +1,21 @@
# This file is part of inventur.
# inventur is a simple web app using rocket to help maintain inventory data.
# Copyright (C) 2024 Johannes Randerath
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
[package] [package]
name = "inventur" name = "inventur"
version = "0.1.0" version = "0.1.0"

201
db.sql
View File

@ -1,201 +0,0 @@
/*!999999\- enable the sandbox mode */
-- MariaDB dump 10.19 Distrib 10.11.8-MariaDB, for Linux (x86_64)
--
-- Host: localhost Database: inventur
-- ------------------------------------------------------
-- Server version 10.11.8-MariaDB
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Current Database: `inventur`
--
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `inventur` /*!40100 DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci */;
USE `inventur`;
--
-- Table structure for table `__diesel_schema_migrations`
--
DROP TABLE IF EXISTS `__diesel_schema_migrations`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `__diesel_schema_migrations` (
`version` varchar(50) NOT NULL,
`run_on` timestamp NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (`version`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `__diesel_schema_migrations`
--
LOCK TABLES `__diesel_schema_migrations` WRITE;
/*!40000 ALTER TABLE `__diesel_schema_migrations` DISABLE KEYS */;
INSERT INTO `__diesel_schema_migrations` VALUES
('20240819150533','2024-08-19 19:57:15'),
('20240819183025','2024-08-21 18:28:28'),
('20240821180845','2024-08-21 18:43:01'),
('20240821185127','2024-08-21 19:07:06'),
('20240822171815','2024-08-22 18:07:34'),
('20240822203903','2024-08-22 21:18:07'),
('20240822205948','2024-08-27 12:00:00'),
('20240827120510','2024-08-27 12:18:10');
/*!40000 ALTER TABLE `__diesel_schema_migrations` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `jrcells`
--
DROP TABLE IF EXISTS `jrcells`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `jrcells` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`cell_value` varchar(2048) NOT NULL,
`jrentry_id` int(11) NOT NULL,
`jrcolumn_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `jrentry_id` (`jrentry_id`),
KEY `jrcolumn_id` (`jrcolumn_id`),
CONSTRAINT `jrcells_ibfk_1` FOREIGN KEY (`jrentry_id`) REFERENCES `jrentries` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `jrcells_ibfk_2` FOREIGN KEY (`jrcolumn_id`) REFERENCES `jrcolumns` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4604 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `jrcells`
--
LOCK TABLES `jrcells` WRITE;
/*!40000 ALTER TABLE `jrcells` DISABLE KEYS */;
/*!40000 ALTER TABLE `jrcells` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `jrcolumns`
--
DROP TABLE IF EXISTS `jrcolumns`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `jrcolumns` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`jrtable_id` int(11) NOT NULL,
`id_in_table` int(11) NOT NULL,
`column_type` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
KEY `jrtable` (`jrtable_id`),
CONSTRAINT `jrtable` FOREIGN KEY (`jrtable_id`) REFERENCES `jrtables` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=64 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `jrcolumns`
--
LOCK TABLES `jrcolumns` WRITE;
/*!40000 ALTER TABLE `jrcolumns` DISABLE KEYS */;
/*!40000 ALTER TABLE `jrcolumns` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `jrentries`
--
DROP TABLE IF EXISTS `jrentries`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `jrentries` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`row_pos` int(11) NOT NULL,
`jrtable_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `jrtable_id` (`jrtable_id`),
CONSTRAINT `jrentries_ibfk_1` FOREIGN KEY (`jrtable_id`) REFERENCES `jrtables` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1602 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `jrentries`
--
LOCK TABLES `jrentries` WRITE;
/*!40000 ALTER TABLE `jrentries` DISABLE KEYS */;
/*!40000 ALTER TABLE `jrentries` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `jrtables`
--
DROP TABLE IF EXISTS `jrtables`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `jrtables` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`owner_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `fk_owner_id` (`owner_id`),
CONSTRAINT `fk_owner_id` FOREIGN KEY (`owner_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `jrtables`
--
LOCK TABLES `jrtables` WRITE;
/*!40000 ALTER TABLE `jrtables` DISABLE KEYS */;
/*!40000 ALTER TABLE `jrtables` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`email` varchar(512) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `users`
--
LOCK TABLES `users` WRITE;
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2024-08-27 22:05:31

View File

@ -1,3 +1,21 @@
# This file is part of inventur.
# inventur is a simple web app using rocket to help maintain inventory data.
# Copyright (C) 2024 Johannes Randerath
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
[package] [package]
name = "inventur_db" name = "inventur_db"
version = "0.1.0" version = "0.1.0"

View File

@ -1,3 +1,21 @@
# This file is part of inventur.
# inventur is a simple web app using rocket to help maintain inventory data.
# Copyright (C) 2024 Johannes Randerath
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# For documentation on how to configure this file, # For documentation on how to configure this file,
# see https://diesel.rs/guides/configuring-diesel-cli # see https://diesel.rs/guides/configuring-diesel-cli

View File

@ -1 +1,19 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
DROP TABLE jrtables; DROP TABLE jrtables;

View File

@ -1,3 +1,21 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
CREATE TABLE jrtables ( CREATE TABLE jrtables (
id INTEGER AUTO_INCREMENT PRIMARY KEY, id INTEGER AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL,

View File

@ -1 +1,19 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
DROP TABLE jrcolumns; DROP TABLE jrcolumns;

View File

@ -1 +0,0 @@
-- This file should undo anything in `up.sql`

View File

@ -1,3 +1,21 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
CREATE TABLE jrcolumns ( CREATE TABLE jrcolumns (
id INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY, id INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY,
name VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL,

View File

@ -1,9 +0,0 @@
CREATE TABLE jrcolumns (
id INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
jrtable_id INTEGER NOT NULL,
FOREIGN KEY jrtable(jrtable_id) REFERENCES jrtables(id)
ON DELETE CASCADE
ON UPDATE CASCADE,
id_in_table INTEGER NOT NULL
);

View File

@ -1 +1,19 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
DROP TABLE jrentries; DROP TABLE jrentries;

View File

@ -1 +0,0 @@
-- This file should undo anything in `up.sql`

View File

@ -1,3 +1,21 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
CREATE TABLE jrentries ( CREATE TABLE jrentries (
id INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY, id INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY,
row_pos INTEGER NOT NULL, row_pos INTEGER NOT NULL,

View File

@ -1 +0,0 @@
-- Your SQL goes here

View File

@ -1 +1,19 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
DROP TABLE jrcells; DROP TABLE jrcells;

View File

@ -1 +0,0 @@
-- This file should undo anything in `up.sql`

View File

@ -1,3 +1,21 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
CREATE TABLE jrcells ( CREATE TABLE jrcells (
id INTEGER AUTO_INCREMENT NOT NULL, id INTEGER AUTO_INCREMENT NOT NULL,
PRIMARY KEY(id), PRIMARY KEY(id),

View File

@ -1 +0,0 @@
-- Your SQL goes here

View File

@ -1,2 +1,20 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
ALTER TABLE jrtables ALTER TABLE jrtables
ADD num_fields INTEGER NOT NULL; ADD num_fields INTEGER NOT NULL;

View File

@ -1 +0,0 @@
-- This file should undo anything in `up.sql`

View File

@ -1,2 +1,20 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
ALTER TABLE jrtables ALTER TABLE jrtables
DROP COLUMN num_fields; DROP COLUMN num_fields;

View File

@ -1 +0,0 @@
-- Your SQL goes here

View File

@ -0,0 +1,24 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
CREATE TABLE users (
id INTEGER AUTO_INCREMENT NOT NULL,
PRIMARY KEY(id),
username VARCHAR(255) NOT NULL,
email VARCHAR(512) NOT NULL
);

View File

@ -1 +1,19 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
DROP TABLE users; DROP TABLE users;

View File

@ -1 +0,0 @@
-- This file should undo anything in `up.sql`

View File

@ -1,3 +1,21 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
CREATE TABLE users ( CREATE TABLE users (
id INTEGER AUTO_INCREMENT NOT NULL, id INTEGER AUTO_INCREMENT NOT NULL,
PRIMARY KEY(id), PRIMARY KEY(id),

View File

@ -1 +0,0 @@
-- Your SQL goes here

View File

@ -1,3 +1,21 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
SET FOREIGN_KEY_CHECKS=0; SET FOREIGN_KEY_CHECKS=0;
UPDATE TABLE jrtables UPDATE TABLE jrtables
DROP COLUMN owner_id DROP COLUMN owner_id

View File

@ -1 +0,0 @@
-- This file should undo anything in `up.sql`

View File

@ -1,3 +1,21 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
SET FOREIGN_KEY_CHECKS=0; SET FOREIGN_KEY_CHECKS=0;
ALTER TABLE jrtables ALTER TABLE jrtables
ADD owner_id INTEGER NOT NULL; ADD owner_id INTEGER NOT NULL;

View File

@ -1 +0,0 @@
-- Your SQL goes here

View File

@ -1,2 +1,20 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
ALTER TABLE jrcolumns ALTER TABLE jrcolumns
DROP COLUMN column_type; DROP COLUMN column_type;

View File

@ -1 +0,0 @@
-- This file should undo anything in `up.sql`

View File

@ -1,2 +1,20 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
ALTER TABLE jrcolumns ALTER TABLE jrcolumns
ADD column_type INTEGER NOT NULL DEFAULT 0; ADD column_type INTEGER NOT NULL DEFAULT 0;

View File

@ -1 +0,0 @@
-- Your SQL goes here

View File

@ -1,28 +0,0 @@
use inventur_db::*;
use std::env::args;
fn main() {
let tblid = args()
.nth(1)
.expect("Usage: add_cell <tblid> <rowpos> <idintbl> <value>.")
.parse::<i32>()
.expect("Expected a number.");
let rowpos = args()
.nth(2)
.expect("Usage: add_cell <tblid> <rowpos> <idintbl> <value>.")
.parse::<i32>()
.expect("Expected a number.");
let idintbl = args()
.nth(3)
.expect("Usage: add_cell <tblid> <rowpos> <idintbl> <value>.")
.parse::<i32>()
.expect("Expected a number.");
let value = args()
.nth(4)
.expect("Usage: add_cell <tblid> <clmnid> <value>.");
println!("{:?}", create_jrcell_relative(&mut establish_connection(), tblid, rowpos, idintbl, value));
}

View File

@ -1,3 +1,21 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use inventur_db::*; use inventur_db::*;
use std::env::args; use std::env::args;

View File

@ -1,15 +0,0 @@
use inventur_db::*;
use std::env::args;
fn main() {
let name = args()
.nth(1)
.expect("Name missing");
let table_id = args()
.nth(2)
.expect("Table_id missing.")
.parse::<i32>()
.expect("Expected a number as table id.");
let conn = &mut establish_connection();
jrcolumns::create_jrcolumn(conn, name, table_id);
}

View File

@ -1,3 +1,21 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use inventur_db::*; use inventur_db::*;
use std::env::args; use std::env::args;
use std::io::{stdin, Read}; use std::io::{stdin, Read};

View File

@ -1,36 +0,0 @@
use inventur_db::*;
use std::env::args;
use std::io::{stdin, Read};
fn main() {
let tblid = args()
.nth(1)
.expect("Usage: add_entry <tblid> <uid>.")
.parse::<i32>()
.expect("Usage: add_entry <tblid> <uid>.");
let uid = args()
.nth(2)
.expect("Usage: add_entry <tblid> <uid>.")
.parse::<i32>()
.expect("Usage: add_entry <tblid> <uid>.");
let conn = &mut establish_connection();
let tbl = get_table(conn, tblid, uid);
if tbl.is_none() {
panic!("Table not found.");
}
let tbl = tbl.unwrap();
let mut rows = Vec::new();
for clm in tbl.column_names {
println!("{}:", clm);
let mut cell = String::new();
stdin().read_line(&mut cell);
rows.push(cell.clone());
}
println!("{}", add_row(conn, tblid, rows, uid).expect("Error"));
}

View File

@ -1,3 +1,21 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use inventur_db::*; use inventur_db::*;
use std::env::args; use std::env::args;

View File

@ -1,28 +0,0 @@
use inventur_db::*;
use std::env::args;
fn main() {
let tblid = args()
.nth(1)
.expect("Usage: change_cell_value <tblid> <rowpos> <idintbl> <newvalue>.")
.parse::<i32>()
.expect("Expected a number.");
let rowpos = args()
.nth(2)
.expect("Usage: change_cell_value <tblid> <rowpos> <idintbl> <newvalue>.")
.parse::<i32>()
.expect("Expected a number.");
let idintbl = args()
.nth(3)
.expect("Usage: change_cell_value <tblid> <rowpos> <idintbl> <newvalue>.")
.parse::<i32>()
.expect("Expected a number.");
let newvalue = args()
.nth(4)
.expect("Usage: change_cell_value <tblid> <rowpos> <idintbl> <newvalue>.");
println!("{:?}", jrcells::change_jrcell_value_relative(&mut establish_connection(), tblid, rowpos, idintbl, newvalue));
}

View File

@ -1,3 +1,21 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use inventur_db::*; use inventur_db::*;
use std::io::stdin; use std::io::stdin;

View File

@ -1,38 +0,0 @@
use inventur_db::*;
use std::io::stdin;
fn main() {
let conn = &mut establish_connection();
let mut name = String::new();
let mut num_fields = String::new();
let mut uid = String::new();
println!("Name: ");
stdin().read_line(&mut name).unwrap();
let name = name.trim_end();
println!("Number of fields: ");
stdin().read_line(&mut num_fields);
println!("Userid:");
stdin().read_line(&mut uid);
let uid = uid
.trim()
.parse::<i32>()
.expect("Number expected.");
let num_fields = num_fields
.trim()
.parse::<i32>()
.expect("Number expected");
let mut fields = Vec::new();
for i in 0..num_fields {
let mut field = String::new();
stdin().read_line(&mut field);
field.trim();
fields.push(field);
}
println!("{}", create_table(conn, name.to_string(), fields, uid).unwrap());
}

View File

@ -1,3 +1,21 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use inventur_db::*; use inventur_db::*;
use std::env::args; use std::env::args;

View File

@ -1,14 +0,0 @@
use inventur_db::*;
use std::env::args;
fn main() {
let uname = args()
.nth(1)
.expect("Usage: create_user <username> <email>.");
let mail = args()
.nth(2)
.expect("Usage: create_user <username> <email>.");
println!("{}", register_or_login(&mut establish_connection(), uname, mail).unwrap().uid);
}

View File

@ -1,24 +0,0 @@
use inventur_db::*;
use std::env::args;
fn main() {
let tblid = args()
.nth(1)
.expect("Usage: add_cell <tblid> <rowpos> <idintbl> <value>.")
.parse::<i32>()
.expect("Expected a number.");
let rowpos = args()
.nth(2)
.expect("Usage: add_cell <tblid> <rowpos> <idintbl> <value>.")
.parse::<i32>()
.expect("Expected a number.");
let idintbl = args()
.nth(3)
.expect("Usage: add_cell <tblid> <rowpos> <idintbl> <value>.")
.parse::<i32>()
.expect("Expected a number.");
println!("{:?}", delete_jrcell_relative(&mut establish_connection(), tblid, rowpos, idintbl));
}

View File

@ -1,3 +1,21 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use inventur_db::*; use inventur_db::*;
use std::env::args; use std::env::args;

View File

@ -1,20 +0,0 @@
use inventur_db::*;
use std::env::args;
fn main() {
let tblid = args()
.nth(1)
.expect("Table id missing.")
.parse::<i32>()
.expect("Expected a number.");
let idintbl = args()
.nth(2)
.expect("Id in table missing.")
.parse::<i32>()
.expect("Expected a number.");
let conn = &mut establish_connection();
println!("{:?}", jrcolumns::delete_column_relative(conn, tblid, idintbl));
}

View File

@ -1,3 +1,21 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use inventur_db::*; use inventur_db::*;
use std::env::args; use std::env::args;

View File

@ -1,19 +0,0 @@
use inventur_db::*;
use std::env::args;
fn main() {
let tblid = args()
.nth(1)
.expect("Usage: delete_entry <tblid> <rowpos>")
.parse::<i32>()
.expect("Expected a number.");
let rowpos = args()
.nth(2)
.expect("Usage: delete_entry <tblid> <rowpos>")
.parse::<i32>()
.expect("Expected a number.");
jrentries::delete_jrentry_relative(&mut establish_connection(), tblid, rowpos);
}

View File

@ -1,3 +1,21 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use inventur_db::*; use inventur_db::*;
use std::env::args; use std::env::args;

View File

@ -1,12 +0,0 @@
use inventur_db::*;
use std::env::args;
fn main() {
let tblid = args()
.nth(1)
.expect("Usage: delete_jrtable <tableid>.")
.parse::<i32>()
.expect("Expected a number.");
println!("{:?}", jrtables::delete_jrtable(&mut establish_connection(), tblid));
}

View File

@ -1,3 +1,21 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use inventur_db::*; use inventur_db::*;
use std::env::args; use std::env::args;

View File

@ -1,19 +0,0 @@
use inventur_db::*;
use std::env::args;
fn main() {
let arg = args()
.nth(1)
.expect("Missing argument.");
let conn = &mut establish_connection();
let mut uid = users::get_uid_uname(conn, &arg);
if uid.is_err() {
uid = users::get_uid_email(conn, &arg);
}
if uid.is_err() {
panic!("User not found!");
}
let uid = uid.unwrap();
delete_user(conn, uid);
}

View File

@ -1,3 +1,21 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use std::env::args; use std::env::args;
use inventur_db::*; use inventur_db::*;

View File

@ -1,25 +0,0 @@
use std::env::args;
use inventur_db::*;
fn main() {
let tblid = args()
.nth(1)
.expect("Table id missing.")
.parse::<i32>()
.expect("Expected a number.");
let idintbl = args()
.nth(2)
.expect("Id in table missing.")
.parse::<i32>()
.expect("Expected a number.");
let newidintbl = args()
.nth(3)
.expect("New id in table missing.")
.parse::<i32>()
.expect("Expected a number.");
let conn = &mut establish_connection();
jrcolumns::move_column_relative(conn, tblid, idintbl, newidintbl);
}

View File

@ -1,3 +1,21 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use inventur_db::*; use inventur_db::*;
use std::env::args; use std::env::args;

View File

@ -1,25 +0,0 @@
use inventur_db::*;
use std::env::args;
fn main() {
let tblid = args()
.nth(1)
.expect("Usage: move_entry <tblid> <rowpos> <newpos>.")
.parse::<i32>()
.expect("Expected a number.");
let rowpos = args()
.nth(2)
.expect("Usage: move_entry <tblid> <rowpos> <newpos>.")
.parse::<i32>()
.expect("Expected a number.");
let newpos = args()
.nth(3)
.expect("Usage: move_entry <tblid> <rowpos> <newpos>.")
.parse::<i32>()
.expect("Expected a number.");
println!("{:?}", jrentries::move_jrentry(&mut establish_connection(), tblid, rowpos, newpos));
}

View File

@ -1,3 +1,21 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use inventur_db::*; use inventur_db::*;
use std::env::args; use std::env::args;

View File

@ -1,27 +0,0 @@
use inventur_db::*;
use std::env::args;
fn main() {
if args().len() != 4 {
panic!("Usage: rename_column <table_id> <id_in_table> <new name>.");
}
let table_id = args()
.nth(1)
.unwrap()
.parse::<i32>()
.expect("Table id must be a number.");
let id_in_table = args()
.nth(2)
.unwrap()
.parse::<i32>()
.expect("id in table must be a number.");
let name = args()
.nth(3)
.unwrap();
let conn = &mut establish_connection();
jrcolumns::rename_column_relative(conn, table_id, id_in_table, name);
}

View File

@ -1,3 +1,21 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use inventur_db::*; use inventur_db::*;
use std::env::args; use std::env::args;

View File

@ -1,23 +0,0 @@
use inventur_db::*;
use std::env::args;
fn main() {
let table_id = args()
.nth(1)
.expect("Usage: rename_jrtable <tblid> <uid> <new name>.")
.parse::<i32>()
.expect("number expected for id.");
let uid = args()
.nth(2)
.expect("Usage: rename_jrtable <tblid> <uid> <new name>.")
.parse::<i32>()
.expect("Usage: rename_jrtable <tblid> <uid> <new name>.");
let new_name = args()
.nth(3)
.expect("Usage: rename_jrtable <tblid> <uid> <new name>.");
let conn = &mut establish_connection();
rename_table(conn, table_id, uid, new_name);
}

View File

@ -1,3 +1,21 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use inventur_db::*; use inventur_db::*;
use std::env::args; use std::env::args;

View File

@ -1,29 +0,0 @@
use inventur_db::*;
use std::env::args;
fn main() {
let tblid = args()
.nth(1)
.expect("Usage: show_table <tblid>.")
.parse::<i32>()
.expect("Expected a number.");
let tbl = get_table(&mut establish_connection(), tblid, 1);
if tbl.is_none() {
panic!("Couldn't get table.");
}
let tbl = tbl.unwrap();
println!("Table {}: {}", tbl.tblid, tbl.name);
println!();
print!("|");
for clm in tbl.column_names {
print!(" {} |", clm);
}
println!();
for row in tbl.rows {
print!("|");
for cell in row.cells {
print!(" {} |", cell);
}
println!();
}
}

View File

@ -1,16 +0,0 @@
use inventur_db::*;
fn main() {
let conn = &mut establish_connection();
let results = get_all_tables(conn).expect("Error loading tables.");
println!("Total: {} tables.", results.len());
for table in results {
println!("{}: {} has {} columns.", table.id, table.name, table.num_fields);
let columns = get_columns_of(conn, table.id).expect(format!("Error reading columns for table {}.", table.id).as_str());
for column in columns {
print!("{} ", column.name);
}
}
}

View File

@ -1,3 +1,21 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use inventur_db::*; use inventur_db::*;
use std::env::args; use std::env::args;

View File

@ -1,10 +0,0 @@
use inventur_db::*;
use std::env::args;
fn main() {
let uid = args()
.nth(1)
.parse::<i32>()
.expect("Usage: show_user_tblids <uid>.");
println!("{:?}", get_user_tblids(uid));
}

View File

@ -1,3 +1,20 @@
/* Simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use crate::schema; use crate::schema;
use crate::models; use crate::models;
use crate::jrcolumns; use crate::jrcolumns;

View File

@ -1,98 +0,0 @@
use crate::schema;
use crate::models;
use crate::jrcolumns;
use crate::jrentries;
use models::{ Jrcell, NewJrcell };
use schema::jrcells::dsl::{jrcells, id, jrentry_id, jrcolumn_id, cell_value};
use diesel::prelude::*;
use diesel::mysql::MysqlConnection;
pub fn create_jrcell_relative(conn: &mut MysqlConnection, tblid: i32, rowpos: i32, idintbl: i32, value: String) -> Result<usize, diesel::result::Error> {
let ntrid = jrentries::get_jrentry_id(conn, tblid, rowpos);
if ntrid.is_err() {
return Err(ntrid.err().unwrap());
}
let ntrid = ntrid.unwrap();
let clmid = jrcolumns::get_clmid_relative(conn, tblid, idintbl);
if clmid.is_err() {
return Err(clmid.err().unwrap());
}
let clmid = clmid.unwrap();
create_jrcell(conn, ntrid, clmid, value)
}
pub fn change_jrcell_value_relative(conn: &mut MysqlConnection, tblid: i32, rowpos: i32, idintbl: i32, new_value: String) -> Result<usize, diesel::result::Error> {
let ntrid = jrentries::get_jrentry_id(conn, tblid, rowpos);
if ntrid.is_err() {
return Err(ntrid.err().unwrap());
}
let ntrid = ntrid.unwrap();
let clmid = jrcolumns::get_clmid_relative(conn, tblid, idintbl);
if clmid.is_err() {
return Err(clmid.err().unwrap());
}
let clmid = clmid.unwrap();
change_jrcell_value(conn, ntrid, clmid, new_value)
}
pub fn delete_jrcell_relative(conn: &mut MysqlConnection, tblid: i32, rowpos: i32, idintbl: i32) -> Result<usize, diesel::result::Error> {
let ntrid = jrentries::get_jrentry_id(conn, tblid, rowpos);
if ntrid.is_err() {
return Err(ntrid.err().unwrap());
}
let ntrid = ntrid.unwrap();
let clmid = jrcolumns::get_clmid_relative(conn, tblid, idintbl);
if clmid.is_err() {
return Err(clmid.err().unwrap());
}
let clmid = clmid.unwrap();
delete_jrcell(conn, ntrid, clmid)
}
pub fn create_jrcell(conn: &mut MysqlConnection, entryid: i32, columnid: i32, value: String) -> Result<usize, diesel::result::Error> {
use self::schema::jrentries::dsl::jrentries;
use self::schema::jrcolumns::dsl::jrcolumns;
let ntr = jrentries
.find(entryid)
.execute(conn);
if ntr.is_err() {
return ntr;
}
let clmn = jrcolumns
.find(columnid)
.execute(conn);
if clmn.is_err() {
return clmn;
}
let cell = NewJrcell { cell_value: value, jrentry_id: entryid, jrcolumn_id: columnid };
diesel::insert_into(crate::schema::jrcells::table)
.values(cell)
.execute(conn)
}
pub fn change_jrcell_value(conn: &mut MysqlConnection, entryid: i32, columnid: i32, new_value: String) -> Result<usize, diesel::result::Error> {
diesel::update(jrcells.filter(jrentry_id.eq(entryid)).filter(jrcolumn_id.eq(columnid)))
.set(cell_value.eq(new_value))
.execute(conn)
}
pub fn delete_jrcell(conn: &mut MysqlConnection, entryid: i32, columnid: i32) -> Result<usize, diesel::result::Error> {
diesel::delete(jrcells.filter(jrentry_id.eq(entryid)).filter(jrcolumn_id.eq(columnid)))
.execute(conn)
}
pub fn get_entry_cells(conn: &mut MysqlConnection, entryid: i32) -> Result<Vec<Jrcell>, diesel::result::Error> {
jrcells
.filter(jrentry_id.eq(entryid))
.select(Jrcell::as_select())
.load(conn)
}

View File

@ -1,3 +1,20 @@
/* Simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use diesel::prelude::*; use diesel::prelude::*;
use diesel::mysql::MysqlConnection; use diesel::mysql::MysqlConnection;
use crate::models; use crate::models;

View File

@ -1,197 +0,0 @@
use diesel::prelude::*;
use diesel::mysql::MysqlConnection;
use crate::models;
use crate::schema;
use crate::jrtables;
use models::{ Jrcolumn, NewJrcolumn };
use schema::jrcolumns::dsl::{ jrcolumns, id, name, jrtable_id, id_in_table };
pub fn create_jrcolumn(conn: &mut MysqlConnection, tblid: i32, clmnname: String) -> Result<usize, diesel::result::Error> {
let ncols = jrtables::get_ncols(conn, tblid);
if ncols.is_err() {
return ncols;
}
let ncols = ncols.unwrap() as i32;
let jrcolumn = NewJrcolumn { name: clmnname, jrtable_id: tblid, id_in_table: ncols + 1 };
diesel::insert_into(crate::schema::jrcolumns::table)
.values(&jrcolumn)
.execute(conn)
}
pub fn create_jrcolumns(conn: &mut MysqlConnection, tblid: i32, names: Vec<String>) -> Result<usize, diesel::result::Error> {
let mut cols : Vec<NewJrcolumn> = Vec::new();
let ncols = jrtables::get_ncols(conn, tblid);
if ncols.is_err() {
return ncols;
}
let mut ncols = ncols.unwrap() as i32;
for clmnname in names {
ncols += 1;
cols.push(NewJrcolumn { name: clmnname, jrtable_id: tblid, id_in_table: ncols});
}
let cols = cols;
diesel::insert_into(crate::schema::jrcolumns::table)
.values(&cols)
.execute(conn)
}
pub fn get_last_column_id_of(conn: &mut MysqlConnection, tblid: i32) -> Result<i32, diesel::result::Error> {
jrcolumns
.filter(jrtable_id.eq(tblid))
.order(id_in_table.desc())
.select(id)
.first::<i32>(conn)
}
pub fn get_columns_of(conn: &mut MysqlConnection, tblid: i32) -> Result<Vec<Jrcolumn>, diesel::result::Error> {
jrcolumns
.filter(jrtable_id.eq(tblid))
.order(id_in_table.asc())
.select(Jrcolumn::as_select())
.load(conn)
}
pub fn get_clmid_relative(conn: &mut MysqlConnection, tblid: i32, idintbl: i32) -> Result<i32, diesel::result::Error> {
jrcolumns
.filter(jrtable_id.eq(tblid))
.filter(id_in_table.eq(idintbl))
.select(id)
.first::<i32>(conn)
}
pub fn rename_column_relative(conn: &mut MysqlConnection, tblid: i32, id_in_tbl: i32, new_name: String) -> Result<usize, diesel::result::Error> {
let clmid = get_clmid_relative(conn, tblid, id_in_tbl);
if clmid.is_err() {
return Err(clmid.err().unwrap());
}
rename_column(conn, clmid.unwrap(), new_name)
}
pub fn rename_column(conn: &mut MysqlConnection, clmnid: i32, new_name: String) -> Result<usize, diesel::result::Error> {
diesel::update(jrcolumns.find(clmnid))
.set(name.eq(new_name))
.execute(conn)
}
pub fn move_column_relative(conn: &mut MysqlConnection, tblid: i32, id_in_tbl: i32, new_id_in_tbl: i32) -> Result<usize, diesel::result::Error> {
let clmid = get_clmid_relative(conn, tblid, id_in_tbl);
if clmid.is_err() {
return Err(clmid.err().unwrap());
}
move_column(conn, clmid.unwrap(), new_id_in_tbl)
}
pub fn move_column(conn: &mut MysqlConnection, clmnid: i32, new_id_in_table: i32) -> Result<usize, diesel::result::Error>{
let tbl_id = jrcolumns
.find(clmnid)
.select(jrtable_id)
.first::<i32>(conn);
if tbl_id.is_err() {
return Err(tbl_id.err().unwrap());
}
let tbl_id = tbl_id.unwrap();
let cols = jrcolumns
.filter(jrtable_id.eq(tbl_id))
.order(id_in_table.asc())
.select(Jrcolumn::as_select())
.load(conn);
if cols.is_err() {
return Err(cols.err().unwrap());
}
let cols = cols.unwrap();
let ncols = cols.len() as i32;
if new_id_in_table > ncols || new_id_in_table < 0 {
return Err(diesel::result::Error::NotFound);
}
let cur_id_in_table =
jrcolumns
.find(clmnid)
.select(id_in_table)
.first::<i32>(conn);
if cur_id_in_table.is_err() {
return Err(cur_id_in_table.err().unwrap());
}
let cur_id_in_table = cur_id_in_table.unwrap();
let dir;
let a;
let b;
if cur_id_in_table < new_id_in_table {
dir = -1;
a = cur_id_in_table + 1;
b = new_id_in_table;
} else {
dir = 1;
a = new_id_in_table;
b = cur_id_in_table - 1;
}
for j in a..=b {
let upd = diesel::update(jrcolumns.find(cols[(j-1) as usize].id))
.set(id_in_table.eq(id_in_table + dir))
.execute(conn);
if upd.is_err() {
return upd;
}
}
diesel::update(jrcolumns.find(clmnid))
.set(id_in_table.eq(new_id_in_table))
.execute(conn)
}
pub fn delete_column_relative(conn: &mut MysqlConnection, tblid: i32, idinclm: i32) -> Result<usize, diesel::result::Error> {
let clmid = get_clmid_relative(conn, tblid, idinclm);
if clmid.is_err() {
return Err(clmid.err().unwrap());
}
delete_column(conn, clmid.unwrap())
}
pub fn delete_column(conn: &mut MysqlConnection, clmnid: i32) -> Result<usize, diesel::result::Error> {
let tblid = jrcolumns
.find(clmnid)
.select(jrtable_id)
.first::<i32>(conn);
if tblid.is_err() {
return Err(tblid.err().unwrap());
}
let tblid = tblid.unwrap();
let ncols = jrcolumns
.filter(jrtable_id.eq(tblid))
.execute(conn);
if ncols.is_err() {
return ncols;
}
let ncols = ncols.unwrap() as i32;
let mv = move_column(conn, clmnid, ncols);
if mv.is_err() {
return mv;
}
diesel::delete(jrcolumns.find(clmnid))
.execute(conn)
}
pub fn get_clmns_of(conn: &mut MysqlConnection, tblid: i32) -> Result<Vec<Jrcolumn>, diesel::result::Error> {
jrcolumns
.filter(jrtable_id.eq(tblid))
.order(id_in_table.asc())
.select(Jrcolumn::as_select())
.load(conn)
}

View File

@ -1,3 +1,20 @@
/* Simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use crate::models; use crate::models;
use crate::schema; use crate::schema;

View File

@ -1,131 +0,0 @@
use crate::models;
use crate::schema;
use schema::jrentries::dsl::{jrentries, id, jrtable_id, row_pos};
use models::{ Jrentry, NewJrentry };
use diesel::prelude::*;
use diesel::mysql::MysqlConnection;
pub fn create_jrentry(conn: &mut MysqlConnection, tblid: i32) -> Result<usize, diesel::result::Error> {
let rowpos = jrentries
.filter(jrtable_id.eq(tblid))
.select(row_pos)
.load::<i32>(conn);
if rowpos.is_err() {
return Err(rowpos.err().unwrap());
}
let rowpos = rowpos.unwrap().len() + 1;
let ntr = NewJrentry { jrtable_id: tblid, row_pos: rowpos as i32 };
diesel::insert_into(crate::schema::jrentries::table)
.values(ntr)
.execute(conn)
}
pub fn move_jrentry(conn: &mut MysqlConnection, tblid: i32, rowpos: i32, newrowpos: i32) -> Result<usize, diesel::result::Error> {
let ntrids = jrentries
.filter(jrtable_id.eq(tblid))
.order(row_pos.asc())
.select(id)
.load::<i32>(conn);
if ntrids.is_err() {
return Err(ntrids.err().unwrap());
}
let ntrids = ntrids.unwrap();
let a;
let b;
let dir;
let entryid = ntrids[(rowpos-1) as usize];
if rowpos < newrowpos {
a = rowpos + 1;
b = newrowpos;
dir = -1;
}else {
a = newrowpos;
b = rowpos - 1;
dir = 1;
}
for i in a..=b {
let upd = diesel::update(jrentries.find(ntrids[(i-1) as usize]))
.set(row_pos.eq(row_pos + dir))
.execute(conn);
if upd.is_err() {
return upd;
}
}
diesel::update(jrentries.find(entryid))
.set(row_pos.eq(newrowpos))
.execute(conn)
}
pub fn delete_jrentry_relative(conn: &mut MysqlConnection, tblid: i32, rowpos: i32) -> Result<usize, diesel::result::Error> {
let entryid = jrentries
.filter(jrtable_id.eq(tblid))
.filter(row_pos.eq(rowpos))
.select(id)
.first::<i32>(conn);
if entryid.is_err() {
return Err(entryid.err().unwrap());
}
delete_jrentry(conn, entryid.unwrap())
}
pub fn delete_jrentry(conn: &mut MysqlConnection, entryid: i32) -> Result<usize, diesel::result::Error> {
let rp = jrentries
.find(entryid)
.select(row_pos)
.first::<i32>(conn);
let tblid = jrentries
.find(entryid)
.select(jrtable_id)
.first::<i32>(conn);
if rp.is_err() {
return Err(tblid.err().unwrap());
}
if tblid.is_err() {
return Err(tblid.err().unwrap());
}
let rp = rp.unwrap();
let tblid = tblid.unwrap();
let nr = jrentries
.filter(jrtable_id.eq(tblid))
.execute(conn);
if nr.is_err() {
return nr;
}
move_jrentry(conn, tblid, rp, nr.unwrap() as i32);
diesel::delete(jrentries.find(entryid)).execute(conn)
}
pub fn get_jrentry_id(conn: &mut MysqlConnection, tblid: i32, rowpos: i32) -> Result<i32, diesel::result::Error> {
jrentries
.filter(jrtable_id.eq(tblid))
.filter(row_pos.eq(rowpos))
.select(id)
.first::<i32>(conn)
}
pub fn get_entries_of(conn: &mut MysqlConnection, tblid: i32) -> Result<Vec<Jrentry>, diesel::result::Error> {
jrentries
.filter(jrtable_id.eq(tblid))
.select(Jrentry::as_select())
.load(conn)
}

View File

@ -1,3 +1,20 @@
/* Simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use diesel::prelude::*; use diesel::prelude::*;
use diesel::mysql::MysqlConnection; use diesel::mysql::MysqlConnection;
use crate::models; use crate::models;

View File

@ -1,95 +0,0 @@
use diesel::prelude::*;
use diesel::mysql::MysqlConnection;
use crate::models;
use crate::schema;
use crate::jrcolumns;
use models::{ Jrtable, NewJrtable };
use schema::jrtables::dsl::{ jrtables, id, name, owner_id };
pub fn create_jrtable(conn: &mut MysqlConnection, tblname: &String, field_names: Vec<String>, uid: i32) -> Result<i32, diesel::result::Error> {
let jrtable = NewJrtable { name: tblname.to_string(), owner_id: uid };
let tbl = diesel::insert_into(crate::schema::jrtables::table)
.values(&jrtable)
.execute(conn);
if tbl.is_err() {
return Err(tbl.err().unwrap());
}
let tblid = jrtables
.order(id.desc())
.select(id)
.first::<i32>(conn);
if tblid.is_err() {
return Err(tblid.err().unwrap());
}
let tblid = tblid.unwrap();
let cols = jrcolumns::create_jrcolumns_empty_tbl(conn, tblid, field_names);
if cols.is_err() {
return Err(cols.err().unwrap());
}
Ok(tblid)
}
pub fn rename_jrtable(conn: &mut MysqlConnection, tblid: i32, new_name: &str) -> Result<usize, diesel::result::Error> {
diesel::update(jrtables.find(tblid))
.set(name.eq(new_name))
.execute(conn)
}
pub fn delete_jrtable(conn: &mut MysqlConnection, tblid: i32) -> Result<usize, diesel::result::Error> {
diesel::delete(jrtables.find(tblid))
.execute(conn)
}
pub fn get_all_tables(conn: &mut MysqlConnection) -> Result<Vec<Jrtable>, diesel::result::Error> {
jrtables
.select(Jrtable::as_select())
.load(conn)
}
pub fn get_tbl(conn: &mut MysqlConnection, tblid: i32) -> Result<Jrtable, diesel::result::Error> {
jrtables
.find(tblid)
.select(Jrtable::as_select())
.first(conn)
}
pub fn get_ncols(conn: &mut MysqlConnection, tblid: i32) -> Result<usize, diesel::result::Error> {
use schema::jrcolumns::dsl::{ jrcolumns, jrtable_id };
jrcolumns
.filter(jrtable_id.eq(tblid))
.execute(conn)
}
pub fn get_nrows(conn: &mut MysqlConnection, tblid: i32) -> Result<usize, diesel::result::Error> {
use schema::jrentries::dsl::{jrentries, jrtable_id};
jrentries
.filter(jrtable_id.eq(tblid))
.execute(conn)
}
pub fn get_tblids_uid(conn: &mut MysqlConnection, uid: i32) -> Result<Vec<i32>, diesel::result::Error> {
jrtables
.filter(owner_id.eq(uid))
.select(id)
.load::<i32>(conn)
}
pub fn get_owner_id(conn: &mut MysqlConnection, tblid: i32) -> Result<i32, diesel::result::Error> {
jrtables
.find(tblid)
.select(owner_id)
.first::<i32>(conn)
}
pub fn get_tbl_by_name_uid(conn: &mut MysqlConnection, tblname: &String, uid: i32) -> Result<i32, diesel::result::Error> {
jrtables
.filter(owner_id.eq(uid))
.filter(name.eq(tblname))
.select(id)
.first::<i32>(conn)
}

View File

@ -1,4 +1,20 @@
#![recursion_limit = "512"] /* Simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
//! Database API using the table style system provided by this crate //! Database API using the table style system provided by this crate
mod models; mod models;
mod schema; mod schema;

View File

@ -1,314 +0,0 @@
//! Database API using the table style system provided by this crate
mod models;
mod schema;
mod jrtables;
mod jrcolumns;
mod jrentries;
mod jrcells;
mod users;
use dotenvy::dotenv;
use std::env;
use diesel::mysql::MysqlConnection;
use diesel::prelude::*;
/// represents and summarised all relevant data of a table.
/// Standard return type if whole tables should be returned
pub struct Tbl {
/// table id of the represented object
pub tblid: i32,
pub name: String,
pub column_names: Vec<String>,
pub rows: Vec<TRow>,
}
/// Represents a table's row.
/// Internal data structure is abstracted until strings.
pub struct TRow {
pub row_pos: i32,
pub cells: Vec<String>,
}
/// Identifies a user
/// All fields are unique within the db at any given point.
pub struct User {
/// User's unique id.
pub uid: i32,
pub uname: String,
pub email: String,
}
/// Connect to database.
/// Return value must be passed to most of the crate's functions.
pub fn establish_connection() -> MysqlConnection {
dotenv().ok();
let db_url = env::var("DATABASE_URL").expect("No database url set.");
MysqlConnection::establish(&db_url)
.unwrap_or_else(|_| panic!("Couldn't open database."))
}
/// Fetch one whole table from the database. Identified by it's ID.
/// Needs the id of the requesting user.
/// Returns:
/// A Tbl struct
/// Or:
/// None
/// if the table was not found or
/// if it could not be read or
/// if the requesting user is not the table's owner or
/// if there has been another error
///
pub fn get_table(conn: &mut MysqlConnection, tblid: i32, uid: i32) -> Option<Tbl> {
let tbl = jrtables::get_tbl(conn, tblid);
if tbl.is_err() {
return None;
}
let tbl = tbl.unwrap();
if tbl.owner_id != uid {
return None;
}
let clmns = jrcolumns::get_clmns_of(conn, tblid);
if clmns.is_err() {
return None;
}
let clmns = clmns.unwrap();
let mut clmn_nms = Vec::new();
for clmn in &clmns {
clmn_nms.push(clmn.name.clone());
}
let clmn_nms = clmn_nms;
let mut clmn_ids = Vec::new();
for clmn in clmns {
clmn_ids.push(clmn.id);
}
let clmn_ids = clmn_ids;
let rowids = jrentries::get_entries_of(conn, tblid);
if rowids.is_err() {
return None;
}
let rowids = rowids.unwrap();
let mut rows = Vec::new();
for rowid in rowids {
let row = jrcells::get_entry_cells(conn, rowid.id);
if row.is_err() {
return None;
}
let row = row.unwrap();
let mut data = Vec::new();
for cell in row {
data.push(cell.cell_value);
}
let data = data;
rows.push(TRow { row_pos: rowid.row_pos, cells: data });
}
Some(Tbl { tblid: tbl.id, name: tbl.name, column_names: clmn_nms, rows: rows })
}
pub fn get_tblnames(conn: &mut MysqlConnection, tblids: Vec<i32>) -> Option<Vec<String>> {
let mut tblnames = Vec::new();
for tblid in tblids {
let tblname = jrtables::get_tbl(conn, tblid);
if tblname.is_err() {
return None;
}
tblnames.push(tblname.unwrap().name);
}
Some(tblnames)
}
/// Returns a Vec of the ids of a user's table if the user exists, else None.
/// User is identified by its user ID.
pub fn get_user_tblids(conn: &mut MysqlConnection, uid: i32) -> Option<Vec<i32>> {
let tblids = jrtables::get_tblids_uid(conn, uid);
if tblids.is_err() {
return None;
}
Some(tblids.unwrap())
}
/// Change the name of a table.
/// Needs the user ID of the requesting user.
/// Returns Some(true) if the action seems to have been successful and the requesting user is the
/// table's owner.
/// None otherwise.
pub fn rename_table(conn: &mut MysqlConnection, tblid: i32, new_name: String, uid: i32) -> Option<bool> {
let owner = jrtables::get_owner_id(conn, tblid);
if owner.is_err() || owner.unwrap() != uid {
return None;
}
let rnm = jrtables::rename_jrtable(conn, tblid, &new_name);
if rnm.is_err() {
return None;
}
Some(true)
}
/// Delete a table.
/// Needs the user ID of the requesting user.
/// Returns Some(true) if the action seems to have been successful and the requesting user is the
/// table's owner.
/// None otherwise.
pub fn delete_table(conn: &mut MysqlConnection, tblid: i32, uid: i32) -> Option<bool> {
let owner = jrtables::get_owner_id(conn, tblid);
if owner.is_err() || owner.unwrap() != uid {
return None;
}
let dlt = jrtables::delete_jrtable(conn, tblid);
if dlt.is_err() {
return None;
}
Some(true)
}
/// Create a new table.
/// Needs the user ID of the requesting user.
/// Returns the id of the newly created table if the action seems to have been successful and the requesting user is the
/// table's owner.
/// None otherwise.
pub fn create_table(conn: &mut MysqlConnection, name: String, field_names: Vec<String>, uid: i32) -> Option<i32> {
if jrtables::get_tbl_by_name_uid(conn, &name, uid).is_ok() {
return None;
}
if jrtables::create_jrtable(conn, &name, field_names, uid).is_err() {
return None;
}
let tblid = jrtables::get_tbl_by_name_uid(conn, &name, uid);
if tblid.is_err() {
return None;
}
Some(tblid.unwrap())
}
/// Returns a User struct of a requested user if the combination of username and email are
/// consistent or both do not exist yet, in which case the user is newly created.
pub fn register_or_login(conn: &mut MysqlConnection, uname: String, mail: String) -> Option<User> {
let mut uid = users::get_uid_email(conn, &mail);
if uid.is_err() {
if users::get_uid_uname(conn, &uname).is_ok() || users::create_user(conn, &uname, &mail).is_err() {
return None;
}
uid = users::get_uid_email(conn, &mail);
if uid.is_err() {
return None;
}
}
let uid = uid.unwrap();
let nm = users::get_uname(conn, uid);
if nm.is_err() || nm.unwrap() != uname {
return None;
}
Some(User { uid: uid, uname: uname, email: mail })
}
pub fn delete_user(conn: &mut MysqlConnection, uid: i32) -> Option<bool> {
if users::delete_user(conn, uid).is_err() {
return None;
}
Some(true)
}
pub fn add_row(conn: &mut MysqlConnection, tblid: i32, values: Vec<String>, uid: i32) -> Option<i32> {
let owner = jrtables::get_owner_id(conn, tblid);
let nrows = jrtables::get_nrows(conn, tblid);
if nrows.is_err() || owner.is_err() || owner.unwrap() != uid {
return None;
}
let nrows = nrows.unwrap() as i32;
if jrentries::create_jrentry(conn, tblid).is_err() {
return None;
}
let entryid = jrentries::get_jrentry_id(conn, tblid, nrows+1);
if entryid.is_err() {
return None;
}
let entryid = entryid.unwrap();
let cols = jrcolumns::get_clmns_of(conn, tblid);
if cols.is_err() {
return None;
}
let cols = cols.unwrap();
for (i,col) in cols.iter().enumerate() {
if jrcells::create_jrcell(conn, entryid, col.id, &values[i]).is_err() {
return None;
}
}
Some(entryid)
}
pub fn delete_row(conn: &mut MysqlConnection, tblid: i32, row_pos: i32, uid: i32) -> Option<bool> {
let owner = jrtables::get_owner_id(conn, tblid);
if owner.is_err() || owner.unwrap() != uid || jrentries::delete_jrentry_relative(conn, tblid, row_pos).is_err() {
return None;
}
Some(true)
}
pub fn move_row(conn: &mut MysqlConnection, tblid: i32, rowpos: i32, newpos: i32, uid: i32) -> Option<bool> {
let owner = jrtables::get_owner_id(conn, tblid);
if owner.is_err() || owner.unwrap() != uid || jrentries::move_jrentry(conn, tblid, rowpos, newpos).is_err() {
return None;
}
Some(true)
}
pub fn edit_cell(conn: &mut MysqlConnection, tblid: i32, row_pos: i32, column_pos: i32, new_value: String, uid: i32) -> Option<bool> {
let owner = jrtables::get_owner_id(conn, tblid);
if owner.is_err() ||
owner.unwrap() != uid ||
jrcells::change_jrcell_value_relative(conn, tblid, row_pos, column_pos, new_value).is_err()
{
return None;
}
Some(true)
}
pub fn move_column(conn: &mut MysqlConnection, tblid:i32, column_pos: i32, new_column_pos: i32, uid: i32) -> Option<bool> {
let owner = jrtables::get_owner_id(conn, tblid);
if owner.is_err() ||
owner.unwrap() != uid ||
jrcolumns::move_column_relative(conn, tblid, column_pos, new_column_pos).is_err()
{
return None;
}
Some(true)
}
pub fn add_column(conn: &mut MysqlConnection, tblid: i32, name: String, uid: i32) -> Option<i32> {
let owner = jrtables::get_owner_id(conn, tblid);
if owner.is_err() ||
owner.unwrap() != uid ||
jrcolumns::create_jrcolumn(conn, tblid, name).is_err()
{
return None;
}
let clmid = jrcolumns::get_last_column_id_of(conn, tblid);
if clmid.is_err() {
return None;
}
Some(clmid.unwrap())
}
pub fn delete_column(conn: &mut MysqlConnection, tblid: i32, column_pos: i32, uid: i32) -> Option<bool> {
let owner = jrtables::get_owner_id(conn, tblid);
if owner.is_err() ||
owner.unwrap() != uid ||
jrcolumns::delete_column_relative(conn, tblid, column_pos).is_err()
{
return None;
}
Some(true)
}
pub fn rename_column(conn: &mut MysqlConnection, tblid: i32, column_pos: i32, new_name: String, uid: i32) -> Option<bool> {
let owner = jrtables::get_owner_id(conn, tblid);
if owner.is_err() ||
owner.unwrap() != uid ||
jrcolumns::rename_column_relative(conn, tblid, column_pos, new_name).is_err()
{
return None;
}
Some(true)
}

View File

@ -1,3 +1,20 @@
/* Simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use diesel::prelude::*; use diesel::prelude::*;
use crate::schema::{jrtables, jrcolumns, jrentries, jrcells, users}; use crate::schema::{jrtables, jrcolumns, jrentries, jrcells, users};

View File

@ -1,97 +0,0 @@
use diesel::prelude::*;
use crate::schema::{jrtables, jrcolumns, jrentries, jrcells, users};
#[derive(Queryable, Selectable, Identifiable, Associations)]
#[diesel(table_name = crate::schema::jrtables)]
#[diesel(belongs_to(User, foreign_key = owner_id))]
#[diesel(check_for_backend(diesel::mysql::Mysql))]
pub struct Jrtable {
pub id: i32,
pub name: String,
pub owner_id: i32,
}
#[derive(Insertable)]
#[diesel(table_name = jrtables)]
#[diesel(check_for_backend(diesel::mysql::Mysql))]
pub struct NewJrtable {
pub name: String,
pub owner_id: i32,
}
#[derive(Queryable, Selectable, Identifiable, Associations)]
#[diesel(table_name = jrcolumns)]
#[diesel(belongs_to(Jrtable))]
#[diesel(check_for_backend(diesel::mysql::Mysql))]
pub struct Jrcolumn {
pub id: i32,
pub name: String,
pub jrtable_id: i32,
pub id_in_table: i32,
}
#[derive(Insertable)]
#[diesel(table_name = jrcolumns)]
#[diesel(check_for_backend(diesel::mysql::Mysql))]
pub struct NewJrcolumn {
pub name: String,
pub jrtable_id: i32,
pub id_in_table: i32,
}
#[derive(Queryable, Selectable, Identifiable, Associations)]
#[diesel(table_name = jrentries)]
#[diesel(belongs_to(Jrtable))]
#[diesel(check_for_backend(diesel::mysql::Mysql))]
pub struct Jrentry {
pub id: i32,
pub row_pos: i32,
pub jrtable_id: i32,
}
#[derive(Insertable)]
#[diesel(table_name = jrentries)]
#[diesel(check_for_backend(diesel::mysql::Mysql))]
pub struct NewJrentry {
pub row_pos: i32,
pub jrtable_id: i32,
}
#[derive(Queryable, Selectable, Identifiable, Associations)]
#[diesel(table_name = jrcells)]
#[diesel(belongs_to(Jrentry))]
#[diesel(belongs_to(Jrcolumn))]
#[diesel(check_for_backend(diesel::mysql::Mysql))]
pub struct Jrcell {
pub id: i32,
pub cell_value: String,
pub jrentry_id: i32,
pub jrcolumn_id: i32,
}
#[derive(Insertable)]
#[diesel(table_name = jrcells)]
#[diesel(check_for_backend(diesel::mysql::Mysql))]
pub struct NewJrcell {
pub cell_value: String,
pub jrentry_id: i32,
pub jrcolumn_id: i32,
}
#[derive(Queryable, Selectable, Identifiable)]
#[diesel(table_name = users)]
#[diesel(check_for_backend(diesel::mysql::Mysql))]
pub struct User {
pub id: i32,
pub username: String,
pub email: String,
}
#[derive(Insertable)]
#[diesel(table_name = users)]
#[diesel(check_for_backend(diesel::mysql::Mysql))]
pub struct NewUser {
pub username: String,
pub email: String,
}

View File

@ -1,3 +1,20 @@
/* Simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// @generated automatically by Diesel CLI. // @generated automatically by Diesel CLI.
diesel::table! { diesel::table! {

View File

@ -1,3 +1,21 @@
/* This file is part of inventur.
* inventur is a simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use crate::models; use crate::models;
use crate::schema; use crate::schema;

View File

@ -1,56 +0,0 @@
use crate::models;
use crate::schema;
use schema::users::dsl::{users, id, username, email};
use models::NewUser;
use diesel::prelude::*;
use diesel::mysql::MysqlConnection;
pub fn create_user(conn: &mut MysqlConnection, uname: String, mail: String) -> Result<usize, diesel::result::Error> {
let user = NewUser { username: uname, email: mail};
diesel::insert_into(crate::schema::users::table)
.values(&user)
.execute(conn)
}
pub fn delete_user(conn: &mut MysqlConnection, uid: i32) -> Result<usize, diesel::result::Error> {
diesel::delete(users.find(uid))
.execute(conn)
}
pub fn get_uid_email(conn: &mut MysqlConnection, mail: String) -> Result<i32, diesel::result::Error> {
users
.filter(email.eq(mail))
.select(id)
.first::<i32>(conn)
}
pub fn get_uid_uname(conn: &mut MysqlConnection, uname: String) -> Result<i32, diesel::result::Error> {
users
.filter(username.eq(uname))
.select(id)
.first::<i32>(conn)
}
pub fn get_uname(conn: &mut MysqlConnection, uid: i32) -> Result<String, diesel::result::Error> {
users
.find(uid)
.select(username)
.first::<String>(conn)
}
pub fn get_email(conn: &mut MysqlConnection, uid: i32) -> Result<String, diesel::result::Error> {
users
.find(uid)
.select(email)
.first::<String>(conn)
}
pub fn get_user_tables(conn: &mut MysqlConnection, uid: i32) -> Result<Vec<i32>, diesel::result::Error> {
use schema::jrtables::dsl::{jrtables, id as tblid, owner_id};
jrtables
.filter(owner_id.eq(uid))
.select(tblid)
.load::<i32>(conn)
}

View File

@ -1,3 +1,20 @@
/* Simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use crate::Db; use crate::Db;
use rocket::response::Redirect; use rocket::response::Redirect;

View File

View File

@ -1,10 +1,26 @@
/* Simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#[macro_use] extern crate rocket; #[macro_use] extern crate rocket;
mod auth; mod auth;
mod table; mod table;
use auth::AuthUser; use auth::AuthUser;
// TODO: filter (ajax, spinning circle), show options as in excel
use rocket::fs::{FileServer, relative}; use rocket::fs::{FileServer, relative};
use rocket_dyn_templates::{Template, context}; use rocket_dyn_templates::{Template, context};
use rocket::request; use rocket::request;

View File

@ -1,10 +0,0 @@
// @generated automatically by Diesel CLI.
diesel::table! {
jrtables (id) {
id -> Integer,
#[max_length = 255]
name -> Varchar,
num_fields -> Integer,
}
}

View File

@ -1,3 +1,20 @@
/* Simple web app using rocket to help maintain inventory data.
* Copyright (C) 2024 Johannes Randerath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use crate::auth; use crate::auth;
use auth::AuthUser; use auth::AuthUser;

View File

@ -1,120 +0,0 @@
#[get("/<tid>")]
async fn table(conn: Db, tid: i32, user: AuthUser) -> Option<Template> {
let uid = user.uid;
let table = conn.run(move |c| inventur_db::get_table(c, tid, uid)).await;
if table.is_none() {
return None;
}
let table = table.unwrap();
let tname = table.name;
let columns = table.column_names;
let trows = table.rows;
let mut rows = Vec::new();
for trow in trows {
rows.push(trow.cells);
let index = rows.len()-1;
rows[index].insert(0, trow.row_pos.to_string());
}
let rows = rows;
let mut tids = conn.run(move |c| inventur_db::get_user_tblids(c, uid)).await;
let tnames;
if tids.is_none() {
tids = Some(Vec::new());
tnames = Some(Vec::new());
}else {
let tids = tids.clone().unwrap();
tnames = conn.run(move |c| inventur_db::get_tblnames(c, tids)).await;
}
let tids = tids.unwrap();
if tnames.is_none() {
return None;
}
Some(
Template::render("table",
context!{
sort_field: 0,
sort_dir: 0,
tblid: tid,
tblname: tname,
tids: tids,
tnames: tnames,
columns: columns,
rows: rows,
}
)
)
}
#[derive(FromForm)]
struct NewEntry {
tblid: i32,
cells: Vec<String>,
}
#[post("/new", data="<data>")]
async fn new_entry(conn: Db, data: Form<NewEntry>, user: AuthUser) -> Result<Redirect, Status> {
let uid = user.uid;
let cells = data.cells.clone();
let tblid = data.tblid;
if conn.run(move |c| inventur_db::add_row(c, data.tblid, cells, uid)).await.is_none() {
return Err(Status::Forbidden);
}
Ok(Redirect::to(uri!("/table", table(tblid))))
}
#[derive(FromForm)]
struct EditTname {
tblid: i32,
new_name: String,
}
#[post("/name/edit", data="<data>")]
async fn edit_tname(conn: Db, data: Form<EditTname>, user: AuthUser) -> Result<Redirect, Status> {
let uid = user.uid;
let tblid = data.tblid;
if conn.run(move |c| inventur_db::rename_table(c, data.tblid, data.new_name.clone(), uid)).await.is_none() {
return Err(Status::Forbidden);
}
Ok(Redirect::to(uri!("/table", table(tblid))))
}
#[derive(FromForm)]
struct NewTable {
name: String,
fields: Vec<String>,
}
#[post("/create", data="<data>")]
async fn create(conn: Db, data: Form<NewTable>, user: AuthUser) -> Result<Redirect, Status> {
let uid = user.uid;
let tblid = conn.run(move |c| inventur_db::create_table(c, data.name.clone(), data.fields.clone(), uid)).await;
if tblid.is_none() {
return Err(Status::Forbidden);
}
Ok(Redirect::to(uri!("/table", table(tblid.unwrap()))))
}
#[derive(Deserialize)]
#[serde(crate = "rocket::serde")]
struct ImportTable {
name: String,
columns: Vec<String>,
rows: Vec<Vec<String>>,
}
#[post("/import", data="<data>")]
pub async fn import_table(conn: Db, data: Json<ImportTable>, user: AuthUser) -> Result<Redirect, Status> {
let uid = user.uid;
let columns = data.columns.clone();
let rows = data.rows.clone();
let tblid = conn.run(move |c| inventur_db::create_table(c, data.name.clone(), columns, uid)).await;
if tblid.is_none() {
return Err(Status::UnprocessableEntity);
}
let tblid = tblid.unwrap();
for row in rows {
conn.run(move |c| inventur_db::add_row(c, tblid, row, uid)).await;
}
Ok(Redirect::to(uri!("/table", table(tblid))))
}

View File

@ -1,14 +1,23 @@
{# vim: set filetype=html :#} {# vim: set filetype=html :#}
<!DOCTYPE html> <!DOCTYPE html>
<!-- <!-- This file is part of inventur.
This file is part of Inventory. -- inventur is a simple web app using rocket to help maintain inventory data.
-- Copyright (C) 2024 Johannes Randerath
Inventory is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. --
-- This program is free software: you can redistribute it and/or modify
Foobar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -- it under the terms of the GNU Affero General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
You should have received a copy of the GNU General Public License along with Inventory. If not, see <https://www.gnu.org/licenses/>. -- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU Affero General Public License for more details.
--
-- You should have received a copy of the GNU Affero General Public License
-- along with this program. If not, see <https://www.gnu.org/licenses/>.
--> -->
<html> <html>
<head lang="en"> <head lang="en">
<meta name="author" content="Johannes Randerath" /> <meta name="author" content="Johannes Randerath" />

View File

@ -1,4 +1,22 @@
{# vim: set filetype=html: #} {# vim: set filetype=html: #}
<!-- This file is part of inventur.
-- inventur is a simple web app using rocket to help maintain inventory data.
-- Copyright (C) 2024 Johannes Randerath
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU Affero General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU Affero General Public License for more details.
--
-- You should have received a copy of the GNU Affero General Public License
-- along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
{% extends "base" %} {% extends "base" %}
{% block body %} {% block body %}
<div class="accordion" id="my_tables"> <div class="accordion" id="my_tables">

View File

@ -1,30 +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 - Index</title>
</head>
<body>
<nav class='navbar navbar-expand-lg bg-body bg-body-tertiary'>
<div class="container-fluid">
<a class='navbar-brand' href='base.html'>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 ms-auto mb-2 mb-lg-0">
<li class="nav-item"><a class="nav-link" href="login.html">Login <i class="bi bi-box-arrow-in-right"></i></a></li>
</ul>
</div>
</div>
</nav>
<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>

View File

@ -1,41 +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 - Index</title>
</head>
<body>
<nav class='navbar navbar-expand-lg bg-body bg-body-tertiary'>
<div class="container-fluid">
<a class='navbar-brand' href='base.html'>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 ms-auto mb-2 mb-lg-0">
<li class="nav-item"><a class="nav-link" href="register.html">Register <i class="bi bi-person-plus"></i></a></li>
</ul>
</div>
</div>
</nav>
<h2>Login to Inventory</h2>
<form>
<div class="mb-3">
<label for="login_email" class="form-label">Email</label>
<input id="login_email" class="form-control" placeholder="me@member.fsf.org" type="email">
</div>
<div class="mb-3">
<label for="login_password" class="form-label">Password</label>
<input id="login_password" class="form-control" placeholder="123456789" type="password">
</div>
<button type="submit" class="btn btn-primary">Login</button>
</form>
<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>

View File

@ -1,46 +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 - Index</title>
</head>
<body>
<nav class='navbar navbar-expand-lg bg-body bg-body-tertiary'>
<div class="container-fluid">
<a class='navbar-brand' href='base.html'>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 ms-auto mb-2 mb-lg-0">
<li class="nav-item"><a class="nav-link" href="login.html">Login <i class="bi bi-box-arrow-in-right"></i></a></li>
</ul>
</div>
</div>
</nav>
<h2>Register for Inventory</h2>
<form>
<div class="mb-3">
<label for="register_email" class="form-label">Email</label>
<input id="register_email" type="email" class="form-control" placeholder="me@member.fsf.org">
</div>
<div class="mb-3">
<label for="register_password" class="form-label">Password</label>
<input id="register_password" type="password" class="form-control" placeholder="123456789">
</div>
<div class="mb-3">
<label for="confirm_password" class="form-label">Confirm password</label>
<input id="confirm_password" type="password" class="form-control" placeholder="123456789">
</div>
<button class="btn btn-primary" type="submit">Register</button>
</form>
<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>

View File

@ -1,4 +1,21 @@
{# vim: set filetype=html: #} {# vim: set filetype=html: #}
<!-- This file is part of inventur.
-- inventur is a simple web app using rocket to help maintain inventory data.
-- Copyright (C) 2024 Johannes Randerath
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU Affero General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU Affero General Public License for more details.
--
-- You should have received a copy of the GNU Affero General Public License
-- along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
{% extends "base" %} {% extends "base" %}
{% block pagename %}Table{% endblock pagename %} {% block pagename %}Table{% endblock pagename %}

View File

@ -1,3 +0,0 @@
{% extends "base" %}
{% block pagename %}Test{% endblock pagename%}
{% block body %}{% endblock body %}