Ext . define ( 'Rambox.view.main.Main' , {
extend : 'Ext.tab.Panel'
, requires : [
'Rambox.view.main.MainController'
, 'Rambox.view.main.MainModel'
, 'Rambox.ux.WebView'
, 'Rambox.ux.mixin.Badge'
, 'Rambox.view.add.Add'
, 'Ext.ux.TabReorderer'
]
, xtype : 'app-main'
, controller : 'main'
, viewModel : {
type : 'main'
}
, plugins : [
{
ptype : 'tabreorderer'
}
]
, autoRender : true
, autoShow : true
, deferredRender : false
, tabBar : {
id : 'mainTabBar'
, cls : JSON . parse ( localStorage . getItem ( 'dontDisturb' ) ) ? 'dontdisturb' : ''
, items : [ {
xtype : 'button'
, html : '<span class="fa fa-heart" style="color:red;font-size:16px;cursor:pointer;padding:0 5px;"></span>'
, baseCls : ''
, tooltip : locale [ 'app.main[25]' ]
, href : 'https://rambox.pro/#donate'
} ]
}
, items : [
{
icon : 'resources/IconTray@2x.png'
, id : 'ramboxTab'
, closable : false
, reorderable : false
, autoScroll : true
, layout : 'hbox'
, tabConfig : { } // Created empty for Keyboard Shortcuts
, items : [
{
xtype : 'panel'
, title : locale [ 'app.main[0]' ]
, margin : '0 5 0 0'
, flex : 2
, header : { height : 50 }
, tools : [
{
xtype : 'checkboxgroup'
, items : [
{
xtype : 'checkbox'
, boxLabel : locale [ 'app.main[1]' ]
, name : 'messaging'
, checked : true
, uncheckedValue : false
, inputValue : true
}
, {
xtype : 'checkbox'
, boxLabel : locale [ 'app.main[2]' ]
, margin : '0 10 0 10'
, name : 'email'
, checked : true
, uncheckedValue : false
, inputValue : true
}
]
, listeners : {
change : 'doTypeFilter'
}
}
, {
xtype : 'textfield'
, grow : true
, growMin : 120
, growMax : 170
, triggers : {
clear : {
weight : 0
, cls : Ext . baseCSSPrefix + 'form-clear-trigger'
, hidden : true
, handler : 'onClearClick'
}
, search : {
weight : 1
, cls : Ext . baseCSSPrefix + 'form-search-trigger search-trigger'
}
}
, listeners : {
change : 'onSearchServiceChange'
, afterrender : 'onSearchRender'
, specialkey : 'onSearchEnter'
}
}
]
, items : [
{
xtype : 'dataview'
, store : 'ServicesList'
, itemSelector : 'div.service'
, tpl : [
'<tpl for=".">'
, '<div class="service" data-qtip="{description}">'
, '<img src="https://firebasestorage.googleapis.com/v0/b/rambox-d1326.appspot.com/o/services%2F{logo}?alt=media&token=49036238-8f37-4f08-a7e5-1563be94c36e" width="48" />'
, '<span>{name}</span>'
, '</div>'
, '</tpl>'
]
, emptyText : '<div style="padding: 20px;">' + locale [ 'app.main[3]' ] + '</div>'
, listeners : {
itemclick : 'onNewServiceSelect'
}
}
]
}
, {
xtype : 'grid'
, title : locale [ 'app.main[4]' ]
, store : 'Services'
, hideHeaders : true
, margin : '0 0 0 5'
, flex : 1
, header : { height : 50 }
, features : [
{
ftype : 'grouping'
, collapsible : false
, groupHeaderTpl : '{columnName:uppercase}: {name:capitalize} ({rows.length} {[values.rows.length > 1 ? "' + locale [ 'app.main[9]' ] + '" : "' + locale [ 'app.main[8]' ] + '"]})'
}
]
, plugins : {
ptype : 'cellediting'
, clicksToEdit : 2
}
, tools : [
{
xtype : 'button'
, glyph : 'xf1f8@FontAwesome'
, baseCls : ''
, tooltip : locale [ 'app.main[10]' ]
, handler : 'removeAllServices'
, bind : {
disabled : '{emptyServices}'
}
}
]
, columns : [
{
xtype : 'templatecolumn'
, width : 52
, variableRowHeight : true
, tpl : '<img src="{[ values.type !== \"custom\" ? \"https://firebasestorage.googleapis.com/v0/b/rambox-d1326.appspot.com/o/services%2F\"+values.logo+\"?alt=media\" : (values.logo == \"\" ? \"https://firebasestorage.googleapis.com/v0/b/rambox-d1326.appspot.com/o/services%2Fcustom.png?alt=media\" : values.logo) ]}" data-qtip="{type:capitalize}" width="32" style="{[ values.enabled ? \"-webkit-filter: grayscale(0)\" : \"-webkit-filter: grayscale(1)\" ]}" />'
}
, {
dataIndex : 'name'
, variableRowHeight : true
, flex : 1
, editor : {
xtype : 'textfield'
, allowBlank : true
}
}
, {
xtype : 'actioncolumn'
, width : 60
, align : 'right'
, items : [
{
glyph : 0xf1f7
, tooltip : locale [ 'app.main[11]' ]
, getClass : function ( value , metaData , record , rowIndex , colIndex , store , view ) {
if ( record . get ( 'notifications' ) ) return 'x-hidden' ;
}
}
, {
glyph : 0xf026
, tooltip : locale [ 'app.main[12]' ]
, getClass : function ( value , metaData , record , rowIndex , colIndex , store , view ) {
if ( ! record . get ( 'muted' ) ) return 'x-hidden' ;
}
}
]
}
, {
xtype : 'actioncolumn'
, width : 60
, align : 'center'
, items : [
{
glyph : 0xf013
, tooltip : locale [ 'app.main[13]' ]
, handler : 'configureService'
, getClass : function ( ) { return 'x-hidden-display' ; }
}
, {
glyph : 0xf1f8
, tooltip : locale [ 'app.main[14]' ]
, handler : 'removeService'
, getClass : function ( ) { return 'x-hidden-display' ; }
}
]
}
, {
xtype : 'checkcolumn'
, width : 40
, dataIndex : 'enabled'
, renderer : function ( value , metaData ) {
metaData . tdAttr = 'data-qtip="Service ' + ( value ? 'Enabled' : 'Disabled' ) + '"' ;
return this . defaultRenderer ( value , metaData ) ;
}
, listeners : {
checkchange : 'onEnableDisableService'
}
}
]
, viewConfig : {
emptyText : locale [ 'app.main[15]' ]
, forceFit : true
, stripeRows : true
}
, listeners : {
edit : 'onRenameService'
, rowdblclick : 'showServiceTab'
}
}
]
, tbar : {
xtype : 'toolbar'
, height : 42
, ui : 'main'
, enableOverflow : true
, overflowHandler : 'menu'
, items : [
{
glyph : JSON . parse ( localStorage . getItem ( 'dontDisturb' ) ) ? 'xf1f7@FontAwesome' : 'xf0f3@FontAwesome'
, text : locale [ 'app.main[16]' ] + ': ' + ( JSON . parse ( localStorage . getItem ( 'dontDisturb' ) ) ? locale [ 'app.window[20]' ] : locale [ 'app.window[21]' ] )
, tooltip : locale [ 'app.main[17]' ] + '<br/><b>' + locale [ 'app.main[18]' ] + ( require ( 'electron' ) . remote . process . platform === 'darwin' ? 'Cmd + D</b>' : ': Alt + Shift + D</b>' )
, enableToggle : true
, handler : 'dontDisturb'
, reference : 'disturbBtn'
, id : 'disturbBtn'
, pressed : JSON . parse ( localStorage . getItem ( 'dontDisturb' ) )
}
, {
glyph : 'xf023@FontAwesome'
, text : locale [ 'app.main[19]' ]
, tooltip : locale [ 'app.main[20]' ] + '<br/><b>' + locale [ 'app.main[18]' ] + ( require ( 'electron' ) . remote . process . platform === 'darwin' ? 'Cmd + Alt + L</b>' : ': Alt + Shift + L</b>' )
, handler : 'lockRambox'
, id : 'lockRamboxBtn'
} , '-'
, {
html : '<span style="color:#FFF;cursor:pointer;"><span class="fa fa-star" style="color:#F8D64E;font-size:16px;padding:0 5px;"></span> Try Rambox Pro</span>'
, href : 'https://rambox.pro/api/download'
, baseCls : ''
}
, '->'
, {
xtype : 'image'
, id : 'avatar'
, bind : {
src : '{avatar}'
, hidden : '{!avatar}'
}
, width : 30
, height : 30
, style : 'border-radius: 50%;border:2px solid #d8d8d8;'
}
, {
id : 'usernameBtn'
, bind : {
text : '{username}'
, hidden : '{!username}'
}
, menu : [
{
text : 'Synchronize Configuration'
, glyph : 'xf0c2@FontAwesome'
, menu : [
{
xtype : 'label'
, bind : {
html : '<b class="menu-title">Last Sync: {last_sync}</b>'
}
}
, {
text : 'Backup'
, glyph : 'xf0ee@FontAwesome'
, scope : Rambox . ux . Auth0
, handler : Rambox . ux . Auth0 . backupConfiguration
}
, {
text : 'Restore'
, glyph : 'xf0ed@FontAwesome'
, scope : Rambox . ux . Auth0
, handler : Rambox . ux . Auth0 . restoreConfiguration
}
, {
text : 'Check for updated backup'
, glyph : 'xf021@FontAwesome'
, scope : Rambox . ux . Auth0
, handler : Rambox . ux . Auth0 . checkConfiguration
}
]
}
, '-'
, {
text : locale [ 'app.main[21]' ]
, glyph : 'xf08b@FontAwesome'
, handler : 'logout'
}
]
}
, {
text : locale [ 'app.main[22]' ]
, icon : 'resources/auth0.png'
, id : 'loginBtn'
, tooltip : locale [ 'app.main[23]' ] + '<br /><br /><i>' + locale [ 'app.main[24]' ] + ' Auth0 (https://auth0.com)</i>'
, bind : {
hidden : '{username}'
}
, handler : 'login'
}
, {
tooltip : locale [ 'preferences[0]' ]
, glyph : 'xf013@FontAwesome'
, handler : 'openPreferences'
}
]
}
, bbar : [
{
xtype : 'segmentedbutton'
, allowToggle : false
, items : [
{
text : '<b>Help us</b> with'
, pressed : true
}
, {
text : locale [ 'app.main[25]' ]
, glyph : 'xf21e@FontAwesome'
, href : 'https://rambox.pro/#donate'
}
, {
text : 'Translation'
, glyph : 'xf0ac@FontAwesome'
, href : 'https://crowdin.com/project/rambox/invite'
}
]
}
, '->'
, {
xtype : 'label'
, html : '<span class="fa fa-code" style="color:black;"></span> ' + locale [ 'app.main[26]' ] + ' <span class="fa fa-heart" style="color:red;"></span> ' + locale [ 'app.main[27]' ] . replace ( 'Argentina' , '<img src="resources/flag.png" alt="Argentina" data-qtip="Argentina" />' )
}
, '->'
, {
xtype : 'segmentedbutton'
, allowToggle : false
, items : [
{
text : '<b>Follow us</b>'
, pressed : true
}
, {
glyph : 'xf082@FontAwesome'
, href : 'https://www.facebook.com/ramboxapp'
}
, {
glyph : 'xf099@FontAwesome'
, href : 'https://www.twitter.com/ramboxapp'
}
, {
glyph : 'xf09b@FontAwesome'
, href : 'https://github.com/ramboxapp/community-edition'
}
]
}
]
}
, { id : 'tbfill' , tabConfig : { xtype : 'tbfill' } }
]
, listeners : {
tabchange : 'onTabChange'
, add : 'updatePositions'
, remove : 'updatePositions'
, childmove : 'updatePositions'
, boxready : 'initialize'
}
} ) ;