2018-06-07 18:46:24 +02:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
const brToNewline = require('br2nl')
|
|
|
|
|
|
|
|
const parseDateTime = require('./date-time')
|
|
|
|
|
2018-06-30 18:04:44 +02:00
|
|
|
const typesByIcon = Object.assign(Object.create(null), {
|
|
|
|
HimWarn: 'status'
|
|
|
|
})
|
|
|
|
|
2018-06-07 18:46:24 +02:00
|
|
|
// todo: is passing in profile necessary?
|
2018-06-30 18:04:44 +02:00
|
|
|
const parseWarning = (profile, w, icons) => {
|
2018-06-07 18:46:24 +02:00
|
|
|
// todo: hid, act, pub, lead, tckr, icoX, fLocX, tLocX, prod, comp,
|
|
|
|
// todo: cat (1, 2), pubChL
|
|
|
|
// pubChL:
|
|
|
|
// [ { name: 'timetable',
|
|
|
|
// fDate: '20180606',
|
|
|
|
// fTime: '073000',
|
|
|
|
// tDate: '20180713',
|
|
|
|
// tTime: '030000' },
|
|
|
|
// { name: 'export',
|
|
|
|
// fDate: '20180606',
|
|
|
|
// fTime: '073000',
|
|
|
|
// tDate: '20180713',
|
|
|
|
// tTime: '030000' } ]
|
|
|
|
|
2018-07-02 16:59:38 +02:00
|
|
|
const icon = 'number' === typeof w.icoX && icons[w.icoX] || null
|
2018-06-30 18:04:44 +02:00
|
|
|
const type = icon && icon.res && typesByIcon[icon.res] || 'warning'
|
|
|
|
|
2018-06-07 18:46:24 +02:00
|
|
|
return {
|
2018-06-30 18:04:44 +02:00
|
|
|
type,
|
2018-06-07 18:46:24 +02:00
|
|
|
summary: brToNewline(w.head),
|
|
|
|
text: brToNewline(w.text),
|
|
|
|
priority: w.prio,
|
|
|
|
category: w.cat, // todo: parse to sth meaningful
|
|
|
|
validFrom: parseDateTime(profile, w.sDate, w.sTime).toISO(),
|
|
|
|
validUntil: parseDateTime(profile, w.eDate, w.eTime).toISO(),
|
|
|
|
modified: parseDateTime(profile, w.lModDate, w.lModTime).toISO()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = parseWarning
|