Skip to content

Commit

Permalink
fixes to model manager view
Browse files Browse the repository at this point in the history
  • Loading branch information
greenmtnboy committed Mar 29, 2024
1 parent 12c00a5 commit 262029c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
16 changes: 5 additions & 11 deletions frontend/src/components/sidebar/ModelManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
<div v-else class="header">
No active model
</div>
<v-select theme="dark" variant="solo" density="compact"
class="minimal-select" v-model="selectedModel"
label="Change Connection Model" :items="models" item-title="name" @update:modelValue="changeConnectionModel">
<v-select theme="dark" variant="solo" density="compact" class="minimal-select" v-model="selectedModel"
label="Change Connection Model" :items="models" item-title="name"
@update:modelValue="changeConnectionModel">
</v-select>

<div class="connection-list py-0">
<v-expansion-panels theme="dark" variant="accordion">
<v-expansion-panel class="py-0">
<v-expansion-panel-title>
<div class="pl-4">Editor Sources</div>
<div class="pl-4">Editor Sources ({{ editors.length }})</div>
</v-expansion-panel-title>
<v-expansion-panel-text class="px-0">
<template v-if="activeModelFromConnection">
Expand All @@ -26,14 +26,8 @@
</template>
<div class="connection-list-item" v-else>No active model</div>
<div class="d-flex flex-column align-center pa-0">
<v-toolbar height="24" extension-height="24" class="sidebar-button-list">
<v-toolbar height="24" extension-height="24" class="sidebar-button-list align-center">
<AddEditorToModelPopup :model="activeModelFromConnection" />
<!-- <v-btn icon="mdi-format-align-left"></v-btn>
<v-btn density="compact" icon="mdi-format-align-center"></v-btn> -->
<!-- <v-btn @click="removeConnection(connection)" density="compact" icon="mdi-cancel"></v-btn>
<EditConnectionPopup :connection="connection" />
<RemoveConnectionPopup :connection="connection" />
<NewEditorPopup :defaultConnection="connection.name" /> -->
</v-toolbar>
</div>
</v-expansion-panel-text>
Expand Down
29 changes: 20 additions & 9 deletions frontend/src/components/sidebar/model/AddEditorToModelPopup.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@


<template>
<v-dialog v-model="dialog" max-width="500" min-width=400>
<template v-slot:activator="{ props }">
<v-btn class="tab-btn pa-0 ba-0" v-bind="props" density="compact" icon="mdi-plus"
<v-btn class="sidebar-action-button pa-0 ba-0" v-bind="props" density="compact" icon="mdi-plus"
v-shortkey.once="['ctrl', 'n']" @shortkey="showPopup()">
+
</v-btn>
Expand All @@ -15,7 +13,7 @@
</v-text-field>
<v-divider />
<v-select variant="solo" density="compact" :readonly="loading" v-model="editor" label="Editor"
:rules="[required]" :items="editors" item-title="name">
:items="editors" item-title="name">
</v-select>
</v-container>
<v-divider></v-divider>
Expand Down Expand Up @@ -65,20 +63,33 @@ export default {
model: [Model, LocalModel],
},
computed: {
...mapGetters(['editors']),
},
mounted: () => {
// console.log(this.connections)
...mapGetters(['editors', 'activeEditor', 'getConnectionByName',]),
},
methods: {
...mapActions(['addEditorToModel']),
...mapActions(['addEditorToModel', 'newEditor']),
showPopup() {
this.dialog = true;
},
submit() {
this.localAddEditorToModel();
},
localAddEditorToModel() {
// create it with alias name if not exist
let local = this;
if (!this.editor) {
const fullConnection = local.getConnectionByName(local.activeEditor.connection)
local.newEditor({
name: local.name,
connection: fullConnection,
syntax: 'preql',
}).then(() => {
local.editor = local.name
return localAddEditortoModel()
})
}
//otherwise add
this.addEditorToModel({
alias: this.name,
editor: this.editor,
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/store/modules/editors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ const mutations = {
},
newEditor(state, data) {
let newEd: Editor | RawEditor | null = null
if (!data.name) {
throw Error('Editor name is required')
}
if (data.syntax === 'preql') {
newEd = new Editor(data.name, data.connection.type, data.connection.name,);
}
Expand Down

0 comments on commit 262029c

Please sign in to comment.