2014-01-10 06:36:43 -08:00
|
|
|
'use strict';
|
|
|
|
|
2014-01-17 10:25:15 -08:00
|
|
|
angular.module('insight.address').controller('AddressController',
|
2014-01-20 08:31:37 -08:00
|
|
|
function ($scope, $rootScope, $routeParams, $location, Global, Address, get_socket) {
|
2014-01-13 15:42:15 -08:00
|
|
|
$scope.global = Global;
|
|
|
|
|
|
|
|
$scope.findOne = function() {
|
|
|
|
Address.get({
|
|
|
|
addrStr: $routeParams.addrStr
|
|
|
|
}, function(address) {
|
|
|
|
$scope.address = address;
|
2014-01-20 11:11:35 -08:00
|
|
|
}, function(e) {
|
|
|
|
if (e.status === 400) {
|
|
|
|
$rootScope.flashMessage = 'Invalid Address: ' + $routeParams.addrStr;
|
|
|
|
}
|
|
|
|
else if (e.status === 503) {
|
|
|
|
$rootScope.flashMessage = 'Backend Error. ' + e.data;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$rootScope.flashMessage = 'Address Not Found';
|
|
|
|
}
|
2014-01-17 13:25:48 -08:00
|
|
|
$location.path('/');
|
2014-01-13 15:42:15 -08:00
|
|
|
});
|
|
|
|
};
|
2014-01-20 08:31:37 -08:00
|
|
|
var socket = get_socket($scope);
|
|
|
|
socket.emit('subscribe', $routeParams.addrStr);
|
2014-01-13 15:42:15 -08:00
|
|
|
|
2014-01-14 15:34:01 -08:00
|
|
|
$scope.params = $routeParams;
|
2014-01-20 13:09:18 -08:00
|
|
|
});
|