From 95b3cbdf1859df77943f9b73d2a02fdb5140a61e Mon Sep 17 00:00:00 2001 From: Joseph Milazzo Date: Sun, 4 Feb 2024 10:26:58 -0600 Subject: [PATCH] Added a tag on the announcements screen that shows if you're on a nightly when looking at the changelog. Added changelog to System tab in case users don't know about Announcements page. --- .../manage-system.component.html | 67 ++++++++++--------- .../manage-system/manage-system.component.ts | 3 +- .../changelog/changelog.component.html | 1 + .../changelog/changelog.component.ts | 52 ++++++++++---- UI/Web/src/assets/langs/en.json | 4 +- 5 files changed, 82 insertions(+), 45 deletions(-) diff --git a/UI/Web/src/app/admin/manage-system/manage-system.component.html b/UI/Web/src/app/admin/manage-system/manage-system.component.html index d45c6414a4..34583edb71 100644 --- a/UI/Web/src/app/admin/manage-system/manage-system.component.html +++ b/UI/Web/src/app/admin/manage-system/manage-system.component.html @@ -1,8 +1,8 @@
-

{{t('title')}}

-
+
+

{{t('title')}}

{{t('version-title')}}
{{serverInfo.kavitaVersion}}
@@ -12,36 +12,43 @@

{{t('title')}}

-

{{t('more-info-title')}}

-
-
-
{{t('home-page-title')}}
- -
-
-
{{t('wiki-title')}}
- -
-
-
{{t('discord-title')}}
- -
-
-
{{t('donations-title')}}
- +
+

{{t('more-info-title')}}

+
+
{{t('home-page-title')}}
+ +
+
+
{{t('wiki-title')}}
+ +
+
+
{{t('discord-title')}}
+ +
+
+
{{t('donations-title')}}
+ +
+
+
{{t('source-title')}}
+ +
+
+
{{t('localization-title')}}
+ +
+
+
{{t('feature-request-title')}}
+ +
-
-
{{t('source-title')}}
- -
-
-
{{t('localization-title')}}
- -
-
-
{{t('feature-request-title')}}
- + +
+

{{t('updates-title')}}

+
+
diff --git a/UI/Web/src/app/admin/manage-system/manage-system.component.ts b/UI/Web/src/app/admin/manage-system/manage-system.component.ts index 4e6467ce98..5d8976e3bb 100644 --- a/UI/Web/src/app/admin/manage-system/manage-system.component.ts +++ b/UI/Web/src/app/admin/manage-system/manage-system.component.ts @@ -3,6 +3,7 @@ import {ServerService} from 'src/app/_services/server.service'; import {ServerInfoSlim} from '../_models/server-info'; import {NgIf} from '@angular/common'; import {TranslocoDirective} from "@ngneat/transloco"; +import {ChangelogComponent} from "../../announcements/_components/changelog/changelog.component"; @Component({ selector: 'app-manage-system', @@ -10,7 +11,7 @@ import {TranslocoDirective} from "@ngneat/transloco"; styleUrls: ['./manage-system.component.scss'], standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, - imports: [NgIf, TranslocoDirective] + imports: [NgIf, TranslocoDirective, ChangelogComponent] }) export class ManageSystemComponent implements OnInit { diff --git a/UI/Web/src/app/announcements/_components/changelog/changelog.component.html b/UI/Web/src/app/announcements/_components/changelog/changelog.component.html index c63e810469..d5ea64ff31 100644 --- a/UI/Web/src/app/announcements/_components/changelog/changelog.component.html +++ b/UI/Web/src/app/announcements/_components/changelog/changelog.component.html @@ -9,6 +9,7 @@

{{update.updateTitle}}  + {{t('nightly', {version: update.currentVersion})}} {{t('installed')}} {{t('available')}}

diff --git a/UI/Web/src/app/announcements/_components/changelog/changelog.component.ts b/UI/Web/src/app/announcements/_components/changelog/changelog.component.ts index 0ae467ebb2..2be9caa0fe 100644 --- a/UI/Web/src/app/announcements/_components/changelog/changelog.component.ts +++ b/UI/Web/src/app/announcements/_components/changelog/changelog.component.ts @@ -1,29 +1,55 @@ -import { Component, OnInit } from '@angular/core'; -import { UpdateVersionEvent } from 'src/app/_models/events/update-version-event'; -import { ServerService } from 'src/app/_services/server.service'; -import { LoadingComponent } from '../../../shared/loading/loading.component'; -import { ReadMoreComponent } from '../../../shared/read-more/read-more.component'; -import { NgFor, NgIf, DatePipe } from '@angular/common'; +import {ChangeDetectionStrategy, ChangeDetectorRef, Component, inject, OnInit} from '@angular/core'; +import {UpdateVersionEvent} from 'src/app/_models/events/update-version-event'; +import {ServerService} from 'src/app/_services/server.service'; +import {LoadingComponent} from '../../../shared/loading/loading.component'; +import {ReadMoreComponent} from '../../../shared/read-more/read-more.component'; +import {DatePipe, NgFor, NgIf} from '@angular/common'; import {TranslocoDirective} from "@ngneat/transloco"; @Component({ - selector: 'app-changelog', - templateUrl: './changelog.component.html', - styleUrls: ['./changelog.component.scss'], - standalone: true, - imports: [NgFor, NgIf, ReadMoreComponent, LoadingComponent, DatePipe, TranslocoDirective] + selector: 'app-changelog', + templateUrl: './changelog.component.html', + styleUrls: ['./changelog.component.scss'], + standalone: true, + imports: [NgFor, NgIf, ReadMoreComponent, LoadingComponent, DatePipe, TranslocoDirective], + changeDetection: ChangeDetectionStrategy.OnPush }) export class ChangelogComponent implements OnInit { + private readonly serverService = inject(ServerService); + private readonly cdRef = inject(ChangeDetectorRef); updates: Array = []; isLoading: boolean = true; - constructor(private serverService: ServerService) { } - ngOnInit(): void { this.serverService.getChangelog().subscribe(updates => { this.updates = updates; this.isLoading = false; + this.cdRef.markForCheck(); }); } + + isNightly(update: UpdateVersionEvent) { + // Split the version numbers into arrays + const updateVersionArr = update.updateVersion.split('.'); + const currentVersionArr = update.currentVersion.split('.'); + + // Compare the first three parts of the version numbers + for (let i = 0; i < 3; i++) { + const updatePart = parseInt(updateVersionArr[i]); + const currentPart = parseInt(currentVersionArr[i]); + + // If any part of the update version is less than the corresponding part of the current version, return true + if (updatePart < currentPart) { + return true; + } + // If any part of the update version is greater than the corresponding part of the current version, return false + else if (updatePart > currentPart) { + return false; + } + } + + // If all parts are equal, compare the length of the version numbers + return updateVersionArr.length < currentVersionArr.length; + } } diff --git a/UI/Web/src/assets/langs/en.json b/UI/Web/src/assets/langs/en.json index 8473320b04..5ef83ab298 100644 --- a/UI/Web/src/assets/langs/en.json +++ b/UI/Web/src/assets/langs/en.json @@ -559,6 +559,7 @@ "changelog": { "installed": "Installed", "download": "Download", + "nightly": "Nightly: {{version}}", "published-label": "Published: ", "available": "Available", "description": "If you do not see an {{installed}}", @@ -1231,7 +1232,8 @@ "donations-title": "Donations:", "source-title": "Source:", "feature-request-title": "Feature Requests:", - "localization-title": "Localizations:" + "localization-title": "Localizations:", + "updates-title": "Update History" }, "manage-tasks-settings": {