Compare commits
11
Commits
v0.9.2
...
6a9b2ca31d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a9b2ca31d | ||
|
|
17a8db543e | ||
|
|
68aabbb361 | ||
|
|
6e841b12f5 | ||
|
|
7f227fcf05 | ||
|
|
a34a646c71 | ||
|
|
4a0ce08338 | ||
|
|
43749647ca | ||
|
|
3dbacb4359 | ||
|
|
d8e20754c7 | ||
|
|
4e6e0d4d48 |
+37
-24
@@ -24,35 +24,48 @@ jobs:
|
|||||||
- name: Build project
|
- name: Build project
|
||||||
run: npm run build
|
run: npm run build
|
||||||
|
|
||||||
- name: Create Gitea Release
|
- name: Create Gitea Release via API
|
||||||
uses: actions/gitea-release-action@v1
|
run: |
|
||||||
with:
|
# Получаем описание из тега (если есть)
|
||||||
release_name: ${{ gitea.ref_name }}
|
TAG_MESSAGE=$(git tag -l --format='%(contents)' "${{ gitea.ref_name }}" 2>/dev/null || echo "Автоматический релиз через CI/CD")
|
||||||
release_notes: |
|
|
||||||
## Релиз ${{ gitea.ref_name }}
|
|
||||||
|
|
||||||
${{ (github.event.head_commit.message != '' && format('📝 {0}', github.event.head_commit.message)) || '' }}
|
# Экранируем кавычки и переносы для JSON
|
||||||
|
TAG_MESSAGE_ESCAPED=$(echo "$TAG_MESSAGE" | sed 's/"/\\"/g' | awk '{printf "%s\\n", $0}')
|
||||||
|
|
||||||
### 📦 Что изменилось
|
# Формируем JSON
|
||||||
${{ github.event.head_commit.message || 'Автоматический релиз через CI/CD' }}
|
JSON_PAYLOAD=$(cat <<EOF
|
||||||
|
{
|
||||||
|
"tag_name": "${{ gitea.ref_name }}",
|
||||||
|
"name": "Release ${{ gitea.ref_name }}",
|
||||||
|
"body": "## Релиз ${{ gitea.ref_name }}\n\n📝 ${TAG_MESSAGE_ESCAPED}\n\n---\n\n**🏷️ Тег:** \`${{ gitea.ref_name }}\`\n**👤 Автор:** @${{ gitea.actor }}\n\n✅ Автоматически собрано и развёрнуто",
|
||||||
|
"draft": false,
|
||||||
|
"prerelease": false
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
---
|
# Отправляем запрос
|
||||||
|
RESPONSE=$(curl -s -w "\n%{http_code}" \
|
||||||
|
-X POST \
|
||||||
|
-H "Authorization: token ${{ secrets.ACCESS_TOKEN }}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "$JSON_PAYLOAD" \
|
||||||
|
"https://git.uvpn.shop/api/v1/repos/${{ gitea.repository }}/releases")
|
||||||
|
|
||||||
### 🔧 Технические детали
|
# Проверяем ответ
|
||||||
- **Тег:** `${{ gitea.ref_name }}`
|
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
|
||||||
- **Ветка:** `${{ gitea.ref }}`
|
BODY=$(echo "$RESPONSE" | sed '$d')
|
||||||
- **Автор:** ${{ gitea.actor }}
|
|
||||||
|
|
||||||
### 🚀 Деплой
|
if [ "$HTTP_CODE" -eq 201 ]; then
|
||||||
- ✅ Сервер обновлён автоматически
|
echo "✅ Релиз успешно создан!"
|
||||||
|
echo "$BODY" | jq '.'
|
||||||
---
|
elif [ "$HTTP_CODE" -eq 409 ]; then
|
||||||
|
echo "⚠️ Релиз с таким тегом уже существует, пропускаем"
|
||||||
> Релиз создан автоматически через Gitea Actions
|
else
|
||||||
draft: false
|
echo "❌ Ошибка создания релиза (HTTP $HTTP_CODE)"
|
||||||
prerelease: false
|
echo "$BODY"
|
||||||
env:
|
exit 1
|
||||||
GITEA_API_KEY: ${{ secrets.ACCESS_TOKEN }}
|
fi
|
||||||
|
|
||||||
- name: Install SSH key
|
- name: Install SSH key
|
||||||
uses: webfactory/ssh-agent@v0.9.0
|
uses: webfactory/ssh-agent@v0.9.0
|
||||||
|
|||||||
+3
-2
@@ -1,12 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "frontend",
|
"name": "frontend",
|
||||||
"version": "0.9.2",
|
"version": "0.9.7",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"preview": "vite preview"
|
"preview": "vite preview",
|
||||||
|
"postbuild": "scp -r dist/. root@uvpn.shop:/opt/uvpn.shop/frontend"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@lucide/vue": "^1.16.0",
|
"@lucide/vue": "^1.16.0",
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
<template>
|
<template>
|
||||||
<section class="px-6 py-20 md:px-12 max-w-7xl mx-auto">
|
<section class="px-6 py-20 md:px-12 max-w-7xl mx-auto">
|
||||||
|
<div class="mb-10">
|
||||||
<h2 class="text-3xl md:text-4xl font-bold text-center mb-14">
|
<h2 class="text-3xl md:text-4xl font-bold text-center mb-14">
|
||||||
Статус серверов
|
Статус серверов
|
||||||
</h2>
|
</h2>
|
||||||
|
<div class="flex justify-center mt-6">
|
||||||
<div class="flex justify-end mb-4">
|
|
||||||
<button
|
<button
|
||||||
@click="refreshData"
|
@click="refreshData"
|
||||||
:disabled="loading"
|
:disabled="loading"
|
||||||
class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg text-sm font-medium transition disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2"
|
class="px-5 py-2.5 bg-blue-600 hover:bg-blue-700 text-white rounded-xl text-sm font-medium transition disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2 cursor-pointer"
|
||||||
>
|
>
|
||||||
<RefreshCw :size="16" :class="{ 'animate-spin': loading }" />
|
<RefreshCw :size="16" :class="{ 'animate-spin': loading }" />
|
||||||
{{ loading ? 'Обновление...' : 'Обновить все' }}
|
{{ loading ? 'Обновление...' : 'Обновить пинг' }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div v-if="loading && !hosts.length" class="flex justify-center py-12">
|
<div v-if="loading && !hosts.length" class="flex justify-center py-12">
|
||||||
<div class="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600"></div>
|
<div class="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600"></div>
|
||||||
@@ -25,28 +26,35 @@
|
|||||||
<div
|
<div
|
||||||
v-for="host in sortedHosts"
|
v-for="host in sortedHosts"
|
||||||
:key="host.address"
|
:key="host.address"
|
||||||
class="flex items-center justify-between bg-white dark:bg-gray-900 rounded-xl px-4 py-2.5 border transition hover:shadow-md"
|
class="flex items-center justify-between bg-white dark:bg-gray-900 rounded-xl px-4 py-2.5 border"
|
||||||
:class="host.isOnline ? 'border-green-500/30' : 'border-red-500/30 opacity-60'"
|
:class="host.isOnline ? 'border-green-500/30' : 'border-red-500/30 opacity-60'"
|
||||||
>
|
>
|
||||||
<div class="flex items-center gap-3">
|
<div class="flex items-center gap-3">
|
||||||
<img
|
<img
|
||||||
v-if="host.countryCode"
|
v-if="host.countryCode"
|
||||||
:src="`https://cdn.jsdelivr.net/npm/flag-icons@7.2.3/flags/4x3/${host.countryCode}.svg`"
|
:src="`https://cdn.jsdelivr.net/npm/flag-icons@7.2.3/flags/4x3/${host.countryCode.toLowerCase()}.svg`"
|
||||||
class="h-5 w-auto rounded-sm"
|
class="h-5 w-auto rounded-sm"
|
||||||
|
:alt="host.name"
|
||||||
/>
|
/>
|
||||||
<span class="font-semibold text-gray-800 dark:text-white">{{ host.name }}</span>
|
<span class="font-semibold text-gray-800 dark:text-white">{{ host.name }}</span>
|
||||||
|
|
||||||
|
<!-- Индикатор состояния -->
|
||||||
|
<span class="relative flex h-2 w-2">
|
||||||
<span
|
<span
|
||||||
class="text-[10px] px-2 py-0.5 rounded-full font-medium"
|
class="animate-ping absolute inline-flex h-full w-full rounded-full opacity-75"
|
||||||
:class="host.isOnline ? 'bg-green-100 text-green-700' : 'bg-red-100 text-red-700'"
|
:class="host.isOnline ? 'bg-green-500' : 'bg-red-500'"
|
||||||
>
|
></span>
|
||||||
{{ host.isOnline ? 'online' : 'offline' }}
|
<span
|
||||||
|
class="relative inline-flex rounded-full h-2 w-2"
|
||||||
|
:class="host.isOnline ? 'bg-green-600' : 'bg-red-600'"
|
||||||
|
></span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex items-center gap-4">
|
<div class="flex items-center gap-3">
|
||||||
<span
|
<span
|
||||||
v-if="host.ping !== undefined && host.ping !== null"
|
v-if="host.ping !== undefined && host.ping !== null"
|
||||||
class="font-mono font-semibold flex items-center gap-1 min-w-[60px] justify-end"
|
class="font-mono font-semibold flex items-center gap-1.5"
|
||||||
:class="{
|
:class="{
|
||||||
'text-green-600': host.ping < 200,
|
'text-green-600': host.ping < 200,
|
||||||
'text-yellow-600': host.ping >= 200 && host.ping < 500,
|
'text-yellow-600': host.ping >= 200 && host.ping < 500,
|
||||||
@@ -56,20 +64,7 @@
|
|||||||
<Wifi :size="14" />
|
<Wifi :size="14" />
|
||||||
{{ host.ping }} ms
|
{{ host.ping }} ms
|
||||||
</span>
|
</span>
|
||||||
<span v-else class="text-gray-300 min-w-[60px] text-right">—</span>
|
<span v-else class="text-gray-300 font-mono">—</span>
|
||||||
|
|
||||||
<button
|
|
||||||
@click="pingSingleHost(host)"
|
|
||||||
:disabled="host.pinging"
|
|
||||||
class="text-xs px-3 py-1 rounded-lg transition font-medium"
|
|
||||||
:class="[
|
|
||||||
host.isOnline && !host.pinging
|
|
||||||
? 'bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-600'
|
|
||||||
: 'bg-gray-100 dark:bg-gray-800 text-gray-400 cursor-not-allowed'
|
|
||||||
]"
|
|
||||||
>
|
|
||||||
{{ host.pinging ? '⏳' : 'Пинг' }}
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -77,40 +72,13 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, onMounted, onUnmounted } from 'vue'
|
import { ref, computed, onMounted } from 'vue'
|
||||||
import { Wifi, RefreshCw } from '@lucide/vue'
|
import { Wifi, RefreshCw } from '@lucide/vue'
|
||||||
import { getAllCountries } from '@tw-labs/countries'
|
|
||||||
|
|
||||||
const hosts = ref([])
|
const hosts = ref([])
|
||||||
const loading = ref(true)
|
const loading = ref(true)
|
||||||
const error = ref(null)
|
const error = ref(null)
|
||||||
let interval = null
|
|
||||||
|
|
||||||
const countriesList = getAllCountries()
|
|
||||||
|
|
||||||
// Поиск страны по первому слову в названии
|
|
||||||
const findCountryByFirstWord = (name) => {
|
|
||||||
if (!name) return null
|
|
||||||
|
|
||||||
// Берём первое слово из названия
|
|
||||||
const firstWord = name.split(' ')[0]
|
|
||||||
if (!firstWord) return null
|
|
||||||
|
|
||||||
// Ищем точное совпадение
|
|
||||||
const exact = countriesList.find(c =>
|
|
||||||
c.label.toLowerCase() === firstWord.toLowerCase()
|
|
||||||
)
|
|
||||||
if (exact) return exact
|
|
||||||
|
|
||||||
// Ищем частичное совпадение
|
|
||||||
const partial = countriesList.find(c =>
|
|
||||||
firstWord.toLowerCase().includes(c.label.toLowerCase()) ||
|
|
||||||
c.label.toLowerCase().includes(firstWord.toLowerCase())
|
|
||||||
)
|
|
||||||
return partial || null
|
|
||||||
}
|
|
||||||
|
|
||||||
// Сортировка по пингу
|
|
||||||
const sortedHosts = computed(() => {
|
const sortedHosts = computed(() => {
|
||||||
return [...hosts.value].sort((a, b) => {
|
return [...hosts.value].sort((a, b) => {
|
||||||
if (a.ping === null && b.ping === null) return 0
|
if (a.ping === null && b.ping === null) return 0
|
||||||
@@ -120,18 +88,6 @@ const sortedHosts = computed(() => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// Пинг одного хоста
|
|
||||||
const pingSingleHost = async (host) => {
|
|
||||||
if (host.pinging || !host.isOnline) return
|
|
||||||
host.pinging = true
|
|
||||||
host.ping = null
|
|
||||||
|
|
||||||
const result = await pingHost(host)
|
|
||||||
host.ping = result
|
|
||||||
host.pinging = false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Пинг через fetch
|
|
||||||
const pingHost = async (host) => {
|
const pingHost = async (host) => {
|
||||||
const url = `https://${host.address}:${host.port}`
|
const url = `https://${host.address}:${host.port}`
|
||||||
const start = performance.now()
|
const start = performance.now()
|
||||||
@@ -149,39 +105,20 @@ const pingHost = async (host) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Пинг всех хостов
|
|
||||||
const pingAllHosts = async () => {
|
|
||||||
const pings = await Promise.all(
|
|
||||||
hosts.value.map(async (h) => {
|
|
||||||
if (!h.isOnline) return null
|
|
||||||
return await pingHost(h)
|
|
||||||
})
|
|
||||||
)
|
|
||||||
hosts.value.forEach((h, i) => {
|
|
||||||
if (h.isOnline) h.ping = pings[i]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const fetchHosts = async () => {
|
const fetchHosts = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await fetch('/api/v1/hosts')
|
const res = await fetch('/api/v1/hosts')
|
||||||
if (!res.ok) throw new Error()
|
if (!res.ok) throw new Error()
|
||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
|
|
||||||
hosts.value = data.map((h) => {
|
hosts.value = data.map((h) => ({
|
||||||
const country = findCountryByFirstWord(h.name)
|
|
||||||
return {
|
|
||||||
...h,
|
...h,
|
||||||
countryCode: country?.code?.toLowerCase() || null,
|
countryCode: h.country_code ? h.country_code.toLowerCase() : null,
|
||||||
isOnline: true,
|
isOnline: true,
|
||||||
ping: null,
|
ping: null,
|
||||||
pinging: false,
|
}))
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
await pingAllHosts()
|
|
||||||
} catch {
|
} catch {
|
||||||
error.value = 'Ошибка загрузки'
|
error.value = 'Ошибка загрузки данных'
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
@@ -189,13 +126,35 @@ const fetchHosts = async () => {
|
|||||||
|
|
||||||
const refreshData = async () => {
|
const refreshData = async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
await fetchHosts()
|
error.value = null
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await fetch('/api/v1/hosts')
|
||||||
|
if (!res.ok) throw new Error()
|
||||||
|
const data = await res.json()
|
||||||
|
|
||||||
|
hosts.value = data.map((h) => ({
|
||||||
|
...h,
|
||||||
|
countryCode: h.country_code ? h.country_code.toLowerCase() : null,
|
||||||
|
isOnline: true,
|
||||||
|
ping: null,
|
||||||
|
}))
|
||||||
|
|
||||||
|
// Пингуем все хосты параллельно
|
||||||
|
const pings = await Promise.all(hosts.value.map(h => pingHost(h)))
|
||||||
|
hosts.value.forEach((h, i) => {
|
||||||
|
h.ping = pings[i]
|
||||||
|
})
|
||||||
|
|
||||||
|
} catch {
|
||||||
|
error.value = 'Ошибка обновления данных'
|
||||||
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(async () => {
|
||||||
fetchHosts()
|
await fetchHosts()
|
||||||
interval = setInterval(refreshData, 30000)
|
await refreshData()
|
||||||
})
|
})
|
||||||
onUnmounted(() => clearInterval(interval))
|
|
||||||
</script>
|
</script>
|
||||||
Reference in New Issue
Block a user