mirror of
https://github.com/GNS3/gns3-registry.git
synced 2025-01-18 18:56:38 +00:00
Hide install button if we don't have all require files
This commit is contained in:
parent
e73b3d0dfc
commit
1efe06d9f4
@ -12,6 +12,8 @@ function download(appliance, md5sum) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var installable_versions = gns3.installableVersions("{{appliance|jsonify|b64encode}}");
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
@ -54,9 +56,11 @@ function download(appliance, md5sum) {
|
||||
{{ key }}: {{ appliance["qemu"][key] }}<br />
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% for version in appliance["versions"] | reverse %}
|
||||
<h2>{{ appliance["name"] }} {{version["name"]}}</h2>
|
||||
<button class="btn btn-primary btn-lg" type="button" onclick='gns3_button(function() { return gns3.install("{{appliance|jsonify|b64encode}}", "{{version["name"]}}") })'>Install</button>
|
||||
<button class="btn btn-primary btn-lg" id="download_button_{{loop.index}}" type="button">Install</button>
|
||||
<script>gns3_show_if("#download_button_{{loop.index}}", installable_versions.indexOf("{{version["name"]}}") != -1)</script>
|
||||
<h3>Require files</h3>
|
||||
{% for image in version.images.values() %}
|
||||
<h4>{{image["filename"]}}</h4>
|
||||
@ -69,7 +73,7 @@ function download(appliance, md5sum) {
|
||||
Direct download url: <a href="{{image["direct_download_url"]}}">{{image["direct_download_url"]}}</a><br />
|
||||
<button class="btn btn-primary btn-lg" type="button" onclick='return download("{{appliance|jsonify|b64encode}}", "{{image["md5sum"]}}")'>Download</button>
|
||||
{% endif %}
|
||||
<button class="btn btn-primary btn-lg" type="button" onclick="gns3_button(function() { return gns3.importAppliance(); })">Import file</button>
|
||||
<button class="btn btn-primary btn-lg" type="button" onclick="gns3_button(function() { return gns3.importAppliance(); })">Import file</button>
|
||||
<hr />
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
@ -27,22 +27,24 @@
|
||||
</style>
|
||||
|
||||
<script>
|
||||
if (gns3.marketplace_api_version() != 1) {
|
||||
alert("Your client is out of date please update it");
|
||||
}
|
||||
|
||||
function gns3_notif(type, msg) {
|
||||
var notif = $("#notif")
|
||||
notif.append("<div class=\"alert alert-" + type + " alert-dismissible fade in\" role=\"alert\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-label=\"Close\"><span aria-hidden=\"true\">×</span></button>" + msg + "</div>")
|
||||
}
|
||||
|
||||
gns3.error.connect(function(msg) {
|
||||
gns3_notif("danger", msg);
|
||||
});
|
||||
if (typeof gns3 !== "undefined") {
|
||||
gns3.error.connect(function(msg) {
|
||||
gns3_notif("danger", msg);
|
||||
});
|
||||
|
||||
gns3.success.connect(function(msg) {
|
||||
gns3_notif("success", msg);
|
||||
});
|
||||
gns3.success.connect(function(msg) {
|
||||
gns3_notif("success", msg);
|
||||
});
|
||||
|
||||
if (gns3.marketplaceApiVersion() != 1) {
|
||||
alert("Your client is out of date please update it");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Deactivate the button after success click
|
||||
@ -61,12 +63,25 @@
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Show or hide element depending of the test
|
||||
*/
|
||||
gns3_show_if = function(id, test) {
|
||||
if (test) {
|
||||
$(id).show();
|
||||
}
|
||||
else {
|
||||
$(id).hide();
|
||||
}
|
||||
}
|
||||
|
||||
function humanFileSize(bytes) {
|
||||
var exp = Math.log(bytes) / Math.log(1024) | 0;
|
||||
var result = (bytes / Math.pow(1024, exp)).toFixed(2);
|
||||
|
||||
return result + ' ' + (exp == 0 ? 'bytes': 'KMGTPEZY'[exp - 1] + 'B');
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
Loading…
Reference in New Issue
Block a user