-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Expand file tree
/
Copy pathOperationsBar.jsx
More file actions
87 lines (84 loc) · 3.52 KB
/
Copy pathOperationsBar.jsx
File metadata and controls
87 lines (84 loc) · 3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { useOperations } from '../hooks/useOperations'
export default function OperationsBar() {
const { operations, cancelOperation, dismissFailedOp } = useOperations()
if (operations.length === 0) return null
return (
<div className="operations-bar">
{operations.map(op => (
<div key={op.jobID || op.id} className="operation-item">
<div className="operation-info">
{op.error ? (
<i className="fas fa-circle-exclamation" style={{ color: 'var(--color-error)', marginRight: 'var(--spacing-xs)' }} />
) : op.isCancelled ? (
<i className="fas fa-ban" style={{ color: 'var(--color-warning)', marginRight: 'var(--spacing-xs)' }} />
) : op.isDeletion ? (
<i className="fas fa-trash" style={{ color: 'var(--color-error)', marginRight: 'var(--spacing-xs)' }} />
) : (
<div className="operation-spinner" />
)}
<span className="operation-text">
{op.error ? (
<>
Failed to install {op.isBackend ? 'backend' : 'model'}: {op.name || op.id}
<span style={{ fontSize: '0.75rem', color: 'var(--color-text-muted)', marginLeft: 'var(--spacing-xs)' }}>
({op.error})
</span>
</>
) : op.taskType === 'staging' ? (
<>
<i className="fas fa-cloud-arrow-up" style={{ marginRight: 'var(--spacing-xs)' }} />
Staging model: {op.name}{op.nodeName ? ` → ${op.nodeName}` : ''}
</>
) : (
<>
{op.isDeletion ? 'Removing' : 'Installing'}{' '}
{op.isBackend ? 'backend' : 'model'}: {op.name || op.id}
</>
)}
</span>
{!op.error && op.isQueued && (
<span style={{ fontSize: '0.75rem', color: 'var(--color-text-muted)', marginLeft: 'var(--spacing-xs)' }}>
(Queued)
</span>
)}
{!op.error && op.isCancelled && (
<span style={{ fontSize: '0.75rem', color: 'var(--color-warning)', marginLeft: 'var(--spacing-xs)' }}>
Cancelling...
</span>
)}
{!op.error && op.message && !op.isQueued && !op.isCancelled && (
<span style={{ fontSize: '0.75rem', color: 'var(--color-text-muted)', marginLeft: 'var(--spacing-xs)' }}>
{op.message}
</span>
)}
{!op.error && op.progress !== undefined && op.progress > 0 && (
<span className="operation-progress">{Math.round(op.progress)}%</span>
)}
</div>
{!op.error && op.progress !== undefined && op.progress > 0 && (
<div className="operation-bar-container">
<div className="operation-bar" style={{ width: `${op.progress}%` }} />
</div>
)}
{op.error ? (
<button
className="operation-cancel"
onClick={() => dismissFailedOp(op.id)}
title="Dismiss"
>
<i className="fas fa-xmark" />
</button>
) : op.cancellable && !op.isCancelled ? (
<button
className="operation-cancel"
onClick={() => cancelOperation(op.jobID)}
title="Cancel"
>
<i className="fas fa-xmark" />
</button>
) : null}
</div>
))}
</div>
)
}