Skip to content

Commit

Permalink
refactor: levels
Browse files Browse the repository at this point in the history
  • Loading branch information
yan-elena committed Nov 27, 2023
1 parent 61c3155 commit 44fd474
Show file tree
Hide file tree
Showing 39 changed files with 87 additions and 71 deletions.
5 changes: 3 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import AgentEventsPage from "./pages/AgentEventsPage";
import NavBar from "./component/NavBar";
import {useEffect, useState} from "react";
import PageLocation from "./component/PageLocation";
import {Level} from "./model/Level";

function App() {
const navigate = useNavigate();
Expand Down Expand Up @@ -42,8 +43,8 @@ function App() {
<PageLocation agent={selectedAgent}/>
<Routes className="content">
<Route path="/agents" element={<HomePage files={files} loadAgentLog={loadAgentLog}/>}/>
<Route path="/agents/:agentName/implementation" exact element={<AgentEventsPage agent={selectedAgent} filter={""} level={"JASON"}/>}/>
<Route path="/agents/:agentName/design" exact element={<AgentEventsPage agent={selectedAgent} filter={""} level={"BDI"}/>}/>
<Route path="/agents/:agentName/implementation" exact element={<AgentEventsPage agent={selectedAgent} filter={""} level={Level.IMPLEMENTATION}/>}/>
<Route path="/agents/:agentName/design" exact element={<AgentEventsPage agent={selectedAgent} filter={""} level={Level.DESIGN}/>}/>
<Route path="/" exact element={<UploadLogPage setLogFiles={setLogFiles}/>}/>
</Routes>
</div>
Expand Down
16 changes: 13 additions & 3 deletions src/component/ControlForm.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import React from "react";
import Form from 'react-bootstrap/Form';
import {Col} from "react-bootstrap";
import {useLocation, useNavigate} from "react-router-dom";
import {Level} from "../model/Level";

function ControlForm(props) {

const navigate = useNavigate();
const location = useLocation()
function selectLevel(ev) {
const level = ev.target.value
navigate(location.pathname.replace(/[^/]*$/, level))
props.selectLevel(level)
}

return (
<Form.Group className="row m-4" controlId="formBasicSelect">
<Col sm={5}>
Expand All @@ -22,9 +32,9 @@ function ControlForm(props) {
<Col sm={1}/>
<Col sm={5}>
<Form.Label>Select the level:</Form.Label>
<Form.Select value={props.level} onChange={e => props.selectLevel(e.target.value)}>
<option value="JASON">Implementation Level</option>
<option value="BDI">Design Level</option>
<Form.Select value={props.level} onChange={selectLevel}>
<option value={Level.IMPLEMENTATION}>{Level.IMPLEMENTATION} level</option>
<option value={Level.DESIGN}>{Level.DESIGN} level</option>
</Form.Select>
</Col>

Expand Down
4 changes: 2 additions & 2 deletions src/component/PageLocation.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Breadcrumb from 'react-bootstrap/Breadcrumb';
import {useLocation} from "react-router-dom";

function PageLocation() {
function PageLocation(props) {

const location = useLocation().pathname
const pathname = location.split("/").filter(p => p).map(p => p.charAt(0).toUpperCase() + p.slice(1))
Expand All @@ -11,7 +11,7 @@ function PageLocation() {
<Breadcrumb className="m-1">
<Breadcrumb.Item href="#/">Home</Breadcrumb.Item>
{pathname.map((path, idx) => (
<Breadcrumb.Item href={"#/" + pathname.slice(0, idx + 1).join("/").toLowerCase()} key={idx} active={idx === pathname.length - 1}>{path}</Breadcrumb.Item>
<Breadcrumb.Item href={"#/" + pathname.slice(0, idx + 1).join("/").toLowerCase()} key={idx} active={path.toLowerCase() === props.agent.name || idx === pathname.length - 1}>{path}</Breadcrumb.Item>
))}
</Breadcrumb>
);
Expand Down
123 changes: 61 additions & 62 deletions src/component/event/EventMapping.js
Original file line number Diff line number Diff line change
@@ -1,67 +1,66 @@
import PlanAdded from "./jason/planEvent/PlanAdded";
import ExecutedDeed from "./jason/actionEvent/ExecutedDeed";
import ExternalActionFinished from "./jason/actionEvent/ExternalActionFinished";
import ExternalActionTriggered from "./jason/actionEvent/ExternalActionTriggered";
import InternalActionFinished from "./jason/actionEvent/InternalActionFinished";
import BeliefFromSrcAdded from "./jason/beliefEvent/BeliefFromSrcAdded";
import BeliefAdded from "./jason/beliefEvent/BeliefAdded";
import BeliefFromSrcRemoved from "./jason/beliefEvent/BeliefFromSrcRemoved";
import BeliefRemoved from "./jason/beliefEvent/BeliefRemoved";
import GoalCreated from "./jason/goalEvent/GoalCreated";
import GoalRemoved from "./jason/goalEvent/GoalRemoved";
import GoalSuspended from "./jason/goalEvent/GoalSuspended";
import IntentionCreated from "./jason/intentionEvent/IntentionCreated";
import IntentionRemoved from "./jason/intentionEvent/IntentionRemoved";
import IntentionSuspended from "./jason/intentionEvent/IntentionSuspended";
import IntentionUpdated from "./jason/intentionEvent/IntentionUpdated";
import IntentionWaiting from "./jason/intentionEvent/IntentionWaiting";
import NewPercept from "./jason/perceptEvent/NewPercept";
import PlanRemoved from "./jason/planEvent/PlanRemoved";
import SelectPlanEvent from "./jason/planEvent/SelectPlanEvent";
import ReasoningCycleStarted from "./jason/reasoningCycleEvent/ReasoningCycleStarted";
import NewAgentSignal from "./jason/signalEvent/NewAgentSignal";
import NewArtifactSignal from "./jason/signalEvent/NewArtifactSignal";
import MailBoxMessages from "./jason/speechActMessageEvent/MailBoxMessages";
import NewSpeechActMessage from "./jason/speechActMessageEvent/NewSpeechActMessage";
import SelectedMessage from "./jason/speechActMessageEvent/SelectedMessage";
import SendMessage from "./jason/speechActMessageEvent/SendMessage";
import PlanSelected from "./jason/goalEvent/PlanSelected";
import NewDesire from "./bdi/NewDesire";
import DesireCommitted from "./bdi/DesireCommitted";
import DesireRemoved from "./bdi/DesireRemoved";
import ExecutedAction from "./bdi/ExecutedAction";
import BDIBeliefRemoved from "./bdi/BeliefRemoved";
import NewBelief from "./bdi/NewBelief";
import PlanAdded from "./implementation/planEvent/PlanAdded";
import ExecutedDeed from "./implementation/actionEvent/ExecutedDeed";
import ExternalActionFinished from "./implementation/actionEvent/ExternalActionFinished";
import ExternalActionTriggered from "./implementation/actionEvent/ExternalActionTriggered";
import InternalActionFinished from "./implementation/actionEvent/InternalActionFinished";
import BeliefFromSrcAdded from "./implementation/beliefEvent/BeliefFromSrcAdded";
import BeliefAdded from "./implementation/beliefEvent/BeliefAdded";
import BeliefFromSrcRemoved from "./implementation/beliefEvent/BeliefFromSrcRemoved";
import BeliefRemoved from "./implementation/beliefEvent/BeliefRemoved";
import GoalCreated from "./implementation/goalEvent/GoalCreated";
import GoalRemoved from "./implementation/goalEvent/GoalRemoved";
import GoalSuspended from "./implementation/goalEvent/GoalSuspended";
import IntentionCreated from "./implementation/intentionEvent/IntentionCreated";
import IntentionRemoved from "./implementation/intentionEvent/IntentionRemoved";
import IntentionSuspended from "./implementation/intentionEvent/IntentionSuspended";
import IntentionUpdated from "./implementation/intentionEvent/IntentionUpdated";
import IntentionWaiting from "./implementation/intentionEvent/IntentionWaiting";
import NewPercept from "./implementation/perceptEvent/NewPercept";
import PlanRemoved from "./implementation/planEvent/PlanRemoved";
import SelectPlanEvent from "./implementation/planEvent/SelectPlanEvent";
import ReasoningCycleStarted from "./implementation/reasoningCycleEvent/ReasoningCycleStarted";
import NewAgentSignal from "./implementation/signalEvent/NewAgentSignal";
import NewArtifactSignal from "./implementation/signalEvent/NewArtifactSignal";
import MailBoxMessages from "./implementation/speechActMessageEvent/MailBoxMessages";
import NewSpeechActMessage from "./implementation/speechActMessageEvent/NewSpeechActMessage";
import SelectedMessage from "./implementation/speechActMessageEvent/SelectedMessage";
import SendMessage from "./implementation/speechActMessageEvent/SendMessage";
import PlanSelected from "./implementation/goalEvent/PlanSelected";
import NewDesire from "./design/NewDesire";
import DesireCommitted from "./design/DesireCommitted";
import DesireRemoved from "./design/DesireRemoved";
import ExecutedAction from "./design/ExecutedAction";
import NewBelief from "./design/NewBelief";

const EventMapping = {
ExecutedDeed: {JASON: <ExecutedDeed/>, BDI: <ExecutedAction/>},
ExternalActionFinished: {JASON: <ExternalActionFinished/>, BDI: <ExecutedAction/>},
ExternalActionTriggered: {JASON: <ExternalActionTriggered/>, BDI: <></>},
InternalActionFinished: {JASON: <InternalActionFinished/>, BDI: <ExecutedAction/>},
BeliefAdded: {JASON: <BeliefAdded/>, BDI: <NewBelief/>},
BeliefFromSrcAdded: {JASON: <BeliefFromSrcAdded/>, BDI: <></>},
BeliefFromSrcRemoved: {JASON: <BeliefFromSrcRemoved/>, BDI: <></>},
BeliefRemoved: {JASON: <BeliefRemoved/>, BDI: <BDIBeliefRemoved/>},
GoalCreated: {JASON: <GoalCreated/>, BDI: <NewDesire/>},
GoalRemoved: {JASON: <GoalRemoved/>, BDI: <DesireRemoved/>},
GoalSuspended: {JASON: <GoalSuspended/>, BDI: <></>},
PlanSelected: {JASON: <PlanSelected/>, BDI: <></>},
IntentionCreated: {JASON: <IntentionCreated/>, BDI: <></>},
IntentionRemoved: {JASON: <IntentionRemoved/>, BDI: <></>},
IntentionSuspended: {JASON: <IntentionSuspended/>, BDI: <></>},
IntentionUpdated: {JASON: <IntentionUpdated/>, BDI: <></>},
IntentionWaiting: {JASON: <IntentionWaiting/>, BDI: <></>},
NewPercept: {JASON: <NewPercept/>, BDI: <></>},
PlanAdded: {JASON: <PlanAdded/>, BDI: <></>},
PlanRemoved: {JASON: <PlanRemoved/>, BDI: <></>},
SelectPlanEvent: {JASON: <SelectPlanEvent/>, BDI: <DesireCommitted/>},
ReasoningCycleStarted: {JASON: <ReasoningCycleStarted/>, BDI: <></>},
NewAgentSignal: {JASON: <NewAgentSignal/>, BDI: <></>},
NewArtifactSignal: {JASON: <NewArtifactSignal/>, BDI: <NewArtifactSignal/>},
MailBoxMessages: {JASON: <MailBoxMessages/>, BDI: <></>},
NewSpeechActMessage: {JASON: <NewSpeechActMessage/>, BDI: <NewSpeechActMessage/>},
SelectedMessage: {JASON: <SelectedMessage/>, BDI: <></>},
SendMessage: {JASON: <SendMessage/>, BDI: <SendMessage/>}
ExecutedDeed: {implementation: <ExecutedDeed/>, design: <ExecutedAction/>},
ExternalActionFinished: {implementation: <ExternalActionFinished/>, design: <ExecutedAction/>},
ExternalActionTriggered: {implementation: <ExternalActionTriggered/>, design: <></>},
InternalActionFinished: {implementation: <InternalActionFinished/>, design: <ExecutedAction/>},
BeliefAdded: {implementation: <BeliefAdded/>, design: <NewBelief/>},
BeliefFromSrcAdded: {implementation: <BeliefFromSrcAdded/>, design: <></>},
BeliefFromSrcRemoved: {implementation: <BeliefFromSrcRemoved/>, design: <></>},
BeliefRemoved: {implementation: <BeliefRemoved/>, design: <designBeliefRemoved/>},
GoalCreated: {implementation: <GoalCreated/>, design: <NewDesire/>},
GoalRemoved: {implementation: <GoalRemoved/>, design: <DesireRemoved/>},
GoalSuspended: {implementation: <GoalSuspended/>, design: <></>},
PlanSelected: {implementation: <PlanSelected/>, design: <></>},
IntentionCreated: {implementation: <IntentionCreated/>, design: <></>},
IntentionRemoved: {implementation: <IntentionRemoved/>, design: <></>},
IntentionSuspended: {implementation: <IntentionSuspended/>, design: <></>},
IntentionUpdated: {implementation: <IntentionUpdated/>, design: <></>},
IntentionWaiting: {implementation: <IntentionWaiting/>, design: <></>},
NewPercept: {implementation: <NewPercept/>, design: <></>},
PlanAdded: {implementation: <PlanAdded/>, design: <></>},
PlanRemoved: {implementation: <PlanRemoved/>, design: <></>},
SelectPlanEvent: {implementation: <SelectPlanEvent/>, design: <DesireCommitted/>},
ReasoningCycleStarted: {implementation: <ReasoningCycleStarted/>, design: <></>},
NewAgentSignal: {implementation: <NewAgentSignal/>, design: <></>},
NewArtifactSignal: {implementation: <NewArtifactSignal/>, design: <NewArtifactSignal/>},
MailBoxMessages: {implementation: <MailBoxMessages/>, design: <></>},
NewSpeechActMessage: {implementation: <NewSpeechActMessage/>, design: <NewSpeechActMessage/>},
SelectedMessage: {implementation: <SelectedMessage/>, design: <></>},
SendMessage: {implementation: <SendMessage/>, design: <SendMessage/>}
};

export default EventMapping;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from "react";
import Event from "../../Event";
import {agentState} from "../../../../model/agentState";
import {Level} from "../../../../model/Level";

function NewArtifactSignal(props) {
if (props.level === "JASON") {
if (props.level === Level.IMPLEMENTATION) {
return (
<div>
<Event type={props.event.message.type.replace(/\B([A-Z])\B/g, ' $1')}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from "react";
import Event from "../../Event";
import {agentState} from "../../../../model/agentState";
import {Level} from "../../../../model/Level";

function NewSpeechActMessage(props) {

if (props.level === "JASON") {
if (props.level === Level.IMPLEMENTATION) {
return (
<div>
<Event type={props.event.message.type.replace(/\B([A-Z])\B/g, ' $1')}
Expand Down
4 changes: 4 additions & 0 deletions src/model/Level.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const Level = {
IMPLEMENTATION: "implementation",
DESIGN: "design"
}

0 comments on commit 44fd474

Please sign in to comment.