Files
server-manager/views/admin/app_version.php
Agent 53e9b92a8d feat: admin app version mgmt + notification system
- New tables: app_config, notifications
- Admin views: App Version editor, Notification sender
- API: GET /api/notifications, POST /api/notifications/:id/read, POST /api/notifications/read-all
- App version now stored in DB, editable by super admin
- Notifications: send to all users or specific user
- Android notification models + API client
- Sidebar: App Version + Notifications links for super_admin
2026-06-09 17:06:22 -04:00

87 lines
3.6 KiB
PHP

<?php $config = $config ?? []; ?>
<div class="page-header">
<div class="page-header-left">
<h1 class="page-title">App Version</h1>
<p class="page-subtitle">Manage the Android application version and update settings</p>
</div>
</div>
<div class="card">
<div class="card-body">
<form id="versionForm">
<input type="hidden" name="_csrf_token" value="<?= $this->csrfToken() ?>">
<div class="form-group">
<label for="app_version">Version Number</label>
<input type="text" id="app_version" name="app_version" class="form-input"
value="<?= htmlspecialchars($config['app_version'] ?? '1.0.0') ?>"
placeholder="e.g. 1.0.1" required>
<small class="form-hint">Semantic version (X.Y.Z). Must be higher than previous to trigger updates.</small>
</div>
<div class="form-group">
<label for="apk_url">APK URL</label>
<input type="text" id="apk_url" name="apk_url" class="form-input"
value="<?= htmlspecialchars($config['apk_url'] ?? '/sysadmin.apk') ?>"
placeholder="e.g. /sysadmin.apk" required>
<small class="form-hint">Path or URL to the APK file.</small>
</div>
<div class="form-group">
<label for="force_update">Force Update</label>
<select id="force_update" name="force_update" class="form-select">
<option value="0" <?= ($config['force_update'] ?? '0') === '0' ? 'selected' : '' ?>>Optional — user can skip</option>
<option value="1" <?= ($config['force_update'] ?? '0') === '1' ? 'selected' : '' ?>>Forced — user must update</option>
</select>
<small class="form-hint">If forced, users cannot dismiss the update dialog.</small>
</div>
<div class="form-group">
<label for="release_notes">Release Notes</label>
<textarea id="release_notes" name="release_notes" class="form-input" rows="6"
placeholder="• What changed&#10;• Bug fixes&#10;• New features"><?= htmlspecialchars($config['release_notes'] ?? '') ?></textarea>
<small class="form-hint">One change per line. These will be shown in the update dialog on Android.</small>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">
<i class="fas fa-save"></i> Save Version
</button>
</div>
</form>
</div>
</div>
<script>
document.getElementById('versionForm').addEventListener('submit', function(e) {
e.preventDefault();
const btn = this.querySelector('button[type="submit"]');
btn.disabled = true;
btn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Saving...';
fetch('/admin/app-version', {
method: 'POST',
headers: {
'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]')?.content || '',
},
body: new URLSearchParams(new FormData(this)),
})
.then(r => r.json())
.then(data => {
if (data.success) {
showToast('success', data.message);
} else {
showToast('error', data.message);
}
btn.disabled = false;
btn.innerHTML = '<i class="fas fa-save"></i> Save Version';
})
.catch(() => {
showToast('error', 'Failed to save version');
btn.disabled = false;
btn.innerHTML = '<i class="fas fa-save"></i> Save Version';
});
});
</script>