2021-07-31 22:45:28 +00:00
|
|
|
<template>
|
2021-10-04 02:38:45 +00:00
|
|
|
<v-container fluid class="narrow-container">
|
|
|
|
<BasePageTitle divider>
|
|
|
|
<template #header>
|
2021-10-30 23:46:44 +00:00
|
|
|
<v-img max-height="200" max-width="150" :src="require('~/static/svgs/admin-site-settings.svg')"></v-img>
|
2021-10-04 02:38:45 +00:00
|
|
|
</template>
|
|
|
|
<template #title> {{ $t("settings.site-settings") }} </template>
|
|
|
|
</BasePageTitle>
|
2021-10-05 04:16:37 +00:00
|
|
|
|
|
|
|
<section>
|
2021-10-30 23:46:44 +00:00
|
|
|
<BaseCardSectionTitle class="pb-0" :icon="$globals.icons.cog" title="General Configuration">
|
|
|
|
</BaseCardSectionTitle>
|
|
|
|
<v-card v-for="(check, idx) in simpleChecks" :key="idx" class="mb-4">
|
2021-10-04 02:38:45 +00:00
|
|
|
<v-list-item>
|
|
|
|
<v-list-item-avatar>
|
2021-10-30 23:46:44 +00:00
|
|
|
<v-icon :color="getColor(check.status)">
|
|
|
|
{{ check.status ? $globals.icons.checkboxMarkedCircle : $globals.icons.close }}
|
2021-10-04 02:38:45 +00:00
|
|
|
</v-icon>
|
|
|
|
</v-list-item-avatar>
|
|
|
|
<v-list-item-content>
|
2021-10-30 23:46:44 +00:00
|
|
|
<v-list-item-title :class="getTextClass(check.status)"> {{ check.text }} </v-list-item-title>
|
|
|
|
<v-list-item-subtitle :class="getTextClass(check.status)">
|
|
|
|
{{ check.status ? check.successText : check.errorText }}
|
2021-10-04 02:38:45 +00:00
|
|
|
</v-list-item-subtitle>
|
|
|
|
</v-list-item-content>
|
|
|
|
</v-list-item>
|
2021-10-05 04:16:37 +00:00
|
|
|
</v-card>
|
|
|
|
</section>
|
|
|
|
<section>
|
|
|
|
<BaseCardSectionTitle class="pt-2" :icon="$globals.icons.email" title="Email Configuration">
|
|
|
|
</BaseCardSectionTitle>
|
|
|
|
<v-card>
|
2021-10-04 02:38:45 +00:00
|
|
|
<v-card-text>
|
2021-10-05 04:16:37 +00:00
|
|
|
<v-list-item>
|
|
|
|
<v-list-item-avatar>
|
|
|
|
<v-icon :color="getColor(appConfig.emailReady)">
|
|
|
|
{{ appConfig.emailReady ? $globals.icons.checkboxMarkedCircle : $globals.icons.close }}
|
|
|
|
</v-icon>
|
|
|
|
</v-list-item-avatar>
|
|
|
|
<v-list-item-content>
|
|
|
|
<v-list-item-title :class="getTextClass(appConfig.emailReady)">
|
|
|
|
Email Configuration Status
|
|
|
|
</v-list-item-title>
|
|
|
|
<v-list-item-subtitle :class="getTextClass(appConfig.emailReady)">
|
|
|
|
{{ appConfig.emailReady ? "Ready" : "Not Ready - Check Env Variables" }}
|
|
|
|
</v-list-item-subtitle>
|
|
|
|
</v-list-item-content>
|
|
|
|
</v-list-item>
|
|
|
|
<v-card-actions>
|
|
|
|
<v-text-field v-model="address" class="mr-4" :label="$t('user.email')" :rules="[validators.email]">
|
|
|
|
</v-text-field>
|
|
|
|
<BaseButton
|
|
|
|
color="info"
|
|
|
|
:disabled="!appConfig.emailReady || !validEmail"
|
|
|
|
:loading="loading"
|
|
|
|
@click="testEmail"
|
|
|
|
>
|
|
|
|
<template #icon> {{ $globals.icons.email }} </template>
|
|
|
|
{{ $t("general.test") }}
|
|
|
|
</BaseButton>
|
|
|
|
</v-card-actions>
|
2021-10-04 02:38:45 +00:00
|
|
|
</v-card-text>
|
2021-10-05 04:16:37 +00:00
|
|
|
<template v-if="tested">
|
|
|
|
<v-divider class="my-x"></v-divider>
|
|
|
|
<v-card-text>
|
|
|
|
Email Test Result: {{ success ? "Succeeded" : "Failed" }}
|
|
|
|
<div>Errors: {{ error }}</div>
|
|
|
|
</v-card-text>
|
|
|
|
</template>
|
|
|
|
</v-card>
|
|
|
|
</section>
|
2021-08-07 00:28:12 +00:00
|
|
|
</v-container>
|
2021-08-02 03:24:47 +00:00
|
|
|
</template>
|
2021-08-07 00:28:12 +00:00
|
|
|
|
2021-08-02 03:24:47 +00:00
|
|
|
<script lang="ts">
|
2021-10-05 04:16:37 +00:00
|
|
|
import { computed, defineComponent, onMounted, reactive, toRefs, ref } from "@nuxtjs/composition-api";
|
2021-10-24 00:42:45 +00:00
|
|
|
import { CheckAppConfig } from "~/api/admin/admin-about";
|
2021-10-05 04:16:37 +00:00
|
|
|
import { useAdminApi, useApiSingleton } from "~/composables/use-api";
|
2021-10-04 02:38:45 +00:00
|
|
|
import { validators } from "~/composables/use-validators";
|
2021-08-02 03:24:47 +00:00
|
|
|
|
2021-10-30 23:46:44 +00:00
|
|
|
interface SimpleCheck {
|
|
|
|
status: boolean;
|
|
|
|
text: string;
|
|
|
|
successText: string;
|
|
|
|
errorText: string;
|
|
|
|
}
|
|
|
|
|
2021-08-02 03:24:47 +00:00
|
|
|
export default defineComponent({
|
|
|
|
layout: "admin",
|
|
|
|
setup() {
|
2021-10-04 02:38:45 +00:00
|
|
|
const state = reactive({
|
|
|
|
loading: false,
|
|
|
|
address: "",
|
|
|
|
success: false,
|
|
|
|
error: "",
|
|
|
|
tested: false,
|
|
|
|
});
|
|
|
|
|
2021-10-05 04:16:37 +00:00
|
|
|
const appConfig = ref<CheckAppConfig>({
|
|
|
|
emailReady: false,
|
|
|
|
baseUrlSet: false,
|
2021-10-30 23:46:44 +00:00
|
|
|
isSiteSecure: false,
|
2021-10-05 04:16:37 +00:00
|
|
|
});
|
|
|
|
|
2021-10-04 02:38:45 +00:00
|
|
|
const api = useApiSingleton();
|
|
|
|
|
2021-10-05 04:16:37 +00:00
|
|
|
const adminAPI = useAdminApi();
|
2021-10-04 02:38:45 +00:00
|
|
|
onMounted(async () => {
|
2021-10-05 04:16:37 +00:00
|
|
|
const { data } = await adminAPI.about.checkApp();
|
2021-10-04 02:38:45 +00:00
|
|
|
|
|
|
|
if (data) {
|
2021-10-05 04:16:37 +00:00
|
|
|
appConfig.value = data;
|
2021-10-04 02:38:45 +00:00
|
|
|
}
|
2021-10-30 23:46:44 +00:00
|
|
|
|
|
|
|
appConfig.value.isSiteSecure = isLocalhostorHttps();
|
|
|
|
});
|
|
|
|
|
|
|
|
function isLocalhostorHttps() {
|
|
|
|
return window.location.hostname === "localhost" || window.location.protocol === "https:";
|
|
|
|
}
|
|
|
|
|
|
|
|
const simpleChecks = computed<SimpleCheck[]>(() => {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
status: appConfig.value.baseUrlSet,
|
|
|
|
text: "Server Side Base URL",
|
|
|
|
errorText: "Error - `BASE_URL` still default on API Server",
|
|
|
|
successText: "Server Side URL does not match the default",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
status: appConfig.value.isSiteSecure,
|
|
|
|
text: "Secure Site",
|
|
|
|
errorText: "Error - Serve via localhost or secure with https.",
|
|
|
|
successText: "Site is accessed by localhost or https",
|
|
|
|
},
|
|
|
|
];
|
2021-10-04 02:38:45 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
async function testEmail() {
|
|
|
|
state.loading = true;
|
|
|
|
state.tested = false;
|
|
|
|
const { data } = await api.email.test({ email: state.address });
|
|
|
|
|
|
|
|
if (data) {
|
|
|
|
if (data.success) {
|
|
|
|
state.success = true;
|
|
|
|
} else {
|
|
|
|
state.error = data.error;
|
|
|
|
state.success = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
state.loading = false;
|
|
|
|
state.tested = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
const validEmail = computed(() => {
|
|
|
|
if (state.address === "") {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
const valid = validators.email(state.address);
|
|
|
|
|
|
|
|
// Explicit bool check because validators.email sometimes returns a string
|
|
|
|
if (valid === true) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2021-10-05 04:16:37 +00:00
|
|
|
function getTextClass(booly: boolean | any) {
|
|
|
|
return booly ? "success--text" : "error--text";
|
|
|
|
}
|
|
|
|
function getColor(booly: boolean | any) {
|
|
|
|
return booly ? "success" : "error";
|
|
|
|
}
|
|
|
|
|
2021-10-04 02:38:45 +00:00
|
|
|
return {
|
2021-10-30 23:46:44 +00:00
|
|
|
simpleChecks,
|
2021-10-05 04:16:37 +00:00
|
|
|
getColor,
|
|
|
|
getTextClass,
|
|
|
|
appConfig,
|
2021-10-04 02:38:45 +00:00
|
|
|
validEmail,
|
|
|
|
validators,
|
|
|
|
...toRefs(state),
|
|
|
|
testEmail,
|
|
|
|
};
|
2021-08-02 03:24:47 +00:00
|
|
|
},
|
2021-10-07 17:39:47 +00:00
|
|
|
head() {
|
|
|
|
return {
|
|
|
|
title: this.$t("settings.site-settings") as string,
|
|
|
|
};
|
|
|
|
},
|
2021-08-02 03:24:47 +00:00
|
|
|
});
|
|
|
|
</script>
|
2021-08-07 00:28:12 +00:00
|
|
|
|
2021-08-02 03:24:47 +00:00
|
|
|
<style scoped>
|
|
|
|
</style>
|