Add ImageJ.JS and Kaibu to the plugin menu
This commit is contained in:
parent
a692b90ede
commit
3b002d59a5
1 changed files with 72 additions and 15 deletions
|
|
@ -26,6 +26,24 @@
|
||||||
v-if="Object.keys(loadedPlugins).length > 0"
|
v-if="Object.keys(loadedPlugins).length > 0"
|
||||||
class="uk-nav-divider"
|
class="uk-nav-divider"
|
||||||
></li>
|
></li>
|
||||||
|
<li>
|
||||||
|
<a href="#" @click="startImageJ()"
|
||||||
|
><img
|
||||||
|
alt="ImageJ.JS icon"
|
||||||
|
style="width:20px;"
|
||||||
|
src="https://ij.imjoy.io/assets/icons/chrome/chrome-installprocess-128-128.png"
|
||||||
|
/> ImageJ.JS</a
|
||||||
|
>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="#" @click="startKaibu()"
|
||||||
|
><img
|
||||||
|
alt="Kaibu icon"
|
||||||
|
style="width:20px;"
|
||||||
|
src="https://kaibu.org/static/img/kaibu-icon.svg"
|
||||||
|
/> Kaibu</a
|
||||||
|
>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a
|
<a
|
||||||
v-for="(p, name) in loadedPlugins"
|
v-for="(p, name) in loadedPlugins"
|
||||||
|
|
@ -53,6 +71,15 @@
|
||||||
<h4 class="window-title">{{ w.name }}</h4>
|
<h4 class="window-title">{{ w.name }}</h4>
|
||||||
<div :id="w.window_id" class="window-container"></div>
|
<div :id="w.window_id" class="window-container"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="!activeWindow || windows.length <= 0"
|
||||||
|
class="uk-position-center position-relative text-center"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
style="width:80px;"
|
||||||
|
src="https://imjoy.io/static/img/imjoy-icon.svg"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div v-show="loading" class="progress uk-margin-small">
|
<div v-show="loading" class="progress uk-margin-small">
|
||||||
<div class="indeterminate"></div>
|
<div class="indeterminate"></div>
|
||||||
|
|
@ -69,7 +96,7 @@ export default {
|
||||||
components: {},
|
components: {},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
windows: {},
|
windows: [],
|
||||||
loading: false,
|
loading: false,
|
||||||
loadedPlugins: {},
|
loadedPlugins: {},
|
||||||
activeWindow: null,
|
activeWindow: null,
|
||||||
|
|
@ -95,17 +122,49 @@ export default {
|
||||||
closeActiveWindow() {
|
closeActiveWindow() {
|
||||||
if (this.activeWindow) {
|
if (this.activeWindow) {
|
||||||
this.activeWindow.api.close();
|
this.activeWindow.api.close();
|
||||||
this.activeWindow = null;
|
const index = this.windows.indexOf(this.activeWindow);
|
||||||
|
if (index > -1) {
|
||||||
|
this.windows.splice(index, 1);
|
||||||
|
}
|
||||||
|
if (this.windows.length > 0) {
|
||||||
|
this.activeWindow = this.windows[this.windows.length - 1];
|
||||||
|
} else {
|
||||||
|
this.activeWindow = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
selectWindow(name) {
|
selectWindow(name) {
|
||||||
for (let w of Object.values(this.windows)) {
|
for (let w of this.windows) {
|
||||||
if (w.name === name) {
|
if (w.name === name) {
|
||||||
this.activeWindow = w;
|
this.activeWindow = w;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async startKaibu() {
|
||||||
|
this.viewers.kaibu = await this.imjoy.pm.createWindow(null, {
|
||||||
|
name: "Kaibu",
|
||||||
|
src: "https://kaibu.org/#/app"
|
||||||
|
});
|
||||||
|
this.viewers.kaibu.on("close", () => {
|
||||||
|
delete this.viewers.kaibu;
|
||||||
|
});
|
||||||
|
this.selectWindow("Kaibu");
|
||||||
|
},
|
||||||
|
async startImageJ() {
|
||||||
|
this.viewers.imagej = await this.imjoy.pm.createWindow(null, {
|
||||||
|
name: "ImageJ.JS",
|
||||||
|
src: "https://ij.imjoy.io"
|
||||||
|
});
|
||||||
|
this.viewers.imagej.on("close", () => {
|
||||||
|
delete this.viewers.imagej;
|
||||||
|
});
|
||||||
|
// load the ITK/VTK viewer for imagej.js
|
||||||
|
this.loadPlugin(
|
||||||
|
"https://gist.githubusercontent.com/oeway/e5c980fbf6582f25fde795262a7e33ec/raw/itk-vtk-viewer-imagej.imjoy.html"
|
||||||
|
);
|
||||||
|
this.selectWindow("ImageJ.JS");
|
||||||
|
},
|
||||||
async setupViewers() {
|
async setupViewers() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
// TODO: improve this using the ImJoy `api.getServices`
|
// TODO: improve this using the ImJoy `api.getServices`
|
||||||
|
|
@ -116,13 +175,13 @@ export default {
|
||||||
// And this can be used for render our "Open In ImJoy" menu
|
// And this can be used for render our "Open In ImJoy" menu
|
||||||
try {
|
try {
|
||||||
const self = this;
|
const self = this;
|
||||||
this.viewers.kaibu = await this.imjoy.pm.createWindow(null, {
|
|
||||||
name: "Kaibu",
|
|
||||||
src: "https://kaibu.org/#/app"
|
|
||||||
});
|
|
||||||
this.$store.commit("addOpenInImjoyMenuItem", {
|
this.$store.commit("addOpenInImjoyMenuItem", {
|
||||||
title: "Kaibu",
|
title: "Kaibu",
|
||||||
async callback(name, imageUrl) {
|
async callback(name, imageUrl) {
|
||||||
|
if (!self.viewers.kaibu) {
|
||||||
|
await self.startKaibu();
|
||||||
|
}
|
||||||
self.selectWindow("Kaibu");
|
self.selectWindow("Kaibu");
|
||||||
const viewer = self.viewers.kaibu;
|
const viewer = self.viewers.kaibu;
|
||||||
viewer.set_mode("full");
|
viewer.set_mode("full");
|
||||||
|
|
@ -130,15 +189,13 @@ export default {
|
||||||
await viewer.add_shapes([]);
|
await viewer.add_shapes([]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.viewers.imagej = await this.imjoy.pm.createWindow(null, {
|
|
||||||
name: "ImageJ.JS",
|
|
||||||
src: "https://ij.imjoy.io"
|
|
||||||
});
|
|
||||||
// load the ITK/VTK viewer for imagej.js
|
|
||||||
this.loadPlugin("https://gist.githubusercontent.com/oeway/e5c980fbf6582f25fde795262a7e33ec/raw/itk-vtk-viewer-imagej.imjoy.html");
|
|
||||||
this.$store.commit("addOpenInImjoyMenuItem", {
|
this.$store.commit("addOpenInImjoyMenuItem", {
|
||||||
title: "ImageJ.JS",
|
title: "ImageJ.JS",
|
||||||
async callback(name, imageUrl) {
|
async callback(name, imageUrl) {
|
||||||
|
if (!self.viewers.imagej) {
|
||||||
|
await self.startImageJ();
|
||||||
|
}
|
||||||
self.selectWindow("ImageJ.JS");
|
self.selectWindow("ImageJ.JS");
|
||||||
const viewer = self.viewers.imagej;
|
const viewer = self.viewers.imagej;
|
||||||
const response = await fetch(imageUrl);
|
const response = await fetch(imageUrl);
|
||||||
|
|
@ -155,8 +212,8 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
addWindow(w) {
|
addWindow(w) {
|
||||||
this.windows = this.windows || {};
|
this.windows = this.windows || [];
|
||||||
this.windows[w.window_id] = w;
|
this.windows.push(w);
|
||||||
this.activeWindow = w;
|
this.activeWindow = w;
|
||||||
this.$forceUpdate();
|
this.$forceUpdate();
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue