Compare commits

..

No commits in common. "7dc4c3ca7c98bdbfceed24827518667682645f4e" and "8b3cf7bbb940f38071158403a26139e35bfdb1a9" have entirely different histories.

12 changed files with 34 additions and 54 deletions

View File

@ -16,8 +16,4 @@ 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) {
this.router.navigate(['/User', user.publicUuid]);
this.router.navigate(['/User', {uuid: user.publicUuid}]);
}
refresh() {

View File

@ -15,10 +15,6 @@ export class Group {
// -
}
isOwner(user: UserPublic) {
return this.owner.publicUuid === user.publicUuid;
}
static fromJson(json: any): Group {
return new Group(
validateString(json['uuid']),
@ -35,16 +31,5 @@ export class Group {
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) {
this.router.navigate(['Group', group.uuid]);
this.router.navigate(['Group', {uuid: group.uuid}]);
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +0,0 @@
<?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>