Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7c24b1f24a | |||
| 882517dffc | |||
| f98db57a97 | |||
| 7a68362149 | |||
| f716afee74 | |||
| aecab00e70 | |||
| 65d921ddde | |||
| 5d39d90044 | |||
| 6a685a2562 | |||
| d4ee91ed10 | |||
| 9fc11d8c61 | |||
| cb09e0eb84 | |||
| 12a60f57e3 | |||
| a3e32178ac | |||
| 9e76cb32fe | |||
| 63e47ae505 | |||
| 319da7c13c | |||
| e03c635e7b | |||
| b2b5f8ba54 | |||
| dcff85cfe5 | |||
| 65cbfec7af | |||
| c2c997e53f | |||
| 9d2afaf57c | |||
| 8b410bca89 | |||
| e11b5b2100 | |||
| f292780972 | |||
| 89bd3ed27a | |||
| 2a22e92be4 | |||
| 5d829befca | |||
| 2eb7385516 | |||
| 543f573c7f | |||
| 463daba2cf | |||
| 9588e5189e |
27
Makefile
27
Makefile
@@ -1,13 +1,18 @@
|
|||||||
SHELL:=/bin/bash
|
SHELL:=/bin/bash
|
||||||
SOURCES=$(find . -name '*.go' -type f)
|
SOURCES := $(shell find . -name '*.go' -type f)
|
||||||
|
GIT_REV := $(shell git describe --exact-match --tags 2>/dev/null || printf "%s-%s" $$(git describe --tags --abbrev=0) $$(git rev-parse HEAD | head -c8))
|
||||||
.DEFAULT_GOAL := dist
|
.DEFAULT_GOAL := dist
|
||||||
|
MIQT_UIC ?= ~/go/bin/miqt-uic
|
||||||
|
MIQT_RCC ?= ~/go/bin/miqt-rcc
|
||||||
|
MIQT_DOCKER ?= ~/go/bin/miqt-docker
|
||||||
|
GO_WINRES ?= ~/go/bin/go-winres
|
||||||
|
|
||||||
.PHONY: generate
|
.PHONY: generate
|
||||||
generate:
|
generate:
|
||||||
~/go/bin/miqt-uic -InFile mainwindow.ui -OutFile mainwindow.go -Qt6
|
$(MIQT_UIC) -InFile mainwindow.ui -OutFile mainwindow.go -Qt6
|
||||||
~/go/bin/miqt-uic -InFile connectionDialog.ui -OutFile connectionDialog.go -Qt6
|
$(MIQT_UIC) -InFile connectionDialog.ui -OutFile connectionDialog.go -Qt6
|
||||||
~/go/bin/miqt-uic -InFile connectionManagerDialog.ui -OutFile connectionManagerDialog.go -Qt6
|
$(MIQT_UIC) -InFile connectionManagerDialog.ui -OutFile connectionManagerDialog.go -Qt6
|
||||||
~/go/bin/miqt-rcc -Input embed.qrc -Qt6
|
$(MIQT_RCC) -Input embed.qrc -Qt6
|
||||||
|
|
||||||
.PHONY: designer
|
.PHONY: designer
|
||||||
designer:
|
designer:
|
||||||
@@ -22,16 +27,21 @@ optimize-images:
|
|||||||
|
|
||||||
yvbolt: $(SOURCES)
|
yvbolt: $(SOURCES)
|
||||||
# Target a debian-12 baseline build
|
# Target a debian-12 baseline build
|
||||||
~/go/bin/miqt-docker linux64-go1.25-qt6.4-dynamic -minify-build
|
sed -i -re 's/".+"/"$(GIT_REV)"/g' version.go
|
||||||
|
$(MIQT_DOCKER) linux64-go1.25-qt6.4-dynamic -minify-build
|
||||||
|
git checkout -- version.go
|
||||||
chmod 755 yvbolt
|
chmod 755 yvbolt
|
||||||
upx --lzma yvbolt
|
upx --lzma yvbolt
|
||||||
|
|
||||||
yvbolt.exe: $(SOURCES)
|
yvbolt.exe: $(SOURCES)
|
||||||
~/go/bin/miqt-docker win64-cross-go1.24-qt6.5-static -windows-build --tags=windowsqtstatic
|
sed -i -re 's/".+"/"$(GIT_REV)"/g' version.go
|
||||||
|
$(MIQT_DOCKER) win64-cross-go1.24-qt6.5-static -windows-build --tags=windowsqtstatic
|
||||||
|
git checkout -- version.go
|
||||||
|
$(GO_WINRES) patch --in winres.json --no-backup --product-version git-tag --file-version git-tag yvbolt.exe
|
||||||
upx --lzma yvbolt.exe
|
upx --lzma yvbolt.exe
|
||||||
|
|
||||||
yvbolt.apk: $(SOURCES)
|
yvbolt.apk: $(SOURCES)
|
||||||
~/go/bin/miqt-docker android-armv8a-go1.23-qt6.6-dynamic -android-build
|
$(MIQT_DOCKER) android-armv8a-go1.23-qt6.6-dynamic -android-build
|
||||||
|
|
||||||
yvbolt.linux64.tar.xz: yvbolt
|
yvbolt.linux64.tar.xz: yvbolt
|
||||||
rm -f yvbolt.linux64.tar.xz
|
rm -f yvbolt.linux64.tar.xz
|
||||||
@@ -46,4 +56,5 @@ dist: yvbolt.linux64.tar.xz yvbolt.win64.zip
|
|||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
|
git checkout -- version.go
|
||||||
rm -f yvbolt.exe yvbolt yvbolt.linux64.tar.xz yvbolt.win64.zip
|
rm -f yvbolt.exe yvbolt yvbolt.linux64.tar.xz yvbolt.win64.zip
|
||||||
|
|||||||
44
README.md
44
README.md
@@ -17,20 +17,21 @@ See also [qbolt](https://code.ivysaur.me/qbolt) for more/different functionality
|
|||||||
|
|
||||||
## Supported databases
|
## Supported databases
|
||||||
|
|
||||||
There are currently 10 supported databases:
|
There are currently 11 supported databases:
|
||||||
|
|
||||||
Database |Read |Editing |Connection options |Context menu actions
|
Database |Read |Editing |Query |Connection options |Context menu actions
|
||||||
-------------|------|---------|--------------------|--------
|
-------------|------|---------|------|--------------------|--------
|
||||||
Badger v4 |Yes |No |Encrypted, readonly, in-memory |Backup, restore, compact
|
Badger v4 |Yes |Yes |No |Encrypted, readonly, in-memory |Backup, restore, compact
|
||||||
Bolt |Yes |Yes |Readonly |Create/delete child buckets
|
Bolt |Yes |Yes |No |Readonly |Create/delete child buckets
|
||||||
Debconf |Yes |No | |
|
Debconf |Yes |No |No | |
|
||||||
Freedesktop.org Secret Service |Yes |No | |Unlock, create new collection
|
Freedesktop.org Secret Service |Yes |No | No | |Unlock, create new collection
|
||||||
LevelDB |Yes |No |Readonly |
|
LevelDB |Yes |Yes |No |Readonly |
|
||||||
LMDB |Yes |Yes |Multi-DB, readonly |Create/delete child databases
|
LMDB |Yes |Yes |No |Multi-DB, readonly |Create/delete child databases
|
||||||
Pebble |Yes |No |Readonly, in-memory |
|
MongoDB |Yes |Yes |Yes |SSH tunnel |Create/delete child databases and collections
|
||||||
Redis |Yes |No |SSH tunnel, RESP v3 |
|
Pebble |Yes |Yes |No |Readonly, in-memory |
|
||||||
SQLite |Yes |Yes |CLI driver, in-memory |Vacuum, export
|
Redis |Yes |No |Yes |SSH tunnel, RESP v3 |
|
||||||
Starskey |Yes |No |Compression |
|
SQLite |Yes |Yes |Yes |CLI driver, in-memory |Vacuum, export
|
||||||
|
Starskey |Yes |Yes |No |Compression |
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
@@ -43,6 +44,23 @@ The code in this project is licensed under the ISC license (see `LICENSE` file f
|
|||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
|
Unreleased vNext
|
||||||
|
|
||||||
|
- MongoDB: Initial support, including SSH tunnel, managing collections, and querying
|
||||||
|
- Badger: Fix k/v column display, support editing
|
||||||
|
- LMDB: Support editing
|
||||||
|
- LevelDB: Support editing
|
||||||
|
- Pebble: Support editing
|
||||||
|
- Starskey: Fix k/v column display, support editing
|
||||||
|
- Redis: Bump driver version v9.16.0 -> v9.17.2
|
||||||
|
- Connection manager: When saving, use the database's preferred name
|
||||||
|
- App: Use virtualized table renderer
|
||||||
|
- App: Fix graphical flicker when editing connections on Windows
|
||||||
|
- App: Set up icon and exe properties on Windows
|
||||||
|
- App: Embed version number in release builds
|
||||||
|
- App: Show unsaved-changes warning also when changing database
|
||||||
|
- App: Fix rich text formatting appearing when pasting into the query window
|
||||||
|
|
||||||
2025-12-02 v0.9.0
|
2025-12-02 v0.9.0
|
||||||
|
|
||||||
- LMDB: Initial support, including multi-database mode, data editing, and managing child databases
|
- LMDB: Initial support, including multi-database mode, data editing, and managing child databases
|
||||||
|
|||||||
30
TODO
30
TODO
@@ -1,14 +1,14 @@
|
|||||||
- Bolt, LMDB: Editing primary key causes duplicate field
|
- BUG: Adding new entries to connection manager, then selecting them, opens wrong entry
|
||||||
|
- BUG: ExecQuery being called multiple times on error?
|
||||||
- Parity with QBolt, merge projects together
|
- Parity with QBolt, merge projects together
|
||||||
- Portable mode (portable.txt or portable/ dir)
|
- Portable mode (portable.txt or portable/ dir)
|
||||||
- Syntax highlighting in editor
|
- Syntax highlighting in editor
|
||||||
|
- Table: quick filter
|
||||||
|
- Cancellation
|
||||||
|
- Loading animations for connection + queries
|
||||||
- Mutation
|
- Mutation
|
||||||
- Badger: Support insert/update/delete
|
|
||||||
- Pebble: Support insert/update/delete
|
|
||||||
- Debconf: Support insert/update/delete
|
- Debconf: Support insert/update/delete
|
||||||
- Redis: Support insert/update/delete
|
- Redis: Support insert/update/delete
|
||||||
- LevelDB: Support insert/update/delete
|
|
||||||
- Starskey: Support insert/update/delete
|
|
||||||
- SecretService: Support insert/update/delete
|
- SecretService: Support insert/update/delete
|
||||||
- Binary data viewer
|
- Binary data viewer
|
||||||
- Detect jpg/png and show as image
|
- Detect jpg/png and show as image
|
||||||
@@ -17,8 +17,7 @@
|
|||||||
- MySQL (& MariaDB/TiDB)
|
- MySQL (& MariaDB/TiDB)
|
||||||
- Postgres
|
- Postgres
|
||||||
- CLI using psql
|
- CLI using psql
|
||||||
- MongoDB
|
- Lungo: Mini embeddable Mongo - https://github.com/256dpi/lungo
|
||||||
- Lungo: Mini embeddable Mongo - https://github.com/256dpi/lungo
|
|
||||||
- MSSQL (recursive navigation for instances)
|
- MSSQL (recursive navigation for instances)
|
||||||
- Other K/V stores from https://github.com/smallnest/kvbench
|
- Other K/V stores from https://github.com/smallnest/kvbench
|
||||||
- Windows registry
|
- Windows registry
|
||||||
@@ -63,15 +62,24 @@
|
|||||||
- Badger:
|
- Badger:
|
||||||
- v1/v2/v3 support
|
- v1/v2/v3 support
|
||||||
- option to use namespace separators for virtual buckets
|
- option to use namespace separators for virtual buckets
|
||||||
- SQLite: drop table doesn't autorefresh nav since callback is late
|
- SQLite:
|
||||||
|
- drop table doesn't autorefresh nav since callback is late
|
||||||
|
- more accurate type handling
|
||||||
|
- views
|
||||||
|
- other special objects (triggers? udf functions?)
|
||||||
- LMDB: dupsort mode (duplicate keys / entries-per-key)
|
- LMDB: dupsort mode (duplicate keys / entries-per-key)
|
||||||
- Build
|
- MongoDB
|
||||||
- Win32 icon resource
|
- UI for replica sets, ssl certs, cluster, custom auth database
|
||||||
|
- SSH tunnel: error `ssh: tcpChan: deadline not supported` - needs workaround
|
||||||
|
- BSON type column with autoconfig based column editor
|
||||||
|
- Backup/restore
|
||||||
|
- drop db/collection doesn't autorefresh nav since server is asynchronous
|
||||||
|
- SSH tunnel - option to use external/system SSH
|
||||||
- Performance
|
- Performance
|
||||||
- Warning if data table is filtered to 1000 rows, or add pagination
|
- Warning if data table is filtered to 1000 rows, or add pagination
|
||||||
- Context/interrupt slow queries
|
- Context/interrupt slow queries
|
||||||
- Faster virtual rendering
|
|
||||||
- Query history
|
- Query history
|
||||||
|
- Query log
|
||||||
- Test suite
|
- Test suite
|
||||||
- `CREATE TABLE foo (id integer primary key, aaa text not null, bbb text not null);`
|
- `CREATE TABLE foo (id integer primary key, aaa text not null, bbb text not null);`
|
||||||
- Ability to convert database types
|
- Ability to convert database types
|
||||||
|
|||||||
BIN
assets/vendor_mongodb.png
Normal file
BIN
assets/vendor_mongodb.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 460 B |
22
config.go
22
config.go
@@ -23,22 +23,18 @@ type ConnectionConfig struct {
|
|||||||
Bolt *boltConfig `yicon:":/assets/vendor_github.png" json:",omitempty"`
|
Bolt *boltConfig `yicon:":/assets/vendor_github.png" json:",omitempty"`
|
||||||
Debconf *debconfConnection `yicon:":/assets/vendor_debian.png" json:",omitempty"`
|
Debconf *debconfConnection `yicon:":/assets/vendor_debian.png" json:",omitempty"`
|
||||||
SecretService *secretServiceConnection `ylabel:"Freedesktop.org Secret Service" yicon:":/assets/vendor_freedesktop.png" json:",omitempty"`
|
SecretService *secretServiceConnection `ylabel:"Freedesktop.org Secret Service" yicon:":/assets/vendor_freedesktop.png" json:",omitempty"`
|
||||||
LevelDB *leveldbConnection `yicon:":/assets/vendor_leveldb.png" json:",omitempty"`
|
LevelDB *leveldbConnection `ylabel:"LevelDB" yicon:":/assets/vendor_leveldb.png" json:",omitempty"`
|
||||||
LMDB *lmdbConnection `yicon:":/assets/vendor_lmdb.png" json:",omitempty"`
|
LMDB *lmdbConnection `yicon:":/assets/vendor_lmdb.png" json:",omitempty"`
|
||||||
|
MongoDB *mongoConnection `ylabel:"MongoDB" yicon:":/assets/vendor_mongodb.png" json:",omitempty"`
|
||||||
Pebble *pebbleConnection `yicon:":/assets/vendor_cockroach.png" json:",omitempty"`
|
Pebble *pebbleConnection `yicon:":/assets/vendor_cockroach.png" json:",omitempty"`
|
||||||
Redis *redisConnectionOptions `yicon:":/assets/vendor_redis.png" json:",omitempty"`
|
Redis *redisConnectionOptions `yicon:":/assets/vendor_redis.png" json:",omitempty"`
|
||||||
SQLite *sqliteConnection `yicon:":/assets/vendor_sqlite.png" json:",omitempty"`
|
SQLite *sqliteConnection `ylabel:"SQLite" yicon:":/assets/vendor_sqlite.png" json:",omitempty"`
|
||||||
Starskey *starskeyConnection `yicon:":/assets/vendor_starskey.png" json:",omitempty"`
|
Starskey *starskeyConnection `yicon:":/assets/vendor_starskey.png" json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConnectionConfig() *ConnectionConfig {
|
func NewConnectionConfig() *ConnectionConfig {
|
||||||
return &ConnectionConfig{
|
return &ConnectionConfig{
|
||||||
Debconf: &debconfConnection{
|
Type: "Bolt", // favouritism
|
||||||
Database: "/var/cache/debconf/config.dat", // Prefill default path
|
|
||||||
},
|
|
||||||
Redis: &redisConnectionOptions{
|
|
||||||
Address: autoconfig.AddressPort{Port: 6379}, // default value
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,7 +135,7 @@ func (f *App) OnMnuConnectClick() {
|
|||||||
// Connection OK
|
// Connection OK
|
||||||
// Offer to save into connection-manager
|
// Offer to save into connection-manager
|
||||||
if res := qt.QMessageBox_Question2(dlg.ConnectDialog.QWidget, APPNAME, "Connection successful. Save the details into Connection Manager?", qt.QMessageBox__Save, qt.QMessageBox__Ignore); res == int(qt.QMessageBox__Save) {
|
if res := qt.QMessageBox_Question2(dlg.ConnectDialog.QWidget, APPNAME, "Connection successful. Save the details into Connection Manager?", qt.QMessageBox__Save, qt.QMessageBox__Ignore); res == int(qt.QMessageBox__Save) {
|
||||||
f.TrySaveIntoConnectionManager(config)
|
f.TrySaveIntoConnectionManager(config, displayName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default accept behaviour is: setResult(Accepted), emits onFinished; && Hide()
|
// Default accept behaviour is: setResult(Accepted), emits onFinished; && Hide()
|
||||||
@@ -174,14 +170,18 @@ func (c ConnMgrSaveError) Unwrap() error {
|
|||||||
return c.e
|
return c.e
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *App) TrySaveIntoConnectionManager(cc *ConnectionConfig) {
|
func (f *App) TrySaveIntoConnectionManager(cc *ConnectionConfig, displayName string) {
|
||||||
data, err := f.getConnectionManagerContents()
|
data, err := f.getConnectionManagerContents()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
qt.QMessageBox_Warning(f.ui.MainWindow.QWidget, APPNAME, ConnMgrLoadError{err}.Error())
|
qt.QMessageBox_Warning(f.ui.MainWindow.QWidget, APPNAME, ConnMgrLoadError{err}.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if displayName == "" {
|
||||||
|
displayName = cc.String()
|
||||||
|
}
|
||||||
|
|
||||||
data.Entries = append(data.Entries, SavedConfigEntry{
|
data.Entries = append(data.Entries, SavedConfigEntry{
|
||||||
Description: cc.String(),
|
Description: displayName,
|
||||||
Connection: *cc,
|
Connection: *cc,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
33
db_badger.go
33
db_badger.go
@@ -21,20 +21,17 @@ func (ld *badgerLoadedDatabase) DriverName() string {
|
|||||||
return "BadgerDB v4"
|
return "BadgerDB v4"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ld *badgerLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []string) error {
|
func (ld *badgerLoadedDatabase) Properties(bucketPath []string) (string, error) {
|
||||||
|
|
||||||
// Load properties
|
|
||||||
|
|
||||||
content := fmt.Sprintf("Table statistics: %#v", ld.db.Tables())
|
content := fmt.Sprintf("Table statistics: %#v", ld.db.Tables())
|
||||||
f.propertiesBox.SetText(content)
|
return content, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ld *badgerLoadedDatabase) RenderForNav(f *tableState, bucketPath []string) error {
|
||||||
|
|
||||||
// Load data
|
// Load data
|
||||||
// Badger always uses Key + Value as the columns
|
// Badger always uses Key + Value as the columns
|
||||||
|
|
||||||
f.contentBox.SetColumnCount(2)
|
f.SetupColumns([]columnType{columnType_popupData, columnType_popupData}, []string{"Key", "Value"})
|
||||||
f.contentBox.SetHorizontalHeaderLabels([]string{"Key", "Value"})
|
|
||||||
|
|
||||||
f.contentBox.SetRowCount(0)
|
|
||||||
|
|
||||||
err := ld.db.View(func(txn *badger.Txn) error {
|
err := ld.db.View(func(txn *badger.Txn) error {
|
||||||
|
|
||||||
@@ -48,11 +45,7 @@ func (ld *badgerLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []strin
|
|||||||
item := it.Item()
|
item := it.Item()
|
||||||
k := item.Key()
|
k := item.Key()
|
||||||
err := item.Value(func(v []byte) error {
|
err := item.Value(func(v []byte) error {
|
||||||
rpos := f.contentBox.RowCount()
|
f.AddRow_PK_Data(k, k, v)
|
||||||
f.contentBox.SetRowCount(rpos + 1)
|
|
||||||
f.contentBox.SetItem(rpos, 0, qt.NewQTableWidgetItem2(formatUtf8(k)))
|
|
||||||
f.contentBox.SetItem(rpos, 0, qt.NewQTableWidgetItem2(formatUtf8(v)))
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -66,11 +59,16 @@ func (ld *badgerLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Valid
|
// Valid
|
||||||
f.contentBox.ResizeColumnsToContents()
|
f.Ready()
|
||||||
f.contentBox.SetEnabled(true)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n *badgerLoadedDatabase) ApplyChanges(f *tableState, bucketPath []string) error {
|
||||||
|
return n.db.Update(func(txn *badger.Txn) error {
|
||||||
|
return kvstore_ApplyChanges(f, txn.Set, txn.Delete)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (ld *badgerLoadedDatabase) NavChildren(bucketPath []string) ([]string, error) {
|
func (ld *badgerLoadedDatabase) NavChildren(bucketPath []string) ([]string, error) {
|
||||||
return []string{}, nil // No children
|
return []string{}, nil // No children
|
||||||
}
|
}
|
||||||
@@ -134,7 +132,8 @@ func (ld *badgerLoadedDatabase) Close() {
|
|||||||
_ = ld.db.Close()
|
_ = ld.db.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ loadedDatabase = &badgerLoadedDatabase{} // interface assertion
|
var _ loadedDatabase = &badgerLoadedDatabase{} // interface assertion
|
||||||
|
var _ editableLoadedDatabase = &badgerLoadedDatabase{} // interface assertion
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|||||||
118
db_bolt.go
118
db_bolt.go
@@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -58,13 +59,15 @@ func (ld *boltLoadedDatabase) DriverName() string {
|
|||||||
return "Bolt " + version.Version
|
return "Bolt " + version.Version
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ld *boltLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []string) error {
|
func (ld *boltLoadedDatabase) Properties(bucketPath []string) (string, error) {
|
||||||
|
content := fmt.Sprintf("Selected database: %#v", ld.db.Stats())
|
||||||
|
return content, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ld *boltLoadedDatabase) RenderForNav(f *tableState, bucketPath []string) error {
|
||||||
|
|
||||||
// Load properties
|
// Load properties
|
||||||
|
|
||||||
content := fmt.Sprintf("Selected database: %#v", ld.db.Stats())
|
|
||||||
f.propertiesBox.SetText(content)
|
|
||||||
|
|
||||||
if len(bucketPath) == 0 {
|
if len(bucketPath) == 0 {
|
||||||
return nil // Can't have data outside of the top bucket
|
return nil // Can't have data outside of the top bucket
|
||||||
}
|
}
|
||||||
@@ -72,10 +75,7 @@ func (ld *boltLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []string)
|
|||||||
// Load data
|
// Load data
|
||||||
// Bolt always uses Key + Value as the columns
|
// Bolt always uses Key + Value as the columns
|
||||||
|
|
||||||
f.contentBox.SetColumnCount(2)
|
f.SetupColumns([]columnType{columnType_popupData, columnType_popupData}, []string{"Key", "Value"})
|
||||||
f.contentBox.SetHorizontalHeaderLabels([]string{"Key", "Value"})
|
|
||||||
|
|
||||||
f.contentBox.SetRowCount(0)
|
|
||||||
|
|
||||||
err := ld.db.View(func(tx *bbolt.Tx) error {
|
err := ld.db.View(func(tx *bbolt.Tx) error {
|
||||||
b := boltTargetBucket(tx, bucketPath)
|
b := boltTargetBucket(tx, bucketPath)
|
||||||
@@ -94,10 +94,7 @@ func (ld *boltLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []string)
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
rpos := f.contentBox.RowCount()
|
f.AddRow_PK_Data(k, k, v)
|
||||||
f.contentBox.SetRowCount(rpos + 1)
|
|
||||||
f.contentBox.SetItem(rpos, 0, qt.NewQTableWidgetItem2(formatUtf8(k)))
|
|
||||||
f.contentBox.SetItem(rpos, 1, qt.NewQTableWidgetItem2(formatUtf8(v)))
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@@ -106,21 +103,66 @@ func (ld *boltLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Valid
|
// Valid
|
||||||
f.contentBox.ResizeColumnsToContents()
|
f.Ready()
|
||||||
f.contentBox.SetEnabled(true)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *boltLoadedDatabase) ApplyChanges(f *App, bucketPath []string) error {
|
// kvstore_ApplyChanges is a helper function to apply edits to K/V stores that
|
||||||
if n.db.IsReadOnly() {
|
// can use a common abstraction.
|
||||||
return errors.New("Database was opened read-only")
|
// It always uses the "popupData" type i.e. []byte.
|
||||||
|
func kvstore_ApplyChanges(f *tableState, Put func(k, v []byte) error, Delete func(k []byte) error) error {
|
||||||
|
|
||||||
|
// Edit
|
||||||
|
for rowid, _ /*editcells*/ := range f.updateRows {
|
||||||
|
k_orig := f.primaryKeys[rowid]
|
||||||
|
k_new := f.columns_popupData[0][rowid]
|
||||||
|
v := f.columns_popupData[1][rowid]
|
||||||
|
|
||||||
|
if !bytes.Equal(k_orig, k_new) {
|
||||||
|
// Editing the primary key
|
||||||
|
// Delete k_orig and only put in k_new
|
||||||
|
err := Delete(k_orig)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Deleting cell %q: %w", formatUtf8(k_orig), err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err := Put(k_new, []byte(v))
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Updating cell %q: %w", formatUtf8(k_new), err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have rendered row IDs, need to convert back to a bolt primary key
|
// Delete by key (affects rowids after re-render)
|
||||||
// TODO stash the real key inside f.contentBox.Objects()
|
for rowid, _ := range f.deleteRows {
|
||||||
// FIXME breaks if you try and edit the primary key(!)
|
k := f.primaryKeys[rowid]
|
||||||
primaryKeyForRendered := func(rowid int) []byte {
|
err := Delete(k)
|
||||||
return []byte(f.ui.contentBox.Item(rowid, 0).Text())
|
if err != nil {
|
||||||
|
return fmt.Errorf("Deleting cell %q: %w", formatUtf8(k), err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insert all new entries
|
||||||
|
for rowid, _ := range f.insertRows {
|
||||||
|
// Newly inserted rows will not have a valid value stashed in the
|
||||||
|
// f.primaryKeys slice
|
||||||
|
// Have to get it from the data content of the cell directly
|
||||||
|
|
||||||
|
k := f.columns_popupData[0][rowid]
|
||||||
|
v := f.columns_popupData[1][rowid] // There's only one value cell
|
||||||
|
err := Put(k, v)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Inserting cell %q: %w", formatUtf8(k), err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Done
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *boltLoadedDatabase) ApplyChanges(f *tableState, bucketPath []string) error {
|
||||||
|
if n.db.IsReadOnly() {
|
||||||
|
return errors.New("Database was opened read-only")
|
||||||
}
|
}
|
||||||
|
|
||||||
return n.db.Update(func(tx *bbolt.Tx) error {
|
return n.db.Update(func(tx *bbolt.Tx) error {
|
||||||
@@ -128,37 +170,7 @@ func (n *boltLoadedDatabase) ApplyChanges(f *App, bucketPath []string) error {
|
|||||||
// Get current bucket handle
|
// Get current bucket handle
|
||||||
b := boltTargetBucket(tx, bucketPath)
|
b := boltTargetBucket(tx, bucketPath)
|
||||||
|
|
||||||
// Edit
|
return kvstore_ApplyChanges(f, b.Put, b.Delete)
|
||||||
for rowid, _ /*editcells*/ := range f.updateRows {
|
|
||||||
k := primaryKeyForRendered(rowid)
|
|
||||||
v := f.ui.contentBox.Item(rowid, 1).Text() // There's only one value cell
|
|
||||||
err := b.Put(k, []byte(v))
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("Updating cell %q: %w", formatUtf8(k), err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete by key (affects rowids after re-render)
|
|
||||||
for rowid, _ := range f.deleteRows {
|
|
||||||
k := primaryKeyForRendered(rowid)
|
|
||||||
err := b.Delete(k)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("Deleting cell %q: %w", formatUtf8(k), err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Insert all new entries
|
|
||||||
for rowid, _ := range f.insertRows {
|
|
||||||
k := primaryKeyForRendered(rowid)
|
|
||||||
v := f.ui.contentBox.Item(rowid, 1).Text() // There's only one value cell
|
|
||||||
err := b.Put(k, []byte(v))
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("Inserting cell %q: %w", formatUtf8(k), err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Done
|
|
||||||
return nil
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
|
|
||||||
"yvbolt/debconf"
|
"yvbolt/debconf"
|
||||||
|
|
||||||
"github.com/mappu/autoconfig"
|
"github.com/mappu/autoconfig"
|
||||||
qt "github.com/mappu/miqt/qt6"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type debconfLoadedDatabase struct {
|
type debconfLoadedDatabase struct {
|
||||||
@@ -20,12 +20,12 @@ func (ld *debconfLoadedDatabase) DriverName() string {
|
|||||||
return "debconf"
|
return "debconf"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ld *debconfLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []string) error {
|
func (ld *debconfLoadedDatabase) Properties(bucketPath []string) (string, error) {
|
||||||
|
|
||||||
// Load properties
|
|
||||||
|
|
||||||
content := fmt.Sprintf("Applications: %d\nUnique attributes: %d\n", len(ld.db.Entries), len(ld.db.AllColumnNames))
|
content := fmt.Sprintf("Applications: %d\nUnique attributes: %d\n", len(ld.db.Entries), len(ld.db.AllColumnNames))
|
||||||
f.propertiesBox.SetText(content)
|
return content, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ld *debconfLoadedDatabase) RenderForNav(f *tableState, bucketPath []string) error {
|
||||||
|
|
||||||
// Load data
|
// Load data
|
||||||
|
|
||||||
@@ -35,14 +35,8 @@ func (ld *debconfLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []stri
|
|||||||
|
|
||||||
// Find application entry for bucketPath
|
// Find application entry for bucketPath
|
||||||
|
|
||||||
var appInfo *debconf.Application
|
appInfo, ok := ld.db.FindApplicationByName(bucketPath[0])
|
||||||
|
if !ok {
|
||||||
for idx, app := range ld.db.Entries {
|
|
||||||
if app.Name == bucketPath[0] {
|
|
||||||
appInfo = &ld.db.Entries[idx] // TODO faster lookup?
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if appInfo == nil {
|
|
||||||
return fmt.Errorf("Invalid application %q", bucketPath[0])
|
return fmt.Errorf("Invalid application %q", bucketPath[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,8 +44,7 @@ func (ld *debconfLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []stri
|
|||||||
|
|
||||||
indexes := make(map[string]int)
|
indexes := make(map[string]int)
|
||||||
|
|
||||||
f.contentBox.SetColumnCount(len(ld.db.AllColumnNames))
|
f.SetupColumns(slice_repeat(columnType_inlineText, len(ld.db.AllColumnNames)), ld.db.AllColumnNames)
|
||||||
f.contentBox.SetHorizontalHeaderLabels(ld.db.AllColumnNames)
|
|
||||||
|
|
||||||
for i, cname := range ld.db.AllColumnNames {
|
for i, cname := range ld.db.AllColumnNames {
|
||||||
indexes[cname] = i
|
indexes[cname] = i
|
||||||
@@ -59,18 +52,16 @@ func (ld *debconfLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []stri
|
|||||||
|
|
||||||
for _, entry := range appInfo.Entries {
|
for _, entry := range appInfo.Entries {
|
||||||
|
|
||||||
rpos := f.contentBox.RowCount()
|
rpos := f.AddRow()
|
||||||
f.contentBox.SetRowCount(rpos + 1)
|
f.SetCell(rpos, 0, entry.Name)
|
||||||
f.contentBox.SetItem(rpos, 0, qt.NewQTableWidgetItem2(entry.Name))
|
|
||||||
|
|
||||||
for _, proppair := range entry.Properties {
|
for _, proppair := range entry.Properties {
|
||||||
f.contentBox.SetItem(rpos, indexes[proppair[0]], qt.NewQTableWidgetItem2(proppair[1]))
|
f.SetCell(rpos, indexes[proppair[0]], proppair[1])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Valid
|
// Valid
|
||||||
f.contentBox.ResizeColumnsToContents()
|
f.Ready()
|
||||||
f.contentBox.SetEnabled(true)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,6 +95,12 @@ type debconfConnection struct {
|
|||||||
Database autoconfig.ExistingFile `yfilter:"Debconf database (*.dat);;All files (*)"`
|
Database autoconfig.ExistingFile `yfilter:"Debconf database (*.dat);;All files (*)"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (dc *debconfConnection) Reset() {
|
||||||
|
if runtime.GOOS == "linux" {
|
||||||
|
dc.Database = "/var/cache/debconf/config.dat" // Prefill default path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (dc *debconfConnection) Connect(ctx context.Context) (loadedDatabase, string, error) {
|
func (dc *debconfConnection) Connect(ctx context.Context) (loadedDatabase, string, error) {
|
||||||
fh, err := os.OpenFile(string(dc.Database), os.O_RDONLY, 0400)
|
fh, err := os.OpenFile(string(dc.Database), os.O_RDONLY, 0400)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/mappu/autoconfig"
|
"github.com/mappu/autoconfig"
|
||||||
qt "github.com/mappu/miqt/qt6"
|
|
||||||
"github.com/syndtr/goleveldb/leveldb"
|
"github.com/syndtr/goleveldb/leveldb"
|
||||||
"github.com/syndtr/goleveldb/leveldb/opt"
|
"github.com/syndtr/goleveldb/leveldb/opt"
|
||||||
)
|
)
|
||||||
@@ -19,43 +18,55 @@ func (ld *leveldbLoadedDatabase) DriverName() string {
|
|||||||
return "LevelDB"
|
return "LevelDB"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ld *leveldbLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []string) error {
|
func (ld *leveldbLoadedDatabase) Properties(bucketPath []string) (string, error) {
|
||||||
|
|
||||||
// Load properties
|
|
||||||
|
|
||||||
var s leveldb.DBStats
|
var s leveldb.DBStats
|
||||||
err := ld.db.Stats(&s)
|
err := ld.db.Stats(&s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Stats: %w", err)
|
return "", fmt.Errorf("Stats: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
content := fmt.Sprintf("LevelDB stats: %#v", s)
|
content := fmt.Sprintf("LevelDB stats: %#v", s)
|
||||||
f.propertiesBox.SetText(content)
|
return content, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ld *leveldbLoadedDatabase) RenderForNav(f *tableState, bucketPath []string) error {
|
||||||
|
|
||||||
// Load data
|
// Load data
|
||||||
// leveldb always uses Key + Value as the columns
|
// leveldb always uses Key + Value as the columns
|
||||||
|
f.SetupColumns([]columnType{columnType_popupData, columnType_popupData}, []string{"Key", "Value"})
|
||||||
f.contentBox.SetColumnCount(2)
|
|
||||||
f.contentBox.SetHorizontalHeaderLabels([]string{"Key", "Value"})
|
|
||||||
|
|
||||||
itn := ld.db.NewIterator(nil, nil)
|
itn := ld.db.NewIterator(nil, nil)
|
||||||
defer itn.Release()
|
defer itn.Release()
|
||||||
|
|
||||||
for itn.Next() {
|
for itn.Next() {
|
||||||
|
f.AddRow_PK_Data(itn.Key(), itn.Key(), itn.Value())
|
||||||
rpos := f.contentBox.RowCount()
|
|
||||||
f.contentBox.SetRowCount(rpos + 1)
|
|
||||||
|
|
||||||
f.contentBox.SetItem(rpos, 0, qt.NewQTableWidgetItem2(string(itn.Key())))
|
|
||||||
f.contentBox.SetItem(rpos, 1, qt.NewQTableWidgetItem2(string(itn.Value())))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Valid
|
// Valid
|
||||||
f.contentBox.ResizeColumnsToContents()
|
f.Ready()
|
||||||
f.contentBox.SetEnabled(true)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n *leveldbLoadedDatabase) ApplyChanges(f *tableState, bucketPath []string) error {
|
||||||
|
txn, err := n.db.OpenTransaction()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("OpenTransaction: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = kvstore_ApplyChanges(
|
||||||
|
f,
|
||||||
|
func(k, v []byte) error { return txn.Put(k, v, nil) },
|
||||||
|
func(k []byte) error { return txn.Delete(k, nil) },
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
txn.Discard()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return txn.Commit()
|
||||||
|
}
|
||||||
|
|
||||||
func (ld *leveldbLoadedDatabase) NavChildren(bucketPath []string) ([]string, error) {
|
func (ld *leveldbLoadedDatabase) NavChildren(bucketPath []string) ([]string, error) {
|
||||||
return []string{}, nil // No children
|
return []string{}, nil // No children
|
||||||
}
|
}
|
||||||
@@ -68,7 +79,8 @@ func (ld *leveldbLoadedDatabase) Close() {
|
|||||||
_ = ld.db.Close()
|
_ = ld.db.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ loadedDatabase = &leveldbLoadedDatabase{} // interface assertion
|
var _ loadedDatabase = &leveldbLoadedDatabase{} // interface assertion
|
||||||
|
var _ editableLoadedDatabase = &leveldbLoadedDatabase{} // interface assertion
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|||||||
68
db_lmdb.go
68
db_lmdb.go
@@ -19,14 +19,17 @@ func (ld *lmdbDatabase) DriverName() string {
|
|||||||
return lmdb.VersionString() // Already includes "LMDB" prefix
|
return lmdb.VersionString() // Already includes "LMDB" prefix
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ld *lmdbDatabase) RenderForNav(f *MainWindowUi, bucketPath []string) error {
|
func (ld *lmdbDatabase) Properties(bucketPath []string) (string, error) {
|
||||||
|
info, err := ld.db.Info()
|
||||||
// Properties
|
if err != nil {
|
||||||
|
return "", err
|
||||||
if info, err := ld.db.Info(); err == nil {
|
|
||||||
f.propertiesBox.SetPlainText(fmt.Sprintf("LMDB info: %#v", info))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf("LMDB info: %#v", info), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ld *lmdbDatabase) RenderForNav(f *tableState, bucketPath []string) error {
|
||||||
|
|
||||||
// Load data
|
// Load data
|
||||||
|
|
||||||
if ld.isMulti && len(bucketPath) == 0 {
|
if ld.isMulti && len(bucketPath) == 0 {
|
||||||
@@ -38,8 +41,7 @@ func (ld *lmdbDatabase) RenderForNav(f *MainWindowUi, bucketPath []string) error
|
|||||||
|
|
||||||
// LMDB always uses Key + Value as the columns
|
// LMDB always uses Key + Value as the columns
|
||||||
|
|
||||||
f.contentBox.SetColumnCount(2)
|
f.SetupColumns([]columnType{columnType_popupData, columnType_popupData}, []string{"Key", "Value"})
|
||||||
f.contentBox.SetHorizontalHeaderLabels([]string{"Key", "Value"})
|
|
||||||
|
|
||||||
err := ld.db.View(func(txn *lmdb.Txn) error {
|
err := ld.db.View(func(txn *lmdb.Txn) error {
|
||||||
var dbi lmdb.DBI
|
var dbi lmdb.DBI
|
||||||
@@ -76,12 +78,7 @@ func (ld *lmdbDatabase) RenderForNav(f *MainWindowUi, bucketPath []string) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
op = lmdb.Next
|
op = lmdb.Next
|
||||||
|
f.AddRow_PK_Data(key, key, val)
|
||||||
rpos := f.contentBox.RowCount()
|
|
||||||
f.contentBox.SetRowCount(rpos + 1)
|
|
||||||
|
|
||||||
f.contentBox.SetItem(rpos, 0, qt.NewQTableWidgetItem2(string(key)))
|
|
||||||
f.contentBox.SetItem(rpos, 1, qt.NewQTableWidgetItem2(string(val)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
@@ -92,12 +89,11 @@ func (ld *lmdbDatabase) RenderForNav(f *MainWindowUi, bucketPath []string) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Valid
|
// Valid
|
||||||
f.contentBox.ResizeColumnsToContents()
|
f.Ready()
|
||||||
f.contentBox.SetEnabled(true)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ld *lmdbDatabase) ApplyChanges(f *App, bucketPath []string) error {
|
func (ld *lmdbDatabase) ApplyChanges(f *tableState, bucketPath []string) error {
|
||||||
return ld.db.Update(func(txn *lmdb.Txn) error {
|
return ld.db.Update(func(txn *lmdb.Txn) error {
|
||||||
var dbi lmdb.DBI
|
var dbi lmdb.DBI
|
||||||
var err error
|
var err error
|
||||||
@@ -111,36 +107,11 @@ func (ld *lmdbDatabase) ApplyChanges(f *App, bucketPath []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert
|
return kvstore_ApplyChanges(
|
||||||
|
f,
|
||||||
for rowid, _ := range f.insertRows {
|
func(k, v []byte) error { return txn.Put(dbi, k, v, 0) },
|
||||||
key := f.ui.contentBox.Item(rowid, 0).Text()
|
func(k []byte) error { return txn.Del(dbi, k, nil) },
|
||||||
val := f.ui.contentBox.Item(rowid, 1).Text()
|
)
|
||||||
err = txn.Put(dbi, []byte(key), []byte(val), 0)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("Inserting %q: %w", key, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Edit
|
|
||||||
|
|
||||||
for rowid, _ := range f.updateRows {
|
|
||||||
_ = rowid
|
|
||||||
// FIXME need to support delete+reinsert if the key column is edited
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete
|
|
||||||
for rowid, _ := range f.deleteRows {
|
|
||||||
key := f.ui.contentBox.Item(rowid, 0).Text()
|
|
||||||
err = txn.Del(dbi, []byte(key), nil)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("Removing %q: %w", key, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Done
|
|
||||||
return nil
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,7 +217,8 @@ func (ld *lmdbDatabase) Close() {
|
|||||||
_ = ld.db.Close()
|
_ = ld.db.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ loadedDatabase = &lmdbDatabase{} // interface assertion
|
var _ loadedDatabase = &lmdbDatabase{} // interface assertion
|
||||||
|
var _ editableLoadedDatabase = &lmdbDatabase{} // interface assertion
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|||||||
344
db_mongo.go
Normal file
344
db_mongo.go
Normal file
@@ -0,0 +1,344 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"golang.org/x/crypto/ssh"
|
||||||
|
|
||||||
|
"github.com/mappu/autoconfig"
|
||||||
|
qt "github.com/mappu/miqt/qt6"
|
||||||
|
"go.mongodb.org/mongo-driver/v2/bson"
|
||||||
|
"go.mongodb.org/mongo-driver/v2/mongo"
|
||||||
|
"go.mongodb.org/mongo-driver/v2/mongo/options"
|
||||||
|
"go.mongodb.org/mongo-driver/v2/mongo/readpref"
|
||||||
|
"go.mongodb.org/mongo-driver/v2/version"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MongoDB support
|
||||||
|
// To test:
|
||||||
|
// sudo docker run --rm -p 127.0.0.1:27017:27017 -e MONGO_INITDB_ROOT_USERNAME=root -e MONGO_INITDB_ROOT_PASSWORD=toor mongo:latest
|
||||||
|
|
||||||
|
type mongoLdb struct {
|
||||||
|
client *mongo.Client
|
||||||
|
sshc *ssh.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ld *mongoLdb) DriverName() string {
|
||||||
|
return "MongoDB " + version.Driver
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ld *mongoLdb) Properties(bucketPath []string) (string, error) {
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
if len(bucketPath) == 0 {
|
||||||
|
return "", nil // no properties
|
||||||
|
|
||||||
|
} else if len(bucketPath) == 1 {
|
||||||
|
// Database is selected
|
||||||
|
db := ld.client.Database(bucketPath[0])
|
||||||
|
return "Database " + db.Name(), nil
|
||||||
|
|
||||||
|
} else if len(bucketPath) == 2 {
|
||||||
|
// Collection is selected
|
||||||
|
db := ld.client.Database(bucketPath[0])
|
||||||
|
coll := db.Collection(bucketPath[1])
|
||||||
|
|
||||||
|
info := "Database " + db.Name() + "\n"
|
||||||
|
info += "Collection " + coll.Name() + "\n"
|
||||||
|
|
||||||
|
count, err := coll.EstimatedDocumentCount(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
info += fmt.Sprintf("Estimated document count: %d", count) + "\n"
|
||||||
|
|
||||||
|
// TODO return more details
|
||||||
|
|
||||||
|
return info, nil
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return "", errors.New("??")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ld *mongoLdb) RenderForNav(f *tableState, bucketPath []string) error {
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
if len(bucketPath) == 0 || len(bucketPath) == 1 {
|
||||||
|
// Leave the table disabled
|
||||||
|
return nil
|
||||||
|
|
||||||
|
} else if len(bucketPath) == 2 {
|
||||||
|
|
||||||
|
f.SetupColumns([]columnType{columnType_inlineText, columnType_popupData}, []string{"_id", "Document"})
|
||||||
|
|
||||||
|
db := ld.client.Database(bucketPath[0])
|
||||||
|
coll := db.Collection(bucketPath[1])
|
||||||
|
|
||||||
|
cur, err := coll.Find(ctx, bson.D{}) // An empty document as filter = find all results
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Find: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer cur.Close(ctx)
|
||||||
|
return ld.populateRows(ctx, cur, f)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return errors.New("??")
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ld *mongoLdb) populateRows(ctx context.Context, cur *mongo.Cursor, f *tableState) error {
|
||||||
|
|
||||||
|
for cur.Next(ctx) {
|
||||||
|
var result bson.D
|
||||||
|
if err := cur.Decode(&result); err != nil {
|
||||||
|
return fmt.Errorf("Decode: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// The document is always an ordered map[string]any.
|
||||||
|
// MongoDB enforces there is an "_id" key.
|
||||||
|
var idValue string
|
||||||
|
for _, pair := range result {
|
||||||
|
if pair.Key == "_id" {
|
||||||
|
idValue = pair.Value.(string)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if idValue == "" {
|
||||||
|
return errors.New("Surprised to find a document missing an '_id' field")
|
||||||
|
}
|
||||||
|
|
||||||
|
jb, err := result.MarshalJSON()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("MarshalJSON for document %q: %w", idValue, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
f.AddRow_PK_Data([]byte(idValue), idValue, jb)
|
||||||
|
}
|
||||||
|
if err := cur.Err(); err != nil {
|
||||||
|
return fmt.Errorf("Cursor: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Done
|
||||||
|
f.Ready()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ld *mongoLdb) NavChildren(bucketPath []string) ([]string, error) {
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
if len(bucketPath) == 0 {
|
||||||
|
return ld.client.ListDatabaseNames(ctx, bson.D{})
|
||||||
|
|
||||||
|
} else if len(bucketPath) == 1 {
|
||||||
|
db := ld.client.Database(bucketPath[0])
|
||||||
|
return db.ListCollectionNames(ctx, bson.D{})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return []string{}, nil // No children
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ld *mongoLdb) actionNewDatabase(sender *qt.QTreeWidgetItem, bucketPath []string) error {
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
dbName := qt.QInputDialog_GetText(sender.TreeWidget().QWidget, APPNAME, "Enter a name for the new database:")
|
||||||
|
if dbName == "" {
|
||||||
|
return nil // cancel
|
||||||
|
}
|
||||||
|
|
||||||
|
// MongoDB: databases just start to exist when you write to them
|
||||||
|
newDb := ld.client.Database(dbName)
|
||||||
|
return newDb.CreateCollection(ctx, "my.new.collection")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ld *mongoLdb) actionNewCollection(sender *qt.QTreeWidgetItem, bucketPath []string) error {
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
collName := qt.QInputDialog_GetText(sender.TreeWidget().QWidget, APPNAME, "Enter a name for the new collection:")
|
||||||
|
if collName == "" {
|
||||||
|
return nil // cancel
|
||||||
|
}
|
||||||
|
|
||||||
|
// MongoDB: databases just start to exist when you write to them
|
||||||
|
newDb := ld.client.Database(bucketPath[0])
|
||||||
|
return newDb.CreateCollection(ctx, collName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ld *mongoLdb) actionDropDatabase(sender *qt.QTreeWidgetItem, bucketPath []string) error {
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
// FIXME add warning
|
||||||
|
db := ld.client.Database(bucketPath[0])
|
||||||
|
return db.Drop(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ld *mongoLdb) actionDropCollection(sender *qt.QTreeWidgetItem, bucketPath []string) error {
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
// FIXME add warning
|
||||||
|
db := ld.client.Database(bucketPath[0])
|
||||||
|
coll := db.Collection(bucketPath[1])
|
||||||
|
return coll.Drop(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ld *mongoLdb) ExecQuery(query string, bucketPath []string, resultArea *tableState) error {
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
if len(bucketPath) == 0 {
|
||||||
|
return errors.New("Please select a database first.")
|
||||||
|
}
|
||||||
|
|
||||||
|
db := ld.client.Database(bucketPath[0])
|
||||||
|
|
||||||
|
// The query should be JSON, e.g.
|
||||||
|
// { "hello": 1 } or
|
||||||
|
// { "explain": { "count": "system.users" } } or
|
||||||
|
// { "listDatabases": 1 }
|
||||||
|
|
||||||
|
doc := bson.D{}
|
||||||
|
err := doc.UnmarshalJSON([]byte(query))
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Parsing JSON query: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME how to tell if the response will have a cursor or a singleResult?
|
||||||
|
|
||||||
|
if false {
|
||||||
|
// Cursor
|
||||||
|
cur, err := db.RunCommandCursor(ctx, doc)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Running command: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer cur.Close(ctx)
|
||||||
|
return ld.populateRows(ctx, cur, resultArea)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Single result
|
||||||
|
|
||||||
|
res := db.RunCommand(ctx, doc)
|
||||||
|
|
||||||
|
response := bson.D{}
|
||||||
|
err = res.Decode(&response)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Decoding response: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
responseJson, err := response.MarshalJSON()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Decoding response: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
resultArea.SetupColumns([]columnType{columnType_popupData}, []string{"Response"})
|
||||||
|
resultArea.AddRowData(responseJson)
|
||||||
|
resultArea.Ready()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ld *mongoLdb) NavContext(bucketPath []string) ([]contextAction, error) {
|
||||||
|
if len(bucketPath) == 0 {
|
||||||
|
// Top-level connection
|
||||||
|
return []contextAction{
|
||||||
|
{"Create database...", ld.actionNewDatabase},
|
||||||
|
}, nil
|
||||||
|
|
||||||
|
} else if len(bucketPath) == 1 {
|
||||||
|
// Database selected
|
||||||
|
return []contextAction{
|
||||||
|
{"Create collection...", ld.actionNewCollection},
|
||||||
|
{"Drop database...", ld.actionDropDatabase},
|
||||||
|
}, nil
|
||||||
|
|
||||||
|
} else if len(bucketPath) == 2 {
|
||||||
|
// Collection selected
|
||||||
|
return []contextAction{
|
||||||
|
{"Drop collection...", ld.actionDropCollection},
|
||||||
|
}, nil
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return nil, errors.New("???")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ld *mongoLdb) Close() {
|
||||||
|
_ = ld.client.Disconnect(context.Background())
|
||||||
|
if ld.sshc != nil {
|
||||||
|
_ = ld.sshc.Close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ loadedDatabase = &mongoLdb{} // interface assertion
|
||||||
|
var _ queryableLoadedDatabase = &mongoLdb{} // interface assertion
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
type mongoConnection struct {
|
||||||
|
Conn struct {
|
||||||
|
Mode autoconfig.OneOf
|
||||||
|
|
||||||
|
Connection_String *string
|
||||||
|
}
|
||||||
|
|
||||||
|
SSH_Tunnel *SSHTunnel
|
||||||
|
}
|
||||||
|
|
||||||
|
func (moc *mongoConnection) Reset() {
|
||||||
|
moc.Conn.Mode = "Connection_String"
|
||||||
|
moc.Conn.Connection_String = address_of("mongodb://localhost:27017")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (moc *mongoConnection) Connect(ctx context.Context) (loadedDatabase, string, error) {
|
||||||
|
|
||||||
|
ctx, _ = context.WithTimeout(ctx, 5*time.Second) // shadow parent ctx
|
||||||
|
|
||||||
|
opts := options.Client().ApplyURI(string(*moc.Conn.Connection_String))
|
||||||
|
|
||||||
|
// Our used library supports all compressors
|
||||||
|
opts.SetCompressors([]string{"zstd", "snappy", "zlib"})
|
||||||
|
|
||||||
|
ret := mongoLdb{}
|
||||||
|
|
||||||
|
if moc.SSH_Tunnel != nil {
|
||||||
|
sshc, err := moc.SSH_Tunnel.Open(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
opts.Dialer = sshc // interface implements DialContext()
|
||||||
|
ret.sshc = sshc
|
||||||
|
|
||||||
|
// The crypto/ssh library does not support deadlines over tcp tunnels
|
||||||
|
// Go-redis has a workaround for this, but go-mongo does not
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
client, err := mongo.Connect(opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, "", err
|
||||||
|
}
|
||||||
|
ret.client = client
|
||||||
|
|
||||||
|
// Connect() does not block for server discovery. Check that the server really
|
||||||
|
// is reachable
|
||||||
|
|
||||||
|
err = client.Ping(ctx, readpref.Primary())
|
||||||
|
if err != nil {
|
||||||
|
return nil, "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
// We should be able to ListDatabases - there may be an authentication error
|
||||||
|
_, err = client.ListDatabaseNames(ctx, bson.D{})
|
||||||
|
if err != nil {
|
||||||
|
return nil, "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &ret, "MongoDB", nil
|
||||||
|
}
|
||||||
@@ -6,8 +6,10 @@ func (n *noLoadedDatabase) DriverName() string {
|
|||||||
return "No database selected"
|
return "No database selected"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *noLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []string) error {
|
func (n *noLoadedDatabase) Properties(bucketPath []string) (string, error) {
|
||||||
f.propertiesBox.SetText("Open a database to get started...")
|
return "Open a database to get started...", nil
|
||||||
|
}
|
||||||
|
func (n *noLoadedDatabase) RenderForNav(f *tableState, bucketPath []string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
43
db_pebble.go
43
db_pebble.go
@@ -10,7 +10,6 @@ import (
|
|||||||
"github.com/cockroachdb/pebble"
|
"github.com/cockroachdb/pebble"
|
||||||
"github.com/cockroachdb/pebble/vfs"
|
"github.com/cockroachdb/pebble/vfs"
|
||||||
"github.com/mappu/autoconfig"
|
"github.com/mappu/autoconfig"
|
||||||
qt "github.com/mappu/miqt/qt6"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type pebbleLoadedDatabase struct {
|
type pebbleLoadedDatabase struct {
|
||||||
@@ -45,20 +44,19 @@ func (ld *pebbleLoadedDatabase) DriverName() string {
|
|||||||
return "Pebble " + pebbleDriverVersion() // Parsed from embedded go.mod copy
|
return "Pebble " + pebbleDriverVersion() // Parsed from embedded go.mod copy
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ld *pebbleLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []string) error {
|
func (ld *pebbleLoadedDatabase) Properties(bucketPath []string) (string, error) {
|
||||||
|
content := fmt.Sprintf("Pebble metrics: %#v", ld.db.Metrics())
|
||||||
|
return content, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ld *pebbleLoadedDatabase) RenderForNav(f *tableState, bucketPath []string) error {
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
// Load properties
|
|
||||||
|
|
||||||
content := fmt.Sprintf("Pebble metrics: %#v", ld.db.Metrics())
|
|
||||||
f.propertiesBox.SetText(content)
|
|
||||||
|
|
||||||
// Load data
|
// Load data
|
||||||
// pebble always uses Key + Value as the columns
|
// pebble always uses Key + Value as the columns
|
||||||
|
|
||||||
f.contentBox.SetColumnCount(2)
|
f.SetupColumns([]columnType{columnType_popupData, columnType_popupData}, []string{"Key", "Value"})
|
||||||
f.contentBox.SetHorizontalHeaderLabels([]string{"Key", "Value"})
|
|
||||||
|
|
||||||
itr, err := ld.db.NewIterWithContext(ctx, nil)
|
itr, err := ld.db.NewIterWithContext(ctx, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -73,19 +71,29 @@ func (ld *pebbleLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []strin
|
|||||||
return fmt.Errorf("Failed to load data for key %q: %w", formatAny(k), err)
|
return fmt.Errorf("Failed to load data for key %q: %w", formatAny(k), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
rpos := f.contentBox.RowCount()
|
f.AddRow_PK_Data(k, k, v)
|
||||||
f.contentBox.SetRowCount(rpos + 1)
|
|
||||||
|
|
||||||
f.contentBox.SetItem(rpos, 0, qt.NewQTableWidgetItem2(formatUtf8(k)))
|
|
||||||
f.contentBox.SetItem(rpos, 1, qt.NewQTableWidgetItem2(formatUtf8(v)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Valid
|
// Valid
|
||||||
f.contentBox.ResizeColumnsToContents()
|
f.Ready()
|
||||||
f.contentBox.SetEnabled(true)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n *pebbleLoadedDatabase) ApplyChanges(f *tableState, bucketPath []string) error {
|
||||||
|
|
||||||
|
txn := n.db.NewBatch()
|
||||||
|
|
||||||
|
err := kvstore_ApplyChanges(
|
||||||
|
f,
|
||||||
|
func(k, v []byte) error { return txn.Set(k, v, nil) },
|
||||||
|
func(k []byte) error { return txn.Delete(k, nil) },
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return txn.Commit(nil)
|
||||||
|
}
|
||||||
|
|
||||||
func (ld *pebbleLoadedDatabase) NavChildren(bucketPath []string) ([]string, error) {
|
func (ld *pebbleLoadedDatabase) NavChildren(bucketPath []string) ([]string, error) {
|
||||||
return []string{}, nil // No children
|
return []string{}, nil // No children
|
||||||
}
|
}
|
||||||
@@ -98,7 +106,8 @@ func (ld *pebbleLoadedDatabase) Close() {
|
|||||||
_ = ld.db.Close()
|
_ = ld.db.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ loadedDatabase = &pebbleLoadedDatabase{} // interface assertion
|
var _ loadedDatabase = &pebbleLoadedDatabase{} // interface assertion
|
||||||
|
var _ editableLoadedDatabase = &pebbleLoadedDatabase{} // interface assertion
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|||||||
68
db_redis.go
68
db_redis.go
@@ -8,7 +8,6 @@ import (
|
|||||||
"yvbolt/lexer"
|
"yvbolt/lexer"
|
||||||
|
|
||||||
"github.com/mappu/autoconfig"
|
"github.com/mappu/autoconfig"
|
||||||
qt "github.com/mappu/miqt/qt6"
|
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
"golang.org/x/crypto/ssh"
|
"golang.org/x/crypto/ssh"
|
||||||
)
|
)
|
||||||
@@ -20,6 +19,10 @@ type redisConnectionOptions struct {
|
|||||||
SSH_Tunnel *SSHTunnel
|
SSH_Tunnel *SSHTunnel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (config *redisConnectionOptions) Reset() {
|
||||||
|
config.Address.Port = 6379
|
||||||
|
}
|
||||||
|
|
||||||
func (config *redisConnectionOptions) Connect(ctx context.Context) (loadedDatabase, string, error) {
|
func (config *redisConnectionOptions) Connect(ctx context.Context) (loadedDatabase, string, error) {
|
||||||
|
|
||||||
ld := &redisLoadedDatabase{
|
ld := &redisLoadedDatabase{
|
||||||
@@ -99,18 +102,27 @@ func (ld *redisLoadedDatabase) DriverName() string {
|
|||||||
return "Redis " + ld.serverVersion
|
return "Redis " + ld.serverVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ld *redisLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []string) error {
|
func (ld *redisLoadedDatabase) Properties(bucketPath []string) (string, error) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
if len(bucketPath) == 0 {
|
if len(bucketPath) == 0 {
|
||||||
// Top-level: Show info() on main Properties tab
|
// Top-level: Show info() on main Properties tab
|
||||||
infostr, err := ld.db.Info(ctx).Result()
|
infostr, err := ld.db.Info(ctx).Result()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Retreiving database info: %w", err)
|
return "", fmt.Errorf("Retreiving database info: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
f.propertiesBox.SetText(infostr)
|
return infostr, nil
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return "Database " + bucketPath[0], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ld *redisLoadedDatabase) RenderForNav(f *tableState, bucketPath []string) error {
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
if len(bucketPath) == 0 {
|
||||||
// Leave data tab disabled (default behaviour)
|
// Leave data tab disabled (default behaviour)
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
@@ -127,12 +139,12 @@ func (ld *redisLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []string
|
|||||||
return fmt.Errorf("Listing keys in database %q: %w", bucketPath[0], err)
|
return fmt.Errorf("Listing keys in database %q: %w", bucketPath[0], err)
|
||||||
}
|
}
|
||||||
|
|
||||||
f.propertiesBox.SetText(fmt.Sprintf("Database %s\nTotal keys: %d\n", bucketPath[0], len(allKeys)))
|
// Redis always uses Key string, Type string, Value []byte as the columns
|
||||||
|
|
||||||
// Redis always uses Key + Value as the columns
|
f.SetupColumns(
|
||||||
|
[]columnType{columnType_popupData, columnType_inlineText, columnType_popupData},
|
||||||
f.contentBox.SetColumnCount(3)
|
[]string{"Key", "Type", "Value"},
|
||||||
f.contentBox.SetHorizontalHeaderLabels([]string{"Key", "Type", "Value"})
|
)
|
||||||
|
|
||||||
for _, key := range allKeys {
|
for _, key := range allKeys {
|
||||||
typeName, err := ld.db.Type(ctx, key).Result()
|
typeName, err := ld.db.Type(ctx, key).Result()
|
||||||
@@ -140,10 +152,9 @@ func (ld *redisLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []string
|
|||||||
return fmt.Errorf("Loading %q/%q: %w", bucketPath[0], key, err)
|
return fmt.Errorf("Loading %q/%q: %w", bucketPath[0], key, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
rpos := f.contentBox.RowCount()
|
rpos := f.AddRow()
|
||||||
f.contentBox.SetRowCount(rpos + 1)
|
f.SetCell(rpos, 0, key)
|
||||||
f.contentBox.SetItem(rpos, 0, qt.NewQTableWidgetItem2(formatUtf8([]byte(key))))
|
f.SetCell(rpos, 1, typeName)
|
||||||
f.contentBox.SetItem(rpos, 1, qt.NewQTableWidgetItem2(typeName))
|
|
||||||
|
|
||||||
switch typeName {
|
switch typeName {
|
||||||
case "string":
|
case "string":
|
||||||
@@ -151,7 +162,8 @@ func (ld *redisLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []string
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Loading %q/%q: %w", bucketPath[0], key, err)
|
return fmt.Errorf("Loading %q/%q: %w", bucketPath[0], key, err)
|
||||||
}
|
}
|
||||||
f.contentBox.SetItem(rpos, 2, qt.NewQTableWidgetItem2(val))
|
|
||||||
|
f.SetCell(rpos, 2, []byte(val))
|
||||||
|
|
||||||
case "hash":
|
case "hash":
|
||||||
val, err := ld.db.HGetAll(ctx, key).Result()
|
val, err := ld.db.HGetAll(ctx, key).Result()
|
||||||
@@ -159,7 +171,7 @@ func (ld *redisLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []string
|
|||||||
return fmt.Errorf("Loading %q/%q: %w", bucketPath[0], key, err)
|
return fmt.Errorf("Loading %q/%q: %w", bucketPath[0], key, err)
|
||||||
}
|
}
|
||||||
// It's a map[string]string
|
// It's a map[string]string
|
||||||
f.contentBox.SetItem(rpos, 2, qt.NewQTableWidgetItem2(formatAny(val)))
|
f.SetCell(rpos, 2, []byte(formatAny(val)))
|
||||||
|
|
||||||
case "lists":
|
case "lists":
|
||||||
fallthrough
|
fallthrough
|
||||||
@@ -171,14 +183,13 @@ func (ld *redisLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []string
|
|||||||
fallthrough
|
fallthrough
|
||||||
|
|
||||||
default:
|
default:
|
||||||
f.contentBox.SetItem(rpos, 2, qt.NewQTableWidgetItem2("<<<other object type>>>"))
|
f.SetCell(rpos, 2, []byte("<<<other object type>>>"))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Valid
|
// Valid
|
||||||
f.contentBox.ResizeColumnsToContents()
|
f.Ready()
|
||||||
f.contentBox.SetEnabled(true)
|
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -213,7 +224,7 @@ func (ld *redisLoadedDatabase) NavContext(bucketPath []string) ([]contextAction,
|
|||||||
return nil, nil // No special actions are supported
|
return nil, nil // No special actions are supported
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ld *redisLoadedDatabase) ExecQuery(query string, resultArea *qt.QTableWidget) error {
|
func (ld *redisLoadedDatabase) ExecQuery(query string, _ []string, resultArea *tableState) error {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
// Need to parse the query into separate string+args fields for the protocol
|
// Need to parse the query into separate string+args fields for the protocol
|
||||||
@@ -229,32 +240,23 @@ func (ld *redisLoadedDatabase) ExecQuery(query string, resultArea *qt.QTableWidg
|
|||||||
return fmt.Errorf("The redis query returned an error: %w", err)
|
return fmt.Errorf("The redis query returned an error: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
vcl_clear_grid(resultArea)
|
resultArea.SetupColumns([]columnType{columnType_inlineText}, []string{"Result"})
|
||||||
resultArea.SetColumnCount(1)
|
|
||||||
resultArea.SetHorizontalHeaderLabels([]string{"Result"})
|
|
||||||
|
|
||||||
// The result is probably a single value or a string slice
|
// The result is probably a single value or a string slice
|
||||||
switch ret := ret.(type) {
|
switch ret := ret.(type) {
|
||||||
case []string:
|
case []string:
|
||||||
// Multiple values
|
// Multiple values
|
||||||
for _, single := range ret {
|
for _, single := range ret {
|
||||||
|
resultArea.AddRowData(single)
|
||||||
rpos := resultArea.RowCount()
|
|
||||||
resultArea.SetRowCount(rpos + 1)
|
|
||||||
resultArea.SetItem(rpos, 0, qt.NewQTableWidgetItem2(formatUtf8([]byte(single))))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Single value
|
// Single value
|
||||||
rpos := resultArea.RowCount()
|
// Unknown object type
|
||||||
resultArea.SetRowCount(rpos + 1)
|
resultArea.AddRowData(formatAny(ret)) // formatUtf8
|
||||||
resultArea.SetItem(rpos, 0, qt.NewQTableWidgetItem2(formatAny(ret))) // formatUtf8
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resultArea.ResizeColumnsToContents()
|
resultArea.Ready()
|
||||||
resultArea.SetEnabled(true)
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,11 @@ func (ld *secretServiceDb) DriverName() string {
|
|||||||
return "FreeDesktop.org Secret Service"
|
return "FreeDesktop.org Secret Service"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ld *secretServiceDb) RenderForNav(f *MainWindowUi, bucketPath []string) error {
|
func (ld *secretServiceDb) Properties(bucketPath []string) (string, error) {
|
||||||
|
return "", nil // No properties
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ld *secretServiceDb) RenderForNav(f *tableState, bucketPath []string) error {
|
||||||
|
|
||||||
const (
|
const (
|
||||||
collectionBasePath = "/org/freedesktop/secrets/collection/"
|
collectionBasePath = "/org/freedesktop/secrets/collection/"
|
||||||
@@ -28,16 +32,14 @@ func (ld *secretServiceDb) RenderForNav(f *MainWindowUi, bucketPath []string) er
|
|||||||
serviceName = "org.freedesktop.secrets"
|
serviceName = "org.freedesktop.secrets"
|
||||||
)
|
)
|
||||||
|
|
||||||
// No properties
|
|
||||||
|
|
||||||
// No data
|
|
||||||
|
|
||||||
if len(bucketPath) == 0 {
|
if len(bucketPath) == 0 {
|
||||||
// No data
|
// No data
|
||||||
} else if len(bucketPath) == 1 {
|
} else if len(bucketPath) == 1 {
|
||||||
|
|
||||||
f.contentBox.SetColumnCount(6)
|
f.SetupColumns(
|
||||||
f.contentBox.SetHorizontalHeaderLabels([]string{"ID", "Label", "Attributes", "ContentType", "Parameters", "Value"})
|
slice_repeat(columnType_inlineText, 6),
|
||||||
|
[]string{"ID", "Label", "Attributes", "ContentType", "Parameters", "Value"},
|
||||||
|
)
|
||||||
|
|
||||||
// Collection is selected
|
// Collection is selected
|
||||||
collection := ld.svc.GetCollection(bucketPath[0])
|
collection := ld.svc.GetCollection(bucketPath[0])
|
||||||
@@ -71,20 +73,19 @@ func (ld *secretServiceDb) RenderForNav(f *MainWindowUi, bucketPath []string) er
|
|||||||
return fmt.Errorf("Reading secret %q: %w", item, err)
|
return fmt.Errorf("Reading secret %q: %w", item, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
rpos := f.contentBox.RowCount()
|
f.AddRowData(
|
||||||
f.contentBox.SetRowCount(rpos + 1)
|
// All strings
|
||||||
|
string(item), // ID
|
||||||
f.contentBox.SetItem(rpos, 0, qt.NewQTableWidgetItem2(string(item))) // ID
|
label.Value().(string), // Label
|
||||||
f.contentBox.SetItem(rpos, 1, qt.NewQTableWidgetItem2(label.Value().(string))) // Label
|
attrs.String(), // Attributes (JSON)
|
||||||
f.contentBox.SetItem(rpos, 2, qt.NewQTableWidgetItem2(attrs.String())) // Attributes (JSON)
|
secr.ContentType, // ContentType
|
||||||
f.contentBox.SetItem(rpos, 3, qt.NewQTableWidgetItem2(secr.ContentType)) // ContentType
|
string(secr.Parameters), // Parameters
|
||||||
f.contentBox.SetItem(rpos, 4, qt.NewQTableWidgetItem2(string(secr.Parameters))) // Parameters
|
string(secr.Value), // Value
|
||||||
f.contentBox.SetItem(rpos, 5, qt.NewQTableWidgetItem2(string(secr.Value))) // Value
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Valid
|
// Valid
|
||||||
f.contentBox.ResizeColumnsToContents()
|
f.Ready()
|
||||||
f.contentBox.SetEnabled(true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
138
db_sqlite.go
138
db_sqlite.go
@@ -32,22 +32,12 @@ func (ld *sqliteLoadedDatabase) DriverName() string {
|
|||||||
return "SQLite " + ver1
|
return "SQLite " + ver1
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ld *sqliteLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []string) error {
|
func (ld *sqliteLoadedDatabase) Properties(bucketPath []string) (string, error) {
|
||||||
|
if len(bucketPath) == 0 || len(bucketPath) == 1 {
|
||||||
|
return "Please select...", nil // No properties
|
||||||
|
|
||||||
ctx := context.TODO()
|
} else {
|
||||||
|
|
||||||
if len(bucketPath) == 0 {
|
|
||||||
// Top-level
|
|
||||||
f.propertiesBox.SetText("Please select...")
|
|
||||||
return nil
|
|
||||||
|
|
||||||
} else if len(bucketPath) == 1 {
|
|
||||||
// Category (tables, ...)
|
|
||||||
f.propertiesBox.SetText("Please select...")
|
|
||||||
return nil
|
|
||||||
|
|
||||||
} else if len(bucketPath) == 2 && bucketPath[0] == sqliteTablesCaption {
|
|
||||||
// Render for specific table
|
|
||||||
tableName := bucketPath[1]
|
tableName := bucketPath[1]
|
||||||
|
|
||||||
// Get some basic properties
|
// Get some basic properties
|
||||||
@@ -59,7 +49,24 @@ func (ld *sqliteLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Display table properties
|
// Display table properties
|
||||||
f.propertiesBox.SetText(fmt.Sprintf("Selected table %q\n\nSchema:\n\n%s", tableName, schemaStmt))
|
return fmt.Sprintf("Selected table %q\n\nSchema:\n\n%s", tableName, schemaStmt), nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ld *sqliteLoadedDatabase) RenderForNav(f *tableState, bucketPath []string) error {
|
||||||
|
|
||||||
|
ctx := context.TODO()
|
||||||
|
|
||||||
|
if len(bucketPath) == 0 {
|
||||||
|
return nil
|
||||||
|
|
||||||
|
} else if len(bucketPath) == 1 {
|
||||||
|
// Category (tables, ...)
|
||||||
|
return nil
|
||||||
|
|
||||||
|
} else if len(bucketPath) == 2 && bucketPath[0] == sqliteTablesCaption {
|
||||||
|
// Render for specific table
|
||||||
|
tableName := bucketPath[1]
|
||||||
|
|
||||||
// Load column details
|
// Load column details
|
||||||
// Use SELECT form instead of common PRAGMA table_info so we can just get names
|
// Use SELECT form instead of common PRAGMA table_info so we can just get names
|
||||||
@@ -70,7 +77,7 @@ func (ld *sqliteLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []strin
|
|||||||
return fmt.Errorf("Failed to load columns for table %q: %w", tableName, err)
|
return fmt.Errorf("Failed to load columns for table %q: %w", tableName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
populateColumns(columnNames, f.contentBox)
|
populateColumns(columnNames, f)
|
||||||
|
|
||||||
// Find primary key, if any
|
// Find primary key, if any
|
||||||
var primaryKeyIdx int = -1
|
var primaryKeyIdx int = -1
|
||||||
@@ -89,11 +96,14 @@ func (ld *sqliteLoadedDatabase) RenderForNav(f *MainWindowUi, bucketPath []strin
|
|||||||
return fmt.Errorf("Failed to load data for table %q: %w", tableName, err)
|
return fmt.Errorf("Failed to load data for table %q: %w", tableName, err)
|
||||||
}
|
}
|
||||||
defer datar.Close()
|
defer datar.Close()
|
||||||
populateRows(datar, f.contentBox, primaryKeyIdx)
|
|
||||||
|
err = populateRows(datar, f, primaryKeyIdx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// We successfully populated the data grid
|
// We successfully populated the data grid
|
||||||
f.contentBox.ResizeColumnsToContents()
|
f.Ready()
|
||||||
f.contentBox.SetEnabled(true)
|
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -130,14 +140,14 @@ func (ld *sqliteLoadedDatabase) sqliteGetColumnNamesForTable(tableName string) (
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func populateColumns(names []string, dest *qt.QTableWidget) {
|
func populateColumns(names []string, dest *tableState) {
|
||||||
dest.SetColumnCount(len(names))
|
// FIXME better column types?
|
||||||
dest.SetHorizontalHeaderLabels(names)
|
dest.SetupColumns(slice_repeat(columnType_inlineText, len(names)), names)
|
||||||
}
|
}
|
||||||
|
|
||||||
func populateRows(rr *sql.Rows, dest *qt.QTableWidget, pk_index int) {
|
func populateRows(rr *sql.Rows, dest *tableState, pk_index int) error {
|
||||||
|
|
||||||
numColumns := int(dest.ColumnCount())
|
numColumns := len(dest.currentColumns)
|
||||||
|
|
||||||
for rr.Next() {
|
for rr.Next() {
|
||||||
fields := make([]interface{}, numColumns)
|
fields := make([]interface{}, numColumns)
|
||||||
@@ -148,34 +158,23 @@ func populateRows(rr *sql.Rows, dest *qt.QTableWidget, pk_index int) {
|
|||||||
|
|
||||||
err := rr.Scan(pfields...)
|
err := rr.Scan(pfields...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
qt.QMessageBox_Warning(dest.QWidget, APPNAME, fmt.Sprintf("Failed to load data: %s", err.Error()))
|
return fmt.Errorf("Scan: %w", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rpos := dest.RowCount()
|
rpos := dest.AddRow()
|
||||||
dest.SetRowCount(rpos + 1)
|
|
||||||
for i := 0; i < len(fields); i += 1 {
|
for i := 0; i < len(fields); i += 1 {
|
||||||
|
dest.SetCell(rpos, i, formatAny(fields[i])) // FIXME stop doing string conversion here
|
||||||
|
}
|
||||||
|
|
||||||
cellItem := qt.NewQTableWidgetItem2(formatAny(fields[i]))
|
if pk_index >= 0 {
|
||||||
if i == pk_index {
|
dest.SetRowPrimaryKey(rpos, []byte(formatAny(fields[pk_index]))) // FIXME stop doing string conversion here
|
||||||
cellItem.SetData(DataPrimaryKeyRole, qt.NewQVariant11(formatAny(fields[i]))) // FIXME stop doing string conversion here
|
|
||||||
} else if pk_index < 0 {
|
|
||||||
// We do not have a primary key for this table
|
|
||||||
// Therefore - disable editing
|
|
||||||
cellItem.SetFlags(cellItem.Flags() & ^qt.ItemIsEditable)
|
|
||||||
}
|
|
||||||
|
|
||||||
dest.SetItem(rpos, i, cellItem)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if rr.Err() != nil {
|
return rr.Err()
|
||||||
qt.QMessageBox_Warning(dest.QWidget, APPNAME, fmt.Sprintf("Failed to load data: %s", rr.Err().Error()))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ld *sqliteLoadedDatabase) ExecQuery(query string, resultArea *qt.QTableWidget) error {
|
func (ld *sqliteLoadedDatabase) ExecQuery(query string, _ []string, resultArea *tableState) error {
|
||||||
rr, err := ld.db.Query(query)
|
rr, err := ld.db.Query(query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -183,8 +182,6 @@ func (ld *sqliteLoadedDatabase) ExecQuery(query string, resultArea *qt.QTableWid
|
|||||||
|
|
||||||
defer rr.Close()
|
defer rr.Close()
|
||||||
|
|
||||||
vcl_clear_grid(resultArea)
|
|
||||||
|
|
||||||
columns, err := rr.Columns()
|
columns, err := rr.Columns()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -192,11 +189,12 @@ func (ld *sqliteLoadedDatabase) ExecQuery(query string, resultArea *qt.QTableWid
|
|||||||
|
|
||||||
populateColumns(columns, resultArea)
|
populateColumns(columns, resultArea)
|
||||||
|
|
||||||
populateRows(rr, resultArea, -1)
|
err = populateRows(rr, resultArea, -1)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
resultArea.ResizeColumnsToContents()
|
resultArea.Ready()
|
||||||
resultArea.SetEnabled(true)
|
|
||||||
resultArea.EditTriggers()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,17 +208,13 @@ func (n *sqliteLoadedDatabase) getPrimaryKeyForTable(ctx context.Context, tx Row
|
|||||||
return primaryColumnName, err
|
return primaryColumnName, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *sqliteLoadedDatabase) ApplyChanges(f *App, bucketPath []string) (retErr error) {
|
func (n *sqliteLoadedDatabase) ApplyChanges(f *tableState, bucketPath []string) (retErr error) {
|
||||||
|
|
||||||
if len(bucketPath) != 2 {
|
if len(bucketPath) != 2 {
|
||||||
return errors.New("invalid selection")
|
return errors.New("invalid selection")
|
||||||
}
|
}
|
||||||
tableName := bucketPath[1]
|
tableName := bucketPath[1]
|
||||||
|
|
||||||
// We have rendered row IDs, need to convert back to an SQLite primary key
|
|
||||||
// TODO stash the real key inside f.ui.contentBox.Objects()
|
|
||||||
// FIXME breaks if you try and edit the primary key(!) because the previous
|
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
tx, err := n.db.BeginTx(ctx, nil)
|
tx, err := n.db.BeginTx(ctx, nil)
|
||||||
@@ -238,24 +232,12 @@ func (n *sqliteLoadedDatabase) ApplyChanges(f *App, bucketPath []string) (retErr
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Data grid properties
|
|
||||||
var columnNames []string
|
|
||||||
for i := 0; i < f.ui.contentBox.ColumnCount(); i++ {
|
|
||||||
columnNames = append(columnNames, f.ui.contentBox.HorizontalHeaderItem(i).Text())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Query sqlite table metadata to determine which of these is the PRIMARY KEY
|
// Query sqlite table metadata to determine which of these is the PRIMARY KEY
|
||||||
primaryColumnName, err := n.getPrimaryKeyForTable(ctx, tx, tableName)
|
primaryColumnName, err := n.getPrimaryKeyForTable(ctx, tx, tableName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Finding primary key for update: %w", err)
|
return fmt.Errorf("Finding primary key for update: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert it to an index
|
|
||||||
primaryColumnIdx, ok := slice_find(columnNames, primaryColumnName)
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("Primary key %q missing from available columns", primaryColumnName)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SQLite can only LIMIT 1 on update/delete if it was compiled with
|
// SQLite can only LIMIT 1 on update/delete if it was compiled with
|
||||||
// SQLITE_ENABLE_UPDATE_DELETE_LIMIT, which isn't the case for the mattn
|
// SQLITE_ENABLE_UPDATE_DELETE_LIMIT, which isn't the case for the mattn
|
||||||
// cgo library
|
// cgo library
|
||||||
@@ -263,22 +245,20 @@ func (n *sqliteLoadedDatabase) ApplyChanges(f *App, bucketPath []string) (retErr
|
|||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
for rowid, editcells := range f.updateRows {
|
for rowid, editcells := range f.updateRows {
|
||||||
stmt := `UPDATE "` + tableName + `" SET `
|
stmt := `UPDATE [` + tableName + `] SET `
|
||||||
params := []interface{}{} // FIXME reinstate types for the driver (although SQLite doesn't mind)
|
params := []interface{}{} // FIXME reinstate types for the driver (although SQLite doesn't mind)
|
||||||
|
|
||||||
for ct, cell := range editcells {
|
for ct, cell := range editcells {
|
||||||
if ct > 0 {
|
if ct > 0 {
|
||||||
stmt += `, `
|
stmt += `, `
|
||||||
}
|
}
|
||||||
stmt += `"` + columnNames[cell] + `" = ?`
|
stmt += `[` + f.columnLabels[cell] + `] = ?`
|
||||||
params = append(params, f.ui.contentBox.Item(rowid, cell).Text())
|
params = append(params, f.columns_inlineText[cell][rowid]) // FIXME stop doing string conversion
|
||||||
}
|
}
|
||||||
stmt += ` WHERE "` + primaryColumnName + `" = ?`
|
stmt += ` WHERE [` + primaryColumnName + `] = ?`
|
||||||
|
|
||||||
// The primary key was stashed in DataPrimaryKeyRole, on the pk_idx'th
|
// Update by primary key (stored separately)
|
||||||
// column, as a QString qvariant
|
pkVal := string(f.primaryKeys[rowid]) // FIXME avoid string marshalling
|
||||||
// FIXME avoid string marshalling
|
|
||||||
pkVal := f.ui.contentBox.Item(rowid, primaryColumnIdx).Data(DataPrimaryKeyRole).ToString()
|
|
||||||
params = append(params, pkVal)
|
params = append(params, pkVal)
|
||||||
|
|
||||||
_, err = tx.ExecContext(ctx, stmt, params...)
|
_, err = tx.ExecContext(ctx, stmt, params...)
|
||||||
@@ -289,9 +269,9 @@ func (n *sqliteLoadedDatabase) ApplyChanges(f *App, bucketPath []string) (retErr
|
|||||||
|
|
||||||
// Delete by key (affects rowids after re-render)
|
// Delete by key (affects rowids after re-render)
|
||||||
for rowid, _ := range f.deleteRows {
|
for rowid, _ := range f.deleteRows {
|
||||||
pkVal := f.ui.contentBox.Item(rowid, primaryColumnIdx).Text()
|
pkVal := string(f.primaryKeys[rowid]) // FIXME avoid string marshalling
|
||||||
|
|
||||||
stmt := `DELETE FROM "` + tableName + `" WHERE "` + primaryColumnName + `" = ?`
|
stmt := `DELETE FROM [` + tableName + `] WHERE [` + primaryColumnName + `] = ?`
|
||||||
|
|
||||||
_, err = tx.ExecContext(ctx, stmt, pkVal)
|
_, err = tx.ExecContext(ctx, stmt, pkVal)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -301,15 +281,15 @@ func (n *sqliteLoadedDatabase) ApplyChanges(f *App, bucketPath []string) (retErr
|
|||||||
|
|
||||||
// Insert all new entries
|
// Insert all new entries
|
||||||
for rowid, _ := range f.insertRows {
|
for rowid, _ := range f.insertRows {
|
||||||
stmt := `INSERT INTO "` + tableName + `" (` + strings.Join(columnNames, `, `) + `) VALUES (`
|
stmt := `INSERT INTO [` + tableName + `] ([` + strings.Join(f.columnLabels, `], [`) + `]) VALUES (`
|
||||||
params := []interface{}{} // FIXME reinstate types for the driver (although SQLite doesn't mind)
|
params := []interface{}{} // FIXME reinstate types for the driver (although SQLite doesn't mind)
|
||||||
|
|
||||||
for colid := 0; colid < len(columnNames); colid++ {
|
for colid := 0; colid < len(f.columnLabels); colid++ {
|
||||||
if colid > 0 {
|
if colid > 0 {
|
||||||
stmt += `, `
|
stmt += `, `
|
||||||
}
|
}
|
||||||
stmt += "?"
|
stmt += "?"
|
||||||
params = append(params, f.ui.contentBox.Item(rowid, colid).Text())
|
params = append(params, f.columns_inlineText[colid][rowid]) // FIXME stop doing string conversion
|
||||||
}
|
}
|
||||||
stmt += `)`
|
stmt += `)`
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/mappu/autoconfig"
|
"github.com/mappu/autoconfig"
|
||||||
qt "github.com/mappu/miqt/qt6"
|
|
||||||
"github.com/starskey-io/starskey"
|
"github.com/starskey-io/starskey"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -18,26 +17,27 @@ func (ld *starskeyLdb) DriverName() string {
|
|||||||
return "Starskey"
|
return "Starskey"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ld *starskeyLdb) RenderForNav(f *MainWindowUi, bucketPath []string) error {
|
func (ld *starskeyLdb) Properties(bucketPath []string) (string, error) {
|
||||||
|
return "", nil // No properties
|
||||||
|
}
|
||||||
|
|
||||||
// No properties
|
func (ld *starskeyLdb) RenderForNav(f *tableState, bucketPath []string) error {
|
||||||
|
|
||||||
// Load data
|
// Load data
|
||||||
// Starskey always uses Key + Value as the columns
|
// Starskey always uses Key + Value as the columns
|
||||||
|
|
||||||
f.contentBox.SetColumnCount(2)
|
f.SetupColumns([]columnType{columnType_popupData, columnType_popupData}, []string{"Key", "Value"})
|
||||||
f.contentBox.SetHorizontalHeaderLabels([]string{"Key", "Value"})
|
|
||||||
|
|
||||||
// It's possible to create a transaction in Starskey, but you can't enumerate keys
|
// It's possible to create a transaction in Starskey, but you can't enumerate keys
|
||||||
// within the transaction - doesn't really help us
|
// within the transaction - doesn't really help us
|
||||||
|
|
||||||
// We have to supply valid bounds that work for bytes.Compare
|
var allKeys [][]byte
|
||||||
// FIXME any better way to find all keys?
|
_, err := ld.db.FilterKeys(func(key []byte) bool {
|
||||||
earliestPossibleKey := []byte{0x00}
|
allKeys = append(allKeys, slice_dup(key))
|
||||||
lastPossibleKey := []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
|
return false // don't get value in here
|
||||||
allKeys, err := ld.db.Range(earliestPossibleKey, lastPossibleKey)
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("FilterKeys: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, key := range allKeys {
|
for _, key := range allKeys {
|
||||||
@@ -46,20 +46,25 @@ func (ld *starskeyLdb) RenderForNav(f *MainWindowUi, bucketPath []string) error
|
|||||||
// We get <nil, nil> if not found, so any error is a real error
|
// We get <nil, nil> if not found, so any error is a real error
|
||||||
return fmt.Errorf("Reading key %q: %w", string(key), err)
|
return fmt.Errorf("Reading key %q: %w", string(key), err)
|
||||||
}
|
}
|
||||||
|
if val == nil {
|
||||||
|
// Key not found
|
||||||
|
// The hack to use FilterKeys() means this can happen if the key is
|
||||||
|
// pointing to a tombstone
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
rpos := f.contentBox.RowCount()
|
f.AddRow_PK_Data(key, key, val)
|
||||||
f.contentBox.SetRowCount(rpos + 1)
|
|
||||||
|
|
||||||
f.contentBox.SetItem(rpos, 0, qt.NewQTableWidgetItem2(string(key)))
|
|
||||||
f.contentBox.SetItem(rpos, 1, qt.NewQTableWidgetItem2(string(val)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Valid
|
// Valid
|
||||||
f.contentBox.ResizeColumnsToContents()
|
f.Ready()
|
||||||
f.contentBox.SetEnabled(true)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n *starskeyLdb) ApplyChanges(f *tableState, bucketPath []string) error {
|
||||||
|
return kvstore_ApplyChanges(f, n.db.Put, n.db.Delete)
|
||||||
|
}
|
||||||
|
|
||||||
func (ld *starskeyLdb) NavChildren(bucketPath []string) ([]string, error) {
|
func (ld *starskeyLdb) NavChildren(bucketPath []string) ([]string, error) {
|
||||||
return []string{}, nil // No children
|
return []string{}, nil // No children
|
||||||
}
|
}
|
||||||
@@ -72,7 +77,8 @@ func (ld *starskeyLdb) Close() {
|
|||||||
_ = ld.db.Close()
|
_ = ld.db.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ loadedDatabase = &starskeyLdb{} // interface assertion
|
var _ loadedDatabase = &starskeyLdb{} // interface assertion
|
||||||
|
var _ editableLoadedDatabase = &starskeyLdb{} // interface assertion
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,16 @@ type Database struct {
|
|||||||
AllColumnNames []string
|
AllColumnNames []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *Database) FindApplicationByName(search string) (*Application, bool) {
|
||||||
|
for idx, app := range d.Entries {
|
||||||
|
if app.Name == search {
|
||||||
|
return &d.Entries[idx], true // TODO faster lookup?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
|
||||||
func Parse(r io.Reader) (*Database, error) {
|
func Parse(r io.Reader) (*Database, error) {
|
||||||
sc := bufio.NewScanner(r)
|
sc := bufio.NewScanner(r)
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
<file>assets/vendor_github.png</file>
|
<file>assets/vendor_github.png</file>
|
||||||
<file>assets/vendor_leveldb.png</file>
|
<file>assets/vendor_leveldb.png</file>
|
||||||
<file>assets/vendor_lmdb.png</file>
|
<file>assets/vendor_lmdb.png</file>
|
||||||
|
<file>assets/vendor_mongodb.png</file>
|
||||||
<file>assets/vendor_mysql.png</file>
|
<file>assets/vendor_mysql.png</file>
|
||||||
<file>assets/vendor_redis.png</file>
|
<file>assets/vendor_redis.png</file>
|
||||||
<file>assets/vendor_sqlite.png</file>
|
<file>assets/vendor_sqlite.png</file>
|
||||||
|
|||||||
48
go.mod
48
go.mod
@@ -7,19 +7,24 @@ toolchain go1.24.4
|
|||||||
require (
|
require (
|
||||||
github.com/cockroachdb/pebble v1.1.5
|
github.com/cockroachdb/pebble v1.1.5
|
||||||
github.com/dgraph-io/badger/v4 v4.8.0
|
github.com/dgraph-io/badger/v4 v4.8.0
|
||||||
|
github.com/godbus/dbus/v5 v5.2.0
|
||||||
github.com/google/uuid v1.6.0
|
github.com/google/uuid v1.6.0
|
||||||
github.com/mappu/autoconfig v0.3.1-0.20251126064959-64718706eb2a
|
github.com/ledgerwatch/lmdb-go v1.18.2
|
||||||
|
github.com/mappu/autoconfig v0.4.1
|
||||||
github.com/mappu/miqt v0.12.1-0.20251106063543-466b60e47edf
|
github.com/mappu/miqt v0.12.1-0.20251106063543-466b60e47edf
|
||||||
github.com/mattn/go-sqlite3 v1.14.32
|
github.com/mattn/go-sqlite3 v1.14.32
|
||||||
github.com/redis/go-redis/v9 v9.16.0
|
github.com/redis/go-redis/v9 v9.17.2
|
||||||
|
github.com/starskey-io/starskey v0.1.9
|
||||||
github.com/stretchr/testify v1.11.1
|
github.com/stretchr/testify v1.11.1
|
||||||
github.com/syndtr/goleveldb v1.0.0
|
github.com/syndtr/goleveldb v1.0.0
|
||||||
|
github.com/zalando/go-keyring v0.2.6
|
||||||
go.etcd.io/bbolt v1.4.3
|
go.etcd.io/bbolt v1.4.3
|
||||||
golang.org/x/crypto v0.44.0
|
go.mongodb.org/mongo-driver/v2 v2.4.1
|
||||||
|
golang.org/x/crypto v0.46.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
al.essio.dev/pkg/shellescape v1.5.1 // indirect
|
al.essio.dev/pkg/shellescape v1.6.0 // indirect
|
||||||
github.com/DataDog/zstd v1.5.7 // indirect
|
github.com/DataDog/zstd v1.5.7 // indirect
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
@@ -28,44 +33,45 @@ require (
|
|||||||
github.com/cockroachdb/logtags v0.0.0-20241215232642-bb51bb14a506 // indirect
|
github.com/cockroachdb/logtags v0.0.0-20241215232642-bb51bb14a506 // indirect
|
||||||
github.com/cockroachdb/redact v1.1.6 // indirect
|
github.com/cockroachdb/redact v1.1.6 // indirect
|
||||||
github.com/cockroachdb/tokenbucket v0.0.0-20250429170803-42689b6311bb // indirect
|
github.com/cockroachdb/tokenbucket v0.0.0-20250429170803-42689b6311bb // indirect
|
||||||
github.com/danieljoos/wincred v1.2.2 // indirect
|
github.com/danieljoos/wincred v1.2.3 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/dgraph-io/ristretto/v2 v2.3.0 // indirect
|
github.com/dgraph-io/ristretto/v2 v2.3.0 // indirect
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||||
github.com/getsentry/sentry-go v0.36.2 // indirect
|
github.com/getsentry/sentry-go v0.40.0 // indirect
|
||||||
github.com/go-logr/logr v1.4.3 // indirect
|
github.com/go-logr/logr v1.4.3 // indirect
|
||||||
github.com/go-logr/stdr v1.2.2 // indirect
|
github.com/go-logr/stdr v1.2.2 // indirect
|
||||||
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
|
||||||
github.com/gogo/protobuf v1.3.2 // indirect
|
github.com/gogo/protobuf v1.3.2 // indirect
|
||||||
github.com/golang/snappy v1.0.0 // indirect
|
github.com/golang/snappy v1.0.0 // indirect
|
||||||
github.com/google/flatbuffers v25.9.23+incompatible // indirect
|
github.com/google/flatbuffers v25.9.23+incompatible // indirect
|
||||||
github.com/klauspost/compress v1.18.1 // indirect
|
github.com/klauspost/compress v1.18.2 // indirect
|
||||||
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
|
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
||||||
github.com/kr/pretty v0.3.1 // indirect
|
github.com/kr/pretty v0.3.1 // indirect
|
||||||
github.com/kr/text v0.2.0 // indirect
|
github.com/kr/text v0.2.0 // indirect
|
||||||
github.com/ledgerwatch/lmdb-go v1.18.2 // indirect
|
|
||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/prometheus/client_golang v1.23.2 // indirect
|
github.com/prometheus/client_golang v1.23.2 // indirect
|
||||||
github.com/prometheus/client_model v0.6.2 // indirect
|
github.com/prometheus/client_model v0.6.2 // indirect
|
||||||
github.com/prometheus/common v0.67.2 // indirect
|
github.com/prometheus/common v0.67.4 // indirect
|
||||||
github.com/prometheus/procfs v0.19.2 // indirect
|
github.com/prometheus/procfs v0.19.2 // indirect
|
||||||
github.com/rogpeppe/go-internal v1.14.1 // indirect
|
github.com/rogpeppe/go-internal v1.14.1 // indirect
|
||||||
github.com/starskey-io/starskey v0.1.9 // indirect
|
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
|
||||||
github.com/zalando/go-keyring v0.2.6 // indirect
|
github.com/xdg-go/scram v1.2.0 // indirect
|
||||||
|
github.com/xdg-go/stringprep v1.0.4 // indirect
|
||||||
|
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
|
||||||
github.com/zeebo/xxh3 v1.0.2 // indirect
|
github.com/zeebo/xxh3 v1.0.2 // indirect
|
||||||
go.mongodb.org/mongo-driver v1.17.2 // indirect
|
go.mongodb.org/mongo-driver v1.17.6 // indirect
|
||||||
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
|
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
|
||||||
go.opentelemetry.io/otel v1.38.0 // indirect
|
go.opentelemetry.io/otel v1.39.0 // indirect
|
||||||
go.opentelemetry.io/otel/metric v1.38.0 // indirect
|
go.opentelemetry.io/otel/metric v1.39.0 // indirect
|
||||||
go.opentelemetry.io/otel/trace v1.38.0 // indirect
|
go.opentelemetry.io/otel/trace v1.39.0 // indirect
|
||||||
go.yaml.in/yaml/v2 v2.4.3 // indirect
|
go.yaml.in/yaml/v2 v2.4.3 // indirect
|
||||||
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 // indirect
|
golang.org/x/exp v0.0.0-20251209150349-8475f28825e9 // indirect
|
||||||
golang.org/x/net v0.46.0 // indirect
|
golang.org/x/net v0.48.0 // indirect
|
||||||
golang.org/x/sys v0.38.0 // indirect
|
golang.org/x/sync v0.19.0 // indirect
|
||||||
golang.org/x/text v0.31.0 // indirect
|
golang.org/x/sys v0.39.0 // indirect
|
||||||
|
golang.org/x/text v0.32.0 // indirect
|
||||||
google.golang.org/protobuf v1.36.10 // indirect
|
google.golang.org/protobuf v1.36.10 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
117
go.sum
117
go.sum
@@ -1,5 +1,5 @@
|
|||||||
al.essio.dev/pkg/shellescape v1.5.1 h1:86HrALUujYS/h+GtqoB26SBEdkWfmMI6FubjXlsXyho=
|
al.essio.dev/pkg/shellescape v1.6.0 h1:NxFcEqzFSEVCGN2yq7Huv/9hyCEGVa/TncnOOBBeXHA=
|
||||||
al.essio.dev/pkg/shellescape v1.5.1/go.mod h1:6sIqp7X2P6mThCQ7twERpZTuigpr6KbZWtls1U8I890=
|
al.essio.dev/pkg/shellescape v1.6.0/go.mod h1:6sIqp7X2P6mThCQ7twERpZTuigpr6KbZWtls1U8I890=
|
||||||
github.com/DataDog/zstd v1.5.7 h1:ybO8RBeh29qrxIhCA9E8gKY6xfONU9T6G6aP9DTKfLE=
|
github.com/DataDog/zstd v1.5.7 h1:ybO8RBeh29qrxIhCA9E8gKY6xfONU9T6G6aP9DTKfLE=
|
||||||
github.com/DataDog/zstd v1.5.7/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
|
github.com/DataDog/zstd v1.5.7/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
|
||||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||||
@@ -25,8 +25,8 @@ github.com/cockroachdb/redact v1.1.6/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZ
|
|||||||
github.com/cockroachdb/tokenbucket v0.0.0-20250429170803-42689b6311bb h1:3bCgBvB8PbJVMX1ouCcSIxvsqKPYM7gs72o0zC76n9g=
|
github.com/cockroachdb/tokenbucket v0.0.0-20250429170803-42689b6311bb h1:3bCgBvB8PbJVMX1ouCcSIxvsqKPYM7gs72o0zC76n9g=
|
||||||
github.com/cockroachdb/tokenbucket v0.0.0-20250429170803-42689b6311bb/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ=
|
github.com/cockroachdb/tokenbucket v0.0.0-20250429170803-42689b6311bb/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ=
|
||||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
github.com/danieljoos/wincred v1.2.2 h1:774zMFJrqaeYCK2W57BgAem/MLi6mtSE47MB6BOJ0i0=
|
github.com/danieljoos/wincred v1.2.3 h1:v7dZC2x32Ut3nEfRH+vhoZGvN72+dQ/snVXo/vMFLdQ=
|
||||||
github.com/danieljoos/wincred v1.2.2/go.mod h1:w7w4Utbrz8lqeMbDAK0lkNJUv5sAOkFi7nd/ogr0Uh8=
|
github.com/danieljoos/wincred v1.2.3/go.mod h1:6qqX0WNrS4RzPZ1tnroDzq9kY3fu1KwE7MRLQK4X0bs=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dgraph-io/badger/v4 v4.8.0 h1:JYph1ChBijCw8SLeybvPINizbDKWZ5n/GYbz2yhN/bs=
|
github.com/dgraph-io/badger/v4 v4.8.0 h1:JYph1ChBijCw8SLeybvPINizbDKWZ5n/GYbz2yhN/bs=
|
||||||
@@ -40,8 +40,8 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cu
|
|||||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
github.com/getsentry/sentry-go v0.36.2 h1:uhuxRPTrUy0dnSzTd0LrYXlBYygLkKY0hhlG5LXarzM=
|
github.com/getsentry/sentry-go v0.40.0 h1:VTJMN9zbTvqDqPwheRVLcp0qcUcM+8eFivvGocAaSbo=
|
||||||
github.com/getsentry/sentry-go v0.36.2/go.mod h1:p5Im24mJBeruET8Q4bbcMfCQ+F+Iadc4L48tB1apo2c=
|
github.com/getsentry/sentry-go v0.40.0/go.mod h1:eRXCoh3uvmjQLY6qu63BjUZnaBu5L5WhMV1RwYO8W5s=
|
||||||
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
|
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
|
||||||
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
|
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
|
||||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||||
@@ -49,8 +49,8 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
|||||||
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||||
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
|
github.com/godbus/dbus/v5 v5.2.0 h1:3WexO+U+yg9T70v9FdHr9kCxYlazaAXUhx2VMkbfax8=
|
||||||
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
github.com/godbus/dbus/v5 v5.2.0/go.mod h1:3AAv2+hPq5rdnr5txxxRwiGjPXamgoIHgz9FPBfOp3c=
|
||||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
@@ -61,30 +61,26 @@ github.com/google/flatbuffers v25.9.23+incompatible h1:rGZKv+wOb6QPzIdkM2KxhBZCD
|
|||||||
github.com/google/flatbuffers v25.9.23+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
|
github.com/google/flatbuffers v25.9.23+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
|
||||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||||
|
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
|
||||||
|
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
|
||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co=
|
github.com/klauspost/compress v1.18.2 h1:iiPHWW0YrcFgpBYhsA6D1+fqHssJscY/Tm/y2Uqnapk=
|
||||||
github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0=
|
github.com/klauspost/compress v1.18.2/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4=
|
||||||
github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
|
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
|
||||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
github.com/ledgerwatch/lmdb-go v1.18.2 h1:6YKp/KYcqGunNRHKZBBhiYADcIcWKzvu5QZv89RhnFQ=
|
github.com/ledgerwatch/lmdb-go v1.18.2 h1:6YKp/KYcqGunNRHKZBBhiYADcIcWKzvu5QZv89RhnFQ=
|
||||||
github.com/ledgerwatch/lmdb-go v1.18.2/go.mod h1:NKRpCxksoTQPyxsUcBiVOe0135uqnJsnf6cElxmOL0o=
|
github.com/ledgerwatch/lmdb-go v1.18.2/go.mod h1:NKRpCxksoTQPyxsUcBiVOe0135uqnJsnf6cElxmOL0o=
|
||||||
github.com/mappu/autoconfig v0.1.0 h1:T740iW7/rkqi+pxJIlP+WB433h34jNRjqqG9ABTSScs=
|
github.com/mappu/autoconfig v0.4.1 h1:ekO7mzN+beFu7VhNfJxNlL/5wkYcP9PAl9VTG4EDxYs=
|
||||||
github.com/mappu/autoconfig v0.1.0/go.mod h1:kca6kaYjqOwkZnY9z5YKo0oI/7Bxe2fMIHhYzXwGHEE=
|
github.com/mappu/autoconfig v0.4.1/go.mod h1:kca6kaYjqOwkZnY9z5YKo0oI/7Bxe2fMIHhYzXwGHEE=
|
||||||
github.com/mappu/autoconfig v0.2.0 h1:5auhryqiubVBFq9CdY+VHU36bysG70tRGPpyT+M4ycs=
|
|
||||||
github.com/mappu/autoconfig v0.2.0/go.mod h1:kca6kaYjqOwkZnY9z5YKo0oI/7Bxe2fMIHhYzXwGHEE=
|
|
||||||
github.com/mappu/autoconfig v0.3.1-0.20251126064959-64718706eb2a h1:3vhzzO7RLT9qx3kWaPrHTS52pt7ENCRNbeJlkyWfEzw=
|
|
||||||
github.com/mappu/autoconfig v0.3.1-0.20251126064959-64718706eb2a/go.mod h1:kca6kaYjqOwkZnY9z5YKo0oI/7Bxe2fMIHhYzXwGHEE=
|
|
||||||
github.com/mappu/miqt v0.12.0 h1:bBMBDeACmV8TbdLfoN51la7kF6QT3sNAcG+ZdRDgmxU=
|
|
||||||
github.com/mappu/miqt v0.12.0/go.mod h1:xFg7ADaO1QSkmXPsPODoKe/bydJpRG9fgCYyIDl/h1U=
|
|
||||||
github.com/mappu/miqt v0.12.1-0.20251106063543-466b60e47edf h1:SmBzNUevLUzu1msJ5xzWH/Kot+GtOtoz0u9la42dRU4=
|
github.com/mappu/miqt v0.12.1-0.20251106063543-466b60e47edf h1:SmBzNUevLUzu1msJ5xzWH/Kot+GtOtoz0u9la42dRU4=
|
||||||
github.com/mappu/miqt v0.12.1-0.20251106063543-466b60e47edf/go.mod h1:xFg7ADaO1QSkmXPsPODoKe/bydJpRG9fgCYyIDl/h1U=
|
github.com/mappu/miqt v0.12.1-0.20251106063543-466b60e47edf/go.mod h1:xFg7ADaO1QSkmXPsPODoKe/bydJpRG9fgCYyIDl/h1U=
|
||||||
github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs=
|
github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs=
|
||||||
@@ -107,39 +103,54 @@ github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h
|
|||||||
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
|
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
|
||||||
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
|
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
|
||||||
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
|
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
|
||||||
github.com/prometheus/common v0.67.2 h1:PcBAckGFTIHt2+L3I33uNRTlKTplNzFctXcWhPyAEN8=
|
github.com/prometheus/common v0.67.4 h1:yR3NqWO1/UyO1w2PhUvXlGQs/PtFmoveVO0KZ4+Lvsc=
|
||||||
github.com/prometheus/common v0.67.2/go.mod h1:63W3KZb1JOKgcjlIr64WW/LvFGAqKPj0atm+knVGEko=
|
github.com/prometheus/common v0.67.4/go.mod h1:gP0fq6YjjNCLssJCQp0yk4M8W6ikLURwkdd/YKtTbyI=
|
||||||
github.com/prometheus/procfs v0.19.2 h1:zUMhqEW66Ex7OXIiDkll3tl9a1ZdilUOd/F6ZXw4Vws=
|
github.com/prometheus/procfs v0.19.2 h1:zUMhqEW66Ex7OXIiDkll3tl9a1ZdilUOd/F6ZXw4Vws=
|
||||||
github.com/prometheus/procfs v0.19.2/go.mod h1:M0aotyiemPhBCM0z5w87kL22CxfcH05ZpYlu+b4J7mw=
|
github.com/prometheus/procfs v0.19.2/go.mod h1:M0aotyiemPhBCM0z5w87kL22CxfcH05ZpYlu+b4J7mw=
|
||||||
github.com/redis/go-redis/v9 v9.16.0 h1:OotgqgLSRCmzfqChbQyG1PHC3tLNR89DG4jdOERSEP4=
|
github.com/redis/go-redis/v9 v9.17.2 h1:P2EGsA4qVIM3Pp+aPocCJ7DguDHhqrXNhVcEp4ViluI=
|
||||||
github.com/redis/go-redis/v9 v9.16.0/go.mod h1:u410H11HMLoB+TP67dz8rL9s6QW2j76l0//kSOd3370=
|
github.com/redis/go-redis/v9 v9.17.2/go.mod h1:u410H11HMLoB+TP67dz8rL9s6QW2j76l0//kSOd3370=
|
||||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||||
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||||
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
||||||
github.com/starskey-io/starskey v0.1.9 h1:lABmD5KQgkpJZTCwSt+BHSOPXe82B9smbuScRL6T8Zk=
|
github.com/starskey-io/starskey v0.1.9 h1:lABmD5KQgkpJZTCwSt+BHSOPXe82B9smbuScRL6T8Zk=
|
||||||
github.com/starskey-io/starskey v0.1.9/go.mod h1:qly4ec2C/4Y45jhpL+q4m+Uxzg3mjj0t7RjpJslB3ao=
|
github.com/starskey-io/starskey v0.1.9/go.mod h1:qly4ec2C/4Y45jhpL+q4m+Uxzg3mjj0t7RjpJslB3ao=
|
||||||
|
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
|
||||||
|
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||||
github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE=
|
github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE=
|
||||||
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
|
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
|
||||||
|
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
|
||||||
|
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
|
||||||
|
github.com/xdg-go/scram v1.2.0 h1:bYKF2AEwG5rqd1BumT4gAnvwU/M9nBp2pTSxeZw7Wvs=
|
||||||
|
github.com/xdg-go/scram v1.2.0/go.mod h1:3dlrS0iBaWKYVt2ZfA4cj48umJZ+cAEbR6/SjLA88I8=
|
||||||
|
github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8=
|
||||||
|
github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=
|
||||||
|
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM=
|
||||||
|
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI=
|
||||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
github.com/zalando/go-keyring v0.2.6 h1:r7Yc3+H+Ux0+M72zacZoItR3UDxeWfKTcabvkI8ua9s=
|
github.com/zalando/go-keyring v0.2.6 h1:r7Yc3+H+Ux0+M72zacZoItR3UDxeWfKTcabvkI8ua9s=
|
||||||
github.com/zalando/go-keyring v0.2.6/go.mod h1:2TCrxYrbUNYfNS/Kgy/LSrkSQzZ5UPVH85RwfczwvcI=
|
github.com/zalando/go-keyring v0.2.6/go.mod h1:2TCrxYrbUNYfNS/Kgy/LSrkSQzZ5UPVH85RwfczwvcI=
|
||||||
|
github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ=
|
||||||
|
github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
|
||||||
github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0=
|
github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0=
|
||||||
github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA=
|
github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA=
|
||||||
go.etcd.io/bbolt v1.4.3 h1:dEadXpI6G79deX5prL3QRNP6JB8UxVkqo4UPnHaNXJo=
|
go.etcd.io/bbolt v1.4.3 h1:dEadXpI6G79deX5prL3QRNP6JB8UxVkqo4UPnHaNXJo=
|
||||||
go.etcd.io/bbolt v1.4.3/go.mod h1:tKQlpPaYCVFctUIgFKFnAlvbmB3tpy1vkTnDWohtc0E=
|
go.etcd.io/bbolt v1.4.3/go.mod h1:tKQlpPaYCVFctUIgFKFnAlvbmB3tpy1vkTnDWohtc0E=
|
||||||
go.mongodb.org/mongo-driver v1.17.2 h1:gvZyk8352qSfzyZ2UMWcpDpMSGEr1eqE4T793SqyhzM=
|
go.mongodb.org/mongo-driver v1.17.6 h1:87JUG1wZfWsr6rIz3ZmpH90rL5tea7O3IHuSwHUpsss=
|
||||||
go.mongodb.org/mongo-driver v1.17.2/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ=
|
go.mongodb.org/mongo-driver v1.17.6/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ=
|
||||||
|
go.mongodb.org/mongo-driver/v2 v2.4.1 h1:hGDMngUao03OVQ6sgV5csk+RWOIkF+CuLsTPobNMGNI=
|
||||||
|
go.mongodb.org/mongo-driver/v2 v2.4.1/go.mod h1:jHeEDJHJq7tm6ZF45Issun9dbogjfnPySb1vXA7EeAI=
|
||||||
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
|
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
|
||||||
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
|
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
|
||||||
go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8=
|
go.opentelemetry.io/otel v1.39.0 h1:8yPrr/S0ND9QEfTfdP9V+SiwT4E0G7Y5MO7p85nis48=
|
||||||
go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM=
|
go.opentelemetry.io/otel v1.39.0/go.mod h1:kLlFTywNWrFyEdH0oj2xK0bFYZtHRYUdv1NklR/tgc8=
|
||||||
go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA=
|
go.opentelemetry.io/otel/metric v1.39.0 h1:d1UzonvEZriVfpNKEVmHXbdf909uGTOQjA0HF0Ls5Q0=
|
||||||
go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI=
|
go.opentelemetry.io/otel/metric v1.39.0/go.mod h1:jrZSWL33sD7bBxg1xjrqyDjnuzTUB0x1nBERXd7Ftcs=
|
||||||
go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE=
|
go.opentelemetry.io/otel/trace v1.39.0 h1:2d2vfpEDmCJ5zVYz7ijaJdOF59xLomrvj7bjt6/qCJI=
|
||||||
go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs=
|
go.opentelemetry.io/otel/trace v1.39.0/go.mod h1:88w4/PnZSazkGzz/w84VHpQafiU4EtqqlVdxWy+rNOA=
|
||||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||||
go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0=
|
go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0=
|
||||||
@@ -147,41 +158,55 @@ go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8=
|
|||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.44.0 h1:A97SsFvM3AIwEEmTBiaxPPTYpDC47w720rdiiUvgoAU=
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
golang.org/x/crypto v0.44.0/go.mod h1:013i+Nw79BMiQiMsOPcVCB5ZIJbYkerPrGnOa00tvmc=
|
golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU=
|
||||||
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 h1:mgKeJMpvi0yx/sU5GsxQ7p6s2wtOnGAHZWCHUM4KGzY=
|
golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0=
|
||||||
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546/go.mod h1:j/pmGrbnkbPtQfxEe5D0VQhZC6qKbfKifgD0oM7sR70=
|
golang.org/x/exp v0.0.0-20251209150349-8475f28825e9 h1:MDfG8Cvcqlt9XXrmEiD4epKn7VJHZO84hejP9Jmp0MM=
|
||||||
|
golang.org/x/exp v0.0.0-20251209150349-8475f28825e9/go.mod h1:EPRbTFwzwjXj9NpYyyrvenVh9Y+GFeEvMNh7Xuz7xgU=
|
||||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4=
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210=
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
|
golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU=
|
||||||
|
golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY=
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I=
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
|
||||||
|
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU=
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254=
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
|
||||||
|
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||||
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
|
golang.org/x/term v0.38.0 h1:PQ5pkm/rLO6HnxFR7N2lJHOZX6Kez5Y1gDSJla6jo7Q=
|
||||||
|
golang.org/x/term v0.38.0/go.mod h1:bSEAKrOT1W+VSu9TSCMtoGEOUcKxOKgl3LE5QEF/xVg=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
|
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
|
||||||
|
golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
|
||||||
|
golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||||
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
|||||||
@@ -16,16 +16,17 @@ type contextAction struct {
|
|||||||
// loadedDatabase is a DB-agnostic interface for each loaded database.
|
// loadedDatabase is a DB-agnostic interface for each loaded database.
|
||||||
type loadedDatabase interface {
|
type loadedDatabase interface {
|
||||||
DriverName() string
|
DriverName() string
|
||||||
RenderForNav(f *MainWindowUi, bucketPath []string) error
|
Properties(bucketPath []string) (string, error)
|
||||||
|
RenderForNav(f *tableState, bucketPath []string) error
|
||||||
NavChildren(bucketPath []string) ([]string, error)
|
NavChildren(bucketPath []string) ([]string, error)
|
||||||
NavContext(bucketPath []string) ([]contextAction, error)
|
NavContext(bucketPath []string) ([]contextAction, error)
|
||||||
Close()
|
Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
type queryableLoadedDatabase interface {
|
type queryableLoadedDatabase interface {
|
||||||
ExecQuery(query string, resultArea *qt.QTableWidget) error
|
ExecQuery(query string, bucketPath []string, resultArea *tableState) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type editableLoadedDatabase interface {
|
type editableLoadedDatabase interface {
|
||||||
ApplyChanges(f *App, bucketPath []string) error
|
ApplyChanges(f *tableState, bucketPath []string) error
|
||||||
}
|
}
|
||||||
|
|||||||
250
main.go
250
main.go
@@ -8,31 +8,26 @@ import (
|
|||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/mappu/miqt/qt/mainthread"
|
||||||
|
|
||||||
qt "github.com/mappu/miqt/qt6"
|
qt "github.com/mappu/miqt/qt6"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
APPNAME = "yvbolt"
|
APPNAME = "yvbolt"
|
||||||
HOMEPAGE_URL = "https://code.ivysaur.me/yvbolt"
|
HOMEPAGE_URL = "https://code.ivysaur.me/yvbolt"
|
||||||
|
|
||||||
CO_INSERT = qt.Yellow
|
|
||||||
CO_EDIT_IMPLICIT = qt.Green
|
|
||||||
CO_EDIT_EXPLICIT = qt.DarkGreen
|
|
||||||
CO_DELETE = qt.Red
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type App struct {
|
type App struct {
|
||||||
ui *MainWindowUi
|
ui *MainWindowUi
|
||||||
|
|
||||||
|
contentTbl *tableState
|
||||||
|
resultsTbl *tableState
|
||||||
|
|
||||||
none *noLoadedDatabase
|
none *noLoadedDatabase
|
||||||
|
|
||||||
dbs_next int
|
dbs_next int
|
||||||
dbs map[int]loadedDatabase
|
dbs map[int]loadedDatabase
|
||||||
|
|
||||||
isEditing bool
|
|
||||||
updateRows map[int][]int // row => []column
|
|
||||||
insertRows map[int]struct{}
|
|
||||||
deleteRows map[int]struct{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newApp() *App {
|
func newApp() *App {
|
||||||
@@ -42,11 +37,6 @@ func newApp() *App {
|
|||||||
a.dbs_next = 0
|
a.dbs_next = 0
|
||||||
a.dbs = make(map[int]loadedDatabase, 0)
|
a.dbs = make(map[int]loadedDatabase, 0)
|
||||||
|
|
||||||
a.isEditing = false
|
|
||||||
a.updateRows = make(map[int][]int, 0)
|
|
||||||
a.insertRows = make(map[int]struct{}, 0)
|
|
||||||
a.deleteRows = make(map[int]struct{}, 0)
|
|
||||||
|
|
||||||
a.ui = NewMainWindowUi()
|
a.ui = NewMainWindowUi()
|
||||||
|
|
||||||
// Using stylesheet works better than picking a palette colour across all
|
// Using stylesheet works better than picking a palette colour across all
|
||||||
@@ -86,36 +76,37 @@ func newApp() *App {
|
|||||||
//
|
//
|
||||||
|
|
||||||
a.ui.actionRefresh.OnTriggered(a.RefreshCurrentItem)
|
a.ui.actionRefresh.OnTriggered(a.RefreshCurrentItem)
|
||||||
a.ui.actionAddRow.OnTriggered(a.OnDataInsertClick)
|
|
||||||
a.ui.actionDelete_row.OnTriggered(a.OnDataDeleteRowClick)
|
|
||||||
a.ui.actionApply_changes.OnTriggered(a.OnDataCommitClick)
|
|
||||||
|
|
||||||
a.ui.actionAbout_Qt.OnTriggered(func() {
|
a.ui.actionAbout_Qt.OnTriggered(func() {
|
||||||
qt.QMessageBox_AboutQt2(a.ui.MainWindow.QWidget, APPNAME)
|
qt.QMessageBox_AboutQt2(a.ui.MainWindow.QWidget, APPNAME)
|
||||||
})
|
})
|
||||||
|
|
||||||
// contentBox: set editable
|
a.contentTbl = NewTableState(a.ui.contentBox)
|
||||||
vcl_clear_grid(a.ui.contentBox)
|
a.contentTbl.OnEdited = func() {
|
||||||
a.ui.contentBox.SetHorizontalScrollMode(qt.QAbstractItemView__ScrollPerPixel)
|
a.ui.actionApply_changes.SetEnabled(a.contentTbl.AnyChanges())
|
||||||
a.ui.contentBox.SetVerticalScrollMode(qt.QAbstractItemView__ScrollPerPixel)
|
}
|
||||||
a.ui.contentBox.OnCellChanged(a.OnDataCellEdited)
|
a.ui.actionDelete_row.OnTriggered(func() {
|
||||||
|
a.contentTbl.DeleteSelectedRows()
|
||||||
|
})
|
||||||
|
a.ui.actionAddRow.OnTriggered(func() {
|
||||||
|
a.contentTbl.InsertNewRow()
|
||||||
|
})
|
||||||
|
a.ui.actionApply_changes.OnTriggered(a.OnDataCommitClick)
|
||||||
|
|
||||||
// a.ui.queryInput.OnTextChanged(a.OnQueryTextChanged) // apply syntax highlighting
|
// a.ui.queryInput.OnTextChanged(a.OnQueryTextChanged) // apply syntax highlighting
|
||||||
|
|
||||||
a.ui.mnuExecute.OnTriggered(a.OnQueryExecute)
|
a.ui.mnuExecute.OnTriggered(a.OnQueryExecute)
|
||||||
|
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
a.ui.queryInput.SetFontFamily("Consolas")
|
a.ui.queryInput.SetFont(qt.NewQFont2("Consolas"))
|
||||||
} else {
|
} else {
|
||||||
a.ui.queryInput.SetFontFamily("monospace")
|
a.ui.queryInput.SetFont(qt.NewQFont2("monospace"))
|
||||||
}
|
}
|
||||||
|
|
||||||
vcl_clear_grid(a.ui.queryResult)
|
a.resultsTbl = NewTableState(a.ui.queryResult)
|
||||||
a.ui.queryResult.SetHorizontalScrollMode(qt.QAbstractItemView__ScrollPerPixel)
|
|
||||||
a.ui.queryResult.SetVerticalScrollMode(qt.QAbstractItemView__ScrollPerPixel)
|
|
||||||
|
|
||||||
a.none = &noLoadedDatabase{}
|
a.none = &noLoadedDatabase{}
|
||||||
a.OnNavChange(nil, nil) // calls f.none.RenderForNav and sets up status bar content
|
a.refreshContent(nil) // calls f.none.RenderForNav and sets up status bar content
|
||||||
|
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
@@ -168,7 +159,7 @@ func (f *App) OnMenuHelpVersion() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qt.QMessageBox_About(f.ui.MainWindow.QWidget, APPNAME, info)
|
qt.QMessageBox_About(f.ui.MainWindow.QWidget, APPNAME+" "+appVersion, info)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *App) OnNavContextPopup(pos *qt.QPoint) {
|
func (f *App) OnNavContextPopup(pos *qt.QPoint) {
|
||||||
@@ -236,18 +227,8 @@ func (f *App) RefreshCurrentItem() {
|
|||||||
return // nothing to do
|
return // nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there were any edited rows, refreshing will lose them
|
|
||||||
// Prompt for confirmation first
|
|
||||||
// FIXME this should also trigger when changing selection on LHS nav??
|
|
||||||
if len(f.deleteRows) > 0 || len(f.updateRows) > 0 || len(f.deleteRows) > 0 {
|
|
||||||
ok := qt.QMessageBox_Warning2(f.ui.MainWindow.QWidget, APPNAME, "Your modifications have not been applied. Continue without applying?", qt.QMessageBox__Ok, qt.QMessageBox__Cancel)
|
|
||||||
if ok != int(qt.QMessageBox__Ok) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
f.OnNavContextRefresh(curItem) // Refresh LHS pane/children
|
f.OnNavContextRefresh(curItem) // Refresh LHS pane/children
|
||||||
f.OnNavChange(curItem, curItem) // Refresh RHS pane/data content
|
f.OnNavChange(curItem, curItem) // Refresh RHS pane/data content and warn if unsaved changes
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *App) OnNavContextRefresh(item *qt.QTreeWidgetItem) {
|
func (f *App) OnNavContextRefresh(item *qt.QTreeWidgetItem) {
|
||||||
@@ -272,101 +253,17 @@ func (f *App) OnNavContextRefresh(item *qt.QTreeWidgetItem) {
|
|||||||
item.SetExpanded(isExpanded)
|
item.SetExpanded(isExpanded)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *App) OnDataCellEdited(aRow, aCol int) {
|
|
||||||
|
|
||||||
if !f.isEditing {
|
|
||||||
return // current in full table refresh, this signal is not a true edit
|
|
||||||
}
|
|
||||||
|
|
||||||
// If this is an insert row, no need to patch updateRows
|
|
||||||
if _, ok := f.insertRows[aRow]; ok {
|
|
||||||
return // nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
if chk, ok := f.updateRows[aRow]; ok {
|
|
||||||
if slice_contains(chk, aCol) {
|
|
||||||
return // nothing to do
|
|
||||||
} else {
|
|
||||||
chk = append(chk, aCol)
|
|
||||||
f.updateRows[aRow] = chk
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
f.updateRows[aRow] = []int{aCol}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If this row was marked for deletion, this new edit takes priority
|
|
||||||
delete(f.deleteRows, aRow)
|
|
||||||
|
|
||||||
// Recolour the row
|
|
||||||
|
|
||||||
vcl_grid_set_row_colour(f.ui.contentBox, aRow, qt.NewQBrush4(CO_EDIT_IMPLICIT))
|
|
||||||
|
|
||||||
explicitColour := qt.NewQBrush4(CO_EDIT_EXPLICIT)
|
|
||||||
for _, explicitCol := range f.updateRows[aRow] {
|
|
||||||
|
|
||||||
// NOTICE: This triggers a cellChanged event because we are changing
|
|
||||||
// the cell's background colour. However the recursion is blocked by
|
|
||||||
// the above "nothing to do" check
|
|
||||||
|
|
||||||
cell := f.ui.contentBox.Item(aRow, explicitCol)
|
|
||||||
cell.SetBackground(explicitColour)
|
|
||||||
}
|
|
||||||
|
|
||||||
f.ui.actionApply_changes.SetEnabled(true) // There are currently some edits again
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *App) OnDataInsertClick() {
|
|
||||||
if !f.ui.contentBox.IsEnabled() {
|
|
||||||
return // Not an active data view
|
|
||||||
}
|
|
||||||
|
|
||||||
rpos := f.ui.contentBox.RowCount()
|
|
||||||
f.ui.contentBox.SetRowCount(rpos + 1)
|
|
||||||
|
|
||||||
f.insertRows[rpos] = struct{}{}
|
|
||||||
|
|
||||||
// Create the cells, so they're not nil when we try and set the bgcolor
|
|
||||||
colCt := f.ui.contentBox.ColumnCount()
|
|
||||||
for i := 0; i < colCt; i++ {
|
|
||||||
f.ui.contentBox.SetItem(rpos, i, qt.NewQTableWidgetItem())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Repaint cells
|
|
||||||
vcl_grid_set_row_colour(f.ui.contentBox, rpos, qt.NewQBrush4(CO_INSERT))
|
|
||||||
|
|
||||||
// Scroll to bottom
|
|
||||||
f.ui.contentBox.ScrollToBottom()
|
|
||||||
|
|
||||||
f.ui.actionApply_changes.SetEnabled(true) // There are currently some edits again
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *App) OnDataDeleteRowClick() {
|
|
||||||
if !f.ui.contentBox.IsEnabled() {
|
|
||||||
return // Not an active data view
|
|
||||||
}
|
|
||||||
|
|
||||||
f.isEditing = false
|
|
||||||
defer func() {
|
|
||||||
f.isEditing = true
|
|
||||||
}()
|
|
||||||
|
|
||||||
rpos := f.ui.contentBox.CurrentRow()
|
|
||||||
f.deleteRows[rpos] = struct{}{}
|
|
||||||
|
|
||||||
// If this row was marked for edit, this takes priority
|
|
||||||
delete(f.updateRows, rpos)
|
|
||||||
|
|
||||||
// Repaint cells
|
|
||||||
vcl_grid_set_row_colour(f.ui.contentBox, rpos, qt.NewQBrush4(CO_DELETE))
|
|
||||||
|
|
||||||
f.ui.actionApply_changes.SetEnabled(true) // There are currently some edits again
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *App) OnDataCommitClick() {
|
func (f *App) OnDataCommitClick() {
|
||||||
if !f.ui.contentBox.IsEnabled() {
|
if !f.ui.contentBox.IsEnabled() {
|
||||||
|
qt.QMessageBox_Warning(f.ui.MainWindow.QWidget, APPNAME, "Can't apply changes: editing is disabled")
|
||||||
return // Not an active data view
|
return // Not an active data view
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !f.contentTbl.allowEdit {
|
||||||
|
qt.QMessageBox_Warning(f.ui.MainWindow.QWidget, APPNAME, "Can't apply changes: database is not editable")
|
||||||
|
return // ??? Shouldn't be able to reach this point
|
||||||
|
}
|
||||||
|
|
||||||
node := f.ui.Buckets.CurrentItem()
|
node := f.ui.Buckets.CurrentItem()
|
||||||
if node == nil {
|
if node == nil {
|
||||||
qt.QMessageBox_Warning(f.ui.MainWindow.QWidget, APPNAME, "No database selected")
|
qt.QMessageBox_Warning(f.ui.MainWindow.QWidget, APPNAME, "No database selected")
|
||||||
@@ -386,15 +283,16 @@ func (f *App) OnDataCommitClick() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = editableLd.ApplyChanges(f, bucketPath)
|
err = editableLd.ApplyChanges(f.contentTbl, bucketPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
qt.QMessageBox_Warning(f.ui.MainWindow.QWidget, APPNAME, err.Error())
|
qt.QMessageBox_Warning(f.ui.MainWindow.QWidget, APPNAME, err.Error())
|
||||||
|
// fallthrough to refresh
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh content
|
// Refresh content
|
||||||
f.OnNavChange(node, node) // Refresh RHS pane/data content
|
// This disables the 'apply changes' button again as there are no remaining edits
|
||||||
|
// Don't call onNavChange here because we don't want to warn about changes
|
||||||
f.ui.actionApply_changes.SetEnabled(false) // There are currently no edits again
|
f.refreshContent(node) // Refresh RHS pane/data content
|
||||||
|
|
||||||
// Preserve scroll position
|
// Preserve scroll position
|
||||||
// TODO
|
// TODO
|
||||||
@@ -488,20 +386,65 @@ func (f *App) OnQueryExecute() {
|
|||||||
|
|
||||||
ld := f.getLoadedDatabaseFor(node)
|
ld := f.getLoadedDatabaseFor(node)
|
||||||
|
|
||||||
|
// bucketPath is only used for some databases, not for others
|
||||||
|
bucketPath, err := f.getBucketPathFor(node)
|
||||||
|
if err != nil {
|
||||||
|
panic(err) // shouldn't happen
|
||||||
|
}
|
||||||
|
|
||||||
queryableLd, ok := ld.(queryableLoadedDatabase)
|
queryableLd, ok := ld.(queryableLoadedDatabase)
|
||||||
if !ok {
|
if !ok {
|
||||||
qt.QMessageBox_Warning(f.ui.MainWindow.QWidget, APPNAME, "Unsupported action for this database")
|
qt.QMessageBox_Warning(f.ui.MainWindow.QWidget, APPNAME, "Unsupported action for this database")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := queryableLd.ExecQuery(queryString, f.ui.queryResult)
|
f.resultsTbl.Wipeout()
|
||||||
|
err = queryableLd.ExecQuery(queryString, bucketPath, f.resultsTbl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
qt.QMessageBox_Warning(f.ui.MainWindow.QWidget, APPNAME, err.Error())
|
qt.QMessageBox_Warning(f.ui.MainWindow.QWidget, APPNAME, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *App) OnNavChange(node *qt.QTreeWidgetItem, _ *qt.QTreeWidgetItem) {
|
func (f *App) OnNavChange(node *qt.QTreeWidgetItem, prev *qt.QTreeWidgetItem) {
|
||||||
|
|
||||||
|
// If there are unsaved changes, we may want to block this change / switch
|
||||||
|
// back to the previous selection
|
||||||
|
// Prompt for confirmation first
|
||||||
|
if f.contentTbl.AnyChanges() {
|
||||||
|
ok := qt.QMessageBox_Warning2(f.ui.MainWindow.QWidget, APPNAME, "Your changes have not been saved.", qt.QMessageBox__Ok, qt.QMessageBox__Discard)
|
||||||
|
if ok != int(qt.QMessageBox__Discard) {
|
||||||
|
|
||||||
|
// We want to stop this change
|
||||||
|
if prev == nil {
|
||||||
|
return // that's enough
|
||||||
|
}
|
||||||
|
|
||||||
|
// We need to block recursive triggering
|
||||||
|
// First time, to update , but doesn't update selection stat
|
||||||
|
f.ui.Buckets.BlockSignals(true)
|
||||||
|
f.ui.Buckets.SetCurrentItem(prev) // Also sets selection
|
||||||
|
f.ui.Buckets.BlockSignals(false)
|
||||||
|
|
||||||
|
f.ui.Buckets.SetEnabled(false)
|
||||||
|
|
||||||
|
// On next event loop tick:
|
||||||
|
mainthread.Start(func() {
|
||||||
|
|
||||||
|
// Second time
|
||||||
|
// Since it's already set, won't trigger onNavChange
|
||||||
|
f.ui.Buckets.SetCurrentItem(prev)
|
||||||
|
f.ui.Buckets.SetEnabled(true)
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OK, continue with change
|
||||||
|
f.refreshContent(node)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *App) refreshContent(node *qt.QTreeWidgetItem) {
|
||||||
|
|
||||||
var ld loadedDatabase = f.none
|
var ld loadedDatabase = f.none
|
||||||
var bucketPath []string = nil
|
var bucketPath []string = nil
|
||||||
@@ -515,15 +458,17 @@ func (f *App) OnNavChange(node *qt.QTreeWidgetItem, _ *qt.QTreeWidgetItem) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset some controls that the render function is expected to populate
|
|
||||||
f.insertRows = make(map[int]struct{})
|
|
||||||
f.updateRows = make(map[int][]int)
|
|
||||||
f.deleteRows = make(map[int]struct{})
|
|
||||||
f.isEditing = false
|
|
||||||
f.ui.propertiesBox.Clear()
|
f.ui.propertiesBox.Clear()
|
||||||
vcl_clear_grid(f.ui.contentBox)
|
propertiesText, err := ld.Properties(bucketPath)
|
||||||
|
if err != nil {
|
||||||
|
f.ui.propertiesBox.SetPlainText("Error loading properties: " + err.Error())
|
||||||
|
} else {
|
||||||
|
f.ui.propertiesBox.SetPlainText(propertiesText)
|
||||||
|
}
|
||||||
|
|
||||||
err := ld.RenderForNav(f.ui, bucketPath) // Handover to the database type's own renderer function
|
// Load database content
|
||||||
|
f.contentTbl.Wipeout()
|
||||||
|
err = ld.RenderForNav(f.contentTbl, bucketPath) // Handover to the database type's own renderer function
|
||||||
if err != nil {
|
if err != nil {
|
||||||
qt.QMessageBox_Warning(f.ui.MainWindow.QWidget, APPNAME, fmt.Sprintf("Loading contents of bucket %v: %s", bucketPath, err.Error()))
|
qt.QMessageBox_Warning(f.ui.MainWindow.QWidget, APPNAME, fmt.Sprintf("Loading contents of bucket %v: %s", bucketPath, err.Error()))
|
||||||
|
|
||||||
@@ -532,17 +477,18 @@ func (f *App) OnNavChange(node *qt.QTreeWidgetItem, _ *qt.QTreeWidgetItem) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Toggle the Edit functionality
|
// Toggle the Edit functionality
|
||||||
_, ok := ld.(editableLoadedDatabase)
|
// Do this *after* RenderForNav as it disables editing by default.
|
||||||
|
_, editable := ld.(editableLoadedDatabase)
|
||||||
f.ui.actionApply_changes.SetEnabled(false) // will be enabled after add/delete/edit
|
f.ui.actionApply_changes.SetEnabled(false) // will be enabled after add/delete/edit
|
||||||
f.ui.actionDelete_row.SetEnabled(ok)
|
f.ui.actionDelete_row.SetEnabled(editable)
|
||||||
f.ui.actionAddRow.SetEnabled(ok)
|
f.ui.actionAddRow.SetEnabled(editable)
|
||||||
f.isEditing = ok
|
f.contentTbl.SetAllowEditing(editable)
|
||||||
|
|
||||||
// Toggle the Query functionality
|
// Toggle the Query functionality
|
||||||
_, ok = ld.(queryableLoadedDatabase)
|
_, queryable := ld.(queryableLoadedDatabase)
|
||||||
f.ui.queryInput.SetEnabled(ok)
|
f.ui.queryInput.SetEnabled(queryable)
|
||||||
f.ui.queryResult.SetEnabled(ok)
|
f.ui.queryResult.SetEnabled(queryable)
|
||||||
f.ui.mnuExecute.SetEnabled(ok)
|
f.ui.mnuExecute.SetEnabled(queryable)
|
||||||
|
|
||||||
// We're in charge of common status bar text updates
|
// We're in charge of common status bar text updates
|
||||||
// Find database displayname
|
// Find database displayname
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ type MainWindowUi struct {
|
|||||||
propertiesBox *qt.QTextEdit
|
propertiesBox *qt.QTextEdit
|
||||||
tabData *qt.QWidget
|
tabData *qt.QWidget
|
||||||
verticalLayout *qt.QVBoxLayout
|
verticalLayout *qt.QVBoxLayout
|
||||||
contentBox *qt.QTableWidget
|
contentBox *qt.QTableView
|
||||||
tabQuery *qt.QWidget
|
tabQuery *qt.QWidget
|
||||||
verticalLayout_2 *qt.QVBoxLayout
|
verticalLayout_2 *qt.QVBoxLayout
|
||||||
splitter_2 *qt.QSplitter
|
splitter_2 *qt.QSplitter
|
||||||
queryInput *qt.QTextEdit
|
queryInput *qt.QPlainTextEdit
|
||||||
queryResult *qt.QTableWidget
|
queryResult *qt.QTableView
|
||||||
menubar *qt.QMenuBar
|
menubar *qt.QMenuBar
|
||||||
menu_File *qt.QMenu
|
menu_File *qt.QMenu
|
||||||
menu_Query *qt.QMenu
|
menu_Query *qt.QMenu
|
||||||
@@ -205,7 +205,7 @@ func NewMainWindowUi() *MainWindowUi {
|
|||||||
verticalLayout__objectName.Delete() // setter copied value
|
verticalLayout__objectName.Delete() // setter copied value
|
||||||
ui.verticalLayout.SetContentsMargins(11, 11, 11, 11)
|
ui.verticalLayout.SetContentsMargins(11, 11, 11, 11)
|
||||||
ui.verticalLayout.SetSpacing(6)
|
ui.verticalLayout.SetSpacing(6)
|
||||||
ui.contentBox = qt.NewQTableWidget(ui.tabData)
|
ui.contentBox = qt.NewQTableView(ui.tabData)
|
||||||
contentBox__objectName := qt.NewQAnyStringView3("contentBox")
|
contentBox__objectName := qt.NewQAnyStringView3("contentBox")
|
||||||
ui.contentBox.SetObjectName(*contentBox__objectName)
|
ui.contentBox.SetObjectName(*contentBox__objectName)
|
||||||
contentBox__objectName.Delete() // setter copied value
|
contentBox__objectName.Delete() // setter copied value
|
||||||
@@ -232,13 +232,13 @@ func NewMainWindowUi() *MainWindowUi {
|
|||||||
splitter_2__objectName.Delete() // setter copied value
|
splitter_2__objectName.Delete() // setter copied value
|
||||||
ui.splitter_2.SetOrientation(qt.Vertical)
|
ui.splitter_2.SetOrientation(qt.Vertical)
|
||||||
ui.splitter_2.SetChildrenCollapsible(false)
|
ui.splitter_2.SetChildrenCollapsible(false)
|
||||||
ui.queryInput = qt.NewQTextEdit(ui.splitter_2.QWidget)
|
ui.queryInput = qt.NewQPlainTextEdit(ui.splitter_2.QWidget)
|
||||||
queryInput__objectName := qt.NewQAnyStringView3("queryInput")
|
queryInput__objectName := qt.NewQAnyStringView3("queryInput")
|
||||||
ui.queryInput.SetObjectName(*queryInput__objectName)
|
ui.queryInput.SetObjectName(*queryInput__objectName)
|
||||||
queryInput__objectName.Delete() // setter copied value
|
queryInput__objectName.Delete() // setter copied value
|
||||||
/* miqt-uic: no handler for queryInput property 'font' */
|
/* miqt-uic: no handler for queryInput property 'font' */
|
||||||
ui.splitter_2.AddWidget(ui.queryInput.QWidget)
|
ui.splitter_2.AddWidget(ui.queryInput.QWidget)
|
||||||
ui.queryResult = qt.NewQTableWidget(ui.splitter_2.QWidget)
|
ui.queryResult = qt.NewQTableView(ui.splitter_2.QWidget)
|
||||||
queryResult__objectName := qt.NewQAnyStringView3("queryResult")
|
queryResult__objectName := qt.NewQAnyStringView3("queryResult")
|
||||||
ui.queryResult.SetObjectName(*queryResult__objectName)
|
ui.queryResult.SetObjectName(*queryResult__objectName)
|
||||||
queryResult__objectName.Delete() // setter copied value
|
queryResult__objectName.Delete() // setter copied value
|
||||||
|
|||||||
@@ -84,7 +84,7 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTableWidget" name="contentBox">
|
<widget class="QTableView" name="contentBox">
|
||||||
<property name="verticalScrollMode">
|
<property name="verticalScrollMode">
|
||||||
<enum>QAbstractItemView::ScrollMode::ScrollPerPixel</enum>
|
<enum>QAbstractItemView::ScrollMode::ScrollPerPixel</enum>
|
||||||
</property>
|
</property>
|
||||||
@@ -112,14 +112,14 @@
|
|||||||
<property name="childrenCollapsible">
|
<property name="childrenCollapsible">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QTextEdit" name="queryInput">
|
<widget class="QPlainTextEdit" name="queryInput">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<family>Monospace</family>
|
<family>Monospace</family>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QTableWidget" name="queryResult">
|
<widget class="QTableView" name="queryResult">
|
||||||
<property name="verticalScrollMode">
|
<property name="verticalScrollMode">
|
||||||
<enum>QAbstractItemView::ScrollMode::ScrollPerPixel</enum>
|
<enum>QAbstractItemView::ScrollMode::ScrollPerPixel</enum>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
450
table.go
Normal file
450
table.go
Normal file
@@ -0,0 +1,450 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
qt "github.com/mappu/miqt/qt6"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
CO_INSERT = qt.Yellow
|
||||||
|
CO_EDIT_IMPLICIT = qt.Green
|
||||||
|
CO_EDIT_EXPLICIT = qt.DarkGreen
|
||||||
|
CO_DELETE = qt.Red
|
||||||
|
)
|
||||||
|
|
||||||
|
type columnType int
|
||||||
|
|
||||||
|
const (
|
||||||
|
columnType_invalid columnType = iota
|
||||||
|
columnType_inlineText
|
||||||
|
columnType_popupData
|
||||||
|
// TODO add a column type for map[string]string that can show content in a mini popup?? (Useful for redis + secretsvc)
|
||||||
|
)
|
||||||
|
|
||||||
|
type tableState struct {
|
||||||
|
rowCount int
|
||||||
|
columns_inlineText [][]string // Sized to include all columns, but, inner vectors are not allocated for unused entries
|
||||||
|
columns_popupData [][][]byte
|
||||||
|
currentColumns []columnType
|
||||||
|
columnLabels []string
|
||||||
|
|
||||||
|
primaryKeys [][]byte
|
||||||
|
|
||||||
|
allowEdit bool
|
||||||
|
updateRows map[int][]int // row => []column
|
||||||
|
insertRows map[int]struct{}
|
||||||
|
deleteRows map[int]struct{}
|
||||||
|
OnEdited func()
|
||||||
|
|
||||||
|
model *qt.QAbstractTableModel
|
||||||
|
tbl *qt.QTableView
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetupColumns resets the table's content.
|
||||||
|
// It preserves the OnEdited callback
|
||||||
|
func (ts *tableState) SetupColumns(columns []columnType, labels []string) {
|
||||||
|
|
||||||
|
if ts.tbl.IsEnabled() {
|
||||||
|
ts.tbl.SetEnabled(false)
|
||||||
|
ts.model.BeginResetModel()
|
||||||
|
}
|
||||||
|
|
||||||
|
ts.currentColumns = columns
|
||||||
|
ts.columnLabels = labels
|
||||||
|
ts.rowCount = 0
|
||||||
|
|
||||||
|
ts.columns_inlineText = make([][]string, len(columns))
|
||||||
|
ts.columns_popupData = make([][][]byte, len(columns))
|
||||||
|
|
||||||
|
ts.SetAllowEditing(false)
|
||||||
|
ts.updateRows = make(map[int][]int, 0)
|
||||||
|
ts.insertRows = make(map[int]struct{}, 0)
|
||||||
|
ts.deleteRows = make(map[int]struct{}, 0)
|
||||||
|
ts.primaryKeys = nil
|
||||||
|
|
||||||
|
for i, ctype := range columns {
|
||||||
|
switch ctype {
|
||||||
|
case columnType_inlineText:
|
||||||
|
ts.columns_inlineText[i] = make([]string, 0)
|
||||||
|
case columnType_popupData:
|
||||||
|
ts.columns_popupData[i] = make([][]byte, 0)
|
||||||
|
default:
|
||||||
|
panic("bad columnType")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ts *tableState) SetAllowEditing(allow bool) {
|
||||||
|
ts.allowEdit = allow
|
||||||
|
if allow {
|
||||||
|
ts.tbl.SetEditTriggers(qt.QAbstractItemView__DoubleClicked | qt.QAbstractItemView__EditKeyPressed)
|
||||||
|
} else {
|
||||||
|
ts.tbl.SetEditTriggers(qt.QAbstractItemView__NoEditTriggers)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ts *tableState) AnyChanges() bool {
|
||||||
|
return len(ts.insertRows) > 0 || len(ts.updateRows) > 0 || len(ts.deleteRows) > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddRow inserts a new row.
|
||||||
|
// It's assumed to be initial data. For user-modified data, use InsertNewRow.
|
||||||
|
func (ts *tableState) AddRow() int {
|
||||||
|
newRowId := ts.rowCount
|
||||||
|
ts.SetRowCount(ts.rowCount + 1)
|
||||||
|
return newRowId
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddRowData inserts a new row.
|
||||||
|
// It's assumed to be initial data. For user-modified data, use InsertNewRow.
|
||||||
|
func (ts *tableState) AddRowData(cells ...any) {
|
||||||
|
aRow := ts.AddRow()
|
||||||
|
for aCol, cellData := range cells {
|
||||||
|
ts.SetCell(aRow, aCol, cellData)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ts *tableState) AddRow_PK_Data(pk []byte, cells ...any) {
|
||||||
|
aRow := ts.AddRow()
|
||||||
|
|
||||||
|
ts.SetRowPrimaryKey(aRow, pk)
|
||||||
|
|
||||||
|
for aCol, cellData := range cells {
|
||||||
|
ts.SetCell(aRow, aCol, cellData)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ts *tableState) SetRowCount(newlen int) {
|
||||||
|
if ts.rowCount == newlen {
|
||||||
|
return // no change
|
||||||
|
}
|
||||||
|
ts.rowCount = newlen
|
||||||
|
|
||||||
|
for i, ctype := range ts.currentColumns {
|
||||||
|
switch ctype {
|
||||||
|
case columnType_inlineText:
|
||||||
|
ts.columns_inlineText[i] = slice_set_len(ts.columns_inlineText[i], newlen)
|
||||||
|
case columnType_popupData:
|
||||||
|
ts.columns_popupData[i] = slice_set_len(ts.columns_popupData[i], newlen)
|
||||||
|
default:
|
||||||
|
panic("bad columnType")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// We don't know if editing will be enabled until after the whole RenderForNav
|
||||||
|
// has completed. Set up primary key support regardless.
|
||||||
|
ts.primaryKeys = slice_set_len(ts.primaryKeys, newlen)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ts *tableState) SetCell(aRow, aCol int, data any) {
|
||||||
|
if aRow >= ts.rowCount {
|
||||||
|
panic("SetCell with too large row")
|
||||||
|
}
|
||||||
|
|
||||||
|
ctype := ts.currentColumns[aCol]
|
||||||
|
switch ctype {
|
||||||
|
case columnType_inlineText:
|
||||||
|
// data must be a string
|
||||||
|
strData, ok := data.(string)
|
||||||
|
if !ok {
|
||||||
|
panic("wrong type for string column")
|
||||||
|
}
|
||||||
|
ts.columns_inlineText[aCol][aRow] = strData
|
||||||
|
|
||||||
|
case columnType_popupData: // data must be a []byte
|
||||||
|
bslcData, ok := data.([]byte)
|
||||||
|
if !ok {
|
||||||
|
panic("wrong type for []byte column")
|
||||||
|
}
|
||||||
|
|
||||||
|
// We are probably passed only a view
|
||||||
|
// Copy the data
|
||||||
|
ts.columns_popupData[aCol][aRow] = slice_dup(bslcData)
|
||||||
|
default:
|
||||||
|
panic("bad columnType")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRowPrimaryKey
|
||||||
|
// The slice data will be copied.
|
||||||
|
func (ts *tableState) SetRowPrimaryKey(aRow int, data []byte) {
|
||||||
|
if len(ts.primaryKeys) != ts.rowCount {
|
||||||
|
panic("messed up")
|
||||||
|
}
|
||||||
|
if aRow >= ts.rowCount {
|
||||||
|
panic("SetRowPrimaryKey with too large row")
|
||||||
|
}
|
||||||
|
|
||||||
|
ts.primaryKeys[aRow] = slice_dup(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ts *tableState) Wipeout() {
|
||||||
|
ts.SetupColumns(
|
||||||
|
[]columnType{
|
||||||
|
columnType_inlineText,
|
||||||
|
columnType_popupData,
|
||||||
|
},
|
||||||
|
[]string{"Key", "Value"},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ts *tableState) Ready() {
|
||||||
|
ts.model.EndResetModel()
|
||||||
|
|
||||||
|
ts.tbl.ResizeColumnsToContents()
|
||||||
|
ts.tbl.SetEnabled(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteSelectedRows marks the selected rows for deletion.
|
||||||
|
func (ts *tableState) DeleteSelectedRows() {
|
||||||
|
rows := ts.tbl.SelectionModel().SelectedRows()
|
||||||
|
// n.b. if the selection model for the table allows single-cell selection,
|
||||||
|
// this won't find all rows, just fully-selected rows from clicking on the
|
||||||
|
// vertical header bar
|
||||||
|
|
||||||
|
for _, row := range rows {
|
||||||
|
row_ := row.Row() // your boat
|
||||||
|
|
||||||
|
// Mark for deletion
|
||||||
|
ts.deleteRows[row_] = struct{}{}
|
||||||
|
|
||||||
|
// This supersedes any updates in the row
|
||||||
|
if _, ok := ts.updateRows[row_]; ok {
|
||||||
|
delete(ts.updateRows, row_)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Refresh background colour
|
||||||
|
ts.model.DataChanged(&row, &row)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(rows) > 0 {
|
||||||
|
ts.OnEdited()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// InsertNewRow is the user action of inserting a new row at the bottom of the
|
||||||
|
// table.
|
||||||
|
func (ts *tableState) InsertNewRow() {
|
||||||
|
rowId := ts.rowCount
|
||||||
|
|
||||||
|
ts.model.BeginInsertRows(qt.NewQModelIndex(), rowId, rowId)
|
||||||
|
|
||||||
|
ts.AddRow()
|
||||||
|
ts.insertRows[rowId] = struct{}{}
|
||||||
|
|
||||||
|
ts.model.EndInsertRows()
|
||||||
|
|
||||||
|
// Scroll to bottom (only works after EndInsertRows has caused the view to
|
||||||
|
// refresh)
|
||||||
|
ts.tbl.ScrollToBottom()
|
||||||
|
|
||||||
|
// There are currently some edits again
|
||||||
|
ts.OnEdited()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewTableState(tbl *qt.QTableView) *tableState {
|
||||||
|
|
||||||
|
// Stylistic changes
|
||||||
|
tbl.SetHorizontalScrollMode(qt.QAbstractItemView__ScrollPerPixel)
|
||||||
|
tbl.SetVerticalScrollMode(qt.QAbstractItemView__ScrollPerPixel)
|
||||||
|
tbl.VerticalHeader().Hide() // Table row IDs do not match data IDs
|
||||||
|
tbl.SetSelectionBehavior(qt.QAbstractItemView__SelectRows)
|
||||||
|
|
||||||
|
// @ref https://doc.qt.io/qt-6/qabstracttablemodel.html#subclassing
|
||||||
|
model := qt.NewQAbstractTableModel2(tbl.QObject)
|
||||||
|
|
||||||
|
var ts tableState
|
||||||
|
ts.model = model
|
||||||
|
ts.tbl = tbl
|
||||||
|
ts.OnEdited = func() {} // no-op
|
||||||
|
ts.Wipeout()
|
||||||
|
|
||||||
|
model.OnRowCount(func(parent *qt.QModelIndex) int {
|
||||||
|
return ts.rowCount
|
||||||
|
})
|
||||||
|
|
||||||
|
model.OnColumnCount(func(parent *qt.QModelIndex) int {
|
||||||
|
return len(ts.currentColumns)
|
||||||
|
})
|
||||||
|
|
||||||
|
model.OnHeaderData(func(super func(section int, orientation qt.Orientation, role int) *qt.QVariant, section int, orientation qt.Orientation, role int) *qt.QVariant {
|
||||||
|
if role == int(qt.DisplayRole) && orientation == qt.Horizontal {
|
||||||
|
if section >= len(ts.columnLabels) {
|
||||||
|
return qt.NewQVariant() // invalid request
|
||||||
|
}
|
||||||
|
|
||||||
|
return qt.NewQVariant11(ts.columnLabels[section])
|
||||||
|
}
|
||||||
|
|
||||||
|
return super(section, orientation, role)
|
||||||
|
})
|
||||||
|
|
||||||
|
model.OnFlags(func(super func(index *qt.QModelIndex) qt.ItemFlag, index *qt.QModelIndex) qt.ItemFlag {
|
||||||
|
ret := super(index)
|
||||||
|
if ts.allowEdit {
|
||||||
|
ret |= qt.ItemIsEditable
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
})
|
||||||
|
|
||||||
|
model.OnData(func(index *qt.QModelIndex, role int) *qt.QVariant {
|
||||||
|
if !index.IsValid() {
|
||||||
|
return qt.NewQVariant() // invalid
|
||||||
|
}
|
||||||
|
|
||||||
|
aCol := index.Column()
|
||||||
|
aRow := index.Row()
|
||||||
|
|
||||||
|
switch role {
|
||||||
|
case int(qt.DisplayRole):
|
||||||
|
|
||||||
|
// Formatting for display, return a QVariant of plain string type
|
||||||
|
|
||||||
|
ctype := ts.currentColumns[aCol]
|
||||||
|
switch ctype {
|
||||||
|
case columnType_inlineText:
|
||||||
|
return qt.NewQVariant11(ts.columns_inlineText[aCol][aRow])
|
||||||
|
case columnType_popupData:
|
||||||
|
return qt.NewQVariant11(formatUtf8(ts.columns_popupData[aCol][aRow]))
|
||||||
|
default:
|
||||||
|
panic("bad columnType")
|
||||||
|
}
|
||||||
|
|
||||||
|
case int(qt.EditRole):
|
||||||
|
|
||||||
|
// Supplying to the editor, return a QVariant of raw editing type
|
||||||
|
|
||||||
|
ctype := ts.currentColumns[aCol]
|
||||||
|
switch ctype {
|
||||||
|
case columnType_inlineText:
|
||||||
|
return qt.NewQVariant11(ts.columns_inlineText[aCol][aRow])
|
||||||
|
case columnType_popupData:
|
||||||
|
return qt.NewQVariant12(ts.columns_popupData[aCol][aRow])
|
||||||
|
default:
|
||||||
|
panic("bad columnType")
|
||||||
|
}
|
||||||
|
|
||||||
|
case int(qt.BackgroundRole):
|
||||||
|
|
||||||
|
if _, ok := ts.deleteRows[aRow]; ok {
|
||||||
|
return qt.NewQColor2(CO_DELETE).ToQVariant()
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ok := ts.insertRows[aRow]; ok {
|
||||||
|
return qt.NewQColor2(CO_INSERT).ToQVariant()
|
||||||
|
}
|
||||||
|
|
||||||
|
if cells, ok := ts.updateRows[aRow]; ok {
|
||||||
|
if slice_contains(cells, aCol) {
|
||||||
|
return qt.NewQColor2(CO_EDIT_EXPLICIT).ToQVariant()
|
||||||
|
} else {
|
||||||
|
return qt.NewQColor2(CO_EDIT_IMPLICIT).ToQVariant()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Row is not modified
|
||||||
|
return qt.NewQVariant() // trigger default behaviour
|
||||||
|
|
||||||
|
default:
|
||||||
|
return qt.NewQVariant() // invalid
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
model.OnSetData(func(super func(index *qt.QModelIndex, value *qt.QVariant, role int) bool, index *qt.QModelIndex, value *qt.QVariant, role int) bool {
|
||||||
|
|
||||||
|
if !index.IsValid() {
|
||||||
|
return super(index, value, role) // invalid
|
||||||
|
}
|
||||||
|
|
||||||
|
aCol := index.Column()
|
||||||
|
aRow := index.Row()
|
||||||
|
|
||||||
|
switch role {
|
||||||
|
case int(qt.EditRole):
|
||||||
|
// Update content
|
||||||
|
ctype := ts.currentColumns[aCol]
|
||||||
|
switch ctype {
|
||||||
|
case columnType_inlineText:
|
||||||
|
ts.columns_inlineText[aCol][aRow] = value.ToString()
|
||||||
|
case columnType_popupData:
|
||||||
|
ts.columns_popupData[aCol][aRow] = value.ToByteArray()
|
||||||
|
default:
|
||||||
|
panic("bad columnType")
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this is an insert row, no need to patch updateRows
|
||||||
|
if _, ok := ts.insertRows[aRow]; ok {
|
||||||
|
// nothing to do
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// If this row was marked for deletion, this new edit takes priority
|
||||||
|
delete(ts.deleteRows, aRow)
|
||||||
|
|
||||||
|
// Set background colour
|
||||||
|
cells, ok := ts.updateRows[aRow]
|
||||||
|
if !ok {
|
||||||
|
cells = make([]int, 0, 1)
|
||||||
|
}
|
||||||
|
if slice_contains(cells, aCol) {
|
||||||
|
// already ok
|
||||||
|
} else {
|
||||||
|
cells = append(cells, aCol)
|
||||||
|
}
|
||||||
|
ts.updateRows[aRow] = cells
|
||||||
|
}
|
||||||
|
|
||||||
|
// Emit signal
|
||||||
|
// TODO ideally this would run after this function returned?
|
||||||
|
ts.OnEdited()
|
||||||
|
|
||||||
|
// Done
|
||||||
|
return true
|
||||||
|
|
||||||
|
default:
|
||||||
|
return super(index, value, role)
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
// Set target QTableView's model
|
||||||
|
|
||||||
|
tbl.SetModel(model.QAbstractItemModel)
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
/*
|
||||||
|
zombie := qt.NewQStyledItemDelegate2(tbl.QObject)
|
||||||
|
zombie.OnCreateEditor(func(super func(parent *qt.QWidget, option *qt.QStyleOptionViewItem, index *qt.QModelIndex) *qt.QWidget, parent *qt.QWidget, option *qt.QStyleOptionViewItem, index *qt.QModelIndex) *qt.QWidget {
|
||||||
|
// return a custom editor widget
|
||||||
|
foo := qt.NewQPushButton(parent)
|
||||||
|
return foo.QWidget
|
||||||
|
|
||||||
|
// return the default editor widget
|
||||||
|
//return super(parent, option, index)
|
||||||
|
})
|
||||||
|
|
||||||
|
zombie.OnSetEditorData(func(super func(editor *qt.QWidget, index *qt.QModelIndex), editor *qt.QWidget, index *qt.QModelIndex) {
|
||||||
|
// populate the custom editor with the table's current data
|
||||||
|
|
||||||
|
super(editor, index)
|
||||||
|
})
|
||||||
|
|
||||||
|
zombie.OnSetModelData(func(super func(editor *qt.QWidget, model *qt.QAbstractItemModel, index *qt.QModelIndex), editor *qt.QWidget, model *qt.QAbstractItemModel, index *qt.QModelIndex) {
|
||||||
|
// the table has requested to save data from the editor back into the model
|
||||||
|
|
||||||
|
super(editor, model, index)
|
||||||
|
})
|
||||||
|
|
||||||
|
zombie.OnUpdateEditorGeometry(func(super func(editor *qt.QWidget, option *qt.QStyleOptionViewItem, index *qt.QModelIndex), editor *qt.QWidget, option *qt.QStyleOptionViewItem, index *qt.QModelIndex) {
|
||||||
|
// after having created our custom editor, set the widget's size as per the table column
|
||||||
|
editor.SetGeometryWithGeometry(option.Rect())
|
||||||
|
|
||||||
|
// super(editor, option, index)
|
||||||
|
})
|
||||||
|
|
||||||
|
tbl.SetItemDelegate(zombie.QAbstractItemDelegate) // for all rows? just some columns/...
|
||||||
|
*/
|
||||||
|
|
||||||
|
return &ts
|
||||||
|
}
|
||||||
@@ -15,6 +15,24 @@ func box_interface[T any](input []T) []interface{} {
|
|||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func slice_repeat[T any](value T, count int) []T {
|
||||||
|
ret := make([]T, count)
|
||||||
|
for i := 0; i < count; i++ {
|
||||||
|
ret[i] = value
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func address_of[T any](value T) *T {
|
||||||
|
return &value
|
||||||
|
}
|
||||||
|
|
||||||
|
func slice_dup[T any](src []T) []T {
|
||||||
|
ret := make([]T, len(src))
|
||||||
|
copy(ret, src)
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
func slice_contains[T comparable](haystack []T, needle T) bool {
|
func slice_contains[T comparable](haystack []T, needle T) bool {
|
||||||
_, ok := slice_find(haystack, needle)
|
_, ok := slice_find(haystack, needle)
|
||||||
return ok
|
return ok
|
||||||
@@ -34,6 +52,19 @@ func slice_remove_index[T comparable](slice []T, s int) []T {
|
|||||||
return append(slice[:s], slice[s+1:]...)
|
return append(slice[:s], slice[s+1:]...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// slice_set_len sets the length of the slice. Use it like append -
|
||||||
|
// x = slice_set_len(x, 10)
|
||||||
|
func slice_set_len[T any](slice []T, newlen int) []T {
|
||||||
|
|
||||||
|
if newlen > len(slice) {
|
||||||
|
// Extending length
|
||||||
|
return append(slice, make([]T, newlen-len(slice))...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Truncating
|
||||||
|
return slice[0:newlen]
|
||||||
|
}
|
||||||
|
|
||||||
func pathlist_encode(bp []string) ([]byte, error) {
|
func pathlist_encode(bp []string) ([]byte, error) {
|
||||||
buff := bytes.Buffer{}
|
buff := bytes.Buffer{}
|
||||||
enc := gob.NewEncoder(&buff)
|
enc := gob.NewEncoder(&buff)
|
||||||
|
|||||||
23
util_vcl.go
23
util_vcl.go
@@ -4,13 +4,6 @@ import (
|
|||||||
qt "github.com/mappu/miqt/qt6"
|
qt "github.com/mappu/miqt/qt6"
|
||||||
)
|
)
|
||||||
|
|
||||||
func vcl_clear_grid(grid *qt.QTableWidget) {
|
|
||||||
grid.Clear() // clears header labels
|
|
||||||
grid.SetColumnCount(0) // clears content
|
|
||||||
grid.SetRowCount(0) // clears content
|
|
||||||
grid.SetEnabled(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
func vcl_confirm_dialog(parent *qt.QWidget, title string, message string) bool {
|
func vcl_confirm_dialog(parent *qt.QWidget, title string, message string) bool {
|
||||||
|
|
||||||
ret := qt.QMessageBox_Question2(parent, title, message,
|
ret := qt.QMessageBox_Question2(parent, title, message,
|
||||||
@@ -19,19 +12,3 @@ func vcl_confirm_dialog(parent *qt.QWidget, title string, message string) bool {
|
|||||||
|
|
||||||
return ret == int(qt.QMessageBox__Apply)
|
return ret == int(qt.QMessageBox__Apply)
|
||||||
}
|
}
|
||||||
|
|
||||||
func vcl_grid_set_row_colour(grid *qt.QTableWidget, rowId int, colour *qt.QBrush) {
|
|
||||||
|
|
||||||
// Avoid triggering onCellChanged events while we update the background
|
|
||||||
// colours
|
|
||||||
if !grid.SignalsBlocked() {
|
|
||||||
grid.BlockSignals(true)
|
|
||||||
defer grid.BlockSignals(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
numCols := grid.ColumnCount()
|
|
||||||
for i := 0; i < numCols; i++ {
|
|
||||||
cell := grid.Item(rowId, i)
|
|
||||||
cell.SetBackground(colour)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
3
version.go
Normal file
3
version.go
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
const appVersion = "v0.0.0-devel"
|
||||||
54
winres.json
Normal file
54
winres.json
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
{
|
||||||
|
"RT_GROUP_ICON": {
|
||||||
|
"APP": {
|
||||||
|
"0000": "assets/database_lightning.png"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"RT_VERSION": {
|
||||||
|
"#1": {
|
||||||
|
"0000": {
|
||||||
|
"fixed": {
|
||||||
|
"file_version": "0.0.0.0",
|
||||||
|
"product_version": "0.0.0.0"
|
||||||
|
},
|
||||||
|
"info": {
|
||||||
|
"0409": {
|
||||||
|
"Comments": "",
|
||||||
|
"CompanyName": "code.ivysaur.me",
|
||||||
|
"FileDescription": "yvbolt Database Editor",
|
||||||
|
"FileVersion": "0.0.0.0",
|
||||||
|
"LegalCopyright": "code.ivysaur.me",
|
||||||
|
"LegalTrademarks": "",
|
||||||
|
"ProductName": "yvbolt",
|
||||||
|
"ProductVersion": "0.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"RT_MANIFEST": {
|
||||||
|
"#1": {
|
||||||
|
"0409": {
|
||||||
|
"identity": {
|
||||||
|
"name": "",
|
||||||
|
"version": ""
|
||||||
|
},
|
||||||
|
"description": "",
|
||||||
|
"minimum-os": "win7",
|
||||||
|
"execution-level": "as invoker",
|
||||||
|
"ui-access": false,
|
||||||
|
"auto-elevate": false,
|
||||||
|
"dpi-awareness": "per monitor v2",
|
||||||
|
"disable-theming": false,
|
||||||
|
"disable-window-filtering": false,
|
||||||
|
"high-resolution-scrolling-aware": false,
|
||||||
|
"ultra-high-resolution-scrolling-aware": false,
|
||||||
|
"long-path-aware": false,
|
||||||
|
"printer-driver-isolation": false,
|
||||||
|
"gdi-scaling": false,
|
||||||
|
"segment-heap": false,
|
||||||
|
"use-common-controls-v6": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user