From fe4dcc07af812244b85826a963234a85ff72a6ee Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Sun, 14 Apr 2019 09:13:57 -0400 Subject: if all monitors is not saved in profiles, reset layout --- www/js/MontageCtrl.js | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'www/js/MontageCtrl.js') diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js index 5c84d097..b783a4b3 100644 --- a/www/js/MontageCtrl.js +++ b/www/js/MontageCtrl.js @@ -281,7 +281,13 @@ angular.module('zmApp.controllers') } else { //console.log ("POSITION STR IS " + positionsStr); - positions = JSON.parse(positionsStr); + try { + positions = JSON.parse(positionsStr); + } + catch (e) { + NVR.debug ("error parsing profile"); + } + NVR.log("found a packery layout"); layouttype = false; @@ -1635,7 +1641,16 @@ angular.module('zmApp.controllers') ld.packeryPositions = ld.packeryPositionsArray[mName]; ld.currentMontageProfile = mName; $scope.currentProfileName = mName; - //console.log ("NEW POS="+ld.packeryPositions); + console.log ("NEW POS="+ld.packeryPositions); + + if (!ld.packeryPositions) { + ld.packeryPositions = []; + NVR.debug ("This profile doesn't seem to have been saved. Resetting it to defaults..."); + $scope.resetSizes(true); + + } + + NVR.setLogin(ld); @@ -1818,6 +1833,7 @@ angular.module('zmApp.controllers') // if you are saving to default all monitor profile // then I will undo any hidden monitors if ($scope.data.montageName == $translate.instant('kMontageDefaultProfile')) { + NVR.debug ("All monitors is special, unhiding all"); for (var p = 0; p < getMonPos.length; p++) { //console.log ("CHECK"); if (getMonPos[p].display != 'show') { @@ -1829,7 +1845,7 @@ angular.module('zmApp.controllers') var pos = JSON.stringify(getMonPos); - //console.log ("SAVING POS = "+pos); + // console.log ("SAVING POS = "+pos); ld.packeryPositionsArray[$scope.data.montageName] = pos; NVR.debug("Saving " + $scope.data.montageName + " with:" + pos); @@ -2327,9 +2343,12 @@ angular.module('zmApp.controllers') }); - $scope.resetSizes = function () { + $scope.resetSizes = function (unhideAll) { var somethingReset = false; for (var i = 0; i < $scope.MontageMonitors.length; i++) { + if (unhideAll) { + $scope.MontageMonitors[i].Monitor.listDisplay = 'show'; + } if ($scope.isDragabillyOn) { if ($scope.MontageMonitors[i].Monitor.selectStyle == "dragborder-selected") { $scope.MontageMonitors[i].Monitor.gridScale = "50"; -- cgit v1.2.3