Rotate recently added apps
This commit will rotate the apps displayed in the "Recently Added Apps" section of the front page. This is achieved by sorting the assets array by last modified date, picking the 15 most recent assets, randomizing that list, and then displaying 5 from that randomized list. Co-Authored-By: Ryan Moe <rmoe@mirantis.com> Change-Id: I77c5b4d32ad4c5f45caee2132ed1789e09144c77
This commit is contained in:
parent
6d712a45c2
commit
86fec992dd
@ -97,42 +97,6 @@
|
||||
<p>(Requires OpenStack)</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2 col-sm-6">
|
||||
<div class="inner murano">
|
||||
<a href="#tab=murano-apps&asset=Kubernetes%20Cluster">
|
||||
<img src="static/images/logo-kubernetes.png">
|
||||
<p>Kubernetes</p>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2 col-sm-6">
|
||||
<div class="inner glance">
|
||||
<a href="#tab=glance-images&asset=Chef%20Server">
|
||||
<img src="static/images/Chef-124x90-logo.png">
|
||||
<p>Chef</p></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2 col-sm-6">
|
||||
<div class="inner murano">
|
||||
<a href="#tab=murano-apps&asset=Oracle Pluggable Database">
|
||||
<img src="static/images/logo-oracle.png">
|
||||
<p>Oracle</p></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2 col-sm-6">
|
||||
<div class="inner glance">
|
||||
<a href="#tab=glance-images&asset=Debian%20Jessie%208.0.0%20x64">
|
||||
<img src="static/images/logo-debian.png">
|
||||
<p>Debian</p></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2 col-sm-6">
|
||||
<div class="inner heat">
|
||||
<a href="#tab=heat-templates&asset=OpenShift%20Origin%203">
|
||||
<img src="static/images/logo-openshift.png">
|
||||
<p>OpenShift</p></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row pluginbox">
|
||||
<div class="col-sm-2">
|
||||
|
BIN
openstack_catalog/web/static/images/openstack-icon.png
Normal file
BIN
openstack_catalog/web/static/images/openstack-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
@ -224,6 +224,54 @@ function show_asset (tab, tableData)
|
||||
}
|
||||
}
|
||||
|
||||
var recent_apps = [];
|
||||
|
||||
function build_recently_added ()
|
||||
{
|
||||
assets.assets.sort(function(a,b) {
|
||||
return new Date(b.last_modified) - new Date(a.last_modified);
|
||||
});
|
||||
sorted_assets = assets.assets.slice(0,15);
|
||||
sorted_assets.sort(
|
||||
function() {
|
||||
return 0.5 - Math.random();
|
||||
});
|
||||
for (var i = 0; i < 5; i++) {
|
||||
var iconurl,
|
||||
fittedname,
|
||||
divclass,
|
||||
hreftab;
|
||||
if (typeof (sorted_assets[i].icon) === 'undefined') {
|
||||
iconurl = "static/images/openstack-icon.png";
|
||||
} else {
|
||||
iconurl = sorted_assets[i].icon.url;
|
||||
}
|
||||
if (sorted_assets[i].name.length > 15) {
|
||||
fittedname = sorted_assets[i].name.slice(0,13) + "...";
|
||||
} else
|
||||
{ fittedname = sorted_assets[i].name; }
|
||||
if (sorted_assets[i].service.type == 'glance') {
|
||||
divclass = "glance";
|
||||
hreftab = "#tab=glance-images&asset=";
|
||||
} else if (sorted_assets[i].service.type == 'heat') {
|
||||
divclass = "heat";
|
||||
hreftab = "#tab=heat-templates&asset=";
|
||||
} else if ((sorted_assets[i].service.type == 'murano') ||
|
||||
(sorted_assets[i].service.type == 'bundle')) {
|
||||
divclass = "murano";
|
||||
hreftab = "#tab=murano-apps&asset=";
|
||||
}
|
||||
$('.featured').append(
|
||||
$('<div>', {class: "col-md-2 col-sm-6"})
|
||||
.append($('<div>', {class: "inner " + divclass})
|
||||
.append($("<a>", {href: hreftab + sorted_assets[i].name})
|
||||
.append($('<img>', {src: iconurl, height: 90}))
|
||||
.append($('<p>', {text: fittedname})))
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function initMarketPlace ()
|
||||
{
|
||||
navigate ();
|
||||
@ -245,6 +293,7 @@ function initMarketPlace ()
|
||||
$.ajax({ url: "api/v1/assets" }).
|
||||
done (function (data) {
|
||||
assets = data;
|
||||
build_recently_added ();
|
||||
for (var i = 0; i < assets.assets.length; i++) {
|
||||
var asset = assets.assets[i];
|
||||
if (asset.service.type == 'glance') {
|
||||
@ -263,6 +312,7 @@ function initMarketPlace ()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var tableData;
|
||||
|
||||
tableData = glance_images.assets;
|
||||
|
Loading…
x
Reference in New Issue
Block a user