Commit a2323c04 authored by Ad Schellevis's avatar Ad Schellevis Committed by Franco Fichtner

(firmware) add subscription option for private repositories

(cherry picked from commit e061374a)
parent 9112ec28
function: "sha256"
fingerprint: "c3cf42fa6dd81c9be7decd2c76d1ee834b903b2f0188c90fa773b60673dd47ae"
......@@ -396,6 +396,7 @@ class FirmwareController extends ApiControllerBase
$mirrors = array();
$mirrors[''] = '(default)';
$mirrors['https://opnsense.aivian.org'] = 'Aivian (Shaoxing, CN)';
$mirrors['https://opnsense-update.deciso.com'] = 'Deciso (NL, Commercial)';
$mirrors['https://mirror.auf-feindgebiet.de/opnsense'] = 'auf-feindgebiet.de (Karlsruhe, DE)';
$mirrors['https://opnsense.c0urier.net'] = 'c0urier.net (Lund, SE)';
//$mirrors['https://fleximus.org/mirror/opnsense'] = 'Fleximus (Roubaix, FR)';
......@@ -408,12 +409,15 @@ class FirmwareController extends ApiControllerBase
$mirrors['http://mirror.ragenetwork.de/opnsense'] = 'RageNetwork (Munich, DE)';
$mirrors['http://mirror.wjcomms.co.uk/opnsense'] = 'WJComms (London, GB)';
$has_subscription = array();
$has_subscription[] = 'https://opnsense-update.deciso.com';
$flavours = array();
$flavours[''] = '(default)';
$flavours['libressl'] = 'LibreSSL';
$flavours['latest'] = 'OpenSSL';
return array("mirrors"=>$mirrors, "flavours" => $flavours);
return array("mirrors"=>$mirrors, "flavours" => $flavours, 'has_subscription' => $has_subscription);
}
/**
......@@ -448,6 +452,7 @@ class FirmwareController extends ApiControllerBase
$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);
$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)) {
......@@ -457,7 +462,13 @@ class FirmwareController extends ApiControllerBase
if (!isset(Config::getInstance()->object()->system->firmware->mirror)) {
Config::getInstance()->object()->system->firmware->addChild('mirror');
}
Config::getInstance()->object()->system->firmware->mirror = $selectedMirror;
if (empty($selSubscription)) {
Config::getInstance()->object()->system->firmware->mirror = $selectedMirror;
} else {
// prepend subscription
Config::getInstance()->object()->system->firmware->mirror = $selectedMirror . '/' . $selSubscription;
}
if (!isset(Config::getInstance()->object()->system->firmware->flavour)) {
Config::getInstance()->object()->system->firmware->addChild('flavour');
......
......@@ -318,6 +318,7 @@ POSSIBILITY OF SUCH DAMAGE.
$("#firmware_mirror").append($("<option/>")
.attr("value",key)
.text(value)
.data("has_subscription", firmwareoptions['has_subscription'].indexOf(key) == 0)
.prop('selected', selected)
);
});
......@@ -325,8 +326,15 @@ POSSIBILITY OF SUCH DAMAGE.
.attr("value", firmwareconfig['mirror'])
.text("(other)")
.data("other", 1)
.data("has_subscription", false)
.prop('selected', other_selected)
);
if ($("#firmware_mirror option:selected").data("has_subscription") == true) {
$("#firmware_mirror_subscription").val(firmwareconfig['mirror'].substr($("#firmware_mirror").val().length+1));
} else {
$("#firmware_mirror_subscription").val("");
}
$("#firmware_mirror").selectpicker('refresh');
$("#firmware_mirror").change();
......@@ -361,6 +369,11 @@ POSSIBILITY OF SUCH DAMAGE.
} else {
$("#firmware_mirror_other").hide();
}
if ($("#firmware_mirror option:selected").data("has_subscription") == true) {
$("#firmware_mirror_subscription").parent().parent().show();
} else {
$("#firmware_mirror_subscription").parent().parent().hide();
}
});
$("#firmware_flavour").change(function() {
$("#firmware_flavour_value").val($(this).val());
......@@ -374,8 +387,13 @@ POSSIBILITY OF SUCH DAMAGE.
$("#change_mirror").click(function(){
$("#change_mirror_progress").addClass("fa fa-spinner fa-pulse");
var confopt = {};
confopt.mirror = $("#firmware_mirror_value").val()
confopt.flavour = $("#firmware_flavour_value").val()
confopt.mirror = $("#firmware_mirror_value").val();
confopt.flavour = $("#firmware_flavour_value").val();
if ($("#firmware_mirror option:selected").data("has_subscription") == true) {
confopt.subscription = $("#firmware_mirror_subscription").val();
} else {
confopt.subscription = null;
}
ajaxCall(url='/api/core/firmware/setFirmwareConfig',sendData=confopt, callback=function(data,status) {
$("#change_mirror_progress").removeClass("fa fa-spinner fa-pulse");
});
......@@ -439,6 +457,18 @@ POSSIBILITY OF SUCH DAMAGE.
</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>
<input type="text" id="firmware_mirror_subscription">
<div class="hidden" for="help_for_mirror_subscription">
<strong>
{{ lang._("Provide subscription key.") }}
</strong>
</div>
</td>
<td></td>
</tr>
<tr>
<td></td>
<td>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment