Skip to content

Commit

Permalink
show only active FSMs added to viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
mgonzs13 committed Aug 9, 2024
1 parent f1e30d4 commit ee45bb5
Show file tree
Hide file tree
Showing 9 changed files with 182 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"files": {
"main.css": "/static/css/main.073c9b0a.css",
"main.js": "/static/js/main.e6d78718.js",
"main.js": "/static/js/main.989a7d71.js",
"static/js/787.d1eb2cfc.chunk.js": "/static/js/787.d1eb2cfc.chunk.js",
"index.html": "/index.html",
"main.073c9b0a.css.map": "/static/css/main.073c9b0a.css.map",
"main.e6d78718.js.map": "/static/js/main.e6d78718.js.map",
"main.989a7d71.js.map": "/static/js/main.989a7d71.js.map",
"787.d1eb2cfc.chunk.js.map": "/static/js/787.d1eb2cfc.chunk.js.map"
},
"entrypoints": [
"static/css/main.073c9b0a.css",
"static/js/main.e6d78718.js"
"static/js/main.989a7d71.js"
]
}
2 changes: 1 addition & 1 deletion yasmin_viewer/yasmin_viewer_web_client/build/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>YASMIN Viewer</title><script defer="defer" src="/static/js/main.e6d78718.js"></script><link href="/static/css/main.073c9b0a.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>YASMIN Viewer</title><script defer="defer" src="/static/js/main.989a7d71.js"></script><link href="/static/css/main.073c9b0a.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

108 changes: 108 additions & 0 deletions yasmin_viewer/yasmin_viewer_web_client/nodesource_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#!/bin/bash

# Logger Function
log() {
local message="$1"
local type="$2"
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
local color
local endcolor="\033[0m"

case "$type" in
"info") color="\033[38;5;79m" ;;
"success") color="\033[1;32m" ;;
"error") color="\033[1;31m" ;;
*) color="\033[1;34m" ;;
esac

echo -e "${color}${timestamp} - ${message}${endcolor}"
}

# Error handler function
handle_error() {
local exit_code=$1
local error_message="$2"
log "Error: $error_message (Exit Code: $exit_code)" "error"
exit $exit_code
}

# Function to check for command availability
command_exists() {
command -v "$1" &> /dev/null
}

check_os() {
if ! [ -f "/etc/debian_version" ]; then
echo "Error: This script is only supported on Debian-based systems."
exit 1
fi
}

# Function to Install the script pre-requisites
install_pre_reqs() {
log "Installing pre-requisites" "info"

# Run 'apt-get update'
if ! apt-get update -y; then
handle_error "$?" "Failed to run 'apt-get update'"
fi

# Run 'apt-get install'
if ! apt-get install -y apt-transport-https ca-certificates curl gnupg; then
handle_error "$?" "Failed to install packages"
fi

if ! mkdir -p /usr/share/keyrings; then
handle_error "$?" "Makes sure the path /usr/share/keyrings exist or run ' mkdir -p /usr/share/keyrings' with sudo"
fi

rm -f /usr/share/keyrings/nodesource.gpg || true
rm -f /etc/apt/sources.list.d/nodesource.list || true

# Run 'curl' and 'gpg'
if ! curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /usr/share/keyrings/nodesource.gpg; then
handle_error "$?" "Failed to download and import the NodeSource signing key"
fi
}

# Function to configure the Repo
configure_repo() {
local node_version=$1

arch=$(dpkg --print-architecture)
if [ "$arch" != "amd64" ] && [ "$arch" != "arm64" ] && [ "$arch" != "armhf" ]; then
handle_error "1" "Unsupported architecture: $arch. Only amd64, arm64, and armhf are supported."
fi

echo "deb [arch=$arch signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$node_version nodistro main" | tee /etc/apt/sources.list.d/nodesource.list > /dev/null

# N|solid Config
echo "Package: nsolid" | tee /etc/apt/preferences.d/nsolid > /dev/null
echo "Pin: origin deb.nodesource.com" | tee -a /etc/apt/preferences.d/nsolid > /dev/null
echo "Pin-Priority: 600" | tee -a /etc/apt/preferences.d/nsolid > /dev/null

# Nodejs Config
echo "Package: nodejs" | tee /etc/apt/preferences.d/nodejs > /dev/null
echo "Pin: origin deb.nodesource.com" | tee -a /etc/apt/preferences.d/nodejs > /dev/null
echo "Pin-Priority: 600" | tee -a /etc/apt/preferences.d/nodejs > /dev/null

# Run 'apt-get update'
if ! apt-get update -y; then
handle_error "$?" "Failed to run 'apt-get update'"
else
log "Repository configured successfully."
log "To install Node.js, run: apt-get install nodejs -y" "info"
log "You can use N|solid Runtime as a node.js alternative" "info"
log "To install N|solid Runtime, run: apt-get install nsolid -y \n" "success"
fi
}

# Define Node.js version
NODE_VERSION="18.x"

# Check OS
check_os

# Main execution
install_pre_reqs || handle_error $? "Failed installing pre-requisites"
configure_repo "$NODE_VERSION" || handle_error $? "Failed configuring repository"
4 changes: 2 additions & 2 deletions yasmin_viewer/yasmin_viewer_web_client/src/components/FSM.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class FSM extends React.Component {
name = "";
}

