Skip to content
Snippets Groups Projects
Commit 26b3aea7 authored by Winnie Hellmann's avatar Winnie Hellmann
Browse files

Introduce gl-countdown directive for updating delayed job timers

parent 0330fa4b
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -4,10 +4,12 @@ import { formatTime } from '~/lib/utils/datetime_utility';
import eventHub from '../event_hub';
import icon from '../../vue_shared/components/icon.vue';
import tooltip from '../../vue_shared/directives/tooltip';
import glCountdown from '~/vue_shared/directives/gl_countdown';
 
export default {
directives: {
tooltip,
glCountdown,
},
components: {
icon,
Loading
Loading
@@ -100,7 +102,10 @@ export default {
class="pull-right"
>
<icon name="clock" />
{{ remainingTime(action) }}
<time
v-gl-countdown="{ endDate: action.scheduled_at }"
:datetime="action.scheduled_at"
>00:00:00</time>
</span>
</button>
</li>
Loading
Loading
import { formatTime } from '~/lib/utils/datetime_utility';
const updateRemainingTime = (el, binding) => {
const { endDate } = binding.value;
const remainingMilliseconds = new Date(endDate).getTime() - Date.now();
if (remainingMilliseconds >= 0) {
el.innerText = formatTime(remainingMilliseconds);
}
};
export default {
bind(el, binding) {
updateRemainingTime(el, binding);
el.dataset.countdownUpdateIntervalId = window.setInterval(
() => updateRemainingTime(el, binding),
1000,
);
},
unbind(el) {
window.clearInterval(el.dataset.countdownUpdateIntervalId);
}
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment