removed file upload dialog
removes file upload dialog from frontend, upload from backend along with parsing dependencies
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
<mat-radio-group [(ngModel)]="type">
|
||||
<mat-radio-button value="day">Dzień</mat-radio-button>
|
||||
<mat-radio-button value="week">Tydzień</mat-radio-button>
|
||||
<mat-radio-button value="file">Plik</mat-radio-button>
|
||||
</mat-radio-group>
|
||||
<div>
|
||||
@switch (type) {
|
||||
@@ -21,9 +20,6 @@
|
||||
<mat-date-range-picker #picker></mat-date-range-picker>
|
||||
</mat-form-field>
|
||||
}
|
||||
@case ("file") {
|
||||
<button mat-flat-button (click)="activateUpload()">Otwórz okno</button>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</mat-dialog-content>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
mat-dialog-content {
|
||||
padding-bottom: 5px !important;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Component, inject, signal } from '@angular/core'
|
||||
import { MenuUploadComponent } from '../menu-upload/menu-upload.component'
|
||||
import { MatDialog, MatDialogRef } from '@angular/material/dialog'
|
||||
import { MatDialogRef } from '@angular/material/dialog'
|
||||
import { FDSelection } from 'src/app/fd.da'
|
||||
import { FormControl, FormGroup } from '@angular/forms'
|
||||
import { MAT_DATE_RANGE_SELECTION_STRATEGY } from '@angular/material/datepicker'
|
||||
@@ -18,7 +17,6 @@ import { weekendFilter } from 'src/app/util'
|
||||
})
|
||||
export class MenuAddComponent {
|
||||
public dialogRef: MatDialogRef<MenuAddComponent> = inject(MatDialogRef)
|
||||
private dialog = inject(MatDialog)
|
||||
|
||||
type: string | undefined
|
||||
filter = weekendFilter
|
||||
@@ -45,15 +43,4 @@ export class MenuAddComponent {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
activateUpload() {
|
||||
this.dialog
|
||||
.open(MenuUploadComponent)
|
||||
.afterClosed()
|
||||
.subscribe(data => {
|
||||
if (data) {
|
||||
this.dialogRef.close({ type: 'file', ...data })
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import { FDSelection } from 'src/app/fd.da'
|
||||
import { Menu } from 'src/app/types/menu'
|
||||
import { MatTableDataSource } from '@angular/material/table'
|
||||
import { MatDialog } from '@angular/material/dialog'
|
||||
import { MenuUploadComponent } from './menu-upload/menu-upload.component'
|
||||
import { Status } from 'src/app/types/status'
|
||||
import { MatSnackBar } from '@angular/material/snack-bar'
|
||||
import { MenuAddComponent } from './menu-add/menu-add.component'
|
||||
@@ -121,15 +120,6 @@ export class MenuEditComponent implements OnDestroy {
|
||||
if (s.status.toString().match(/2\d\d/)) this.refresh()
|
||||
}
|
||||
|
||||
activateUpload() {
|
||||
this.dialog
|
||||
.open(MenuUploadComponent)
|
||||
.afterClosed()
|
||||
.subscribe(data => {
|
||||
if (data) this.refresh()
|
||||
})
|
||||
}
|
||||
|
||||
editSn(id: string) {
|
||||
this.ac
|
||||
.editSn(id, this.dataSource.data.find(v => v._id == id)!.sn)
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
<h1 mat-dialog-title>Import z pliku</h1>
|
||||
<mat-dialog-content>
|
||||
<input type="file" name="menu" #fu style="display: none;" (change)="onFileChange($event)" accept=".xlsx,.ods,application/vnd.oasis.opendocument.spreadsheet">
|
||||
<button matButton="outlined" (click)="fu.click()">Wybierz plik</button>
|
||||
<div style="color: red;">
|
||||
<h1>UWAGA!</h1>
|
||||
<h3>Przed wysłaniem upewnij się że</h3>
|
||||
<ul>
|
||||
<li>Daty w pliku są prawidłowe i poprawnie sformatowane (DD.MM.RRRR)</li>
|
||||
<li>Wszystkie pozycje w menu są w osobnych linijkach</li>
|
||||
<li>Załączony dokument to arkusz w formacie XLSX lub ODS</li>
|
||||
</ul>
|
||||
<h2>Nie spełnienie któregokolwiek z tych wymagań może skutkować szkodami w programie!</h2>
|
||||
<h3>Późniejsza modyfikacja danych jest niemożliwa w tej wersji programu.</h3>
|
||||
</div>
|
||||
</mat-dialog-content>
|
||||
<mat-dialog-actions>
|
||||
<button matButton="outlined" class="error-color" [disabled]="file === undefined" (click)="submit()">Wyślij</button>
|
||||
<button mat-button mat-dialog-close>Anuluj</button>
|
||||
</mat-dialog-actions>
|
||||
@@ -1,4 +0,0 @@
|
||||
:host {
|
||||
margin: 8pt;
|
||||
display: block;
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
||||
|
||||
import { MenuUploadComponent } from './menu-upload.component'
|
||||
import { MatDialogModule, MatDialogRef } from '@angular/material/dialog'
|
||||
import { MenuEditService } from '../menu-edit.service'
|
||||
|
||||
xdescribe('MenuUploadComponent', () => {
|
||||
let component: MenuUploadComponent
|
||||
let fixture: ComponentFixture<MenuUploadComponent>
|
||||
|
||||
beforeEach(() => {
|
||||
const acMock = jasmine.createSpyObj('AdminCommService')
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [MenuUploadComponent],
|
||||
providers: [
|
||||
{ provide: MenuEditService, useValue: acMock },
|
||||
{ provide: MatDialogRef, useValue: {} },
|
||||
],
|
||||
imports: [MatDialogModule],
|
||||
})
|
||||
fixture = TestBed.createComponent(MenuUploadComponent)
|
||||
component = fixture.componentInstance
|
||||
fixture.detectChanges()
|
||||
})
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy()
|
||||
})
|
||||
})
|
||||
@@ -1,30 +0,0 @@
|
||||
import { Component, inject } from '@angular/core'
|
||||
import { MatDialogRef } from '@angular/material/dialog'
|
||||
import { MenuEditService } from '../menu-edit.service'
|
||||
|
||||
@Component({
|
||||
selector: 'app-upload-edit',
|
||||
templateUrl: './menu-upload.component.html',
|
||||
styleUrls: ['./menu-upload.component.scss'],
|
||||
standalone: false,
|
||||
})
|
||||
export class MenuUploadComponent {
|
||||
private ac = inject(MenuEditService)
|
||||
public dialogRef: MatDialogRef<MenuUploadComponent> = inject(MatDialogRef)
|
||||
|
||||
protected file: File | undefined
|
||||
onFileChange(event: Event) {
|
||||
const file: File = (event.target as HTMLInputElement).files![0]
|
||||
if (file) {
|
||||
this.file = file
|
||||
} else {
|
||||
this.file = undefined
|
||||
}
|
||||
}
|
||||
|
||||
submit() {
|
||||
this.ac.postMenu(this.file!)?.subscribe(value => {
|
||||
this.dialogRef.close(value)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,6 @@ import { LogoutConfirmationComponent } from './app-view/personal/logout-confirma
|
||||
import { PersonalComponent } from './app-view/personal/personal.component'
|
||||
import { AppComponent } from './app.component'
|
||||
import { LoginComponent } from './login/login.component'
|
||||
import { MenuUploadComponent } from './admin-view/menu-edit/menu-upload/menu-upload.component'
|
||||
import { NewsEditComponent } from './admin-view/news-edit/news-edit.component'
|
||||
import { MatSnackBarModule } from '@angular/material/snack-bar'
|
||||
import { NewPostComponent } from './admin-view/news-edit/new-post/edit-post.component'
|
||||
@@ -109,7 +108,6 @@ import { MatTooltipModule } from "@angular/material/tooltip";
|
||||
LogoutConfirmationComponent,
|
||||
DateSelectorComponent,
|
||||
AdminViewComponent,
|
||||
MenuUploadComponent,
|
||||
NewsEditComponent,
|
||||
NewPostComponent,
|
||||
AccountMgmtComponent,
|
||||
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
withInterceptorsFromDi,
|
||||
} from '@angular/common/http'
|
||||
import { environment } from 'src/environments/environment'
|
||||
import { firstValueFrom } from 'rxjs'
|
||||
|
||||
describe('UpdatesService', () => {
|
||||
let service: UpdatesService
|
||||
@@ -33,7 +32,7 @@ describe('UpdatesService', () => {
|
||||
})
|
||||
|
||||
it('should grab news', () => {
|
||||
const res = firstValueFrom(service.getNews())
|
||||
const res = service.getNews()
|
||||
const req = httpTestingController.expectOne(environment.apiEndpoint+`/app/news`)
|
||||
|
||||
expect(res).withContext("empty news array").toBeDefined()
|
||||
|
||||
Reference in New Issue
Block a user