8 Commits
Author SHA1 Message Date
austnv 3dbacb4359 feat: minify component NodesStatus
Build and Deploy Frontend via SSH / deploy (push) Successful in 44s
2026-06-21 22:50:30 +03:00
austnv d8e20754c7 dix: release author 2026-06-21 22:44:14 +03:00
austnv 4e6e0d4d48 fix deploy
Build and Deploy Frontend via SSH / deploy (push) Successful in 47s
2026-06-21 22:39:42 +03:00
austnv a22662f11b v0.9.2
Build and Deploy Frontend via SSH / deploy (push) Failing after 4s
2026-06-21 21:56:47 +03:00
austnv 75531a9ec3 update workflow: add auto release 2026-06-21 21:56:19 +03:00
austnv e6ab2667c9 fix: micropatch NodesStatus 2026-06-21 21:50:00 +03:00
austnv 3a38b3f7fa v0.9.1
Build and Deploy Frontend via SSH / deploy (push) Successful in 42s
2026-06-21 21:43:21 +03:00
austnv b69cc4bc4b update NodesStatus.vue 2026-06-21 21:38:23 +03:00
3 changed files with 124 additions and 47 deletions
+43
View File
@@ -24,6 +24,49 @@ jobs:
- name: Build project - name: Build project
run: npm run build run: npm run build
- name: Create Gitea Release via API
run: |
# Получаем описание из тега (если есть)
TAG_MESSAGE=$(git tag -l --format='%(contents)' "${{ gitea.ref_name }}" 2>/dev/null || echo "Автоматический релиз через CI/CD")
# Экранируем кавычки и переносы для JSON
TAG_MESSAGE_ESCAPED=$(echo "$TAG_MESSAGE" | sed 's/"/\\"/g' | awk '{printf "%s\\n", $0}')
# Формируем JSON
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")
# Проверяем ответ
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
BODY=$(echo "$RESPONSE" | sed '$d')
if [ "$HTTP_CODE" -eq 201 ]; then
echo "✅ Релиз успешно создан!"
echo "$BODY" | jq '.'
elif [ "$HTTP_CODE" -eq 409 ]; then
echo "⚠️ Релиз с таким тегом уже существует, пропускаем"
else
echo "❌ Ошибка создания релиза (HTTP $HTTP_CODE)"
echo "$BODY"
exit 1
fi
- name: Install SSH key - name: Install SSH key
uses: webfactory/ssh-agent@v0.9.0 uses: webfactory/ssh-agent@v0.9.0
with: with:
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "frontend", "name": "frontend",
"version": "0.9.0", "version": "0.9.4",
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {
+80 -46
View File
@@ -1,20 +1,30 @@
<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">
<h2 class="text-3xl md:text-4xl font-bold text-center mb-14"> <div class="flex items-center justify-between mb-10 flex-wrap gap-4">
Статус серверов <h2 class="text-3xl md:text-4xl font-bold">
</h2> Статус серверов
</h2>
<button
@click="refreshData"
:disabled="loading"
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"
>
<RefreshCw :size="16" :class="{ 'animate-spin': loading }" />
{{ loading ? 'Обновление...' : 'Обновить пинг' }}
</button>
</div>
<div v-if="loading" 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>
</div> </div>
<p v-else-if="error" class="text-center text-red-500 py-12">{{ error }}</p> <p v-else-if="error" class="text-center text-red-500 py-12">{{ error }}</p>
<div v-else class="space-y-3 max-w-3xl mx-auto"> <div v-else class="space-y-2 max-w-3xl mx-auto">
<div <div
v-for="host in hosts" 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-3 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 transition hover:shadow-md"
: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">
@@ -23,7 +33,7 @@
: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}.svg`"
class="h-5 w-auto rounded-sm" class="h-5 w-auto rounded-sm"
/> />
<span class="font-semibold text-gray-800 dark:text-white">{{ host.cleanName }}</span> <span class="font-semibold text-gray-800 dark:text-white">{{ host.name }}</span>
<span <span
class="text-[10px] px-2 py-0.5 rounded-full font-medium" class="text-[10px] px-2 py-0.5 rounded-full font-medium"
:class="host.isOnline ? 'bg-green-100 text-green-700' : 'bg-red-100 text-red-700'" :class="host.isOnline ? 'bg-green-100 text-green-700' : 'bg-red-100 text-red-700'"
@@ -32,21 +42,20 @@
</span> </span>
</div> </div>
<div class="flex items-center gap-4 text-sm text-gray-500 dark:text-gray-400"> <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" class="font-mono font-semibold flex items-center gap-1.5"
:class="{ :class="{
'text-green-600': host.ping < 50, 'text-green-600': host.ping < 200,
'text-yellow-600': host.ping >= 50 && host.ping < 150, 'text-yellow-600': host.ping >= 200 && host.ping < 500,
'text-orange-600': host.ping >= 150 && host.ping < 300, 'text-red-600': host.ping >= 500,
'text-red-600': host.ping >= 300,
}" }"
> >
<Wifi :size="14" /> <Wifi :size="14" />
{{ host.ping }}ms {{ host.ping }}ms
</span> </span>
<span v-else class="text-gray-300"></span> <span v-else class="text-gray-300 font-mono"></span>
</div> </div>
</div> </div>
</div> </div>
@@ -54,41 +63,42 @@
</template> </template>
<script setup> <script setup>
import { ref, onMounted, onUnmounted } from 'vue' import { ref, computed, onMounted } from 'vue'
import { Wifi } from '@lucide/vue' import { Wifi, RefreshCw } from '@lucide/vue'
import { getAllCountries } from '@tw-labs/countries' 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 countriesList = getAllCountries()
// Поиск страны по названию (из IpSecurity.vue) const findCountryByFirstWord = (name) => {
const findCountryByName = (countryName) => { if (!name) return null
if (!countryName) return null const firstWord = name.split(' ')[0]
const found = countriesList.find(c => c.label.toLowerCase() === countryName.toLowerCase()) if (!firstWord) return null
if (found) return found
const exact = countriesList.find(c =>
c.label.toLowerCase() === firstWord.toLowerCase()
)
if (exact) return exact
const partial = countriesList.find(c => const partial = countriesList.find(c =>
countryName.toLowerCase().includes(c.label.toLowerCase()) || firstWord.toLowerCase().includes(c.label.toLowerCase()) ||
c.label.toLowerCase().includes(countryName.toLowerCase()) c.label.toLowerCase().includes(firstWord.toLowerCase())
) )
return partial || null return partial || null
} }
// Очистка имени от эмодзи и лишних символов const sortedHosts = computed(() => {
const cleanName = (name) => { return [...hosts.value].sort((a, b) => {
return name.replace(/^[🇷🇺🇫🇮🇸🇪🇺🇸🇵🇱🇱🇻🇳🇱🇩🇪]\s*/, '').replace(/[🚀⭐🔥]/g, '').trim() if (a.ping === null && b.ping === null) return 0
} if (a.ping === null) return 1
if (b.ping === null) return -1
return a.ping - b.ping
})
})
// Извлечение названия страны из name (удаляем эмодзи)
const extractCountryName = (name) => {
const cleaned = cleanName(name)
return cleaned.replace(/\s*\d+$/, '').trim() // убираем цифры в конце (например "Finland 2" -> "Finland")
}
// Пинг через 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()
@@ -111,22 +121,16 @@ const fetchHosts = async () => {
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 countryName = extractCountryName(h.name) const country = findCountryByFirstWord(h.name)
const country = findCountryByName(countryName)
return { return {
...h, ...h,
cleanName: cleanName(h.name),
countryCode: country?.code?.toLowerCase() || null, countryCode: country?.code?.toLowerCase() || null,
isOnline: true, isOnline: true,
ping: null, ping: null,
} }
}) })
const pings = await Promise.all(hosts.value.map((h) => pingHost(h)))
hosts.value.forEach((h, i) => (h.ping = pings[i]))
} catch { } catch {
error.value = 'Ошибка загрузки' error.value = 'Ошибка загрузки'
} finally { } finally {
@@ -134,9 +138,39 @@ const fetchHosts = async () => {
} }
} }
const refreshData = async () => {
loading.value = true
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) => {
const country = findCountryByFirstWord(h.name)
return {
...h,
countryCode: country?.code?.toLowerCase() || null,
isOnline: true,
ping: null,
}
})
// Пингуем все хосты параллельно
const pings = await Promise.all(hosts.value.map(h => pingHost(h)))
hosts.value.forEach((h, i) => {
if (h.isOnline) h.ping = pings[i]
})
} catch {
error.value = 'Ошибка обновления'
} finally {
loading.value = false
}
}
onMounted(() => { onMounted(() => {
fetchHosts() fetchHosts()
interval = setInterval(fetchHosts, 30000)
}) })
onUnmounted(() => clearInterval(interval))
</script> </script>