if (hide_nested_fsm && state.parent != 0 && state.id != 0) {
if (hide_nested_fsm && state.parent !== 0 && state.id !== 0) {
continue;
}

Expand Down Expand Up @@ -85,7 +85,7 @@ class FSM extends React.Component {

// FSM outcome
if (state.is_fsm) {
if (!hide_nested_fsm || (hide_nested_fsm && state.id == 0)) {
if (!hide_nested_fsm || (hide_nested_fsm && state.id === 0)) {
nodes.push({
data: {
id: fsm_data[0].name + "node" + state.id + outcome,
Expand Down
39 changes: 37 additions & 2 deletions yasmin_viewer/yasmin_viewer_web_client/src/components/TopAppBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@ export default function TopAppBar({
fsm_name_list,
handle_current_fsm,
handle_hide_nested_fsm,
handle_show_only_active_fsms,
}) {
const [hideNestedFSM, setHideNestedFSM] = React.useState(false);
const [currentFSM, setCurrentFSM] = React.useState("ALL");
const [hideNestedFSM, setHideNestedFSM] = React.useState(false);
const [showOnlyActiveFSMs, setShowOnlyActiveFSMs] = React.useState(false);

const handleChangeHideNestedFSM = (event) => {
setHideNestedFSM(event.target.checked);
};

const handleShowOnlyActiveFSMs = (event) => {
setShowOnlyActiveFSMs(event.target.checked);
};

React.useEffect(() => {
handle_current_fsm(currentFSM);
}, [currentFSM]);
Expand All @@ -29,6 +35,10 @@ export default function TopAppBar({
handle_hide_nested_fsm(hideNestedFSM);
}, [hideNestedFSM]);

React.useEffect(() => {
handle_show_only_active_fsms(showOnlyActiveFSMs);
}, [showOnlyActiveFSMs]);

return (
<Box sx={{ flexGrow: 1 }} style={{ width: "100%", height: "6.75vh" }}>
<AppBar style={{ margin: 0 }}>
Expand Down Expand Up @@ -105,7 +115,7 @@ export default function TopAppBar({
/>

<FormControlLabel
label="Hide Nested FSM"
label="Hide Nested FSMs"
control={
<Checkbox
checked={hideNestedFSM}
Expand All @@ -120,6 +130,31 @@ export default function TopAppBar({
/>
}
/>

<Divider
orientation="vertical"
variant="middle"
flexItem
color="white"
style={{ marginLeft: 30, marginRight: 30 }}
/>

<FormControlLabel
label="Show Only Active FSMs"
control={
<Checkbox
checked={showOnlyActiveFSMs}
onChange={handleShowOnlyActiveFSMs}
inputProps={{ "aria-label": "controlled" }}
sx={{
color: "white",
"&.Mui-checked": {
color: "white",
},
}}
/>
}
/>
</Toolbar>
</AppBar>
</Box>
Expand Down
40 changes: 27 additions & 13 deletions yasmin_viewer/yasmin_viewer_web_client/src/components/Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ class Viewer extends React.Component {
current_fsm_data: undefined,
current_fsm: "ALL",
hide_nested_fsm: false,
show_only_active_fsms: false,
};

this.handle_current_fsm = this.handle_current_fsm.bind(this);
this.handle_hide_nested_fsm = this.handle_hide_nested_fsm.bind(this);
this.handle_show_only_active_fsms =
this.handle_show_only_active_fsms.bind(this);
}

get_fsms() {
Expand Down Expand Up @@ -87,13 +90,18 @@ class Viewer extends React.Component {
this.setState({ hide_nested_fsm: hide_nested_fsm });
}

handle_show_only_active_fsms(show_only_active_fsms) {
this.setState({ show_only_active_fsms: show_only_active_fsms });
}

render() {
return (
<div>
<TopAppBar
fsm_name_list={this.state.fsm_name_list}
handle_current_fsm={this.handle_current_fsm}
handle_hide_nested_fsm={this.handle_hide_nested_fsm}
handle_show_only_active_fsms={this.handle_show_only_active_fsms}
/>

<div
Expand All @@ -107,19 +115,25 @@ class Viewer extends React.Component {
<Grid container spacing={3}>
{this.state.current_fsm === "ALL" ? (
this.state.fsm_list.map((fsm) => {
return (
<Grid
item
xs={6}
key={fsm[0].name + this.state.hide_nested_fsm}
>
<FSM
fsm_data={fsm}
alone={false}
hide_nested_fsm={this.state.hide_nested_fsm}
/>
</Grid>
);
if (
(this.state.show_only_active_fsms &&
fsm[0].current_state !== -1) ||
!this.state.show_only_active_fsms
) {
return (
<Grid
item
xs={6}
key={fsm[0].name + this.state.hide_nested_fsm}
>
<FSM
fsm_data={fsm}
alone={false}
hide_nested_fsm={this.state.hide_nested_fsm}
/>
</Grid>
);
}
})
) : (
<Grid item xs={12} key={this.state.hide_nested_fsm}>
Expand Down

0 comments on commit ee45bb5

Please sign in to comment.