Skip to content

Commit b6a3895

Browse files
committed
Refactor usage component and usage report service
1 parent 745405c commit b6a3895

File tree

4 files changed

+31
-13
lines changed

4 files changed

+31
-13
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export class UsageComponent implements OnInit, OnDestroy {
4242
ngOnInit() {
4343
this.subscriptions.push(
4444
this.range.valueChanges.pipe(debounceTime(500)).subscribe(value => {
45-
console.log('value', value);
4645
if (value.start && value.start instanceof Date && !isNaN(value.start.getTime()) &&
4746
value.end && value.end instanceof Date && !isNaN(value.end.getTime())) {
4847
this.usageReportService.applyFilter({

src/app/usage-report.service.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { TitleCasePipe } from '@angular/common';
12
import { Injectable } from '@angular/core';
23
import { UsageReport, UsageReportLine } from 'github-usage-report/types';
34
import { BehaviorSubject, Observable, map } from 'rxjs';
@@ -238,8 +239,23 @@ export class UsageReportService {
238239
}
239240

240241
formatSku(sku: string) {
241-
if (sku === 'ubuntu') return 'ubuntu 2';
242+
let formatted;
242243
const skuParts = sku.split('Compute - ');
243-
return skuParts.length > 1 ? skuParts[1].toLowerCase().replaceAll('_', ' ').replace(' core', '') : sku;
244+
if (skuParts.length < 2) return sku;
245+
formatted = skuParts[1].replaceAll('_', ' ').replace(' CORE', '');
246+
formatted = titlecasePipe.transform(formatted);
247+
formatted = formatted.replace('Macos', 'MacOS');
248+
switch(formatted) {
249+
case 'Ubuntu':
250+
return 'Ubuntu 2';
251+
case 'Windows':
252+
return 'Windows 2';
253+
case 'MacOS':
254+
return 'MacOS 3';
255+
default:
256+
return formatted;
257+
}
244258
}
245259
}
260+
261+
const titlecasePipe = new TitleCasePipe();

src/material.theme.scss

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,13 @@ $light-theme: mat.define-light-theme((
116116
:root {
117117
color-scheme: light;
118118
}
119+
}
119120

120-
@debug mat.get-theme-color($dark-theme, primary, default);
121+
.mat-column-user,
122+
.mat-column-workflow,
123+
.mat-column-repo,
124+
.mat-column-sku {
125+
background: #e0e0e0 !important;
121126
}
122127

123128
@media (prefers-color-scheme: dark) {
@@ -146,5 +151,12 @@ $light-theme: mat.define-light-theme((
146151
.mat-button-toggle-appearance-standard {
147152
background: #0d1117 !important;
148153
}
154+
155+
.mat-column-user,
156+
.mat-column-workflow,
157+
.mat-column-repo,
158+
.mat-column-sku {
159+
background: #161b22 !important;
160+
}
149161
}
150162

src/styles.scss

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,3 @@ mat-cell {
8181
vertical-align: bottom !important;
8282
}
8383
}
84-
85-
86-
.mat-column-user,
87-
.mat-column-workflow,
88-
.mat-column-repo,
89-
.mat-column-sku {
90-
background: #161b22 !important;
91-
max-width: 350px;
92-
}

0 commit comments

Comments
 (0)