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