Skip to content

Commit

Permalink
trigger remote run config fetch on config.ini save
Browse files Browse the repository at this point in the history
  • Loading branch information
MFA-X-AI committed Sep 4, 2024
1 parent 1b72607 commit fb22c59
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/XircuitsFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class XircuitsFactory extends ABCWidgetFactory<DocumentWidget> {
commands: any;
serviceManager: ServiceManager;
fetchComponentsSignal: Signal<this, any>;
fetchRemoteRunConfigSignal: Signal<this, any>;
saveXircuitSignal: Signal<this, any>;
compileXircuitSignal: Signal<this, any>;
runXircuitSignal: Signal<this, any>;
Expand All @@ -55,6 +56,7 @@ export class XircuitsFactory extends ABCWidgetFactory<DocumentWidget> {
this.commands = options.commands;
this.serviceManager = options.serviceManager;
this.fetchComponentsSignal = new Signal<this, any>(this);
this.fetchRemoteRunConfigSignal = new Signal<this, any>(this);
this.saveXircuitSignal = new Signal<this, any>(this);
this.compileXircuitSignal = new Signal<this, any>(this);
this.runXircuitSignal = new Signal<this, any>(this);
Expand All @@ -76,6 +78,7 @@ export class XircuitsFactory extends ABCWidgetFactory<DocumentWidget> {
context: context,
serviceManager: this.serviceManager,
fetchComponentsSignal: this.fetchComponentsSignal,
fetchRemoteRunConfigSignal: this.fetchRemoteRunConfigSignal,
saveXircuitSignal: this.saveXircuitSignal,
compileXircuitSignal: this.compileXircuitSignal,
runXircuitSignal: this.runXircuitSignal,
Expand Down
3 changes: 3 additions & 0 deletions src/XircuitsWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class XircuitsPanel extends ReactWidget {
xircuitsApp: XircuitsApplication;
serviceManager: ServiceManager;
fetchComponentsSignal: Signal<this,any>;
fetchRemoteRunConfigSignal: Signal<this,any>;
saveXircuitSignal: Signal<this, any>;
compileXircuitSignal: Signal<this, any>;
runXircuitSignal: Signal<this, any>;
Expand All @@ -38,6 +39,7 @@ export class XircuitsPanel extends ReactWidget {
this.context = options.context;
this.serviceManager = options.serviceManager;
this.fetchComponentsSignal = options.fetchComponentsSignal;
this.fetchRemoteRunConfigSignal = options.fetchRemoteRunConfigSignal;
this.saveXircuitSignal = options.saveXircuitSignal;
this.compileXircuitSignal = options.compileXircuitSignal;
this.runXircuitSignal = options.runXircuitSignal;
Expand Down Expand Up @@ -89,6 +91,7 @@ export class XircuitsPanel extends ReactWidget {
widgetId={this.parent?.id}
serviceManager={this.serviceManager}
fetchComponentsSignal={this.fetchComponentsSignal}
fetchRemoteRunConfigSignal={this.fetchRemoteRunConfigSignal}
saveXircuitSignal={this.saveXircuitSignal}
compileXircuitSignal={this.compileXircuitSignal}
runXircuitSignal={this.runXircuitSignal}
Expand Down
3 changes: 2 additions & 1 deletion src/commands/CommandIDs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ export const commandIDs = {
refreshComponentList: "xircuits-sidebar:refresh-component-list",
toggleDisplayNodesInLibrary: "xircuits-sidebar:toggle-display-nodes-in-library",
helpOpenResource: "xircuits-help:open-resource",
openXircuitsConfiguration: "xircuits-config:open-config"
openXircuitsConfiguration: "xircuits-config:open-config",
fetchRemoteRunConfig: "xircuits-config:fetch-remote-config"
};
4 changes: 3 additions & 1 deletion src/components/XircuitsBodyWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export interface BodyWidgetProps {
widgetId?: string;
serviceManager: ServiceManager;
fetchComponentsSignal: Signal<XircuitsPanel, any>;
fetchRemoteRunConfigSignal: Signal<XircuitsPanel, any>;
saveXircuitSignal: Signal<XircuitsPanel, any>;
compileXircuitSignal: Signal<XircuitsPanel, any>;
runXircuitSignal: Signal<XircuitsPanel, any>;
Expand Down Expand Up @@ -81,6 +82,7 @@ export const BodyWidget: FC<BodyWidgetProps> = ({
commands,
widgetId,
fetchComponentsSignal,
fetchRemoteRunConfigSignal,
saveXircuitSignal,
compileXircuitSignal,
runXircuitSignal,
Expand Down Expand Up @@ -859,6 +861,7 @@ export const BodyWidget: FC<BodyWidgetProps> = ({
[saveXircuitSignal, handleSaveClick],
[compileXircuitSignal, handleCompileClick],
[runXircuitSignal, handleRunClick],
[fetchRemoteRunConfigSignal, getRemoteRunTypeFromConfig],
[lockNodeSignal, handleLockClick],
[triggerLoadingAnimationSignal, triggerLoadingAnimation],
[reloadAllNodesSignal, handleReloadAll],
Expand All @@ -878,7 +881,6 @@ export const BodyWidget: FC<BodyWidgetProps> = ({
runTypeXircuitSignal.connect((_, args) => {
runType = args["runType"];
setRunType(runType)
// console.log(runType)
});
}, [runTypeXircuitSignal])

Expand Down
14 changes: 12 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,16 @@ const xircuits: JupyterFrontEndPlugin<void> = {
{label: "Run Xircuits", icon: runIcon, execute: emitSignal(widgetFactory.runXircuitSignal)}],
[commandIDs.compileXircuit,
{execute: emitSignal(widgetFactory.compileXircuitSignal)}],
[commandIDs.lockXircuit,
[commandIDs.fetchRemoteRunConfig,
{execute: emitSignal(widgetFactory.fetchRemoteRunConfigSignal)}],
[commandIDs.lockXircuit,
{execute: emitSignal(widgetFactory.lockNodeSignal)}],
[commandIDs.triggerLoadingAnimation,
{execute: emitSignal(widgetFactory.triggerLoadingAnimationSignal)}],
[commandIDs.reloadAllNodes,
{execute: emitSignal(widgetFactory.reloadAllNodesSignal)}],
[commandIDs.toggleAllLinkAnimation,
{execute: emitSignal(widgetFactory.toggleAllLinkAnimationSignal)}],
{execute: emitSignal(widgetFactory.toggleAllLinkAnimationSignal)}]
]
signalConnections.forEach(([cmdId, def]) => app.commands.addCommand(cmdId, def))

Expand Down Expand Up @@ -288,6 +290,14 @@ const xircuits: JupyterFrontEndPlugin<void> = {
}
});
}

if (context.path.endsWith('config.ini')) {
context.fileChanged.connect(async () => {
if(context.path.startsWith(".xircuits/")){
await app.commands.execute(commandIDs.fetchRemoteRunConfig);
}
});
}
});

let outputPanel: OutputPanel;
Expand Down

0 comments on commit fb22c59

Please sign in to comment.