|
5 | 5 |
|
6 | 6 | import { send_to_py } from "./py_vue_bridge.js" |
7 | 7 | import {get_tokens} from './clip_tokeniser/clip_encoder.js' |
| 8 | +const moment = require('moment') |
8 | 9 |
|
9 | 10 | let notification_sound = new Audio(require('@/assets/notification.mp3')) |
10 | 11 |
|
@@ -144,28 +145,27 @@ export default { |
144 | 145 | this.generation_state_msg = iter_time/1000 + " s/it"; |
145 | 146 | this.times.push(iter_time); |
146 | 147 | let median = this.times.sort((a, b) => a - b)[Math.floor(this.times.length / 2)]; |
147 | | - |
148 | | - let time_remaining = Math.floor(median*((100-p)*this.nb_its/100) / 1000); |
149 | | - |
150 | | - let minutes = Math.floor(time_remaining / 60); |
151 | | - let seconds = time_remaining - minutes * 60; |
| 148 | + let time_remaining = moment.duration(median*((100-p)*this.nb_its/100)); |
152 | 149 |
|
153 | 150 | if(time_remaining > 1){ |
154 | | - this.remaining_times = `(${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')} left)`; |
| 151 | + if (time_remaining.hours() > 0) { |
| 152 | + this.remaining_times = `(${time_remaining.hours()}h${time_remaining.minutes()}m left)`; |
| 153 | + } else { |
| 154 | + this.remaining_times = `(${time_remaining.minutes()}m${time_remaining.seconds()}s left)`; |
| 155 | + } |
155 | 156 | if (this.generation_loop) { |
156 | 157 | clearInterval(this.generation_loop); |
157 | 158 | } |
158 | | - this.generation_loop = setInterval(() => { |
159 | | - seconds--; |
160 | | - if (seconds < 0) { |
161 | | - seconds = 59; |
162 | | - minutes--; |
| 159 | + this.generation_loop = setInterval(() => { |
| 160 | + time_remaining.subtract(1, 'seconds'); |
| 161 | + if (time_remaining.hours() > 0) { |
| 162 | + this.remaining_times = `(${time_remaining.hours()}h${time_remaining.minutes()}m left)`; |
| 163 | + } else { |
| 164 | + this.remaining_times = `(${time_remaining.minutes()}m${time_remaining.seconds()}s left)`; |
163 | 165 | } |
164 | | - if (minutes == 0 && seconds == 0) { |
| 166 | + if (time_remaining < 1) { |
165 | 167 | clearInterval(this.generation_loop); |
166 | 168 | this.remaining_times = ""; |
167 | | - } else{ |
168 | | - this.remaining_times = `(${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')} left)`; |
169 | 169 | } |
170 | 170 | }, 1000); |
171 | 171 | } |
|
0 commit comments