App-Netdisco
view release on metacpan or search on metacpan
share/public/javascripts/netdisco.js view on Meta::CPAN
$(from_id).toggleClass('active');
$(to_id).toggleClass('active');
update_content(
from_id.replace(/^#/,"").replace(/_pane$/,""),
to_id.replace(/^#/,"").replace(/_pane$/,"")
);
});
// bootstrap modal mucks about with mouse actions on higher elements
// so need to bury and raise it when needed
$('.tab-pane').on('show.bs.modal', '.nd_modal', function () {
$(this).toggleClass('nd_deep-horizon');
});
$('.tab-pane').on('hidden.bs.modal', '.nd_modal', function () {
$(this).toggleClass('nd_deep-horizon');
});
// activate daterange plugin
$('#daterange').daterangepicker({
ranges: {
'Today': [moment(), moment()]
,'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')]
,'Last 7 Days': [moment().subtract(6, 'days'), moment()]
,'Last 30 Days': [moment().subtract(29, 'days'), moment()]
,'This Month': [moment().startOf('month'), moment().endOf('month')]
,'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
}
// The plugin seeds its options from this element's data-* attributes and
// lets the caller override them, so an unset option is the one a stray
// attribute could supply. Both of these reach a jQuery HTML sink, so pin
// them here rather than relying on the markup never gaining an attribute.
//
// The template is copied verbatim from daterangepicker 3.1.0, the version
// named in package.json, where the plugin builds it at daterangepicker.js
// lines 100 to 116. Re-copy it whenever that version changes: the plugin
// queries selectors inside this container, so a stale copy renders a broken
// widget with nothing thrown and no test to catch it.
,template:
'<div class="daterangepicker">' +
'<div class="ranges"></div>' +
'<div class="drp-calendar left">' +
'<div class="calendar-table"></div>' +
'<div class="calendar-time"></div>' +
'</div>' +
'<div class="drp-calendar right">' +
'<div class="calendar-table"></div>' +
'<div class="calendar-time"></div>' +
'</div>' +
'<div class="drp-buttons">' +
'<span class="drp-selected"></span>' +
'<button class="cancelBtn" type="button"></button>' +
'<button class="applyBtn" disabled="disabled" type="button"></button> ' +
'</div>' +
'</div>'
,parentEl: 'body'
,minDate: '2004-01-01'
,showDropdowns: true
,timePicker: false
,opens: 'left'
,locale: { format: 'YYYY-MM-DD', separator: ' to ' }
,autoUpdateInput: false
}
,function(start, end) {
$('#daterange').trigger('input');
});
// daterangepicker 3.x writes the picker's own dates into the input on init
// unless autoUpdateInput is off, which blanks the server-rendered value. With
// it off, nothing updates the input when a range is applied, so do it here.
$('#daterange').on('apply.daterangepicker', function (ev, picker) {
$(this).val(picker.startDate.format('YYYY-MM-DD')
+ ' to ' + picker.endDate.format('YYYY-MM-DD'));
$(this).trigger('input');
});
// handler for datepicker in node sidebar
$('.nd_sidebar').on('input', '#daterange', function() {
if ($(this).prop('value') == '') {
$('#daterange').parent('.clearfix').removeClass('success');
}
else {
$('#daterange').parent('.clearfix').addClass('success');
}
});
$('#daterange').trigger('input');
// htmx glue. Converted panes get the same empty-result, error and
// after-swap handling do_search gives the unconverted ones, so the two
// transports are indistinguishable to a user. Keyed on any *_pane, not just
// admin, because later rungs convert the search and device tabs onto this.
document.body.addEventListener('htmx:afterSwap', function (evt) {
var target = evt.detail.target;
if (!target.id.match(/_pane$/)) return;
var tab = target.id.replace(/_pane$/, '');
if (target.innerHTML === '') {
target.innerHTML =
'<div class="col-md-2 alert alert-info">No matching records.</div>';
return;
}
holdUntilSettled(target, document.getElementById(tab + '_indicator'));
$('div.content > div.tab-content table.nd_floatinghead').floatThead({
top: 40
,position: 'fixed'
});
inner_view_processing(tab);
});
// Empty the pane for the duration of the request, so the indicator is the
// only thing on screen. Leaving the previous results up gives an interactive
// table that no longer answers the search being run.
//
// jobqueue is excluded for the reason it carries no indicator: it refreshes
// on a timer and would blank on every tick.
document.body.addEventListener('htmx:beforeRequest', function (evt) {
var target = evt.detail.target;
if (!target.id.match(/_pane$/) || target.id === 'jobqueue_pane') return;
// force-graph renders every frame until destroyed, and emptying the pane
// only detaches its canvas. netmap.js destroys the previous instance as
// well, but not until the new fragment's script runs.
if (target.id === 'netmap_pane' && window.graph && window.graph.fg
( run in 0.444 second using v1.01-cache-2.11-cpan-ff9377addf4 )