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.
183 lines
5.9 KiB
183 lines
5.9 KiB
3 years ago
|
import { mapGetters } from 'vuex'
|
||
4 years ago
|
|
||
|
export default {
|
||
3 years ago
|
data() {
|
||
4 years ago
|
return {
|
||
|
isHydrated: false,
|
||
3 years ago
|
drawer: null
|
||
4 years ago
|
|
||
|
}
|
||
|
},
|
||
|
computed: {
|
||
3 years ago
|
dashboardUrl() {
|
||
3 years ago
|
return `${location.origin}${location.pathname || ''}`
|
||
3 years ago
|
},
|
||
3 years ago
|
isDark() {
|
||
3 years ago
|
return this.$vuetify && this.$vuetify.theme && this.$vuetify.theme.dark
|
||
4 years ago
|
},
|
||
3 years ago
|
isLight() {
|
||
3 years ago
|
return this.$vuetify && this.$vuetify.theme && this.$vuetify.theme.light
|
||
4 years ago
|
},
|
||
3 years ago
|
isThisMobile() { // just an example, could be one specific value if that's all you need
|
||
3 years ago
|
return this.isHydrated ? this.$vuetify && this.$vuetify.breakpoint && this.$vuetify.breakpoint.smAndDown : false
|
||
4 years ago
|
},
|
||
|
|
||
3 years ago
|
isTool() {
|
||
3 years ago
|
return process.env && process.env.tool
|
||
4 years ago
|
},
|
||
3 years ago
|
isDashboard() {
|
||
3 years ago
|
return this.$route &&
|
||
|
this.$route.path &&
|
||
|
(this.$route.path === '/nc' || this.$route.path === '/nc/' || this.$route.path.startsWith('/nc/'))
|
||
4 years ago
|
},
|
||
4 years ago
|
|
||
3 years ago
|
_meta() {
|
||
3 years ago
|
return this._isMac ? '⌘' : '^'
|
||
4 years ago
|
},
|
||
3 years ago
|
_isMac() {
|
||
3 years ago
|
return process.platform === 'darwin'
|
||
4 years ago
|
},
|
||
3 years ago
|
_isWindows() {
|
||
3 years ago
|
return process.platform === 'win32'
|
||
4 years ago
|
},
|
||
3 years ago
|
_isDev() {
|
||
3 years ago
|
return process.env.NODE_ENV && process.env.NODE_ENV.toLowerCase().startsWith('dev')
|
||
4 years ago
|
},
|
||
3 years ago
|
_isEE() {
|
||
3 years ago
|
return process.env.EE
|
||
4 years ago
|
},
|
||
3 years ago
|
_isZh() {
|
||
3 years ago
|
const zhLan = ['zh', 'zh-cn', 'zh-hk', 'zh-mo', 'zh-sg', 'zh-tw']
|
||
|
const browserLan = (navigator.languages || [navigator.language || navigator.userLanguage || 'en']).map(v => v.toLowerCase())
|
||
|
return zhLan.some(l => browserLan.includes(l))
|
||
3 years ago
|
},
|
||
3 years ago
|
_isRtl() {
|
||
|
const rtl = ['fa']
|
||
|
return rtl.includes(this.$store.state.settings.language)
|
||
|
},
|
||
4 years ago
|
...mapGetters({
|
||
3 years ago
|
_isUIAllowed: 'users/GtrIsUIAllowed',
|
||
|
projectName: 'project/GtrProjectName',
|
||
|
projectId: 'project/GtrProjectId'
|
||
4 years ago
|
})
|
||
|
},
|
||
3 years ago
|
mounted() {
|
||
4 years ago
|
// this.isHydrated = true
|
||
|
// if (!this.$vuetify.breakpoint.smAndDown) {
|
||
|
// //console.log('setting drawer to false');
|
||
|
// this.drawer = true;
|
||
|
// } else {
|
||
|
// //console.log('setting drawer to false');
|
||
|
// this.drawer = false;
|
||
|
// }
|
||
3 years ago
|
// console.log('this.items', this.$store.getters.GtrPaidUser);
|
||
4 years ago
|
// this.items[1].show = !this.$store.getters.GtrPaidUser;
|
||
|
},
|
||
|
// methods: {
|
||
|
// _isUIAllowed(page) {
|
||
|
// const user = this.$store.state.users.user;
|
||
|
// let roles = user && user.roles;
|
||
|
//
|
||
|
// if (this.$store.state.users.previewAs) {
|
||
|
// roles = {
|
||
|
// [this.$store.state.users.previewAs]: true
|
||
|
// }
|
||
|
// }
|
||
|
// return user && user.roles && Object.entries(roles).some(([name, hasRole]) => {
|
||
|
// return hasRole && rolePermissions[name] && (rolePermissions[name] === '*' || rolePermissions[name][page])
|
||
|
// })
|
||
|
// }
|
||
|
// },
|
||
|
methods: {
|
||
3 years ago
|
_extractRowId(row, meta) {
|
||
|
return meta.columns.filter(c => c.pk).map(c => row[c.title]).join('___')
|
||
|
},
|
||
3 years ago
|
upgradeToEE() {
|
||
3 years ago
|
this.$toast.info('Upgrade to Enterprise Edition').goAway(3000)
|
||
4 years ago
|
},
|
||
3 years ago
|
comingSoon() {
|
||
3 years ago
|
this.$toast.info('Coming soon').goAway(3000)
|
||
4 years ago
|
},
|
||
3 years ago
|
async sqlOp(args, op, opArgs, cusHeaders, cusAxiosOptions, queryParams) {
|
||
4 years ago
|
return this.$store.dispatch('sqlMgr/ActSqlOp', [args, op, opArgs, cusHeaders, cusAxiosOptions, queryParams])
|
||
3 years ago
|
},
|
||
|
async _extractSdkResponseError(e) {
|
||
|
if (!e || !e.response) { return e }
|
||
|
let msg
|
||
|
if (e.response.data instanceof Blob) {
|
||
|
try {
|
||
|
msg = JSON.parse(await e.response.data.text()).msg
|
||
|
} catch {
|
||
|
msg = 'Some internal error occurred'
|
||
|
}
|
||
|
} else {
|
||
|
msg = e.response.data.msg || 'Some internal error occurred'
|
||
|
}
|
||
|
const err = new Error(msg)
|
||
|
err.response = e.response
|
||
|
return err
|
||
|
},
|
||
|
async _extractSdkResponseErrorMsg(e) {
|
||
|
if (!e || !e.response) { return e.message }
|
||
|
let msg
|
||
|
if (e.response.data instanceof Blob) {
|
||
|
try {
|
||
|
msg = JSON.parse(await e.response.data.text()).msg
|
||
|
} catch {
|
||
|
msg = 'Some internal error occurred'
|
||
|
}
|
||
|
} else {
|
||
|
msg = e.response.data.msg || 'Some internal error occurred'
|
||
|
}
|
||
|
return msg || 'Some error occurred'
|
||
3 years ago
|
},
|
||
|
open(url, target = '_blank') {
|
||
|
window.open(url, target)
|
||
4 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
/**
|
||
|
* @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/>.
|
||
|
*
|
||
|
*/
|
||
|
/**
|
||
|
* @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/>.
|
||
|
*
|
||
|
*/
|