Skip to content

Commit

Permalink
feat: added domain name in interface (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaile authored Dec 15, 2023
1 parent 32a3470 commit 7bcaaa2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/composables/useConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ref } from 'vue'
import axios from 'axios'

interface ConfigResponse {
domain?: string
}

export function useConfig() {
const domainName = ref<string>()

axios.get<ConfigResponse>('/config.json').then(({ data }) => (domainName.value = data.domain))

return { domainName }
}
3 changes: 2 additions & 1 deletion src/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"password": "Password",
"remember_me": "Remember me",
"sign_in": "Sign in",
"invalid_credentials": "Invalid credentials"
"invalid_credentials": "Invalid credentials",
"domain": "Domain"
},
"account_settings": {
"title": "Account settings",
Expand Down
4 changes: 4 additions & 0 deletions src/views/BaseTemplate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ import { faBars, faXmark } from '@fortawesome/free-solid-svg-icons'
import { ref } from 'vue'
import { NeButton } from '@nethserver/vue-tailwind-lib'
import NotificationHandler from '@/components/NotificationHandler.vue'
import { useConfig } from '@/composables/useConfig'
const { logout, uid } = useAuth()
const router = useRouter()
const { domainName } = useConfig()
const sidebarRef = ref<HTMLElement | null>(null)
Expand Down Expand Up @@ -60,7 +62,9 @@ function handleLogout() {
>
<FontAwesomeIcon :icon="faBars" class="h-full w-full" />
</button>

<div class="ml-auto flex items-center text-gray-700 dark:text-gray-200">
<p class="pr-6 text-sm">{{ domainName }}</p>
<div class="mr-2 h-8 w-8">
<FontAwesomeIcon :icon="faCircleUser" class="h-full w-full" />
</div>
Expand Down
10 changes: 9 additions & 1 deletion src/views/LoginView.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<script lang="ts" setup>
import { NeCheckbox, NeTextInput, NeButton } from '@nethserver/vue-tailwind-lib'
import { NeButton, NeCheckbox, NeTextInput } from '@nethserver/vue-tailwind-lib'
import { NeInlineNotification } from '@nethesis/vue-components'
import { ref } from 'vue'
import { useAuth } from '@/composables/useAuth'
import axios from 'axios'
import { useRouter } from 'vue-router'
import { useConfig } from '@/composables/useConfig'
const { login } = useAuth()
const router = useRouter()
const { domainName } = useConfig()
const username = ref('')
const password = ref('')
Expand Down Expand Up @@ -57,6 +59,12 @@ async function handleLogin() {
<p class="text-sm font-normal">{{ $t('login_form.sign_in_description') }}</p>
</div>
<NeInlineNotification v-if="errorMessage" :title="$t(errorMessage)" kind="error" />
<NeTextInput
v-if="domainName"
v-model="domainName"
disabled
:label="$t('login_form.domain')"
/>
<NeTextInput
v-model="username"
:disabled="loading"
Expand Down

0 comments on commit 7bcaaa2

Please sign in to comment.