Statusbar.js (2528B)
1 Ext.define('PartKeepr.Statusbar', { 2 extend: 'Ext.ux.statusbar.StatusBar', 3 4 defaultText: i18n("Ready."), 5 defaultIconCls: 'x-status-valid', 6 iconCls: 'x-status-valid', 7 autoClear: 3000, 8 initComponent: function () 9 { 10 this.connectionButton = new PartKeepr.ConnectionButton(); 11 this.connectionButton.on("click", this.onConnectionButtonClick, this); 12 this.timeDisplay = Ext.create("PartKeepr.TimeDisplay"); 13 this.currentUserDisplay = Ext.create("Ext.toolbar.TextItem"); 14 15 this.showMessageLog = Ext.create("Ext.Button", { 16 iconCls: 'web-icon application_osx_terminal', 17 cls: 'x-btn-icon', 18 handler: function () 19 { 20 PartKeepr.getApplication().toggleMessageLog(); 21 } 22 }); 23 24 this.systemNoticeButton = Ext.create("PartKeepr.SystemNoticeButton", { 25 hidden: true 26 }); 27 28 Ext.apply(this, { 29 items: [ 30 this.currentUserDisplay, 31 {xtype: 'tbseparator'}, 32 this.timeDisplay, 33 {xtype: 'tbseparator'}, 34 this.showMessageLog, 35 {xtype: 'tbseparator'}, 36 this.connectionButton, 37 this.systemNoticeButton 38 39 ] 40 }); 41 42 this.setDisconnected(); 43 44 this.callParent(); 45 }, 46 getConnectionButton: function () 47 { 48 return this.connectionButton; 49 }, 50 setCurrentUser: function (username) 51 { 52 this.currentUserDisplay.setText(i18n("Logged in as") + ": " + username); 53 }, 54 startLoad: function (message) 55 { 56 if (message !== null) { 57 this.showBusy({text: message, iconCls: "x-status-busy"}); 58 } else { 59 this.showBusy(); 60 } 61 }, 62 endLoad: function () 63 { 64 this.clearStatus({useDefaults: true}); 65 }, 66 setConnected: function () 67 { 68 var user = PartKeepr.getApplication().getLoginManager().getUser(); 69 70 this.setCurrentUser(user.get("username")); 71 this.connectionButton.setConnected(); 72 }, 73 setDisconnected: function () 74 { 75 this.connectionButton.setDisconnected(); 76 this.currentUserDisplay.setText(i18n("Not logged in")); 77 }, 78 onConnectionButtonClick: function () 79 { 80 var loginManager = PartKeepr.getApplication().getLoginManager(); 81 if (loginManager.isLoggedIn()) { 82 loginManager.logout(); 83 } else { 84 loginManager.login(); 85 } 86 } 87 }); 88 89