open-consul/ui-v2/app/helpers/format-time.js
Kenia 92c2614f6a
ui: Redesign Node Lock Sessions Tab (#8535)
* Add delay svg icon

* Create ConsulLockSessionList component

* Implement ConsulLockSession component in Lock Sessions tab

* Create format-time helper

* Add Invalidate button and fix up styling

* Fixup and add additional tests
2020-08-20 10:29:16 -04:00

30 lines
693 B
JavaScript

import { helper } from '@ember/component/helper';
export default helper(function formatTime([params], hash) {
let day, hour, minute, seconds;
seconds = Math.floor(params / 1000);
minute = Math.floor(seconds / 60);
seconds = seconds % 60;
hour = Math.floor(minute / 60);
minute = minute % 60;
day = Math.floor(hour / 24);
hour = hour % 24;
const time = {
day: day,
hour: hour,
minute: minute,
seconds: seconds,
};
switch (true) {
case time.day !== 0:
return time.day + 'd';
case time.hour !== 0:
return time.hour + 'h';
case time.minute !== 0:
return time.minute + 'm';
default:
return time.seconds + 's';
}
});