diff --git a/LICENSE.md b/LICENSE.md index 7d1785c..a65513a 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -87,5 +87,29 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND Font Awesome Free 5.0.6 by @fontawesome - http://fontawesome.com License - http://fontawesome.com/license (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) + + **Material Icons** + + We have made these icons available for you to incorporate them into your products under the Apache License Version 2.0. + + Feel free to remix and re-share these icons and documentation in your products. + + We'd love attribution in your app's about screen, but it's not required. + +**Roboto Icons** + + These fonts are licensed under the Apache License, Version 2.0. + + You can use them in your products & projects – print or digital, commercial or otherwise. + + This isn't legal advice, please consider consulting a lawyer and see the full license for all details. + +**Oswald Icons** + + These fonts are licensed under the Open Font License. + + You can use them in your products & projects – print or digital, commercial or otherwise. + + This isn't legal advice, please consider consulting a lawyer and see the full license for all details. \ No newline at end of file diff --git a/js/main.js b/js/main.js index 40816fb..02a483d 100644 --- a/js/main.js +++ b/js/main.js @@ -1,3 +1,8 @@ +/** + * main.js. + * The main.js library describes UI actions. like show/hide and update the html element with style based on user interaction. + */ + let attenuator = document.querySelector('#attenuator'); let roadm = document.querySelector('#roadm'); let ILA = document.querySelector('#ILA'); @@ -9,10 +14,12 @@ let singlefiber = document.querySelector('#singlefiber'); let singlepatch = document.querySelector('#singlepatch'); let dualpatch = document.querySelector('#dualpatch'); let ramanamp = document.querySelector('#ramanamp'); - - let drawerclose = document.getElementById('drawer-close') +/** + * Open drawer based on node/fiber/patch/service. + * @param {string} node - The type of component. + */ function openDrawer(node) { switch (node) { case 'attenuator': @@ -187,6 +194,10 @@ function openDrawer(node) { } } +/** + * Close drawer based on node/fiber/patch/service. + * @param {string} node - The type of component. + */ function closeDrawer(node) { switch (node) { case 'attenuator': @@ -238,30 +249,16 @@ function closeDrawer(node) { } } -//sidebar - -// let sidebarleft = document.querySelector('#sidebar'); -// let buttonleft = document.getElementById('lefttoggle'); -// buttonleft.addEventListener("click",function(){ -// sidebarleft.classList.toggle("d-left-none") -// buttonleft.classList.toggle('ml--btn') -// }) - - var tabcontent = document.querySelector(".stp-tab"); var arrowbtn1 = document.querySelector("#toggle-arrow-1"); var arrowbtn2 = document.querySelector("#toggle-arrow-2"); var arrowbtn3 = document.querySelector("#toggle-arrow-3"); var arrowbtn4 = document.querySelector("#toggle-arrow-4"); -//var arrowbtn5 = document.querySelector("#toggle-arrow-5"); var sidebartext = document.querySelectorAll(".sidebar-text"); var sidebartext1 = document.querySelectorAll(".sidebar-text1"); var sidebartext2 = document.querySelectorAll(".sidebar-text2"); var sidebartext3 = document.querySelectorAll(".sidebar-text3"); - - - arrowbtn2.addEventListener("click", function () { tabcontent.classList.toggle('left-59') for (var i = 0; i < sidebartext1.length; i++) { @@ -284,15 +281,11 @@ arrowbtn4.addEventListener("click", function () { sidebartext3[i].classList.toggle("d-none") } }) -//arrowbtn5.addEventListener("click", function () { -// tabcontent.classList.toggle('left-59') -// for (var i = 0; i < sidebartext4.length; i++) { -// sidebartext4[i].classList.toggle("d-none") -// } -//}) - - +/** + * Highlight the steper menu by selection. + * @param {number} index - The menu index. + */ function stepColor(index) { showMenu = 0; modeHighLight(); @@ -331,6 +324,7 @@ function stepColor(index) { break; } } + var btnAddRoadm = "#btnAddRoadm"; var btnAddFused = "#btnAddFused"; var btnAddILA = "#btnAddILA"; @@ -342,6 +336,11 @@ var btnServiceActive = "#btnServiceActive"; var btnAddSinglePatch = "#btnAddSinglePatch"; var btnAddDualPatch = "#btnAddDualPatch"; var btnAddRamAmp = "#btnAddRamAmp"; + +/** + * Highlight node/fiber/patch/service menu by name. + * @param {string} node - The type on component. + */ function modeHighLight(node) { disableFiberService(); showHideDrawerandMenu(); @@ -489,6 +488,7 @@ function modeHighLight(node) { } } +/** Show/Hide the context menu of node/fiber/patch/service. */ function showHideDrawerandMenu() { document.getElementById("roadmMenu").style.display = "none"; document.getElementById("attenuatorMenu").style.display = "none"; diff --git a/js/networkgraph/alea.js b/js/networkgraph/alea.js index fb43429..f26bc98 100644 --- a/js/networkgraph/alea.js +++ b/js/networkgraph/alea.js @@ -1,4 +1,9 @@ -(function (root, factory) { +/** + * alea.js. + * Alea library is a pseudo-random number generator (PRNG). + */ + +(function (root, factory) { if (typeof exports === 'object') { module.exports = factory(); } else if (typeof define === 'function' && define.amd) { diff --git a/js/networkgraph/constraints.js b/js/networkgraph/constraints.js index c0e2843..8e586c5 100644 --- a/js/networkgraph/constraints.js +++ b/js/networkgraph/constraints.js @@ -1,4 +1,16 @@ -function nodeRule(from, to, nodeType) { +/** + * constraints.js + * The constraints library a list of rules for components. It is defining the network topology validation. + */ + + +/** + * Check connections rules between nodes. + * @param {string} from - Source node. + * @param {string} to - Destination node. + * @param {string} nodeType - Node type. + */ +function nodeRule(from, to, nodeType) { var fromConnections = network.getConnectedEdges(from); var toConnections = network.getConnectedEdges(to); var connections = []; @@ -85,6 +97,7 @@ return { message: message, flag: flag }; } +/** Check the ROADM, transceiver link and type rules. */ function checkLink() { var roadmList = network.body.data.nodes.get({ @@ -145,6 +158,7 @@ function checkLink() { return { message: message, flag: flag }; } +/** check the limits of amplifier, attenuator link rules. */ function checkMisLink() { var roadmList = network.body.data.nodes.get({ @@ -219,6 +233,7 @@ function checkMisLink() { return { message: message, flag: flag }; } +/** To check the node type force rules. */ function checkTypeForce() { var transList = network.body.data.nodes.get({ @@ -272,6 +287,7 @@ function checkTypeForce() { return { message: message, flag: flag }; } +/** check the fiber properties rules. */ function checkFiberPro() { var fiberList = network.body.data.edges.get({ @@ -302,6 +318,8 @@ function checkFiberPro() { message = msg.join(' '); return { message: message, flag: flag }; } + +/** Check the node link and type rules on import network JSON file. */ function nodeRuleOnImportJSON() { //checkLink var roadmList = network.body.data.nodes.get({ @@ -384,6 +402,7 @@ function nodeRuleOnImportJSON() { }); } +/** Set fiber/patch/service smooth while on import network JSON file. */ function edgeStyleOnImportJSON() { var edgeList = network.body.data.edges.get(); var cfrom; @@ -439,6 +458,12 @@ function edgeStyleOnImportJSON() { } } + +/** + * Check the node connections and fiber/patch/service rules on import network JSON file. + * @param {string} cfrom - Source node. + * @param {string} cto - Destination node. + */ function nodeValidationInEdge(cfrom, cto) { // start remove highlight once roadm have equal in/out conn var roadmList = []; diff --git a/js/networkgraph/fiber.js b/js/networkgraph/fiber.js index cb61405..7c38ee8 100644 --- a/js/networkgraph/fiber.js +++ b/js/networkgraph/fiber.js @@ -1,4 +1,9 @@ -var addEdgeData = { +/** + * fiber.js. + * The fiber library describes to add a fiber connection between any 2 nodes by dragging from source node to destination and defines the fiber manipulation. + */ + +var addEdgeData = { from: '', to: '' }; @@ -16,6 +21,10 @@ function dualFiberMode() { to: '' }; } +/** + * Enable settings for fiber and reset other settings. + * Set fiber 1 = enable, 0 = disable. + */ function singleFiberMode() { UnSelectAll(); isSingleFiberMode = 1; @@ -29,7 +38,7 @@ function singleFiberMode() { }; } - +/** Check connections rule for dual fiber not single fiber before add it. */ function addFiber() { var srcNode = network.body.data.nodes.get(addEdgeData.from); var DestNode = network.body.data.nodes.get(addEdgeData.to); @@ -77,6 +86,18 @@ function addFiber() { UnSelectAll(); network.addEdgeMode(); } + +/** + * Fiber creation. + * Fiber style and configuration data loaded from configurationdata, styledata json. + * Check connections rules. + * @param {number} cmode - Fiber mode 1 for add. + * @param {string} cfrom - Source node ID. + * @param {string} cto - Destination node ID. + * @param {string} clabel - The Label of the service. + * @param {string} ctext - The Text of the service. + * @param {boolean} isImport - false -> manual add, true -> automattically added while import json. + */ function addFiberComponent(cmode, cfrom, cto, clabel, ctext, isImport) { if (cmode == 1) { @@ -289,6 +310,7 @@ function addFiberComponent(cmode, cfrom, cto, clabel, ctext, isImport) { tempUndo.push(tedge); } } + function dualFiberInsertNode(fiberID, node_type, callback) { var fiberDetails = network.body.data.edges.get(fiberID); var fromNode = network.body.nodes[fiberDetails.from]; @@ -500,6 +522,12 @@ function dualFiberInsertNode(fiberID, node_type, callback) { enableEdgeIndicator(); } +/** + * Insert a node (ROADM/Attenuator/Amplifier/Raman Amplifier) in the middle of selected fiber. + * @param {string} fiberID - Selected fiber ID + * @param {string} node_type - Type of node. + * @param callback - The callback that handles the response.. + */ function singleFiberInsertNode(fiberID, node_type, callback) { var fiberDetails = network.body.data.edges.get(fiberID); @@ -752,6 +780,11 @@ function clearCbxandAccordian() { $('#cbx_clone').prop('checked', false); } +/** + * Populate fiber details by fiber ID. + * @param {string} fiberID - Selected Fiber ID. + * @param callback - The callback that handles the response. + */ function singleFiberEdit(fiberID, callback) { $("#txtLoss_Coefficient").removeClass('input_error'); $('#cbxLength_Based_Loss').prop('checked', false); @@ -817,6 +850,13 @@ function singleFiberEdit(fiberID, callback) { document.getElementById("btnCloseSingleFiber").onclick = clearSingleFiber.bind( ); } + +/** + * Update fiber. + * Update fiber by fiber ID. + * Apply connections rules. + * @param {string} fiberID - Fiber ID. + */ function updateSingleFiber(fiberID) { removeEdgeList = []; var id = fiberID[fiberID.length - 1].id; @@ -918,6 +958,8 @@ function updateSingleFiber(fiberID) { } } + +/** Clear input/teporary data and other settings. */ function clearSingleFiber() { $("#txtSinlgeFiberName").val(''); @@ -967,6 +1009,12 @@ function deleteFiber(fiberList) { enableEdgeIndicator(); } + +/** + * Remove fiber by fiber ID. + * @param {string} fiberID - Component ID. + * @param {boolean} isMultiple - Remove multiple fiber. + */ function removeFiber(fiberID, isMultiple) { var fiber = network.body.data.edges.get(fiberID); @@ -1023,6 +1071,10 @@ function removeFiber(fiberID, isMultiple) { } } +/** + * Displays fiber details when hover the mouse near the single fiber. + * @param {object} params - Fiber details. + */ function displayFiberHover(params) { var fiberDetails = network.body.data.edges.get(params.edge); var fiber_type = ""; diff --git a/js/networkgraph/mynetwork.js b/js/networkgraph/mynetwork.js index 6b26c90..adeb76e 100644 --- a/js/networkgraph/mynetwork.js +++ b/js/networkgraph/mynetwork.js @@ -1,4 +1,9 @@ -var nodes = null; +/** + * mynetwork.js. + * The mynetwork library file describes to initialize the network area using vis.js and defines common functionalities of network components. + */ + +var nodes = null; var edges = null; var network = null; var data = getScaleFreeNetwork(0); @@ -72,7 +77,13 @@ var preScale; var prePosition; var _eqpt_json; var isEqptFile = false; +var isImportJSON = false; +var displayEdgeLabels = false; +var hiddenNodeTextDisplayOptions; +var displayNodeLabels = false; + +/** Hide fiber/patch/service label. */ var hiddenEdgeTextOptions = { edges: { font: { @@ -89,8 +100,8 @@ var hiddenEdgeTextOptions = { } }, }; -var displayEdgeLabels = false; +/** Hide node label. */ var hiddenNodeTextOptions = { nodes: { font: { @@ -100,8 +111,6 @@ var hiddenNodeTextOptions = { } } }; -var hiddenNodeTextDisplayOptions; -var displayNodeLabels = false; $(document).ready(function () { @@ -386,6 +395,12 @@ $(document).ready(function () { $("#importEqptLink").click(function () { $("#importEqpt").click(); }); + + /** + * Read text from import json file. + * @param {string} file - Get path as file. + * @param callback - The callback that handles the response. + */ function readTextFile(file, callback) { var rawFile = new XMLHttpRequest(); rawFile.overrideMimeType("application/json"); @@ -429,6 +444,19 @@ $(document).ready(function () { }); } }); + + /** + * Undo network actions. + * The redo function is used to restores any actions that were previously undone using an undo. + * We stored every undo action detail one by one into array list (tempRedo) like node creation/deletion/updating etc... + * Ex: node creation/deletion/updating: tempRedo.push(nodedata). + * we fetch latest one record from array list (tempRedo) then will check record whether creation/deletion/updating after that will call the relevant action. + * After will stored action details into new array list (tempUndo) then will using pop method to remove record from array list (tempRedo) ex: tempRedo.pop(). + * Ex: node deletion: + * tempUndoo.push(nodedata). + * data.nodes.remove (latest record of tempRedo). + */ + $("#button_undo").on("click", function () { if (tempUndo.length > 0) { var tempData = tempUndo[tempUndo.length - 1]; @@ -580,6 +608,18 @@ $(document).ready(function () { enableEdgeIndicator(); }); + + /** + * Redo network actions. + * The undo function is used to reverse a mistake, such as deleting the wrong element in a network topology. + * We stored every action detail one by one into array list (tempUndo) like node creation/deletion/updating etc... + * ex:node creation/deletion/updating: tempUndo.push(nodedata). + * we fetch latest one record from array list (tempUndo) then will check record whether creation/deletion/updating after that will call the relevant action. + * After will stored action details into new array list (tempRedo) then will using pop method to remove record from array list (tempUndo) ex: tempUndo.pop(). + * Ex: node updating: + * tempRedo.push(nodedata). + * data.nodes.update (latest record of tempUndo). + */ $("#button_redo").on("click", function () { if (tempRedo.length > 0) { var tempData = tempRedo[tempRedo.length - 1]; @@ -670,7 +710,6 @@ $(document).ready(function () { enableEdgeIndicator(); }); - //end undo and redo $("#showHideEle").on("click", function () { hideEdgeLabels(); enableEdgeIndicator(); @@ -712,6 +751,11 @@ $(document).ready(function () { }); }); +/** + * Network view changes by selection. + * Show/Hid the some components menu and options based on selected network view. + * @param {number} view - 1 -> NE view, 2-> Functional view. + */ function networkView(view) { if (view == topologyView.NE_View)//collapsed view /NE view { @@ -759,6 +803,10 @@ function networkView(view) { } } +/** + * Show/Hide the node/fiber/patch/service label by network view. + * @param {number} view - 1 -> NE view, 2-> Functional view. + */ function expandAndCollapseView(view) { var FVEdges = network.body.data.edges.get({ filter: function (item) { @@ -845,6 +893,11 @@ function networkMenuHide() { $("#stepCreateTopology").click(); } } +/** This function is used to show/hide the nodes/fiber/patch/service labels except ROADM. + * Here we udpate the network options. + * Update the model of edge and node color as transparent then set it to network options. + */ + function hideEdgeLabels() { if (!displayEdgeLabels) { // Apply options for hidden edge text @@ -860,6 +913,13 @@ function hideEdgeLabels() { } enableEdgeIndicator(); } + +/** + * Calculate the fiber span loss, length and coefficient. + * @param {string} eleSL - The span length of fiber. + * @param {string} eleLC - The loss coefficient of fiber. + * @param {string} eleSpanLoss - The span loss of fiber. + */ function fiberLengthCal(eleSL, eleLC, eleSpanLoss) { var spanLength = "#" + eleSL; var lossCoefficient = "#" + eleLC; @@ -868,6 +928,12 @@ function fiberLengthCal(eleSL, eleLC, eleSpanLoss) { var loss_coefficient = parseFloat($(lossCoefficient).val()); $(spanLoss).val(span_length * loss_coefficient); } + +/** + * Highlight/Un-Highlight the component menu by node mode and name. + * @param {string} mode - Node mode. + * @param {string} nodename - Node name. + */ function enableDisableNode(mode, nodename) { if (nodeMode == mode) { modeHighLight(); @@ -878,16 +944,28 @@ function enableDisableNode(mode, nodename) { AddNodeMode(mode); } } -//disabled browser right click menu + +/** Disable browser right click options. */ $(document).bind("contextmenu", function (e) { return false; }); + +/** To create random text for token creation. */ var rand = function () { return Math.random().toString(36).substr(2); // remove `0.` }; + +/** To generate token for component creation. + * It will consider as component ID. */ var token = function () { return rand() + rand(); // to make it longer }; + +/** + * Initialize the vis.network,Data and options. + * Define all component events. + * @param {boolean} isImport - True -> Initialize while import network json file, False -> Initialize while page loading. + */ function draw(isImport) { // create a network var container = document.getElementById("mynetwork"); @@ -1393,10 +1471,10 @@ function draw(isImport) { if (sNodes.length > 0) copyDetails = network.body.data.nodes.get(sNodes[sNodes.length - 1].id); else { - if(nodeDatas) + if (nodeDatas) copyDetails = network.body.data.nodes.get(nodeDatas.id); } - + } else copyDetails = network.body.data.nodes.get(sNodes[0].id); @@ -1993,6 +2071,11 @@ function draw(isImport) { hideEdgeLabels(); } } + +/** + * Create container element for display component details when hover mouse on it. + * @param {string} html - Html elements. + */ function htmlTitle(html) { const container = document.createElement("pre"); container.innerHTML = html; @@ -2005,6 +2088,12 @@ function htmlTitle(html) { container.style.fontVariant = commonJSON.font_variant; return container; } + +/** + *Initiate the network initialize by the flag. + * @param {boolean} isImport - True -> Initialize network while import network json file, False -> Will initialize while page loading. + */ + function init(isImport) { if (isImport) { draw(isImport); @@ -2015,6 +2104,13 @@ function init(isImport) { }, 1000); } } + +/** + * Export/Save the network topology as a JSON file. + * The JSON file data's are loaded from network dataset. like nodes, edges. + * The schema of the JSON file will match the given JSON file like Equipment_JSON_MOD2.json. + * @param {boolean} isSaveNetwork - True -> Save network topology, False -> Export network topology. + */ function exportNetwork(isSaveNetwork) { var nodeList = []; var edgeList = []; @@ -2232,10 +2328,17 @@ function exportNetwork(isSaveNetwork) { saveAs(blob, filename); } + +/** Hide the loader after completion of action. */ function hideLoader() { $('#loader').hide(); $("#importEqpt").val(''); } + +/** + * This function is used to load the equipment configuration data from the import json file. + * @param {boolean} isFileUpload - True -> Load data from import network json, False -> Load data from default equipment configuration json. + */ function load_EqptConfig(isFileUpload) { try { if (!eqpt_config['tip-photonic-simulation:simulation'] || !eqpt_config['tip-photonic-equipment:transceiver'] || !eqpt_config['tip-photonic-equipment:fiber'] || !eqpt_config['tip-photonic-equipment:amplifier']) { @@ -2306,6 +2409,11 @@ function handleFileLoad(event) { _import_json = event.target.result; importNetwork(); } + +/** + * This function is used to load all nodes element data into dataset from import json file. + * @param {number} index - Index number for get node details from import json. + */ function importNode(index) { var nodeDetails = ""; var shape = ""; @@ -2449,6 +2557,11 @@ function importNode(index) { }); } + +/** + * This function is used to load all fiber/patch/service element data into dataset from import json file. + * @param {number} index - Index number for get edge details from import json. + */ function importEdge(index) { var edgeData = _import_json["network"][0]['ietf-network-topology:link'][index]; var to = edgeData["destination"]["dest-node"]; @@ -2485,10 +2598,17 @@ function importEdge(index) { addServiceComponent(1, from, to, labelvalue, textvalue, true); } } + +/** + * Get random point to displays node if not available lat, long in import network json file. + * @param {number} min - Minimum of random number. + * @param {number} max - Maximum of random number. + */ function getRandomNumberBetween(min, max) { return Math.floor(Math.random() * (max - min + 1) + min); } -var isImportJSON = false; + +/** This is used to load the network component data from import network json file. */ function importNetwork() { try { importNodes = []; @@ -2564,6 +2684,12 @@ function importNetwork() { } draw(true); } + +/** + * Loop through the node dataset and get some properties then store it into array list. + * It is return node dataset. + * @param {object} data - Dataset of node. + */ function getNodeData(data) { data.forEach(function (elem, index, array) { importNodes.push({ @@ -2586,6 +2712,12 @@ function getNodeData(data) { return new vis.DataSet(importNodes); } + +/** + * Get node details by ID. + * @param {object} data - Node details. + * @param {string} id - The ID of destination node component. + */ function getNodeById(data, id) { for (var n = 0; n < data.length; n++) { if (data[n].id == id) { @@ -2596,6 +2728,12 @@ function getNodeById(data, id) { throw "cannot find id '" + id + "' in data"; } + +/** + * Loop through the edge dataset and assign some properties then store it into array list. + * It is return edge dataset. + * @param {object} data - Dataset of edge. edge like fiber/patch/service. + */ function getEdgeData(data) { data.forEach(function (elem) { @@ -2636,13 +2774,19 @@ function getEdgeData(data) { return new vis.DataSet(importEdges); } + +/** Save the network topology. */ function SaveNetwork() { exportNetwork(true); } + +/** Clear component selection. */ function UnSelectAll() { network.unselectAll(); remove_NodeFiberHighlight(); } + +/** Capture network topology as image file. */ function captureImage() { network.fit(); html2canvas(document.querySelector("#mynetwork"), { @@ -2657,6 +2801,10 @@ function captureImage() { }); return false; } + +/** Disable fiber/patch/service mode. + * Reteset the data values. + */ function disableFiberService() { nodeMode = ""; @@ -2678,6 +2826,12 @@ function disableFiberService() { to: '' }; } + +/** + * Check source and destination node have same connections. + * @param {string} fromNode - Source node ID. + * @param {string} toNode - Destination node ID. + */ function checkfiberconnection(fromNode, toNode) { var edgesarr = network.body.data.edges.get(); var flag = false; @@ -2689,6 +2843,12 @@ function checkfiberconnection(fromNode, toNode) { } return flag; } + +/** + * This function is used to add multiple single fiber / patch and service between same set of nodes and re - arrange them one by one. + * @param {string} cfrom - Source node ID. + * @param {string} cto - Destination node ID. + */ function multipleFiberService1(cfrom, cto) { var connectedFiber = network.getConnectedEdges(cfrom); @@ -2724,6 +2884,12 @@ function multipleFiberService1(cfrom, cto) { else return fiberJSON.options.smooth; } + +/** + * This function is used to add multiple single fiber / patch and service between same set of nodes and re - arrange them one by one. + * @param {string} cfrom - Source node ID. + * @param {string} cto - Destination node ID. + */ function multipleFiberService(cfrom, cto) { var connectedFiber = network.getConnectedEdges(cfrom); connectedFiber.push(network.getConnectedEdges(cto)); @@ -2769,6 +2935,16 @@ function multipleFiberService(cfrom, cto) { } }); } + +/** + * Count fiber/patch and service connections between same set of node. + * @param {number} isdualfiber - True -> Dual fiber connection count. + * @param {number} issinglefiber - True -> Single fiber connection count. + * @param {number} isservice - True - > Service connection count. + * @param {number} ispatch - True -> Single patch connection count. + * @param {string} cfrom - Source node ID. + * @param {string} cto - Destination node ID. + */ function countFiberService(isdualfiber, issinglefiber, isservice, ispatch, cfrom, cto) { var conCount = 1; var connectedFiber = network.getConnectedEdges(cfrom); @@ -2806,7 +2982,12 @@ function countFiberService(isdualfiber, issinglefiber, isservice, ispatch, cfrom }); return conCount; } -//check node have connection + +/** + * Check node component have connection. + * @param {string} from -Source node ID. + * @param {string} to - Destination node ID . + */ function checkNodeConnection(from, to) { var flag = false; var fiberList = network.getConnectedEdges(from); @@ -2819,7 +3000,12 @@ function checkNodeConnection(from, to) { }); return flag; } -//check node have service connection + +/** + * Check node component have a service connection. + * @param {string} from - Source node ID. + * @param {string} to - Destination node ID. + */ function checkNodeServiceConnection(from, to) { var flag = false; var fiberList = network.getConnectedEdges(from); @@ -2835,6 +3021,13 @@ function checkNodeServiceConnection(from, to) { }); return flag; } + +/** + * Restriction to remove transceiver node connection(fiber/patch) while transceiver having service. + * @param {number} from - Source node ID. + * @param {number} to - Destination node ID. + * @param {string} edgeType - The type of fiber/patch/service. + */ function checkFiberPatchServiceCon(from, to, edgeType) { var isOk = false; var nodeDetails = network.body.data.nodes.get(from); @@ -2885,12 +3078,18 @@ function checkFiberPatchServiceCon(from, to, edgeType) { return isOk; } + +/** + * Close context menu by menu ID. + * @param {string} menuID - The ID of menu. + */ function closeMenu(menuID) { document.getElementById(menuID).style.display = "none"; UnSelectAll(); } -//append node,preamp, booster type + +/** Append node,preamp and booster type to dropdown input control. */ function appendSinglePreAmpandBoosterType() { if (eqpt_config['tip-photonic-equipment:amplifier']) { @@ -2901,7 +3100,11 @@ function appendSinglePreAmpandBoosterType() { }); } } -//append node, preamp, booster type for dynamic ele + +/** + * Append node, preamp, booster type for dynamically generate element. + * @param {string} ddlID - The ID of dynamic input control. like dropdown. + */ function appendPreAmpandBoosterType(ddlID) { var preAmpType = []; var boosterType = []; @@ -2923,7 +3126,13 @@ function appendPreAmpandBoosterType(ddlID) { }); } } -//show context menu on righ click of the component + +/** + * show context menu near by selected component. + * @param {string} x - The point of selected component. + * @param {string} y - The point of selected component. + * @param {string} menu - Html element ID. + */ function showContextMenu(x, y, menu) { showHideDrawerandMenu(); var windowHeight = $(window).height() / 2; @@ -2955,31 +3164,38 @@ function showContextMenu(x, y, menu) { } document.getElementById(menu).style.display = "block"; } -//show fiber and service details when hover the mouse over on it + +/** + * Show the element for displays fiber, service and node components details when hover the mouse over on it. + * @param {string} x - left side menu. + * @param {string} y - bottom of the menu. + * @param {string} menu - Element ID. + */ function showHoverDiv(x, y, menu) { var windowHeight = $(window).height() / 2; var windowWidth = $(window).width() / 2; var element = "#" + menu; if (y > windowHeight && x <= windowWidth) { + //Bottom-left part of window $(element).css("left", x); $(element).css("bottom", $(window).height() - y); $(element).css("right", "auto"); $(element).css("top", "auto"); } else if (y > windowHeight && x > windowWidth) { - //When user click on bottom-right part of window + //Bottom-right part of window $(element).css("right", $(window).width() - x); $(element).css("bottom", $(window).height() - y); $(element).css("left", "auto"); $(element).css("top", "auto"); } else if (y <= windowHeight && x <= windowWidth) { - //When user click on top-left part of window + //Top-left part of window $(element).css("left", x); $(element).css("top", y); $(element).css("right", "auto"); $(element).css("bottom", "auto"); } else { - //When user click on top-right part of window + //Top-right part of window $(element).css("right", $(window).width() - x); $(element).css("top", y); $(element).css("left", "auto"); @@ -2987,6 +3203,8 @@ function showHoverDiv(x, y, menu) { } document.getElementById(menu).style.display = "block"; } + +/** To check network topology have components. */ function networkValidation() { var flag = false; if (network.body.data.nodes.get().length > 0 || network.body.data.edges.get().length > 0) @@ -2997,6 +3215,14 @@ function networkValidation() { return flag; } + +/** + * To load ROADM component type to dropdown control. + * @param {string} fiberID - The ID of fiber component. + * @param {string} nodeID - The ID of node component. + * @param {string} node_type - Type of ROADM component. + * @param {string} appendElement - Html element for loading component type. + */ function loadRoadmType(fiberID, nodeID, node_type, appendElement) { var appendDiv = "#" + appendElement var fiberDetails = network.body.data.edges.get(fiberID); @@ -3028,6 +3254,12 @@ function loadRoadmType(fiberID, nodeID, node_type, appendElement) { getRoadmDetails(fiberID, node_type); } } + +/** + * Generate accordian and dropdown element for loading type. + * @param {string} label - The label of component. + * @param {string} ddlEleID - Dropdown element for loading component type. + */ function generateAccordianEle(label, ddlEleID) { var eleHtml = ""; eleHtml += "
"; @@ -3036,6 +3268,12 @@ function generateAccordianEle(label, ddlEleID) { eleHtml += "
"; return eleHtml; } + +/** + * Get ROADM component details by fiber ID. + * @param {string} fiberID - Fiber component ID. + * @param {string} node_type - The type of component. + */ function getRoadmDetails(fiberID, node_type) { if (_roadmListDB({ roadm_fiber_id: fiberID }).count() > 0) { var roadmDetails = _roadmListDB({ roadm_fiber_id: fiberID }).first(); @@ -3055,6 +3293,13 @@ function getRoadmDetails(fiberID, node_type) { clearILA(); } } + +/** + * Get next level of fiber/patch/service label. + * @param {string} from - Source node ID. + * @param {string} to - Destination node ID. + * @param {string} component_type - The type of component. + */ function getLabel(from, to, component_type) { var flabel; var tlabel; @@ -3071,6 +3316,15 @@ function getLabel(from, to, component_type) { return component_type + " " + flabel + ' - ' + tlabel; } + +/** + * This function is used to store simulation parameters in session storage as JSON format. + * @param {number} fre_min - Frequency-max value. + * @param {number} frq_max - Frequency-min value. + * @param {number} spacing - Spacings. + * @param {number} channel - Number of channels. + * @param {number} margin - System margin. + */ function saveSimulations(fre_min, frq_max, spacing, channel, margin) { var simulationPara = { "frequency-min": fre_min, @@ -3081,6 +3335,13 @@ function saveSimulations(fre_min, frq_max, spacing, channel, margin) { } sessionStorage.setItem("simulationParameters", JSON.stringify(simulationPara)); } + +/** + * This function is used to show alert message. + * @param {string} messageType - Type of message.ex : Success/Info/Error/Warning. + * @param {string} textmsg - Message content. + * @param {boolean} removeTimeout - Set timeout for alert message. + */ function showMessage(messageType, textmsg, removeTimeout) { $("#img_src").show(); switch (messageType) { @@ -3151,6 +3412,12 @@ function showMessage(messageType, textmsg, removeTimeout) { } + +/** + * This function is used to set/remove time interval for alert message. + * @param {number} targetEle - Target of toaster element like. Success/Warning/Error... + * @param {number} removeTimeout - Remove the interval time for alert message . + */ function clearAndSetTimeout(targetEle, removeTimeout) { const highestId = window.setTimeout(() => { for (let i = highestId; i >= 0; i--) { @@ -3164,10 +3431,17 @@ function clearAndSetTimeout(targetEle, removeTimeout) { }, 6000); } } + +/** To enable fiber/patch/service mode. */ function enableEdgeIndicator() { if (isDualFiberMode == 1 || isSingleFiberMode == 1 || isSinglePatchMode == 1 || isDualPatchMode == 1 || isAddService == 1) network.addEdgeMode(); } + +/** + * This function is used to check the node link, mis-link, fiber properties and consolidate all error list. + * @param {number} isTime - True -> remove time interval for error summary list. + */ function topologyValidation(isTime) { //removeHighlight(); var flag = false; @@ -3202,6 +3476,14 @@ function topologyValidation(isTime) { } return flag; } + +/** + * Focus the error componets. + * Focus the node/fiber/patch/service components by span error ID. + * Update the components for highlight error component to set image, size, is_error, color properties by span error ID. + * @param {string} ID - Node/Fiber ID. + * @param {number} type - Component type. + */ function focusNodeFiber(ID, type) { removeHighlight(); UnSelectAll(); @@ -3233,6 +3515,12 @@ function focusNodeFiber(ID, type) { network.body.data.edges.update([{ id: ID, pre_color: edgeDetails.color, color: singleFiberJSON.options.err_color, is_error: true }]); } } + +/** + * To remove focused error component highlight. + * Update node component to set image, size, is_error by focused component ID. + * Update fiber/patch/service components to set color, is_error by focused component ID. + */ function removeHighlight() { var errNodes = network.body.data.nodes.get({ @@ -3260,6 +3548,12 @@ function removeHighlight() { }); } } + +/** + * To remove span error element on error summary list. + * @param {string} item - Node ID. + * @param {boolean} transUpdate - True -> remove span error element for transceiver, False -> remove rest of span error. + */ function removeSpanInError(item, transUpdate) { var image; @@ -3288,6 +3582,8 @@ function removeSpanInError(item, transUpdate) { $(removeID).remove(); checkErrorFree(); } + +/** To clear summary error element if there is no any error. */ function checkErrorFree() { var roadmRule = $("#spanEven").find('p').length; var linkRule = $("#spanMisLink").find('p').length; @@ -3310,12 +3606,23 @@ function checkErrorFree() { }); } } + +/** + * Realtime update of summary error list. + * To do any action with component while error chec active on active, summary error list automatically update by component action. + */ function realUpdate() { if ($("#div_toaster").is(":visible") && !$("#img_src").is(":visible")) { $("#btnValidation").click(); } } +/** + * To reset component selection/highlight. + * Get all highlighted components by is_highlight. + * Update the node components to set is_highlight, image properties by selected component ID. + * Update the fiber/patch/service components to set is_highlight, shadow properties by selected component ID. + * */ function remove_NodeFiberHighlight() { var hNodes = network.body.data.nodes.get({ filter: function (item) { diff --git a/js/networkgraph/node.js b/js/networkgraph/node.js index f8c24cd..b4cfb36 100644 --- a/js/networkgraph/node.js +++ b/js/networkgraph/node.js @@ -1,4 +1,13 @@ -//1-roadm, 2-amp, 3-fused, 4-transceiver, 6- raman amp +/** + * node.js. + * The node can be defined as the connection point of "ROADM, Attenuator, Transceiver, Amplifier and Raman Amplifier" and defines the node manipulations. + */ + + +/** + * Check node Mode 1-roadm, 2-amp, 3-fused, 4-transceiver, 6- raman amp + * @param {Number} nodemode - Mode of the component. + */ function AddNodeMode(nodemode) { nodeMode = nodemode; @@ -8,6 +17,13 @@ function AddNodeMode(nodemode) { } } +/** + * Node creation by node mode. + * Node will be placed based on co-ordidate points x,y. + * Node style and configuration data loaded from configurationdata, styledata json. + * @param {object} data - The data of the component. + * @param callback - The callback that handles the response. + */ function addNodes(data, callback) { var nodeDetails = ""; @@ -110,6 +126,11 @@ function addNodes(data, callback) { tempUndo.push(network.body.data.nodes.get(data.id)); } +/** + * Populate ROADM component details by node ID. + * @param {string} nodeID - The ID of the ROADM component. + * @param callback - The callback that handles the response. + */ function roadmEdit(nodeID, callback) { _roadmListDB().remove(); document.getElementById("roadmMenu").style.display = "none"; @@ -174,6 +195,12 @@ function roadmEdit(nodeID, callback) { document.getElementById("btnCloseRoadm").onclick = clearRoadm.bind( ); } + +/** + * Update ROADM. + * Update ROADM label, type by ROADM ID. + * @param {string} nodeID - The ID of the ROADM component + */ function updateRoadm(nodeID) { removeNodeList = []; if (nameLengthValidation("txtRoadmName")) { @@ -252,6 +279,8 @@ function updateRoadm(nodeID) { } } + +/** Clear input/teporary data and other settings. */ function clearRoadm() { $("#txtRoadmName").val(''); $("#divRoadmPro").empty(); @@ -261,6 +290,11 @@ function clearRoadm() { UnSelectAll(); } +/** + * Check ROADM component rules and update check-errors summary. + * @param {string} id - The ID of ROADM component. + * @param {string} rtype - The type of ROADM component. + */ function realUpdate_Roadm(id, rtype) { var roadmtype = rtype; var connectedEges = network.getConnectedEdges(id); @@ -291,6 +325,11 @@ function realUpdate_Roadm(id, rtype) { } } +/** + * Populate Attenuator component details by node ID. + * @param {string} nodeID - The ID of the Attenuator component. + * @param callback - The callback that handles the response. + */ function attenuatorEdit(nodeID, callback) { document.getElementById("attenuatorMenu").style.display = "none"; openDrawer('attenuator'); @@ -306,6 +345,12 @@ function attenuatorEdit(nodeID, callback) { document.getElementById("btnCloseAttenuator").onclick = clearAttenuator.bind( ); } + +/** + * Update Attenuator. + * Update Attenuator label, type by Attenuator ID. + * @param {string} nodeID - The ID of the Attenuator component + */ function updateAttenuator(nodeID) { var id = nodeID; @@ -328,6 +373,8 @@ function updateAttenuator(nodeID) { } } + +/** Clear input/teporary data and other settings. */ function clearAttenuator() { $("#txtAttenuatorName").val(''); closeDrawer('attenuator'); @@ -404,6 +451,11 @@ function clearILA() { _roadmListDB().remove(); } +/** + * Populate Amplifier component details by node ID. + * @param {string} nodeID - The ID of the Amplifier component. + * @param callback - The callback that handles the response. + */ function amplifierEdit(nodeID, callback) { document.getElementById("amplifierMenu").style.display = "none"; openDrawer('amplifier'); @@ -448,6 +500,12 @@ function amplifierEdit(nodeID, callback) { document.getElementById("btnCloseAmplifier").onclick = clearAmplifier.bind( ); } + +/** + * Update Amplifier. + * Update Amplifier label, type by Amplifier ID. + * @param {string} nodeID - The ID of the Amplifier component + */ function updateAmplifier(nodeID) { removeNodeList = []; if (nameLengthValidation("txtAmplifierName")) { @@ -508,12 +566,20 @@ function updateAmplifier(nodeID) { } } + +/** Clear input/teporary data and other settings. */ function clearAmplifier() { $("#txtAmplifierName").val(''); $("#ddlAmplifierType").val(''); closeDrawer('amplifier'); UnSelectAll(); } + +/** + * Check Amplifier component rules and update check-errors summary. + * @param {string} id - The ID of Amplifier component. + * @param {string} rtype - The type of Amplifier component. + */ function realUpdate_Amplifier(id, rtype) { var amptype = rtype; var connectedEdges; @@ -544,6 +610,11 @@ function realUpdate_Amplifier(id, rtype) { } +/** + * Populate Raman Amplifier component details by node ID. + * @param {string} nodeID - The ID of the Raman Amplifier component. + * @param callback - The callback that handles the response. + */ function ramanAmpEdit(nodeID, callback) { document.getElementById("ramanAmpMenu").style.display = "none"; openDrawer('ramanamp'); @@ -601,6 +672,12 @@ function ramanAmpEdit(nodeID, callback) { document.getElementById("btnCloseRamanAmp").onclick = clearRamanAmp.bind( ); } + +/** + * Update Raman Amplifier. + * Update Raman Amplifier label, type by Raman Amplifier ID. + * @param {string} nodeID - The ID of the Raman Amplifier component + */ function updateRamanAmp(nodeID) { removeNodeList = []; if (nameLengthValidation("txtRamanAmpName")) { @@ -665,6 +742,8 @@ function updateRamanAmp(nodeID) { } } } + +/** Clear input/teporary data and other settings. */ function clearRamanAmp() { $("#txtRamanAmpName").val(''); $("#ddlRamanAmpType").val(''); @@ -672,6 +751,12 @@ function clearRamanAmp() { closeDrawer('ramanamp'); UnSelectAll(); } + +/** + * Check Raman Amplifier component rules and update check-errors summary. + * @param {string} id - The ID of Raman Amplifier component. + * @param {string} rtype - The type of Raman Amplifier component. + */ function realUpdate_RamanAmp(id, rtype) { var amptype = rtype; var connectedEdges; @@ -705,6 +790,11 @@ function realUpdate_RamanAmp(id, rtype) { } +/** + * Populate Transceiver component details by node ID. + * @param {string} nodeID - The ID of the Transceiver component. + * @param callback - The callback that handles the response. + */ function transceiverEdit(nodeID, callback) { document.getElementById("transceiverMenu").style.display = "none"; openDrawer('transceiver'); @@ -749,6 +839,12 @@ function transceiverEdit(nodeID, callback) { document.getElementById("btnCloseTransceiver").onclick = clearTransceiver.bind( ); } + +/** + * Update Transceiver. + * Update Transceiver label, type by Transceiver ID. + * @param {string} nodeID - The ID of the Transceiver component + */ function updateTransceiver(nodeID) { removeNodeList = []; if (nameLengthValidation("txtTransceiverName")) { @@ -906,6 +1002,8 @@ function updateTransceiver(nodeID) { } } + +/** Clear input/teporary data and other settings. */ function clearTransceiver() { $("#txtTransceiverName").val(''); $("#ddlTransceiverType").val(''); @@ -913,6 +1011,12 @@ function clearTransceiver() { closeDrawer('transceiver'); UnSelectAll(); } + +/** + * Check Transceiver component rules and update check-errors summary. + * @param {string} id - The ID of Transceiver component. + * @param {string} rtype - The type of Transceiver component. + */ function realUpdate_Transceiver(id, rtype) { var connectedEges = network.getConnectedEdges(id); var tempEdge = []; @@ -978,6 +1082,12 @@ function deleteNode(nodeList) { UnSelectAll(); } + +/** + * Remove node by node ID. + * @param {string} nodeID - Component ID. + * @param {boolean} isMultiple - Remove multiple node. + */ function removeNodes(nodeID, isMultiple) { var nodeDetails = network.body.data.nodes.get(nodeID); var node_type = nodeDetails.node_type; @@ -1033,6 +1143,12 @@ function removeNodes(nodeID, isMultiple) { network.body.data.nodes.remove(nodeID); } +/** + * Bind pasteNode method. + * Copy node parameters by selected node ID + * @param {string} nodeID - Component ID. + * @param callback - The callback that handles the response. + */ function copyNode(nodeID, callback) { showHideDrawerandMenu(); isCopy = true; @@ -1044,6 +1160,12 @@ function copyNode(nodeID, callback) { ); } + +/** + * Create new node by copied node parameters. + * Node will be placed based on co-ordidates. + * @param {string} nodeId - Copied node ID. + */ function pasteNode(nodeId) { if (isCopy) { isCopy = false; @@ -1128,6 +1250,12 @@ function pasteNode(nodeId) { } } +/** + * Copy node template by selected node ID. + * Validate the node template by type, category + * @param {string} nodeID - The ID of Copied node template. + * @param callback - The callback that handles the response. + */ function copyNodeTemplate(nodeID, callback) { var isOk = false; var nodeDetails = network.body.data.nodes.get(nodeID); @@ -1162,12 +1290,27 @@ function copyNodeTemplate(nodeID, callback) { function cancelCopyTemplate(nodeId) { clearNodeTemplate(); } + +/** + * Apply copied template to specified ROADM node. + * Check node rules and update check-errors summary. + * @param {string} nodeID - The ID of the destination node. + * @param {string} roadm_type - Coponent type. + */ function applyRoadmTemplate(nodeID, roadm_type) { network.body.data.nodes.update({ id: nodeID, roadm_type: roadm_type }); realUpdate_Roadm(nodeID, roadm_type); } + +/** + * Apply copied template to specified Transceiver node. + * Check node rules and update check-errors summary. + * @param {string} nodeID - The ID of the destination node. + * @param {string} node_type - Node type. + * @param {string} trans_type - Transceiver type. + */ function applyTransceiverTemplate(nodeID, node_type, trans_type) { var id = nodeID; var connectedEdges = network.getConnectedEdges(id); @@ -1213,12 +1356,20 @@ function applyTransceiverTemplate(nodeID, node_type, trans_type) { } return isOk; } +/// +/// To apply copied template to specified Amplifier node. +/// Apply node rules. +/// function applyAmpTemplate(nodeID, amp_type) { network.body.data.nodes.update({ id: nodeID, amp_type: amp_type }); realUpdate_Amplifier(nodeID, amp_type); } +/// +/// To apply copied template to specified Raman Amplifier node. +/// Apply node rules. +/// function applyRamanAmpTemplate(nodeID, amp_type, category) { network.body.data.nodes.update({ id: nodeID, amp_type: amp_type, category: category @@ -1226,6 +1377,13 @@ function applyRamanAmpTemplate(nodeID, amp_type, category) { realUpdate_RamanAmp(nodeID, amp_type); } + +/** + * Apply copied template to specified node. + * Apply node rules. + * @param {object} nodes - Selected destination nodes for apply template. + * @param callback - The callback that handles the response. + */ function applyTemplate(nodes, callback) { var isUpdated = false; if (isCopyPara) { @@ -1317,6 +1475,8 @@ function applyTemplate(nodes, callback) { clearNodeTemplate(); } } + +/** Reset the copied template data. */ function clearNodeTemplate() { isCopyPara = false; copiedNodeID = ""; @@ -1327,6 +1487,10 @@ function clearNodeTemplate() { remove_NodeFiberHighlight(); } +/** + * Displays node name, type parameter when hover the mouse near the node. + * @param {object} params - Node details. + */ function displayNodesHover(params) { var nodeDetails = network.body.data.nodes.get(params.node); if (nodeDetails.component_type == roadmJSON.component_type) { @@ -1348,6 +1512,11 @@ function displayNodesHover(params) { showHoverDiv(params.event.pageX, params.event.pageY, "hoverDiv"); } +/** + * Get next level of node label name by node type/amplifer category. + * @param {string} node_type - Node type. + * @param {string} amp_category - Amplifier category. + */ function nodeName(node_type, amp_category) { const number = []; var nodeList = []; @@ -1419,6 +1588,11 @@ function nodeName(node_type, amp_category) { } +/** + * Set warning icons to imcompleted node by node ID. + * Update node size, image by node ID. + * @param {string} nodeID - Node ID. + */ function addNodeHighlight(nodeID) { var nodeDetails = network.body.data.nodes.get(nodeID); if (nodeDetails.node_type == roadmJSON.node_type) diff --git a/js/networkgraph/patch.js b/js/networkgraph/patch.js index 00ae1f4..483c635 100644 --- a/js/networkgraph/patch.js +++ b/js/networkgraph/patch.js @@ -1,4 +1,9 @@ -var isDualPatchMode = 0; +/** + * patch.js + * The patch library describes to add a patch connection between any 2 nodes by dragging from source node to destination and defines the patch manipulation. + */ + +var isDualPatchMode = 0; var isSinglePatchMode = 0; var addPatchData = { from: '', @@ -16,6 +21,11 @@ function dualPatchMode() { to: '' }; } + +/** + * Enable settings for patch and reset other settings. + * Set patch 1 = enable, 0 = disable. + */ function singlePatchMode() { UnSelectAll(); isDualPatchMode = 0; @@ -59,6 +69,17 @@ function addSinglePatch() { UnSelectAll(); network.addEdgeMode(); } + +/** + * Patch creation. + * Patch style and configuration data loaded from configurationdata, styledata json. + * @param {number} cmode - Service mode 1 for add. + * @param {string} cfrom - Source node ID. + * @param {string} cto - Destination node ID. + * @param {string} clabel - The Label of the service. + * @param {string} ctext - The Text of the service. + * @param {boolean} isImport - false -> manual add, true -> automattically added while import json. + */ function addPatchComponent(cmode, cfrom, cto, clabel, ctext, isImport) { if (cmode == 1) { @@ -136,6 +157,12 @@ function addPatchComponent(cmode, cfrom, cto, clabel, ctext, isImport) { tempUndo.push(tedge); } } + +/** + * Populate patch details by patch ID. + * @param {string} patchID - Patch ID. + * @param callback - The callback that handles the response. + */ function singlePatchEdit(patchID, callback) { document.getElementById("singlePatchMenu").style.display = "none"; var edgeDetails = network.body.data.edges.get(patchID); @@ -149,6 +176,12 @@ function singlePatchEdit(patchID, callback) { document.getElementById("btnCloseSinglePatch").onclick = clearSinglePatch.bind( ); } + +/** + * Update patch. + * Update patch label, text by patch ID. + * @param {string} patchID - patch ID. + */ function updateSinglePatch(patchID) { var id = patchID; @@ -172,6 +205,11 @@ function updateSinglePatch(patchID) { } } + +/** + * Remove patch by patch ID. + * @param {string} patchID - patch ID. + */ function deletePatch(patchID) { var patchDetails = network.body.data.edges.get(patchID); var patchLabel = patchDetails.label; @@ -192,6 +230,8 @@ function deletePatch(patchID) { UnSelectAll(); enableEdgeIndicator(); } + +/** Clear input/teporary data and other settings. */ function clearSinglePatch() { $("#txtSinglePatchName").val(''); diff --git a/js/networkgraph/service.js b/js/networkgraph/service.js index b48f957..13f4a9c 100644 --- a/js/networkgraph/service.js +++ b/js/networkgraph/service.js @@ -1,8 +1,18 @@ -var isAddService = 0; +/** + * service.js + * The Service it is also same as the connectivity path between 2 transceiver nodes. This library file defines the service manipulation. + */ + +var isAddService = 0; var addServiceData = { from: '', to: '' }; + +/** + * Enable settings for service and reset other settings. + * Set service 1 = enable, 0 = disable. + */ function addServiceMode() { UnSelectAll(); isAddService = 1; @@ -15,6 +25,8 @@ function addServiceMode() { to: '' }; } + +/** Check service connections rule before add it. */ function addService() { var fromDetails = network.body.data.nodes.get(addServiceData.from); @@ -50,6 +62,16 @@ function addService() { UnSelectAll(); } + +/** + * Service creation. + * Service style and configuration data loaded from configurationdata, styledata json. + * @param {number} cmode - Service mode 1 for add. + * @param {string} cfrom - Source node ID. + * @param {string} cto - Destination node ID. + * @param {string} clabel - The Label of the service. + * @param {boolean} isImport - false -> manual add, true -> automattically added while import json. + */ function addServiceComponent(cmode, cfrom, cto, clabel, isImport) { var serviceID = token(); if (cmode == 1) { @@ -79,6 +101,12 @@ function addServiceComponent(cmode, cfrom, cto, clabel, isImport) { UnSelectAll(); network.addEdgeMode(); } + +/** + * Populate service details by service ID. + * @param {string} serviceID - Service ID. + * @param callback - The callback that handles the response. + */ function serviceEdit(serviceID, callback) { document.getElementById("serviceMenu").style.display = "none"; var edgeDetails = network.body.data.edges.get(serviceID); @@ -96,6 +124,12 @@ function serviceEdit(serviceID, callback) { document.getElementById("btnCloseService").onclick = clearService.bind( ); } + +/** + * Update service. + * Update service label, text, band_width by service ID. + * @param {string} serviceID - Service ID. + */ function updateService(serviceID) { var id = serviceID; @@ -123,6 +157,11 @@ function updateService(serviceID) { } } + +/** + * Remove service by service ID. + * @param {string} serviceID - Service ID. + */ function deleteService(serviceID) { var serviceDetails = network.body.data.edges.get(serviceID); document.getElementById("serviceMenu").style.display = "none"; @@ -135,6 +174,8 @@ function deleteService(serviceID) { UnSelectAll(); enableEdgeIndicator(); } + +/** Clear input/teporary data and other settings. */ function clearService() { $("#txtServiceName").val(''); diff --git a/js/networkgraph/validation.js b/js/networkgraph/validation.js index 992aa5b..4575760 100644 --- a/js/networkgraph/validation.js +++ b/js/networkgraph/validation.js @@ -1,4 +1,9 @@ -$(document).ready(function () { +/** + * validation.js + * The Validations library currently describes the validation of component name, length, type. + */ + +$(document).ready(function () { $("#txtSpan_Length").change(function () { var span_length = $("#txtSpan_Length").val().trim(); var spanlen = parseFloat(span_length); @@ -93,6 +98,10 @@ }); +/** + * Validate the node/fiber/patch/service name and name length. + * @param {HTMLElement} element - Input element + */ function nameLengthValidation(element) { var flag = true; var elementID = "#" + element @@ -110,6 +119,8 @@ function nameLengthValidation(element) { showMessage(alertType.Error, msg); return flag; } + +/** Validate export file name. */ function exportFileValidation() { var flag = false; if ($("#txtFileName").val().trim() != '') @@ -118,6 +129,8 @@ function exportFileValidation() { showMessage(alertType.Error, 'Please enter file name'); return flag; } + +/** Validate ROADM list, type and Amplifier type. */ function roadmProVal() { var flag = false; if ($("#ddlRoadmList").val().trim() != 0 && $("#ddlROADMType").val().trim() != 0 && $("#ddlRPreAmpType").val().trim() != 0 && $("#ddlRBoosterType").val().trim() != 0)