misc v0.9.3 fixes -- numToString, block counts, fix docsite images/video (#1354)

This commit is contained in:
Mike Sawka 2024-11-25 18:07:29 -08:00 committed by GitHub
parent 4f809550b9
commit b6ce2cd022
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 73 additions and 12 deletions

View File

@ -87,7 +87,7 @@ tasks:
- "dist/docsite/**/*"
cmds:
- cd docs && yarn build-embedded
- task: copyfiles:'docs/build':'dist/docsite'
- task: copyfiles:'docs/build/':'dist/docsite'
deps:
- yarn

View File

@ -140,6 +140,7 @@ func beforeSendActivityUpdate(ctx context.Context) {
activity := telemetry.ActivityUpdate{}
activity.NumTabs, _ = wstore.DBGetCount[*waveobj.Tab](ctx)
activity.NumBlocks, _ = wstore.DBGetCount[*waveobj.Block](ctx)
activity.Blocks, _ = wstore.DBGetBlockViewCounts(ctx)
activity.NumWindows, _ = wstore.DBGetCount[*waveobj.Window](ctx)
activity.NumSSHConn = conncontroller.GetNumSSHHasConnected()
activity.NumWSLConn = wsl.GetNumWSLHasConnected()

View File

@ -9,7 +9,7 @@ title: "Customization"
<img
title="Tab Context Menu"
style={{ float: "right", margin: "0 0 10px 10px" }}
src="/img/tab-context-menu.png"
src="./img/tab-context-menu.png"
width="300"
/>
@ -24,7 +24,7 @@ It is also possible to create your own themes using custom colors, gradients, im
<img
title="Terminal Context Menu"
style={{ float: "right", margin: "0 0 10px 10px" }}
src="/img/terminal-context-menu.png"
src="./img/terminal-context-menu.png"
width="300"
/>
@ -53,7 +53,7 @@ There is no UI to edit your default terminal font family. But, it _can_ be overr
<img
title="Terminal Context Menu"
style={{ float: "right", margin: "0 0 10px 10px" }}
src="/img/custom-widgets.png"
src="./img/custom-widgets.png"
width="120"
/>

View File

@ -49,7 +49,7 @@ You can move blocks by clicking on the block header and dragging the block aroun
There are 7 different drop targets for any given block. A block is divided into quadrants along its diagonals. If the block is tiling as a row (left-to-right), dropping a block into the left or right quadrant will place the dropped block in the same level as the targeted block. This can be considered dropping the block inline. If you drop the block out of line (in quadrants corresponding to opposite tiling direction), the block will either be placed one level above or one level below the targeted block. Dropping the block towards the outside will place it in the same level as the target block's parent, while dropping it towards the center of the block will create a new level, where both the target block and the dropped block will be moved. The middle fifth of the block is reserved for the swap action. Dropping a block here will cause the target block and the dropped block to swap positions in the layout.
<video width="100%" height="100%" playsinline autoplay muted controls>
<source src="/img/drag-move-24fps-crf43.mp4" type="video/mp4" />
<source src="./img/drag-move-24fps-crf43.mp4" type="video/mp4" />
</video>
#### Possible block movements
@ -72,7 +72,7 @@ All block movements except for Swap will cause the rest of the layout to shift t
### Resize a block
<video width="100%" height="100%" playsinline autoplay muted controls>
<source src="/img/resize-24fps-crf43.mp4" type="video/mp4" />
<source src="./img/resize-24fps-crf43.mp4" type="video/mp4" />
</video>
![screenshot showing the line that appears when the cursor hovers over the margin of a block, indicating which blocks

View File

@ -50,7 +50,7 @@ When telemetry is active, we collect the following data. It is stored in the `te
| NumBlocks | The number of existing blocks open on a given day |
| NumTabs | The number of existing tabs open on a given day. |
| NewTab | The number of new tabs created on a given day |
| NumWindows | The number of existing windows open on a give day. |
| NumWindows | The number of existing windows open on a given day. |
| NewTab | The number of new tabs opened on a given day. |
| NumStartup | The number of times waveterm has been started on a given day. |
| NumShutdown | The number of times waveterm has been shut down on a given day. |
@ -61,6 +61,7 @@ When telemetry is active, we collect the following data. It is stored in the `te
| NumWSLConns | The number of distinct WSL connections that have been made to distinct distros |
| Renderers | The number of new block views of each type are open on a given day. |
| WshCmds | The number of wsh commands of each type run on a given day |
| Blocks | The number of blocks of different view types open on a given day |
| Conn | The number of successful remote connections made (and errors) on a given day |
## Associated Data

View File

@ -15,7 +15,6 @@ const baseUrlRegex = /http[s]?:\/\/([^:\/])+(:\d+)?/;
class HelpViewModel extends WebViewModel {
constructor(blockId: string, nodeModel: BlockNodeModel) {
super(blockId, nodeModel);
this.getSettingsMenuItems = undefined;
this.viewText = atom((get) => {
// force a dependency on meta.url so we re-render the buttons when the url changes
get(this.blockAtom)?.meta?.url || get(this.homepageUrl);
@ -58,6 +57,23 @@ class HelpViewModel extends WebViewModel {
return newUrl;
};
}
getSettingsMenuItems(): ContextMenuItem[] {
return [
{
label: this.webviewRef.current?.isDevToolsOpened() ? "Close DevTools" : "Open DevTools",
click: async () => {
if (this.webviewRef.current) {
if (this.webviewRef.current.isDevToolsOpened()) {
this.webviewRef.current.closeDevTools();
} else {
this.webviewRef.current.openDevTools();
}
}
},
},
];
}
}
function makeHelpViewModel(blockId: string, nodeModel: BlockNodeModel) {

View File

@ -32,6 +32,7 @@ declare global {
buildtime?: string;
displays?: ActivityDisplayType[];
renderers?: {[key: string]: number};
blocks?: {[key: string]: number};
wshcmds?: {[key: string]: number};
conn?: {[key: string]: number};
};

View File

@ -44,6 +44,7 @@ type ActivityUpdate struct {
BuildTime string `json:"buildtime,omitempty"`
Displays []ActivityDisplayType `json:"displays,omitempty"`
Renderers map[string]int `json:"renderers,omitempty"`
Blocks map[string]int `json:"blocks,omitempty"`
WshCmds map[string]int `json:"wshcmds,omitempty"`
Conn map[string]int `json:"conn,omitempty"`
}
@ -77,6 +78,7 @@ type TelemetryData struct {
SetTabTheme int `json:"settabtheme,omitempty"`
Displays []ActivityDisplayType `json:"displays,omitempty"`
Renderers map[string]int `json:"renderers,omitempty"`
Blocks map[string]int `json:"blocks,omitempty"`
WshCmds map[string]int `json:"wshcmds,omitempty"`
Conn map[string]int `json:"conn,omitempty"`
}
@ -185,6 +187,9 @@ func UpdateActivity(ctx context.Context, update ActivityUpdate) error {
if len(update.Displays) > 0 {
tdata.Displays = update.Displays
}
if len(update.Blocks) > 0 {
tdata.Blocks = update.Blocks
}
query = `UPDATE db_activity
SET tdata = ?,
clientversion = ?,

View File

@ -471,10 +471,26 @@ func UseEffect(ctx context.Context, fn func() func(), deps []any) {
func numToString[T any](value T) (string, bool) {
switch v := any(value).(type) {
case int, int8, int16, int32, int64:
return strconv.FormatInt(v.(int64), 10), true
case uint, uint8, uint16, uint32, uint64:
return strconv.FormatUint(v.(uint64), 10), true
case int:
return strconv.FormatInt(int64(v), 10), true
case int8:
return strconv.FormatInt(int64(v), 10), true
case int16:
return strconv.FormatInt(int64(v), 10), true
case int32:
return strconv.FormatInt(int64(v), 10), true
case int64:
return strconv.FormatInt(v, 10), true
case uint:
return strconv.FormatUint(uint64(v), 10), true
case uint8:
return strconv.FormatUint(uint64(v), 10), true
case uint16:
return strconv.FormatUint(uint64(v), 10), true
case uint32:
return strconv.FormatUint(uint64(v), 10), true
case uint64:
return strconv.FormatUint(v, 10), true
case float32:
return strconv.FormatFloat(float64(v), 'f', -1, 32), true
case float64:

View File

@ -8,6 +8,7 @@ import (
"fmt"
"log"
"reflect"
"regexp"
"time"
"github.com/wavetermdev/waveterm/pkg/filestore"
@ -44,6 +45,26 @@ func DBGetCount[T waveobj.WaveObj](ctx context.Context) (int, error) {
})
}
var viewRe = regexp.MustCompile(`^[a-z0-9]{1,20}$`)
func DBGetBlockViewCounts(ctx context.Context) (map[string]int, error) {
return WithTxRtn(ctx, func(tx *TxWrap) (map[string]int, error) {
query := `SELECT COALESCE(json_extract(data, '$.meta.view'), '') AS view FROM db_block`
views := tx.SelectStrings(query)
rtn := make(map[string]int)
for _, view := range views {
if view == "" {
continue
}
if !viewRe.MatchString(view) {
continue
}
rtn[view]++
}
return rtn, nil
})
}
type idDataType struct {
OId string
Version int