@@ -82,15 +82,20 @@ function UsageView({ attributionId, billingMode }: UsageViewProps) {
82
82
return "Prebuild" ;
83
83
} ;
84
84
85
+ const isRunning = ( usage : Usage ) => {
86
+ if ( usage . kind !== "workspaceinstance" ) {
87
+ return false ;
88
+ }
89
+ const metaData = usage . metadata as WorkspaceInstanceUsageData ;
90
+ return metaData . endTime === "" || metaData . endTime === undefined ;
91
+ } ;
92
+
85
93
const getMinutes = ( usage : Usage ) => {
86
94
if ( usage . kind !== "workspaceinstance" ) {
87
95
return "" ;
88
96
}
89
97
const metaData = usage . metadata as WorkspaceInstanceUsageData ;
90
- if ( ! metaData . endTime ) {
91
- return "running" ;
92
- }
93
- const end = new Date ( metaData . endTime ) . getTime ( ) ;
98
+ const end = metaData . endTime ? new Date ( metaData . endTime ) . getTime ( ) : Date . now ( ) ;
94
99
const start = new Date ( metaData . startTime ) . getTime ( ) ;
95
100
const lengthOfUsage = Math . floor ( end - start ) ;
96
101
const inMinutes = ( lengthOfUsage / ( 1000 * 60 ) ) . toFixed ( 1 ) ;
@@ -139,7 +144,12 @@ function UsageView({ attributionId, billingMode }: UsageViewProps) {
139
144
140
145
return (
141
146
< >
142
- < Header title = "Usage" subtitle = "View usage details (updated every 15 minutes)." />
147
+ < Header
148
+ title = "Usage"
149
+ subtitle = { `${ new Date ( startDateOfBillMonth ) . toLocaleDateString ( ) } - ${ new Date (
150
+ endDateOfBillMonth ,
151
+ ) . toLocaleDateString ( ) } (updated every 15 minutes).`}
152
+ />
143
153
< div className = "app-container pt-5" >
144
154
{ errorMessage && < p className = "text-base" > { errorMessage } </ p > }
145
155
{ ! errorMessage && (
@@ -163,29 +173,31 @@ function UsageView({ attributionId, billingMode }: UsageViewProps) {
163
173
< div className = "text-base text-gray-500" > Total usage</ div >
164
174
< div className = "flex text-lg text-gray-600 font-semibold" >
165
175
< CreditsSvg className = "my-auto mr-1" />
166
- < span > { totalCreditsUsed } Credits</ span >
176
+ < span > { Intl . NumberFormat ( ) . format ( totalCreditsUsed ) } Credits</ span >
167
177
</ div >
168
178
</ div >
169
179
) }
170
180
</ div >
171
181
</ div >
172
- { ! isLoading && usagePage === undefined && ! errorMessage && (
173
- < div className = "flex flex-col w-full mb-8" >
174
- < h3 className = "text-center text-gray-500 mt-8" > No sessions found.</ h3 >
175
- < p className = "text-center text-gray-500 mt-1" >
176
- Have you started any
177
- < a className = "gp-link" href = { gitpodHostUrl . asWorkspacePage ( ) . toString ( ) } >
178
- { " " }
179
- workspaces
180
- </ a > { " " }
181
- in{ " " }
182
- { new Date ( startDateOfBillMonth ) . toLocaleString ( "default" , {
183
- month : "long" ,
184
- } ) } { " " }
185
- { new Date ( startDateOfBillMonth ) . getFullYear ( ) } or checked your other teams?
186
- </ p >
187
- </ div >
188
- ) }
182
+ { ! isLoading &&
183
+ ( usagePage === undefined || usagePage . usageEntriesList . length === 0 ) &&
184
+ ! errorMessage && (
185
+ < div className = "flex flex-col w-full mb-8" >
186
+ < h3 className = "text-center text-gray-500 mt-8" > No sessions found.</ h3 >
187
+ < p className = "text-center text-gray-500 mt-1" >
188
+ Have you started any
189
+ < a className = "gp-link" href = { gitpodHostUrl . asWorkspacePage ( ) . toString ( ) } >
190
+ { " " }
191
+ workspaces
192
+ </ a > { " " }
193
+ in{ " " }
194
+ { new Date ( startDateOfBillMonth ) . toLocaleString ( "default" , {
195
+ month : "long" ,
196
+ } ) } { " " }
197
+ { new Date ( startDateOfBillMonth ) . getFullYear ( ) } or checked your other teams?
198
+ </ p >
199
+ </ div >
200
+ ) }
189
201
{ isLoading && (
190
202
< div className = "flex flex-col place-items-center align-center w-full" >
191
203
< div className = "uppercase text-sm text-gray-400 dark:text-gray-500 mb-5" >
@@ -237,9 +249,20 @@ function UsageView({ attributionId, billingMode }: UsageViewProps) {
237
249
</ span >
238
250
</ div >
239
251
< div className = "flex flex-col col-span-5 my-auto" >
240
- < span className = "truncate text-gray-600 dark:text-gray-100 text-md font-medium" >
241
- { ( usage . metadata as WorkspaceInstanceUsageData ) . workspaceId }
242
- </ span >
252
+ < div className = "flex" >
253
+ { isRunning ( usage ) && (
254
+ < div
255
+ className = "rounded-full w-2 h-2 text-sm align-middle bg-green-500 my-auto mx-1"
256
+ title = "Still running"
257
+ />
258
+ ) }
259
+ < span className = "truncate text-gray-600 dark:text-gray-100 text-md font-medium" >
260
+ {
261
+ ( usage . metadata as WorkspaceInstanceUsageData )
262
+ . workspaceId
263
+ }
264
+ </ span >
265
+ </ div >
243
266
< span className = "text-sm truncate text-gray-400 dark:text-gray-500" >
244
267
{ ( usage . metadata as WorkspaceInstanceUsageData )
245
268
. contextURL &&
@@ -253,9 +276,11 @@ function UsageView({ attributionId, billingMode }: UsageViewProps) {
253
276
< span className = "text-right text-gray-500 dark:text-gray-400 font-medium" >
254
277
{ usage . credits . toFixed ( 1 ) }
255
278
</ span >
256
- < span className = "text-right truncate text-sm text-gray-400 dark:text-gray-500" >
257
- { getMinutes ( usage ) }
258
- </ span >
279
+ < div className = "flex" >
280
+ < span className = "text-right truncate text-sm text-gray-400 dark:text-gray-500" >
281
+ { getMinutes ( usage ) }
282
+ </ span >
283
+ </ div >
259
284
</ div >
260
285
< div className = "my-auto" />
261
286
< div className = "flex flex-col col-span-3 my-auto" >
0 commit comments