diff --git a/Layout/default/VoiceCallActive/Index.php b/Layout/default/VoiceCallActive/Index.php new file mode 100644 index 000000000..2b182f9d8 --- /dev/null +++ b/Layout/default/VoiceCallActive/Index.php @@ -0,0 +1,97 @@ + self::getUrl("VoiceCallActive"), + "DASHBOARD_URL" => self::getUrl("Dashboard"), + "MFAPPNAME" => MFAPPNAME_SLUG, + "PAGE_TITLE" => "Active Voice Calls", + "PATH" => [ + ["text" => MFAPPNAME_SLUG, "href" => self::getUrl("Dashboard")], + ["text" => "Active Voice Calls", "href" => self::getUrl("VoiceCallActive")] + ], + "VOICE_CALL_ACTIVE_API_URL" => self::getUrl("VoiceCallActive/api"), +]; + +$additionalJS = ["plugins/vue/vue.js", + "plugins/axios/axios.min.js", + "plugins/vue/tt-components/tt-page-title.js", + "plugins/vue/tt-components/tt-table.js", +]; +$additionalCSS = [ + 'plugins/vue/tt-components/css/tt-table.css', +]; + +include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?> + +
+ + + + + + + + + + +
+ + + + + + + + + + + diff --git a/Layout/default/VoiceCallHistory/Index.php b/Layout/default/VoiceCallHistory/Index.php index d83832ade..fe8392989 100644 --- a/Layout/default/VoiceCallHistory/Index.php +++ b/Layout/default/VoiceCallHistory/Index.php @@ -77,8 +77,9 @@ include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php") methods: { async importCallsFromToday() { this.importCallsFromTodayLoading = true; - await axios.get(window['TT_CONFIG']['VOICE_CALL_HISTORY_API_URL'] + '?do=importCallsFromToday'); - this.$refs.table.fetchData(); + const response = await axios.get(window['TT_CONFIG']['VOICE_CALL_HISTORY_API_URL'] + '?do=importCallsFromToday'); + window.notify(response.data.status === 'success' ? 'success' : 'error', response.data.message); + await this.$refs.table.fetchData(); this.importCallsFromTodayLoading = false; }, } diff --git a/Layout/default/menu.php b/Layout/default/menu.php index 29c440775..1547b0e23 100644 --- a/Layout/default/menu.php +++ b/Layout/default/menu.php @@ -124,9 +124,10 @@ Telefonie
diff --git a/application/VoiceCallActive/VoiceCallActive.php b/application/VoiceCallActive/VoiceCallActive.php new file mode 100644 index 000000000..da22152ae --- /dev/null +++ b/application/VoiceCallActive/VoiceCallActive.php @@ -0,0 +1,9 @@ +loadMe(); + $this->layout()->set("me", $me); + $this->me = $me; + + if (!$this->me->isAdmin()) { + $this->redirect("dashboard"); + } + + $this->kolmisoftMore = new KolmisoftMore($this->VOICE_PORTAL_HOST, $this->VOICE_PORTAL_API_KEY, $this->VOICE_PORTAL_USERNAME); + + } + + protected function indexAction(): void { + $this->layout()->setTemplate("VoiceCallActive/Index"); + } + + protected function apiAction() { + $do = $this->request->do; + + if (!$this->me->isAdmin()) { + $this->redirect("dashboard"); + } + + switch ($do) { + case "getActiveCalls": + $return = $this->getActiveCalls(); + break; + default: + $return = false; + break; + } + + if (!$return) { + $return = [ + "status" => "error", + "message" => "Invalid request." + ]; + } + + die(json_encode($return)); + } + + private function getActiveCalls(): array { + return [ + "rows" => $this->kolmisoftMore->getActiveCalls() + ]; + } +} \ No newline at end of file diff --git a/application/VoiceCallHistory/VoiceCallHistoryController.php b/application/VoiceCallHistory/VoiceCallHistoryController.php index 18139d1dc..51a72f875 100644 --- a/application/VoiceCallHistory/VoiceCallHistoryController.php +++ b/application/VoiceCallHistory/VoiceCallHistoryController.php @@ -1,15 +1,10 @@ kolmisoftMore->getVoiceCallHistory($startDate, $endDate); diff --git a/application/VoiceCallHistoryJob/VoiceCallHistoryJobController.php b/application/VoiceCallHistoryJob/VoiceCallHistoryJobController.php index b805f062f..7eb6a0a5e 100644 --- a/application/VoiceCallHistoryJob/VoiceCallHistoryJobController.php +++ b/application/VoiceCallHistoryJob/VoiceCallHistoryJobController.php @@ -7,9 +7,9 @@ class VoiceCallHistoryJobController extends mfBaseController { private User $me; - private string $VOICE_PORTAL_HOST = "vportal.xinon.at"; - private string $VOICE_PORTAL_API_KEY = "2f9mpw3oamALg7gSgtWUTCKNZ01fFRDh"; - private string $VOICE_PORTAL_USERNAME = "700342020"; + private string $VOICE_PORTAL_HOST = KOLMISOFT_API_HOST; + private string $VOICE_PORTAL_API_KEY = KOLMISOFT_API_KEY; + private string $VOICE_PORTAL_USERNAME = KOLMISOFT_API_USERNAME; private KolmisoftMore $kolmisoftMore; @@ -43,9 +43,6 @@ class VoiceCallHistoryJobController extends mfBaseController { case "runJobs": $return = $this->runJobs(); break; - case "importCallsFromToday": - $return = $this->importCallsFromToday(); - break; default: $return = false; break; diff --git a/config/config.sample.php b/config/config.sample.php index ac1d60149..7b72ae8e3 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -690,4 +690,8 @@ define("TT_MBI_API_KEY", ""); //Raspberry Display Configuration define("XINON_RASPBERRY_DISPLAY_SSH_USER", ""); -define("XINON_RASPBERRY_DISPLAY_SSH_PASS", ""); \ No newline at end of file +define("XINON_RASPBERRY_DISPLAY_SSH_PASS", ""); + +define("TT_KOLMISOFT_API_URL", "vportal.xxx.xx"); +define("TT_KOLMISOFT_API_KEY", ""); +define("TT_KOLMISOFT_API_USERNAME", ""); diff --git a/lib/KolmisoftMore/KolmisoftMore.php b/lib/KolmisoftMore/KolmisoftMore.php index a1c111c23..89c784f53 100644 --- a/lib/KolmisoftMore/KolmisoftMore.php +++ b/lib/KolmisoftMore/KolmisoftMore.php @@ -79,4 +79,22 @@ class KolmisoftMore { } + public function getActiveCalls() { + $queryParameters = ['u' => $this->username]; + + $hash = $this->generateHash($queryParameters); + + $queryParameters['hash'] = $hash; + + $queryString = http_build_query($queryParameters); + + $response = $this->makeRequest('active_calls_get', $queryString); + + if ($response) { + return $response['status']['active_call']; + } else { + return false; + } + } + } \ No newline at end of file diff --git a/public/plugins/vue/tt-components/tt-table.js b/public/plugins/vue/tt-components/tt-table.js index 3f44c7ecf..bbcbff71c 100644 --- a/public/plugins/vue/tt-components/tt-table.js +++ b/public/plugins/vue/tt-components/tt-table.js @@ -143,7 +143,7 @@ Vue.component('tt-table', {