Skip to content

Commit

Permalink
added the raw date and time in the Meshes detail view.
Browse files Browse the repository at this point in the history
Signed-off-by: Daryn St. Pierre <daryn.st.pierre@konghq.com>
  • Loading branch information
Daryn St. Pierre committed Jul 23, 2020
1 parent c95d9e8 commit 44bb863
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
17 changes: 17 additions & 0 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,22 @@ export function humanReadableDate (tdate) {
return `on ${systemDate.toLocaleDateString()}`
}

/**
* rawReadableDate
*/
export function rawReadableDate (date) {
const rawDate = new Date(Date.parse(date))
const options = {
year: 'numeric',
month: 'long',
day: 'numeric'
}
const formattedDate = rawDate.toLocaleDateString('en-US', options)
const formattedTime = `${rawDate.getHours()}:${rawDate.getMinutes()}:${rawDate.getSeconds()}`

return `${formattedDate} @ ${formattedTime}`
}

/**
* Takes an object or array and only returns the keys and
* values you want based on the `items` value.
Expand Down Expand Up @@ -371,6 +387,7 @@ export default {
formatDate,
deepIncludes,
humanReadableDate,
rawReadableDate,
getSome,
stripUrl,
getOffset,
Expand Down
11 changes: 8 additions & 3 deletions src/views/Entities/Meshes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
{{ key }}
</h4>
<p v-if="key === 'creationTime' || key === 'modificationTime'">
{{ value | readableDate }}
{{ value | readableDate }} <em>({{ value | rawDate }})</em>
</p>
<p v-else>
{{ value }}
Expand Down Expand Up @@ -150,7 +150,7 @@

<script>
import { mapState } from 'vuex'
import { getSome, humanReadableDate, getOffset } from '@/helpers'
import { getSome, humanReadableDate, rawReadableDate, getOffset, stripTimes } from '@/helpers'
import EntityURLControl from '@/components/Utils/EntityURLControl'
import sortEntities from '@/mixins/EntitySorter'
import FrameSkeleton from '@/components/Skeletons/FrameSkeleton'
Expand Down Expand Up @@ -180,6 +180,9 @@ export default {
},
readableDate (value) {
return humanReadableDate(value)
},
rawDate (value) {
return rawReadableDate(value)
}
},
mixins: [
Expand Down Expand Up @@ -508,7 +511,9 @@ export default {
basicData: col1,
extendedData: formatted()
}
this.rawEntity = response
// this.rawEntity = response
this.rawEntity = stripTimes(response)
} else {
this.entity = null
this.entityIsEmpty = true
Expand Down

0 comments on commit 44bb863

Please sign in to comment.