Browse Source

[Fix-8615][UI Next][V1.0.0-Alpha] Fix resource manage file edit page blank bug (#8631)

3.0.0/version-upgrade
Devosend 3 years ago committed by GitHub
parent
commit
18c384c60a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      dolphinscheduler-ui-next/src/service/modules/resources/index.ts
  2. 8
      dolphinscheduler-ui-next/src/service/modules/resources/types.ts
  3. 2
      dolphinscheduler-ui-next/src/views/resource/file/create/index.tsx
  4. 34
      dolphinscheduler-ui-next/src/views/resource/file/edit/index.tsx
  5. 5
      dolphinscheduler-ui-next/src/views/resource/file/edit/use-edit.ts

5
dolphinscheduler-ui-next/src/service/modules/resources/index.ts

@ -223,7 +223,10 @@ export function updateResourceContent(data: ContentReq, id: number): any {
})
}
export function viewResource(params: ViewResourceReq, id: number): any {
export function viewResource(
params: ViewResourceReq,
id: number
): ResourceViewRes {
return axios({
url: `/resources/${id}/view`,
method: 'get',

8
dolphinscheduler-ui-next/src/service/modules/resources/types.ts

@ -113,6 +113,11 @@ interface ResourceListRes {
totalList: ResourceFile[]
}
interface ResourceViewRes {
alias: string
content: string
}
export {
FileReq,
ResourceTypeReq,
@ -131,5 +136,6 @@ export {
ViewResourceReq,
ResourceIdReq,
UdfFuncReq,
ResourceListRes
ResourceListRes,
ResourceViewRes
}

2
dolphinscheduler-ui-next/src/views/resource/file/create/index.tsx

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { defineComponent, ref, toRefs } from 'vue'
import { defineComponent, toRefs } from 'vue'
import { useRouter } from 'vue-router'
import { NForm, NFormItem, NInput, NSelect, NButton } from 'naive-ui'
import { useI18n } from 'vue-i18n'

34
dolphinscheduler-ui-next/src/views/resource/file/edit/index.tsx

@ -15,46 +15,46 @@
* limitations under the License.
*/
import { useRouter } from 'vue-router'
import { defineComponent, onMounted, ref, toRefs } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { defineComponent, toRefs, watch } from 'vue'
import { NButton, NForm, NFormItem, NSpace } from 'naive-ui'
import { useI18n } from 'vue-i18n'
import Card from '@/components/card'
import MonacoEditor from '@/components/monaco-editor'
import { useForm } from './use-form'
import { useEdit } from './use-edit'
import styles from '../index.module.scss'
import type { Router } from 'vue-router'
export default defineComponent({
name: 'ResourceFileEdit',
setup() {
const router: Router = useRouter()
const route = useRoute()
const router = useRouter()
const resourceViewRef = ref()
const routeNameRef = ref(router.currentRoute.value.name)
const idRef = ref(Number(router.currentRoute.value.params.id))
const componentName = route.name
const fileId = Number(route.params.id)
const { state } = useForm()
const { getResourceView, handleUpdateContent } = useEdit(state)
const handleFileContent = () => {
state.fileForm.content = resourceViewRef.value.content
handleUpdateContent(idRef.value)
handleUpdateContent(fileId)
}
const handleReturn = () => {
router.go(-1)
}
onMounted(() => {
resourceViewRef.value = getResourceView(idRef.value)
})
const resourceViewRef = getResourceView(fileId)
watch(
() => resourceViewRef.value.content,
() => (state.fileForm.content = resourceViewRef.value.content)
)
return {
idRef,
routeNameRef,
componentName,
resourceViewRef,
handleReturn,
handleFileContent,
@ -67,7 +67,7 @@ export default defineComponent({
<Card title={t('resource.file.file_details')}>
<div class={styles['file-edit-content']}>
<h2>
<span>{this.resourceViewRef.value?.alias}</span>
<span>{this.resourceViewRef.alias}</span>
</h2>
<NForm
rules={this.rules}
@ -77,11 +77,11 @@ export default defineComponent({
<NFormItem path='content'>
<div style={{ width: '90%' }}>
<MonacoEditor
v-model={[this.resourceViewRef.value.content, 'value']}
v-model={[this.resourceViewRef.content, 'value']}
/>
</div>
</NFormItem>
{this.routeNameRef === 'resource-file-edit' && (
{this.componentName === 'resource-file-edit' && (
<NSpace>
<NButton
type='info'

5
dolphinscheduler-ui-next/src/views/resource/file/edit/use-edit.ts

@ -33,7 +33,10 @@ export function useEdit(state: any) {
skipLineNum: 0,
limit: 3000
}
const { state } = useAsyncState(viewResource(params, id), {})
const { state } = useAsyncState(viewResource(params, id), {
alias: '',
content: ''
})
return state
}

Loading…
Cancel
Save