Skip to content

Commit 745405c

Browse files
committed
Update styles and components
1 parent 5cb8e68 commit 745405c

File tree

10 files changed

+58
-29
lines changed

10 files changed

+58
-29
lines changed

src/app/components/usage/actions/charts/chart-line-usage-daily/chart-line-usage-daily.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<mat-button-toggle value="total">All</mat-button-toggle>
44
<mat-button-toggle value="repo">Repo</mat-button-toggle>
55
<mat-button-toggle value="sku">Runner</mat-button-toggle>
6-
<mat-button-toggle value="user">User</mat-button-toggle>
76
<mat-button-toggle value="workflow">Workflow</mat-button-toggle>
7+
<mat-button-toggle value="user">User</mat-button-toggle>
88
</mat-button-toggle-group>
99
<mat-button-toggle-group name="timeType" aria-label="Toggle Time" [value]="timeType" (change)="timeType = $event.value; redrawChart()">
1010
<mat-button-toggle value="total">Total</mat-button-toggle>

src/app/components/usage/actions/charts/chart-line-usage-daily/chart-line-usage-daily.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ export class ChartLineUsageDailyComponent implements OnChanges {
5050
},
5151
};
5252
updateFromInput: boolean = false;
53-
chartType: 'repo' | 'total' | 'sku' | 'user' | 'workflow' = 'total';
54-
timeType: 'total' | 'daily' | 'weekly' | 'monthly' | 'rolling20' | 'rolling7' = 'total';
53+
chartType: 'repo' | 'total' | 'sku' | 'user' | 'workflow' = 'sku';
54+
timeType: 'total' | 'daily' | 'weekly' | 'monthly' | 'rolling20' | 'rolling7' = 'rolling20';
5555
rollingDays = 20;
5656

5757
constructor(

src/app/components/usage/actions/table-workflow-usage/table-workflow-usage.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
<td mat-footer-cell *matFooterCellDef> <b>{{ column.footer ? column.footer() : '' }}</b> </td>
3434
</ng-container>
3535
}
36-
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
36+
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>
3737
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
38-
<tr mat-footer-row *matFooterRowDef="displayedColumns"></tr>
38+
<tr mat-footer-row *matFooterRowDef="displayedColumns; sticky: true"></tr>
3939

4040
<tr class="mat-row" *matNoDataRow>
4141
<td class="mat-cell" colspan="4">No data matching the filter "{{input.value}}"</td>

