feat(vikon): add part selection UI to Vue dashboard
This commit is contained in:
@@ -41,6 +41,7 @@ class VikonController extends Controller
|
|||||||
'is_authenticated' => $isAuth,
|
'is_authenticated' => $isAuth,
|
||||||
'current_version' => config('vikon.current_version'),
|
'current_version' => config('vikon.current_version'),
|
||||||
'modules' => config('vikon.modules'),
|
'modules' => config('vikon.modules'),
|
||||||
|
'parts' => config('vikon.parts'),
|
||||||
'vikon_api_domain' => config('vikon.api_domain'),
|
'vikon_api_domain' => config('vikon.api_domain'),
|
||||||
'vikon_client_id' => config('vikon.client_id'),
|
'vikon_client_id' => config('vikon.client_id'),
|
||||||
]);
|
]);
|
||||||
@@ -74,6 +75,7 @@ class VikonController extends Controller
|
|||||||
'is_authenticated' => $isAuth,
|
'is_authenticated' => $isAuth,
|
||||||
'current_version' => config('vikon.current_version'),
|
'current_version' => config('vikon.current_version'),
|
||||||
'modules' => config('vikon.modules'),
|
'modules' => config('vikon.modules'),
|
||||||
|
'parts' => config('vikon.parts'),
|
||||||
'vikon_api_domain' => config('vikon.api_domain'),
|
'vikon_api_domain' => config('vikon.api_domain'),
|
||||||
'vikon_client_id' => config('vikon.client_id'),
|
'vikon_client_id' => config('vikon.client_id'),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -67,7 +67,8 @@
|
|||||||
<h3 class="text-sm font-medium">Модули для обновления</h3>
|
<h3 class="text-sm font-medium">Модули для обновления</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="divide-y divide-line-2">
|
<div class="divide-y divide-line-2">
|
||||||
<div v-for="(mod, id) in modules" :key="id" class="px-6 py-4 flex items-center justify-between">
|
<div v-for="(mod, id) in modules" :key="id" class="px-6 py-4">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
<div class="flex items-center gap-3">
|
<div class="flex items-center gap-3">
|
||||||
<DashboardIcon name="cube" size="6" class="text-primary" />
|
<DashboardIcon name="cube" size="6" class="text-primary" />
|
||||||
<div>
|
<div>
|
||||||
@@ -80,6 +81,21 @@
|
|||||||
{{ updating ? 'Обновление...' : 'Обновить' }}
|
{{ updating ? 'Обновление...' : 'Обновить' }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="parts && parts[id]" class="mt-3 flex items-center gap-2">
|
||||||
|
<select v-model="selectedPart[id]" class="text-sm bg-layer border border-layer-line rounded-md px-2 py-1.5">
|
||||||
|
<option value="">Выберите часть...</option>
|
||||||
|
<option v-for="p in parts[id]" :key="p" :value="p">{{ p }}</option>
|
||||||
|
</select>
|
||||||
|
<button
|
||||||
|
@click="updatePart(id, selectedPart[id])"
|
||||||
|
:disabled="!selectedPart[id] || updatingPart"
|
||||||
|
class="text-sm bg-surface border border-layer-line px-3 py-1.5 rounded-md hover:bg-muted-hover disabled:opacity-50"
|
||||||
|
>
|
||||||
|
<span v-if="updatingPart === `${id}-${selectedPart[id]}`">Обновление...</span>
|
||||||
|
<span v-else>Обновить часть</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -95,6 +111,13 @@
|
|||||||
<p class="text-xs text-muted-foreground-1 mt-2">{{ progress }}%</p>
|
<p class="text-xs text-muted-foreground-1 mt-2">{{ progress }}%</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Результат обновления части -->
|
||||||
|
<div v-if="partResult" class="bg-layer border border-layer-line rounded-lg p-4">
|
||||||
|
<p class="text-sm" :class="partResult.success ? 'text-green-600' : 'text-red-600'">
|
||||||
|
{{ partResult.message }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Ошибка -->
|
<!-- Ошибка -->
|
||||||
<div v-if="updateError" class="bg-layer border border-red-200 rounded-lg p-6">
|
<div v-if="updateError" class="bg-layer border border-red-200 rounded-lg p-6">
|
||||||
<div class="flex items-start gap-3">
|
<div class="flex items-start gap-3">
|
||||||
@@ -126,6 +149,7 @@ const props = defineProps({
|
|||||||
is_authenticated: Boolean,
|
is_authenticated: Boolean,
|
||||||
current_version: String,
|
current_version: String,
|
||||||
modules: Object,
|
modules: Object,
|
||||||
|
parts: Object,
|
||||||
vikon_api_domain: String,
|
vikon_api_domain: String,
|
||||||
vikon_client_id: String,
|
vikon_client_id: String,
|
||||||
});
|
});
|
||||||
@@ -139,6 +163,9 @@ const progress = ref(0);
|
|||||||
const updateError = ref(null);
|
const updateError = ref(null);
|
||||||
const versionInfo = ref({ current_version: props.current_version, has_update: false, latest_version: null });
|
const versionInfo = ref({ current_version: props.current_version, has_update: false, latest_version: null });
|
||||||
const accessInfo = ref({ has_access: false, error: null });
|
const accessInfo = ref({ has_access: false, error: null });
|
||||||
|
const selectedPart = ref({});
|
||||||
|
const updatingPart = ref(null);
|
||||||
|
const partResult = ref(null);
|
||||||
|
|
||||||
const authUrl = computed(() => {
|
const authUrl = computed(() => {
|
||||||
const redirect = encodeURIComponent(`${window.location.origin}/vikon_core/update/index.php`);
|
const redirect = encodeURIComponent(`${window.location.origin}/vikon_core/update/index.php`);
|
||||||
@@ -234,6 +261,32 @@ async function updateModule(moduleId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function updatePart(moduleId, part) {
|
||||||
|
if (!part) return;
|
||||||
|
|
||||||
|
updatingPart.value = `${moduleId}-${part}`;
|
||||||
|
partResult.value = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await fetch('/dashboard/vikon-updates/update-part', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')?.content,
|
||||||
|
'Accept': 'application/json',
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ module_id: moduleId, part }),
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = await res.json();
|
||||||
|
partResult.value = data;
|
||||||
|
} catch (e) {
|
||||||
|
partResult.value = { success: false, message: e.message };
|
||||||
|
} finally {
|
||||||
|
updatingPart.value = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function logout() {
|
async function logout() {
|
||||||
try {
|
try {
|
||||||
await axios.post(route('dashboard.vikon-updates.logout'));
|
await axios.post(route('dashboard.vikon-updates.logout'));
|
||||||
|
|||||||
Reference in New Issue
Block a user