Created
January 21, 2015 16:27
-
-
Save simonmorley/67ee511ab09a79da3498 to your computer and use it in GitHub Desktop.
medium, creating an interceptor to device device types
This file contains hidden or 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
| app.factory('apInterceptor', ['$q', '$location', '$rootScope', '$routeParams', 'DEVICES', | |
| function($q, $location, $rootScope, $routeParams, DEVICES) { | |
| return { | |
| request: function(config) { | |
| var setDevice = function() { | |
| if ($routeParams.uamip !== undefined && $routeParams.uamport !== undefined) { | |
| $rootScope.deviceId = DEVICES.ct; | |
| } else if ( $routeParams.switchip !== undefined && $routeParams.cmd !== undefined ) { | |
| $rootScope.deviceId = DEVICES.aruba; | |
| } else if ( $routeParams.login_url !== undefined && $routeParams.ap_tags !== undefined) { | |
| $rootScope.deviceId = DEVICES.meraki; | |
| } | |
| }; | |
| $rootScope.$on('$routeChangeSuccess', function () { | |
| if ($rootScope.deviceId === undefined) { | |
| setDevice(); | |
| } | |
| }); | |
| return config; | |
| } | |
| }; | |
| } | |
| ]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment