Skip to content

Commit d9eaaa5

Browse files
committed
chore: align demo index to table plugin
1 parent d506042 commit d9eaaa5

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

demo/index.html

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<title>YASGUI Graph Plugin Demo</title>
1717

1818
<!-- YASGUI CSS -->
19-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@matdata/yasgui@5.1.0/build/yasgui.min.css">
19+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@matdata/yasgui@5.6.0/build/yasgui.min.css">
2020

2121
<!-- Font Awesome for icons -->
2222
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
@@ -102,6 +102,7 @@
102102
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
103103
}
104104
</style>
105+
105106
</head>
106107
<body>
107108
<h1>🔷 YASGUI Graph Plugin Demo</h1>
@@ -138,34 +139,25 @@ <h2 onclick="toggleInstructions()">
138139
<div id="yasgui"></div>
139140

140141
<!-- YASGUI JavaScript -->
141-
<script src="https://cdn.jsdelivr.net/npm/@matdata/yasgui@5.1.0/build/yasgui.min.js"></script>
142+
<script src="https://cdn.jsdelivr.net/npm/@matdata/yasgui@5.6.0/build/yasgui.min.js"></script>
142143

143144
<!-- Sample queries -->
144145
<script src="./queries.js"></script>
145146

146147
<!-- Graph Plugin: Load from source in dev, or from dist in production -->
147148
<script type="module">
148-
// Detect if we're in development mode by checking if running on localhost/file protocol
149-
const isDev = window.location.hostname === 'localhost' ||
150-
window.location.hostname === '127.0.0.1' ||
151-
window.location.hostname === '[::1]' ||
152-
window.location.protocol === 'file:';
149+
// Detect if running in Vite dev server (module system available)
150+
const isViteDev = import.meta.env?.DEV;
153151

154152
let pluginLoaded = false;
155153

156-
// In development mode, try to load from source
157-
if (isDev) {
158-
try {
159-
const { default: GraphPlugin } = await import('../src/GraphPlugin.js');
160-
if (window.Yasgui && window.Yasgui.Yasr) {
161-
window.Yasgui.Yasr.registerPlugin('Graph-Dev', GraphPlugin);
162-
pluginLoaded = true;
163-
console.log('✅ Graph Plugin loaded from source (dev mode)');
164-
}
165-
} catch (error) {
166-
console.log('⚠️ Source not available, falling back to bundle');
167-
}
168-
}
154+
if (isViteDev) {
155+
// Development mode: Load plugin from source
156+
const { default: GraphPlugin } = await import('@matdata/yasgui-graph-plugin');
157+
window.YasguiGraphPlugin = { GraphPlugin };
158+
pluginLoaded = true;
159+
console.log('✅ Graph Plugin loaded from source (Vite dev mode)');
160+
}
169161

170162
// In production mode or if dev load failed, load the bundle
171163
if (!pluginLoaded) {
@@ -184,6 +176,14 @@ <h2 onclick="toggleInstructions()">
184176
});
185177
}
186178

179+
// Register the graph plugin
180+
if (window.Yasgui && window.YasguiGraphPlugin) {
181+
Yasgui.Yasr.registerPlugin('Graph-Dev', window.YasguiGraphPlugin.GraphPlugin);
182+
console.log('✅ Graph Plugin registered as "Graph-Dev"');
183+
} else {
184+
console.error('❌ Failed to load Graph Plugin');
185+
}
186+
187187
// Initialize YASGUI after plugin is registered
188188
const yasgui = new Yasgui(document.getElementById('yasgui'), {
189189
// Set the SPARQL endpoint
@@ -197,8 +197,7 @@ <h2 onclick="toggleInstructions()">
197197
{ endpoint: "https://data-interop.era.europa.eu/api/sparql", label: "ERA" }
198198
],
199199
yasr: {
200-
pluginOrder: ['Table', 'Response', 'Graph'],
201-
defaultPlugin: 'Graph',
200+
defaultPlugin: 'Graph-Dev',
202201
},
203202
copyEndpointOnNewTab: false,
204203
});

0 commit comments

Comments
 (0)