diff --git a/INSTALL b/INSTALL
index 3dd0fa0..be117b4 100644
--- a/INSTALL
+++ b/INSTALL
@@ -66,6 +66,18 @@ Customize path and access rights to your needs
chown -R www-data /var/local/yms
chmod -R 750 /var/local/yms
+To grant access for the local gui the directory has to be writeable by a special
+group (here as example 'yms'). The user which runs the local gui (here
+'guiuser') has also to be a member of that group as well as the webserver user
+''www-data'.
+
+ groupadd yms
+ usermod -aG yms www-data
+ usermod -aG yms guiuser
+ chgrp yms /var/local/yms
+ chgrp yms /var/local/yms/thumb
+ chmod -R 770 /var/local/yms
+
5. Install webgui
5.1 Upload webgui files
diff --git a/yms/database.py b/yms/database.py
index 7f6eb02..6454ddb 100644
--- a/yms/database.py
+++ b/yms/database.py
@@ -8,6 +8,7 @@ class Database():
self.conn = None
self.cur = None
self.dcur = None
+ self.error = None
def connect(self, dbuser, dbpass):
if self.conn:
@@ -17,7 +18,7 @@ class Database():
self.conn = MySQLdb.connect(host=self.hostname, db=self.schema,
user=dbuser, passwd=dbpass, charset='utf8')
except MySQLdb.Error as e:
- print(e)
+ self.error = e
return False
self.cur = self.conn.cursor()
self.dcur = self.conn.cursor(MySQLdb.cursors.DictCursor)
@@ -32,7 +33,7 @@ class Database():
self.conn = MySQLdb.connect(host='localhost', db=self.schema,
unix_socket='/run/mysqld/mysqld.sock', charset='utf8')
except MySQLdb.Error as e:
- print(e)
+ self.error = e
return False
self.cur = self.conn.cursor()
self.dcur = self.conn.cursor(MySQLdb.cursors.DictCursor)
@@ -45,3 +46,11 @@ class Database():
def is_connected(self):
return self.conn.open
+
+ def last_error(self):
+ if not self.error:
+ return(0, '')
+ code = self.error.args[0]
+ text = self.error.args[1]
+ self.error = None
+ return(code, text)
diff --git a/yms/gtkutils.py b/yms/gtkutils.py
index 120e2a3..87d9d80 100644
--- a/yms/gtkutils.py
+++ b/yms/gtkutils.py
@@ -17,7 +17,8 @@ def init_named_controls(window, builder):
'tbl': 'table',
'mnu': 'menu',
'img': 'image',
- 'drw': 'area'
+ 'drw': 'area',
+ 'stk': 'stack'
}
for ctrl in ctrltype.values():
setattr(window, ctrl, {})
diff --git a/yms/ui/main.ui b/yms/ui/main.ui
index 35909da..093b414 100644
--- a/yms/ui/main.ui
+++ b/yms/ui/main.ui
@@ -5,6 +5,9 @@
@@ -118,13 +158,56 @@
False
vertical
-
+
+ True
+ True
+ in
+
+
+ True
+ True
+
+
+
+
+
+
+
+ True
+ True
+ 0
+
-
-
-
-
+
+ True
+ False
+ end
+
+
+
+
+
+
+
+
+ Edit
+ True
+ True
+ True
+
+
+ True
+ True
+ 2
+
+
+
+
+ False
+ True
+ 2
+
@@ -143,43 +226,321 @@
-
+
True
- False
- vertical
+ True
-
+
True
- True
- in
+ False
+ vertical
-
+
True
- True
+ False
+
+ False
+ True
+ 0
+
+
+
+
+ True
+ False
+ vertical
+
+
+ True
+ True
+ 1
+
+
+
+
+ True
+ False
+ end
+
+
+ New
+ True
+ True
+ True
+
+
+ True
+ True
+ 0
+
+
+
+
+ Delete
+ True
+ True
+ True
+
+
+ True
+ True
+ 2
+
+
+
+
+ False
+ True
+ 3
+
- False
- True
- 0
+ False
+ True
-
-
-
-
- Ok
+
True
- True
- True
-
+ False
+ vertical
+
+
+
+ True
+ False
+
+
+ True
+ False
+ Login
+
+
+ 0
+ 0
+
+
+
+
+ True
+ False
+ Displayname
+
+
+ 0
+ 1
+
+
+
+
+ True
+ True
+
+
+ 1
+ 0
+
+
+
+
+ True
+ True
+
+
+ 1
+ 1
+
+
+
+
+ True
+ False
+ Role
+
+
+ 0
+ 3
+
+
+
+
+ True
+ False
+ Language
+
+
+ 0
+ 4
+
+
+
+
+ True
+ False
+
+
+ 1
+ 3
+
+
+
+
+ True
+ False
+
+
+ 1
+ 4
+
+
+
+
+ True
+ False
+ Password
+
+
+ 0
+ 6
+
+
+
+
+ True
+ True
+
+
+ 1
+ 6
+
+
+
+
+ Create
+ True
+ True
+ True
+
+
+ 2
+ 6
+
+
+
+
+ Locked
+ True
+ True
+ False
+ True
+
+
+ 1
+ 8
+
+
+
+
+ Deleted
+ True
+ True
+ False
+ True
+
+
+ 1
+ 9
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ True
+ True
+ 0
+
+
+
+
+ True
+ False
+ end
+
+
+ Save
+ True
+ True
+ True
+
+
+ True
+ True
+ 0
+
+
+
+
+ False
+ True
+ 1
+
+
- False
- True
- 2
+ True
+ True
@@ -211,11 +572,678 @@
-
+
True
False
- Equipment
-Here be dragons
+
+
+ True
+ False
+ vertical
+
+
+ True
+ True
+
+
+
+ True
+ False
+
+
+ True
+ False
+ vertical
+ start
+
+
+ Clear
+ True
+ True
+ True
+
+
+ True
+ True
+ 0
+
+
+
+
+ Apply
+ True
+ True
+ True
+
+
+ True
+ True
+ 1
+
+
+
+
+ 3
+ 0
+ 4
+
+
+
+
+ True
+ False
+ Category
+
+
+ 0
+ 0
+
+
+
+
+ True
+ False
+ Manufacturer
+
+
+ 0
+ 1
+
+
+
+
+ True
+ False
+ Supplier
+
+
+ 0
+ 2
+
+
+
+
+ True
+ False
+ Text
+
+
+ 0
+ 3
+
+
+
+
+ True
+ False
+ Flags
+
+
+ 0
+ 4
+
+
+
+
+ True
+ True
+
+
+ 1
+ 3
+
+
+
+
+ True
+ False
+
+
+ 1
+ 0
+
+
+
+
+ True
+ False
+
+
+ 1
+ 1
+
+
+
+
+ True
+ False
+
+
+ 1
+ 2
+
+
+
+
+ ordered
+ True
+ True
+ False
+ True
+
+
+ 1
+ 4
+
+
+
+
+ removed
+ True
+ True
+ False
+ True
+
+
+ 2
+ 4
+
+
+
+
+ deleted
+ True
+ True
+ False
+ True
+
+
+ 3
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ True
+ False
+ Filter Equipment
+
+
+
+
+ False
+ True
+ 0
+
+
+
+
+ True
+ True
+ in
+
+
+ True
+ True
+
+
+
+
+ True
+ True
+ 1
+
+
+
+
+ True
+ False
+ end
+
+
+ New
+ True
+ True
+ True
+
+
+ True
+ True
+ 0
+
+
+
+
+ Edit
+ True
+ True
+ True
+
+
+
+ True
+ True
+ 1
+
+
+
+
+ Details
+ True
+ True
+ True
+
+
+
+ True
+ True
+ 2
+
+
+
+
+ False
+ True
+ 2
+
+
+
+
+ page0
+ page0
+
+
+
+
+ True
+ False
+ vertical
+
+
+ True
+ False
+ Equipment details
+
+
+ False
+ True
+ 0
+
+
+
+
+
+
+
+ True
+ False
+ end
+
+
+ Delete
+ True
+ True
+ True
+
+
+ True
+ True
+ 0
+ True
+
+
+
+
+ Edit
+ True
+ True
+ True
+
+
+
+ True
+ True
+ 1
+
+
+
+
+ Close
+ True
+ True
+ True
+
+
+
+ True
+ True
+ 2
+
+
+
+
+ False
+ True
+ 2
+
+
+
+
+ page2
+ page2
+ 1
+
+
+
+
+ True
+ False
+ vertical
+
+
+
+ True
+ False
+
+
+ True
+ False
+ Name
+
+
+ 0
+ 0
+
+
+
+
+ True
+ False
+ Short name
+
+
+ 0
+ 1
+
+
+
+
+ True
+ True
+
+
+ 1
+ 0
+
+
+
+
+ True
+ True
+
+
+ 1
+ 1
+
+
+
+
+ True
+ False
+ Manufacturer
+
+
+ 0
+ 2
+
+
+
+
+ True
+ False
+ Model
+
+
+ 0
+ 3
+
+
+
+
+ True
+ False
+ Serial no.
+
+
+ 0
+ 4
+
+
+
+
+ True
+ False
+ Weight, kg
+
+
+ 0
+ 5
+
+
+
+
+ True
+ False
+ Price, €
+
+
+ 0
+ 6
+
+
+
+
+ True
+ False
+ Date puchase
+
+
+ 0
+ 7
+
+
+
+
+ True
+ False
+
+
+ 1
+ 2
+
+
+
+
+ True
+ True
+
+
+ 1
+ 3
+
+
+
+
+ True
+ True
+
+
+ 1
+ 4
+
+
+
+
+ True
+ True
+
+
+ 1
+ 5
+
+
+
+
+ True
+ True
+
+
+ 1
+ 6
+
+
+
+
+ True
+ True
+
+
+ 1
+ 7
+
+
+
+
+ True
+ False
+ Supplier
+
+
+ 0
+ 8
+
+
+
+
+ True
+ False
+ Category
+
+
+ 0
+ 9
+
+
+
+
+ True
+ False
+ Remarks
+
+
+ 0
+ 10
+
+
+
+
+ True
+ False
+
+
+ 1
+ 8
+
+
+
+
+ True
+ False
+
+
+ 1
+ 9
+
+
+
+
+ True
+ True
+
+
+ 1
+ 10
+
+
+
+
+ False
+ True
+ 0
+
+
+
+
+ True
+ False
+ end
+
+
+ Save
+ True
+ True
+ True
+
+
+
+ True
+ True
+ 0
+
+
+
+
+ Cancel
+ True
+ True
+ True
+
+
+
+ True
+ True
+ 1
+
+
+
+
+ False
+ True
+ end
+ 1
+
+
+
+
+ page1
+ page1
+ 2
+
+
1
@@ -233,10 +1261,210 @@ Here be dragons
-
+
True
False
- label
+ vertical
+
+
+ True
+ True
+
+
+
+ True
+ False
+
+
+ True
+ False
+ vertical
+ start
+
+
+ Clear
+ True
+ True
+ True
+
+
+ True
+ True
+ 0
+
+
+
+
+ Apply
+ True
+ True
+ True
+
+
+ True
+ True
+ 1
+
+
+
+
+ 2
+ 0
+ 3
+
+
+
+
+ True
+ False
+ Storage
+
+
+ 0
+ 0
+
+
+
+
+ True
+ False
+ Condition
+
+
+ 0
+ 1
+
+
+
+
+ True
+ False
+ Text
+
+
+ 0
+ 2
+
+
+
+
+ True
+ False
+
+
+ 1
+ 0
+
+
+
+
+ True
+ False
+
+
+ 1
+ 1
+
+
+
+
+ True
+ True
+
+
+ 1
+ 2
+
+
+
+
+
+
+ True
+ False
+ Filter Inventory
+
+
+
+
+ False
+ True
+ 0
+
+
+
+
+ True
+ True
+ in
+
+
+ True
+ True
+
+
+
+
+
+
+
+ True
+ True
+ 1
+
+
+
+
+ True
+ False
+ 2
+ end
+
+
+ New
+ True
+ True
+ True
+
+
+ True
+ True
+ 0
+
+
+
+
+ Edit
+ True
+ True
+ True
+
+
+ True
+ True
+ 1
+
+
+
+
+ Details
+ True
+ True
+ True
+
+
+ True
+ True
+ 2
+
+
+
+
+ False
+ True
+ 2
+
+
2
@@ -259,13 +1487,189 @@ Here be dragons
False
vertical
-
+
+ True
+ True
+
+
+
+ True
+ False
+ 2
+ 2
+
+
+ True
+ False
+ Kategorie
+
+
+ 0
+ 0
+
+
+
+
+ True
+ False
+ True
+
+
+ 1
+ 0
+ 2
+
+
+
+
+ True
+ False
+ Text
+
+
+ 0
+ 1
+
+
+
+
+ True
+ True
+ True
+
+
+ 1
+ 1
+ 2
+
+
+
+
+ True
+ False
+ vertical
+ 2
+ start
+
+
+ Clear
+ True
+ True
+ True
+
+
+ True
+ True
+ 0
+
+
+
+
+ Apply
+ True
+ True
+ True
+
+
+ True
+ True
+ 1
+
+
+
+
+ 3
+ 0
+ 2
+
+
+
+
+
+
+ True
+ False
+ Filter Providions (here selection description)
+
+
+
+
+ False
+ True
+ 0
+
-
+
+ True
+ True
+ in
+
+
+ True
+ True
+
+
+
+
+
+
+
+ True
+ True
+ 1
+
-
+
+ True
+ False
+ end
+
+
+ New
+ True
+ True
+ True
+
+
+ True
+ True
+ 0
+
+
+
+
+ Edit
+ True
+ True
+ True
+
+
+ True
+ True
+ 1
+
+
+
+
+ Delete
+ True
+ True
+ True
+
+
+ True
+ True
+ 2
+
+
+
+
+ False
+ True
+ 2
+
@@ -289,13 +1693,182 @@ Here be dragons
False
vertical
-
+
+ True
+ True
+
+
+
+ True
+ False
+
+
+ True
+ False
+ vertical
+ start
+
+
+ Clear
+ True
+ True
+ True
+
+
+ True
+ True
+ 0
+
+
+
+
+ Apply
+ True
+ True
+ True
+
+
+ True
+ True
+ 1
+
+
+
+
+ 2
+ 0
+ 2
+
+
+
+
+ True
+ False
+ Equipment
+
+
+ 0
+ 0
+
+
+
+
+ True
+ False
+ Text
+
+
+ 0
+ 1
+
+
+
+
+ True
+ False
+
+
+ 1
+ 0
+
+
+
+
+ True
+ True
+
+
+ 1
+ 1
+
+
+
+
+
+
+ True
+ False
+ Filter Maintenance
+
+
+
+
+ False
+ True
+ 0
+
-
+
+ True
+ True
+ in
+
+
+ True
+ True
+
+
+
+
+
+
+
+ True
+ True
+ 1
+
-
+
+ True
+ False
+ end
+
+
+ New
+ True
+ True
+ True
+
+
+ True
+ True
+ 0
+
+
+
+
+ Edit
+ True
+ True
+ True
+
+
+ True
+ True
+ 1
+
+
+
+
+ Delete
+ True
+ True
+ True
+
+
+ True
+ True
+ 2
+
+
+
+
+ False
+ True
+ 2
+
@@ -319,13 +1892,203 @@ Here be dragons
False
vertical
-
+
+ True
+ True
+
+
+
+ True
+ False
+
+
+ True
+ False
+ vertical
+ start
+
+
+ Clear
+ True
+ True
+ True
+
+
+ True
+ True
+ 0
+
+
+
+
+ Apply
+ True
+ True
+ True
+
+
+ True
+ True
+ 1
+
+
+
+
+ 2
+ 0
+ 3
+
+
+
+
+ True
+ False
+ Name
+
+
+ 0
+ 0
+
+
+
+
+ True
+ False
+ Status
+
+
+ 0
+ 1
+
+
+
+
+ True
+ False
+ Remarks
+
+
+ 0
+ 2
+
+
+
+
+ True
+ True
+
+
+ 1
+ 0
+
+
+
+
+ True
+ True
+
+
+ 1
+ 2
+
+
+
+
+ True
+ False
+
+
+ 1
+ 1
+
+
+
+
+
+
+ True
+ False
+ Filter Projects
+
+
+
+
+ False
+ True
+ 0
+
-
+
+ True
+ True
+ in
+
+
+ True
+ True
+
+
+
+
+
+
+
+ True
+ True
+ 1
+
-
+
+ True
+ False
+ end
+
+
+ New
+ True
+ True
+ True
+
+
+ True
+ True
+ 0
+
+
+
+
+ Edit
+ True
+ True
+ True
+
+
+ True
+ True
+ 1
+
+
+
+
+ Delete
+ True
+ True
+ True
+
+
+ True
+ True
+ 2
+
+
+
+
+ False
+ True
+ 2
+
@@ -349,13 +2112,203 @@ Here be dragons
False
vertical
-
+
+ True
+ True
+
+
+
+ True
+ False
+
+
+ True
+ False
+ vertical
+ start
+
+
+ Clear
+ True
+ True
+ True
+
+
+ True
+ True
+ 0
+
+
+
+
+ Apply
+ True
+ True
+ True
+
+
+ True
+ True
+ 1
+
+
+
+
+ 2
+ 0
+ 3
+
+
+
+
+ True
+ False
+ Type
+
+
+ 0
+ 0
+
+
+
+
+ True
+ False
+ Reference
+
+
+ 0
+ 1
+
+
+
+
+ True
+ False
+ Text
+
+
+ 0
+ 2
+
+
+
+
+ True
+ False
+
+
+ 1
+ 0
+
+
+
+
+ True
+ False
+
+
+ 1
+ 1
+
+
+
+
+ True
+ True
+
+
+ 1
+ 2
+
+
+
+
+
+
+ True
+ False
+ Filter Documents
+
+
+
+
+ False
+ True
+ 0
+
-
+
+ True
+ True
+ in
+
+
+ True
+ True
+
+
+
+
+
+
+
+ True
+ True
+ 1
+
-
+
+ True
+ False
+ end
+
+
+ New
+ True
+ True
+ True
+
+
+ True
+ True
+ 0
+
+
+
+
+ Edit
+ True
+ True
+ True
+
+
+ True
+ True
+ 1
+
+
+
+
+ Delete
+ True
+ True
+ True
+
+
+ True
+ True
+ 2
+
+
+
+
+ False
+ True
+ 2
+
@@ -373,6 +2326,51 @@ Here be dragons
False
+
+
+ True
+ False
+ vertical
+
+
+ True
+ False
+ Status
+
+
+ False
+ True
+ 0
+
+
+
+
+ True
+ False
+ Here be dragons!
+
+
+ True
+ True
+ 1
+
+
+
+
+ 7
+
+
+
+
+ True
+ False
+ Status
+
+
+ 7
+ False
+
+
diff --git a/ymsgui.py b/ymsgui.py
index 2f66300..4578b3a 100755
--- a/ymsgui.py
+++ b/ymsgui.py
@@ -2,6 +2,9 @@
"""
+YMS native GUI.
+Runs as user SYSTEM with id=0
+
Configuration file located at ~/.config/ymsgui.conf:
[DB]
host = localhost
@@ -31,7 +34,8 @@ cfg = {
'cfgfile': '~/.config/ymsgui.conf',
'host': 'localhost',
'db': 'yms',
- 'user': 'yms'
+ 'user': 'yms',
+ 'docpath': '/var/local/yms'
}
class Frontend():
@@ -73,13 +77,27 @@ class Frontend():
Gtk.main()
def on_but_info_clicked(self, widget):
-
# Userlist
sql = ("SELECT userid, login, displayname FROM user ORDER BY login")
db.cur.execute(sql)
for row in db.cur.fetchall():
print(row)
+ def on_but_equip_detail_clicked(self, widget):
+ self.stack['equipment'].set_visible_child(self.box['equip_detail'])
+
+ def on_but_equip_edit_clicked(self, widget):
+ self.stack['equipment'].set_visible_child(self.box['equip_edit'])
+
+ def on_but_equip_save_clicked(self, widget):
+ pass
+
+ def on_but_equip_cancel_clicked(self, widget):
+ self.stack['equipment'].set_visible_child(self.box['equipment'])
+
+ def on_but_equip_cancel_clicked(self, widget):
+ self.stack['equipment'].set_visible_child(self.box['equipment'])
+
def on_destroy(self, widget, data=None):
Gtk.main_quit()
@@ -101,12 +119,14 @@ def create_config(cfgfile):
# create inital config file
with open(cfgfile, 'w') as fh:
fh.write('[DB]\n')
- fh.write('host = localhost\n')
- fh.write('db = yms\n')
- fh.write('user = yms\n')
- fh.write('pass = geheim\n\n')
+ fh.write('host = {}\n'.format(cfg['host']))
+ fh.write('db = {}\n'.format(cfg['db']))
+ fh.write('user = {}\n'.format(cfg['user']))
+ fh.write('pass = changeme!\n\n')
fh.write('[documents]\n')
- fh.write('basepath = /var/local/yms\n')
+ fh.write('basepath = {}\n'.format(cfg['docpath']))
+ # secure configuration
+ os.chmod(cfgfile, 0o600)
if __name__ == "__main__":
locale.setlocale(locale.LC_ALL, '')
@@ -117,7 +137,11 @@ if __name__ == "__main__":
cfgfile = os.path.expanduser(cfg['cfgfile'])
if not config.read(cfgfile):
create_config(cfgfile)
- messagebox(_("Configuration file not found"), title="YMS")
+ messagebox(_("Configuration file '%s' not found.\n"
+ "Default configuration has been created.\n"
+ "Please edit that file according to your needs.\n\n"
+ "Then restart this program."
+ ) % cfgfile, title="YMS")
else:
cfg['host'] = config.get('DB', 'host')
cfg['db'] = config.get('DB', 'db')
@@ -129,6 +153,10 @@ if __name__ == "__main__":
app.run()
db.disconnect()
else:
- messagebox(_("Database connection cannot be established"), title="YMS")
+ errno, errtxt = db.last_error()
+ messagebox(_("Database connection cannot be established.\n\n"
+ "Server: %s\nDatabase: %s\n"
+ "Error: %s (%d)"
+ ) % (cfg['host'], cfg['db'], errtxt, errno), title="YMS")
# Another fine product of the sirius cybernetics corporation