2024-06-22 09:41:49 +02:00
|
|
|
// Copyright 2024, Command Line Inc.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2024-06-20 08:59:41 +02:00
|
|
|
package wconfig
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
"github.com/wavetermdev/thenextwave/pkg/wavebase"
|
|
|
|
"github.com/wavetermdev/thenextwave/pkg/wstore"
|
|
|
|
)
|
|
|
|
|
|
|
|
const settingsFile = "settings.json"
|
|
|
|
|
|
|
|
var settingsAbsPath = filepath.Join(configDirAbsPath, settingsFile)
|
|
|
|
|
|
|
|
type WidgetsConfigType struct {
|
2024-06-20 22:03:50 +02:00
|
|
|
Icon string `json:"icon"`
|
|
|
|
Color string `json:"color,omitempty"`
|
|
|
|
Label string `json:"label,omitempty"`
|
|
|
|
Description string `json:"description,omitempty"`
|
|
|
|
BlockDef wstore.BlockDef `json:"blockdef"`
|
2024-06-20 08:59:41 +02:00
|
|
|
}
|
|
|
|
|
2024-06-21 22:23:07 +02:00
|
|
|
type TerminalConfigType struct {
|
|
|
|
FontSize int `json:"fontsize,omitempty"`
|
|
|
|
FontFamily string `json:"fontfamily,omitempty"`
|
|
|
|
}
|
|
|
|
|
2024-06-22 09:41:49 +02:00
|
|
|
type MimeTypeConfigType struct {
|
2024-06-26 21:14:59 +02:00
|
|
|
Icon string `json:"icon"`
|
|
|
|
Color string `json:"color"`
|
2024-06-22 09:41:49 +02:00
|
|
|
}
|
|
|
|
|
2024-06-25 01:25:53 +02:00
|
|
|
type BlockHeaderOpts struct {
|
|
|
|
ShowBlockIds bool `json:"showblockids"`
|
|
|
|
}
|
|
|
|
|
2024-07-19 01:55:04 +02:00
|
|
|
type AutoUpdateOpts struct {
|
|
|
|
Enabled bool `json:"enabled"`
|
|
|
|
IntervalMs uint32 `json:"intervalms"`
|
|
|
|
}
|
|
|
|
|
2024-06-20 08:59:41 +02:00
|
|
|
type SettingsConfigType struct {
|
2024-06-25 01:25:53 +02:00
|
|
|
MimeTypes map[string]MimeTypeConfigType `json:"mimetypes"`
|
|
|
|
Term TerminalConfigType `json:"term"`
|
|
|
|
Widgets []WidgetsConfigType `json:"widgets"`
|
|
|
|
BlockHeader BlockHeaderOpts `json:"blockheader"`
|
2024-07-19 01:55:04 +02:00
|
|
|
AutoUpdate AutoUpdateOpts `json:"autoupdate"`
|
2024-06-20 08:59:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func getSettingsConfigDefaults() SettingsConfigType {
|
|
|
|
return SettingsConfigType{
|
2024-06-22 09:41:49 +02:00
|
|
|
MimeTypes: map[string]MimeTypeConfigType{
|
|
|
|
"audio": {Icon: "file-audio"},
|
|
|
|
"application/pdf": {Icon: "file-pdf"},
|
|
|
|
"application/json": {Icon: "file-lines"},
|
2024-06-27 21:30:08 +02:00
|
|
|
"directory": {Icon: "folder", Color: "var(--term-bright-blue)"},
|
2024-06-22 09:41:49 +02:00
|
|
|
"font": {Icon: "book-font"},
|
|
|
|
"image": {Icon: "file-image"},
|
|
|
|
"text": {Icon: "file-lines"},
|
|
|
|
"text/css": {Icon: "css3-alt fa-brands"},
|
|
|
|
"text/javascript": {Icon: "js fa-brands"},
|
|
|
|
"text/typescript": {Icon: "js fa-brands"},
|
2024-07-09 00:04:48 +02:00
|
|
|
"text/golang": {Icon: "golang fa-brands"},
|
2024-06-22 09:41:49 +02:00
|
|
|
"text/html": {Icon: "html5 fa-brands"},
|
|
|
|
"text/less": {Icon: "less fa-brands"},
|
|
|
|
"text/markdown": {Icon: "markdown fa-brands"},
|
|
|
|
"text/rust": {Icon: "rust fa-brands"},
|
|
|
|
"text/scss": {Icon: "sass fa-brands"},
|
|
|
|
"video": {Icon: "file-video"},
|
2024-06-26 18:39:41 +02:00
|
|
|
"text/csv": {Icon: "file-csv"},
|
2024-06-22 09:41:49 +02:00
|
|
|
},
|
2024-06-20 08:59:41 +02:00
|
|
|
Widgets: []WidgetsConfigType{
|
|
|
|
{
|
2024-06-26 18:39:41 +02:00
|
|
|
Icon: "files",
|
|
|
|
Label: "files",
|
2024-06-20 08:59:41 +02:00
|
|
|
BlockDef: wstore.BlockDef{
|
|
|
|
View: "preview",
|
|
|
|
Meta: map[string]any{"file": wavebase.GetHomeDir()},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2024-06-26 18:39:41 +02:00
|
|
|
Icon: "chart-simple",
|
|
|
|
Label: "chart",
|
2024-06-20 08:59:41 +02:00
|
|
|
BlockDef: wstore.BlockDef{
|
|
|
|
View: "plot",
|
|
|
|
},
|
|
|
|
},
|
2024-06-26 18:39:41 +02:00
|
|
|
{
|
|
|
|
Icon: "globe",
|
|
|
|
Label: "web",
|
|
|
|
BlockDef: wstore.BlockDef{
|
|
|
|
View: "web",
|
|
|
|
Meta: map[string]any{"url": "https://waveterm.dev/"},
|
|
|
|
},
|
|
|
|
},
|
2024-07-03 23:32:55 +02:00
|
|
|
{
|
|
|
|
Icon: "sparkles",
|
|
|
|
Label: "waveai",
|
|
|
|
BlockDef: wstore.BlockDef{
|
|
|
|
View: "waveai",
|
|
|
|
},
|
|
|
|
},
|
2024-06-20 08:59:41 +02:00
|
|
|
},
|
2024-07-19 01:55:04 +02:00
|
|
|
AutoUpdate: AutoUpdateOpts{
|
|
|
|
Enabled: true,
|
|
|
|
IntervalMs: 3600000,
|
|
|
|
},
|
2024-06-20 08:59:41 +02:00
|
|
|
}
|
|
|
|
}
|