mirror of
https://github.com/fazo96/telecommander.git
synced 2025-01-10 11:34:20 +01:00
added a status bar that shows last login/online status
This commit is contained in:
parent
d640d6a5b6
commit
0bc343b434
@ -17,7 +17,7 @@ As of __now__, __Telecommander lets you__:
|
|||||||
- Sign in with a code sent via SMS or Telegram until you delete the Telecommander session files or the session expires
|
- Sign in with a code sent via SMS or Telegram until you delete the Telecommander session files or the session expires
|
||||||
- Chat in groups and in private (it also marks messages as read when you read them)
|
- Chat in groups and in private (it also marks messages as read when you read them)
|
||||||
- Know when you have unread messages
|
- Know when you have unread messages
|
||||||
- View who's online
|
- View who's online and when was the last time someone logged in
|
||||||
- Do everything __completely in the terminal, even via ssh__ using only the keyboard
|
- Do everything __completely in the terminal, even via ssh__ using only the keyboard
|
||||||
- Do everything (except writing messages, duh) using only the mouse, in the terminal!
|
- Do everything (except writing messages, duh) using only the mouse, in the terminal!
|
||||||
- Navigate your contact and chat list
|
- Navigate your contact and chat list
|
||||||
@ -25,7 +25,6 @@ As of __now__, __Telecommander lets you__:
|
|||||||
|
|
||||||
Waht's missing for version _0.1.0_ (__Almost done!__):
|
Waht's missing for version _0.1.0_ (__Almost done!__):
|
||||||
|
|
||||||
- View when was the last time someone logged in
|
|
||||||
- Download latest messages on session start and show unreads
|
- Download latest messages on session start and show unreads
|
||||||
|
|
||||||
What's missing (for future versions up to 1.0)
|
What's missing (for future versions up to 1.0)
|
||||||
|
42
lib/ui.js
42
lib/ui.js
@ -26,6 +26,7 @@ module.exports = function(data){
|
|||||||
data.msgBox[data.selectedWindow].hide()
|
data.msgBox[data.selectedWindow].hide()
|
||||||
if(boxname === undefined){
|
if(boxname === undefined){
|
||||||
// Leave the clear
|
// Leave the clear
|
||||||
|
data.statusBar.hide()
|
||||||
} else {
|
} else {
|
||||||
// Switch window
|
// Switch window
|
||||||
data.selectedWindow = boxname;
|
data.selectedWindow = boxname;
|
||||||
@ -37,12 +38,21 @@ module.exports = function(data){
|
|||||||
data.cmdline.setLabel('Command for Telecommander')
|
data.cmdline.setLabel('Command for Telecommander')
|
||||||
}
|
}
|
||||||
var newb = data.getMsgBox(data.selectedWindow)
|
var newb = data.getMsgBox(data.selectedWindow)
|
||||||
|
data.refreshStatusBar()
|
||||||
|
data.statusBar.show()
|
||||||
newb.show()
|
newb.show()
|
||||||
newb.emit('scroll')
|
newb.emit('scroll')
|
||||||
}
|
}
|
||||||
data.screen.render()
|
data.screen.render()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.refreshStatusBar = function(){
|
||||||
|
var obj = data.nameToObj(data.selectedWindow)
|
||||||
|
if(obj && obj.id)
|
||||||
|
data.statusBar.setContent(data.getName(obj.id,obj.title?'group':'user','statusbar'))
|
||||||
|
else data.statusBar.setContent(data.selectedWindow)
|
||||||
|
}
|
||||||
|
|
||||||
data.screen = blessed.screen({
|
data.screen = blessed.screen({
|
||||||
smartCSR: true,
|
smartCSR: true,
|
||||||
dockBorders: true
|
dockBorders: true
|
||||||
@ -117,10 +127,11 @@ module.exports = function(data){
|
|||||||
tags: true,
|
tags: true,
|
||||||
mouse: true,
|
mouse: true,
|
||||||
right: 0,
|
right: 0,
|
||||||
label: { text: txt, side: 'left' },
|
top: 2,
|
||||||
|
//label: { text: txt, side: 'left' },
|
||||||
width: '80%',
|
width: '80%',
|
||||||
hidden: true,
|
hidden: true,
|
||||||
height: data.screen.height - data.cmdline.height,
|
height: data.screen.height - data.cmdline.height - 2,
|
||||||
border: { type: 'line' },
|
border: { type: 'line' },
|
||||||
scrollable: true,
|
scrollable: true,
|
||||||
autoscroll: true,
|
autoscroll: true,
|
||||||
@ -133,9 +144,16 @@ module.exports = function(data){
|
|||||||
},
|
},
|
||||||
style: data.getDefaultStyle()
|
style: data.getDefaultStyle()
|
||||||
})
|
})
|
||||||
|
b.on('focus',function(){
|
||||||
|
data.statusBarStyle.border.fg = b.style.focus.border.fg
|
||||||
|
data.screen.render()
|
||||||
|
})
|
||||||
|
b.on('blur',function(){
|
||||||
|
data.statusBarStyle.border.fg = b.style.border.fg
|
||||||
|
})
|
||||||
var obj = data.nameToObj(txt)
|
var obj = data.nameToObj(txt)
|
||||||
if(obj && obj.id)
|
/*if(obj && obj.id)
|
||||||
b.setLabel(data.getName(obj.id,obj.title?'group':'user','label'))
|
b.setLabel(data.getName(obj.id,obj.title?'group':'user','label'))*/
|
||||||
b.data.downloadedHistoryTimes = 0
|
b.data.downloadedHistoryTimes = 0
|
||||||
b.key('enter',function(){
|
b.key('enter',function(){
|
||||||
this.setScrollPerc(100)
|
this.setScrollPerc(100)
|
||||||
@ -152,6 +170,22 @@ module.exports = function(data){
|
|||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.statusBarStyle = data.getDefaultStyle()
|
||||||
|
data.statusBarStyle.border.fg = 'white'
|
||||||
|
data.statusBar = blessed.box({
|
||||||
|
tags: true,
|
||||||
|
input: false,
|
||||||
|
keyable: false,
|
||||||
|
keys: false,
|
||||||
|
border: { type: 'line' },
|
||||||
|
height: 3,
|
||||||
|
right: 0,
|
||||||
|
top: 0,
|
||||||
|
width: '80%',
|
||||||
|
style: data.statusBarStyle
|
||||||
|
})
|
||||||
|
data.screen.append(data.statusBar)
|
||||||
|
|
||||||
data.getDefaultPopupStyle = function(){
|
data.getDefaultPopupStyle = function(){
|
||||||
return {
|
return {
|
||||||
width: '30%',
|
width: '30%',
|
||||||
|
@ -155,7 +155,7 @@ module.exports = function(data){
|
|||||||
if(online_expires)
|
if(online_expires)
|
||||||
if(moment().isBefore(online_expires))
|
if(moment().isBefore(online_expires))
|
||||||
name = name + '{|}{green-fg}Online{/green-fg}'
|
name = name + '{|}{green-fg}Online{/green-fg}'
|
||||||
else name = name + '{|}Last Seen: '+moment(online_expires).fromNow()
|
else name = name + '{|}Last Seen {grey-fg}'+moment(online_expires).fromNow()+'{/grey-fg}'
|
||||||
} else if(f === 'label'){
|
} else if(f === 'label'){
|
||||||
name = 'to ' + name
|
name = 'to ' + name
|
||||||
}
|
}
|
||||||
|
@ -217,6 +217,7 @@ data.downloadUpdates = function(){
|
|||||||
for(c in res.other_updates.list) data.onUpdate(res.other_updates.list[c])
|
for(c in res.other_updates.list) data.onUpdate(res.other_updates.list[c])
|
||||||
}
|
}
|
||||||
data.rebuildChatList()
|
data.rebuildChatList()
|
||||||
|
data.refreshStatusBar()
|
||||||
}
|
}
|
||||||
setTimeout(data.downloadUpdates,1000)
|
setTimeout(data.downloadUpdates,1000)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user