Compare commits

...

3 Commits

Author SHA1 Message Date
7dc4c3ca7c group page cleanup 2024-10-29 11:58:12 +01:00
63231e0181 speaking routes 2024-10-29 11:26:30 +01:00
14f1358528 database webapp context.xml 2024-10-29 11:26:21 +01:00
12 changed files with 54 additions and 34 deletions

View File

@ -16,4 +16,8 @@ export class UserPublic {
); );
} }
static compareName(a: UserPublic, b: UserPublic) {
return a.name.localeCompare(b.name);
}
} }

View File

@ -49,7 +49,7 @@ export class UserService {
} }
goto(user: UserPublic) { goto(user: UserPublic) {
this.router.navigate(['/User', {uuid: user.publicUuid}]); this.router.navigate(['/User', user.publicUuid]);
} }
refresh() { refresh() {

View File

@ -15,6 +15,10 @@ export class Group {
// - // -
} }
isOwner(user: UserPublic) {
return this.owner.publicUuid === user.publicUuid;
}
static fromJson(json: any): Group { static fromJson(json: any): Group {
return new Group( return new Group(
validateString(json['uuid']), validateString(json['uuid']),
@ -31,5 +35,16 @@ export class Group {
return a.created.getTime() - b.created.getTime(); return a.created.getTime() - b.created.getTime();
} }
usersByNameOwnerFirst() {
return this.users.sort(this.compareOwnerFirstThenName);
}
private compareOwnerFirstThenName(a: UserPublic, b: UserPublic): number {
if (a.publicUuid === this.owner.publicUuid) {
return -1;
}
return UserPublic.compareName(a, b);
}
} }

View File

@ -63,7 +63,7 @@ export class GroupService {
} }
goto(group: Group) { goto(group: Group) {
this.router.navigate(['Group', {uuid: group.uuid}]); this.router.navigate(['Group', group.uuid]);
} }
} }

View File

