-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update UI layout and add new components
- Loading branch information
1 parent
48926eb
commit af10f85
Showing
20 changed files
with
254 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
<h1>GitHub Usage Report</h1> | ||
<p>This is an entirely client side application. Your usage report never leaves your computer.</p> | ||
<app-usage></app-usage> | ||
<div class="container"> | ||
<div class="header"> | ||
<div class="logo"> | ||
<img src="assets/github-mark.svg"> | ||
</div> | ||
<h1 class=" mat-headline-1"> | ||
Github Usage Report | ||
</h1> | ||
</div> | ||
<div class="flex-center"> | ||
<h2>Visualize your Github usage</h2> | ||
<p>This is an entirely client side application. Your usage report never leaves your computer.</p> | ||
<app-usage></app-usage> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions
10
...e-owner/chart-pie-owner.component.spec.ts → ...pie-user/chart-pie-user.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
<input type="file" #fileInput name="fileUpload" (change)="onFileSelected($event)" style="display: none;"> | ||
<button mat-button color="primary" (click)="fileInput.click()">Browse</button> | ||
<input type="file" #fileInput name="fileUpload" (change)="onFileSelected($event)" style="display: none;"> | ||
<button mat-fab extended (click)="fileInput.click()"> | ||
<mat-icon>upload_file</mat-icon> | ||
Choose File | ||
</button> |
21 changes: 21 additions & 0 deletions
21
src/app/table-workflow-usage/table-workflow-usage.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<h1>Workflow Usage</h1> | ||
|
||
<div class="mat-elevation-z8"> | ||
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8 demo-table" matSort> | ||
@for (column of columns; track column) { | ||
<ng-container [matColumnDef]="column.columnDef"> | ||
<th mat-header-cell *matHeaderCellDef mat-sort-header> | ||
{{column.header}} | ||
</th> | ||
<td mat-cell *matCellDef="let row"> | ||
{{column.cell(row)}} | ||
</td> | ||
</ng-container> | ||
} | ||
|
||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> | ||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> | ||
</table> | ||
|
||
<mat-paginator [pageSizeOptions]="[10, 25, 100]" aria-label="Select page of users"></mat-paginator> | ||
</div> |
Empty file.
23 changes: 23 additions & 0 deletions
23
src/app/table-workflow-usage/table-workflow-usage.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { TableWorkflowUsageComponent } from './table-workflow-usage.component'; | ||
|
||
describe('TableWorkflowUsageComponent', () => { | ||
let component: TableWorkflowUsageComponent; | ||
let fixture: ComponentFixture<TableWorkflowUsageComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [TableWorkflowUsageComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(TableWorkflowUsageComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
77 changes: 77 additions & 0 deletions
77
src/app/table-workflow-usage/table-workflow-usage.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { Component, Input, ViewChild } from '@angular/core'; | ||
import { UsageReport, UsageReportLine } from 'github-usage-report/types'; | ||
import { MatPaginator, MatPaginatorModule } from '@angular/material/paginator'; | ||
import { MatTableDataSource, MatTableModule } from '@angular/material/table'; | ||
import { MatSort } from '@angular/material/sort'; | ||
|
||
@Component({ | ||
selector: 'app-table-workflow-usage', | ||
templateUrl: './table-workflow-usage.component.html', | ||
styleUrl: './table-workflow-usage.component.scss' | ||
}) | ||
export class TableWorkflowUsageComponent { | ||
columns = [ | ||
{ | ||
columnDef: 'workflow', | ||
header: 'Workflow', | ||
cell: (workflowItem: any) => `${workflowItem.workflow}`, | ||
}, | ||
{ | ||
columnDef: 'total', | ||
header: 'Total', | ||
cell: (workflowItem: any) => `${workflowItem.total}`, | ||
} | ||
]; | ||
displayedColumns = this.columns.map(c => c.columnDef); | ||
@Input() data!: UsageReport; | ||
dataSource: MatTableDataSource<UsageReportLine> = new MatTableDataSource<any>(); // Initialize the dataSource property | ||
|
||
@ViewChild(MatPaginator) paginator!: MatPaginator; | ||
@ViewChild(MatSort) sort!: MatSort; | ||
|
||
ngOnInit() { | ||
const workflowUsage = this.data.lines.filter(a => a.actionsWorkflow).reduce((acc, line) => { | ||
const workflowEntry = acc.find(a => a.workflow === line.actionsWorkflow); | ||
const date = new Date(line.date); | ||
const month: string = date.toLocaleString('default', { month: 'long' }); | ||
if (workflowEntry) { | ||
if (workflowEntry[month]) { | ||
workflowEntry[month] += line.quantity || 0; | ||
} else { | ||
workflowEntry[month] = line.quantity || 0; | ||
} | ||
workflowEntry.total += line.quantity || 0; | ||
if (!this.columns.find(c => c.columnDef === month)) { | ||
this.columns.push({ | ||
columnDef: month, | ||
header: month, | ||
cell: (cost: any) => `${cost[month]}`, | ||
}); | ||
this.displayedColumns = this.columns.map(c => c.columnDef); | ||
} | ||
} else { | ||
acc.push({ | ||
workflow: line.actionsWorkflow, | ||
repo: line.repositorySlug, | ||
total: line.quantity || 0, | ||
[month]: line.quantity || 0 | ||
}); | ||
} | ||
return acc; // Add this line to return the accumulator | ||
}, [] as any[]); | ||
// fill in undefined months in workflowUsage | ||
workflowUsage.forEach((workflowItem: any) => { | ||
this.columns.forEach((column: any) => { | ||
if (!workflowItem[column.columnDef]) { | ||
workflowItem[column.columnDef] = 0; | ||
} | ||
}); | ||
}); | ||
this.dataSource = new MatTableDataSource(workflowUsage); | ||
} | ||
|
||
ngAfterViewInit() { | ||
this.dataSource.paginator = this.paginator; | ||
this.dataSource.sort = this.sort; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
<app-file-upload (fileText)="onFileText($event)"></app-file-upload> | ||
|
||
<ng-container *ngIf="usage"> | ||
<app-chart-pie-owner [data]="usage.lines"></app-chart-pie-owner> | ||
<app-chart-pie-user [data]="usage.lines"></app-chart-pie-user> | ||
<app-chart-line-usage-time [data]="usage"></app-chart-line-usage-time> | ||
<!-- <app-usage-table [data]="usage.lines"></app-usage-table> --> | ||
<app-table-workflow-usage [data]="usage"></app-table-workflow-usage> | ||
</ng-container> | ||
|
||
<app-file-upload (fileText)="onFileText($event)"></app-file-upload> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
@use '@angular/material' as mat; | ||
|
||
@include mat.core(); | ||
|
||
// Define a dark theme | ||
$dark-theme: mat.define-dark-theme(( | ||
color: ( | ||
primary: mat.define-palette(mat.$pink-palette), | ||
accent: mat.define-palette(mat.$blue-grey-palette), | ||
), | ||
// Only include `typography` and `density` in the default dark theme. | ||
typography: mat.define-typography-config(), | ||
density: 0, | ||
)); | ||
|
||
// Define a light theme | ||
$light-theme: mat.define-light-theme(( | ||
color: ( | ||
primary: mat.define-palette(mat.$indigo-palette), | ||
accent: mat.define-palette(mat.$pink-palette), | ||
), | ||
)); | ||
|
||
// Apply the dark theme by default | ||
// @include mat.core-theme($dark-theme); | ||
// @include mat.button-theme($dark-theme); | ||
|
||
// Apply the light theme only when the user prefers light themes. | ||
@media (prefers-color-scheme: light) { | ||
// Use the `-color` mixins to only apply color styles without reapplying the same | ||
// typography and density styles. | ||
@include mat.core-color($light-theme); | ||
@include mat.button-color($light-theme); | ||
} |
Oops, something went wrong.