소스 수정
This commit is contained in:
@@ -4,7 +4,7 @@ import { refreshServerTimer } from '../../../utils/server-scheduler'
|
|||||||
export default defineEventHandler(async (event) => {
|
export default defineEventHandler(async (event) => {
|
||||||
const targetId = getRouterParam(event, 'id')
|
const targetId = getRouterParam(event, 'id')
|
||||||
const body = await readBody(event)
|
const body = await readBody(event)
|
||||||
const { name, host, port, username, auth_type, is_active } = body
|
const { server_name, server_ip, glances_url, is_active, collect_interval, physical_location } = body
|
||||||
|
|
||||||
if (!targetId) {
|
if (!targetId) {
|
||||||
throw createError({
|
throw createError({
|
||||||
@@ -15,15 +15,15 @@ export default defineEventHandler(async (event) => {
|
|||||||
|
|
||||||
const changes = await execute(`
|
const changes = await execute(`
|
||||||
UPDATE server_targets
|
UPDATE server_targets
|
||||||
SET name = $1,
|
SET server_name = $1,
|
||||||
host = $2,
|
server_ip = $2,
|
||||||
port = $3,
|
glances_url = $3,
|
||||||
username = $4,
|
is_active = $4,
|
||||||
auth_type = $5,
|
collect_interval = $5,
|
||||||
is_active = $6,
|
physical_location = $6,
|
||||||
updated_at = NOW()
|
updated_at = NOW()
|
||||||
WHERE target_id = $7
|
WHERE target_id = $7
|
||||||
`, [name, host, port || 22, username, auth_type || 'password', is_active ? 1 : 0, targetId])
|
`, [server_name, server_ip, glances_url, is_active ? 1 : 0, collect_interval || 60, physical_location || '운영서버실', targetId])
|
||||||
|
|
||||||
// 스케줄러에 반영
|
// 스케줄러에 반영
|
||||||
refreshServerTimer(Number(targetId))
|
refreshServerTimer(Number(targetId))
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { refreshServerTimer } from '../../../utils/server-scheduler'
|
|||||||
|
|
||||||
export default defineEventHandler(async (event) => {
|
export default defineEventHandler(async (event) => {
|
||||||
const body = await readBody(event)
|
const body = await readBody(event)
|
||||||
const { server_name, server_ip, glances_url, is_active = 1, collect_interval = 60 } = body
|
const { server_name, server_ip, glances_url, is_active = 1, collect_interval = 60, physical_location = '운영서버실' } = body
|
||||||
|
|
||||||
if (!server_name || !server_ip || !glances_url) {
|
if (!server_name || !server_ip || !glances_url) {
|
||||||
throw createError({
|
throw createError({
|
||||||
@@ -13,10 +13,10 @@ export default defineEventHandler(async (event) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const result = await queryOne<{ target_id: number }>(`
|
const result = await queryOne<{ target_id: number }>(`
|
||||||
INSERT INTO server_targets (server_name, server_ip, glances_url, is_active, collect_interval)
|
INSERT INTO server_targets (server_name, server_ip, glances_url, is_active, collect_interval, physical_location)
|
||||||
VALUES ($1, $2, $3, $4, $5)
|
VALUES ($1, $2, $3, $4, $5, $6)
|
||||||
RETURNING target_id
|
RETURNING target_id
|
||||||
`, [server_name, server_ip, glances_url, is_active ? 1 : 0, collect_interval])
|
`, [server_name, server_ip, glances_url, is_active ? 1 : 0, collect_interval, physical_location])
|
||||||
|
|
||||||
const targetId = result?.target_id
|
const targetId = result?.target_id
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,9 @@
|
|||||||
style="width: 80px;"
|
style="width: 80px;"
|
||||||
min="10"
|
min="10"
|
||||||
/>
|
/>
|
||||||
|
<select v-model="newTarget.physical_location" class="input-field" style="width: 110px;">
|
||||||
|
<option v-for="loc in locationOptions" :key="loc" :value="loc">{{ loc }}</option>
|
||||||
|
</select>
|
||||||
<label class="checkbox-label">
|
<label class="checkbox-label">
|
||||||
<input type="checkbox" v-model="newTarget.is_active" />
|
<input type="checkbox" v-model="newTarget.is_active" />
|
||||||
활성
|
활성
|
||||||
@@ -93,7 +96,8 @@
|
|||||||
<th style="width: 100px;">서버명</th>
|
<th style="width: 100px;">서버명</th>
|
||||||
<th style="width: 120px;">IP</th>
|
<th style="width: 120px;">IP</th>
|
||||||
<th>Glances URL</th>
|
<th>Glances URL</th>
|
||||||
<th style="width: 70px;">주기(초)</th>
|
<th style="width: 70px;">주기</th>
|
||||||
|
<th style="width: 100px;">위치</th>
|
||||||
<th style="width: 50px;">상태</th>
|
<th style="width: 50px;">상태</th>
|
||||||
<th style="width: 120px;">관리</th>
|
<th style="width: 120px;">관리</th>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -117,6 +121,12 @@
|
|||||||
<input v-if="editingId === target.target_id" v-model.number="editTarget.collect_interval" type="number" class="edit-input" min="10" />
|
<input v-if="editingId === target.target_id" v-model.number="editTarget.collect_interval" type="number" class="edit-input" min="10" />
|
||||||
<span v-else>{{ target.collect_interval }}</span>
|
<span v-else>{{ target.collect_interval }}</span>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<select v-if="editingId === target.target_id" v-model="editTarget.physical_location" class="edit-input">
|
||||||
|
<option v-for="loc in locationOptions" :key="loc" :value="loc">{{ loc }}</option>
|
||||||
|
</select>
|
||||||
|
<span v-else>{{ target.physical_location || '운영서버실' }}</span>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<label v-if="editingId === target.target_id" class="checkbox-label">
|
<label v-if="editingId === target.target_id" class="checkbox-label">
|
||||||
<input type="checkbox" v-model="editTarget.is_active" />
|
<input type="checkbox" v-model="editTarget.is_active" />
|
||||||
@@ -151,6 +161,7 @@ interface ServerTarget {
|
|||||||
glances_url: string
|
glances_url: string
|
||||||
is_active: number
|
is_active: number
|
||||||
collect_interval: number
|
collect_interval: number
|
||||||
|
physical_location: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SchedulerStatus {
|
interface SchedulerStatus {
|
||||||
@@ -159,6 +170,11 @@ interface SchedulerStatus {
|
|||||||
total_targets: number
|
total_targets: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const locationOptions = [
|
||||||
|
'운영서버실', '개발서버실', '터보사무실', '백업실',
|
||||||
|
'기타1', '기타2', '기타3', '기타4'
|
||||||
|
]
|
||||||
|
|
||||||
const targets = ref<ServerTarget[]>([])
|
const targets = ref<ServerTarget[]>([])
|
||||||
const currentTime = ref('')
|
const currentTime = ref('')
|
||||||
const editingId = ref<number | null>(null)
|
const editingId = ref<number | null>(null)
|
||||||
@@ -173,7 +189,8 @@ const newTarget = ref({
|
|||||||
server_ip: '',
|
server_ip: '',
|
||||||
glances_url: '',
|
glances_url: '',
|
||||||
is_active: true,
|
is_active: true,
|
||||||
collect_interval: 60
|
collect_interval: 60,
|
||||||
|
physical_location: '운영서버실'
|
||||||
})
|
})
|
||||||
|
|
||||||
const editTarget = ref({
|
const editTarget = ref({
|
||||||
@@ -181,7 +198,8 @@ const editTarget = ref({
|
|||||||
server_ip: '',
|
server_ip: '',
|
||||||
glances_url: '',
|
glances_url: '',
|
||||||
is_active: true,
|
is_active: true,
|
||||||
collect_interval: 60
|
collect_interval: 60,
|
||||||
|
physical_location: '운영서버실'
|
||||||
})
|
})
|
||||||
|
|
||||||
const canAdd = computed(() =>
|
const canAdd = computed(() =>
|
||||||
@@ -243,7 +261,7 @@ async function addTarget() {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: newTarget.value
|
body: newTarget.value
|
||||||
})
|
})
|
||||||
newTarget.value = { server_name: '', server_ip: '', glances_url: '', is_active: true, collect_interval: 60 }
|
newTarget.value = { server_name: '', server_ip: '', glances_url: '', is_active: true, collect_interval: 60, physical_location: '운영서버실' }
|
||||||
await fetchTargets()
|
await fetchTargets()
|
||||||
await fetchSchedulerStatus()
|
await fetchSchedulerStatus()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -258,7 +276,8 @@ function startEdit(target: ServerTarget) {
|
|||||||
server_ip: target.server_ip,
|
server_ip: target.server_ip,
|
||||||
glances_url: target.glances_url,
|
glances_url: target.glances_url,
|
||||||
is_active: !!target.is_active,
|
is_active: !!target.is_active,
|
||||||
collect_interval: target.collect_interval || 60
|
collect_interval: target.collect_interval || 60,
|
||||||
|
physical_location: target.physical_location || '운영서버실'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user