From ffbcd7fe1af44e7c55d43922cedfe7b65baf3e03 Mon Sep 17 00:00:00 2001
From: _Bastler <_Bastler@bstly.de>
Date: Thu, 12 Aug 2021 20:31:52 +0200
Subject: [PATCH] fix actions for other timeslots
---
.../partey/timeslots/timeslots.component.html | 12 +-
.../partey/timeslots/timeslots.compontent.ts | 120 ++++++++++--------
2 files changed, 72 insertions(+), 60 deletions(-)
diff --git a/src/app/pages/partey/timeslots/timeslots.component.html b/src/app/pages/partey/timeslots/timeslots.component.html
index 1581527..3bf275a 100644
--- a/src/app/pages/partey/timeslots/timeslots.component.html
+++ b/src/app/pages/partey/timeslots/timeslots.component.html
@@ -68,16 +68,18 @@
{{'partey.timeslots.stream' | i18n}}
|
-
- {{ timeslot.stream }}
+
+
+ {{ timeslot.stream }}
+
|
{{'partey.timeslots.edit' | i18n}} |
-
+
edit
|
@@ -86,7 +88,7 @@
{{'partey.timeslots.delete' | i18n}} |
-
+
delete
|
diff --git a/src/app/pages/partey/timeslots/timeslots.compontent.ts b/src/app/pages/partey/timeslots/timeslots.compontent.ts
index 84b1c1c..d178057 100644
--- a/src/app/pages/partey/timeslots/timeslots.compontent.ts
+++ b/src/app/pages/partey/timeslots/timeslots.compontent.ts
@@ -1,21 +1,22 @@
-import {Component, OnInit, ViewChild, Inject} from '@angular/core';
-import {Sort} from '@angular/material/sort';
-import {MatSnackBar} from '@angular/material/snack-bar';
-import {FormBuilder, FormGroup, Validators, NgForm} from '@angular/forms';
-import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog';
-import {DatePipe} from '@angular/common';
-import {FormControl} from '@angular/forms';
-import {debounceTime} from 'rxjs/operators';
-import {PageEvent} from '@angular/material/paginator';
+import { Component, OnInit, ViewChild, Inject } from '@angular/core';
+import { Sort } from '@angular/material/sort';
+import { MatSnackBar } from '@angular/material/snack-bar';
+import { FormBuilder, FormGroup, Validators, NgForm } from '@angular/forms';
+import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
+import { DatePipe } from '@angular/common';
+import { FormControl } from '@angular/forms';
+import { debounceTime } from 'rxjs/operators';
+import { PageEvent } from '@angular/material/paginator';
-import {ParteyTimeslotsService} from '../../../services/partey.timeslots.service';
-import {ConfirmDialog} from '../../../ui/confirm/confirm.component';
-import {I18nService} from './../../../services/i18n.service';
+import { ParteyTimeslotsService } from '../../../services/partey.timeslots.service';
+import { ConfirmDialog } from '../../../ui/confirm/confirm.component';
+import { I18nService } from './../../../services/i18n.service';
+import { AuthService } from './../../../services/auth.service';
@Component({
selector: 'app-partey-timeslots',
templateUrl: './timeslots.component.html',
- styleUrls: ['./timeslots.component.scss']
+ styleUrls: [ './timeslots.component.scss' ]
})
export class ParteyTimeslotsComponent implements OnInit {
@@ -27,13 +28,14 @@ export class ParteyTimeslotsComponent implements OnInit {
success: boolean;
working: boolean;
datetimeformat: string;
- page: any = {page: 0, size: 10, sort: "id", desc: false};
+ page: any = { page: 0, size: 10, sort: "id", desc: false };
filter: any = {};
- pageSizeOptions: number[] = [5, 10, 25, 50];
- visibilities = ["PRIVATE", "PROTECTED", "PUBLIC"];
- types = ["VIDEO", "AUDIO"];
+ pageSizeOptions: number[] = [ 5, 10, 25, 50 ];
+ visibilities = [ "PRIVATE", "PROTECTED", "PUBLIC" ];
+ types = [ "VIDEO", "AUDIO" ];
+ userId: any;
- timeslotsColumns = ["type", "starts", "ends", "title", "description", "stream", "edit", "delete"];
+ timeslotsColumns = [ "type", "starts", "ends", "title", "description", "stream", "edit", "delete" ];
searchFormControl = new FormControl();
ownerFormControl = new FormControl();
@@ -43,19 +45,27 @@ export class ParteyTimeslotsComponent implements OnInit {
constructor(
private formBuilder: FormBuilder,
private parteyTimeslotsService: ParteyTimeslotsService,
+ private authService: AuthService,
private i18n: I18nService,
private datePipe: DatePipe,
private snackBar: MatSnackBar,
- public dialog: MatDialog) {}
+ public dialog: MatDialog) { }
ngOnInit(): void {
+
+ this.authService.auth.subscribe((auth: any) => {
+ if (auth.principal && auth.principal.userId) {
+ this.userId = auth.principal.userId;
+ }
+ });
+
this.datetimeformat = this.i18n.get('format.datetime', []);
this.form = this.formBuilder.group({
- room: ['', Validators.required],
- starts: ['', Validators.nullValidator],
- moderationStarts: ['', Validators.nullValidator],
- expires: ['', Validators.nullValidator],
+ room: [ '', Validators.required ],
+ starts: [ '', Validators.nullValidator ],
+ moderationStarts: [ '', Validators.nullValidator ],
+ expires: [ '', Validators.nullValidator ],
});
this.filter.owner = "";
@@ -69,25 +79,25 @@ export class ParteyTimeslotsComponent implements OnInit {
this.filter.search = value;
this.parteyTimeslotsService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.filter).subscribe((data: any) => {
this.timeslots = data;
- }, (error) => {})
+ }, (error) => { })
})
this.ownerFormControl.valueChanges.subscribe(value => {
this.filter.owner = value;
this.parteyTimeslotsService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.filter).subscribe((data: any) => {
this.timeslots = data;
- }, (error) => {})
+ }, (error) => { })
})
this.typeFormControl.valueChanges.subscribe(value => {
this.filter.type = value;
this.parteyTimeslotsService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.filter).subscribe((data: any) => {
this.timeslots = data;
- }, (error) => {})
+ }, (error) => { })
})
this.afterFormControl.valueChanges.subscribe((value: Date) => {
this.filter.after = value && value.toUTCString() || undefined;
this.parteyTimeslotsService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.filter).subscribe((data: any) => {
this.timeslots = data;
- }, (error) => {})
+ }, (error) => { })
})
this.refresh();
@@ -110,11 +120,11 @@ export class ParteyTimeslotsComponent implements OnInit {
this.page.size = event.pageSize;
this.parteyTimeslotsService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.filter).subscribe((data: any) => {
this.timeslots = data;
- }, (error) => {})
+ }, (error) => { })
}
updateSort(sort: Sort) {
- if(sort.direction == "") {
+ if (sort.direction == "") {
this.page.sort = "id";
this.page.desc = false;
} else {
@@ -123,19 +133,19 @@ export class ParteyTimeslotsComponent implements OnInit {
}
this.parteyTimeslotsService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.filter).subscribe((data: any) => {
this.timeslots = data;
- }, (error) => {})
+ }, (error) => { })
}
confirmDelete(timeslot) {
const dialogRef = this.dialog.open(ConfirmDialog, {
data: {
'label': 'partey.timeslots.confirmDelete',
- 'args': [timeslot.title, this.datePipe.transform(new Date(timeslot.starts), this.datetimeformat)]
+ 'args': [ timeslot.title, this.datePipe.transform(new Date(timeslot.starts), this.datetimeformat) ]
}
})
dialogRef.afterClosed().subscribe(result => {
- if(result) {
+ if (result) {
this.parteyTimeslotsService.delete(timeslot.id).subscribe((result: any) => {
this.refresh();
})
@@ -145,12 +155,12 @@ export class ParteyTimeslotsComponent implements OnInit {
openCreate(type) {
const dialogRef = this.dialog.open(ParteyTimeslotDialog, {
- data: {"type": type ? type : "VIDEO", "visibility": "PROTECTED"},
+ data: { "type": type ? type : "VIDEO", "visibility": "PROTECTED" },
minWidth: '400px'
});
dialogRef.afterClosed().subscribe(result => {
- if(result) {
+ if (result) {
this.refresh();
}
});
@@ -164,7 +174,7 @@ export class ParteyTimeslotsComponent implements OnInit {
});
dialogRef.afterClosed().subscribe(result => {
- if(result) {
+ if (result) {
this.refresh();
}
});
@@ -191,15 +201,15 @@ export class ParteyTimeslotsComponent implements OnInit {
@Component({
selector: 'app-timeslot-dialog',
templateUrl: 'timeslot.dialog.html',
- styleUrls: ['./timeslot.dialog.scss']
+ styleUrls: [ './timeslot.dialog.scss' ]
})
export class ParteyTimeslotDialog {
form: FormGroup;
timeslot;
- visibilities = ["PRIVATE", "PROTECTED", "PUBLIC"];
- types = ["VIDEO", "AUDIO"];
+ visibilities = [ "PRIVATE", "PROTECTED", "PUBLIC" ];
+ types = [ "VIDEO", "AUDIO" ];
constructor(
private parteyTimeslotsService: ParteyTimeslotsService,
@@ -212,11 +222,11 @@ export class ParteyTimeslotDialog {
ngOnInit() {
this.form = this.formBuilder.group({
- starts: ['', Validators.required],
- ends: ['', Validators.required],
- title: ['', Validators.nullValidator],
- description: ['', Validators.nullValidator],
- stream: ['', this.timeslot.type == 'VIDEO' ? Validators.required : Validators.nullValidator],
+ starts: [ '', Validators.required ],
+ ends: [ '', Validators.required ],
+ title: [ '', Validators.nullValidator ],
+ description: [ '', Validators.nullValidator ],
+ stream: [ '', this.timeslot.type == 'VIDEO' ? Validators.required : Validators.nullValidator ],
});
}
@@ -226,15 +236,15 @@ export class ParteyTimeslotDialog {
this.parteyTimeslotsService.create(timeslot).subscribe((result: any) => {
this.dialogRef.close(timeslot);
}, (error) => {
- if(error.status == 409) {
+ if (error.status == 409) {
let errors = {};
- for(let code of error.error) {
- errors[code.field] = errors[code.field] || {};
- errors[code.field][code.code] = true;
+ for (let code of error.error) {
+ errors[ code.field ] = errors[ code.field ] || {};
+ errors[ code.field ][ code.code ] = true;
}
- for(let code in errors) {
- this.form.get(code).setErrors(errors[code]);
+ for (let code in errors) {
+ this.form.get(code).setErrors(errors[ code ]);
}
}
});
@@ -244,15 +254,15 @@ export class ParteyTimeslotDialog {
this.parteyTimeslotsService.update(timeslot).subscribe((result: any) => {
this.dialogRef.close(timeslot);
}, (error) => {
- if(error.status == 409) {
+ if (error.status == 409) {
let errors = {};
- for(let code of error.error) {
- errors[code.field] = errors[code.field] || {};
- errors[code.field][code.code] = true;
+ for (let code of error.error) {
+ errors[ code.field ] = errors[ code.field ] || {};
+ errors[ code.field ][ code.code ] = true;
}
- for(let code in errors) {
- this.form.get(code).setErrors(errors[code]);
+ for (let code in errors) {
+ this.form.get(code).setErrors(errors[ code ]);
}
}
});