mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
275 lines
7.4 KiB
275 lines
7.4 KiB
3 years ago
|
<template>
|
||
|
<v-container fluid class="textColor--text">
|
||
3 years ago
|
<v-form v-model="valid">
|
||
|
<template v-if="formDetails">
|
||
|
<div class="title d-flex align-center justify-center mb-4">
|
||
3 years ago
|
<div
|
||
|
v-if="plugin.logo"
|
||
|
:style="{ background : plugin.title === 'SES' ? '#242f3e' : '' }"
|
||
|
class="mr-1 d-flex align-center justify-center"
|
||
|
:class="{ 'pa-2' : plugin.title === 'SES'}"
|
||
|
>
|
||
3 years ago
|
<img
|
||
3 years ago
|
:src="plugin.logo"
|
||
|
height="25"
|
||
|
>
|
||
3 years ago
|
</div>
|
||
|
<v-icon
|
||
3 years ago
|
v-else-if="plugin.icon"
|
||
|
color="#242f3e"
|
||
|
size="30"
|
||
|
class="mr-1"
|
||
|
>
|
||
|
{{ plugin.icon }}
|
||
3 years ago
|
</v-icon>
|
||
|
|
||
|
<span @dblclick="copyDefault">{{ formDetails.title }}</span>
|
||
3 years ago
|
</div>
|
||
|
|
||
3 years ago
|
<v-divider class="mb-7" />
|
||
3 years ago
|
<div v-if="formDetails.array">
|
||
3 years ago
|
<table class="form-table mx-auto">
|
||
3 years ago
|
<thead>
|
||
3 years ago
|
<tr>
|
||
|
<th v-for="(item,i) in formDetails.items" :key="i">
|
||
|
<label class="caption ">{{ item.label }} <span v-if="item.required" class="red--text">*</span></label>
|
||
|
</th>
|
||
|
</tr>
|
||
3 years ago
|
</thead>
|
||
|
<tbody>
|
||
3 years ago
|
<tr v-for="(set,j) in settings" :key="j">
|
||
|
<td v-for="(item,i) in formDetails.items" :key="i">
|
||
|
<form-input v-model="set[item.key]" :input-details="item" />
|
||
|
</td>
|
||
|
<td v-if="j">
|
||
|
<x-icon small icon-class="pointer" color="error" @click="settings.splice(j,1)">
|
||
|
mdi-delete-outline
|
||
|
</x-icon>
|
||
|
</td>
|
||
|
</tr>
|
||
3 years ago
|
|
||
3 years ago
|
<tr>
|
||
|
<td :colspan="formDetails.items.length" class="text-center">
|
||
|
<x-icon icon-class="pointer" @click="settings.push({})">
|
||
|
mdi-plus
|
||
|
</x-icon>
|
||
|
</td>
|
||
|
</tr>
|
||
3 years ago
|
</tbody>
|
||
|
</table>
|
||
|
</div>
|
||
3 years ago
|
|
||
3 years ago
|
<div v-else class="d-flex justify-center">
|
||
|
<div class="form-grid">
|
||
|
<template v-for="(item,i) in formDetails.items">
|
||
|
<div :key="i" class="text-right form-input-label">
|
||
|
<label class="caption ">{{ item.label }} <span v-if="item.required" class="red--text">*</span></label>
|
||
|
</div>
|
||
|
<div :key="i">
|
||
3 years ago
|
<form-input v-model="settings[item.key]" :input-details="item" />
|
||
3 years ago
|
</div>
|
||
|
</template>
|
||
|
</div>
|
||
3 years ago
|
</div>
|
||
|
<div class="d-flex mb-4 mt-7 justify-center">
|
||
3 years ago
|
<v-btn
|
||
|
v-for="action in formDetails.actions"
|
||
|
:key="action.key"
|
||
|
small
|
||
|
:outlined="action.key !== 'save'"
|
||
|
:color="action.key === 'save' ? 'primary' : '' "
|
||
|
:disabled="(action.key === 'save' && !valid) || (action.key === 'test' && testing)"
|
||
|
:loading="action.key === 'test' && testing"
|
||
|
@click="doAction(action)"
|
||
|
>
|
||
|
{{ action.label }}
|
||
3 years ago
|
</v-btn>
|
||
|
</div>
|
||
|
</template>
|
||
|
</v-form>
|
||
3 years ago
|
</v-container>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
3 years ago
|
import FormInput from '@/components/project/appStore/FormInput'
|
||
3 years ago
|
|
||
|
export default {
|
||
3 years ago
|
name: 'AppInstall',
|
||
|
components: { FormInput },
|
||
3 years ago
|
props: ['id', 'defaultConfig'],
|
||
3 years ago
|
data: () => ({
|
||
|
plugin: null,
|
||
|
formDetails: null,
|
||
|
settings: null,
|
||
|
pluginId: null,
|
||
3 years ago
|
// title: null,
|
||
3 years ago
|
valid: null,
|
||
|
testing: false
|
||
3 years ago
|
}),
|
||
3 years ago
|
watch: {
|
||
3 years ago
|
async id() {
|
||
3 years ago
|
this.settings = {}
|
||
|
await this.readPluginDetails()
|
||
|
}
|
||
|
},
|
||
3 years ago
|
async created() {
|
||
3 years ago
|
await this.readPluginDetails()
|
||
|
},
|
||
3 years ago
|
methods: {
|
||
3 years ago
|
simpleAnim() {
|
||
3 years ago
|
const count = 200
|
||
|
const defaults = {
|
||
|
origin: { y: 0.7 }
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
function fire(particleRatio, opts) {
|
||
3 years ago
|
window.confetti(Object.assign({}, defaults, opts, {
|
||
|
particleCount: Math.floor(count * particleRatio)
|
||
3 years ago
|
}))
|
||
3 years ago
|
}
|
||
|
|
||
|
fire(0.25, {
|
||
|
spread: 26,
|
||
3 years ago
|
startVelocity: 55
|
||
|
})
|
||
3 years ago
|
fire(0.2, {
|
||
3 years ago
|
spread: 60
|
||
|
})
|
||
3 years ago
|
fire(0.35, {
|
||
|
spread: 100,
|
||
|
decay: 0.91,
|
||
|
scalar: 0.8
|
||
3 years ago
|
})
|
||
3 years ago
|
fire(0.1, {
|
||
|
spread: 120,
|
||
|
startVelocity: 25,
|
||
|
decay: 0.92,
|
||
|
scalar: 1.2
|
||
3 years ago
|
})
|
||
3 years ago
|
fire(0.1, {
|
||
|
spread: 120,
|
||
3 years ago
|
startVelocity: 45
|
||
|
})
|
||
3 years ago
|
},
|
||
3 years ago
|
async saveSettings() {
|
||
3 years ago
|
try {
|
||
3 years ago
|
await this.$api.plugin.update(this.id, {
|
||
|
input: JSON.stringify(this.settings),
|
||
|
active: 1
|
||
|
})
|
||
3 years ago
|
|
||
3 years ago
|
this.$emit('saved')
|
||
|
this.$toast.success(this.formDetails.msgOnInstall || 'Plugin settings saved successfully').goAway(5000)
|
||
|
this.simpleAnim()
|
||
3 years ago
|
} catch (_e) {
|
||
|
const e = await this._extractSdkResponseError(_e)
|
||
3 years ago
|
this.$toast.error(e.message).goAway(3000)
|
||
3 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async testSettings() {
|
||
3 years ago
|
this.testing = true
|
||
3 years ago
|
try {
|
||
3 years ago
|
// const res = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcPluginTest', {
|
||
|
// input: this.settings,
|
||
|
// id: this.pluginId,
|
||
|
// category: this.plugin.category,
|
||
|
// title: this.plugin.title
|
||
|
// }])
|
||
|
const res = (await this.$api.plugin.test({
|
||
3 years ago
|
input: this.settings,
|
||
|
id: this.pluginId,
|
||
|
category: this.plugin.category,
|
||
|
title: this.plugin.title
|
||
3 years ago
|
}))
|
||
3 years ago
|
if (res) {
|
||
|
this.$toast.success('Successfully tested plugin settings').goAway(3000)
|
||
|
} else {
|
||
|
this.$toast.info('Invalid credentials').goAway(3000)
|
||
|
}
|
||
3 years ago
|
} catch (_e) {
|
||
|
const e = await this._extractSdkResponseError(_e)
|
||
3 years ago
|
this.$toast[e.message === 'Not implemented' ? 'info' : 'error'](e.message).goAway(3000)
|
||
3 years ago
|
}
|
||
3 years ago
|
this.testing = false
|
||
3 years ago
|
},
|
||
3 years ago
|
async doAction(action) {
|
||
3 years ago
|
switch (action.key) {
|
||
|
case 'save' :
|
||
3 years ago
|
await this.saveSettings()
|
||
|
break
|
||
3 years ago
|
case 'test' :
|
||
3 years ago
|
await this.testSettings()
|
||
|
break
|
||
3 years ago
|
default:
|
||
3 years ago
|
break
|
||
3 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async readPluginDetails() {
|
||
3 years ago
|
try {
|
||
3 years ago
|
// this.plugin = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcPluginRead', {
|
||
|
// title: this.title
|
||
|
// }])
|
||
|
this.plugin = (await this.$api.plugin.read(this.id))
|
||
3 years ago
|
this.formDetails = JSON.parse(this.plugin.input_schema)
|
||
|
this.pluginId = this.plugin.id
|
||
|
this.settings = JSON.parse(this.plugin.input) || (this.formDetails.array ? [{}] : {})
|
||
3 years ago
|
} catch (e) {
|
||
|
}
|
||
|
},
|
||
3 years ago
|
copyDefault() {
|
||
3 years ago
|
if (this.plugin.title.replace(/\s/g, '_').toLowerCase() in this.defaultConfig) {
|
||
3 years ago
|
const data = this.defaultConfig[this.plugin.title.replace(/\s/g, '_').toLowerCase()]
|
||
|
this.settings = JSON.parse(JSON.stringify(data))
|
||
|
this.$toast.info('Demo credentials added').goAway(3000)
|
||
3 years ago
|
}
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
}
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<style scoped lang="scss">
|
||
|
|
||
|
::v-deep {
|
||
3 years ago
|
//input,
|
||
|
//select,
|
||
|
//textarea {
|
||
|
// border: 1px solid #7f828b33;
|
||
|
// padding: 1px 5px;
|
||
|
// font-size: .8rem;
|
||
|
// border-radius: 4px;
|
||
|
//
|
||
|
// &:focus {
|
||
|
// border: 1px solid var(--v-primary-base);
|
||
|
// }
|
||
|
//
|
||
|
// &:hover:not(:focus) {
|
||
|
// box-shadow: 0 0 2px dimgrey;
|
||
|
// }
|
||
|
//}
|
||
|
//
|
||
|
//
|
||
|
//input, textarea {
|
||
|
// min-width: 300px;
|
||
|
//}
|
||
3 years ago
|
}
|
||
|
|
||
|
.form-grid {
|
||
|
display: grid;
|
||
|
grid-template-columns:auto auto;
|
||
|
column-gap: 10px;
|
||
3 years ago
|
row-gap: 20px;
|
||
|
align-items: center;
|
||
3 years ago
|
}
|
||
|
|
||
|
.form-table {
|
||
|
border: none;
|
||
3 years ago
|
min-width: 400px;
|
||
3 years ago
|
}
|
||
|
|
||
|
tbody tr:nth-of-type(odd) {
|
||
|
background-color: transparent;
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
</style>
|