Skip to content

Commit

Permalink
[VTAdmin] Remove vtctld web link, improve local example (#15607)
Browse files Browse the repository at this point in the history
Signed-off-by: notfelineit <notfelineit@gmail.com>
  • Loading branch information
notfelineit committed May 1, 2024
1 parent 0af0297 commit 79dd600
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
7 changes: 6 additions & 1 deletion examples/common/scripts/vtadmin-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ web_dir="${script_dir}/../../../web/vtadmin"
vtadmin_api_port=14200
vtadmin_web_port=14201

echo "vtadmin-api http-origin set to \"http://${hostname}:${vtadmin_web_port}\""

vtadmin \
--addr "${hostname}:${vtadmin_api_port}" \
--http-origin "http://${hostname}:${vtadmin_web_port}" \
Expand All @@ -48,9 +50,12 @@ vtadmin-api is running!
- PID: ${vtadmin_api_pid}
"

echo "Building vtadmin-web..."
source "${web_dir}/build.sh"

# Wait for vtadmin to successfully discover the cluster
expected_cluster_result="{\"result\":{\"clusters\":[{\"id\":\"${cluster_name}\",\"name\":\"${cluster_name}\"}]},\"ok\":true}"
for _ in {0..300}; do
for _ in {0..100}; do
result=$(curl -s "http://${hostname}:${vtadmin_api_port}/api/clusters")
if [[ ${result} == "${expected_cluster_result}" ]]; then
break
Expand Down
9 changes: 9 additions & 0 deletions web/vtadmin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ web_dir="${script_dir}"

vtadmin_api_port=14200

if [ -z "${hostname}" ]
then
hostname=$(hostname -f)
output "\n\033[1;32mhostname was empty, set it to \"${hostname}\"\033[0m"
fi

# Download nvm and node
if [[ -z ${NVM_DIR} ]]; then
export NVM_DIR="$HOME/.nvm"
Expand All @@ -50,6 +56,9 @@ npm --prefix "$web_dir" --silent install

export PATH=$PATH:$web_dir/node_modules/.bin/

vite_vtadmin_api_address="http://${hostname}:${vtadmin_api_port}"
output "\n\033[1;32mSetting VITE_VTADMIN_API_ADDRESS to \"${vite_vtadmin_api_address}\"\033[0m"

VITE_VTADMIN_API_ADDRESS="http://${hostname}:${vtadmin_api_port}" \
VITE_ENABLE_EXPERIMENTAL_TABLET_DEBUG_VARS="true" \
npm run --prefix "$web_dir" build
11 changes: 1 addition & 10 deletions web/vtadmin/src/components/routes/Vtctlds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export const Vtctlds = () => {
cluster: v.cluster?.name,
clusterID: v.cluster?.id,
hostname: v.hostname,
fqdn: v.FQDN,
}));

const filtered = filterNouns(filter, mapped);
Expand All @@ -50,15 +49,7 @@ export const Vtctlds = () => {
return (
<tr key={row.hostname}>
<DataCell>
<div className="font-bold">
{row.fqdn ? (
<a href={`//${row.fqdn}`} rel="noopener noreferrer" target="_blank">
{row.hostname}
</a>
) : (
row.hostname
)}
</div>
<div className="font-bold">{row.hostname}</div>
</DataCell>
<DataCell>
{row.cluster}
Expand Down

0 comments on commit 79dd600

Please sign in to comment.