From af8481f348c3795a98be32cbc7da77f981902386 Mon Sep 17 00:00:00 2001 From: Pavel Date: Tue, 24 Oct 2023 20:11:46 +0200 Subject: [PATCH] #2406 move current value from 'Last visit' to 'Last study activity' field --- .../src/app/modules/admin/models/user.model.ts | 1 + .../admin/modules/users/users.component.html | 16 +++++++++++++++- .../admin/modules/users/users.component.spec.ts | 2 ++ .../admin/modules/users/users.component.ts | 1 + .../admin/services/api/admin-api.service.fake.ts | 4 +++- frontend-angular/src/assets/i18n/en.json | 1 + frontend-angular/src/assets/i18n/ru.json | 1 + .../kotlin/com/epam/brn/dto/UserAccountDto.kt | 1 - .../dto/response/UserWithAnalyticsResponse.kt | 4 ++++ .../kotlin/com/epam/brn/model/UserAccount.kt | 2 +- 10 files changed, 29 insertions(+), 4 deletions(-) diff --git a/frontend-angular/src/app/modules/admin/models/user.model.ts b/frontend-angular/src/app/modules/admin/models/user.model.ts index c8ac3b06d..d04e457d3 100644 --- a/frontend-angular/src/app/modules/admin/models/user.model.ts +++ b/frontend-angular/src/app/modules/admin/models/user.model.ts @@ -22,6 +22,7 @@ export interface User { spentTime: number; studyDaysInCurrentMonth: number; userId: string; + lastVisit: string; } export interface UserMapped extends User { diff --git a/frontend-angular/src/app/modules/admin/modules/users/users.component.html b/frontend-angular/src/app/modules/admin/modules/users/users.component.html index f11e3f54e..06568b1b6 100644 --- a/frontend-angular/src/app/modules/admin/modules/users/users.component.html +++ b/frontend-angular/src/app/modules/admin/modules/users/users.component.html @@ -87,13 +87,27 @@ - + {{ 'Admin.Modules.Users.Components.UsersTable.ColumnsName.LastVisit' | translate }} + +
+ {{ user.lastVisit | date: 'medium' }} +
+ +
+ + + + {{ + 'Admin.Modules.Users.Components.UsersTable.ColumnsName.LastStudyActivity' + | translate + }} +
{{ user.lastDone | date: 'medium' }} diff --git a/frontend-angular/src/app/modules/admin/modules/users/users.component.spec.ts b/frontend-angular/src/app/modules/admin/modules/users/users.component.spec.ts index 4043de75f..6dbe524a1 100644 --- a/frontend-angular/src/app/modules/admin/modules/users/users.component.spec.ts +++ b/frontend-angular/src/app/modules/admin/modules/users/users.component.spec.ts @@ -49,6 +49,7 @@ describe('UsersComponent', () => { active: true, firstDone: '2021-12-13T19:07:04.832', lastDone: '2021-12-15T19:07:04.832', + lastVisit: '2023-10-24T19:07:04.832', lastWeek: [], studyDaysInCurrentMonth: 1, diagnosticProgress: { @@ -70,6 +71,7 @@ describe('UsersComponent', () => { active: true, firstDone: '2021-12-17T19:07:04.832', lastDone: '2021-12-20T19:07:04.832', + lastVisit: '2023-10-24T19:07:04.832', lastWeek: [], studyDaysInCurrentMonth: 2, diagnosticProgress: { diff --git a/frontend-angular/src/app/modules/admin/modules/users/users.component.ts b/frontend-angular/src/app/modules/admin/modules/users/users.component.ts index 3e2eafdf1..47ee7993b 100644 --- a/frontend-angular/src/app/modules/admin/modules/users/users.component.ts +++ b/frontend-angular/src/app/modules/admin/modules/users/users.component.ts @@ -32,6 +32,7 @@ export class UsersComponent implements OnInit, OnDestroy { 'name', 'firstDone', 'lastDone', + 'lastVisit', 'currentWeek', 'spentTime', 'doneExercises', diff --git a/frontend-angular/src/app/modules/admin/services/api/admin-api.service.fake.ts b/frontend-angular/src/app/modules/admin/services/api/admin-api.service.fake.ts index fa9e720a4..dcc10d8b5 100644 --- a/frontend-angular/src/app/modules/admin/services/api/admin-api.service.fake.ts +++ b/frontend-angular/src/app/modules/admin/services/api/admin-api.service.fake.ts @@ -18,7 +18,7 @@ import { getRandomString } from '@shared/helpers/get-random-string'; export class AdminApiServiceFake implements Pick { + 'getUserWeeklyStatistics' | 'getUserYearlyStatistics' | 'getUsers' | 'getUserDailyDetailStatistics'> { private readonly options: IOptions = {}; constructor(o?: IOptions) { @@ -94,6 +94,7 @@ export class AdminApiServiceFake Date.now() - getRandomIntInclusive(0, 365 * 24 * 60 * 60 * 1000), ).toISOString(); const lastDone = dayjs(firstDone).add(1, 'month').toISOString(); + const lastVisit = dayjs(lastDone).add(1, 'day').toISOString(); const lastWeek: number[] = []; for (let dayNumber = 0; dayNumber < DAYS_IN_WEEK; dayNumber++) { @@ -126,6 +127,7 @@ export class AdminApiServiceFake userId: '1234', spentTime: 10, doneExercises: 2, + lastVisit, }); } diff --git a/frontend-angular/src/assets/i18n/en.json b/frontend-angular/src/assets/i18n/en.json index 75b6b44b3..dd79ed1d9 100644 --- a/frontend-angular/src/assets/i18n/en.json +++ b/frontend-angular/src/assets/i18n/en.json @@ -75,6 +75,7 @@ "Favorite": "Favorite", "FirstVisit": "First visit", "LastVisit": "Last visit", + "LastStudyActivity": "Last study activity", "CurrentWeek": "Current week", "Name": "Name", "Progress": "Progress", diff --git a/frontend-angular/src/assets/i18n/ru.json b/frontend-angular/src/assets/i18n/ru.json index 9359fb63c..24cae3309 100644 --- a/frontend-angular/src/assets/i18n/ru.json +++ b/frontend-angular/src/assets/i18n/ru.json @@ -75,6 +75,7 @@ "Favorite": "Любимый", "FirstVisit": "Первый визит", "LastVisit": "Последнее посещение", + "LastStudyActivity": "Последнее учебное занятие", "CurrentWeek": "Текущая неделя", "Name": "Имя", "Progress": "Прогресс", diff --git a/src/main/kotlin/com/epam/brn/dto/UserAccountDto.kt b/src/main/kotlin/com/epam/brn/dto/UserAccountDto.kt index 5e45f00b6..8d8ddc765 100644 --- a/src/main/kotlin/com/epam/brn/dto/UserAccountDto.kt +++ b/src/main/kotlin/com/epam/brn/dto/UserAccountDto.kt @@ -16,7 +16,6 @@ data class UserAccountDto( var active: Boolean = true, val created: LocalDateTime = LocalDateTime.now(ZoneOffset.UTC), val changed: LocalDateTime = LocalDateTime.now(ZoneOffset.UTC), - val lastVisit: LocalDateTime? = null, var avatar: String? = null, val photo: String? = null, val description: String? = null, diff --git a/src/main/kotlin/com/epam/brn/dto/response/UserWithAnalyticsResponse.kt b/src/main/kotlin/com/epam/brn/dto/response/UserWithAnalyticsResponse.kt index b80209bc5..85246b113 100644 --- a/src/main/kotlin/com/epam/brn/dto/response/UserWithAnalyticsResponse.kt +++ b/src/main/kotlin/com/epam/brn/dto/response/UserWithAnalyticsResponse.kt @@ -23,4 +23,8 @@ data class UserWithAnalyticsResponse( var diagnosticProgress: Map = mapOf(AudiometryType.SIGNALS to true), // todo fill by user var doneExercises: Int = 0, // for all time var spentTime: Duration = Duration.ZERO, // spent time by doing exercises for all time + /** + * Last visit to our site + */ + val lastVisit: LocalDateTime? = null, ) diff --git a/src/main/kotlin/com/epam/brn/model/UserAccount.kt b/src/main/kotlin/com/epam/brn/model/UserAccount.kt index 847434322..b1fc1a3ec 100644 --- a/src/main/kotlin/com/epam/brn/model/UserAccount.kt +++ b/src/main/kotlin/com/epam/brn/model/UserAccount.kt @@ -83,7 +83,6 @@ data class UserAccount( gender = gender?.let { BrnGender.valueOf(it) }, created = created, changed = changed, - lastVisit = lastVisit ?: created, avatar = avatar, photo = photo, description = description, @@ -105,6 +104,7 @@ data class UserAccount( email = email, bornYear = bornYear, gender = gender?.let { BrnGender.valueOf(it) }, + lastVisit = lastVisit ?: created, ) override fun equals(other: Any?): Boolean {