From f80e8b44762491dbc906dd99a93218ece7cc7a8f Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Thu, 26 May 2022 10:00:19 +0200 Subject: [PATCH] Beta --- forms/admin/access-log/ui.xml | 14 ++++---- forms/ecomerce/catalog/catalog.js | 36 +++++++++++---------- js/hedera/app.js | 54 +++++++++++++++++-------------- js/hedera/gui.js | 5 ++- js/hedera/gui.scss | 22 +++++++------ js/htk/style/components.scss | 1 + js/vn/json-connection.js | 7 ++-- 7 files changed, 75 insertions(+), 64 deletions(-) diff --git a/forms/admin/access-log/ui.xml b/forms/admin/access-log/ui.xml index eb3b8661..732def39 100644 --- a/forms/admin/access-log/ui.xml +++ b/forms/admin/access-log/ui.xml @@ -5,8 +5,9 @@ - SELECT u.id, u.nickname, u.email, c.phone - FROM account.user u + SELECT u.id, u.name user, u.nickname, u.email, c.phone, r.name role + FROM account.user u + JOIN account.role r ON r.id = u.role LEFT JOIN vn.client c ON c.id = u.id WHERE u.id = #user @@ -24,10 +25,11 @@
-

#{{$.userForm.id}}

-

{{$.userForm.nickname}}

-

{{$.userForm.email}}

-

{{$.userForm.phone}}

+

+

# -

+

+

+

