Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stacking service-tiles v2 #25

Merged
merged 2 commits into from
Apr 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions flash/static/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ var updateServices = function() {
};

/**
* This can be wrapped up in a jquery plugin.
* The current visual feedback is not great and will be improved.
* bundleService puts tiles of the same kind into a wrapper element and animates the transition.
* bundleService as well as bundleServices could be nicely encapsulated in a jquery plugin.
*/
var bundleService = function (serviceSelector, interval) {
console.log('bundle ', serviceSelector)
Expand All @@ -73,6 +73,7 @@ var bundleService = function (serviceSelector, interval) {

tiles.each(function (index, obj) {
stacked[index] = $(obj);
stacked[index].append('<div class="tiles-count">' + (index + 1) + ' of ' + tiles.length+ '</div>');
wrapper.append(stacked[index]);
});
$('.dashboard').append(wrapper);
Expand All @@ -87,15 +88,42 @@ var bundleService = function (serviceSelector, interval) {

stacked[currentActive]
.show()
.effect('shake', {distance: 10, times: 1});
.effect('shake', {distance: 10, times: 3});
}

updateStacked();
setInterval(updateStacked, interval)
}

/**
* bundleServices goes over all tiles and finds tiles of the same kind > 1
* The order ot the tiles changes at the moment, tiles with more than one tile
* are appended to the end.
*/
function bundleServices() {
var serviceTiles = $('.service-tile');
var cssClassTotals = {}

serviceTiles.each(function (index, obj) {
$(obj).attr('class').match(/.*-tile/)[0].split(/\s+/).forEach(function (cssClass) {
if (cssClass === 'service-tile') return;
if (!cssClassTotals[cssClass]) cssClassTotals[cssClass] = 0;
cssClassTotals[cssClass] += 1;
})
})

for (var cssClass in cssClassTotals) {
if (cssClassTotals.hasOwnProperty(cssClass)) {
if (cssClassTotals[cssClass] > 1) {
var cssSelector = '.' + cssClass;
bundleService(cssSelector, 10000);
}
}
}
}

$(document).ready(function () {
bundleService('.tracker-tile', 10000);
bundleServices();
updateServices();
setInterval(updateServices, 60000);
});
9 changes: 5 additions & 4 deletions flash/static/styles/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,13 @@ h1 {

.service-tile {
background: rgba(165, 165, 165, 0.1);
border-left: 15px solid rgb(66, 66, 66);
border-radius: 5px;
font-size: 1.8rem;
margin: 40px 0;
padding: 1rem;
}

.service-tile {
border-left: 15px solid rgb(66, 66, 66);
}

.service-tile.tile-ok {
border-left: 15px solid rgb(52, 123, 52);
}
Expand All @@ -46,6 +43,10 @@ h1 {
width: 98%;
}

.tiles-count {
text-align: center;
}

.pane {
display: flex;
height: 200px;
Expand Down