Skip to content

feat: Add Milliseconds Display Preference and Remove Duplicate Filter… #782

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/devtools/filters.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export function formatTime (timestamp) {
return (new Date(timestamp)).toString().match(/\d\d:\d\d:\d\d/)[0]
export function formatTime (timestamp, format) {
const date = new Date(timestamp)
return `${date.toString().match(/\d\d:\d\d:\d\d/)[0]}${format === 'ms' ? '.' + date.getMilliseconds() : ''}`
}
6 changes: 1 addition & 5 deletions src/devtools/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import SharedData, { init as initSharedData, destroy as destroySharedData } from
import { init as initStorage } from 'src/storage'
import VuexResolve from './views/vuex/resolve'

// register filters
for (const key in filters) {
Vue.filter(key, filters[key])
}
Expand Down Expand Up @@ -191,11 +192,6 @@ function initApp (shell) {
store.commit('routes/CHANGED', parse(payload))
})

// register filters
Vue.filter('formatTime', function (timestamp) {
return (new Date(timestamp)).toString().match(/\d\d:\d\d:\d\d/)[0]
})

bridge.on('events:reset', () => {
store.commit('events/RESET')
})
Expand Down
2 changes: 1 addition & 1 deletion src/devtools/views/events/EventsHistory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<span class="component-name">{{ displayComponentName(event.instanceName) }}</span>
<span>&gt;</span>
</span>
<span class="time">{{ event.timestamp | formatTime }}</span>
<span class="time">{{ event.timestamp | formatTime($shared.timeFormat) }}</span>
</div>
</template>
</RecycleScroller>
Expand Down
4 changes: 1 addition & 3 deletions src/devtools/views/perf/FramerateGraph.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@
import { mapState, mapGetters } from 'vuex'
import * as d3 from 'd3'
import { FPS_MARKERS_PRECISION } from './module'
import { formatTime } from 'filters'

import SplitPane from 'components/SplitPane.vue'
import FramerateMarkerInspector from './FramerateMarkerInspector.vue'

Expand Down Expand Up @@ -167,7 +165,7 @@ export default {
getBarTootip (metric) {
return `
<div>${metric.value} frames per second</div>
<div style="color:#999;">${formatTime(metric.time)}</div>
<div style="color:#999;">${this.$options.filters.formatTime(metric.time, this.$shared.timeFormat)}</div>
`
},

Expand Down
2 changes: 1 addition & 1 deletion src/devtools/views/perf/FramerateMarkerInspector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
{{ entry.label }}
</div>
<div class="time">
{{ entry.timestamp | formatTime }}
{{ entry.timestamp | formatTime($shared.timeFormat) }}
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/devtools/views/router/RouterHistory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
@click="inspect(routeChanges.indexOf(route))"
>
<span class="route-name">{{ route.to.path }}</span>
<span class="time">{{ route.timestamp | formatTime }}</span>
<span class="time">{{ route.timestamp | formatTime($shared.timeFormat) }}</span>
<span
v-if="route.to.redirectedFrom"
class="label redirect"
Expand Down
9 changes: 9 additions & 0 deletions src/devtools/views/settings/GlobalPreferences.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@
</template>
</VueFormField>

<VueFormField title="Time Format">
<VueSwitch
:value="$shared.timeFormat === 'ms'"
@update="value => $shared.timeFormat = value ? 'ms' : 'default'"
>
Display milliseconds
</VueSwitch>
</VueFormField>

<VueFormField title="Detected Vue message">
<VueSwitch v-model="$shared.logDetected">
Display in browser console
Expand Down
11 changes: 2 additions & 9 deletions src/devtools/views/vuex/VuexHistory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
</a>
</span>
<span class="time">
{{ lastCommit | formatTime }}
{{ lastCommit | formatTime($shared.timeFormat) }}
</span>
<span
v-if="activeIndex === -1"
Expand Down Expand Up @@ -144,7 +144,7 @@
v-tooltip="entry.timestamp"
class="time"
>
{{ entry.timestamp | formatTime }}
{{ entry.timestamp | formatTime($shared.timeFormat) }}
</span>
<span
v-if="isActive(index, entry)"
Expand Down Expand Up @@ -180,13 +180,6 @@ export default {
ActionHeader,
ScrollPane
},

filters: {
formatTime (timestamp) {
return (new Date(timestamp)).toString().match(/\d\d:\d\d:\d\d/)[0]
}
},

mixins: [
Keyboard({
onKeyDown ({ key, modifiers }) {
Expand Down
4 changes: 3 additions & 1 deletion src/shared-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const internalSharedData = {
componentNameStyle: 'class',
theme: 'auto',
displayDensity: 'low',
timeFormat: 'default',
recordVuex: true,
cacheVuexSnapshotsEvery: 50,
cacheVuexSnapshotsLimit: 10,
Expand All @@ -25,7 +26,8 @@ const persisted = [
'editableProps',
'logDetected',
'vuexNewBackend',
'vuexAutoload'
'vuexAutoload',
'timeFormat'
]

// ---- INTERNALS ---- //
Expand Down