Gate both kiosks behind a device token, and make an unreachable setting a test failure
This commit is contained in:
@@ -10,6 +10,50 @@
|
||||
is nothing in it to find and edit.
|
||||
</p>
|
||||
|
||||
<div class="card form-card">
|
||||
<h3>Collector behaviour</h3>
|
||||
<div class="form-group">
|
||||
<label>Corporate ranges (CIDR)</label>
|
||||
<input v-model="extra.collector_corporate_ranges" type="text"
|
||||
class="form-control" placeholder="10.0.0.0/8, 192.168.0.0/16" />
|
||||
<p class="field-hint">
|
||||
Comma-separated CIDRs naming this site's routable networks. The server
|
||||
picks a PC's primary address from these when the agent reports several.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Quiet report hours</label>
|
||||
<input v-model.number="extra.computers_quietreporthours" type="number"
|
||||
min="1" class="form-control" />
|
||||
<p class="field-hint">
|
||||
Hours without a collector report before a PC counts as silent on the
|
||||
dashboard.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="check-row">
|
||||
<input type="checkbox" v-model="machinelinkAlerts" />
|
||||
<span>Alert when a PC takes over another PC's machine</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="check-row">
|
||||
<input type="checkbox" v-model="configPoliciesEnabled" />
|
||||
<span>Configuration and business policies</span>
|
||||
</label>
|
||||
<p class="field-hint">
|
||||
Master switch for the RMM-style policy pages. Off by default.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-primary" :disabled="savingExtra" @click="saveExtra">
|
||||
{{ savingExtra ? 'Saving...' : 'Save' }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="card form-card">
|
||||
<div v-if="message" class="settings-success">{{ message }}</div>
|
||||
<div v-if="error" class="error-message">{{ error }}</div>
|
||||
@@ -61,13 +105,57 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { settingsApi } from '@/api'
|
||||
import api from '@/api'
|
||||
|
||||
const RANGES_KEY = 'computers_routableranges'
|
||||
|
||||
const ranges = ref('')
|
||||
|
||||
// The rest of the plugin's settings. They were declared and seeded but rendered
|
||||
// nowhere, so a site could only change them with SQL - see
|
||||
// tests/test_plugin_settings_reachable.py, written after that shipped twice.
|
||||
const EXTRA_KEYS = [
|
||||
'collector_corporate_ranges',
|
||||
'computers_quietreporthours',
|
||||
'computers_machinelink_alerts',
|
||||
'computers_configpolicies_enabled',
|
||||
]
|
||||
const extra = ref({
|
||||
collector_corporate_ranges: '',
|
||||
computers_quietreporthours: 24,
|
||||
computers_machinelink_alerts: 'false',
|
||||
computers_configpolicies_enabled: 'false',
|
||||
})
|
||||
const savingExtra = ref(false)
|
||||
|
||||
// Settings store strings; bridge the checkboxes rather than letting a boolean
|
||||
// round-trip into the string 'True'.
|
||||
function boolSetting(key) {
|
||||
return computed({
|
||||
get: () => String(extra.value[key]).toLowerCase() === 'true',
|
||||
set: (on) => { extra.value[key] = on ? 'true' : 'false' },
|
||||
})
|
||||
}
|
||||
const machinelinkAlerts = boolSetting('computers_machinelink_alerts')
|
||||
const configPoliciesEnabled = boolSetting('computers_configpolicies_enabled')
|
||||
|
||||
async function saveExtra() {
|
||||
savingExtra.value = true
|
||||
error.value = ''
|
||||
message.value = ''
|
||||
try {
|
||||
for (const key of EXTRA_KEYS) {
|
||||
await settingsApi.update(key, String(extra.value[key]))
|
||||
}
|
||||
message.value = 'Saved.'
|
||||
} catch (saveError) {
|
||||
error.value = saveError?.response?.data?.data?.error?.message || 'Save failed.'
|
||||
} finally {
|
||||
savingExtra.value = false
|
||||
}
|
||||
}
|
||||
const saving = ref(false)
|
||||
const downloading = ref(false)
|
||||
const digest = ref('')
|
||||
@@ -79,6 +167,9 @@ onMounted(async () => {
|
||||
const response = await settingsApi.list({ category: 'computers' })
|
||||
const row = (response.data.data || []).find(entry => entry.key === RANGES_KEY)
|
||||
if (row) ranges.value = row.value || ''
|
||||
for (const entry of response.data.data || []) {
|
||||
if (EXTRA_KEYS.includes(entry.key)) extra.value[entry.key] = entry.value
|
||||
}
|
||||
} catch (loadError) {
|
||||
error.value = 'Could not load settings'
|
||||
console.error(loadError)
|
||||
|
||||
Reference in New Issue
Block a user