mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-18 18:44:44 +00:00
firmware: allow to select the release family
This commit is contained in:
parent
0a5da792eb
commit
2b991cffec
@ -716,7 +716,16 @@ class FirmwareController extends ApiControllerBase
|
||||
$flavours['libressl'] = 'LibreSSL';
|
||||
$flavours['latest'] = 'OpenSSL';
|
||||
|
||||
return array("mirrors"=>$mirrors, "flavours" => $flavours, 'has_subscription' => $has_subscription);
|
||||
$families = array();
|
||||
$families[''] = gettext('Production');
|
||||
$families['devel'] = gettext('Development');
|
||||
|
||||
return array(
|
||||
'has_subscription' => $has_subscription,
|
||||
'flavours' => $flavours,
|
||||
'families' => $families,
|
||||
'mirrors' => $mirrors,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -725,15 +734,23 @@ class FirmwareController extends ApiControllerBase
|
||||
*/
|
||||
public function getFirmwareConfigAction()
|
||||
{
|
||||
$config = Config::getInstance()->object();
|
||||
$result = array();
|
||||
$result['mirror'] = '';
|
||||
$result['flavour'] = '';
|
||||
|
||||
if (!empty(Config::getInstance()->object()->system->firmware->mirror)) {
|
||||
$result['mirror'] = (string)Config::getInstance()->object()->system->firmware->mirror;
|
||||
$result['flavour'] = '';
|
||||
$result['family'] = '';
|
||||
$result['mirror'] = '';
|
||||
|
||||
if (!empty($config->system->firmware->flavour)) {
|
||||
$result['flavour'] = (string)$config->system->firmware->flavour;
|
||||
}
|
||||
if (!empty(Config::getInstance()->object()->system->firmware->flavour)) {
|
||||
$result['flavour'] = (string)Config::getInstance()->object()->system->firmware->flavour;
|
||||
|
||||
if (!empty($config->system->firmware->family)) {
|
||||
$result['family'] = (string)$config->system->firmware->family;
|
||||
}
|
||||
|
||||
if (!empty($config->system->firmware->mirror)) {
|
||||
$result['mirror'] = (string)$config->system->firmware->mirror;
|
||||
}
|
||||
|
||||
return $result;
|
||||
@ -748,31 +765,40 @@ class FirmwareController extends ApiControllerBase
|
||||
$response = array("status" => "failure");
|
||||
|
||||
if ($this->request->isPost()) {
|
||||
$config = Config::getInstance()->object();
|
||||
|
||||
$response['status'] = 'ok';
|
||||
|
||||
$selectedMirror = filter_var($this->request->getPost("mirror", null, ""), FILTER_SANITIZE_URL);
|
||||
$selectedFlavour = filter_var($this->request->getPost("flavour", null, ""), FILTER_SANITIZE_URL);
|
||||
$selectedFamily = filter_var($this->request->getPost("family", null, ""), FILTER_SANITIZE_URL);
|
||||
$selSubscription = filter_var($this->request->getPost("subscription", null, ""), FILTER_SANITIZE_URL);
|
||||
|
||||
// config data without model, prepare xml structure and write data
|
||||
if (!isset(Config::getInstance()->object()->system->firmware)) {
|
||||
Config::getInstance()->object()->system->addChild('firmware');
|
||||
if (!isset($config->system->firmware)) {
|
||||
$config->system->addChild('firmware');
|
||||
}
|
||||
|
||||
if (!isset(Config::getInstance()->object()->system->firmware->mirror)) {
|
||||
Config::getInstance()->object()->system->firmware->addChild('mirror');
|
||||
if (!isset($config->system->firmware->mirror)) {
|
||||
$config->system->firmware->addChild('mirror');
|
||||
}
|
||||
|
||||
if (empty($selSubscription)) {
|
||||
Config::getInstance()->object()->system->firmware->mirror = $selectedMirror;
|
||||
$config->system->firmware->mirror = $selectedMirror;
|
||||
} else {
|
||||
// prepend subscription
|
||||
Config::getInstance()->object()->system->firmware->mirror = $selectedMirror . '/' . $selSubscription;
|
||||
$config->system->firmware->mirror = $selectedMirror . '/' . $selSubscription;
|
||||
}
|
||||
|
||||
if (!isset(Config::getInstance()->object()->system->firmware->flavour)) {
|
||||
Config::getInstance()->object()->system->firmware->addChild('flavour');
|
||||
if (!isset($config->system->firmware->flavour)) {
|
||||
$config->system->firmware->addChild('flavour');
|
||||
}
|
||||
Config::getInstance()->object()->system->firmware->flavour = $selectedFlavour;
|
||||
$config->system->firmware->flavour = $selectedFlavour;
|
||||
|
||||
if (!isset($config->system->firmware->family)) {
|
||||
$config->system->firmware->addChild('family');
|
||||
}
|
||||
$config->system->firmware->family = $selectedFamily;
|
||||
|
||||
Config::getInstance()->save();
|
||||
|
||||
|
||||
@ -603,6 +603,20 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
);
|
||||
$("#firmware_flavour").selectpicker('refresh');
|
||||
$("#firmware_flavour").change();
|
||||
|
||||
$.each(firmwareoptions.families, function(key, value) {
|
||||
var selected = false;
|
||||
if (key == firmwareconfig['family']) {
|
||||
selected = true;
|
||||
}
|
||||
$("#firmware_family").append($("<option/>")
|
||||
.attr("value",key)
|
||||
.text(value)
|
||||
.prop('selected', selected)
|
||||
);
|
||||
});
|
||||
$("#firmware_family").selectpicker('refresh');
|
||||
$("#firmware_family").change();
|
||||
});
|
||||
});
|
||||
|
||||
@ -633,6 +647,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
var confopt = {};
|
||||
confopt.mirror = $("#firmware_mirror_value").val();
|
||||
confopt.flavour = $("#firmware_flavour_value").val();
|
||||
confopt.family = $("#firmware_family").val();
|
||||
if ($("#firmware_mirror option:selected").data("has_subscription") == true) {
|
||||
confopt.subscription = $("#firmware_mirror_subscription").val();
|
||||
} else {
|
||||
@ -753,6 +768,17 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_family" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> {{ lang._('Release Family') }}</td>
|
||||
<td>
|
||||
<select class="selectpicker" id="firmware_family">
|
||||
</select>
|
||||
<div class="hidden" for="help_for_family">
|
||||
{{ lang._('Select the release family. Use with care.') }}
|
||||
</div>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 150px;"><a id="help_for_mirror_subscription" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> {{ lang._('Subscription') }}</td>
|
||||
<td>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user