From 2503187e596cdf718e6b55d6cd3a065a3fb9a72e Mon Sep 17 00:00:00 2001 From: Sergey Kalinin Date: Fri, 23 Aug 2019 17:31:13 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A4=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BE=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B5=20=D1=81=20?= =?UTF-8?q?JSON?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/function.tcl | 51 +++++++++++++++++++++++++++++------------------- lib/json.tcl | 1 + lib/theme.tcl | 32 ++++++++++++++++++++++++++++++ rac_gui.tcl | 48 +++++++++++++++++---------------------------- 4 files changed, 82 insertions(+), 50 deletions(-) create mode 100644 lib/theme.tcl diff --git a/lib/function.tcl b/lib/function.tcl index 31350f1..af6861f 100644 --- a/lib/function.tcl +++ b/lib/function.tcl @@ -7,6 +7,8 @@ ########################################### proc Quit {} { + global servers_list + puts [tcl2json $servers_list] exit } @@ -30,7 +32,7 @@ proc TreePress {tree} { } 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 values [$tree item $id -values] set key [lindex [split $id "::"] 0] @@ -52,15 +54,23 @@ proc SetGlobalVarFromTreeItems {tree id} { close $orig_file } work_server {set server $values} - cluster {set active_cluster $values} - infobase {set infobase $values} + cluster { + 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} } + if {$parent eq ""} { return } else { SetGlobalVarFromTreeItems $tree $parent } + } proc InsertItemsWorkList {lst} { @@ -340,31 +350,31 @@ proc GetWorkTreeRow {} { return $lst } -proc CreateInfoBasesJSONfile {} { +proc CreateInfoBasesJSONfile {serversList} { global default dir + puts $serversList + puts [tcl2json $serversList] set info_base_json_file [file join $dir(work) infobases.lst] - set jsonStr { \ - { - "servers":[ - { "server-id": "server_id1", + set jsonStr { + { + "servers":[ + { "server-id": "server_id1", + "clusters": [ + {"cluster-id": "cluster_id_1", "infobases": [ + {"infobase-uid": "infobase_uid_1", "infobase-user":"infobase_user", "infobase-pwd":"infobase_pwd"}, + {"infobase-uid": "infobase_uid_2", "infobase-user":"infobase_user", "infobase-pwd":"infobase_pwd"}] + } + ] + }, + { "server-id": "server_id2", "clusters": [ {"cluster-id": "cluster_id_1", "infobases": [ {"infobase-uid": "infobase_uid_1", "infobase-user":"infobase_user", "infobase-pwd":"infobase_pwd"}, {"infobase-uid": "infobase_uid_2", "infobase-user":"infobase_user", "infobase-pwd":"infobase_pwd"}] } - ] - }, - { "server-id": "server_id2", - "clusters": [ - {"cluster-id": "cluster_id_1", "infobases": [ - {"infobase-uid": "infobase_uid_1", "infobase-user":"infobase_user", "infobase-pwd":"infobase_pwd"}, - {"infobase-uid": "infobase_uid_2", "infobase-user":"infobase_user", "infobase-pwd":"infobase_pwd"}] - } + ]} ]} - ]} -} - - + } } namespace eval Run {} {} @@ -2464,3 +2474,4 @@ proc Del::inet {tree host profile_name} { + diff --git a/lib/json.tcl b/lib/json.tcl index eff505b..3920849 100644 --- a/lib/json.tcl +++ b/lib/json.tcl @@ -57,3 +57,4 @@ proc jsonget {json args} { return $json } + diff --git a/lib/theme.tcl b/lib/theme.tcl new file mode 100644 index 0000000..56f9387 --- /dev/null +++ b/lib/theme.tcl @@ -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 + diff --git a/rac_gui.tcl b/rac_gui.tcl index 1ee51db..aa5dec9 100755 --- a/rac_gui.tcl +++ b/rac_gui.tcl @@ -2,20 +2,23 @@ # Tcl ignores the next line -*- tcl -*- \ 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 json 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] @@ -83,6 +86,8 @@ source [file join $dir(lib) gui.tcl] source [file join $dir(work) rac_gui.cfg] # Читаем файл со списком серверов 1С +#set serversList [dict create servers] + if [file exists [file join $dir(work) 1c_srv.cfg]] { set f [open [file join $dir(work) 1c_srv.cfg] "RDONLY"] 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] } .frm_tree.tree insert {} end -id "server::$host" -text "$host" -values "$host" + # готовим конфиг + dict set servers_list $host clusters {} } } -# 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 +CreateInfoBasesJSONfile $servers_list -CreateInfoBasesJSONfile