6 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
3 changed files with 96 additions and 70 deletions
+43
View File
@@ -24,6 +24,49 @@ jobs:
- name: Build project
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
uses: webfactory/ssh-agent@v0.9.0
with:
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "frontend",
"version": "0.9.1",
"version": "0.9.4",
"private": true,
"type": "module",
"scripts": {
+52 -69
View File
@@ -1,17 +1,16 @@
<template>
<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">
Статус серверов
</h2>
<div class="flex justify-end mb-4">
<div class="flex items-center justify-between mb-10 flex-wrap gap-4">
<h2 class="text-3xl md:text-4xl font-bold">
Статус серверов
</h2>
<button
@click="refreshData"
: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"
>
<RefreshCw :size="16" :class="{ 'animate-spin': loading }" />
{{ loading ? 'Обновление...' : 'Обновить все' }}
{{ loading ? 'Обновление...' : 'Обновить пинг' }}
</button>
</div>
@@ -43,11 +42,10 @@
</span>
</div>
<div class="flex items-center gap-4">
<!-- Пинг -->
<div class="flex items-center gap-3">
<span
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="{
'text-green-600': host.ping < 200,
'text-yellow-600': host.ping >= 200 && host.ping < 500,
@@ -57,21 +55,7 @@
<Wifi :size="14" />
{{ host.ping }}ms
</span>
<span v-else class="text-gray-300 min-w-[60px] text-right"></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>
<span v-else class="text-gray-300 font-mono"></span>
</div>
</div>
</div>
@@ -79,32 +63,35 @@
</template>
<script setup>
import { ref, computed, onMounted, onUnmounted } from 'vue'
import { ref, computed, onMounted } from 'vue'
import { Wifi, RefreshCw } from '@lucide/vue'
import { getAllCountries } from '@tw-labs/countries'
const hosts = ref([])
const loading = ref(true)
const error = ref(null)
let interval = null
const countriesList = getAllCountries()
const findCountryByName = (countryName) => {
if (!countryName) return null
const found = countriesList.find(c => c.label.toLowerCase() === countryName.toLowerCase())
if (found) return found
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 =>
countryName.toLowerCase().includes(c.label.toLowerCase()) ||
c.label.toLowerCase().includes(countryName.toLowerCase())
firstWord.toLowerCase().includes(c.label.toLowerCase()) ||
c.label.toLowerCase().includes(firstWord.toLowerCase())
)
return partial || null
}
// Сортировка по пингу (меньше -> выше)
const sortedHosts = computed(() => {
return [...hosts.value].sort((a, b) => {
// Если пинг null -> в конец
if (a.ping === null && b.ping === null) return 0
if (a.ping === null) return 1
if (b.ping === null) return -1
@@ -112,18 +99,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 url = `https://${host.address}:${host.port}`
const start = performance.now()
@@ -141,19 +116,6 @@ 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 () => {
try {
const res = await fetch('/api/v1/hosts')
@@ -161,17 +123,14 @@ const fetchHosts = async () => {
const data = await res.json()
hosts.value = data.map((h) => {
const country = findCountryByName(h.name)
const country = findCountryByFirstWord(h.name)
return {
...h,
countryCode: country?.code?.toLowerCase() || null,
isOnline: true,
ping: null,
pinging: false,
}
})
await pingAllHosts()
} catch {
error.value = 'Ошибка загрузки'
} finally {
@@ -181,13 +140,37 @@ const fetchHosts = async () => {
const refreshData = async () => {
loading.value = true
await fetchHosts()
loading.value = false
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(() => {
fetchHosts()
interval = setInterval(refreshData, 30000)
})
onUnmounted(() => clearInterval(interval))
</script>s
</script>