Compare commits
2 Commits
81bf02be9b
...
c891691dfe
| Author | SHA1 | Date | |
|---|---|---|---|
| c891691dfe | |||
| 5912044843 |
25
src/main/angular/src/app/api/UUID.ts
Normal file
25
src/main/angular/src/app/api/UUID.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import {CrudService} from "./tools/shopping/crudService";
|
||||
import {Subscription} from "rxjs";
|
||||
|
||||
export abstract class UUID<T extends UUID<T>> {
|
||||
|
||||
private sub?: Subscription;
|
||||
|
||||
protected constructor(
|
||||
crudService: CrudService<T>,
|
||||
readonly uuid: string,
|
||||
) {
|
||||
if (uuid.length !== 36) {
|
||||
throw Error(`UUID must be of length 36: uuid="${uuid}", length=${uuid.length}`);
|
||||
}
|
||||
this.sub = crudService.subscribe(uuid, next => Object.assign(this, next));
|
||||
}
|
||||
|
||||
equals(uuid: T | null | undefined) {
|
||||
if (uuid === null || uuid === undefined) {
|
||||
return false;
|
||||
}
|
||||
return this.uuid === uuid?.uuid;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
import {UserPublic} from "../User/UserPublic";
|
||||
import {UserPublic} from "../user/UserPublic";
|
||||
import {validateDate, validateList, validateString} from "../common/validators";
|
||||
import {UserPrivate} from "../User/UserPrivate";
|
||||
import {UserPrivate} from "../user/UserPrivate";
|
||||
import {GroupUuid} from "./GroupUuid";
|
||||
|
||||
export class Group extends GroupUuid {
|
||||
|
||||
@ -2,10 +2,10 @@ import {ApiService} from "../common/api.service";
|
||||
import {Next} from "../common/types";
|
||||
import {Group} from "./Group";
|
||||
import {Router} from "@angular/router";
|
||||
import {UserService} from "../User/user.service";
|
||||
import {UserService} from "../user/user.service";
|
||||
import {validateBoolean} from "../common/validators";
|
||||
import {Injectable} from "@angular/core";
|
||||
import {UserPublic} from "../User/UserPublic";
|
||||
import {UserPublic} from "../user/UserPublic";
|
||||
import {GroupUserRequest} from "./requests/GroupUserRequest";
|
||||
import {GroupChangeTitleRequest} from "./requests/GroupChangeTitleRequest";
|
||||
import {GroupChangePasswordRequest} from "./requests/GroupChangePasswordRequest";
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import {Group} from "../Group";
|
||||
import {UserPublic} from "../../User/UserPublic";
|
||||
import {UserPublic} from "../../user/UserPublic";
|
||||
|
||||
export class GroupUserRequest {
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import {Group} from "../../group/Group";
|
||||
import {validateDate, validateList, validateString} from "../../common/validators";
|
||||
import {NumbersLot} from "./NumbersLot";
|
||||
import {UserPrivate} from "../../User/UserPrivate";
|
||||
import {UserPublic} from "../../User/UserPublic";
|
||||
import {UserPrivate} from "../../user/UserPrivate";
|
||||
import {UserPublic} from "../../user/UserPublic";
|
||||
|
||||
export class Numbers {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import {UserPublic} from "../../User/UserPublic";
|
||||
import {UserPublic} from "../../user/UserPublic";
|
||||
import {validateBoolean, validateNumberOrNull} from "../../common/validators";
|
||||
import {UserPrivate} from "../../User/UserPrivate";
|
||||
import {UserPrivate} from "../../user/UserPrivate";
|
||||
|
||||
export class NumbersLot {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ApiService} from "../../common/api.service";
|
||||
import {Router} from "@angular/router";
|
||||
import {UserService} from "../../User/user.service";
|
||||
import {UserService} from "../../user/user.service";
|
||||
import {Next} from "../../common/types";
|
||||
import {Numbers} from "./Numbers";
|
||||
import {validateBoolean, validateString} from "../../common/validators";
|
||||
23
src/main/angular/src/app/api/tools/shopping/Shopping.ts
Normal file
23
src/main/angular/src/app/api/tools/shopping/Shopping.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import {validateString} from "../../common/validators";
|
||||
import {UUID} from "../../UUID";
|
||||
import {ShoppingService} from "./shopping.service";
|
||||
|
||||
export class Shopping extends UUID<Shopping> {
|
||||
|
||||
constructor(
|
||||
shoppingService: ShoppingService,
|
||||
uuid: string,
|
||||
readonly name: string,
|
||||
) {
|
||||
super(shoppingService, uuid);
|
||||
}
|
||||
|
||||
static fromJson(shoppingService: ShoppingService, json: any): Shopping {
|
||||
return new Shopping(
|
||||
shoppingService,
|
||||
validateString(json.uuid),
|
||||
validateString(json.name),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
57
src/main/angular/src/app/api/tools/shopping/crudService.ts
Normal file
57
src/main/angular/src/app/api/tools/shopping/crudService.ts
Normal file
@ -0,0 +1,57 @@
|
||||
import {UUID} from "../../UUID";
|
||||
import {ApiService} from "../../common/api.service";
|
||||
import {FromJson, Next} from "../../common/types";
|
||||
import {Page} from "../../common/Page";
|
||||
import {Subscription} from "rxjs";
|
||||
|
||||
export abstract class CrudService<T extends UUID<T>> {
|
||||
|
||||
protected constructor(
|
||||
readonly api: ApiService,
|
||||
readonly path: any[],
|
||||
readonly fromJson: FromJson<T>,
|
||||
) {
|
||||
// -
|
||||
}
|
||||
|
||||
subscribe(uuid: string, next: Next<T>): Subscription {
|
||||
return this.api.subscribe([...this.path, uuid], this.fromJson, next);
|
||||
}
|
||||
|
||||
protected modify(uuid: string, key: string, value: any, next?: Next<void>): void {
|
||||
this.api.postNone([...this.path, key], {uuid: uuid, value: value}, next);
|
||||
}
|
||||
|
||||
protected getNone(path: string[], next?: Next<void>): void {
|
||||
this.api.getNone([...this.path, ...path], next);
|
||||
}
|
||||
|
||||
protected getSingle(path: string[], next?: Next<T>): void {
|
||||
this.api.getSingle([...this.path, ...path], this.fromJson, next);
|
||||
}
|
||||
|
||||
protected getList(path: string[], next?: Next<T[]>): void {
|
||||
this.api.getList([...this.path, ...path], this.fromJson, next);
|
||||
}
|
||||
|
||||
protected getPage(path: string[], next?: Next<Page<T>>): void {
|
||||
this.api.getPage([...this.path, ...path], this.fromJson, next);
|
||||
}
|
||||
|
||||
protected postNone(path: string[], data: any, next?: Next<void>): void {
|
||||
this.api.postNone([...this.path, ...path], data, next);
|
||||
}
|
||||
|
||||
protected postSingle(path: string[], data: any, next?: Next<T>): void {
|
||||
this.api.postSingle([...this.path, ...path], data, this.fromJson, next);
|
||||
}
|
||||
|
||||
protected postList(path: string[], data: any, next?: Next<T[]>): void {
|
||||
this.api.postList([...this.path, ...path], data, this.fromJson, next);
|
||||
}
|
||||
|
||||
protected postPage(path: string[], data: any, next?: Next<Page<T>>): void {
|
||||
this.api.postPage([...this.path, ...path], data, this.fromJson, next);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Shopping} from "./Shopping";
|
||||
import {ApiService} from "../../common/api.service";
|
||||
import {CrudService} from "./crudService";
|
||||
import {Next} from "../../common/types";
|
||||
import {UserService} from "../../user/user.service";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ShoppingService extends CrudService<Shopping> {
|
||||
|
||||
constructor(
|
||||
api: ApiService,
|
||||
readonly userService: UserService,
|
||||
) {
|
||||
super(api, ['Shopping'], json => Shopping.fromJson(this, json));
|
||||
}
|
||||
|
||||
create(next?: Next<Shopping>): void {
|
||||
this.getSingle(['create'], next);
|
||||
}
|
||||
|
||||
get(uuid: string, next?: Next<Shopping>): void {
|
||||
this.postSingle(['get'], uuid, next);
|
||||
}
|
||||
|
||||
delete(uuid: string, next?: Next<void>): void {
|
||||
this.postNone(['delete'], uuid, next);
|
||||
}
|
||||
|
||||
name(uuid: string, name: string, next?: Next<void>): void {
|
||||
this.modify(uuid, 'name', name, next);
|
||||
}
|
||||
|
||||
listOwn(next?: Next<Shopping[]>): void {
|
||||
if (this.userService.user) {
|
||||
this.postList(['mine'], this.userService.user, next);
|
||||
} else {
|
||||
next && next([]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -7,7 +7,7 @@ import {Router} from "@angular/router";
|
||||
import {filter, map, Subject, Subscription} from "rxjs";
|
||||
import {Group} from "../group/Group";
|
||||
import {StompService} from "@stomp/ng2-stompjs";
|
||||
import {Numbers} from "../tools/Numbers/Numbers";
|
||||
import {Numbers} from "../tools/numbers/Numbers";
|
||||
import {GroupDeletedEvent} from "../group/events/GroupDeletedEvent";
|
||||
import {GroupLeftEvent} from "../group/events/GroupLeftEvent";
|
||||
import {UserLogoutEvent} from "./events/UserLogoutEvent";
|
||||
@ -1,9 +1,9 @@
|
||||
import {AfterViewInit, Component, ElementRef, OnDestroy, OnInit, ViewChild} from '@angular/core';
|
||||
import {Router, RouterLink, RouterLinkActive, RouterOutlet} from '@angular/router';
|
||||
import {JsonPipe, NgForOf, NgIf, NgTemplateOutlet} from "@angular/common";
|
||||
import {UserService} from "./api/User/user.service";
|
||||
import {UserService} from "./api/user/user.service";
|
||||
import {Subscription, timer} from "rxjs";
|
||||
import {NotificationService} from "./api/Notification/notification.service";
|
||||
import {NotificationService} from "./api/notification/notification.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
|
||||
@ -7,7 +7,7 @@ import {UserComponent} from "./pages/user/user.component";
|
||||
import {GroupsComponent} from "./pages/group/groups/groups.component";
|
||||
import {GroupComponent} from "./pages/group/group/group.component";
|
||||
import {NumbersComponent} from "./pages/tools/numbers/numbers.component";
|
||||
import {EmailConfirmationComponent} from "./pages/email-confirmation/email-confirmation.component";
|
||||
import {EmailConfirmationComponent} from "./pages/profile/email-confirmation/email-confirmation.component";
|
||||
import {LoginComponent} from "./pages/login/login.component";
|
||||
import {AdminComponent} from "./pages/admin/admin.component";
|
||||
|
||||
|
||||
@ -2,8 +2,8 @@ import {Component, OnInit} from '@angular/core';
|
||||
import {NgForOf} from "@angular/common";
|
||||
import {Page} from "../../api/common/Page";
|
||||
import {PaginationComponent} from "../../shared/pagination/pagination.component";
|
||||
import {UserService} from "../../api/User/user.service";
|
||||
import {UserPrivate} from "../../api/User/UserPrivate";
|
||||
import {UserService} from "../../api/user/user.service";
|
||||
import {UserPrivate} from "../../api/user/UserPrivate";
|
||||
import {RelativePipe} from "../../shared/relative.pipe";
|
||||
|
||||
@Component({
|
||||
|
||||
@ -4,17 +4,17 @@ import {FormsModule, ReactiveFormsModule} from "@angular/forms";
|
||||
import {TextComponent} from "../../../shared/text/text.component";
|
||||
import {ActivatedRoute, Router} from "@angular/router";
|
||||
import {GroupService} from "../../../api/group/group.service";
|
||||
import {UserService} from "../../../api/User/user.service";
|
||||
import {UserService} from "../../../api/user/user.service";
|
||||
import {Group} from "../../../api/group/Group";
|
||||
import {NumbersService} from "../../../api/tools/Numbers/numbers.service";
|
||||
import {NumbersService} from "../../../api/tools/numbers/numbers.service";
|
||||
import {PasswordTileComponent} from "../../../shared/password-tile/password-tile.component";
|
||||
import {Numbers} from "../../../api/tools/Numbers/Numbers";
|
||||
import {Numbers} from "../../../api/tools/numbers/Numbers";
|
||||
import {Page} from "../../../api/common/Page";
|
||||
import {RelativePipe} from "../../../shared/relative.pipe";
|
||||
import {Subscription, timer} from "rxjs";
|
||||
import {GroupDeletedEvent} from "../../../api/group/events/GroupDeletedEvent";
|
||||
import {GroupLeftEvent} from "../../../api/group/events/GroupLeftEvent";
|
||||
import {UserPublic} from "../../../api/User/UserPublic";
|
||||
import {UserPublic} from "../../../api/user/UserPublic";
|
||||
|
||||
@Component({
|
||||
selector: 'app-group',
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import {Component, OnDestroy, OnInit} from '@angular/core';
|
||||
import {GroupListComponent} from "../shared/group-list/group-list.component";
|
||||
import {UserService} from "../../../api/User/user.service";
|
||||
import {UserService} from "../../../api/user/user.service";
|
||||
import {NgIf} from "@angular/common";
|
||||
import {GroupService} from "../../../api/group/group.service";
|
||||
import {Group} from "../../../api/group/Group";
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import {Component, Input} from '@angular/core';
|
||||
import {UserService} from "../../../../api/User/user.service";
|
||||
import {UserService} from "../../../../api/user/user.service";
|
||||
import {Group} from "../../../../api/group/Group";
|
||||
import {DatePipe, NgForOf} from "@angular/common";
|
||||
import {GroupService} from "../../../../api/group/group.service";
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import {Component, OnDestroy, OnInit} from '@angular/core';
|
||||
import {UserService} from "../../api/User/user.service";
|
||||
import {UserService} from "../../api/user/user.service";
|
||||
import {Subscription} from "rxjs";
|
||||
import {UserPrivate} from "../../api/User/UserPrivate";
|
||||
import {UserPrivate} from "../../api/user/UserPrivate";
|
||||
import {FormsModule} from "@angular/forms";
|
||||
|
||||
@Component({
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import {Component, OnDestroy, OnInit} from '@angular/core';
|
||||
import {Subscription} from "rxjs";
|
||||
import {ActivatedRoute, Router} from "@angular/router";
|
||||
import {GroupService} from "../../api/group/group.service";
|
||||
import {UserService} from "../../api/User/user.service";
|
||||
import {GroupService} from "../../../api/group/group.service";
|
||||
import {UserService} from "../../../api/user/user.service";
|
||||
import {NgIf} from "@angular/common";
|
||||
|
||||
@Component({
|
||||
@ -1,6 +1,6 @@
|
||||
import {Component, ElementRef, ViewChild} from '@angular/core';
|
||||
import {NgForOf, NgIf} from "@angular/common";
|
||||
import {UserService} from "../../api/User/user.service";
|
||||
import {UserService} from "../../api/user/user.service";
|
||||
import {FormsModule} from "@angular/forms";
|
||||
import {TextComponent} from "../../shared/text/text.component";
|
||||
import {GroupListComponent} from "../group/shared/group-list/group-list.component";
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import {Component, HostListener, OnDestroy, OnInit} from '@angular/core';
|
||||
import {Numbers} from "../../../api/tools/Numbers/Numbers";
|
||||
import {Numbers} from "../../../api/tools/numbers/Numbers";
|
||||
import {ActivatedRoute} from "@angular/router";
|
||||
import {NumbersService} from "../../../api/tools/Numbers/numbers.service";
|
||||
import {NumbersService} from "../../../api/tools/numbers/numbers.service";
|
||||
import {NgForOf, NgIf} from "@angular/common";
|
||||
import {FormsModule} from "@angular/forms";
|
||||
import {PasswordTileComponent} from "../../../shared/password-tile/password-tile.component";
|
||||
import {GroupService} from "../../../api/group/group.service";
|
||||
import {UserService} from "../../../api/User/user.service";
|
||||
import {UserService} from "../../../api/user/user.service";
|
||||
import {RelativePipe} from "../../../shared/relative.pipe";
|
||||
import {Subscription, timer} from "rxjs";
|
||||
import {Group} from "../../../api/group/Group";
|
||||
|
||||
@ -0,0 +1 @@
|
||||
<p>shopping works!</p>
|
||||
@ -0,0 +1,12 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-shopping',
|
||||
standalone: true,
|
||||
imports: [],
|
||||
templateUrl: './shopping.component.html',
|
||||
styleUrl: './shopping.component.less'
|
||||
})
|
||||
export class ShoppingComponent {
|
||||
|
||||
}
|
||||
@ -3,9 +3,9 @@ import {NgForOf, NgIf} from "@angular/common";
|
||||
import {ActivatedRoute} from "@angular/router";
|
||||
import {GroupListComponent} from "../group/shared/group-list/group-list.component";
|
||||
import {GroupService} from "../../api/group/group.service";
|
||||
import {UserService} from "../../api/User/user.service";
|
||||
import {UserService} from "../../api/user/user.service";
|
||||
import {Group} from "../../api/group/Group";
|
||||
import {UserPublic} from "../../api/User/UserPublic";
|
||||
import {UserPublic} from "../../api/user/UserPublic";
|
||||
import {ReactiveFormsModule} from "@angular/forms";
|
||||
import {TextComponent} from "../../shared/text/text.component";
|
||||
import {Subscription} from "rxjs";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user