From a4d2e37cc249136d9504cd597afa65d18f14236d Mon Sep 17 00:00:00 2001 From: erikphillips Date: Tue, 21 Feb 2017 18:59:58 -0800 Subject: [PATCH 1/5] fixing issue 47 by checking for current channel --- common/js/ogAPI2.js | 8 +++++-- .../directives/StationCell.directive.js | 21 +++++++++++++++++-- .../app/components/guide/guide.controller.js | 4 ++-- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/common/js/ogAPI2.js b/common/js/ogAPI2.js index 48d6172..897f893 100644 --- a/common/js/ogAPI2.js +++ b/common/js/ogAPI2.js @@ -588,11 +588,15 @@ var GLOBAL_UPDATE_TARGET; service.getNowAndNext = function () { return $http.get( API_PATH + 'tv/currentgrid' ) .then(stripData); - } + }; service.changeChannel = function ( channelNum ) { return $http.post( API_PATH + 'tv/change/' + channelNum ); - } + }; + + service.getCurrentChannel = function () { + return $http.get( API_PATH + 'tv/currentchannel'); + }; return service; } ) diff --git a/control/app/components/directives/StationCell.directive.js b/control/app/components/directives/StationCell.directive.js index 77ddadb..ac35198 100644 --- a/control/app/components/directives/StationCell.directive.js +++ b/control/app/components/directives/StationCell.directive.js @@ -28,8 +28,25 @@ app.directive( 'stationCell', var hud = uibHelper.curtainModal( 'Changing...' ); $log.debug( "Changing channel to: " + scope.grid.channel.channelNumber ); ogProgramGuide.changeChannel( scope.grid.channel.channelNumber ); - $rootScope.currentChannel = scope.grid; - $timeout(function(){ hud.dismiss() }, 5000); + $rootScope.tempCurrentChannel = scope.grid; + $timeout(function() { + ogProgramGuide.getCurrentChannel() + .then(function ( channel ) { + if ($rootScope.tempCurrentChannel.channel.channelNumber != channel.data.channelNumber) { + $log.debug("channel numbers do NOT match!"); + hud.dismiss(); + uibHelper.headsupModal('Unable to Change Channel', 'The channel change was unsuccessful. You are not subscribed to the channel.'); + } else { + $log.debug("channel change successful"); + $rootScope.currentChannel = $rootScope.tempCurrentChannel; + hud.dismiss(); + } + }) + .catch(function ( err ) { + hud.dismiss(); + uibHelper.headsupModal('Error', 'An error has occurred while getting the current channel.'); + }) + }, 5000); } diff --git a/control/app/components/guide/guide.controller.js b/control/app/components/guide/guide.controller.js index f619b01..f94a9eb 100644 --- a/control/app/components/guide/guide.controller.js +++ b/control/app/components/guide/guide.controller.js @@ -17,7 +17,7 @@ app.controller( "guideController", $rootScope.currentChannel = {}; - function getCurrentChannel() { + function getCurrentProgramming() { return ogProgramGuide.getNowAndNext() .then(function (grid) { $log.debug("Got the grid and current channel."); @@ -25,7 +25,7 @@ app.controller( "guideController", }); } - getCurrentChannel(); + getCurrentProgramming(); function loadListings(){ ogNet.getGrid(false) From 6ffc2b68e5548958dd58b63de397575cf0a668df Mon Sep 17 00:00:00 2001 From: erikphillips Date: Wed, 22 Feb 2017 18:14:44 -0800 Subject: [PATCH 2/5] updates to station cell channel changing - untested --- common/js/ogAPI2.js | 3 +- .../directives/StationCell.directive.js | 72 +++++++++++++------ 2 files changed, 54 insertions(+), 21 deletions(-) diff --git a/common/js/ogAPI2.js b/common/js/ogAPI2.js index 897f893..7f2c4b5 100644 --- a/common/js/ogAPI2.js +++ b/common/js/ogAPI2.js @@ -595,7 +595,8 @@ var GLOBAL_UPDATE_TARGET; }; service.getCurrentChannel = function () { - return $http.get( API_PATH + 'tv/currentchannel'); + return $http.get( API_PATH + 'tv/currentchannel') + .then(stripData); }; return service; diff --git a/control/app/components/directives/StationCell.directive.js b/control/app/components/directives/StationCell.directive.js index ac35198..a7e2e0d 100644 --- a/control/app/components/directives/StationCell.directive.js +++ b/control/app/components/directives/StationCell.directive.js @@ -27,28 +27,60 @@ app.directive( 'stationCell', var hud = uibHelper.curtainModal( 'Changing...' ); $log.debug( "Changing channel to: " + scope.grid.channel.channelNumber ); - ogProgramGuide.changeChannel( scope.grid.channel.channelNumber ); - $rootScope.tempCurrentChannel = scope.grid; - $timeout(function() { - ogProgramGuide.getCurrentChannel() - .then(function ( channel ) { - if ($rootScope.tempCurrentChannel.channel.channelNumber != channel.data.channelNumber) { - $log.debug("channel numbers do NOT match!"); - hud.dismiss(); - uibHelper.headsupModal('Unable to Change Channel', 'The channel change was unsuccessful. You are not subscribed to the channel.'); - } else { - $log.debug("channel change successful"); - $rootScope.currentChannel = $rootScope.tempCurrentChannel; - hud.dismiss(); - } - }) - .catch(function ( err ) { + ogProgramGuide.changeChannel( scope.grid.channel.channelNumber ) + .then( function () { + return $timeout(5000); + }) + .then( function () { + return ogProgramGuide.getCurrentChannel(); + }) + .then( function( channel ) { + if ( scope.grid.channel.channelNumber != channel.channelNumber ) { + $log.debug("channel numbers do NOT match!"); hud.dismiss(); - uibHelper.headsupModal('Error', 'An error has occurred while getting the current channel.'); - }) - }, 5000); + uibHelper.headsupModal('Unable to Change Channel', 'The channel change was unsuccessful. You are not subscribed to the channel.'); + } else { + $log.debug("channel change successful"); + $rootScope.currentChannel = scope.grid; // ERIK: is this allowed? will scope.grid be preserved in the async call? + hud.dismiss(); + } + }) + .catch( function ( err ) { + hud.dismiss(); + switch ( err.status ) { + case 406: + uibHelper.headsupModal( "Problem Changing Channel", "There was an issue with changing the channel and your request could not be completed."); + break; + case 500: + uibHelper.headsupModal( "Internal Server Error", "The device was not able to change the channel."); + break; + default: + uibHelper.headsupModal( "Error: Unable to connect", "Unable to connect to the system. Please check wifi connection and try again."); + break; + } + }); - } + // $rootScope.tempCurrentChannel = scope.grid; + // $timeout(function() { + // ogProgramGuide.getCurrentChannel() + // .then(function ( channel ) { + // if ($rootScope.tempCurrentChannel.channel.channelNumber != channel.data.channelNumber) { + // $log.debug("channel numbers do NOT match!"); + // hud.dismiss(); + // uibHelper.headsupModal('Unable to Change Channel', 'The channel change was unsuccessful. You are not subscribed to the channel.'); + // } else { + // $log.debug("channel change successful"); + // $rootScope.currentChannel = $rootScope.tempCurrentChannel; + // hud.dismiss(); + // } + // }) + // .catch(function ( err ) { + // hud.dismiss(); + // uibHelper.headsupModal('Error', 'An error has occurred while getting the current channel.'); + // }) + // }, 5000); + + }; scope.displayTime = function ( timeStr) { From 387b3a2d6e67c3adec3f4554a4a28cbd44de4dd0 Mon Sep 17 00:00:00 2001 From: erikphillips Date: Wed, 22 Feb 2017 18:15:25 -0800 Subject: [PATCH 3/5] updates to station cell channel changing - untested --- control/app/components/directives/StationCell.directive.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/control/app/components/directives/StationCell.directive.js b/control/app/components/directives/StationCell.directive.js index a7e2e0d..56448fa 100644 --- a/control/app/components/directives/StationCell.directive.js +++ b/control/app/components/directives/StationCell.directive.js @@ -41,7 +41,7 @@ app.directive( 'stationCell', uibHelper.headsupModal('Unable to Change Channel', 'The channel change was unsuccessful. You are not subscribed to the channel.'); } else { $log.debug("channel change successful"); - $rootScope.currentChannel = scope.grid; // ERIK: is this allowed? will scope.grid be preserved in the async call? + $rootScope.currentChannel = scope.grid; // TODO ERIK: is this allowed? will scope.grid be preserved in the async call? hud.dismiss(); } }) From 91f6fbda92bfe19a6f46e6a0391d6da660f5788c Mon Sep 17 00:00:00 2001 From: erikphillips Date: Wed, 22 Feb 2017 18:28:31 -0800 Subject: [PATCH 4/5] updates to station cell channel changing - untested --- control/app/components/directives/StationCell.directive.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/control/app/components/directives/StationCell.directive.js b/control/app/components/directives/StationCell.directive.js index 56448fa..34b47e7 100644 --- a/control/app/components/directives/StationCell.directive.js +++ b/control/app/components/directives/StationCell.directive.js @@ -29,7 +29,7 @@ app.directive( 'stationCell', $log.debug( "Changing channel to: " + scope.grid.channel.channelNumber ); ogProgramGuide.changeChannel( scope.grid.channel.channelNumber ) .then( function () { - return $timeout(5000); + return $timeout(5000); // TODO ERIK: this is untested. Will this work correctly as a $timeout? }) .then( function () { return ogProgramGuide.getCurrentChannel(); From 17cfcd225ccea47449a0d78a756868fb5da09ea0 Mon Sep 17 00:00:00 2001 From: erikphillips Date: Fri, 24 Feb 2017 14:06:34 -0800 Subject: [PATCH 5/5] resolved issue 47 - changing channel will check for success or error --- control/app/components/directives/StationCell.directive.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/control/app/components/directives/StationCell.directive.js b/control/app/components/directives/StationCell.directive.js index 34b47e7..0d1a376 100644 --- a/control/app/components/directives/StationCell.directive.js +++ b/control/app/components/directives/StationCell.directive.js @@ -29,7 +29,7 @@ app.directive( 'stationCell', $log.debug( "Changing channel to: " + scope.grid.channel.channelNumber ); ogProgramGuide.changeChannel( scope.grid.channel.channelNumber ) .then( function () { - return $timeout(5000); // TODO ERIK: this is untested. Will this work correctly as a $timeout? + return $timeout(5000); }) .then( function () { return ogProgramGuide.getCurrentChannel(); @@ -41,7 +41,7 @@ app.directive( 'stationCell', uibHelper.headsupModal('Unable to Change Channel', 'The channel change was unsuccessful. You are not subscribed to the channel.'); } else { $log.debug("channel change successful"); - $rootScope.currentChannel = scope.grid; // TODO ERIK: is this allowed? will scope.grid be preserved in the async call? + $rootScope.currentChannel = scope.grid; hud.dismiss(); } })