Browse Source

fix: Added loader for api

pull/6560/head
Muhammed Mustafa 1 year ago
parent
commit
b5258454ac
  1. 18
      packages/nc-gui/components/smartsheet/Details.vue
  2. 40
      packages/nc-gui/components/smartsheet/details/Api.vue

18
packages/nc-gui/components/smartsheet/Details.vue

@ -1,4 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { LoadingOutlined } from '@ant-design/icons-vue'
const { openedViewsTab } = storeToRefs(useViewsStore()) const { openedViewsTab } = storeToRefs(useViewsStore())
const { onViewsTabChange } = useViewsStore() const { onViewsTabChange } = useViewsStore()
@ -8,6 +10,17 @@ const { $e } = useNuxtApp()
const { isUIAllowed } = useRoles() const { isUIAllowed } = useRoles()
const { base } = storeToRefs(useBase())
const meta = inject(MetaInj, ref())
const view = inject(ActiveViewInj, ref())
const indicator = h(LoadingOutlined, {
style: {
fontSize: '2rem',
},
spin: true,
})
const openedSubTab = computed({ const openedSubTab = computed({
get() { get() {
return openedViewsTab.value return openedViewsTab.value
@ -66,7 +79,10 @@ watch(openedSubTab, () => {
<div>{{ $t('labels.apis') }}</div> <div>{{ $t('labels.apis') }}</div>
</div> </div>
</template> </template>
<SmartsheetDetailsApi /> <SmartsheetDetailsApi v-if="base && meta && view" />
<div v-else class="h-full w-full flex flex-col justify-center items-center mt-28 mb-4">
<a-spin size="large" :indicator="indicator" />
</div>
</a-tab-pane> </a-tab-pane>
<a-tab-pane v-if="isUIAllowed('hookList')" key="webhook"> <a-tab-pane v-if="isUIAllowed('hookList')" key="webhook">

40
packages/nc-gui/components/smartsheet/details/Api.vue

@ -1,5 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import HTTPSnippet from 'httpsnippet' import HTTPSnippet from 'httpsnippet'
import { LoadingOutlined } from '@ant-design/icons-vue'
import { import {
ActiveViewInj, ActiveViewInj,
MetaInj, MetaInj,
@ -31,6 +33,13 @@ const { xWhere } = useSmartsheetStoreOrThrow()
const { queryParams } = useViewData(meta, view, xWhere) const { queryParams } = useViewData(meta, view, xWhere)
const indicator = h(LoadingOutlined, {
style: {
fontSize: '2rem',
},
spin: true,
})
const { copy } = useCopy() const { copy } = useCopy()
const langs = [ const langs = [
@ -75,7 +84,7 @@ const selectedLangName = ref(langs[0].name)
const apiUrl = computed( const apiUrl = computed(
() => () =>
new URL( new URL(
`/api/v1/data/noco/${base.value.id}/${meta.value?.title}/views/${view.value?.title}`, `/api/v1/data/noco/${base.value?.id}/${meta.value?.title}/views/${view.value?.title}`,
(appInfo.value && appInfo.value.ncSiteUrl) || '/', (appInfo.value && appInfo.value.ncSiteUrl) || '/',
).href, ).href,
) )
@ -109,7 +118,7 @@ const api = new Api({
api.dbViewRow.list( api.dbViewRow.list(
"noco", "noco",
${JSON.stringify(base.value.title)}, ${JSON.stringify(base.value?.title)},
${JSON.stringify(meta.value?.title)}, ${JSON.stringify(meta.value?.title)},
${JSON.stringify(view.value?.title)}, ${JSON.stringify(queryParams.value, null, 4)}).then(function (data) { ${JSON.stringify(view.value?.title)}, ${JSON.stringify(queryParams.value, null, 4)}).then(function (data) {
console.log(data); console.log(data);
@ -180,16 +189,23 @@ watch(activeLang, (newLang) => {
</NcButton> </NcButton>
</div> </div>
<LazyMonacoEditor <Suspense>
class="border-1 border-gray-200 py-4 rounded-lg" <MonacoEditor
style="height: calc(100vh - (var(--topbar-height) * 2) - 8rem)" class="border-1 border-gray-200 py-4 rounded-lg"
:model-value="code" style="height: calc(100vh - (var(--topbar-height) * 2) - 8rem)"
:read-only="true" :model-value="code"
lang="typescript" :read-only="true"
:validate="false" lang="typescript"
:disable-deep-compare="true" :validate="false"
hide-minimap :disable-deep-compare="true"
/> hide-minimap
/>
<template #fallback>
<div class="h-full w-full flex flex-col justify-center items-center mt-28">
<a-spin size="large" :indicator="indicator" />
</div>
</template>
</Suspense>
</a-tab-pane> </a-tab-pane>
</NcTabs> </NcTabs>
</div> </div>

Loading…
Cancel
Save