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