Skip to content

Commit

Permalink
fix(logs): fix logs ui test
Browse files Browse the repository at this point in the history
  • Loading branch information
burgerni10 authored and Nicolas Burger committed Nov 9, 2022
1 parent 53102ce commit b4a84c3
Show file tree
Hide file tree
Showing 8 changed files with 1,648 additions and 1,374 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ exports[`OIbDate check date with value="2021-11-20" 1`] = `
>
<label
class="form-label"
for="endTimedate"
for="endDate"
>
To date
</label>
<input
class="oi-form-input form-control"
id="endTimedate"
id="endDate"
placeholder="yyyy-mm-ddThh:mm:ss+hh:mm"
required=""
type="date"
value="2021-11-20"
/>
<input
class="oi-form-input form-control"
id="endTimetime"
id="endTime"
placeholder="yyyy-mm-ddThh:mm:ss+hh:mm"
required=""
type="time"
Expand Down
22 changes: 11 additions & 11 deletions src/frontend/components/oib-form/oib-date.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ import { DateTime } from 'luxon'
import { FormGroup, FormFeedback, FormText, Label, Input } from 'reactstrap'

const OibDate = ({ label, help, valid, value, name, onChange, inline, hidden, maxDateString }) => {
let dateTime = value ? DateTime.fromISO(new Date(value).toISOString()) : DateTime.now().set({second: 0, millisecond: 0})
let dateTime = value ? DateTime.fromISO(new Date(value).toISOString()) : DateTime.now().set({ second: 0, millisecond: 0 })

const handleTimeChange = (event) => {
const { target } = event
const { value: newVal } = target
const inputDate = newVal.split(":")
dateTime = dateTime.set({ hour: parseInt(inputDate[0]), minute: parseInt(inputDate[1]) })
const inputDate = newVal.split(':')
dateTime = dateTime.set({ hour: parseInt(inputDate[0], 10), minute: parseInt(inputDate[1], 10) })
onChange(name, dateTime.toISO(), valid(newVal))
}

const handleDateChange = (event) => {
const { target } = event
const { value: newVal } = target

const inputDate = newVal.split("-")
dateTime = dateTime.set({ year: parseInt(inputDate[0]), month: parseInt(inputDate[1]), day: parseInt(inputDate[2]) })
const inputDate = newVal.split('-')
dateTime = dateTime.set({ year: parseInt(inputDate[0], 10), month: parseInt(inputDate[1], 10), day: parseInt(inputDate[2], 10) })
onChange(name, dateTime.toISO(), valid(newVal))
}

Expand All @@ -29,11 +29,11 @@ const OibDate = ({ label, help, valid, value, name, onChange, inline, hidden, ma
}
if (hidden) return null
const validCheck = valid(value)
const formattedDate = value ? DateTime.fromISO(new Date(value).toISOString()).toFormat('yyyy-MM-dd') : ""
const formattedTime = value ? DateTime.fromISO(new Date(value).toISOString()).toFormat('HH:mm') : ""
const dateId = name+ "date"
const timeId = name+ "time"

const formattedDate = value ? DateTime.fromISO(new Date(value).toISOString()).toFormat('yyyy-MM-dd') : ''
const formattedTime = value ? DateTime.fromISO(new Date(value).toISOString()).toFormat('HH:mm') : ''
const dateId = `${name}Date`
const timeId = `${name}Time`

return (
<FormGroup style={style}>
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/components/oib-form/oib-date.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('OIbDate', () => {
test('check date with value="2021-11-20"', () => {
act(() => {
root.render(<OibDate
name="endTime"
name="end"
value="2021-11-20"
label="To date"
onChange={() => {}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,21 +179,21 @@ exports[`HistoryQueryForm check HistoryQueryForm with data: MSSQL South -> Conso
>
<label
class="form-label"
for="startTimedate"
for="startDate"
>
From date
</label>
<input
class="oi-form-input form-control"
id="startTimedate"
id="startDate"
placeholder="yyyy-mm-ddThh:mm:ss+hh:mm"
required=""
type="date"
value="2021-10-15"
/>
<input
class="oi-form-input form-control"
id="startTimetime"
id="startTime"
placeholder="yyyy-mm-ddThh:mm:ss+hh:mm"
required=""
type="time"
Expand All @@ -212,21 +212,21 @@ exports[`HistoryQueryForm check HistoryQueryForm with data: MSSQL South -> Conso
>
<label
class="form-label"
for="endTimedate"
for="endDate"
>
To date
</label>
<input
class="oi-form-input form-control"
id="endTimedate"
id="endDate"
placeholder="yyyy-mm-ddThh:mm:ss+hh:mm"
required=""
type="date"
value="2021-10-16"
/>
<input
class="oi-form-input form-control"
id="endTimetime"
id="endTime"
placeholder="yyyy-mm-ddThh:mm:ss+hh:mm"
required=""
type="time"
Expand Down Expand Up @@ -551,21 +551,21 @@ exports[`HistoryQueryForm check HistoryQueryForm with data: MSSQL South -> OIAna
>
<label
class="form-label"
for="startTimedate"
for="startDate"
>
From date
</label>
<input
class="oi-form-input form-control"
id="startTimedate"
id="startDate"
placeholder="yyyy-mm-ddThh:mm:ss+hh:mm"
required=""
type="date"
value="2021-10-15"
/>
<input
class="oi-form-input form-control"
id="startTimetime"
id="startTime"
placeholder="yyyy-mm-ddThh:mm:ss+hh:mm"
required=""
type="time"
Expand All @@ -584,21 +584,21 @@ exports[`HistoryQueryForm check HistoryQueryForm with data: MSSQL South -> OIAna
>
<label
class="form-label"
for="endTimedate"
for="endDate"
>
To date
</label>
<input
class="oi-form-input form-control"
id="endTimedate"
id="endDate"
placeholder="yyyy-mm-ddThh:mm:ss+hh:mm"
required=""
type="date"
value="2021-10-16"
/>
<input
class="oi-form-input form-control"
id="endTimetime"
id="endTime"
placeholder="yyyy-mm-ddThh:mm:ss+hh:mm"
required=""
type="time"
Expand Down Expand Up @@ -922,21 +922,21 @@ exports[`HistoryQueryForm check HistoryQueryForm with empty North 1`] = `
>
<label
class="form-label"
for="startTimedate"
for="startDate"
>
From date
</label>
<input
class="oi-form-input form-control"
id="startTimedate"
id="startDate"
placeholder="yyyy-mm-ddThh:mm:ss+hh:mm"
required=""
type="date"
value=""
/>
<input
class="oi-form-input form-control"
id="startTimetime"
id="startTime"
placeholder="yyyy-mm-ddThh:mm:ss+hh:mm"
required=""
type="time"
Expand All @@ -955,21 +955,21 @@ exports[`HistoryQueryForm check HistoryQueryForm with empty North 1`] = `
>
<label
class="form-label"
for="endTimedate"
for="endDate"
>
To date
</label>
<input
class="oi-form-input form-control"
id="endTimedate"
id="endDate"
placeholder="yyyy-mm-ddThh:mm:ss+hh:mm"
required=""
type="date"
value=""
/>
<input
class="oi-form-input form-control"
id="endTimetime"
id="endTime"
placeholder="yyyy-mm-ddThh:mm:ss+hh:mm"
required=""
type="time"
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/history-query/form/history-query-form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,15 +307,15 @@ const HistoryQueryForm = ({ query }) => {
<Row>
<Col md={2}>
<OibDate
name="startTime"
name="start"
value={queryToUpdate.startTime}
label="From date"
onChange={onChange}
/>
</Col>
<Col md={2}>
<OibDate
name="endTime"
name="end"
value={queryToUpdate.endTime}
label="To date"
onChange={onChange}
Expand Down
Loading

0 comments on commit b4a84c3

Please sign in to comment.