Browse files

Merge pull request #8 from mythmon/master

DatetimePicker and timezone fixes.
  • Loading branch information...
2 parents 6e9d7e3 + 11d7094 commit 27c34ad86b9e8630c470623c763a0cf5f36fef87 @marineam marineam committed Aug 11, 2011
View
6 python/nagcat/nagios_api.py
@@ -525,6 +525,12 @@ def xmlrpc_scheduleDowntime(self, expr, start, stop, user, comment):
raise xmlrpc.Fault(1, "start/stop must be integers")
now = int(time.time())
+
+ if start < now:
+ start = now
+ if end < now:
+ raise xmlrpc.Fault(1, "stop must be in the future")
+
key = base64.urlsafe_b64encode(struct.pack('ib',
now, random.randint(-127,127))).strip('=')
comment += ' key:%s expr:%s' % (key, expr.strip())
View
2 railroad/static/css/style.css
@@ -422,7 +422,6 @@ fieldset {
background-color: #EEE;
height: 21px;
padding: 4px 8px;
- cursor: pointer;
margin-right: -1px;
border-radius: 2px;
}
@@ -432,6 +431,7 @@ fieldset {
#toolbar li:not(.nohover):hover {
background-color: #CCC;
+ cursor: pointer;
border-color: #777;
}
View
20 railroad/static/js/configurator.js
@@ -124,10 +124,11 @@ $(document).ready(function() {
$('#downtime-submit').parent().after(
'<img src="/railroad-static/images/loading.gif" ' +
'id="downtimeLoading" />');
+ $('.cancelcode').remove();
// gather data
var expr = '';
- var checkedServiceRows =
+ var checkedServiceRows =
$('.service_row').filter(
function(index) {
return $(this).find('.controls input')
@@ -170,20 +171,11 @@ $(document).ready(function() {
var from = $('#downtime-from').datepicker('getDate');
var to = $('#downtime-to').datepicker('getDate');
- var about_now = new Date().add({minutes: 5});
- if (from < about_now) {
- from = about_now;
- }
if (!(from && to)) {
makeDowntimeError("Invalid dates!");
$('#downtimeLoading').remove();
return;
}
- if (to < about_now) {
- makeDowntimeError("Can't schedule downtimes in the past.");
- $('#downtimeLoading').remove();
- return;
- }
// Correct for time zones, since the datetimepicker doesn't store the
// time zone. *glare*
@@ -195,11 +187,6 @@ $(document).ready(function() {
to = Math.round(to.getTime() / 1000.0);
var comment = $('#downtime-comment').prop('value');
- if (!expr) {
- console.log('no comment');
- return;
- }
-
var user = $('#remoteuserid').text().trim();
var args = [expr, from, to, user, comment]
@@ -219,7 +206,8 @@ $(document).ready(function() {
.format(cancellationCode));
$('#downtimeLoading').remove();
},
- error: function () {
+ error: function (jqXHR, textStatus, errorThrown) {
+ console.log(textStatus + ': ' + jqXHR.responseText);
makeDowntimeError("There was an error.");
$('#downtimeLoading').remove();
}
View
11 railroad/static/js/functions.js
@@ -67,6 +67,16 @@ Array.prototype.uniqueList = function() {
return uniqList;
}
+// Fix the datetimepicker's now button to account for time zones.
+$.datepicker._gotoToday = function(id) {
+ this._base_gotoToday(id);
+ var now = new Date();
+ if ($('#utc').prop('checked')) {
+ now.add({minutes: now.getTimezoneOffset()});
+ }
+ this._setTime(this._getInst($(id)[0]), now);
+}
+
/******* FLOT HELPER FUNCTIONS *******/
$.plot.formatDate = function(d, fmt, monthNames) {
var leftPad = function(n) {
@@ -348,6 +358,7 @@ function makeDatetimePicker(elem, date, onClose) {
changeMonth: true,
changeYear: true,
});
+ datePicker.timezone = tz;
if (date) {
$(datePicker).datetimepicker('setDate', date)
}

0 comments on commit 27c34ad

Please sign in to comment.