Work on native gui design and install documentation

This commit is contained in:
2026-07-16 13:54:03 +02:00
parent a183a4725f
commit 3a8233e930
5 changed files with 2106 additions and 58 deletions
+12
View File
@@ -66,6 +66,18 @@ Customize path and access rights to your needs
chown -R www-data /var/local/yms chown -R www-data /var/local/yms
chmod -R 750 /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. Install webgui
5.1 Upload webgui files 5.1 Upload webgui files
+11 -2
View File
@@ -8,6 +8,7 @@ class Database():
self.conn = None self.conn = None
self.cur = None self.cur = None
self.dcur = None self.dcur = None
self.error = None
def connect(self, dbuser, dbpass): def connect(self, dbuser, dbpass):
if self.conn: if self.conn:
@@ -17,7 +18,7 @@ class Database():
self.conn = MySQLdb.connect(host=self.hostname, db=self.schema, self.conn = MySQLdb.connect(host=self.hostname, db=self.schema,
user=dbuser, passwd=dbpass, charset='utf8') user=dbuser, passwd=dbpass, charset='utf8')
except MySQLdb.Error as e: except MySQLdb.Error as e:
print(e) self.error = e
return False return False
self.cur = self.conn.cursor() self.cur = self.conn.cursor()
self.dcur = self.conn.cursor(MySQLdb.cursors.DictCursor) self.dcur = self.conn.cursor(MySQLdb.cursors.DictCursor)
@@ -32,7 +33,7 @@ class Database():
self.conn = MySQLdb.connect(host='localhost', db=self.schema, self.conn = MySQLdb.connect(host='localhost', db=self.schema,
unix_socket='/run/mysqld/mysqld.sock', charset='utf8') unix_socket='/run/mysqld/mysqld.sock', charset='utf8')
except MySQLdb.Error as e: except MySQLdb.Error as e:
print(e) self.error = e
return False return False
self.cur = self.conn.cursor() self.cur = self.conn.cursor()
self.dcur = self.conn.cursor(MySQLdb.cursors.DictCursor) self.dcur = self.conn.cursor(MySQLdb.cursors.DictCursor)
@@ -45,3 +46,11 @@ class Database():
def is_connected(self): def is_connected(self):
return self.conn.open 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)
+2 -1
View File
@@ -17,7 +17,8 @@ def init_named_controls(window, builder):
'tbl': 'table', 'tbl': 'table',
'mnu': 'menu', 'mnu': 'menu',
'img': 'image', 'img': 'image',
'drw': 'area' 'drw': 'area',
'stk': 'stack'
} }
for ctrl in ctrltype.values(): for ctrl in ctrltype.values():
setattr(window, ctrl, {}) setattr(window, ctrl, {})
+2044 -46
View File
File diff suppressed because it is too large Load Diff
+37 -9
View File
@@ -2,6 +2,9 @@
""" """
YMS native GUI.
Runs as user SYSTEM with id=0
Configuration file located at ~/.config/ymsgui.conf: Configuration file located at ~/.config/ymsgui.conf:
[DB] [DB]
host = localhost host = localhost
@@ -31,7 +34,8 @@ cfg = {
'cfgfile': '~/.config/ymsgui.conf', 'cfgfile': '~/.config/ymsgui.conf',
'host': 'localhost', 'host': 'localhost',
'db': 'yms', 'db': 'yms',
'user': 'yms' 'user': 'yms',
'docpath': '/var/local/yms'
} }
class Frontend(): class Frontend():
@@ -73,13 +77,27 @@ class Frontend():
Gtk.main() Gtk.main()
def on_but_info_clicked(self, widget): def on_but_info_clicked(self, widget):
# Userlist # Userlist
sql = ("SELECT userid, login, displayname FROM user ORDER BY login") sql = ("SELECT userid, login, displayname FROM user ORDER BY login")
db.cur.execute(sql) db.cur.execute(sql)
for row in db.cur.fetchall(): for row in db.cur.fetchall():
print(row) 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): def on_destroy(self, widget, data=None):
Gtk.main_quit() Gtk.main_quit()
@@ -101,12 +119,14 @@ def create_config(cfgfile):
# create inital config file # create inital config file
with open(cfgfile, 'w') as fh: with open(cfgfile, 'w') as fh:
fh.write('[DB]\n') fh.write('[DB]\n')
fh.write('host = localhost\n') fh.write('host = {}\n'.format(cfg['host']))
fh.write('db = yms\n') fh.write('db = {}\n'.format(cfg['db']))
fh.write('user = yms\n') fh.write('user = {}\n'.format(cfg['user']))
fh.write('pass = geheim\n\n') fh.write('pass = changeme!\n\n')
fh.write('[documents]\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__": if __name__ == "__main__":
locale.setlocale(locale.LC_ALL, '') locale.setlocale(locale.LC_ALL, '')
@@ -117,7 +137,11 @@ if __name__ == "__main__":
cfgfile = os.path.expanduser(cfg['cfgfile']) cfgfile = os.path.expanduser(cfg['cfgfile'])
if not config.read(cfgfile): if not config.read(cfgfile):
create_config(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: else:
cfg['host'] = config.get('DB', 'host') cfg['host'] = config.get('DB', 'host')
cfg['db'] = config.get('DB', 'db') cfg['db'] = config.get('DB', 'db')
@@ -129,6 +153,10 @@ if __name__ == "__main__":
app.run() app.run()
db.disconnect() db.disconnect()
else: 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 # Another fine product of the sirius cybernetics corporation