feat: Completed migration from moment to luxon

This commit is contained in:
2025-06-09 21:52:20 +02:00
parent 8ad18e8670
commit 76de91349d
34 changed files with 424 additions and 238 deletions

View File

@@ -23,7 +23,8 @@
},
"index": "src/index.html",
"polyfills": [
"zone.js"
"zone.js",
"@angular/localize/init"
],
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
@@ -107,7 +108,7 @@
},
"options": {
"servePath": "/ipwa/",
"open": true
"open": false
},
"defaultConfiguration": "development"
},
@@ -122,7 +123,8 @@
"options": {
"polyfills": [
"zone.js",
"zone.js/testing"
"zone.js/testing",
"@angular/localize/init"
],
"tsConfig": "tsconfig.spec.json",
"inlineStyleLanguage": "scss",
@@ -137,6 +139,9 @@
"scripts": []
}
}
},
"i18n": {
"sourceLocale": "pl"
}
}
},

218
package-lock.json generated
View File

@@ -17,14 +17,13 @@
"@angular/core": "^20.0.2",
"@angular/forms": "^20.0.2",
"@angular/material": "^20.0.2",
"@angular/material-moment-adapter": "^20.0.2",
"@angular/material-luxon-adapter": "^20.0.2",
"@angular/platform-browser": "^20.0.2",
"@angular/platform-browser-dynamic": "^20.0.2",
"@angular/router": "^20.0.2",
"@angular/service-worker": "^20.0.2",
"luxon": "^3.6.1",
"marked": "^12.0.1",
"moment": "^2.29.4",
"rxjs": "~7.5.0",
"tslib": "^2.3.0",
"zone.js": "~0.15.1"
@@ -32,6 +31,7 @@
"devDependencies": {
"@angular/build": "^20.0.1",
"@angular/compiler-cli": "^20.0.2",
"@angular/localize": "^20.0.2",
"@types/jasmine": "~4.3.0",
"@types/luxon": "^3.6.2",
"jasmine-core": "~4.5.0",
@@ -934,6 +934,159 @@
"rxjs": "^6.5.3 || ^7.4.0"
}
},
"node_modules/@angular/localize": {
"version": "20.0.2",
"resolved": "https://registry.npmjs.org/@angular/localize/-/localize-20.0.2.tgz",
"integrity": "sha512-k872tsni1WhrxZNEreCrPatcs35le1LZiLYXg6iGvDmwr8K125DiI2cC6l0dSoD6b3qwP2g+BtRT5lR8V6ROrg==",
"dev": true,
"license": "MIT",
"dependencies": {
"@babel/core": "7.27.4",
"@types/babel__core": "7.20.5",
"tinyglobby": "^0.2.12",
"yargs": "^18.0.0"
},
"bin": {
"localize-extract": "tools/bundles/src/extract/cli.js",
"localize-migrate": "tools/bundles/src/migrate/cli.js",
"localize-translate": "tools/bundles/src/translate/cli.js"
},
"engines": {
"node": "^20.19.0 || ^22.12.0 || >=24.0.0"
},
"peerDependencies": {
"@angular/compiler": "20.0.2",
"@angular/compiler-cli": "20.0.2"
}
},
"node_modules/@angular/localize/node_modules/ansi-regex": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz",
"integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/chalk/ansi-regex?sponsor=1"
}
},
"node_modules/@angular/localize/node_modules/ansi-styles": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz",
"integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/@angular/localize/node_modules/cliui": {
"version": "9.0.1",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-9.0.1.tgz",
"integrity": "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==",
"dev": true,
"license": "ISC",
"dependencies": {
"string-width": "^7.2.0",
"strip-ansi": "^7.1.0",
"wrap-ansi": "^9.0.0"
},
"engines": {
"node": ">=20"
}
},
"node_modules/@angular/localize/node_modules/emoji-regex": {
"version": "10.4.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.4.0.tgz",
"integrity": "sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==",
"dev": true,
"license": "MIT"
},
"node_modules/@angular/localize/node_modules/string-width": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz",
"integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"emoji-regex": "^10.3.0",
"get-east-asian-width": "^1.0.0",
"strip-ansi": "^7.1.0"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/@angular/localize/node_modules/strip-ansi": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz",
"integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-regex": "^6.0.1"
},
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/chalk/strip-ansi?sponsor=1"
}
},
"node_modules/@angular/localize/node_modules/wrap-ansi": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.0.tgz",
"integrity": "sha512-G8ura3S+3Z2G+mkgNRq8dqaFZAuxfsxpBB8OCTGRTCtp+l/v9nbFNmCUP1BZMts3G1142MsZfn6eeUKrr4PD1Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-styles": "^6.2.1",
"string-width": "^7.0.0",
"strip-ansi": "^7.1.0"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
}
},
"node_modules/@angular/localize/node_modules/yargs": {
"version": "18.0.0",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-18.0.0.tgz",
"integrity": "sha512-4UEqdc2RYGHZc7Doyqkrqiln3p9X2DZVxaGbwhn2pi7MrRagKaOcIKe8L3OxYcbhXLgLFUS3zAYuQjKBQgmuNg==",
"dev": true,
"license": "MIT",
"dependencies": {
"cliui": "^9.0.1",
"escalade": "^3.1.1",
"get-caller-file": "^2.0.5",
"string-width": "^7.2.0",
"y18n": "^5.0.5",
"yargs-parser": "^22.0.0"
},
"engines": {
"node": "^20.19.0 || ^22.12.0 || >=23"
}
},
"node_modules/@angular/localize/node_modules/yargs-parser": {
"version": "22.0.0",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-22.0.0.tgz",
"integrity": "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw==",
"dev": true,
"license": "ISC",
"engines": {
"node": "^20.19.0 || ^22.12.0 || >=23"
}
},
"node_modules/@angular/material": {
"version": "20.0.2",
"resolved": "https://registry.npmjs.org/@angular/material/-/material-20.0.2.tgz",
@@ -951,10 +1104,10 @@
"rxjs": "^6.5.3 || ^7.4.0"
}
},
"node_modules/@angular/material-moment-adapter": {
"node_modules/@angular/material-luxon-adapter": {
"version": "20.0.2",
"resolved": "https://registry.npmjs.org/@angular/material-moment-adapter/-/material-moment-adapter-20.0.2.tgz",
"integrity": "sha512-EwpvAjoS18qV+31eNq3VffKOiLjo3X/OaoST+caf1opGxXLzgLol1OYZcBUo/lkPMPjmCriVzdT4rt5CiKJfMA==",
"resolved": "https://registry.npmjs.org/@angular/material-luxon-adapter/-/material-luxon-adapter-20.0.2.tgz",
"integrity": "sha512-39poLZpr8tSygAcl5J6tDPzc1jh6+kdvojXR67iQl4fxW923lM8SyEBletHPrIQuA+Hds5g+gaFEBet7CWfWxw==",
"license": "MIT",
"dependencies": {
"tslib": "^2.3.0"
@@ -962,7 +1115,7 @@
"peerDependencies": {
"@angular/core": "^20.0.0 || ^21.0.0",
"@angular/material": "20.0.2",
"moment": "^2.18.1"
"luxon": "^3.0.0"
}
},
"node_modules/@angular/platform-browser": {
@@ -3845,6 +3998,51 @@
"node": "^18.17.0 || >=20.5.0"
}
},
"node_modules/@types/babel__core": {
"version": "7.20.5",
"resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz",
"integrity": "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@babel/parser": "^7.20.7",
"@babel/types": "^7.20.7",
"@types/babel__generator": "*",
"@types/babel__template": "*",
"@types/babel__traverse": "*"
}
},
"node_modules/@types/babel__generator": {
"version": "7.27.0",
"resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.27.0.tgz",
"integrity": "sha512-ufFd2Xi92OAVPYsy+P4n7/U7e68fex0+Ee8gSG9KX7eo084CWiQ4sdxktvdl0bOPupXtVJPY19zk6EwWqUQ8lg==",
"dev": true,
"license": "MIT",
"dependencies": {
"@babel/types": "^7.0.0"
}
},
"node_modules/@types/babel__template": {
"version": "7.4.4",
"resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.4.tgz",
"integrity": "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==",
"dev": true,
"license": "MIT",
"dependencies": {
"@babel/parser": "^7.1.0",
"@babel/types": "^7.0.0"
}
},
"node_modules/@types/babel__traverse": {
"version": "7.20.7",
"resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.7.tgz",
"integrity": "sha512-dkO5fhS7+/oos4ciWxyEyjWe48zmG6wbCheo/G2ZnHx4fs3EU6YC6UM8rk56gAjNJ9P3MTH2jo5jb92/K6wbng==",
"dev": true,
"license": "MIT",
"dependencies": {
"@babel/types": "^7.20.7"
}
},
"node_modules/@types/cors": {
"version": "2.8.17",
"resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.17.tgz",
@@ -6826,14 +7024,6 @@
"mkdirp": "bin/cmd.js"
}
},
"node_modules/moment": {
"version": "2.29.4",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz",
"integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==",
"engines": {
"node": "*"
}
},
"node_modules/mrmime": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.1.tgz",

