From 729046807badb52c446c51315b215ddbfe9bf23b Mon Sep 17 00:00:00 2001 From: Moe Date: Thu, 24 Oct 2024 20:48:02 -0700 Subject: [PATCH] Add Open Next dropdown for WallView --- languages/en_CA.json | 1 + web/assets/css/bs5.wallview.css | 2 +- web/assets/js/bs5.wallview.js | 37 ++++++++++++++++++++++++++++----- web/pages/wallview.ejs | 10 +++++++++ 4 files changed, 44 insertions(+), 6 deletions(-) diff --git a/languages/en_CA.json b/languages/en_CA.json index 3a16f1cb..916deae5 100644 --- a/languages/en_CA.json +++ b/languages/en_CA.json @@ -235,6 +235,7 @@ "Hide List": "Hide List", "Motion GUI": "Motion GUI", "Motion": "Motion", + "Open Next": "Open Next", "Over by": "Over by", "Under by": "Under by", "Global Detector Settings": "Global Detector Settings", diff --git a/web/assets/css/bs5.wallview.css b/web/assets/css/bs5.wallview.css index 21799b36..c88dde2b 100644 --- a/web/assets/css/bs5.wallview.css +++ b/web/assets/css/bs5.wallview.css @@ -16,8 +16,8 @@ #wallview-controls{ position: absolute; - width: 100%; top: 0; + right: 0; padding: 5px; opacity: 0; transition: 0.2s; diff --git a/web/assets/js/bs5.wallview.js b/web/assets/js/bs5.wallview.js index a015a747..bb617c99 100644 --- a/web/assets/js/bs5.wallview.js +++ b/web/assets/js/bs5.wallview.js @@ -1,6 +1,5 @@ var loadedMonitors = {} var selectedMonitors = {} -var selectedMonitorsCount = 0 $(document).ready(function(){ PNotify.prototype.options.styling = "fontawesome"; var wallViewMonitorList = $('#wallview-monitorList') @@ -76,7 +75,6 @@ $(document).ready(function(){ if(numberOfSelected > 3 && !featureIsActivated(true)){ return } - ++selectedMonitorsCount selectedMonitors[monitorId] = Object.assign({}, loadedMonitors[monitorId]); wallViewCanvas.append(`
`) wallViewCanvas.find(`[live-stream="${monitorId}"]`) @@ -98,7 +96,6 @@ $(document).ready(function(){ getMonitorListItem(monitorId).addClass('active') } function deselectMonitor(monitorId){ - --selectedMonitorsCount delete(selectedMonitors[monitorId]) var monitorItem = wallViewCanvas.find(`[live-stream="${monitorId}"]`); monitorItem.find('iframe').attr('src','about:blank') @@ -171,7 +168,7 @@ $(document).ready(function(){ } function displayInfoScreen(){ - if(selectedMonitorsCount === 0){ + if(getCurrentLayout().length === 0){ wallViewInfoScreen.css('display','flex') }else{ wallViewInfoScreen.hide() @@ -239,13 +236,38 @@ $(document).ready(function(){ function openAllMonitors(){ $.each(loadedMonitors,function(monitorId, monitor){ - selectMonitor(monitorId) + var modeAccepted = monitor.mode !== 'stop' && monitor.mode !== 'idle' + if(modeAccepted)selectMonitor(monitorId) }) autoPlaceCurrentMonitorItems() displayInfoScreen() saveLayout() } + function openNextMonitors(numberOf){ + var allLayouts = getAllLayouts() + var ignoreMonitors = [] + var availableMonitors = [] + var numberToOpen = parseInt(numberOf) || 4; + $.each(allLayouts,function(windowName, { layout }){ + $.each(layout,function(n, { monitorId }){ + ignoreMonitors.push(monitorId) + }) + }); + $.each(loadedMonitors,function(monitorId, monitor){ + if(ignoreMonitors.indexOf(monitor.mid) === -1){ + var modeAccepted = monitor.mode !== 'stop' && monitor.mode !== 'idle' + if(modeAccepted)availableMonitors.push(monitorId) + } + }); + for (let i = 0; i < numberToOpen; i++) { + selectMonitor(availableMonitors[i]) + } + autoPlaceCurrentMonitorItems() + displayInfoScreen() + saveLayout() + } + function closeAllMonitors(){ $.each(loadedMonitors,function(monitorId, monitor){ deselectMonitor(monitorId) @@ -301,6 +323,11 @@ $(document).ready(function(){ e.preventDefault() openAllMonitors() }) + .on('click', '.wallview-open-next', function(e){ + e.preventDefault() + var numberOf = $(this).attr('number-of') + openNextMonitors(numberOf) + }) .on('click', '.wallview-close-all', function(e){ e.preventDefault() closeAllMonitors() diff --git a/web/pages/wallview.ejs b/web/pages/wallview.ejs index 204b6dc3..3abf69f4 100644 --- a/web/pages/wallview.ejs +++ b/web/pages/wallview.ejs @@ -63,6 +63,16 @@ <%- lang['Close All'] %> <%- lang['Auto Placement'] %> <%- lang['New Wall Display'] %> +