Skip to content

Commit e3fe752

Browse files
committed
feat: Add support for auto-loading test data in development mode and extend usage report service with custom image storage
1 parent 6d0e9f0 commit e3fe752

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/app/components/usage/usage.component.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { OnInit, ChangeDetectorRef, Component, OnDestroy } from '@angular/core';
1+
import { OnInit, ChangeDetectorRef, Component, OnDestroy, isDevMode } from '@angular/core';
22
import { FormControl, FormGroup } from '@angular/forms';
33
import { UsageReport } from 'github-usage-report/src/types';
44
import { Observable, Subscription, debounceTime, map, startWith } from 'rxjs';
55
import { CustomUsageReportLine, UsageReportService } from 'src/app/usage-report.service';
66
import { DialogBillingNavigateComponent } from './dialog-billing-navigate';
77
import { MatDialog } from '@angular/material/dialog';
88
import { ModelUsageReport } from 'github-usage-report';
9+
import { HttpClient } from '@angular/common/http';
910

1011
@Component({
1112
selector: 'app-usage',
@@ -42,10 +43,16 @@ export class UsageComponent implements OnInit, OnDestroy {
4243
private usageReportService: UsageReportService,
4344
public dialog: MatDialog,
4445
private cdr: ChangeDetectorRef,
46+
private http: HttpClient,
4547
) {
4648
}
4749

4850
ngOnInit() {
51+
// Auto-load test data in development mode
52+
if (isDevMode()) {
53+
this.loadTestData();
54+
}
55+
4956
this.subscriptions.push(
5057
this.range.valueChanges.pipe(debounceTime(500)).subscribe(value => {
5158
if (value.start && value.start instanceof Date && !isNaN(value.start.getTime()) &&
@@ -193,4 +200,16 @@ export class UsageComponent implements OnInit, OnDestroy {
193200
a.click();
194201
(a as any).parentNode.removeChild(a);
195202
}
203+
204+
private async loadTestData() {
205+
try {
206+
const response = await this.http.get('assets/github-usage-report.csv', { responseType: 'text' }).toPromise();
207+
if (response) {
208+
console.log('Auto-loading test data in development mode...');
209+
await this.onFileText(response, 'metered');
210+
}
211+
} catch (error) {
212+
console.warn('Could not auto-load test data:', error);
213+
}
214+
}
196215
}

src/app/usage-report.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export class UsageReportService {
7979
"actions_windows_8_core": 'Windows 8',
8080
"actions_windows_8_core_arm": 'Windows 8 (ARM)',
8181
"actions_storage": 'Actions Storage',
82+
"actions_custom_image_storage": 'Custom Image Storage',
8283
"actions_unknown": 'Actions Unknown',
8384
"copilot_enterprise": 'Copilot Enterprise',
8485
"copilot_for_business": 'Copilot Business',

0 commit comments

Comments
 (0)