mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
feat(web): show more app info (#1145)
* feat(web): add app info * database type used * application binary path * config path * feat(web): label colors light theme * feat(web): truncate long fields
This commit is contained in:
parent
2eed1b3e90
commit
d3ca3e59c0
4 changed files with 41 additions and 12 deletions
|
@ -6,6 +6,8 @@ package http
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/autobrr/autobrr/internal/config"
|
"github.com/autobrr/autobrr/internal/config"
|
||||||
"github.com/autobrr/autobrr/internal/domain"
|
"github.com/autobrr/autobrr/internal/domain"
|
||||||
|
@ -15,6 +17,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type configJson struct {
|
type configJson struct {
|
||||||
|
Application string `json:"application"`
|
||||||
|
ConfigDir string `json:"config_dir"`
|
||||||
|
Database string `json:"database"`
|
||||||
Host string `json:"host"`
|
Host string `json:"host"`
|
||||||
Port int `json:"port"`
|
Port int `json:"port"`
|
||||||
LogLevel string `json:"log_level"`
|
LogLevel string `json:"log_level"`
|
||||||
|
@ -50,6 +55,7 @@ func (h configHandler) Routes(r chi.Router) {
|
||||||
|
|
||||||
func (h configHandler) getConfig(w http.ResponseWriter, r *http.Request) {
|
func (h configHandler) getConfig(w http.ResponseWriter, r *http.Request) {
|
||||||
conf := configJson{
|
conf := configJson{
|
||||||
|
ConfigDir: h.cfg.Config.ConfigPath,
|
||||||
Host: h.cfg.Config.Host,
|
Host: h.cfg.Config.Host,
|
||||||
Port: h.cfg.Config.Port,
|
Port: h.cfg.Config.Port,
|
||||||
LogLevel: h.cfg.Config.LogLevel,
|
LogLevel: h.cfg.Config.LogLevel,
|
||||||
|
@ -57,12 +63,29 @@ func (h configHandler) getConfig(w http.ResponseWriter, r *http.Request) {
|
||||||
LogMaxSize: h.cfg.Config.LogMaxSize,
|
LogMaxSize: h.cfg.Config.LogMaxSize,
|
||||||
LogMaxBackups: h.cfg.Config.LogMaxBackups,
|
LogMaxBackups: h.cfg.Config.LogMaxBackups,
|
||||||
BaseURL: h.cfg.Config.BaseURL,
|
BaseURL: h.cfg.Config.BaseURL,
|
||||||
|
Database: h.cfg.Config.DatabaseType,
|
||||||
CheckForUpdates: h.cfg.Config.CheckForUpdates,
|
CheckForUpdates: h.cfg.Config.CheckForUpdates,
|
||||||
Version: h.server.version,
|
Version: h.server.version,
|
||||||
Commit: h.server.commit,
|
Commit: h.server.commit,
|
||||||
Date: h.server.date,
|
Date: h.server.date,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ex, err := os.Executable()
|
||||||
|
if err != nil {
|
||||||
|
h.encoder.Error(w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
conf.Application = ex
|
||||||
|
|
||||||
|
absPath, err := filepath.Abs(h.cfg.Config.ConfigPath)
|
||||||
|
if err != nil {
|
||||||
|
h.encoder.Error(w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
conf.ConfigDir = absPath
|
||||||
|
|
||||||
render.JSON(w, r, conf)
|
render.JSON(w, r, conf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,9 @@ interface RowItemProps {
|
||||||
const RowItem = ({ label, value, title, emptyText }: RowItemProps) => {
|
const RowItem = ({ label, value, title, emptyText }: RowItemProps) => {
|
||||||
return (
|
return (
|
||||||
<div className="py-4 sm:py-5 sm:grid sm:grid-cols-4 sm:gap-4 sm:px-6">
|
<div className="py-4 sm:py-5 sm:grid sm:grid-cols-4 sm:gap-4 sm:px-6">
|
||||||
<dt className="font-medium text-gray-500 dark:text-white" title={title}>{label}:</dt>
|
<dt className="font-medium text-gray-900 dark:text-white text-sm" title={title}>{label}</dt>
|
||||||
<dd className="mt-1 text-gray-900 dark:text-white sm:mt-0 sm:col-span-2 break-all">
|
<dd className="mt-1 text-gray-900 dark:text-gray-300 text-sm sm:mt-0 sm:col-span-3 break-all truncate">
|
||||||
{value ? <span className="px-1 py-0.5 bg-gray-200 dark:bg-gray-700 rounded shadow">{value}</span> : emptyText}
|
{value ? <span className="px-1.5 py-1 bg-gray-200 dark:bg-gray-700 rounded shadow">{value}</span> : emptyText}
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -59,9 +59,9 @@ const RowItemVersion = ({ label, value, title, newUpdate }: RowItemProps) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="py-4 sm:py-5 sm:grid sm:grid-cols-4 sm:gap-4 sm:px-6">
|
<div className="py-4 sm:py-5 sm:grid sm:grid-cols-4 sm:gap-4 sm:px-6">
|
||||||
<dt className="font-medium text-gray-500 dark:text-white" title={title}>{label}:</dt>
|
<dt className="font-medium text-gray-900 dark:text-white text-sm" title={title}>{label}</dt>
|
||||||
<dd className="mt-1 text-gray-900 dark:text-white sm:mt-0 sm:col-span-2 break-all">
|
<dd className="mt-1 text-gray-900 dark:text-gray-300 text-sm sm:mt-0 sm:col-span-2 break-all truncate">
|
||||||
<span className="px-1 py-0.5 bg-gray-200 dark:bg-gray-700 rounded shadow">{value}</span>
|
<span className="px-1.5 py-1 bg-gray-200 dark:bg-gray-700 rounded shadow">{value}</span>
|
||||||
{newUpdate && newUpdate.html_url && (
|
{newUpdate && newUpdate.html_url && (
|
||||||
<span>
|
<span>
|
||||||
<a href={newUpdate.html_url} target="_blank" rel="noopener noreferrer"><span className="ml-2 inline-flex items-center rounded-md bg-green-100 px-2.5 py-0.5 text-sm font-medium text-green-800">{newUpdate.name} available!</span></a>
|
<a href={newUpdate.html_url} target="_blank" rel="noopener noreferrer"><span className="ml-2 inline-flex items-center rounded-md bg-green-100 px-2.5 py-0.5 text-sm font-medium text-green-800">{newUpdate.name} available!</span></a>
|
||||||
|
@ -174,6 +174,9 @@ function ApplicationSettings() {
|
||||||
<RowItemVersion label="Version" value={data?.version} newUpdate={updateData ?? undefined} />
|
<RowItemVersion label="Version" value={data?.version} newUpdate={updateData ?? undefined} />
|
||||||
<RowItem label="Commit" value={data?.commit} />
|
<RowItem label="Commit" value={data?.commit} />
|
||||||
<RowItem label="Build date" value={data?.date} />
|
<RowItem label="Build date" value={data?.date} />
|
||||||
|
<RowItem label="Application" value={data?.application} />
|
||||||
|
<RowItem label="Config path" value={data?.config_dir} />
|
||||||
|
<RowItem label="Database" value={data?.database} />
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
<ul className="divide-y divide-gray-200 dark:divide-gray-700">
|
<ul className="divide-y divide-gray-200 dark:divide-gray-700">
|
||||||
|
|
|
@ -24,9 +24,9 @@ interface RowItemProps {
|
||||||
const RowItem = ({ label, value, title, emptyText }: RowItemProps) => {
|
const RowItem = ({ label, value, title, emptyText }: RowItemProps) => {
|
||||||
return (
|
return (
|
||||||
<div className="py-4 sm:py-5 sm:grid sm:grid-cols-4 sm:gap-4 sm:px-6">
|
<div className="py-4 sm:py-5 sm:grid sm:grid-cols-4 sm:gap-4 sm:px-6">
|
||||||
<dt className="font-medium text-gray-500 dark:text-white" title={title}>{label}:</dt>
|
<dt className="font-medium text-gray-900 dark:text-white text-sm" title={title}>{label}</dt>
|
||||||
<dd className="mt-1 text-gray-900 dark:text-white sm:mt-0 sm:col-span-2 break-all">
|
<dd className="mt-1 text-gray-900 dark:text-white text-sm sm:mt-0 sm:col-span-2 break-all truncate">
|
||||||
<span className="px-1 py-0.5 bg-gray-200 dark:bg-gray-700 rounded shadow">{value ? value : emptyText}</span>
|
<span className="px-1.5 py-1 bg-gray-200 dark:bg-gray-700 rounded shadow">{value ? value : emptyText}</span>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -42,9 +42,9 @@ interface RowItemNumberProps {
|
||||||
const RowItemNumber = ({ label, value, title, unit }: RowItemNumberProps) => {
|
const RowItemNumber = ({ label, value, title, unit }: RowItemNumberProps) => {
|
||||||
return (
|
return (
|
||||||
<div className="py-4 sm:py-5 sm:grid sm:grid-cols-4 sm:gap-4 sm:px-6">
|
<div className="py-4 sm:py-5 sm:grid sm:grid-cols-4 sm:gap-4 sm:px-6">
|
||||||
<dt className="font-medium text-gray-500 dark:text-white" title={title}>{label}:</dt>
|
<dt className="font-medium text-gray-900 dark:text-white text-sm" title={title}>{label}</dt>
|
||||||
<dd className="mt-1 text-gray-900 dark:text-white sm:mt-0 sm:col-span-2 break-all">
|
<dd className="mt-1 text-gray-900 dark:text-white text-sm sm:mt-0 sm:col-span-2 break-all truncate">
|
||||||
<span className="px-1 py-0.5 bg-gray-200 dark:bg-gray-700 rounded shadow">{value}</span>
|
<span className="px-1.5 py-1 bg-gray-200 dark:bg-gray-700 rounded shadow truncate">{value}</span>
|
||||||
{unit &&
|
{unit &&
|
||||||
<span className="ml-1 text-sm text-gray-700 dark:text-gray-400">{unit}</span>
|
<span className="ml-1 text-sm text-gray-700 dark:text-gray-400">{unit}</span>
|
||||||
}
|
}
|
||||||
|
|
3
web/src/types/Config.d.ts
vendored
3
web/src/types/Config.d.ts
vendored
|
@ -6,6 +6,9 @@
|
||||||
type LogLevel = "DEBUG" | "INFO" | "WARN" | "ERROR" | "TRACE";
|
type LogLevel = "DEBUG" | "INFO" | "WARN" | "ERROR" | "TRACE";
|
||||||
|
|
||||||
interface Config {
|
interface Config {
|
||||||
|
config_dir: string;
|
||||||
|
application: string;
|
||||||
|
database: string;
|
||||||
host: string;
|
host: string;
|
||||||
port: number;
|
port: number;
|
||||||
log_level: LogLevel;
|
log_level: LogLevel;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue