Browse Source

chore: linting

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/2716/head
Pranav C 2 years ago
parent
commit
1d04b8dd29
  1. 98
      packages/nc-gui-v2/components/editable-cell/Attachment.vue
  2. 0
      packages/nc-gui-v2/components/editable-cell/TextAreaCell.vue
  3. 98
      packages/nc-gui-v2/components/editable-cell/TextAreaCellOld.vue
  4. 13
      packages/nc-gui-v2/composables/useAttachment.ts
  5. 30
      packages/nc-gui-v2/pages/projects/create-external.vue

98
packages/nc-gui-v2/components/editable-cell/Attachment.vue

@ -1,50 +1,50 @@
<script setup lang="ts">
import { useNuxtApp } from "#app";
import { useNuxt } from "@nuxt/kit";
import { inject, watchEffect } from "@vue/runtime-core";
import { ColumnType, TableType } from "nocodb-sdk";
import { Ref } from "vue";
import { useToast } from "vue-toastification";
import useProject from "~/composables/useProject";
import { useNuxt } from '@nuxt/kit'
import { inject, watchEffect } from '@vue/runtime-core'
import type { ColumnType, TableType } from 'nocodb-sdk'
import type { Ref } from 'vue'
import { useToast } from 'vue-toastification'
import { useNuxtApp } from '#app'
import useProject from '~/composables/useProject'
// import FileSaver from "file-saver";
import { isImage } from "~/utils/fileUtils";
import MaterialPlusIcon from "~icons/mdi/plus";
import MaterialArrowExpandIcon from "~icons/mdi/arrow-expand";
import { isImage } from '~/utils/fileUtils'
import MaterialPlusIcon from '~icons/mdi/plus'
import MaterialArrowExpandIcon from '~icons/mdi/arrow-expand'
const { modelValue } = defineProps<{ modelValue: string | Array<any> }>();
const emit = defineEmits(["update:modelValue"]);
const { modelValue } = defineProps<{ modelValue: string | Array<any> }>()
const emit = defineEmits(['update:modelValue'])
const isPublicForm = inject<boolean>("isPublicForm", false);
const isForm = inject<boolean>("isForm", false);
const meta = inject<Ref<TableType>>("meta");
const column = inject<ColumnType>("column");
const isPublicForm = inject<boolean>('isPublicForm', false)
const isForm = inject<boolean>('isForm', false)
const meta = inject<Ref<TableType>>('meta')
const column = inject<ColumnType>('column')
const localFilesState = reactive([]);
const attachments = ref([]);
const uploading = ref(false);
const fileInput = ref<HTMLInputElement>();
const localFilesState = reactive([])
const attachments = ref([])
const uploading = ref(false)
const fileInput = ref<HTMLInputElement>()
const { $api } = useNuxtApp();
const { project } = useProject();
const toast = useToast();
const { $api } = useNuxtApp()
const { project } = useProject()
const toast = useToast()
watchEffect(() => {
if (modelValue) {
attachments.value = ((typeof modelValue === "string" ? JSON.parse(modelValue) : modelValue) || []).filter(Boolean);
attachments.value = ((typeof modelValue === 'string' ? JSON.parse(modelValue) : modelValue) || []).filter(Boolean)
}
});
})
const selectImage = (file: any, i) => {
// todo: implement
};
}
const openUrl = (url: string, target = "_blank") => {
window.open(url, target);
};
const openUrl = (url: string, target = '_blank') => {
window.open(url, target)
}
const addFile = () => {
fileInput.value?.click();
};
fileInput.value?.click()
}
const onFileSelection = async (e) => {
// if (this.isPublicGrid) {
@ -72,31 +72,32 @@ const onFileSelection = async (e) => {
// }
// todo : move to com
uploading.value = true;
const newAttachments = [];
uploading.value = true
const newAttachments = []
for (const file of fileInput.value?.files ?? []) {
try {
const data = await $api.storage.upload(
{
path: ["noco", project.value.title, meta?.value?.title, column?.title].join("/")
}, {
path: ['noco', project.value.title, meta?.value?.title, column?.title].join('/'),
},
{
files: file,
json: "{}"
}
);
newAttachments.push(...data);
json: '{}',
},
)
newAttachments.push(...data)
} catch (e: any) {
toast.error((e.message) || "Some internal error occurred");
uploading.value = false;
return;
toast.error(e.message || 'Some internal error occurred')
uploading.value = false
return
}
}
uploading.value = false;
emit("update:modelValue", JSON.stringify([...attachments.value, ...newAttachments]));
uploading.value = false
emit('update:modelValue', JSON.stringify([...attachments.value, ...newAttachments]))
// this.$emit('input', JSON.stringify(this.localState))
// this.$emit('update')
};
}
</script>
<template>
@ -130,13 +131,10 @@ const onFileSelection = async (e) => {
<!-- <template #placeholder> -->
<!-- <v-skeleton-loader type="image" :height="active ? 33 : 22" :width="active ? 33 : 22" /> -->
<!-- </template> -->
<v-icon v-else-if="item.icon" :size="active ? 33 : 22" v-on="on"
@click="openUrl(item.url || item.data, '_blank')">
<v-icon v-else-if="item.icon" :size="active ? 33 : 22" v-on="on" @click="openUrl(item.url || item.data, '_blank')">
{{ item.icon }}
</v-icon>
<v-icon v-else :size="active ? 33 : 22" v-on="on" @click="openUrl(item.url || item.data, '_blank')">
mdi-file
</v-icon>
<v-icon v-else :size="active ? 33 : 22" v-on="on" @click="openUrl(item.url || item.data, '_blank')"> mdi-file </v-icon>
<!-- </template> -->
<!-- <span>{{ item.title }}</span> -->
<!-- </v-tooltip> -->

0
packages/nc-gui-v2/components/editable-cell/TextAreaCell.vue

98
packages/nc-gui-v2/components/editable-cell/TextAreaCellOld.vue

@ -1,98 +0,0 @@
<script>
export default {
name: 'TextAreaCell',
props: {
value: String,
isForm: Boolean,
},
data: () => ({
localState: '',
}),
computed: {
parentListeners() {
const $listeners = {}
if (this.$listeners.blur) {
$listeners.blur = this.$listeners.blur
}
if (this.$listeners.focus) {
$listeners.focus = this.$listeners.focus
}
return $listeners
},
},
watch: {
value(val) {
this.localState = val
},
localState(val) {
if (this.isForm) {
this.$emit('input', val)
}
},
},
created() {
this.localState = this.value
},
mounted() {
this.$refs.textarea && this.$refs.textarea.focus()
},
methods: {
save() {
this.$emit('input', this.localState)
},
},
}
</script>
<template>
<div>
<div v-if="!isForm" class="d-flex ma-1">
<v-spacer />
<v-btn v-if="!isForm" outlined x-small class="mr-1" @click="$emit('cancel')">
<!-- Cancel -->
{{ $t('general.cancel') }}
</v-btn>
<v-btn v-if="!isForm" x-small color="primary" @click="save">
<!-- Save -->
{{ $t('general.save') }}
</v-btn>
</div>
<textarea ref="textarea" v-model="localState" rows="3" v-on="parentListeners" @input="isForm && save()" @keydown.stop.enter />
</div>
</template>
<style scoped>
input,
textarea {
width: 100%;
min-height: 60px;
height: calc(100% - 28px);
color: var(--v-textColor-base);
}
</style>
<!--
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-->

13
packages/nc-gui-v2/composables/useAttachment.ts

@ -1,14 +1,9 @@
// todo:
export default () => {
const localFilesState = reactive([]);
const attachments = ref([]);
const localFilesState = reactive([])
const attachments = ref([])
const uploadFile = () => {}
const uploadFile = () => {
};
return { uploadFile, localFilesState, attachments };
return { uploadFile, localFilesState, attachments }
}

30
packages/nc-gui-v2/pages/projects/create-external.vue

@ -140,7 +140,7 @@ const testConnection = async () => {
<v-text-field v-model="projectDatasource.connection.database" density="compact" label="Database name" />
</v-col>
<!-- <v-col cols="6">
<!-- <v-col cols="6">
<v-text-field
v-model="inflection.tableName"
density="compact"
@ -155,22 +155,22 @@ const testConnection = async () => {
label="Database name"
/>
</v-col> -->
</v-row>
</v-container>
<div class="d-flex justify-center" style="gap: 4px">
<v-btn :disabled="!testSuccess" large :loading="loading" color="primary" @click="createProject">
<MaterialSymbolsRocketLaunchOutline class="mr-1" />
<span> {{ $t('general.create') }} </span>
</v-btn>
<!-- <v-btn small class="px-2">-->
<!-- todo:implement test connection -->
<!-- <v-btn size="sm" class="text-sm text-capitalize">
</v-row>
</v-container>
<div class="d-flex justify-center" style="gap: 4px">
<v-btn :disabled="!testSuccess" large :loading="loading" color="primary" @click="createProject">
<MaterialSymbolsRocketLaunchOutline class="mr-1" />
<span> {{ $t('general.create') }} </span>
</v-btn>
<!-- <v-btn small class="px-2"> -->
<!-- todo:implement test connection -->
<!-- <v-btn size="sm" class="text-sm text-capitalize">
&lt;!&ndash; Test Database Connection &ndash;&gt;
{{ $t('activity.testDbConn') }}
</v-btn>-->
</div>
</v-btn> -->
</div>
</v-card>
</v-form>
</v-container>

Loading…
Cancel
Save