-
Notifications
You must be signed in to change notification settings - Fork 164
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
Showing
18 changed files
with
492 additions
and
403 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
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,47 @@ | ||
<template> | ||
<q-card> | ||
<q-tabs v-model="activeTabName" align="left" outside-arrows> | ||
<template v-for="(tab, index) in restQueryTabs.all.value" :key="tab.name"> | ||
<q-tab :name="tab.name" style="white-space: nowrap; flex-shrink: 0"> | ||
<div class="flex"> | ||
{{ tab.label }} | ||
|
||
<q-btn icon="edit" flat dense size="sm"> | ||
<q-popup-edit v-slot="scope" v-model="tab.label" auto-save anchor="top left" | ||
@save="(v) => {updateTab(v, tab)}"> | ||
<q-input v-model="scope.value" dense autofocu outlined @keyup.enter="scope.set" /> | ||
</q-popup-edit> | ||
</q-btn> | ||
|
||
<q-btn icon="close" flat dense size="sm" @click.stop="removeTab(index as number)" /> | ||
</div> | ||
</q-tab> | ||
<q-separator vertical /> | ||
</template> | ||
<q-btn icon="add" flat style="height:48px;" @click="addTab" /> | ||
</q-tabs> | ||
|
||
<q-separator /> | ||
|
||
<q-tab-panels v-model="activeTabName"> | ||
<q-tab-panel v-for="tab in restQueryTabs.all.value" :key="`${tab.name}-panel`" :name="tab.name"> | ||
<rest-query-form :tab="tab" /> | ||
</q-tab-panel> | ||
</q-tab-panels> | ||
</q-card> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { onMounted } from 'vue' | ||
import RestQueryForm from './RestQueryForm.vue' | ||
import { useRestQueryTabs } from '../../composables/components/rest/RestQueryTabs.ts' | ||
import { useIdbStore } from '../../db/Idb.ts' | ||
const { restQueryTabs } = useIdbStore() | ||
onMounted(() => (restQueryTabs.reload())) | ||
const { activeTabName, addTab, updateTab, removeTab, setActiveTab, activeTabIndex } = useRestQueryTabs() | ||
setActiveTab() | ||
defineExpose({ addTab, activeTabIndex }) | ||
</script> |
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,62 @@ | ||
<template> | ||
<rest-query-list v-if="open" | ||
heading="History" | ||
:pagination-options="{sortBy: 'date', descending: true}" | ||
:data="restQueryHistory.all.value" | ||
:columns="columns" | ||
:searchable-columns="['method', 'path']" | ||
@use-request="(v: RestQueryRequestLike) => emit('useRequest', v)" | ||
@use-request-new-tab="(v: RestQueryRequestLike) => emit('useRequestNewTab', v)"> | ||
<template #default="{row}"> | ||
<td> | ||
<div class="q-py-xs"> | ||
<span :class="`http-${row.method}`" class="text-bold">{{ row.method }}</span> {{ row.path }} | ||
<div> | ||
<small class="text-muted ellipsis">{{ row.body.slice(0, 100).replace(/\s/g, '') }}</small> | ||
</div> | ||
</div> | ||
</td> | ||
<td class="small-wrap">{{ row.date?.toLocaleString() }}</td> | ||
<td class="small-wrap"> | ||
<q-btn-group> | ||
<q-btn icon="save" color="dark-grey" dense @click.stop="saveHistory(row)" /> | ||
<q-btn icon="delete" color="dark-grey" dense @click.stop="removeHistory(row.id)" /> | ||
</q-btn-group> | ||
</td> | ||
</template> | ||
</rest-query-list> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import RestQueryList from './RestQueryList.vue' | ||
import { useTranslation } from '../../composables/i18n.ts' | ||
import { useIdbStore } from '../../db/Idb.ts' | ||
import { onMounted } from 'vue' | ||
import { IdbRestQueryHistory } from '../../db/types.ts' | ||
defineProps<{ open: boolean }>() | ||
const emit = defineEmits<{ | ||
useRequest: [request: RestQueryRequestLike], | ||
useRequestNewTab: [request: RestQueryRequestLike] | ||
}>() | ||
const t = useTranslation() | ||
const { restQueryHistory, restQuerySavedQueries } = useIdbStore() | ||
onMounted(() => (restQueryHistory.reload())) | ||
const saveHistory = (row: IdbRestQueryHistory) => { | ||
const { method, path, body } = row | ||
restQuerySavedQueries.insert({ method, path, body }) | ||
} | ||
const removeHistory = (id: number) => (restQueryHistory.remove(id)) | ||
const columns = [ | ||
{ label: t('query.rest_query_history.table.headers.query'), field: 'query', name: 'query', align: 'left' }, | ||
{ | ||
label: t('query.rest_query_history.table.headers.timestamp'), field: 'date', name: 'date', align: 'left', | ||
sortOrder: 'da', sortable: true | ||
}, | ||
{ label: '' }, | ||
] | ||
</script> |
Oops, something went wrong.