Skip to content

Commit

Permalink
Merge pull request #224 from buggregator/issue/#222-nomolog-improve
Browse files Browse the repository at this point in the history
Issue/#222 nomolog improve
  • Loading branch information
Kreezag authored Sep 2, 2024
2 parents 52d52ba + 598b6eb commit d8c24aa
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 9 deletions.
7 changes: 6 additions & 1 deletion middleware/auth.global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ export default defineNuxtRouteMiddleware(async (to) => {
await profileStore.getStoredToken()

if (isAuthenticated.value) {
await profileStore.getProfile();
try {
await profileStore.getProfile();
} catch (e) {
console.error(e);
return navigateTo('/login')
}
}

if (to.name !== 'login' && !isAuthenticated.value) {
Expand Down
2 changes: 2 additions & 0 deletions src/entities/monolog/mocks/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import monologExtendedMock from './monolog-extended.json';
import monologMock from './monolog.json';

export {
monologMock,
monologExtendedMock,
}
30 changes: 30 additions & 0 deletions src/entities/monolog/mocks/monolog-extended.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"uuid": "019059fe-9284-71fe-9e47-a392664a8c87",
"project": null,
"type": "monolog",
"payload": {
"channel": "application",
"context": {
"cool": "heck yeah",
"here": "where?"
},
"datetime": "2024-06-27T15:59:34.201624+02:00",
"extra": {
"callType": null,
"class": null,
"file": "[REDACTED]",
"function": "[REDACTED]",
"http_method": "GET",
"instance": "[REDACTED]",
"ip": "[REDACTED]",
"line": 514,
"referrer": null,
"server": "[REDACTED]",
"url": "[REDACTED]"
},
"level": 200,
"level_name": "INFO",
"message": "Hello world"
},
"timestamp": 1719496774.2804
}
8 changes: 7 additions & 1 deletion src/entities/monolog/ui/preview-card/preview-card.stories.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Meta, StoryObj } from "@storybook/vue3";
import { useMonolog } from "../../lib";
import { monologMock } from '../../mocks'
import { monologMock, monologExtendedMock } from '../../mocks'
import PreviewCard from './preview-card.vue';

const { normalizeMonologEvent } = useMonolog();
Expand Down Expand Up @@ -28,3 +28,9 @@ export const WithOrigin: StoryObj<typeof PreviewCard> = {
}
}
}

export const ComplexObject: StoryObj<typeof PreviewCard> = {
args: {
event: normalizeMonologEvent(monologExtendedMock),
}
}
5 changes: 2 additions & 3 deletions src/entities/monolog/ui/preview-card/preview-card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ const toggleView = () => {
/>

<CodeSnippet
v-for="(field, key) in event.payload.extra"
:key="key"
class="preview-card__snippet"
:code="{ [key]: field }"
language="json"
:code="event.payload.extra"
/>
</PreviewCard>
</template>
Expand Down
6 changes: 2 additions & 4 deletions src/shared/stores/profile/profile-store.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { defineStore } from "pinia";
import {navigateTo} from "#app"; // eslint-disable-line @conarti/feature-sliced/layers-slices
import {REST_API_URL} from "../../lib/io/constants";
import type {TProfile} from "../../types";
import {getStoredToken, removeStoredToken, setStoredToken} from "./local-storage-actions";
Expand Down Expand Up @@ -32,12 +31,11 @@ export const useProfileStore = defineStore("profileStore", {
// TODO: add toast to show error
console.error('Auth Error', response.status, response.statusText)

navigateTo('/login')
return new Error('Auth Error')
}

return response
return response.json()
})
.then((response) => response.json())
.catch((e) => {
console.error(e);

Expand Down

0 comments on commit d8c24aa

Please sign in to comment.