merge branch og-portcontrol
This commit is contained in:
2
Netdisco/public/javascripts/bootstrap.min.js
vendored
2
Netdisco/public/javascripts/bootstrap.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -144,7 +144,7 @@ $(document).ready(function() {
|
||||
|
||||
// bind submission to the navbar go icon
|
||||
$('#navsearchgo').click(function() {
|
||||
$('#navsearchgo').parent('form').submit();
|
||||
$('#navsearchgo').parents('form').submit();
|
||||
});
|
||||
|
||||
// fix green background on search checkboxes
|
||||
@@ -155,9 +155,9 @@ $(document).ready(function() {
|
||||
$('.add-on :checkbox').each(syncCheckBox).click(syncCheckBox);
|
||||
|
||||
// sidebar toggle - pinning
|
||||
$('#sidebar_pin_box').click(function() {
|
||||
$(this).toggleClass('sidebar_pin_box_pressed');
|
||||
$('.sidebar_pin').click(function() {
|
||||
$('.sidebar').toggleClass('sidebar_pinned');
|
||||
$('.sidebar_pin').toggleClass('sidebar_pin_clicked');
|
||||
});
|
||||
// sidebar toggle - trigger in/out on image click()
|
||||
$('#sidebar_toggle_img_in').click(function() {
|
||||
|
||||
37
Netdisco/public/javascripts/netdisco_portcontrol.js
Normal file
37
Netdisco/public/javascripts/netdisco_portcontrol.js
Normal file
@@ -0,0 +1,37 @@
|
||||
// user clicked or asked for port changes to be submitted via ajax
|
||||
function port_control (e) {
|
||||
var td = $(e).closest('.nd_editable_cell');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST'
|
||||
,url: uri_base + '/ajax/portcontrol'
|
||||
,data: {
|
||||
device: td.data('for-device')
|
||||
,port: td.data('for-port')
|
||||
,field: td.data('field')
|
||||
,action: td.data('action')
|
||||
,value: td.text().trim()
|
||||
}
|
||||
,success: function() {
|
||||
toastr.info('Submitted change request');
|
||||
}
|
||||
,error: function() {
|
||||
toastr.error('Failed to submit change request')
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// for growl-like functionality, check for notifications periodically
|
||||
(function worker() {
|
||||
$.ajax({
|
||||
url: uri_base + '/ajax/userlog'
|
||||
,success: function(data) {
|
||||
// Schedule next request when the current one's complete
|
||||
setTimeout(worker, 5000);
|
||||
}
|
||||
,error: function() {
|
||||
// after one failure, don't try again
|
||||
toastr.warning('Unable to retrieve change request log')
|
||||
}
|
||||
});
|
||||
})();
|
||||
173
Netdisco/public/javascripts/toastr.js
Normal file
173
Netdisco/public/javascripts/toastr.js
Normal file
@@ -0,0 +1,173 @@
|
||||
// By: Hans Fjällemark and John Papa
|
||||
// https://github.com/CodeSeven/toastr
|
||||
//
|
||||
// Modified to support css styling instead of inline styling
|
||||
// Inspired by https://github.com/Srirangan/notifer.js/
|
||||
|
||||
;(function(window, $) {
|
||||
window.toastr = (function() {
|
||||
var
|
||||
defaults = {
|
||||
tapToDismiss: true,
|
||||
toastClass: 'toast',
|
||||
containerId: 'toast-container',
|
||||
debug: false,
|
||||
fadeIn: 300,
|
||||
fadeOut: 1000,
|
||||
extendedTimeOut: 1000,
|
||||
iconClasses: {
|
||||
error: 'toast-error',
|
||||
info: 'toast-info',
|
||||
success: 'toast-success',
|
||||
warning: 'toast-warning'
|
||||
},
|
||||
iconClass: 'toast-info',
|
||||
positionClass: 'toast-top-right',
|
||||
timeOut: 5000, // Set timeOut to 0 to make it sticky
|
||||
titleClass: 'toast-title',
|
||||
messageClass: 'toast-message'
|
||||
},
|
||||
|
||||
|
||||
error = function(message, title) {
|
||||
return notify({
|
||||
iconClass: getOptions().iconClasses.error,
|
||||
message: message,
|
||||
title: title
|
||||
})
|
||||
},
|
||||
|
||||
getContainer = function(options) {
|
||||
var $container = $('#' + options.containerId)
|
||||
|
||||
if ($container.length)
|
||||
return $container
|
||||
|
||||
$container = $('<div/>')
|
||||
.attr('id', options.containerId)
|
||||
.addClass(options.positionClass)
|
||||
|
||||
$container.appendTo($('body'))
|
||||
|
||||
return $container
|
||||
},
|
||||
|
||||
getOptions = function() {
|
||||
return $.extend({}, defaults, toastr.options)
|
||||
},
|
||||
|
||||
info = function(message, title) {
|
||||
return notify({
|
||||
iconClass: getOptions().iconClasses.info,
|
||||
message: message,
|
||||
title: title
|
||||
})
|
||||
},
|
||||
|
||||
notify = function(map) {
|
||||
var
|
||||
options = getOptions(),
|
||||
iconClass = map.iconClass || options.iconClass,
|
||||
intervalId = null,
|
||||
$container = getContainer(options),
|
||||
$toastElement = $('<div/>'),
|
||||
$titleElement = $('<div/>'),
|
||||
$messageElement = $('<div/>'),
|
||||
response = { options: options, map: map }
|
||||
|
||||
if (map.iconClass) {
|
||||
$toastElement.addClass(options.toastClass).addClass(iconClass)
|
||||
}
|
||||
|
||||
if (map.title) {
|
||||
$titleElement.append(map.title).addClass(options.titleClass)
|
||||
$toastElement.append($titleElement)
|
||||
}
|
||||
|
||||
if (map.message) {
|
||||
$messageElement.append(map.message).addClass(options.messageClass)
|
||||
$toastElement.append($messageElement)
|
||||
}
|
||||
|
||||
var fadeAway = function() {
|
||||
if ($(':focus', $toastElement).length > 0)
|
||||
return
|
||||
|
||||
var fade = function() {
|
||||
return $toastElement.fadeOut(options.fadeOut)
|
||||
}
|
||||
|
||||
$.when(fade()).done(function() {
|
||||
if ($toastElement.is(':visible')) {
|
||||
return
|
||||
}
|
||||
$toastElement.remove()
|
||||
if ($container.children().length === 0)
|
||||
$container.remove()
|
||||
})
|
||||
}
|
||||
|
||||
var delayedFadeAway = function() {
|
||||
if (options.timeOut > 0 || options.extendedTimeOut > 0) {
|
||||
intervalId = setTimeout(fadeAway, options.extendedTimeOut)
|
||||
}
|
||||
}
|
||||
|
||||
var stickAround = function() {
|
||||
clearTimeout(intervalId)
|
||||
$toastElement.stop(true, true)
|
||||
.fadeIn(options.fadeIn)
|
||||
}
|
||||
|
||||
$toastElement.hide()
|
||||
$container.prepend($toastElement)
|
||||
$toastElement.fadeIn(options.fadeIn)
|
||||
|
||||
if (options.timeOut > 0) {
|
||||
intervalId = setTimeout(fadeAway, options.timeOut)
|
||||
}
|
||||
|
||||
$toastElement.hover(stickAround, delayedFadeAway)
|
||||
|
||||
if (!options.onclick && options.tapToDismiss) {
|
||||
$toastElement.click(fadeAway)
|
||||
}
|
||||
|
||||
if (options.onclick) {
|
||||
$toastElement.click(function() {
|
||||
options.onclick() && fadeAway()
|
||||
})
|
||||
}
|
||||
|
||||
if (options.debug) {
|
||||
console.log(response)
|
||||
}
|
||||
|
||||
return $toastElement
|
||||
},
|
||||
|
||||
success = function(message, title) {
|
||||
return notify({
|
||||
iconClass: getOptions().iconClasses.success,
|
||||
message: message,
|
||||
title: title
|
||||
})
|
||||
},
|
||||
|
||||
warning = function(message, title) {
|
||||
return notify({
|
||||
iconClass: getOptions().iconClasses.warning,
|
||||
message: message,
|
||||
title: title
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
error: error,
|
||||
info: info,
|
||||
options: {},
|
||||
success: success,
|
||||
warning: warning
|
||||
}
|
||||
})()
|
||||
} (window, jQuery));
|
||||
Reference in New Issue
Block a user