@ -1,16 +1,12 @@
import {UserPublic} from "../../User/UserPublic"; import {validateString} from "../../common/validators";
import {validateBoolean, validateDate, validateList, validateString} from "../../common/validators"; import {Group} from "../../group/Group";
export class Numbers { export class Numbers {
constructor( constructor(
readonly uuid: string, readonly uuid: string,
readonly title: string, readonly name: string,
readonly owner: UserPublic, readonly group: Group,
readonly created: Date,
readonly password: string,
readonly users: UserPublic[],
readonly initial: boolean,
) { ) {
// - // -
} }
@ -18,12 +14,8 @@ export class Numbers {
static fromJson(json: any): Numbers { static fromJson(json: any): Numbers {
return new Numbers( return new Numbers(
validateString(json['uuid']), validateString(json['uuid']),
validateString(json['title']), validateString(json['name']),
UserPublic.fromJson(json['owner']), Group.fromJson(json['group']),
validateDate(json['created']),
validateString(json['password']),
validateList(json['users'], UserPublic.fromJson),
validateBoolean(json['initial']),
); );
} }

View File

@ -14,15 +14,12 @@ export const routes: Routes = [
{path: 'VoltageDrop', component: VoltageDropComponent}, {path: 'VoltageDrop', component: VoltageDropComponent},
{path: 'Groups', component: GroupsComponent}, {path: 'Groups', component: GroupsComponent},
{path: 'Group', component: GroupComponent}, {path: 'Group/:uuid', component: GroupComponent},
{path: 'User', component: UserComponent}, {path: 'User/:publicUuid', component: UserComponent},
{path: 'Profile', component: ProfileComponent}, {path: 'Profile', component: ProfileComponent},
// historic
{path: 'Solar', redirectTo: '/SolarSystem'},
// fallback // fallback
{path: '**', redirectTo: '/SolarSystem'}, {path: '**', redirectTo: '/SolarSystem'},
]; ];

View File

@ -19,14 +19,10 @@
<ng-container *ngIf="!userService.owns(group)"></ng-container> <ng-container *ngIf="!userService.owns(group)"></ng-container>
</td> </td>
</tr> </tr>
<tr>
<th>Besitzer</th>
<td class="user" (click)="userService.goto(group.owner)">{{ group.owner.name }}</td>
</tr>
<tr> <tr>
<th>Teilnehmer</th> <th>Teilnehmer</th>
<td> <td>
<div class="user" *ngFor="let user of group.users" (click)="userService.goto(user)">{{ user.name }}</div> <div class="user" [class.user_owner]="group.isOwner(user)" *ngFor="let user of group.usersByNameOwnerFirst()" (click)="userService.goto(user)">{{ user.name }}</div>
</td> </td>
</tr> </tr>
</table> </table>
@ -35,4 +31,5 @@
<ng-container *ngIf="uuid && !group && accessDenied"> <ng-container *ngIf="uuid && !group && accessDenied">
<h1>Passwort</h1> <h1>Passwort</h1>
<input type="text" [(ngModel)]="password" (keydown.enter)="join()"> <input type="text" [(ngModel)]="password" (keydown.enter)="join()">
<button (click)="join()">Beitreten</button>
</ng-container> </ng-container>

View File

@ -1 +1,5 @@
@import "../../../../common.less"; @import "../../../../common.less";
th {
text-align: left;
}

View File

@ -2,10 +2,10 @@ import {Component, OnInit} from '@angular/core';
import {DatePipe, NgForOf, NgIf} from "@angular/common"; import {DatePipe, NgForOf, NgIf} from "@angular/common";
import {FormsModule, ReactiveFormsModule} from "@angular/forms"; import {FormsModule, ReactiveFormsModule} from "@angular/forms";
import {TextComponent} from "../../../shared/text/text.component"; import {TextComponent} from "../../../shared/text/text.component";
import {Numbers} from "../../../api/tools/Numbers/Numbers";
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {GroupService} from "../../../api/group/GroupService"; import {GroupService} from "../../../api/group/GroupService";
import {UserService} from "../../../api/User/user.service"; import {UserService} from "../../../api/User/user.service";
import {Group} from "../../../api/group/Group";
@Component({ @Component({
selector: 'app-group', selector: 'app-group',
@ -23,7 +23,7 @@ import {UserService} from "../../../api/User/user.service";
}) })
export class GroupComponent implements OnInit { export class GroupComponent implements OnInit {
protected group: Numbers | null = null; protected group: Group | null = null;
protected uuid: string | null = null; protected uuid: string | null = null;
@ -56,7 +56,7 @@ export class GroupComponent implements OnInit {
}); });
} }
private setGroup(group: Numbers): void { private setGroup(group: Group): void {
this.group = group; this.group = group;
} }
@ -66,11 +66,11 @@ export class GroupComponent implements OnInit {
} }
} }
protected changeTitle(group: Numbers, title: string) { protected changeTitle(group: Group, title: string) {
this.groupService.changeTitle(group, title, group => this.setGroup(group)); this.groupService.changeTitle(group, title, group => this.setGroup(group));
} }
protected changePassword(group: Numbers, password: string) { protected changePassword(group: Group, password: string) {
this.groupService.changePassword(group, password, group => this.setGroup(group)); this.groupService.changePassword(group, password, group => this.setGroup(group));
} }

View File

@ -29,9 +29,9 @@ export class UserComponent implements OnInit {
ngOnInit(): void { ngOnInit(): void {
this.activatedRoute.params.subscribe(params => { this.activatedRoute.params.subscribe(params => {
const uuid = params['uuid']; const publicUuid = params['publicUuid'];
if (uuid) { if (publicUuid) {
this.userService.getCommonByUuid(uuid, user => this.user = user); this.userService.getCommonByUuid(publicUuid, user => this.user = user);
} }
}); });
} }

View File

@ -1,10 +1,17 @@
@import "./config.less"; @import "./config.less";
.user { .user {
clear: left;
float: left; float: left;
padding: @halfSpace; padding: @halfSpace;
background-color: lightskyblue; background-color: lightskyblue;
border-radius: @halfSpace; border-radius: @halfSpace;
margin-right: @halfSpace;
margin-bottom: @halfSpace;
}
.user_owner {
border: 1px solid black;
} }
.user:hover { .user:hover {

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="Tools">
<Environment name="spring.config.location" value="classpath:/,file:./,file:./properties/Tools.properties" type="java.lang.String"/>
</Context>