1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-19 08:19:15 +08:00

feat: 增加nginx log日志

This commit is contained in:
zhengkunwang223 2022-11-23 16:59:06 +08:00 committed by zhengkunwang223
parent c30f39185e
commit 70c2185cf4
8 changed files with 61 additions and 33 deletions

View File

@ -49,6 +49,7 @@ type CheckInstalled struct {
CreatedAt time.Time `json:"createdAt"` CreatedAt time.Time `json:"createdAt"`
LastBackupAt string `json:"lastBackupAt"` LastBackupAt string `json:"lastBackupAt"`
AppInstallID uint `json:"appInstallId"` AppInstallID uint `json:"appInstallId"`
ContainerName string `json:"containerName"`
} }
type AppInstalled struct { type AppInstalled struct {

View File

@ -51,6 +51,7 @@ func (a AppInstallService) CheckExist(key string) (*dto.CheckInstalled, error) {
if reflect.DeepEqual(appInstall, model.AppInstall{}) { if reflect.DeepEqual(appInstall, model.AppInstall{}) {
return res, nil return res, nil
} }
res.ContainerName = appInstall.ContainerName
res.Name = appInstall.Name res.Name = appInstall.Name
res.Version = appInstall.Version res.Version = appInstall.Version
res.CreatedAt = appInstall.CreatedAt res.CreatedAt = appInstall.CreatedAt

View File

@ -91,6 +91,7 @@ export namespace App {
createdAt: string; createdAt: string;
lastBackupAt: string; lastBackupAt: string;
appInstallId: number; appInstallId: number;
containerName: string;
} }
export interface AppInstalledOp { export interface AppInstalledOp {

View File

@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<el-card class="app-card" v-loading="loading">
<div class="app-content" v-if="data.isExist"> <div class="app-content" v-if="data.isExist">
<el-card class="app-card" v-loading="loading">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="1"> <el-col :span="1">
<div> <div>
@ -32,22 +32,15 @@
<el-button type="primary" link @click="setting">{{ $t('commons.button.set') }}</el-button> <el-button type="primary" link @click="setting">{{ $t('commons.button.set') }}</el-button>
</el-col> </el-col>
</el-row> </el-row>
</el-card>
</div> </div>
<div v-else> <div v-else>
<el-row> <el-alert :closable="false" :title="$t('app.checkInstalledWarn', [data.app])" type="info">
<el-col :span="2">
{{ $t('app.checkInstalledWarn', [data.app]) }}
<el-tag effect="dark" type="success">{{ data.app }}</el-tag>
</el-col>
<el-col :span="3">
<el-link icon="Position" @click="goRouter('/apps')" type="primary"> <el-link icon="Position" @click="goRouter('/apps')" type="primary">
{{ $t('database.goInstall') }} {{ $t('database.goInstall') }}
</el-link> </el-link>
</el-col> </el-alert>
</el-row>
<span></span>
</div> </div>
</el-card>
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -72,6 +65,7 @@ let data = ref({
lastBackupAt: '', lastBackupAt: '',
appInstallId: 0, appInstallId: 0,
isExist: false, isExist: false,
containerName: '',
}); });
let loading = ref(false); let loading = ref(false);
let operateReq = reactive({ let operateReq = reactive({
@ -79,7 +73,7 @@ let operateReq = reactive({
operate: '', operate: '',
}); });
const em = defineEmits(['setting']); const em = defineEmits(['setting', 'isExist']);
const setting = () => { const setting = () => {
em('setting', false); em('setting', false);
}; };
@ -92,6 +86,7 @@ const onCheck = async () => {
loading.value = true; loading.value = true;
const res = await CheckAppInstalled(key.value); const res = await CheckAppInstalled(key.value);
data.value = res.data; data.value = res.data;
em('isExist', res.data);
operateReq.installId = res.data.appInstallId; operateReq.installId = res.data.appInstallId;
loading.value = false; loading.value = false;
}; };

View File

@ -687,7 +687,7 @@ export default {
update: '升级', update: '升级',
versioneSelect: '请选择版本', versioneSelect: '请选择版本',
operatorHelper: '将对选中应用进行 {0} 操作是否继续', operatorHelper: '将对选中应用进行 {0} 操作是否继续',
checkInstalledWarn: '未检测到', checkInstalledWarn: '未检测到 {0} ,请进入应用商店点击安装!',
gotoInstalled: '去安装', gotoInstalled: '去安装',
}, },
website: { website: {
@ -758,5 +758,6 @@ export default {
source: '源文', source: '源文',
security: '安全', security: '安全',
backup: '备份', backup: '备份',
log: '日志',
}, },
}; };

View File

@ -1,6 +1,6 @@
<template> <template>
<LayoutContent> <AppStatus :app-key="'nginx'" @setting="setting" @is-exist="checkExist"></AppStatus>
<AppStatus :app-key="'nginx'" @setting="setting"></AppStatus> <LayoutContent v-if="nginxIsExist">
<br /> <br />
<el-card v-if="!openNginxConfig"> <el-card v-if="!openNginxConfig">
<LayoutContent :header="$t('website.website')"> <LayoutContent :header="$t('website.website')">
@ -33,7 +33,7 @@
</LayoutContent> </LayoutContent>
</el-card> </el-card>
<el-card v-if="openNginxConfig"> <el-card v-if="openNginxConfig">
<NginxConfig></NginxConfig> <NginxConfig :containerName="containerName"></NginxConfig>
</el-card> </el-card>
<CreateWebSite ref="createRef" @close="search"></CreateWebSite> <CreateWebSite ref="createRef" @close="search"></CreateWebSite>
@ -56,11 +56,14 @@ import NginxConfig from './nginx/index.vue';
import i18n from '@/lang'; import i18n from '@/lang';
import router from '@/routers'; import router from '@/routers';
import { App } from '@/api/interface/app';
const createRef = ref(); const createRef = ref();
const deleteRef = ref(); const deleteRef = ref();
const groupRef = ref(); const groupRef = ref();
let openNginxConfig = ref(false); let openNginxConfig = ref(false);
let nginxIsExist = ref(false);
let containerName = ref('');
const paginationConfig = reactive({ const paginationConfig = reactive({
currentPage: 1, currentPage: 1,
@ -116,6 +119,11 @@ const openGroup = () => {
groupRef.value.acceptParams(); groupRef.value.acceptParams();
}; };
const checkExist = (data: App.CheckInstalled) => {
nginxIsExist.value = data.isExist;
containerName.value = data.containerName;
};
onMounted(() => { onMounted(() => {
search(); search();
}); });

View File

@ -4,6 +4,9 @@
<el-collapse-item :title="$t('website.source')" name="1"> <el-collapse-item :title="$t('website.source')" name="1">
<Source></Source> <Source></Source>
</el-collapse-item> </el-collapse-item>
<el-collapse-item :title="$t('website.log')" name="2">
<ContainerLog ref="dialogContainerLogRef" />
</el-collapse-item>
</el-collapse> </el-collapse>
</LayoutContent> </LayoutContent>
</template> </template>
@ -11,7 +14,26 @@
<script lang="ts" setup> <script lang="ts" setup>
import LayoutContent from '@/layout/layout-content.vue'; import LayoutContent from '@/layout/layout-content.vue';
import Source from './source/index.vue'; import Source from './source/index.vue';
import { ref } from 'vue'; import { ref, watch } from 'vue';
import ContainerLog from '@/components/container-log/index.vue';
let activeName = ref('1'); let activeName = ref('1');
let dialogContainerLogRef = ref();
const props = defineProps({
containerName: {
type: String,
default: '',
},
});
watch(
activeName,
(newvalue) => {
if (newvalue === '2') {
dialogContainerLogRef.value!.acceptParams({ containerID: props.containerName });
}
},
{ immediate: true },
);
</script> </script>

View File

@ -55,7 +55,6 @@ const getNginx = async () => {
const res = await GetNginx(); const res = await GetNginx();
data.value = res.data; data.value = res.data;
content.value = data.value.content; content.value = data.value.content;
console.log(content.value);
}; };
onMounted(() => { onMounted(() => {