@@ -3,42 +3,10 @@ import workflowsResponse from "./workflows-response.json";
33import plansResponse from "./plans-response.json" ;
44import instrumentSessionsResponse from "./instrumentSessions-response.json" ;
55import type { ScanEventMessage } from "../components/useSpectroscopyData" ;
6+ import { mapData } from "./mock_data" ;
67
78const fakeTaskId = "7304e8e0-81c6-4978-9a9d-9046ab79ce3c" ;
89
9- function mapData ( ) : ( number | null ) [ ] [ ] {
10- return [
11- [
12- 5467227.0 , 5467227.0 , 5480663.0 , 5478486.0 , 5477020.0 , 5474645.0 ,
13- 5472603.0 , 5470330.0 , 5468827.0 , 5467346.0 ,
14- ] ,
15- [
16- 5465947.0 , 5464940.0 , 5483401.0 , 5480384.0 , 5477378.0 , 5474776.0 ,
17- 5471462.0 , 5450634.0 , 5454651.0 , 5465208.0 ,
18- ] ,
19- [
20- 5463907.0 , 5463469.0 , 5481975.0 , 5479338.0 , 5476649.0 , 5474993.0 ,
21- 5473529.0 , 5471431.0 , 5470030.0 , 5468721.0 ,
22- ] ,
23- [
24- 5466907.0 , 5466023.0 , 5483679.0 , 5480875.0 , 5478044.0 , 5475180.0 ,
25- 5473196.0 , 5471168.0 , 5469539.0 , 5468190.0 ,
26- ] ,
27- [
28- 5466626.0 , 5465494.0 , 5483503.0 , 5480586.0 , 5477659.0 , 5475069.0 ,
29- 5473287.0 , 5471380.0 , 5469737.0 , 5468496.0 ,
30- ] ,
31- [
32- 5466713.0 , 5465920.0 , 5483587.0 , 5480582.0 , 5477829.0 , 5475202.0 ,
33- 5473244.0 , 5471103.0 , 5468010.0 , 5468222.0 ,
34- ] ,
35- [ 5467700.0 , null , null , null , null , null , null , null , null , null ] ,
36- [ null , null , null , null , null , null , null , null , null , null ] ,
37- [ null , null , null , null , null , null , null , null , null , null ] ,
38- [ null , null , null , null , null , null , null , null , null , null ] ,
39- ] ;
40- }
41-
4210export const handlers = [
4311 http . post ( "/api/graphql" , request => {
4412 const referrer = request . request . referrer ;
@@ -69,8 +37,9 @@ export const handlers = [
6937 const url = new URL ( request . url ) ;
7038 const filepath = url . searchParams . get ( "filepath" ) ;
7139 const datapath = url . searchParams . get ( "datapath" ) ;
72- console . log ( "Mock /api/data/map called" , { filepath, datapath } ) ;
73- const data = mapData ( ) ;
40+ const snake : boolean = JSON . parse ( url . searchParams . get ( "snake" ) ! ) ;
41+ console . log ( "Mock /api/data/map called" , { filepath, datapath, snake } ) ;
42+ const data = mapData ( snake ) ;
7443 return HttpResponse . json ( { values : data } ) ;
7544 } ) ,
7645
@@ -91,20 +60,22 @@ export const handlers = [
9160 uuid : "fake-scan-uuid" ,
9261 filepath : "/mock/path/fake.nxs" ,
9362 status : "running" ,
63+ snake : true ,
9464 } ) ;
9565
9666 // simulate data collection for ~5 seconds
9767 let counter = 0 ;
9868 const interval = setInterval ( ( ) => {
9969 counter ++ ;
100- console . log ( "Mock event tick" , counter ) ;
70+ // console.log("Mock event tick", counter);
10171 if ( counter >= 25 ) {
10272 clearInterval ( interval ) ;
10373 // Scan stops
10474 send ( {
10575 uuid : "fake-scan-uuid" ,
10676 filepath : "/mock/path/fake.nxs" ,
10777 status : "finished" ,
78+ snake : true ,
10879 } ) ;
10980 }
11081 } , 200 ) ;
0 commit comments