-
-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added URL query parameter support for setting configuration
- Loading branch information
Paris Pinkney
committed
Dec 21, 2018
1 parent
c9395c9
commit f36d142
Showing
1 changed file
with
19 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,35 @@ | ||
angular. | ||
module('buildMonitor.settings', [ 'buildMonitor.services', 'rzModule']). | ||
|
||
controller('controlPanel', ['$scope', 'cookieJar', 'townCrier', | ||
function ($scope, cookieJar, townCrier) { | ||
controller('controlPanel', ['$scope', '$window', 'cookieJar', 'townCrier', | ||
function ($scope, $window, cookieJar, townCrier) { | ||
'use strict'; | ||
|
||
$scope.settings.fontSize = cookieJar.get('fontSize', 1); | ||
$scope.settings.numberOfColumns = cookieJar.get('numberOfColumns', 2); | ||
$scope.settings.colourBlind = cookieJar.get('colourBlind', 0); | ||
$scope.settings.reduceMotion = cookieJar.get('reduceMotion', 0); | ||
$scope.settings.showBadges = cookieJar.get('showBadges', 0); | ||
var url = new URL($window.location.href); | ||
var params = new URLSearchParams(url.search); | ||
|
||
var fontSize = params.get('fontSize') || cookieJar.get('fontSize', 1); | ||
var numberOfColumns = params.get('numberOfColumns') || cookieJar.get('numberOfColumns', 2); | ||
var colourBlind = params.get('colourBlind') || cookieJar.get('colourBlind', 0); | ||
var reduceMotion = params.get('reduceMotion') || cookieJar.get('reduceMotion', 0); | ||
var showBadges = params.get('showBadges') || cookieJar.get('showBadges', 0); | ||
|
||
$scope.settings.fontSize = fontSize; | ||
$scope.settings.numberOfColumns = numberOfColumns; | ||
$scope.settings.colourBlind = colourBlind; | ||
$scope.settings.reduceMotion = reduceMotion; | ||
$scope.settings.showBadges = showBadges; | ||
|
||
angular.forEach($scope.settings, function(value, name) { | ||
$scope.$watch('settings.' + name, function(currentValue) { | ||
cookieJar.put(name, currentValue); | ||
params.set(name, currentValue); | ||
}); | ||
}); | ||
|
||
// that's the minimum viable product .. at its tiniest | ||
townCrier.uponNewVersion(function() { | ||
$scope.newVersionAvailable = true; | ||
}); | ||
}]); | ||
} | ||
]); |