Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
renderEventSummary() {
const { event, boxEvents, derivedIncidents } = this.state;
const date = event ? Moment(event.target_event_start_timestamp_ms).format('YYYY-MM-DD') : '';
const time = event ? Moment(event.target_event_start_timestamp_ms).format('HH:mm:ss') : '';
const duration_ms = event ? event.target_event_end_timestamp_ms - event.target_event_start_timestamp_ms : '';
// Get the location description of the initial triggered box event.
const { triggeredBoxEvents } = this.separateBoxEvents(event, boxEvents);
const boxEvent = (triggeredBoxEvents.length) ? triggeredBoxEvents[0] : null;
const locationDoc = boxEvent ? this.getBoxEventLocationDoc(boxEvent) : null;
const triggeredBoxEventLocation = locationDoc ? locationDoc.description : 'UNAVAILABLE';
const pStyle = { fontSize: '16px' };
const derivedIncidentsDisplay = derivedIncidents.length ? (
<div>
<p style="{pStyle}">
This event generated {derivedIncidents.length} incidents:
</p>
<div style="{{"></div></div>
setUrlQuery(boxIds, startTime_ms, endTime_ms) {
const startTimeFormatted = Moment(startTime_ms).format('YYYY-MM-DDTHH:mm:ss');
const endTimeFormatted = Moment(endTime_ms).format('YYYY-MM-DDTHH:mm:ss');
// HashRouter doesn't seem to play nicely with history.push(), so we use replace() instead. The only loss is
// that we can no longer use back/forward on the browser history to navigate between previous inspector queries.
this.props.history.replace({
pathname: this.props.location.pathname,
search: `?startTime=${startTimeFormatted}&endTime=${endTimeFormatted}&boxes=${boxIds}`,
});
}
export function getValueString(obsType, val, unitSystem, format) {
if (val === undefined) {
return "N/A";
}
// Special treatment for time
if (obsType === "timestamp") {
if (format == null) format = "D-MMM-YYYY HH:mm:ss";
return moment(val).format(format);
}
// It's a regular ol' observation type. Get a label and format the number.
const label = getUnitLabel(obsType, unitSystem, val);
const unitFormat = format || getUnitFormat(obsType, unitSystem);
return sprintf(unitFormat, val) + label;
}
constructor(props) {
super(props);
const end = Moment();
const start = Moment(end).subtract(1, 'day');
this.state = {
start: start.format('YYYY-MM-DDTHH:mm:ss'),
end: end.format('YYYY-MM-DDTHH:mm:ss'),
loading: false,
loaded: false,
selectedBoxes: [],
incidents: [],
column: null,
direction: null, // Either 'ascending', 'descending', or null
};
}
define({ event_id, type, description, boxes_triggered, boxes_received, target_event_start_timestamp_ms,
target_event_end_timestamp_ms, latencies_ms }) {
// Allow start and end times to be anything acceptable to the moment() parser.
target_event_start_timestamp_ms = moment(target_event_start_timestamp_ms).valueOf(); // eslint-disable-line
target_event_end_timestamp_ms = moment(target_event_end_timestamp_ms).valueOf(); // eslint-disable-line
// Make sure boxes_triggered contains valid box_ids.
OpqBoxes.assertValidBoxIds(boxes_triggered);
const docID = this._collection.insert({ event_id, type, description, boxes_triggered, boxes_received,
target_event_start_timestamp_ms, target_event_end_timestamp_ms, latencies_ms });
return docID;
}
render: (text) => {
return moment(text, "X").format("YYYY-MM-DD HH:mm:ss");
}
}, {
getTomorrowsPrayerTime() {
var date = moment()
.add(1, 'days')
.format('DD/MM/YYYY');
var _data = new PrayerData();
return _data.getPrayerTimes(date);
}
const downloadPrivateKeys = () => {
const element = document.createElement('a')
const text = getText()
const message = 'Check your browser downloads'
element.setAttribute('href', `data:text/plaincharset=utf-8,${encodeURIComponent(text)}`)
element.setAttribute('download', `${window.location.hostname}_keys_${moment().format('DD.MM.YYYY')}.txt`)
element.style.display = 'none'
document.body.appendChild(element)
element.click()
document.body.removeChild(element)
actions.notifications.show(constants.notifications.Message, {
message,
})
localStorage.setItem(constants.localStorage.privateKeysSaved, true)
}