Skip to content

Commit

Permalink
Draft setup page
Browse files Browse the repository at this point in the history
  • Loading branch information
Natan Vieira do Nascimento committed Aug 31, 2023
1 parent 7537d5b commit cb6d453
Show file tree
Hide file tree
Showing 16 changed files with 202 additions and 40 deletions.
9 changes: 9 additions & 0 deletions src/assets/styles/base/_transitions.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.v-fade-enter-active,
.v-fade-leave-active {
transition: opacity 0.5s ease;
}

.v-fade-enter-from,
.v-fade-leave-to {
opacity: 0;
}
10 changes: 4 additions & 6 deletions src/assets/styles/base/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,10 @@ h6 {
}

.text--overline {
.root {
font-family: var(--kt-body-font);
font-weight: 400;
font-size: 9px;
letter-spacing: 1.5px;
}
font-family: var(--kt-body-font);
font-weight: 400;
font-size: 9px;
letter-spacing: 1.5px;
}

.text--subtitle1 {
Expand Down
2 changes: 1 addition & 1 deletion src/assets/styles/main.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@import "abstracts/variables", "abstracts/functions", "abstracts/spacing", "abstracts/colors";
@import "base/base", "base/reset", "base/typography", "base/grid";
@import "base/base", "base/reset", "base/typography", "base/grid", "base/transitions";
@import "vendor/vue-simple-context-menu.css", "vendor/vue-progressive-image.css",
"vendor/vue-loading-overlay.css", "vendor/codemirror";
@import "components/alert", "components/button", "components/card", "components/form",
Expand Down
2 changes: 1 addition & 1 deletion src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function setI18nLanguage(i18n: I18n, locale: Locale) {
document.querySelector("html")?.setAttribute("lang", locale)
}

export async function loadLocaleMessages(i18n: I18n, locale: Locale) {
export async function loadLocaleMessages(i18n: I18n, locale: Locale): Promise<void> {
const messages = await import(`./lang/${locale}.json`)
i18n.global.setLocaleMessage(locale, messages.default)
return nextTick()
Expand Down
5 changes: 4 additions & 1 deletion src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,8 @@
"blueprints.home.title": "Blueprints",
"blueprints.home.subtitle": "Blueprints are definition files, design patterns used to determine how a game server instance will be built, each game server can only have one blueprint defined for it throughout its lifetime. Internally, blueprints are files in .conf format and have their own semantics.",
"blueprints.empty-state.title": "Blueprints have... gone?",
"blueprints.empty-state.description": "Import or create new blueprints and they will appear here."
"blueprints.empty-state.description": "Import or create new blueprints and they will appear here.",
"setup.title": "Let's get started",
"setup.header.label.docs": "Need help?",
"setup.header.label.login": "Log in"
}
6 changes: 5 additions & 1 deletion src/lang/pt.json
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
{}
{
"setup.title": "Configurar credenciais",
"setup.header.label.docs": "Precisa de ajuda?",
"setup.header.label.login": "Fazer login"
}
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createVfm } from "vue-final-modal"
import ECharts from "vue-echarts"
import router from "@/router"
import i18n, { DEFAULT_LOCALE, loadLocaleMessages } from "@/i18n"
import {createPinia} from "pinia";
import { createPinia } from "pinia"
import VueProgressiveImage from "vue-progressive-image"
import logService from "@/modules/platform/api/services/log.service"
import configService from "@/modules/platform/api/services/config.service"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,29 @@ import type { Logger } from "@/modules/platform/api/services/log.service"
import { useAccountsStore } from "../../accounts.store"
import logService from "@/modules/platform/api/services/log.service"
import type { Account } from "../models/account.model"
import httpService from "@/modules/platform/api/services/http.service"
import type { AxiosResponse } from "axios"

class AccountService {
class AccountsService {
private readonly logger!: Logger

constructor() {
this.logger = logService.create(AccountService.name)
this.logger = logService.create(AccountsService.name)
}

get isLoggedIn(): boolean {
return useAccountsStore().isLoggedIn
}

async listAccounts(): Promise<Account[]> {
return httpService.get("accounts")
.then((res: AxiosResponse) => res.data as Account[]);
}

async updateAccount(account: Account): Promise<void> {
this.logger.debug("Account updated", account)
useAccountsStore().updateAccount(account)
}
}

export default new AccountService()
export default new AccountsService()
4 changes: 2 additions & 2 deletions src/modules/auth/guards/authenticated-only.guard.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { NavigationGuard, NavigationGuardNext, RouteLocationNormalized } from "vue-router"
import accountService from "@/modules/accounts/api/services/account.service"
import accountService from "@/modules/accounts/api/services/accounts.service"
import authService from "@/modules/auth/api/services/auth.service"
import { isNull } from "@/utils"
import type { Account } from "@/modules/accounts/api/models/account.model"
Expand All @@ -22,7 +22,7 @@ export const AuthenticatedOnlyGuard: NavigationGuard = (
.verify(localToken!)
.then(async (account: Account) => {
await accountService.updateAccount(account)
next();
next()
})
.catch((error: Error) => {
logService.debug("Unable to verify local token", error)
Expand Down
20 changes: 0 additions & 20 deletions src/modules/platform/api/models/server-info.model.ts

This file was deleted.

3 changes: 3 additions & 0 deletions src/modules/platform/api/models/server-info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type ServerInfo = {
setup: boolean
}
23 changes: 23 additions & 0 deletions src/modules/platform/api/services/server.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { ServerInfo } from "@/modules/platform/api/models/server-info"
import { usePlatformStore } from "@/modules/platform/platform.store"
import type { Logger } from "@/modules/platform/api/services/log.service"
import logService from "@/modules/platform/api/services/log.service"

class ServerService {

private readonly logger: Logger = logService.create("backend")

async getInfo(): Promise<ServerInfo> {
const store = usePlatformStore()
if (store.hasServerInfo)
return store.getServerInfo

const value = { setup: true } as ServerInfo
this.logger.debug(value);
store.updateServerInfo(value)
return value
// return httpService.get("/").then((res: AxiosResponse) => res.data as SystemInfo);
}
}

export default new ServerService()
25 changes: 25 additions & 0 deletions src/modules/platform/platform.store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { defineStore } from "pinia"
import type { ServerInfo } from "@/modules/platform/api/models/server-info"
import { isNull } from "@/utils"

type PlatformStore = { serverInfo: ServerInfo | null }

export const usePlatformStore = defineStore("platform", {
state: (): PlatformStore => ({ serverInfo: null }),
getters: {
getServerInfo(): ServerInfo {
if (!this.hasServerInfo)
throw new Error("Missing system information")

return this.serverInfo!
},
hasServerInfo(): boolean {
return !isNull(this.serverInfo);
}
},
actions: {
updateServerInfo(serverInfo: ServerInfo) {
this.serverInfo = serverInfo;
}
}
})
2 changes: 1 addition & 1 deletion src/modules/platform/ui/components/LoadingState.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useLoading } from "vue-loading-overlay"
const root = ref(null)
const loading = useLoading({
isFullPage: false,
isFullPage: true,
lockScroll: true
})
Expand Down
105 changes: 105 additions & 0 deletions src/modules/platform/ui/pages/SetupPage.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<template>
<div class="header">
<VContainer class="items">
<TheLogo
black
class="logo"
/>
<ul class="links">
<li>
<a
v-t="'setup.header.label.docs'"
:href="links.docs"
target="_blank"
/>
</li>
<li>
<a
v-t="'setup.header.label.login'"
:href="links.login"
/>
</li>
</ul>
</VContainer>
</div>
<div class="root">
<VContainer>
<h2
v-t="'setup.title'"
class="title"
/>
<h4>Let's get you up and running!</h4>
</VContainer>
</div>
</template>

<script setup lang="ts">
import VContainer from "@/modules/platform/ui/components/grid/VContainer.vue"
import TheLogo from "@/modules/platform/ui/components/TheLogo.vue"
import configService from "@/modules/platform/api/services/config.service"
import { useRouter } from "vue-router"
const router = useRouter()
const links = {
docs: configService.appWebsite,
login: "/login"
}
</script>

<style scoped lang="scss">
.root {
background-color: var(--kt-background-surface);
height: 100%;
width: 100%;
}
.title {
margin-top: 0.8em;
user-select: none;
}
.header {
background-color: var(--kt-background-surface);
border-bottom: 1px solid var(--kt-border-medium);
padding: 0.8rem 0;
.items {
display: flex;
flex-direction: row;
align-content: space-between;
width: 100%;
}
.logo {
width: 48px;
height: 48px;
border-radius: 8px;
}
.links {
display: flex;
align-items: center;
justify-content: flex-end;
flex-grow: 1;
gap: 2.4rem;
li {
font-weight: 500;
font-size: 14px;
a {
text-decoration: none;
color: var(--kt-content-neutral);
&:hover {
color: var(--kt-content-neutral-low);
}
}
}
}
}
.languages {
}
</style>
11 changes: 8 additions & 3 deletions src/router.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createRouter, createWebHistory } from "vue-router"
import { createRouter, createWebHistory, type RouteRecordRaw } from "vue-router"
import i18n, { loadLocaleMessages, setI18nLanguage, SUPPORTED_LOCALES } from "@/i18n"
import { AuthRoutes } from "@/modules/auth/auth.routes"
import { AccountsRoute } from "@/modules/accounts/accounts.routes"
Expand All @@ -14,17 +14,22 @@ export function importPage(module: string, path: string): () => Promise<unknown>
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
...AuthRoutes,
{
path: "/",
component: importPage("platform", "Root"),
beforeEnter: AuthenticatedOnlyGuard,
children: [
...HomeRoutes,
...AccountsRoute,
...BlueprintsRoutes
...BlueprintsRoutes,
]
},
...AuthRoutes
{
path: "/setup",
name: "setup",
component: importPage("platform", "Setup")
},
]
})

Expand Down

0 comments on commit cb6d453

Please sign in to comment.