зеркало из https://github.com/mozilla/MozDef.git
date sanity to store in javascript/UTC but display in user/browser timezone
This commit is contained in:
Родитель
5c0e9e8526
Коммит
d716de4a69
|
@ -10,6 +10,12 @@ Jeff Bryner jbryner@mozilla.com
|
|||
|
||||
<!--new incident form -->
|
||||
<template name="addincidentform">
|
||||
<style>
|
||||
|
||||
.daterangepicker td{
|
||||
color:black;
|
||||
}
|
||||
</style>
|
||||
<form id="addincidentform" class="form-horizontal" style="margin: 0px 30% 20px;">
|
||||
<legend>New Incident</legend>
|
||||
<fieldset>
|
||||
|
@ -17,23 +23,25 @@ Jeff Bryner jbryner@mozilla.com
|
|||
<div class="control-group">
|
||||
<label class="control-label" for="summary">Incident Summary</label>
|
||||
<div class="controls">
|
||||
<input id="summary" name="summary" placeholder="summary" class="input-xlarge summary" required="" type="text">
|
||||
<input id="summary" name="summary" placeholder="summary" class="input-xxlarge summary" required="" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<!-- date Opened -->
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="dateOpened">Date Opened</label>
|
||||
<div class="controls">
|
||||
<input class="input-xlarge dateOpened" name="dateOpened" id="dateOpened" type="text" placeholder="today" value="{{now}}">
|
||||
<div class="input-prepend input-group">
|
||||
<span class="add-on input-group-addon"><i class="icon-calendar fa fa-calendar"></i></span>
|
||||
<input class="input dateOpened calendarfield" name="dateOpened" id="dateOpened" type="text" placeholder="today" value="{{uiDateFormat now}}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- Phase -->
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="phase">Phase</label>
|
||||
<div class="controls">
|
||||
<select id="phase" name="phase" class="input-xlarge">
|
||||
<option >Identification</option>
|
||||
<option>Identification</option>
|
||||
<option>Containment</option>
|
||||
<option>Eradication</option>
|
||||
<option>Recovery</option>
|
||||
|
|
|
@ -72,7 +72,7 @@ Jeff Bryner jbryner@mozilla.com
|
|||
<div class="controls">
|
||||
<div class="input-prepend input-group">
|
||||
<span class="add-on input-group-addon"><i class="icon-calendar fa fa-calendar"></i></span>
|
||||
<input class="input dateOpened calendarfield" name="dateOpened" id="dateOpened" type="text" placeholder="today" value="{{dateOpened}}">
|
||||
<input class="input dateOpened calendarfield" name="dateOpened" id="dateOpened" type="text" placeholder="today" value="{{uiDateFormat dateOpened}}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -82,7 +82,7 @@ Jeff Bryner jbryner@mozilla.com
|
|||
<div class="controls">
|
||||
<div class="input-prepend input-group">
|
||||
<span class="add-on input-group-addon"><i class="icon-calendar fa fa-calendar"></i></span>
|
||||
<input class="form-control dateClosed calendarfield" name="dateClosed" id="dateClosed" type="text" value="{{dateClosed}}">
|
||||
<input class="form-control dateClosed calendarfield" name="dateClosed" id="dateClosed" type="text" value="{{uiDateFormat dateClosed}}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -117,20 +117,20 @@ Jeff Bryner jbryner@mozilla.com
|
|||
<div class="controls">
|
||||
<div class="input-prepend input-group input-append">
|
||||
<span class="add-on input-group-addon"><i class="icon-calendar fa fa-calendar"></i></span>
|
||||
<input class="form-control dateReported calendarfield" name="dateReported" id="dateReported" type="text" value="{{dateReported}}">
|
||||
<input class="form-control dateReported calendarfield" name="dateReported" id="dateReported" type="text" value="{{uiDateFormat dateReported}}">
|
||||
<span class="add-on" style="padding-right:12px">Reported</span>
|
||||
</div>
|
||||
<div class="input-prepend input-group input-append">
|
||||
<span class="add-on input-group-addon"><i class="icon-calendar fa fa-calendar"></i></span>
|
||||
<input class="form-control dateVerified calendarfield" name="dateVerified" id="dateVerified" type="text" value="{{dateVerified}}"><span class="add-on" style="padding-right: 20px">Verified</span>
|
||||
<input class="form-control dateVerified calendarfield" name="dateVerified" id="dateVerified" type="text" value="{{uiDateFormat dateVerified}}"><span class="add-on" style="padding-right: 20px">Verified</span>
|
||||
</div>
|
||||
<div class="input-prepend input-group input-append">
|
||||
<span class="add-on input-group-addon"><i class="icon-calendar fa fa-calendar"></i></span>
|
||||
<input class="form-control dateMitigated calendarfield" name="dateMitigated" id="dateMitigated" type="text" value="{{dateMitigated}}"><span class="add-on" style="padding-right:10px">Mitigated</span>
|
||||
<input class="form-control dateMitigated calendarfield" name="dateMitigated" id="dateMitigated" type="text" value="{{uiDateFormat dateMitigated}}"><span class="add-on" style="padding-right:10px">Mitigated</span>
|
||||
</div>
|
||||
<div class="input-prepend input-group input-append">
|
||||
<span class="add-on input-group-addon"><i class="icon-calendar fa fa-calendar"></i></span>
|
||||
<input class="form-control dateContained calendarfield" name="dateContained" id="dateContained" type="text" value="{{dateContained}}"><span class="add-on" style="padding-right:7px">Contained</span>
|
||||
<input class="form-control dateContained calendarfield" name="dateContained" id="dateContained" type="text" value="{{uiDateFormat dateContained}}"><span class="add-on" style="padding-right:7px">Contained</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ if (Meteor.isClient) {
|
|||
Template.incidents.events({
|
||||
"click": function(e,t){
|
||||
if (this._id != undefined){
|
||||
Session.set('displayMessage','Starting edit for incident._id: ' + this._id);
|
||||
//Session.set('displayMessage','Starting edit for incident._id: ' + this._id);
|
||||
Router.go('/incident/' + this._id + '/edit');
|
||||
}
|
||||
}
|
||||
|
@ -46,24 +46,11 @@ if (Meteor.isClient) {
|
|||
|
||||
|
||||
Template.incidents.rendered = function(){
|
||||
Meteor.subscribe("incidents-summary");
|
||||
Deps.autorun(function() {
|
||||
Meteor.subscribe("incidents-summary");
|
||||
});
|
||||
};
|
||||
|
||||
//edit helpers
|
||||
Template.editincidentform.helpers({
|
||||
incident: function() {
|
||||
return incidents.findOne(Session.get('incidentID'));
|
||||
},
|
||||
eachSort: function(context,options){
|
||||
var ret = "";
|
||||
|
||||
for(var i=0, j=context.length; i<j; i++) {
|
||||
ret = ret + options.fn(context.sort()[i]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
});
|
||||
|
||||
var incidentRevision = function() {
|
||||
this.save = function(e, template) {
|
||||
|
@ -71,17 +58,19 @@ if (Meteor.isClient) {
|
|||
incidentSaveTimer.clear();
|
||||
|
||||
// tags are saved in real realtime (without timer)
|
||||
// other tabs are saved as they are changed
|
||||
// this is only for the main tab
|
||||
|
||||
var incidentobj = {
|
||||
summary: template.find("#summary").value,
|
||||
description: template.find("#description").value,
|
||||
dateOpened: template.find("#dateOpened").value,
|
||||
dateClosed: template.find("#dateClosed").value,
|
||||
dateOpened: dateOrNull(template.find("#dateOpened").value),
|
||||
dateClosed: dateOrNull(template.find("#dateClosed").value),
|
||||
phase: template.find("#phase").value,
|
||||
dateReported: template.find("#dateReported").value,
|
||||
dateVerified: template.find("#dateVerified").value,
|
||||
dateMitigated: template.find("#dateMitigated").value,
|
||||
dateContained: template.find("#dateContained").value
|
||||
dateReported: dateOrNull(template.find("#dateReported").value),
|
||||
dateVerified: dateOrNull(template.find("#dateVerified").value),
|
||||
dateMitigated: dateOrNull(template.find("#dateMitigated").value),
|
||||
dateContained: dateOrNull(template.find("#dateContained").value)
|
||||
}
|
||||
|
||||
incidents.update(Session.get('incidentID'),
|
||||
|
@ -114,13 +103,13 @@ if (Meteor.isClient) {
|
|||
|
||||
template.find("#summary").value = incident.summary;
|
||||
template.find("#description").value = incident.description;
|
||||
template.find("#dateOpened").value = incident.dateOpened;
|
||||
template.find("#dateClosed").value = incident.dateClosed;
|
||||
template.find("#dateOpened").value = dateFormat(incident.dateOpened);
|
||||
template.find("#dateClosed").value = dateFormat(incident.dateClosed);
|
||||
template.find("#phase").value = incident.phase;
|
||||
template.find("#dateReported").value = incident.dateReported;
|
||||
template.find("#dateVerified").value = incident.dateVerified;
|
||||
template.find("#dateMitigated").value = incident.dateMitigated;
|
||||
template.find("#dateContained").value = incident.dateContained;
|
||||
template.find("#dateReported").value = dateFormat(incident.dateReported);
|
||||
template.find("#dateVerified").value = dateFormat(incident.dateVerified);
|
||||
template.find("#dateMitigated").value = dateFormat(incident.dateMitigated);
|
||||
template.find("#dateContained").value = dateFormat(incident.dateContained);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,13 +124,13 @@ if (Meteor.isClient) {
|
|||
|
||||
template.find("#summary").value = incident.summary;
|
||||
template.find("#description").value = incident.description;
|
||||
template.find("#dateOpened").value = incident.dateOpened;
|
||||
template.find("#dateClosed").value = incident.dateClosed;
|
||||
template.find("#dateOpened").value = dateFormat(incident.dateOpened);
|
||||
template.find("#dateClosed").value = dateFormat(incident.dateClosed);
|
||||
template.find("#phase").value = incident.phase;
|
||||
template.find("#dateReported").value = incident.dateReported;
|
||||
template.find("#dateVerified").value = incident.dateVerified;
|
||||
template.find("#dateMitigated").value = incident.dateMitigated;
|
||||
template.find("#dateContained").value = incident.dateContained;
|
||||
template.find("#dateReported").value = dateFormat(incident.dateReported);
|
||||
template.find("#dateVerified").value = dateFormat(incident.dateVerified);
|
||||
template.find("#dateMitigated").value = dateFormat(incident.dateMitigated);
|
||||
template.find("#dateContained").value = dateFormat(incident.dateContained);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,7 +175,6 @@ if (Meteor.isClient) {
|
|||
e.preventDefault(); //allow the drag
|
||||
},
|
||||
"keyup .tagfilter":function(e,template){
|
||||
//console.log(e);
|
||||
//var letter_pressed = String.fromCharCode(e.keyCode);
|
||||
//console.log(template.find("#tagfilter").value);
|
||||
Session.set('verisfilter',template.find("#tagfilter").value);
|
||||
|
@ -194,7 +182,6 @@ if (Meteor.isClient) {
|
|||
},
|
||||
"drop .tags": function(e){
|
||||
e.preventDefault();
|
||||
//console.log(e)
|
||||
tagtext = e.originalEvent.dataTransfer.getData("text/plain");
|
||||
//e.target.textContent=droptag
|
||||
//console.log(tagtext)
|
||||
|
@ -368,70 +355,83 @@ if (Meteor.isClient) {
|
|||
}
|
||||
});
|
||||
|
||||
Template.editincidentform.rendered = function() {
|
||||
if (typeof console !== 'undefined') {
|
||||
console.log('load edit incident form ' + Session.get('incidentID'));
|
||||
}
|
||||
//init the date pickers.
|
||||
$('#dateClosed').daterangepicker({
|
||||
singleDatePicker: true,
|
||||
timePicker:true,
|
||||
timePickerIncrement:1,
|
||||
format: 'MM/DD/YYYY hh:mm:ss A',
|
||||
startDate: moment()
|
||||
});
|
||||
Template.editincidentform.rendered = function() {
|
||||
initDatePickers=function(){
|
||||
//init the date pickers.
|
||||
$('#dateClosed').daterangepicker({
|
||||
singleDatePicker: true,
|
||||
timePicker:true,
|
||||
timePickerIncrement:1,
|
||||
format: 'MM/DD/YYYY hh:mm:ss A',
|
||||
startDate: dateOrNull($('#dateClosed').val() ) || moment()
|
||||
});
|
||||
$('#dateOpened').daterangepicker({
|
||||
singleDatePicker: true,
|
||||
timePicker:true,
|
||||
timePickerIncrement:1,
|
||||
format: 'MM/DD/YYYY hh:mm:ss A',
|
||||
startDate: dateOrNull($('#dateOpened').val() ) || moment()
|
||||
});
|
||||
$('#dateReported').daterangepicker({
|
||||
singleDatePicker: true,
|
||||
timePicker:true,
|
||||
timePickerIncrement:1,
|
||||
format: 'MM/DD/YYYY hh:mm:ss A',
|
||||
startDate: dateOrNull($('#dateReported').val() ) || moment()
|
||||
});
|
||||
$('#dateVerified').daterangepicker({
|
||||
singleDatePicker: true,
|
||||
timePicker:true,
|
||||
timePickerIncrement:1,
|
||||
format: 'MM/DD/YYYY hh:mm:ss A',
|
||||
startDate: dateOrNull($('#dateVerified').val() ) || moment()
|
||||
});
|
||||
$('#dateMitigated').daterangepicker({
|
||||
singleDatePicker: true,
|
||||
timePicker:true,
|
||||
timePickerIncrement:1,
|
||||
format: 'MM/DD/YYYY hh:mm:ss A',
|
||||
startDate: dateOrNull($('#dateMitigated').val() ) || moment()
|
||||
});
|
||||
$('#dateContained').daterangepicker({
|
||||
singleDatePicker: true,
|
||||
timePicker:true,
|
||||
timePickerIncrement:1,
|
||||
format: 'MM/DD/YYYY hh:mm:ss A',
|
||||
startDate: dateOrNull($('#dateContained').val() ) || moment()
|
||||
});
|
||||
};
|
||||
|
||||
//set up reactive data
|
||||
Deps.autorun(function() {
|
||||
//Meteor.subscribe("incidents-details",Session.get('incidentID'));
|
||||
Meteor.subscribe("incidents-details",Session.get('incidentID'), onReady=function(){
|
||||
initDatePickers();
|
||||
});
|
||||
}); //end deps.autorun
|
||||
};
|
||||
|
||||
Template.addincidentform.rendered = function() {
|
||||
$('#dateOpened').daterangepicker({
|
||||
singleDatePicker: true,
|
||||
timePicker:true,
|
||||
timePickerIncrement:1,
|
||||
format: 'MM/DD/YYYY hh:mm:ss A',
|
||||
startDate: moment()
|
||||
});
|
||||
$('#dateReported').daterangepicker({
|
||||
singleDatePicker: true,
|
||||
timePicker:true,
|
||||
timePickerIncrement:1,
|
||||
format: 'MM/DD/YYYY hh:mm:ss A',
|
||||
startDate: moment()
|
||||
});
|
||||
$('#dateVerified').daterangepicker({
|
||||
singleDatePicker: true,
|
||||
timePicker:true,
|
||||
timePickerIncrement:1,
|
||||
format: 'MM/DD/YYYY hh:mm:ss A',
|
||||
startDate: moment()
|
||||
});
|
||||
$('#dateMitigated').daterangepicker({
|
||||
singleDatePicker: true,
|
||||
timePicker:true,
|
||||
timePickerIncrement:1,
|
||||
format: 'MM/DD/YYYY hh:mm:ss A',
|
||||
startDate: moment()
|
||||
});
|
||||
$('#dateContained').daterangepicker({
|
||||
singleDatePicker: true,
|
||||
timePicker:true,
|
||||
timePickerIncrement:1,
|
||||
format: 'MM/DD/YYYY hh:mm:ss A',
|
||||
startDate: moment()
|
||||
});
|
||||
//set up reactive data
|
||||
Deps.autorun(function() {
|
||||
Meteor.subscribe("incidents-details",Session.get('incidentID'));
|
||||
}); //end deps.autorun
|
||||
});
|
||||
};
|
||||
|
||||
//add incident events
|
||||
Template.addincidentform.events({
|
||||
"submit form": function(event, template) {
|
||||
event.preventDefault();
|
||||
incidents.insert({
|
||||
summary: template.find("#summary").value,
|
||||
dateOpened: template.find("#dateOpened").value,
|
||||
phase: template.find("#phase").value
|
||||
});
|
||||
//TODO; reroute to full blown edit form after this minimal input is complete
|
||||
Router.go('/incidents/')
|
||||
newIncident=models.incident();
|
||||
newIncident.summary= template.find("#summary").value,
|
||||
newIncident.dateOpened=dateOrNull(template.find("#dateOpened").value),
|
||||
newIncident.phase=template.find("#phase").value
|
||||
newid=incidents.insert(newIncident);
|
||||
//reroute to full blown edit form after this minimal input is complete
|
||||
Router.go('/incident/' + newid + '/edit');
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -11,12 +11,39 @@ Anthony Verez averez@mozilla.com
|
|||
|
||||
if (Meteor.isClient) {
|
||||
//defaults:
|
||||
Meteor.startup(function () {
|
||||
Session.set('verisfilter','');
|
||||
Session.set('alertsearchtext','');
|
||||
});
|
||||
Meteor.startup(function () {
|
||||
Session.set('verisfilter','');
|
||||
Session.set('alertsearchtext','');
|
||||
});
|
||||
|
||||
//helper functions for UI templates
|
||||
//and other client javascript routines
|
||||
dateOrNull=function(maybeDate){
|
||||
adate=moment(maybeDate);
|
||||
if (adate.isValid()) {
|
||||
return adate.toDate();
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
dateFormat=function(adate){
|
||||
mdate=moment(adate || null);
|
||||
if (mdate.isValid()) {
|
||||
dformat='MM/DD/YYYY hh:mm:ss A';
|
||||
return mdate.format(dformat);
|
||||
}else{
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
//debug/testing functions
|
||||
debugLog=function(logthis){
|
||||
if (typeof console !== 'undefined') {
|
||||
console.log(logthis);
|
||||
}
|
||||
};
|
||||
|
||||
Template.hello.greeting = function () {
|
||||
if (typeof console !== 'undefined')
|
||||
console.log("mozdef starting");
|
||||
|
@ -35,6 +62,10 @@ if (Meteor.isClient) {
|
|||
Meteor.call('loadKibanaDashboards');
|
||||
return kibanadashboards.find();
|
||||
};
|
||||
|
||||
UI.registerHelper('uiDateFormat',function(adate){
|
||||
return dateFormat(adate);
|
||||
});
|
||||
|
||||
//helper functions for handlebars
|
||||
UI.registerHelper('now', function() {
|
||||
|
|
|
@ -88,7 +88,16 @@ if (Meteor.isServer) {
|
|||
|
||||
|
||||
Meteor.publish("incidents-summary", function () {
|
||||
return incidents.find({}, {limit:100});
|
||||
return incidents.find({},
|
||||
{fields: {
|
||||
_id:1,
|
||||
summary:1,
|
||||
phase:1,
|
||||
dateOpened:1,
|
||||
dateClosed:1
|
||||
},
|
||||
sort: {dateOpened: -1},
|
||||
limit:100});
|
||||
});
|
||||
|
||||
Meteor.publish("incidents-details",function(incidentid){
|
||||
|
|
Загрузка…
Ссылка в новой задаче