Improved format of duration.

This commit is contained in:
Martin Edenhofer 2016-05-31 10:56:13 +02:00
parent c1d8269145
commit 94148b37aa
2 changed files with 175 additions and 6 deletions

View file

@ -106,14 +106,11 @@ class App.CTI extends App.Controller
return return
format = (time) -> format = (time) ->
# Minutes and seconds
mins = ~~(time / 60)
secs = time % 60
# Hours, minutes and seconds # Hours, minutes and seconds
hrs = ~~(time / 3600) hrs = ~~parseInt((time / 3600))
mins = ~~((time % 3600) / 60) mins = ~~parseInt(((time % 3600) / 60))
secs = time % 60 secs = parseInt(time % 60)
# Output like "1:01" or "4:03:59" or "123:03:59" # Output like "1:01" or "4:03:59" or "123:03:59"
mins = "0#{mins}" if mins < 10 mins = "0#{mins}" if mins < 10

View file

@ -43,6 +43,178 @@ module Cti
state: 'hangup', state: 'hangup',
) )
example data, can be used for demo
Cti::Log.create(
direction: 'in',
from: '4930609854180',
from_comment: 'Franz Bauer',
to: '4930609811111',
to_comment: 'Bob Smith',
call_id: '00001',
comment: '',
state: 'newCall',
done: false,
preferences: {
from: [
{
caller_id: '4930726128135',
comment: nil,
level: 'known',
object: 'User',
o_id: 2,
user_id: 2,
}
]
}
)
Cti::Log.create(
direction: 'out',
from: '4930609854180',
from_comment: 'Franz Bauer',
to: '4930609811111',
to_comment: 'Bob Smith',
call_id: '00002',
comment: '',
state: 'newCall',
preferences: {
to: [
{
caller_id: '4930726128135',
comment: nil,
level: 'known',
object: 'User',
o_id: 2,
user_id: 2,
}
]
}
)
Cti::Log.create(
direction: 'in',
from: '4930609854180',
from_comment: 'Franz Bauer',
to: '4930609811111',
to_comment: 'Bob Smith',
call_id: '00003',
comment: '',
state: 'answer',
preferences: {
from: [
{
caller_id: '4930726128135',
comment: nil,
level: 'known',
object: 'User',
o_id: 2,
user_id: 2,
}
]
}
)
Cti::Log.create(
direction: 'in',
from: '4930609854180',
from_comment: 'Franz Bauer',
to: '4930609811111',
to_comment: 'Bob Smith',
call_id: '00004',
comment: '',
state: 'hangup',
comment: 'normalClearing',
done: false,
preferences: {
from: [
{
caller_id: '4930726128135',
comment: nil,
level: 'known',
object: 'User',
o_id: 2,
user_id: 2,
}
]
}
)
Cti::Log.create(
direction: 'in',
from: '4930609854180',
from_comment: 'Franz Bauer',
to: '4930609811111',
to_comment: 'Bob Smith',
call_id: '00005',
comment: '',
state: 'hangup',
start: Time.zone.now - 15.seconds,
'end': Time.zone.now,
preferences: {
from: [
{
caller_id: '4930726128135',
comment: nil,
level: 'known',
object: 'User',
o_id: 2,
user_id: 2,
}
]
}
)
Cti::Log.create(
direction: 'in',
from: '4930609854180',
from_comment: 'Franz Bauer',
to: '4930609811111',
to_comment: '',
call_id: '00006',
comment: '',
state: 'hangup',
start: Time.zone.now - 15.seconds,
'end': Time.zone.now,
preferences: {
from: [
{
caller_id: '4930726128135',
comment: nil,
level: 'known',
object: 'User',
o_id: 2,
user_id: 2,
}
]
}
)
Cti::Log.create(
direction: 'in',
from: '4930609854180',
from_comment: 'Franz Bauer',
to: '4930609811111',
to_comment: 'Bob Smith',
call_id: '00007',
comment: '',
state: 'hangup',
start: Time.zone.now - 15.seconds,
'end': Time.zone.now,
preferences: {
from: [
{
caller_id: '4930726128135',
comment: nil,
level: 'maybe',
object: 'User',
o_id: 2,
user_id: 2,
}
]
}
)
=end =end
=begin =begin