Compare commits
3 Commits
8b3cf7bbb9
...
7dc4c3ca7c
| Author | SHA1 | Date | |
|---|---|---|---|
| 7dc4c3ca7c | |||
| 63231e0181 | |||
| 14f1358528 |
@ -16,4 +16,8 @@ export class UserPublic {
|
||||
);
|
||||
}
|
||||
|
||||
static compareName(a: UserPublic, b: UserPublic) {
|
||||
return a.name.localeCompare(b.name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ export class UserService {
|
||||
}
|
||||
|
||||
goto(user: UserPublic) {
|
||||
this.router.navigate(['/User', {uuid: user.publicUuid}]);
|
||||
this.router.navigate(['/User', user.publicUuid]);
|
||||
}
|
||||
|
||||
refresh() {
|
||||
|
||||
@ -15,6 +15,10 @@ export class Group {
|
||||
// -
|
||||
}
|
||||
|
||||
isOwner(user: UserPublic) {
|
||||
return this.owner.publicUuid === user.publicUuid;
|
||||
}
|
||||
|
||||
static fromJson(json: any): Group {
|
||||
return new Group(
|
||||
validateString(json['uuid']),
|
||||
@ -31,5 +35,16 @@ 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ export class GroupService {
|
||||
}
|
||||
|
||||
goto(group: Group) {
|
||||
this.router.navigate(['Group', {uuid: group.uuid}]);
|
||||
this.router.navigate(['Group', group.uuid]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,16 +1,12 @@
|
||||
import {UserPublic} from "../../User/UserPublic";
|
||||
import {validateBoolean, validateDate, validateList, validateString} from "../../common/validators";
|
||||
import {validateString} from "../../common/validators";
|
||||
import {Group} from "../../group/Group";
|
||||
|
||||
export class Numbers {
|
||||
|
||||
constructor(
|
||||
readonly uuid: string,
|
||||
readonly title: string,
|
||||
readonly owner: UserPublic,
|
||||
readonly created: Date,
|
||||
readonly password: string,
|
||||
readonly users: UserPublic[],
|
||||
readonly initial: boolean,
|
||||
readonly name: string,
|
||||
readonly group: Group,
|
||||
) {
|
||||
// -
|
||||
}
|
||||
@ -18,12 +14,8 @@ export class Numbers {
|
||||
static fromJson(json: any): Numbers {
|
||||
return new Numbers(
|
||||
validateString(json['uuid']),
|
||||
validateString(json['title']),
|
||||
UserPublic.fromJson(json['owner']),
|
||||
validateDate(json['created']),
|
||||
validateString(json['password']),
|
||||
validateList(json['users'], UserPublic.fromJson),
|
||||
validateBoolean(json['initial']),
|
||||
validateString(json['name']),
|
||||
Group.fromJson(json['group']),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -14,15 +14,12 @@ export const routes: Routes = [
|
||||
{path: 'VoltageDrop', component: VoltageDropComponent},
|
||||
|
||||
{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},
|
||||
|
||||
// historic
|
||||
{path: 'Solar', redirectTo: '/SolarSystem'},
|
||||
|
||||
// fallback
|
||||
{path: '**', redirectTo: '/SolarSystem'},
|
||||
];
|
||||
|
||||
@ -19,14 +19,10 @@
|
||||
<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" *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>
|
||||
</tr>
|
||||
</table>
|
||||
@ -35,4 +31,5 @@
|
||||
<ng-container *ngIf="uuid && !group && accessDenied">
|
||||
<h1>Passwort</h1>
|
||||
<input type="text" [(ngModel)]="password" (keydown.enter)="join()">
|
||||
<button (click)="join()">Beitreten</button>
|
||||
</ng-container>
|
||||
|
||||
@ -1 +1,5 @@
|
||||
@import "../../../../common.less";
|
||||
|
||||
th {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
@ -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 {UserService} from "../../../api/User/user.service";
|
||||
})
|
||||
export class GroupComponent implements OnInit {
|
||||
|
||||
protected group: Numbers | null = null;
|
||||
protected group: Group | 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;
|
||||
}
|
||||
|
||||
@ -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));
|
||||
}
|
||||
|
||||
protected changePassword(group: Numbers, password: string) {
|
||||
protected changePassword(group: Group, password: string) {
|
||||
this.groupService.changePassword(group, password, group => this.setGroup(group));
|
||||
}
|
||||
|
||||
|
||||
@ -29,9 +29,9 @@ export class UserComponent implements OnInit {
|
||||
|
||||
ngOnInit(): void {
|
||||
this.activatedRoute.params.subscribe(params => {
|
||||
const uuid = params['uuid'];
|
||||
if (uuid) {
|
||||
this.userService.getCommonByUuid(uuid, user => this.user = user);
|
||||
const publicUuid = params['publicUuid'];
|
||||
if (publicUuid) {
|
||||
this.userService.getCommonByUuid(publicUuid, user => this.user = user);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,10 +1,17 @@
|
||||
@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 {
|
||||
|
||||
4
src/main/webapp/META-INF/context.xml
Normal file
4
src/main/webapp/META-INF/context.xml
Normal 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>
|
||||
Loading…
Reference in New Issue
Block a user