Skip to content

Commit

Permalink
feat: add info section with build info
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwep committed Nov 13, 2023
1 parent 2dc3801 commit 25595b1
Show file tree
Hide file tree
Showing 15 changed files with 120 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/app/components/base/dialog/Dialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,6 @@ onMounted(() => {
text-align: center;
font-weight: var(--font-weight-l);
font-style: var(--font-size-m);
padding-bottom: 8px;
padding-bottom: 14px;
}
</style>
1 change: 0 additions & 1 deletion src/app/components/base/form/Form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const submit = (e: Event) => {
flex-direction: column;
width: 250px;
gap: 12px;
padding-top: 8px;
.btn {
text-align: center;
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/base/icon/Icon.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ export type AppIcon =
| 'eye-close'
| 'eye-line'
| 'file-fill'
| 'github-line'
| 'global-line'
| 'google-fill'
| 'grid-line'
| 'hand-coin'
| 'information-line'
| 'key-2-line'
| 'magic-line'
| 'menu-line'
Expand Down
1 change: 1 addition & 0 deletions src/app/components/base/link/Link.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
v-tooltip="{ text: tooltip, position: tooltipPosition }"
:href="to"
:class="classes"
rel="noopener,noreferrer,nofollow"
target="_blank"
>
<Icon v-if="icon" :class="$style.icon" :icon="icon" />
Expand Down
13 changes: 2 additions & 11 deletions src/app/pages/Frame.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,13 @@
:to="button.link"
/>

<template v-if="media !== 'mobile'">
<div :class="$style.divider" />
<Link
:tooltip="t('navigation.githubProject')"
color="dimmed"
to="https://github.com/simonwep/ocular"
icon="github-line"
/>
</template>

<ToolsButton :class="[$style.top, $style.btn]" />
<AdminButton v-if="user?.admin" :class="$style.btn" />
<SelectYearButton :class="$style.btn" />
<template v-if="media !== 'mobile'">
<ChangeLanguageButton :class="$style.btn" />
<ChangeCurrencyButton :class="$style.btn" />
<InfoButton :class="$style.btn" />
</template>
<div :class="$style.divider" />
<CloudButton :class="$style.btn" />
Expand All @@ -46,8 +37,8 @@
import { computed, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import InfoButton from '@app/pages/navigation/info/InfoButton.vue';
import { AppIcon } from '@components/base/icon/Icon.types';
import Icon from '@components/base/icon/Icon.vue';
import Link from '@components/base/link/Link.vue';
import AnimatedRouterView from '@components/misc/animated-router-view/AnimatedRouterView.vue';
import { useMediaQuery } from '@composables';
Expand Down
5 changes: 5 additions & 0 deletions src/app/pages/dashboard/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,9 @@ const rotateYear = (dir: -1 | 1) => {
display: flex;
grid-gap: 10px;
}
.version {
color: var(--c-text-dark-muted);
font-size: var(--font-size-xs);
}
</style>
28 changes: 28 additions & 0 deletions src/app/pages/navigation/info/InfoButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<template>
<Button
:tooltip="t('app.about')"
:class="classes"
textual
color="dimmed"
icon="information-line"
@click="showInfoDialog = true"
/>
<InfoDialog :open="showInfoDialog" @close="showInfoDialog = false" />
</template>

<script lang="ts" setup>
import { computed, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import Button from '@components/base/button/Button.vue';
import { ClassNames } from '@utils';
import InfoDialog from './InfoDialog.vue';
const props = defineProps<{
class?: ClassNames;
}>();
const { t } = useI18n();
const showInfoDialog = ref(false);
const classes = computed(() => props.class);
</script>
61 changes: 61 additions & 0 deletions src/app/pages/navigation/info/InfoDialog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<template>
<Dialog :open="open" :title="t('app.about')" @close="emit('close')">
<div :class="$style.infoBox">
<span :class="$style.link">
<i18n-t keypath="app.github">
<template #link>
<Link :custom="false" color="primary" to="https://github.com/simonwep/ocular">Github</Link>
</template>
</i18n-t>
</span>
<span :class="$style.love">{{ t('app.madeWithLove') }}</span>
<span :class="$style.meta">
{{ OCULAR_BUILD_VERSION }} / {{ new Date(OCULAR_BUILD_TIMESTAMP).toDateString() }} / {{ OCULAR_BUILD_SHA }}
</span>
</div>
</Dialog>
</template>

<script lang="ts" setup>
import { useI18n } from 'vue-i18n';
import Dialog from '@components/base/dialog/Dialog.vue';
import Link from '@components/base/link/Link.vue';
const { OCULAR_BUILD_SHA, OCULAR_BUILD_TIMESTAMP, OCULAR_BUILD_VERSION } = import.meta.env;
const emit = defineEmits<{
(e: 'close'): void;
}>();
defineProps<{
open: boolean;
}>();
const { t } = useI18n();
</script>

<style lang="scss" module>
.infoBox {
display: flex;
flex-direction: column;
font-size: var(--font-size-s);
gap: 2px;
}
.link {
margin-top: 8px;
}
.love {
display: inline-block;
font-size: var(--font-size-xs);
font-weight: var(--font-weight-l);
margin-top: 8px;
text-align: center;
}
.meta {
font-size: var(--font-size-xs);
text-align: center;
}
</style>
2 changes: 1 addition & 1 deletion src/app/pages/shared/Pane.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ useScrollShadow(header, content, 'var(--app-scroll-box-shadow)');
.title {
display: flex;
align-items: center;
align-items: end;
gap: 8px;
font-size: var(--font-size-s);
font-weight: var(--font-weight-l);
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
}
},
"app": {
"about": "Über Ocular",
"github": "Schau dir dieses Projekt auf {link} an!",
"madeWithLove": "Made with ❤️ by Simon",
"name": "Ocular"
},
"auth": {
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
}
},
"app": {
"about": "About Ocular",
"github": "Check this project out on {link}!",
"madeWithLove": "Made with ❤️ by Simon",
"name": "Ocular"
},
"auth": {
Expand Down
1 change: 0 additions & 1 deletion src/icons/github-line.svg

This file was deleted.

1 change: 1 addition & 0 deletions src/icons/information-line.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion src/types/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ declare interface HTMLDialogElement {
}

interface ImportMetaEnv {
// Development
readonly OCULAR_TEST_USERNAME?: string;
readonly OCULAR_TEST_PASSWORD?: string;

// Backend host
readonly OCULAR_GENESIS_HOST: string;
readonly OCULAR_BUILD_TIMESTAMP: string;

// Build information
readonly OCULAR_BUILD_TIMESTAMP: number;
readonly OCULAR_BUILD_SHA: string;
readonly OCULAR_BUILD_VERSION: string;
}

interface ImportMeta {
Expand Down
7 changes: 6 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { execSync } from 'child_process';
import vue from '@vitejs/plugin-vue';
import { defineConfig } from 'vite';
import { optimizeCssModules } from 'vite-plugin-optimize-css-modules';
Expand All @@ -17,7 +18,11 @@ export default defineConfig({
}
},
define: {
'import.meta.env.OCULAR_BUILD_TIMESTAMP': Date.now()
'import.meta.env.OCULAR_BUILD_TIMESTAMP': Date.now(),
'import.meta.env.OCULAR_BUILD_SHA': JSON.stringify(execSync('git rev-parse --short HEAD').toString().trim()),
'import.meta.env.OCULAR_BUILD_VERSION': JSON.stringify(
execSync('git describe --tags --always --abbrev=0').toString().trim()
)
},
plugins: [
tsconfigPaths({ loose: true }),
Expand Down

0 comments on commit 25595b1

Please sign in to comment.