From f655ae991676548e479b3510bf03548c86609b27 Mon Sep 17 00:00:00 2001 From: Max Stephan Date: Thu, 28 Oct 2021 16:43:29 +0200 Subject: [PATCH 01/24] [web-gui] install date-fns --- web-gui/package-lock.json | 46 ++++++++------------------------------- web-gui/package.json | 1 + 2 files changed, 10 insertions(+), 37 deletions(-) diff --git a/web-gui/package-lock.json b/web-gui/package-lock.json index 4b235ad..15d9ca0 100644 --- a/web-gui/package-lock.json +++ b/web-gui/package-lock.json @@ -4194,6 +4194,11 @@ "assert-plus": "^1.0.0" } }, + "date-fns": { + "version": "2.25.0", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.25.0.tgz", + "integrity": "sha512-ovYRFnTrbGPD4nqaEqescPEv1mNwvt+UTqI3Ay9SzNtey9NZnYu6E2qCcBBgJ6/2VF1zGGygpyTDITqpQQ5e+w==" + }, "debug": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", @@ -12657,45 +12662,12 @@ "dev": true }, "wide-align": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", - "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz", + "integrity": "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==", "dev": true, "requires": { - "string-width": "^1.0.2 || 2" - }, - "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "^3.0.0" - } - } + "string-width": "^1.0.2 || 2 || 3 || 4" } }, "wildcard": { diff --git a/web-gui/package.json b/web-gui/package.json index 4519a1e..8d55ff7 100644 --- a/web-gui/package.json +++ b/web-gui/package.json @@ -25,6 +25,7 @@ "@angular/router": "^12.2.8", "@auth0/angular-jwt": "^5.0.2", "angular2-click-outside": "^0.1.0", + "date-fns": "^2.25.0", "howler": "^2.2.3", "ngx-avatar": "^4.1.0", "rsocket-core": "0.0.27", From 3f8703e0fb17623f758048a7acc9c21bd566b8ee Mon Sep 17 00:00:00 2001 From: Max Stephan Date: Thu, 28 Oct 2021 16:45:30 +0200 Subject: [PATCH 02/24] [time-formatter] use date-fns functions --- .../src/app/util/time-formatter.service.ts | 99 ++++++------------- 1 file changed, 32 insertions(+), 67 deletions(-) diff --git a/web-gui/src/app/util/time-formatter.service.ts b/web-gui/src/app/util/time-formatter.service.ts index 3cc6702..5cbc42a 100644 --- a/web-gui/src/app/util/time-formatter.service.ts +++ b/web-gui/src/app/util/time-formatter.service.ts @@ -1,85 +1,50 @@ -/** - * Quelle: https://muffinman.io/blog/javascript-time-ago-function/ - */ - import { Injectable } from '@angular/core'; +import { formatDistanceToNowStrict, formatRelative } from 'date-fns'; +import { de } from 'date-fns/locale'; @Injectable({ - providedIn: 'root' + providedIn: 'root', }) export class TimeFormatterService { + private formatDistanceLocale: any = { + xSeconds: { one: 'gerade eben', other: 'gerade eben' }, + xMinutes: { one: 'vor {{count}} Minute', other: 'vor {{count}} Minuten' }, + }; - constructor() { } + private formatRelativeLocal: any = { + today: "'heute um' p", + yesterday: "'gestern um' p", + lastWeek: "dd. MMM 'um' p", + other: "dd. MMM 'um' p", + }; - private months: string[] = [ - 'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', - 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember' - ]; + private formatDistance = (token: any, count: number) => { + if (!Object.keys(this.formatDistanceLocale).includes(token)) return ''; - // @ts-ignore - private getFormattedDate(date, prefomattedDate: string = undefined, hideYear = false) { - const day = date.getDate(); - const month = this.months[date.getMonth()]; - const year = date.getFullYear(); - const hours = date.getHours(); - let minutes = date.getMinutes(); + const res = this.formatDistanceLocale[token as any]; - if (minutes < 10) { - // Adding leading zero to minutes - minutes = `0${ minutes }`; + if (count === 1) { + return res.one.replace('{{count}}', count); } - if (prefomattedDate) { - // Today at 10:20 - // Yesterday at 10:20 - return `${ prefomattedDate } um ${ hours }:${ minutes }`; - } + return res.other.replace('{{count}}', count); + }; - if (hideYear) { - // 10. January at 10:20 - return `${ day }. ${ month } um ${ hours }:${ minutes }`; - } + private locale = { + ...de, + formatRelative: (token: any) => this.formatRelativeLocal[token], + formatDistance: this.formatDistance, + }; - // 10. January 2017. at 10:20 - return `${ day }. ${ month } ${ year }. um ${ hours }:${ minutes }`; - } + public timeAgo(dateParam: number): string { + const date = new Date(dateParam); + const timeAgo = formatDistanceToNowStrict(date, { + locale: { ...de, formatDistance: this.formatDistance }, + }); -// --- Main function -// @ts-ignore - public timeAgo(dateParam): string { - if (!dateParam) { - // @ts-ignore - return null; - } - - const date = typeof dateParam === 'object' ? dateParam : new Date(dateParam); - const DAY_IN_MS = 86400000; // 24 * 60 * 60 * 1000 - const today: number = Date.now() - const yesterday = new Date(today - DAY_IN_MS); - const seconds = Math.round((today - date) / 1000); - const minutes = Math.round(seconds / 60); - const isToday = new Date(today).toDateString() === date.toDateString(); - const isYesterday = yesterday.toDateString() === date.toDateString(); - const isThisYear = new Date(today).getFullYear() === date.getFullYear(); - - - if (seconds < 30) { - return 'gerade eben'; - //} else if (seconds < 30) { - // return `vor ${ seconds } Sek.`; - } else if (seconds < 90) { - return 'vor 1 Minute'; - } else if (minutes < 60) { - return `vor ${ minutes } Minuten`; - } else if (isToday) { - return this.getFormattedDate(date, 'Heute'); // Today at 10:20 - } else if (isYesterday) { - return this.getFormattedDate(date, 'Gestern'); // Yesterday at 10:20 - } else if (isThisYear) { - return this.getFormattedDate(date, undefined, true); // 10. January at 10:20 - } + if (timeAgo) return timeAgo; - return this.getFormattedDate(date); // 10. January 2017. at 10:20 + return formatRelative(date, new Date(), { locale: this.locale }); } } From 01255451939c1f44f764f36825391340ca86922d Mon Sep 17 00:00:00 2001 From: Max Stephan Date: Thu, 28 Oct 2021 17:18:25 +0200 Subject: [PATCH 03/24] [time-formatter] added some docstrings --- web-gui/src/app/util/time-formatter.service.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/web-gui/src/app/util/time-formatter.service.ts b/web-gui/src/app/util/time-formatter.service.ts index 5cbc42a..22f4a6b 100644 --- a/web-gui/src/app/util/time-formatter.service.ts +++ b/web-gui/src/app/util/time-formatter.service.ts @@ -15,9 +15,13 @@ export class TimeFormatterService { today: "'heute um' p", yesterday: "'gestern um' p", lastWeek: "dd. MMM 'um' p", - other: "dd. MMM 'um' p", + other: "dd. MMM y 'um' p", }; + /** + * Custom formatDistance function that + * returns a string only if the distance is less than one hour + */ private formatDistance = (token: any, count: number) => { if (!Object.keys(this.formatDistanceLocale).includes(token)) return ''; @@ -36,6 +40,16 @@ export class TimeFormatterService { formatDistance: this.formatDistance, }; + /** + * Calculates the elapsed time since the given date, and formats it as follows: + * + * - < 1 min = gerade eben + * - < 1 h = ${minutes} Minuten + * - today = heute um ${hh:mm} + * - yesterday = gestern um ${hh:mm} + * - last Week = ${dd. MM} um ${hh:mm} + * - other = ${dd. MM y} um ${hh:mm} + */ public timeAgo(dateParam: number): string { const date = new Date(dateParam); From 8ed129db046dca0fc47c776615c6e40b3d5b992c Mon Sep 17 00:00:00 2001 From: Max Stephan Date: Thu, 28 Oct 2021 17:19:04 +0200 Subject: [PATCH 04/24] [angular.json] increase production budget --- web-gui/angular.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web-gui/angular.json b/web-gui/angular.json index 3f6b125..d3ceba9 100644 --- a/web-gui/angular.json +++ b/web-gui/angular.json @@ -47,8 +47,8 @@ "budgets": [ { "type": "initial", - "maximumWarning": "10024kb", - "maximumError": "1mb" + "maximumWarning": "15024kb", + "maximumError": "1.5mb" }, { "type": "anyComponentStyle", From 658f2357c6624117a1cfecdb2e27ee2a470b7683 Mon Sep 17 00:00:00 2001 From: Max Stephan Date: Thu, 28 Oct 2021 17:19:29 +0200 Subject: [PATCH 05/24] [ticket-user-display] fix overflow for long names --- .../ticket-user-display/ticket-user-display.component.scss | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket-user-display/ticket-user-display.component.scss b/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket-user-display/ticket-user-display.component.scss index 9c71898..171bb40 100644 --- a/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket-user-display/ticket-user-display.component.scss +++ b/web-gui/src/app/page-components/classroom/ticket-list/ticket/ticket-user-display/ticket-user-display.component.scss @@ -4,7 +4,7 @@ align-items: center; min-width: 132px; max-width: 200px; - height: 38px; + min-height: 38px; .user-avatar { height: 32px; margin-right: 5px; @@ -15,11 +15,12 @@ align-items: baseline; .label { text-align: left; - color: #B1B1B1; + color: #b1b1b1; font-size: 14px; } .user-name { font-size: 16.4px; + word-wrap: break-word; } } } From 89e389d1d9f6ca026c7c774ec82c0b386e1e45af Mon Sep 17 00:00:00 2001 From: Max Stephan Date: Thu, 28 Oct 2021 18:15:14 +0200 Subject: [PATCH 06/24] [dropdown-menu] style improvements --- .../dropdown-menu.component.html | 8 ++++---- .../dropdown-menu.component.scss | 18 +++++++++++++---- .../menu-bar/menu-bar.component.html | 20 ++++++++++++------- .../menu-bar/menu-bar.component.scss | 12 +++++------ 4 files changed, 37 insertions(+), 21 deletions(-) diff --git a/web-gui/src/app/page-components/menu-bar/dropdown-menu/dropdown-menu.component.html b/web-gui/src/app/page-components/menu-bar/dropdown-menu/dropdown-menu.component.html index 72dff78..94dc42d 100644 --- a/web-gui/src/app/page-components/menu-bar/dropdown-menu/dropdown-menu.component.html +++ b/web-gui/src/app/page-components/menu-bar/dropdown-menu/dropdown-menu.component.html @@ -1,6 +1,6 @@ diff --git a/web-gui/src/app/page-components/menu-bar/dropdown-menu/dropdown-menu.component.scss b/web-gui/src/app/page-components/menu-bar/dropdown-menu/dropdown-menu.component.scss index 48f0d11..55da976 100644 --- a/web-gui/src/app/page-components/menu-bar/dropdown-menu/dropdown-menu.component.scss +++ b/web-gui/src/app/page-components/menu-bar/dropdown-menu/dropdown-menu.component.scss @@ -1,8 +1,8 @@ .menu-bubble { position: absolute; background: white; - border-radius: .4em; - border: 1px solid #B1B1B1; + border-radius: 0.4em; + border: 1px solid #b1b1b1; display: flex; flex-flow: column nowrap; @@ -12,15 +12,25 @@ } .menu-bubble:after { - content: ''; + content: ""; position: absolute; top: 0; left: 85%; width: 0; height: 0; border: 0.5em solid transparent; - border-bottom-color: #B1B1B1; + border-bottom-color: #b1b1b1; border-top: 0; margin-left: -0.4em; margin-top: -0.5em; } + +.menu-text { + line-height: 24px; + margin-left: 5px; +} + +.menu-item { + display: flex; + cursor: pointer; +} diff --git a/web-gui/src/app/page-components/menu-bar/menu-bar.component.html b/web-gui/src/app/page-components/menu-bar/menu-bar.component.html index 74f6ec8..daa2828 100644 --- a/web-gui/src/app/page-components/menu-bar/menu-bar.component.html +++ b/web-gui/src/app/page-components/menu-bar/menu-bar.component.html @@ -1,17 +1,21 @@ - diff --git a/web-gui/src/app/page-components/menu-bar/menu-bar.component.scss b/web-gui/src/app/page-components/menu-bar/menu-bar.component.scss index 6c68b81..2d438e6 100644 --- a/web-gui/src/app/page-components/menu-bar/menu-bar.component.scss +++ b/web-gui/src/app/page-components/menu-bar/menu-bar.component.scss @@ -3,21 +3,30 @@ .menu-bar { background-color: transparent; box-sizing: border-box; - height: 5%; - display: flex; - flex-flow: row nowrap; - justify-content: space-between; + min-height: 42px; align-items: center; padding: 5px 5px; box-shadow: none; + display: grid; + grid-auto-flow: column; + grid-template-columns: 1fr repeat(2, max-content); + position: relative; .menu-bar-section { + margin: 0 5px 0 5px; display: flex; flex-flow: row nowrap; align-items: center; - justify-content: space-evenly; - margin: 0 5px 0 5px; - cursor: pointer; + } + + .room-label { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100vh; + justify-content: center; } .user-info { @@ -25,6 +34,12 @@ flex-flow: row nowrap; align-items: center; } + + .menu-leave { + cursor: pointer; + color: #f35656; + margin-top: 4px; + } } .room-name { diff --git a/web-gui/src/app/page-components/menu-bar/menu-bar.component.ts b/web-gui/src/app/page-components/menu-bar/menu-bar.component.ts index 4de794a..7e5c2a5 100644 --- a/web-gui/src/app/page-components/menu-bar/menu-bar.component.ts +++ b/web-gui/src/app/page-components/menu-bar/menu-bar.component.ts @@ -1,30 +1,24 @@ -import {Component, Input} from '@angular/core'; -import {parseCourseRole, User} from 'src/app/model/User'; -import {ClassroomService} from "../../service/classroom.service"; -import {ConferenceService} from "../../service/conference.service"; -import {ClassroomInfo} from "../../model/ClassroomInfo"; -import {UserIconService} from "../../util/user-icon.service"; +import { Component, Input, ViewChild } from '@angular/core'; +import { parseCourseRole, User } from 'src/app/model/User'; +import { ClassroomService } from '../../service/classroom.service'; +import { ConferenceService } from '../../service/conference.service'; +import { ClassroomInfo } from '../../model/ClassroomInfo'; +import { UserIconService } from '../../util/user-icon.service'; +import { DropdownMenuComponent } from './dropdown-menu/dropdown-menu.component'; @Component({ selector: 'app-menu-bar', templateUrl: './menu-bar.component.html', - styleUrls: ['./menu-bar.component.scss'] + styleUrls: ['./menu-bar.component.scss'], }) export class MenuBarComponent { - - public parseCourseRole: Function = parseCourseRole - @Input() public currentUser: User | undefined - @Input() public classroomInfo: ClassroomInfo | undefined - menuVisible: boolean = false; + public parseCourseRole: Function = parseCourseRole; + @Input() public currentUser: User | undefined; + @Input() public classroomInfo: ClassroomInfo | undefined; constructor( public classroomService: ClassroomService, public conferenceService: ConferenceService, public userIconService: UserIconService ) {} - - toggleMenu() { - this.menuVisible = !this.menuVisible; - } - } From 15798a7666a582fb57c00a52e80e3de27d94cbb0 Mon Sep 17 00:00:00 2001 From: Max Stephan Date: Thu, 28 Oct 2021 20:01:22 +0200 Subject: [PATCH 08/24] [menu-bar] show icon based on user role --- .../app/page-components/menu-bar/menu-bar.component.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web-gui/src/app/page-components/menu-bar/menu-bar.component.html b/web-gui/src/app/page-components/menu-bar/menu-bar.component.html index d08a9f8..d357dc9 100644 --- a/web-gui/src/app/page-components/menu-bar/menu-bar.component.html +++ b/web-gui/src/app/page-components/menu-bar/menu-bar.component.html @@ -1,6 +1,10 @@