Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview & Load Feature #2834

Merged
merged 72 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
08ffd48
Add a nice dropzone animation
jameskerr Aug 4, 2023
65fd05b
Tweek the animation
jameskerr Aug 7, 2023
9f7f1a2
Save the data to a form
jameskerr Aug 7, 2023
5c8aee3
Building the form
jameskerr Aug 8, 2023
70e1b21
Scroll shadow working wonderfully
jameskerr Aug 15, 2023
226a8b3
Form Submission Works
jameskerr Aug 16, 2023
a74ac42
Zq operation running
jameskerr Aug 21, 2023
76667cc
ZQ works on many files
jameskerr Aug 21, 2023
4eb6d82
Clean up the zq command
jameskerr Aug 21, 2023
e150b80
Load data form is done.
jameskerr Aug 24, 2023
873fcdd
Clean up the code
jameskerr Aug 25, 2023
a2515b6
Clean up the code
jameskerr Aug 25, 2023
7f07da3
Results Headers and Footers
jameskerr Aug 29, 2023
4d845ee
Lint
jameskerr Aug 29, 2023
e1a6027
Results toolbar Responsive
jameskerr Aug 30, 2023
562a9ca
Add data format to the mix
jameskerr Aug 30, 2023
4346485
Fix the table bug when things are not records.
jameskerr Aug 31, 2023
85223de
Resizing the editor works very well.
jameskerr Aug 31, 2023
310d3c3
Everything can be resized
jameskerr Aug 31, 2023
6df65ba
Put the drag anchors in the right spots
jameskerr Aug 31, 2023
eef5fca
load pane progress
jameskerr Sep 13, 2023
8a324f4
Performance Issues Under Control
jameskerr Sep 13, 2023
69827b9
New Lake Modal Done
jameskerr Sep 14, 2023
7620925
Modals are all updated
jameskerr Sep 14, 2023
3784b9a
Use responsive menu works
jameskerr Sep 19, 2023
c850c2d
E2E
jameskerr Sep 21, 2023
503d71b
Got some tests working
jameskerr Sep 21, 2023
12c6140
Pool loads works
jameskerr Sep 22, 2023
cb3c015
Working on error states
jameskerr Sep 22, 2023
2fe174b
Clean up the error handling
jameskerr Sep 26, 2023
0917002
e2e tests work
jameskerr Sep 26, 2023
507e24a
Test fix
jameskerr Sep 26, 2023
7f8ca56
Cleanup ZQ Processes
jameskerr Sep 27, 2023
7ccf151
Cleanup ZQ procs
jameskerr Sep 27, 2023
e5d9da6
Clean up ZQ Processes
jameskerr Sep 28, 2023
9159c5e
Reset the form after submission
jameskerr Sep 29, 2023
e367829
No Header Carot if No Menu
jameskerr Sep 29, 2023
3437286
Show the Head Limit
jameskerr Sep 29, 2023
81ec543
Changed ZQ Error to Shaper Error
jameskerr Sep 29, 2023
8f9c6d1
Make Sure The Message Body Makes It
jameskerr Sep 29, 2023
67e02f5
Pass Files to ZQ
jameskerr Sep 29, 2023
7918a17
Preferences On Top
jameskerr Oct 2, 2023
71e62ba
Removed Common Form Components
jameskerr Oct 3, 2023
58e1ef1
Quick Load Finished
jameskerr Oct 5, 2023
f52fb71
Renamed Panes to Views
jameskerr Oct 6, 2023
96ec55f
Fix default value & recent loads
jameskerr Oct 12, 2023
3b7855e
Change the default sort order.
jameskerr Oct 12, 2023
cb73a7b
Add error message to table view.
jameskerr Oct 12, 2023
4abacc2
Cleanup ZQ
jameskerr Oct 12, 2023
222dcfd
Add the custom views to the preview load views.
jameskerr Oct 12, 2023
ec9bcde
Polish loads
jameskerr Oct 12, 2023
3efa8b8
Put the empty pool section on top
jameskerr Oct 12, 2023
c09b11b
Add a details area for the errors.
jameskerr Oct 12, 2023
8c47161
Quick Load Working Well
jameskerr Oct 16, 2023
2e5328d
Make sure the pool exists
jameskerr Oct 16, 2023
8303646
Fix pcap loading
jameskerr Oct 16, 2023
e1c7cf4
Remove unused code
jameskerr Oct 16, 2023
b750dfe
Fix PCAPS
jameskerr Oct 16, 2023
b67c794
Ensure zq process is really killed
jameskerr Oct 17, 2023
cc32ebc
Tests passing
jameskerr Oct 19, 2023
14b875b
Fix bug where focused window was hidden window
jameskerr Oct 20, 2023
001a139
Zui Player Tests Working
jameskerr Oct 20, 2023
f4178d9
Update scripts
jameskerr Oct 20, 2023
9ebc734
Default checked should be the descending
jameskerr Oct 20, 2023
15ce0b9
Exclude Zui Player from Lint
jameskerr Oct 20, 2023
49ecacc
Fix tests
jameskerr Oct 21, 2023
dca9286
Fix Form Submission
jameskerr Oct 23, 2023
6d6e3fc
Test Preview and Load
jameskerr Oct 23, 2023
8149b83
Polish Zui Player Readme
jameskerr Oct 23, 2023
c1d65d5
Tests Passing
jameskerr Oct 23, 2023
fa9a1a7
Fixup Yarn
jameskerr Oct 23, 2023
33d0af2
Forget this test
jameskerr Oct 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions apps/zui/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const moduleNameMapper = pathsToModuleNameMapper(config.compilerOptions.paths, {
module.exports = {
transform: {
"^.+\\.(t|j)sx?$": ["@swc/jest"],
".+\\.(css|styl|less|sass|scss)$": "jest-css-modules-transform",
},
setupFiles: ["./src/test/unit/setup/before-env.ts"],
setupFilesAfterEnv: ["./src/test/unit/setup/after-env.ts"],
Expand Down
9 changes: 6 additions & 3 deletions apps/zui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
"start:main": "yarn build:main --watch",
"start:renderer": "next dev",
"start:electron": "nodemon --watch dist ../../node_modules/electron/cli.js .",
"watch-code": "run-p start:main start:renderer",
"build": "run-p -l 'build:**'",
"build:main": "node scripts/esbuild.mjs",
"build:renderer": "next build",
"clean": "node scripts/clean",
"test": "jest",
"format": "prettier '**/*.{js,ts,tsx,scss}' --write --loglevel warn",
"tsc": "tsc",
"postinstall": "node scripts/post-install",
"prepare": "husky install",
"package": "electron-builder --publish never",
Expand Down Expand Up @@ -62,7 +64,7 @@
"@types/react-dom": "^18.0.1",
"@types/react-redux": "^7.1.25",
"@types/react-router": "^5.1.11",
"@types/react-transition-group": "^4.4.0",
"@types/react-transition-group": "^4.4.6",
"@types/react-window": "^1.8.5",
"@types/semver": "^7.3.3",
"@types/sprintf-js": "^1.1.2",
Expand All @@ -85,7 +87,7 @@
"electron": "22.0.0",
"electron-builder": "^23.6.0",
"electron-builder-notarize": "^1.2.0",
"electron-devtools-installer": "^3.2.0",
"electron-devtools-assembler": "^1.2.0",
"electron-dl": "^3.0.1",
"electron-localshortcut": "^3.2.1",
"electron-log": "5.0.0-beta.6",
Expand All @@ -106,6 +108,7 @@
"husky": "^7.0.4",
"is-wsl": "^2.2.0",
"jest": "^28.0.0",
"jest-css-modules-transform": "^4.4.2",
"jest-environment-jsdom": "^28.0.0",
"jwt-decode": "^3.1.2",
"lint-staged": "^12.1.5",
Expand Down Expand Up @@ -139,7 +142,7 @@
"react-router": "5.3.1",
"react-spring": "^8.0.27",
"react-tooltip": "^4.2.7",
"react-transition-group": "^2.9.0",
"react-transition-group": "^4.4.5",
"react-window": "^1.8.7",
"regenerator-runtime": "^0.13.6",
"reselect": "4.0.0",
Expand Down
1 change: 0 additions & 1 deletion apps/zui/pages/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export default function DetailPage() {
return (
<AppProvider store={app.store} api={app.api}>
<AppWindowRouter>
<div id="modal-dialog-root" />
<LogDetailsWindow />
<Modals />
<Tooltip />
Expand Down
4 changes: 2 additions & 2 deletions apps/zui/pages/search.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {useEffect, useState} from "react"
import {AppProvider} from "src/app/core/context"
import {invoke} from "src/core/invoke"
import App from "src/js/components/App"
import Application from "src/views/application"
import initialize from "src/js/initializers/initialize"
import TabHistories from "src/js/state/TabHistories"
import {getPersistedWindowState} from "src/js/state/stores/get-persistable"
Expand All @@ -28,7 +28,7 @@ export default function SearchPage() {

return (
<AppProvider store={app.store} api={app.api}>
<App />
<Application />
</AppProvider>
)
}
18 changes: 9 additions & 9 deletions apps/zui/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,8 @@
"sourceRoot": "apps/zui",
"projectType": "app",
"targets": {
"tsc": {
"executor": "@nrwl/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/apps/zui",
"main": "apps/zui/src/index.ts",
"tsConfig": "apps/zui/tsconfig.json",
"assets": ["apps/zui/*.md"]
}
"watch-tsc": {
"command": "tsc -p apps/zui/tsconfig.json --watch"
},
"lint": {
"executor": "@nrwl/linter:eslint",
Expand All @@ -29,6 +22,13 @@
"jestConfig": "apps/zui/jest.config.js",
"passWithNoTests": true
}
},
"build": {
"executor": "nx:run-script",
"outputs": ["{projectRoot}/dist", "{projectRoot}/out"],
"options": {
"script": "build"
}
}
}
}
6 changes: 6 additions & 0 deletions apps/zui/public/select-input-arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 3 additions & 9 deletions apps/zui/scripts/clean.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
const fs = require("fs-extra")
const glob = require("glob")
const {bold} = require("chalk")
const flags = require("./util/flags")

console.log(bold("Cleaning built files"))
if (!flags.keepDist) {
fs.removeSync("packages/zealot/dist")
fs.removeSync("dist")
} else {
console.log(bold("Keeping dist directories"))
}
fs.removeSync("out")
fs.removeSync(".next")
fs.removeSync("dist")
// These are broken symlinks that electron leaves around when it
// forcefully exists and can't clean them up. Babel tries to call
// stat on the broken symlinks and blows up.
Expand Down
7 changes: 0 additions & 7 deletions apps/zui/src/app/commands/new-pool.ts

This file was deleted.

81 changes: 1 addition & 80 deletions apps/zui/src/app/commands/pools.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import {CreatePoolOpts, LoadFormat} from "@brimdata/zed-js"
import errors from "src/js/errors"
import {ErrorData} from "src/js/errors/types"
import ErrorFactory from "src/js/models/ErrorFactory"
import {PoolName} from "../features/sidebar/pools-section/pool-name"
import {createCommand} from "./command"
import {deletePools} from "./delete-pools"
import {invoke} from "src/core/invoke"

function replaceLastItem<T>(array: T[], item: T) {
const next = [...array]
Expand All @@ -28,6 +23,7 @@ export const renameGroup = createCommand(
const parts = poolName.parts
// Replace the group part of the full name
parts[index] = parts[index].replace(prevName, newName)

const name = parts.join(delimiter)
changes.push({id: pool.id, changes: {name}})
}
Expand Down Expand Up @@ -69,78 +65,3 @@ export const deleteGroup = createCommand(
return deletePools.run(descendantIds)
}
)

export const createAndLoadFiles = createCommand(
"pools.createAndLoadFiles",
async (
{api},
files: string[],
opts: {name?: string; format?: LoadFormat} & Partial<CreatePoolOpts> = {}
) => {
let poolId: string | null = null
const poolNames = api.pools.all.map((p) => p.name)
if (!opts.name && files.length === 0) {
api.toast("No pool name and no files provided.")
return
}
try {
const name =
opts.name || (await invoke("derivePoolNameOp", files, poolNames))
poolId = await api.pools.create(name, opts)

if (files.length === 0) {
api.toast.success("Pool created: " + name)
} else {
const promise = api.pools.loadFiles(poolId, files, opts.format)
api.toast.promise(promise, {
loading: `Loading data into pool: ${name}...`,
success: "Load successful",
error: "Load error",
})
await promise
return poolId
}
} catch (e) {
console.error(e)
if (poolId) await api.pools.delete(poolId)
api.notice.error(parseError(e))
api.pools.syncAll()
throw e
}
}
)

export const loadFiles = createCommand(
"pools.loadFiles",
async ({api}, id: string, files: string[], format?: LoadFormat) => {
try {
const promise = api.pools.loadFiles(id, files, format)
api.toast.promise(promise, {
loading: "Loading data into pool...",
success: "Load successful",
error: "Load error",
})
await promise
} catch (e) {
api.notice.error(parseError(e))
api.pools.syncAll()
console.error(e)
}
}
)

function parseError(e: Error): ErrorData {
if (/(Failed to fetch)|(network error)/.test(e && e.message)) {
return errors.importInterrupt()
} else if (/format detection error/i.test(e && e.message)) {
return errors.formatDetection(e.message)
} else if (/EISDIR/.test(e && e.message)) {
return ErrorFactory.create(
new Error(
"Importing directories is not yet supported. Select multiple files."
)
)
} else {
return ErrorFactory.create(e)
}
}
21 changes: 21 additions & 0 deletions apps/zui/src/app/core/hooks/use-parent-size.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {MutableRefObject, useEffect, useState} from "react"

export function useParentSize<T extends HTMLElement>(ref: MutableRefObject<T>) {
const [{height, width}, setSize] = useState({width: 10, height: 10})

useEffect(() => {
const el = ref.current
const parent = el.parentElement
const ro = new ResizeObserver((e) => {
const {height, width} = e[0].contentRect
setSize({height, width})
})
ro.observe(parent)
return () => {
ro.unobserve(parent)
ro.disconnect()
}
}, [])

return {height, width}
}
4 changes: 2 additions & 2 deletions apps/zui/src/app/core/icon-temp.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react"
import classNames from "classnames"
import styled, {css} from "styled-components"
import styled from "styled-components"
import icons from "./icons"

export type IconName = keyof typeof icons
Expand All @@ -22,7 +22,7 @@ const Wrap = styled.i<{
svg {
height: ${(p) => p.size || 22}px;
width: ${(p) => p.size || 22}px;
fill: ${(p) => p.fill || css`var(--foreground-color)`};
fill: ${(p) => p.fill || "currentColor"};
stroke: ${(p) => p.stroke || "inherit"};
}
`
Expand Down
39 changes: 20 additions & 19 deletions apps/zui/src/app/core/models/abortables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,27 @@ export type Abortable<Meta = any> = {
}

type NewAbortable = Omit<Abortable, "id">
type Predicate = string | Partial<Abortable>

export class Abortables {
registry: Abortable[] = []

async abort(predicate: string | Partial<Abortable>) {
if (isString(predicate)) {
const a = this.get(predicate)
if (a) {
return await a.abort()
}
} else {
return Promise.all(
this.filter(predicate).map((a) => {
return a.abort()
})
)
}
const aborts = this.filter(predicate)
this.remove(predicate)
return await Promise.all(aborts.map((a) => a.abort()))
}

async abortAll() {
return Promise.all(this.all().map((a) => a.abort()))
}

create(id: string) {
const ctl = new AbortController()
this.add({id, abort: () => ctl.abort()})
return ctl
}

add(a: Abortable | NewAbortable) {
const id = "id" in a ? a.id : nanoid()
this.registry.push({id, ...a})
Expand All @@ -43,7 +41,7 @@ export class Abortables {
return [...this.registry]
}

filter(predicate?: Partial<Abortable>) {
filter(predicate?: Predicate) {
if (!predicate) return this.all()
return this.registry.filter(this.matchFn(predicate))
}
Expand All @@ -52,18 +50,21 @@ export class Abortables {
return this.registry.find((a) => a.id === id) || null
}

remove(predicate?: string | Partial<Abortable>) {
remove(predicate?: Predicate) {
if (!predicate) {
this.registry = []
} else if (isString(predicate)) {
remove(this.registry, (a) => a.id === predicate)
} else {
remove(this.registry, this.matchFn(predicate))
}
}

private matchFn(predicate) {
return (a) =>
Object.keys(predicate).every((key) => a[key] === predicate[key])
private matchFn(predicate: Predicate) {
return (a: Abortable) => {
if (isString(predicate)) {
return a.id === predicate
} else {
return Object.keys(predicate).every((key) => a[key] === predicate[key])
}
}
}
}
10 changes: 10 additions & 0 deletions apps/zui/src/app/core/models/zed-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,14 @@ export class ZedScript {
get ast() {
return this._ast || (this._ast = new ZedAst(this.script))
}

isEmpty() {
const lines = this.script.split("\n")
const comment = /^\s*\/\/.*$/
const whiteSpace = /^\s*$/
const linesWithZed = lines.filter(
(line) => !comment.test(line) && !whiteSpace.test(line)
)
return linesWithZed.length === 0
}
}
3 changes: 1 addition & 2 deletions apps/zui/src/app/core/pools/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ export class Pool {
}

empty() {
if (this.stats && this.stats.span) return this.stats.span.dur === 0
else return true
return this.size === 0
}

minTime(): Date {
Expand Down
Loading
Loading