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.
261 lines
7.7 KiB
261 lines
7.7 KiB
3 years ago
|
import browserLang from 'browser-lang'
|
||
|
import themes from '../helpers/themes'
|
||
4 years ago
|
|
||
|
export const state = () => ({
|
||
|
treeWindow: true,
|
||
|
logWindow: true,
|
||
|
outputWindow: true,
|
||
|
darkTheme: false,
|
||
|
clientDisabledLogWindow: false,
|
||
|
theme: {},
|
||
|
themeName: 'default',
|
||
|
isGaEnabled: true,
|
||
|
isErrorReportingEnabled: true,
|
||
|
customTheme: {},
|
||
4 years ago
|
language: browserLang({
|
||
3 years ago
|
languages: ['en', 'ar', 'nl', 'fr', 'de', 'it', 'ja', 'ru', 'es', 'ca', 'cs', 'et', 'lt', 'no', 'te', 'ur', 'zh-cn', 'da', 'tl', 'el', 'ms', 'pl', 'sr', 'sv', 'th', 'bn', 'zh-tw', 'fi', 'ko', 'iw', 'ml', 'pt', 'sk', 'tg', 'tr', 'vi', 'bg', 'hr', 'eo', 'id', 'lv', 'mr', 'ro', 'sl', 'ta', 'uk', 'kn', 'hi'],
|
||
|
fallback: 'en'
|
||
4 years ago
|
}),
|
||
4 years ago
|
showTour: {
|
||
|
home: true,
|
||
|
dashboard: true
|
||
|
},
|
||
3 years ago
|
startedDate: new Date(), // moment().format(),
|
||
4 years ago
|
scaffoldOnSave: false,
|
||
|
pollingFailedMaxRetry: 0,
|
||
|
stats: {
|
||
|
tableCount: 0,
|
||
|
viewCount: 0,
|
||
3 years ago
|
relationCount: 0
|
||
4 years ago
|
},
|
||
|
version: '0.0.0',
|
||
|
checkForUpdate: true,
|
||
|
downloadAndUpdateRelease: true,
|
||
|
isComp: false,
|
||
|
metatables: false,
|
||
|
nc: true,
|
||
4 years ago
|
miniSponsorCard: 0,
|
||
4 years ago
|
screensaver: true,
|
||
4 years ago
|
autoApplyFilter: true,
|
||
3 years ago
|
apiLoading: false,
|
||
3 years ago
|
includeM2M: false,
|
||
2 years ago
|
feedbackForm: {
|
||
|
// eslint-disable-next-line max-len
|
||
|
url: 'https://docs.google.com/forms/d/e/1FAIpQLSeTlAfZjszgr53lArz3NvUEnJGOT9JtG9NAU5d0oQwunDS2Pw/viewform?embedded=true',
|
||
|
createdAt: new Date('2020-01-01T00:00:00.000Z'),
|
||
2 years ago
|
isHidden: false
|
||
2 years ago
|
}
|
||
3 years ago
|
})
|
||
4 years ago
|
|
||
|
export const mutations = {
|
||
3 years ago
|
MutApiLoading(state, status) {
|
||
4 years ago
|
state.apiLoading = status
|
||
|
},
|
||
3 years ago
|
MutAutoApplyFilter(state, v) {
|
||
3 years ago
|
state.autoApplyFilter = v
|
||
|
},
|
||
3 years ago
|
MutToggleLogWindow(state, show) {
|
||
3 years ago
|
state.logWindow = !state.logWindow
|
||
|
},
|
||
2 years ago
|
MutFeedbackForm(state, feedbackForm) {
|
||
|
state.feedbackForm = feedbackForm
|
||
3 years ago
|
},
|
||
3 years ago
|
MutScreensaver(state, show) {
|
||
3 years ago
|
state.screensaver = show
|
||
|
},
|
||
3 years ago
|
MutToggleDarkMode(state, status) {
|
||
3 years ago
|
if (typeof status !== 'boolean') {
|
||
|
status = !state.darkTheme
|
||
|
}
|
||
|
state.darkTheme = status
|
||
|
},
|
||
3 years ago
|
MutToggleGaEnabled(state, isEnabled) {
|
||
3 years ago
|
state.isGaEnabled = isEnabled
|
||
|
},
|
||
3 years ago
|
MutToggleErrorReportingEnabled(state, isEnabled) {
|
||
3 years ago
|
state.isErrorReportingEnabled = isEnabled
|
||
|
},
|
||
3 years ago
|
MutToggleTelemetryEnabled(state, isEnabled) {
|
||
3 years ago
|
state.isTelemetryEnabled = isEnabled
|
||
|
},
|
||
3 years ago
|
MutSetTheme(state, { theme, themeName }) {
|
||
3 years ago
|
state.themeName = themeName
|
||
|
state.theme = theme
|
||
|
},
|
||
3 years ago
|
MutToggleTheme(state) {
|
||
3 years ago
|
const keys = Object.keys(themes)
|
||
|
const index = keys.indexOf(state.themeName) + 1
|
||
|
state.themeName = keys[index]
|
||
|
state.theme = themes[state.themeName]
|
||
|
},
|
||
3 years ago
|
MutSetCustomTheme(state, theme) {
|
||
3 years ago
|
state.customTheme = theme
|
||
|
},
|
||
3 years ago
|
MutLanguage(state, language) {
|
||
3 years ago
|
state.language = language
|
||
|
},
|
||
3 years ago
|
MutToggleTreeviewWindow(state, show) {
|
||
3 years ago
|
state.treeWindow = !state.treeWindow
|
||
|
},
|
||
3 years ago
|
MutToggleOutputWindow(state, show) {
|
||
3 years ago
|
state.outputWindow = !state.outputWindow
|
||
|
},
|
||
3 years ago
|
MutToggleLogWindowFromTab(state, { client, status }) {
|
||
4 years ago
|
if (client) {
|
||
3 years ago
|
state.clientDisabledLogWindow = status
|
||
|
state.logWindow = false
|
||
|
} else if (state.clientDisabledLogWindow) {
|
||
|
state.logWindow = true
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
MutShowTour(state, { page, status = false }) {
|
||
3 years ago
|
state.showTour = { ...state.showTour, [page]: status }
|
||
4 years ago
|
},
|
||
3 years ago
|
MutStartedDate(state, date) {
|
||
3 years ago
|
state.expiryDate = date
|
||
4 years ago
|
},
|
||
3 years ago
|
MutPollingIncrementBy(state, val = 1) {
|
||
3 years ago
|
state.pollingFailedMaxRetry += val
|
||
4 years ago
|
},
|
||
3 years ago
|
MutPollingSet(state, val = 0) {
|
||
3 years ago
|
state.pollingFailedMaxRetry = val
|
||
4 years ago
|
},
|
||
3 years ago
|
MutToggleScaffoldOnSave(state, status) {
|
||
4 years ago
|
if (typeof status === 'boolean') {
|
||
|
state.scaffoldOnSave = status
|
||
|
} else {
|
||
3 years ago
|
state.scaffoldOnSave = !state.scaffoldOnSave
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
MutStat(state, stats) {
|
||
3 years ago
|
for (const key in stats) {
|
||
|
stats[key] += state.stats[key] || 0
|
||
|
}
|
||
|
state.stats = { ...state.stats, ...stats }
|
||
4 years ago
|
},
|
||
3 years ago
|
MutResetStats(state) {
|
||
3 years ago
|
for (const key in state.stats) {
|
||
|
state.stats[key] = 0
|
||
|
}
|
||
|
state.stats = { ...state.stats }
|
||
4 years ago
|
},
|
||
3 years ago
|
MutVersion(state, version) {
|
||
3 years ago
|
state.version = version
|
||
4 years ago
|
},
|
||
|
|
||
3 years ago
|
MutCheckForUpdate(state, checkForUpdate) {
|
||
3 years ago
|
state.checkForUpdate = checkForUpdate
|
||
4 years ago
|
},
|
||
3 years ago
|
MutDownloadAndUpdateRelease(state, downloadAndUpdateRelease) {
|
||
3 years ago
|
state.downloadAndUpdateRelease = downloadAndUpdateRelease
|
||
4 years ago
|
},
|
||
3 years ago
|
MutIsComp(state, isComp) {
|
||
3 years ago
|
state.isComp = isComp
|
||
4 years ago
|
},
|
||
3 years ago
|
MutMetatables(state, show) {
|
||
3 years ago
|
state.metatables = show
|
||
4 years ago
|
},
|
||
3 years ago
|
MutNc(state, nc) {
|
||
3 years ago
|
state.nc = nc
|
||
4 years ago
|
},
|
||
3 years ago
|
MutMiniSponsorCard(state, miniSponsorCard) {
|
||
3 years ago
|
state.miniSponsorCard = miniSponsorCard
|
||
3 years ago
|
},
|
||
|
MutIncludeM2M(state, includeM2M) {
|
||
|
state.includeM2M = includeM2M
|
||
4 years ago
|
}
|
||
3 years ago
|
}
|
||
4 years ago
|
|
||
|
export const getters = {
|
||
3 years ago
|
GtrNoOfDaysLeft(state) {
|
||
4 years ago
|
// const passedDays = moment().diff(state.startedDate, 'days');
|
||
|
// return passedDays > 30 ? 0 : 30 - passedDays;
|
||
|
},
|
||
3 years ago
|
GtrHasTrialPeriodExpired(state) {
|
||
4 years ago
|
// const passedDays = moment().diff(state.startedDate, 'days');
|
||
|
// return passedDays > 30;
|
||
|
},
|
||
3 years ago
|
GtrMaxPollingRetryExceeded(state) {
|
||
3 years ago
|
return state.pollingFailedMaxRetry >= process.env.pollingFailedMaxRetry
|
||
4 years ago
|
},
|
||
3 years ago
|
GtrShouldWork(state) {
|
||
3 years ago
|
return () => state.isComp ? Math.floor(Math.random() * 1000) % 5 === 0 : true
|
||
4 years ago
|
}
|
||
3 years ago
|
}
|
||
4 years ago
|
|
||
|
export const actions = {
|
||
3 years ago
|
ActGetExpiryDate({ state, commit }, args) {
|
||
4 years ago
|
// if (!state.startedDate) {
|
||
|
// commit('MutStartedDate', moment().format())
|
||
|
// }
|
||
|
// return moment().diff(state.startedDate, 'days') // 1
|
||
|
},
|
||
3 years ago
|
ActToggleDarkMode({ state, commit, rootState }, status) {
|
||
4 years ago
|
//
|
||
|
// const prepareToastMessage = () => {
|
||
|
// if (rootState.users.user && rootState.users.user.email) {
|
||
|
// return `Get free lifetime access to Dark theme click <a href="#/referral" style="color: white;font-weight: bold;">HERE</a>`
|
||
|
// } else {
|
||
|
// return `Sign up and refer to get Dark theme`
|
||
|
// }
|
||
|
// };
|
||
|
//
|
||
|
// if (status && !rootState.users.ui_ability.rules.darkTheme) {
|
||
|
// setTimeout(() => {
|
||
|
// if (state.darkTheme) {
|
||
|
//
|
||
|
//
|
||
|
// this.commit('snackbar/setSnack', prepareToastMessage())
|
||
|
//
|
||
|
// commit('MutToggleDarkMode', false)
|
||
|
// }
|
||
|
// }, process.env.darkThemeResetInSeconds)
|
||
|
// }
|
||
|
commit('MutToggleDarkMode', status)
|
||
3 years ago
|
},
|
||
3 years ago
|
ActCheckMaxTable({ state, commit, rootState }, { tableIndex }) {
|
||
3 years ago
|
// const prepareToastMessage = () => {
|
||
|
// return `You are allowed to access only ${rootState.users.ui_ability.rules.maxTables} tables.<br/>
|
||
|
// You can either upgrade or <a href="#/referral" style="color: white;font-weight: bold;">refer</a> us. `
|
||
|
// }
|
||
|
//
|
||
|
// if (process.env.ui_ability) {
|
||
|
// if (tableIndex > rootState.users.ui_ability.rules.maxTables) {
|
||
|
// this.commit('snackbar/setSnack', prepareToastMessage())
|
||
|
// return false
|
||
|
// }
|
||
|
// }
|
||
3 years ago
|
return true
|
||
4 years ago
|
},
|
||
3 years ago
|
ActSetTheme({ state, commit, rootState }, { theme, themeName, custom }) {
|
||
4 years ago
|
if (custom) {
|
||
3 years ago
|
commit('MutSetCustomTheme', theme)
|
||
4 years ago
|
} else {
|
||
3 years ago
|
commit('MutSetTheme', { theme, themeName })
|
||
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/>.
|
||
|
*
|
||
|
*/
|