Функции по работе с JSON

This commit is contained in:
Sergey Kalinin 2019-08-23 17:31:13 +03:00
parent 9ab792d761
commit 2503187e59
4 changed files with 82 additions and 50 deletions

View File

@ -7,6 +7,8 @@
########################################### ###########################################
proc Quit {} { proc Quit {} {
global servers_list
puts [tcl2json $servers_list]
exit exit
} }
@ -30,7 +32,7 @@ proc TreePress {tree} {
} }
proc SetGlobalVarFromTreeItems {tree id} { proc SetGlobalVarFromTreeItems {tree id} {
global host server active_cluster infobase profile_name dir rac_cmd_for_host rac_cmd global host server active_cluster infobase profile_name dir rac_cmd_for_host rac_cmd servers_list
set parent [$tree parent $id] set parent [$tree parent $id]
set values [$tree item $id -values] set values [$tree item $id -values]
set key [lindex [split $id "::"] 0] set key [lindex [split $id "::"] 0]
@ -52,15 +54,23 @@ proc SetGlobalVarFromTreeItems {tree id} {
close $orig_file close $orig_file
} }
work_server {set server $values} work_server {set server $values}
cluster {set active_cluster $values} cluster {
infobase {set infobase $values} set active_cluster $values
#dict set servers_list $host $values
}
infobase {
set infobase $values
#dict set servers_list $host $active_cluster infobases $values
}
profile {set profile_name $values} profile {set profile_name $values}
} }
if {$parent eq ""} { if {$parent eq ""} {
return return
} else { } else {
SetGlobalVarFromTreeItems $tree $parent SetGlobalVarFromTreeItems $tree $parent
} }
} }
proc InsertItemsWorkList {lst} { proc InsertItemsWorkList {lst} {
@ -340,10 +350,12 @@ proc GetWorkTreeRow {} {
return $lst return $lst
} }
proc CreateInfoBasesJSONfile {} { proc CreateInfoBasesJSONfile {serversList} {
global default dir global default dir
puts $serversList
puts [tcl2json $serversList]
set info_base_json_file [file join $dir(work) infobases.lst] set info_base_json_file [file join $dir(work) infobases.lst]
set jsonStr { \ set jsonStr {
{ {
"servers":[ "servers":[
{ "server-id": "server_id1", { "server-id": "server_id1",
@ -362,9 +374,7 @@ proc CreateInfoBasesJSONfile {} {
} }
]} ]}
]} ]}
} }
} }
namespace eval Run {} {} namespace eval Run {} {}
@ -2464,3 +2474,4 @@ proc Del::inet {tree host profile_name} {

View File

@ -57,3 +57,4 @@ proc jsonget {json args} {
return $json return $json
} }

32
lib/theme.tcl Normal file
View File

@ -0,0 +1,32 @@
######################################################
# Rac GUI
# Graphical theme settings
#
# Distributed under GNU Public License
# Author: Sergey Kalinin svk@nuk-svk.ru
# Home page: https://nuk-svk.ru
# Git repos: https://bitbucket.org/svk28/rac-gui
######################################################
# set editor(fg) grey
# set editor(bg) black
# option add *Entry.Foreground $editor(fg) interactive
# option add *Entry.Background $editor(bg) interactive
# option add *Label.Foreground $editor(fg) interactive
# option add *Label.Background $editor(bg) interactive
# option add *Checkbox.Foreground $editor(fg) interactive
# option add *Checkbox.Background $editor(bg) interactive
# option add *Checkbutton.Foreground $editor(fg) interactive
# option add *Checkbutton.Background $editor(bg) interactive
# option add *Combobox.Foreground $editor(fg) interactive
# option add *Combobox.Background $editor(bg) interactive
# option add *Listbox.Foreground $editor(fg) interactive
# option add *Listbox.Background $editor(bg) interactive
# option add *TreeView.Background $editor(bg) interactive
#option add *Treeview.Foreground red interactive
# #option add *Frame.Background $editor(bg) interactive
# option add *ScrollableFrame.Background $editor(bg) interactive
# option add *ScrolledWindow.Background $editor(bg) interactive

View File

@ -2,20 +2,23 @@
# Tcl ignores the next line -*- tcl -*- \ # Tcl ignores the next line -*- tcl -*- \
exec wish "$0" -- "$@" exec wish "$0" -- "$@"
######################################################
# Rac GUI
# 1C RAC (tm) grafical user interface
# Distributed under GNU Public License
# Author: Sergey Kalinin svk@nuk-svk.ru
# Home page: https://nuk-svk.ru
# Git repos: https://bitbucket.org/svk28/rac-gui
#
# version: 1.1.0
# release: 1
#
######################################################
package require msgcat package require msgcat
package require json package require json
package require json::write package require json::write
######################################################
# Rac GUI
# Distributed under GNU Public License
# Author: Sergey Kalinin svk@nuk-svk.ru
# Home page: https://bitbucket.org/svk28/rac-gui
#
# version: 1.0.3
# release: 1
#
######################################################
# Устанавливаем текущий каталог # Устанавливаем текущий каталог
set dir(root) [pwd] set dir(root) [pwd]
@ -83,6 +86,8 @@ source [file join $dir(lib) gui.tcl]
source [file join $dir(work) rac_gui.cfg] source [file join $dir(work) rac_gui.cfg]
# Читаем файл со списком серверов 1С # Читаем файл со списком серверов 1С
#set serversList [dict create servers]
if [file exists [file join $dir(work) 1c_srv.cfg]] { if [file exists [file join $dir(work) 1c_srv.cfg]] {
set f [open [file join $dir(work) 1c_srv.cfg] "RDONLY"] set f [open [file join $dir(work) 1c_srv.cfg] "RDONLY"]
while {[gets $f line] >=0} { while {[gets $f line] >=0} {
@ -92,27 +97,10 @@ if [file exists [file join $dir(work) 1c_srv.cfg]] {
set rac_cmd_for_host($host) [lindex $l 1] set rac_cmd_for_host($host) [lindex $l 1]
} }
.frm_tree.tree insert {} end -id "server::$host" -text "$host" -values "$host" .frm_tree.tree insert {} end -id "server::$host" -text "$host" -values "$host"
# готовим конфиг
dict set servers_list $host clusters {}
} }
} }
# set editor(fg) grey CreateInfoBasesJSONfile $servers_list
# set editor(bg) black
# option add *Entry.Foreground $editor(fg) interactive
# option add *Entry.Background $editor(bg) interactive
# option add *Label.Foreground $editor(fg) interactive
# option add *Label.Background $editor(bg) interactive
# option add *Checkbox.Foreground $editor(fg) interactive
# option add *Checkbox.Background $editor(bg) interactive
# option add *Checkbutton.Foreground $editor(fg) interactive
# option add *Checkbutton.Background $editor(bg) interactive
# option add *Combobox.Foreground $editor(fg) interactive
# option add *Combobox.Background $editor(bg) interactive
# option add *Listbox.Foreground $editor(fg) interactive
# option add *Listbox.Background $editor(bg) interactive
# option add *TreeView.Background $editor(bg) interactive
#option add *Treeview.Foreground red interactive
# #option add *Frame.Background $editor(bg) interactive
# option add *ScrollableFrame.Background $editor(bg) interactive
# option add *ScrolledWindow.Background $editor(bg) interactive
CreateInfoBasesJSONfile