Skip to content

Commit

Permalink
ui: add duration to workflow view
Browse files Browse the repository at this point in the history
  • Loading branch information
sevein committed Jan 23, 2020
1 parent 1f5dd1a commit 9fe22a7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
14 changes: 14 additions & 0 deletions ui/src/filters/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import Vue from 'vue';
import moment from 'moment';
import humanizeDuration from 'humanize-duration';

Vue.filter('formatDateTimeString', (value: string) => {
const date = new Date(value);
Expand All @@ -19,3 +21,15 @@ Vue.filter('formatEpoch', (value: number) => {
const date = new Date(value / 1000 / 1000); // TODO: is this right?
return date.toLocaleString();
});

Vue.filter('formatDuration', (from: Date, to: Date) => {
const diff = moment(to).diff(from);
return humanizeDuration(moment.duration(diff).asMilliseconds());
});

Vue.filter('formatEpochDuration', (from: number, to: number) => {
const f = new Date(Math.round(from / 1000 / 1000));
const t = new Date(Math.round(to / 1000 / 1000));
const diff = moment(t).diff(f);
return humanizeDuration(moment.duration(diff).asMilliseconds());
});
9 changes: 1 addition & 8 deletions ui/src/views/CollectionShow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<dt>Stored</dt>
<dd>
{{ collection.completedAt | formatDateTime }}
(took {{ took(collection.startedAt, collection.completedAt) }})
(took {{ collection.startedAt | formatDuration(collection.completedAt) }})
</dd>
</template>

Expand Down Expand Up @@ -106,8 +106,6 @@ import { Component, Vue } from 'vue-property-decorator';
import { namespace } from 'vuex-class';
import * as CollectionStore from '../store/collection';
import CollectionStatusBadge from '@/components/CollectionStatusBadge.vue';
import moment from 'moment';
import humanizeDuration from 'humanize-duration';
import { api, EnduroCollectionClient } from '../client';
Expand All @@ -126,11 +124,6 @@ export default class CollectionShow extends Vue {
@collectionStoreNs.Action(CollectionStore.SEARCH_COLLECTION)
private search: any;
private took(created: Date, completed: Date): string {
const diff = moment(completed).diff(created);
return humanizeDuration(moment.duration(diff).asMilliseconds());
}
private retry(id: string): Promise<any> {
return EnduroCollectionClient.collectionRetry({id: +id});
}
Expand Down
6 changes: 4 additions & 2 deletions ui/src/views/CollectionShowWorkflow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@

<template v-if="completedAt">
<dt>Completed</dt>
<dd>{{ completedAt | formatEpoch }}</dd>
<dd>
{{ completedAt | formatEpoch }}
(took {{ startedAt | formatEpochDuration(completedAt) }})
</dd>
</template>

<dt>Activity summary</dt>
Expand Down Expand Up @@ -193,7 +196,6 @@ export default class CollectionShowWorkflow extends Vue {
} else if (event.type === 'WorkflowExecutionStarted') {
this.startedAt = details.timestamp;
} else if (event.type === 'WorkflowExecutionCompleted') {
console.log(details);
this.completedAt = details.timestamp;
} else if (event.type === 'WorkflowExecutionFailed') {
const attrs = details.workflowExecutionFailedEventAttributes;
Expand Down

0 comments on commit 9fe22a7

Please sign in to comment.