Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions ci/test/lint-main/checks/check-js-typedefs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

# Copyright Materialize, Inc. and contributors. All rights reserved.
#
# Use of this software is governed by the Business Source License
# included in the LICENSE file at the root of this repository.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0.
#
# check-js-typedefs.sh — type-check JS files with JSDoc annotations.

set -euo pipefail

cd "$(dirname "$0")/../../../.."

. misc/shlib/shlib.bash

if ! command -v npm &>/dev/null; then
echo "lint: npm is not installed"
echo "hint: install Node.js from https://nodejs.org/ or via your package manager"
fi

try npm install --prefix test/dataflow-visualizer --silent
try npx --prefix test/dataflow-visualizer tsc -p test/dataflow-visualizer/tsconfig.typecheck.json
Comment on lines +25 to +26
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could check that npm exists and if not print a note for how to install it


try_status_report
5 changes: 5 additions & 0 deletions src/environmentd/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ mod cluster;
mod console;
mod memory;
mod metrics;
mod metrics_viz;
mod probe;
mod prometheus;
mod root;
Expand Down Expand Up @@ -210,6 +211,10 @@ impl HttpServer {
"/hierarchical-memory",
routing::get(memory::handle_hierarchical_memory),
)
.route(
"/metrics-viz",
routing::get(metrics_viz::handle_metrics_viz),
)
Comment on lines +214 to +217
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Realizing that these interactive JS pages are going to not work if password authentication is enabled. This was already an issue, but might be worth documenting this somewhere

.route("/static/{*path}", routing::get(root::handle_static));

let mut ws_router = Router::new()
Expand Down
25 changes: 25 additions & 0 deletions src/environmentd/src/http/metrics_viz.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright Materialize, Inc. and contributors. All rights reserved.
//
// Use of this software is governed by the Business Source License
// included in the LICENSE file.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0.

use askama::Template;
use axum::response::IntoResponse;

use crate::BUILD_INFO;

#[derive(Template)]
#[template(path = "metrics-viz.html")]
struct MetricsVizTemplate<'a> {
version: &'a str,
}

pub async fn handle_metrics_viz() -> impl IntoResponse {
mz_http_util::template_response(MetricsVizTemplate {
version: BUILD_INFO.version,
})
}
35 changes: 35 additions & 0 deletions src/environmentd/src/http/static/js/fetch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright Materialize, Inc. and contributors. All rights reserved.
//
// Use of this software is governed by the Business Source License
// included in the LICENSE file.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0.

'use strict';

/**
* Execute a SQL query against the /api/sql endpoint.
*
* @param {string} sql - SQL query string
* @returns {Promise<Object>} - The parsed JSON response
*/
async function query(sql) {
const response = await fetch('/api/sql', {
method: 'POST',
body: JSON.stringify({ query: sql }),
headers: { 'Content-Type': 'application/json' },
});
if (!response.ok) {
const text = await response.text();
throw `request failed: ${response.status} ${response.statusText}: ${text}`;
}
const data = await response.json();
for (const result of data.results) {
if (result.error) {
throw `SQL error: ${result.error.message}`;
}
}
return data;
}
14 changes: 0 additions & 14 deletions src/environmentd/src/http/static/js/hierarchical-memory.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,6 @@

const hpccWasm = window['@hpcc-js/wasm'];

async function query(sql) {
const response = await fetch('/api/sql', {
method: 'POST',
body: JSON.stringify({ query: sql }),
headers: { 'Content-Type': 'application/json' },
});
if (!response.ok) {
const text = await response.text();
throw `request failed: ${response.status} ${response.statusText}: ${text}`;
}
const data = await response.json();
return data;
}

function formatNameForQuery(name) {
return `'${name.replace('\'', '\'\'')}'`;
}
Expand Down
19 changes: 0 additions & 19 deletions src/environmentd/src/http/static/js/memory.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,6 @@

const hpccWasm = window['@hpcc-js/wasm'];

async function query(sql) {
const response = await fetch('/api/sql', {
method: 'POST',
body: JSON.stringify({ query: sql }),
headers: { 'Content-Type': 'application/json' },
});
if (!response.ok) {
const text = await response.text();
throw `request failed: ${response.status} ${response.statusText}: ${text}`;
}
const data = await response.json();
for (const result of data.results) {
if (result.error) {
throw `SQL error: ${result.error.message}`;
}
}
return data;
}

function formatNameForQuery(name) {
return `'${name.replace('\'', '\'\'')}'`;
}
Expand Down
Loading