mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-06-23 15:30:34 -04:00
Changed the fingerprinting code for Kavita+. Optimized System tab to be way faster. (#2140)
This commit is contained in:
parent
43cc771838
commit
5f505eaf6d
@ -124,6 +124,17 @@ public class ServerController : BaseApiController
|
|||||||
return Ok(await _statsService.GetServerInfo());
|
return Ok(await _statsService.GetServerInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns non-sensitive information about the current system
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>This is just for the UI and is extremly lightweight</remarks>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("server-info-slim")]
|
||||||
|
public async Task<ActionResult<ServerInfoDto>> GetSlimVersion()
|
||||||
|
{
|
||||||
|
return Ok(await _statsService.GetServerInfoSlim());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Triggers the scheduling of the convert media job. This will convert all media to the target encoding (except for PNG). Only one job will run at a time.
|
/// Triggers the scheduling of the convert media job. This will convert all media to the target encoding (except for PNG). Only one job will run at a time.
|
||||||
|
21
API/DTOs/Stats/ServerInfoSlimDto.cs
Normal file
21
API/DTOs/Stats/ServerInfoSlimDto.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
namespace API.DTOs.Stats;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This is just for the Server tab on UI
|
||||||
|
/// </summary>
|
||||||
|
public class ServerInfoSlimDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Unique Id that represents a unique install
|
||||||
|
/// </summary>
|
||||||
|
public required string InstallId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// If the Kavita install is using Docker
|
||||||
|
/// </summary>
|
||||||
|
public bool IsDocker { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Version of Kavita
|
||||||
|
/// </summary>
|
||||||
|
public required string KavitaVersion { get; set; }
|
||||||
|
|
||||||
|
}
|
@ -23,6 +23,7 @@ public interface IStatsService
|
|||||||
{
|
{
|
||||||
Task Send();
|
Task Send();
|
||||||
Task<ServerInfoDto> GetServerInfo();
|
Task<ServerInfoDto> GetServerInfo();
|
||||||
|
Task<ServerInfoSlimDto> GetServerInfoSlim();
|
||||||
Task SendCancellation();
|
Task SendCancellation();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -171,6 +172,17 @@ public class StatsService : IStatsService
|
|||||||
return serverInfo;
|
return serverInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<ServerInfoSlimDto> GetServerInfoSlim()
|
||||||
|
{
|
||||||
|
var serverSettings = await _unitOfWork.SettingsRepository.GetSettingsDtoAsync();
|
||||||
|
return new ServerInfoSlimDto()
|
||||||
|
{
|
||||||
|
InstallId = serverSettings.InstallId,
|
||||||
|
KavitaVersion = serverSettings.InstallVersion,
|
||||||
|
IsDocker = OsInfo.IsDocker
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public async Task SendCancellation()
|
public async Task SendCancellation()
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Informing KavitaStats that this instance is no longer sending stats");
|
_logger.LogInformation("Informing KavitaStats that this instance is no longer sending stats");
|
||||||
|
@ -45,28 +45,7 @@ public static class HashUtil
|
|||||||
|
|
||||||
public static string ServerToken()
|
public static string ServerToken()
|
||||||
{
|
{
|
||||||
var seed = new DeviceIdBuilder()
|
return AnonymousToken();
|
||||||
.AddMacAddress()
|
|
||||||
.AddUserName()
|
|
||||||
.AddComponent("ProcessorCount", new DeviceIdComponent($"{Environment.ProcessorCount}"))
|
|
||||||
.AddComponent("OSPlatform", new DeviceIdComponent($"{Environment.OSVersion.Platform}"))
|
|
||||||
.OnWindows(windows => windows
|
|
||||||
.AddProcessorId())
|
|
||||||
.OnLinux(linux =>
|
|
||||||
{
|
|
||||||
var osInfo = RunAndCapture("uname", "-a");
|
|
||||||
if (Regex.IsMatch(osInfo, @"\bUnraid\b"))
|
|
||||||
{
|
|
||||||
var cpuModel = RunAndCapture("lscpu", string.Empty);
|
|
||||||
var match = Regex.Match(cpuModel, @"Model name:\s+(.+)");
|
|
||||||
linux.AddComponent("CPUModel", new DeviceIdComponent($"{match.Groups[1].Value.Trim()}"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
linux.AddMotherboardSerialNumber();
|
|
||||||
})
|
|
||||||
.OnMac(mac => mac.AddSystemDriveSerialNumber())
|
|
||||||
.ToString();
|
|
||||||
return CalculateCrc(seed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { environment } from 'src/environments/environment';
|
import { environment } from 'src/environments/environment';
|
||||||
import { ServerInfo } from '../admin/_models/server-info';
|
import {ServerInfoSlim} from '../admin/_models/server-info';
|
||||||
import { UpdateVersionEvent } from '../_models/events/update-version-event';
|
import { UpdateVersionEvent } from '../_models/events/update-version-event';
|
||||||
import { Job } from '../_models/job/job';
|
import { Job } from '../_models/job/job';
|
||||||
import { KavitaMediaError } from '../admin/_models/media-error';
|
import { KavitaMediaError } from '../admin/_models/media-error';
|
||||||
@ -17,7 +17,7 @@ export class ServerService {
|
|||||||
|
|
||||||
|
|
||||||
getServerInfo() {
|
getServerInfo() {
|
||||||
return this.httpClient.get<ServerInfo>(this.baseUrl + 'server/server-info');
|
return this.httpClient.get<ServerInfoSlim>(this.baseUrl + 'server/server-info-slim');
|
||||||
}
|
}
|
||||||
|
|
||||||
clearCache() {
|
clearCache() {
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
export interface ServerInfo {
|
export interface ServerInfoSlim {
|
||||||
os: string;
|
|
||||||
dotnetVersion: string;
|
|
||||||
runTimeVersion: string;
|
|
||||||
kavitaVersion: string;
|
kavitaVersion: string;
|
||||||
NumOfCores: number;
|
|
||||||
installId: string;
|
installId: string;
|
||||||
isDocker: boolean;
|
isDocker: boolean;
|
||||||
}
|
}
|
@ -4,7 +4,7 @@ import { ToastrService } from 'ngx-toastr';
|
|||||||
import { take } from 'rxjs/operators';
|
import { take } from 'rxjs/operators';
|
||||||
import { ServerService } from 'src/app/_services/server.service';
|
import { ServerService } from 'src/app/_services/server.service';
|
||||||
import { SettingsService } from '../settings.service';
|
import { SettingsService } from '../settings.service';
|
||||||
import { ServerInfo } from '../_models/server-info';
|
import {ServerInfoSlim} from '../_models/server-info';
|
||||||
import { ServerSettings } from '../_models/server-settings';
|
import { ServerSettings } from '../_models/server-settings';
|
||||||
import { NgIf } from '@angular/common';
|
import { NgIf } from '@angular/common';
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ export class ManageSystemComponent implements OnInit {
|
|||||||
|
|
||||||
settingsForm: FormGroup = new FormGroup({});
|
settingsForm: FormGroup = new FormGroup({});
|
||||||
serverSettings!: ServerSettings;
|
serverSettings!: ServerSettings;
|
||||||
serverInfo!: ServerInfo;
|
serverInfo!: ServerInfoSlim;
|
||||||
|
|
||||||
|
|
||||||
constructor(private settingsService: SettingsService, private toastr: ToastrService,
|
constructor(private settingsService: SettingsService, private toastr: ToastrService,
|
||||||
|
33
openapi.json
33
openapi.json
@ -7,7 +7,7 @@
|
|||||||
"name": "GPL-3.0",
|
"name": "GPL-3.0",
|
||||||
"url": "https://github.com/Kareadita/Kavita/blob/develop/LICENSE"
|
"url": "https://github.com/Kareadita/Kavita/blob/develop/LICENSE"
|
||||||
},
|
},
|
||||||
"version": "0.7.4.4"
|
"version": "0.7.4.5"
|
||||||
},
|
},
|
||||||
"servers": [
|
"servers": [
|
||||||
{
|
{
|
||||||
@ -8384,6 +8384,37 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/api/Server/server-info-slim": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"Server"
|
||||||
|
],
|
||||||
|
"summary": "Returns non-sensitive information about the current system",
|
||||||
|
"description": "This is just for the UI and is extremly lightweight",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Success",
|
||||||
|
"content": {
|
||||||
|
"text/plain": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/ServerInfoDto"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/ServerInfoDto"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"text/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/ServerInfoDto"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/api/Server/convert-media": {
|
"/api/Server/convert-media": {
|
||||||
"post": {
|
"post": {
|
||||||
"tags": [
|
"tags": [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user