Skip to content

Commit

Permalink
Merge pull request #482 from highperformancecoder/ravel-498-confused-…
Browse files Browse the repository at this point in the history
…pick-slices

Rejig pick-slices to use direct query of backend api, rather than com…
  • Loading branch information
highperformancecoder committed Apr 29, 2024
2 parents 1ac70d5 + 2629753 commit 8382b5f
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 48 deletions.
1 change: 0 additions & 1 deletion gui-js/apps/minsky-electron/src/app/backend-init.ts
Expand Up @@ -52,7 +52,6 @@ export async function backend(command: string, ...args: any[]): Promise<any> {
}
CppClass.record(`${command} ${arg}`);

log.info('Async Rest API: ',command,arg);
let response=await restService.call(command, arg);
if (logFilter(command))
log.info('Async Rest API: ',command,arg,"=>",response);
Expand Down
8 changes: 0 additions & 8 deletions gui-js/apps/minsky-electron/src/app/events/electron.events.ts
Expand Up @@ -11,7 +11,6 @@ import {
events,
HandleDescriptionPayload,
HandleDimensionPayload,
PickSlicesPayload,
MinskyProcessPayload,
minsky,
RenderNativeWindow,
Expand Down Expand Up @@ -175,13 +174,6 @@ ipcMain.handle(
}
);

ipcMain.handle(
events.SAVE_PICK_SLICES,
async (event, payload: PickSlicesPayload) => {
return await CommandsManager.savePickSlices(payload);
}
);

ipcMain.handle(
events.CURRENT_TAB_POSITION,
async (event)=>{
Expand Down
12 changes: 1 addition & 11 deletions gui-js/apps/minsky-electron/src/app/managers/CommandsManager.ts
Expand Up @@ -4,7 +4,6 @@ import {
events,
Functions,
HandleDimensionPayload,
PickSlicesPayload,
InitializePopupWindowPayload,
electronMenuBarHeightForWindows, HandleDescriptionPayload,
importCSVvariableName,
Expand Down Expand Up @@ -1067,24 +1066,15 @@ export class CommandsManager {
}

static async pickSlices(ravel: Ravel, handleIndex: number) {
// encode slice labels for transport through CGI URI
const allSliceLabels = (await ravel.allSliceLabels()).map(x=>encodeURIComponent(x));
const pickedSliceLabels = (await ravel.pickedSliceLabels()).map(x=>encodeURIComponent(x));

const window=WindowManager.createPopupWindowWithRouting({
title: `Pick slices`,
url: `#/headless/pick-slices?command=${ravel.$prefix()}&handleIndex=${handleIndex}&allSliceLabels=${allSliceLabels.join()}&pickedSliceLabels=${pickedSliceLabels.join()}`,
url: `#/headless/pick-slices?command=${ravel.$prefix()}&handleIndex=${handleIndex}`,
height: 400,
width: 400,
});
Object.defineProperty(window,'dontCloseOnReturn',{value: true,writable:false});
}

static async savePickSlices(payload: PickSlicesPayload) {
await (new Ravel(payload.command)).pickSliceLabels(payload.handleIndex, payload.pickedSliceLabels);
minsky.reset();
}

static async lockSpecificHandles(ravel: Ravel) {
let allLockHandles = await ravel.lockGroup.allLockHandles();
if(Object.keys(allLockHandles).length === 0) {
Expand Down
Expand Up @@ -927,8 +927,8 @@ export class ContextMenuManager {
new MenuItem({
label: 'Pick axis slices',
enabled: handleAvailable,
click: async () => {
await CommandsManager.pickSlices(ravel,handleIndex);
click: () => {
CommandsManager.pickSlices(ravel,handleIndex);
}
}),
new MenuItem({
Expand Down
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { events, CurrentWindowDetails, HandleDescriptionPayload, HandleDimensionPayload, PickSlicesPayload,} from '@minsky/shared';
import { events, CurrentWindowDetails, HandleDescriptionPayload, HandleDimensionPayload,} from '@minsky/shared';
import isElectron from 'is-electron';
import {Minsky, CppClass} from '@minsky/shared';

Expand Down Expand Up @@ -69,10 +69,6 @@ export class ElectronService {
return await this.ipcRenderer.invoke(events.SAVE_HANDLE_DIMENSION, payload);
}

async savePickSlices(payload: PickSlicesPayload) {
return await this.ipcRenderer.invoke(events.SAVE_PICK_SLICES, payload);
}

async currentTabPosition(): Promise<number[]> {
return await this.ipcRenderer.invoke(events.CURRENT_TAB_POSITION);
}
Expand Down
6 changes: 0 additions & 6 deletions gui-js/libs/shared/src/lib/interfaces/Interfaces.ts
Expand Up @@ -52,12 +52,6 @@ export interface HandleDimensionPayload {
units: string;
}

export interface PickSlicesPayload {
command: string;
handleIndex: number;
pickedSliceLabels: string[];
}

export interface ElectronCanvasOffset {
left: number;
top: number;
Expand Down
Expand Up @@ -4,6 +4,7 @@ import { ElectronService } from '@minsky/core';
import { MessageBoxSyncOptions } from 'electron/renderer';
import { MatButtonModule } from '@angular/material/button';
import { NgFor } from '@angular/common';
import {Ravel} from '@minsky/shared';

@Component({
selector: 'minsky-pick-slices',
Expand All @@ -15,7 +16,7 @@ import { NgFor } from '@angular/common';
export class PickSlicesComponent implements OnInit {
sliceLabels: {label: string, selected: boolean, lastClicked: boolean}[] = [];

command: string;
ravel: Ravel;
handleIndex: number;

constructor(
Expand All @@ -24,16 +25,16 @@ export class PickSlicesComponent implements OnInit {
) {}

ngOnInit(): void {
this.route.queryParams.subscribe((params) => {
this.command=params['command'];
this.route.queryParams.subscribe(async (params) => {
this.ravel=new Ravel(params['command']);
this.handleIndex = +params['handleIndex'];

const pickedSliceLabels = params['pickedSliceLabels'].split(',');
this.sliceLabels = params['allSliceLabels'].split(',').map(l => ({
label: l,
selected: pickedSliceLabels.includes(l),
lastClicked: false
}));
const pickedSliceLabels = await this.ravel.pickedSliceLabels();
const allSliceLabels=await this.ravel.allSliceLabelsAxis(this.handleIndex);
this.sliceLabels = allSliceLabels.map(l => ({
label: l,
selected: pickedSliceLabels.includes(l),
lastClicked: false
}));
});
}

Expand All @@ -48,11 +49,7 @@ export class PickSlicesComponent implements OnInit {

await this.electronService.showMessageBoxSync(options);
} else {
await this.electronService.savePickSlices({
command: this.command,
handleIndex: this.handleIndex,
pickedSliceLabels: this.sliceLabels.filter(sl => sl.selected).map(sl => sl.label)
});
await this.ravel.pickSliceLabels(this.handleIndex, this.sliceLabels.filter(sl => sl.selected).map(sl => sl.label));
}
}
this.closeWindow();
Expand Down

0 comments on commit 8382b5f

Please sign in to comment.