Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
piphone-front
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
La Quadrature du Net
piphone
piphone-front
Commits
68a3c82b
Commit
68a3c82b
authored
Jan 18, 2017
by
okhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Call bar is now working
parent
45163032
Pipeline
#767
canceled with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
10 deletions
+62
-10
app/SIP.php
app/SIP.php
+4
-4
templates/feedbackform.html
templates/feedbackform.html
+58
-6
No files found.
app/SIP.php
View file @
68a3c82b
...
...
@@ -14,7 +14,7 @@ class SIP extends Controller {
function
afterRoute
(
$f3
,
$args
)
{
// We return only JSON, so no templates
return
;
echo
$f3
->
get
(
'response'
)
;
}
// Getting a call from the SIP_API
function
feedbacksip
(
$f3
,
$args
)
{
...
...
@@ -27,12 +27,12 @@ class SIP extends Controller {
try
{
$token
=
JWT
::
encode
(
array
(
'api'
=>
JWT_TOKEN
),
JWT_KEY
);
$res
=
$client
->
get
(
"calls/
$call_id
"
,
[
'query'
=>
$data
]);
return
(
GuzzleHttp\Psr7\copy_to_string
(
$res
->
getBody
(
)));
$f3
->
set
(
'response'
,
(
GuzzleHttp\Psr7\copy_to_string
(
$res
->
getBody
()
)));
}
catch
(
RequestException
$e
)
{
if
(
$e
->
hasResponse
())
{
return
Psr7\str
(
$e
->
getResponse
(
));
$f3
->
set
(
'response'
,
Psr7\str
(
$e
->
getResponse
()
));
}
return
Psr7\str
(
$e
->
getRequest
(
));
$f3
->
set
(
'response'
,
Psr7\str
(
$e
->
getRequest
()
));
}
}
}
templates/feedbackform.html
View file @
68a3c82b
...
...
@@ -74,29 +74,81 @@
<script
type=
"text/javascript"
>
var
call
=
JSON
.
parse
(
'
{{ @call | raw }}
'
);
var
call_url
=
call
[
'
data
'
][
'
url
'
];
function
update_call
(
calls
)
{
var
call_history
=
calls
[
'
data
'
][
'
history
'
];
var
intervall
function
normalize_phone
(
phone
)
{
if
(
phone
.
startsWith
(
'
+
'
))
{
return
phone
.
replace
(
'
+
'
,
'
00
'
);
}
return
phone
;
}
function
update_call
(
response
)
{
var
call_history
=
response
[
'
data
'
][
'
history
'
];
var
call_state
=
call_history
.
sort
(
function
(
a
,
b
)
{
var
date1
=
new
Date
(
a
[
1
]);
var
date2
=
new
Date
(
b
[
1
]);
return
date
1
-
date2
;
return
date
2
-
date1
;
})[
0
];
$
(
'
.step_text
'
).
removeClass
(
'
visible
'
);
if
(
call_state
[
0
].
startsWith
(
'
Created:Init
'
))
{
$
(
'
#caller
'
).
addClass
(
'
outline_green
'
);
$
(
'
#step_init
'
).
addClass
(
'
visible
'
);
};
if
(
call_state
[
0
].
startsWith
(
'
Ringing:
'
))
{
phone
=
normalize_phone
(
call_state
[
0
].
split
(
'
:
'
)[
1
]);
caller
=
normalize_phone
(
response
[
'
data
'
][
'
caller
'
]);
callee
=
normalize_phone
(
response
[
'
data
'
][
'
callee
'
]);
if
(
phone
===
caller
)
{
$
(
'
#caller
'
).
addClass
(
'
outline_green
'
);
$
(
'
#step_caller
'
).
addClass
(
'
visible
'
);
}
else
{
$
(
'
#step1
'
).
addClass
(
'
green
'
);
$
(
'
#step2
'
).
addClass
(
'
green
'
);
$
(
'
#step3
'
).
addClass
(
'
green
'
);
$
(
'
#wait
'
).
addClass
(
'
green
'
);
$
(
'
#callee
'
).
addClass
(
'
outline_red
'
);
$
(
'
#step4
'
).
addClass
(
'
outline_red
'
);
$
(
'
#step5
'
).
addClass
(
'
outline_red
'
);
$
(
'
#step6
'
).
addClass
(
'
outline_red
'
);
$
(
'
#step_callee
'
).
addClass
(
'
visible
'
);
};
};
if
(
call_state
[
0
].
startsWith
(
'
Up:
'
))
{
// Need to check if we're caller or callee
phone
=
normalize_phone
(
call_state
[
0
].
split
(
'
:
'
)[
1
]);
caller
=
normalize_phone
(
response
[
'
data
'
][
'
caller
'
]);
callee
=
normalize_phone
(
response
[
'
data
'
][
'
callee
'
]);
if
(
phone
===
caller
)
{
$
(
'
#caller
'
).
addClass
(
'
green
'
);
$
(
'
#step1
'
).
addClass
(
'
outline_green
'
);
$
(
'
#step2
'
).
addClass
(
'
outline_green
'
);
$
(
'
#step3
'
).
addClass
(
'
outline_green
'
);
$
(
'
#wait
'
).
addClass
(
'
outline_green
'
);
$
(
'
#step_wait
'
).
addClass
(
'
visible
'
);
}
else
{
$
(
'
#callee
'
).
addClass
(
'
red
'
);
$
(
'
#step4
'
).
addClass
(
'
red
'
);
$
(
'
#step5
'
).
addClass
(
'
red
'
);
$
(
'
#step6
'
).
addClass
(
'
red
'
);
$
(
'
#step_connected
'
).
addClass
(
'
visible
'
);
window
.
clearInterval
(
intervall
);
};
};
console
.
log
(
call_state
);
};
function
fetch
()
{
$
.
ajax
({
method
:
'
GET
'
,
url
:
call_url
,
dataType
:
'
json
'
,
success
:
update_call
complete
:
function
(
xhr
,
status
)
{
update_call
(
xhr
.
responseJSON
);
}
});
};
$
(
document
).
ready
(
function
()
{
update_call
(
call
);
window
.
setInterval
(
fetch
,
2
000
);
intervall
=
window
.
setInterval
(
fetch
,
3
000
);
});
</script>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment