File tree 5 files changed +61
-117
lines changed
lib/lightning_web/components
5 files changed +61
-117
lines changed Original file line number Diff line number Diff line change @@ -30,13 +30,11 @@ import topbar from '../vendor/topbar.cjs';
30
30
import * as Hooks from './hooks' ;
31
31
import JobEditor from './job-editor' ;
32
32
import WorkflowEditor from './workflow-editor' ;
33
- import DataclipViewer from './dataclip-viewer' ;
34
33
import LogViewer from './log-viewer' ;
35
34
36
35
let hooks = {
37
36
JobEditor,
38
37
WorkflowEditor,
39
- DataclipViewer,
40
38
LogViewer,
41
39
...Hooks ,
42
40
} ;
@@ -123,6 +121,6 @@ window.liveSocket = liveSocket;
123
121
124
122
// Testing helper to simulate a reconnect
125
123
window . triggerReconnect = function triggerReconnect ( timeout = 5000 ) {
126
- liveSocket . disconnect ( ( ) => { } ) ;
124
+ liveSocket . disconnect ( ( ) => { } ) ;
127
125
setTimeout ( liveSocket . connect . bind ( liveSocket ) , timeout ) ;
128
126
} ;
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ import { MonacoEditor } from '#/monaco' ;
2
+ import { useEffect , useState } from 'react' ;
3
+
4
+ async function fetchDataclipContent ( dataclipId : string ) {
5
+ try {
6
+ const response = await fetch ( `/dataclip/body/${ dataclipId } ` , {
7
+ cache : 'default' ,
8
+ } ) ;
9
+ if ( ! response . ok && response . status !== 304 ) {
10
+ throw new Error ( 'Network response was not ok' ) ;
11
+ }
12
+
13
+ return await response . text ( ) ;
14
+ } catch ( error ) {
15
+ console . error ( 'Error fetching content:' , error ) ;
16
+ return 'Failed to load content' ;
17
+ }
18
+ }
19
+
20
+ export const DataclipViewer = ( { dataclipId } : { dataclipId : string } ) => {
21
+ const [ content , setContent ] = useState < string > ( '' ) ;
22
+ console . log ( "farhan:" , dataclipId )
23
+
24
+ useEffect ( ( ) => {
25
+ fetchDataclipContent ( dataclipId ) . then ( setContent ) ;
26
+ } , [ dataclipId ] ) ;
27
+
28
+ return (
29
+ < div className = 'h-full relative' >
30
+ < MonacoEditor
31
+ defaultLanguage = "json"
32
+ theme = "default"
33
+ value = { content }
34
+ loading = { < div > Loading...</ div > }
35
+ options = { {
36
+ readOnly : true ,
37
+ lineNumbersMinChars : 3 ,
38
+ tabSize : 2 ,
39
+ scrollBeyondLastLine : false ,
40
+ overviewRulerLanes : 0 ,
41
+ overviewRulerBorder : false ,
42
+ fontFamily : 'Fira Code VF' ,
43
+ fontSize : 14 ,
44
+ fontLigatures : true ,
45
+ minimap : {
46
+ enabled : false ,
47
+ } ,
48
+ wordWrap : 'on' ,
49
+ } }
50
+ />
51
+ </ div >
52
+ ) ;
53
+ } ;
Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ defmodule LightningWeb.Components.Viewers do
20
20
21
21
require Lightning.Run
22
22
23
+ import React
24
+
23
25
@ doc """
24
26
Renders out a log line stream
25
27
@@ -191,21 +193,14 @@ defmodule LightningWeb.Components.Viewers do
191
193
end
192
194
193
195
attr :id , :string , required: true
194
- attr :dataclip , :map , required: true
196
+ attr :dataclipId , :map , required: true
197
+
198
+ # react imports
199
+ jsx ( "assets/js/react/components/DataclipViewer.tsx" )
195
200
196
201
def dataclip_viewer ( assigns ) do
197
202
~H"""
198
- < div
199
- id = { @ id }
200
- class = "h-full relative "
201
- phx-hook = "DataclipViewer "
202
- phx-update = "ignore "
203
- data-id = { @ dataclip . id }
204
- data-target = { "#{ @ id } -viewer" }
205
- >
206
- < . dataclip_type id = { "#{ @ id } -type" } type = { @ dataclip . type } />
207
- < div id = { "#{ @ id } -viewer" } class = "h-full " > </ div >
208
- </ div >
203
+ < . DataclipViewer id = { @ id } dataclipId = { @ dataclip . id } />
209
204
"""
210
205
end
211
206
You can’t perform that action at this time.
0 commit comments