114 lines
No EOL
3 KiB
PHP
114 lines
No EOL
3 KiB
PHP
<?php
|
|
|
|
use Symfony\Component\Yaml\Yaml;
|
|
use Utils\CsrfToken;
|
|
use Utils\Select;
|
|
use Utils\Debug;
|
|
|
|
if (!isset($error)) {
|
|
$error = null;
|
|
}
|
|
|
|
if (!isset($content)) {
|
|
$content = Yaml::dump($services, 2);
|
|
}
|
|
|
|
$breadcrumbs = ' / Edit';
|
|
$debug = new Debug;
|
|
|
|
|
|
require 'header.php';
|
|
require 'titleBar.php';
|
|
?>
|
|
<?php
|
|
/*<table class="table-list">
|
|
<thead>
|
|
<tr>
|
|
<th>Title</th>
|
|
<th>Link</th>
|
|
<th>Delete</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($services as $service) : ?>
|
|
<tr>
|
|
<td><?= $service['title']; ?></td>
|
|
<td><?= $service['link']; ?></td>
|
|
<td>Delete</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>*/
|
|
?>
|
|
<form action="index.php" class="login" method="post">
|
|
|
|
<div class="alert" style="color: red;" id="alert">
|
|
<?= $error; ?>
|
|
</div>
|
|
|
|
<textarea rows="50" name="services" id="services" spellcheck="false"><?= $content; ?></textarea>
|
|
|
|
<input type="hidden" name="token" value="<?= CsrfToken::generateToken(); ?>">
|
|
<input type="hidden" name="edit" value="1" />
|
|
|
|
<div class="flex">
|
|
<a class="button" href="?">Cancel</a>
|
|
<button type="submit">Save</button>
|
|
</div>
|
|
</form>
|
|
<!--
|
|
<form action="index.php" class="login" method="post">
|
|
|
|
<label for="title">Title</label>
|
|
<input type="text" name="title" id="title">
|
|
|
|
<label for="screenshot">Screenshot name</label>
|
|
<input type="text" name="screenshot" id="screenshot">
|
|
|
|
<label for="favicon">Favicon name</label>
|
|
<input type="text" name="favicon" id="favicon">
|
|
|
|
<label for="link">Link</label>
|
|
<input type="text" name="link" id="link">
|
|
|
|
<label for="appHome">Home application</label>
|
|
<input type="text" name="appHome" id="appHome">
|
|
|
|
<label for="desc">Desc</label>
|
|
<input type="text" name="desc" id="desc">
|
|
|
|
<label for="location">Location</label>
|
|
<input type="text" name="location" id="location">
|
|
|
|
<label for="type">Install instalation type</label>
|
|
<select name="type" id="type">
|
|
<option value="docker">Docker</option>
|
|
<option value="vm">Virtual machine</option>
|
|
<option value="webapp">Webapp</option>
|
|
<option value="redirection">Redirection</option>
|
|
</select>
|
|
|
|
<input type="hidden" name="token" value="">
|
|
<input type="hidden" name="settings" value="1" />
|
|
<button type="submit">Add</button>
|
|
</form>
|
|
!-->
|
|
|
|
<script src="assets/js/js-yaml.min.js"></script>
|
|
<script>
|
|
function validateYAML() {
|
|
console.log('here')
|
|
const inputText = document.getElementById('services').value;
|
|
try {
|
|
jsyaml.load(inputText);
|
|
document.getElementById('alert').textContent = "Your YAML is valid!";
|
|
} catch (e) {
|
|
document.getElementById('alert').textContent = "Your YAML is not valid!" + "\n\n" + "Error message: " + e.message;
|
|
}
|
|
}
|
|
document.getElementById('services').addEventListener('keyup', validateYAML);
|
|
</script>
|
|
|
|
<?php
|
|
require('footer.php');
|
|
?>
|