mirror of
https://github.com/GNS3/gns3-registry.git
synced 2025-01-31 16:35:29 +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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var installable_versions = gns3.installableVersions("{{appliance|jsonify|b64encode}}");
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
@ -54,9 +56,11 @@ function download(appliance, md5sum) {
|
|||||||
{{ key }}: {{ appliance["qemu"][key] }}<br />
|
{{ key }}: {{ appliance["qemu"][key] }}<br />
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% for version in appliance["versions"] | reverse %}
|
{% for version in appliance["versions"] | reverse %}
|
||||||
<h2>{{ appliance["name"] }} {{version["name"]}}</h2>
|
<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>
|
<h3>Require files</h3>
|
||||||
{% for image in version.images.values() %}
|
{% for image in version.images.values() %}
|
||||||
<h4>{{image["filename"]}}</h4>
|
<h4>{{image["filename"]}}</h4>
|
||||||
|
@ -27,15 +27,12 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
if (gns3.marketplace_api_version() != 1) {
|
|
||||||
alert("Your client is out of date please update it");
|
|
||||||
}
|
|
||||||
|
|
||||||
function gns3_notif(type, msg) {
|
function gns3_notif(type, msg) {
|
||||||
var notif = $("#notif")
|
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>")
|
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>")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof gns3 !== "undefined") {
|
||||||
gns3.error.connect(function(msg) {
|
gns3.error.connect(function(msg) {
|
||||||
gns3_notif("danger", msg);
|
gns3_notif("danger", msg);
|
||||||
});
|
});
|
||||||
@ -44,6 +41,11 @@
|
|||||||
gns3_notif("success", 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
|
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) {
|
function humanFileSize(bytes) {
|
||||||
var exp = Math.log(bytes) / Math.log(1024) | 0;
|
var exp = Math.log(bytes) / Math.log(1024) | 0;
|
||||||
var result = (bytes / Math.pow(1024, exp)).toFixed(2);
|
var result = (bytes / Math.pow(1024, exp)).toFixed(2);
|
||||||
|
|
||||||
return result + ' ' + (exp == 0 ? 'bytes': 'KMGTPEZY'[exp - 1] + 'B');
|
return result + ' ' + (exp == 0 ? 'bytes': 'KMGTPEZY'[exp - 1] + 'B');
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user