2022-11-10 15:55:58 -05:00
|
|
|
# --==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-- #
|
|
|
|
# Bruno Charest
|
|
|
|
# 2022-08-09
|
|
|
|
#
|
|
|
|
# __ DESCRIPTIONS __
|
|
|
|
# web_utils : procedure related web interface
|
|
|
|
#
|
|
|
|
# --==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-- #
|
|
|
|
import xlsx # read dashbord.xlsx
|
|
|
|
import jester
|
|
|
|
import ../communication/joplin/joplin_utils
|
|
|
|
import strutils
|
|
|
|
import std/asyncdispatch
|
|
|
|
|
|
|
|
# --==--==--==--==--==--==--==--==--==--==-- #
|
|
|
|
# TYPE : Selected Option for master web page
|
|
|
|
# --==--==--==--==--==--==--==--==--==--==-- #
|
|
|
|
type
|
|
|
|
selectedOption* = enum
|
|
|
|
newNote = "New Note", search = "Search", shortcuts = "Shortcuts",
|
|
|
|
notes = "Notes", notebooks = "Notesbooks", tags = "Tags",
|
|
|
|
notes_selectednote = "Notes-SelectedNote", dashbord = "Dashboard"
|
|
|
|
|
|
|
|
# --==--==--==--==--==--==--==--==--==--==-- #
|
|
|
|
# TYPE : Dashbord information
|
|
|
|
# --==--==--==--==--==--==--==--==--==--==-- #
|
|
|
|
type DashbordData* = object
|
|
|
|
position*: seq[int]
|
|
|
|
ext_link*: seq[string]
|
|
|
|
int_link*: seq[string]
|
|
|
|
ip_link*: seq[string]
|
|
|
|
title*: seq[string]
|
|
|
|
description*: seq[string]
|
|
|
|
server*: seq[string]
|
|
|
|
ip*: seq[string]
|
|
|
|
port*: seq[int]
|
|
|
|
ssl*: seq[bool]
|
|
|
|
category*: seq[string]
|
|
|
|
icon*: seq[string]
|
|
|
|
open_method*: seq[string]
|
|
|
|
tag*: seq[seq[string]]
|
|
|
|
hotkey*: seq[string]
|
|
|
|
color*: seq[string]
|
|
|
|
|
2022-11-10 23:16:14 -05:00
|
|
|
|
|
|
|
# --==--==--==--==--==--==--==--==--==--==-- #
|
|
|
|
# Setup user data
|
|
|
|
# --==--==--==--==--==--==--==--==--==--==-- #
|
|
|
|
type
|
|
|
|
TData* = ref object of RootObj
|
|
|
|
loggedIn*: bool
|
|
|
|
userid*, username*, userpass*, email*: string
|
|
|
|
notification*: int
|
|
|
|
req*: Request
|
|
|
|
|
|
|
|
|
2022-11-10 15:55:58 -05:00
|
|
|
# --==--==--==--==--==--==--==--==--==--==-- #
|
|
|
|
# TYPE : Data Informations for Left Colomn
|
|
|
|
# --==--==--==--==--==--==--==--==--==--==-- #
|
|
|
|
type ColomnLeftData* = ref object of RootObj
|
|
|
|
j_status*: bool
|
|
|
|
option*: selectedOption
|
|
|
|
j_notes*: joplin_notes
|
|
|
|
j_notes_nb*: int
|
|
|
|
j_notebooks*: joplin_notebooks
|
|
|
|
j_notebooks_nb*: int
|
|
|
|
j_tags*: joplin_tags
|
|
|
|
j_tags_nb*: int
|
|
|
|
dashbord*: DashbordData
|
|
|
|
req*: Request
|
|
|
|
|
|
|
|
# --==--==--==--==--==--==--==--==--==--==-- #
|
|
|
|
# TYPE : Data Informations for Right Colomn
|
|
|
|
# --==--==--==--==--==--==--==--==--==--==-- #
|
|
|
|
type ColomnRightData* = ref object of RootObj
|
|
|
|
j_status*: bool
|
|
|
|
option*: selectedOption
|
|
|
|
j_SelectedNote*: joplin_note
|
|
|
|
j_notebooksNote*: joplin_notebooks
|
|
|
|
j_tagsNote*: joplin_tags
|
|
|
|
req*: Request
|
|
|
|
|
|
|
|
|
|
|
|
# --==--==--==--==--==--==--==--==--==--==--==--==--==--==-- #
|
|
|
|
# PROC : get data from dashbord file
|
|
|
|
# --==--==--==--==--==--==--==--==--==--==--==--==--==--==-- #
|
|
|
|
proc getDashbordData*(): Future[DashbordData] {.async.} =
|
|
|
|
|
|
|
|
var ddata: DashbordData
|
2022-11-10 23:16:14 -05:00
|
|
|
var tagslist: seq[string]
|
2022-11-10 15:55:58 -05:00
|
|
|
|
|
|
|
let
|
|
|
|
data = parseExcel("data/dashbord.xlsx", header = true)
|
|
|
|
sheetName = "dashbord"
|
|
|
|
#echo data[sheetName]
|
|
|
|
|
|
|
|
let rows = data[sheetName].toSeq(true)
|
|
|
|
echo rows.len()
|
|
|
|
for i in 0..(rows.len()-1):
|
|
|
|
ddata.position.add(parseInt(rows[i][0]))
|
|
|
|
ddata.ext_link.add(rows[i][1])
|
|
|
|
ddata.int_link.add(rows[i][2])
|
|
|
|
ddata.ip_link.add(rows[i][3])
|
|
|
|
ddata.title.add(rows[i][4])
|
|
|
|
ddata.description.add(rows[i][5])
|
|
|
|
ddata.server.add(rows[i][6])
|
|
|
|
ddata.ip.add(rows[i][7])
|
|
|
|
ddata.port.add(parseInt(rows[i][8]))
|
|
|
|
if rows[i][9] == "OUI":
|
|
|
|
ddata.ssl.add(true)
|
|
|
|
else:
|
|
|
|
ddata.ssl.add(false)
|
|
|
|
|
|
|
|
ddata.category.add(rows[i][10])
|
|
|
|
ddata.icon.add(rows[i][11])
|
|
|
|
ddata.open_method.add(rows[i][12])
|
|
|
|
|
|
|
|
tagslist = rows[i][13].split(',')
|
|
|
|
|
|
|
|
ddata.tag.add(tagslist)
|
|
|
|
ddata.hotkey.add(rows[i][14])
|
|
|
|
ddata.color.add(rows[i][15])
|
|
|
|
|
|
|
|
echo ddata
|
|
|
|
return ddata
|