add interaction api- ui

This commit is contained in:
Robin COuret
2026-02-23 17:03:39 +01:00
parent 978f726c10
commit cf99d5d388
4557 changed files with 541 additions and 662217 deletions

1
user-interface/.env Normal file
View File

@@ -0,0 +1 @@
VITE_API_URL=http://127.0.0.1:8000/

View File

@@ -0,0 +1 @@
VITE_API_URL=http://127.0.0.1:8000/

File diff suppressed because it is too large Load Diff

View File

@@ -19,7 +19,7 @@
"format": "prettier --write --experimental-cli src/"
},
"dependencies": {
"buetify": "^0.1.7",
"buefy": "^3.0.4",
"pinia": "^3.0.4",
"vue": "^3.5.27",
"vue-router": "^5.0.1"
@@ -30,15 +30,15 @@
"@types/node": "^24.10.9",
"@vitejs/plugin-vue": "^6.0.3",
"@vitest/eslint-plugin": "^1.6.6",
"@vue/eslint-config-typescript": "^14.6.0",
"@vue/test-utils": "^2.4.6",
"@vue/eslint-config-typescript": "^14.2.0",
"@vue/test-utils": "^2.4.0",
"@vue/tsconfig": "^0.8.1",
"cypress": "^15.9.0",
"eslint": "^9.39.2",
"eslint": "^10.0.1",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-cypress": "^5.2.1",
"eslint-plugin-oxlint": "~1.42.0",
"eslint-plugin-vue": "~10.7.0",
"eslint-plugin-vue": "^10.2.0",
"jiti": "^2.6.1",
"jsdom": "^27.4.0",
"npm-run-all2": "^8.0.4",

View File

@@ -16,13 +16,13 @@ import AppTopbar from '@/components/AppTopbar.vue'
</template>
<style>
/* #app {
width: 100%;
display: flex;
flex-direction: column;
#app {
background-color: #FFF4EA;
padding-inline: 5%;
height: 100vh;
}
main {
/* main {
height: 100%;
}

View File

@@ -0,0 +1,10 @@
// variables.sass
@import '~buetify/src/sass/variables'
@import '~bulma/sass/utilities/initial-variables'
// provide any variable overrides here
@import '~bulma/sass/utilities/functions'
@import '~bulma/sass/utilities/derived-variables'
@import '~bulma/sass/utilities/controls'
@import '~bulma/sass/utilities/mixins'

View File

@@ -1,11 +1,26 @@
<script setup lang="ts">
import { BField, BInput, BButton } from "buefy";
import { apiClient } from "@/services/api";
let knowledgeText = ""
function postKnowledge(){
let knowlegde = {
content: knowledgeText,
uri: "wiki"
}
apiClient.post("api/v1/knowledges/", knowlegde)
}
</script>
<template>
<div class="container">
<h2>Collect Knowledge</h2>
<b-field label="Knowledge">
<b-input maxlength="1200" type="textarea" v-model="knowledgeText"></b-input>
</b-field>
<b-button type="is-primary" @click="postKnowledge" >Submit</b-button>
</div>
</template>
<style scoped>

View File

@@ -3,11 +3,14 @@ import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
import './styles/global.css';
import Buefy from "buefy";
import "buefy/dist/css/buefy.css";
const app = createApp(App)
app.use(createPinia())
app.use(router)
app.use(Buefy)
app.mount('#app')

View File

@@ -0,0 +1,74 @@
class ApiClient {
private baseURL: string
private defaultHeaders: Record<string, string>
constructor(baseURL: string) {
this.baseURL = baseURL
this.defaultHeaders = {
'Content-Type': 'application/json',
}
}
private async request<T>(endpoint: string, options: RequestInit = {}): Promise<T> {
const url = `${this.baseURL}${endpoint}`
const config: RequestInit = {
headers: { ...this.defaultHeaders, ...options.headers },
...options,
}
let response
try {
response = await fetch(url, config)
} catch (error) {
if (error instanceof Error) {
throw new HTTPError(`Network error: ${error.message}`)
}
throw new HTTPError('Unknown network error')
}
if (response?.ok) {
return response.json()
}
const errorData = await response.json().catch(() => ({}))
throw new HTTPError(
errorData.message || `HTTP ${response.status}: ${response.statusText}`,
response.status,
response,
)
}
/**
* HTTP Get
* @param endpoint
* @returns
*/
async get<T>(endpoint: string): Promise<T> {
return this.request<T>(endpoint, { method: 'GET' })
}
/**
* HTTP Post
* @param endpoint
* @param data
* @returns
*/
async post<T>(endpoint: string, data: unknown): Promise<T> {
return this.request<T>(endpoint, { method: 'POST', body: JSON.stringify(data) })
}
}
class HTTPError extends Error {
constructor(
message: string,
private status: number | null = null,
private reponse: Response | null = null,
) {
super(message)
this.name = 'HTTPError'
}
}
export const apiClient = new ApiClient(import.meta.env.VITE_API_URL)

View File

@@ -1,4 +0,0 @@
body {
background-color: #FFF4EA;
margin-inline: 5%;
}