src/app/components/usage/actions/table-workflow-usage/table-workflow-usage.component.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ interface UsageColumn {
5454
})
5555
export class TableWorkflowUsageComponent implements OnChanges, AfterViewInit {
5656
columns = [] as UsageColumn[];
57+
monthColumns = [] as UsageColumn[];
5758
displayedColumns = this.columns.map(c => c.columnDef);
5859
@Input() data!: CustomUsageReportLine[];
5960
@Input() currency!: string;
@@ -91,7 +92,6 @@ export class TableWorkflowUsageComponent implements OnChanges, AfterViewInit {
9192
} else {
9293
(item as any)[month] = line.value || 0;
9394
}
94-
item.total += line.value;
9595
if (!this.columns.find(c => c.columnDef === month)) {
9696
const column: UsageColumn = {
9797
columnDef: month,
@@ -103,11 +103,11 @@ export class TableWorkflowUsageComponent implements OnChanges, AfterViewInit {
103103
},
104104
date: new Date(line.date),
105105
};
106-
const lastMonth: string = new Date(line.date.getFullYear(), line.date.getMonth() - 1).toLocaleString('default', { month: 'long' });
106+
const lastMonth: string = new Date(line.date.getFullYear(), line.date.getMonth() - 1).toLocaleString('default', { month: 'short' });
107107
const lastMonthValue = (item as any)[lastMonth];
108108
if (lastMonthValue) {
109109
column.tooltip = (workflowItem: WorkflowUsageItem) => {
110-
return (workflowItem as any)[month + 'PercentChange'].toFixed(2) + '%';
110+
return (workflowItem as any)[month + 'PercentChange']?.toFixed(2) + '%';
111111
};
112112
column.icon = (workflowItem: WorkflowUsageItem) => {
113113
const percentageChanged = (workflowItem as any)[month + 'PercentChange'];
@@ -121,6 +121,7 @@ export class TableWorkflowUsageComponent implements OnChanges, AfterViewInit {
121121
};
122122
}
123123
this.columns.push(column);
124+
this.monthColumns.push(column);
124125
}
125126
item.cost += line.quantity * line.pricePerUnit;
126127
item.total += line.quantity;
@@ -144,11 +145,12 @@ export class TableWorkflowUsageComponent implements OnChanges, AfterViewInit {
144145
}, [] as WorkflowUsageItem[]);
145146

146147
usageItems.forEach((item) => {
147-
this.usageReportService.monthsOrder.forEach((month: string) => {
148+
this.monthColumns.forEach((column: UsageColumn) => {
149+
const month = column.columnDef;
148150
if (!(item as any)[month]) {
149151
(item as any)[month] = 0;
150152
}
151-
const lastMonth: string = new Date(new Date().getFullYear(), this.usageReportService.monthsOrder.indexOf(month) - 1).toLocaleString('default', { month: 'long' });
153+
const lastMonth: string = new Date(new Date().getFullYear(), this.usageReportService.monthsOrder.indexOf(month) - 1).toLocaleString('default', { month: 'short' });
152154
const lastMonthValue = (item as any)[lastMonth];
153155
const percentageChanged = this.calculatePercentageChange(lastMonthValue, (item as any)[month]);
154156
(item as any)[month + 'PercentChange'] = percentageChanged;
@@ -158,7 +160,6 @@ export class TableWorkflowUsageComponent implements OnChanges, AfterViewInit {
158160
item.avgCost = item.cost / item.runs;
159161
});
160162
usage = usageItems;
161-
// sort the columns by date
162163
this.columns = this.columns.sort((a, b) => (a.date?.getTime() || 0) - (b.date?.getTime() || 0));
163164
this.displayedColumns = this.columns.map(c => c.columnDef);
164165
this.dataSource.data = usage;
@@ -276,6 +277,7 @@ export class TableWorkflowUsageComponent implements OnChanges, AfterViewInit {
276277
}
277278
columns[0].footer = () => 'Total';
278279
this.columns = columns;
280+
this.monthColumns = [];
279281
this.displayedColumns = this.columns.map(c => c.columnDef);
280282
}
281283

src/app/components/usage/shared-storage/table-shared-storage/table-shared-storage.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class TableSharedStorageComponent implements OnChanges, AfterViewInit {
4242
const workflowUsage = this.data.reduce((acc, line) => {
4343
const workflowEntry = acc.find(a => a.repo === line.repositorySlug);
4444
const date = line.date;
45-
const month: string = date.toLocaleString('default', { month: 'long' });
45+
const month: string = date.toLocaleString('default', { month: 'short' });
4646
const cost = line.pricePerUnit * line.quantity;
4747
if (workflowEntry) {
4848
const daysInMonth = new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();

src/app/components/usage/usage.component.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
<div *ngIf="!usage" class="flex-center-horizontally full-width">
1+
<div *ngIf="!usage" class="full-width">
22
<h1 class="mat-headline-2" style="user-select: none; font-weight: 800; text-align: center;">
3-
GitHub Metered Usage Report Viewer
3+
GitHub<br>Usage Report Viewer
44
</h1>
5+
<!-- <h2 class="mat-h2" style="user-select: none; font-weight: 800; text-align: center;">
6+
<i>Visualize your GitHub Metered Usage!</i>
7+
</h2> -->
58
</div>
69
<div class="flex-center-horizontally full-width">
710
<app-file-upload [text]="status" (fileText)="onFileText($event)"></app-file-upload>
@@ -20,6 +23,10 @@ <h1 class="mat-headline-2" style="user-select: none; font-weight: 800; text-alig
2023
</mat-date-range-input>
2124
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
2225
<mat-date-range-picker #picker></mat-date-range-picker>
26+
<button *ngIf="range.controls.start.value !== minDate || range.controls.end.value !== maxDate" mat-icon-button
27+
matSuffix (click)="range.setValue({ start: minDate, end: maxDate })">
28+
<mat-icon>close</mat-icon>
29+
</button>
2330
</mat-form-field>
2431
<mat-form-field style="flex: 1; max-width: 500px;" *ngIf="tabSelected === 'actions'">
2532
<mat-label>Workflow</mat-label>

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ 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);
4546
if (value.start && value.start instanceof Date && !isNaN(value.start.getTime()) &&
4647
value.end && value.end instanceof Date && !isNaN(value.end.getTime())) {
4748
this.usageReportService.applyFilter({
@@ -102,8 +103,11 @@ export class UsageComponent implements OnInit, OnDestroy {
102103
});
103104
this.minDate = new Date(usage.lines[0]?.date);
104105
this.maxDate = new Date(usage.lines[usage.lines.length - 1]?.date);
105-
this.range.controls.start.setValue(usage.lines[0]?.date, { emitEvent: false });
106-
this.range.controls.end.setValue(usage.lines[usage.lines.length - 1]?.date, { emitEvent: false });
106+
// make the date 00:00:00
107+
this.minDate.setHours(0, 0, 0, 0);
108+
this.maxDate.setHours(0, 0, 0, 0);
109+
this.range.controls.start.setValue(this.minDate, { emitEvent: false });
110+
this.range.controls.end.setValue(this.maxDate, { emitEvent: false });
107111
this.status = 'Choose File';
108112
this.progress = null;
109113
this.usage = usage;

src/app/usage-report.service.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,21 +191,15 @@ export class UsageReportService {
191191
}): void {
192192
Object.assign(this.filters, filter);
193193
let filtered = this.usageReport.lines;
194-
if (this.filters.sku !== '') {
194+
if (this.filters.sku) {
195195
filtered = filtered.filter(line => line.sku === this.filters.sku);
196196
}
197-
if (this.filters.workflow !== '') {
197+
if (this.filters.workflow) {
198198
filtered = filtered.filter(line => line.actionsWorkflow === this.filters.workflow);
199199
}
200200
if (this.filters.startDate && this.filters.endDate) {
201201
filtered = filtered.filter(line => {
202-
const lineDate = new Date(line.date);
203-
if (this.filters.startDate.getTime() === this.filters.endDate.getTime()) {
204-
const day = this.filters.startDate.toISOString().split('T')[0];
205-
const lineDay = lineDate.toISOString().split('T')[0];
206-
return day === lineDay;
207-
}
208-
return lineDate >= this.filters.startDate && lineDate <= this.filters.endDate;
202+
return line.date >= this.filters.startDate && line.date <= this.filters.endDate;
209203
});
210204
}
211205
this.usageReportFiltered.next(filtered);

src/material.theme.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ $dark-theme: mat.define-dark-theme((
9191

9292
// #0d1117
9393

94-
$backgroundColor: #0d1117; // GitHub background color
94+
$backgroundColor: #010409; // GitHub background color
9595
$foreground: #e6edf3; // GitHub foreground color
9696
$color: map.get($dark-theme, "color");
9797
$colorBackground: map.get($color, "background");
@@ -137,14 +137,14 @@ $light-theme: mat.define-light-theme((
137137
}
138138
.mat-mdc-paginator,
139139
.mat-mdc-table tbody, .mat-mdc-table tfoot, .mat-mdc-table thead, .mat-mdc-cell, .mat-mdc-footer-cell, .mat-mdc-header-row, .mat-mdc-row, .mat-mdc-footer-row, .mat-mdc-table .mat-mdc-header-cell {
140-
background: #161b22 !important;
140+
background: #0d1117 !important;
141141
}
142142

143143
.mat-button-toggle-appearance-standard.mat-button-toggle-checked {
144144
background: mat.get-theme-color($dark-theme, primary, 500) !important;
145145
}
146146
.mat-button-toggle-appearance-standard {
147-
background: #161b22 !important;
147+
background: #0d1117 !important;
148148
}
149149
}
150150

src/styles.scss

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,28 @@ table {
6565
}
6666

6767
.table-container {
68-
margin-top: 1rem;
6968
overflow-x: auto;
69+
max-height: 700px;
70+
}
71+
72+
.table-control {
73+
display: flex;
74+
mat-form-field {
75+
margin-right: 15px;
76+
}
77+
}
78+
79+
mat-cell {
80+
mat-icon {
81+
vertical-align: bottom !important;
82+
}
83+
}
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;
7092
}

0 commit comments

Comments
 (0)