fix: 🚚 remove alias and cleanup
This commit is contained in:
parent
c629b1b682
commit
83fbc483f0
@ -42,20 +42,6 @@ async def check_auth(
|
|||||||
return credentials
|
return credentials
|
||||||
|
|
||||||
|
|
||||||
class AuthStaticFiles(StaticFiles):
|
|
||||||
async def __call__(
|
|
||||||
self, scope: types.Scope, receive: types.Receive, send: types.Send
|
|
||||||
) -> None:
|
|
||||||
request = Request(scope, receive)
|
|
||||||
credentials = await security(request)
|
|
||||||
|
|
||||||
if not credentials:
|
|
||||||
raise http_401()
|
|
||||||
|
|
||||||
await check_auth(credentials)
|
|
||||||
await super().__call__(scope, receive, send)
|
|
||||||
|
|
||||||
|
|
||||||
app = FastAPI(dependencies=[Depends(check_auth)])
|
app = FastAPI(dependencies=[Depends(check_auth)])
|
||||||
|
|
||||||
|
|
||||||
@ -66,7 +52,6 @@ class SerializedContainer(BaseModel):
|
|||||||
labels: dict[str, str]
|
labels: dict[str, str]
|
||||||
status: str
|
status: str
|
||||||
health: str
|
health: str
|
||||||
ports: dict[str, str]
|
|
||||||
owner: str | None
|
owner: str | None
|
||||||
environment: list[str]
|
environment: list[str]
|
||||||
|
|
||||||
@ -79,7 +64,6 @@ def serialize_container(container: Container) -> SerializedContainer:
|
|||||||
labels=container.labels,
|
labels=container.labels,
|
||||||
status=container.status,
|
status=container.status,
|
||||||
health=container.health,
|
health=container.health,
|
||||||
ports=container.ports,
|
|
||||||
owner=container.labels.get("owner"),
|
owner=container.labels.get("owner"),
|
||||||
environment=container.attrs["Config"]["Env"],
|
environment=container.attrs["Config"]["Env"],
|
||||||
)
|
)
|
||||||
@ -182,6 +166,20 @@ def update_container(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class AuthStaticFiles(StaticFiles):
|
||||||
|
async def __call__(
|
||||||
|
self, scope: types.Scope, receive: types.Receive, send: types.Send
|
||||||
|
) -> None:
|
||||||
|
request = Request(scope, receive)
|
||||||
|
credentials = await security(request)
|
||||||
|
|
||||||
|
if not credentials:
|
||||||
|
raise http_401()
|
||||||
|
|
||||||
|
await check_auth(credentials)
|
||||||
|
await super().__call__(scope, receive, send)
|
||||||
|
|
||||||
|
|
||||||
app.mount(
|
app.mount(
|
||||||
"/",
|
"/",
|
||||||
AuthStaticFiles(
|
AuthStaticFiles(
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Message from '@/components/Message.vue'
|
import Message from './Message.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Loading',
|
name: 'Loading',
|
||||||
|
@ -2,7 +2,7 @@ import 'bulma/css/bulma.min.css'
|
|||||||
import 'font-awesome/css/font-awesome.min.css'
|
import 'font-awesome/css/font-awesome.min.css'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
import router from './router.ts'
|
import router from './router'
|
||||||
|
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
app.use(router)
|
app.use(router)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { createRouter, createWebHistory } from 'vue-router'
|
import { createRouter, createWebHistory } from 'vue-router'
|
||||||
import Container from './views/Container.vue'
|
import Container from '../views/Container.vue'
|
||||||
import Home from './views/Home.vue'
|
import Home from '../views/Home.vue'
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
history: createWebHistory(import.meta.env.BASE_URL),
|
history: createWebHistory(import.meta.env.BASE_URL),
|
10
frontend/types.ts
Normal file
10
frontend/types.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
export interface Container {
|
||||||
|
id: number
|
||||||
|
name: string | null
|
||||||
|
image: string | null
|
||||||
|
labels: Record<string, string>
|
||||||
|
status: string
|
||||||
|
health: string
|
||||||
|
owner: string
|
||||||
|
environment: string[]
|
||||||
|
}
|
@ -19,8 +19,9 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import axios, { AxiosError } from 'axios'
|
import axios, { AxiosError } from 'axios'
|
||||||
import Icon from '@/components/Icon.vue'
|
import type { Container } from '../types'
|
||||||
import Loading from '@/components/Loading.vue'
|
import Icon from '../components/Icon.vue'
|
||||||
|
import Loading from '../components/Loading.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Home',
|
name: 'Home',
|
||||||
@ -30,14 +31,14 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
containers: [],
|
containers: [] as Container[],
|
||||||
error: '',
|
error: '',
|
||||||
loading: true,
|
loading: true,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get('/api/containers')
|
const response = await axios.get<Container[]>('/api/containers')
|
||||||
this.containers = response.data
|
this.containers = response.data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
@ -5,9 +5,5 @@
|
|||||||
"composite": true,
|
"composite": true,
|
||||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
|
||||||
"@/*": ["frontend/*"]
|
|
||||||
},
|
|
||||||
"allowImportingTsExtensions": true,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
import { URL, fileURLToPath } from 'node:url'
|
|
||||||
|
|
||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite'
|
||||||
import vue from '@vitejs/plugin-vue'
|
import vue from '@vitejs/plugin-vue'
|
||||||
|
|
||||||
// https://vite.dev/config/
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [vue()],
|
plugins: [vue()],
|
||||||
resolve: {
|
|
||||||
alias: {
|
|
||||||
'@': fileURLToPath(new URL('./frontend', import.meta.url)),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
build: {
|
build: {
|
||||||
outDir: 'backend/dist',
|
outDir: 'backend/dist',
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user