mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-09-22 00:00:50 +00:00
fix(ssh): display SSH login logs in server timezone (#13869)
The SSH log page formatted dates with the browser timezone, so logs looked shifted when the client timezone differed from the server. Format the timestamp with the offset returned by the API so the page matches auth.log, the terminal and the CSV export. Refs #13860.
This commit is contained in:
@@ -74,6 +74,15 @@ export function dateFormat(row: any, col: any, dataStr: any) {
|
||||
return `${String(y)}-${String(m)}-${String(d)} ${String(h)}:${String(minute)}:${String(second)}`;
|
||||
}
|
||||
|
||||
export function dateFormatServerTimezone(row: any, col: any, dataStr: any) {
|
||||
const text = String(dataStr || '');
|
||||
const matched = /^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})/.exec(text);
|
||||
if (!matched) {
|
||||
return text;
|
||||
}
|
||||
return `${matched[1]} ${matched[2]}`;
|
||||
}
|
||||
|
||||
export function dateFormatSimple(dataStr: any) {
|
||||
const date = new Date(dataStr);
|
||||
const y = date.getFullYear();
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
<el-table-column
|
||||
prop="date"
|
||||
:label="$t('commons.table.date')"
|
||||
:formatter="dateFormat"
|
||||
:formatter="dateFormatServerTimezone"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
</ComplexTable>
|
||||
@@ -94,7 +94,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import ConfirmDialog from '@/components/confirm-dialog/index.vue';
|
||||
import { dateFormat } from '@/utils/date';
|
||||
import { dateFormatServerTimezone } from '@/utils/date';
|
||||
import { downloadFile } from '@/utils/file';
|
||||
import { onMounted, reactive, ref } from 'vue';
|
||||
import { cleanSSHLogs, exportSSHLogs, loadSSHLogs } from '@/api/modules/host';
|
||||
|
||||
Reference in New Issue
Block a user