diff --git a/yms/ui/base.ui b/yms/ui/base.ui index aaf6a95..54734be 100644 --- a/yms/ui/base.ui +++ b/yms/ui/base.ui @@ -5,6 +5,7 @@ True False + 8 True @@ -309,7 +310,7 @@ - + True False @@ -726,7 +727,7 @@ True in - + True True diff --git a/yms/ui/documents.ui b/yms/ui/documents.ui index 8284504..ace064b 100644 --- a/yms/ui/documents.ui +++ b/yms/ui/documents.ui @@ -5,6 +5,7 @@ True False + 8 True diff --git a/yms/ui/equipment.ui b/yms/ui/equipment.ui index 7f9e439..7d7fc3c 100644 --- a/yms/ui/equipment.ui +++ b/yms/ui/equipment.ui @@ -5,6 +5,7 @@ True False + 8 True diff --git a/yms/ui/inventory.ui b/yms/ui/inventory.ui index 0224620..2b7db1c 100644 --- a/yms/ui/inventory.ui +++ b/yms/ui/inventory.ui @@ -5,6 +5,7 @@ True False + 8 True diff --git a/yms/ui/main.ui b/yms/ui/main.ui index 387ef22..9e77a61 100644 --- a/yms/ui/main.ui +++ b/yms/ui/main.ui @@ -8,6 +8,7 @@ center 800 600 + ../../icons/yms.svg diff --git a/yms/ui/maintenance.ui b/yms/ui/maintenance.ui index b1acf66..17ce13d 100644 --- a/yms/ui/maintenance.ui +++ b/yms/ui/maintenance.ui @@ -5,6 +5,7 @@ True False + 8 True diff --git a/yms/ui/projects.ui b/yms/ui/projects.ui index 737b85c..8bc2260 100644 --- a/yms/ui/projects.ui +++ b/yms/ui/projects.ui @@ -5,6 +5,7 @@ True False + 8 True diff --git a/yms/ui/provisions.ui b/yms/ui/provisions.ui index 0d98106..12fbcb5 100644 --- a/yms/ui/provisions.ui +++ b/yms/ui/provisions.ui @@ -5,6 +5,7 @@ True False + 8 True diff --git a/yms/ui/status.ui b/yms/ui/status.ui index ad0a0c6..0f256e2 100644 --- a/yms/ui/status.ui +++ b/yms/ui/status.ui @@ -5,6 +5,7 @@ True False + 8 vertical @@ -33,7 +34,7 @@ - + True True @@ -100,9 +101,60 @@ thread in "Segeln Forum" False + + + True + False + vertical + + + True + False + + + False + True + 0 + + + + + True + True + in + + + True + True + False + + + + + True + True + 1 + + + + + 2 + + + + + True + False + Config + + + 2 + False + + - False + True True 2 diff --git a/yms/view/base.py b/yms/view/base.py index 3353bcc..08e8a9d 100644 --- a/yms/view/base.py +++ b/yms/view/base.py @@ -48,25 +48,46 @@ class BaseView(View): # prepare lists self.lst_user = Gtk.ListStore(int, str) - self.db.cur.execute("SELECT userid, login FROM user WHERE userid > 0 ORDER BY login") + self.db.cur.execute("SELECT userid, login FROM user WHERE userid>0 ORDER BY login") for row in self.db.cur.fetchall(): - print(row) self.lst_user.append(row) treeview.add_column(self.tree['user'], 'ID', 0) treeview.add_column(self.tree['user'], 'Login', 1) self.tree['user'].set_model(self.lst_user) - # companies - """ - self.lst_companies = Gtk.ListStore(int, str, str, str) - self.db.cur.execute("SELECT compid, compname, comptype FROM company ORDER BY compname") + # list of dropdown lists + self.lst_lists = Gtk.ListStore(int, str, int) + # self.db.cur.execute("SELECT ddval, ddtext FROM dropdown WHERE ddid=0 AND ddval>0 ORDER BY ddval") + sql = ( + "SELECT dd.ddval, dd.ddtext, COUNT(n.ddval) AS records " + "FROM dropdown AS dd LEFT JOIN dropdown AS n ON dd.ddval=n.ddid " + "WHERE dd.ddid=0 " + "GROUP BY dd.ddval, dd.ddtext " + "ORDER BY dd.ddval" + ) + self.db.cur.execute(sql) for row in self.db.cur.fetchall(): - self.lst_user.append(row) + self.lst_lists.append(row) + treeview.add_column(self.tree['ddlists'], _('ID'), 0) + treeview.add_column(self.tree['ddlists'], _('List'), 1) + treeview.add_column(self.tree['ddlists'], _('Records'), 2) + self.tree['ddlists'].set_model(self.lst_lists) + + # company types + self.db.cur.execute("SELECT ddval, ddtext FROM dropdown WHERE ddid=2 ORDER BY ddval") + self.comptype = dict(self.db.cur.fetchall()) + combobox.load_from_dict(self.combo['flt_type'], {-1: _("─── all ───")} | self.comptype, -1) + + # companies + self.lst_companies = Gtk.ListStore(int, str, str, str) + self.db.cur.execute("SELECT compid, compname, comptype, remarks FROM company ORDER BY compname") + for row in self.db.cur.fetchall(): + self.lst_companies.append((row[0], row[1], self.comptype[row[2]], row[3])) treeview.add_column(self.tree['companies'], _('ID'), 0) treeview.add_column(self.tree['companies'], _('Name'), 1) treeview.add_column(self.tree['companies'], _('Type'), 2) + treeview.add_column(self.tree['companies'], _('Remarks'), 3) self.tree['companies'].set_model(self.lst_companies) - """ # combos roles = {'captain': 'Captain', 'helmsman': 'Helmsman', 'sailor': 'Sailor'} @@ -74,6 +95,17 @@ class BaseView(View): langs = {'de': 'Deutsch', 'en': 'English'} combobox.load_from_dict(self.combo['user_lang'], langs) + # shipyard + self.db.cur.execute("SELECT compid, compname FROM company WHERE comptype=3 ORDER BY compname") + shipyards = dict(self.db.cur.fetchall()) + combobox.load_from_dict(self.combo['shipyard'], shipyards) + + # default storage + self.lst_storage_dfl = Gtk.ListStore(int, str) + self.db.cur.execute("SELECT sid, sname FROM storage WHERE stype=0 ORDER BY sname") + storages = dict(self.db.cur.fetchall()) + combobox.load_from_dict(self.combo['storage'], storages) + # load shape of vessel if available if self.context.vessel.vid > 0: self.db.cur.execute("SELECT shapefile FROM vessel WHERE vid=%s", (self.context.vessel.vid, )) diff --git a/yms/view/status.py b/yms/view/status.py index e9041c8..108bcd7 100644 --- a/yms/view/status.py +++ b/yms/view/status.py @@ -4,6 +4,7 @@ import os import gi gi.require_version("Gtk", "3.0") from gi.repository import Gtk +import re from yms import gtkutils, combobox, treeview @@ -27,6 +28,17 @@ class StatusView: treeview.add_column(self.tree['tables'], '# Records', 1) self.tree['tables'].set_model(self.lst_tables) + # Load current config file + self.label['config'].set_label(context.cfg['cfgfile']) + cfgfile = os.path.expanduser(context.cfg['cfgfile']) + try: + with open(cfgfile, "r", encoding="utf-8") as f: + contents = f.read() + except OSError as e: + contents = f"Could not read file: {e}" + contents = re.sub(r'(^\s*pass\s*=\s*).*$', r'\1********', contents, flags=re.MULTILINE) + self.text ['config'].get_buffer().set_text(contents) + def get_table_counts(self): # Detect all tables in database sql= ("SELECT table_name "