Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
234 lines (203 loc) · 7.09 KB
/
Copy pathindex.html
File metadata and controls
234 lines (203 loc) · 7.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Transmission Pipeline Editor</title>
<script type="importmap">
{
"imports": {
"@elicdavis/node-flow": "./node_modules/@elicdavis/node-flow/dist/index.mjs",
"grapoi": "./node_modules/grapoi/index.js",
"rdf-ext": "./node_modules/rdf-ext/dist/rdf-ext.mjs",
"node-flow-components": "./src/tools/nodeflow/components/index.js"
}
}
</script>
<style>
body,
html {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
overflow: hidden;
font-family: Arial, sans-serif;
}
#editor-container {
position: relative;
width: 100%;
height: 100%;
}
#canvas {
width: 100%;
height: 100%;
display: block;
}
#toolbar {
position: fixed;
top: 0;
left: 0;
right: 0;
padding: 10px;
background-color: #0c2b35;
color: #afb9bb;
display: flex;
gap: 10px;
z-index: 100;
}
button {
padding: 5px 10px;
background-color: #154050;
color: #afb9bb;
border: 1px solid #1c1c1c;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.2s;
}
button:hover {
background-color: #195366;
}
#status {
margin-left: auto;
padding: 5px 10px;
background-color: #07212a;
border-radius: 4px;
}
.dialog {
display: none;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #0c2b35;
border: 1px solid #154050;
border-radius: 8px;
padding: 20px;
z-index: 200;
min-width: 300px;
}
.dialog h2 {
margin-top: 0;
color: #afb9bb;
}
.dialog label {
display: block;
margin-bottom: 5px;
color: #afb9bb;
}
.dialog input {
width: 100%;
padding: 8px;
background-color: #07212a;
border: 1px solid #154050;
border-radius: 4px;
color: #afb9bb;
margin-bottom: 15px;
}
.dialog-buttons {
display: flex;
justify-content: flex-end;
gap: 10px;
}
</style>
</head>
<body>
<div id="toolbar">
<button id="load-btn">Load TTL</button>
<button id="save-btn">Save TTL</button>
<button id="new-btn">New Transmission</button>
<button id="organize-btn">Organize</button>
<span id="status">Ready</span>
</div>
<div id="editor-container">
<canvas id="canvas"></canvas>
</div>
<div id="new-dialog" class="dialog">
<h2>New Transmission</h2>
<label for="transmission-name">Transmission Name:</label>
<input type="text" id="transmission-name" value="New Transmission">
<div class="dialog-buttons">
<button id="cancel-new">Cancel</button>
<button id="create-new">Create</button>
</div>
</div>
<!-- Hidden file input -->
<input type="file" id="file-input" accept=".ttl" style="display:none">
<script type="module">
import { TransmissionEditor } from "./src/tools/nodeflow/components/index.js"
document.addEventListener('DOMContentLoaded', () => {
// Initialize the editor
const canvas = document.getElementById('canvas')
const editor = new TransmissionEditor(canvas)
// Set up UI elements
const fileInput = document.getElementById('file-input')
const loadBtn = document.getElementById('load-btn')
const saveBtn = document.getElementById('save-btn')
const newBtn = document.getElementById('new-btn')
const organizeBtn = document.getElementById('organize-btn')
const status = document.getElementById('status')
// New transmission dialog
const newDialog = document.getElementById('new-dialog')
const transmissionName = document.getElementById('transmission-name')
const cancelNewBtn = document.getElementById('cancel-new')
const createNewBtn = document.getElementById('create-new')
// Load TTL file
loadBtn.addEventListener('click', () => {
fileInput.click()
})
fileInput.addEventListener('change', async (e) => {
const file = e.target.files[0]
if (file) {
try {
status.textContent = `Loading ${file.name}...`
await editor.loadFromFile(file.path || URL.createObjectURL(file))
status.textContent = `Loaded ${file.name}`
} catch (error) {
status.textContent = `Error: ${error.message}`
console.error(error)
}
}
})
// Save TTL file
saveBtn.addEventListener('click', async () => {
try {
status.textContent = 'Saving...'
// In a real application, we would show a file dialog here
// For now, we'll just save to the loaded file
await editor.saveToFile()
status.textContent = 'Saved!'
} catch (error) {
status.textContent = `Error: ${error.message}`
console.error(error)
}
})
// New transmission
newBtn.addEventListener('click', () => {
newDialog.style.display = 'block'
})
cancelNewBtn.addEventListener('click', () => {
newDialog.style.display = 'none'
})
createNewBtn.addEventListener('click', () => {
const name = transmissionName.value.trim() || 'New Transmission'
editor.createNewTransmission(name)
newDialog.style.display = 'none'
status.textContent = `Created new transmission: ${name}`
})
// Organize graph
organizeBtn.addEventListener('click', () => {
try {
editor.getGraph().organize()
status.textContent = 'Graph organized!'
} catch (error) {
status.textContent = `Error: ${error.message}`
console.error(error)
}
})
// Initial status
status.textContent = 'Ready - Click "Load TTL" to open a transmission file'
});
</script>
</body>
</html>