10 changed files with 166 additions and 35 deletions
@ -0,0 +1,17 @@ |
|||
<div class="signInForm"> |
|||
<input type="file" accept=".gbx" class="file-input" (change)="onFileSelected($event)" #fileUpload> |
|||
<h1 mat-dialog-title>Replay Upload</h1> |
|||
<p>Replay files can be found in Documents/Trackmania/Replays/My Replays</p> |
|||
<div mat-dialog-content class="full-width"> |
|||
<mat-label>File</mat-label> |
|||
{{fileName || "No file uploaded yet."}} |
|||
<button mat-fab color="primary" class="upload-btn" |
|||
(click)="fileUpload.click()"> |
|||
<mat-icon>attach_file</mat-icon> |
|||
</button> |
|||
</div> |
|||
<mat-dialog-actions align="end"> |
|||
<button mat-button mat-dialog-close>Cancel</button> |
|||
<button mat-button mat-dialog-close (click)="onClickSubmit()">Submit</button> |
|||
</mat-dialog-actions> |
|||
</div> |
|||
@ -0,0 +1,16 @@ |
|||
.file-input { |
|||
display: none; |
|||
} |
|||
|
|||
.signInForm { |
|||
width: 400px; |
|||
padding: 12px 24px 24px; |
|||
|
|||
igx-input-group + igx-input-group { |
|||
margin-top: 24px; |
|||
} |
|||
} |
|||
|
|||
.full-width { |
|||
width: 100%; |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
import { ComponentFixture, TestBed } from '@angular/core/testing'; |
|||
|
|||
import { ClaimRacerDialogComponent } from './claim-racer-dialog.component'; |
|||
|
|||
describe('ClaimRacerDialogComponent', () => { |
|||
let component: ClaimRacerDialogComponent; |
|||
let fixture: ComponentFixture<ClaimRacerDialogComponent>; |
|||
|
|||
beforeEach(async () => { |
|||
await TestBed.configureTestingModule({ |
|||
imports: [ClaimRacerDialogComponent] |
|||
}) |
|||
.compileComponents(); |
|||
|
|||
fixture = TestBed.createComponent(ClaimRacerDialogComponent); |
|||
component = fixture.componentInstance; |
|||
fixture.detectChanges(); |
|||
}); |
|||
|
|||
it('should create', () => { |
|||
expect(component).toBeTruthy(); |
|||
}); |
|||
}); |
|||
@ -0,0 +1,73 @@ |
|||
import { Component, Inject } from '@angular/core'; |
|||
import { CommonModule } from '@angular/common'; |
|||
import { ReactiveFormsModule, FormControl } from '@angular/forms'; |
|||
import { FormsModule } from '@angular/forms'; |
|||
|
|||
import { MatDialog, MAT_DIALOG_DATA, MatDialogRef, MatDialogTitle, |
|||
MatDialogContent, MatDialogActions, MatDialogClose,} from '@angular/material/dialog'; |
|||
|
|||
import { MatButtonModule } from '@angular/material/button'; |
|||
import { MatDialogModule } from '@angular/material/dialog'; |
|||
import { MatInputModule } from '@angular/material/input'; |
|||
import { MatFormFieldModule } from '@angular/material/form-field'; |
|||
import { MatIconModule } from '@angular/material/icon'; |
|||
import { MatSnackBar } from '@angular/material/snack-bar'; |
|||
|
|||
import { ReplaysService } from '../../services/replays.service'; |
|||
import { catchError, throwError } from 'rxjs'; |
|||
import { HttpErrorResponse } from '@angular/common/http'; |
|||
|
|||
@Component({ |
|||
selector: 'app-claim-racer-dialog', |
|||
standalone: true, |
|||
imports: [ |
|||
CommonModule, |
|||
ReactiveFormsModule, |
|||
MatButtonModule, |
|||
MatDialogModule, |
|||
MatInputModule, |
|||
MatFormFieldModule, |
|||
FormsModule, |
|||
MatDialogTitle, |
|||
MatDialogContent, |
|||
MatDialogActions, |
|||
MatDialogClose, |
|||
MatIconModule, |
|||
], |
|||
templateUrl: './claim-racer-dialog.component.html', |
|||
styleUrl: './claim-racer-dialog.component.scss' |
|||
}) |
|||
export class ClaimRacerDialogComponent { |
|||
fileName: string = ""; |
|||
file?: File; |
|||
errors: string[]; |
|||
|
|||
constructor( |
|||
private replaysService: ReplaysService, |
|||
private _snackBar: MatSnackBar |
|||
) { |
|||
this.errors = []; |
|||
} |
|||
|
|||
onFileSelected(event: any) { |
|||
const file: File = event.target.files[0]; |
|||
if (file) |
|||
{ |
|||
this.fileName = file.name; |
|||
this.file = file; |
|||
} |
|||
} |
|||
|
|||
onClickSubmit() { |
|||
if(this.file == undefined) { |
|||
return; |
|||
} |
|||
|
|||
let formData = new FormData(); |
|||
formData.append("file", this.file); |
|||
let filetime = this.file.lastModified; |
|||
formData.append("fileTime", filetime.toString()); |
|||
const upload$ = this.replaysService.claimRacer(formData); |
|||
upload$.subscribe(); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue