EOS/Scripts/js_dashboard/activeDashboard.js
Nidhi Bhargava f0c1ab20e1 code push
2025-09-04 16:25:07 +05:30

283 lines
8.5 KiB
JavaScript

/*================================================================================================================\
+
+ Project : NOCOUT-MTS
+ Filename : activeDashboard.js
+ Module Name : TileDashboard
+ Purpose : To show Active Tile deshboard
+ Coded By : Pankaj Khandal
+
+================================================================================================================*/
/**
* To show Infra Tile deshboard
* @module TileDashboard
*/
/**
* Global References: To store Ajax Request's XHR object.
* @for ActiveTileDashboard
*/
var xhr_showNetworkAvailability;
var xhr_showInfraDashboardDate;
var xhr_refreshDashboard;
/**
* Global References: To store Global Values.
* @for ActiveTileDashboard
*/
var timeInterval;
var checkedCircle = [];
var defaultURL = '';
/**
* To dynamically add Query parameter on given URI.
* @method updateQueryStringParameter
* @param {String} uri Unique Resource Identifier.
* @param {String} key The key which is to be updated.
* @param {String} value The value of the Key to be updated.
* @class ActiveTileDashboard
* @constructor
*/
function updateQueryStringParameter(uri, key, value) {
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
var separator = uri.indexOf('?') !== -1 ? "&" : "?";
if (uri.match(re)) {
return uri.replace(re, '$1' + key + "=" + value + '$2');
}
else {
return uri + separator + key + "=" + value;
}
}
/**
* Add Attributes (Href,target) to given element.
* @method addLinkValue
* @param {Object} $eleParentHref The Link Object.
* @param {String} linkValue The value of the Key to be updated.
* @for ActiveTileDashboard
*/
function addLinkValue($eleParentHref, linkValue) {
$eleParentHref.attr({
'href': linkValue,
'target': '_blank'
}).css("cursor", "pointer");
}
/**
* Add Alarms details on tile.
* @method addAlarmDetails
* @param {String} alarmId Code of Alarm.
* @param {String} alatmValue Count of Alarm.
* @param {String} alarmName Name of Alarm.
* @for ActiveTileDashboard
*/
function addAlarmDetails(alarmId, alatmValue, alarmName) {
$('#' + alarmId).find('h4').text(alatmValue);
$('#' + alarmId).find('p').text(alarmName);
}
/**
* Get Hidden field values and make it globally available.
* @method getHiddenFieldInfraURL
* @for ActiveTileDashboard
*/
function getHiddenFieldInfraURL() {
defaultURL = $("#hiddenInfraUrl").val();
}
/**
* Add parameters to url.
* @method addParameters
* @param {Array} params Key-Value pair of URL-Parameters.
* @for ActiveTileDashboard
*/
function addParameters(params) {
var url = defaultURL;
for (var count = 0; count < params.length; count++) {
url = updateQueryStringParameter(url, params[count].key, params[count].value);
}
return url;
}
/**
* Shows Network Availability for Selected Circles
* @method showNetworkAvailability
* @param {Array} checkedCircleFinal Circle-Array which are selected, contains IDs of circles.
* @for ActiveTileDashboard
*/
function showNetworkAvailability(checkedCircleFinal) {
if (xhr_showNetworkAvailability && xhr_showNetworkAvailability.readystate != 4) {
xhr_showNetworkAvailability.abort();
}
xhr_showNetworkAvailability = $.ajax({
type: "GET",
url: "/Infra/GetNetworkAvailabilityForAllCircle/",
data: { circleList: checkedCircleFinal },
success: function (data) {
var networkAvl = (data.TotalCellNetwork).toFixed(2);
$('#NetworkAvailabity').html(networkAvl);
},
complete: function () {
},
error: function (data) {
console.log("Error");
}
});
}
/**
* Shows Last parsed file's date. (Applicable only for one circle)
* @method showInfraDashboardDate
* @param {string} circleName Name of Circle.
* @for ActiveTileDashboard
*/
function showInfraDashboardDate(circleName) {
if (xhr_showInfraDashboardDate && xhr_showInfraDashboardDate.readystate != 4) {
xhr_showInfraDashboardDate.abort();
}
xhr_showInfraDashboardDate = $.ajax({
type: "GET",
url: "/Infra/GetInfraDashboardDate/",
data: { circleName: circleName },
success: function (data) {
//console.log(data.TotalCellNetwork);
$('#infraDashboardDate').html(data);
},
complete: function () {
$('#infraDashboardDate').show();
},
error: function (data) {
console.log("Error");
}
});
}
/**
* To bind values on infra tile dashboard for selected circles.
* @method refreshDashboard
* @param {Array} checkedCircleFinal Circle-Array which are selected, contains IDs of circles.
* @for ActiveTileDashboard
*/
function refreshDashboard(checkedCircleFinal) {
$('.wrapup-pod').find('h4').html(0);
var btsDownText = '';
var count = 3;
var count1 = 1; var totalDownSites = 0;
var totalDownSitesValue = 0;
var arrDownSites = [];
if (xhr_refreshDashboard && xhr_refreshDashboard.readystate != 4) {
xhr_refreshDashboard.abort();
}
xhr_refreshDashboard = $.ajax({
type: "GET",
url: "/Infra/ActiveTileDashboard_Zte_Grid/",
data: { circleList: checkedCircleFinal },
success: function (model) {
// Storing selected circles
checkedCircle = "";
$(".checkboxButton label").each(function () {
if ($(this).hasClass('activeLabel')) {
checkedCircle += ($(this).attr('id')) + ',';
}
});
var checkedCircleFinal = checkedCircle.substring(0, checkedCircle.lastIndexOf(','));
// Finding text of BTS Down Text.
for (var counter = 0 ; counter < model.length; counter++) {
if (model[counter].AlarmId == '133157') {
btsDownText = model[counter].AlarmName;
break;
}
}
// Set values in each tile.
for (var i = 0; i < model.length; i++) {
// Values for total BTS
if (model[i].AlarmId == "TotalBTS") {
$("#TotalBTS").text(model[i].Value);
$("#textTotalBTS").text(model[i].AlarmName);
}
else {
////if ((model[i].AlarmId != 'UPSites') && (model[i].Value != 0)) {
if ((model[i].AlarmId != 'UPSites')) {
// taking parent element (anchor tag) of specified div
var $parentHref = $('#' + model[i].AlarmId).parent();
// update url with value of alarmType.
var linkValue = addParameters([{ "key": "alarmList", "value": model[i]['AlarmId'] }, { "key": "selectedCircles", "value": checkedCircleFinal }]);
// set attributes to anchor tag.
addLinkValue($parentHref, linkValue);
}
addAlarmDetails(model[i].AlarmId, model[i]['Value'], model[i]['AlarmName']);
}
}
},
complete: function () {
$('.excelIcon').show();
},
error: function (data) {
console.log("Error");
}
});
}
/**
* To show Infra Tile dashboard for selected Circles.
* @method showInfraTileDashboard
* @class ActiveTileDashboard
*/
function showInfraTileDashboard() {
checkedCircleName = [];
$(".checkboxButton label").each(function () {
if ($(this).hasClass('activeLabel')) {
checkedCircleName.push($(this).text());
}
});
checkedCircle = "";
$(".checkboxButton label").each(function () {
if ($(this).hasClass('activeLabel')) {
checkedCircle += ($(this).attr('id')) + ',';
}
});
var checkedCircleFinal = checkedCircle.substring(0, checkedCircle.lastIndexOf(','));
if (checkedCircleFinal == '') {
alert("Please select atleast one circle !!");
return false;
};
refreshDashboard(checkedCircleFinal);
showNetworkAvailability(checkedCircleFinal);
$('#infraDashboardDate').hide();
if (checkedCircleFinal.lastIndexOf(',') == -1) {
showInfraDashboardDate(checkedCircleName[0]);
}
$('.circleFilter').show();
}
/**
* Calls when Document is prepared.
* @event document.ready
* @for ActiveTileDashboard
*/
$(document).ready(function () {
//Getting Hidden field values and making it available globally.
getHiddenFieldInfraURL();
// Loading Dashboard data.
showInfraTileDashboard();
//Refresh Dashboard every-hour
setInterval("showInfraTileDashboard()", 1000 * 60 * 60);
});