r1769 - oipf/emulator/js/contollers
Author: ygrego Date: 2015-07-07 10:14:27 +0000 (Tue, 07 Jul 2015) New Revision: 1769 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1769 Log: Discharge some controllers. Added: oipf/emulator/js/contollers/PanelChannelController.js oipf/emulator/js/contollers/PowerStateController.js oipf/emulator/js/contollers/VideoBroadcastController.js Added: oipf/emulator/js/contollers/PanelChannelController.js =================================================================== --- oipf/emulator/js/contollers/PanelChannelController.js (rev 0) +++ oipf/emulator/js/contollers/PanelChannelController.js 2015-07-07 10:14:27 UTC (rev 1769) @@ -0,0 +1,23 @@ +Controllers.controller("PanelChannelController", + ["$rootScope", "$scope", "VideoBroadcastService", function($rootScope, $scope, VideoBroadcastService) { + $scope.isRequired = false; +// VideoBroadcastService.videoBroadcastObject.currentChannel = {logoURL: ""}; + $scope.videoBroadcastService = VideoBroadcastService; + + $scope.chanLogo = ""; + + $rootScope.$watch("channelInfo", function(newInfo) { + console.group("PanelChannelController"); + if (newInfo) { + console.log("Panel channel info will be activated."); + $scope.chanLogo = $scope.videoBroadcastService.getCurrentChannelLogoUrl(); + $scope.isRequired = true; + + } else if (!newInfo) { + console.log("Panel channel info will be deactivated."); + $scope.isRequired = false; + } + console.groupEnd("PanelChannelController"); + }); + +}]); Added: oipf/emulator/js/contollers/PowerStateController.js =================================================================== --- oipf/emulator/js/contollers/PowerStateController.js (rev 0) +++ oipf/emulator/js/contollers/PowerStateController.js 2015-07-07 10:14:27 UTC (rev 1769) @@ -0,0 +1,62 @@ +Controllers.controller("PowerStateController", + ["$rootScope", "$scope", "$timeout", "ConfigurationService", "ChannelConfigService", + function($rootScope, $scope, $timeout, ConfigurationService, ChannelConfigService) { + + $scope.state = "show"; + $scope.beforeON = false; + $rootScope.systemReady = false; + $scope.configurationService = ConfigurationService; + $scope.channelConfigService = ChannelConfigService; + + $scope.configurationService.configurationObject.localSystem.onPowerStateChange = function(state) { + + if ($scope.waitingState == state && $scope.result) { + if (state == 0) { + console.log("POWER STATE CHANGE: OFF."); + $scope.state = "show"; + $rootScope.systemReady = false; + + } else { + console.log("POWER STATE CHANGE: ON."); + $scope.setSystemReadyAndHideWaitingView(); + } + + } else { + + console.log("POWER STATE CHANGE: ERROR."); + + } + $scope.$apply(); + + console.groupEnd("PowerStateController"); + }; + + $scope.$on("PowerStateChangeEvent", function() { + + console.group("PowerStateController"); + console.log("The power state will change."); + + if ($scope.configurationService.getPowerState() == 0) { + + $scope.waitingState = 1; + $scope.beforeON = true; + $timeout(function() { + $scope.result = $scope.configurationService.setPowerState(1); + }, 3500); + + } else if ($scope.configurationService.getPowerState() == 1) { + + $scope.waitingState = 0; + $scope.result = $scope.configurationService.setPowerState(0); + } + + }); + + $scope.setSystemReadyAndHideWaitingView = function() { + console.log("The system is ready."); + $scope.state = "hidden"; + $rootScope.systemReady = true; + $scope.beforeON = false; + } + +}]); Added: oipf/emulator/js/contollers/VideoBroadcastController.js =================================================================== --- oipf/emulator/js/contollers/VideoBroadcastController.js (rev 0) +++ oipf/emulator/js/contollers/VideoBroadcastController.js 2015-07-07 10:14:27 UTC (rev 1769) @@ -0,0 +1,131 @@ +Controllers.controller("VideoBroadcastController", + ["$rootScope", "$scope", "$timeout", "VideoBroadcastService", "SearchManagerService", "ConfigurationService", + function($rootScope, $scope, $timeout, VideoBroadcastService, SearchManagerService, ConfigurationService) { + + $scope.videoBroadcastService = VideoBroadcastService; + $scope.searchManagerService = SearchManagerService; + $scope.configurationService = ConfigurationService; + + $scope.chanLogo = ""; + + $scope.promiseVolumeView = null; + $scope.volumeClass = "glyphicon-volume-down"; + $scope.currentVolume = $scope.configurationService.configurationObject.localSystem.volume; + + $rootScope.channelInfo = false; + $scope.volumeViewActive = true; + + $scope.setChannelByNumber = function(buttonId) { + $scope.channelNumberActive = true; + + if ($scope.channel.length == 0) { + $timeout(function() { + $scope.channel = $scope.channelNumber.toString(); + $scope.channelNumber = ""; + $scope.channelNumberActive = false; + }, 3000); + } + $scope.channelNumber += buttonId; + + }; + + $scope.$on("ChannelChangeEvent", function(event, changeType) { + console.log(changeType); + }); + + $scope.$on("VolumeEvent", function(event, changeType) { + console.log("A VolumeEvent has been received: The volume will change."); + console.log("Activation of volume view."); + + if (changeType == "V+") { + $scope.volumeClass = "glyphicon-volume-up"; + + } else if (changeType == "V-") { + $scope.volumeClass = "glyphicon-volume-down"; + } + + $scope.volumeViewActive = true; + var result = $scope.videoBroadcastService.setVolume(changeType); + + if (result) { + $scope.currentVolume = $scope.videoBroadcastService.getVolume(); + } + + $scope.promiseVolumeView = $timeout(function() { + console.log("Deactivation of volume view."); + $scope.volumeViewActive = false; + }, 5000); + + }); + + $rootScope.$watch("systemReady", function(isReady) { + + if (isReady) { + console.group("VideoBroadcastController"); + console.log("System ready after power ON: active channel info view"); + var promise = $scope.videoBroadcastService.bindToCurrentChannel.call($scope.videoBroadcastService); + + promise.then(function() { + console.log("VideoBroadcast current channel binding OK."); + console.groupEnd("VideoBroadcastController"); +// $rootScope.channelInfo = true; + $scope.chanLogo = $scope.videoBroadcastService.getCurrentChannelLogoUrl(); + $timeout(function() { + $rootScope.channelInfo = false; + }, 4000); + }) + .then(function() { + return $scope.searchManagerService + ._findCurrentProgramme($scope.videoBroadcastService.getCurrentChannel()); + }) + .then(function() { + console.log("Current programme OK."); + $rootScope.channelInfo = true; + console.groupEnd("VideoBroadcastController"); + $timeout(function() { + $rootScope.channelInfo = false; + }, 4000); + }); + } else { + var promise = $scope.videoBroadcastService.release.call($scope.videoBroadcastService); + promise.then(function() { + console.group("VideoBroadcastController"); + console.log("The video-broadcast object have been released, SYSTEM OFF.") + console.groupEnd("VideoBroadcastController"); + }); + } + + }); + + /*$rootScope.$watch("channelChange", function(type) { + + if (type == "+P") { + console.group("VideoBroadcastController"); + console.log("Require a channel switch up"); + var promise = $scope.videoBroadcastService.prevChannel.call($scope.videoBroadcastService); + + promise.then(function() { + $rootScope.channelInfo = true; + $scope.chanLogo = $scope.videoBroadcastService.getCurrentChannelLogoUrl(); + $timeout(function() { + $rootScope.channelInfo = false; + }, 4000); + }); + + } else { + console.group("VideoBroadcastController"); + console.log("Require a channel switch down"); + var promise = $scope.videoBroadcastService.nextChannel.call($scope.videoBroadcastService); + + promise.then(function() { + $rootScope.channelInfo = true; + $scope.chanLogo = $scope.videoBroadcastService.getCurrentChannelLogoUrl(); + $timeout(function() { + $rootScope.channelInfo = false; + }, 4000); + }); + } + + });*/ + +}]);
participants (1)
-
ygregoï¼ users.nuiton.org