feat : ajout de la lecture des logs symfony et docker (#3)
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
Reviewed-on: #3 Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
This commit was merged in pull request #3.
This commit is contained in:
@@ -6,6 +6,8 @@ import type { DeployResult } from '~/services/dto/deploy'
|
||||
import { getAvailableTags, deploy } from '~/services/deploy'
|
||||
import type { EnvironmentHealth } from '~/services/dto/dashboard'
|
||||
import { getEnvironmentHealth } from '~/services/dashboard'
|
||||
import type { LogOutput } from '~/services/dto/logs'
|
||||
import { getDockerLogs, getSymfonyLog } from '~/services/logs'
|
||||
|
||||
const { t } = useI18n()
|
||||
const route = useRoute()
|
||||
@@ -29,6 +31,15 @@ const deployResult = ref<DeployResult | null>(null)
|
||||
const healthByEnvId = ref<Record<number, EnvironmentHealth>>({})
|
||||
const loadingHealth = ref(false)
|
||||
|
||||
// Log modals
|
||||
const showLogModal = ref(false)
|
||||
const logContent = ref('')
|
||||
const logLoading = ref(false)
|
||||
const logTitle = ref('')
|
||||
const logEnvId = ref<number | null>(null)
|
||||
const logFileId = ref<number | null>(null)
|
||||
const logIsSymfony = ref(false)
|
||||
|
||||
// App edit modal
|
||||
const showAppModal = ref(false)
|
||||
const editForm = ref<ApplicationWrite>({ name: '', slug: '', registryImage: '', description: '', giteaUrl: '' })
|
||||
@@ -226,6 +237,41 @@ function statusClass(status: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
// Log functions
|
||||
async function openDockerLogs(env: Environment) {
|
||||
logEnvId.value = env.id!
|
||||
logFileId.value = null
|
||||
logIsSymfony.value = false
|
||||
logTitle.value = `${t('logs.docker')} — ${env.name}`
|
||||
logContent.value = ''
|
||||
showLogModal.value = true
|
||||
}
|
||||
|
||||
async function openSymfonyLog(env: Environment, lf: { id?: number, label: string }) {
|
||||
logEnvId.value = env.id!
|
||||
logFileId.value = lf.id!
|
||||
logIsSymfony.value = true
|
||||
logTitle.value = `${t('logs.symfony')} — ${lf.label}`
|
||||
logContent.value = ''
|
||||
showLogModal.value = true
|
||||
}
|
||||
|
||||
async function refreshLogs(lines: number, level: string) {
|
||||
if (!logEnvId.value) return
|
||||
logLoading.value = true
|
||||
try {
|
||||
let result: LogOutput
|
||||
if (logIsSymfony.value && logFileId.value) {
|
||||
result = await getSymfonyLog(logEnvId.value, logFileId.value, lines, level || undefined)
|
||||
} else {
|
||||
result = await getDockerLogs(logEnvId.value, lines)
|
||||
}
|
||||
logContent.value = result.content
|
||||
} finally {
|
||||
logLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const envModalTitle = computed(() =>
|
||||
editingEnvId.value ? t('environments.editButton') : t('environments.addButton')
|
||||
)
|
||||
@@ -334,6 +380,13 @@ onMounted(loadApplication)
|
||||
</a>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<MalioButton
|
||||
:label="t('logs.docker')"
|
||||
variant="secondary"
|
||||
icon-name="mdi:text-box-outline"
|
||||
icon-position="left"
|
||||
@click="openDockerLogs(env)"
|
||||
/>
|
||||
<MalioButton
|
||||
:label="t('environments.deploy.button')"
|
||||
icon-name="mdi:rocket-launch-outline"
|
||||
@@ -358,9 +411,16 @@ onMounted(loadApplication)
|
||||
<!-- Log files -->
|
||||
<div v-if="env.logFiles.length" class="mt-4 border-t border-neutral-200 pt-3">
|
||||
<p class="text-sm font-bold uppercase tracking-wider mb-2">{{ t('environments.logFiles.title') }}</p>
|
||||
<div v-for="lf in env.logFiles" :key="lf.id" class="text-sm text-neutral-700 flex gap-2">
|
||||
<span class="font-medium">{{ lf.label }} :</span>
|
||||
<div v-for="lf in env.logFiles" :key="lf.id" class="text-sm text-neutral-700 flex gap-2 items-center">
|
||||
<span class="font-medium">{{ lf.label }}</span>
|
||||
<span class="font-mono text-neutral-400">{{ lf.path }}</span>
|
||||
<MalioButtonIcon
|
||||
icon="mdi:console"
|
||||
:aria-label="lf.label"
|
||||
variant="ghost"
|
||||
icon-size="16"
|
||||
@click="openSymfonyLog(env, lf)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -613,5 +673,15 @@ onMounted(loadApplication)
|
||||
/>
|
||||
</template>
|
||||
</AppModal>
|
||||
|
||||
<!-- Log modal -->
|
||||
<LogModal
|
||||
v-model="showLogModal"
|
||||
:title="logTitle"
|
||||
:content="logContent"
|
||||
:loading="logLoading"
|
||||
:show-level-filter="logIsSymfony"
|
||||
@refresh="refreshLogs"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user