manqod-server-console 1.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/manqod-server-console +31 -0
- data/doc/README +18 -0
- data/doc/server.conf.example +18 -0
- data/lib/ConnectionProperties.rb +113 -0
- data/lib/Gtk.rb +55 -0
- data/lib/ServerConsole.rb +281 -0
- data/lib/ServerSelector.rb +42 -0
- metadata +84 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
#this file is part of manqod-server-console
|
3
|
+
#manqod is distributed under the CDDL licence
|
4
|
+
#the author of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)
|
5
|
+
|
6
|
+
path=File::expand_path(File.join(File.dirname(__FILE__),".."))
|
7
|
+
@@etc=File::expand_path(File.join(path,"etc/"))
|
8
|
+
$LOAD_PATH.unshift(File::expand_path(File.join(path,"lib/")))
|
9
|
+
|
10
|
+
INFO=0
|
11
|
+
WARNING=1
|
12
|
+
ERROR=2
|
13
|
+
|
14
|
+
require 'rubygems'
|
15
|
+
begin
|
16
|
+
require 'gtk2'
|
17
|
+
rescue LoadError => err
|
18
|
+
print "install ruby-gtk2\n"
|
19
|
+
exit
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'Gtk.rb'
|
23
|
+
require 'ServerSelector.rb'
|
24
|
+
require 'ServerConsole.rb'
|
25
|
+
require 'ConnectionProperties.rb'
|
26
|
+
|
27
|
+
|
28
|
+
ServerSelector.new
|
29
|
+
|
30
|
+
Gtk.main
|
31
|
+
|
data/doc/README
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
LICENCE:
|
2
|
+
the owner of this program(manqod) is Dobai-Pataky Balint(dpblnt dot gmail dot com)
|
3
|
+
manqod is distributed under the CDDL licence(http://www.opensource.org/licenses/cddl1.php)
|
4
|
+
don't worry this only means the following
|
5
|
+
* you can use it, copy it, modify it
|
6
|
+
* if you want your modifications to be distributed send them back to me, i'll merge them in
|
7
|
+
* nobody can sell it
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
manqod is a program witten in ruby, using ruby-gtk2 for the GKT+ toolkit
|
12
|
+
it's goal is to give us a frontend to manage our data in an sql server
|
13
|
+
|
14
|
+
this is the console of the server
|
15
|
+
|
16
|
+
copy server.conf.example to server.conf
|
17
|
+
uncomment and set the url
|
18
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#
|
2
|
+
# for the host part you can use a fqdn or an ip
|
3
|
+
#
|
4
|
+
#server_uri = "druby://192.168.1.1:5549"
|
5
|
+
|
6
|
+
# the server needs to connect back to clients, so client sends it's address on initial connection
|
7
|
+
# by default the manqod-server-console will use your address returned by gethostname and send that to the server
|
8
|
+
# use client_uri, if you don't have a fqdn, or the server is not be able to resolve your fqdn, or can't reach you by the resolved fqdn
|
9
|
+
#
|
10
|
+
# for the port part you can set a fix the port or set it to 0, than your OS will assign one for us
|
11
|
+
#
|
12
|
+
#client_uri = "druby://192.168.1.2:0"
|
13
|
+
|
14
|
+
{ "localhost" => {
|
15
|
+
:uri => "druby://192.168.1.1:5549",
|
16
|
+
:bind => "druby://:0"
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,113 @@
|
|
1
|
+
#this file is part of manqod-server-console
|
2
|
+
#manqod is distributed under the CDDL licence
|
3
|
+
#the author of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)
|
4
|
+
|
5
|
+
class ConnectionProperties < Gtk::Dialog
|
6
|
+
def initialize(parent_window,cn,manqod_server)
|
7
|
+
@manqod_server=manqod_server
|
8
|
+
@cn=cn
|
9
|
+
conn=@manqod_server.conn(@cn)
|
10
|
+
|
11
|
+
super("Connection Properties",parent_window,Gtk::Dialog::MODAL,[Gtk::Stock::OK,Gtk::Dialog::RESPONSE_ACCEPT],[Gtk::Stock::CANCEL,Gtk::Dialog::RESPONSE_REJECT])
|
12
|
+
dh=Gtk::Table.new(2,1)
|
13
|
+
dh.attach2("Conenction: ",Gtk::Label.new(@cn))
|
14
|
+
@name=dh.attach2("Visible connection name: ",Gtk::Entry.new.set_text(conn["name"]))
|
15
|
+
@uri=dh.attach2("URI:",Gtk::Entry.new.set_text(conn["uri"]))
|
16
|
+
@cache_host=dh.attach2("Memcache host:",Gtk::Entry.new.set_text(conn["cache_host"]))
|
17
|
+
@sql_host=dh.attach2("SQL host:",Gtk::Entry.new.set_text(conn["sql_host"]))
|
18
|
+
@sql_user=dh.attach2("SQL user:",Gtk::Entry.new.set_text(conn["sql_user"]))
|
19
|
+
@sql_password=dh.attach2("SQL password:",Gtk::Entry.new.set_text(conn["sql_password"]))
|
20
|
+
@sql_db=dh.attach2("SQL database:",Gtk::Entry.new.set_text(conn["sql_db"]))
|
21
|
+
|
22
|
+
dh.attach2("SQL database functions:",Gtk::HButtonBox.new.
|
23
|
+
pack_start(check_db=Gtk::Button.new("check")).
|
24
|
+
pack_start(pstruct_db=Gtk::Button.new("populate\nstructure"))).
|
25
|
+
pack_start(pmanqod_db=Gtk::Button.new("pupulate\nmanqod"))
|
26
|
+
|
27
|
+
@admin_uri=dh.attach2("Admin URI:",Gtk::Entry.new.set_text(conn["admin_uri"]))
|
28
|
+
@client_uri=dh.attach2("Client URI:",Gtk::Entry.new.set_text(conn["client_uri"]))
|
29
|
+
@auto_load=dh.attach2("Auto load on startup:",Gtk::CheckButton.new.set_active(conn["auto_load"]))
|
30
|
+
@auto_load_order=dh.attach2("Auto load order:",Gtk::Entry.new.set_text(conn["auto_load_order"]))
|
31
|
+
@client_default=dh.attach2("Default for clients:",Gtk::CheckButton.new.set_active(conn["client_default"]))
|
32
|
+
|
33
|
+
vbox.pack_start(dh)
|
34
|
+
|
35
|
+
#check and create database and permission
|
36
|
+
check_db.signal_connect("clicked",@cn){|me,cn|
|
37
|
+
begin
|
38
|
+
save_conn
|
39
|
+
@manqod_server.check_sql_db(cn)
|
40
|
+
Gtk::warn("Mysql connection is OK")
|
41
|
+
rescue =>err
|
42
|
+
begin
|
43
|
+
Gtk::warn("checking #{cn.inspect} failed",err,ERROR)
|
44
|
+
dialog=Gtk::Dialog.new("Crate database and permissions",self,Gtk::Dialog::MODAL,[Gtk::Stock::OK,Gtk::Dialog::RESPONSE_ACCEPT],[Gtk::Stock::CANCEL,Gtk::Dialog::RESPONSE_REJECT])
|
45
|
+
holder=Gtk::Table.new(2,1)
|
46
|
+
su=holder.attach2("Super User Username",Gtk::Entry.new.set_text("root"))
|
47
|
+
sup=holder.attach2("Super User Password",Gtk::Entry.new.set_visibility(false))
|
48
|
+
dialog.vbox.pack_start(holder)
|
49
|
+
dialog.show_all
|
50
|
+
if dialog.run == Gtk::Dialog::RESPONSE_ACCEPT
|
51
|
+
@manqod_server.create_sql_db_and_perms(cn,su.text,sup.text)
|
52
|
+
Gtk::warn("Mysql database and permissions created.\nCheck again.")
|
53
|
+
end
|
54
|
+
rescue =>err2
|
55
|
+
Gtk::warn("SU on #{@cn.inspect} failed",err2,ERROR)
|
56
|
+
ensure
|
57
|
+
dialog.destroy
|
58
|
+
end
|
59
|
+
end
|
60
|
+
}
|
61
|
+
#populate manqod db
|
62
|
+
pmanqod_db.signal_connect("clicked",@cn){|me,cn|
|
63
|
+
begin
|
64
|
+
save_conn
|
65
|
+
@manqod_server.populate_manqod_db(cn)
|
66
|
+
Gtk::warn("Population of #{cn} was succesful")
|
67
|
+
rescue =>err
|
68
|
+
Gtk::warn("Population of #{cn.inspect} failed",err,ERROR)
|
69
|
+
end
|
70
|
+
}
|
71
|
+
#populate manqod db structure
|
72
|
+
pstruct_db.signal_connect("clicked",@cn){|me,cn|
|
73
|
+
begin
|
74
|
+
save_conn
|
75
|
+
@manqod_server.populate_manqod_db(cn,true)
|
76
|
+
Gtk::warn("Structure population of #{cn} was succesful")
|
77
|
+
rescue =>err
|
78
|
+
Gtk::warn("Structure population of #{cn.inspect} failed",err,ERROR)
|
79
|
+
end
|
80
|
+
}
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
def run
|
85
|
+
show_all
|
86
|
+
ret=super()
|
87
|
+
if ret==Gtk::Dialog::RESPONSE_ACCEPT
|
88
|
+
save_conn
|
89
|
+
end
|
90
|
+
ret=@name.text
|
91
|
+
destroy
|
92
|
+
ret
|
93
|
+
end
|
94
|
+
def save_conn
|
95
|
+
begin
|
96
|
+
@manqod_server.set_conn_variables(@cn,{"name" => @name.text,
|
97
|
+
"uri" => @uri.text,
|
98
|
+
"cache_host" => @cache_host.text,
|
99
|
+
"sql_host" => @sql_host.text,
|
100
|
+
"sql_user" => @sql_user.text,
|
101
|
+
"sql_password" => @sql_password.text,
|
102
|
+
"sql_db" => @sql_db.text,
|
103
|
+
"admin_uri" => @admin_uri.text,
|
104
|
+
"client_uri" => @client_uri.text,
|
105
|
+
"auto_load" => @auto_load.active?,
|
106
|
+
"auto_load_order" => @auto_load_order.text,
|
107
|
+
"client_default" => @client_default.active?}
|
108
|
+
)
|
109
|
+
rescue => err
|
110
|
+
retry if Gtk::warn("restoring #{@cn.inspect} failed",err,ERROR,true)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
data/lib/Gtk.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
#this file is part of manqod-server-console
|
2
|
+
#manqod is distributed under the CDDL licence
|
3
|
+
#the author of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)
|
4
|
+
|
5
|
+
module Gtk
|
6
|
+
def self.warn(subject,details=nil,level=INFO,canretry=false)
|
7
|
+
subject="#{subject}\n#{details.message}" if details && details.class != String
|
8
|
+
print "#{subject}\n"
|
9
|
+
details="#{details.backtrace.join("\n\t")}" if details && details.class != String
|
10
|
+
print "#{details}\n" unless details.nil?
|
11
|
+
|
12
|
+
dialog=Gtk::MessageDialog.new(nil,Gtk::Dialog::Flags::MODAL,
|
13
|
+
case level
|
14
|
+
when ERROR then Gtk::MessageDialog::ERROR
|
15
|
+
when WARNING then Gtk::MessageDialog::WARNING
|
16
|
+
when INFO then Gtk::MessageDialog::INFO
|
17
|
+
else Gtk::MessageDialog::OTHER
|
18
|
+
end,
|
19
|
+
if canretry
|
20
|
+
Gtk::MessageDialog::ButtonsType::YES_NO
|
21
|
+
else
|
22
|
+
Gtk::MessageDialog::ButtonsType::CLOSE
|
23
|
+
end,
|
24
|
+
subject)
|
25
|
+
# dialog.set_secondary_text("please report it!")
|
26
|
+
dialog.vbox.pack_start(expander=Gtk::Expander.new("details",true).add(Gtk::TextView.new(Gtk::TextBuffer.new.set_text(details)))) unless details.nil?
|
27
|
+
dialog.vbox.pack_end(Gtk::Label.new("retry?"),false,false) if canretry
|
28
|
+
# dialog.set_size_request(400,300)
|
29
|
+
dialog.show_all
|
30
|
+
ret=dialog.run
|
31
|
+
dialog.destroy
|
32
|
+
ret == Gtk::Dialog::ResponseType::YES
|
33
|
+
end
|
34
|
+
def self.ask(question)
|
35
|
+
print question,": "
|
36
|
+
dialog=Gtk::MessageDialog.new(nil,Gtk::Dialog::Flags::MODAL,Gtk::MessageDialog::QUESTION,Gtk::MessageDialog::ButtonsType::YES_NO,question)
|
37
|
+
# dialog.set_size_request(400,300)
|
38
|
+
dialog.show_all
|
39
|
+
ret=dialog.run == Gtk::Dialog::ResponseType::YES
|
40
|
+
dialog.destroy
|
41
|
+
print ret,"\n"
|
42
|
+
ret
|
43
|
+
end
|
44
|
+
|
45
|
+
class Table
|
46
|
+
def attach2(text,obj)
|
47
|
+
n=self.n_rows
|
48
|
+
self.attach_defaults(Gtk::Label.new(text).set_xalign(0),0,1,n,n+1)
|
49
|
+
self.attach_defaults(obj,1,2,n,n+1)
|
50
|
+
self.n_rows=n+1
|
51
|
+
obj
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
@@ -0,0 +1,281 @@
|
|
1
|
+
#this file is part of manqod-server-console
|
2
|
+
#manqod is distributed under the CDDL licence
|
3
|
+
#the author of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)
|
4
|
+
|
5
|
+
class ServerConsole < Gtk::Window
|
6
|
+
class MyStore < Gtk::TreeStore
|
7
|
+
def find_iter(col_num,col_data)
|
8
|
+
found_iter=nil
|
9
|
+
each{|model,path,iter|
|
10
|
+
if iter[col_num]==col_data
|
11
|
+
found_iter=iter
|
12
|
+
break
|
13
|
+
end
|
14
|
+
}
|
15
|
+
found_iter
|
16
|
+
end
|
17
|
+
end
|
18
|
+
def initialize(name,server_uri,client_uri)
|
19
|
+
super("Manqod Server Console on #{name}")
|
20
|
+
signal_connect("destroy") {|me| Gtk.main_quit}
|
21
|
+
set_size_request(600,400)
|
22
|
+
require 'drb'
|
23
|
+
DRb.start_service(client_uri)
|
24
|
+
@manqod_server=DRb::DRbObject.new(nil,server_uri)
|
25
|
+
begin
|
26
|
+
@manqod_server.alive?
|
27
|
+
rescue =>err
|
28
|
+
retry if Gtk::warn("no server?","tried: #{server_uri}\n#{err}\n",ERROR,true)
|
29
|
+
exit
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
#type,conn_name,conn_display,moditem_id,moditem_display
|
34
|
+
#types:0=connection,1=moditem
|
35
|
+
tree_store=MyStore.new(Integer,String,String,Integer,String,String)
|
36
|
+
view=Gtk::TreeView.new(tree_store)
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
renderer = Gtk::CellRendererText.new
|
41
|
+
#view.append_column(conn_col=Gtk::TreeViewColumn.new("connections", renderer, :text => 0))
|
42
|
+
view.append_column(conn_col=Gtk::TreeViewColumn.new("Server", renderer, :text => 2))
|
43
|
+
view.append_column(moditem_col = Gtk::TreeViewColumn.new("List", renderer, :text => 4))
|
44
|
+
view.append_column(cnt_col = Gtk::TreeViewColumn.new("Rows", renderer, :text => 5))
|
45
|
+
view.set_expander_column(moditem_col).set_enable_tree_lines(true)
|
46
|
+
|
47
|
+
begin
|
48
|
+
@manqod_server.conn_list{|conn_name,conn|
|
49
|
+
iter=tree_store.append(nil)
|
50
|
+
iter[0]=0
|
51
|
+
iter[1]=conn_name
|
52
|
+
iter[2]=conn["name"]
|
53
|
+
}
|
54
|
+
rescue =>err
|
55
|
+
retry if Gtk::warn("cannot fill connections list!\nserver is gone?","tried: #{server_uri}\n#{err}\n#{err.backtrace.join("\n")}",ERROR,true)
|
56
|
+
end
|
57
|
+
|
58
|
+
begin
|
59
|
+
@manqod_server.dbs.each_pair{|conn_name,db|
|
60
|
+
piter=tree_store.find_iter(1,conn_name)
|
61
|
+
begin
|
62
|
+
db.each_moditem{|drb_list_model|
|
63
|
+
iter=tree_store.append(piter)
|
64
|
+
iter[0]=1
|
65
|
+
iter[3]=drb_list_model.get_id
|
66
|
+
iter[4]=drb_list_model.moditem["display"]
|
67
|
+
iter[5]=drb_list_model.rowcount.to_s
|
68
|
+
}
|
69
|
+
rescue => err
|
70
|
+
p err
|
71
|
+
end
|
72
|
+
}
|
73
|
+
rescue =>err
|
74
|
+
retry if Gtk::warn("cannot get dbs!\nserver is gone?","tried: #{server_uri}\n#{err}\n#{err.backtrace.join("\n")}",ERROR,true)
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
def edit_connection(view,tree_store,parent_window)
|
79
|
+
if view.cursor[0] and cur_iter=tree_store.get_iter(view.cursor[0]) and cur_iter[0]==0
|
80
|
+
cn=cur_iter[1]
|
81
|
+
else
|
82
|
+
Gtk::warn("select a connection first!")
|
83
|
+
return
|
84
|
+
end
|
85
|
+
begin
|
86
|
+
cp=ConnectionProperties.new(parent_window,cn,@manqod_server)
|
87
|
+
cur_iter[2]=cp.run
|
88
|
+
rescue =>err
|
89
|
+
retry if Gtk::warn("tried to edit #{cn}",err,ERROR)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
holder=Gtk::VBox.new
|
94
|
+
holder.pack_start(buttons=Gtk::Toolbar.new,false,false)
|
95
|
+
holder.pack_end(Gtk::ScrolledWindow.new.set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC).add(view))
|
96
|
+
buttons.append(Gtk::Stock::NEW,"create a new connection"){
|
97
|
+
if Gtk::ask("create a new connection?")
|
98
|
+
dialog=Gtk::Dialog.new("Connection Properties",self,Gtk::Dialog::MODAL,[Gtk::Stock::OK,Gtk::Dialog::RESPONSE_ACCEPT],[Gtk::Stock::CANCEL,Gtk::Dialog::RESPONSE_REJECT])
|
99
|
+
dh=Gtk::Table.new(2,1)
|
100
|
+
dh.attach_defaults(Gtk::Label.new("connection name"),0,1,0,1)
|
101
|
+
dh.attach_defaults(name=Gtk::Entry.new,1,2,0,1)
|
102
|
+
name.text="new"
|
103
|
+
dialog.vbox.pack_start(dh)
|
104
|
+
dialog.show_all
|
105
|
+
if dialog.run==Gtk::Dialog::RESPONSE_ACCEPT
|
106
|
+
iter=tree_store.append(nil);
|
107
|
+
iter[0]=0
|
108
|
+
iter[1]=name.text
|
109
|
+
iter[2]=name.text
|
110
|
+
view.set_cursor(iter.path,nil,false)
|
111
|
+
begin
|
112
|
+
@manqod_server.create_conn(name.text)
|
113
|
+
@manqod_server.set_conn_variables(name.text,{"name" => name.text,
|
114
|
+
"uri" => "druby://:5550",
|
115
|
+
"cache_host" => "localhost",
|
116
|
+
"sql_host" => "localhost",
|
117
|
+
"sql_user" => "root",
|
118
|
+
"sql_password" => "",
|
119
|
+
"sql_db" => "manqod",
|
120
|
+
"admin_uri" => "druby://127.0.0.1:5549",
|
121
|
+
"client_uri" => "druby://127.0.0.1:5549",
|
122
|
+
"auto_load" => true,
|
123
|
+
"auto_load_order" => "1",
|
124
|
+
"client_default" => false}
|
125
|
+
)
|
126
|
+
rescue =>err
|
127
|
+
retry if Gtk::warn("Creating new connection failed",err,ERROR,true)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
dialog.destroy
|
131
|
+
end
|
132
|
+
}
|
133
|
+
buttons.append(Gtk::Stock::PROPERTIES,"set the connection's properties"){edit_connection(view,tree_store,self)}
|
134
|
+
buttons.append(Gtk::Stock::REMOVE,"remove the connection"){
|
135
|
+
if view.cursor[0] and cur_iter=tree_store.get_iter(view.cursor[0]) and cur_iter[0]==0
|
136
|
+
if Gtk::ask("delete the connection from the server?")
|
137
|
+
cn=cur_iter[1]
|
138
|
+
begin
|
139
|
+
@manqod_server.remove_conn(cn)
|
140
|
+
rescue => err
|
141
|
+
retry if Gtk::warn("server is gone?\ntried: #{server_uri}",err,ERROR,true)
|
142
|
+
end
|
143
|
+
tree_store.remove(cur_iter)
|
144
|
+
end
|
145
|
+
else
|
146
|
+
Gtk::warn("select a connection first!")
|
147
|
+
end
|
148
|
+
}
|
149
|
+
buttons.append_space
|
150
|
+
buttons.append(Gtk::Stock::EXECUTE,"start the selected server thread"){
|
151
|
+
if view.cursor[0] and cur_iter=tree_store.get_iter(view.cursor[0]) and cur_iter[0]==0
|
152
|
+
cn=cur_iter[1]
|
153
|
+
begin
|
154
|
+
@manqod_server.load_conn(cn)
|
155
|
+
@manqod_server.dbs[cn].moditems.each_pair{|moditem_id,drb_list_model|
|
156
|
+
iter=tree_store.append(cur_iter)
|
157
|
+
iter[0]=1
|
158
|
+
iter[3]=moditem_id
|
159
|
+
iter[4]=drb_list_model.moditem["display"]
|
160
|
+
}
|
161
|
+
rescue
|
162
|
+
retry if Gtk::warn("Starting server thread #{cn} failed",err,ERROR,true)
|
163
|
+
end
|
164
|
+
else
|
165
|
+
Gtk::warn("select a connection first!")
|
166
|
+
end
|
167
|
+
}
|
168
|
+
buttons.append(Gtk::Stock::STOP,"stop the selected server thread"){
|
169
|
+
if view.cursor[0] and cur_iter=tree_store.get_iter(view.cursor[0]) and cur_iter[0]==0
|
170
|
+
cn=cur_iter[1]
|
171
|
+
if Gtk::ask("stop server thread #{cn}?")
|
172
|
+
while cur_iter.has_child? do if i=cur_iter.clone.first_child then tree_store.remove(i) end end
|
173
|
+
# tree_store.each{|model,path,iter| tree_store.remove(iter) if iter.parent == cur_iter}
|
174
|
+
begin
|
175
|
+
@manqod_server.free_conn(cn)
|
176
|
+
rescue =>err
|
177
|
+
retry if Gtk::warn("Stop server thread #{cn} failed",err,ERROR,true)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
else
|
181
|
+
Gtk::warn("select a server to stop")
|
182
|
+
end
|
183
|
+
}
|
184
|
+
buttons.append(Gtk::Stock::REFRESH,"reload the selected server thread"){
|
185
|
+
if view.cursor[0] and cur_iter=tree_store.get_iter(view.cursor[0]) and cur_iter[0]==0
|
186
|
+
cn=cur_iter[1]
|
187
|
+
if Gtk::ask("reload server thread #{cn}?")
|
188
|
+
while cur_iter.has_child? do if i=cur_iter.clone.first_child then tree_store.remove(i) end end
|
189
|
+
begin
|
190
|
+
@manqod_server.reload_conn(cn)
|
191
|
+
@manqod_server.dbs[cn].moditems.each_pair{|moditem_id,drb_list_model|
|
192
|
+
iter=tree_store.append(cur_iter)
|
193
|
+
iter[0]=1
|
194
|
+
iter[3]=moditem_id
|
195
|
+
iter[4]=drb_list_model.moditem["display"]
|
196
|
+
}
|
197
|
+
rescue =>err
|
198
|
+
retry if Gtk::warn("Reload server thread #{cn} failed",err,ERROR,true)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
else
|
202
|
+
Gtk::warn("select a server thread to reload")
|
203
|
+
end
|
204
|
+
}
|
205
|
+
buttons.append_space
|
206
|
+
buttons.append(Gtk::Stock::REFRESH,"reload the selected list"){
|
207
|
+
if view.cursor[0] and cur_iter=tree_store.get_iter(view.cursor[0]) and cur_iter[0]!=0
|
208
|
+
cn=cur_iter.parent[1]
|
209
|
+
if Gtk::ask("reload item #{cur_iter[3]} on server thread #{cn}?")
|
210
|
+
begin
|
211
|
+
@manqod_server.dbs[cn].reload_moditem(cur_iter[3])
|
212
|
+
rescue =>err
|
213
|
+
retry if Gtk::warn("Reload list #{cn} failed",err,ERROR,true)
|
214
|
+
end
|
215
|
+
end
|
216
|
+
else
|
217
|
+
Gtk::warn("select an item to reload")
|
218
|
+
end
|
219
|
+
}
|
220
|
+
buttons.append(Gtk::Stock::JUMP_TO,"download selected list"){
|
221
|
+
if view.cursor[0] and cur_iter=tree_store.get_iter(view.cursor[0]) and cur_iter[0]!=0
|
222
|
+
cn=cur_iter.parent[1]
|
223
|
+
if Gtk::ask("download item #{cur_iter[3]} on server thread #{cn}?")
|
224
|
+
begin
|
225
|
+
list=@manqod_server.dbs[cn].moditem(cur_iter[3]).filtered_fetch2
|
226
|
+
print "downloaded #{list.size} rows\n"
|
227
|
+
rescue =>err
|
228
|
+
retry if Gtk::warn("Download test of #{cn} failed",err,ERROR,true)
|
229
|
+
end
|
230
|
+
end
|
231
|
+
else
|
232
|
+
Gtk::warn("select an item to download")
|
233
|
+
end
|
234
|
+
}
|
235
|
+
buttons.append_space
|
236
|
+
buttons.append(Gtk::Stock::STOP,"Stop manqod server"){
|
237
|
+
if Gtk::ask("Are you sure you want to stop the manqod server and all it's server threads?")
|
238
|
+
begin
|
239
|
+
@manqod_server.stop
|
240
|
+
rescue =>err
|
241
|
+
retry if Gtk::warn("Stop server failed",err,ERROR,true)
|
242
|
+
end
|
243
|
+
Gtk.main_quit if Gtk::ask("Nothing to do here anymore,\nDo you wan to Quit?")
|
244
|
+
end
|
245
|
+
}
|
246
|
+
buttons.append(Gtk::Stock::ABOUT,"about the registered users"){
|
247
|
+
|
248
|
+
wu=Gtk::Window.new('Manqod Server Console')
|
249
|
+
wu.move(position[0]+size[0]+10,position[1])
|
250
|
+
wu.set_size_request(200,size[1])
|
251
|
+
|
252
|
+
tree_store=Gtk::ListStore.new(String,String)
|
253
|
+
view=Gtk::TreeView.new(tree_store)
|
254
|
+
renderer = Gtk::CellRendererText.new
|
255
|
+
view.append_column(Gtk::TreeViewColumn.new("Connection", renderer, :text => 0))
|
256
|
+
view.append_column(Gtk::TreeViewColumn.new("Nick", renderer, :text => 1))
|
257
|
+
wu.add(view)
|
258
|
+
wu.show_all
|
259
|
+
|
260
|
+
begin
|
261
|
+
@manqod_server.connected_clients.each_pair{|rpc,db|
|
262
|
+
iter=tree_store.append
|
263
|
+
iter[0]=db
|
264
|
+
begin
|
265
|
+
iter[1]=rpc.nick
|
266
|
+
rescue =>e
|
267
|
+
#connection failed
|
268
|
+
end
|
269
|
+
}
|
270
|
+
rescue =>err
|
271
|
+
retry if Gtk::warn("Fetching client list failed",err,ERROR,true)
|
272
|
+
end
|
273
|
+
|
274
|
+
}
|
275
|
+
buttons.append(Gtk::Stock::QUIT,"leave manqod-server-console"){Gtk.main_quit if Gtk::ask("Really Quit?")}
|
276
|
+
buttons.set_toolbar_style(Gtk::Toolbar::ICONS)
|
277
|
+
add(holder)
|
278
|
+
show_all
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#this file is part of manqod-server-console
|
2
|
+
#manqod is distributed under the CDDL licence
|
3
|
+
#the author of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)
|
4
|
+
|
5
|
+
class ServerSelector < Gtk::Window
|
6
|
+
def initialize
|
7
|
+
super()
|
8
|
+
servers={ "localhost" =>{ :uri => "druby://127.0.0.1:5549", :bind => "druby://:0"}}
|
9
|
+
begin
|
10
|
+
path=File::expand_path(File.join(File.join(File::dirname(__FILE__),".."),"etc"))
|
11
|
+
conf=""
|
12
|
+
conf=File.new(File::expand_path(File.join(path,"server.conf"))).read
|
13
|
+
servers=eval(conf)
|
14
|
+
rescue => err
|
15
|
+
Gtk.warn("no server.conf","#{err}\n\nusing default:\n#{servers.inspect}\n")
|
16
|
+
end
|
17
|
+
add(Gtk::HBox.new.
|
18
|
+
pack_start(Gtk::Label.new("Select server")).
|
19
|
+
pack_start(server_combo=Gtk::ComboBox.new(model=Gtk::ListStore.new(String,String,String)).
|
20
|
+
pack_start(renderer=Gtk::CellRendererText.new,true).add_attribute(renderer,:text,0)
|
21
|
+
).
|
22
|
+
pack_start(ok=Gtk::Button.new(Gtk::Stock::CONNECT)).
|
23
|
+
pack_start(quit=Gtk::Button.new(Gtk::Stock::QUIT))
|
24
|
+
)
|
25
|
+
quit.signal_connect("clicked"){|me|
|
26
|
+
Gtk.main_quit if Gtk::ask("Are you sure, you want to quit?")
|
27
|
+
}
|
28
|
+
ok.signal_connect("clicked"){|me|
|
29
|
+
if i=server_combo.active_iter
|
30
|
+
ServerConsole.new(i[0],i[1],i[2])
|
31
|
+
hide
|
32
|
+
end
|
33
|
+
}
|
34
|
+
servers.each_pair{|conn,addr|
|
35
|
+
i=model.append
|
36
|
+
i[0]=conn
|
37
|
+
i[1]=addr[:uri]
|
38
|
+
i[2]=addr[:bind]
|
39
|
+
}
|
40
|
+
show_all
|
41
|
+
end
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: manqod-server-console
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 29
|
8
|
+
- 0
|
9
|
+
version: 1.29.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Dobai-Pataky Balint
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-02-20 00:00:00 +02:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: gtk2
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
33
|
+
description: Manqod is a desktop application for small companies to organize their data on an interface customised for them by themselves
|
34
|
+
email: dpblnt@gmail.com
|
35
|
+
executables:
|
36
|
+
- manqod-server-console
|
37
|
+
extensions: []
|
38
|
+
|
39
|
+
extra_rdoc_files: []
|
40
|
+
|
41
|
+
files:
|
42
|
+
- bin/manqod-server-console
|
43
|
+
- doc/README
|
44
|
+
- doc/server.conf.example
|
45
|
+
- lib/ServerConsole.rb
|
46
|
+
- lib/ConnectionProperties.rb
|
47
|
+
- lib/Gtk.rb
|
48
|
+
- lib/ServerSelector.rb
|
49
|
+
has_rdoc: true
|
50
|
+
homepage: http://manqod.sourceforge.net/
|
51
|
+
licenses:
|
52
|
+
- CDDL
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
segments:
|
64
|
+
- 1
|
65
|
+
- 8
|
66
|
+
- 5
|
67
|
+
version: 1.8.5
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
76
|
+
requirements: []
|
77
|
+
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 1.3.7
|
80
|
+
signing_key:
|
81
|
+
specification_version: 3
|
82
|
+
summary: Manqod is a desktop application for small companies to organize their data on an interface customised for them by themselves. This is the server console.
|
83
|
+
test_files: []
|
84
|
+
|