| 162 | } |
| 163 | |
| 164 | fn draw( |
| 165 | frame: &mut Frame, |
| 166 | progress: &Progress, |
| 167 | sample: &Resources, |
| 168 | cpu: Option<f64>, |
| 169 | elapsed: Duration, |
| 170 | metrics: &Metrics, |
| 171 | ) { |
| 172 | let area = frame.area(); |
| 173 | if area.width < 76 || area.height < 22 { |
| 174 | let content = format!("{}\nBlob budget is not total process memory.\nStaging is private; final proof is required.", plain(progress, sample, cpu, elapsed)); |
| 175 | frame.render_widget( |
| 176 | Paragraph::new(content).wrap(Wrap { trim: true }).block( |
| 177 | panel(" Atomic import ").title_style(Style::default().fg(Color::Cyan).bold()), |
| 178 | ), |
| 179 | area, |
| 180 | ); |
| 181 | return; |
| 182 | } |
| 183 | let rows = Layout::vertical([ |
| 184 | Constraint::Length(4), |
| 185 | Constraint::Length(3), |
| 186 | Constraint::Length(6), |
| 187 | Constraint::Min(7), |
| 188 | Constraint::Length(2), |
| 189 | ]) |
| 190 | .split(area); |
| 191 | let status_color = match progress.phase { |
| 192 | "complete" => Color::Green, |
| 193 | "stopped / failed" => Color::Red, |
| 194 | "final proof / promote" => Color::Yellow, |
| 195 | _ => Color::Cyan, |
| 196 | }; |
| 197 | let header = vec![ |
| 198 | Line::from(vec![ |
| 199 | Span::styled( |
| 200 | format!(" {} ", progress.phase), |
| 201 | Style::default().fg(status_color).bold(), |
| 202 | ), |
| 203 | Span::raw(format!(" {:.1}s elapsed", elapsed.as_secs_f64())), |
| 204 | ]), |
| 205 | Line::from(format!( |
| 206 | " {:.1} commits/s average Staging ETA {}", |
| 207 | rate(progress, elapsed), |
| 208 | eta(progress, elapsed) |
| 209 | )), |
| 210 | ]; |
| 211 | frame.render_widget( |
| 212 | Paragraph::new(header).block(panel(" ATOMIC / ROLLING IMPORT ")), |
| 213 | rows[0], |
| 214 | ); |
| 215 | frame.render_widget( |
| 216 | Gauge::default() |
| 217 | .block(panel(" Privately staged history ")) |
| 218 | .gauge_style(Style::default().fg(Color::Cyan)) |
| 219 | .ratio(ratio(progress.published, progress.total)) |
| 220 | .label(format!( |
| 221 | "{} / {} commits", |