first-commit
This commit is contained in:
15
web_src/js/standalone/devtest.ts
Normal file
15
web_src/js/standalone/devtest.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import {showInfoToast, showWarningToast, showErrorToast} from '../modules/toast.ts';
|
||||
|
||||
function initDevtestToast() {
|
||||
const levelMap: Record<string, any> = {info: showInfoToast, warning: showWarningToast, error: showErrorToast};
|
||||
for (const el of document.querySelectorAll('.toast-test-button')) {
|
||||
el.addEventListener('click', () => {
|
||||
const level = el.getAttribute('data-toast-level');
|
||||
const message = el.getAttribute('data-toast-message');
|
||||
levelMap[level](message);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// NOTICE: keep in mind that this file is not in "index.js", they do not share the same module system.
|
||||
initDevtestToast();
|
30
web_src/js/standalone/swagger.ts
Normal file
30
web_src/js/standalone/swagger.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import SwaggerUI from 'swagger-ui-dist/swagger-ui-es-bundle.js';
|
||||
import 'swagger-ui-dist/swagger-ui.css';
|
||||
|
||||
window.addEventListener('load', async () => {
|
||||
const url = document.querySelector('#swagger-ui').getAttribute('data-source');
|
||||
const res = await fetch(url);
|
||||
const spec = await res.json();
|
||||
|
||||
// Make the page's protocol be at the top of the schemes list
|
||||
const proto = window.location.protocol.slice(0, -1);
|
||||
spec.schemes.sort((a: string, b: string) => {
|
||||
if (a === proto) return -1;
|
||||
if (b === proto) return 1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
SwaggerUI({
|
||||
spec,
|
||||
dom_id: '#swagger-ui',
|
||||
deepLinking: true,
|
||||
docExpansion: 'none',
|
||||
defaultModelRendering: 'model', // don't show examples by default, because they may be incomplete
|
||||
presets: [
|
||||
SwaggerUI.presets.apis,
|
||||
],
|
||||
plugins: [
|
||||
SwaggerUI.plugins.DownloadUrl,
|
||||
],
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user