Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config page #49

Merged
merged 10 commits into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "add config page for site",
"packageName": "@acedatacloud/nexior",
"email": "germey@acedata.cloud",
"dependentChangeType": "patch"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
"vuex-persistedstate": "^4.0.0"
},
"devDependencies": {
"@acedatacloud/transmart-cli": "^0.5.0",
"@rollup/plugin-replace": "^3.0.0",
"@transmart/cli": "^0.5.0",
"@types/lodash": "^4.14.172",
"@types/markdown-it": "^12.2.3",
"@types/node": "^16.7.4",
Expand Down
4 changes: 2 additions & 2 deletions src/components/chat/InputBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import { defineComponent } from 'vue';
import { ElMessage, ElTooltip, ElUpload } from 'element-plus';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import { IChatModel } from '@/models';
import { getBaseUrlData } from '@/utils';
import { getBaseUrlPlatform } from '@/utils';
import { CHAT_MODEL_GPT_4_VISION } from '@/constants';

export default defineComponent({
Expand Down Expand Up @@ -86,7 +86,7 @@ export default defineComponent({
inputHeight: '35px', //add inputHeight
questionValue: this.question,
fileList: [],
uploadUrl: getBaseUrlData() + '/api/v1/files/'
uploadUrl: getBaseUrlPlatform() + '/api/v1/files/'
};
},
computed: {
Expand Down
4 changes: 2 additions & 2 deletions src/components/chatdoc/UploadDocument.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import { defineComponent } from 'vue';
import { ElButton, ElDialog, ElUpload, ElIcon, ElMessage, UploadFiles } from 'element-plus';
import { UploadFilled } from '@element-plus/icons-vue';
import { getBaseUrlData } from '@/utils';
import { getBaseUrlPlatform } from '@/utils';

interface IData {
dialogVisible: boolean;
Expand All @@ -55,7 +55,7 @@ export default defineComponent({
dialogVisible: false,
fileList: [],
learning: false,
uploadUrl: getBaseUrlData() + '/api/v1/files/'
uploadUrl: getBaseUrlPlatform() + '/api/v1/files/'
};
},
computed: {
Expand Down
8 changes: 4 additions & 4 deletions src/components/common/AuthPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ export default defineComponent({
},
computed: {
iframeUrl() {
return `${getBaseUrlAuth()}/auth/login?config=${JSON.stringify(this.$config.auth)}&inviter_id=${this.inviterId}`;
return `${getBaseUrlAuth()}/auth/login?inviter_id=${this.inviterId}`;
},
inviterId() {
// if forceInviterId is set, then use forceInviterId
if (this.$config?.distribution?.forceInviterId) {
return this.$config?.distribution?.forceInviterId;
if (this.$store?.state?.site?.distribution?.force_inviter_id) {
return this.$store?.state?.site?.distribution?.force_inviter_id;
}
// Otherwise, use the inviter_id in the url, then use the inviter_id in the cookie, and finally use the default inviter_id
const result =
this.$route.query.inviter_id?.toString() ||
getCookie('INVITER_ID') ||
this.$config?.distribution?.defaultInviterId;
this.$store?.state?.site?.distribution?.default_inviter_id;
return result;
},
authenticated() {
Expand Down
9 changes: 5 additions & 4 deletions src/components/common/DarkSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ export default defineComponent({
ElButton
},
emits: ['update:dark'],
computed: {
dark() {
return getCookie('THEME') === 'dark';
}
data() {
return {
dark: getCookie('THEME') === 'dark'
};
},
watch: {
dark(val) {
Expand All @@ -48,6 +48,7 @@ export default defineComponent({
path: '/',
domain: getDomain()
});
this.dark = isDark;
}
}
});
Expand Down
40 changes: 27 additions & 13 deletions src/components/common/Navigator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<div class="middle" />
<div v-if="!collapsed" class="bottom">
<el-menu :default-active="activeIndex">
<el-menu-item v-if="$config.navigation?.console" @click="onConsole">
<el-menu-item @click="onConsole">
<font-awesome-icon icon="fa-solid fa-compass" class="mr-2" />
<template #title>{{ $t('common.nav.console') }}</template>
</el-menu-item>
Expand All @@ -46,25 +46,32 @@
</el-menu>
</div>
<div v-else class="bottom">
<div v-if="$config.navigation?.darkMode" class="link">
<div class="link">
<el-tooltip effect="dark" :content="$t('common.nav.darkMode')" placement="right">
<dark-selector class="button" />
</el-tooltip>
</div>
<div v-if="$config.navigation?.locale" class="link">
<div class="link">
<el-tooltip effect="dark" :content="$t('common.nav.locale')" placement="right">
<el-button class="button">
<locale-selector />
</el-button>
</el-tooltip>
</div>
<div v-if="$config.navigation?.console" class="link">
<div class="link">
<el-tooltip effect="dark" :content="$t('common.nav.console')" placement="right">
<el-button class="button" @click="onConsole">
<font-awesome-icon icon="fa-solid fa-compass" />
</el-button>
</el-tooltip>
</div>
<div v-if="showSite" class="link">
<el-tooltip effect="dark" :content="$t('common.nav.site')" placement="right">
<el-button class="button" @click="onSite">
<font-awesome-icon icon="fa-solid fa-gear" />
</el-button>
</el-tooltip>
</div>
<div v-if="showDistribution" class="link">
<el-tooltip effect="dark" :content="$t('common.nav.distribution')" placement="right">
<el-button class="button" @click="onDistribution">
Expand Down Expand Up @@ -102,7 +109,8 @@ import {
ROUTE_MIDJOURNEY_HISTORY,
ROUTE_MIDJOURNEY_INDEX,
ROUTE_QRART_INDEX,
ROUTE_QRART_HISTORY
ROUTE_QRART_HISTORY,
ROUTE_SITE_INDEX
} from '@/router/constants';
import Chevron from './Chevron.vue';
import Logo from './Logo.vue';
Expand All @@ -122,7 +130,7 @@ export default defineComponent({
},
data() {
const links = [];
if (this.$config?.navigation?.chat) {
if (this.$store?.state?.site?.features?.chat?.enabled) {
links.push({
route: {
name: ROUTE_CHAT_CONVERSATION_NEW
Expand All @@ -132,7 +140,7 @@ export default defineComponent({
routes: [ROUTE_CHAT_CONVERSATION, ROUTE_CHAT_CONVERSATION_NEW]
});
}
if (this.$config.navigation?.midjourney) {
if (this.$store?.state?.site?.features?.midjourney?.enabled) {
links.push({
route: {
name: ROUTE_MIDJOURNEY_INDEX
Expand All @@ -143,7 +151,7 @@ export default defineComponent({
});
}

if (this.$config.navigation?.chatdoc) {
if (this.$store?.state?.site?.features?.chatdoc?.enabled) {
links.push({
route: {
name: ROUTE_CHATDOC_INDEX
Expand All @@ -154,7 +162,7 @@ export default defineComponent({
});
}

if (this.$config.navigation?.qrart) {
if (this.$store?.state?.site?.features?.qrart?.enabled) {
links.push({
route: {
name: ROUTE_QRART_INDEX
Expand All @@ -174,14 +182,15 @@ export default defineComponent({
authenticated() {
return !!this.$store.state.token.access;
},
showSite() {
return this.$store?.state?.site?.admins?.includes(this.$store.getters.user?.id);
},
showDistribution() {
return (
// config is enabled
this.$config.navigation.distribution &&
// if forcedInviterId is set, only the forced inviter can see the distribution menu
// if forcedInviterId is not set, everyone can see the distribution menu
(!this.$config.distribution?.forceInviterId ||
this.$store.getters.user?.id === this.$config.distribution?.forceInviterId)
!this.$store?.state?.site?.distribution?.force_inviter_id ||
this.$store.getters.user?.id === this.$store?.state?.site?.distribution?.force_inviter_id
);
},
collapsed: {
Expand All @@ -201,6 +210,11 @@ export default defineComponent({
name: ROUTE_INDEX
});
},
onSite() {
this.$router.push({
name: ROUTE_SITE_INDEX
});
},
onDistribution() {
this.$router.push({
name: ROUTE_DISTRIBUTION_INDEX
Expand Down
5 changes: 2 additions & 3 deletions src/components/midjourney/ReferenceImage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<div class="mb-4">
<el-upload
v-model:file-list="fileList"
class="upload-demo"
name="file"
:limit="5"
:multiple="true"
Expand All @@ -29,7 +28,7 @@
import { defineComponent } from 'vue';
import { ElUpload, ElButton, UploadFiles, UploadFile, ElMessage } from 'element-plus';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import { getBaseUrlData } from '@/utils';
import { getBaseUrlPlatform } from '@/utils';

interface IData {
fileList: UploadFiles;
Expand All @@ -47,7 +46,7 @@ export default defineComponent({
data(): IData {
return {
fileList: [],
uploadUrl: getBaseUrlData() + '/api/v1/files/'
uploadUrl: getBaseUrlPlatform() + '/api/v1/files/'
};
},
computed: {
Expand Down
137 changes: 137 additions & 0 deletions src/components/site/EditArray.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<template>
<el-dialog v-model="editing" :title="title" width="400px">
<el-tag
v-for="(item, itemKey) in value"
:key="itemKey"
closable
round
class="mr-2 mb-2"
:disable-transitions="false"
@close="onClose(item)"
>
{{ item }}
</el-tag>
<el-input
v-if="inputVisible"
ref="input"
v-model="inputValue"
class="block"
size="small"
@keyup.enter="onInputConfirm"
@blur="onInputConfirm"
/>
<el-button v-else round class="block" size="small" @click="onNewItem"> + </el-button>
<span class="block tip">{{ tip }}</span>
<template #footer>
<span class="dialog-footer">
<el-button round @click="onCancel">{{ $t('common.button.cancel') }}</el-button>
<el-button round type="primary" @click="onConfirm">{{ $t('common.button.confirm') }}</el-button>
</span>
</template>
</el-dialog>
<span class="edit" @click="editing = true">
<el-icon class="icon">
<edit />
</el-icon>
</span>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import { ElDialog, ElInput, ElButton, ElIcon, ElTag, ElMessage } from 'element-plus';
import { Edit } from '@element-plus/icons-vue';

export default defineComponent({
name: 'EditText',
components: {
ElDialog,
ElInput,
ElButton,
ElIcon,
ElTag,
Edit
},
props: {
modelValue: {
type: Array,
required: true
},
title: {
type: String,
required: true
},
placeholder: {
type: String,
required: true
},
tip: {
type: String,
default: undefined
},
min: {
type: Number,
default: undefined
},
minErrorMessage: {
type: String,
default: undefined
}
},
emits: ['confirm', 'cancel'],
data() {
return {
inputVisible: false,
inputValue: '',
editing: false,
value: JSON.parse(JSON.stringify(this.modelValue))
};
},
methods: {
onCancel() {
this.editing = false;
},
onConfirm() {
if (this.min !== undefined && this.value.length < this.min) {
ElMessage.error(this.minErrorMessage);
return;
}
this.$emit('confirm', this.value);
this.editing = false;
},
onClose(item: any) {
this.value.splice(this.value.indexOf(item), 1);
},
onInputConfirm() {
const inputValue = this.inputValue;
if (inputValue) {
this.value.push(inputValue);
}
this.inputVisible = false;
this.inputValue = '';
},
onNewItem() {
this.inputVisible = true;
this.$nextTick(() => {
// @ts-ignore
this.$refs.input.focus();
});
}
}
});
</script>

<style lang="scss">
.edit {
cursor: pointer;
margin-left: 5px;
position: relative;
top: 2px;
.icon {
font-size: 14px;
}
}
.tip {
color: var(--el-text-color-secondary);
font-size: 12px;
}
</style>
Loading
Loading