Addendum 3: Controller Code

The Controller code includes the following code.
angular.module(‘myApp’, [‘app-ip’])
    .controller(‘HomeCtrl’, function ($scope, $http) {
        $scope.info = {};
        $scope.buttonpressed = false;
        $scope.c = 0;
        $scope.PrefixRemoved = 0;
        $scope.PrefixFound = 0;
        $scope.AddaPrefix = 0;
        $scope.PrefixAdded = 0;
        $scope.DeleteAPrefix = 0;
        $scope.PrefixRemain = 1000;
        $scope.validaddress = false;
        $scope.showAdd = true;
        $scope.repush = false;
        $scope.repushed = false;
        $scope.PhaseOne = true;
        $scope.DBSearched = false;
        $scope.AddSuccess = 0;
        $scope.PushedErr = false;
        $scope.PrefixCopied = 0;
        $scope.ReadOnly = true;
        $scope.info.nexthop = “null”
        $scope.info.aspath = “null”
        $scope.info.localpref = “null”
        $scope.info.prefix = “null”
        $scope.info.neighbor = “null”
        $scope.info.opnotes = “null”
        $scope.Repush = function () {
            $scope.PhaseOne = false
            $scope.repush = true
            $http({
                method: ‘POST’,
                url: ‘/repush’,
            }).then(function (response) {
                results = response.data
                $scope.PrefixCopied = results[‘result’]
                $scope.repushed = results[‘pushed’]
                $scope.PreFix = results[‘prefix’]
                $scope.NHop = results[‘nhop’]
                $scope.PushedErr = results[‘pusherr’]
                $scope.message = results[‘msg’]
            }, function (error) {
                $scope.PushedErr = results[‘pusherr’]
                $scope.status = results[‘stat’]
                $scope.message = results[‘msg’]
            });
        }
        $scope.selectentry = function () {
            $scope.info.prefix = $scope.ipAddress1
            $scope.buttonpressed = true
            $http({
                method: ‘POST’,
                url: ‘/SearchPrefix’,
                data: {
                    info: $scope.info
                }
            }).then(function (response) {
                results = response.data
                var myWindow = window.open(“”, “popup”, “width=200,height=100”);
                myWindow.document.write(“<p>” + results[‘result’] + ” ” + results[‘message’] + “</p>”);
                $scope.PrefixFound = results[‘result’]
            }, function (error) {
                var myWindow = window.open(“”, “popup”, “width=200,height=100”);
                myWindow.document.write(“<p>” + results[‘message’] + “</p>”);
            });
        }
        $scope.Addentry = function () {
            $scope.AddaPrefix = 1
        }
        $scope.Removeentry = function () {
            $scope.DeleteAPrefix = 1
        }
        $scope.DBaseSearch = function () {
            $scope.PhaseOne = false
            $scope.repush = false
            $scope.DBSearched = true
        }
        $scope.DenounceEntry = function () {
            $scope.testout = $scope.info.prefix
            $http({
                method: ‘POST’,
                url: ‘/RemovePrefix’,
                data: {
                    info: $scope.info
                }
            }).then(function (response) {
                results = response.data
                $scope.PrefixRemain = results[‘result’]
            }, function (error) {
                console.log(error);
            });
        }
        $scope.AnnouncePrefix = function () {
            $http({
                method: ‘POST’,
                url: ‘/AnnouncePrefix’,
                data: {
                    info: $scope.info
                }
            }).then(function (response) {
                results = response.data
                $scope.AddSuccess = results[‘result’]
                var myWindow = window.open(“”, “popup”, “width=200,height=100”);
                myWindow.document.write(“<p>” + results[‘result’] + ” ” + results[‘message’] + “</p>”);
            }, function (error) {
                console.log(error);
            });
        }
        $scope.SearchPrefix = function () {
            $http({
                method: ‘POST’,
                url: ‘/SearchPrefix’,
                data: {
                    info: $scope.info
                }
            }).then(function (response) {
                results = response.data
                var myWindow = window.open(“”, “popup”, “width=200,height=100”);
                myWindow.document.write(“<p>” + results[‘result’] + ” ” + results[‘message’] + “</p>”);
            }, function (error) {
                console.log(error);
            });
        }
    })