Browse Source

Improved StatusBar

Added a service option to keep status bar visible or hide it if
everything is ok.
Fixes #645
v0.5.8
Ramiro Saenz 8 years ago
parent
commit
b447ebb4ab
  1. 4
      app/model/Service.js
  2. 87
      app/ux/WebView.js
  3. 34
      app/view/add/Add.js
  4. 4
      app/view/add/AddController.js

4
app/model/Service.js

@ -37,6 +37,10 @@ Ext.define('Rambox.model.Service', {
name: 'muted' name: 'muted'
,type: 'boolean' ,type: 'boolean'
,defaultValue: false ,defaultValue: false
},{
name: 'statusbar'
,type: 'boolean'
,defaultValue: true
},{ },{
name: 'displayTabUnreadCounter' name: 'displayTabUnreadCounter'
,type: 'boolean' ,type: 'boolean'

87
app/ux/WebView.js

@ -123,23 +123,19 @@ Ext.define('Rambox.ux.WebView',{
] ]
} }
} }
,bbar: {
xtype: 'statusbar'
,defaultText: '<i class="fa fa-check fa-fw" aria-hidden="true"></i> Ready'
,busyIconCls : ''
,busyText: '<i class="fa fa-circle-o-notch fa-spin fa-fw"></i> Loading...'
,items: [
,{
xtype: 'tbtext'
,itemId: 'url'
}
]
}
,listeners: { ,listeners: {
afterrender: me.onAfterRender afterrender: me.onAfterRender
} }
}); });
if ( me.record.get('statusbar') ) {
Ext.apply(me, {
bbar: me.statusBarConstructor(false)
});
} else {
me.items.push(me.statusBarConstructor(true));
}
me.callParent(config); me.callParent(config);
} }
@ -157,7 +153,7 @@ Ext.define('Rambox.ux.WebView',{
,padding: 100 ,padding: 100
}; };
} else { } else {
cfg = { cfg = [{
xtype: 'component' xtype: 'component'
,hideMode: 'offsets' ,hideMode: 'offsets'
,autoRender: true ,autoRender: true
@ -175,7 +171,7 @@ Ext.define('Rambox.ux.WebView',{
,useragent: Ext.getStore('ServicesList').getById(me.record.get('type')).get('userAgent') ,useragent: Ext.getStore('ServicesList').getById(me.record.get('type')).get('userAgent')
,preload: './resources/js/rambox-service-api.js' ,preload: './resources/js/rambox-service-api.js'
} }
}; }];
if ( Ext.getStore('ServicesList').getById(me.record.get('type')).get('allow_popups') ) cfg.autoEl.allowpopups = 'on'; if ( Ext.getStore('ServicesList').getById(me.record.get('type')).get('allow_popups') ) cfg.autoEl.allowpopups = 'on';
} }
@ -183,6 +179,42 @@ Ext.define('Rambox.ux.WebView',{
return cfg; return cfg;
} }
,statusBarConstructor: function(floating) {
var me = this;
return {
xtype: 'statusbar'
,hidden: !me.record.get('statusbar')
,keep: me.record.get('statusbar')
,y: floating ? '-18px' : 'auto'
,height: 19
,dock: 'bottom'
,defaultText: '<i class="fa fa-check fa-fw" aria-hidden="true"></i> Ready'
,busyIconCls : ''
,busyText: '<i class="fa fa-circle-o-notch fa-spin fa-fw"></i> Loading...'
,items: [
{
xtype: 'tbtext'
,itemId: 'url'
}
,{
xtype: 'button'
,glyph: 'xf00d@FontAwesome'
,scale: 'small'
,ui: 'decline'
,padding: 0
,scope: me
,hidden: floating
,handler: me.closeStatusBar
,tooltip: {
text: 'Close statusbar until next time'
,mouseOffset: [0,-60]
}
}
]
};
}
,onAfterRender: function() { ,onAfterRender: function() {
var me = this; var me = this;
@ -199,10 +231,12 @@ Ext.define('Rambox.ux.WebView',{
// Show and hide spinner when is loading // Show and hide spinner when is loading
webview.addEventListener("did-start-loading", function() { webview.addEventListener("did-start-loading", function() {
console.info('Start loading...', me.src); console.info('Start loading...', me.src);
if ( !me.down('statusbar').closed || !me.down('statusbar').keep ) me.down('statusbar').show();
me.down('statusbar').showBusy(); me.down('statusbar').showBusy();
}); });
webview.addEventListener("did-stop-loading", function() { webview.addEventListener("did-stop-loading", function() {
me.down('statusbar').clearStatus({useDefaults: true}); me.down('statusbar').clearStatus({useDefaults: true});
if ( !me.down('statusbar').keep ) me.down('statusbar').hide();
}); });
webview.addEventListener("did-finish-load", function(e) { webview.addEventListener("did-finish-load", function(e) {
@ -338,9 +372,13 @@ Ext.define('Rambox.ux.WebView',{
} else { } else {
callback(false); callback(false);
} }
me.down('statusbar').keep = true;
me.down('statusbar').show();
me.down('statusbar').setStatus({ me.down('statusbar').setStatus({
text: '<i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Certification Warning' text: '<i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Certification Warning'
}); });
me.down('statusbar').down('button').show();
}); });
}); });
@ -515,6 +553,27 @@ Ext.define('Rambox.ux.WebView',{
if ( me.record.get('enabled') ) webview.setAudioMuted(muted); if ( me.record.get('enabled') ) webview.setAudioMuted(muted);
} }
,closeStatusBar: function() {
var me = this;
me.down('statusbar').hide();
me.down('statusbar').closed = true;
me.down('statusbar').keep = me.record.get('statusbar');
}
,setStatusBar: function(keep) {
var me = this;
me.down('statusbar').destroy();
if ( keep ) {
me.addDocked(me.statusBarConstructor(false));
} else {
me.add(me.statusBarConstructor(true));
}
me.down('statusbar').keep = keep;
}
,setNotifications: function(notification, calledFromDisturb) { ,setNotifications: function(notification, calledFromDisturb) {
var me = this; var me = this;
var webview = me.down('component').el.dom; var webview = me.down('component').el.dom;

34
app/view/add/Add.js

@ -141,6 +141,10 @@ Ext.define('Rambox.view.add.Add',{
xtype: 'fieldset' xtype: 'fieldset'
,title: 'Options' ,title: 'Options'
,margin: '10 0 0 0' ,margin: '10 0 0 0'
,items: [
{
xtype: 'checkboxgroup'
,columns: 2
,items: [ ,items: [
{ {
xtype: 'checkbox' xtype: 'checkbox'
@ -166,6 +170,14 @@ Ext.define('Rambox.view.add.Add',{
,uncheckedValue: false ,uncheckedValue: false
,inputValue: true ,inputValue: true
} }
,{
xtype: 'checkbox'
,boxLabel: 'Always display Status Bar'
,name: 'statusbar'
,checked: me.edit ? me.record.get('statusbar') : true
,uncheckedValue: false
,inputValue: true
}
,{ ,{
xtype: 'checkbox' xtype: 'checkbox'
,boxLabel: 'Trust invalid authority certificates' ,boxLabel: 'Trust invalid authority certificates'
@ -176,12 +188,18 @@ Ext.define('Rambox.view.add.Add',{
,inputValue: true ,inputValue: true
} }
] ]
}, }
]
}
,{
xtype: 'fieldset'
,title: 'Unread counter'
,margin: '10 0 0 0'
,items: [
{ {
xtype: 'fieldset', xtype: 'checkboxgroup'
title: 'Unread counter', ,columns: 2
margin: '10 0 0 0', ,items: [
items: [
{ {
xtype: 'checkbox', xtype: 'checkbox',
boxLabel: 'Display tab unread counter', boxLabel: 'Display tab unread counter',
@ -199,8 +217,10 @@ Ext.define('Rambox.view.add.Add',{
inputValue: true inputValue: true
} }
] ]
}, }
{ ]
}
,{
xtype: 'fieldset' xtype: 'fieldset'
,title: 'Advanced' ,title: 'Advanced'
,margin: '10 0 0 0' ,margin: '10 0 0 0'

4
app/view/add/AddController.js

@ -34,6 +34,7 @@ Ext.define('Rambox.view.add.AddController', {
,align: formValues.align ,align: formValues.align
,notifications: formValues.notifications ,notifications: formValues.notifications
,muted: formValues.muted ,muted: formValues.muted
,statusbar: formValues.statusbar
,displayTabUnreadCounter: formValues.displayTabUnreadCounter ,displayTabUnreadCounter: formValues.displayTabUnreadCounter
,includeInGlobalUnreadCounter: formValues.includeInGlobalUnreadCounter ,includeInGlobalUnreadCounter: formValues.includeInGlobalUnreadCounter
,trust: formValues.trust ,trust: formValues.trust
@ -47,6 +48,8 @@ Ext.define('Rambox.view.add.AddController', {
view.setTitle(formValues.serviceName); view.setTitle(formValues.serviceName);
// Change sound of the Tab // Change sound of the Tab
view.setAudioMuted(formValues.muted); view.setAudioMuted(formValues.muted);
// Change statusbar of the Tab
view.setStatusBar(formValues.statusbar);
// Change notifications of the Tab // Change notifications of the Tab
view.setNotifications(formValues.notifications); view.setNotifications(formValues.notifications);
// Change the icon of the Tab // Change the icon of the Tab
@ -86,6 +89,7 @@ Ext.define('Rambox.view.add.AddController', {
,align: formValues.align ,align: formValues.align
,notifications: formValues.notifications ,notifications: formValues.notifications
,muted: formValues.muted ,muted: formValues.muted
,statusbar: formValues.statusbar
,displayTabUnreadCounter: formValues.displayTabUnreadCounter ,displayTabUnreadCounter: formValues.displayTabUnreadCounter
,includeInGlobalUnreadCounter: formValues.includeInGlobalUnreadCounter ,includeInGlobalUnreadCounter: formValues.includeInGlobalUnreadCounter
,trust: formValues.trust ,trust: formValues.trust

Loading…
Cancel
Save