diff options
author | Javier Hernandez <jhernandez@soleta.eu> | 2024-01-11 11:53:41 +0100 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2024-01-11 12:10:04 +0100 |
commit | 529d83b19e502b2d2c951954112e4faf00101452 (patch) | |
tree | 5abd44670b3592bd3369810141b5e9c552dd5017 | |
parent | bc787a9a68de88cd534f8cb8541ecec0861a2053 (diff) |
rest: Support adding clients inside folder
Add support for adding clients that are inside a folder.
Add new folder_id field, if zero it means computer is not in a folder.
-rw-r--r-- | src/dbi.h | 1 | ||||
-rw-r--r-- | src/rest.c | 17 |
2 files changed, 12 insertions, 6 deletions
@@ -82,6 +82,7 @@ struct og_computer { unsigned int repo_id; unsigned int center; unsigned int room; + unsigned int folder_id; unsigned int id; bool maintenance; bool remote; @@ -2130,6 +2130,11 @@ static int og_cmd_post_client_add(json_t *element, sizeof(computer.serial_number)); } else if (!strcmp(key, "hardware_id")) { err = og_json_parse_uint(value, &computer.hardware_id); + } else if (!strcmp(key, "folder_id")) { + err = og_json_parse_uint(value, &computer.folder_id); + if (!err) + computer.folder_id = computer.folder_id & 0x0000ffff; + } else if (!strcmp(key, "netdriver")) { err = og_json_parse_string_copy(value, computer.netdriver, @@ -2221,16 +2226,16 @@ static int og_cmd_post_client_add(json_t *element, " oglivedir," " inremotepc," " maintenance" - ") VALUES ('%s', '%s', '%s', '%s', %u, 0, %u," + ") VALUES ('%s', '%s', '%s', '%s', %u, %u, %u," " %u, '%s', '%s', '%s', '%s'," " '%s', %u, %u)", computer.name, computer.serial_number, computer.ip, computer.mac, computer.room, - computer.hardware_id, computer.repo_id, - computer.netmask, computer.boot, - computer.netiface, computer.netdriver, - computer.livedir, computer.remote, - computer.maintenance); + computer.folder_id, computer.hardware_id, + computer.repo_id, computer.netmask, + computer.boot, computer.netiface, + computer.netdriver, computer.livedir, + computer.remote, computer.maintenance); if (!result) { dbi_conn_error(dbi->conn, &msglog); |