diff --git a/gui/dashboard/app.svelte b/gui/dashboard/app.svelte
index e12b8c7..5307229 100644
--- a/gui/dashboard/app.svelte
+++ b/gui/dashboard/app.svelte
@@ -7,13 +7,17 @@
const [ send, receive ] = shuffle;
let size = ($settings.cols || 4) * ($settings.rows || 3);
+ let placesLeft = size;
let pageNum = -1;
+ let pageCount = 1;
+ let pageCountFreePlaces = 1;
let tiles = [];
let time = '';
let globalData = {};
let resizeTimer;
let automaticallyProportionalised = false;
let hasData = false;
+ let centerEl;
function onResize() {
clearTimeout(resizeTimer);
@@ -21,9 +25,8 @@
}
function proportionalGrid() {
- const container = document.querySelector('.center');
- const w = container.clientWidth;
- const h = container.clientHeight;
+ const w = centerEl.clientWidth;
+ const h = centerEl.clientHeight;
const tileW = 400;
const tileH = 300;
const availableCols = Math.floor(w / tileW);
@@ -67,16 +70,18 @@
const { servicesUp, servicesDown, servicesUnknown, total } = globalData;
const upOrUnknown = [ ...servicesUp, ...servicesUnknown ];
servicesTemp = servicesDown.slice(0, size);
+ pageCount = Math.ceil(upOrUnknown.length / size);
+ placesLeft = size - servicesTemp.length;
+ pageCountFreePlaces = Math.ceil(upOrUnknown.length / placesLeft);
if (pageNum === -1 || total >= size) {
pageNum++;
- if (pageNum > Math.ceil(upOrUnknown.length / size)) {
+ if (pageNum > pageCount) {
pageNum = 0;
}
}
- const placesLeft = size - servicesTemp.length;
const offset = placesLeft * pageNum;
if (placesLeft > 0) {
servicesTemp.push(
@@ -122,7 +127,7 @@
}, 100);
settings.subscribe(s => {
- size = (s.cols || 4) * (s.rows || 3) - 1;
+ size = (s.cols || 4) * (s.rows || 3);
if (hasData) organiseGrid();
});
@@ -131,23 +136,37 @@