removed is_logging column

This commit is contained in:
Sergey Yarkov 2023-11-07 09:12:45 +03:00
parent 3dd5ce81c9
commit 0252681847
9 changed files with 10 additions and 26 deletions

View File

@ -60,7 +60,7 @@ export const modbusController = {
*/
async createDevice(req, res, next) {
try {
const { id, name, g_display_reg_addr, g_display_reg_format, g_display_reg_type, g_y_label, is_logging } =
const { id, name, g_display_reg_addr, g_display_reg_format, g_display_reg_type, g_y_label } =
req.body;
await db.run(
`INSERT INTO "modbus_slaves" (
@ -69,10 +69,9 @@ export const modbusController = {
"g_display_reg_addr",
"g_display_reg_format",
"g_display_reg_type",
"g_y_label",
"is_logging")
"g_y_label")
VALUES (?, ?, ?, ?, ?, ?, ?)`,
[id, name, g_display_reg_addr, g_display_reg_format, g_display_reg_type, g_y_label, is_logging],
[id, name, g_display_reg_addr, g_display_reg_format, g_display_reg_type, g_y_label],
);
return res.status(200).json({ message: "Device created." });
} catch (error) {

BIN
data.db

Binary file not shown.

View File

@ -4,7 +4,6 @@ SELECT
g_display_reg_addr,
g_display_reg_format,
g_y_label,
is_logging,
CASE
WHEN COUNT(dv.id) = 0 THEN '[]'
ELSE '[' || GROUP_CONCAT(

1
index.d.ts vendored
View File

@ -30,7 +30,6 @@ export type ModbusDevice = {
g_display_reg_format: NumberType | null;
g_display_reg_type: "HR" | "IR";
g_y_label: string | null;
is_logging: boolean;
display_values?: DisplayValue[]
}

View File

@ -25,7 +25,6 @@ CREATE TABLE IF NOT EXISTS "modbus_slaves" (
"g_display_reg_type" VARCHAR(3) CHECK(g_display_reg_type IN("HR", "IR")) DEFAULT "IR",
"g_display_reg_format" VARCHAR(5) CHECK(g_display_reg_format IN("UI16", "I16", "UI32", "I32", "FP32")) DEFAULT "UI16",
"g_y_label" VARCHAR(40) DEFAULT "Label",
"is_logging" BOOLEAN NOT NULL DEFAULT FALSE,
PRIMARY KEY("id")
);
@ -56,12 +55,12 @@ CREATE TABLE IF NOT EXISTS "display_values" (
-- )
INSERT INTO "modbus_slaves" (
"id", "name", "g_display_reg_addr", "g_display_reg_type", "g_display_reg_format", "g_y_label", "is_logging"
"id", "name", "g_display_reg_addr", "g_display_reg_type", "g_display_reg_format", "g_y_label"
) VALUES
(1, "Device #1", 0, "IR", "UI16", "Label 1", 1),
(2, "Device #2", 1, "IR", "UI32", "Label 2", 1),
(3, "Device #3", 3, "IR", "UI16", "Label 3", 0),
(4, "Device #4", NULL, NULL, NULL, "Label 4", 0);
(1, "Device #1", 0, "IR", "UI16", "Label 1"),
(2, "Device #2", 1, "IR", "UI32", "Label 2"),
(3, "Device #3", 3, "IR", "UI16", "Label 3"),
(4, "Device #4", NULL, NULL, NULL, "Label 4");
INSERT INTO "display_values" (
"id", "name", "slave_id", "reg_addr", "reg_format", "reg_type"

View File

@ -66,7 +66,7 @@
<hr />
<form @submit.prevent="create(() => graphView = 'none')" action="#">
<div
x-id="['id', 'name', 'graph-display', 'g_display_reg_addr', 'g_display_reg_format', 'g_y_label', 'is_logging']"
x-id="['id', 'name', 'graph-display', 'g_display_reg_addr', 'g_display_reg_format', 'g_y_label']"
class="flex flex-col space-y-2"
>
<div>
@ -158,15 +158,6 @@
<option value="FP32">Floating Point 32</option>
</select>
</div>
<div>
<input
x-model="data.is_logging"
:id="$id('is_logging')"
name="is_logging"
type="checkbox"
/>
<label :for="$id('is_logging')">Logging</label>
</div>
</div>
</div>
<div>

View File

@ -70,7 +70,6 @@ document.addEventListener("alpine:init", async () => {
g_display_reg_format: "UI16",
g_display_reg_type: "IR",
g_y_label: "",
is_logging: false,
},
resetDataFields() {
this.data.id = null;
@ -79,7 +78,6 @@ document.addEventListener("alpine:init", async () => {
this.data.g_display_reg_format = "UI16";
this.g_display_reg_type = "IR";
this.data.g_y_label = "";
this.data.is_logging = false;
},
async create(cb) {
try {

View File

@ -123,7 +123,7 @@ export const modbusService = {
async getDevices() {
/** @type {import("..").ModbusDevice[]} */
const devices = await db.all(`
SELECT ms.id AS id, ms.name AS name, g_display_reg_addr, g_display_reg_format, g_display_reg_type, g_y_label, is_logging,
SELECT ms.id AS id, ms.name AS name, g_display_reg_addr, g_display_reg_format, g_display_reg_type, g_y_label,
CASE
WHEN COUNT(dv.id) = 0 THEN '[]'
ELSE '[' || GROUP_CONCAT(

View File

@ -7,7 +7,6 @@ export const modbusDeviceSchema = object({
g_display_reg_format: string().oneOf(["UI16", "I16", "UI32", "I32", "FP32"]).nullable(),
g_display_reg_type: string().oneOf(["HR", "IR"]).nullable(),
g_y_label: string().max(40).nullable(),
is_logging: boolean().required()
});
export const removeModbusDeviceSchema = modbusDeviceSchema.pick(['id']);