To implement validation for ROADM, Amplifer, Raman Amplifier

This commit is contained in:
sakv2e10204
2022-04-12 18:47:09 +05:30
parent f8de6c51a5
commit 19b2defd3d
4 changed files with 165 additions and 17 deletions

View File

@@ -4925,10 +4925,15 @@ function roadmEdit(nodeID, callback) {
} }
else if (nodeDetails.node_type == roadmJSON.node_type && $("#ddlNetworkView").val() == topologyView.Functional_View) { else if (nodeDetails.node_type == roadmJSON.node_type && $("#ddlNetworkView").val() == topologyView.Functional_View) {
$("#divRoadmType").show(); $("#divRoadmType").show();
if (nodeDetails.roadm_type) if (nodeDetails.roadm_type) {
$("#ddlRoadmType").removeClass('input_error');
$("#ddlRoadmType").val(nodeDetails.roadm_type); $("#ddlRoadmType").val(nodeDetails.roadm_type);
else }
else {
$("#ddlRoadmType").val(''); $("#ddlRoadmType").val('');
$("#ddlRoadmType").addClass('input_error');
}
} }
document.getElementById("btnUpdateRoadm").onclick = updateRoadm.bind( document.getElementById("btnUpdateRoadm").onclick = updateRoadm.bind(
@@ -4969,6 +4974,15 @@ function updateRoadm(nodeID) {
} }
else if (node_type == roadmJSON.node_type && $("#ddlNetworkView").val() == topologyView.Functional_View) { else if (node_type == roadmJSON.node_type && $("#ddlNetworkView").val() == topologyView.Functional_View) {
if ($("#ddlRoadmType").val() == null) {
showMessage(alertType.Error, 'Pleae select type');
$("#ddlRoadmType").addClass('input_error');
return;
}
else
$("#ddlRoadmType").removeClass('input_error');
network.body.data.nodes.update({ network.body.data.nodes.update({
id: id, label: label, roadm_type: $("#ddlRoadmType").val() id: id, label: label, roadm_type: $("#ddlRoadmType").val()
}); });
@@ -5135,6 +5149,13 @@ function amplifierEdit(nodeID, callback) {
$("#txtAmplifierName").val(nodeDetails.label); $("#txtAmplifierName").val(nodeDetails.label);
$("#ddlAmplifierType").val(nodeDetails.amp_type); $("#ddlAmplifierType").val(nodeDetails.amp_type);
if (nodeDetails.amp_type) {
$("#ddlAmplifierType").removeClass('input_error');
}
else {
$("#ddlAmplifierType").addClass('input_error');
}
document.getElementById("btnAmplifierUpdate").onclick = updateAmplifier.bind( document.getElementById("btnAmplifierUpdate").onclick = updateAmplifier.bind(
this, this,
nodeID, nodeID,
@@ -5152,6 +5173,15 @@ function updateAmplifier(nodeID) {
if (nameLengthValidation("txtAmplifierName")) { if (nameLengthValidation("txtAmplifierName")) {
if ($("#ddlAmplifierType").val() == null) {
showMessage(alertType.Error, 'Pleae select type');
$("#ddlAmplifierType").addClass('input_error');
return;
}
else
$("#ddlAmplifierType").removeClass('input_error');
if (amp_category == amplifierJSON.amp_category) { if (amp_category == amplifierJSON.amp_category) {
network.body.data.nodes.update({ network.body.data.nodes.update({
id: id, label: label, amp_type: $("#ddlAmplifierType").val(), id: id, label: label, amp_type: $("#ddlAmplifierType").val(),
@@ -5205,6 +5235,19 @@ function ramanAmpEdit(nodeID, callback) {
$("#ddlRamanAmpType").val(nodeDetails.amp_type); $("#ddlRamanAmpType").val(nodeDetails.amp_type);
$("#ddlRamanAmpCategory").val(nodeDetails.category); $("#ddlRamanAmpCategory").val(nodeDetails.category);
if (nodeDetails.amp_type) {
$("#ddlRamanAmpType").removeClass('input_error');
}
else {
$("#ddlRamanAmpType").addClass('input_error');
}
if (nodeDetails.category) {
$("#ddlRamanAmpCategory").removeClass('input_error');
}
else {
$("#ddlRamanAmpCategory").addClass('input_error');
}
document.getElementById("btnRamanAmpUpdate").onclick = updateRamanAmp.bind( document.getElementById("btnRamanAmpUpdate").onclick = updateRamanAmp.bind(
this, this,
nodeID, nodeID,
@@ -5222,6 +5265,23 @@ function updateRamanAmp(nodeID) {
if (nameLengthValidation("txtRamanAmpName")) { if (nameLengthValidation("txtRamanAmpName")) {
if ($("#ddlRamanAmpType").val() == null) {
showMessage(alertType.Error, 'Pleae select type');
$("#ddlRamanAmpType").addClass('input_error');
return;
}
else
$("#ddlRamanAmpType").removeClass('input_error');
if ($("#ddlRamanAmpCategory").val() == null) {
showMessage(alertType.Error, 'Pleae select category');
$("#ddlRamanAmpCategory").addClass('input_error');
return;
}
else
$("#ddlRamanAmpCategory").removeClass('input_error');
if (amp_category == ramanampJSON.amp_category) { if (amp_category == ramanampJSON.amp_category) {
network.body.data.nodes.update({ network.body.data.nodes.update({
id: id, label: label, amp_type: $("#ddlRamanAmpType").val(), category: $("#ddlRamanAmpCategory").val() id: id, label: label, amp_type: $("#ddlRamanAmpType").val(), category: $("#ddlRamanAmpCategory").val()
@@ -5252,6 +5312,7 @@ function updateRamanAmp(nodeID) {
if (amptype) { if (amptype) {
removeID = "#spanTF" + id.replace(/\s/g, ''); removeID = "#spanTF" + id.replace(/\s/g, '');
$(removeID).remove(); $(removeID).remove();
$(removeID).remove();
} }
} }
@@ -5277,6 +5338,13 @@ function transceiverEdit(nodeID, callback) {
$("#txtTransceiverName").val(nodeDetails.label); $("#txtTransceiverName").val(nodeDetails.label);
$("#ddlTransceiverType").val(nodeDetails.transceiver_type); $("#ddlTransceiverType").val(nodeDetails.transceiver_type);
if (nodeDetails.transceiver_type) {
$("#ddlTransceiverType").removeClass('input_error');
}
else {
$("#ddlTransceiverType").addClass('input_error');
}
document.getElementById("btnTransceiverUpdate").onclick = updateTransceiver.bind( document.getElementById("btnTransceiverUpdate").onclick = updateTransceiver.bind(
this, this,
nodeID, nodeID,
@@ -5294,8 +5362,11 @@ function updateTransceiver(nodeID) {
var transceiverType = $("#ddlTransceiverType").val(); var transceiverType = $("#ddlTransceiverType").val();
if (transceiverType == null || transceiverType == "") { if (transceiverType == null || transceiverType == "") {
showMessage(alertType.Error, 'Please select transceiver type'); showMessage(alertType.Error, 'Please select transceiver type');
$("#ddlTransceiverType").addClass('input_error');
return; return;
} }
else
$("#ddlTransceiverType").removeClass('input_error');
if (nameLengthValidation("txtTransceiverName")) { if (nameLengthValidation("txtTransceiverName")) {
@@ -5419,10 +5490,21 @@ function deleteNode(nodeID) {
} else { } else {
//nodes.remove(nodeID); //nodes.remove(nodeID);
if (nodeDetails.node_type == transceiverJSON.node_type) { if (nodeDetails.node_type == transceiverJSON.node_type || nodeDetails.node_type == roadmJSON.node_type) {
removeSpanInError(nodeID); removeSpanInError(nodeID);
removeSpanInError(nodeID, true); removeSpanInError(nodeID, true);
} }
else if (nodeDetails.node_type == amplifierJSON.node_type) {
if (nodeDetails.amp_category == amplifierJSON.amp_category) {
removeSpanInError(nodeID);
removeSpanInError(nodeID, true);
}
if (nodeDetails.amp_category == ramanampJSON.amp_category) {
removeSpanInError(nodeID);
removeSpanInError(nodeID, true);
removeSpanInError(nodeID, true);
}
}
else else
removeSpanInError(nodeID); removeSpanInError(nodeID);
@@ -6708,6 +6790,10 @@ function checkTypeForce() {
msg.push('<p class="focusNode" title="Click here to focus the node" id=\'spanTF' + item.id.replace(/\s/g, '') + '\' onClick="focusNode(\'' + item.id + '\')"><img width="25" src="./Assets/img/error-listing-icon.png"> <b>' + item.label + '</b> - ' + ramanampJSON.amp_category + ' type not entered by the user.</p>'); msg.push('<p class="focusNode" title="Click here to focus the node" id=\'spanTF' + item.id.replace(/\s/g, '') + '\' onClick="focusNode(\'' + item.id + '\')"><img width="25" src="./Assets/img/error-listing-icon.png"> <b>' + item.label + '</b> - ' + ramanampJSON.amp_category + ' type not entered by the user.</p>');
flag = true; flag = true;
} }
if (!item.category) {
msg.push('<p class="focusNode" title="Click here to focus the node" id=\'spanTF' + item.id.replace(/\s/g, '') + '\' onClick="focusNode(\'' + item.id + '\')"><img width="25" src="./Assets/img/error-listing-icon.png"> <b>' + item.label + '</b> - ' + ramanampJSON.amp_category + ' category not entered by the user.</p>');
flag = true;
}
} }
} }
@@ -6885,14 +6971,30 @@ function nodeValidationInEdge(cfrom, cto) {
else { else {
if (network.body.data.nodes.get(item).node_type == amplifierJSON.node_type) { if (network.body.data.nodes.get(item).node_type == amplifierJSON.node_type) {
if (network.body.data.nodes.get(item).amp_type != "") {
removeSpanInError(item, true);
removeSpanInError(item); if (network.body.data.nodes.get(item).amp_category == amplifierJSON.amp_category) {
if (network.body.data.nodes.get(item).amp_type != "") {
removeSpanInError(item, true);
removeSpanInError(item);
}
else {
var removeID = "#span" + item.replace(/\s/g, '');
$(removeID).remove();
}
} }
else { else if (network.body.data.nodes.get(item).amp_category == ramanampJSON.amp_category) {
var removeID = "#span" + item.replace(/\s/g, ''); if (network.body.data.nodes.get(item).amp_type != "" && (network.body.data.nodes.get(item).category)) {
$(removeID).remove(); removeSpanInError(item, true);
removeSpanInError(item);
}
else {
var removeID = "#span" + item.replace(/\s/g, '');
$(removeID).remove();
}
} }
} }
else { else {
removeSpanInError(item); removeSpanInError(item);
@@ -7101,9 +7203,16 @@ function nodeRuleOnImportJSON() {
addNodeHighlight(item.id); addNodeHighlight(item.id);
} }
else { else {
if (item.node_type == amplifierJSON.node_type && item.amp_type == "") { if (item.node_type == amplifierJSON.node_type)
addNodeHighlight(item.id); {
if (item.amp_category == ramanampJSON.amp_category && item.amp_type == "" && !(item.category)) {
addNodeHighlight(item.id);
}
else if (item.amp_category == amplifierJSON.amp_category && item.amp_type == "") {
addNodeHighlight(item.id);
}
} }
} }
//if (connectedEdges.length <= 1) { //if (connectedEdges.length <= 1) {
// addNodeHighlight(item.id); // addNodeHighlight(item.id);

View File

@@ -19,13 +19,52 @@
$("#ddlSingleFiberType").removeClass('input_error'); $("#ddlSingleFiberType").removeClass('input_error');
}); });
//$("input").keydown(function () { $("#ddlRoadmType").change(function () {
if ($(this).val() == "") {
$("#ddlRoadmType").addClass('input_error');
return;
}
else
$("#ddlRoadmType").removeClass('input_error');
});
$("#ddlAmplifierType").change(function () {
if ($(this).val() == "") {
$("#ddlAmplifierType").addClass('input_error');
return;
}
else
$("#ddlAmplifierType").removeClass('input_error');
});
$("#ddlRamanAmpType").change(function () {
if ($(this).val() == "") {
$("#ddlRamanAmpType").addClass('input_error');
return;
}
else
$("#ddlRamanAmpType").removeClass('input_error');
});
$("#ddlRamanAmpCategory").change(function () {
if ($(this).val() == "") {
$("#ddlRamanAmpCategory").addClass('input_error');
return;
}
else
$("#ddlRamanAmpCategory").removeClass('input_error');
});
$("#ddlTransceiverType").change(function () {
if ($(this).val() == "") {
$("#ddlTransceiverType").addClass('input_error');
return;
}
else
$("#ddlTransceiverType").removeClass('input_error');
});
// $("input").css("background-color", "yellow");
//});
//$("input").keyup(function () {
// $("input").css("background-color", "pink");
//});
}); });
function nameLengthValidation(element) { function nameLengthValidation(element) {