{ "data": { "settings": { "version": "1.0.6", "debug": true, "unit": 1, "localDb": "0", "localPath": "db/reslevis", "localPath1":"https://jsonic.it/reslevis/app/db/reslevis", "serverId": "0", "serverMethod": "GET", "serverToken": "0", "serverTokenUrl": "https://192.168.1.3:10002/realms/API.Server.local/protocol/openid-connect/token", "updateInterval": 50000 }, "user": { "id": "1", "name": "Vito", "token": "" }, "ui": { "pages": { "Building": { "columns": [ { "accessorKey": "name", "header": "Name" }, { "accessorKey": "city", "header": "City" }, { "accessorKey": "actions", "header": "" } ] }, "Plan": { "columns": [ { "accessorKey": "name", "header": "Name" }, { "accessorKey": "Building", "header": "Building" }, { "accessorKey": "actions", "header": "" } ] }, "Zone": { "columns": [ { "accessorKey": "name", "header": "Name" }, { "accessorKey": "Building", "header": "Building" }, { "accessorKey": "Plan", "header": "Plan" }, { "accessorKey": "actions", "header": "" } ] }, "Operator": { "columns": [ { "accessorKey": "name", "header": "Name" }, { "accessorKey": "actions", "header": "" } ] }, "Subject": { "columns": [ { "accessorKey": "name", "header": "Name" }, { "accessorKey": "actions", "header": "" } ] }, "Alarm": { "columns": [ { "accessorKey": "name", "header": "Name" }, { "accessorKey": "actions", "header": "" } ] }, "Gateway": { "columns": [ { "accessorKey": "name", "header": "Name" }, { "accessorKey": "status", "header": "Status" }, { "accessorKey": "model", "header": "Model" }, { "accessorKey": "ip", "header": "IP" }, { "accessorKey": "position", "header": "Position" }, { "accessorKey": "actions", "header": "" } ] }, "Tracker": { "columns": [ { "accessorKey": "name", "header": "Name" }, { "accessorKey": "status", "header": "Status" }, { "accessorKey": "model", "header": "Model" }, { "accessorKey": "actions", "header": "" } ] }, "Track": { "columns": [ { "accessorKey": "time", "header": "Time" }, { "accessorKey": "subject", "header": "Subject" }, { "accessorKey": "gateway", "header": "Gateway" }, { "accessorKey": "status", "header": "Status" }, { "accessorKey": "signal", "header": "Signal" }, { "accessorKey": "actions", "header": "" } ] }, "Setting": { "columns": [ { "accessorKey": "name", "header": "Name" }, { "accessorKey": "role", "header": "Role" }, { "accessorKey": "actions", "header": "" } ] } } } }, "on": { "resize": [ ], "hashchange": [ { "log": "hashchange" }, { "browser:pageFromHash": { "pagesClass": "page", "pageChanger": "rl:openPage" } } ], "init": [ { "rl:menuIcons": { "selector": "body", "items": [ { "title": "Buildings", "icon": "rl:buildings", "link": "#Building" }, { "title": "Plans", "icon": "rl:plans", "link": "#Plan" }, { "title": "Zones", "icon": "rl:zones", "link": "#Zone" }, { "title": "Operators", "icon": "rl:operators", "link": "#Operator" }, { "title": "Subjects", "icon": "rl:subjects", "link": "#Subject" }, { "title": "Alarms", "icon": "rl:alarms", "link": "#Alarm" }, { "title": "Gateways", "icon": "rl:gateways", "link": "#Gateway" }, { "title": "Trackers", "icon": "rl:trackers", "link": "#Tracker" }, { "title": "Tracks", "icon": "rl:tracks", "link": "#Track" }, { "title": "Settings", "icon": "rl:settings", "link": "#Setting" }, { "title": "Info", "icon": "rl:info", "link": "#Info" } ] } }, { "fetchJson": { "url": "./assets/api/reslevis.api-1.0.4.json", "to": "data api", "options": { "method": "POST", "headers": { "Content-Type": "application/json", "Authorization": "" }, "body": "{var formData}" }, "success": [ { "log": "API {data api info version} loaded" }, { "getToken": { "url": "{data settings serverTokenUrl}", "options": { "method": "POST", "headers": { "Content-Type": "application/x-www-form-urlencoded" }, "body": "grant_type=client_credentials&client_id=Fastapi&client_secret=wojuoB7Z5xhlPFrF2lIxJSSdVHCApEgC" }, "success": [ { "rl:createPages": {} } ], "error": [ { "rl:createPages": {} } ] } } ], "error": [ { "log": "Error loading reslevis.api-1.0.4.json" }, { "getToken": { "url": "{data settings serverTokenUrl}", "options": { "method": "POST", "headers": { "Content-Type": "application/x-www-form-urlencoded" }, "body": "grant_type=client_credentials&client_id=Fastapi&client_secret=wojuoB7Z5xhlPFrF2lIxJSSdVHCApEgC" }, "success": [ { "rl:createPages": {} } ], "error": [ { "rl:createPages": {} } ] } } ] } } ] }, "plugins": [ { "name": "app", "version": "", "ondemand": false, "files": [ { "type": "link", "url": "app.css" }, { "type": "script", "url": "app.js" } ] }, { "name": "tablestack", "description": "Headless UI for building powerful tables & datagrids", "version": "8.21.3", "ondemand": false, "files": [ { "type": "script", "url": "assets/plugins/tablestack.min.js", "cdn": "https://unpkg.com/@tanstack/table-core@8.11.6/build/umd/index.production.js" } ] }, { "name": "alpinejs", "description": "The rugged, minimal JavaScript framework", "version": "3.x.x", "ondemand": false, "files": [ { "type": "script", "url": "assets/plugins/alpinejs.min.js" } ] }, { "name": "simplebar", "description": "Scrollbars, simpler", "version": "6.2.7", "ondemand": false, "files": [ { "type": "link", "url": "assets/plugins/simplebar.css" }, { "type": "script", "url": "assets/plugins/simplebar.min.js" } ] }, { "name": "flatpickr", "description": " A lightweight, powerful javascript datetime picker", "version": "4.6.13", "ondemand": false, "files": [ { "type": "link", "url": "assets/plugins/flatpickr.min.css" }, { "type": "script", "url": "assets/plugins/flatpickr.min.js" } ] }, { "name": "sweetalert2", "description": "A beautiful, responsive, customizable and accessible (WAI-ARIA) replacement for JavaScript's popup boxes", "version": "11.17.2", "ondemand": false, "files": [ { "type": "script", "url": "assets/plugins/sweetalert2@11.js" } ] }, { "name": "snapsvg", "description": "JavaScript Vector Library", "type": "script", "version": "0.5.1", "ondemand": false, "url": "assets/plugins/snap.svg-min.js" }, { "name": "qrcode-svg", "description": "A simple QR Code generator in pure JavaScript", "type": "script", "version": "1.1.0", "ondemand": false, "url": "assets/plugins/qrcode.min.js", "ref": "https://papnkukn.github.io/qrcode-svg/" } ], "plugins-disabled": [], "setup": { "webhookPlayground": "https://webhook.site/#!/view/03f56bb4-e516-49cf-96d7-89bd76eff70c/fb1151db-574e-4bbe-b253-66e8c7030a6e/1", "languages": [ "en" ], "language": "en", "log": false, "modules": [ { "name": "reslevisIcons", "url": "assets/modules/reslevis.icons.json" }, { "name": "reslevisData", "url": "assets/modules/reslevis.data.json" }, { "name": "reslevisTexts", "url": "assets/modules/reslevis.texts.json" } ] }, "parts": { "rl": { "getToken": [ { "log": "getToken from {arguments:serverTokenUrl}" }, { "fetchJson": { "to": "data user token", "url": "{arguments:serverTokenUrl}", "options": { "method": "POST", "headers": { "Content-Type": "application/x-www-form-urlencoded" }, "body": "grant_type=client_credentials&client_id=Fastapi&client_secret=wojuoB7Z5xhlPFrF2lIxJSSdVHCApEgC" }, "success": [ { "log": "token ok" } ], "error": [ { "log": "Error fetching auth token" } ] } } ], "createPages": { "do": [ { "log": "Create pages" }, { "for": { "var": "db", "of": [ "Building", "Plan", "Zone", "Operator", "Subject", "Alarm", "Gateway", "Tracker", "Track", "Setting" ], "do": [ { "html": [ { "selector": ".main", "tag": "div", "attr": { "id": "page{var db}", "data-value": "{var db}", "class": "page hidden" }, "text": "" } ] }, { "rl:getDb": { "db": "{var db}", "serverId": "{data settings serverId}", "serverMethod": "{data settings serverMethod}", "localDb": "{data settings localDb}", "localPath": "{data settings localPath}", "token": "{data user token}" } } ] } }, { "browser:pageFromHash": { "pagesClass": "page", "pageChanger": "rl:openPage" } } ] }, "updateDb": { "do": [ { "set": { "var dbUrl": [ "{data api servers {arguments:localDb} url}/get{arguments:db}s", "{arguments:localPath}/{arguments:db}.json" ], "var token": "{data user token}" } }, { "log": "DB update: {var dbUrl {arguments:localDb}}" }, { "fetchJson": { "to": "data db {arguments:db}", "url": "{var dbUrl {arguments:localDb}}", "options": { "method": "{arguments:serverMethod}", "headers": { "Content-Type": "application/json", "Authorization": "Bearer {var token}" }, "body": "" }, "success": [ { "js": "{document.querySelector('.update{arguments:db}').click()}" } ] } } ] }, "getDb": { "do": [ { "set": { "var dbUrl": [ "{data api servers {arguments:localDb} url}/get{arguments:db}s", "{arguments:localPath}/{arguments:db}.json" ], "var infoText": "{texts info{arguments:db}s}", "var token": "{data user token}" } }, { "log": "getDb: {var dbUrl {arguments:localDb}}" }, { "fetchJson": { "to": "data db {arguments:db}", "url": "{var dbUrl {arguments:localDb}}", "options": { "method": "{arguments:serverMethod}", "headers": { "Content-Type": "application/json", "Authorization": "Bearer {var token}" } }, "success": [ { "loadTemplate": { "selector": "#page{arguments:db}", "url": "./assets/templates/{arguments:db}.html", "to": "template {arguments:db}", "empty": true, "arguments": { "db": "{arguments:db}", "info": "{texts info{arguments:db}s}", "serverId": "{data settings serverId}", "new": "rl:newPost" }, "callback": [] } } ], "errorDisabled": [ { "log": "Error loading {var dbUrl {arguments:localDb}}" } ] } } ] }, "openPage": { "arguments": "(page, path)", "do": [ { "if": { "is": "{arguments:page} !== {var actualPage}", "then": [ { "set": { "var actualPage": "{arguments:page}" } } ], "else": [ { "rl:closePost": { "db": "{arguments:page}" } }, { "clearInterval": { "name": "update" } }, { "setInterval2": { "name": "update", "duration": 10000, "do": [ { "rl:updateDb": { "db": "{arguments:page}", "serverId": "{data settings serverId}", "serverMethod": "{data settings serverMethod}", "localDb": "{data settings localDb}", "localPath": "{data settings localPath}", "token": "{data user token}" } } ] } } ] } } ] }, "updateTable": { "do": [ { "set": { "var dbUrl": [ "{data api servers {arguments:localDb} url}/get{arguments:db}s", "{arguments:localPath}/{arguments:db}.json" ], "var token": "{data user token}" } }, { "log": "DB source: {var dbUrl {arguments:localDb}}" }, { "fetchJson": { "to": "data db {arguments:db}", "url": "{var dbUrl {arguments:localDb}}", "options": { "method": "POST", "headers": { "Content-Type": "application/json", "Authorization": "Bearer {var token}" }, "body": "" }, "success": [ { "loadTemplate": { "selector": "#page{arguments:db}", "url": "./assets/templates/{arguments:db}Table.html", "to": "template {arguments:db}", "empty": true, "arguments": { "db": "{arguments:db}", "info": "{var infoText}", "serverId": "{data settings serverId}", "new": "rl:newPost" }, "callback": [] } } ] } } ] }, "openPost": { "do": [ { "set": { "var schemaItem": "{data api components schemas {arguments:db}Item}" } }, { "loadTemplate": { "selector": ".page[data-value={arguments:db}] .post", "url": "./assets/templates/Post.html", "to": "template post", "empty": true, "arguments": { "db": "{arguments:db}", "serverId": "{data settings serverId}", "close": "rl:closePost", "remove": "rl:removePost", "save": "rl:savePost" }, "callback": [ { "html": [ { "selector": ".cancelButton", "on": { "mousedown": [ { "rl:closePost": { "db": "{arguments:db}" } } ] } } ] }, { "createForm": { "selector": ".page[data-value={arguments:db}] .fields", "serverId": "{data settings serverId}", "db": "{arguments:db}", "name": "{arguments:db}", "schema": "{var schemaItem}", "fields": "{arguments:fields}", "error": [ { "log": "error" } ], "success": [ { "log": "success" } ], "callback": [] } } ] } }, { "attr": { "selector": ".page[data-value={arguments:db}] .post", "removeClass": "hidden" } } ] }, "newPost": { "note": "https://developer.mozilla.org/en-US/docs/Glossary/UUID", "do": [ { "rl:openPost": { "db": "{arguments:db}", "id": "", "fields": { "id": "{js:window.crypto.randomUUID();}" } } } ] }, "closePost": { "do": [ { "attr": { "selector": ".page[data-value={arguments:db}] .post", "addClass": "hidden" } } ] }, "savePost": { "do": [ { "log": "savePost:{arguments:name} {arguments:serverId}" }, { "for": { "var": "field", "of": [], "do": [] } }, { "set": { "var formData": "{formDataToJson:.form{arguments:name}}" } }, { "set": { "var formUrl": "{data api servers {arguments:serverId} url}", "var token": "{data user token}" } }, { "fetchJson": { "url": "{data api servers {arguments:serverId} url}/post{arguments:name}", "to": "var result", "options": { "method": "{arguments:serverMethod}", "headers": { "Content-Type": "application/json", "Authorization": "Bearer {var token}" }, "body": "{var formData}" }, "success": [ { "log": "fetched!" } ] } } ] }, "removePost": { "do": [ { "log": "removePost:{arguments:name}" }, { "for": { "var": "field", "of": [], "do": [] } }, { "set": { "var formData": "{formDataToJson:.form{arguments:name}}" } }, { "set": { "var formUrl": "{data api servers {arguments:serverId} url}", "var token": "{data user token}" } }, { "fetchJson": { "url": "{var formUrl}/remove{arguments:name}", "to": "var result", "options": { "method": "{arguments:serverMethod}", "headers": { "Content-Type": "application/json", "Authorization": "Bearer {var token}" }, "body": "{var formData}" }, "success": [ { "log": "fetched!" } ] } } ] }, "menuIcons": { "do": [ { "html": [ { "selector": "body", "tag": "div", "attr": { "class": "main w-full h-full" }, "html": [ { "tag": "div", "attr": { "class": "header flex align-items-center justify-content-center text-center float-wrap" }, "html": [ { "tag": "div", "attr": { "class": "logo m-[10px]" }, "html": [ { "tag": "div", "attr": { "class": "w-[120px] h-[120px] float-left" }, "html": [ { "tag": "img", "attr": { "class": "", "src": "./assets/images/logo-reslevis.svg" } } ] } ] }, { "for": { "var": "item", "of": "{arguments:items}", "html": [ { "tag": "div", "attr": { "class": "p-[20px] text-center" }, "html": [ { "tag": "a", "attr": { "href": "{var item link}" }, "html": [ { "tag": "span", "attr": { "class": "iconify text-[60px] bg-[transparent] text-[#008EED]", "data-icon": "{var item icon}" } } ] }, { "html": [ { "tag": "a", "attr": { "href": "{var item link}" } }, { "tag": "span", "text": "{var item title}", "attr": { "class": "text-[#008EED] text-[16px] px-[0px] py-[10px]" } } ] } ] } ] } } ] } ] } ] } ] } } }, "functions": { "getToken": { "js": "let args = arguments[0]; UI.getToken(args);" }, "createTable": { "js": "let args = arguments[0]; console.log('createTable'); console.log(args); UI.createTable(args); js.callback({do:args.callback});" }, "createForm": { "js": "let args = arguments[0]; /*console.log('createForm'); console.log(args);*/ UI.createForm(args); js.callback({do:args.callback});" }, "loadTemplate": { "js": "let args = arguments[0]; /*console.log('loadTemplate'); console.log(args);*/ UI.loadTemplate(args); js.callback({do:args.callback});" } } }