Skip to content

Commit

Permalink
Added a tag on the announcements screen that shows if you're on a nig…
Browse files Browse the repository at this point in the history
…htly when looking at the changelog.

Added changelog to System tab in case users don't know about Announcements page.
  • Loading branch information
majora2007 committed Feb 4, 2024
1 parent 4f486f0 commit 95b3cbd
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 45 deletions.
67 changes: 37 additions & 30 deletions UI/Web/src/app/admin/manage-system/manage-system.component.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<ng-container *transloco="let t; read: 'manage-system'">
<div class="container-fluid">
<h3>{{t('title')}}</h3>
<hr/>

<div class="mb-3" *ngIf="serverInfo">
<h3>{{t('title')}}</h3>
<dl>
<dt>{{t('version-title')}}</dt>
<dd>{{serverInfo.kavitaVersion}}</dd>
Expand All @@ -12,36 +12,43 @@ <h3>{{t('title')}}</h3>
</dl>
</div>

<h3>{{t('more-info-title')}}</h3>
<hr/>
<div class="row">
<div class="col-4">{{t('home-page-title')}}</div>
<div class="col"><a href="https://www.kavitareader.com" target="_blank" rel="noopener noreferrer">kavitareader.com</a></div>
</div>
<div class="row">
<div class="col-4">{{t('wiki-title')}}</div>
<div class="col"><a href="https://wiki.kavitareader.com" target="_blank" rel="noopener noreferrer">wiki.kavitareader.com</a></div>
</div>
<div class="row">
<div class="col-4">{{t('discord-title')}}</div>
<div class="col"><a href="https://discord.gg/b52wT37kt7" target="_blank" rel="noopener noreferrer">discord.gg/b52wT37kt7</a></div>
</div>
<div class="row">
<div class="col-4">{{t('donations-title')}}</div>
<div class="col"><a href="https://opencollective.com/kavita" target="_blank" rel="noopener noreferrer">opencollective.com/kavita</a></div>
<div class="mb-3">
<h3>{{t('more-info-title')}}</h3>
<div class="row">
<div class="col-4">{{t('home-page-title')}}</div>
<div class="col"><a href="https://www.kavitareader.com" target="_blank" rel="noopener noreferrer">kavitareader.com</a></div>
</div>
<div class="row">
<div class="col-4">{{t('wiki-title')}}</div>
<div class="col"><a href="https://wiki.kavitareader.com" target="_blank" rel="noopener noreferrer">wiki.kavitareader.com</a></div>
</div>
<div class="row">
<div class="col-4">{{t('discord-title')}}</div>
<div class="col"><a href="https://discord.gg/b52wT37kt7" target="_blank" rel="noopener noreferrer">discord.gg/b52wT37kt7</a></div>
</div>
<div class="row">
<div class="col-4">{{t('donations-title')}}</div>
<div class="col"><a href="https://opencollective.com/kavita" target="_blank" rel="noopener noreferrer">opencollective.com/kavita</a></div>
</div>
<div class="row">
<div class="col-4">{{t('source-title')}}</div>
<div class="col"><a href="https://github.com/Kareadita/Kavita" target="_blank" rel="noopener noreferrer">github.com/Kareadita/Kavita</a></div>
</div>
<div class="row">
<div class="col-4">{{t('localization-title')}}</div>
<div class="col"><a href="https://hosted.weblate.org/engage/kavita/" target="_blank" rel="noopener noreferrer">Weblate</a><br/></div>
</div>
<div class="row">
<div class="col-4">{{t('feature-request-title')}}</div>
<div class="col"><a href="https://github.com/Kareadita/Kavita/discussions/2529" target="_blank" rel="noopener noreferrer">https://github.com/Kareadita/Kavita/discussions/</a><br/></div>
</div>
</div>
<div class="row">
<div class="col-4">{{t('source-title')}}</div>
<div class="col"><a href="https://github.com/Kareadita/Kavita" target="_blank" rel="noopener noreferrer">github.com/Kareadita/Kavita</a></div>
</div>
<div class="row">
<div class="col-4">{{t('localization-title')}}</div>
<div class="col"><a href="https://hosted.weblate.org/engage/kavita/" target="_blank" rel="noopener noreferrer">Weblate</a><br/></div>
</div>
<div class="row">
<div class="col-4">{{t('feature-request-title')}}</div>
<div class="col"><a href="https://github.com/Kareadita/Kavita/discussions/2529" target="_blank" rel="noopener noreferrer">https://github.com/Kareadita/Kavita/discussions/</a><br/></div>

<div class="mb-3">
<h3>{{t('updates-title')}}</h3>
<app-changelog></app-changelog>
</div>

</div>

</ng-container>
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ 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',
templateUrl: './manage-system.component.html',
styleUrls: ['./manage-system.component.scss'],
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NgIf, TranslocoDirective]
imports: [NgIf, TranslocoDirective, ChangelogComponent]
})
export class ManageSystemComponent implements OnInit {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<div class="card w-100 mb-2" style="width: 18rem;">
<div class="card-body">
<h4 class="card-title">{{update.updateTitle}}&nbsp;
<span class="badge bg-secondary" *ngIf="isNightly(update)">{{t('nightly', {version: update.currentVersion})}}</span>
<span class="badge bg-secondary" *ngIf="update.updateVersion === update.currentVersion">{{t('installed')}}</span>
<span class="badge bg-secondary" *ngIf="update.updateVersion > update.currentVersion">{{t('available')}}</span>
</h4>
Expand Down
Original file line number Diff line number Diff line change
@@ -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<UpdateVersionEvent> = [];
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;
}
}
4 changes: 3 additions & 1 deletion UI/Web/src/assets/langs/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}}",
Expand Down Expand Up @@ -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": {
Expand Down

0 comments on commit 95b3cbd

Please sign in to comment.