feat: add support for the new api
All checks were successful
Build and Deploy Angular App / build (push) Successful in 43s
All checks were successful
Build and Deploy Angular App / build (push) Successful in 43s
This commit is contained in:
@ -74,14 +74,14 @@ export class ScheduleService extends ApiService {
|
||||
return this.addAuth(request).post<any>(request);
|
||||
}
|
||||
|
||||
public uploadScheduleFile(files: File[], force: boolean) {
|
||||
public uploadScheduleFile(files: File[], campus: string[], force: boolean) {
|
||||
const formData = new FormData();
|
||||
files.forEach(file => formData.append('files', file, file.name));
|
||||
|
||||
const request = this.createRequestBuilder()
|
||||
.setEndpoint('Upload')
|
||||
.setData(formData)
|
||||
.setQueryParams({force: force})
|
||||
.setQueryParams({force: force, defaultCampus: campus})
|
||||
.build;
|
||||
|
||||
return this.addAuth(request).post(request);
|
||||
|
@ -18,11 +18,19 @@
|
||||
@if (selectedFiles.length > 0) {
|
||||
<div style="margin-top: 15px;">
|
||||
<p>Выбранные файлы:</p>
|
||||
<ul>
|
||||
@for (file of selectedFiles; track $index) {
|
||||
<li>{{ file.name }}</li>
|
||||
@for (item of selectedFiles; track $index) {
|
||||
<div>
|
||||
<p>
|
||||
{{ item.file.name }}
|
||||
</p>
|
||||
<mat-form-field color="accent">
|
||||
<mat-label>
|
||||
Кампус по умолчанию
|
||||
</mat-label>
|
||||
<input matInput type="text" [(ngModel)]="item.campus"/>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
}
|
||||
</app-configuration-card>
|
||||
|
@ -9,6 +9,9 @@ import {MatButtonModule} from "@angular/material/button";
|
||||
import {MatIcon} from "@angular/material/icon";
|
||||
import {ScheduleService} from "@api/v1/configuration/schedule.service";
|
||||
import {DataSpinnerComponent} from "@component/common/data-spinner/data-spinner.component";
|
||||
import {MatFormFieldModule} from "@angular/material/form-field";
|
||||
import {FormsModule} from "@angular/forms";
|
||||
import {MatInput} from "@angular/material/input";
|
||||
|
||||
@Component({
|
||||
selector: 'app-schedule-file-upload',
|
||||
@ -16,13 +19,16 @@ import {DataSpinnerComponent} from "@component/common/data-spinner/data-spinner.
|
||||
ConfigurationCardComponent,
|
||||
MatButtonModule,
|
||||
MatIcon,
|
||||
DataSpinnerComponent
|
||||
DataSpinnerComponent,
|
||||
MatFormFieldModule,
|
||||
FormsModule,
|
||||
MatInput
|
||||
],
|
||||
templateUrl: './schedule-file-upload.component.html',
|
||||
providers: [ScheduleService]
|
||||
})
|
||||
export class ScheduleFileUploadComponent {
|
||||
selectedFiles: File[] = [];
|
||||
selectedFiles: { file: File, campus: string }[] = [];
|
||||
fileLoading: boolean = false;
|
||||
@ViewChild('fileInput') input!: ElementRef;
|
||||
|
||||
@ -34,7 +40,10 @@ export class ScheduleFileUploadComponent {
|
||||
const dialogRef = this.dialog.open(ConfirmDeleteScheduleDialogComponent);
|
||||
|
||||
return dialogRef.afterClosed().pipe(switchMap(result => {
|
||||
return this.api.uploadScheduleFile(this.selectedFiles, result);
|
||||
return this.api.uploadScheduleFile(
|
||||
this.selectedFiles.map(x => x.file),
|
||||
this.selectedFiles.map(x => x.campus),
|
||||
result);
|
||||
}));
|
||||
};
|
||||
}
|
||||
@ -46,7 +55,9 @@ export class ScheduleFileUploadComponent {
|
||||
|
||||
onFileSelected(event: any): void {
|
||||
this.fileLoading = false;
|
||||
this.selectedFiles = Array.from(event.target.files);
|
||||
console.log(Array.from(event.target.files));
|
||||
this.selectedFiles = Array.from(event.target.files)
|
||||
.map(x => <{file: File, campus: string}>{file: x, campus: ''});
|
||||
}
|
||||
|
||||
onUpload(data: Observable<any>): void {
|
||||
|
Reference in New Issue
Block a user