Skip to content

Instantly share code, notes, and snippets.

@pieper
Created January 24, 2020 09:38
Show Gist options
  • Select an option

  • Save pieper/658731a7ef77231711c651ec622a6432 to your computer and use it in GitHub Desktop.

Select an option

Save pieper/658731a7ef77231711c651ec622a6432 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="description"
content="Open Health Imaging Foundation DICOM Viewer"
/>
<meta
name="viewport"
content="width=device-width,initial-scale=1.0,minimum-scale=1,maximum-scale=1,user-scalable=no"
/>
<meta name="theme-color" content="#000000" />
<meta http-equiv="cleartype" content="on" />
<meta name="MobileOptimized" content="320" />
<meta name="HandheldFriendly" content="True" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<!-- WEB FONTS -->
<link
href="https://fonts.googleapis.com/css?family=Sanchez"
rel="stylesheet"
/>
<title>OHIF Standalone Viewer</title>
</head>
<body>
<noscript> You need to enable JavaScript to run this app. </noscript>
<div id="root"></div>
<script
src="https://unpkg.com/@ohif/viewer@3.3.3/dist/index.umd.js"
crossorigin
></script>
<script>
var containerId = "root";
var componentRenderedOrUpdatedCallback = function() {
console.log("OHIF Viewer rendered/updated");
};
const viewerConfig = {
// routerBasename: '/',
servers: {
dicomWeb: [
{
"name": "dicomweb_server",
"wadoUriRoot": "http://localhost:5985",
"qidoRoot": "http://localhost:5985",
"wadoRoot": "http://localhost:5985",
"qidoSupportsIncludeField": true,
"imageRendering": "wadouri",
"thumbnailRendering": "wadouri",
"requestOptions": {
"requestFromBrowser": true
}
},
/*
{
name: "DCM4CHEE",
wadoUriRoot:
"https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/wado",
qidoRoot:
"https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs",
wadoRoot:
"https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs",
qidoSupportsIncludeField: true,
imageRendering: "wadors",
thumbnailRendering: "wadors"
}
*/
],
},
extensions: [
{
id: "slicerExtension",
getToolbarModule() {
return {
definitions: [
{
id: "slicer",
label: "3D Slicer",
icon: "exclamation-triangle",
type: "command",
commandName: "launchSlicer"
}
],
defaultContext: "VIEWER"
};
},
getCommandsModule({ servicesManager }) {
const { UINotificationService } = servicesManager.services;
return {
definitions: {
launchSlicer: {
commandFn: function() {
console.log(UINotificationService);
console.log(launchSlicer());
UINotificationService.show({
title: "Launching 3D Slicer",
message: "New tab will open when ready"
});
},
storeContexts: [],
options: {}
}
},
defaultContext: ["VIEWER"]
};
}
}
]
};
const googleOIDCConfig = [ {
// ~ REQUIRED
// Authorization Server URL
authority: 'https://accounts.google.com',
client_id: '370953977065-o32uf5cn5f4bovtogdu862mlnhbcv9hk.apps.googleusercontent.com',
redirect_uri: '/callback.html', // `OHIFStandaloneViewer.js`
response_type: 'id_token token',
scope: 'email profile openid https://www.googleapis.com/auth/cloudplatformprojects.readonly https://www.googleapis.com/auth/cloud-healthcare', // email profile openid
// ~ OPTIONAL
post_logout_redirect_uri: '/logout-redirect.html',
revoke_uri: 'https://accounts.google.com/o/oauth2/revoke?token=',
automaticSilentRenew: true,
revokeAccessTokenOnSignout: true,
} ];
viewerConfig.servers = { dicomWeb: [], };
viewerConfig.oidc = googleOIDCConfig;
window.OHIFViewer.installViewer(
viewerConfig,
containerId,
componentRenderedOrUpdatedCallback
);
function launchSlicer() {
const postEndpoint = "https://www.googleapis.com/compute/v1/projects/project-7519307760985532298/zones/us-central1-a/instances"
const launchTemplate = `
{
"kind": "compute#instance",
"name": "slicer-1",
"zone": "projects/project-7519307760985532298/zones/us-central1-a",
"machineType": "projects/project-7519307760985532298/zones/us-central1-a/machineTypes/n1-standard-1",
"displayDevice": {
"enableDisplay": false
},
"metadata": {
"kind": "compute#metadata",
"items": [
{
"key": "gce-container-declaration",
"value": "spec:\n containers:\n - name: slicer-1\n image: stevepieper/slicer\n env:\n - name: SLICER_COMMAND\n value: print(10)\n stdin: false\n tty: false\n restartPolicy: Always\n\n# This container declaration format is not public API and may change without notice. Please\n# use gcloud command-line tool or Google Cloud Console to run Containers on Google Compute Engine."
},
{
"key": "google-logging-enabled",
"value": "true"
}
]
},
"tags": {
"items": [
"http-server"
]
},
"disks": [
{
"kind": "compute#attachedDisk",
"type": "PERSISTENT",
"boot": true,
"mode": "READ_WRITE",
"autoDelete": true,
"deviceName": "slicer-1",
"initializeParams": {
"sourceImage": "projects/cos-cloud/global/images/cos-stable-79-12607-80-0",
"diskType": "projects/project-7519307760985532298/zones/us-central1-a/diskTypes/pd-standard",
"diskSizeGb": "10"
},
"diskEncryptionKey": {}
}
],
"canIpForward": false,
"networkInterfaces": [
{
"kind": "compute#networkInterface",
"subnetwork": "projects/project-7519307760985532298/regions/us-central1/subnetworks/default",
"accessConfigs": [
{
"kind": "compute#accessConfig",
"name": "External NAT",
"type": "ONE_TO_ONE_NAT",
"networkTier": "PREMIUM"
}
],
"aliasIpRanges": []
}
],
"description": "",
"labels": {
"container-vm": "cos-stable-79-12607-80-0"
},
"scheduling": {
"preemptible": false,
"onHostMaintenance": "MIGRATE",
"automaticRestart": true,
"nodeAffinities": []
},
"deletionProtection": false,
"reservationAffinity": {
"consumeReservationType": "ANY_RESERVATION"
},
"serviceAccounts": [
{
"email": "748016054504-compute@developer.gserviceaccount.com",
"scopes": [
"https://www.googleapis.com/auth/cloud-platform"
]
}
]
}
`
var xhr = new XMLHttpRequest();
xhr.open("POST", '/server', true);
//Send the proper header information along with the request
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() { // Call a function when the state changes.
if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
// Request finished. Do processing here.
}
}
xhr.send("foo=bar&lorem=ipsum");
// xhr.send(new Int8Array());
// xhr.send(document);
}
</script>
</body>
</html>
@Entersjkhdfkjdhfksjf

Copy link
Copy Markdown

I would like to know what this is

@pieper

pieper commented Oct 4, 2024

Copy link
Copy Markdown
Author

It was an experiment to plug in a virtual machine launcher into the ohif system (ohif.org). I doubt it will work with current version of the software.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment