-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
107 additions
and
6 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
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
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
Empty file.
20 changes: 20 additions & 0 deletions
20
frontend/xpirit-beerxchange/src/app/components/list-credit/list-credit.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,20 @@ | ||
<div class="card"> | ||
<div class="card-body"> | ||
<h2>User Credit Overview</h2> | ||
<p *ngIf="!(userCredits.length > 0)"><em>Loading credits...</em></p> | ||
<div class="mat-elevation-z8"> | ||
<table mat-table [dataSource]="userCredits" class="w-100" *ngIf="userCredits.length > 0"> | ||
<ng-container matColumnDef="name"> | ||
<th mat-header-cell *matHeaderCellDef> Name </th> | ||
<td mat-cell *matCellDef="let element"> {{element.name}} </td> | ||
</ng-container> | ||
<ng-container matColumnDef="credits"> | ||
<th mat-header-cell *matHeaderCellDef> Credits </th> | ||
<td mat-cell *matCellDef="let element"> {{element.credits}} </td> | ||
</ng-container> | ||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> | ||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> | ||
</table> | ||
</div> | ||
</div> | ||
</div> |
25 changes: 25 additions & 0 deletions
25
frontend/xpirit-beerxchange/src/app/components/list-credit/list-credit.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,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ListCreditComponent } from './list-credit.component'; | ||
|
||
describe('ListCreditComponent', () => { | ||
let component: ListCreditComponent; | ||
let fixture: ComponentFixture<ListCreditComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ ListCreditComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(ListCreditComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
35 changes: 35 additions & 0 deletions
35
frontend/xpirit-beerxchange/src/app/components/list-credit/list-credit.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,35 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { Subscription, timer } from 'rxjs'; | ||
import { FridgeService } from 'src/app/services/fridge.service'; | ||
import { UserCredits } from '../../model/userCredits'; | ||
|
||
@Component({ | ||
selector: 'list-credit', | ||
templateUrl: './list-credit.component.html', | ||
styleUrls: ['./list-credit.component.css'] | ||
}) | ||
export class ListCreditComponent implements OnInit { | ||
displayedColumns: string[] = ['name', 'credits']; | ||
private readonly _subscription: Subscription = new Subscription(); | ||
|
||
constructor(private fridgeService: FridgeService) { } | ||
|
||
userCredits: Array<UserCredits> = []; | ||
|
||
ngOnInit() { | ||
this._subscription.add(timer(0, 30000).subscribe(() => { | ||
this.setUserCreditList(); | ||
})); | ||
} | ||
|
||
setUserCreditList() { | ||
this._subscription.add(this.fridgeService.getUserCredits().subscribe((userCredits: Array<UserCredits>) => { | ||
this.userCredits = userCredits; | ||
})); | ||
} | ||
|
||
ngOnDestroy() { | ||
this._subscription.unsubscribe(); | ||
} | ||
|
||
} |
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,4 @@ | ||
export interface UserCredits { | ||
name: string; | ||
credits: number; | ||
} |
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