|
| 1 | +<!-- |
| 2 | +Copyright 2025 Google Inc. All rights reserved. |
| 3 | + |
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | + |
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + |
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +--> |
| 16 | +<template> |
| 17 | + <v-card class="pa-4 pt-5" min-height="800px"> |
| 18 | + <v-card-title class="pl-6">Settings</v-card-title> |
| 19 | + <v-list class="pr-3" v-if="settings" two-line subheader flat> |
| 20 | + <v-list-subheader class="ml-3">Layout</v-list-subheader> |
| 21 | + <v-list-item> |
| 22 | + <div class="d-flex align-center pl-3"> |
| 23 | + <v-switch v-model="settings.showLeftPanel" color="primary" @change="saveSettings()" hide-details></v-switch> |
| 24 | + <div class="pl-5"> |
| 25 | + <v-list-item-title>Show side panel</v-list-item-title> |
| 26 | + <v-list-item-subtitle |
| 27 | + >Select if the side panel should be expanded or collapsed by default</v-list-item-subtitle |
| 28 | + > |
| 29 | + </div> |
| 30 | + </div> |
| 31 | + </v-list-item> |
| 32 | + <v-list-item v-if="systemSettings.LLM_PROVIDER"> |
| 33 | + <div class="d-flex align-center pl-3"> |
| 34 | + <v-switch v-model="settings.generateQuery" color="primary" @change="saveSettings()"></v-switch> |
| 35 | + <div class="pl-5"> |
| 36 | + <v-list-item-title>AI generated queries</v-list-item-title> |
| 37 | + <v-list-item-subtitle |
| 38 | + >Select to enable experimental AI query suggestions for DFIQ questions</v-list-item-subtitle |
| 39 | + > |
| 40 | + </div> |
| 41 | + </div> |
| 42 | + </v-list-item> |
| 43 | + </v-list> |
| 44 | + </v-card> |
| 45 | +</template> |
| 46 | + |
| 47 | +<script> |
| 48 | +import ApiClient from '../utils/RestApiClient' |
| 49 | +import { useAppStore } from "@/stores/app"; |
| 50 | + |
| 51 | +const DEFAULT_SETTINGS = { |
| 52 | + showLeftPanel: true, |
| 53 | +} |
| 54 | + |
| 55 | +export default { |
| 56 | + data() { |
| 57 | + return { |
| 58 | + appStore: useAppStore(), |
| 59 | + settings: { |
| 60 | + showLeftPanel: true, |
| 61 | + generateQuery: true, |
| 62 | + }, |
| 63 | + } |
| 64 | + }, |
| 65 | + computed: { |
| 66 | + sketch() { |
| 67 | + return this.appStore.sketch |
| 68 | + }, |
| 69 | + systemSettings() { |
| 70 | + return this.appStore.systemSettings |
| 71 | + }, |
| 72 | + userSettings() { |
| 73 | + return this.appStore.settings |
| 74 | + }, |
| 75 | + }, |
| 76 | + methods: { |
| 77 | + saveSettings() { |
| 78 | + ApiClient.saveUserSettings(this.settings) |
| 79 | + .then(() => this.appStore.updateUserSettings()) |
| 80 | + .catch((error) => { |
| 81 | + console.log(error) |
| 82 | + }) |
| 83 | + }, |
| 84 | + }, |
| 85 | + mounted() { |
| 86 | + this.settings = { ...this.userSettings } |
| 87 | + // Set default values when the users don't have any settings saved. |
| 88 | + if (this.settings && !Object.keys(this.settings).length) { |
| 89 | + this.settings = { ...DEFAULT_SETTINGS } |
| 90 | + this.saveSettings() |
| 91 | + } |
| 92 | + }, |
| 93 | +} |
| 94 | +</script> |
| 95 | + |
| 96 | +<style scoped> |
| 97 | +.example { |
| 98 | + color: red; |
| 99 | +} |
| 100 | +</style> |
0 commit comments