Working cors URL update
This commit is contained in:
parent
7ee9a220af
commit
f9c009a1be
|
@ -26,11 +26,9 @@
|
||||||
<div id="corsSlideToggle">
|
<div id="corsSlideToggle">
|
||||||
<span><strong>CORS URL </strong></span><span id="corsCaret" class="caret"></span><hr/>
|
<span><strong>CORS URL </strong></span><span id="corsCaret" class="caret"></span><hr/>
|
||||||
</div>
|
</div>
|
||||||
<div id="corsFormBody">
|
<div class="form-group">
|
||||||
<div class="form-group">
|
<label class="control-label" for="corsUrl">CORS URLs</label>
|
||||||
<label class="control-label" for="corsURL">CORS URLs</label>
|
<textarea name="corsUrl" class="form-control" id="corsUrl" rows="4" cols="50"></textarea>
|
||||||
<textarea class="form-control" id="corsURL" rows="4" cols="50"></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 9.7 KiB |
|
@ -87,6 +87,7 @@ function formSlide(dir) {
|
||||||
steps = parseInt(stepCount.html());
|
steps = parseInt(stepCount.html());
|
||||||
stepCount.html((dir == "next") ? (steps + 1) : (steps - 1));
|
stepCount.html((dir == "next") ? (steps + 1) : (steps - 1));
|
||||||
hideRMQForm();
|
hideRMQForm();
|
||||||
|
hideCORSForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,6 +113,15 @@ function hideRMQForm() {
|
||||||
$("#advCaret").removeClass("caret-up");
|
$("#advCaret").removeClass("caret-up");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide the RMQ form when the slider is called to avoid showing
|
||||||
|
* scrollbars on slider panels that fit vertically
|
||||||
|
*/
|
||||||
|
function hideCORSForm() {
|
||||||
|
$("#corsFormBody").slideUp(500);
|
||||||
|
$("#corsCaret").removeClass("caret-up");
|
||||||
|
}
|
||||||
|
|
||||||
function submitForm(e, obj) {
|
function submitForm(e, obj) {
|
||||||
resetFeedback();
|
resetFeedback();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
|
@ -22,30 +22,33 @@ require_once(dirname(dirname( __DIR__)) . "/application/models/airtime/om/BaseCc
|
||||||
* Wrapper class for validating and setting up general settings during the installation process
|
* Wrapper class for validating and setting up general settings during the installation process
|
||||||
*/
|
*/
|
||||||
class GeneralSetup extends Setup {
|
class GeneralSetup extends Setup {
|
||||||
static $corsUrl;
|
|
||||||
// airtime.conf section header
|
// airtime.conf section header
|
||||||
protected static $_section = "[general]";
|
protected static $_section = "[general]";
|
||||||
|
|
||||||
|
// Array of key->value pairs for airtime.conf
|
||||||
|
protected static $_properties;
|
||||||
|
|
||||||
// Constant form field names for passing errors back to the front-end
|
// Constant form field names for passing errors back to the front-end
|
||||||
const GENERAL_PORT = "generalPort",
|
const GENERAL_PORT = "generalPort",
|
||||||
GENERAL_HOST = "generalHost";
|
GENERAL_HOST = "generalHost";
|
||||||
const CORS_URL = "corsURL";
|
const CORS_URL = "corsUrl";
|
||||||
|
|
||||||
// Array of key->value pairs for airtime.conf
|
static $cors_url;
|
||||||
protected static $_properties;
|
|
||||||
|
|
||||||
// Message and error fields to return to the front-end
|
// Message and error fields to return to the front-end
|
||||||
static $message = null;
|
static $message = null;
|
||||||
static $errors = array();
|
static $errors = array();
|
||||||
|
|
||||||
function __construct($settings) {
|
function __construct($settings) {
|
||||||
self::$corsUrl = $settings[self::CORS_URL];
|
|
||||||
self::$_properties = array(
|
self::$_properties = array(
|
||||||
"api_key" => $this->generateRandomString(),
|
"api_key" => $this->generateRandomString(),
|
||||||
"base_url" => $settings[self::GENERAL_HOST],
|
"base_url" => $settings[self::GENERAL_HOST],
|
||||||
"base_port" => $settings[self::GENERAL_PORT],
|
"base_port" => $settings[self::GENERAL_PORT],
|
||||||
"cors_url" => $settings[self::CORS_URL]
|
"cors_url" => $settings[self::CORS_URL]
|
||||||
);
|
);
|
||||||
|
self::$cors_url = $settings[self::CORS_URL];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,8 +60,11 @@ class GeneralSetup extends Setup {
|
||||||
if (count(self::$errors) <= 0) {
|
if (count(self::$errors) <= 0) {
|
||||||
$this->writeToTemp();
|
$this->writeToTemp();
|
||||||
}
|
}
|
||||||
$this->setupCorsUrl();
|
if (strlen(self::$cors_url) == 0) {
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->setupCorsUrl();
|
||||||
|
}
|
||||||
return array(
|
return array(
|
||||||
"message" => self::$message,
|
"message" => self::$message,
|
||||||
"errors" => self::$errors
|
"errors" => self::$errors
|
||||||
|
@ -75,7 +81,7 @@ class GeneralSetup extends Setup {
|
||||||
$con = Propel::getConnection();
|
$con = Propel::getConnection();
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
self::$message = "Failed to insert Cors URL; database isn't configured properly!";
|
self::$message = "Failed to insert Cors URL; database isn't configured properly!";
|
||||||
self::$errors[] = self::MEDIA_FOLDER;
|
self::$errors[] = self::CORS_URL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,38 +90,11 @@ class GeneralSetup extends Setup {
|
||||||
|
|
||||||
function runCorsUrlQuery($con) {
|
function runCorsUrlQuery($con) {
|
||||||
try {
|
try {
|
||||||
//Check if key already exists
|
Application_Model_Preference::SetAllowedCorsUrls(self::$cors_url);
|
||||||
$sql = "SELECT valstr FROM cc_pref"
|
|
||||||
." WHERE keystr = 'allowed_cors_urls'";
|
|
||||||
|
|
||||||
$paramMap = array();
|
|
||||||
$paramMap[':key'] = 'allowed_cors_urls';
|
|
||||||
|
|
||||||
$sql .= " FOR UPDATE";
|
|
||||||
|
|
||||||
$result = Application_Common_Database::prepareAndExecute($sql,
|
|
||||||
$paramMap,
|
|
||||||
Application_Common_Database::ROW_COUNT,
|
|
||||||
PDO::FETCH_ASSOC,
|
|
||||||
$con);
|
|
||||||
|
|
||||||
if ($result > 1) {
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$pref = new CcPref();
|
|
||||||
//if (self::$corsUrl != '') {
|
|
||||||
$pref->setKeyStr('allowed_cors_urls')
|
|
||||||
->setValStr(self::$corsUrl)
|
|
||||||
->save();
|
|
||||||
//$pref::setValue('allowed_cors_urls', self::CORS_URL);
|
|
||||||
self::$message = "Saved cors_url";
|
|
||||||
//}
|
|
||||||
Propel::close();
|
Propel::close();
|
||||||
//unset($_SERVER['AIRTIME_CONF']);
|
//unset($_SERVER['AIRTIME_CONF']);
|
||||||
}
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
self::$message = "Failed to insert " . self::$corsUrl . " into cc_pref" . $e;
|
self::$message = "Failed to insert " . self::$cors_url . " into cc_pref" . $e;
|
||||||
self::$errors[] = self::CORS_URL;
|
self::$errors[] = self::CORS_URL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue