mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
update ToolLog with suboperations
This commit is contained in:
parent
d444ef5f6b
commit
b263961d50
5 changed files with 46 additions and 39 deletions
|
@ -37,10 +37,12 @@
|
||||||
<breadcrumb />
|
<breadcrumb />
|
||||||
|
|
||||||
<main id="main">
|
<main id="main">
|
||||||
|
<!-- The `key` on router-view make sure that if a link points to a page that
|
||||||
|
use the same component as the previous one, it will be refreshed -->
|
||||||
<transition v-if="transitions" :name="transitionName">
|
<transition v-if="transitions" :name="transitionName">
|
||||||
<router-view class="animated" />
|
<router-view class="animated" :key="$route.fullPath" />
|
||||||
</transition>
|
</transition>
|
||||||
<router-view v-else class="static" />
|
<router-view v-else class="static" :key="$route.fullPath" />
|
||||||
</main>
|
</main>
|
||||||
</api-wait-overlay>
|
</api-wait-overlay>
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ body {
|
||||||
|
|
||||||
// <b-row /> elems with <b-col> inside and eventually .sep inside
|
// <b-row /> elems with <b-col> inside and eventually .sep inside
|
||||||
.row-line {
|
.row-line {
|
||||||
&:hover > div :first-child {
|
&:hover > div > :first-child {
|
||||||
background-color: rgba(0, 0, 0, 0.05);
|
background-color: rgba(0, 0, 0, 0.05);
|
||||||
border-radius: 0.2rem;
|
border-radius: 0.2rem;
|
||||||
padding: 0 .5rem;
|
padding: 0 .5rem;
|
||||||
|
|
|
@ -111,6 +111,7 @@ export default {
|
||||||
'SERVER_RESPONDED' ({ state, dispatch, commit }, responseIsOk) {
|
'SERVER_RESPONDED' ({ state, dispatch, commit }, responseIsOk) {
|
||||||
if (responseIsOk) {
|
if (responseIsOk) {
|
||||||
commit('UPDATE_WAITING', false)
|
commit('UPDATE_WAITING', false)
|
||||||
|
commit('SET_ERROR', '')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -6,40 +6,41 @@
|
||||||
<h2><icon iname="info-circle" /> {{ description }}</h2>
|
<h2><icon iname="info-circle" /> {{ description }}</h2>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<dl>
|
<b-row
|
||||||
<dt v-t="'logs_path'" />
|
v-for="(value, prop) in info" :key="prop"
|
||||||
<dd>{{ log_path }}</dd>
|
no-gutters class="row-line"
|
||||||
<hr>
|
>
|
||||||
|
<b-col cols="5" md="3" xl="3">
|
||||||
<template v-if="metadata.started_at">
|
<strong>{{ $t('logs_' + prop) }}</strong>
|
||||||
<dt v-t="'logs_started_at'" />
|
<span class="sep" />
|
||||||
<dd>{{ metadata.started_at | readableDate }}</dd>
|
</b-col>
|
||||||
<hr>
|
<b-col>
|
||||||
</template>
|
<span v-if="prop.endsWith('_at')">{{ value | readableDate }}</span>
|
||||||
|
<div v-else-if="prop === 'suboperations'">
|
||||||
<template v-if="metadata.ended_at">
|
<div v-for="operation in value" :key="operation.name">
|
||||||
<dt v-t="'logs_ended_at'" />
|
<icon v-if="!operation.success" iname="times" class="text-danger" />
|
||||||
<dd>{{ metadata.ended_at | readableDate }}</dd>
|
<b-link :to="{ name: 'tool-log', params: { name: operation.name } }">
|
||||||
<hr>
|
{{ operation.description }}
|
||||||
</template>
|
</b-link>
|
||||||
|
</div>
|
||||||
<template v-if="metadata.error">
|
</div>
|
||||||
<dt v-t="'logs_ended_at'" />
|
<span v-else>{{ value }}</span>
|
||||||
<dd>{{ metadata.error }}</dd>
|
</b-col>
|
||||||
<hr>
|
</b-row>
|
||||||
</template>
|
|
||||||
</dl>
|
|
||||||
</b-card>
|
</b-card>
|
||||||
|
|
||||||
<b-alert v-if="metadata.error" variant="danger" show>
|
<b-alert
|
||||||
<icon iname="exclamation-circle" /> {{ $t('operation_failed_explanation') }}
|
v-if="info.error" variant="danger" show
|
||||||
|
class="my-5"
|
||||||
|
>
|
||||||
|
<icon iname="exclamation-circle" /> <span v-html="$t('operation_failed_explanation')" />
|
||||||
</b-alert>
|
</b-alert>
|
||||||
|
|
||||||
<!-- LOGS CARD -->
|
<!-- LOGS CARD -->
|
||||||
<b-card class="log">
|
<b-card class="log">
|
||||||
<template v-slot:header>
|
<template v-slot:header>
|
||||||
<div class="d-sm-flex justify-content-sm-between">
|
<div class="d-sm-flex justify-content-sm-between">
|
||||||
<h2><icon iname="file-text" /> {{ metadata ? $t('logs') : log_path }}</h2>
|
<h2><icon iname="file-text" /> {{ $t('logs') }}</h2>
|
||||||
<b-button @click="shareLogs">
|
<b-button @click="shareLogs">
|
||||||
<icon iname="cloud-upload" /> {{ $t('logs_share_with_yunopaste') }}
|
<icon iname="cloud-upload" /> {{ $t('logs_share_with_yunopaste') }}
|
||||||
</b-button>
|
</b-button>
|
||||||
|
@ -76,11 +77,10 @@ export default {
|
||||||
return {
|
return {
|
||||||
// Log data
|
// Log data
|
||||||
description: '',
|
description: '',
|
||||||
log_path: '',
|
info: {},
|
||||||
logs: '',
|
logs: '',
|
||||||
metadata: {},
|
|
||||||
// Logs line display
|
// Logs line display
|
||||||
numberOfLines: 50,
|
numberOfLines: 25,
|
||||||
moreLogsAvailable: false
|
moreLogsAvailable: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -94,6 +94,7 @@ export default {
|
||||||
const queryString = objectToParams({
|
const queryString = objectToParams({
|
||||||
path: this.name,
|
path: this.name,
|
||||||
filter_irrelevant: '',
|
filter_irrelevant: '',
|
||||||
|
with_suboperations: '',
|
||||||
number: this.numberOfLines
|
number: this.numberOfLines
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -105,18 +106,24 @@ export default {
|
||||||
this.moreLogsAvailable = false
|
this.moreLogsAvailable = false
|
||||||
}
|
}
|
||||||
this.description = log.description
|
this.description = log.description
|
||||||
this.log_path = log.log_path
|
|
||||||
this.metadata = log.metadata
|
|
||||||
|
|
||||||
const levels = ['ERROR', 'WARNING', 'SUCCESS', 'INFO']
|
const levels = ['ERROR', 'WARNING', 'SUCCESS', 'INFO']
|
||||||
this.logs = log.logs.map(line => {
|
this.logs = log.logs.map(line => {
|
||||||
for (const level of levels) {
|
for (const level of levels) {
|
||||||
if (line.includes(level + ' -')) {
|
if (line.includes(level + ' -')) {
|
||||||
return `<span class="alert-${level === 'ERROR' ? 'danger' : level.toLowerCase()}">${line}</span>`
|
return `<span class="alert-${level === 'ERROR'
|
||||||
|
? 'danger'
|
||||||
|
: level.toLowerCase()}">${line}</span>`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return line
|
return line
|
||||||
}).join('\n')
|
}).join('\n')
|
||||||
|
|
||||||
|
const { started_at, ended_at, error, success, suboperations } = log.metadata
|
||||||
|
const info = { path: log.log_path, started_at, ended_at }
|
||||||
|
if (!success) info.error = error
|
||||||
|
if (suboperations) info.suboperations = suboperations
|
||||||
|
this.info = info
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
import api from '@/api'
|
import api from '@/api'
|
||||||
import { distanceToNow, readableDate } from '@/helpers/filters/date'
|
import { distanceToNow, readableDate } from '@/helpers/filters/date'
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ServiceList',
|
name: 'ServiceList',
|
||||||
|
|
||||||
|
@ -59,7 +60,6 @@ export default {
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
fetchData () {
|
fetchData () {
|
||||||
// FIXME only prints operation for now (can't receive 'history', 'app', 'service', etc.)
|
|
||||||
api.get(`logs?limit=${25}&with_details`).then(({ operation }) => {
|
api.get(`logs?limit=${25}&with_details`).then(({ operation }) => {
|
||||||
operation.forEach((log, index) => {
|
operation.forEach((log, index) => {
|
||||||
if (log.success === '?') {
|
if (log.success === '?') {
|
||||||
|
@ -83,6 +83,3 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
</style>
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue