profile
viewpoint
Lukas Garberg garberg Göteborg, Sweden

plajjan/snabbswitch 8

Snabb Switch: Fast open source packet processing

garberg/bmpd 7

A daemon for the BGP Monitoring Protocol (BMP).

plajjan/spcli 2

A very non-complete CLI - you do not want this

garberg/pybgp 1

A git(hub) copy of pybgp (which is otherwise bzr hosted at launchpad) for easier access.

garberg/SLANG 1

SLANG is a system for accurate measurements of RTT and derived metrics in an IP network.

plajjan/erlang-ripper 1

A RIP daemon written in Erlang - first Erlang project!

garberg/NIPAP 0

Neat IP Address Planner - NIPAP is the best open source IPAM in the known universe, challenging classical IP address management (IPAM) systems in many areas.

garberg/public 0

Repository for publishing OpenConfig models, documentation, and other material for the community.

garberg/py-etherdelta 0

The most up-to-date Python client for interacting with the EtherDelta API and Smart Contracts.

startedios-xr/model-driven-telemetry

started time in 10 days

Pull request review commentSpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

 var nipapAppControllers = angular.module('nipapApp.controllers', []);  */ nipapAppControllers.controller('VRFListController', function ($scope, $http) { -	// Fetch VRFs from backend-	$http.post('/xhr/list_vrf',-		JSON.stringify({}),-		{ 'headers': { 'Content-Type': 'application/json' } })-		.then(function (response) {-			if (response.data.hasOwnProperty('error')) {-				showDialogNotice('Error', response.data.message);-			} else {-				$scope.vrfs = response.data;-			}-		})-		.catch(function (response) {-			var msg = response.data || "Unknown failure";-			showDialogNotice('Error', response.status + ': ' + msg);-		});+	var isSmartSearch;

Can't see this extra indent in my code. It should be a new blank row below "nipapAppControllers.controller('VRFListController', function ($scope, $http) {"

image

I tried to follow how the following method was written: "/*

  • PoolListController - used to list pools on the /pool/list-page */ nipapAppControllers.controller('PoolListController', function ($scope, $http) {" image
BjornPerssonSigma

comment created time in 11 days

Pull request review commentSpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

 var nipapAppControllers = angular.module('nipapApp.controllers', []);  */ nipapAppControllers.controller('VRFListController', function ($scope, $http) { -	// Fetch VRFs from backend-	$http.post('/xhr/list_vrf',-		JSON.stringify({}),-		{ 'headers': { 'Content-Type': 'application/json' } })-		.then(function (response) {-			if (response.data.hasOwnProperty('error')) {-				showDialogNotice('Error', response.data.message);-			} else {-				$scope.vrfs = response.data;-			}-		})-		.catch(function (response) {-			var msg = response.data || "Unknown failure";-			showDialogNotice('Error', response.status + ': ' + msg);-		});+	var isSmartSearch;+    var allVrfs;+    var VRF_BATCH_SIZE = 100;+    var smartOffset = 0;++    if ($scope.query === '' || $scope.query === undefined) {+        fetchAllVrfs();+    }++    /*+     * Fetch all Vrfs+     */+    function fetchAllVrfs(){+    $scope.isLoading = true;+    $http.post('/xhr/list_vrf',+        JSON.stringify({}),+        { 'headers': { 'Content-Type': 'application/json' } })+        .then(function (response) {+            if (response.data.hasOwnProperty('error')) {+                showDialogNotice('Error', response.data.message);+            } else {+                allVrfs = response.data;+                $scope.vrfs = allVrfs.slice(0, VRF_BATCH_SIZE);+            }+        })+        .catch(function (response) {+            var msg = response.data || "Unknown failure";+            showDialogNotice('Error', response.status + ': ' + msg);+        });+    $scope.isLoading = false;+    }++    /*+     * Smart search for VRF list+     */+    $scope.smartSearch = function (offset = 0) {+        if ($scope.query === '') {+            return;+        }++        if (offset === 0){+          smartOffset = 0;+        }++        if ($scope.isLoading)+            return;++        var search_q = {

Identifier 'search_q' is not in camel case.

BjornPerssonSigma

comment created time in 11 days

Pull request review commentSpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

 var nipapAppControllers = angular.module('nipapApp.controllers', []);  */ nipapAppControllers.controller('VRFListController', function ($scope, $http) { -	// Fetch VRFs from backend-	$http.post('/xhr/list_vrf',-		JSON.stringify({}),-		{ 'headers': { 'Content-Type': 'application/json' } })-		.then(function (response) {-			if (response.data.hasOwnProperty('error')) {-				showDialogNotice('Error', response.data.message);-			} else {-				$scope.vrfs = response.data;-			}-		})-		.catch(function (response) {-			var msg = response.data || "Unknown failure";-			showDialogNotice('Error', response.status + ': ' + msg);-		});+	var isSmartSearch;+    var allVrfs;+    var VRF_BATCH_SIZE = 100;+    var smartOffset = 0;++    if ($scope.query === '' || $scope.query === undefined) {+        fetchAllVrfs();+    }++    /*+     * Fetch all Vrfs+     */+    function fetchAllVrfs(){+    $scope.isLoading = true;+    $http.post('/xhr/list_vrf',+        JSON.stringify({}),+        { 'headers': { 'Content-Type': 'application/json' } })+        .then(function (response) {+            if (response.data.hasOwnProperty('error')) {+                showDialogNotice('Error', response.data.message);+            } else {+                allVrfs = response.data;+                $scope.vrfs = allVrfs.slice(0, VRF_BATCH_SIZE);+            }+        })+        .catch(function (response) {+            var msg = response.data || "Unknown failure";+            showDialogNotice('Error', response.status + ': ' + msg);+        });+    $scope.isLoading = false;+    }++    /*+     * Smart search for VRF list+     */+    $scope.smartSearch = function (offset = 0) {

'default parameters' is only available in ES6 (use 'esversion: 6').

BjornPerssonSigma

comment created time in 11 days

Pull request review commentSpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

 var nipapAppControllers = angular.module('nipapApp.controllers', []);  */ nipapAppControllers.controller('VRFListController', function ($scope, $http) { -	// Fetch VRFs from backend-	$http.post('/xhr/list_vrf',-		JSON.stringify({}),-		{ 'headers': { 'Content-Type': 'application/json' } })-		.then(function (response) {-			if (response.data.hasOwnProperty('error')) {-				showDialogNotice('Error', response.data.message);-			} else {-				$scope.vrfs = response.data;-			}-		})-		.catch(function (response) {-			var msg = response.data || "Unknown failure";-			showDialogNotice('Error', response.status + ': ' + msg);-		});+	var isSmartSearch;+    var allVrfs;+    var VRF_BATCH_SIZE = 100;+    var smartOffset = 0;++    if ($scope.query === '' || $scope.query === undefined) {+        fetchAllVrfs();+    }++    /*+     * Fetch all Vrfs+     */+    function fetchAllVrfs(){+    $scope.isLoading = true;+    $http.post('/xhr/list_vrf',+        JSON.stringify({}),+        { 'headers': { 'Content-Type': 'application/json' } })+        .then(function (response) {+            if (response.data.hasOwnProperty('error')) {+                showDialogNotice('Error', response.data.message);+            } else {+                allVrfs = response.data;+                $scope.vrfs = allVrfs.slice(0, VRF_BATCH_SIZE);+            }+        })+        .catch(function (response) {+            var msg = response.data || "Unknown failure";+            showDialogNotice('Error', response.status + ': ' + msg);+        });+    $scope.isLoading = false;+    }++    /*+     * Smart search for VRF list+     */+    $scope.smartSearch = function (offset = 0) {+        if ($scope.query === '') {+            return;+        }++        if (offset === 0){+          smartOffset = 0;+        }++        if ($scope.isLoading)+            return;

Expected '{' and instead saw 'return'.

BjornPerssonSigma

comment created time in 11 days

Pull request review commentSpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

 var nipapAppControllers = angular.module('nipapApp.controllers', []);  */ nipapAppControllers.controller('VRFListController', function ($scope, $http) { -	// Fetch VRFs from backend-	$http.post('/xhr/list_vrf',-		JSON.stringify({}),-		{ 'headers': { 'Content-Type': 'application/json' } })-		.then(function (response) {-			if (response.data.hasOwnProperty('error')) {-				showDialogNotice('Error', response.data.message);-			} else {-				$scope.vrfs = response.data;-			}-		})-		.catch(function (response) {-			var msg = response.data || "Unknown failure";-			showDialogNotice('Error', response.status + ': ' + msg);-		});+	var isSmartSearch;+    var allVrfs;+    var VRF_BATCH_SIZE = 100;+    var smartOffset = 0;++    if ($scope.query === '' || $scope.query === undefined) {+        fetchAllVrfs();+    }++    /*+     * Fetch all Vrfs+     */+    function fetchAllVrfs(){+    $scope.isLoading = true;+    $http.post('/xhr/list_vrf',+        JSON.stringify({}),+        { 'headers': { 'Content-Type': 'application/json' } })+        .then(function (response) {+            if (response.data.hasOwnProperty('error')) {+                showDialogNotice('Error', response.data.message);+            } else {+                allVrfs = response.data;+                $scope.vrfs = allVrfs.slice(0, VRF_BATCH_SIZE);+            }+        })+        .catch(function (response) {+            var msg = response.data || "Unknown failure";+            showDialogNotice('Error', response.status + ': ' + msg);+        });+    $scope.isLoading = false;+    }++    /*+     * Smart search for VRF list+     */+    $scope.smartSearch = function (offset = 0) {+        if ($scope.query === '') {+            return;+        }++        if (offset === 0){+          smartOffset = 0;+        }++        if ($scope.isLoading)+            return;++        var search_q = {+            'query_string': $scope.query,+            'max_result': VRF_BATCH_SIZE,+            'offset': offset,+        }+        $scope.isLoading = true;+        $http.post('/xhr/smart_search_vrf',+            JSON.stringify(search_q),+            { 'headers': { 'Content-Type': 'application/json' } })+            .then(function (response) {+                if (offset === 0) {+                    $scope.vrfs = response.data.result;+                } else {+                  $scope.vrfs = $scope.vrfs.concat(response.data.result);+                }+            })+            .catch(function (response) {+                var msg = response.data || "Unknown failure";

Mixed double and single quotes.

BjornPerssonSigma

comment created time in 11 days

Pull request review commentSpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

 var nipapAppControllers = angular.module('nipapApp.controllers', []);  */ nipapAppControllers.controller('VRFListController', function ($scope, $http) { -	// Fetch VRFs from backend-	$http.post('/xhr/list_vrf',-		JSON.stringify({}),-		{ 'headers': { 'Content-Type': 'application/json' } })-		.then(function (response) {-			if (response.data.hasOwnProperty('error')) {-				showDialogNotice('Error', response.data.message);-			} else {-				$scope.vrfs = response.data;-			}-		})-		.catch(function (response) {-			var msg = response.data || "Unknown failure";-			showDialogNotice('Error', response.status + ': ' + msg);-		});+	var isSmartSearch;+    var allVrfs;+    var VRF_BATCH_SIZE = 100;+    var smartOffset = 0;++    if ($scope.query === '' || $scope.query === undefined) {+        fetchAllVrfs();+    }++    /*+     * Fetch all Vrfs+     */+    function fetchAllVrfs(){+    $scope.isLoading = true;+    $http.post('/xhr/list_vrf',+        JSON.stringify({}),+        { 'headers': { 'Content-Type': 'application/json' } })+        .then(function (response) {+            if (response.data.hasOwnProperty('error')) {+                showDialogNotice('Error', response.data.message);+            } else {+                allVrfs = response.data;+                $scope.vrfs = allVrfs.slice(0, VRF_BATCH_SIZE);+            }+        })+        .catch(function (response) {+            var msg = response.data || "Unknown failure";+            showDialogNotice('Error', response.status + ': ' + msg);+        });+    $scope.isLoading = false;+    }++    /*+     * Smart search for VRF list+     */+    $scope.smartSearch = function (offset = 0) {+        if ($scope.query === '') {+            return;+        }++        if (offset === 0){+          smartOffset = 0;+        }++        if ($scope.isLoading)+            return;++        var search_q = {+            'query_string': $scope.query,+            'max_result': VRF_BATCH_SIZE,+            'offset': offset,+        }

Missing semicolon.

BjornPerssonSigma

comment created time in 11 days

Pull request review commentSpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

 var nipapAppControllers = angular.module('nipapApp.controllers', []);  */ nipapAppControllers.controller('VRFListController', function ($scope, $http) { -	// Fetch VRFs from backend-	$http.post('/xhr/list_vrf',-		JSON.stringify({}),-		{ 'headers': { 'Content-Type': 'application/json' } })-		.then(function (response) {-			if (response.data.hasOwnProperty('error')) {-				showDialogNotice('Error', response.data.message);-			} else {-				$scope.vrfs = response.data;-			}-		})-		.catch(function (response) {-			var msg = response.data || "Unknown failure";-			showDialogNotice('Error', response.status + ': ' + msg);-		});+	var isSmartSearch;+    var allVrfs;+    var VRF_BATCH_SIZE = 100;+    var smartOffset = 0;++    if ($scope.query === '' || $scope.query === undefined) {+        fetchAllVrfs();+    }++    /*+     * Fetch all Vrfs+     */+    function fetchAllVrfs(){+    $scope.isLoading = true;+    $http.post('/xhr/list_vrf',+        JSON.stringify({}),+        { 'headers': { 'Content-Type': 'application/json' } })+        .then(function (response) {+            if (response.data.hasOwnProperty('error')) {+                showDialogNotice('Error', response.data.message);+            } else {+                allVrfs = response.data;+                $scope.vrfs = allVrfs.slice(0, VRF_BATCH_SIZE);+            }+        })+        .catch(function (response) {+            var msg = response.data || "Unknown failure";+            showDialogNotice('Error', response.status + ': ' + msg);+        });+    $scope.isLoading = false;+    }++    /*+     * Smart search for VRF list+     */+    $scope.smartSearch = function (offset = 0) {+        if ($scope.query === '') {+            return;+        }++        if (offset === 0){+          smartOffset = 0;+        }++        if ($scope.isLoading)+            return;++        var search_q = {+            'query_string': $scope.query,+            'max_result': VRF_BATCH_SIZE,+            'offset': offset,+        }+        $scope.isLoading = true;+        $http.post('/xhr/smart_search_vrf',+            JSON.stringify(search_q),

Identifier 'search_q' is not in camel case.

BjornPerssonSigma

comment created time in 11 days

Pull request review commentSpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

 var nipapAppControllers = angular.module('nipapApp.controllers', []);  */ nipapAppControllers.controller('VRFListController', function ($scope, $http) { -	// Fetch VRFs from backend-	$http.post('/xhr/list_vrf',-		JSON.stringify({}),-		{ 'headers': { 'Content-Type': 'application/json' } })-		.then(function (response) {-			if (response.data.hasOwnProperty('error')) {-				showDialogNotice('Error', response.data.message);-			} else {-				$scope.vrfs = response.data;-			}-		})-		.catch(function (response) {-			var msg = response.data || "Unknown failure";-			showDialogNotice('Error', response.status + ': ' + msg);-		});+	var isSmartSearch;+    var allVrfs;+    var VRF_BATCH_SIZE = 100;+    var smartOffset = 0;++    if ($scope.query === '' || $scope.query === undefined) {+        fetchAllVrfs();+    }++    /*+     * Fetch all Vrfs+     */+    function fetchAllVrfs(){+    $scope.isLoading = true;+    $http.post('/xhr/list_vrf',+        JSON.stringify({}),+        { 'headers': { 'Content-Type': 'application/json' } })+        .then(function (response) {+            if (response.data.hasOwnProperty('error')) {+                showDialogNotice('Error', response.data.message);+            } else {+                allVrfs = response.data;+                $scope.vrfs = allVrfs.slice(0, VRF_BATCH_SIZE);+            }+        })+        .catch(function (response) {+            var msg = response.data || "Unknown failure";+            showDialogNotice('Error', response.status + ': ' + msg);+        });+    $scope.isLoading = false;+    }++    /*+     * Smart search for VRF list+     */+    $scope.smartSearch = function (offset = 0) {+        if ($scope.query === '') {+            return;+        }++        if (offset === 0){+          smartOffset = 0;+        }++        if ($scope.isLoading)+            return;++        var search_q = {+            'query_string': $scope.query,+            'max_result': VRF_BATCH_SIZE,+            'offset': offset,+        }+        $scope.isLoading = true;+        $http.post('/xhr/smart_search_vrf',+            JSON.stringify(search_q),+            { 'headers': { 'Content-Type': 'application/json' } })+            .then(function (response) {+                if (offset === 0) {+                    $scope.vrfs = response.data.result;+                } else {+                  $scope.vrfs = $scope.vrfs.concat(response.data.result);+                }+            })+            .catch(function (response) {+                var msg = response.data || "Unknown failure";+                showDialogNotice('Error', response.status + ': ' + msg);+            });+        $scope.isLoading = false;+    }

Missing semicolon.

BjornPerssonSigma

comment created time in 11 days

Pull request review commentSpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

 var nipapAppControllers = angular.module('nipapApp.controllers', []);  */ nipapAppControllers.controller('VRFListController', function ($scope, $http) { -	// Fetch VRFs from backend-	$http.post('/xhr/list_vrf',-		JSON.stringify({}),-		{ 'headers': { 'Content-Type': 'application/json' } })-		.then(function (response) {-			if (response.data.hasOwnProperty('error')) {-				showDialogNotice('Error', response.data.message);-			} else {-				$scope.vrfs = response.data;-			}-		})-		.catch(function (response) {-			var msg = response.data || "Unknown failure";-			showDialogNotice('Error', response.status + ': ' + msg);-		});+	var isSmartSearch;+    var allVrfs;+    var VRF_BATCH_SIZE = 100;+    var smartOffset = 0;++    if ($scope.query === '' || $scope.query === undefined) {+        fetchAllVrfs();+    }++    /*+     * Fetch all Vrfs+     */+    function fetchAllVrfs(){+    $scope.isLoading = true;+    $http.post('/xhr/list_vrf',+        JSON.stringify({}),+        { 'headers': { 'Content-Type': 'application/json' } })+        .then(function (response) {+            if (response.data.hasOwnProperty('error')) {+                showDialogNotice('Error', response.data.message);+            } else {+                allVrfs = response.data;+                $scope.vrfs = allVrfs.slice(0, VRF_BATCH_SIZE);+            }+        })+        .catch(function (response) {+            var msg = response.data || "Unknown failure";+            showDialogNotice('Error', response.status + ': ' + msg);+        });+    $scope.isLoading = false;+    }++    /*+     * Smart search for VRF list+     */+    $scope.smartSearch = function (offset = 0) {+        if ($scope.query === '') {+            return;+        }++        if (offset === 0){+          smartOffset = 0;+        }++        if ($scope.isLoading)+            return;++        var search_q = {+            'query_string': $scope.query,+            'max_result': VRF_BATCH_SIZE,+            'offset': offset,+        }+        $scope.isLoading = true;+        $http.post('/xhr/smart_search_vrf',+            JSON.stringify(search_q),+            { 'headers': { 'Content-Type': 'application/json' } })+            .then(function (response) {+                if (offset === 0) {+                    $scope.vrfs = response.data.result;+                } else {+                  $scope.vrfs = $scope.vrfs.concat(response.data.result);+                }+            })+            .catch(function (response) {+                var msg = response.data || "Unknown failure";+                showDialogNotice('Error', response.status + ': ' + msg);+            });+        $scope.isLoading = false;+    }++    // Check and run functionallity based on+    // smart search or loading of all Vrfs+    $scope.checkAndRunNextPage = function() {+        if ($scope.query === '' || typeof $scope.query === "undefined") {

Mixed double and single quotes.

BjornPerssonSigma

comment created time in 11 days

Pull request review commentSpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

 var nipapAppControllers = angular.module('nipapApp.controllers', []);  */ nipapAppControllers.controller('VRFListController', function ($scope, $http) { -	// Fetch VRFs from backend-	$http.post('/xhr/list_vrf',-		JSON.stringify({}),-		{ 'headers': { 'Content-Type': 'application/json' } })-		.then(function (response) {-			if (response.data.hasOwnProperty('error')) {-				showDialogNotice('Error', response.data.message);-			} else {-				$scope.vrfs = response.data;-			}-		})-		.catch(function (response) {-			var msg = response.data || "Unknown failure";-			showDialogNotice('Error', response.status + ': ' + msg);-		});+	var isSmartSearch;+    var allVrfs;+    var VRF_BATCH_SIZE = 100;+    var smartOffset = 0;++    if ($scope.query === '' || $scope.query === undefined) {+        fetchAllVrfs();+    }++    /*+     * Fetch all Vrfs+     */+    function fetchAllVrfs(){+    $scope.isLoading = true;+    $http.post('/xhr/list_vrf',+        JSON.stringify({}),+        { 'headers': { 'Content-Type': 'application/json' } })+        .then(function (response) {+            if (response.data.hasOwnProperty('error')) {+                showDialogNotice('Error', response.data.message);+            } else {+                allVrfs = response.data;+                $scope.vrfs = allVrfs.slice(0, VRF_BATCH_SIZE);+            }+        })+        .catch(function (response) {+            var msg = response.data || "Unknown failure";+            showDialogNotice('Error', response.status + ': ' + msg);+        });+    $scope.isLoading = false;+    }++    /*+     * Smart search for VRF list+     */+    $scope.smartSearch = function (offset = 0) {+        if ($scope.query === '') {+            return;+        }++        if (offset === 0){+          smartOffset = 0;+        }++        if ($scope.isLoading)+            return;++        var search_q = {+            'query_string': $scope.query,+            'max_result': VRF_BATCH_SIZE,+            'offset': offset,+        }+        $scope.isLoading = true;+        $http.post('/xhr/smart_search_vrf',+            JSON.stringify(search_q),+            { 'headers': { 'Content-Type': 'application/json' } })+            .then(function (response) {+                if (offset === 0) {+                    $scope.vrfs = response.data.result;+                } else {+                  $scope.vrfs = $scope.vrfs.concat(response.data.result);+                }+            })+            .catch(function (response) {+                var msg = response.data || "Unknown failure";+                showDialogNotice('Error', response.status + ': ' + msg);+            });+        $scope.isLoading = false;+    }++    // Check and run functionallity based on+    // smart search or loading of all Vrfs+    $scope.checkAndRunNextPage = function() {+        if ($scope.query === '' || typeof $scope.query === "undefined") {+            isSmartSearch = false;+        } else {+            isSmartSearch = true;+        }++        if (typeof $scope.vrfs === "undefined")+            return;++        if(isSmartSearch){+          smartOffset += VRF_BATCH_SIZE;+          $scope.smartSearch(smartOffset);++        } else {+            if(typeof allVrfs === "undefined"){

Mixed double and single quotes.

BjornPerssonSigma

comment created time in 11 days

Pull request review commentSpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

 var nipapAppControllers = angular.module('nipapApp.controllers', []);  */ nipapAppControllers.controller('VRFListController', function ($scope, $http) { -	// Fetch VRFs from backend-	$http.post('/xhr/list_vrf',-		JSON.stringify({}),-		{ 'headers': { 'Content-Type': 'application/json' } })-		.then(function (response) {-			if (response.data.hasOwnProperty('error')) {-				showDialogNotice('Error', response.data.message);-			} else {-				$scope.vrfs = response.data;-			}-		})-		.catch(function (response) {-			var msg = response.data || "Unknown failure";-			showDialogNotice('Error', response.status + ': ' + msg);-		});+	var isSmartSearch;+    var allVrfs;+    var VRF_BATCH_SIZE = 100;+    var smartOffset = 0;++    if ($scope.query === '' || $scope.query === undefined) {+        fetchAllVrfs();+    }++    /*+     * Fetch all Vrfs+     */+    function fetchAllVrfs(){+    $scope.isLoading = true;+    $http.post('/xhr/list_vrf',+        JSON.stringify({}),+        { 'headers': { 'Content-Type': 'application/json' } })+        .then(function (response) {+            if (response.data.hasOwnProperty('error')) {+                showDialogNotice('Error', response.data.message);+            } else {+                allVrfs = response.data;+                $scope.vrfs = allVrfs.slice(0, VRF_BATCH_SIZE);+            }+        })+        .catch(function (response) {+            var msg = response.data || "Unknown failure";+            showDialogNotice('Error', response.status + ': ' + msg);+        });+    $scope.isLoading = false;+    }++    /*+     * Smart search for VRF list+     */+    $scope.smartSearch = function (offset = 0) {+        if ($scope.query === '') {+            return;+        }++        if (offset === 0){+          smartOffset = 0;+        }++        if ($scope.isLoading)+            return;++        var search_q = {+            'query_string': $scope.query,+            'max_result': VRF_BATCH_SIZE,+            'offset': offset,+        }+        $scope.isLoading = true;+        $http.post('/xhr/smart_search_vrf',+            JSON.stringify(search_q),+            { 'headers': { 'Content-Type': 'application/json' } })+            .then(function (response) {+                if (offset === 0) {+                    $scope.vrfs = response.data.result;+                } else {+                  $scope.vrfs = $scope.vrfs.concat(response.data.result);+                }+            })+            .catch(function (response) {+                var msg = response.data || "Unknown failure";+                showDialogNotice('Error', response.status + ': ' + msg);+            });+        $scope.isLoading = false;+    }++    // Check and run functionallity based on+    // smart search or loading of all Vrfs+    $scope.checkAndRunNextPage = function() {+        if ($scope.query === '' || typeof $scope.query === "undefined") {+            isSmartSearch = false;+        } else {+            isSmartSearch = true;+        }++        if (typeof $scope.vrfs === "undefined")

Mixed double and single quotes.

BjornPerssonSigma

comment created time in 11 days

Pull request review commentSpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

 var nipapAppControllers = angular.module('nipapApp.controllers', []);  */ nipapAppControllers.controller('VRFListController', function ($scope, $http) { -	// Fetch VRFs from backend-	$http.post('/xhr/list_vrf',-		JSON.stringify({}),-		{ 'headers': { 'Content-Type': 'application/json' } })-		.then(function (response) {-			if (response.data.hasOwnProperty('error')) {-				showDialogNotice('Error', response.data.message);-			} else {-				$scope.vrfs = response.data;-			}-		})-		.catch(function (response) {-			var msg = response.data || "Unknown failure";-			showDialogNotice('Error', response.status + ': ' + msg);-		});+	var isSmartSearch;+    var allVrfs;+    var VRF_BATCH_SIZE = 100;+    var smartOffset = 0;++    if ($scope.query === '' || $scope.query === undefined) {+        fetchAllVrfs();+    }++    /*+     * Fetch all Vrfs+     */+    function fetchAllVrfs(){+    $scope.isLoading = true;+    $http.post('/xhr/list_vrf',+        JSON.stringify({}),+        { 'headers': { 'Content-Type': 'application/json' } })+        .then(function (response) {+            if (response.data.hasOwnProperty('error')) {+                showDialogNotice('Error', response.data.message);+            } else {+                allVrfs = response.data;+                $scope.vrfs = allVrfs.slice(0, VRF_BATCH_SIZE);+            }+        })+        .catch(function (response) {+            var msg = response.data || "Unknown failure";+            showDialogNotice('Error', response.status + ': ' + msg);+        });+    $scope.isLoading = false;+    }++    /*+     * Smart search for VRF list+     */+    $scope.smartSearch = function (offset = 0) {+        if ($scope.query === '') {+            return;+        }++        if (offset === 0){+          smartOffset = 0;+        }++        if ($scope.isLoading)+            return;++        var search_q = {+            'query_string': $scope.query,+            'max_result': VRF_BATCH_SIZE,+            'offset': offset,+        }+        $scope.isLoading = true;+        $http.post('/xhr/smart_search_vrf',+            JSON.stringify(search_q),+            { 'headers': { 'Content-Type': 'application/json' } })+            .then(function (response) {+                if (offset === 0) {+                    $scope.vrfs = response.data.result;+                } else {+                  $scope.vrfs = $scope.vrfs.concat(response.data.result);+                }+            })+            .catch(function (response) {+                var msg = response.data || "Unknown failure";+                showDialogNotice('Error', response.status + ': ' + msg);+            });+        $scope.isLoading = false;+    }++    // Check and run functionallity based on+    // smart search or loading of all Vrfs+    $scope.checkAndRunNextPage = function() {+        if ($scope.query === '' || typeof $scope.query === "undefined") {+            isSmartSearch = false;+        } else {+            isSmartSearch = true;+        }++        if (typeof $scope.vrfs === "undefined")+            return;

Expected '{' and instead saw 'return'.

BjornPerssonSigma

comment created time in 11 days

Pull request review commentSpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

 var nipapAppControllers = angular.module('nipapApp.controllers', []);  */ nipapAppControllers.controller('VRFListController', function ($scope, $http) { -	// Fetch VRFs from backend-	$http.post('/xhr/list_vrf',-		JSON.stringify({}),-		{ 'headers': { 'Content-Type': 'application/json' } })-		.then(function (response) {-			if (response.data.hasOwnProperty('error')) {-				showDialogNotice('Error', response.data.message);-			} else {-				$scope.vrfs = response.data;-			}-		})-		.catch(function (response) {-			var msg = response.data || "Unknown failure";-			showDialogNotice('Error', response.status + ': ' + msg);-		});+	var isSmartSearch;+    var allVrfs;+    var VRF_BATCH_SIZE = 100;+    var smartOffset = 0;++    if ($scope.query === '' || $scope.query === undefined) {+        fetchAllVrfs();+    }++    /*+     * Fetch all Vrfs+     */+    function fetchAllVrfs(){+    $scope.isLoading = true;+    $http.post('/xhr/list_vrf',+        JSON.stringify({}),+        { 'headers': { 'Content-Type': 'application/json' } })+        .then(function (response) {+            if (response.data.hasOwnProperty('error')) {+                showDialogNotice('Error', response.data.message);+            } else {+                allVrfs = response.data;+                $scope.vrfs = allVrfs.slice(0, VRF_BATCH_SIZE);+            }+        })+        .catch(function (response) {+            var msg = response.data || "Unknown failure";+            showDialogNotice('Error', response.status + ': ' + msg);+        });+    $scope.isLoading = false;+    }++    /*+     * Smart search for VRF list+     */+    $scope.smartSearch = function (offset = 0) {+        if ($scope.query === '') {+            return;+        }++        if (offset === 0){+          smartOffset = 0;+        }++        if ($scope.isLoading)+            return;++        var search_q = {+            'query_string': $scope.query,+            'max_result': VRF_BATCH_SIZE,+            'offset': offset,+        }+        $scope.isLoading = true;+        $http.post('/xhr/smart_search_vrf',+            JSON.stringify(search_q),+            { 'headers': { 'Content-Type': 'application/json' } })+            .then(function (response) {+                if (offset === 0) {+                    $scope.vrfs = response.data.result;+                } else {+                  $scope.vrfs = $scope.vrfs.concat(response.data.result);+                }+            })+            .catch(function (response) {+                var msg = response.data || "Unknown failure";+                showDialogNotice('Error', response.status + ': ' + msg);+            });+        $scope.isLoading = false;+    }++    // Check and run functionallity based on+    // smart search or loading of all Vrfs+    $scope.checkAndRunNextPage = function() {+        if ($scope.query === '' || typeof $scope.query === "undefined") {+            isSmartSearch = false;+        } else {+            isSmartSearch = true;+        }++        if (typeof $scope.vrfs === "undefined")+            return;++        if(isSmartSearch){+          smartOffset += VRF_BATCH_SIZE;+          $scope.smartSearch(smartOffset);++        } else {+            if(typeof allVrfs === "undefined"){+                fetchAllVrfs();+            } else {+                performVrfNextPage(allVrfs);+            }+        }+    }++    // Dynamically adding values to $scope.vrfs if fetched all Vrfs+    function performVrfNextPage(allVrfData) {+        if ($scope.vrfs.length === allVrfData) {+            return;+        }++        if($scope.isLoading)+            return;

Expected '{' and instead saw 'return'.

BjornPerssonSigma

comment created time in 11 days

Pull request review commentSpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

 var nipapAppControllers = angular.module('nipapApp.controllers', []);  */ nipapAppControllers.controller('VRFListController', function ($scope, $http) { -	// Fetch VRFs from backend-	$http.post('/xhr/list_vrf',-		JSON.stringify({}),-		{ 'headers': { 'Content-Type': 'application/json' } })-		.then(function (response) {-			if (response.data.hasOwnProperty('error')) {-				showDialogNotice('Error', response.data.message);-			} else {-				$scope.vrfs = response.data;-			}-		})-		.catch(function (response) {-			var msg = response.data || "Unknown failure";-			showDialogNotice('Error', response.status + ': ' + msg);-		});+	var isSmartSearch;+    var allVrfs;+    var VRF_BATCH_SIZE = 100;+    var smartOffset = 0;++    if ($scope.query === '' || $scope.query === undefined) {+        fetchAllVrfs();+    }++    /*+     * Fetch all Vrfs+     */+    function fetchAllVrfs(){+    $scope.isLoading = true;+    $http.post('/xhr/list_vrf',+        JSON.stringify({}),+        { 'headers': { 'Content-Type': 'application/json' } })+        .then(function (response) {+            if (response.data.hasOwnProperty('error')) {+                showDialogNotice('Error', response.data.message);+            } else {+                allVrfs = response.data;+                $scope.vrfs = allVrfs.slice(0, VRF_BATCH_SIZE);+            }+        })+        .catch(function (response) {+            var msg = response.data || "Unknown failure";+            showDialogNotice('Error', response.status + ': ' + msg);+        });+    $scope.isLoading = false;+    }++    /*+     * Smart search for VRF list+     */+    $scope.smartSearch = function (offset = 0) {+        if ($scope.query === '') {+            return;+        }++        if (offset === 0){+          smartOffset = 0;+        }++        if ($scope.isLoading)+            return;++        var search_q = {+            'query_string': $scope.query,+            'max_result': VRF_BATCH_SIZE,+            'offset': offset,+        }+        $scope.isLoading = true;+        $http.post('/xhr/smart_search_vrf',+            JSON.stringify(search_q),+            { 'headers': { 'Content-Type': 'application/json' } })+            .then(function (response) {+                if (offset === 0) {+                    $scope.vrfs = response.data.result;+                } else {+                  $scope.vrfs = $scope.vrfs.concat(response.data.result);+                }+            })+            .catch(function (response) {+                var msg = response.data || "Unknown failure";+                showDialogNotice('Error', response.status + ': ' + msg);+            });+        $scope.isLoading = false;+    }++    // Check and run functionallity based on+    // smart search or loading of all Vrfs+    $scope.checkAndRunNextPage = function() {+        if ($scope.query === '' || typeof $scope.query === "undefined") {+            isSmartSearch = false;+        } else {+            isSmartSearch = true;+        }++        if (typeof $scope.vrfs === "undefined")+            return;++        if(isSmartSearch){+          smartOffset += VRF_BATCH_SIZE;+          $scope.smartSearch(smartOffset);++        } else {+            if(typeof allVrfs === "undefined"){+                fetchAllVrfs();+            } else {+                performVrfNextPage(allVrfs);+            }+        }+    }

Missing semicolon.

BjornPerssonSigma

comment created time in 11 days

Pull request review commentSpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

 var nipapAppControllers = angular.module('nipapApp.controllers', []);  */ nipapAppControllers.controller('VRFListController', function ($scope, $http) { -	// Fetch VRFs from backend-	$http.post('/xhr/list_vrf',-		JSON.stringify({}),-		{ 'headers': { 'Content-Type': 'application/json' } })-		.then(function (response) {-			if (response.data.hasOwnProperty('error')) {-				showDialogNotice('Error', response.data.message);-			} else {-				$scope.vrfs = response.data;-			}-		})-		.catch(function (response) {-			var msg = response.data || "Unknown failure";-			showDialogNotice('Error', response.status + ': ' + msg);-		});+	var isSmartSearch;+    var allVrfs;+    var VRF_BATCH_SIZE = 100;+    var smartOffset = 0;++    if ($scope.query === '' || $scope.query === undefined) {+        fetchAllVrfs();+    }++    /*+     * Fetch all Vrfs+     */+    function fetchAllVrfs(){+    $scope.isLoading = true;+    $http.post('/xhr/list_vrf',+        JSON.stringify({}),+        { 'headers': { 'Content-Type': 'application/json' } })+        .then(function (response) {+            if (response.data.hasOwnProperty('error')) {+                showDialogNotice('Error', response.data.message);+            } else {+                allVrfs = response.data;+                $scope.vrfs = allVrfs.slice(0, VRF_BATCH_SIZE);+            }+        })+        .catch(function (response) {+            var msg = response.data || "Unknown failure";+            showDialogNotice('Error', response.status + ': ' + msg);+        });+    $scope.isLoading = false;+    }++    /*+     * Smart search for VRF list+     */+    $scope.smartSearch = function (offset = 0) {+        if ($scope.query === '') {+            return;+        }++        if (offset === 0){+          smartOffset = 0;+        }++        if ($scope.isLoading)+            return;++        var search_q = {+            'query_string': $scope.query,+            'max_result': VRF_BATCH_SIZE,+            'offset': offset,+        }+        $scope.isLoading = true;+        $http.post('/xhr/smart_search_vrf',+            JSON.stringify(search_q),+            { 'headers': { 'Content-Type': 'application/json' } })+            .then(function (response) {+                if (offset === 0) {+                    $scope.vrfs = response.data.result;+                } else {+                  $scope.vrfs = $scope.vrfs.concat(response.data.result);+                }+            })+            .catch(function (response) {+                var msg = response.data || "Unknown failure";+                showDialogNotice('Error', response.status + ': ' + msg);+            });+        $scope.isLoading = false;+    }++    // Check and run functionallity based on+    // smart search or loading of all Vrfs+    $scope.checkAndRunNextPage = function() {+        if ($scope.query === '' || typeof $scope.query === "undefined") {+            isSmartSearch = false;+        } else {+            isSmartSearch = true;+        }++        if (typeof $scope.vrfs === "undefined")+            return;++        if(isSmartSearch){+          smartOffset += VRF_BATCH_SIZE;+          $scope.smartSearch(smartOffset);++        } else {+            if(typeof allVrfs === "undefined"){+                fetchAllVrfs();+            } else {+                performVrfNextPage(allVrfs);+            }+        }+    }++    // Dynamically adding values to $scope.vrfs if fetched all Vrfs+    function performVrfNextPage(allVrfData) {+        if ($scope.vrfs.length === allVrfData) {+            return;+        }++        if($scope.isLoading)+            return;++        var lastElementId = $scope.vrfs.length - 1;++        if (lastElementId + VRF_BATCH_SIZE <= allVrfs.length - 1) {+            $scope.vrfs = $scope.vrfs.concat(allVrfs.slice(lastElementId, lastElementId + VRF_BATCH_SIZE));+        }+        else {+            $scope.vrfs = $scope.vrfs.concat(allVrfs.slice(lastElementId, allVrfs.length - 1));

Line is too long.

BjornPerssonSigma

comment created time in 11 days

Pull request review commentSpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

 var nipapAppControllers = angular.module('nipapApp.controllers', []);  */ nipapAppControllers.controller('VRFListController', function ($scope, $http) { -	// Fetch VRFs from backend-	$http.post('/xhr/list_vrf',-		JSON.stringify({}),-		{ 'headers': { 'Content-Type': 'application/json' } })-		.then(function (response) {-			if (response.data.hasOwnProperty('error')) {-				showDialogNotice('Error', response.data.message);-			} else {-				$scope.vrfs = response.data;-			}-		})-		.catch(function (response) {-			var msg = response.data || "Unknown failure";-			showDialogNotice('Error', response.status + ': ' + msg);-		});+	var isSmartSearch;+    var allVrfs;+    var VRF_BATCH_SIZE = 100;+    var smartOffset = 0;++    if ($scope.query === '' || $scope.query === undefined) {+        fetchAllVrfs();+    }++    /*+     * Fetch all Vrfs+     */+    function fetchAllVrfs(){+    $scope.isLoading = true;+    $http.post('/xhr/list_vrf',+        JSON.stringify({}),+        { 'headers': { 'Content-Type': 'application/json' } })+        .then(function (response) {+            if (response.data.hasOwnProperty('error')) {+                showDialogNotice('Error', response.data.message);+            } else {+                allVrfs = response.data;+                $scope.vrfs = allVrfs.slice(0, VRF_BATCH_SIZE);+            }+        })+        .catch(function (response) {+            var msg = response.data || "Unknown failure";+            showDialogNotice('Error', response.status + ': ' + msg);+        });+    $scope.isLoading = false;+    }++    /*+     * Smart search for VRF list+     */+    $scope.smartSearch = function (offset = 0) {+        if ($scope.query === '') {+            return;+        }++        if (offset === 0){+          smartOffset = 0;+        }++        if ($scope.isLoading)+            return;++        var search_q = {+            'query_string': $scope.query,+            'max_result': VRF_BATCH_SIZE,+            'offset': offset,+        }+        $scope.isLoading = true;+        $http.post('/xhr/smart_search_vrf',+            JSON.stringify(search_q),+            { 'headers': { 'Content-Type': 'application/json' } })+            .then(function (response) {+                if (offset === 0) {+                    $scope.vrfs = response.data.result;+                } else {+                  $scope.vrfs = $scope.vrfs.concat(response.data.result);+                }+            })+            .catch(function (response) {+                var msg = response.data || "Unknown failure";+                showDialogNotice('Error', response.status + ': ' + msg);+            });+        $scope.isLoading = false;+    }++    // Check and run functionallity based on+    // smart search or loading of all Vrfs+    $scope.checkAndRunNextPage = function() {+        if ($scope.query === '' || typeof $scope.query === "undefined") {+            isSmartSearch = false;+        } else {+            isSmartSearch = true;+        }++        if (typeof $scope.vrfs === "undefined")+            return;++        if(isSmartSearch){+          smartOffset += VRF_BATCH_SIZE;+          $scope.smartSearch(smartOffset);++        } else {+            if(typeof allVrfs === "undefined"){+                fetchAllVrfs();+            } else {+                performVrfNextPage(allVrfs);+            }+        }+    }++    // Dynamically adding values to $scope.vrfs if fetched all Vrfs+    function performVrfNextPage(allVrfData) {+        if ($scope.vrfs.length === allVrfData) {+            return;+        }++        if($scope.isLoading)+            return;++        var lastElementId = $scope.vrfs.length - 1;++        if (lastElementId + VRF_BATCH_SIZE <= allVrfs.length - 1) {+            $scope.vrfs = $scope.vrfs.concat(allVrfs.slice(lastElementId, lastElementId + VRF_BATCH_SIZE));

Line is too long.

BjornPerssonSigma

comment created time in 11 days

Pull request review commentSpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

+/* ng-infinite-scroll - v1.0.0 - 2013-02-23 +Copyright (c) 2012 Brandon Tilley++Permission is hereby granted, free of charge, to any person+obtaining a copy of this software and associated documentation+files (the "Software"), to deal in the Software without+restriction, including without limitation the rights to use,+copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the+Software is furnished to do so, subject to the following+conditions:++The above copyright notice and this permission notice shall be+included in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR+OTHER DEALINGS IN THE SOFTWARE.*/+var mod;mod=angular.module("infinite-scroll",[]),mod.directive("infiniteScroll",["$rootScope","$window","$timeout",function(i,n,e){return{link:function(t,l,o){var r,c,f,a;return n=angular.element(n),f=0,null!=o.infiniteScrollDistance&&t.$watch(o.infiniteScrollDistance,function(i){return f=parseInt(i,10)}),a=!0,r=!1,null!=o.infiniteScrollDisabled&&t.$watch(o.infiniteScrollDisabled,function(i){return a=!i,a&&r?(r=!1,c()):void 0}),c=function(){var e,c,u,d;return d=n.height()+n.scrollTop(),e=l.offset().top+l.height(),c=e-d,u=n.height()*f>=c,u&&a?i.$$phase?t.$eval(o.infiniteScroll):t.$apply(o.infiniteScroll):u?r=!0:void 0},n.on("scroll",c),t.$on("$destroy",function(){return n.off("scroll",c)}),e(function(){return o.infiniteScrollImmediateCheck?t.$eval(o.infiniteScrollImmediateCheck)?c():void 0:c()},0)}}}]);

Did you mean to return a conditional instead of an assignment?<br>Expected an assignment or function call and instead saw an expression.<br>Line is too long.<br>Missing semicolon.

BjornPerssonSigma

comment created time in 11 days

PR opened SpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

Fix on the VRF page so that users can search before the loading of all data has been made. Have also implemented infinite scroll, that is loading data by scrolling, so that it fits with angular.js.

The change has shortened the loading time and made it possible to search before the initial load has been made. There are still some delay of around 4-6 seconds before the initial load will show on the screen.

License for Infinite scroll has been added to the ng-infinite-scroll.min.js - file.

+146 -22

0 comment

5 changed files

pr created time in 11 days

PR closed SpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

Fix on the VRF page so that users can search before the loading of all data has been made. Have also implemented infinite scroll, that is loading data by scrolling, so that it fits with angular.js.

The change has shortened the loading time and made it possible to search before the initial load has been made. There are still some delay of around 4-6 seconds before the initial load will show on the screen.

License for Infinite scroll has been added to the ng-infinite-scroll.min.js - file.

Ps. used a formating tool hence some changes ragarding spaces etc.

+0 -0

0 comment

0 changed file

BjornPerssonSigma

pr closed time in 11 days

push eventSpriteLink/NIPAP

requires.io

commit sha 487872d48ec5cad361044a174621779bb66d4538

[requires.io] dependency update

view details

push time in 14 days

push eventSpriteLink/NIPAP

requires.io

commit sha 1de1c0e7c1a8ef3466e45781013be1b833e2b317

[requires.io] dependency update

view details

push time in 17 days

Pull request review commentSpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

 nipapAppControllers.controller('PrefixListController', function ($scope, $uibMod  */ nipapAppControllers.controller('PrefixAddController', function ($scope, $routeParams, $http, prefixHelpers, inputValidationHelpers) { -	// prefix method is add - used to customize prefix form template-	$scope.method = 'add';--	// Expose prefixHelpers.enableNodeInput to templates-	$scope.enableNodeInput = prefixHelpers.enableNodeInput;--	// open up the datepicker-	$scope.dpOpen = function($event) {-		$event.preventDefault();-		$event.stopPropagation();--		$scope.dpOpened = !$scope.dpOpened;-	};--	$scope.prefix_alloc_method = null;-	// Set to true if allocation method was provided in URL-	$scope.prefix_alloc_method_provided = false;--	$scope.from_pool = null;-	// Set to true if the pool to allocate from was provided in the URL-	$scope.from_pool_provided = false;--	$scope.from_prefix = null;-	// Set to true if the prefix to allocate from was provided in the URL-	$scope.from_prefix_provided = false;--	// Set to true if pool has a default prefix length for current address family-	$scope.pool_has_default_preflen = false;--	// Keep track on whether the user wants to use the pool's default prefix-	// length or not-	$scope.pool_use_default_preflen = true;-	$scope.pool_default_preflen = null;--	// Keep track of whether the user has chosen to enable the prefix type-	// input fields, when allocating prefix from a pool (ie. to not use the-	// pool's default prefix type)-	$scope.display_type_input_pool = false;--	$scope.prefix_family = 4;-	$scope.prefix_length = null;--	$scope.prefix = {-		prefix: null,-		vrf: null,-		pool: null,-		status: 'assigned',-		description: null,-		comment: null,-		node: null,-		tags: [],-		type: null,-		country: null,-		order_id: null,-		customer_id: null,-		vlan: null,-		monitor: false,-		alarm_priority: null,-		avps: []-	};--	// List of prefixes added to NIPAP-	$scope.added_prefixes = [];--	/*-	 * Handle route parameters (extracted from the URL)-	 */-	// Is allocation method set?-	if ($routeParams.hasOwnProperty('allocation_method')) {-		$scope.prefix_alloc_method = $routeParams.allocation_method;-		$scope.prefix_alloc_method_provided = true;-	}--	// Did we get any allocation parameters (pool ID or prefix ID)?-	if ($routeParams.hasOwnProperty('allocation_method_parameter')) {--		var allocation_parameter = parseInt($routeParams.allocation_method_parameter);--		if ($scope.prefix_alloc_method == 'from-pool') {--			// Allocation method parameter is pool ID - fetch pool-			$scope.from_pool_provided = true;-			$http.post('/xhr/list_pool',-				JSON.stringify({ 'id': allocation_parameter }),-				{ 'headers': { 'Content-Type': 'application/json' } })-				.then(function (response) {-					if (response.data.hasOwnProperty('error')) {-						showDialogNotice('Error', response.data.message);-					} else {-						$scope.from_pool = response.data[0];-					}-				})-				.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-				});--		} else if ($scope.prefix_alloc_method == 'from-prefix') {--			// Allocation method parameter is prefix ID - fetch prefix-			$scope.from_prefix_provided = true;-			$http.post('/xhr/list_prefix',-				JSON.stringify({ 'id': allocation_parameter }),-				{ 'headers': { 'Content-Type': 'application/json' } })-				.then(function (response) {-					if (response.data.hasOwnProperty('error')) {-						showDialogNotice('Error', response.data.message);-					} else {-						$scope.from_prefix = response.data[0];-						$scope.prefix_family = response.data[0].family;-					}-				})-				.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-				});-		}-	}--	/*-	 * Watch for change to 'from_pool' and 'prefix_family' variables-	 */-	$scope.$watchCollection('[ from_pool, prefix_family ]', function(newValue, oldValue){--		if ($scope.from_pool !== null) {--			// We're allocating from a pool - reset from_prefix-			$scope.from_prefix = null;--			if ($scope.from_pool.default_type !== null) {-				$scope.prefix.type = $scope.from_pool.default_type;-				$scope.display_type_input_pool = false;-			} else {-				$scope.display_type_input_pool = true;-			}--			// Extract default prefix length for selected address family-			var def_preflen;-			if ($scope.prefix_family == "4") {-				def_preflen = "ipv4_default_prefix_length";-			} else {-				def_preflen = "ipv6_default_prefix_length";-			}--			if ($scope.from_pool[def_preflen] !== null) {-				$scope.pool_has_default_preflen = true;-				$scope.pool_default_preflen = $scope.from_pool[def_preflen];-				$scope.prefix_length = $scope.from_pool[def_preflen];-			} else {-				$scope.pool_has_default_preflen = false;-				$scope.pool_default_preflen = null;-				$scope.pool_use_default_preflen = false;-				$scope.prefix_length = null;-			}--			if ($scope.from_pool.vrf_id !== null) {-				// fetch VRF data for pool's implied VRF-				$http.post('/xhr/smart_search_vrf',-					JSON.stringify({-						'vrf_id': $scope.from_pool.vrf_id,-						'query_string': ''-						}-					), {-						'headers': { 'Content-Type': 'application/json'}-					})-					.then(function (response) {-						if (response.data.hasOwnProperty('error')) {-							showDialogNotice('Error', response.data.message);-						} else {-							$scope.prefix.vrf = response.data.result[0];-						}-					})-					.catch(function (response) {-						var msg = response.data || "Unknown failure";-						showDialogNotice('Error', response.status + ': ' + msg);-					});-			} else {-				// Pool is missing implied VRF - means the pool is empty!-				$scope.prefix.vrf = null;-			}-		}-	});--	/*-	 * Watch for changes to the 'from_prefix' variable-	 */-	$scope.$watch('from_prefix', function() {--		if ($scope.from_prefix !== null) {--			// We're allocating from a prefix - reset from_pool-			$scope.from_pool = null;--			// Fetch prefix's VRF-			$http.post('/xhr/smart_search_vrf',-				JSON.stringify({-					'vrf_id': $scope.from_prefix.vrf_id,-					'query_string': ''-				}), {-					'headers': { 'Content-Type': 'application/json' }-				})-				.then(function (response) {-					if (response.data.hasOwnProperty('error')) {-						showDialogNotice('Error', response.data.message);-					} else {-						$scope.prefix.vrf = response.data.result[0];-					}-				})-				.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-				});--			// If we're allocating from an assignment, set prefix type to host-			// and prefix length to max prefix length for the selected address family.-			if ($scope.from_prefix.type == 'assignment') {-				$scope.prefix.type = 'host';-				if ($scope.from_prefix.family == 4) {-					$scope.prefix_length = 32;-				} else {-					$scope.prefix_length = 128;-				}-			}-		}-	});--	// add another empty "extra attribute" (AVP) input row-	$scope.addAvp = function() {-		$scope.prefix.avps.push({ 'attribute': '', 'value': '' });-	}--	// remove AVP row-	$scope.removeAvp = function(avp) {-		var index = $scope.prefix.avps.indexOf(avp);-		$scope.prefix.avps.splice( index, 1 );-	}--	/*-	 * Submit prefix form - add prefix to NIPAP-	 */-	$scope.submitForm = function () {--		/*-		 * Create object specifying prefix attributes and how it should be-		 * added. For simplicity, we start with a copy of the prefix object-		 * from the scope and add/remove attributes according to what's-		 * required by the different allocation methods.-		 */-		var query_data = angular.copy($scope.prefix);-		query_data.vrf = null;-		query_data.pool = null;--		// Tags, VRF and pool are needed no matter allocation method-		query_data.tags = $scope.prefix.tags.map(function (elem) { return elem.text; });-		if ($scope.prefix.vrf != null) {-			query_data.vrf = $scope.prefix.vrf.id;-		}--		if ($scope.prefix.pool != null) {-			query_data.pool = $scope.prefix.pool.id;-		}--		// Mangle avps-		query_data.avps = {};-		$scope.prefix.avps.forEach(function(avp) {-			if (avp.attribute != '' && avp.value != '') {-				query_data.avps[avp.attribute] = avp.value;-			}-		});--		// Rewrite empty VLAN to null-		query_data.vlan = inputValidationHelpers.emptyToNull($scope.prefix.vlan);--		if ($scope.prefix_alloc_method == 'from-pool') {--			// Allocation from pool requires prefix length, family and pool to-			// allocate from. Prefix not needed.-			delete query_data.prefix;-			query_data.family = $scope.prefix_family;-			if ($scope.pool_use_default_preflen) {-				query_data.prefix_length = $scope.pool_default_preflen;-			} else {-				query_data.prefix_length = $scope.prefix_length;-			}-			query_data.from_pool = $scope.from_pool.id;--		} else if ($scope.prefix_alloc_method == 'from-prefix') {--			// Allocation from prefix requires prefix length and prefix to-			// allocate from. Prefix not needed.-			delete query_data.prefix;-			query_data.prefix_length = $scope.prefix_length;-			query_data['from_prefix'] = [ $scope.from_prefix.prefix ];--		}--		// Send query!-		$http.post('/xhr/add_prefix',-				JSON.stringify(query_data),-				{ 'headers': { 'Content-Type': 'application/json'} })-			.then(function (response){-				if (response.data.hasOwnProperty('error')) {-					showDialogNotice('Error', response.data.message);-				} else {-					$scope.added_prefixes.push(response.data);-				}-			})-			.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-			});--	}+    // prefix method is add - used to customize prefix form template+    $scope.method = 'add';++    // Expose prefixHelpers.enableNodeInput to templates+    $scope.enableNodeInput = prefixHelpers.enableNodeInput;++    // open up the datepicker+    $scope.dpOpen = function ($event) {+        $event.preventDefault();+        $event.stopPropagation();++        $scope.dpOpened = !$scope.dpOpened;+    };++    $scope.prefix_alloc_method = null;+    // Set to true if allocation method was provided in URL+    $scope.prefix_alloc_method_provided = false;++    $scope.from_pool = null;+    // Set to true if the pool to allocate from was provided in the URL+    $scope.from_pool_provided = false;

Identifier 'from_pool_provided' is not in camel case.

BjornPerssonSigma

comment created time in 17 days

Pull request review commentSpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

 nipapAppControllers.controller('PrefixListController', function ($scope, $uibMod  */ nipapAppControllers.controller('PrefixAddController', function ($scope, $routeParams, $http, prefixHelpers, inputValidationHelpers) { -	// prefix method is add - used to customize prefix form template-	$scope.method = 'add';--	// Expose prefixHelpers.enableNodeInput to templates-	$scope.enableNodeInput = prefixHelpers.enableNodeInput;--	// open up the datepicker-	$scope.dpOpen = function($event) {-		$event.preventDefault();-		$event.stopPropagation();--		$scope.dpOpened = !$scope.dpOpened;-	};--	$scope.prefix_alloc_method = null;-	// Set to true if allocation method was provided in URL-	$scope.prefix_alloc_method_provided = false;--	$scope.from_pool = null;-	// Set to true if the pool to allocate from was provided in the URL-	$scope.from_pool_provided = false;--	$scope.from_prefix = null;-	// Set to true if the prefix to allocate from was provided in the URL-	$scope.from_prefix_provided = false;--	// Set to true if pool has a default prefix length for current address family-	$scope.pool_has_default_preflen = false;--	// Keep track on whether the user wants to use the pool's default prefix-	// length or not-	$scope.pool_use_default_preflen = true;-	$scope.pool_default_preflen = null;--	// Keep track of whether the user has chosen to enable the prefix type-	// input fields, when allocating prefix from a pool (ie. to not use the-	// pool's default prefix type)-	$scope.display_type_input_pool = false;--	$scope.prefix_family = 4;-	$scope.prefix_length = null;--	$scope.prefix = {-		prefix: null,-		vrf: null,-		pool: null,-		status: 'assigned',-		description: null,-		comment: null,-		node: null,-		tags: [],-		type: null,-		country: null,-		order_id: null,-		customer_id: null,-		vlan: null,-		monitor: false,-		alarm_priority: null,-		avps: []-	};--	// List of prefixes added to NIPAP-	$scope.added_prefixes = [];--	/*-	 * Handle route parameters (extracted from the URL)-	 */-	// Is allocation method set?-	if ($routeParams.hasOwnProperty('allocation_method')) {-		$scope.prefix_alloc_method = $routeParams.allocation_method;-		$scope.prefix_alloc_method_provided = true;-	}--	// Did we get any allocation parameters (pool ID or prefix ID)?-	if ($routeParams.hasOwnProperty('allocation_method_parameter')) {--		var allocation_parameter = parseInt($routeParams.allocation_method_parameter);--		if ($scope.prefix_alloc_method == 'from-pool') {--			// Allocation method parameter is pool ID - fetch pool-			$scope.from_pool_provided = true;-			$http.post('/xhr/list_pool',-				JSON.stringify({ 'id': allocation_parameter }),-				{ 'headers': { 'Content-Type': 'application/json' } })-				.then(function (response) {-					if (response.data.hasOwnProperty('error')) {-						showDialogNotice('Error', response.data.message);-					} else {-						$scope.from_pool = response.data[0];-					}-				})-				.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-				});--		} else if ($scope.prefix_alloc_method == 'from-prefix') {--			// Allocation method parameter is prefix ID - fetch prefix-			$scope.from_prefix_provided = true;-			$http.post('/xhr/list_prefix',-				JSON.stringify({ 'id': allocation_parameter }),-				{ 'headers': { 'Content-Type': 'application/json' } })-				.then(function (response) {-					if (response.data.hasOwnProperty('error')) {-						showDialogNotice('Error', response.data.message);-					} else {-						$scope.from_prefix = response.data[0];-						$scope.prefix_family = response.data[0].family;-					}-				})-				.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-				});-		}-	}--	/*-	 * Watch for change to 'from_pool' and 'prefix_family' variables-	 */-	$scope.$watchCollection('[ from_pool, prefix_family ]', function(newValue, oldValue){--		if ($scope.from_pool !== null) {--			// We're allocating from a pool - reset from_prefix-			$scope.from_prefix = null;--			if ($scope.from_pool.default_type !== null) {-				$scope.prefix.type = $scope.from_pool.default_type;-				$scope.display_type_input_pool = false;-			} else {-				$scope.display_type_input_pool = true;-			}--			// Extract default prefix length for selected address family-			var def_preflen;-			if ($scope.prefix_family == "4") {-				def_preflen = "ipv4_default_prefix_length";-			} else {-				def_preflen = "ipv6_default_prefix_length";-			}--			if ($scope.from_pool[def_preflen] !== null) {-				$scope.pool_has_default_preflen = true;-				$scope.pool_default_preflen = $scope.from_pool[def_preflen];-				$scope.prefix_length = $scope.from_pool[def_preflen];-			} else {-				$scope.pool_has_default_preflen = false;-				$scope.pool_default_preflen = null;-				$scope.pool_use_default_preflen = false;-				$scope.prefix_length = null;-			}--			if ($scope.from_pool.vrf_id !== null) {-				// fetch VRF data for pool's implied VRF-				$http.post('/xhr/smart_search_vrf',-					JSON.stringify({-						'vrf_id': $scope.from_pool.vrf_id,-						'query_string': ''-						}-					), {-						'headers': { 'Content-Type': 'application/json'}-					})-					.then(function (response) {-						if (response.data.hasOwnProperty('error')) {-							showDialogNotice('Error', response.data.message);-						} else {-							$scope.prefix.vrf = response.data.result[0];-						}-					})-					.catch(function (response) {-						var msg = response.data || "Unknown failure";-						showDialogNotice('Error', response.status + ': ' + msg);-					});-			} else {-				// Pool is missing implied VRF - means the pool is empty!-				$scope.prefix.vrf = null;-			}-		}-	});--	/*-	 * Watch for changes to the 'from_prefix' variable-	 */-	$scope.$watch('from_prefix', function() {--		if ($scope.from_prefix !== null) {--			// We're allocating from a prefix - reset from_pool-			$scope.from_pool = null;--			// Fetch prefix's VRF-			$http.post('/xhr/smart_search_vrf',-				JSON.stringify({-					'vrf_id': $scope.from_prefix.vrf_id,-					'query_string': ''-				}), {-					'headers': { 'Content-Type': 'application/json' }-				})-				.then(function (response) {-					if (response.data.hasOwnProperty('error')) {-						showDialogNotice('Error', response.data.message);-					} else {-						$scope.prefix.vrf = response.data.result[0];-					}-				})-				.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-				});--			// If we're allocating from an assignment, set prefix type to host-			// and prefix length to max prefix length for the selected address family.-			if ($scope.from_prefix.type == 'assignment') {-				$scope.prefix.type = 'host';-				if ($scope.from_prefix.family == 4) {-					$scope.prefix_length = 32;-				} else {-					$scope.prefix_length = 128;-				}-			}-		}-	});--	// add another empty "extra attribute" (AVP) input row-	$scope.addAvp = function() {-		$scope.prefix.avps.push({ 'attribute': '', 'value': '' });-	}--	// remove AVP row-	$scope.removeAvp = function(avp) {-		var index = $scope.prefix.avps.indexOf(avp);-		$scope.prefix.avps.splice( index, 1 );-	}--	/*-	 * Submit prefix form - add prefix to NIPAP-	 */-	$scope.submitForm = function () {--		/*-		 * Create object specifying prefix attributes and how it should be-		 * added. For simplicity, we start with a copy of the prefix object-		 * from the scope and add/remove attributes according to what's-		 * required by the different allocation methods.-		 */-		var query_data = angular.copy($scope.prefix);-		query_data.vrf = null;-		query_data.pool = null;--		// Tags, VRF and pool are needed no matter allocation method-		query_data.tags = $scope.prefix.tags.map(function (elem) { return elem.text; });-		if ($scope.prefix.vrf != null) {-			query_data.vrf = $scope.prefix.vrf.id;-		}--		if ($scope.prefix.pool != null) {-			query_data.pool = $scope.prefix.pool.id;-		}--		// Mangle avps-		query_data.avps = {};-		$scope.prefix.avps.forEach(function(avp) {-			if (avp.attribute != '' && avp.value != '') {-				query_data.avps[avp.attribute] = avp.value;-			}-		});--		// Rewrite empty VLAN to null-		query_data.vlan = inputValidationHelpers.emptyToNull($scope.prefix.vlan);--		if ($scope.prefix_alloc_method == 'from-pool') {--			// Allocation from pool requires prefix length, family and pool to-			// allocate from. Prefix not needed.-			delete query_data.prefix;-			query_data.family = $scope.prefix_family;-			if ($scope.pool_use_default_preflen) {-				query_data.prefix_length = $scope.pool_default_preflen;-			} else {-				query_data.prefix_length = $scope.prefix_length;-			}-			query_data.from_pool = $scope.from_pool.id;--		} else if ($scope.prefix_alloc_method == 'from-prefix') {--			// Allocation from prefix requires prefix length and prefix to-			// allocate from. Prefix not needed.-			delete query_data.prefix;-			query_data.prefix_length = $scope.prefix_length;-			query_data['from_prefix'] = [ $scope.from_prefix.prefix ];--		}--		// Send query!-		$http.post('/xhr/add_prefix',-				JSON.stringify(query_data),-				{ 'headers': { 'Content-Type': 'application/json'} })-			.then(function (response){-				if (response.data.hasOwnProperty('error')) {-					showDialogNotice('Error', response.data.message);-				} else {-					$scope.added_prefixes.push(response.data);-				}-			})-			.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-			});--	}+    // prefix method is add - used to customize prefix form template+    $scope.method = 'add';++    // Expose prefixHelpers.enableNodeInput to templates+    $scope.enableNodeInput = prefixHelpers.enableNodeInput;++    // open up the datepicker+    $scope.dpOpen = function ($event) {+        $event.preventDefault();+        $event.stopPropagation();++        $scope.dpOpened = !$scope.dpOpened;+    };++    $scope.prefix_alloc_method = null;+    // Set to true if allocation method was provided in URL+    $scope.prefix_alloc_method_provided = false;++    $scope.from_pool = null;+    // Set to true if the pool to allocate from was provided in the URL+    $scope.from_pool_provided = false;++    $scope.from_prefix = null;+    // Set to true if the prefix to allocate from was provided in the URL+    $scope.from_prefix_provided = false;

Identifier 'from_prefix_provided' is not in camel case.

BjornPerssonSigma

comment created time in 17 days

Pull request review commentSpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

 nipapAppControllers.controller('PrefixListController', function ($scope, $uibMod  */ nipapAppControllers.controller('PrefixAddController', function ($scope, $routeParams, $http, prefixHelpers, inputValidationHelpers) { -	// prefix method is add - used to customize prefix form template-	$scope.method = 'add';--	// Expose prefixHelpers.enableNodeInput to templates-	$scope.enableNodeInput = prefixHelpers.enableNodeInput;--	// open up the datepicker-	$scope.dpOpen = function($event) {-		$event.preventDefault();-		$event.stopPropagation();--		$scope.dpOpened = !$scope.dpOpened;-	};--	$scope.prefix_alloc_method = null;-	// Set to true if allocation method was provided in URL-	$scope.prefix_alloc_method_provided = false;--	$scope.from_pool = null;-	// Set to true if the pool to allocate from was provided in the URL-	$scope.from_pool_provided = false;--	$scope.from_prefix = null;-	// Set to true if the prefix to allocate from was provided in the URL-	$scope.from_prefix_provided = false;--	// Set to true if pool has a default prefix length for current address family-	$scope.pool_has_default_preflen = false;--	// Keep track on whether the user wants to use the pool's default prefix-	// length or not-	$scope.pool_use_default_preflen = true;-	$scope.pool_default_preflen = null;--	// Keep track of whether the user has chosen to enable the prefix type-	// input fields, when allocating prefix from a pool (ie. to not use the-	// pool's default prefix type)-	$scope.display_type_input_pool = false;--	$scope.prefix_family = 4;-	$scope.prefix_length = null;--	$scope.prefix = {-		prefix: null,-		vrf: null,-		pool: null,-		status: 'assigned',-		description: null,-		comment: null,-		node: null,-		tags: [],-		type: null,-		country: null,-		order_id: null,-		customer_id: null,-		vlan: null,-		monitor: false,-		alarm_priority: null,-		avps: []-	};--	// List of prefixes added to NIPAP-	$scope.added_prefixes = [];--	/*-	 * Handle route parameters (extracted from the URL)-	 */-	// Is allocation method set?-	if ($routeParams.hasOwnProperty('allocation_method')) {-		$scope.prefix_alloc_method = $routeParams.allocation_method;-		$scope.prefix_alloc_method_provided = true;-	}--	// Did we get any allocation parameters (pool ID or prefix ID)?-	if ($routeParams.hasOwnProperty('allocation_method_parameter')) {--		var allocation_parameter = parseInt($routeParams.allocation_method_parameter);--		if ($scope.prefix_alloc_method == 'from-pool') {--			// Allocation method parameter is pool ID - fetch pool-			$scope.from_pool_provided = true;-			$http.post('/xhr/list_pool',-				JSON.stringify({ 'id': allocation_parameter }),-				{ 'headers': { 'Content-Type': 'application/json' } })-				.then(function (response) {-					if (response.data.hasOwnProperty('error')) {-						showDialogNotice('Error', response.data.message);-					} else {-						$scope.from_pool = response.data[0];-					}-				})-				.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-				});--		} else if ($scope.prefix_alloc_method == 'from-prefix') {--			// Allocation method parameter is prefix ID - fetch prefix-			$scope.from_prefix_provided = true;-			$http.post('/xhr/list_prefix',-				JSON.stringify({ 'id': allocation_parameter }),-				{ 'headers': { 'Content-Type': 'application/json' } })-				.then(function (response) {-					if (response.data.hasOwnProperty('error')) {-						showDialogNotice('Error', response.data.message);-					} else {-						$scope.from_prefix = response.data[0];-						$scope.prefix_family = response.data[0].family;-					}-				})-				.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-				});-		}-	}--	/*-	 * Watch for change to 'from_pool' and 'prefix_family' variables-	 */-	$scope.$watchCollection('[ from_pool, prefix_family ]', function(newValue, oldValue){--		if ($scope.from_pool !== null) {--			// We're allocating from a pool - reset from_prefix-			$scope.from_prefix = null;--			if ($scope.from_pool.default_type !== null) {-				$scope.prefix.type = $scope.from_pool.default_type;-				$scope.display_type_input_pool = false;-			} else {-				$scope.display_type_input_pool = true;-			}--			// Extract default prefix length for selected address family-			var def_preflen;-			if ($scope.prefix_family == "4") {-				def_preflen = "ipv4_default_prefix_length";-			} else {-				def_preflen = "ipv6_default_prefix_length";-			}--			if ($scope.from_pool[def_preflen] !== null) {-				$scope.pool_has_default_preflen = true;-				$scope.pool_default_preflen = $scope.from_pool[def_preflen];-				$scope.prefix_length = $scope.from_pool[def_preflen];-			} else {-				$scope.pool_has_default_preflen = false;-				$scope.pool_default_preflen = null;-				$scope.pool_use_default_preflen = false;-				$scope.prefix_length = null;-			}--			if ($scope.from_pool.vrf_id !== null) {-				// fetch VRF data for pool's implied VRF-				$http.post('/xhr/smart_search_vrf',-					JSON.stringify({-						'vrf_id': $scope.from_pool.vrf_id,-						'query_string': ''-						}-					), {-						'headers': { 'Content-Type': 'application/json'}-					})-					.then(function (response) {-						if (response.data.hasOwnProperty('error')) {-							showDialogNotice('Error', response.data.message);-						} else {-							$scope.prefix.vrf = response.data.result[0];-						}-					})-					.catch(function (response) {-						var msg = response.data || "Unknown failure";-						showDialogNotice('Error', response.status + ': ' + msg);-					});-			} else {-				// Pool is missing implied VRF - means the pool is empty!-				$scope.prefix.vrf = null;-			}-		}-	});--	/*-	 * Watch for changes to the 'from_prefix' variable-	 */-	$scope.$watch('from_prefix', function() {--		if ($scope.from_prefix !== null) {--			// We're allocating from a prefix - reset from_pool-			$scope.from_pool = null;--			// Fetch prefix's VRF-			$http.post('/xhr/smart_search_vrf',-				JSON.stringify({-					'vrf_id': $scope.from_prefix.vrf_id,-					'query_string': ''-				}), {-					'headers': { 'Content-Type': 'application/json' }-				})-				.then(function (response) {-					if (response.data.hasOwnProperty('error')) {-						showDialogNotice('Error', response.data.message);-					} else {-						$scope.prefix.vrf = response.data.result[0];-					}-				})-				.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-				});--			// If we're allocating from an assignment, set prefix type to host-			// and prefix length to max prefix length for the selected address family.-			if ($scope.from_prefix.type == 'assignment') {-				$scope.prefix.type = 'host';-				if ($scope.from_prefix.family == 4) {-					$scope.prefix_length = 32;-				} else {-					$scope.prefix_length = 128;-				}-			}-		}-	});--	// add another empty "extra attribute" (AVP) input row-	$scope.addAvp = function() {-		$scope.prefix.avps.push({ 'attribute': '', 'value': '' });-	}--	// remove AVP row-	$scope.removeAvp = function(avp) {-		var index = $scope.prefix.avps.indexOf(avp);-		$scope.prefix.avps.splice( index, 1 );-	}--	/*-	 * Submit prefix form - add prefix to NIPAP-	 */-	$scope.submitForm = function () {--		/*-		 * Create object specifying prefix attributes and how it should be-		 * added. For simplicity, we start with a copy of the prefix object-		 * from the scope and add/remove attributes according to what's-		 * required by the different allocation methods.-		 */-		var query_data = angular.copy($scope.prefix);-		query_data.vrf = null;-		query_data.pool = null;--		// Tags, VRF and pool are needed no matter allocation method-		query_data.tags = $scope.prefix.tags.map(function (elem) { return elem.text; });-		if ($scope.prefix.vrf != null) {-			query_data.vrf = $scope.prefix.vrf.id;-		}--		if ($scope.prefix.pool != null) {-			query_data.pool = $scope.prefix.pool.id;-		}--		// Mangle avps-		query_data.avps = {};-		$scope.prefix.avps.forEach(function(avp) {-			if (avp.attribute != '' && avp.value != '') {-				query_data.avps[avp.attribute] = avp.value;-			}-		});--		// Rewrite empty VLAN to null-		query_data.vlan = inputValidationHelpers.emptyToNull($scope.prefix.vlan);--		if ($scope.prefix_alloc_method == 'from-pool') {--			// Allocation from pool requires prefix length, family and pool to-			// allocate from. Prefix not needed.-			delete query_data.prefix;-			query_data.family = $scope.prefix_family;-			if ($scope.pool_use_default_preflen) {-				query_data.prefix_length = $scope.pool_default_preflen;-			} else {-				query_data.prefix_length = $scope.prefix_length;-			}-			query_data.from_pool = $scope.from_pool.id;--		} else if ($scope.prefix_alloc_method == 'from-prefix') {--			// Allocation from prefix requires prefix length and prefix to-			// allocate from. Prefix not needed.-			delete query_data.prefix;-			query_data.prefix_length = $scope.prefix_length;-			query_data['from_prefix'] = [ $scope.from_prefix.prefix ];--		}--		// Send query!-		$http.post('/xhr/add_prefix',-				JSON.stringify(query_data),-				{ 'headers': { 'Content-Type': 'application/json'} })-			.then(function (response){-				if (response.data.hasOwnProperty('error')) {-					showDialogNotice('Error', response.data.message);-				} else {-					$scope.added_prefixes.push(response.data);-				}-			})-			.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-			});--	}+    // prefix method is add - used to customize prefix form template+    $scope.method = 'add';++    // Expose prefixHelpers.enableNodeInput to templates+    $scope.enableNodeInput = prefixHelpers.enableNodeInput;++    // open up the datepicker+    $scope.dpOpen = function ($event) {+        $event.preventDefault();+        $event.stopPropagation();++        $scope.dpOpened = !$scope.dpOpened;+    };++    $scope.prefix_alloc_method = null;+    // Set to true if allocation method was provided in URL+    $scope.prefix_alloc_method_provided = false;++    $scope.from_pool = null;+    // Set to true if the pool to allocate from was provided in the URL+    $scope.from_pool_provided = false;++    $scope.from_prefix = null;+    // Set to true if the prefix to allocate from was provided in the URL+    $scope.from_prefix_provided = false;++    // Set to true if pool has a default prefix length for current address family+    $scope.pool_has_default_preflen = false;

Identifier 'pool_has_default_preflen' is not in camel case.

BjornPerssonSigma

comment created time in 17 days

Pull request review commentSpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

 nipapAppControllers.controller('PrefixListController', function ($scope, $uibMod  */ nipapAppControllers.controller('PrefixAddController', function ($scope, $routeParams, $http, prefixHelpers, inputValidationHelpers) { -	// prefix method is add - used to customize prefix form template-	$scope.method = 'add';--	// Expose prefixHelpers.enableNodeInput to templates-	$scope.enableNodeInput = prefixHelpers.enableNodeInput;--	// open up the datepicker-	$scope.dpOpen = function($event) {-		$event.preventDefault();-		$event.stopPropagation();--		$scope.dpOpened = !$scope.dpOpened;-	};--	$scope.prefix_alloc_method = null;-	// Set to true if allocation method was provided in URL-	$scope.prefix_alloc_method_provided = false;--	$scope.from_pool = null;-	// Set to true if the pool to allocate from was provided in the URL-	$scope.from_pool_provided = false;--	$scope.from_prefix = null;-	// Set to true if the prefix to allocate from was provided in the URL-	$scope.from_prefix_provided = false;--	// Set to true if pool has a default prefix length for current address family-	$scope.pool_has_default_preflen = false;--	// Keep track on whether the user wants to use the pool's default prefix-	// length or not-	$scope.pool_use_default_preflen = true;-	$scope.pool_default_preflen = null;--	// Keep track of whether the user has chosen to enable the prefix type-	// input fields, when allocating prefix from a pool (ie. to not use the-	// pool's default prefix type)-	$scope.display_type_input_pool = false;--	$scope.prefix_family = 4;-	$scope.prefix_length = null;--	$scope.prefix = {-		prefix: null,-		vrf: null,-		pool: null,-		status: 'assigned',-		description: null,-		comment: null,-		node: null,-		tags: [],-		type: null,-		country: null,-		order_id: null,-		customer_id: null,-		vlan: null,-		monitor: false,-		alarm_priority: null,-		avps: []-	};--	// List of prefixes added to NIPAP-	$scope.added_prefixes = [];--	/*-	 * Handle route parameters (extracted from the URL)-	 */-	// Is allocation method set?-	if ($routeParams.hasOwnProperty('allocation_method')) {-		$scope.prefix_alloc_method = $routeParams.allocation_method;-		$scope.prefix_alloc_method_provided = true;-	}--	// Did we get any allocation parameters (pool ID or prefix ID)?-	if ($routeParams.hasOwnProperty('allocation_method_parameter')) {--		var allocation_parameter = parseInt($routeParams.allocation_method_parameter);--		if ($scope.prefix_alloc_method == 'from-pool') {--			// Allocation method parameter is pool ID - fetch pool-			$scope.from_pool_provided = true;-			$http.post('/xhr/list_pool',-				JSON.stringify({ 'id': allocation_parameter }),-				{ 'headers': { 'Content-Type': 'application/json' } })-				.then(function (response) {-					if (response.data.hasOwnProperty('error')) {-						showDialogNotice('Error', response.data.message);-					} else {-						$scope.from_pool = response.data[0];-					}-				})-				.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-				});--		} else if ($scope.prefix_alloc_method == 'from-prefix') {--			// Allocation method parameter is prefix ID - fetch prefix-			$scope.from_prefix_provided = true;-			$http.post('/xhr/list_prefix',-				JSON.stringify({ 'id': allocation_parameter }),-				{ 'headers': { 'Content-Type': 'application/json' } })-				.then(function (response) {-					if (response.data.hasOwnProperty('error')) {-						showDialogNotice('Error', response.data.message);-					} else {-						$scope.from_prefix = response.data[0];-						$scope.prefix_family = response.data[0].family;-					}-				})-				.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-				});-		}-	}--	/*-	 * Watch for change to 'from_pool' and 'prefix_family' variables-	 */-	$scope.$watchCollection('[ from_pool, prefix_family ]', function(newValue, oldValue){--		if ($scope.from_pool !== null) {--			// We're allocating from a pool - reset from_prefix-			$scope.from_prefix = null;--			if ($scope.from_pool.default_type !== null) {-				$scope.prefix.type = $scope.from_pool.default_type;-				$scope.display_type_input_pool = false;-			} else {-				$scope.display_type_input_pool = true;-			}--			// Extract default prefix length for selected address family-			var def_preflen;-			if ($scope.prefix_family == "4") {-				def_preflen = "ipv4_default_prefix_length";-			} else {-				def_preflen = "ipv6_default_prefix_length";-			}--			if ($scope.from_pool[def_preflen] !== null) {-				$scope.pool_has_default_preflen = true;-				$scope.pool_default_preflen = $scope.from_pool[def_preflen];-				$scope.prefix_length = $scope.from_pool[def_preflen];-			} else {-				$scope.pool_has_default_preflen = false;-				$scope.pool_default_preflen = null;-				$scope.pool_use_default_preflen = false;-				$scope.prefix_length = null;-			}--			if ($scope.from_pool.vrf_id !== null) {-				// fetch VRF data for pool's implied VRF-				$http.post('/xhr/smart_search_vrf',-					JSON.stringify({-						'vrf_id': $scope.from_pool.vrf_id,-						'query_string': ''-						}-					), {-						'headers': { 'Content-Type': 'application/json'}-					})-					.then(function (response) {-						if (response.data.hasOwnProperty('error')) {-							showDialogNotice('Error', response.data.message);-						} else {-							$scope.prefix.vrf = response.data.result[0];-						}-					})-					.catch(function (response) {-						var msg = response.data || "Unknown failure";-						showDialogNotice('Error', response.status + ': ' + msg);-					});-			} else {-				// Pool is missing implied VRF - means the pool is empty!-				$scope.prefix.vrf = null;-			}-		}-	});--	/*-	 * Watch for changes to the 'from_prefix' variable-	 */-	$scope.$watch('from_prefix', function() {--		if ($scope.from_prefix !== null) {--			// We're allocating from a prefix - reset from_pool-			$scope.from_pool = null;--			// Fetch prefix's VRF-			$http.post('/xhr/smart_search_vrf',-				JSON.stringify({-					'vrf_id': $scope.from_prefix.vrf_id,-					'query_string': ''-				}), {-					'headers': { 'Content-Type': 'application/json' }-				})-				.then(function (response) {-					if (response.data.hasOwnProperty('error')) {-						showDialogNotice('Error', response.data.message);-					} else {-						$scope.prefix.vrf = response.data.result[0];-					}-				})-				.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-				});--			// If we're allocating from an assignment, set prefix type to host-			// and prefix length to max prefix length for the selected address family.-			if ($scope.from_prefix.type == 'assignment') {-				$scope.prefix.type = 'host';-				if ($scope.from_prefix.family == 4) {-					$scope.prefix_length = 32;-				} else {-					$scope.prefix_length = 128;-				}-			}-		}-	});--	// add another empty "extra attribute" (AVP) input row-	$scope.addAvp = function() {-		$scope.prefix.avps.push({ 'attribute': '', 'value': '' });-	}--	// remove AVP row-	$scope.removeAvp = function(avp) {-		var index = $scope.prefix.avps.indexOf(avp);-		$scope.prefix.avps.splice( index, 1 );-	}--	/*-	 * Submit prefix form - add prefix to NIPAP-	 */-	$scope.submitForm = function () {--		/*-		 * Create object specifying prefix attributes and how it should be-		 * added. For simplicity, we start with a copy of the prefix object-		 * from the scope and add/remove attributes according to what's-		 * required by the different allocation methods.-		 */-		var query_data = angular.copy($scope.prefix);-		query_data.vrf = null;-		query_data.pool = null;--		// Tags, VRF and pool are needed no matter allocation method-		query_data.tags = $scope.prefix.tags.map(function (elem) { return elem.text; });-		if ($scope.prefix.vrf != null) {-			query_data.vrf = $scope.prefix.vrf.id;-		}--		if ($scope.prefix.pool != null) {-			query_data.pool = $scope.prefix.pool.id;-		}--		// Mangle avps-		query_data.avps = {};-		$scope.prefix.avps.forEach(function(avp) {-			if (avp.attribute != '' && avp.value != '') {-				query_data.avps[avp.attribute] = avp.value;-			}-		});--		// Rewrite empty VLAN to null-		query_data.vlan = inputValidationHelpers.emptyToNull($scope.prefix.vlan);--		if ($scope.prefix_alloc_method == 'from-pool') {--			// Allocation from pool requires prefix length, family and pool to-			// allocate from. Prefix not needed.-			delete query_data.prefix;-			query_data.family = $scope.prefix_family;-			if ($scope.pool_use_default_preflen) {-				query_data.prefix_length = $scope.pool_default_preflen;-			} else {-				query_data.prefix_length = $scope.prefix_length;-			}-			query_data.from_pool = $scope.from_pool.id;--		} else if ($scope.prefix_alloc_method == 'from-prefix') {--			// Allocation from prefix requires prefix length and prefix to-			// allocate from. Prefix not needed.-			delete query_data.prefix;-			query_data.prefix_length = $scope.prefix_length;-			query_data['from_prefix'] = [ $scope.from_prefix.prefix ];--		}--		// Send query!-		$http.post('/xhr/add_prefix',-				JSON.stringify(query_data),-				{ 'headers': { 'Content-Type': 'application/json'} })-			.then(function (response){-				if (response.data.hasOwnProperty('error')) {-					showDialogNotice('Error', response.data.message);-				} else {-					$scope.added_prefixes.push(response.data);-				}-			})-			.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-			});--	}+    // prefix method is add - used to customize prefix form template+    $scope.method = 'add';++    // Expose prefixHelpers.enableNodeInput to templates+    $scope.enableNodeInput = prefixHelpers.enableNodeInput;++    // open up the datepicker+    $scope.dpOpen = function ($event) {+        $event.preventDefault();+        $event.stopPropagation();++        $scope.dpOpened = !$scope.dpOpened;+    };++    $scope.prefix_alloc_method = null;+    // Set to true if allocation method was provided in URL+    $scope.prefix_alloc_method_provided = false;++    $scope.from_pool = null;+    // Set to true if the pool to allocate from was provided in the URL+    $scope.from_pool_provided = false;++    $scope.from_prefix = null;

Identifier 'from_prefix' is not in camel case.

BjornPerssonSigma

comment created time in 17 days

Pull request review commentSpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

 nipapAppControllers.controller('PrefixListController', function ($scope, $uibMod  */ nipapAppControllers.controller('PrefixAddController', function ($scope, $routeParams, $http, prefixHelpers, inputValidationHelpers) { -	// prefix method is add - used to customize prefix form template-	$scope.method = 'add';--	// Expose prefixHelpers.enableNodeInput to templates-	$scope.enableNodeInput = prefixHelpers.enableNodeInput;--	// open up the datepicker-	$scope.dpOpen = function($event) {-		$event.preventDefault();-		$event.stopPropagation();--		$scope.dpOpened = !$scope.dpOpened;-	};--	$scope.prefix_alloc_method = null;-	// Set to true if allocation method was provided in URL-	$scope.prefix_alloc_method_provided = false;--	$scope.from_pool = null;-	// Set to true if the pool to allocate from was provided in the URL-	$scope.from_pool_provided = false;--	$scope.from_prefix = null;-	// Set to true if the prefix to allocate from was provided in the URL-	$scope.from_prefix_provided = false;--	// Set to true if pool has a default prefix length for current address family-	$scope.pool_has_default_preflen = false;--	// Keep track on whether the user wants to use the pool's default prefix-	// length or not-	$scope.pool_use_default_preflen = true;-	$scope.pool_default_preflen = null;--	// Keep track of whether the user has chosen to enable the prefix type-	// input fields, when allocating prefix from a pool (ie. to not use the-	// pool's default prefix type)-	$scope.display_type_input_pool = false;--	$scope.prefix_family = 4;-	$scope.prefix_length = null;--	$scope.prefix = {-		prefix: null,-		vrf: null,-		pool: null,-		status: 'assigned',-		description: null,-		comment: null,-		node: null,-		tags: [],-		type: null,-		country: null,-		order_id: null,-		customer_id: null,-		vlan: null,-		monitor: false,-		alarm_priority: null,-		avps: []-	};--	// List of prefixes added to NIPAP-	$scope.added_prefixes = [];--	/*-	 * Handle route parameters (extracted from the URL)-	 */-	// Is allocation method set?-	if ($routeParams.hasOwnProperty('allocation_method')) {-		$scope.prefix_alloc_method = $routeParams.allocation_method;-		$scope.prefix_alloc_method_provided = true;-	}--	// Did we get any allocation parameters (pool ID or prefix ID)?-	if ($routeParams.hasOwnProperty('allocation_method_parameter')) {--		var allocation_parameter = parseInt($routeParams.allocation_method_parameter);--		if ($scope.prefix_alloc_method == 'from-pool') {--			// Allocation method parameter is pool ID - fetch pool-			$scope.from_pool_provided = true;-			$http.post('/xhr/list_pool',-				JSON.stringify({ 'id': allocation_parameter }),-				{ 'headers': { 'Content-Type': 'application/json' } })-				.then(function (response) {-					if (response.data.hasOwnProperty('error')) {-						showDialogNotice('Error', response.data.message);-					} else {-						$scope.from_pool = response.data[0];-					}-				})-				.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-				});--		} else if ($scope.prefix_alloc_method == 'from-prefix') {--			// Allocation method parameter is prefix ID - fetch prefix-			$scope.from_prefix_provided = true;-			$http.post('/xhr/list_prefix',-				JSON.stringify({ 'id': allocation_parameter }),-				{ 'headers': { 'Content-Type': 'application/json' } })-				.then(function (response) {-					if (response.data.hasOwnProperty('error')) {-						showDialogNotice('Error', response.data.message);-					} else {-						$scope.from_prefix = response.data[0];-						$scope.prefix_family = response.data[0].family;-					}-				})-				.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-				});-		}-	}--	/*-	 * Watch for change to 'from_pool' and 'prefix_family' variables-	 */-	$scope.$watchCollection('[ from_pool, prefix_family ]', function(newValue, oldValue){--		if ($scope.from_pool !== null) {--			// We're allocating from a pool - reset from_prefix-			$scope.from_prefix = null;--			if ($scope.from_pool.default_type !== null) {-				$scope.prefix.type = $scope.from_pool.default_type;-				$scope.display_type_input_pool = false;-			} else {-				$scope.display_type_input_pool = true;-			}--			// Extract default prefix length for selected address family-			var def_preflen;-			if ($scope.prefix_family == "4") {-				def_preflen = "ipv4_default_prefix_length";-			} else {-				def_preflen = "ipv6_default_prefix_length";-			}--			if ($scope.from_pool[def_preflen] !== null) {-				$scope.pool_has_default_preflen = true;-				$scope.pool_default_preflen = $scope.from_pool[def_preflen];-				$scope.prefix_length = $scope.from_pool[def_preflen];-			} else {-				$scope.pool_has_default_preflen = false;-				$scope.pool_default_preflen = null;-				$scope.pool_use_default_preflen = false;-				$scope.prefix_length = null;-			}--			if ($scope.from_pool.vrf_id !== null) {-				// fetch VRF data for pool's implied VRF-				$http.post('/xhr/smart_search_vrf',-					JSON.stringify({-						'vrf_id': $scope.from_pool.vrf_id,-						'query_string': ''-						}-					), {-						'headers': { 'Content-Type': 'application/json'}-					})-					.then(function (response) {-						if (response.data.hasOwnProperty('error')) {-							showDialogNotice('Error', response.data.message);-						} else {-							$scope.prefix.vrf = response.data.result[0];-						}-					})-					.catch(function (response) {-						var msg = response.data || "Unknown failure";-						showDialogNotice('Error', response.status + ': ' + msg);-					});-			} else {-				// Pool is missing implied VRF - means the pool is empty!-				$scope.prefix.vrf = null;-			}-		}-	});--	/*-	 * Watch for changes to the 'from_prefix' variable-	 */-	$scope.$watch('from_prefix', function() {--		if ($scope.from_prefix !== null) {--			// We're allocating from a prefix - reset from_pool-			$scope.from_pool = null;--			// Fetch prefix's VRF-			$http.post('/xhr/smart_search_vrf',-				JSON.stringify({-					'vrf_id': $scope.from_prefix.vrf_id,-					'query_string': ''-				}), {-					'headers': { 'Content-Type': 'application/json' }-				})-				.then(function (response) {-					if (response.data.hasOwnProperty('error')) {-						showDialogNotice('Error', response.data.message);-					} else {-						$scope.prefix.vrf = response.data.result[0];-					}-				})-				.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-				});--			// If we're allocating from an assignment, set prefix type to host-			// and prefix length to max prefix length for the selected address family.-			if ($scope.from_prefix.type == 'assignment') {-				$scope.prefix.type = 'host';-				if ($scope.from_prefix.family == 4) {-					$scope.prefix_length = 32;-				} else {-					$scope.prefix_length = 128;-				}-			}-		}-	});--	// add another empty "extra attribute" (AVP) input row-	$scope.addAvp = function() {-		$scope.prefix.avps.push({ 'attribute': '', 'value': '' });-	}--	// remove AVP row-	$scope.removeAvp = function(avp) {-		var index = $scope.prefix.avps.indexOf(avp);-		$scope.prefix.avps.splice( index, 1 );-	}--	/*-	 * Submit prefix form - add prefix to NIPAP-	 */-	$scope.submitForm = function () {--		/*-		 * Create object specifying prefix attributes and how it should be-		 * added. For simplicity, we start with a copy of the prefix object-		 * from the scope and add/remove attributes according to what's-		 * required by the different allocation methods.-		 */-		var query_data = angular.copy($scope.prefix);-		query_data.vrf = null;-		query_data.pool = null;--		// Tags, VRF and pool are needed no matter allocation method-		query_data.tags = $scope.prefix.tags.map(function (elem) { return elem.text; });-		if ($scope.prefix.vrf != null) {-			query_data.vrf = $scope.prefix.vrf.id;-		}--		if ($scope.prefix.pool != null) {-			query_data.pool = $scope.prefix.pool.id;-		}--		// Mangle avps-		query_data.avps = {};-		$scope.prefix.avps.forEach(function(avp) {-			if (avp.attribute != '' && avp.value != '') {-				query_data.avps[avp.attribute] = avp.value;-			}-		});--		// Rewrite empty VLAN to null-		query_data.vlan = inputValidationHelpers.emptyToNull($scope.prefix.vlan);--		if ($scope.prefix_alloc_method == 'from-pool') {--			// Allocation from pool requires prefix length, family and pool to-			// allocate from. Prefix not needed.-			delete query_data.prefix;-			query_data.family = $scope.prefix_family;-			if ($scope.pool_use_default_preflen) {-				query_data.prefix_length = $scope.pool_default_preflen;-			} else {-				query_data.prefix_length = $scope.prefix_length;-			}-			query_data.from_pool = $scope.from_pool.id;--		} else if ($scope.prefix_alloc_method == 'from-prefix') {--			// Allocation from prefix requires prefix length and prefix to-			// allocate from. Prefix not needed.-			delete query_data.prefix;-			query_data.prefix_length = $scope.prefix_length;-			query_data['from_prefix'] = [ $scope.from_prefix.prefix ];--		}--		// Send query!-		$http.post('/xhr/add_prefix',-				JSON.stringify(query_data),-				{ 'headers': { 'Content-Type': 'application/json'} })-			.then(function (response){-				if (response.data.hasOwnProperty('error')) {-					showDialogNotice('Error', response.data.message);-				} else {-					$scope.added_prefixes.push(response.data);-				}-			})-			.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-			});--	}+    // prefix method is add - used to customize prefix form template+    $scope.method = 'add';++    // Expose prefixHelpers.enableNodeInput to templates+    $scope.enableNodeInput = prefixHelpers.enableNodeInput;++    // open up the datepicker+    $scope.dpOpen = function ($event) {+        $event.preventDefault();+        $event.stopPropagation();++        $scope.dpOpened = !$scope.dpOpened;+    };++    $scope.prefix_alloc_method = null;+    // Set to true if allocation method was provided in URL+    $scope.prefix_alloc_method_provided = false;++    $scope.from_pool = null;+    // Set to true if the pool to allocate from was provided in the URL+    $scope.from_pool_provided = false;++    $scope.from_prefix = null;+    // Set to true if the prefix to allocate from was provided in the URL+    $scope.from_prefix_provided = false;++    // Set to true if pool has a default prefix length for current address family

Line is too long.

BjornPerssonSigma

comment created time in 17 days

Pull request review commentSpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

 nipapAppControllers.controller('PrefixListController', function ($scope, $uibMod  */ nipapAppControllers.controller('PrefixAddController', function ($scope, $routeParams, $http, prefixHelpers, inputValidationHelpers) { -	// prefix method is add - used to customize prefix form template-	$scope.method = 'add';--	// Expose prefixHelpers.enableNodeInput to templates-	$scope.enableNodeInput = prefixHelpers.enableNodeInput;--	// open up the datepicker-	$scope.dpOpen = function($event) {-		$event.preventDefault();-		$event.stopPropagation();--		$scope.dpOpened = !$scope.dpOpened;-	};--	$scope.prefix_alloc_method = null;-	// Set to true if allocation method was provided in URL-	$scope.prefix_alloc_method_provided = false;--	$scope.from_pool = null;-	// Set to true if the pool to allocate from was provided in the URL-	$scope.from_pool_provided = false;--	$scope.from_prefix = null;-	// Set to true if the prefix to allocate from was provided in the URL-	$scope.from_prefix_provided = false;--	// Set to true if pool has a default prefix length for current address family-	$scope.pool_has_default_preflen = false;--	// Keep track on whether the user wants to use the pool's default prefix-	// length or not-	$scope.pool_use_default_preflen = true;-	$scope.pool_default_preflen = null;--	// Keep track of whether the user has chosen to enable the prefix type-	// input fields, when allocating prefix from a pool (ie. to not use the-	// pool's default prefix type)-	$scope.display_type_input_pool = false;--	$scope.prefix_family = 4;-	$scope.prefix_length = null;--	$scope.prefix = {-		prefix: null,-		vrf: null,-		pool: null,-		status: 'assigned',-		description: null,-		comment: null,-		node: null,-		tags: [],-		type: null,-		country: null,-		order_id: null,-		customer_id: null,-		vlan: null,-		monitor: false,-		alarm_priority: null,-		avps: []-	};--	// List of prefixes added to NIPAP-	$scope.added_prefixes = [];--	/*-	 * Handle route parameters (extracted from the URL)-	 */-	// Is allocation method set?-	if ($routeParams.hasOwnProperty('allocation_method')) {-		$scope.prefix_alloc_method = $routeParams.allocation_method;-		$scope.prefix_alloc_method_provided = true;-	}--	// Did we get any allocation parameters (pool ID or prefix ID)?-	if ($routeParams.hasOwnProperty('allocation_method_parameter')) {--		var allocation_parameter = parseInt($routeParams.allocation_method_parameter);--		if ($scope.prefix_alloc_method == 'from-pool') {--			// Allocation method parameter is pool ID - fetch pool-			$scope.from_pool_provided = true;-			$http.post('/xhr/list_pool',-				JSON.stringify({ 'id': allocation_parameter }),-				{ 'headers': { 'Content-Type': 'application/json' } })-				.then(function (response) {-					if (response.data.hasOwnProperty('error')) {-						showDialogNotice('Error', response.data.message);-					} else {-						$scope.from_pool = response.data[0];-					}-				})-				.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-				});--		} else if ($scope.prefix_alloc_method == 'from-prefix') {--			// Allocation method parameter is prefix ID - fetch prefix-			$scope.from_prefix_provided = true;-			$http.post('/xhr/list_prefix',-				JSON.stringify({ 'id': allocation_parameter }),-				{ 'headers': { 'Content-Type': 'application/json' } })-				.then(function (response) {-					if (response.data.hasOwnProperty('error')) {-						showDialogNotice('Error', response.data.message);-					} else {-						$scope.from_prefix = response.data[0];-						$scope.prefix_family = response.data[0].family;-					}-				})-				.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-				});-		}-	}--	/*-	 * Watch for change to 'from_pool' and 'prefix_family' variables-	 */-	$scope.$watchCollection('[ from_pool, prefix_family ]', function(newValue, oldValue){--		if ($scope.from_pool !== null) {--			// We're allocating from a pool - reset from_prefix-			$scope.from_prefix = null;--			if ($scope.from_pool.default_type !== null) {-				$scope.prefix.type = $scope.from_pool.default_type;-				$scope.display_type_input_pool = false;-			} else {-				$scope.display_type_input_pool = true;-			}--			// Extract default prefix length for selected address family-			var def_preflen;-			if ($scope.prefix_family == "4") {-				def_preflen = "ipv4_default_prefix_length";-			} else {-				def_preflen = "ipv6_default_prefix_length";-			}--			if ($scope.from_pool[def_preflen] !== null) {-				$scope.pool_has_default_preflen = true;-				$scope.pool_default_preflen = $scope.from_pool[def_preflen];-				$scope.prefix_length = $scope.from_pool[def_preflen];-			} else {-				$scope.pool_has_default_preflen = false;-				$scope.pool_default_preflen = null;-				$scope.pool_use_default_preflen = false;-				$scope.prefix_length = null;-			}--			if ($scope.from_pool.vrf_id !== null) {-				// fetch VRF data for pool's implied VRF-				$http.post('/xhr/smart_search_vrf',-					JSON.stringify({-						'vrf_id': $scope.from_pool.vrf_id,-						'query_string': ''-						}-					), {-						'headers': { 'Content-Type': 'application/json'}-					})-					.then(function (response) {-						if (response.data.hasOwnProperty('error')) {-							showDialogNotice('Error', response.data.message);-						} else {-							$scope.prefix.vrf = response.data.result[0];-						}-					})-					.catch(function (response) {-						var msg = response.data || "Unknown failure";-						showDialogNotice('Error', response.status + ': ' + msg);-					});-			} else {-				// Pool is missing implied VRF - means the pool is empty!-				$scope.prefix.vrf = null;-			}-		}-	});--	/*-	 * Watch for changes to the 'from_prefix' variable-	 */-	$scope.$watch('from_prefix', function() {--		if ($scope.from_prefix !== null) {--			// We're allocating from a prefix - reset from_pool-			$scope.from_pool = null;--			// Fetch prefix's VRF-			$http.post('/xhr/smart_search_vrf',-				JSON.stringify({-					'vrf_id': $scope.from_prefix.vrf_id,-					'query_string': ''-				}), {-					'headers': { 'Content-Type': 'application/json' }-				})-				.then(function (response) {-					if (response.data.hasOwnProperty('error')) {-						showDialogNotice('Error', response.data.message);-					} else {-						$scope.prefix.vrf = response.data.result[0];-					}-				})-				.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-				});--			// If we're allocating from an assignment, set prefix type to host-			// and prefix length to max prefix length for the selected address family.-			if ($scope.from_prefix.type == 'assignment') {-				$scope.prefix.type = 'host';-				if ($scope.from_prefix.family == 4) {-					$scope.prefix_length = 32;-				} else {-					$scope.prefix_length = 128;-				}-			}-		}-	});--	// add another empty "extra attribute" (AVP) input row-	$scope.addAvp = function() {-		$scope.prefix.avps.push({ 'attribute': '', 'value': '' });-	}--	// remove AVP row-	$scope.removeAvp = function(avp) {-		var index = $scope.prefix.avps.indexOf(avp);-		$scope.prefix.avps.splice( index, 1 );-	}--	/*-	 * Submit prefix form - add prefix to NIPAP-	 */-	$scope.submitForm = function () {--		/*-		 * Create object specifying prefix attributes and how it should be-		 * added. For simplicity, we start with a copy of the prefix object-		 * from the scope and add/remove attributes according to what's-		 * required by the different allocation methods.-		 */-		var query_data = angular.copy($scope.prefix);-		query_data.vrf = null;-		query_data.pool = null;--		// Tags, VRF and pool are needed no matter allocation method-		query_data.tags = $scope.prefix.tags.map(function (elem) { return elem.text; });-		if ($scope.prefix.vrf != null) {-			query_data.vrf = $scope.prefix.vrf.id;-		}--		if ($scope.prefix.pool != null) {-			query_data.pool = $scope.prefix.pool.id;-		}--		// Mangle avps-		query_data.avps = {};-		$scope.prefix.avps.forEach(function(avp) {-			if (avp.attribute != '' && avp.value != '') {-				query_data.avps[avp.attribute] = avp.value;-			}-		});--		// Rewrite empty VLAN to null-		query_data.vlan = inputValidationHelpers.emptyToNull($scope.prefix.vlan);--		if ($scope.prefix_alloc_method == 'from-pool') {--			// Allocation from pool requires prefix length, family and pool to-			// allocate from. Prefix not needed.-			delete query_data.prefix;-			query_data.family = $scope.prefix_family;-			if ($scope.pool_use_default_preflen) {-				query_data.prefix_length = $scope.pool_default_preflen;-			} else {-				query_data.prefix_length = $scope.prefix_length;-			}-			query_data.from_pool = $scope.from_pool.id;--		} else if ($scope.prefix_alloc_method == 'from-prefix') {--			// Allocation from prefix requires prefix length and prefix to-			// allocate from. Prefix not needed.-			delete query_data.prefix;-			query_data.prefix_length = $scope.prefix_length;-			query_data['from_prefix'] = [ $scope.from_prefix.prefix ];--		}--		// Send query!-		$http.post('/xhr/add_prefix',-				JSON.stringify(query_data),-				{ 'headers': { 'Content-Type': 'application/json'} })-			.then(function (response){-				if (response.data.hasOwnProperty('error')) {-					showDialogNotice('Error', response.data.message);-				} else {-					$scope.added_prefixes.push(response.data);-				}-			})-			.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-			});--	}+    // prefix method is add - used to customize prefix form template+    $scope.method = 'add';++    // Expose prefixHelpers.enableNodeInput to templates+    $scope.enableNodeInput = prefixHelpers.enableNodeInput;++    // open up the datepicker+    $scope.dpOpen = function ($event) {+        $event.preventDefault();+        $event.stopPropagation();++        $scope.dpOpened = !$scope.dpOpened;+    };++    $scope.prefix_alloc_method = null;+    // Set to true if allocation method was provided in URL+    $scope.prefix_alloc_method_provided = false;++    $scope.from_pool = null;+    // Set to true if the pool to allocate from was provided in the URL+    $scope.from_pool_provided = false;++    $scope.from_prefix = null;+    // Set to true if the prefix to allocate from was provided in the URL+    $scope.from_prefix_provided = false;++    // Set to true if pool has a default prefix length for current address family+    $scope.pool_has_default_preflen = false;++    // Keep track on whether the user wants to use the pool's default prefix+    // length or not+    $scope.pool_use_default_preflen = true;

Identifier 'pool_use_default_preflen' is not in camel case.

BjornPerssonSigma

comment created time in 17 days

Pull request review commentSpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

 nipapAppControllers.controller('PrefixListController', function ($scope, $uibMod  */ nipapAppControllers.controller('PrefixAddController', function ($scope, $routeParams, $http, prefixHelpers, inputValidationHelpers) { -	// prefix method is add - used to customize prefix form template-	$scope.method = 'add';--	// Expose prefixHelpers.enableNodeInput to templates-	$scope.enableNodeInput = prefixHelpers.enableNodeInput;--	// open up the datepicker-	$scope.dpOpen = function($event) {-		$event.preventDefault();-		$event.stopPropagation();--		$scope.dpOpened = !$scope.dpOpened;-	};--	$scope.prefix_alloc_method = null;-	// Set to true if allocation method was provided in URL-	$scope.prefix_alloc_method_provided = false;--	$scope.from_pool = null;-	// Set to true if the pool to allocate from was provided in the URL-	$scope.from_pool_provided = false;--	$scope.from_prefix = null;-	// Set to true if the prefix to allocate from was provided in the URL-	$scope.from_prefix_provided = false;--	// Set to true if pool has a default prefix length for current address family-	$scope.pool_has_default_preflen = false;--	// Keep track on whether the user wants to use the pool's default prefix-	// length or not-	$scope.pool_use_default_preflen = true;-	$scope.pool_default_preflen = null;--	// Keep track of whether the user has chosen to enable the prefix type-	// input fields, when allocating prefix from a pool (ie. to not use the-	// pool's default prefix type)-	$scope.display_type_input_pool = false;--	$scope.prefix_family = 4;-	$scope.prefix_length = null;--	$scope.prefix = {-		prefix: null,-		vrf: null,-		pool: null,-		status: 'assigned',-		description: null,-		comment: null,-		node: null,-		tags: [],-		type: null,-		country: null,-		order_id: null,-		customer_id: null,-		vlan: null,-		monitor: false,-		alarm_priority: null,-		avps: []-	};--	// List of prefixes added to NIPAP-	$scope.added_prefixes = [];--	/*-	 * Handle route parameters (extracted from the URL)-	 */-	// Is allocation method set?-	if ($routeParams.hasOwnProperty('allocation_method')) {-		$scope.prefix_alloc_method = $routeParams.allocation_method;-		$scope.prefix_alloc_method_provided = true;-	}--	// Did we get any allocation parameters (pool ID or prefix ID)?-	if ($routeParams.hasOwnProperty('allocation_method_parameter')) {--		var allocation_parameter = parseInt($routeParams.allocation_method_parameter);--		if ($scope.prefix_alloc_method == 'from-pool') {--			// Allocation method parameter is pool ID - fetch pool-			$scope.from_pool_provided = true;-			$http.post('/xhr/list_pool',-				JSON.stringify({ 'id': allocation_parameter }),-				{ 'headers': { 'Content-Type': 'application/json' } })-				.then(function (response) {-					if (response.data.hasOwnProperty('error')) {-						showDialogNotice('Error', response.data.message);-					} else {-						$scope.from_pool = response.data[0];-					}-				})-				.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-				});--		} else if ($scope.prefix_alloc_method == 'from-prefix') {--			// Allocation method parameter is prefix ID - fetch prefix-			$scope.from_prefix_provided = true;-			$http.post('/xhr/list_prefix',-				JSON.stringify({ 'id': allocation_parameter }),-				{ 'headers': { 'Content-Type': 'application/json' } })-				.then(function (response) {-					if (response.data.hasOwnProperty('error')) {-						showDialogNotice('Error', response.data.message);-					} else {-						$scope.from_prefix = response.data[0];-						$scope.prefix_family = response.data[0].family;-					}-				})-				.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-				});-		}-	}--	/*-	 * Watch for change to 'from_pool' and 'prefix_family' variables-	 */-	$scope.$watchCollection('[ from_pool, prefix_family ]', function(newValue, oldValue){--		if ($scope.from_pool !== null) {--			// We're allocating from a pool - reset from_prefix-			$scope.from_prefix = null;--			if ($scope.from_pool.default_type !== null) {-				$scope.prefix.type = $scope.from_pool.default_type;-				$scope.display_type_input_pool = false;-			} else {-				$scope.display_type_input_pool = true;-			}--			// Extract default prefix length for selected address family-			var def_preflen;-			if ($scope.prefix_family == "4") {-				def_preflen = "ipv4_default_prefix_length";-			} else {-				def_preflen = "ipv6_default_prefix_length";-			}--			if ($scope.from_pool[def_preflen] !== null) {-				$scope.pool_has_default_preflen = true;-				$scope.pool_default_preflen = $scope.from_pool[def_preflen];-				$scope.prefix_length = $scope.from_pool[def_preflen];-			} else {-				$scope.pool_has_default_preflen = false;-				$scope.pool_default_preflen = null;-				$scope.pool_use_default_preflen = false;-				$scope.prefix_length = null;-			}--			if ($scope.from_pool.vrf_id !== null) {-				// fetch VRF data for pool's implied VRF-				$http.post('/xhr/smart_search_vrf',-					JSON.stringify({-						'vrf_id': $scope.from_pool.vrf_id,-						'query_string': ''-						}-					), {-						'headers': { 'Content-Type': 'application/json'}-					})-					.then(function (response) {-						if (response.data.hasOwnProperty('error')) {-							showDialogNotice('Error', response.data.message);-						} else {-							$scope.prefix.vrf = response.data.result[0];-						}-					})-					.catch(function (response) {-						var msg = response.data || "Unknown failure";-						showDialogNotice('Error', response.status + ': ' + msg);-					});-			} else {-				// Pool is missing implied VRF - means the pool is empty!-				$scope.prefix.vrf = null;-			}-		}-	});--	/*-	 * Watch for changes to the 'from_prefix' variable-	 */-	$scope.$watch('from_prefix', function() {--		if ($scope.from_prefix !== null) {--			// We're allocating from a prefix - reset from_pool-			$scope.from_pool = null;--			// Fetch prefix's VRF-			$http.post('/xhr/smart_search_vrf',-				JSON.stringify({-					'vrf_id': $scope.from_prefix.vrf_id,-					'query_string': ''-				}), {-					'headers': { 'Content-Type': 'application/json' }-				})-				.then(function (response) {-					if (response.data.hasOwnProperty('error')) {-						showDialogNotice('Error', response.data.message);-					} else {-						$scope.prefix.vrf = response.data.result[0];-					}-				})-				.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-				});--			// If we're allocating from an assignment, set prefix type to host-			// and prefix length to max prefix length for the selected address family.-			if ($scope.from_prefix.type == 'assignment') {-				$scope.prefix.type = 'host';-				if ($scope.from_prefix.family == 4) {-					$scope.prefix_length = 32;-				} else {-					$scope.prefix_length = 128;-				}-			}-		}-	});--	// add another empty "extra attribute" (AVP) input row-	$scope.addAvp = function() {-		$scope.prefix.avps.push({ 'attribute': '', 'value': '' });-	}--	// remove AVP row-	$scope.removeAvp = function(avp) {-		var index = $scope.prefix.avps.indexOf(avp);-		$scope.prefix.avps.splice( index, 1 );-	}--	/*-	 * Submit prefix form - add prefix to NIPAP-	 */-	$scope.submitForm = function () {--		/*-		 * Create object specifying prefix attributes and how it should be-		 * added. For simplicity, we start with a copy of the prefix object-		 * from the scope and add/remove attributes according to what's-		 * required by the different allocation methods.-		 */-		var query_data = angular.copy($scope.prefix);-		query_data.vrf = null;-		query_data.pool = null;--		// Tags, VRF and pool are needed no matter allocation method-		query_data.tags = $scope.prefix.tags.map(function (elem) { return elem.text; });-		if ($scope.prefix.vrf != null) {-			query_data.vrf = $scope.prefix.vrf.id;-		}--		if ($scope.prefix.pool != null) {-			query_data.pool = $scope.prefix.pool.id;-		}--		// Mangle avps-		query_data.avps = {};-		$scope.prefix.avps.forEach(function(avp) {-			if (avp.attribute != '' && avp.value != '') {-				query_data.avps[avp.attribute] = avp.value;-			}-		});--		// Rewrite empty VLAN to null-		query_data.vlan = inputValidationHelpers.emptyToNull($scope.prefix.vlan);--		if ($scope.prefix_alloc_method == 'from-pool') {--			// Allocation from pool requires prefix length, family and pool to-			// allocate from. Prefix not needed.-			delete query_data.prefix;-			query_data.family = $scope.prefix_family;-			if ($scope.pool_use_default_preflen) {-				query_data.prefix_length = $scope.pool_default_preflen;-			} else {-				query_data.prefix_length = $scope.prefix_length;-			}-			query_data.from_pool = $scope.from_pool.id;--		} else if ($scope.prefix_alloc_method == 'from-prefix') {--			// Allocation from prefix requires prefix length and prefix to-			// allocate from. Prefix not needed.-			delete query_data.prefix;-			query_data.prefix_length = $scope.prefix_length;-			query_data['from_prefix'] = [ $scope.from_prefix.prefix ];--		}--		// Send query!-		$http.post('/xhr/add_prefix',-				JSON.stringify(query_data),-				{ 'headers': { 'Content-Type': 'application/json'} })-			.then(function (response){-				if (response.data.hasOwnProperty('error')) {-					showDialogNotice('Error', response.data.message);-				} else {-					$scope.added_prefixes.push(response.data);-				}-			})-			.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-			});--	}+    // prefix method is add - used to customize prefix form template+    $scope.method = 'add';++    // Expose prefixHelpers.enableNodeInput to templates+    $scope.enableNodeInput = prefixHelpers.enableNodeInput;++    // open up the datepicker+    $scope.dpOpen = function ($event) {+        $event.preventDefault();+        $event.stopPropagation();++        $scope.dpOpened = !$scope.dpOpened;+    };++    $scope.prefix_alloc_method = null;+    // Set to true if allocation method was provided in URL+    $scope.prefix_alloc_method_provided = false;++    $scope.from_pool = null;+    // Set to true if the pool to allocate from was provided in the URL+    $scope.from_pool_provided = false;++    $scope.from_prefix = null;+    // Set to true if the prefix to allocate from was provided in the URL+    $scope.from_prefix_provided = false;++    // Set to true if pool has a default prefix length for current address family+    $scope.pool_has_default_preflen = false;++    // Keep track on whether the user wants to use the pool's default prefix+    // length or not+    $scope.pool_use_default_preflen = true;+    $scope.pool_default_preflen = null;

Identifier 'pool_default_preflen' is not in camel case.

BjornPerssonSigma

comment created time in 17 days

Pull request review commentSpriteLink/NIPAP

Fixing slow load on VRF page and adding functionality for infinite sc…

 nipapAppControllers.controller('PrefixListController', function ($scope, $uibMod  */ nipapAppControllers.controller('PrefixAddController', function ($scope, $routeParams, $http, prefixHelpers, inputValidationHelpers) { -	// prefix method is add - used to customize prefix form template-	$scope.method = 'add';--	// Expose prefixHelpers.enableNodeInput to templates-	$scope.enableNodeInput = prefixHelpers.enableNodeInput;--	// open up the datepicker-	$scope.dpOpen = function($event) {-		$event.preventDefault();-		$event.stopPropagation();--		$scope.dpOpened = !$scope.dpOpened;-	};--	$scope.prefix_alloc_method = null;-	// Set to true if allocation method was provided in URL-	$scope.prefix_alloc_method_provided = false;--	$scope.from_pool = null;-	// Set to true if the pool to allocate from was provided in the URL-	$scope.from_pool_provided = false;--	$scope.from_prefix = null;-	// Set to true if the prefix to allocate from was provided in the URL-	$scope.from_prefix_provided = false;--	// Set to true if pool has a default prefix length for current address family-	$scope.pool_has_default_preflen = false;--	// Keep track on whether the user wants to use the pool's default prefix-	// length or not-	$scope.pool_use_default_preflen = true;-	$scope.pool_default_preflen = null;--	// Keep track of whether the user has chosen to enable the prefix type-	// input fields, when allocating prefix from a pool (ie. to not use the-	// pool's default prefix type)-	$scope.display_type_input_pool = false;--	$scope.prefix_family = 4;-	$scope.prefix_length = null;--	$scope.prefix = {-		prefix: null,-		vrf: null,-		pool: null,-		status: 'assigned',-		description: null,-		comment: null,-		node: null,-		tags: [],-		type: null,-		country: null,-		order_id: null,-		customer_id: null,-		vlan: null,-		monitor: false,-		alarm_priority: null,-		avps: []-	};--	// List of prefixes added to NIPAP-	$scope.added_prefixes = [];--	/*-	 * Handle route parameters (extracted from the URL)-	 */-	// Is allocation method set?-	if ($routeParams.hasOwnProperty('allocation_method')) {-		$scope.prefix_alloc_method = $routeParams.allocation_method;-		$scope.prefix_alloc_method_provided = true;-	}--	// Did we get any allocation parameters (pool ID or prefix ID)?-	if ($routeParams.hasOwnProperty('allocation_method_parameter')) {--		var allocation_parameter = parseInt($routeParams.allocation_method_parameter);--		if ($scope.prefix_alloc_method == 'from-pool') {--			// Allocation method parameter is pool ID - fetch pool-			$scope.from_pool_provided = true;-			$http.post('/xhr/list_pool',-				JSON.stringify({ 'id': allocation_parameter }),-				{ 'headers': { 'Content-Type': 'application/json' } })-				.then(function (response) {-					if (response.data.hasOwnProperty('error')) {-						showDialogNotice('Error', response.data.message);-					} else {-						$scope.from_pool = response.data[0];-					}-				})-				.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-				});--		} else if ($scope.prefix_alloc_method == 'from-prefix') {--			// Allocation method parameter is prefix ID - fetch prefix-			$scope.from_prefix_provided = true;-			$http.post('/xhr/list_prefix',-				JSON.stringify({ 'id': allocation_parameter }),-				{ 'headers': { 'Content-Type': 'application/json' } })-				.then(function (response) {-					if (response.data.hasOwnProperty('error')) {-						showDialogNotice('Error', response.data.message);-					} else {-						$scope.from_prefix = response.data[0];-						$scope.prefix_family = response.data[0].family;-					}-				})-				.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-				});-		}-	}--	/*-	 * Watch for change to 'from_pool' and 'prefix_family' variables-	 */-	$scope.$watchCollection('[ from_pool, prefix_family ]', function(newValue, oldValue){--		if ($scope.from_pool !== null) {--			// We're allocating from a pool - reset from_prefix-			$scope.from_prefix = null;--			if ($scope.from_pool.default_type !== null) {-				$scope.prefix.type = $scope.from_pool.default_type;-				$scope.display_type_input_pool = false;-			} else {-				$scope.display_type_input_pool = true;-			}--			// Extract default prefix length for selected address family-			var def_preflen;-			if ($scope.prefix_family == "4") {-				def_preflen = "ipv4_default_prefix_length";-			} else {-				def_preflen = "ipv6_default_prefix_length";-			}--			if ($scope.from_pool[def_preflen] !== null) {-				$scope.pool_has_default_preflen = true;-				$scope.pool_default_preflen = $scope.from_pool[def_preflen];-				$scope.prefix_length = $scope.from_pool[def_preflen];-			} else {-				$scope.pool_has_default_preflen = false;-				$scope.pool_default_preflen = null;-				$scope.pool_use_default_preflen = false;-				$scope.prefix_length = null;-			}--			if ($scope.from_pool.vrf_id !== null) {-				// fetch VRF data for pool's implied VRF-				$http.post('/xhr/smart_search_vrf',-					JSON.stringify({-						'vrf_id': $scope.from_pool.vrf_id,-						'query_string': ''-						}-					), {-						'headers': { 'Content-Type': 'application/json'}-					})-					.then(function (response) {-						if (response.data.hasOwnProperty('error')) {-							showDialogNotice('Error', response.data.message);-						} else {-							$scope.prefix.vrf = response.data.result[0];-						}-					})-					.catch(function (response) {-						var msg = response.data || "Unknown failure";-						showDialogNotice('Error', response.status + ': ' + msg);-					});-			} else {-				// Pool is missing implied VRF - means the pool is empty!-				$scope.prefix.vrf = null;-			}-		}-	});--	/*-	 * Watch for changes to the 'from_prefix' variable-	 */-	$scope.$watch('from_prefix', function() {--		if ($scope.from_prefix !== null) {--			// We're allocating from a prefix - reset from_pool-			$scope.from_pool = null;--			// Fetch prefix's VRF-			$http.post('/xhr/smart_search_vrf',-				JSON.stringify({-					'vrf_id': $scope.from_prefix.vrf_id,-					'query_string': ''-				}), {-					'headers': { 'Content-Type': 'application/json' }-				})-				.then(function (response) {-					if (response.data.hasOwnProperty('error')) {-						showDialogNotice('Error', response.data.message);-					} else {-						$scope.prefix.vrf = response.data.result[0];-					}-				})-				.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-				});--			// If we're allocating from an assignment, set prefix type to host-			// and prefix length to max prefix length for the selected address family.-			if ($scope.from_prefix.type == 'assignment') {-				$scope.prefix.type = 'host';-				if ($scope.from_prefix.family == 4) {-					$scope.prefix_length = 32;-				} else {-					$scope.prefix_length = 128;-				}-			}-		}-	});--	// add another empty "extra attribute" (AVP) input row-	$scope.addAvp = function() {-		$scope.prefix.avps.push({ 'attribute': '', 'value': '' });-	}--	// remove AVP row-	$scope.removeAvp = function(avp) {-		var index = $scope.prefix.avps.indexOf(avp);-		$scope.prefix.avps.splice( index, 1 );-	}--	/*-	 * Submit prefix form - add prefix to NIPAP-	 */-	$scope.submitForm = function () {--		/*-		 * Create object specifying prefix attributes and how it should be-		 * added. For simplicity, we start with a copy of the prefix object-		 * from the scope and add/remove attributes according to what's-		 * required by the different allocation methods.-		 */-		var query_data = angular.copy($scope.prefix);-		query_data.vrf = null;-		query_data.pool = null;--		// Tags, VRF and pool are needed no matter allocation method-		query_data.tags = $scope.prefix.tags.map(function (elem) { return elem.text; });-		if ($scope.prefix.vrf != null) {-			query_data.vrf = $scope.prefix.vrf.id;-		}--		if ($scope.prefix.pool != null) {-			query_data.pool = $scope.prefix.pool.id;-		}--		// Mangle avps-		query_data.avps = {};-		$scope.prefix.avps.forEach(function(avp) {-			if (avp.attribute != '' && avp.value != '') {-				query_data.avps[avp.attribute] = avp.value;-			}-		});--		// Rewrite empty VLAN to null-		query_data.vlan = inputValidationHelpers.emptyToNull($scope.prefix.vlan);--		if ($scope.prefix_alloc_method == 'from-pool') {--			// Allocation from pool requires prefix length, family and pool to-			// allocate from. Prefix not needed.-			delete query_data.prefix;-			query_data.family = $scope.prefix_family;-			if ($scope.pool_use_default_preflen) {-				query_data.prefix_length = $scope.pool_default_preflen;-			} else {-				query_data.prefix_length = $scope.prefix_length;-			}-			query_data.from_pool = $scope.from_pool.id;--		} else if ($scope.prefix_alloc_method == 'from-prefix') {--			// Allocation from prefix requires prefix length and prefix to-			// allocate from. Prefix not needed.-			delete query_data.prefix;-			query_data.prefix_length = $scope.prefix_length;-			query_data['from_prefix'] = [ $scope.from_prefix.prefix ];--		}--		// Send query!-		$http.post('/xhr/add_prefix',-				JSON.stringify(query_data),-				{ 'headers': { 'Content-Type': 'application/json'} })-			.then(function (response){-				if (response.data.hasOwnProperty('error')) {-					showDialogNotice('Error', response.data.message);-				} else {-					$scope.added_prefixes.push(response.data);-				}-			})-			.catch(function (response) {-					var msg = response.data || "Unknown failure";-					showDialogNotice('Error', response.status + ': ' + msg);-			});--	}+    // prefix method is add - used to customize prefix form template+    $scope.method = 'add';++    // Expose prefixHelpers.enableNodeInput to templates+    $scope.enableNodeInput = prefixHelpers.enableNodeInput;++    // open up the datepicker+    $scope.dpOpen = function ($event) {+        $event.preventDefault();+        $event.stopPropagation();++        $scope.dpOpened = !$scope.dpOpened;+    };++    $scope.prefix_alloc_method = null;+    // Set to true if allocation method was provided in URL+    $scope.prefix_alloc_method_provided = false;++    $scope.from_pool = null;+    // Set to true if the pool to allocate from was provided in the URL+    $scope.from_pool_provided = false;++    $scope.from_prefix = null;+    // Set to true if the prefix to allocate from was provided in the URL+    $scope.from_prefix_provided = false;++    // Set to true if pool has a default prefix length for current address family+    $scope.pool_has_default_preflen = false;++    // Keep track on whether the user wants to use the pool's default prefix+    // length or not+    $scope.pool_use_default_preflen = true;+    $scope.pool_default_preflen = null;++    // Keep track of whether the user has chosen to enable the prefix type+    // input fields, when allocating prefix from a pool (ie. to not use the+    // pool's default prefix type)+    $scope.display_type_input_pool = false;

Identifier 'display_type_input_pool' is not in camel case.

BjornPerssonSigma

comment created time in 17 days

more