1
0
mirror of https://github.com/nerzhul/ocsms.git synced 2025-06-07 07:56:23 +00:00

Load the country settings at app load

This commit is contained in:
Loic Blot 2015-02-16 13:18:48 +00:00
parent 3774653643
commit 77a9e9cccf
4 changed files with 23 additions and 1 deletions

View File

@ -25,4 +25,5 @@ $application->registerRoutes($this, array('routes' => array(
array('name' => 'sms#check_new_messages', 'url' => '/get/new_messages', 'verb' => 'GET'), array('name' => 'sms#check_new_messages', 'url' => '/get/new_messages', 'verb' => 'GET'),
array('name' => 'sms#get_api_version', 'url' => '/get/apiversion', 'verb' => 'GET'), array('name' => 'sms#get_api_version', 'url' => '/get/apiversion', 'verb' => 'GET'),
array('name' => 'sms#set_country', 'url'=> '/set/country', 'verb' => 'POST'), array('name' => 'sms#set_country', 'url'=> '/set/country', 'verb' => 'POST'),
array('name' => 'sms#get_country', 'url'=> '/get/country', 'verb' => 'GET'),
))); )));

View File

@ -314,4 +314,15 @@ class SmsController extends Controller {
$this->configMapper->set("country", $country); $this->configMapper->set("country", $country);
return new JSONResponse(array("status" => true, "msg" => "OK")); return new JSONResponse(array("status" => true, "msg" => "OK"));
} }
/**
* @NoAdminRequired
*/
function getCountry() {
$country = $this->configMapper->getKey("country");
if ($country === false) {
return new JSONResponse(array("status" => false));
}
return new JSONResponse(array("status" => true, "country" => $country));
}
} }

View File

@ -368,6 +368,15 @@ function desktopNotify(msg) {
} }
} }
function fetchInitialSettings() {
$.getJSON(OC.generateUrl('/apps/ocsms/get/country'), function(jsondata, status) {
if (jsondata['status'] == true) {
$('#sel_intl_phone').val(jsondata["country"]);
}
else {
}
});
}
(function ($, OC) { (function ($, OC) {
$(document).ready(function () { $(document).ready(function () {
// Register real title // Register real title
@ -393,6 +402,7 @@ function desktopNotify(msg) {
} }
}); });
fetchInitialSettings();
initDesktopNotifies(); initDesktopNotifies();
setInterval(refreshConversation, 10000); setInterval(refreshConversation, 10000);
setInterval(checkNewMessages, 10000); setInterval(checkNewMessages, 10000);

View File

@ -20,7 +20,7 @@ use \OCA\OcSms\Lib\CountryCodes;
<button name="app settings" class="settings-button" data-apps-slide-toggle="#app-settings-content"></button> <button name="app settings" class="settings-button" data-apps-slide-toggle="#app-settings-content"></button>
</div> </div>
<div id="app-settings-content"> <div id="app-settings-content">
<select name="intl_phone"> <select name="intl_phone" id="sel_intl_phone">
<?php foreach (CountryCodes::$codes as $code => $cval) { ?> <?php foreach (CountryCodes::$codes as $code => $cval) { ?>
<option><?php p($code); ?></option> <option><?php p($code); ?></option>
<?php } ?> <?php } ?>