2024-05-23 16:33:30 +00:00
|
|
|
{{ define "settings" }}
|
|
|
|
<section class="p-5">
|
|
|
|
<form action="/settings/targets/create" method="post">
|
|
|
|
<label for="name">Name</label>
|
|
|
|
<input type="text" name="name" id="name" placeholder="Github.com" />
|
|
|
|
<p>Name of the target can be anything.</p>
|
|
|
|
<label for="visibility">Visibility</label>
|
|
|
|
<select name="visibility" id="visibility" required>
|
|
|
|
<option value="PUBLIC">Public</option>
|
|
|
|
<option value="PRIVATE">Private</option>
|
|
|
|
</select>
|
|
|
|
<p>
|
|
|
|
Visibility determines who can see the target. If set to
|
|
|
|
<code>public</code>, it will be visible to everyone on the homepage.
|
|
|
|
Otherwise it will be only visible to signed in users.
|
|
|
|
</p>
|
|
|
|
<label for="group">Target Group</label>
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
name="group"
|
|
|
|
id="group"
|
|
|
|
placeholder="default"
|
|
|
|
value="default"
|
|
|
|
required
|
|
|
|
/>
|
|
|
|
<p>
|
|
|
|
Group targets together. This affects how they are presented on the
|
|
|
|
homepage.
|
|
|
|
</p>
|
|
|
|
<label for="metadata">Metadata</label>
|
2024-05-25 11:45:25 +00:00
|
|
|
<textarea
|
|
|
|
required
|
|
|
|
id="metadata"
|
|
|
|
name="metadata"
|
|
|
|
class="sm:col-span-2 h-96"
|
|
|
|
>
|
2024-05-23 16:33:30 +00:00
|
|
|
{{ ScriptUnescapeString .Example }}</textarea
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
id="editor-metadata"
|
2024-05-25 11:45:25 +00:00
|
|
|
class="hidden sm:col-span-2 block w-full h-96 rounded-lg border border-gray-300 overflow-hidden"
|
2024-05-23 16:33:30 +00:00
|
|
|
></div>
|
2024-05-25 11:45:25 +00:00
|
|
|
<p class="sm:col-span-2">
|
2024-05-23 16:33:30 +00:00
|
|
|
Metadata is a YAML object that contains the configuration for the
|
|
|
|
target. This configuration can be then used for <code>Checks</code> to
|
|
|
|
filter the targets to act on as well as by using
|
|
|
|
<code>getTarget()</code>
|
|
|
|
function to fetch target metadata.
|
|
|
|
</p>
|
|
|
|
<button type="submit" onclick="save()">Create</button>
|
|
|
|
</form>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<script src="/static/monaco/vs/loader.js"></script>
|
|
|
|
<script>
|
|
|
|
const items = [{ name: "metadata", language: "yaml" }];
|
|
|
|
|
|
|
|
function save() {
|
|
|
|
for (const { name } of items) {
|
|
|
|
const elem = window.editors[name].getValue();
|
|
|
|
document.getElementById(name).value = elem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
window.editors = {};
|
2024-05-25 11:45:25 +00:00
|
|
|
for (const { name, language, options = {} } of items) {
|
2024-05-23 16:33:30 +00:00
|
|
|
const textarea = document.getElementById(name);
|
|
|
|
const editor = document.getElementById("editor-" + name);
|
|
|
|
|
|
|
|
editor.classList.remove("hidden");
|
|
|
|
textarea.hidden = true;
|
|
|
|
|
|
|
|
require.config({ paths: { vs: "/static/monaco/vs" } });
|
|
|
|
require(["vs/editor/editor.main"], function () {
|
|
|
|
window.editors[name] = monaco.editor.create(editor, {
|
|
|
|
value: textarea.value,
|
|
|
|
language: language,
|
|
|
|
minimap: { enabled: false },
|
|
|
|
codeLens: false,
|
|
|
|
contextmenu: false,
|
|
|
|
scrollBeyondLastLine: false,
|
2024-05-25 11:45:25 +00:00
|
|
|
...options,
|
2024-05-23 16:33:30 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
|
|
window.editors[name].layout();
|
|
|
|
});
|
|
|
|
resizeObserver.observe(editor);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
{{ end }}
|