view JSON log message

This commit is contained in:
SPRINX0\prochazka
2024-11-06 15:25:43 +01:00
parent bd169c316a
commit 193940fd63
8 changed files with 26 additions and 78 deletions

View File

@@ -9,11 +9,11 @@
import { apiCall } from './utility/api';
import FormStyledButton from './buttons/FormStyledButton.svelte';
import getElectron from './utility/getElectron';
import { openWebLink } from './utility/exportFileTools';
import SpecialPageLayout from './widgets/SpecialPageLayout.svelte';
import hasPermission from './utility/hasPermission';
import ErrorInfo from './elements/ErrorInfo.svelte';
import { isOneOfPage } from './utility/pageDefs';
import { openWebLink } from './utility/simpleTools';
const config = useConfig();
const values = writable({ amoid: null, databaseServer: null });

View File

@@ -202,11 +202,6 @@
on:click={async e => {
const state = `dbg-dblogin:${strmid}:${selectedConnection?.conid}:${$values.amoid}`;
sessionStorage.setItem('dbloginAuthState', state);
// openWebLink(
// `connections/dblogin?conid=${selectedConnection?.conid}&state=${encodeURIComponent(state)}&redirectUri=${
// location.origin + location.pathname
// }`
// );
internalRedirectTo(
`/connections/dblogin-web?conid=${selectedConnection?.conid}&state=${encodeURIComponent(state)}&redirectUri=${extractRedirectUri()}`
);

View File

@@ -33,7 +33,6 @@ import { removeLocalStorage } from '../utility/storageCache';
import { showSnackbarSuccess } from '../utility/snackbar';
import { apiCall } from '../utility/api';
import runCommand from './runCommand';
import { openWebLink } from '../utility/exportFileTools';
import { getSettings } from '../utility/metadataLoaders';
import { isMac, switchCurrentDatabase } from '../utility/common';
import { doLogout } from '../clientAuth';
@@ -46,6 +45,7 @@ import localforage from 'localforage';
import { openImportExportTab } from '../utility/importExportTools';
import newTable from '../tableeditor/newTable';
import { isProApp } from '../utility/proTools';
import { openWebLink } from '../utility/simpleTools';
// function themeCommand(theme: ThemeDefinition) {
// return {

View File

@@ -1,7 +1,7 @@
<script lang="ts">
import { openWebLink } from '../utility/exportFileTools';
import contextMenu from '../utility/contextMenu';
import { internalRedirectTo } from '../clientAuth';
import { openWebLink } from '../utility/simpleTools';
export let href = undefined;
export let onClick = undefined;

View File

@@ -1,19 +1,5 @@
<script lang="ts" context="module">
function formatDuration(duration) {
if (duration == 0) return '0';
if (duration < 1000) {
return `${Math.round(duration)} ms`;
}
if (duration < 10000) {
return `${Math.round(duration / 100) / 10} s`;
}
return `${Math.round(duration / 1000)} s`;
}
</script>
<script lang="ts">
import { createEventDispatcher } from 'svelte';
import moment from 'moment';
import MessageViewRow from './MessageViewRow.svelte';
export let items: any[];
export let showProcedure = false;
@@ -22,8 +8,6 @@
$: time0 = items[0] && new Date(items[0].time).getTime();
const dispatch = createEventDispatcher();
// $: console.log('MESSAGE ROWS', items);
</script>
@@ -43,28 +27,16 @@
{/if}
</tr>
{#each items as row, index}
<tr
class:isError={row.severity == 'error'}
class:isDebug={row.severity == 'debug'}
class:isActive={row.line}
on:click={() => dispatch('messageclick', row)}
>
<td>{index + 1}</td>
<td>{row.message}</td>
<td>{moment(row.time).format('HH:mm:ss')}</td>
<td>{formatDuration(new Date(row.time).getTime() - time0)}</td>
<td>
{index > 0
? formatDuration(new Date(row.time).getTime() - new Date(items[index - 1].time).getTime())
: 'n/a'}</td
>
{#if showProcedure}
<td>{row.procedure || ''}</td>
{/if}
{#if showLine}
<td>{row.line == null ? '' : row.line + 1 + startLine}</td>
{/if}
</tr>
<MessageViewRow
{row}
{index}
{showProcedure}
{showLine}
{time0}
{startLine}
previousRow={index > 0 ? items[index - 1] : null}
on:messageclick
/>
{/each}
</table>
</div>
@@ -86,23 +58,4 @@
border-spacing: 0;
border-collapse: collapse;
}
td.header {
text-align: left;
border-bottom: 2px solid var(--theme-border);
background-color: var(--theme-bg-1);
padding: 5px;
}
td:not(.header) {
border-top: 1px solid var(--theme-border);
padding: 5px;
}
tr.isActive:hover {
background: var(--theme-bg-2);
}
tr.isError {
color: var(--theme-icon-red);
}
tr.isDebug {
color: var(--theme-font-3);
}
</style>

View File

@@ -9,10 +9,10 @@ import { showModal } from '../modals/modalTools';
import DatabaseLoginModal, { isDatabaseLoginVisible } from '../modals/DatabaseLoginModal.svelte';
import _ from 'lodash';
import uuidv1 from 'uuid/v1';
import { openWebLink } from './exportFileTools';
import { callServerPing } from './connectionsPinger';
import { batchDispatchCacheTriggers, dispatchCacheChange } from './cache';
import { isAdminPage, isOneOfPage } from './pageDefs';
import { openWebLink } from './simpleTools';
export const strmid = uuidv1();

View File

@@ -211,16 +211,6 @@ export async function saveFileToDisk(
}
}
export function openWebLink(href) {
const electron = getElectron();
if (electron) {
electron.send('open-link', href);
} else {
window.open(href, '_blank');
}
}
export async function downloadFromApi(route: string, donloadName: string) {
fetch(`${resolveApi()}/${route}`, {
method: 'GET',
@@ -240,4 +230,3 @@ export async function downloadFromApi(route: string, donloadName: string) {
});
});
}

View File

@@ -0,0 +1,11 @@
import getElectron from './getElectron';
export function openWebLink(href) {
const electron = getElectron();
if (electron) {
electron.send('open-link', href);
} else {
window.open(href, '_blank');
}
}