diff --git a/ui/src/app/home/home-links.controller.js b/ui/src/app/home/home-links.controller.js index 799a0bc0b2..32ae0919a3 100644 --- a/ui/src/app/home/home-links.controller.js +++ b/ui/src/app/home/home-links.controller.js @@ -17,7 +17,42 @@ import './home-links.scss'; /*@ngInject*/ -export default function HomeLinksController($scope, menu) { +export default function HomeLinksController($scope, $mdMedia, menu) { + var vm = this; - vm.model = menu.getHomeSections(); + + vm.sectionColspan = sectionColspan; + + $scope.$watch(function() { return $mdMedia('lg'); }, function() { + updateColumnCount(); + }); + + $scope.$watch(function() { return $mdMedia('gt-lg'); }, function() { + updateColumnCount(); + }); + + updateColumnCount(); + + menu.getHomeSections().then((homeSections) => { + vm.model = homeSections; + }); + + function updateColumnCount() { + vm.cols = 2; + if ($mdMedia('lg')) { + vm.cols = 3; + } + if ($mdMedia('gt-lg')) { + vm.cols = 4; + } + } + + function sectionColspan(section) { + var colspan = vm.cols; + if (section && section.places && section.places.length <= colspan) { + colspan = section.places.length; + } + return colspan; + } + } diff --git a/ui/src/app/home/home-links.tpl.html b/ui/src/app/home/home-links.tpl.html index e27f20a820..f0e558257f 100644 --- a/ui/src/app/home/home-links.tpl.html +++ b/ui/src/app/home/home-links.tpl.html @@ -15,8 +15,8 @@ limitations under the License. --> - - + + @@ -25,12 +25,12 @@ - - - {{place.icon}} - {{place.name}} - - + + + {{place.icon}} + {{place.name}} + +