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 >
2021-12-04 23:18:46 +00:00
< v-alert
v - for = "(check, idx) in simpleChecks"
: key = "idx"
border = "left"
colored - border
: type = "getColor(check.status, check.warning)"
elevation = "2"
>
< div class = "font-weight-medium" > { { check . text } } < / div >
< div >
{ { check . status ? check . successText : check . errorText } }
< / div >
< / v-alert >
2021-10-05 04:16:37 +00:00
< / section >
< section >
2021-12-04 23:18:46 +00:00
< BaseCardSectionTitle class = "pt-2" :icon = "$globals.icons.email" title = "Email Configuration" / >
2021-12-11 04:48:06 +00:00
< v-alert border = "left" colored -border :type = "getColor(appConfig.emailReady)" elevation = "2" >
2021-12-04 23:18:46 +00:00
< div class = "font-weight-medium" > Email Configuration Status < / div >
< div >
{ { appConfig . emailReady ? "Ready" : "Not Ready - Check Environmental Variables" } }
< / div >
< div >
< 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 >
< 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 >
< / div >
< / v-alert >
2021-10-05 04:16:37 +00:00
< / section >
2021-11-05 23:48:10 +00:00
< section class = "mt-4" >
< BaseCardSectionTitle class = "pb-0" :icon = "$globals.icons.cog" title = "General About" > < / BaseCardSectionTitle >
< v-card class = "mb-4" >
< v-list-item v-for = "property in appInfo" :key="property.name" >
< v-list-item-icon >
< v-icon > { { property . icon || $globals . icons . user } } < / v-icon >
< / v-list-item-icon >
< v-list-item-content >
< v-list-item-title >
< div > { { property . name } } < / div >
< / v-list-item-title >
< v-list-item-subtitle class = "text-end" >
{ { property . value } }
< / v-list-item-subtitle >
< / v-list-item-content >
< / v-list-item >
< / v-card >
< / section >
2021-08-07 00:28:12 +00:00
< / v-container >
2021-08-02 03:24:47 +00:00
< / template >
2022-01-09 06:15:23 +00:00
2021-08-02 03:24:47 +00:00
< script lang = "ts" >
2021-11-05 23:48:10 +00:00
import {
computed ,
onMounted ,
reactive ,
toRefs ,
ref ,
defineComponent ,
useAsync ,
useContext ,
} from "@nuxtjs/composition-api" ;
2022-01-16 02:38:11 +00:00
import { CheckAppConfig } from "~/api/admin/admin-about" ;
2021-11-06 19:28:47 +00:00
import { useAdminApi , useUserApi } from "~/composables/api" ;
2021-10-04 02:38:45 +00:00
import { validators } from "~/composables/use-validators" ;
2021-11-05 23:48:10 +00:00
import { useAsyncKey } from "~/composables/use-utils" ;
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 ;
2022-01-16 02:38:11 +00:00
warning : boolean ;
2021-10-30 23:46:44 +00:00
}
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-12-04 23:18:46 +00:00
isUpToDate : false ,
2021-11-25 23:17:02 +00:00
ldapReady : false ,
2021-10-05 04:16:37 +00:00
} ) ;
2021-11-06 19:28:47 +00:00
const api = useUserApi ( ) ;
2021-10-04 02:38:45 +00:00
2021-11-05 23:48:10 +00:00
const adminApi = useAdminApi ( ) ;
2021-10-04 02:38:45 +00:00
onMounted ( async ( ) => {
2021-11-05 23:48:10 +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
2021-11-25 23:17:02 +00:00
appConfig . value . isSiteSecure = isLocalHostOrHttps ( ) ;
2021-10-30 23:46:44 +00:00
} ) ;
2021-11-25 23:17:02 +00:00
function isLocalHostOrHttps ( ) {
2021-10-30 23:46:44 +00:00
return window . location . hostname === "localhost" || window . location . protocol === "https:" ;
}
const simpleChecks = computed < SimpleCheck [ ] > ( ( ) => {
return [
{
2021-12-04 23:18:46 +00:00
status : appConfig . value . isUpToDate ,
text : "Application Version" ,
errorText : ` Your current version ( ${ rawAppInfo . value . version } ) does not match the latest release. Considering updating to the latest version ( ${ rawAppInfo . value . versionLatest } ). ` ,
successText : "Mealie is up to date" ,
warning : true ,
2021-10-30 23:46:44 +00:00
} ,
{
status : appConfig . value . isSiteSecure ,
text : "Secure Site" ,
2021-12-04 23:18:46 +00:00
errorText : "Serve via localhost or secure with https. Clipboard and additional browser APIs may not work." ,
2021-10-30 23:46:44 +00:00
successText : "Site is accessed by localhost or https" ,
2021-12-04 23:18:46 +00:00
warning : false ,
} ,
{
status : appConfig . value . baseUrlSet ,
text : "Server Side Base URL" ,
errorText :
"`BASE_URL` is still the default value on API Server. This will cause issues with notifications links generated on the server for emails, etc." ,
successText : "Server Side URL does not match the default" ,
warning : false ,
2021-10-30 23:46:44 +00:00
} ,
2021-11-25 23:17:02 +00:00
{
status : appConfig . value . ldapReady ,
text : "LDAP Ready" ,
2021-12-04 23:18:46 +00:00
errorText :
"Not all LDAP Values are configured. This can be ignored if you are not using LDAP Authentication." ,
2021-11-25 23:17:02 +00:00
successText : "Required LDAP variables are all set." ,
2021-12-04 23:18:46 +00:00
warning : true ,
2021-11-25 23:17:02 +00:00
} ,
2021-10-30 23:46:44 +00:00
] ;
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 ;
} ) ;
2022-01-09 06:15:23 +00:00
function getColor ( booly : unknown , warning = false ) {
2021-12-04 23:18:46 +00:00
const falsey = warning ? "warning" : "error" ;
return booly ? "success" : falsey ;
2021-10-05 04:16:37 +00:00
}
2021-11-05 23:48:10 +00:00
// ============================================================
// General About Info
2021-12-04 23:18:46 +00:00
2021-11-05 23:48:10 +00:00
const { $globals , i18n } = useContext ( ) ;
2022-01-16 02:38:11 +00:00
const rawAppInfo = ref ( {
2021-12-04 23:18:46 +00:00
version : "null" ,
versionLatest : "null" ,
} ) ;
2021-11-05 23:48:10 +00:00
function getAppInfo ( ) {
const statistics = useAsync ( async ( ) => {
const { data } = await adminApi . about . about ( ) ;
if ( data ) {
2022-01-16 02:38:11 +00:00
rawAppInfo . value . version = data . version ;
rawAppInfo . value . versionLatest = data . versionLatest ;
2021-12-04 23:18:46 +00:00
2021-11-05 23:48:10 +00:00
const prettyInfo = [
{
name : i18n . t ( "about.version" ) ,
icon : $globals . icons . information ,
value : data . version ,
} ,
{
name : i18n . t ( "about.application-mode" ) ,
icon : $globals . icons . devTo ,
value : data . production ? i18n . t ( "about.production" ) : i18n . t ( "about.development" ) ,
} ,
{
name : i18n . t ( "about.demo-status" ) ,
icon : $globals . icons . testTube ,
value : data . demoStatus ? i18n . t ( "about.demo" ) : i18n . t ( "about.not-demo" ) ,
} ,
{
name : i18n . t ( "about.api-port" ) ,
icon : $globals . icons . api ,
value : data . apiPort ,
} ,
{
name : i18n . t ( "about.api-docs" ) ,
icon : $globals . icons . file ,
value : data . apiDocs ? i18n . t ( "general.enabled" ) : i18n . t ( "general.disabled" ) ,
} ,
{
name : i18n . t ( "about.database-type" ) ,
icon : $globals . icons . database ,
value : data . dbType ,
} ,
{
name : i18n . t ( "about.database-url" ) ,
icon : $globals . icons . database ,
value : data . dbUrl ,
} ,
{
name : i18n . t ( "about.default-group" ) ,
icon : $globals . icons . group ,
value : data . defaultGroup ,
} ,
] ;
return prettyInfo ;
}
return data ;
} , useAsyncKey ( ) ) ;
return statistics ;
}
const appInfo = getAppInfo ( ) ;
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 ,
appConfig ,
2021-10-04 02:38:45 +00:00
validEmail ,
validators ,
... toRefs ( state ) ,
testEmail ,
2021-11-05 23:48:10 +00:00
appInfo ,
2021-10-04 02:38:45 +00:00
} ;
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 >
2022-01-09 06:15:23 +00:00
2021-08-02 03:24:47 +00:00
< style scoped >
2022-01-09 06:15:23 +00:00
< / style >