feat: add device description field

This commit is contained in:
Maxi Quoß
2025-01-22 13:21:07 +01:00
parent 558e6484d0
commit 973a1b80d0
21 changed files with 115 additions and 5 deletions

View File

@@ -0,0 +1,45 @@
package migrations
import (
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
)
func init() {
m.Register(func(app core.App) error {
collection, err := app.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
// add field
if err := collection.Fields.AddMarshaledJSONAt(5, []byte(`{
"autogeneratePattern": "",
"hidden": false,
"id": "text1843675174",
"max": 0,
"min": 0,
"name": "description",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": false,
"system": false,
"type": "text"
}`)); err != nil {
return err
}
return app.Save(collection)
}, func(app core.App) error {
collection, err := app.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
// remove field
collection.Fields.RemoveById("text1843675174")
return app.Save(collection)
})
}

View File

@@ -157,6 +157,9 @@
{:else}
<h1 class="card-title">{device.name}</h1>
{/if}
{#if device.description}
<p>{device.description}</p>
{/if}
<ul class="menu rounded-box bg-base-200">
<!-- TODO: change to nic array once backend supports it -->
<DeviceCardNic {device} />

View File

@@ -246,6 +246,21 @@
required
/>
</div>
<div class="form-control w-full max-w-xs">
<label class="label" for="device-description">
<div class="label-text">
<span>{$LL.device.general_description()}</span>
</div>
</label>
<input
id="device-description"
type="text"
placeholder={$LL.device.general_description_placeholder()}
class="input w-full max-w-xs"
bind:value={device.description}
/>
</div>
<span class="badge self-center text-error">* {$LL.device.general_required_field()}</span>
</div>
</div>

View File

@@ -55,6 +55,8 @@ const de = {
general_ip: 'IP',
general_mac: 'Mac',
general_netmask: 'Netmask',
general_description: 'Beschreibung',
general_description_placeholder: 'Eine Beschreibung des Geräts',
general_required_field: 'Pflichtfeld',
ports: 'Ports',
ports_desc: 'UpSnap kann auch prüfen, ob bestimmte Ports offen sind.',

View File

@@ -53,6 +53,8 @@ const en = {
general_ip: 'IP',
general_mac: 'Mac',
general_netmask: 'Netmask',
general_description: 'Description',
general_description_placeholder: 'Some description of the device',
general_required_field: 'required field',
ports: 'Ports',
ports_desc: 'UpSnap can also check if given ports are open.',

View File

@@ -55,6 +55,8 @@ const es = {
general_ip: 'IP',
general_mac: 'Mac',
general_netmask: 'Máscara de red',
general_description: 'Descripción',
general_description_placeholder: 'Descripción del dispositivo',
general_required_field: 'Campo obligatorio',
ports: 'Puertos',
ports_desc: 'UpSnap puede comprobar si ciertos puertos están abiertos.',

View File

@@ -56,6 +56,8 @@ const fr = {
general_ip: 'IP',
general_mac: 'Mac',
general_netmask: 'Masque réseau',
general_description: 'Description',
general_description_placeholder: "Description de l'appareil",
general_required_field: 'champ requis',
ports: 'Ports',
ports_desc: 'UpSnap peut aussi vérifier si certains ports sont ouverts.',

View File

@@ -1,5 +1,4 @@
// This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten.
import { initI18nSvelte } from 'typesafe-i18n/svelte';
import type { Formatters, Locales, TranslationFunctions, Translations } from './i18n-types';

View File

@@ -21,6 +21,7 @@ export type Locales =
| 'it'
| 'it-IT'
| 'ja'
| 'ja-JP'
| 'nl'
| 'nl-NL'
| 'pt'
@@ -233,6 +234,14 @@ type RootTranslation = {
* Netmask
*/
general_netmask: string;
/**
* Description
*/
general_description: string;
/**
* Some description of the device
*/
general_description_placeholder: string;
/**
* required field
*/
@@ -1004,6 +1013,14 @@ export type TranslationFunctions = {
* Netmask
*/
general_netmask: () => LocalizedString;
/**
* Description
*/
general_description: () => LocalizedString;
/**
* Some description of the device
*/
general_description_placeholder: () => LocalizedString;
/**
* required field
*/

View File

@@ -1,5 +1,4 @@
// This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten.
import { initFormatters } from './formatters';
import type { Locales, Translations } from './i18n-types';
@@ -17,6 +16,7 @@ const localeTranslationLoaders = {
it: () => import('./it'),
'it-IT': () => import('./it-IT'),
ja: () => import('./ja'),
'ja-JP': () => import('./ja-JP'),
nl: () => import('./nl'),
'nl-NL': () => import('./nl-NL'),
pt: () => import('./pt'),

View File

@@ -1,5 +1,4 @@
// This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten.
import { initFormatters } from './formatters';
import type { Locales, Translations } from './i18n-types';
@@ -16,6 +15,7 @@ import fr_FR from './fr-FR';
import it from './it';
import it_IT from './it-IT';
import ja from './ja';
import ja_JP from './ja-JP';
import nl from './nl';
import nl_NL from './nl-NL';
import pt from './pt';
@@ -36,6 +36,7 @@ const localeTranslations = {
it,
'it-IT': it_IT,
ja,
'ja-JP': ja_JP,
nl,
'nl-NL': nl_NL,
pt,

View File

@@ -1,5 +1,4 @@
// This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten.
import {
i18n as initI18n,
@@ -26,6 +25,7 @@ export const locales: Locales[] = [
'it',
'it-IT',
'ja',
'ja-JP',
'nl',
'nl-NL',
'pt',

View File

@@ -55,6 +55,8 @@ const it = {
general_ip: 'IP',
general_mac: 'Mac',
general_netmask: 'Maschera di rete',
general_description: 'Descrizione',
general_description_placeholder: 'Descrizione del dispositivo',
general_required_field: 'Campo obbligatorio',
ports: 'Porte',
ports_desc: "UpSnap puo' anche controllare che le porte siano aperte.",

View File

@@ -0,0 +1,8 @@
import type { Translation } from '../i18n-types';
import ja from '../ja';
const ja_JP = {
...(ja as unknown as Translation)
} satisfies Translation;
export default ja_JP;

View File

@@ -53,6 +53,8 @@ const ja = {
general_ip: 'IP',
general_mac: 'Mac',
general_netmask: 'ネットマスク',
general_description: '説明',
general_description_placeholder: '装置の説明',
general_required_field: '必須項目',
ports: 'ポート',
ports_desc: 'UpSnap は指定されたポートが開いているか確認することもできます。',

View File

@@ -55,6 +55,8 @@ const nl = {
general_ip: 'IP',
general_mac: 'Mac',
general_netmask: 'Subnetmask',
general_description: 'Beschrijving',
general_description_placeholder: 'Enige beschrijving van het apparaat',
general_required_field: 'vereist veld',
ports: 'Poorten',
ports_desc: 'UpSnap kan ook controleren of gegeven poorten open zijn.',

View File

@@ -55,6 +55,8 @@ const pt = {
general_ip: 'IP',
general_mac: 'Mac',
general_netmask: 'Máscara de rede',
general_description: 'Descrição',
general_description_placeholder: 'Alguma descrição do dispositivo',
general_required_field: 'campo obrigatório',
ports: 'Portos',
ports_desc: 'UpSnap pode verificar se certos portos estão abertos.',

View File

@@ -1,5 +1,5 @@
import zh from '../zh';
import type { Translation } from '../i18n-types';
import zh from '../zh';
const zh_TW = {
...(zh as unknown as Translation),
@@ -54,6 +54,8 @@ const zh_TW = {
general_ip: 'IP',
general_mac: 'Mac',
general_netmask: '子網域遮罩',
general_description: '描述',
general_description_placeholder: '關於這个裝置的描述',
general_required_field: '必填',
ports: '埠',
ports_desc: 'UpSnap 可以檢查指定的埠是否開啟',

View File

@@ -52,6 +52,8 @@ const zh = {
general_ip: 'IP',
general_mac: 'Mac',
general_netmask: '子网掩码',
general_description: '说明',
general_description_placeholder: '设备的一些说明',
general_required_field: '必填字段',
ports: '端口',
ports_desc: 'UpSnap 可以检查设备端口是否正常.',

View File

@@ -5,6 +5,7 @@ export type Device = RecordModel & {
ip: string;
mac: string;
netmask: string;
description: string;
status: 'pending' | 'online' | 'offline' | '';
ports: string[];
link: URL;

View File

@@ -24,6 +24,7 @@
it: '🇮🇹',
'it-IT': '🇮🇹',
ja: '🇯🇵',
'ja-JP': '🇯🇵',
nl: '🇳🇱',
'nl-NL': '🇳🇱',
pt: '🇵🇹',