View File

@@ -20,14 +20,13 @@
"@angular/core": "^20.0.2",
"@angular/forms": "^20.0.2",
"@angular/material": "^20.0.2",
"@angular/material-moment-adapter": "^20.0.2",
"@angular/material-luxon-adapter": "^20.0.2",
"@angular/platform-browser": "^20.0.2",
"@angular/platform-browser-dynamic": "^20.0.2",
"@angular/router": "^20.0.2",
"@angular/service-worker": "^20.0.2",
"luxon": "^3.6.1",
"marked": "^12.0.1",
"moment": "^2.29.4",
"rxjs": "~7.5.0",
"tslib": "^2.3.0",
"zone.js": "~0.15.1"
@@ -35,6 +34,7 @@
"devDependencies": {
"@angular/build": "^20.0.1",
"@angular/compiler-cli": "^20.0.2",
"@angular/localize": "^20.0.2",
"@types/jasmine": "~4.3.0",
"@types/luxon": "^3.6.2",
"jasmine-core": "~4.5.0",

View File

@@ -23,7 +23,7 @@
</mat-select>
</mat-form-field>
@if (data.type == 'edit') {
<span>Data rejestracji:<br>{{regDate?.format('DD.MM.YYYY')}}</span>
<span>Data rejestracji:<br>{{regDate?.toFormat('D')}}</span>
}
</div>
<div>

View File

@@ -8,8 +8,7 @@ import { UserDeleteComponent } from '../user-delete/user-delete.component';
import { MatSnackBar } from '@angular/material/snack-bar';
import { UserResetComponent } from '../user-reset/user-reset.component';
import { catchError, throwError } from 'rxjs';
import { Moment } from 'moment';
import moment from 'moment';
import { DateTime } from 'luxon';
export namespace UserEditComponent {
export type InputData = {type: "new" | "edit", id?: string, groups: Group[]}
@@ -36,7 +35,7 @@ export class UserEditComponent {
})
groups: Group[]
id?: string
regDate?: Moment;
regDate?: DateTime;
constructor (
public dialogRef: MatDialogRef<UserEditComponent>,
@Inject(MAT_DIALOG_DATA) public data: UserEditComponent.InputData,
@@ -49,7 +48,7 @@ export class UserEditComponent {
if (data.type == "edit") {
this.id = data.id
this.acu.accs.getUser(data.id!).subscribe((r) => {
this.regDate = moment(r.regDate)
this.regDate = DateTime.fromISO(r.regDate)
var flags: Array<number> = []
if (r.admin) {
if ((r.admin & 1) == 1) flags.push(1)

View File

@@ -1,17 +1,16 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Moment } from 'moment';
import { environment } from 'src/environments/environment';
import { Menu } from '../types/menu';
import { Status } from '../types/status';
import { Group } from '../types/group';
import { map, of } from 'rxjs';
import { map } from 'rxjs';
import { Notification } from '../types/notification';
import { News } from '../types/news';
import { AKey } from '../types/key';
import moment from 'moment';
import { IUSettings } from './settings/settings.component';
import User from '../types/user';
import { DateTime } from 'luxon';
@Injectable({
providedIn: 'root'
@@ -22,10 +21,10 @@ export class AdminCommService {
//#region Menu
menu = {
getMenu: (start?: Moment | null, end?: Moment | null) => {
getMenu: (start?: DateTime | null, end?: DateTime | null) => {
if (start && end) {
const body = {start: start.toString(), end: end.toString()}
return this.http.get<Menu[]>(environment.apiEndpoint+"/admin/menu", {withCredentials: true, params: body})
return this.http.get<(Omit<Menu, "day"> & {day: string})[]>(environment.apiEndpoint+"/admin/menu", {withCredentials: true, params: body})
}
return
},
@@ -59,7 +58,7 @@ export class AdminCommService {
return this.putMenu(id, {dayTitle: content})
},
print: (start?: Moment | null, end?: Moment | null) => {
print: (start?: DateTime | null, end?: DateTime | null) => {
if (start && end) {
const body = {start: start.toString(), end: end.toString()}
return this.http.get(environment.apiEndpoint+"/admin/menu/print", {withCredentials: true, params: body, responseType: "text"})
@@ -67,15 +66,15 @@ export class AdminCommService {
return
},
stat: (day: Moment, m: "ob" | "kol") => {
return this.http.get<{y: number, n: number}>(environment.apiEndpoint+`/admin/menu/${day.toISOString()}/votes/${m}`, {withCredentials: true})
stat: (day: DateTime, m: "ob" | "kol") => {
return this.http.get<{y: number, n: number}>(environment.apiEndpoint+`/admin/menu/${day.toISO()}/votes/${m}`, {withCredentials: true})
},
new: {
single: (day: Moment) => {
return this.http.post<Status>(environment.apiEndpoint+`/admin/menu/${day.toISOString()}`, null, {withCredentials: true})
single: (day: DateTime) => {
return this.http.post<Status>(environment.apiEndpoint+`/admin/menu/${day.toISO()}`, null, {withCredentials: true})
},
range: (start: Moment, count: number) => {
return this.http.post<Status>(environment.apiEndpoint+`/admin/menu/${start.toISOString()}/${count}/`, null, {withCredentials: true})
range: (start: DateTime, count: number) => {
return this.http.post<Status>(environment.apiEndpoint+`/admin/menu/${start.toISO()}/${count}/`, null, {withCredentials: true})
}
},
rm: (id: string) => {
@@ -144,7 +143,7 @@ export class AdminCommService {
},
getUser: (id: string) => {
return this.http.get<Omit<User, "pass"> & {lockout: boolean}>(environment.apiEndpoint+`/admin/accs/${id}`, {withCredentials: true})
return this.http.get<Omit<User, "pass" | "regDate"> & {lockout: boolean, regDate: string}>(environment.apiEndpoint+`/admin/accs/${id}`, {withCredentials: true})
},
clearLockout: (id: string) => {
@@ -185,7 +184,10 @@ export class AdminCommService {
},
outbox: {
getSent: () => {
return this.http.get<{_id: string, sentDate: moment.Moment, title: string}[]>(environment.apiEndpoint+"/admin/notif/outbox", {withCredentials: true})
return this.http.get<{_id: string, sentDate: string, title: string}[]>(environment.apiEndpoint+"/admin/notif/outbox", {withCredentials: true}).pipe(map(v => v.map(i => ({
...i,
sentDate: DateTime.fromISO(i.sentDate)
}))))
},
getBody: (id: string) => {
return this.http.get(environment.apiEndpoint+`/admin/notif/outbox/${id}/message`, {withCredentials: true, responseType: "text"})
@@ -199,11 +201,12 @@ export class AdminCommService {
//#region Keys
keys = {
getKeys: () => {
return this.http.get<AKey[]>(environment.apiEndpoint+`/admin/keys`, {withCredentials: true}).pipe(map((v) => {
return this.http.get<(Omit<AKey, "borrow" | "tb"> & {borrow: string, tb?: string})[]>(environment.apiEndpoint+`/admin/keys`, {withCredentials: true}).pipe(map((v) => {
return v.map((r) => {
r.borrow = moment(r.borrow)
if (r.tb) r.tb = moment(r.tb)
return r
let newkey: any = {...r}
newkey.borrow = DateTime.fromISO(r.borrow!)
if (newkey.tb) newkey.tb = DateTime.fromISO(r.tb!)
return newkey as AKey
})
}))
},
@@ -217,7 +220,7 @@ export class AdminCommService {
},
returnKey: (id: string) => {
return this.putKeys(id, {tb: moment.utc()})
return this.putKeys(id, {tb: DateTime.now()})
}
}
@@ -230,8 +233,8 @@ export class AdminCommService {
getConfig: () => {
return this.http.get<{rooms: string[], things: string[]}>(environment.apiEndpoint+`/admin/clean/config`, {withCredentials: true})
},
getClean: (date: moment.Moment, room: string) => {
return this.http.get<{_id: string, date: string, grade: number, gradeDate: string, notes: {label: string, weight: number}[], room: string, tips: string} | null>(environment.apiEndpoint+`/admin/clean/${date.toISOString()}/${room}`, {withCredentials: true})
getClean: (date: string, room: string) => {
return this.http.get<{_id: string, date: string, grade: number, gradeDate: string, notes: {label: string, weight: number}[], room: string, tips: string} | null>(environment.apiEndpoint+`/admin/clean/${date}/${room}`, {withCredentials: true})
},
postClean: (obj: Object) => {
return this.http.post<Status>(environment.apiEndpoint+`/admin/clean/`, obj, {withCredentials: true})
@@ -240,8 +243,8 @@ export class AdminCommService {
return this.http.delete<Status>(environment.apiEndpoint+`/admin/clean/${id}`, {withCredentials: true})
},
summary: {
getSummary: (start: moment.Moment, end: moment.Moment) => {
return this.http.get<{room: string, avg: number}[]>(environment.apiEndpoint+`/admin/clean/summary/${start.toISOString()}/${end.toISOString()}`, {withCredentials: true})
getSummary: (start: DateTime, end: DateTime) => {
return this.http.get<{room: string, avg: number}[]>(environment.apiEndpoint+`/admin/clean/summary/${start.toISO()}/${end.toISO()}`, {withCredentials: true})
}
},
attendence: {

View File

@@ -1,7 +1,7 @@
<app-date-selector [(date)]="date" [filter]="filter" (dateChange)="downloadData()"></app-date-selector>
<app-room-chooser [rooms]="rooms" (room)="roomNumber($event)"/>
<form [formGroup]="form">
<p>Czystość pokoju {{room}} na dzień {{date.format("dddd")}}</p>
<p>Czystość pokoju {{room}} na {{_date.toFormat("cccc, D")}}</p>
<p>Ocena: {{grade}}</p>
<div id="buttons">
<button mat-mini-fab (click)="downloadData()" color="accent"><mat-icon>cancel</mat-icon></button>

View File

@@ -4,20 +4,20 @@ import { GradesComponent } from './grades.component';
import { AdminCommService } from '../admin-comm.service';
import { RouterModule } from '@angular/router';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import * as moment from 'moment';
import { MatIconModule } from '@angular/material/icon';
import { MatFormFieldModule } from '@angular/material/form-field';
import { of } from 'rxjs';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MatInputModule } from '@angular/material/input';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { DateTime } from 'luxon';
@Component({
selector: "app-date-selector", template: '',
standalone: false
})
class DateSelectorStub {
@Input() date: moment.Moment = moment.utc().startOf('day');
@Input() date: string = DateTime.now().toISODate();
@Output() dateChange = new EventEmitter<moment.Moment>();
@Input() filter: (date: moment.Moment | null) => boolean = () => true
}

View File

@@ -1,6 +1,5 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { AdminCommService } from '../admin-comm.service';
import moment from 'moment';
import { FormArray, FormBuilder } from '@angular/forms';
import { weekendFilter } from 'src/app/fd.da';
import { MatSnackBar } from '@angular/material/snack-bar';
@@ -8,6 +7,7 @@ import { ToolbarService } from '../toolbar/toolbar.service';
import { ActivatedRoute, Router } from '@angular/router';
import { MatDialog } from '@angular/material/dialog';
import { AttendenceComponent } from './attendence/attendence.component';
import { DateTime } from 'luxon';
@Component({
selector: 'app-grades',
@@ -18,9 +18,15 @@ import { AttendenceComponent } from './attendence/attendence.component';
export class GradesComponent implements OnInit, OnDestroy {
rooms!: string[]
room: string = "0";
date: moment.Moment;
protected _date: DateTime;
public get date(): string {
return this._date.toISODate()!;
}
public set date(value: string) {
this._date = DateTime.fromISO(value);
}
grade: number = 6
gradeDate?: moment.Moment;
gradeDate?: DateTime;
id?: string
filter = weekendFilter
@@ -46,8 +52,8 @@ export class GradesComponent implements OnInit, OnDestroy {
}
constructor(private ac: AdminCommService, private fb: FormBuilder, private sb: MatSnackBar, private toolbar: ToolbarService, private router: Router, private route: ActivatedRoute, private dialog: MatDialog) {
this.date = moment.utc().startOf('day')
if (!this.filter(this.date)) this.date.isoWeekday(8);
this._date = DateTime.now()
// if (!this.filter(this.date)) this.date.isoWeekday(8);
this.toolbar.comp = this
this.toolbar.menu = [
{ title: "Pokoje do sprawdzenia", check: true, fn: "attendenceSummary", icon: "overview"},
@@ -95,7 +101,7 @@ export class GradesComponent implements OnInit, OnDestroy {
this.ac.clean.getClean(this.date, this.room).subscribe((v) => {
if (v) {
this.notes = v.notes
this.gradeDate = moment(v.gradeDate)
this.gradeDate = DateTime.fromISO(v.gradeDate)
this.grade = v.grade
this.id = v._id
this.form.get("tips")?.setValue(v.tips)
@@ -140,7 +146,7 @@ export class GradesComponent implements OnInit, OnDestroy {
this.calculate()
var obj = {
grade: this.grade,
date: this.date.toDate(),
date: this.date,
room: this.room,
notes: this.notes,
tips: this.form.get("tips")?.value

View File

@@ -2,10 +2,10 @@ import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { ToolbarService } from '../../toolbar/toolbar.service';
import { ActivatedRoute, Router } from '@angular/router';
import { AdminCommService } from '../../admin-comm.service';
import * as moment from 'moment';
import { MatTableDataSource } from '@angular/material/table';
import { FormBuilder } from '@angular/forms';
import { MatSort } from '@angular/material/sort';
import { DateTime } from 'luxon';
@Component({
selector: 'app-summary',
@@ -19,8 +19,8 @@ export class SummaryComponent implements OnInit, OnDestroy {
collumns = ['room', 'avg']
dateSelector = this.fb.group({
start: this.fb.control(moment.utc().startOf('day')),
end: this.fb.control(moment.utc().endOf('day'))
start: this.fb.control(DateTime.utc().startOf('day')),
end: this.fb.control(DateTime.utc().endOf('day'))
})
@ViewChild(MatSort, {static: false}) set content(sort: MatSort) {

View File

@@ -1,10 +1,8 @@
import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core';
import { MatPaginator } from '@angular/material/paginator';
import { MatTableDataSource } from '@angular/material/table';
import * as moment from 'moment';
import { AKey } from 'src/app/types/key';
import { AdminCommService } from '../admin-comm.service';
import { FormControl } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
import { NewKeyComponent } from './new-key/new-key.component';
import { catchError, throwError } from 'rxjs';

View File

@@ -3,9 +3,8 @@ import { MenuUploadComponent } from '../menu-upload/menu-upload.component';
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
import { FDSelection, weekendFilter } from 'src/app/fd.da';
import { FormControl, FormGroup } from '@angular/forms';
import { Moment } from 'moment';
import { MAT_DATE_RANGE_SELECTION_STRATEGY } from '@angular/material/datepicker';
import * as moment from 'moment';
import { DateTime } from 'luxon';
@Component({
selector: 'app-menu-add',
@@ -20,11 +19,11 @@ export class MenuAddComponent {
type: string | undefined;
filter = weekendFilter
day: Moment = moment.utc();
day: string = DateTime.now().toISODate();
range = new FormGroup({
start: new FormControl<Moment|null>(null),
end: new FormControl<Moment|null>(null),
start: new FormControl<DateTime|null>(null),
end: new FormControl<DateTime|null>(null),
})
constructor (public dialogRef: MatDialogRef<MenuAddComponent>, private dialog: MatDialog) { }
@@ -32,10 +31,10 @@ export class MenuAddComponent {
submit() {
switch (this.type) {
case "day":
this.dialogRef.close({type: "day", value: this.day.utc().startOf('day')})
this.dialogRef.close({type: "day", value: this.day})
break;
case "week":
this.dialogRef.close({type: "week", value: {start: this.range.value.start?.utc().hours(24), count: 5}})
this.dialogRef.close({type: "week", value: {start: this.range.value.start?.toISODate(), count: 5}})
break;
default:
break;

View File

@@ -19,8 +19,8 @@
<div matColumnDef="day">
<th mat-header-cell *matHeaderCellDef>Dzień</th>
<td mat-cell *matCellDef="let element">
<span>{{element.day.format('DD.MM.YYYY')}}r.</span>
<p>{{element.day.format('dddd')}}</p>
<span>{{element.day.toFormat('dd.LL.yyyy')}}r.</span>
<p>{{element.day.toFormat('cccc') | titlecase }}</p>
<app-field-editor category="Nazwa" [(word)]="element.dayTitle" (wordChange)="editTitle(element._id)"/><br><hr>
<button (click)="remove(element._id)">Usuń dzień</button>
</td>
@@ -61,7 +61,7 @@
<th mat-header-cell *matHeaderCellDef>Kolacja</th>
<td mat-cell *matCellDef="let element">
<div>
@switch (element.day.isoWeekday()) {
@switch (element.day.weekday) {
@default {
<div>
<ul class="non-editable">

View File

@@ -1,18 +1,17 @@
import { Component } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { MAT_DATE_RANGE_SELECTION_STRATEGY } from '@angular/material/datepicker';
import { Moment } from 'moment';
import { FDSelection } from 'src/app/fd.da';
import { Menu } from 'src/app/types/menu';
import { AdminCommService } from '../admin-comm.service';
import { MatTableDataSource } from '@angular/material/table';
import * as moment from 'moment';
import { MatDialog } from '@angular/material/dialog';
import { MenuUploadComponent } from './menu-upload/menu-upload.component';
import { Status } from 'src/app/types/status';
import { MatSnackBar } from '@angular/material/snack-bar';
import { MenuAddComponent } from './menu-add/menu-add.component';
import { LocalStorageService } from 'src/app/services/local-storage.service';
import { DateTime } from 'luxon';
@Component({
selector: 'app-menu-new',
@@ -27,17 +26,13 @@ export class MenuNewComponent {
dcols: string[] = ['day', 'sn', 'ob', 'kol']
dataSource: MatTableDataSource<Menu> = new MatTableDataSource<Menu>()
range = new FormGroup({
start: new FormControl<Moment|null>(null),
end: new FormControl<Moment|null>(null),
start: new FormControl<DateTime|null>(null),
end: new FormControl<DateTime|null>(null),
})
loading = false
public options: any;
constructor (private ac: AdminCommService, private dialog: MatDialog, private sb: MatSnackBar, readonly ls: LocalStorageService) {
moment.updateLocale('pl', {
weekdays: ["Niedziela", "Poniedziałek", "Wtorek", "Środa", "Czwartek", "Piątek", "Sobota"]
})
}
constructor (private ac: AdminCommService, private dialog: MatDialog, private sb: MatSnackBar, readonly ls: LocalStorageService) { }
print() {
this.ac.menu.print(this.range.value.start, this.range.value.end)?.subscribe((r) => {
@@ -80,7 +75,7 @@ export class MenuNewComponent {
this.dataSource.data = data.map((v) => {
let newMenu: Menu = {
...v,
day: moment.utc(v.day)
day: DateTime.fromISO(v.day)
}
return newMenu
})
@@ -117,7 +112,7 @@ export class MenuNewComponent {
this.ac.menu.editTitle(id, this.dataSource.data.find(v => v._id == id)?.dayTitle).subscribe(s => this.refreshIfGood(s))
}
getStat(day: moment.Moment, m: "ob" | "kol") {
getStat(day: DateTime, m: "ob" | "kol") {
this.ac.menu.stat(day, m).subscribe((s) => this.sb.open(`${s.y} / ${s.y+s.n} = ${((s.y/(s.y+s.n))*100).toFixed(2)}%`, "Zamknij", {duration: 2500}))
}

View File

@@ -4,7 +4,7 @@
<mat-card-title>
{{item.title}}
</mat-card-title>
<mat-card-subtitle>{{item.sentDate.format('[Wysłano] dddd DD MMMM YYYYr. o HH:mm')}}</mat-card-subtitle>
<mat-card-subtitle>Wysłano {{item.sentDate.toFormat("cccc dd LLLL yyyyr. 'o' HH:mm")}}</mat-card-subtitle>
</mat-card-title-group>
</mat-card-header>
<mat-card-content>

View File

@@ -1,9 +1,8 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MessageComponent } from './message.component';
import { AdminCommService } from 'src/app/admin-view/admin-comm.service';
import { MatCardModule } from '@angular/material/card';
import moment from 'moment';
import { DateTime } from 'luxon';
describe('MessageComponent', () => {
let component: MessageComponent;
@@ -26,7 +25,7 @@ describe('MessageComponent', () => {
fixture = TestBed.createComponent(MessageComponent);
component = fixture.componentInstance;
component.item = {_id: "test", sentDate: moment(), title: "Test"}
component.item = {_id: "test", sentDate: DateTime.now(), title: "Test"}
fixture.detectChanges();
});

View File

@@ -1,4 +1,5 @@
import { Component, Input } from '@angular/core';
import { DateTime } from 'luxon';
import { AdminCommService } from 'src/app/admin-view/admin-comm.service';
@Component({
@@ -8,7 +9,7 @@ import { AdminCommService } from 'src/app/admin-view/admin-comm.service';
standalone: false
})
export class MessageComponent {
@Input() item!: {_id: string, sentDate: moment.Moment, title: string}
@Input() item!: {_id: string, sentDate: DateTime, title: string}
body?: string
rcpts?: {_id: string, uname: string, room?: string, fname?: string, surname?: string}[]
loading: boolean = false

View File

@@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { AdminCommService } from '../../admin-comm.service';
import { Router, ActivatedRoute } from '@angular/router';
import { ToolbarService } from '../../toolbar/toolbar.service';
import moment from 'moment';
import { DateTime } from 'luxon';
@Component({
selector: 'app-outbox',
@@ -14,7 +14,7 @@ export class OutboxComponent implements OnInit {
messages!: {
_id: string;
sentDate: moment.Moment;
sentDate: DateTime;
title: string;
}[]
@@ -31,12 +31,7 @@ export class OutboxComponent implements OnInit {
ngOnInit(): void {
this.acs.notif.outbox.getSent().subscribe((v) => {
this.messages = v.map(i => {
return {
...i,
sentDate: moment(i.sentDate)
}
})
this.messages = v
})
}

View File

@@ -1,83 +1,80 @@
import { Component, OnInit } from '@angular/core';
import { UpdatesService } from '../../services/updates.service';
import { Menu } from '../../types/menu';
import * as moment from 'moment';
import { MatBottomSheet } from '@angular/material/bottom-sheet';
import { AllergensComponent } from './allergens/allergens.component';
import { weekendFilter } from "../../fd.da";
import { LocalStorageService } from 'src/app/services/local-storage.service';
import { DateTime } from 'luxon';
@Component({
selector: 'app-menu',
templateUrl: './menu.component.html',
styleUrls: ['./menu.component.scss'],
standalone: false
selector: 'app-menu',
templateUrl: './menu.component.html',
styleUrls: ['./menu.component.scss'],
standalone: false
})
export class MenuComponent {
constructor(private uc:UpdatesService, readonly bs: MatBottomSheet, readonly ls: LocalStorageService) {
this.day = moment.utc()
}
loading = true
constructor(private uc: UpdatesService, readonly bs: MatBottomSheet, readonly ls: LocalStorageService) {
this._day = DateTime.now().toISODate()
}
loading = true
public filter = weekendFilter
private _day!: moment.Moment;
public get day(): moment.Moment {
return this._day;
}
public set day(value: moment.Moment) {
// if (value.isAfter(moment.utc("19:15:00", "HH:mm:ss"))) value.add(1, "day")
if (!this.filter(value)) value.isoWeekday(8);
this._day = moment.utc(value).startOf('day');
this.updateMenu()
}
menu?: Menu;
get getsn() {return (this.menu && this.checkIfAnyProperty(this.menu.sn)) ? this.menu.sn : null}
get getob() {return (this.menu && this.checkIfAnyProperty(this.menu.ob)) ? this.menu.ob : null}
get getkol() {return (this.menu && this.menu.kol) ? this.menu.kol : null}
get gettitle() {return (this.menu && this.menu.dayTitle && this.menu.dayTitle != "") ? this.menu.dayTitle : null}
private checkIfAnyProperty(obj: { [x: string]: string | string[];}) {
for (let i in obj) {
if (Array.isArray(obj[i])) {
if (obj[i].length > 0) return true
} else {
if (!!obj[i]) return true
}
public filter = weekendFilter
private _day: string;
public get day(): string {
return this._day;
}
public set day(value: string) {
this._day = value;
this.updateMenu()
}
menu?: Menu;
get getsn() { return (this.menu && this.checkIfAnyProperty(this.menu.sn)) ? this.menu.sn : null }
get getob() { return (this.menu && this.checkIfAnyProperty(this.menu.ob)) ? this.menu.ob : null }
get getkol() { return (this.menu && this.menu.kol) ? this.menu.kol : null }
get gettitle() { return (this.menu && this.menu.dayTitle && this.menu.dayTitle != "") ? this.menu.dayTitle : null }
private checkIfAnyProperty(obj: { [x: string]: string | string[]; }) {
for (let i in obj) {
if (Array.isArray(obj[i])) {
if (obj[i].length > 0) return true
} else {
if (!!obj[i]) return true
}
return false
}
return false
}
capitalize(str: string) {
return str.charAt(0).toUpperCase()+str.substring(1)
}
capitalize(str: string) {
return str.charAt(0).toUpperCase() + str.substring(1)
}
updateMenu(silent?: boolean) {
this.loading = !silent
if (!silent) this.menu = undefined
this.uc.getMenu(this.day).subscribe(m => {
this.loading = false
this.menu = m
console.log(m);
})
}
updateMenu(silent?: boolean) {
this.loading = !silent
if (!silent) this.menu = undefined
this.uc.getMenu(this.day).subscribe(m => {
this.loading = false
this.menu = m
console.log(m);
})
}
alrg() {
this.bs.open(AllergensComponent)
}
alrg() {
this.bs.open(AllergensComponent)
}
protected vegeColor(text: string) {
if (text.startsWith("V: ")) {
return "#43A047"
}
return "inherit"
protected vegeColor(text: string) {
if (text.startsWith("V: ")) {
return "#43A047"
}
return "inherit"
}
vote(type: "ob" | "kol", vote: "-" | "+" | "n") {
this.uc.postVote(this.menu!.day, type, vote).subscribe((data) => {
this.updateMenu(true)
})
}
vote(type: "ob" | "kol", vote: "-" | "+" | "n") {
this.uc.postVote(this.menu!.day.toISO()!, type, vote).subscribe((data) => {
this.updateMenu(true)
})
}
}

View File

@@ -3,7 +3,7 @@
<p>
{{data.message.body}}
</p>
<div>{{data.sentDate.format("[Wysłano] dddd DD MMMM YYYYr. o HH:mm")}}</div>
<div>{{date.toFormat("[Wysłano] dddd DD MMMM YYYYr. o HH:mm")}}</div>
</mat-dialog-content>
<mat-dialog-actions align="end">
<button mat-raised-button color="primary" (click)="ack()">Odczytano</button>

View File

@@ -1,6 +1,6 @@
import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import moment from 'moment';
import { DateTime } from 'luxon';
import { UpdatesService } from 'src/app/services/updates.service';
@Component({
@@ -11,12 +11,14 @@ import { UpdatesService } from 'src/app/services/updates.service';
})
export class NotifDialogComponent {
date: DateTime
constructor (
@Inject(MAT_DIALOG_DATA) public data: {_id: string, message: {title: string, body: string}, sentDate: moment.Moment},
@Inject(MAT_DIALOG_DATA) public data: {_id: string, message: {title: string, body: string}, sentDate: string},
public dialogRef: MatDialogRef<NotifDialogComponent>,
private uc: UpdatesService
) {
data.sentDate = moment(data.sentDate)
this.date = DateTime.fromISO(data.sentDate)
}
ack () {

View File

@@ -8,14 +8,14 @@ import { MatIconModule } from '@angular/material/icon';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatDatepicker } from '@angular/material/datepicker';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import * as moment from 'moment';
import { DateTime } from 'luxon';
@Component({
selector: "app-date-selector", template: '',
standalone: false
})
class DateSelectorStub {
@Input() date: moment.Moment = moment.utc().startOf('day');
@Input() date: string = DateTime.now().toISODate();
@Output() dateChange = new EventEmitter<moment.Moment>();
@Input() filter: (date: moment.Moment | null) => boolean = () => true
}

View File

@@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
import moment from 'moment';
import { DateTime } from 'luxon';
import { weekendFilter } from 'src/app/fd.da';
import { UpdatesService } from 'src/app/services/updates.service';
import { CleanNote } from 'src/app/types/clean-note';
@@ -11,22 +11,14 @@ import { CleanNote } from 'src/app/types/clean-note';
standalone: false
})
export class CleanComponent implements OnInit {
private _day: moment.Moment = moment()
public get day(): moment.Moment {
return this._day;
}
public set day(value: moment.Moment) {
if (!this.filter(value)) value.isoWeekday(5);
this._day = moment.utc(value).startOf('day');
this.update()
}
protected day: string
grade: number | null = null
notes: CleanNote[] = []
tips: string = ""
filter = weekendFilter
constructor (private updates: UpdatesService) {
this.day = moment.utc();
this.day = DateTime.now().toISODate()
}
ngOnInit(): void {

View File

@@ -1,7 +1,7 @@
import { Component } from '@angular/core';
import { Component, Inject, LOCALE_ID } from '@angular/core';
import { AppUpdateService } from './services/app-update.service';
import { MatIconRegistry } from '@angular/material/icon';
import * as moment from 'moment';
import { Settings } from 'luxon';
@Component({
selector: 'app-root',
@@ -10,12 +10,9 @@ import * as moment from 'moment';
standalone: false
})
export class AppComponent {
constructor (readonly updates: AppUpdateService, mir: MatIconRegistry) {
constructor (readonly updates: AppUpdateService, mir: MatIconRegistry, @Inject(LOCALE_ID) lang: string) {
mir.setDefaultFontSetClass("material-symbols-rounded")
moment.updateLocale('pl', {
weekdays: ["Niedziela", "Poniedziałek", "Wtorek", "Środa", "Czwartek", "Piątek", "Sobota"]
})
moment.locale('pl')
Settings.defaultLocale = lang
}
title = 'Internat';
}

View File

@@ -3,10 +3,8 @@ import { BrowserModule } from '@angular/platform-browser';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MAT_MOMENT_DATE_ADAPTER_OPTIONS, MAT_MOMENT_DATE_FORMATS, MomentDateAdapter } from '@angular/material-moment-adapter';
import { MatButtonModule } from "@angular/material/button";
import { MatCardModule } from "@angular/material/card";
import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE, MatNativeDateModule } from '@angular/material/core';
import { MatDatepickerModule } from "@angular/material/datepicker";
import { MatDialogModule } from '@angular/material/dialog';
import { MatIconModule } from "@angular/material/icon";
@@ -87,6 +85,7 @@ import { MessageComponent } from './admin-view/notifications/outbox/message/mess
import { NotifDialogComponent } from './app-view/notif-dialog/notif-dialog.component';
import { UserSearchComponent } from './commonComponents/user-search/user-search.component';
import { StartAdminComponent } from './admin-view/start/start.component';
import { provideLuxonDateAdapter } from "@angular/material-luxon-adapter";
@NgModule({ declarations: [
AppComponent,
@@ -138,7 +137,9 @@ import { StartAdminComponent } from './admin-view/start/start.component';
UserSearchComponent,
StartAdminComponent,
],
bootstrap: [AppComponent], imports: [BrowserModule,
bootstrap: [AppComponent],
imports: [
BrowserModule,
AppRoutingModule,
BrowserAnimationsModule,
MatTabsModule,
@@ -146,7 +147,6 @@ import { StartAdminComponent } from './admin-view/start/start.component';
MatButtonModule,
MatIconModule,
MatDatepickerModule,
MatNativeDateModule,
MatInputModule,
ReactiveFormsModule,
FormsModule,
@@ -179,10 +179,7 @@ import { StartAdminComponent } from './admin-view/start/start.component';
// or after 30 seconds (whichever comes first).
registrationStrategy: 'registerWhenStable:30000'
})], providers: [
{ provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE, MAT_DATE_FORMATS, MAT_MOMENT_DATE_ADAPTER_OPTIONS] },
{ provide: MAT_DATE_LOCALE, useValue: "pl-PL" },
{ provide: MAT_DATE_FORMATS, useValue: MAT_MOMENT_DATE_FORMATS },
{ provide: MAT_MOMENT_DATE_ADAPTER_OPTIONS, useValue: { useUtc: true } },
provideLuxonDateAdapter(),
FDSelection,
provideHttpClient(withInterceptorsFromDi()),
] })

View File

@@ -1,5 +1,5 @@
<button mat-icon-button (click)="prevDay()"><mat-icon>chevron_left</mat-icon></button>
<p (click)="picker.open()">{{date.format('dddd, D.MM')}}</p>
<p (click)="picker.open()">{{_date_1.toFormat('cccc, d.LL') | titlecase }}</p>
<mat-form-field style="display: none;">
<input #dateinput matInput [matDatepicker]="picker" [formControl]="dateInput" [matDatepickerFilter]="filter">
<mat-datepicker touchUi #picker></mat-datepicker>

View File

@@ -1,6 +1,7 @@
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
import { FormControl } from '@angular/forms';
import moment from 'moment';
import { DateFilterFn } from '@angular/material/datepicker';
import { DateTime } from 'luxon';
@Component({
selector: 'app-date-selector',
@@ -9,40 +10,47 @@ import moment from 'moment';
standalone: false
})
export class DateSelectorComponent implements OnChanges {
@Input() date: moment.Moment = moment.utc().startOf('day');
@Output() dateChange = new EventEmitter<moment.Moment>();
@Input() filter: (date: moment.Moment | null) => boolean = () => true
protected dateInput: FormControl<moment.Moment>
protected _date_1: DateTime = DateTime.now();
protected set _date(value: DateTime) {
this._date_1 = value;
this.date = value.toISODate()!
}
@Input()
public set date(value: string) {
this._date_1 = DateTime.fromISO(value);
}
@Output() dateChange = new EventEmitter<string>();
@Input() filter: DateFilterFn<DateTime | null> = () => true
protected dateInput: FormControl<DateTime>
constructor () {
this.dateInput = new FormControl(this.date, {nonNullable: true});
this.dateInput = new FormControl(this._date_1, {nonNullable: true});
this.dateInput.valueChanges.subscribe((v) => {
v.utc(true).startOf('day')
this.dateChange.emit(v)
this.dateChange.emit(v.toISODate()!)
})
}
ngOnChanges(changes: SimpleChanges): void {
if (changes['date']) {
this.dateInput.setValue(this.date, {emitEvent: false})
this.dateInput.setValue(this._date_1), {emitEvent: false}
}
}
prevDay(): void {
let newDay = moment(this.date);
if (this.filter(newDay.add({days: -1}))) {
this.dateInput.setValue(this.date.add({days: -1}))
let yesterday = this._date_1.minus({day: 1})
if (this.filter(yesterday)) {
this.dateInput.setValue(yesterday)
} else {
this.dateInput.setValue(this.date.isoWeekday(-2))
this.dateInput.setValue(this._date.set({weekday: 5}).minus({week: 1}))
}
}
nextDay(): void {
let newDay = moment(this.date);
if (this.filter(newDay.add({days: 1}))) {
this.dateInput.setValue(this.date.add({days: 1}))
let tomorrow = this._date_1.plus({day: 1})
if (this.filter(tomorrow)) {
this.dateInput.setValue(tomorrow)
} else {
this.dateInput.setValue(this.date.isoWeekday(8))
this.dateInput.setValue(this._date.set({weekday: 1}).plus({week: 1}))
}
}
}

View File

@@ -1,28 +1,28 @@
import { Injectable } from "@angular/core";
import { DateRange, MatDateRangeSelectionStrategy } from "@angular/material/datepicker";
import moment from "moment";
import { DateFilterFn, DateRange, MatDateRangeSelectionStrategy } from "@angular/material/datepicker";
import { DateTime } from "luxon";
@Injectable()
export class FDSelection implements MatDateRangeSelectionStrategy<moment.Moment> {
selectionFinished(date: moment.Moment | null): DateRange<moment.Moment> {
export class FDSelection implements MatDateRangeSelectionStrategy<DateTime> {
selectionFinished(date: DateTime | null): DateRange<DateTime> {
return this._cr(date)
}
createPreview(activeDate: moment.Moment | null): DateRange<moment.Moment> {
createPreview(activeDate: DateTime | null): DateRange<DateTime> {
return this._cr(activeDate)
}
private _cr(date: moment.Moment | null) {
private _cr(date: DateTime | null) {
if (date) {
const start = moment(date).startOf('week')
const end = moment(date).isoWeekday(5).endOf('day')
return new DateRange<moment.Moment>(start, end)
const start = date.toUTC().startOf('week')
const end = date.toUTC().set({weekday: 5}).endOf('day')
return new DateRange<DateTime>(start, end)
}
return new DateRange<moment.Moment>(null, null)
return new DateRange<DateTime>(null, null)
}
}
export const weekendFilter = (date: moment.Moment | null): boolean => {
const day = date?.isoWeekday()
export const weekendFilter: DateFilterFn<DateTime | null> = (date: DateTime | null): boolean => {
const day = date?.weekday
return day !== 6 && day !== 7
}

View File

@@ -3,11 +3,10 @@ import { HttpClient } from '@angular/common/http'
import { Menu } from '../types/menu';
import { environment } from 'src/environments/environment';
import { News } from '../types/news';
import moment from 'moment';
import { map } from 'rxjs';
import { UKey } from '../types/key';
import { CleanNote } from '../types/clean-note';
import { Status } from '../types/status';
import { DateTime } from 'luxon';
@Injectable({
providedIn: 'root'
@@ -27,16 +26,16 @@ export class UpdatesService {
return this.http.get<{ hash: string; count: number; }>(environment.apiEndpoint+`/app/news/check`, {withCredentials: true})
}
getMenu(dom: moment.Moment) {
getMenu(dom: string) {
const headers = {
'Content-Type': 'application/json',
}
return this.http.get<Menu>(environment.apiEndpoint+`/app/menu/${dom.valueOf()}`, {headers: headers, withCredentials: true})
return this.http.get<Menu>(environment.apiEndpoint+`/app/menu/${dom}`, {headers: headers, withCredentials: true})
}
postVote(date: moment.Moment, type: "ob" | "kol", vote: "-" | "+" | "n") {
return this.http.post(environment.apiEndpoint+`/app/menu/${date.valueOf()}`, {
doc: moment().toISOString(true),
postVote(date: string, type: "ob" | "kol", vote: "-" | "+" | "n") {
return this.http.post(environment.apiEndpoint+`/app/menu/${date}`, {
doc: DateTime.now(),
tom: type,
vote: vote
}, {withCredentials: true})
@@ -53,12 +52,12 @@ export class UpdatesService {
return this.http.get<UKey[]>(environment.apiEndpoint+`/app/keys`, {withCredentials: true})
}
getClean(date: moment.Moment) {
return this.http.get<{grade: number, notes: CleanNote[], tips: string}>(environment.apiEndpoint+`/app/clean/${date.toISOString()}`, {withCredentials: true})
getClean(date: string) {
return this.http.get<{grade: number, notes: CleanNote[], tips: string}>(environment.apiEndpoint+`/app/clean/${date}`, {withCredentials: true})
}
getNotifCheck() {
return this.http.get<{_id: string, message: {title: string, body: string}, sentDate: moment.Moment}[]>(environment.apiEndpoint+`/app/notif/check`, {withCredentials: true})
return this.http.get<{_id: string, message: {title: string, body: string}, sentDate: string}[]>(environment.apiEndpoint+`/app/notif/check`, {withCredentials: true})
}
postInfoAck(id: string) {

View File

@@ -1,3 +1,5 @@
import { DateTime } from "luxon";
interface UKey {
room: string;
taken: boolean;
@@ -6,8 +8,8 @@ interface UKey {
interface AKey {
room: string;
whom?: {_id: string, uname: string, room: string};
borrow?: moment.Moment;
tb?: moment.Moment;
borrow: DateTime;
tb?: DateTime;
}
export { UKey, AKey }

View File

@@ -1,8 +1,8 @@
import { Moment } from "moment";
import { DateTime } from "luxon";
export interface Menu {
_id: string;
day: Moment;
day: DateTime;
sn: {
fancy: string[];
second: string;

View File

@@ -1,4 +1,4 @@
import { Moment } from "moment";
import { DateTime } from "luxon";
export default interface User {
_id: string;
@@ -10,6 +10,6 @@ export default interface User {
fname?: string;
surname?: string;
groups: string[];
regDate: Moment;
regDate: DateTime;
defaultPage?: string;
}

View File

@@ -1,5 +1,5 @@
export const environment = {
apiEndpoint: "http://localhost:12230",
apiEndpoint: `http://${window.location.hostname}:12230`,
version: "testing",
production: false
};

View File

@@ -3,7 +3,9 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
"types": [
"@angular/localize"
]
},
"files": [
"src/main.ts"