diff --git a/forms/ecomerce/catalog/catalog.js b/forms/ecomerce/catalog/catalog.js index 1249a32c..f9dfdaf7 100644 --- a/forms/ecomerce/catalog/catalog.js +++ b/forms/ecomerce/catalog/catalog.js @@ -295,10 +295,8 @@ Vn.Filter = new Class({ Extends: Htk.Field ,Tag: 'vn-filter' ,Child: 'model' - ,Properties: - { - model: - { + ,Properties: { + model: { type: Db.Model ,set: function(x) { x.batch = this._batch; @@ -309,8 +307,7 @@ Vn.Filter = new Class({ return this._model; } }, - placeholder: - { + placeholder: { type: String ,set: function(x) { this._select.placeholder = x; @@ -320,8 +317,7 @@ Vn.Filter = new Class({ return this._placeholder; } }, - filter: - { + filter: { type: Sql.Filter ,set: function(x) { this._filter = x; @@ -330,7 +326,7 @@ Vn.Filter = new Class({ ,get: function() { return this._filter; } - }, + } } ,_valueColumnIndex: 0 @@ -432,18 +428,24 @@ Vn.Filter = new Class({ if (!this._label) return; - var row = -1; + let row = -1; + const model = this._model; - if (this._model.ready) - row = this._model.searchByIndex(this._valueColumnIndex, this._value); + if (model) { + if (this._model.ready) + row = model.searchByIndex(this._valueColumnIndex, this._value); - if (row != -1) { - var label = this._model.getByIndex(row, this._showColumnIndex); - this._label.nodeValue = label; - this._emptyLabel = false; + if (row != -1) { + var label = model.getByIndex(row, this._showColumnIndex); + this._label.nodeValue = label; + this._emptyLabel = false; + } else { + this._emptyLabel = true; + this._label.nodeValue = _('Loading...'); + } } else { this._emptyLabel = true; - this._label.nodeValue = _('Loading...'); + this._label.nodeValue = ''; } } }); diff --git a/js/hedera/app.js b/js/hedera/app.js index a27fa926..faded048 100644 --- a/js/hedera/app.js +++ b/js/hedera/app.js @@ -62,38 +62,42 @@ module.exports = new Class({ } ,_onConnError: function(conn, error) { - if (error instanceof Vn.JsonException) - switch (error.exception) { - case 'BadLogin': - Htk.Toast.showError(_('Invalid login')); - this._logout(); - break; - case 'Forbidden': - Htk.Toast.showError(_('You don\'t have enough privileges')); - break; - case 'UserDisabled': - Htk.Toast.showError(_('User disabled')); - this._logout(); - break; - case 'SessionExpired': - Htk.Toast.showError(_('Session expired')); - this._logout(); - break; - case 'OutdatedVersion': - this._newVersion(error); - break; - default: + if (error instanceof Vn.JsonException) { + if (error.message) Htk.Toast.showError(error.message); - } else if (error.statusCode) - switch (error.statusCode) { + else + switch (error.exception) { + case 'BadLogin': + Htk.Toast.showError(_('Invalid login')); + this._logout(); + break; + case 'Forbidden': + Htk.Toast.showError(_('You don\'t have enough privileges')); + break; + case 'UserDisabled': + Htk.Toast.showError(_('User disabled')); + this._logout(); + break; + case 'SessionExpired': + Htk.Toast.showError(_('Session expired')); + this._logout(); + break; + case 'OutdatedVersion': + this._newVersion(error); + break; + default: + Htk.Toast.showError(error.message); + } + } else if (error.statusCode) { + switch (error.statusCode) { case 401: Htk.Toast.showError(_('Invalid login')); this._logout(); break; default: Htk.Toast.showError(error.message); - } - else { + } + } else { console.error(error); this._notifyError(error); } diff --git a/js/hedera/gui.js b/js/hedera/gui.js index 87d5c6c0..5c248edc 100644 --- a/js/hedera/gui.js +++ b/js/hedera/gui.js @@ -477,9 +477,8 @@ module.exports = new Class({ this._onUserSupplant.bind(this, callback, user)); } - ,_onUserSupplant: function(callback, user, supplantOk) { - if (!supplantOk) - return; + ,_onUserSupplant: function(callback, user, supplantOk, err) { + if (err) throw err; sessionStorage.setItem('supplantUser', user); this.loadMenu(); diff --git a/js/hedera/gui.scss b/js/hedera/gui.scss index e529ebbf..fe811fa2 100644 --- a/js/hedera/gui.scss +++ b/js/hedera/gui.scss @@ -1,6 +1,9 @@ @import "../htk/style/classes"; +$side-panel-width: 250px; +$navbar-height: 64px; + .vn-gui { height: inherit; @@ -16,12 +19,12 @@ .navbar { position: fixed; background-color: #1A1A1A; - left: 250px; + left: $side-panel-width; top: 0; right: 0; z-index: 1; overflow: hidden; - height: 64px; + height: $navbar-height; color: white; display: flex; align-items: center; @@ -48,17 +51,18 @@ align-items: center; gap: 15px; overflow: hidden; + padding-left: 15px; & > .title { - white-space: nowrap; overflow: hidden; - text-overflow: ellipsis; h1 { font-weight: normal; font-size: 1.4em; - padding-left: 8px; margin: 0; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; } } } @@ -122,7 +126,7 @@ top: 0; background-color: white; z-index: 20; - width: 250px; + width: $side-panel-width; } .menu-overflow { position: absolute; @@ -135,7 +139,7 @@ .menu-header { background-color: #1A1A1A; color: white; - height: 64px; + height: $navbar-height; display: flex; } .logo { @@ -269,8 +273,8 @@ /* Body */ & > .body { - margin-left: 250px; - padding-top: 4.4em; + margin-left: $side-panel-width; + padding-top: $navbar-height; height: inherit; box-sizing: border-box; height: inherit; diff --git a/js/htk/style/components.scss b/js/htk/style/components.scss index b79d6073..93580c6f 100644 --- a/js/htk/style/components.scss +++ b/js/htk/style/components.scss @@ -230,6 +230,7 @@ td.cell-image .htk-image { margin: .1em 0; text-overflow: ellipsis; white-space: nowrap; + overflow: hidden; } } & > .actions { diff --git a/js/vn/json-connection.js b/js/vn/json-connection.js index e5ec6d22..9e012eb8 100644 --- a/js/vn/json-connection.js +++ b/js/vn/json-connection.js @@ -116,12 +116,12 @@ module.exports = new Class({ this._onUserSupplant.bind(this, callback)); } - ,_onUserSupplant: function(callback, json) { + ,_onUserSupplant: function(callback, json, err) { if (json) this.token = json; if (callback) - callback(json != null); + callback(err == null, err); } /** @@ -302,7 +302,6 @@ module.exports = new Class({ data = null; error = e; } - if (callback) try { callback(data, error); @@ -314,7 +313,7 @@ module.exports = new Class({ if (error) { if (error.exception == 'SessionExpired') this.clearToken(); - + this.signalEmit('error', error); } }