From 45163032a24cc3a06b91eca45bc169ec5b6e587c Mon Sep 17 00:00:00 2001 From: okhin Date: Wed, 18 Jan 2017 16:53:04 +0100 Subject: [PATCH] Starting the work on the JS --- app/Api.php | 17 ++++++++ app/Main.php | 16 +------- app/SIP.php | 38 +++++++++++++++++ app/routes.ini | 2 +- static/css/style.css | 46 +++++++++++++++++++++ templates/call.html | 9 ++--- templates/feedbackform.html | 81 ++++++++++++++++++++++++++++++------- templates/footer.html | 4 -- templates/monitor.html | 18 +++++++++ 9 files changed, 192 insertions(+), 39 deletions(-) create mode 100644 app/SIP.php create mode 100644 templates/monitor.html diff --git a/app/Api.php b/app/Api.php index 26c7e51..0653567 100644 --- a/app/Api.php +++ b/app/Api.php @@ -76,5 +76,22 @@ class Api { return json_decode($json, true); } + // Getting a call from the SIP_API + static function get_sip_call($call_id, $token) { + $data = array('api' => JWT_TOKEN, + 'token' => $token + ); + $client = new GuzzleHttp\Client(['base_uri' => SIP_ARI]); + try { + $res = $client->get("calls/$call_id", ['query' => $data]); + return (GuzzleHttp\Psr7\copy_to_string($res->getBody())); + } catch (RequestException $e) { + return Psr7\str($e->getRequest()); + if ($e->hasResponse()) { + echo Psr7\str($e->getResponse()); + } + } + } + }; diff --git a/app/Main.php b/app/Main.php index d48d7aa..05a9f77 100644 --- a/app/Main.php +++ b/app/Main.php @@ -67,20 +67,7 @@ class Main extends Controller { */ function feedbacksip($f3, $args) { //GET - $token = JWT::encode(array('api' => JWT_TOKEN), JWT_KEY); - $call_id = $args['callid']; - // Create the call - $data = array('api' => 'piphone', 'token' => $token); - $client = new GuzzleHttp\Client(['base_uri' => SIP_API]); - try { - $res = $client->get("calls/$call_id", ['query' => $data]); - return (GuzzleHttp\Psr7\copy_to_string($res->getBody())); - } catch (RequestException $e) { - echo Psr7\str($e->getRequest()); - if ($e->hasResponse()) { - echo Psr7\str($e->getResponse()); - } - } + } /* @@ -144,3 +131,4 @@ class Main extends Controller { } }; +; diff --git a/app/SIP.php b/app/SIP.php new file mode 100644 index 0000000..8fb02af --- /dev/null +++ b/app/SIP.php @@ -0,0 +1,38 @@ + JWT_TOKEN), JWT_KEY); + $call_id = $args['callid']; + $data = array('api' => JWT_TOKEN, + 'token' => $token + ); + $client = new GuzzleHttp\Client(['base_uri' => SIP_API]); + 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())); + } catch (RequestException $e) { + if ($e->hasResponse()) { + return Psr7\str($e->getResponse()); + } + return Psr7\str($e->getRequest()); + } + } +} diff --git a/app/routes.ini b/app/routes.ini index d1ae62b..3eeea54 100644 --- a/app/routes.ini +++ b/app/routes.ini @@ -4,7 +4,7 @@ GET @home:/=Main->home GET|POST @feedback:/feedback=Main->feedbackform GET|POST @call:/call/@id=Main->call GET @contactslist:/contactslist=Main->contactslist -GET @feedbacksip:/feedbacksip/@callid=Main->feedbacksip +GET @feedbacksip:/calls/@callid=SIP->feedbacksip GET @argumentation:/argumentation=Main->argumentation ; Fake REST API diff --git a/static/css/style.css b/static/css/style.css index 541df48..5be9d63 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -95,3 +95,49 @@ display: inline-block; background-color: #ccc; padding: .5em 1em; } + +/* Step styling */ +.step_bar { + line-height: 2ex; + vertical-align: middle; + text-align: center; +} + +.step { + color: white; + text-shadow: 0 2px 0 grey, 0 -2px 0 grey, 2px 0 0 grey, -2px 0 0 grey; + font-size: 2em; +} + +#caller { + transform: rotate(45deg); +} + +#callee { + transform: rotate(225deg); +} + +.step.outline_green { + text-shadow: 0 2px 0 green, 0 -2px 0 green, 2px 0 0 green, -2px 0 0 green; +} +.step.outline_red { + text-shadow: 0 2px 0 red, 0 -2px 0 red, 2px 0 0 red, -2px 0 0 red; +} + +.step.green { + color: green; + text-shadow: none; +} + +.step.red { + color: green; + text-shadow: none; +} + +.step_text { + display: none; +} + +.visible { + display: inherit; +} diff --git a/templates/call.html b/templates/call.html index 1219b9c..dead369 100644 --- a/templates/call.html +++ b/templates/call.html @@ -24,12 +24,11 @@

{{ _("Call at your expense") }}

-

{{ _("If you don't want to call for free, here is the number of the current MEP (you can either dial it from your phone or push the button if any VoIP client is installed on your device.") }}

- ☎ {{ @contact.phone }} - +

{{ _("If you don't want to call for free, here is the number of the current MEP - you can either dial it from your phone or push the button if any VoIP client is installed on your device.") }}

+ ☎ {{ @contact.phone }}
- - + + diff --git a/templates/feedbackform.html b/templates/feedbackform.html index dd87016..8cd22d2 100644 --- a/templates/feedbackform.html +++ b/templates/feedbackform.html @@ -10,7 +10,6 @@

{{ _("Currently calling") }}

-

{{ @contact.first_name }} {{ @contact.last_name }}

{{ _("Phone number") }}: {{ @contact.phone }} @@ -30,22 +29,74 @@ -

+

{{ _("Initialising the call") }}

+

{{ _("Calling you") }}

+

{{ _("When ready, please dial 1 on your phone") }}

+

{{ _(" Calling ")}}{{ @contact.full_name }}

+

{{ _("Connected to ") }}{{ @contact.full_name }}

+ +

{{ @call }}

+
+ +
+ +
+

{{ _("Feedback Form") }}

+

{{ _("Please tell us what happened if you were able to talk to someone. Your feedback is important to us.") }}

+
+
+
+ + +
+ +
+
+ + +
- -

{{ @call }}

-

{{ _("Please tell us what happened if you were able to talk to someone. Your feedback is important to us.") }}

-

{{ _("Feedback Form") }}

-
- - - - {{ @feedback_category.name }} - -

- -
+ + diff --git a/templates/footer.html b/templates/footer.html index 916c15c..308b1d0 100644 --- a/templates/footer.html +++ b/templates/footer.html @@ -1,6 +1,2 @@ - - - - diff --git a/templates/monitor.html b/templates/monitor.html new file mode 100644 index 0000000..d972fa9 --- /dev/null +++ b/templates/monitor.html @@ -0,0 +1,18 @@ + -- GitLab