Skip to content

Commit

Permalink
fix #163
Browse files Browse the repository at this point in the history
  • Loading branch information
cars10 committed Oct 30, 2023
1 parent 3b0a16e commit fd186b6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
## 1.0.0-beta-6

* adds confirm when closing indices, fixes [#153][f153]
* link rest api docs to current version docs, fixes [#163][f163]
* fixes index table filter
* dependency updates

[f153]: https://github.com/cars10/elasticvue/issues/153
[f163]: https://github.com/cars10/elasticvue/issues/163

## 1.0.0-beta-5

Expand Down
22 changes: 9 additions & 13 deletions src/components/rest/RestQuery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<h1 class="text-h5 q-my-none">
{{ t('query.heading') }}
</h1>
<q-btn href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html"
<q-btn :href="`https://www.elastic.co/guide/en/elasticsearch/reference/${clusterMinor}/index.html`"
flat
class="q-ml-md"
icon="launch"
Expand Down Expand Up @@ -53,25 +53,18 @@
</template>

<script setup lang="ts">
import { Ref, ref, toRaw } from 'vue'
import { computed, Ref, ref, toRaw } from 'vue'
import { useIdbStore } from '../../db/Idb.ts'
import { useTranslation } from '../../composables/i18n'
import RestQueryExamples from './RestQueryExamples.vue'
import RestQueryHistoryList from './RestQueryHistoryList.vue'
import RestQuerySavedQueriesList from './RestQuerySavedQueriesList.vue'
import RestQueryFormTabs from './RestQueryFormTabs.vue'
import { IdbRestQueryTabRequest } from '../../db/types.ts'
import { useConnectionStore } from '../../store/connection.ts'
const migrateTabs = async () => {
const { restQueryTabs } = useIdbStore()
const tabs = await restQueryTabs.getAll()
for await (const tab of tabs) {
if (!tab.response) {
await restQueryTabs.update(Object.assign({}, toRaw(tab), { response: { status: '', ok: false, bodyText: '' } }))
}
}
}
migrateTabs()
const { activeCluster } = useConnectionStore()
const clusterMinor = computed(() => (activeCluster?.version?.split('.')?.slice(0, 2)?.join('.')))
const t = useTranslation()
const { restQueryTabs } = useIdbStore()
Expand All @@ -95,7 +88,10 @@
if (!activeTab) return
const { id, label, name } = activeTab
const obj = Object.assign({}, { id, label, name }, { request: toRaw(request), response: { status: '', ok: false, bodyText: '' } })
const obj = Object.assign({}, { id, label, name }, {
request: toRaw(request),
response: { status: '', ok: false, bodyText: '' }
})
await restQueryTabs.update(obj)
}
Expand Down
13 changes: 13 additions & 0 deletions src/services/VuexMigrator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { ConnectionState } from '../store/connection.ts'
import { ThemeState } from '../store/theme.ts'
import { I18nState } from '../store/i18n.ts'
import { useIdbStore } from '../db/Idb.ts'
import { toRaw } from 'vue'

type PiniaData = {
theme?: ThemeState
Expand Down Expand Up @@ -33,6 +35,16 @@ export const migrateVuexData = (data: string): PiniaData => {
return newData
}

const migrateTabs = async () => {
const { restQueryTabs } = useIdbStore()
const tabs = await restQueryTabs.getAll()
for await (const tab of tabs) {
if (!tab.response) {
await restQueryTabs.update(Object.assign({}, toRaw(tab), { response: { status: '', ok: false, bodyText: '' } }))
}
}
}

export const migrate = () => {
if (localStorage.getItem('connection')) return

Expand All @@ -43,4 +55,5 @@ export const migrate = () => {
Object.entries(migrated).forEach(([key, value]) => {
localStorage.setItem(key, JSON.stringify(value))
})
migrateTabs()
}

0 comments on commit fd186b6

Please sign in to comment.