Compare commits
3 Commits
004671c006
...
ea5e731bd2
Author | SHA1 | Date | |
---|---|---|---|
ea5e731bd2 | |||
74a7fe7eb6 | |||
2f9d552e43 |
@ -12,6 +12,7 @@ import {DataSpinnerComponent} from "@component/common/data-spinner/data-spinner.
|
|||||||
import {MatFormFieldModule} from "@angular/material/form-field";
|
import {MatFormFieldModule} from "@angular/material/form-field";
|
||||||
import {FormsModule} from "@angular/forms";
|
import {FormsModule} from "@angular/forms";
|
||||||
import {MatInput} from "@angular/material/input";
|
import {MatInput} from "@angular/material/input";
|
||||||
|
import {ToastrService} from "ngx-toastr";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-schedule-file-upload',
|
selector: 'app-schedule-file-upload',
|
||||||
@ -32,7 +33,7 @@ export class ScheduleFileUploadComponent {
|
|||||||
fileLoading: boolean = false;
|
fileLoading: boolean = false;
|
||||||
@ViewChild('fileInput') input!: ElementRef;
|
@ViewChild('fileInput') input!: ElementRef;
|
||||||
|
|
||||||
constructor(private dialog: MatDialog, private api: ScheduleService) {
|
constructor(private dialog: MatDialog, private api: ScheduleService, private notify: ToastrService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected saveFunction() {
|
protected saveFunction() {
|
||||||
@ -55,13 +56,13 @@ export class ScheduleFileUploadComponent {
|
|||||||
|
|
||||||
onFileSelected(event: any): void {
|
onFileSelected(event: any): void {
|
||||||
this.fileLoading = false;
|
this.fileLoading = false;
|
||||||
console.log(Array.from(event.target.files));
|
|
||||||
this.selectedFiles = Array.from(event.target.files)
|
this.selectedFiles = Array.from(event.target.files)
|
||||||
.map(x => <{file: File, campus: string}>{file: x, campus: ''});
|
.map(x => <{file: File, campus: string}>{file: x, campus: ''});
|
||||||
}
|
}
|
||||||
|
|
||||||
onUpload(data: Observable<any>): void {
|
onUpload(data: Observable<any>): void {
|
||||||
data.subscribe(_ => {
|
data.subscribe(_ => {
|
||||||
|
this.notify.info(`Файлы в размере ${this.selectedFiles.length} успешно загружены. Задача поставлена в очередь`);
|
||||||
this.selectedFiles = [];
|
this.selectedFiles = [];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -69,9 +69,9 @@ export class SkipUpdateScheduleComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
validateSaveButton(): boolean {
|
validateSaveButton(): boolean {
|
||||||
return this.dateItems.some(item =>
|
return (this.dateItems.length == 0 || this.dateItems.some(item =>
|
||||||
(item.start && item.end) || item.date
|
(item.start && item.end) || item.date
|
||||||
) && JSON.stringify(this.dateItems) != JSON.stringify(this.dateItemsBefore);
|
)) && JSON.stringify(this.dateItems) != JSON.stringify(this.dateItemsBefore);
|
||||||
}
|
}
|
||||||
|
|
||||||
saveFunction() {
|
saveFunction() {
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
.notification-content {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.close-button {
|
|
||||||
margin-left: 8px;
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
<div class="notification-content" [class]="data.className">
|
|
||||||
<span>
|
|
||||||
{{ data.message }}
|
|
||||||
</span>
|
|
||||||
<button mat-icon-button class="close-button" (click)="dismiss()">
|
|
||||||
<mat-icon>close</mat-icon>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
@if (showProgressBar) {
|
|
||||||
<mat-progress-bar mode="determinate" [value]="progress" [color]="color"/>
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
import {Component, Inject} from '@angular/core';
|
|
||||||
import {MatIcon} from "@angular/material/icon";
|
|
||||||
import {MatProgressBar} from "@angular/material/progress-bar";
|
|
||||||
import {MAT_SNACK_BAR_DATA, MatSnackBarRef} from "@angular/material/snack-bar";
|
|
||||||
import {MatIconButton} from "@angular/material/button";
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-notification',
|
|
||||||
standalone: true,
|
|
||||||
imports: [
|
|
||||||
MatIconButton,
|
|
||||||
MatIcon,
|
|
||||||
MatProgressBar
|
|
||||||
],
|
|
||||||
templateUrl: './notification.component.html',
|
|
||||||
styleUrl: './notification.component.css'
|
|
||||||
})
|
|
||||||
|
|
||||||
export class NotificationComponent {
|
|
||||||
showProgressBar: boolean = false;
|
|
||||||
progress: number = 100;
|
|
||||||
color: string = "primary";
|
|
||||||
|
|
||||||
constructor(@Inject(MAT_SNACK_BAR_DATA) public data: any, private snackBarRef: MatSnackBarRef<NotificationComponent>) {
|
|
||||||
if (data.duration) {
|
|
||||||
this.startProgress(data.duration);
|
|
||||||
this.showProgressBar = true;
|
|
||||||
}
|
|
||||||
if (data.color) {
|
|
||||||
this.color = data.color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dismiss(): void {
|
|
||||||
this.snackBarRef.dismiss();
|
|
||||||
}
|
|
||||||
|
|
||||||
private startProgress(duration: number): void {
|
|
||||||
const interval: number = duration / 100;
|
|
||||||
const progressInterval = setInterval(async () => {
|
|
||||||
this.progress--;
|
|
||||||
if (this.progress === 0) {
|
|
||||||
clearInterval(progressInterval);
|
|
||||||
setTimeout(() => {
|
|
||||||
this.dismiss();
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
}, interval);
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user