-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c68c02
commit 52ff64a
Showing
8 changed files
with
239 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,50 @@ | ||
import {defineStore} from "pinia"; | ||
import {ApiService} from "../api/ApiService.ts"; | ||
|
||
export interface Variable { | ||
key: string | ||
value: string | ||
} | ||
|
||
|
||
export const useVarsStore = defineStore({ | ||
id: 'vars', | ||
state: () => ({ | ||
vars: new Map<string, Map<string, string>>, | ||
loadings: {} | ||
vars: new Map<string, Variable[]>, | ||
loadings: { | ||
load: false | ||
} | ||
}), | ||
getters: {}, | ||
getters: { | ||
getByProject: state => { | ||
return (project: string) => { | ||
const vars = state.vars.get(project) | ||
return vars ? vars : [] | ||
} | ||
}, | ||
}, | ||
actions: { | ||
async load(project: string | undefined) { | ||
if (!project) return {} | ||
const vars = this.vars.get(project) | ||
if (vars) { | ||
return vars | ||
} | ||
const loadVars = await ApiService.post<Map<string, string>>('/api/vars/load', {project: project}) | ||
this.loadings.load = true | ||
const loadVars = await ApiService.post<Variable[]>('/api/vars/load', {project: project}) | ||
this.vars.set(project, loadVars) | ||
this.loadings.load = false | ||
return loadVars | ||
}, | ||
async change(project: string, key: string, value: string) { | ||
await ApiService.post('/api/vars/change', {project: project, key: key, value: value}) | ||
}, | ||
async remove(project: string, key: string) { | ||
await ApiService.post('/api/vars/remove', {project: project, key: key}) | ||
await this.load(project) | ||
}, | ||
async create(project: string, key: string, value: string) { | ||
await ApiService.post('/api/vars/create', {project: project, key: key, value: value}) | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
<script lang="ts"> | ||
import {defineComponent} from 'vue' | ||
import {useVarsStore} from "../../stores/vars.store.ts"; | ||
import ProjectMainView from "./ProjectMainLayout.vue"; | ||
import {cropText} from "../Utils.ts"; | ||
import InputList from "../Tables/Edit/InputList.vue"; | ||
import RemoveButton from "../Tables/Edit/Components/RemoveButton.vue"; | ||
import {FontAwesomeIcon} from "@fortawesome/vue-fontawesome"; | ||
export default defineComponent({ | ||
name: "ProjectVarView", | ||
components: {FontAwesomeIcon, RemoveButton, InputList, ProjectMainView}, | ||
props: { | ||
project: { | ||
type: String, | ||
required: true | ||
} | ||
}, | ||
setup() { | ||
const varsStore = useVarsStore() | ||
return { | ||
varsStore | ||
} | ||
}, | ||
data() { | ||
return { | ||
headers: [ | ||
{title: 'Key', key: 'key'}, | ||
{title: 'Value', key: 'value'}, | ||
{title: 'Action', value: 'actions'} | ||
], | ||
newVar: { | ||
key: '', | ||
value: '' | ||
}, | ||
loadingSave: false | ||
} | ||
}, | ||
methods: { | ||
cropText, | ||
async save(isActive: any) { | ||
this.loadingSave = true | ||
await this.varsStore.create(this.project, this.newVar.key, this.newVar.value) | ||
this.loadingSave = false | ||
isActive.value = false | ||
}, | ||
async change(key: string, value: string) { | ||
this.loadingSave = true | ||
await this.varsStore.change(this.project, key, value) | ||
this.loadingSave = false | ||
} | ||
} | ||
}) | ||
</script> | ||
|
||
<template> | ||
<ProjectMainView :project="project"> | ||
<VDataTable | ||
:headers="headers" | ||
:items="varsStore.getByProject(project)" | ||
density="compact" | ||
variant="outlined" | ||
:loading="varsStore.loadings.load" | ||
> | ||
<template v-slot:top> | ||
<VToolbar | ||
flat | ||
color="transparent" | ||
density="compact" | ||
> | ||
<VToolbarTitle>Variables {{ project }}</VToolbarTitle> | ||
<VDialog> | ||
<template v-slot:activator="{ props: activatorProps }"> | ||
<VBtn | ||
variant="outlined" | ||
dark | ||
text="New Item" | ||
v-bind="activatorProps" | ||
/> | ||
</template> | ||
<template v-slot:default="{ isActive }"> | ||
<VCard> | ||
<VCardText> | ||
<VRow> | ||
<VTextField v-model="newVar.key" label="Key"/> | ||
</VRow> | ||
<VRow> | ||
<VTextarea v-model="newVar.value" label="Value"/> | ||
</VRow> | ||
<VRow> | ||
<VBtn :loading="loadingSave" class="mr-2" color="success" text="Save" @click.prevent="save(isActive)"/> | ||
</VRow> | ||
</VCardText> | ||
</VCard> | ||
</template> | ||
</VDialog> | ||
</VToolbar> | ||
</template> | ||
<template v-slot:loading> | ||
<VSkeletonLoader type="table-row@5"></VSkeletonLoader> | ||
</template> | ||
<template v-slot:item.value="{ item }"> | ||
{{ cropText(item.value!) }} | ||
</template> | ||
<template v-slot:item.actions="{ item }"> | ||
<VDialog> | ||
<template v-slot:activator="{ props: activatorProps }"> | ||
<FontAwesomeIcon class="pointer" style="margin-right: 0.5rem" icon="fa-pen" v-bind="activatorProps"/> | ||
</template> | ||
<template v-slot:default="{ isActive }"> | ||
<VCard> | ||
<VCardText> | ||
<VRow> | ||
<VTextField v-model="item.key" label="Key"/> | ||
</VRow> | ||
<VRow> | ||
<VTextarea v-model="item.value" label="Value"/> | ||
</VRow> | ||
<VRow> | ||
<VBtn :loading="loadingSave" class="mr-2" color="success" text="Save" | ||
@click.prevent="change(item.key, item.value!)"/> | ||
</VRow> | ||
</VCardText> | ||
</VCard> | ||
</template> | ||
</VDialog> | ||
<RemoveButton variant="icon" :text="cropText(item.value!)" | ||
:remove="() => varsStore.remove(project, item.key)"/> | ||
</template> | ||
</VDataTable> | ||
</ProjectMainView> | ||
</template> | ||
|
||
<style scoped> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters