feat: azure search module + rebuild index
This commit is contained in:
@@ -104,6 +104,7 @@
|
||||
router-view
|
||||
|
||||
nav-footer
|
||||
search-results
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
@@ -28,6 +28,7 @@
|
||||
:key='engine.key'
|
||||
:label='engine.title'
|
||||
:value='engine.key'
|
||||
:disabled='!engine.isAvailable'
|
||||
color='primary'
|
||||
hide-details
|
||||
)
|
||||
@@ -87,6 +88,7 @@ import _ from 'lodash'
|
||||
|
||||
import enginesQuery from 'gql/admin/search/search-query-engines.gql'
|
||||
import enginesSaveMutation from 'gql/admin/search/search-mutation-save-engines.gql'
|
||||
import enginesRebuildMutation from 'gql/admin/search/search-mutation-rebuild-index.gql'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@@ -101,7 +103,7 @@ export default {
|
||||
this.engine = _.find(this.engines, ['key', newValue]) || {}
|
||||
},
|
||||
engines(newValue, oldValue) {
|
||||
this.selectedEngine = 'db'
|
||||
this.selectedEngine = _.get(_.find(this.engines, 'isEnabled'), 'key', 'db')
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -115,29 +117,50 @@ export default {
|
||||
},
|
||||
async save() {
|
||||
this.$store.commit(`loadingStart`, 'admin-search-saveengines')
|
||||
await this.$apollo.mutate({
|
||||
mutation: enginesSaveMutation,
|
||||
variables: {
|
||||
engines: this.engines.map(tgt => _.pick(tgt, [
|
||||
'isEnabled',
|
||||
'key',
|
||||
'config'
|
||||
])).map(str => ({...str, config: str.config.map(cfg => ({...cfg, value: JSON.stringify({ v: cfg.value.value })}))}))
|
||||
try {
|
||||
const resp = await this.$apollo.mutate({
|
||||
mutation: enginesSaveMutation,
|
||||
variables: {
|
||||
engines: this.engines.map(tgt => ({
|
||||
isEnabled: tgt.key === this.selectedEngine,
|
||||
key: tgt.key,
|
||||
config: tgt.config.map(cfg => ({...cfg, value: JSON.stringify({ v: cfg.value.value })}))
|
||||
}))
|
||||
}
|
||||
})
|
||||
if (_.get(resp, 'data.search.updateSearchEngines.responseResult.succeeded', false)) {
|
||||
this.$store.commit('showNotification', {
|
||||
message: 'Search engine configuration saved successfully.',
|
||||
style: 'success',
|
||||
icon: 'check'
|
||||
})
|
||||
} else {
|
||||
throw new Error(_.get(resp, 'data.search.updateSearchEngines.responseResult.message', 'An unexpected error occured'))
|
||||
}
|
||||
})
|
||||
this.$store.commit('showNotification', {
|
||||
message: 'Search engine configuration saved successfully.',
|
||||
style: 'success',
|
||||
icon: 'check'
|
||||
})
|
||||
} catch (err) {
|
||||
this.$store.commit('pushGraphError', err)
|
||||
}
|
||||
this.$store.commit(`loadingStop`, 'admin-search-saveengines')
|
||||
},
|
||||
async rebuild () {
|
||||
this.$store.commit('showNotification', {
|
||||
style: 'indigo',
|
||||
message: `Coming soon...`,
|
||||
icon: 'directions_boat'
|
||||
})
|
||||
this.$store.commit(`loadingStart`, 'admin-search-rebuildindex')
|
||||
try {
|
||||
const resp = await this.$apollo.mutate({
|
||||
mutation: enginesRebuildMutation
|
||||
})
|
||||
if (_.get(resp, 'data.search.rebuildIndex.responseResult.succeeded', false)) {
|
||||
this.$store.commit('showNotification', {
|
||||
message: 'Index rebuilt successfully.',
|
||||
style: 'success',
|
||||
icon: 'check'
|
||||
})
|
||||
} else {
|
||||
throw new Error(_.get(resp, 'data.search.rebuildIndex.responseResult.message', 'An unexpected error occured'))
|
||||
}
|
||||
} catch (err) {
|
||||
this.$store.commit('pushGraphError', err)
|
||||
}
|
||||
this.$store.commit(`loadingStop`, 'admin-search-rebuildindex')
|
||||
}
|
||||
},
|
||||
apollo: {
|
||||
|
@@ -89,29 +89,38 @@
|
||||
v-model='searchAdvMenuShown'
|
||||
left
|
||||
offset-y
|
||||
min-width='350'
|
||||
min-width='450'
|
||||
:close-on-content-click='false'
|
||||
nudge-bottom='7'
|
||||
nudge-right='5'
|
||||
)
|
||||
v-btn.nav-header-search-adv(icon, outline, color='grey darken-2', slot='activator')
|
||||
v-icon(color='white') expand_more
|
||||
v-card
|
||||
v-toolbar(flat, :color='$vuetify.dark ? `grey darken-3-d5` : `grey lighten-4`', dense)
|
||||
v-card.radius-0(dark)
|
||||
v-toolbar(flat, color='grey darken-4', dense)
|
||||
v-icon.mr-2 search
|
||||
v-subheader.pl-0 Advanced Search
|
||||
v-card-text
|
||||
v-card-text.pa-4
|
||||
v-checkbox.mt-0(
|
||||
label='Restrict to Current Language'
|
||||
color='primary'
|
||||
color='white'
|
||||
v-model='searchRestrictLocale'
|
||||
hide-details
|
||||
)
|
||||
v-checkbox(
|
||||
label='Restrict to Below Current Path'
|
||||
color='primary'
|
||||
color='white'
|
||||
v-model='searchRestrictPath'
|
||||
hide-details
|
||||
)
|
||||
v-card-actions
|
||||
v-btn(outline, small, color='grey') Save as defaults
|
||||
v-divider
|
||||
v-card-actions.grey.darken-3-d4
|
||||
v-btn(depressed, color='grey darken-3', block)
|
||||
v-icon(left) chevron_right
|
||||
span Save as defaults
|
||||
v-btn(depressed, color='grey darken-3', block)
|
||||
v-icon(left) cached
|
||||
span Reset
|
||||
v-flex(xs6, :md4='searchIsShown', :md6='!searchIsShown')
|
||||
v-toolbar.nav-header-inner(color='black', dark, flat)
|
||||
v-spacer
|
||||
|
@@ -206,13 +206,13 @@ export default {
|
||||
|
||||
&-items {
|
||||
.highlighted {
|
||||
background-color: mc('blue', '50');
|
||||
background: #FFF linear-gradient(to bottom, #FFF, mc('orange', '100'));
|
||||
}
|
||||
}
|
||||
|
||||
&-suggestions {
|
||||
.highlighted {
|
||||
background-color: mc('blue', '500');
|
||||
background: transparent linear-gradient(to bottom, mc('blue', '500'), mc('blue', '700'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -103,6 +103,7 @@
|
||||
v-card.mt-3(light, v-html='diffHTML')
|
||||
|
||||
nav-footer
|
||||
search-results
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
@@ -23,6 +23,7 @@
|
||||
router-view
|
||||
|
||||
nav-footer
|
||||
search-results
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
@@ -16,6 +16,7 @@
|
||||
slot
|
||||
|
||||
nav-footer
|
||||
search-results
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
Reference in New Issue
Block a user