feat: add Patchmon Sync job
Syncs patchmon field on instances by querying the Patchmon hosts API and matching hostnames. API token masked as REDACTED in responses. seedJobs now uses INSERT OR IGNORE so new jobs are seeded on existing installs without re-running the full seed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
23
js/ui.js
23
js/ui.js
@@ -483,6 +483,17 @@ function _renderJobConfigFields(key, cfg) {
|
||||
<input class="form-input" id="job-cfg-api-key" type="password"
|
||||
placeholder="tskey-api-…" value="${esc(cfg.api_key ?? '')}">
|
||||
</div>`;
|
||||
if (key === 'patchmon_sync') return `
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="job-cfg-api-url">API URL</label>
|
||||
<input class="form-input" id="job-cfg-api-url" type="text"
|
||||
placeholder="http://patchmon:3000/api/v1/api/hosts" value="${esc(cfg.api_url ?? '')}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="job-cfg-api-token">API Token (Basic)</label>
|
||||
<input class="form-input" id="job-cfg-api-token" type="password"
|
||||
placeholder="Basic token…" value="${esc(cfg.api_token ?? '')}">
|
||||
</div>`;
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -501,10 +512,14 @@ async function saveJobDetail(jobId) {
|
||||
const enabled = document.getElementById('job-enabled').checked;
|
||||
const schedule = document.getElementById('job-schedule').value;
|
||||
const cfg = {};
|
||||
const tailnet = document.getElementById('job-cfg-tailnet');
|
||||
const apiKey = document.getElementById('job-cfg-api-key');
|
||||
if (tailnet) cfg.tailnet = tailnet.value.trim();
|
||||
if (apiKey) cfg.api_key = apiKey.value;
|
||||
const tailnet = document.getElementById('job-cfg-tailnet');
|
||||
const apiKey = document.getElementById('job-cfg-api-key');
|
||||
const apiUrl = document.getElementById('job-cfg-api-url');
|
||||
const apiToken = document.getElementById('job-cfg-api-token');
|
||||
if (tailnet) cfg.tailnet = tailnet.value.trim();
|
||||
if (apiKey) cfg.api_key = apiKey.value;
|
||||
if (apiUrl) cfg.api_url = apiUrl.value.trim();
|
||||
if (apiToken) cfg.api_token = apiToken.value;
|
||||
const res = await fetch(`/api/jobs/${jobId}`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
|
||||
Reference in New Issue
Block a user