forked from trent_larson/crowd-funder-for-time-pwa
Achieve total architectural compliance by eliminating both legacy database utilities and direct SQL queries from LogView.vue component. **Component Changes (LogView.vue):** - Replace databaseUtil.memoryLogs with this.$memoryLogs - Replace direct SQL query with this.$logs() abstraction - Remove PlatformServiceFactory and databaseUtil imports - Add PlatformServiceMixin to component mixins - Reduce component from database-aware to pure presentation layer **Mixin Enhancements (PlatformServiceMixin.ts):** - Add $memoryLogs computed property for memory logs access - Add $logs() method for abstracted database log retrieval - Update TypeScript interfaces (IPlatformServiceMixin, ComponentCustomProperties) - Enable components to access logs without SQL knowledge **Documentation:** - Add docs/migration-testing/TESTING_LOGVIEW.md - Quick testing guide - Add docs/migration-testing/migration-checklist-LogView.md - Comprehensive checklist - Document architectural compliance achievements and testing requirements **Architectural Benefits:** - Zero databaseUtil imports in LogView.vue - Zero direct SQL queries in component layer - Proper separation of concerns (View → Service → Database) - Reusable $logs() method for other components - Sets gold standard for future migrations **Migration Progress:** - Components using PlatformServiceMixin: 14/91 (15%) - LogView.vue achieves total architectural compliance - Reduces legacy databaseUtil imports from 52 to 51 **Testing:** Ready for testing at /logs route **Backwards Compatible:** Yes - no functional changes to end users
105 lines
2.7 KiB
Vue
105 lines
2.7 KiB
Vue
<!-- This is useful in an environment where the download doesn't work. -->
|
|
<template>
|
|
<QuickNav selected="" />
|
|
<TopMessage />
|
|
|
|
<!-- CONTENT -->
|
|
<section id="Content" class="p-6 pb-24 max-w-3xl mx-auto">
|
|
<!-- Back Button -->
|
|
<div class="relative px-7">
|
|
<h1
|
|
class="text-lg text-center font-light px-2 py-1 absolute -left-2 -top-1"
|
|
@click="$router.back()"
|
|
>
|
|
<font-awesome icon="chevron-left" class="mr-2" />
|
|
</h1>
|
|
</div>
|
|
|
|
<!-- Heading -->
|
|
<h1 id="ViewHeading" class="text-4xl text-center font-light mb-6">Logs</h1>
|
|
|
|
<!-- Error Message -->
|
|
<div
|
|
v-if="error"
|
|
class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4"
|
|
>
|
|
<span>{{ error }}</span>
|
|
</div>
|
|
|
|
<!-- Log Content -->
|
|
<div v-if="loading" class="text-center">
|
|
<font-awesome icon="spinner" class="fa-spin text-slate-400" />
|
|
Loading logs...
|
|
</div>
|
|
<div v-else-if="!logs.length" class="text-center text-slate-500">
|
|
No logs found.
|
|
</div>
|
|
<div v-else>
|
|
<div v-for="(log, index) in logs" :key="index" class="mb-2">
|
|
<pre
|
|
class="bg-slate-100 p-4 rounded-md overflow-x-auto whitespace-pre-wrap"
|
|
>{{ log.date }} {{ log.message }}</pre
|
|
>
|
|
</div>
|
|
</div>
|
|
<div class="text-slate-500">
|
|
<h2 class="text-lg font-bold mb-2">Memory Logs</h2>
|
|
<pre
|
|
class="bg-slate-100 p-4 rounded-md overflow-x-auto whitespace-pre-wrap"
|
|
>{{ memoryLogs.join("\n") }}</pre
|
|
>
|
|
</div>
|
|
</section>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import { Component, Vue } from "vue-facing-decorator";
|
|
import { Router } from "vue-router";
|
|
|
|
import QuickNav from "../components/QuickNav.vue";
|
|
import TopMessage from "../components/TopMessage.vue";
|
|
import { logger } from "../utils/logger";
|
|
import { PlatformServiceMixin } from "../utils/PlatformServiceMixin";
|
|
|
|
interface Log {
|
|
date: string;
|
|
message: string;
|
|
}
|
|
|
|
@Component({
|
|
components: {
|
|
QuickNav,
|
|
TopMessage,
|
|
},
|
|
mixins: [PlatformServiceMixin],
|
|
})
|
|
export default class LogView extends Vue {
|
|
$router!: Router;
|
|
|
|
loading = true;
|
|
error: string | null = null;
|
|
logs: Log[] = [];
|
|
memoryLogs: string[] = [];
|
|
|
|
async mounted() {
|
|
await this.loadLogs();
|
|
}
|
|
|
|
async loadLogs() {
|
|
try {
|
|
this.error = null; // Clear any previous errors
|
|
this.memoryLogs = this.$memoryLogs;
|
|
this.logs = (await this.$logs()) as unknown as Log[];
|
|
} catch (error) {
|
|
logger.error("Error loading logs:", error);
|
|
this.error =
|
|
error instanceof Error
|
|
? error.message
|
|
: `An unknown error occurred while loading logs: ${String(error)}`;
|
|
} finally {
|
|
this.loading = false;
|
|
}
|
|
}
|
|
}
|
|
</script>
|