Improved format of duration.
This commit is contained in:
parent
c1d8269145
commit
94148b37aa
2 changed files with 175 additions and 6 deletions
|
@ -106,14 +106,11 @@ class App.CTI extends App.Controller
|
|||
return
|
||||
|
||||
format = (time) ->
|
||||
# Minutes and seconds
|
||||
mins = ~~(time / 60)
|
||||
secs = time % 60
|
||||
|
||||
# Hours, minutes and seconds
|
||||
hrs = ~~(time / 3600)
|
||||
mins = ~~((time % 3600) / 60)
|
||||
secs = time % 60
|
||||
hrs = ~~parseInt((time / 3600))
|
||||
mins = ~~parseInt(((time % 3600) / 60))
|
||||
secs = parseInt(time % 60)
|
||||
|
||||
# Output like "1:01" or "4:03:59" or "123:03:59"
|
||||
mins = "0#{mins}" if mins < 10
|
||||
|
|
|
@ -43,6 +43,178 @@ module Cti
|
|||
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
|
||||
|
||||
=begin
|
||||
|
|
Loading…
Reference in a new issue