partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit bd0959a35f2412422934809063563307b85b2043
parent 33dd66faf84be49fbe52633fdebbc48df2ad2c0a
Author: Felicitus <felicitus@felicitus.org>
Date:   Thu, 23 Jun 2011 13:07:27 +0200

Fixed login/logout stuff via the connection button

Diffstat:
Mfrontend/js/Components/ConnectionButton.js | 6+++---
Mfrontend/js/Components/Statusbar.js | 13+++++++++----
Mfrontend/js/Dialogs/Auth/LoginDialog.js | 14+++-----------
Mfrontend/js/PartKeepr.js | 43+++++++++++++++++++++++++++++++++++--------
4 files changed, 50 insertions(+), 26 deletions(-)

diff --git a/frontend/js/Components/ConnectionButton.js b/frontend/js/Components/ConnectionButton.js @@ -4,14 +4,14 @@ Ext.define('PartKeepr.ConnectionButton', { disconnectedIcon: 'resources/silkicons/disconnect.png', cls: 'x-btn-icon', icon: 'resources/silkicons/disconnect.png', - tooltip: i18n("Disconnected"), + //tooltip: i18n("Disconnected"), setConnected: function () { this.setIcon(this.connectedIcon); - this.setTooltip(i18n("Connected")); + //this.setTooltip(i18n("Connected")); }, setDisconnected: function () { this.setIcon(this.disconnectedIcon); - this.setTooltip(i18n("Disconnected")); + //this.setTooltip(i18n("Disconnected")); } }); diff --git a/frontend/js/Components/Statusbar.js b/frontend/js/Components/Statusbar.js @@ -8,6 +8,7 @@ Ext.define('PartKeepr.Statusbar', { initComponent: function () { this.connectionButton = new PartKeepr.ConnectionButton(); + this.connectionButton.on("click", this.onConnectionButtonClick, this); this.timeDisplay = new PartKeepr.TimeDisplay(); this.currentUserDisplay = Ext.create("Ext.toolbar.TextItem"); @@ -52,11 +53,15 @@ Ext.define('PartKeepr.Statusbar', { }, endLoad: function () { this.clearStatus({useDefaults: true}); + }, + onConnectionButtonClick: function () { + if (PartKeepr.getApplication().getSession()) { + PartKeepr.getApplication().logout(); + } else { + var o = new PartKeepr.LoginDialog(); + o.show(); + } } - - - - }); diff --git a/frontend/js/Dialogs/Auth/LoginDialog.js b/frontend/js/Dialogs/Auth/LoginDialog.js @@ -80,19 +80,11 @@ Ext.define('PartKeepr.LoginDialog', { if (!obj.admin) { Ext.getCmp("edit-users").hide(); + } else { + Ext.getCmp("edit-users").show(); } - PartKeepr.getApplication().createGlobalStores(); - - PartKeepr.getApplication().reloadStores(); - - var j = Ext.create("PartKeepr.PartManager", { - title: i18n("Part Manager"), - closable: false - }); - - PartKeepr.getApplication().addItem(j); - j.show(); + PartKeepr.getApplication().login(); PartKeepr.log(i18n("Logged in as")+" "+obj.username); this.close(); diff --git a/frontend/js/PartKeepr.js b/frontend/js/PartKeepr.js @@ -21,6 +21,23 @@ Ext.application({ Ext.QuickTips.init(); }, + login: function () { + this.createGlobalStores(); + this.reloadStores(); + + var j = Ext.create("PartKeepr.PartManager", { + title: i18n("Part Manager"), + closable: false + }); + + this.addItem(j); + this.menuBar.enable(); + }, + logout: function () { + this.menuBar.disable(); + this.centerPanel.removeAll(true); + this.setSession(null); + }, createGlobalStores: function () { this.storageLocationStore = Ext.create("Ext.data.Store", { @@ -123,13 +140,15 @@ Ext.application({ * */ reloadStores: function () { - this.storageLocationStore.load(); - this.footprintStore.load(); - this.manufacturerStore.load(); - this.distributorStore.load(); - this.partUnitStore.load(); - this.unitStore.load(); - Ext.defer(PartKeepr.getApplication().reloadStores, 100000, this); + if (this.getSession()) { + this.storageLocationStore.load(); + this.footprintStore.load(); + this.manufacturerStore.load(); + this.distributorStore.load(); + this.partUnitStore.load(); + this.unitStore.load(); + Ext.defer(PartKeepr.getApplication().reloadStores, 100000, this); + } }, createLayout: function () { @@ -146,6 +165,8 @@ Ext.application({ this.menuBar = Ext.create("PartKeepr.MenuBar"); + this.menuBar.disable(); + Ext.create('Ext.container.Viewport', { layout: 'fit', items: [{ @@ -220,7 +241,13 @@ Ext.application({ setSession: function (session) { this.session = session; - this.getStatusbar().getConnectionButton().setConnected(); + if (session) { + this.getStatusbar().getConnectionButton().setConnected(); + } else { + this.getStatusbar().getConnectionButton().setDisconnected(); + this.setUsername(""); + } + }, setUsername: function (username) { this.username = username;