FreeSTAR-Status-Engine/js/admin.js

59 lines
1.8 KiB
JavaScript
Raw Normal View History

2017-11-23 18:09:36 -05:00
(function(){
2017-12-12 07:56:03 -05:00
$("#time_input").flatpickr({enableTime:true, minDate: "today",time_24hr:true, formatDate: function(date, format) {
2017-11-23 18:09:36 -05:00
return date.toISOString();
}});
$("#end_time").flatpickr({enableTime:true, minDate: "today",time_24hr:true, formatDate: function(date, format) {
return date.toISOString(); // iso date str
}});
var classes = ["panel panel-danger", "panel panel-warning", "panel panel-primary", "panel panel-success"];
var icons = ["fa fa-times", "fa fa-exclamation", "fa fa-info", "fa fa-check"];
$("body").on("change","#new-incident select", function(){
var val = $(this).val();
$("#new-incident .panel.new .panel-heading i").get(0).className = icons[val];
$("#new-incident .panel.new").get(0).className = classes[val] + " new";
});
$("#new-incident select").trigger("change");
$("body").on("submit","#new-incident",function(){
var time = Date.parse($('#time_input').val());
2017-11-23 18:09:36 -05:00
var end_time = Date.parse($('#end_time').val());
var type = $("#type").val();
2017-11-23 18:09:36 -05:00
if (type == 2 &&(isNaN(time) || isNaN(end_time)))
2017-11-23 18:09:36 -05:00
{
if (isNaN(end_time))
{
$('#time_input').addClass("error");
$.growl.error({ message: "Start time is invalid!" });
}
if (isNaN(end_time))
{
$('#end_time').addClass("error");
$.growl.error({ message: "End time is invalid!" });
}
return false;
}
else if (type == 2 && time >= end_time)
{
$.growl.error({ message: "End time is either the same or earlier than start time!" });
2017-11-23 18:09:36 -05:00
$('#time').addClass("error");
$('#end_time').addClass("error");
return false;
}
if($('#status-container :checkbox:checked').length == 0)
{
$.growl.error({ message: "Please check at least one service!" });
2017-11-23 18:09:36 -05:00
$('#status-container').addClass("error");
return false;
}
});
})();
2017-12-12 07:56:03 -05:00