Browse Source

refactor(gui): update eslint rules

Signed-off-by: Pranav C <61551451+pranavxc@users.noreply.github.com>
pull/360/head
Pranav C 3 years ago
parent
commit
59f55e4595
  1. 8
      packages/nc-gui/.eslintrc.json
  2. 25
      packages/nc-gui/components/apiClient/headers.vue
  3. 24
      packages/nc-gui/components/apiClient/params.vue
  4. 6
      packages/nc-gui/components/apiClient/perfTest.vue
  5. 14
      packages/nc-gui/components/apiOverlay.vue
  6. 2
      packages/nc-gui/components/auth.routes.js
  7. 10
      packages/nc-gui/components/auth/apiTokens.vue
  8. 6
      packages/nc-gui/components/auth/authHooks.vue
  9. 18
      packages/nc-gui/components/auth/roles.vue
  10. 44
      packages/nc-gui/components/auth/userManagement.vue
  11. 2
      packages/nc-gui/components/authTab.vue
  12. 8
      packages/nc-gui/components/changeEnv.vue
  13. 100
      packages/nc-gui/components/createOrEditProject.vue
  14. 8
      packages/nc-gui/components/global/recursiveMenu.vue
  15. 28
      packages/nc-gui/components/global/xAutoComplete.vue
  16. 4
      packages/nc-gui/components/global/xIcon.vue
  17. 16
      packages/nc-gui/components/monaco/Monaco.vue
  18. 40
      packages/nc-gui/components/monaco/MonacoSqlEditor.vue
  19. 2
      packages/nc-gui/components/monaco/sqlAutoCompletions.js
  20. 10
      packages/nc-gui/components/notification.vue
  21. 36
      packages/nc-gui/components/project/apis.vue
  22. 18
      packages/nc-gui/components/project/appStore.vue
  23. 4
      packages/nc-gui/components/project/appStore/FormInput.vue
  24. 18
      packages/nc-gui/components/project/appStore/appInstall.vue
  25. 22
      packages/nc-gui/components/project/appStore/inputs/attachment.vue
  26. 10
      packages/nc-gui/components/project/appStore/inputs/longTextField.vue
  27. 6
      packages/nc-gui/components/project/appStore/inputs/passwordField.vue
  28. 6
      packages/nc-gui/components/project/appStore/inputs/textField.vue
  29. 6
      packages/nc-gui/components/project/appStoreOld.vue
  30. 6
      packages/nc-gui/components/project/auditTab/audit.vue
  31. 34
      packages/nc-gui/components/project/auditTab/db.vue
  32. 18
      packages/nc-gui/components/project/cronJobs.vue
  33. 24
      packages/nc-gui/components/project/dlgs/dlgAddRelation.vue
  34. 16
      packages/nc-gui/components/project/dlgs/dlgTriggerAddEdit.vue
  35. 8
      packages/nc-gui/components/project/functionTab/functionAcl.vue
  36. 24
      packages/nc-gui/components/project/functionTab/functionQuery.vue
  37. 8
      packages/nc-gui/components/project/gqlHandlerCodeEditor.vue
  38. 10
      packages/nc-gui/components/project/graphqlClient.vue
  39. 2
      packages/nc-gui/components/project/grpcClient.vue
  40. 8
      packages/nc-gui/components/project/grpcHandlerCodeEditor.vue
  41. 8
      packages/nc-gui/components/project/procedureTab/procedureAcl.vue
  42. 24
      packages/nc-gui/components/project/procedureTab/procedureQuery.vue
  43. 12
      packages/nc-gui/components/project/projectMetadata/disableOrEnableModels.vue
  44. 28
      packages/nc-gui/components/project/projectMetadata/sync/disableOrEnableFunctions.vue
  45. 28
      packages/nc-gui/components/project/projectMetadata/sync/disableOrEnableProcedures.vue
  46. 12
      packages/nc-gui/components/project/projectMetadata/sync/disableOrEnableRelations.vue
  47. 28
      packages/nc-gui/components/project/projectMetadata/sync/disableOrEnableTables.vue
  48. 28
      packages/nc-gui/components/project/projectMetadata/sync/disableOrEnableViews.vue
  49. 10
      packages/nc-gui/components/project/projectMetadata/uiAcl/toggleFunctionUIAcl.vue
  50. 10
      packages/nc-gui/components/project/projectMetadata/uiAcl/toggleProcedureUIAcl.vue
  51. 10
      packages/nc-gui/components/project/projectMetadata/uiAcl/toggleRelationsUIAcl.vue
  52. 10
      packages/nc-gui/components/project/projectMetadata/uiAcl/toggleTableUIAcl.vue
  53. 10
      packages/nc-gui/components/project/projectMetadata/uiAcl/toggleViewUIAcl.vue
  54. 8
      packages/nc-gui/components/project/restHandlerCodeEditor.vue
  55. 30
      packages/nc-gui/components/project/seed.vue
  56. 24
      packages/nc-gui/components/project/sequence.vue
  57. 26
      packages/nc-gui/components/project/settings/appearance.vue
  58. 4
      packages/nc-gui/components/project/settings/env.vue
  59. 10
      packages/nc-gui/components/project/settings/logs.vue
  60. 42
      packages/nc-gui/components/project/settings/versionAndUpdate.vue
  61. 18
      packages/nc-gui/components/project/settings/xcMeta.vue
  62. 2
      packages/nc-gui/components/project/spreadsheet/apis/apiFactory.js
  63. 50
      packages/nc-gui/components/project/spreadsheet/apis/gqlApi.js
  64. 4
      packages/nc-gui/components/project/spreadsheet/apis/grpcApi.js
  65. 24
      packages/nc-gui/components/project/spreadsheet/apis/restApi.js
  66. 2
      packages/nc-gui/components/project/spreadsheet/components/cell/attachmentCell.vue
  67. 2
      packages/nc-gui/components/project/spreadsheet/components/cell/enumCell.vue
  68. 2
      packages/nc-gui/components/project/spreadsheet/components/cell/setListCell.vue
  69. 8
      packages/nc-gui/components/project/spreadsheet/components/columnFilter.vue
  70. 12
      packages/nc-gui/components/project/spreadsheet/components/columnFilterMenu.vue
  71. 38
      packages/nc-gui/components/project/spreadsheet/components/editColumn.vue
  72. 10
      packages/nc-gui/components/project/spreadsheet/components/editColumn/customSelectOptions.vue
  73. 16
      packages/nc-gui/components/project/spreadsheet/components/editColumn/linkedToAnotherOptions.vue
  74. 18
      packages/nc-gui/components/project/spreadsheet/components/editColumn/relationOptions.vue
  75. 12
      packages/nc-gui/components/project/spreadsheet/components/editVirtualColumn.vue
  76. 14
      packages/nc-gui/components/project/spreadsheet/components/editableCell.vue
  77. 8
      packages/nc-gui/components/project/spreadsheet/components/editableCell/booleanCell.vue
  78. 8
      packages/nc-gui/components/project/spreadsheet/components/editableCell/datePickerCell.vue
  79. 8
      packages/nc-gui/components/project/spreadsheet/components/editableCell/dateTimePickerCell.vue
  80. 24
      packages/nc-gui/components/project/spreadsheet/components/editableCell/editableAttachmentCell.vue
  81. 10
      packages/nc-gui/components/project/spreadsheet/components/editableCell/enumListEditableCell.vue
  82. 12
      packages/nc-gui/components/project/spreadsheet/components/editableCell/enumRadioEditableCell.vue
  83. 8
      packages/nc-gui/components/project/spreadsheet/components/editableCell/floatCell.vue
  84. 8
      packages/nc-gui/components/project/spreadsheet/components/editableCell/integerCell.vue
  85. 12
      packages/nc-gui/components/project/spreadsheet/components/editableCell/jsonCell.vue
  86. 14
      packages/nc-gui/components/project/spreadsheet/components/editableCell/setListCheckboxCell.vue
  87. 10
      packages/nc-gui/components/project/spreadsheet/components/editableCell/setListEditableCell.vue
  88. 10
      packages/nc-gui/components/project/spreadsheet/components/editableCell/textAreaCell.vue
  89. 12
      packages/nc-gui/components/project/spreadsheet/components/editableCell/textAreaCellOld.vue
  90. 8
      packages/nc-gui/components/project/spreadsheet/components/editableCell/textCell.vue
  91. 8
      packages/nc-gui/components/project/spreadsheet/components/editableCell/timePickerCell.vue
  92. 40
      packages/nc-gui/components/project/spreadsheet/components/expandedForm.vue
  93. 2
      packages/nc-gui/components/project/spreadsheet/components/extras.vue
  94. 24
      packages/nc-gui/components/project/spreadsheet/components/fieldsMenu.vue
  95. 4
      packages/nc-gui/components/project/spreadsheet/components/headerCell.vue
  96. 2
      packages/nc-gui/components/project/spreadsheet/components/lockMenu.vue
  97. 4
      packages/nc-gui/components/project/spreadsheet/components/pagination.vue
  98. 8
      packages/nc-gui/components/project/spreadsheet/components/sharedViewsList.vue
  99. 8
      packages/nc-gui/components/project/spreadsheet/components/sortListMenu.vue
  100. 40
      packages/nc-gui/components/project/spreadsheet/components/spreadsheetNavDrawer.vue
  101. Some files were not shown because too many files have changed in this diff Show More

8
packages/nc-gui/.eslintrc.json

@ -13,9 +13,11 @@
], ],
"rules": { "rules": {
"no-console": "off", "no-console": "off",
// "space-before-function-paren": "off", "space-before-function-paren": [
"require-await": "off", "error",
"vue/no-mutating-props": "off" "never"
],
"require-await": "off"
}, },
"parserOptions": { "parserOptions": {
"parser": "babel-eslint", "parser": "babel-eslint",

25
packages/nc-gui/components/apiClient/headers.vue

@ -1,4 +1,5 @@
<template> <!-- eslint-disable -->
<!-- todo: update prop mutation with emit --><template>
<v-container fluid> <v-container fluid>
<v-simple-table class="ignore-height-style" dense> <v-simple-table class="ignore-height-style" dense>
<template #default> <template #default>
@ -79,38 +80,38 @@ import draggable from 'vuedraggable'
export default { export default {
directives: {}, directives: {},
components: { draggable }, components: { draggable },
validate ({ params }) { validate({ params }) {
return true return true
}, },
props: { value: Array, env: String }, props: { value: Array, env: String },
data () { data() {
return { return {
headerListAuto: ['A-IM', 'Accept', 'Accept-Charset', 'Accept-Encoding', 'Accept-Language', 'Accept-Datetime', 'Access-Control-Request-Method', 'Access-Control-Request-Headers', 'Authorization', 'Cache-Control', 'Connection', 'Content-Length', 'Content-Type', 'Cookie', 'Date', 'Expect', 'Forwarded', 'From', 'Host', 'If-Match', 'If-Modified-Since', 'If-None-Match', 'If-Range', 'If-Unmodified-Since', 'Max-Forwards', 'Origin', 'Pragma', 'Proxy-Authorization', 'Range', 'Referer', 'TE', 'User-Agent', 'Upgrade', 'Via', 'Warning', 'Non-standard headers', 'Dnt', 'X-Requested-With', 'X-CSRF-Token'] headerListAuto: ['A-IM', 'Accept', 'Accept-Charset', 'Accept-Encoding', 'Accept-Language', 'Accept-Datetime', 'Access-Control-Request-Method', 'Access-Control-Request-Headers', 'Authorization', 'Cache-Control', 'Connection', 'Content-Length', 'Content-Type', 'Cookie', 'Date', 'Expect', 'Forwarded', 'From', 'Host', 'If-Match', 'If-Modified-Since', 'If-None-Match', 'If-Range', 'If-Unmodified-Since', 'Max-Forwards', 'Origin', 'Pragma', 'Proxy-Authorization', 'Range', 'Referer', 'TE', 'User-Agent', 'Upgrade', 'Via', 'Warning', 'Non-standard headers', 'Dnt', 'X-Requested-With', 'X-CSRF-Token']
} }
}, },
head () { head() {
return {} return {}
}, },
computed: { computed: {
headersList: { headersList: {
// two way binding(v-model) // two way binding(v-model)
get () { get() {
return this.value return this.value
}, },
set (value) { set(value) {
this.$emit('input', value) this.$emit('input', value)
} }
} }
}, },
watch: { watch: {
value: { value: {
handler (val) { handler(val) {
// keeps at least one param row // keeps at least one param row
if (!val || !val.length) { this.$emit('input', [{ name: '', value: '', enabled: true }]) } if (!val || !val.length) { this.$emit('input', [{ name: '', value: '', enabled: true }]) }
} }
} }
}, },
created () { created() {
// keeps at least one param row // keeps at least one param row
if (!this.value || !this.value.length) { if (!this.value || !this.value.length) {
this.$emit('input', [{ this.$emit('input', [{
@ -120,15 +121,15 @@ export default {
}]) }])
} }
}, },
mounted () { mounted() {
}, },
beforeDestroy () { beforeDestroy() {
}, },
methods: {}, methods: {},
beforeCreated () { beforeCreated() {
}, },
destroy () { destroy() {
} }
} }
</script> </script>

24
packages/nc-gui/components/apiClient/params.vue

@ -1,3 +1,5 @@
<!-- eslint-disable -->
<!-- todo: update prop mutation with emit -->
<template> <template>
<v-container fluid> <v-container fluid>
<v-simple-table class="ignore-height-style params-table" style="" dense> <v-simple-table class="ignore-height-style params-table" style="" dense>
@ -79,36 +81,36 @@ import draggable from 'vuedraggable'
export default { export default {
directives: {}, directives: {},
components: { draggable }, components: { draggable },
validate ({ params }) { validate({ params }) {
return true return true
}, },
props: { value: Array, env: String }, props: { value: Array, env: String },
data () { data() {
return {} return {}
}, },
head () { head() {
return {} return {}
}, },
computed: { computed: {
paramList: { paramList: {
// two way binding(v-model) // two way binding(v-model)
get () { get() {
return this.value return this.value
}, },
set (value) { set(value) {
this.$emit('input', value) this.$emit('input', value)
} }
} }
}, },
watch: { watch: {
value: { value: {
handler (val) { handler(val) {
// keeps at least one param row // keeps at least one param row
if (!val || !val.length) { this.$emit('input', [{ name: '', value: '', enabled: true }]) } if (!val || !val.length) { this.$emit('input', [{ name: '', value: '', enabled: true }]) }
} }
} }
}, },
created () { created() {
// creating value if not exist // creating value if not exist
if (!this.value || !this.value.length) { if (!this.value || !this.value.length) {
this.$emit('input', [{ this.$emit('input', [{
@ -118,15 +120,15 @@ export default {
}]) }])
} }
}, },
mounted () { mounted() {
}, },
beforeDestroy () { beforeDestroy() {
}, },
methods: {}, methods: {},
beforeCreated () { beforeCreated() {
}, },
destroy () { destroy() {
} }
} }
</script> </script>

6
packages/nc-gui/components/apiClient/perfTest.vue

@ -94,16 +94,16 @@ export default {
}, },
computed: { computed: {
perf: { perf: {
get () { get() {
return { ...(this.value || {}) } return { ...(this.value || {}) }
}, },
set (value) { set(value) {
this.$emit('input', value) this.$emit('input', value)
} }
} }
}, },
methods: { methods: {
open (url) { open(url) {
// shell.openExternal(url) // shell.openExternal(url)
} }
} }

14
packages/nc-gui/components/apiOverlay.vue

@ -127,20 +127,20 @@ export default {
apis: 0 apis: 0
}), }),
computed: { computed: {
rowsCount () { rowsCount() {
return this.databaseList ? Math.ceil(this.databaseList.length / 5) : 0 return this.databaseList ? Math.ceil(this.databaseList.length / 5) : 0
}, },
databaseCount () { databaseCount() {
return this.databaseList ? this.databaseList.length : 0 return this.databaseList ? this.databaseList.length : 0
}, },
cost () { cost() {
if (!this.apis) { return 0 } if (!this.apis) { return 0 }
const cost = Math.round(this.perHourCost * (this.apis / this.apisPerHour)) const cost = Math.round(this.perHourCost * (this.apis / this.apisPerHour))
return (cost + '').replace(/\d(?=(?:\d{3})+$)/g, '$&,') return (cost + '').replace(/\d(?=(?:\d{3})+$)/g, '$&,')
}, },
hoursSaved () { hoursSaved() {
if (!this.apis) { return 0 } if (!this.apis) { return 0 }
const hours = Math.round(this.apis / this.apisPerHour) const hours = Math.round(this.apis / this.apisPerHour)
@ -148,16 +148,16 @@ export default {
return (hours + '').replace(/\d(?=(?:\d{3})+$)/g, '$&,') return (hours + '').replace(/\d(?=(?:\d{3})+$)/g, '$&,')
} }
}, },
created () { created() {
this.initSocketClient() this.initSocketClient()
}, },
beforeDestroy () { beforeDestroy() {
if (this.client) { if (this.client) {
this.client.disconnect() this.client.disconnect()
} }
}, },
methods: { methods: {
initSocketClient () { initSocketClient() {
try { try {
this.client = require('socket.io-client')(`ws://${window.location.hostname}:8083`) this.client = require('socket.io-client')(`ws://${window.location.hostname}:8083`)
const self = this const self = this

2
packages/nc-gui/components/auth.routes.js

@ -50,7 +50,7 @@ authorizedRoutes['/user/password/reset/form'] = true
// freeRoutes['user/authentication/signin'] = true; // freeRoutes['user/authentication/signin'] = true;
// freeRoutes['user/authentication/signup'] = true; // freeRoutes['user/authentication/signup'] = true;
exports.allowed = function (store, path) { exports.allowed = function(store, path) {
// console.log('store.getters.GtrUser',store.getters.GtrUser); // console.log('store.getters.GtrUser',store.getters.GtrUser);
// console.log('path',path); // console.log('path',path);

10
packages/nc-gui/components/auth/apiTokens.vue

@ -140,18 +140,18 @@ export default {
tokenObj: {}, tokenObj: {},
valid: true valid: true
}), }),
created () { created() {
this.loadApiTokens() this.loadApiTokens()
}, },
methods: { methods: {
copyToken (token) { copyToken(token) {
this.$clipboard(token) this.$clipboard(token)
this.$toast.info('Copied to clipboard').goAway(1000) this.$toast.info('Copied to clipboard').goAway(1000)
}, },
async loadApiTokens () { async loadApiTokens() {
this.tokens = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcApiTokenList']) this.tokens = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcApiTokenList'])
}, },
async generateToken () { async generateToken() {
try { try {
this.newTokenDialog = false this.newTokenDialog = false
this.tokens = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcApiTokenCreate', this.tokenObj]) this.tokens = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcApiTokenCreate', this.tokenObj])
@ -162,7 +162,7 @@ export default {
this.$toast.error(e.message).goAway(3000) this.$toast.error(e.message).goAway(3000)
} }
}, },
async deleteToken (item) { async deleteToken(item) {
try { try {
this.tokens = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcApiTokenDelete', { id: item.id }]) this.tokens = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcApiTokenDelete', { id: item.id }])
this.$toast.success('Token deleted successfully').goAway(3000) this.$toast.success('Token deleted successfully').goAway(3000)

6
packages/nc-gui/components/auth/authHooks.vue

@ -55,16 +55,16 @@ export default {
data: () => ({ data: () => ({
data: {} data: {}
}), }),
async created () { async created() {
await this.loadHook() await this.loadHook()
}, },
methods: { methods: {
async loadHook () { async loadHook() {
this.data = await this.$store.dispatch('sqlMgr/ActSqlOp', [{ this.data = await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.nodes.dbAlias dbAlias: this.nodes.dbAlias
}, 'xcAuthHookGet']) }, 'xcAuthHookGet'])
}, },
async save () { async save() {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.nodes.dbAlias dbAlias: this.nodes.dbAlias

18
packages/nc-gui/components/auth/roles.vue

@ -201,7 +201,7 @@ export default {
}), }),
computed: { computed: {
operations () { operations() {
return [ return [
'create', 'create',
'read', 'read',
@ -209,16 +209,16 @@ export default {
'delete' 'delete'
] ]
}, },
customRolesCount () { customRolesCount() {
return (this.roles && this.roles.filter(r => r.type !== 'SYSTEM').length) || 0 return (this.roles && this.roles.filter(r => r.type !== 'SYSTEM').length) || 0
} }
}, },
async created () { async created() {
await this.loadRoles() await this.loadRoles()
await this.loadAggrAcl() await this.loadAggrAcl()
}, },
methods: { methods: {
async loadRoles () { async loadRoles() {
try { try {
this.roles = (await this.$axios.get('/admin/roles', { this.roles = (await this.$axios.get('/admin/roles', {
headers: { headers: {
@ -234,7 +234,7 @@ export default {
this.edited = false this.edited = false
}, },
async loadAggrAcl () { async loadAggrAcl() {
/* try { /* try {
this.aggrAcl = await this.$store.dispatch('sqlMgr/ActSqlOp', [ this.aggrAcl = await this.$store.dispatch('sqlMgr/ActSqlOp', [
// todo: manage dbAlias or get aggregated // todo: manage dbAlias or get aggregated
@ -244,7 +244,7 @@ export default {
} catch (e) { } catch (e) {
} */ } */
}, },
addRole () { addRole() {
this.roles.push({ this.roles.push({
title: ('role name ' + (this.customRolesCount || '')).trim(), title: ('role name ' + (this.customRolesCount || '')).trim(),
description: 'Role description' description: 'Role description'
@ -252,7 +252,7 @@ export default {
this.edited = true this.edited = true
this.scrollAndFocusLastRow() this.scrollAndFocusLastRow()
}, },
async save () { async save() {
try { try {
await this.$axios.put('/admin/roles', { roles: this.roles }, { await this.$axios.put('/admin/roles', { roles: this.roles }, {
headers: { headers: {
@ -281,7 +281,7 @@ export default {
await this.loadRoles() await this.loadRoles()
await this.loadAggrAcl() await this.loadAggrAcl()
}, },
async confirmDelete (hideDialog) { async confirmDelete(hideDialog) {
if (hideDialog) { if (hideDialog) {
this.showConfirmDlg = false this.showConfirmDlg = false
return return
@ -303,7 +303,7 @@ export default {
} }
this.showConfirmDlg = false this.showConfirmDlg = false
}, },
scrollAndFocusLastRow () { scrollAndFocusLastRow() {
this.$nextTick(() => { this.$nextTick(() => {
document.querySelector('.project-container').scrollTop = 9999 document.querySelector('.project-container').scrollTop = 9999
const menuActivator = this.$el && this.$el.querySelector('tr:last-child .v-small-dialog__activator__content') const menuActivator = this.$el && this.$el.querySelector('tr:last-child .v-small-dialog__activator__content')

44
packages/nc-gui/components/auth/userManagement.vue

@ -537,10 +537,10 @@ export default {
}), }),
computed: { computed: {
inviteUrl () { inviteUrl() {
return this.invite_token ? `${location.origin}${location.pathname}#/user/authentication/signup/${this.invite_token.invite_token}` : null return this.invite_token ? `${location.origin}${location.pathname}#/user/authentication/signup/${this.invite_token.invite_token}` : null
}, },
rolesColors () { rolesColors() {
const colors = this.$store.state.windows.darkTheme ? enumColor.dark : enumColor.light const colors = this.$store.state.windows.darkTheme ? enumColor.dark : enumColor.light
return this.roles.reduce((o, r, i) => { return this.roles.reduce((o, r, i) => {
o[r] = colors[i % colors.length] o[r] = colors[i % colors.length]
@ -548,32 +548,32 @@ export default {
}, {}) }, {})
}, },
selectedRoles: { selectedRoles: {
get () { get() {
return this.selectedUser && this.selectedUser.roles ? this.selectedUser.roles.split(',') : [] return this.selectedUser && this.selectedUser.roles ? this.selectedUser.roles.split(',') : []
}, },
set (roles) { set(roles) {
if (this.selectedUser) { if (this.selectedUser) {
this.selectedUser.roles = roles.filter(Boolean).join(',') this.selectedUser.roles = roles.filter(Boolean).join(',')
} }
} }
}, },
selectedUserIndex: { selectedUserIndex: {
get () { get() {
return this.users ? this.users.findIndex(u => u.email === this.selectedUser.email) : -1 return this.users ? this.users.findIndex(u => u.email === this.selectedUser.email) : -1
}, },
set (i) { set(i) {
this.selectedUser = this.users[i] this.selectedUser = this.users[i]
} }
} }
}, },
watch: { watch: {
options: { options: {
async handler () { async handler() {
await this.loadUsers() await this.loadUsers()
}, },
deep: true deep: true
}, },
userEditDialog (v) { userEditDialog(v) {
if (v && (this.selectedUser && !this.selectedUser.id)) { if (v && (this.selectedUser && !this.selectedUser.id)) {
this.$nextTick(() => { this.$nextTick(() => {
setTimeout(() => { setTimeout(() => {
@ -583,23 +583,23 @@ export default {
} }
} }
}, },
async created () { async created() {
this.$eventBus.$on('show-add-user', this.addUser) this.$eventBus.$on('show-add-user', this.addUser)
await this.loadUsers() await this.loadUsers()
await this.loadRoles() await this.loadRoles()
}, },
beforeDestroy () { beforeDestroy() {
this.$eventBus.$off('show-add-user', this.addUser) this.$eventBus.$off('show-add-user', this.addUser)
}, },
methods: { methods: {
simpleAnim () { simpleAnim() {
const count = 30 const count = 30
const defaults = { const defaults = {
origin: { y: 0.7 }, origin: { y: 0.7 },
zIndex: 9999999 zIndex: 9999999
} }
function fire (particleRatio, opts) { function fire(particleRatio, opts) {
window.confetti(Object.assign({}, defaults, opts, { window.confetti(Object.assign({}, defaults, opts, {
particleCount: Math.floor(count * particleRatio) particleCount: Math.floor(count * particleRatio)
})) }))
@ -628,11 +628,11 @@ export default {
startVelocity: 45 startVelocity: 45
}) })
}, },
getInviteUrl (token) { getInviteUrl(token) {
return token ? `${location.origin}${location.pathname}#/user/authentication/signup/${token}` : null return token ? `${location.origin}${location.pathname}#/user/authentication/signup/${token}` : null
}, },
clipboard (str) { clipboard(str) {
const el = document.createElement('textarea') const el = document.createElement('textarea')
el.addEventListener('focusin', e => e.stopPropagation()) el.addEventListener('focusin', e => e.stopPropagation())
el.value = str el.value = str
@ -641,7 +641,7 @@ export default {
document.execCommand('copy') document.execCommand('copy')
document.body.removeChild(el) document.body.removeChild(el)
}, },
async rensendInvite (id) { async rensendInvite(id) {
try { try {
await this.$axios.post('/admin/resendInvite/' + id, { await this.$axios.post('/admin/resendInvite/' + id, {
projectName: this.$store.getters['project/GtrProjectName'] projectName: this.$store.getters['project/GtrProjectName']
@ -659,7 +659,7 @@ export default {
this.$toast.error(e.response.data.msg).goAway(3000) this.$toast.error(e.response.data.msg).goAway(3000)
} }
}, },
async loadUsers () { async loadUsers() {
try { try {
const { page = 1, itemsPerPage = 20 } = this.options const { page = 1, itemsPerPage = 20 } = this.options
const data = (await this.$axios.get('/admin', { const data = (await this.$axios.get('/admin', {
@ -682,7 +682,7 @@ export default {
console.log(e) console.log(e)
} }
}, },
async loadRoles () { async loadRoles() {
try { try {
this.roles = (await this.$axios.get('/admin/roles', { this.roles = (await this.$axios.get('/admin/roles', {
headers: { headers: {
@ -696,7 +696,7 @@ export default {
console.log(e) console.log(e)
} }
}, },
async deleteUser (id) { async deleteUser(id) {
try { try {
await this.$axios.delete('/admin/' + id, { await this.$axios.delete('/admin/' + id, {
params: { params: {
@ -714,7 +714,7 @@ export default {
} }
}, },
async confirmDelete (hideDialog) { async confirmDelete(hideDialog) {
if (hideDialog) { if (hideDialog) {
this.showConfirmDlg = false this.showConfirmDlg = false
return return
@ -722,14 +722,14 @@ export default {
await this.deleteUser(this.deleteId) await this.deleteUser(this.deleteId)
this.showConfirmDlg = false this.showConfirmDlg = false
}, },
addUser () { addUser() {
this.invite_token = null this.invite_token = null
this.selectedUser = { this.selectedUser = {
roles: 'editor' roles: 'editor'
} }
this.userEditDialog = true this.userEditDialog = true
}, },
async inviteUser (email) { async inviteUser(email) {
try { try {
await this.$axios.post('/admin', { await this.$axios.post('/admin', {
email, email,
@ -746,7 +746,7 @@ export default {
this.$toast.error(e.response.data.msg).goAway(3000) this.$toast.error(e.response.data.msg).goAway(3000)
} }
}, },
async saveUser () { async saveUser() {
if (this.loading || !this.valid || !this.selectedUser) { if (this.loading || !this.valid || !this.selectedUser) {
return return
} }

2
packages/nc-gui/components/authTab.vue

@ -53,7 +53,7 @@ export default {
data: () => ({ data: () => ({
showConfirmDlg: false showConfirmDlg: false
}), }),
async created () {}, async created() {},
methods: {} methods: {}
} }
</script> </script>

8
packages/nc-gui/components/changeEnv.vue

@ -52,15 +52,15 @@ export default {
envList: 'project/GtrEnvList' envList: 'project/GtrEnvList'
}), }),
dialogShow: { dialogShow: {
get () { get() {
return this.value return this.value
}, },
set (val) { set(val) {
this.$emit('input', val) this.$emit('input', val)
} }
} }
}, },
mounted () { mounted() {
const unserializedList = this.$store.state.project.unserializedList const unserializedList = this.$store.state.project.unserializedList
this.selectedEnv = (unserializedList[0] && this.selectedEnv = (unserializedList[0] &&
unserializedList[0].projectJson && unserializedList[0].projectJson &&
@ -73,7 +73,7 @@ export default {
}, (value) => { this.selectedEnv = value }) }, (value) => { this.selectedEnv = value })
}, },
methods: { methods: {
async changeEnv () { async changeEnv() {
this.progressbar = true this.progressbar = true
await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'projectChangeEnv', { env: this.selectedEnv }]) await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'projectChangeEnv', { env: this.selectedEnv }])
await new Promise((resolve) => { await new Promise((resolve) => {

100
packages/nc-gui/components/createOrEditProject.vue

@ -1011,7 +1011,7 @@ export default {
}, },
mixins: [colors], mixins: [colors],
layout: 'empty', layout: 'empty',
data () { data() {
return { return {
testSuccess: false, testSuccess: false,
projectCreated: false, projectCreated: false,
@ -1369,23 +1369,23 @@ export default {
}, },
computed: { computed: {
...mapGetters({ sqlMgr: 'sqlMgr/sqlMgr' }), ...mapGetters({ sqlMgr: 'sqlMgr/sqlMgr' }),
isTitle () { isTitle() {
return this.project.title && this.project.title.trim().length return this.project.title && this.project.title.trim().length
}, },
envStatusValid () { envStatusValid() {
return ( return (
this.project.envs && this.project.envs &&
Object.values(this.project.envs).every(this.getEnvironmentStatusAggregatedNew) Object.values(this.project.envs).every(this.getEnvironmentStatusAggregatedNew)
) )
}, },
typeIcon () { typeIcon() {
if (this.project.projectType) { if (this.project.projectType) {
return this.projectTypes.find(({ value }) => value === this.project.projectType) return this.projectTypes.find(({ value }) => value === this.project.projectType)
} else { } else {
return { icon: 'mdi-server', iconColor: 'primary' } return { icon: 'mdi-server', iconColor: 'primary' }
} }
}, },
databaseNamesReverse () { databaseNamesReverse() {
return Object.entries(this.databaseNames).reduce((newObj, [value, key]) => { return Object.entries(this.databaseNames).reduce((newObj, [value, key]) => {
newObj[key] = value newObj[key] = value
return newObj return newObj
@ -1393,7 +1393,7 @@ export default {
} }
}, },
methods: { methods: {
async enableAllSchemas () { async enableAllSchemas() {
this.$toast.info('Enabled all schemas').goAway(3000) this.$toast.info('Enabled all schemas').goAway(3000)
this.allSchemas = true this.allSchemas = true
await this.$axios({ await this.$axios({
@ -1405,23 +1405,23 @@ export default {
...mapActions({ ...mapActions({
loadProjects: 'project/loadProjects' loadProjects: 'project/loadProjects'
}), }),
onAdvancePanelToggle () { onAdvancePanelToggle() {
if (this.$refs.monacoEditor) { if (this.$refs.monacoEditor) {
setTimeout(() => this.$refs.monacoEditor.resizeLayout(), 400) setTimeout(() => this.$refs.monacoEditor.resizeLayout(), 400)
} }
}, },
getProjectEditTooltip () { getProjectEditTooltip() {
// return `Opens ${path.join(this.project.folder, 'config.xc.json')} and edit - its really simple`; // return `Opens ${path.join(this.project.folder, 'config.xc.json')} and edit - its really simple`;
}, },
openJsonInSystemEditor () { openJsonInSystemEditor() {
// shell.openItem(path.join(this.project.folder, 'config.xc.json')); // shell.openItem(path.join(this.project.folder, 'config.xc.json'));
}, },
readFileContent (db, obj, key, index) { readFileContent(db, obj, key, index) {
readFile(this.$refs[`${key}FilePath`][index], (data) => { readFile(this.$refs[`${key}FilePath`][index], (data) => {
Vue.set(db.connection[obj], key, data) Vue.set(db.connection[obj], key, data)
}) })
}, },
selectFile (db, obj, key, index) { selectFile(db, obj, key, index) {
this.$refs[key][index].click() this.$refs[key][index].click()
// console.log(obj, key); // console.log(obj, key);
@ -1437,7 +1437,7 @@ export default {
// Vue.set(db.connection[obj], key, file[0].toString()) // Vue.set(db.connection[obj], key, file[0].toString())
// } // }
}, },
onPanelToggle (panelIndex, envKey) { onPanelToggle(panelIndex, envKey) {
this.$nextTick(() => { this.$nextTick(() => {
if (this.panel !== undefined) { if (this.panel !== undefined) {
const panelContainer = this.$refs.panelContainer const panelContainer = this.$refs.panelContainer
@ -1455,14 +1455,14 @@ export default {
} }
}) })
}, },
scrollToTop () { scrollToTop() {
document.querySelector('html').scrollTop = 0 document.querySelector('html').scrollTop = 0
}, },
showDBTabInEnvPanel (panelIndex, tabIndex) { showDBTabInEnvPanel(panelIndex, tabIndex) {
this.panel = panelIndex this.panel = panelIndex
Vue.set(this.databases, panelIndex, tabIndex) Vue.set(this.databases, panelIndex, tabIndex)
}, },
getProjectJson () { getProjectJson() {
console.log('Project json before creating', this.project) console.log('Project json before creating', this.project)
/** /**
@ -1574,7 +1574,7 @@ export default {
return xcConfig return xcConfig
}, },
constructProjectJsonFromProject (project) { constructProjectJsonFromProject(project) {
// const {projectJson: envs, ...rest} = project; // const {projectJson: envs, ...rest} = project;
// let p = {...rest, ...envs}; // let p = {...rest, ...envs};
@ -1634,7 +1634,7 @@ export default {
delete p.mailer delete p.mailer
}, },
async createOrUpdateProject () { async createOrUpdateProject() {
const projectJson = this.getProjectJson() const projectJson = this.getProjectJson()
delete projectJson.folder delete projectJson.folder
@ -1693,7 +1693,7 @@ export default {
this.projectReloading = false this.projectReloading = false
}, },
mtdDialogGetEnvNameSubmit (envName, cookie) { mtdDialogGetEnvNameSubmit(envName, cookie) {
console.log(envName) console.log(envName)
this.dialogGetEnvName.dialogShow = false this.dialogGetEnvName.dialogShow = false
if (envName in this.project.envs) { if (envName in this.project.envs) {
@ -1736,15 +1736,15 @@ export default {
}) })
} }
}, },
mtdDialogGetEnvNameCancel () { mtdDialogGetEnvNameCancel() {
console.log('mtdDialogGetTableNameCancel cancelled') console.log('mtdDialogGetTableNameCancel cancelled')
this.dialogGetEnvName.dialogShow = false this.dialogGetEnvName.dialogShow = false
}, },
addNewEnvironment () { addNewEnvironment() {
this.dialogGetEnvName.dialogShow = true this.dialogGetEnvName.dialogShow = true
}, },
addNewDB (envKey, panelIndex) { addNewDB(envKey, panelIndex) {
const len = this.project.envs[envKey].db.length const len = this.project.envs[envKey].db.length
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const lastDbName = `${this.project.title}_${envKey}_${len}` const lastDbName = `${this.project.title}_${envKey}_${len}`
@ -1785,10 +1785,10 @@ export default {
this.databases[panelIndex] = newlyCreatedIndex this.databases[panelIndex] = newlyCreatedIndex
}, },
testConnectionMethodSubmit () { testConnectionMethodSubmit() {
this.dialog.show = false this.dialog.show = false
}, },
selectDir (ev) { selectDir(ev) {
// console.log(ev) // console.log(ev)
// const file = dialog.showOpenDialog({ // const file = dialog.showOpenDialog({
// properties: ['openDirectory'] // properties: ['openDirectory']
@ -1799,7 +1799,7 @@ export default {
// this.userSelectedDir = true // this.userSelectedDir = true
// } // }
}, },
selectSqliteFile (db) { selectSqliteFile(db) {
// console.log(ev) // console.log(ev)
// const file = dialog.showOpenDialog({ // const file = dialog.showOpenDialog({
// properties: ["openFile"] // properties: ["openFile"]
@ -1809,7 +1809,7 @@ export default {
// } // }
}, },
getDbStatusColor (db) { getDbStatusColor(db) {
switch (db.ui.setup) { switch (db.ui.setup) {
case -1: case -1:
return 'red' return 'red'
@ -1825,7 +1825,7 @@ export default {
} }
}, },
getDbStatusTooltip (db) { getDbStatusTooltip(db) {
switch (db.ui.setup) { switch (db.ui.setup) {
case -1: case -1:
return 'DB Connection NOT successful' return 'DB Connection NOT successful'
@ -1840,7 +1840,7 @@ export default {
break break
} }
}, },
async newTestConnection (db, env, panelIndex) { async newTestConnection(db, env, panelIndex) {
console.log(this.project.envs[env][0]) console.log(this.project.envs[env][0])
if ( if (
db.connection.host === 'localhost' && db.connection.host === 'localhost' &&
@ -1931,7 +1931,7 @@ export default {
} }
}, },
sendAdvancedConfig (connection) { sendAdvancedConfig(connection) {
if (!connection.ssl) { return false } if (!connection.ssl) { return false }
let sendAdvancedConfig = false let sendAdvancedConfig = false
const sslOptions = Object.values(connection.ssl).filter(el => !!el) const sslOptions = Object.values(connection.ssl).filter(el => !!el)
@ -1944,7 +1944,7 @@ export default {
return sendAdvancedConfig return sendAdvancedConfig
}, },
handleSSL (db, creating = true) { handleSSL(db, creating = true) {
console.log('handleSSL', db) console.log('handleSSL', db)
const sendAdvancedConfig = this.sendAdvancedConfig(db.connection) const sendAdvancedConfig = this.sendAdvancedConfig(db.connection)
if (!sendAdvancedConfig) { if (!sendAdvancedConfig) {
@ -1963,8 +1963,8 @@ export default {
// } // }
} }
}, },
getDatabaseForTestConnection (dbType) {}, getDatabaseForTestConnection(dbType) {},
async testConnection (db, env, panelIndex) { async testConnection(db, env, panelIndex) {
this.$store.commit('notification/MutToggleProgressBar', true) this.$store.commit('notification/MutToggleProgressBar', true)
try { try {
if (!(await this.newTestConnection(db, env, panelIndex))) { if (!(await this.newTestConnection(db, env, panelIndex))) {
@ -2020,17 +2020,17 @@ export default {
this.$store.commit('notification/MutToggleProgressBar', false) this.$store.commit('notification/MutToggleProgressBar', false)
} }
}, },
getEnvironmentStatusAggregated (dbs) { getEnvironmentStatusAggregated(dbs) {
return dbs.every(db => db.ui.setup === 1) return dbs.every(db => db.ui.setup === 1)
}, },
getEnvironmentStatusAggregatedNew (dbs) { getEnvironmentStatusAggregatedNew(dbs) {
return dbs.db.every(db => db.ui.setup === 1) return dbs.db.every(db => db.ui.setup === 1)
}, },
openFirstPanel () { openFirstPanel() {
if (!this.edit) { this.panel = 0 } if (!this.edit) { this.panel = 0 }
}, },
onDatabaseTypeChanged (client, db1, index, env) { onDatabaseTypeChanged(client, db1, index, env) {
for (const env in this.project.envs) { for (const env in this.project.envs) {
if (this.project.envs[env].db.length > index) { if (this.project.envs[env].db.length > index) {
const db = this.project.envs[env].db[index] const db = this.project.envs[env].db[index]
@ -2071,13 +2071,13 @@ export default {
} }
} }
}, },
selectDatabaseClient (database, index = 0) { selectDatabaseClient(database, index = 0) {
if (this.client) { this.client[index] = database } if (this.client) { this.client[index] = database }
}, },
setDBStatus (db, status) { setDBStatus(db, status) {
db.ui.setup = status db.ui.setup = status
}, },
removeDBFromEnv (db, env, panelIndex, dbIndex) { removeDBFromEnv(db, env, panelIndex, dbIndex) {
console.log(db, env, panelIndex, dbIndex) console.log(db, env, panelIndex, dbIndex)
for (const env in this.project.envs) { for (const env in this.project.envs) {
@ -2086,15 +2086,15 @@ export default {
} }
} }
}, },
removeEnv (envKey) { removeEnv(envKey) {
delete this.project.envs[envKey] delete this.project.envs[envKey]
Vue.set(this.project, 'envs', { ...this.project.envs }) Vue.set(this.project, 'envs', { ...this.project.envs })
} }
}, },
fetch ({ store, params }) {}, fetch({ store, params }) {},
beforeCreated () {}, beforeCreated() {},
watch: { watch: {
'project.title' (newValue, oldValue) { 'project.title'(newValue, oldValue) {
if (!newValue) { return } if (!newValue) { return }
if (!this.edit) { if (!this.edit) {
// Vue.set(this.project, 'folder', slash(path.join(this.baseFolder, newValue))) // Vue.set(this.project, 'folder', slash(path.join(this.baseFolder, newValue)))
@ -2121,7 +2121,7 @@ export default {
}, },
'project.envs': { 'project.envs': {
deep: true, deep: true,
handler (envs) { handler(envs) {
if (typeof envs === 'object' && envs) { if (typeof envs === 'object' && envs) {
Object.entries(envs).forEach(([key, env]) => { Object.entries(envs).forEach(([key, env]) => {
let res = 1 let res = 1
@ -2153,7 +2153,7 @@ export default {
} }
} }
}, },
async created () { async created() {
this.compErrorMessage = this.compErrorMessage =
this.compErrorMessages[Math.floor(Math.random() * this.compErrorMessages.length)] this.compErrorMessages[Math.floor(Math.random() * this.compErrorMessages.length)]
@ -2218,8 +2218,8 @@ export default {
// } // }
} }
}, },
beforeMount () {}, beforeMount() {},
mounted () { mounted() {
this.$set( this.$set(
this.project, this.project,
'title', 'title',
@ -2236,12 +2236,12 @@ export default {
input.focus() input.focus()
}) })
}, },
beforeDestroy () {}, beforeDestroy() {},
destroy () {}, destroy() {},
validate ({ params }) { validate({ params }) {
return true return true
}, },
head () { head() {
return { return {
title: this.$t('projects.ext_db.head.title') title: this.$t('projects.ext_db.head.title')
} }

8
packages/nc-gui/components/global/recursiveMenu.vue

@ -82,23 +82,23 @@ export default {
positionX: Number, positionX: Number,
positionY: Number positionY: Number
}, },
data () { data() {
return { return {
active: false active: false
} }
}, },
watch: { watch: {
// two way binding of v-model // two way binding of v-model
value (v) { value(v) {
this.active = v this.active = v
}, },
active (v) { active(v) {
this.$emit('input', v) this.$emit('input', v)
} }
}, },
methods: { methods: {
// event propagating to parent v-menu(click event) // event propagating to parent v-menu(click event)
onSubMenuClick (event) { onSubMenuClick(event) {
this.$emit('click', event) this.$emit('click', event)
// hiding parent menu // hiding parent menu
this.active = false this.active = false

28
packages/nc-gui/components/global/xAutoComplete.vue

@ -43,7 +43,7 @@ export default {
env: String, env: String,
styles: [Array, Object, String] styles: [Array, Object, String]
}, },
data () { data() {
return { return {
show: false, show: false,
x: 0, x: 0,
@ -56,35 +56,35 @@ export default {
}, },
computed: { computed: {
// filtered list based on input // filtered list based on input
items () { items() {
return this.envValues.filter(s => s.includes(this.activeValue)) return this.envValues.filter(s => s.includes(this.activeValue))
}, },
// for setting menu width to textfield width // for setting menu width to textfield width
width () { width() {
return this.input && this.input.clientWidth return this.input && this.input.clientWidth
}, },
// extracting class names from root element // extracting class names from root element
classNames () { classNames() {
return this.el && this.el.className return this.el && this.el.className
}, },
// v-model for the text filed // v-model for the text filed
autocomplete: { autocomplete: {
get () { get() {
return this.value return this.value
}, },
set (val) { set(val) {
this.$emit('input', val) this.$emit('input', val)
} }
}, },
// extracting current env keys // extracting current env keys
envValues () { envValues() {
const envObj = this.isDashboard ? this.$store.getters['project/GtrApiEnvironment'] : this.$store.getters['project/GtrDefaultApiEnvironment'] const envObj = this.isDashboard ? this.$store.getters['project/GtrApiEnvironment'] : this.$store.getters['project/GtrDefaultApiEnvironment']
return envObj && envObj[this.env] ? Object.keys(envObj[this.env]) : [] return envObj && envObj[this.env] ? Object.keys(envObj[this.env]) : []
}, },
isEnvFound () { isEnvFound() {
return /{{\s*\w+\s*}}/.test(this.value) return /{{\s*\w+\s*}}/.test(this.value)
}, },
isEnvUsageValid () { isEnvUsageValid() {
const re = /{{\s*(\w+)\s*}}/g const re = /{{\s*(\w+)\s*}}/g
let m let m
// eslint-disable-next-line no-cond-assign // eslint-disable-next-line no-cond-assign
@ -94,16 +94,16 @@ export default {
return true return true
} }
}, },
mounted () { mounted() {
this.el = this.$el this.el = this.$el
// getting input element reference // getting input element reference
this.input = this.$refs.input && this.$refs.input.$el.querySelector('input') this.input = this.$refs.input && this.$refs.input.$el.querySelector('input')
}, },
created () { created() {
}, },
methods: { methods: {
// handling input event // handling input event
onInput (v) { onInput(v) {
this.curPos = this.input.selectionStart || 0 this.curPos = this.input.selectionStart || 0
// extracting string from beginning to caret position // extracting string from beginning to caret position
// then using regex to check and extract certain pattern like // then using regex to check and extract certain pattern like
@ -119,7 +119,7 @@ export default {
this.show = false this.show = false
} }
}, },
onKeyup (e) { onKeyup(e) {
const menu = this.$refs.autoMenu const menu = this.$refs.autoMenu
// handlig up and down keys // handlig up and down keys
if (this.show && (e.which === 40 || e.which === 38)) { if (this.show && (e.which === 40 || e.which === 38)) {
@ -132,7 +132,7 @@ export default {
menu.onKeyDown(e) menu.onKeyDown(e)
} }
}, },
onSelect (item) { onSelect(item) {
// appending menu value to the input // appending menu value to the input
this.input.setRangeText( this.input.setRangeText(
// add closing only when its necessary // add closing only when its necessary

4
packages/nc-gui/components/global/xIcon.vue

@ -49,12 +49,12 @@ export default {
iconClass: String iconClass: String
}, },
computed: { computed: {
colors () { colors() {
return this.color ? (Array.isArray(this.color) ? this.color : this.color.split(' ')) : [] return this.color ? (Array.isArray(this.color) ? this.color : this.color.split(' ')) : []
} }
}, },
methods: { methods: {
triggerClick (...args) { triggerClick(...args) {
this.$emit('click', ...args) this.$emit('click', ...args)
} }
} }

16
packages/nc-gui/components/monaco/Monaco.vue

@ -34,7 +34,7 @@ export default {
// sqlFormatter // sqlFormatter
}, },
props: ['code', 'cssStyle', 'readOnly', 'heading'], props: ['code', 'cssStyle', 'readOnly', 'heading'],
data () { data() {
return { return {
codeLocal: `${this.code || ''}`, codeLocal: `${this.code || ''}`,
selection: null, selection: null,
@ -45,23 +45,23 @@ export default {
}, },
computed: {}, computed: {},
watch: { watch: {
codeLocal (newValue) { codeLocal(newValue) {
// INFO: for updating value of prop `code` in parent comp // INFO: for updating value of prop `code` in parent comp
// console.log("update:code Event Emitted", newValue); // console.log("update:code Event Emitted", newValue);
this.$emit('update:code', newValue) this.$emit('update:code', newValue)
}, },
code (newValue) { code(newValue) {
this.codeLocal = newValue this.codeLocal = newValue
} }
}, },
beforeCreate () { beforeCreate() {
// console.log(MonacoEditor) // console.log(MonacoEditor)
}, },
created () { created() {
// //
}, },
methods: { methods: {
selectionFn () { selectionFn() {
const editor = this.$refs.editor.getMonaco() const editor = this.$refs.editor.getMonaco()
const range = editor.getSelection() const range = editor.getSelection()
const selectedText = editor.getModel().getValueInRange(range) const selectedText = editor.getModel().getValueInRange(range)
@ -69,7 +69,7 @@ export default {
this.selection = selectedText this.selection = selectedText
this.selectionRange = range this.selectionRange = range
}, },
pretify () { pretify() {
// console.log("this.code", this.code); // console.log("this.code", this.code);
const editor = this.$refs.editor.getMonaco() const editor = this.$refs.editor.getMonaco()
@ -94,7 +94,7 @@ export default {
editor.executeEdits('sqlFormatter', [op]) editor.executeEdits('sqlFormatter', [op])
} }
}, },
toggleMiniMap () { toggleMiniMap() {
const editor = this.$refs.editor.getMonaco() const editor = this.$refs.editor.getMonaco()
this.minimap.enabled = !this.minimap.enabled this.minimap.enabled = !this.minimap.enabled
editor.updateOptions({ editor.updateOptions({

40
packages/nc-gui/components/monaco/MonacoSqlEditor.vue

@ -35,7 +35,7 @@ export default {
// sqlFormatter // sqlFormatter
}, },
props: ['code', 'cssStyle', 'readOnly', 'heading', 'tables', 'columnNames', 'columnNameCbk'], props: ['code', 'cssStyle', 'readOnly', 'heading', 'tables', 'columnNames', 'columnNameCbk'],
data () { data() {
const vm = this const vm = this
return { return {
codeLocal: `${this.code || ''}`, codeLocal: `${this.code || ''}`,
@ -60,7 +60,7 @@ export default {
contextMenuOrder: 1.5, contextMenuOrder: 1.5,
// Method that will be executed when the action is triggered. // Method that will be executed when the action is triggered.
// @param editor The editor instance is passed in as a convinience // @param editor The editor instance is passed in as a convinience
run (ed) { run(ed) {
vm.pretify() vm.pretify()
} }
}, { }, {
@ -80,7 +80,7 @@ export default {
contextMenuOrder: 1.5, contextMenuOrder: 1.5,
// Method that will be executed when the action is triggered. // Method that will be executed when the action is triggered.
// @param editor The editor instance is passed in as a convinience // @param editor The editor instance is passed in as a convinience
run (ed) { run(ed) {
vm.$emit('execute', ed) vm.$emit('execute', ed)
} }
}, { }, {
@ -93,7 +93,7 @@ export default {
keybindingContext: null, keybindingContext: null,
contextMenuGroupId: 'navigation', contextMenuGroupId: 'navigation',
contextMenuOrder: 1.5, contextMenuOrder: 1.5,
run (ed) { run(ed) {
vm.$emit('runAll', ed) vm.$emit('runAll', ed)
} }
}, { }, {
@ -106,7 +106,7 @@ export default {
keybindingContext: null, keybindingContext: null,
contextMenuGroupId: 'navigation', contextMenuGroupId: 'navigation',
contextMenuOrder: 1.5, contextMenuOrder: 1.5,
run (ed) { run(ed) {
vm.$emit('bookmark', ed) vm.$emit('bookmark', ed)
} }
}, { }, {
@ -119,7 +119,7 @@ export default {
keybindingContext: null, keybindingContext: null,
contextMenuGroupId: 'navigation', contextMenuGroupId: 'navigation',
contextMenuOrder: 1.5, contextMenuOrder: 1.5,
run (ed) { run(ed) {
vm.$emit('searchHistory', ed) vm.$emit('searchHistory', ed)
} }
}, { }, {
@ -132,7 +132,7 @@ export default {
keybindingContext: null, keybindingContext: null,
contextMenuGroupId: 'navigation', contextMenuGroupId: 'navigation',
contextMenuOrder: 1.5, contextMenuOrder: 1.5,
run (ed) { run(ed) {
vm.$emit('toggleBookmark', ed) vm.$emit('toggleBookmark', ed)
} }
}, { }, {
@ -145,7 +145,7 @@ export default {
keybindingContext: null, keybindingContext: null,
contextMenuGroupId: 'navigation', contextMenuGroupId: 'navigation',
contextMenuOrder: 1.5, contextMenuOrder: 1.5,
run (ed) { run(ed) {
vm.$emit('openFile', ed) vm.$emit('openFile', ed)
} }
}, { }, {
@ -158,7 +158,7 @@ export default {
keybindingContext: null, keybindingContext: null,
contextMenuGroupId: 'navigation', contextMenuGroupId: 'navigation',
contextMenuOrder: 1.5, contextMenuOrder: 1.5,
run (ed) { run(ed) {
vm.$emit('saveFile', ed) vm.$emit('saveFile', ed)
} }
}, { }, {
@ -171,7 +171,7 @@ export default {
keybindingContext: null, keybindingContext: null,
contextMenuGroupId: 'navigation', contextMenuGroupId: 'navigation',
contextMenuOrder: 1.5, contextMenuOrder: 1.5,
run (ed) { run(ed) {
vm.$emit('clearEditor', ed) vm.$emit('clearEditor', ed)
} }
}] }]
@ -180,23 +180,23 @@ export default {
}, },
computed: {}, computed: {},
watch: { watch: {
codeLocal (newValue) { codeLocal(newValue) {
// INFO: for updating value of prop `code` in parent comp // INFO: for updating value of prop `code` in parent comp
// console.log("update:code Event Emitted", newValue); // console.log("update:code Event Emitted", newValue);
this.$emit('update:code', newValue) this.$emit('update:code', newValue)
}, },
code (newValue) { code(newValue) {
this.codeLocal = newValue this.codeLocal = newValue
} }
}, },
beforeCreate () { beforeCreate() {
// console.log(MonacoEditor) // console.log(MonacoEditor)
}, },
created () { created() {
// //
}, },
methods: { methods: {
selectionFn () { selectionFn() {
const editor = this.$refs.editor.getMonaco() const editor = this.$refs.editor.getMonaco()
const range = editor.getSelection() const range = editor.getSelection()
const selectedText = editor.getModel().getValueInRange(range) const selectedText = editor.getModel().getValueInRange(range)
@ -204,7 +204,7 @@ export default {
this.selection = selectedText this.selection = selectedText
this.selectionRange = range this.selectionRange = range
}, },
pretify () { pretify() {
// console.log("this.code", this.code); // console.log("this.code", this.code);
const editor = this.$refs.editor.getMonaco() const editor = this.$refs.editor.getMonaco()
@ -229,7 +229,7 @@ export default {
editor.executeEdits('sqlFormatter', [op]) editor.executeEdits('sqlFormatter', [op])
} }
}, },
toggleMiniMap () { toggleMiniMap() {
const editor = this.$refs.editor.getMonaco() const editor = this.$refs.editor.getMonaco()
this.minimap.enabled = !this.minimap.enabled this.minimap.enabled = !this.minimap.enabled
editor.updateOptions({ editor.updateOptions({
@ -238,13 +238,13 @@ export default {
} }
}) })
}, },
getCurrentQuery () { getCurrentQuery() {
return this.$refs.editor.getCurrentQuery() return this.$refs.editor.getCurrentQuery()
}, },
getAllContent () { getAllContent() {
return this.$refs.editor.getAllContent() return this.$refs.editor.getAllContent()
}, },
focus () { focus() {
this.$refs.editor.focus() this.$refs.editor.focus()
} }
} }

2
packages/nc-gui/components/monaco/sqlAutoCompletions.js

@ -1,4 +1,4 @@
export default function (monaco) { export default function(monaco) {
return [ return [
{ {
insertText: 'ALTER ', insertText: 'ALTER ',

10
packages/nc-gui/components/notification.vue

@ -93,18 +93,18 @@ export default {
GetHasErrors: 'notification/GetHasErrors', GetHasErrors: 'notification/GetHasErrors',
GetPendingStatus: 'notification/GetPendingStatus' GetPendingStatus: 'notification/GetPendingStatus'
}), }),
notificationList () { notificationList() {
return this.$store.state.notification.list return this.$store.state.notification.list
} }
}, },
filters: { filters: {
capitalize (value) { capitalize(value) {
if (!value) { return '' } if (!value) { return '' }
value = value.toString() value = value.toString()
return value.charAt(0).toUpperCase() + value.slice(1) return value.charAt(0).toUpperCase() + value.slice(1)
} }
}, },
data () { data() {
return { return {
notificationIcons: { notificationIcons: {
success: { success: {
@ -126,7 +126,7 @@ export default {
} }
}, },
methods: { methods: {
timeDifference (previous) { timeDifference(previous) {
const current = Date.now() const current = Date.now()
const msPerMinute = 60 * 1000 const msPerMinute = 60 * 1000
const msPerHour = msPerMinute * 60 const msPerHour = msPerMinute * 60
@ -150,7 +150,7 @@ export default {
return 'approximately ' + Math.round(elapsed / msPerYear) + ' years ago' return 'approximately ' + Math.round(elapsed / msPerYear) + ' years ago'
} }
}, },
clearNotification () { clearNotification() {
this.$store.commit('notification/MutListClearFinished') this.$store.commit('notification/MutListClearFinished')
} }

36
packages/nc-gui/components/project/apis.vue

@ -166,7 +166,7 @@ import { mapGetters, mapActions } from 'vuex'
export default { export default {
components: {}, components: {},
data () { data() {
return { return {
// portNumber: 3000, // portNumber: 3000,
@ -179,11 +179,11 @@ export default {
tabs: 'tabs/list' tabs: 'tabs/list'
}), }),
server1 () { server1() {
return this.$store.state.apiServer.servers[this.nodes.key] return this.$store.state.apiServer.servers[this.nodes.key]
}, },
portNumber () { portNumber() {
return this.server1 ? this.server1.portNumber : 3000 return this.server1 ? this.server1.portNumber : 3000
} }
@ -194,11 +194,11 @@ export default {
changeActiveTab: 'tabs/changeActiveTab' changeActiveTab: 'tabs/changeActiveTab'
}), }),
openWebUrl (url) { openWebUrl(url) {
// shell.openExternal(url) // shell.openExternal(url)
}, },
openUrl (url) { openUrl(url) {
const _nodes = { ...this.nodes } const _nodes = { ...this.nodes }
_nodes.key = _nodes.dbKey + '.apiClient' _nodes.key = _nodes.dbKey + '.apiClient'
_nodes.type = 'apiClientDir' _nodes.type = 'apiClientDir'
@ -217,7 +217,7 @@ export default {
} }
}, },
async startServer () { async startServer() {
try { try {
const args = { ...this.nodes } const args = { ...this.nodes }
args.portNumber = this.server1 ? this.server1.portNumber : 3000 args.portNumber = this.server1 ? this.server1.portNumber : 3000
@ -231,7 +231,7 @@ export default {
} }
}, },
async stopServer () { async stopServer() {
try { try {
const args = { ...this.nodes } const args = { ...this.nodes }
args.portNumber = parseInt(this.server1.portNumber) args.portNumber = parseInt(this.server1.portNumber)
@ -245,7 +245,7 @@ export default {
} }
}, },
async getCloudUrl () { async getCloudUrl() {
try { try {
const args = { ...this.nodes } const args = { ...this.nodes }
args.portNumber = parseInt(this.server1.portNumber) args.portNumber = parseInt(this.server1.portNumber)
@ -259,7 +259,7 @@ export default {
} }
}, },
async sendNotification () { async sendNotification() {
try { try {
const args = { ...this.nodes } const args = { ...this.nodes }
await this.$store.dispatch('apiServer/cloudSendNotification', args) await this.$store.dispatch('apiServer/cloudSendNotification', args)
@ -269,33 +269,33 @@ export default {
throw e throw e
} }
}, },
clipboardSuccessHandler ({ value, event }) { clipboardSuccessHandler({ value, event }) {
this.$toast.info('Copied to clipboard.').goAway(1000) this.$toast.info('Copied to clipboard.').goAway(1000)
}, },
clipboardErrorHandler ({ value, event }) { clipboardErrorHandler({ value, event }) {
this.$toast.info('Clipboard copying failed.').goAway(1000) this.$toast.info('Clipboard copying failed.').goAway(1000)
} }
}, },
beforeCreated () { beforeCreated() {
}, },
watch: {}, watch: {},
async created () { async created() {
// this.server.serverLive = await this.sqlMgr.projectAPIServerIsLive(); // this.server.serverLive = await this.sqlMgr.projectAPIServerIsLive();
}, },
mounted () { mounted() {
}, },
beforeDestroy () { beforeDestroy() {
}, },
destroy () { destroy() {
}, },
directives: {}, directives: {},
validate ({ params }) { validate({ params }) {
return true return true
}, },
head () { head() {
return {} return {}
}, },
props: ['nodes'] props: ['nodes']

18
packages/nc-gui/components/project/appStore.vue

@ -196,27 +196,27 @@ export default {
} }
}), }),
computed: { computed: {
filters () { filters() {
return this.apps.reduce((arr, app) => arr.concat(app.tags || []), []).filter((f, i, arr) => i === arr.indexOf(f)).sort() return this.apps.reduce((arr, app) => arr.concat(app.tags || []), []).filter((f, i, arr) => i === arr.indexOf(f)).sort()
}, },
filteredApps () { filteredApps() {
return this.apps.filter(app => (!this.query.trim() || app.name.toLowerCase().includes(this.query.trim().toLowerCase())) && return this.apps.filter(app => (!this.query.trim() || app.name.toLowerCase().includes(this.query.trim().toLowerCase())) &&
(!this.selectedTags.length || this.selectedTags.some(t => app.tags && app.tags.includes(t))) (!this.selectedTags.length || this.selectedTags.some(t => app.tags && app.tags.includes(t)))
) )
} }
}, },
async created () { async created() {
await this.loadPluginList() await this.loadPluginList()
this.readPluginDefaults() this.readPluginDefaults()
}, },
methods: { methods: {
async readPluginDefaults () { async readPluginDefaults() {
try { try {
this.defaultConfig = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcPluginDemoDefaults']) this.defaultConfig = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcPluginDemoDefaults'])
} catch (e) { } catch (e) {
} }
}, },
async confirmResetPlugin () { async confirmResetPlugin() {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcPluginSet', { await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcPluginSet', {
input: null, input: null,
@ -231,19 +231,19 @@ export default {
this.$toast.error(e.message).goAway(3000) this.$toast.error(e.message).goAway(3000)
} }
}, },
async saved () { async saved() {
this.pluginInstallOverlay = false this.pluginInstallOverlay = false
await this.loadPluginList() await this.loadPluginList()
}, },
async installApp (app) { async installApp(app) {
this.pluginInstallOverlay = true this.pluginInstallOverlay = true
this.installPlugin = app this.installPlugin = app
}, },
async resetApp (app) { async resetApp(app) {
this.pluginUninstallModal = true this.pluginUninstallModal = true
this.resetPluginRef = app this.resetPluginRef = app
}, },
async loadPluginList () { async loadPluginList() {
try { try {
const plugins = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcPluginList']) const plugins = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcPluginList'])
plugins.push(...plugins.splice(0, 3)) plugins.push(...plugins.splice(0, 3))

4
packages/nc-gui/components/project/appStore/FormInput.vue

@ -32,10 +32,10 @@ export default {
}, },
computed: { computed: {
localState: { localState: {
get () { get() {
return this.value return this.value
}, },
set (val) { set(val) {
this.$emit('input', val) this.$emit('input', val)
} }
} }

18
packages/nc-gui/components/project/appStore/appInstall.vue

@ -107,22 +107,22 @@ export default {
testing: false testing: false
}), }),
watch: { watch: {
async id () { async id() {
this.settings = {} this.settings = {}
await this.readPluginDetails() await this.readPluginDetails()
} }
}, },
async created () { async created() {
await this.readPluginDetails() await this.readPluginDetails()
}, },
methods: { methods: {
simpleAnim () { simpleAnim() {
const count = 200 const count = 200
const defaults = { const defaults = {
origin: { y: 0.7 } origin: { y: 0.7 }
} }
function fire (particleRatio, opts) { function fire(particleRatio, opts) {
window.confetti(Object.assign({}, defaults, opts, { window.confetti(Object.assign({}, defaults, opts, {
particleCount: Math.floor(count * particleRatio) particleCount: Math.floor(count * particleRatio)
})) }))
@ -151,7 +151,7 @@ export default {
startVelocity: 45 startVelocity: 45
}) })
}, },
async saveSettings () { async saveSettings() {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcPluginSet', { await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcPluginSet', {
input: this.settings, input: this.settings,
@ -166,7 +166,7 @@ export default {
this.$toast.error(e.message).goAway(3000) this.$toast.error(e.message).goAway(3000)
} }
}, },
async testSettings () { async testSettings() {
this.testing = true this.testing = true
try { try {
const res = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcPluginTest', { const res = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcPluginTest', {
@ -185,7 +185,7 @@ export default {
} }
this.testing = false this.testing = false
}, },
async doAction (action) { async doAction(action) {
switch (action.key) { switch (action.key) {
case 'save' : case 'save' :
await this.saveSettings() await this.saveSettings()
@ -197,7 +197,7 @@ export default {
break break
} }
}, },
async readPluginDetails () { async readPluginDetails() {
try { try {
this.plugin = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcPluginRead', { this.plugin = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcPluginRead', {
title: this.title title: this.title
@ -208,7 +208,7 @@ export default {
} catch (e) { } catch (e) {
} }
}, },
copyDefault () { copyDefault() {
if (this.plugin.title.replace(/\s/g, '_').toLowerCase() in this.defaultConfig) { if (this.plugin.title.replace(/\s/g, '_').toLowerCase() in this.defaultConfig) {
const data = this.defaultConfig[this.plugin.title.replace(/\s/g, '_').toLowerCase()] const data = this.defaultConfig[this.plugin.title.replace(/\s/g, '_').toLowerCase()]
this.settings = JSON.parse(JSON.stringify(data)) this.settings = JSON.parse(JSON.stringify(data))

22
packages/nc-gui/components/project/appStore/inputs/attachment.vue

@ -196,7 +196,7 @@ export default {
selectedImage: null selectedImage: null
}), }),
watch: { watch: {
value (val) { value(val) {
try { try {
this.localState = (typeof val === 'string' ? JSON.parse(val) : val) || [] this.localState = (typeof val === 'string' ? JSON.parse(val) : val) || []
} catch (e) { } catch (e) {
@ -209,7 +209,7 @@ export default {
// } // }
// } // }
}, },
created () { created() {
try { try {
this.localState = (typeof this.value === 'string' ? JSON.parse(this.value) : this.value) || [] this.localState = (typeof this.value === 'string' ? JSON.parse(this.value) : this.value) || []
} catch (e) { } catch (e) {
@ -217,30 +217,30 @@ export default {
} }
document.addEventListener('keydown', this.onArrowDown) document.addEventListener('keydown', this.onArrowDown)
}, },
beforeDestroy () { beforeDestroy() {
document.removeEventListener('keydown', this.onArrowDown) document.removeEventListener('keydown', this.onArrowDown)
}, },
mounted () { mounted() {
}, },
methods: { methods: {
openUrl (url, target) { openUrl(url, target) {
window.open(url, target) window.open(url, target)
}, },
isImage, isImage,
hideIfVisible () { hideIfVisible() {
if (this.showImage) { if (this.showImage) {
this.showImage = false this.showImage = false
} }
}, },
selectImage (selectedImage, i) { selectImage(selectedImage, i) {
this.showImage = true this.showImage = true
this.carousel = i this.carousel = i
this.selectedImage = selectedImage this.selectedImage = selectedImage
}, },
addFile () { addFile() {
this.$refs.file.click() this.$refs.file.click()
}, },
async onFileSelection () { async onFileSelection() {
if (!this.$refs.file.files || !this.$refs.file.files.length) { if (!this.$refs.file.files || !this.$refs.file.files.length) {
return return
} }
@ -256,12 +256,12 @@ export default {
this.$emit('input', JSON.stringify(this.localState)) this.$emit('input', JSON.stringify(this.localState))
this.$emit('update') this.$emit('update')
}, },
removeItem (i) { removeItem(i) {
this.localState.splice(i, 1) this.localState.splice(i, 1)
this.$emit('input', JSON.stringify(this.localState)) this.$emit('input', JSON.stringify(this.localState))
this.$emit('update') this.$emit('update')
}, },
onArrowDown (e) { onArrowDown(e) {
if (!this.showImage) { return } if (!this.showImage) { return }
e = e || window.event e = e || window.event
// eslint-disable-next-line eqeqeq // eslint-disable-next-line eqeqeq

10
packages/nc-gui/components/project/appStore/inputs/longTextField.vue

@ -23,22 +23,22 @@ export default {
}, },
computed: { computed: {
localState: { localState: {
get () { get() {
return this.value return this.value
}, },
set (val) { set(val) {
this.$emit('input', val) this.$emit('input', val)
} }
}, },
parentListeners () { parentListeners() {
const $listeners = {} const $listeners = {}
return $listeners return $listeners
} }
}, },
created () { created() {
this.localState = this.value this.localState = this.value
}, },
mounted () { mounted() {
this.$refs.textarea.focus() this.$refs.textarea.focus()
} }
} }

6
packages/nc-gui/components/project/appStore/inputs/passwordField.vue

@ -32,14 +32,14 @@ export default {
}), }),
computed: { computed: {
localState: { localState: {
get () { get() {
return this.value return this.value
}, },
set (val) { set(val) {
this.$emit('input', val) this.$emit('input', val)
} }
}, },
parentListeners () { parentListeners() {
const $listeners = {} const $listeners = {}
return $listeners return $listeners
} }

6
packages/nc-gui/components/project/appStore/inputs/textField.vue

@ -22,14 +22,14 @@ export default {
}, },
computed: { computed: {
localState: { localState: {
get () { get() {
return this.value return this.value
}, },
set (val) { set(val) {
this.$emit('input', val) this.$emit('input', val)
} }
}, },
parentListeners () { parentListeners() {
const $listeners = {} const $listeners = {}
return $listeners return $listeners
} }

6
packages/nc-gui/components/project/appStoreOld.vue

@ -308,17 +308,17 @@ export default {
] ]
}), }),
computed: { computed: {
filters () { filters() {
return this.apps.reduce((arr, app) => arr.concat(app.tags || []), []).filter((f, i, arr) => i === arr.indexOf(f)).sort() return this.apps.reduce((arr, app) => arr.concat(app.tags || []), []).filter((f, i, arr) => i === arr.indexOf(f)).sort()
}, },
filteredApps () { filteredApps() {
return this.apps.filter(app => (!this.query.trim() || app.name.toLowerCase().includes(this.query.trim().toLowerCase())) && return this.apps.filter(app => (!this.query.trim() || app.name.toLowerCase().includes(this.query.trim().toLowerCase())) &&
(!this.selectedTags.length || this.selectedTags.some(t => app.tags && app.tags.includes(t))) (!this.selectedTags.length || this.selectedTags.some(t => app.tags && app.tags.includes(t)))
) )
} }
}, },
methods: { methods: {
installApp () { installApp() {
this.$toast.info('Coming soon after seed funding.').goAway(5000) this.$toast.info('Coming soon after seed funding.').goAway(5000)
} }
} }

6
packages/nc-gui/components/project/auditTab/audit.vue

@ -90,11 +90,11 @@ export default {
limit: 25, limit: 25,
page: 1 page: 1
}), }),
created () { created() {
this.loadAudits() this.loadAudits()
}, },
methods: { methods: {
async loadAudits () { async loadAudits() {
const { list, count } = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcAuditList', { const { list, count } = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcAuditList', {
limit: this.limit, limit: this.limit,
offset: this.limit * (this.page - 1) offset: this.limit * (this.page - 1)
@ -102,7 +102,7 @@ export default {
this.audits = list this.audits = list
this.count = count this.count = count
}, },
calculateDiff (date) { calculateDiff(date) {
return dayjs.utc(date).fromNow() return dayjs.utc(date).fromNow()
} }
} }

34
packages/nc-gui/components/project/auditTab/db.vue

@ -242,7 +242,7 @@ export default {
Splitpanes, Splitpanes,
Pane Pane
}, },
data () { data() {
return { return {
showUpAndDownBtns: false, showUpAndDownBtns: false,
tableMigrationFiles: { tableMigrationFiles: {
@ -314,12 +314,12 @@ export default {
}) })
}, },
watch: {}, watch: {},
created () { created() {
this.loadEnv() this.loadEnv()
}, },
mounted () { mounted() {
}, },
beforeDestroy () { beforeDestroy() {
}, },
methods: { methods: {
@ -327,12 +327,12 @@ export default {
// shell.openItem(path.join(this.currentProjectFolder, 'server', 'tool', this.nodes.dbAlias, 'migrations')); // shell.openItem(path.join(this.currentProjectFolder, 'server', 'tool', this.nodes.dbAlias, 'migrations'));
// }, // },
isMigrationButtonEnabled (name) { isMigrationButtonEnabled(name) {
console.log('menu -- - ', name) console.log('menu -- - ', name)
return this.nodes.dbConnection.client === 'sqlite3' && name === 'Migration Down' return this.nodes.dbConnection.client === 'sqlite3' && name === 'Migration Down'
}, },
async getMigrationFiles (migration) { async getMigrationFiles(migration) {
this.selectedMigration.migration = '' this.selectedMigration.migration = ''
this.selectedMigration.up = '' this.selectedMigration.up = ''
this.selectedMigration.down = '' this.selectedMigration.down = ''
@ -364,7 +364,7 @@ export default {
this.selectedMigration.down = result.data.object.down this.selectedMigration.down = result.data.object.down
}, },
async loadEnv () { async loadEnv() {
try { try {
this.$store.commit('notification/MutToggleProgressBar', true) this.$store.commit('notification/MutToggleProgressBar', true)
const migrationArgs = { const migrationArgs = {
@ -405,11 +405,11 @@ export default {
this.$store.commit('notification/MutToggleProgressBar', false) this.$store.commit('notification/MutToggleProgressBar', false)
} }
}, },
async applyChanges () { async applyChanges() {
}, },
async deleteView (action = '') { async deleteView(action = '') {
}, },
async migrationUp (steps = 99999999999) { async migrationUp(steps = 99999999999) {
try { try {
// await this.sqlMgr.migrator().migrationsUp({ // await this.sqlMgr.migrator().migrationsUp({
// env: this.nodes.env, // env: this.nodes.env,
@ -439,7 +439,7 @@ export default {
} }
await this.loadEnv() await this.loadEnv()
}, },
async migrationDown (steps = 99999999999) { async migrationDown(steps = 99999999999) {
try { try {
// await this.sqlMgr.migrator().migrationsDown({ // await this.sqlMgr.migrator().migrationsDown({
// env: this.nodes.env, // env: this.nodes.env,
@ -468,7 +468,7 @@ export default {
} }
await this.loadEnv() await this.loadEnv()
}, },
findNextMigrationColor (item) { findNextMigrationColor(item) {
if (item.nextMigration === 1) { if (item.nextMigration === 1) {
return 'orange' return 'orange'
} else if (item.nextMigration === 2) { } else if (item.nextMigration === 2) {
@ -478,7 +478,7 @@ export default {
} }
return '' return ''
}, },
findMigrationTextColor (item) { findMigrationTextColor(item) {
// if (item.nextMigration === 1) { // if (item.nextMigration === 1) {
// return "white--text"; // return "white--text";
// } else if (item.nextMigration === 2) { // } else if (item.nextMigration === 2) {
@ -490,15 +490,15 @@ export default {
} }
}, },
beforeCreated () { beforeCreated() {
}, },
destroy () { destroy() {
}, },
directives: {}, directives: {},
validate ({ params }) { validate({ params }) {
return true return true
}, },
head () { head() {
return {} return {}
}, },
props: ['nodes'] props: ['nodes']

18
packages/nc-gui/components/project/cronJobs.vue

@ -303,14 +303,14 @@ export default {
filter: '', filter: '',
selectedItem: null selectedItem: null
}), }),
async mounted () { async mounted() {
await this.loadCrons() await this.loadCrons()
}, },
methods: { methods: {
async editCronHandler (cron) { async editCronHandler(cron) {
this.selectedItem = cron this.selectedItem = cron
}, },
async deleteCron (cron) { async deleteCron(cron) {
if (cron.id) { if (cron.id) {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.dbAliasList[this.dbsTab].meta.dbAlias, dbAlias: this.dbAliasList[this.dbsTab].meta.dbAlias,
@ -326,7 +326,7 @@ export default {
this.selectedItem = null this.selectedItem = null
} }
}, },
async addNewCron () { async addNewCron() {
this.crons = this.crons || [] this.crons = this.crons || []
this.crons.push(this.selectedItem = { this.crons.push(this.selectedItem = {
title: 'cron_job' + this.crons.length, title: 'cron_job' + this.crons.length,
@ -336,7 +336,7 @@ export default {
cron_handler: '' cron_handler: ''
}) })
}, },
async loadCrons () { async loadCrons() {
this.crons = await this.$store.dispatch('sqlMgr/ActSqlOp', [{ this.crons = await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.dbAliasList[this.dbsTab].meta.dbAlias, dbAlias: this.dbAliasList[this.dbsTab].meta.dbAlias,
env: this.$store.getters['project/GtrEnv'] env: this.$store.getters['project/GtrEnv']
@ -346,7 +346,7 @@ export default {
} }
this.edited = false this.edited = false
}, },
async saveCron () { async saveCron() {
this.updating = true this.updating = true
const errorCrons = [] const errorCrons = []
try { try {
@ -392,14 +392,14 @@ export default {
...mapGetters({ ...mapGetters({
dbAliasList: 'project/GtrDbAliasList' dbAliasList: 'project/GtrDbAliasList'
}), }),
enableCountText () { enableCountText() {
return '' return ''
}, },
selectedItemIndex: { selectedItemIndex: {
get () { get() {
return this.crons ? this.crons.indexOf(this.selectedItem) : -1 return this.crons ? this.crons.indexOf(this.selectedItem) : -1
}, },
set (i) { set(i) {
this.selectedItem = this.crons[i] this.selectedItem = this.crons[i]
} }
} }

24
packages/nc-gui/components/project/dlgs/dlgAddRelation.vue

@ -1,7 +1,7 @@
<template> <template>
<v-row justify="center"> <v-row justify="center">
<v-dialog <v-dialog
v-model="dialogShow" :value="dialogShow"
persistent persistent
max-width="600" max-width="600"
@keydown.esc="mtdDialogCancel()" @keydown.esc="mtdDialogCancel()"
@ -117,7 +117,7 @@
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
export default { export default {
data () { data() {
return { return {
valid: false, valid: false,
onUpdateDeleteOptions: [ onUpdateDeleteOptions: [
@ -145,7 +145,7 @@ export default {
} }
}, },
methods: { methods: {
async loadColumnList () { async loadColumnList() {
if (!this.relation.parentTable) { return } if (!this.relation.parentTable) { return }
this.isRefColumnsLoading = true this.isRefColumnsLoading = true
// const client = await this.sqlMgr.projectGetSqlClient({ // const client = await this.sqlMgr.projectGetSqlClient({
@ -181,7 +181,7 @@ export default {
this.isRefColumnsLoading = false this.isRefColumnsLoading = false
}, },
async loadTablesList () { async loadTablesList() {
this.isRefTablesLoading = true this.isRefTablesLoading = true
// const client = await this.sqlMgr.projectGetSqlClient({ // const client = await this.sqlMgr.projectGetSqlClient({
// env: this.nodes.env, // env: this.nodes.env,
@ -207,14 +207,14 @@ export default {
}, },
computed: { ...mapGetters({ sqlMgr: 'sqlMgr/sqlMgr' }) }, computed: { ...mapGetters({ sqlMgr: 'sqlMgr/sqlMgr' }) },
beforeCreated () { beforeCreated() {
}, },
watch: { watch: {
'relation.parentTable' () { 'relation.parentTable'() {
this.loadColumnList() this.loadColumnList()
} }
}, },
async created () { async created() {
await this.loadTablesList() await this.loadTablesList()
if (!this.relation.parentTable) { if (!this.relation.parentTable) {
@ -228,18 +228,18 @@ export default {
this.relation.parentTable = this.column.rtn this.relation.parentTable = this.column.rtn
} }
}, },
mounted () { mounted() {
}, },
beforeDestroy () { beforeDestroy() {
}, },
destroy () { destroy() {
}, },
directives: {}, directives: {},
components: {}, components: {},
validate ({ params }) { validate({ params }) {
return true return true
}, },
head () { head() {
return {} return {}
}, },
props: [ props: [

16
packages/nc-gui/components/project/dlgs/dlgTriggerAddEdit.vue

@ -94,7 +94,7 @@ import MonacoEditor from '../../monaco/Monaco'
export default { export default {
components: { MonacoEditor }, components: { MonacoEditor },
data () { data() {
return { return {
valid: false, valid: false,
formRules: { formRules: {
@ -120,21 +120,21 @@ export default {
methods: {}, methods: {},
computed: { ...mapGetters({ sqlMgr: 'sqlMgr/sqlMgr' }) }, computed: { ...mapGetters({ sqlMgr: 'sqlMgr/sqlMgr' }) },
beforeCreated () {}, beforeCreated() {},
watch: {}, watch: {},
async created () {}, async created() {},
mounted () { mounted() {
requestAnimationFrame(() => { requestAnimationFrame(() => {
this.$refs.focus.focus() this.$refs.focus.focus()
}) })
}, },
beforeDestroy () {}, beforeDestroy() {},
destroy () {}, destroy() {},
directives: {}, directives: {},
validate ({ params }) { validate({ params }) {
return true return true
}, },
head () { head() {
return {} return {}
}, },
props: [ props: [

8
packages/nc-gui/components/project/functionTab/functionAcl.vue

@ -95,15 +95,15 @@ export default {
data: null data: null
}), }),
computed: { computed: {
roles () { roles() {
return this.data ? Object.keys(this.data) : [] return this.data ? Object.keys(this.data) : []
} }
}, },
async created () { async created() {
await this.loadAcl() await this.loadAcl()
}, },
methods: { methods: {
async loadAcl () { async loadAcl() {
this.loading = true this.loading = true
const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [{ const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [{
env: this.nodes.env, env: this.nodes.env,
@ -115,7 +115,7 @@ export default {
this.loading = false this.loading = false
}, },
async save () { async save() {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{
env: this.nodes.env, env: this.nodes.env,

24
packages/nc-gui/components/project/functionTab/functionQuery.vue

@ -79,7 +79,7 @@ import { SqlUI } from '../../../helpers/SqlUiFactory'
export default { export default {
components: { MonacoEditor, dlgLabelSubmitCancel }, components: { MonacoEditor, dlgLabelSubmitCancel },
data () { data() {
return { return {
functionData: {}, functionData: {},
newFunction: !!this.nodes.newFunction, newFunction: !!this.nodes.newFunction,
@ -98,7 +98,7 @@ export default {
removeFunctionTab: 'tabs/removeFunctionTab' removeFunctionTab: 'tabs/removeFunctionTab'
}), }),
async handleKeyDown ({ metaKey, key, altKey, shiftKey, ctrlKey }) { async handleKeyDown({ metaKey, key, altKey, shiftKey, ctrlKey }) {
console.log(metaKey, key, altKey, shiftKey, ctrlKey) console.log(metaKey, key, altKey, shiftKey, ctrlKey)
// cmd + s -> save // cmd + s -> save
// cmd + l -> reload // cmd + l -> reload
@ -122,7 +122,7 @@ export default {
} }
}, },
async loadFunction () { async loadFunction() {
if (this.newFunction) { if (this.newFunction) {
this.functionData = { this.functionData = {
function_name: this.nodes.function_name, function_name: this.nodes.function_name,
@ -153,7 +153,7 @@ export default {
this.functionData = result.data.list[0] this.functionData = result.data.list[0]
this.oldCreateFunction = `${this.functionData.create_function}` + '' this.oldCreateFunction = `${this.functionData.create_function}` + ''
}, },
async applyChanges () { async applyChanges() {
try { try {
if (this.newFunction) { if (this.newFunction) {
const result = await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [ const result = await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
@ -204,7 +204,7 @@ export default {
throw e throw e
} }
}, },
async deleteFunction (action = '') { async deleteFunction(action = '') {
try { try {
if (action === 'showDialog') { if (action === 'showDialog') {
this.dialogShow = true this.dialogShow = true
@ -242,24 +242,24 @@ export default {
} }
} }
}, },
beforeCreated () { beforeCreated() {
}, },
watch: {}, watch: {},
created () { created() {
this.sqlUi = SqlUI.create(this.nodes.dbConnection) this.sqlUi = SqlUI.create(this.nodes.dbConnection)
}, },
mounted () { mounted() {
this.loadFunction() this.loadFunction()
}, },
beforeDestroy () { beforeDestroy() {
}, },
destroy () { destroy() {
}, },
directives: {}, directives: {},
validate ({ params }) { validate({ params }) {
return true return true
}, },
head () { head() {
return {} return {}
}, },
props: ['nodes'] props: ['nodes']

8
packages/nc-gui/components/project/gqlHandlerCodeEditor.vue

@ -58,16 +58,16 @@ export default {
}), }),
computed: { computed: {
dialogShow: { dialogShow: {
get () { get() {
return this.value return this.value
}, },
set (val) { set(val) {
this.$emit('input', val) this.$emit('input', val)
} }
} }
}, },
watch: { watch: {
async resolver (val) { async resolver(val) {
try { try {
console.log('=============', this.functions) console.log('=============', this.functions)
this.code = JSON.parse(this.functions)[0] this.code = JSON.parse(this.functions)[0]
@ -86,7 +86,7 @@ export default {
} }
}, },
methods: { methods: {
async saveCode () { async saveCode() {
try { try {
this.progressbar = true this.progressbar = true
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{

10
packages/nc-gui/components/project/graphqlClient.vue

@ -47,13 +47,13 @@
<script> <script>
export default { export default {
name: 'GraphqlClient', name: 'GraphqlClient',
data () { data() {
return { return {
url: '', url: '',
webViewUrl: '' webViewUrl: ''
} }
}, },
async created () { async created() {
if (this.$store.state.graphqlClient.list && this.$store.state.graphqlClient.list[0]) { this.webViewUrl = this.url = this.$store.state.graphqlClient.list[0].url } if (this.$store.state.graphqlClient.list && this.$store.state.graphqlClient.list[0]) { this.webViewUrl = this.url = this.$store.state.graphqlClient.list[0].url }
try { try {
const { info } = (await this.$axios.get(`${this.$axios.defaults.baseURL}/nc/${this.$route.params.project_id}/projectApiInfo`, { const { info } = (await this.$axios.get(`${this.$axios.defaults.baseURL}/nc/${this.$route.params.project_id}/projectApiInfo`, {
@ -68,14 +68,14 @@ export default {
} catch (e) { } catch (e) {
} }
}, },
mounted () { mounted() {
}, },
methods: { methods: {
test () { test() {
console.log('triggerd') console.log('triggerd')
}, },
loadUrl () { loadUrl() {
this.webViewUrl = this.url this.webViewUrl = this.url
if (this.url) { this.$store.commit('graphqlClient/MutListAdd', { url: this.url }) } if (this.url) { this.$store.commit('graphqlClient/MutListAdd', { url: this.url }) }
} }

2
packages/nc-gui/components/project/grpcClient.vue

@ -20,7 +20,7 @@ export default {
loading: false loading: false
}), }),
methods: { methods: {
async download () { async download() {
this.loading = true this.loading = true
let data let data
try { try {

8
packages/nc-gui/components/project/grpcHandlerCodeEditor.vue

@ -54,16 +54,16 @@ export default {
}), }),
computed: { computed: {
dialogShow: { dialogShow: {
get () { get() {
return this.value return this.value
}, },
set (val) { set(val) {
this.$emit('input', val) this.$emit('input', val)
} }
} }
}, },
watch: { watch: {
async service (val) { async service(val) {
try { try {
this.code = JSON.parse(this.serviceData.functions)[0] this.code = JSON.parse(this.serviceData.functions)[0]
} catch (e) { } catch (e) {
@ -83,7 +83,7 @@ export default {
} }
}, },
methods: { methods: {
async saveCode () { async saveCode() {
try { try {
this.progressbar = true this.progressbar = true
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{

8
packages/nc-gui/components/project/procedureTab/procedureAcl.vue

@ -95,15 +95,15 @@ export default {
data: null data: null
}), }),
computed: { computed: {
roles () { roles() {
return this.data ? Object.keys(this.data) : [] return this.data ? Object.keys(this.data) : []
} }
}, },
async created () { async created() {
await this.loadAcl() await this.loadAcl()
}, },
methods: { methods: {
async loadAcl () { async loadAcl() {
this.loading = true this.loading = true
const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [{ const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [{
env: this.nodes.env, env: this.nodes.env,
@ -115,7 +115,7 @@ export default {
this.loading = false this.loading = false
}, },
async save () { async save() {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{
env: this.nodes.env, env: this.nodes.env,

24
packages/nc-gui/components/project/procedureTab/procedureQuery.vue

@ -74,7 +74,7 @@ import dlgLabelSubmitCancel from '../../utils/dlgLabelSubmitCancel'
export default { export default {
components: { MonacoEditor, dlgLabelSubmitCancel }, components: { MonacoEditor, dlgLabelSubmitCancel },
data () { data() {
return { return {
procedure: {}, procedure: {},
newProcedure: !!this.nodes.newProcedure, newProcedure: !!this.nodes.newProcedure,
@ -94,7 +94,7 @@ export default {
removeProcedureTab: 'tabs/removeProcedureTab' removeProcedureTab: 'tabs/removeProcedureTab'
}), }),
async handleKeyDown ({ metaKey, key, altKey, shiftKey, ctrlKey }) { async handleKeyDown({ metaKey, key, altKey, shiftKey, ctrlKey }) {
console.log(metaKey, key, altKey, shiftKey, ctrlKey) console.log(metaKey, key, altKey, shiftKey, ctrlKey)
// cmd + s -> save // cmd + s -> save
// cmd + l -> reload // cmd + l -> reload
@ -118,7 +118,7 @@ export default {
} }
}, },
async loadProcedure () { async loadProcedure() {
try { try {
this.$store.commit('notification/MutToggleProgressBar', true) this.$store.commit('notification/MutToggleProgressBar', true)
if (this.newProcedure) { if (this.newProcedure) {
@ -158,7 +158,7 @@ export default {
this.$store.commit('notification/MutToggleProgressBar', false) this.$store.commit('notification/MutToggleProgressBar', false)
} }
}, },
async applyChanges () { async applyChanges() {
try { try {
if (this.newProcedure) { if (this.newProcedure) {
const result = await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [ const result = await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
@ -203,7 +203,7 @@ export default {
throw e throw e
} }
}, },
async deleteProcedure (action = '') { async deleteProcedure(action = '') {
try { try {
if (action === 'showDialog') { if (action === 'showDialog') {
this.dialogShow = true this.dialogShow = true
@ -240,23 +240,23 @@ export default {
} }
} }
}, },
beforeCreated () { beforeCreated() {
}, },
watch: {}, watch: {},
created () { created() {
this.loadProcedure() this.loadProcedure()
}, },
mounted () { mounted() {
}, },
beforeDestroy () { beforeDestroy() {
}, },
destroy () { destroy() {
}, },
directives: {}, directives: {},
validate ({ params }) { validate({ params }) {
return true return true
}, },
head () { head() {
return {} return {}
}, },
props: ['nodes'] props: ['nodes']

12
packages/nc-gui/components/project/projectMetadata/disableOrEnableModels.vue

@ -133,12 +133,12 @@ export default {
filter: '', filter: '',
tables: null tables: null
}), }),
async mounted () { async mounted() {
}, },
methods: {}, methods: {},
computed: { computed: {
dbsTab: { dbsTab: {
set (tab) { set(tab) {
if (!tab) { if (!tab) {
// return this.$router.push({ // return this.$router.push({
// query: {} // query: {}
@ -154,7 +154,7 @@ export default {
} }
}) })
}, },
get () { get() {
return this.$route.query.nested_1 return this.$route.query.nested_1
} }
@ -163,16 +163,16 @@ export default {
...mapGetters({ ...mapGetters({
dbAliasList: 'project/GtrDbAliasList' dbAliasList: 'project/GtrDbAliasList'
}), }),
enableCountText () { enableCountText() {
return this.models return this.models
? `${this.models.filter(m => m.enabled).length}/${this.models.length} enabled` ? `${this.models.filter(m => m.enabled).length}/${this.models.length} enabled`
: '' : ''
}, },
isNewOrDeletedModelFound () { isNewOrDeletedModelFound() {
return this.comparedModelList.some(m => m.new || m.deleted) return this.comparedModelList.some(m => m.new || m.deleted)
}, },
comparedModelList () { comparedModelList() {
const res = [] const res = []
const getPriority = (item) => { const getPriority = (item) => {
if (item.new) { return 2 } if (item.new) { return 2 }

28
packages/nc-gui/components/project/projectMetadata/sync/disableOrEnableFunctions.vue

@ -186,12 +186,12 @@ export default {
filter: '', filter: '',
functions: null functions: null
}), }),
async mounted () { async mounted() {
await this.loadModels() await this.loadModels()
await this.loadTableList() await this.loadTableList()
}, },
methods: { methods: {
async addTableMeta (tables) { async addTableMeta(tables) {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
@ -199,7 +199,7 @@ export default {
}, 'functionMetaCreate', { }, 'functionMetaCreate', {
tableNames: tables// this.comparedModelList.filter(t => t.new).map(t=>t.title) tableNames: tables// this.comparedModelList.filter(t => t.new).map(t=>t.title)
}]) }])
setTimeout(async () => { setTimeout(async() => {
await this.loadModels() await this.loadModels()
this.$toast.success('Table metadata added successfully').goAway(3000) this.$toast.success('Table metadata added successfully').goAway(3000)
}, 1000) }, 1000)
@ -207,7 +207,7 @@ export default {
this.$toast.error('Some error occurred').goAway(5000) this.$toast.error('Some error occurred').goAway(5000)
} }
}, },
async deleteTableMeta (tables) { async deleteTableMeta(tables) {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
@ -215,7 +215,7 @@ export default {
}, 'functioneMetaDelete', { }, 'functioneMetaDelete', {
tableNames: tables tableNames: tables
}]) }])
setTimeout(async () => { setTimeout(async() => {
await this.loadModels() await this.loadModels()
this.$toast.success('Table metadata deleted successfully').goAway(3000) this.$toast.success('Table metadata deleted successfully').goAway(3000)
}, 1000) }, 1000)
@ -223,7 +223,7 @@ export default {
this.$toast.error('Some error occurred').goAway(5000) this.$toast.error('Some error occurred').goAway(5000)
} }
}, },
async syncMetadata () { async syncMetadata() {
const addTables = this.comparedModelList.filter(t => t.new).map(t => t.title) const addTables = this.comparedModelList.filter(t => t.new).map(t => t.title)
const deleteTables = this.comparedModelList.filter(t => t.deleted).map(t => t.title) const deleteTables = this.comparedModelList.filter(t => t.deleted).map(t => t.title)
if (addTables.length) { if (addTables.length) {
@ -234,7 +234,7 @@ export default {
} }
}, },
async recreateTableMeta (table) { async recreateTableMeta(table) {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
@ -242,7 +242,7 @@ export default {
}, 'functionMetaRecreate', { }, 'functionMetaRecreate', {
tn: table tn: table
}]) }])
setTimeout(async () => { setTimeout(async() => {
await this.loadModels() await this.loadModels()
this.$toast.success('Table metadata recreated successfully').goAway(3000) this.$toast.success('Table metadata recreated successfully').goAway(3000)
}, 1000) }, 1000)
@ -250,7 +250,7 @@ export default {
this.$toast.error('Some error occurred').goAway(5000) this.$toast.error('Some error occurred').goAway(5000)
} }
}, },
async loadModels () { async loadModels() {
if (this.dbAliasList[this.dbsTab]) { if (this.dbAliasList[this.dbsTab]) {
this.models = await this.$store.dispatch('sqlMgr/ActSqlOp', [{ this.models = await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
@ -259,14 +259,14 @@ export default {
this.edited = false this.edited = false
} }
}, },
async loadTableList () { async loadTableList() {
this.functions = (await this.$store.dispatch('sqlMgr/ActSqlOp', [{ this.functions = (await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
env: this.$store.getters['project/GtrEnv'] env: this.$store.getters['project/GtrEnv']
}, 'functionList'])).data.list }, 'functionList'])).data.list
}, },
async saveModels () { async saveModels() {
this.updating = true this.updating = true
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{
@ -286,16 +286,16 @@ export default {
...mapGetters({ ...mapGetters({
dbAliasList: 'project/GtrDbAliasList' dbAliasList: 'project/GtrDbAliasList'
}), }),
enableCountText () { enableCountText() {
return this.models return this.models
? `${this.models.filter(m => m.enabled).length}/${this.models.length} enabled` ? `${this.models.filter(m => m.enabled).length}/${this.models.length} enabled`
: '' : ''
}, },
isNewOrDeletedModelFound () { isNewOrDeletedModelFound() {
return this.comparedModelList.some(m => m.new || m.deleted) return this.comparedModelList.some(m => m.new || m.deleted)
}, },
comparedModelList () { comparedModelList() {
const res = [] const res = []
const getPriority = (item) => { const getPriority = (item) => {
if (item.new) { return 2 } if (item.new) { return 2 }

28
packages/nc-gui/components/project/projectMetadata/sync/disableOrEnableProcedures.vue

@ -186,12 +186,12 @@ export default {
filter: '', filter: '',
procedures: null procedures: null
}), }),
async mounted () { async mounted() {
await this.loadModels() await this.loadModels()
await this.loadTableList() await this.loadTableList()
}, },
methods: { methods: {
async addTableMeta (tables) { async addTableMeta(tables) {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
@ -199,7 +199,7 @@ export default {
}, 'procedureMetaCreate', { }, 'procedureMetaCreate', {
tableNames: tables// this.comparedModelList.filter(t => t.new).map(t=>t.title) tableNames: tables// this.comparedModelList.filter(t => t.new).map(t=>t.title)
}]) }])
setTimeout(async () => { setTimeout(async() => {
await this.loadModels() await this.loadModels()
this.$toast.success('Table metadata added successfully').goAway(3000) this.$toast.success('Table metadata added successfully').goAway(3000)
}, 1000) }, 1000)
@ -207,7 +207,7 @@ export default {
this.$toast.error('Some error occurred').goAway(5000) this.$toast.error('Some error occurred').goAway(5000)
} }
}, },
async deleteTableMeta (tables) { async deleteTableMeta(tables) {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
@ -215,7 +215,7 @@ export default {
}, 'procedureMetaDelete', { }, 'procedureMetaDelete', {
tableNames: tables tableNames: tables
}]) }])
setTimeout(async () => { setTimeout(async() => {
await this.loadModels() await this.loadModels()
this.$toast.success('Table metadata deleted successfully').goAway(3000) this.$toast.success('Table metadata deleted successfully').goAway(3000)
}, 1000) }, 1000)
@ -223,7 +223,7 @@ export default {
this.$toast.error('Some error occurred').goAway(5000) this.$toast.error('Some error occurred').goAway(5000)
} }
}, },
async syncMetadata () { async syncMetadata() {
const addTables = this.comparedModelList.filter(t => t.new).map(t => t.title) const addTables = this.comparedModelList.filter(t => t.new).map(t => t.title)
const deleteTables = this.comparedModelList.filter(t => t.deleted).map(t => t.title) const deleteTables = this.comparedModelList.filter(t => t.deleted).map(t => t.title)
if (addTables.length) { if (addTables.length) {
@ -234,7 +234,7 @@ export default {
} }
}, },
async recreateTableMeta (table) { async recreateTableMeta(table) {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
@ -242,7 +242,7 @@ export default {
}, 'procedureMetaRecreate', { }, 'procedureMetaRecreate', {
tn: table tn: table
}]) }])
setTimeout(async () => { setTimeout(async() => {
await this.loadModels() await this.loadModels()
this.$toast.success('Table metadata recreated successfully').goAway(3000) this.$toast.success('Table metadata recreated successfully').goAway(3000)
}, 1000) }, 1000)
@ -250,7 +250,7 @@ export default {
this.$toast.error('Some error occurred').goAway(5000) this.$toast.error('Some error occurred').goAway(5000)
} }
}, },
async loadModels () { async loadModels() {
if (this.dbAliasList[this.dbsTab]) { if (this.dbAliasList[this.dbsTab]) {
this.models = await this.$store.dispatch('sqlMgr/ActSqlOp', [{ this.models = await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
@ -259,14 +259,14 @@ export default {
this.edited = false this.edited = false
} }
}, },
async loadTableList () { async loadTableList() {
this.procedures = (await this.$store.dispatch('sqlMgr/ActSqlOp', [{ this.procedures = (await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
env: this.$store.getters['project/GtrEnv'] env: this.$store.getters['project/GtrEnv']
}, 'procedureList'])).data.list }, 'procedureList'])).data.list
}, },
async saveModels () { async saveModels() {
this.updating = true this.updating = true
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{
@ -286,16 +286,16 @@ export default {
...mapGetters({ ...mapGetters({
dbAliasList: 'project/GtrDbAliasList' dbAliasList: 'project/GtrDbAliasList'
}), }),
enableCountText () { enableCountText() {
return this.models return this.models
? `${this.models.filter(m => m.enabled).length}/${this.models.length} enabled` ? `${this.models.filter(m => m.enabled).length}/${this.models.length} enabled`
: '' : ''
}, },
isNewOrDeletedModelFound () { isNewOrDeletedModelFound() {
return this.comparedModelList.some(m => m.new || m.deleted) return this.comparedModelList.some(m => m.new || m.deleted)
}, },
comparedModelList () { comparedModelList() {
const res = [] const res = []
const getPriority = (item) => { const getPriority = (item) => {
if (item.new) { if (item.new) {

12
packages/nc-gui/components/project/projectMetadata/sync/disableOrEnableRelations.vue

@ -113,18 +113,18 @@ export default {
search: '' search: ''
}), }),
computed: { computed: {
selectedCount () { selectedCount() {
return `${this.relations.filter(({ enabled }) => enabled).length}/${this.relations.length}` return `${this.relations.filter(({ enabled }) => enabled).length}/${this.relations.length}`
}, },
edited () { edited() {
return this.relations.some(({ edited }) => edited) return this.relations.some(({ edited }) => edited)
} }
}, },
async created () { async created() {
await this.loadRelations() await this.loadRelations()
}, },
methods: { methods: {
async loadRelations () { async loadRelations() {
this.loading = true this.loading = true
try { try {
this.relations = await this.$store.dispatch('sqlMgr/ActSqlOp', [{ this.relations = await this.$store.dispatch('sqlMgr/ActSqlOp', [{
@ -136,14 +136,14 @@ export default {
} }
this.loading = false this.loading = false
}, },
toggleAll (toggle) { toggleAll(toggle) {
this.toggle = !toggle this.toggle = !toggle
for (const rel of this.relations) { for (const rel of this.relations) {
this.$set(rel, 'edited', rel.edited || rel.enabled !== toggle) this.$set(rel, 'edited', rel.edited || rel.enabled !== toggle)
this.$set(rel, 'enabled', toggle) this.$set(rel, 'enabled', toggle)
} }
}, },
async save () { async save() {
const editedRelations = this.relations.filter(({ edited }) => edited) const editedRelations = this.relations.filter(({ edited }) => edited)
this.updating = true this.updating = true
try { try {

28
packages/nc-gui/components/project/projectMetadata/sync/disableOrEnableTables.vue

@ -193,12 +193,12 @@ export default {
filter: '', filter: '',
tables: null tables: null
}), }),
async mounted () { async mounted() {
await this.loadModels() await this.loadModels()
await this.loadTableList() await this.loadTableList()
}, },
methods: { methods: {
async addTableMeta (tables) { async addTableMeta(tables) {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
@ -206,7 +206,7 @@ export default {
}, 'tableMetaCreate', { }, 'tableMetaCreate', {
tableNames: tables// this.comparedModelList.filter(t => t.new).map(t=>t.title) tableNames: tables// this.comparedModelList.filter(t => t.new).map(t=>t.title)
}]) }])
setTimeout(async () => { setTimeout(async() => {
await this.loadModels() await this.loadModels()
this.$toast.success('Table metadata added successfully').goAway(3000) this.$toast.success('Table metadata added successfully').goAway(3000)
}, 1000) }, 1000)
@ -214,7 +214,7 @@ export default {
this.$toast.error('Some error occurred').goAway(5000) this.$toast.error('Some error occurred').goAway(5000)
} }
}, },
async deleteTableMeta (tables) { async deleteTableMeta(tables) {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
@ -222,7 +222,7 @@ export default {
}, 'tableMetaDelete', { }, 'tableMetaDelete', {
tableNames: tables tableNames: tables
}]) }])
setTimeout(async () => { setTimeout(async() => {
await this.loadModels() await this.loadModels()
this.$toast.success('Table metadata deleted successfully').goAway(3000) this.$toast.success('Table metadata deleted successfully').goAway(3000)
}, 1000) }, 1000)
@ -230,7 +230,7 @@ export default {
this.$toast.error('Some error occurred').goAway(5000) this.$toast.error('Some error occurred').goAway(5000)
} }
}, },
async syncMetadata () { async syncMetadata() {
const addTables = this.comparedModelList.filter(t => t.new).map(t => t.title) const addTables = this.comparedModelList.filter(t => t.new).map(t => t.title)
const deleteTables = this.comparedModelList.filter(t => t.deleted).map(t => t.title) const deleteTables = this.comparedModelList.filter(t => t.deleted).map(t => t.title)
if (addTables.length) { if (addTables.length) {
@ -241,7 +241,7 @@ export default {
} }
}, },
async recreateTableMeta (table) { async recreateTableMeta(table) {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
@ -249,7 +249,7 @@ export default {
}, 'tableMetaRecreate', { }, 'tableMetaRecreate', {
tn: table tn: table
}]) }])
setTimeout(async () => { setTimeout(async() => {
await this.loadModels() await this.loadModels()
this.$toast.success('Table metadata recreated successfully').goAway(3000) this.$toast.success('Table metadata recreated successfully').goAway(3000)
}, 1000) }, 1000)
@ -257,7 +257,7 @@ export default {
this.$toast[e.response?.status === 402 ? 'info' : 'error'](e.message).goAway(3000) this.$toast[e.response?.status === 402 ? 'info' : 'error'](e.message).goAway(3000)
} }
}, },
async loadModels () { async loadModels() {
if (this.dbAliasList[this.dbsTab]) { if (this.dbAliasList[this.dbsTab]) {
this.models = await this.$store.dispatch('sqlMgr/ActSqlOp', [{ this.models = await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
@ -266,14 +266,14 @@ export default {
this.edited = false this.edited = false
} }
}, },
async loadTableList () { async loadTableList() {
this.tables = (await this.$store.dispatch('sqlMgr/ActSqlOp', [{ this.tables = (await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
env: this.$store.getters['project/GtrEnv'] env: this.$store.getters['project/GtrEnv']
}, 'tableList', { force: true }])).data.list }, 'tableList', { force: true }])).data.list
}, },
async saveModels () { async saveModels() {
this.updating = true this.updating = true
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{
@ -293,16 +293,16 @@ export default {
...mapGetters({ ...mapGetters({
dbAliasList: 'project/GtrDbAliasList' dbAliasList: 'project/GtrDbAliasList'
}), }),
enableCountText () { enableCountText() {
return this.models return this.models
? `${this.models.filter(m => m.enabled).length}/${this.models.length} enabled` ? `${this.models.filter(m => m.enabled).length}/${this.models.length} enabled`
: '' : ''
}, },
isNewOrDeletedModelFound () { isNewOrDeletedModelFound() {
return this.comparedModelList.some(m => m.new || m.deleted) return this.comparedModelList.some(m => m.new || m.deleted)
}, },
comparedModelList () { comparedModelList() {
const res = [] const res = []
const getPriority = (item) => { const getPriority = (item) => {
if (item.new) { return 2 } if (item.new) { return 2 }

28
packages/nc-gui/components/project/projectMetadata/sync/disableOrEnableViews.vue

@ -186,12 +186,12 @@ export default {
filter: '', filter: '',
views: null views: null
}), }),
async mounted () { async mounted() {
await this.loadModels() await this.loadModels()
await this.loadTableList() await this.loadTableList()
}, },
methods: { methods: {
async addTableMeta (tables) { async addTableMeta(tables) {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
@ -199,7 +199,7 @@ export default {
}, 'viewMetaCreate', { }, 'viewMetaCreate', {
viewNames: tables// this.comparedModelList.filter(t => t.new).map(t=>t.title) viewNames: tables// this.comparedModelList.filter(t => t.new).map(t=>t.title)
}]) }])
setTimeout(async () => { setTimeout(async() => {
await this.loadModels() await this.loadModels()
this.$toast.success('Table metadata added successfully').goAway(3000) this.$toast.success('Table metadata added successfully').goAway(3000)
}, 1000) }, 1000)
@ -207,7 +207,7 @@ export default {
this.$toast.error('Some error occurred').goAway(5000) this.$toast.error('Some error occurred').goAway(5000)
} }
}, },
async deleteTableMeta (tables) { async deleteTableMeta(tables) {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
@ -215,7 +215,7 @@ export default {
}, 'viewMetaDelete', { }, 'viewMetaDelete', {
tableNames: tables tableNames: tables
}]) }])
setTimeout(async () => { setTimeout(async() => {
await this.loadModels() await this.loadModels()
this.$toast.success('Table metadata deleted successfully').goAway(3000) this.$toast.success('Table metadata deleted successfully').goAway(3000)
}, 1000) }, 1000)
@ -223,7 +223,7 @@ export default {
this.$toast.error('Some error occurred').goAway(5000) this.$toast.error('Some error occurred').goAway(5000)
} }
}, },
async syncMetadata () { async syncMetadata() {
const addTables = this.comparedModelList.filter(t => t.new).map(t => t.title) const addTables = this.comparedModelList.filter(t => t.new).map(t => t.title)
const deleteTables = this.comparedModelList.filter(t => t.deleted).map(t => t.title) const deleteTables = this.comparedModelList.filter(t => t.deleted).map(t => t.title)
if (addTables.length) { if (addTables.length) {
@ -234,7 +234,7 @@ export default {
} }
}, },
async recreateTableMeta (table) { async recreateTableMeta(table) {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
@ -242,7 +242,7 @@ export default {
}, 'viewMetaRecreate', { }, 'viewMetaRecreate', {
tn: table tn: table
}]) }])
setTimeout(async () => { setTimeout(async() => {
await this.loadModels() await this.loadModels()
this.$toast.success('Table metadata recreated successfully').goAway(3000) this.$toast.success('Table metadata recreated successfully').goAway(3000)
}, 1000) }, 1000)
@ -250,7 +250,7 @@ export default {
this.$toast.error('Some error occurred').goAway(5000) this.$toast.error('Some error occurred').goAway(5000)
} }
}, },
async loadModels () { async loadModels() {
if (this.dbAliasList[this.dbsTab]) { if (this.dbAliasList[this.dbsTab]) {
this.models = await this.$store.dispatch('sqlMgr/ActSqlOp', [{ this.models = await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
@ -259,14 +259,14 @@ export default {
this.edited = false this.edited = false
} }
}, },
async loadTableList () { async loadTableList() {
this.views = (await this.$store.dispatch('sqlMgr/ActSqlOp', [{ this.views = (await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
env: this.$store.getters['project/GtrEnv'] env: this.$store.getters['project/GtrEnv']
}, 'viewList'])).data.list }, 'viewList'])).data.list
}, },
async saveModels () { async saveModels() {
this.updating = true this.updating = true
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{
@ -286,16 +286,16 @@ export default {
...mapGetters({ ...mapGetters({
dbAliasList: 'project/GtrDbAliasList' dbAliasList: 'project/GtrDbAliasList'
}), }),
enableCountText () { enableCountText() {
return this.models return this.models
? `${this.models.filter(m => m.enabled).length}/${this.models.length} enabled` ? `${this.models.filter(m => m.enabled).length}/${this.models.length} enabled`
: '' : ''
}, },
isNewOrDeletedModelFound () { isNewOrDeletedModelFound() {
return this.comparedModelList.some(m => m.new || m.deleted) return this.comparedModelList.some(m => m.new || m.deleted)
}, },
comparedModelList () { comparedModelList() {
const res = [] const res = []
const getPriority = (item) => { const getPriority = (item) => {
if (item.new) { return 2 } if (item.new) { return 2 }

10
packages/nc-gui/components/project/projectMetadata/uiAcl/toggleFunctionUIAcl.vue

@ -112,11 +112,11 @@ export default {
filter: '', filter: '',
functions: null functions: null
}), }),
async mounted () { async mounted() {
await this.loadFunctionList() await this.loadFunctionList()
}, },
methods: { methods: {
async loadFunctionList () { async loadFunctionList() {
this.functions = (await this.$store.dispatch('sqlMgr/ActSqlOp', [{ this.functions = (await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
env: this.$store.getters['project/GtrEnv'] env: this.$store.getters['project/GtrEnv']
@ -124,7 +124,7 @@ export default {
type: 'function' type: 'function'
}])) }]))
}, },
async save () { async save() {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
@ -143,10 +143,10 @@ export default {
...mapGetters({ ...mapGetters({
dbAliasList: 'project/GtrDbAliasList' dbAliasList: 'project/GtrDbAliasList'
}), }),
edited () { edited() {
return this.functions && this.functions.length && this.functions.some(t => t.edited) return this.functions && this.functions.length && this.functions.some(t => t.edited)
}, },
roles () { roles() {
return this.functions && this.functions.length ? Object.keys(this.functions[0].disabled) : [] return this.functions && this.functions.length ? Object.keys(this.functions[0].disabled) : []
} }
} }

10
packages/nc-gui/components/project/projectMetadata/uiAcl/toggleProcedureUIAcl.vue

@ -112,11 +112,11 @@ export default {
filter: '', filter: '',
procedures: null procedures: null
}), }),
async mounted () { async mounted() {
await this.loadFunctionList() await this.loadFunctionList()
}, },
methods: { methods: {
async loadFunctionList () { async loadFunctionList() {
this.procedures = (await this.$store.dispatch('sqlMgr/ActSqlOp', [{ this.procedures = (await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
env: this.$store.getters['project/GtrEnv'] env: this.$store.getters['project/GtrEnv']
@ -124,7 +124,7 @@ export default {
type: 'procedure' type: 'procedure'
}])) }]))
}, },
async save () { async save() {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
@ -143,10 +143,10 @@ export default {
...mapGetters({ ...mapGetters({
dbAliasList: 'project/GtrDbAliasList' dbAliasList: 'project/GtrDbAliasList'
}), }),
edited () { edited() {
return this.procedures && this.procedures.length && this.procedures.some(t => t.edited) return this.procedures && this.procedures.length && this.procedures.some(t => t.edited)
}, },
roles () { roles() {
return this.procedures && this.procedures.length ? Object.keys(this.procedures[0].disabled) : [] return this.procedures && this.procedures.length ? Object.keys(this.procedures[0].disabled) : []
} }
} }

10
packages/nc-gui/components/project/projectMetadata/uiAcl/toggleRelationsUIAcl.vue

@ -113,11 +113,11 @@ export default {
filter: '', filter: '',
relations: null relations: null
}), }),
async mounted () { async mounted() {
await this.loadViewList() await this.loadViewList()
}, },
methods: { methods: {
async loadViewList () { async loadViewList() {
this.relations = (await this.$store.dispatch('sqlMgr/ActSqlOp', [{ this.relations = (await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
env: this.$store.getters['project/GtrEnv'] env: this.$store.getters['project/GtrEnv']
@ -125,7 +125,7 @@ export default {
type: 'relation' type: 'relation'
}])) }]))
}, },
async save () { async save() {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
@ -144,10 +144,10 @@ export default {
...mapGetters({ ...mapGetters({
dbAliasList: 'project/GtrDbAliasList' dbAliasList: 'project/GtrDbAliasList'
}), }),
edited () { edited() {
return this.relations && this.relations.length && this.relations.some(t => t.edited) return this.relations && this.relations.length && this.relations.some(t => t.edited)
}, },
roles () { roles() {
return this.relations && this.relations.length ? Object.keys(this.relations[0].disabled) : [] return this.relations && this.relations.length ? Object.keys(this.relations[0].disabled) : []
} }
} }

10
packages/nc-gui/components/project/projectMetadata/uiAcl/toggleTableUIAcl.vue

@ -119,11 +119,11 @@ export default {
filter: '', filter: '',
tables: null tables: null
}), }),
async mounted () { async mounted() {
await this.loadTableList() await this.loadTableList()
}, },
methods: { methods: {
async loadTableList () { async loadTableList() {
this.tables = (await this.$store.dispatch('sqlMgr/ActSqlOp', [{ this.tables = (await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
env: this.$store.getters['project/GtrEnv'] env: this.$store.getters['project/GtrEnv']
@ -131,7 +131,7 @@ export default {
type: 'table' type: 'table'
}])) }]))
}, },
async save () { async save() {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
@ -150,10 +150,10 @@ export default {
...mapGetters({ ...mapGetters({
dbAliasList: 'project/GtrDbAliasList' dbAliasList: 'project/GtrDbAliasList'
}), }),
edited () { edited() {
return this.tables && this.tables.length && this.tables.some(t => t.edited) return this.tables && this.tables.length && this.tables.some(t => t.edited)
}, },
roles () { roles() {
return this.tables && this.tables.length ? Object.keys(this.tables[0].disabled) : [] return this.tables && this.tables.length ? Object.keys(this.tables[0].disabled) : []
} }
} }

10
packages/nc-gui/components/project/projectMetadata/uiAcl/toggleViewUIAcl.vue

@ -110,11 +110,11 @@ export default {
filter: '', filter: '',
views: null views: null
}), }),
async mounted () { async mounted() {
await this.loadViewList() await this.loadViewList()
}, },
methods: { methods: {
async loadViewList () { async loadViewList() {
this.views = (await this.$store.dispatch('sqlMgr/ActSqlOp', [{ this.views = (await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
env: this.$store.getters['project/GtrEnv'] env: this.$store.getters['project/GtrEnv']
@ -122,7 +122,7 @@ export default {
type: 'view' type: 'view'
}])) }]))
}, },
async save () { async save() {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{
dbAlias: this.db.meta.dbAlias, dbAlias: this.db.meta.dbAlias,
@ -141,10 +141,10 @@ export default {
...mapGetters({ ...mapGetters({
dbAliasList: 'project/GtrDbAliasList' dbAliasList: 'project/GtrDbAliasList'
}), }),
edited () { edited() {
return this.views && this.views.length && this.views.some(t => t.edited) return this.views && this.views.length && this.views.some(t => t.edited)
}, },
roles () { roles() {
return this.views && this.views.length ? Object.keys(this.views[0].disabled) : [] return this.views && this.views.length ? Object.keys(this.views[0].disabled) : []
} }
} }

8
packages/nc-gui/components/project/restHandlerCodeEditor.vue

@ -58,16 +58,16 @@ export default {
}), }),
computed: { computed: {
dialogShow: { dialogShow: {
get () { get() {
return this.value return this.value
}, },
set (val) { set(val) {
this.$emit('input', val) this.$emit('input', val)
} }
} }
}, },
watch: { watch: {
async route (val) { async route(val) {
try { try {
if (this.isMiddleware) { if (this.isMiddleware) {
this.code = JSON.parse(val.functions)[0] this.code = JSON.parse(val.functions)[0]
@ -108,7 +108,7 @@ export default {
} }
}, },
methods: { methods: {
async saveCode () { async saveCode() {
try { try {
this.progressbar = true this.progressbar = true
if (this.isMiddleware) { if (this.isMiddleware) {

30
packages/nc-gui/components/project/seed.vue

@ -94,7 +94,7 @@ export default {
components: { components: {
dlgLabelSubmitCancel dlgLabelSubmitCancel
}, },
data () { data() {
return { return {
settings: {}, settings: {},
dialogShow: false, dialogShow: false,
@ -105,7 +105,7 @@ export default {
...mapGetters({ sqlMgr: 'sqlMgr/sqlMgr' }) ...mapGetters({ sqlMgr: 'sqlMgr/sqlMgr' })
}, },
watch: {}, watch: {},
async created () { async created() {
this.seedsFolder = this.sqlMgr.projectGetFolder({ this.seedsFolder = this.sqlMgr.projectGetFolder({
env: this.nodes.env, env: this.nodes.env,
dbAlias: this.nodes.dbAlias dbAlias: this.nodes.dbAlias
@ -126,12 +126,12 @@ export default {
this.settings = result.data this.settings = result.data
} }
}, },
mounted () { mounted() {
}, },
beforeDestroy () { beforeDestroy() {
}, },
methods: { methods: {
async dlgAction (action = '') { async dlgAction(action = '') {
console.log('dlgAction', action) console.log('dlgAction', action)
if (action === 'hideDialog') { if (action === 'hideDialog') {
this.dialogShow = false this.dialogShow = false
@ -140,7 +140,7 @@ export default {
await this.seedInit() await this.seedInit()
} }
}, },
async seedInit () { async seedInit() {
try { try {
const result = await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [ const result = await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
{ {
@ -159,7 +159,7 @@ export default {
} }
}, },
async seedTerm () { async seedTerm() {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [ await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
{ {
@ -176,9 +176,9 @@ export default {
} }
}, },
async seedStart () { async seedStart() {
try { try {
setTimeout(async () => { setTimeout(async() => {
await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [ await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
{ {
env: this.nodes.env, env: this.nodes.env,
@ -195,7 +195,7 @@ export default {
} }
}, },
async seedStop () { async seedStop() {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [ await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
{ {
@ -212,7 +212,7 @@ export default {
} }
}, },
async seedSettingsUpdate () { async seedSettingsUpdate() {
try { try {
this.settings.rows.value = +this.settings.rows.value > 100 ? 100 : this.settings.rows.value this.settings.rows.value = +this.settings.rows.value > 100 ? 100 : this.settings.rows.value
@ -232,15 +232,15 @@ export default {
}, },
beforeCreated () { beforeCreated() {
}, },
destroy () { destroy() {
}, },
directives: {}, directives: {},
validate ({ params }) { validate({ params }) {
return true return true
}, },
head () { head() {
return {} return {}
}, },
props: ['nodes'] props: ['nodes']

24
packages/nc-gui/components/project/sequence.vue

@ -150,7 +150,7 @@ import dlgLabelSubmitCancel from '../utils/dlgLabelSubmitCancel'
export default { export default {
components: { dlgLabelSubmitCancel }, components: { dlgLabelSubmitCancel },
data () { data() {
return { return {
edited: false, edited: false,
originalNodes: {}, originalNodes: {},
@ -171,7 +171,7 @@ export default {
'project/loadSequencesFromParentTreeNode', 'project/loadSequencesFromParentTreeNode',
removeSequenceTab: 'tabs/removeSequenceTab' removeSequenceTab: 'tabs/removeSequenceTab'
}), }),
async loadSequences () { async loadSequences() {
try { try {
this.$store.commit('notification/MutToggleProgressBar', true) this.$store.commit('notification/MutToggleProgressBar', true)
if (this.newSequence) { if (this.newSequence) {
@ -205,7 +205,7 @@ export default {
this.$store.commit('notification/MutToggleProgressBar', false) this.$store.commit('notification/MutToggleProgressBar', false)
} }
}, },
async applyChanges () { async applyChanges() {
try { try {
if (this.newSequence) { if (this.newSequence) {
const result = await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [ const result = await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
@ -244,7 +244,7 @@ export default {
throw e throw e
} }
}, },
async deleteSequence (action = '') { async deleteSequence(action = '') {
try { try {
if (action === 'showDialog') { if (action === 'showDialog') {
this.dialogShow = true this.dialogShow = true
@ -279,12 +279,12 @@ export default {
throw e throw e
} }
}, },
sequenceNameChanged () { sequenceNameChanged() {
console.log('changed', this.sequence.sequence_name.trim()) console.log('changed', this.sequence.sequence_name.trim())
this.edited = this.sequence.sequence_name.trim() !== '' this.edited = this.sequence.sequence_name.trim() !== ''
} }
}, },
beforeCreated () { beforeCreated() {
}, },
watch: { watch: {
// 'sequence' : { // 'sequence' : {
@ -296,21 +296,21 @@ export default {
// } // }
// } // }
}, },
async created () { async created() {
this.originalNodes = { ...this.nodes } this.originalNodes = { ...this.nodes }
await this.loadSequences() await this.loadSequences()
}, },
mounted () { mounted() {
}, },
beforeDestroy () { beforeDestroy() {
}, },
destroy () { destroy() {
}, },
directives: {}, directives: {},
validate ({ params }) { validate({ params }) {
return true return true
}, },
head () { head() {
return {} return {}
}, },
props: ['nodes'] props: ['nodes']

26
packages/nc-gui/components/project/settings/appearance.vue

@ -163,7 +163,7 @@ import themes from '../../../helpers/themes'
export default { export default {
components: { }, components: { },
data () { data() {
return { return {
rightClickCount: 0, rightClickCount: 0,
tab: null, tab: null,
@ -194,35 +194,35 @@ export default {
themes themes
} }
}, },
fetch ({ store, params }) { fetch({ store, params }) {
}, },
computed: { computed: {
language: { language: {
get () { get() {
return this.$store.state.windows.language return this.$store.state.windows.language
}, },
set (val) { set(val) {
this.$store.commit('windows/MutLanguage', val) this.$store.commit('windows/MutLanguage', val)
} }
}, },
showMetatable: { showMetatable: {
get () { get() {
return this.$store.state.windows.metatables return this.$store.state.windows.metatables
}, },
set (show) { set(show) {
this.$store.commit('windows/MutMetatables', show) this.$store.commit('windows/MutMetatables', show)
} }
}, },
showScreensaver: { showScreensaver: {
get () { get() {
return this.$store.state.windows.screensaver return this.$store.state.windows.screensaver
}, },
set (show) { set(show) {
this.$store.commit('windows/MutScreensaver', show) this.$store.commit('windows/MutScreensaver', show)
} }
} }
}, },
created () { created() {
this.customTheme = { ...this.customTheme, ...this.$store.state.windows.customTheme } this.customTheme = { ...this.customTheme, ...this.$store.state.windows.customTheme }
this.item = this.$store.state.windows.themeName this.item = this.$store.state.windows.themeName
this.$store.watch( this.$store.watch(
@ -239,23 +239,23 @@ export default {
}) })
}, },
methods: { methods: {
rightClick () { rightClick() {
this.rightClickCount++ this.rightClickCount++
if (this.rightClickCount > 5) { if (this.rightClickCount > 5) {
// require('electron').remote.getCurrentWindow().toggleDevTools(); // require('electron').remote.getCurrentWindow().toggleDevTools();
this.rightClickCount = 0 this.rightClickCount = 0
} }
}, },
async changeTheme (t, theme = 'Custom') { async changeTheme(t, theme = 'Custom') {
this.item = theme this.item = theme
if (theme === 'Custom') { await this.$store.dispatch('windows/ActSetTheme', { theme: { ...t }, custom: true }) } if (theme === 'Custom') { await this.$store.dispatch('windows/ActSetTheme', { theme: { ...t }, custom: true }) }
await this.$store.dispatch('windows/ActSetTheme', { theme: { ...t }, themeName: theme }) await this.$store.dispatch('windows/ActSetTheme', { theme: { ...t }, themeName: theme })
}, },
toggleDarkTheme () { toggleDarkTheme() {
this.$store.commit('windows/MutToggleDarkMode') this.$store.commit('windows/MutToggleDarkMode')
} }
}, },
beforeCreated () { beforeCreated() {
} }
} }
</script> </script>

4
packages/nc-gui/components/project/settings/env.vue

@ -48,7 +48,7 @@ export default {
envList: 'project/GtrEnvList' envList: 'project/GtrEnvList'
}) })
}, },
mounted () { mounted() {
const unserializedList = this.$store.state.project.unserializedList const unserializedList = this.$store.state.project.unserializedList
this.selectedEnv = (unserializedList[0] && this.selectedEnv = (unserializedList[0] &&
unserializedList[0].projectJson && unserializedList[0].projectJson &&
@ -61,7 +61,7 @@ export default {
}, (value) => { this.selectedEnv = value }) }, (value) => { this.selectedEnv = value })
}, },
methods: { methods: {
async changeEnv () { async changeEnv() {
this.progressbar = true this.progressbar = true
await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'projectChangeEnv', { env: this.selectedEnv }]) await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'projectChangeEnv', { env: this.selectedEnv }])
await new Promise((resolve) => { await new Promise((resolve) => {

10
packages/nc-gui/components/project/settings/logs.vue

@ -81,19 +81,19 @@ export default {
}), }),
computed: { computed: {
toggleAll: { toggleAll: {
get () { get() {
return this.names && Object.values(this.names).some(v => v) return this.names && Object.values(this.names).some(v => v)
}, },
set (val) { set(val) {
this.names && Object.keys(this.names).forEach(k => this.$set(this.names, k, val)) this.names && Object.keys(this.names).forEach(k => this.$set(this.names, k, val))
} }
} }
}, },
async created () { async created() {
await this.load() await this.load()
}, },
methods: { methods: {
async load () { async load() {
this.loading = true this.loading = true
try { try {
const res = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcDebugGet']) const res = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcDebugGet'])
@ -103,7 +103,7 @@ export default {
this.loading = false this.loading = false
}, },
async save () { async save() {
this.loading = true this.loading = true
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcDebugSet', this.names]) await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcDebugSet', this.names])

42
packages/nc-gui/components/project/settings/versionAndUpdate.vue

@ -77,7 +77,7 @@ import dlgLabelSubmitCancel from '../../utils/dlgLabelSubmitCancel'
export default { export default {
components: { dlgLabelSubmitCancel }, components: { dlgLabelSubmitCancel },
data () { data() {
return { return {
rightClickCount: 0, rightClickCount: 0,
enableAppRefresh: false, enableAppRefresh: false,
@ -94,85 +94,85 @@ export default {
}, },
computed: { computed: {
checkForUpdate: { checkForUpdate: {
get () { get() {
return this.$store.state.windows.checkForUpdate return this.$store.state.windows.checkForUpdate
}, },
set (value) { set(value) {
this.$store.commit('windows/MutCheckForUpdate', value) this.$store.commit('windows/MutCheckForUpdate', value)
} }
}, },
autoUpdate: { autoUpdate: {
get () { get() {
return this.$store.state.windows.downloadAndUpdateRelease return this.$store.state.windows.downloadAndUpdateRelease
}, },
set (value) { set(value) {
this.$store.commit('windows/MutDownloadAndUpdateRelease', value) this.$store.commit('windows/MutDownloadAndUpdateRelease', value)
} }
}, },
isGaEnabled: { isGaEnabled: {
get () { get() {
return this.$store.state.windows.isGaEnabled return this.$store.state.windows.isGaEnabled
}, },
set (value) { set(value) {
this.$store.commit('windows/MutToggleGaEnabled', value) this.$store.commit('windows/MutToggleGaEnabled', value)
} }
}, },
isErrorReportingEnabled: { isErrorReportingEnabled: {
get () { get() {
return this.$store.state.windows.isErrorReportingEnabled return this.$store.state.windows.isErrorReportingEnabled
}, },
set (value) { set(value) {
this.$store.commit('windows/MutToggleErrorReportingEnabled', value) this.$store.commit('windows/MutToggleErrorReportingEnabled', value)
} }
}, },
isTelemetryEnabled: { isTelemetryEnabled: {
get () { get() {
return this.$store.state.windows.isErrorReportingEnabled return this.$store.state.windows.isErrorReportingEnabled
}, },
set (value) { set(value) {
this.$store.commit('windows/MutToggleTelemetryEnabled', value) this.$store.commit('windows/MutToggleTelemetryEnabled', value)
} }
}, },
dialogShow: { dialogShow: {
get () { get() {
return this.value return this.value
}, },
set (val) { set(val) {
this.$emit('input', val) this.$emit('input', val)
} }
}, },
language: { language: {
get () { get() {
return this.$store.state.windows.language return this.$store.state.windows.language
}, },
set (val) { set(val) {
this.$store.commit('windows/MutSetLanguage', val) this.$store.commit('windows/MutSetLanguage', val)
} }
} }
}, },
methods: { methods: {
rightClick () { rightClick() {
this.rightClickCount++ this.rightClickCount++
if (this.rightClickCount > 5) { if (this.rightClickCount > 5) {
// require('electron').remote.getCurrentWindow().toggleDevTools(); // require('electron').remote.getCurrentWindow().toggleDevTools();
this.rightClickCount = 0 this.rightClickCount = 0
} }
}, },
async applicationRefresh () { async applicationRefresh() {
localStorage.removeItem('vuex') localStorage.removeItem('vuex')
location.reload() location.reload()
}, },
toggleGa (event) { toggleGa(event) {
if (this.isGaEnabled) { if (this.isGaEnabled) {
this.gaDialogShow = true this.gaDialogShow = true
} else { this.isGaEnabled = true } } else { this.isGaEnabled = true }
}, },
toggleLogReport (event) { toggleLogReport(event) {
if (this.isErrorReportingEnabled) { if (this.isErrorReportingEnabled) {
this.logReportDialogShow = true this.logReportDialogShow = true
} else { this.isErrorReportingEnabled = true } } else { this.isErrorReportingEnabled = true }
}, },
logReportDialogFunction (action) { logReportDialogFunction(action) {
if (action !== 'hideDialog' && this.$store.state.users.user && this.$store.state.users.user.email) { if (action !== 'hideDialog' && this.$store.state.users.user && this.$store.state.users.user.email) {
this.isErrorReportingEnabled = false this.isErrorReportingEnabled = false
} else { } else {
@ -180,7 +180,7 @@ export default {
} }
this.logReportDialogShow = false this.logReportDialogShow = false
}, },
gaDialogFunction (action) { gaDialogFunction(action) {
if (action !== 'hideDialog') { if (action !== 'hideDialog') {
if (this.$store.state.users.user && this.$store.state.users.user.email) { if (this.$store.state.users.user && this.$store.state.users.user.email) {
this.isGaEnabled = false this.isGaEnabled = false

18
packages/nc-gui/components/project/settings/xcMeta.vue

@ -162,10 +162,10 @@ export default {
confirmMessage: '' confirmMessage: ''
}), }),
methods: { methods: {
async exportMeta () { async exportMeta() {
this.dialogShow = true this.dialogShow = true
this.confirmMessage = 'Do you want to export metadata from meta tables?' this.confirmMessage = 'Do you want to export metadata from meta tables?'
this.confirmAction = async (act) => { this.confirmAction = async(act) => {
if (act === 'hideDialog') { if (act === 'hideDialog') {
this.dialogShow = false this.dialogShow = false
} else { } else {
@ -187,10 +187,10 @@ export default {
} }
} }
}, },
async exportMetaZip () { async exportMetaZip() {
this.dialogShow = true this.dialogShow = true
this.confirmMessage = 'Do you want to export metadata from meta tables?' this.confirmMessage = 'Do you want to export metadata from meta tables?'
this.confirmAction = async (act) => { this.confirmAction = async(act) => {
if (act === 'hideDialog') { if (act === 'hideDialog') {
this.dialogShow = false this.dialogShow = false
} else { } else {
@ -224,10 +224,10 @@ export default {
} }
} }
}, },
async resetMeta () { async resetMeta() {
this.dialogShow = true this.dialogShow = true
this.confirmMessage = 'Do you want to clear metadata from meta tables?' this.confirmMessage = 'Do you want to clear metadata from meta tables?'
this.confirmAction = async (act) => { this.confirmAction = async(act) => {
if (act === 'hideDialog') { if (act === 'hideDialog') {
this.dialogShow = false this.dialogShow = false
} else { } else {
@ -250,10 +250,10 @@ export default {
} }
}, },
async importMeta () { async importMeta() {
this.dialogShow = true this.dialogShow = true
this.confirmMessage = 'Do you want to import metadata from meta directory?' this.confirmMessage = 'Do you want to import metadata from meta directory?'
this.confirmAction = async (act) => { this.confirmAction = async(act) => {
if (act === 'hideDialog') { if (act === 'hideDialog') {
this.dialogShow = false this.dialogShow = false
} else { } else {
@ -275,7 +275,7 @@ export default {
} }
} }
}, },
async importMetaZip () { async importMetaZip() {
if (this.$refs.importFile && this.$refs.importFile.files && this.$refs.importFile.files[0]) { if (this.$refs.importFile && this.$refs.importFile.files && this.$refs.importFile.files[0]) {
const zipFile = this.$refs.importFile.files[0] const zipFile = this.$refs.importFile.files[0]
this.loading = 'import-zip' this.loading = 'import-zip'

2
packages/nc-gui/components/project/spreadsheet/apis/apiFactory.js

@ -3,7 +3,7 @@ import GqlApi from '@/components/project/spreadsheet/apis/gqlApi'
import GrpcApi from '@/components/project/spreadsheet/apis/grpcApi' import GrpcApi from '@/components/project/spreadsheet/apis/grpcApi'
export default class ApiFactory { export default class ApiFactory {
static create (type, table, columns, ctx, meta) { static create(type, table, columns, ctx, meta) {
if (type === 'graphql') { if (type === 'graphql') {
return new GqlApi(table, columns, meta, ctx) return new GqlApi(table, columns, meta, ctx)
} else if (type === 'grpc') { } else if (type === 'grpc') {

50
packages/nc-gui/components/project/spreadsheet/apis/gqlApi.js

@ -1,7 +1,7 @@
import inflection from 'inflection' import inflection from 'inflection'
export default class GqlApi { export default class GqlApi {
constructor (table, columns, meta, $ctx) { constructor(table, columns, meta, $ctx) {
// this.table = table; // this.table = table;
this.columns = columns this.columns = columns
this.meta = meta this.meta = meta
@ -9,7 +9,7 @@ export default class GqlApi {
} }
// todo: - get version letter and use table alias // todo: - get version letter and use table alias
async list (params) { async list(params) {
const data = await this.post(`/nc/${this.$ctx.$route.params.project_id}/v1/graphql`, { const data = await this.post(`/nc/${this.$ctx.$route.params.project_id}/v1/graphql`, {
query: await this.gqlQuery(params), query: await this.gqlQuery(params),
variables: null variables: null
@ -17,7 +17,7 @@ export default class GqlApi {
return data.data.data[this.gqlQueryListName] return data.data.data[this.gqlQueryListName]
} }
async count (params) { async count(params) {
const data = await this.post(`/nc/${this.$ctx.$route.params.project_id}/v1/graphql`, { const data = await this.post(`/nc/${this.$ctx.$route.params.project_id}/v1/graphql`, {
query: this.gqlCountQuery(params), query: this.gqlCountQuery(params),
variables: null variables: null
@ -25,7 +25,7 @@ export default class GqlApi {
return data.data.data[this.gqlQueryCountName] return data.data.data[this.gqlQueryCountName]
} }
post (url, params) { post(url, params) {
return this.$axios({ return this.$axios({
url: `${this.$axios.defaults.baseURL}${url}`, url: `${this.$axios.defaults.baseURL}${url}`,
method: 'post', method: 'post',
@ -33,7 +33,7 @@ export default class GqlApi {
}) })
} }
generateQueryParams (params) { generateQueryParams(params) {
if (!params) { return '(where:"")' } if (!params) { return '(where:"")' }
const res = [] const res = []
if ('limit' in params) { if ('limit' in params) {
@ -57,35 +57,35 @@ export default class GqlApi {
return `(${res.join(',')})` return `(${res.join(',')})`
} }
async gqlQuery (params) { async gqlQuery(params) {
return `{${this.gqlQueryListName}${this.generateQueryParams(params)}{${this.gqlReqBody}${await this.gqlRelationReqBody(params)}}}` return `{${this.gqlQueryListName}${this.generateQueryParams(params)}{${this.gqlReqBody}${await this.gqlRelationReqBody(params)}}}`
} }
gqlReadQuery (id) { gqlReadQuery(id) {
return `{${this.gqlQueryReadName}(id:"${id}"){${this.gqlReqBody}}}` return `{${this.gqlQueryReadName}(id:"${id}"){${this.gqlReqBody}}}`
} }
gqlCountQuery (params) { gqlCountQuery(params) {
return `{${this.gqlQueryCountName}${this.generateQueryParams(params)}}` return `{${this.gqlQueryCountName}${this.generateQueryParams(params)}}`
} }
get gqlQueryListName () { get gqlQueryListName() {
return `${this.meta._tn}List` return `${this.meta._tn}List`
} }
get gqlQueryReadName () { get gqlQueryReadName() {
return `${this.meta._tn}Read` return `${this.meta._tn}Read`
} }
get tableCamelized () { get tableCamelized() {
return `${this.meta._tn}` return `${this.meta._tn}`
} }
get gqlReqBody () { get gqlReqBody() {
return `\n${this.columns.map(c => c._cn).join('\n')}\n` return `\n${this.columns.map(c => c._cn).join('\n')}\n`
} }
async gqlRelationReqBody (params) { async gqlRelationReqBody(params) {
let str = '' let str = ''
if (params.hm) { if (params.hm) {
for (const child of params.hm.split(',')) { for (const child of params.hm.split(',')) {
@ -129,23 +129,23 @@ export default class GqlApi {
return str return str
} }
get gqlQueryCountName () { get gqlQueryCountName() {
return `${this.tableCamelized}Count` return `${this.tableCamelized}Count`
} }
get gqlMutationCreateName () { get gqlMutationCreateName() {
return `${this.tableCamelized}Create` return `${this.tableCamelized}Create`
} }
get gqlMutationUpdateName () { get gqlMutationUpdateName() {
return `${this.tableCamelized}Update` return `${this.tableCamelized}Update`
} }
get gqlMutationDeleteName () { get gqlMutationDeleteName() {
return `${this.tableCamelized}Delete` return `${this.tableCamelized}Delete`
} }
async paginatedList (params) { async paginatedList(params) {
// const list = await this.list(params); // const list = await this.list(params);
// const count = (await this.count({where: params.where || ''})); // const count = (await this.count({where: params.where || ''}));
const [list, count] = await Promise.all([ const [list, count] = await Promise.all([
@ -158,7 +158,7 @@ export default class GqlApi {
return { list, count } return { list, count }
} }
async update (id, data, oldData) { async update(id, data, oldData) {
const data1 = await this.post(`/nc/${this.$ctx.$route.params.project_id}/v1/graphql`, { const data1 = await this.post(`/nc/${this.$ctx.$route.params.project_id}/v1/graphql`, {
query: `mutation update($id:String!, $data:${this.tableCamelized}Input){ query: `mutation update($id:String!, $data:${this.tableCamelized}Input){
${this.gqlMutationUpdateName}(id: $id, data: $data) ${this.gqlMutationUpdateName}(id: $id, data: $data)
@ -180,7 +180,7 @@ export default class GqlApi {
return data1.data.data[this.gqlMutationUpdateName] return data1.data.data[this.gqlMutationUpdateName]
} }
async insert (data) { async insert(data) {
const data1 = await this.post(`/nc/${this.$ctx.$route.params.project_id}/v1/graphql`, { const data1 = await this.post(`/nc/${this.$ctx.$route.params.project_id}/v1/graphql`, {
query: `mutation create($data:${this.tableCamelized}Input){ query: `mutation create($data:${this.tableCamelized}Input){
${this.gqlMutationCreateName}(data: $data){${this.gqlReqBody}} ${this.gqlMutationCreateName}(data: $data){${this.gqlReqBody}}
@ -192,7 +192,7 @@ export default class GqlApi {
return data1.data.data[this.gqlMutationCreateName] return data1.data.data[this.gqlMutationCreateName]
} }
async delete (id) { async delete(id) {
const data1 = await this.post(`/nc/${this.$ctx.$route.params.project_id}/v1/graphql`, { const data1 = await this.post(`/nc/${this.$ctx.$route.params.project_id}/v1/graphql`, {
query: `mutation delete($id:String!){ query: `mutation delete($id:String!){
${this.gqlMutationDeleteName}(id: $id) ${this.gqlMutationDeleteName}(id: $id)
@ -203,7 +203,7 @@ export default class GqlApi {
return data1.data.data[this.gqlMutationDeleteName] return data1.data.data[this.gqlMutationDeleteName]
} }
async read (id) { async read(id) {
const data = await this.post(`/nc/${this.$ctx.$route.params.project_id}/v1/graphql`, { const data = await this.post(`/nc/${this.$ctx.$route.params.project_id}/v1/graphql`, {
query: this.gqlReadQuery(id), query: this.gqlReadQuery(id),
variables: null variables: null
@ -211,15 +211,15 @@ export default class GqlApi {
return data.data.data[this.gqlQueryReadName] return data.data.data[this.gqlQueryReadName]
} }
get $axios () { get $axios() {
return this.$ctx.$axios return this.$ctx.$axios
} }
get table () { get table() {
return this.meta && this.meta._tn && inflection.camelize(this.meta._tn) return this.meta && this.meta._tn && inflection.camelize(this.meta._tn)
} }
async paginatedM2mNotChildrenList (params, assoc, pid) { async paginatedM2mNotChildrenList(params, assoc, pid) {
const list = await this.post(`/nc/${this.$ctx.$route.params.project_id}/v1/graphql`, { const list = await this.post(`/nc/${this.$ctx.$route.params.project_id}/v1/graphql`, {
query: `query m2mNotChildren($pid: String!,$assoc:String!,$parent:String!, $limit:Int, $offset:Int){ query: `query m2mNotChildren($pid: String!,$assoc:String!,$parent:String!, $limit:Int, $offset:Int){
m2mNotChildren(pid: $pid,assoc:$assoc,parent:$parent,limit:$limit, offset:$offset) m2mNotChildren(pid: $pid,assoc:$assoc,parent:$parent,limit:$limit, offset:$offset)

4
packages/nc-gui/components/project/spreadsheet/apis/grpcApi.js

@ -1,12 +1,12 @@
export default class GrpcApi { export default class GrpcApi {
constructor (table, ctx) { constructor(table, ctx) {
this.table = table this.table = table
this.ctx = ctx this.ctx = ctx
} }
// todo: - get version letter and use table alias // todo: - get version letter and use table alias
async paginatedList (params) { async paginatedList(params) {
const result = await this.ctx.$store.dispatch('sqlMgr/ActSqlOp', [{ const result = await this.ctx.$store.dispatch('sqlMgr/ActSqlOp', [{
env: this.ctx.nodes.env, env: this.ctx.nodes.env,
dbAlias: this.ctx.nodes.dbAlias dbAlias: this.ctx.nodes.dbAlias

24
packages/nc-gui/components/project/spreadsheet/apis/restApi.js

@ -1,22 +1,22 @@
export default class RestApi { export default class RestApi {
constructor (table, $ctx) { constructor(table, $ctx) {
this.table = table this.table = table
this.$ctx = $ctx this.$ctx = $ctx
} }
// todo: - get version letter and use table alias // todo: - get version letter and use table alias
async list (params) { async list(params) {
// const data = await this.get(`/nc/${this.$ctx.$route.params.project_id}/api/v1/${this.table}`, params) // const data = await this.get(`/nc/${this.$ctx.$route.params.project_id}/api/v1/${this.table}`, params)
const data = await this.get(`/nc/${this.$ctx.$route.params.project_id}/api/v1/${this.table}`, params) const data = await this.get(`/nc/${this.$ctx.$route.params.project_id}/api/v1/${this.table}`, params)
return data.data return data.data
} }
async read (id) { async read(id) {
const data = await this.get(`/nc/${this.$ctx.$route.params.project_id}/api/v1/${this.table}/${id}`) const data = await this.get(`/nc/${this.$ctx.$route.params.project_id}/api/v1/${this.table}/${id}`)
return data.data return data.data
} }
async count (params) { async count(params) {
if (this.timeout) { if (this.timeout) {
return this.timeout return this.timeout
} }
@ -35,7 +35,7 @@ export default class RestApi {
} }
} }
get (url, params, extras = {}) { get(url, params, extras = {}) {
return this.$axios({ return this.$axios({
url, url,
params, params,
@ -43,7 +43,7 @@ export default class RestApi {
}) })
} }
async paginatedList (params) { async paginatedList(params) {
// const list = await this.list(params); // const list = await this.list(params);
// const count = (await this.count({where: params.where || ''})).count; // const count = (await this.count({where: params.where || ''})).count;
const [list, { count }] = await Promise.all([this.list(params), this.count({ const [list, { count }] = await Promise.all([this.list(params), this.count({
@ -53,7 +53,7 @@ export default class RestApi {
return { list, count } return { list, count }
} }
async paginatedM2mNotChildrenList (params, assoc, pid) { async paginatedM2mNotChildrenList(params, assoc, pid) {
/// api/v1/Film/m2mNotChildren/film_actor/44 /// api/v1/Film/m2mNotChildren/film_actor/44
// const list = await this.list(params); // const list = await this.list(params);
// const count = (await this.count({where: params.where || ''})).count; // const count = (await this.count({where: params.where || ''})).count;
@ -61,7 +61,7 @@ export default class RestApi {
return { list, count } return { list, count }
} }
async update (id, data, oldData) { async update(id, data, oldData) {
const res = await this.$axios({ const res = await this.$axios({
method: 'put', method: 'put',
url: `/nc/${this.$ctx.$route.params.project_id}/api/v1/${this.table}/${id}`, url: `/nc/${this.$ctx.$route.params.project_id}/api/v1/${this.table}/${id}`,
@ -79,7 +79,7 @@ export default class RestApi {
return res return res
} }
async insert (data) { async insert(data) {
return (await this.$axios({ return (await this.$axios({
method: 'post', method: 'post',
url: `/nc/${this.$ctx.$route.params.project_id}/api/v1/${this.table}`, url: `/nc/${this.$ctx.$route.params.project_id}/api/v1/${this.table}`,
@ -87,18 +87,18 @@ export default class RestApi {
})).data })).data
} }
async delete (id) { async delete(id) {
return this.$axios({ return this.$axios({
method: 'delete', method: 'delete',
url: `/nc/${this.$ctx.$route.params.project_id}/api/v1/${this.table}/${id}` url: `/nc/${this.$ctx.$route.params.project_id}/api/v1/${this.table}/${id}`
}) })
} }
get $axios () { get $axios() {
return this.$ctx.$axios return this.$ctx.$axios
} }
get apiUrl () { get apiUrl() {
return `${process.env.NODE_ENV === 'production' return `${process.env.NODE_ENV === 'production'
? `${window.location.protocol}//${window.location.hostname}${window.location.port ? `:${window.location.port}` : ''}` ? `${window.location.protocol}//${window.location.hostname}${window.location.port ? `:${window.location.port}` : ''}`
: 'http://localhost:8080'}/nc/${this.$ctx.$route.params.project_id}/api/v1/${this.table}` : 'http://localhost:8080'}/nc/${this.$ctx.$route.params.project_id}/api/v1/${this.table}`

2
packages/nc-gui/components/project/spreadsheet/components/cell/attachmentCell.vue

@ -48,7 +48,7 @@ export default {
dragOver: false dragOver: false
}), }),
computed: { computed: {
localState () { localState() {
try { try {
return JSON.parse(this.value) || [] return JSON.parse(this.value) || []
} catch (e) { } catch (e) {

2
packages/nc-gui/components/project/spreadsheet/components/cell/enumCell.vue

@ -18,7 +18,7 @@ export default {
name: 'EnumCell', name: 'EnumCell',
props: ['value', 'column'], props: ['value', 'column'],
computed: { computed: {
colors () { colors() {
const col = this.$store.state.windows.darkTheme ? colors.dark : colors.light const col = this.$store.state.windows.darkTheme ? colors.dark : colors.light
if (this.column && this.column.dtxp) { if (this.column && this.column.dtxp) {
return this.column.dtxp.split(',').map(v => v.replace(/^'|'$/g, '')).reduce((obj, v, i) => ({ return this.column.dtxp.split(',').map(v => v.replace(/^'|'$/g, '')).reduce((obj, v, i) => ({

2
packages/nc-gui/components/project/spreadsheet/components/cell/setListCell.vue

@ -21,7 +21,7 @@ export default {
props: ['value', 'column'], props: ['value', 'column'],
computed: { computed: {
setValues () { setValues() {
if (this.column && this.column.dtxp) { if (this.column && this.column.dtxp) {
return this.column.dtxp.split(',').map(v => v.replace(/^'|'$/g, '')) return this.column.dtxp.split(',').map(v => v.replace(/^'|'$/g, ''))
} }

8
packages/nc-gui/components/project/spreadsheet/components/columnFilter.vue

@ -143,20 +143,20 @@ export default {
}), }),
watch: { watch: {
filters: { filters: {
handler (v) { handler(v) {
this.$emit('input', v) this.$emit('input', v)
}, },
deep: true deep: true
}, },
value (v) { value(v) {
this.filters = v || [] this.filters = v || []
} }
}, },
created () { created() {
this.filters = this.value || [] this.filters = this.value || []
}, },
methods: { methods: {
addFilter () { addFilter() {
this.filters.push({ this.filters.push({
field: '', field: '',
op: '', op: '',

12
packages/nc-gui/components/project/spreadsheet/components/columnFilterMenu.vue

@ -63,33 +63,33 @@ export default {
}), }),
computed: { computed: {
autosave: { autosave: {
set (v) { set(v) {
this.$store.commit('windows/MutAutoApplyFilter', v) this.$store.commit('windows/MutAutoApplyFilter', v)
}, },
get () { get() {
return this.$store.state.windows.autoApplyFilter return this.$store.state.windows.autoApplyFilter
} }
} }
}, },
watch: { watch: {
filters: { filters: {
handler (v) { handler(v) {
if (this.autosave) { if (this.autosave) {
this.$emit('input', v) this.$emit('input', v)
} }
}, },
deep: true deep: true
}, },
autosave (v) { autosave(v) {
if (!v) { if (!v) {
this.filters = JSON.parse(JSON.stringify(this.value || [])) this.filters = JSON.parse(JSON.stringify(this.value || []))
} }
}, },
value (v) { value(v) {
this.filters = this.autosave ? v || [] : JSON.parse(JSON.stringify(v || [])) this.filters = this.autosave ? v || [] : JSON.parse(JSON.stringify(v || []))
} }
}, },
created () { created() {
this.filters = this.autosave ? this.value || [] : JSON.parse(JSON.stringify(this.value || [])) this.filters = this.autosave ? this.value || [] : JSON.parse(JSON.stringify(this.value || []))
}, },
methods: {} methods: {}

38
packages/nc-gui/components/project/spreadsheet/components/editColumn.vue

@ -381,46 +381,46 @@ export default {
formulas: ['AVERAGE()', 'COUNT()', 'COUNTA()', 'COUNTALL()', 'SUM()', 'MIN()', 'MAX()', 'AND()', 'OR()', 'TRUE()', 'FALSE()', 'NOT()', 'XOR()', 'ISERROR()', 'IF()', 'LEN()', 'MID()', 'LEFT()', 'RIGHT()', 'FIND()', 'CONCATENATE()', 'T()', 'VALUE()', 'ARRAYJOIN()', 'ARRAYUNIQUE()', 'ARRAYCOMPACT()', 'ARRAYFLATTEN()', 'ROUND()', 'ROUNDUP()', 'ROUNDDOWN()', 'INT()', 'EVEN()', 'ODD()', 'MOD()', 'LOG()', 'EXP()', 'POWER()', 'SQRT()', 'CEILING()', 'FLOOR()', 'ABS()', 'RECORD_ID()', 'CREATED_TIME()', 'ERROR()', 'BLANK()', 'YEAR()', 'MONTH()', 'DAY()', 'HOUR()', 'MINUTE()', 'SECOND()', 'TODAY()', 'NOW()', 'WORKDAY()', 'DATETIME_PARSE()', 'DATETIME_FORMAT()', 'SET_LOCALE()', 'SET_TIMEZONE()', 'DATESTR()', 'TIMESTR()', 'TONOW()', 'FROMNOW()', 'DATEADD()', 'WEEKDAY()', 'WEEKNUM()', 'DATETIME_DIFF()', 'WORKDAY_DIFF()', 'IS_BEFORE()', 'IS_SAME()', 'IS_AFTER()', 'REPLACE()', 'REPT()', 'LOWER()', 'UPPER()', 'TRIM()', 'SUBSTITUTE()', 'SEARCH()', 'SWITCH()', 'LAST_MODIFIED_TIME()', 'ENCODE_URL_COMPONENT()', 'REGEX_EXTRACT()', 'REGEX_MATCH()', 'REGEX_REPLACE()'] formulas: ['AVERAGE()', 'COUNT()', 'COUNTA()', 'COUNTALL()', 'SUM()', 'MIN()', 'MAX()', 'AND()', 'OR()', 'TRUE()', 'FALSE()', 'NOT()', 'XOR()', 'ISERROR()', 'IF()', 'LEN()', 'MID()', 'LEFT()', 'RIGHT()', 'FIND()', 'CONCATENATE()', 'T()', 'VALUE()', 'ARRAYJOIN()', 'ARRAYUNIQUE()', 'ARRAYCOMPACT()', 'ARRAYFLATTEN()', 'ROUND()', 'ROUNDUP()', 'ROUNDDOWN()', 'INT()', 'EVEN()', 'ODD()', 'MOD()', 'LOG()', 'EXP()', 'POWER()', 'SQRT()', 'CEILING()', 'FLOOR()', 'ABS()', 'RECORD_ID()', 'CREATED_TIME()', 'ERROR()', 'BLANK()', 'YEAR()', 'MONTH()', 'DAY()', 'HOUR()', 'MINUTE()', 'SECOND()', 'TODAY()', 'NOW()', 'WORKDAY()', 'DATETIME_PARSE()', 'DATETIME_FORMAT()', 'SET_LOCALE()', 'SET_TIMEZONE()', 'DATESTR()', 'TIMESTR()', 'TONOW()', 'FROMNOW()', 'DATEADD()', 'WEEKDAY()', 'WEEKNUM()', 'DATETIME_DIFF()', 'WORKDAY_DIFF()', 'IS_BEFORE()', 'IS_SAME()', 'IS_AFTER()', 'REPLACE()', 'REPT()', 'LOWER()', 'UPPER()', 'TRIM()', 'SUBSTITUTE()', 'SEARCH()', 'SWITCH()', 'LAST_MODIFIED_TIME()', 'ENCODE_URL_COMPONENT()', 'REGEX_EXTRACT()', 'REGEX_MATCH()', 'REGEX_REPLACE()']
}), }),
computed: { computed: {
isEditDisabled () { isEditDisabled() {
return this.editColumn && this.sqlUi === SqliteUi return this.editColumn && this.sqlUi === SqliteUi
}, },
isSQLite () { isSQLite() {
return this.sqlUi === SqliteUi return this.sqlUi === SqliteUi
}, },
isMSSQL () { isMSSQL() {
return this.sqlUi === MssqlUi return this.sqlUi === MssqlUi
}, },
dataTypes () { dataTypes() {
return this.sqlUi.getDataTypeListForUiType(this.newColumn) return this.sqlUi.getDataTypeListForUiType(this.newColumn)
}, },
isSelect () { isSelect() {
return this.newColumn && (this.newColumn.uidt === 'MultiSelect' || return this.newColumn && (this.newColumn.uidt === 'MultiSelect' ||
this.newColumn.uidt === 'SingleSelect') this.newColumn.uidt === 'SingleSelect')
}, },
isRelation () { isRelation() {
return this.newColumn && this.newColumn.uidt === 'ForeignKey' return this.newColumn && this.newColumn.uidt === 'ForeignKey'
}, },
isLinkToAnotherRecord () { isLinkToAnotherRecord() {
return this.newColumn && this.newColumn.uidt === 'LinkToAnotherRecord' return this.newColumn && this.newColumn.uidt === 'LinkToAnotherRecord'
}, },
relation () { relation() {
return this.meta && this.column && this.meta.belongsTo && this.meta.belongsTo.find(bt => bt.cn === this.column.cn) return this.meta && this.column && this.meta.belongsTo && this.meta.belongsTo.find(bt => bt.cn === this.column.cn)
} }
}, },
watch: { watch: {
column () { column() {
this.genColumnData() this.genColumnData()
} }
}, },
async created () { async created() {
this.genColumnData() this.genColumnData()
// await this.loadDataTypes(); // await this.loadDataTypes();
}, },
mounted () { mounted() {
this.focusInput() this.focusInput()
}, },
methods: { methods: {
onRelColumnSelect (colMeta) { onRelColumnSelect(colMeta) {
Object.assign(this.newColumn, { Object.assign(this.newColumn, {
dt: colMeta.dt, dt: colMeta.dt,
dtxp: colMeta.dtxp, dtxp: colMeta.dtxp,
@ -428,7 +428,7 @@ export default {
un: colMeta.un un: colMeta.un
}) })
}, },
genColumnData () { genColumnData() {
this.newColumn = this.column ? { ...this.column } : this.sqlUi.getNewColumn(this.meta.columns.length + 1) this.newColumn = this.column ? { ...this.column } : this.sqlUi.getNewColumn(this.meta.columns.length + 1)
this.newColumn.cno = this.newColumn.cn this.newColumn.cno = this.newColumn.cn
}, },
@ -447,11 +447,11 @@ export default {
} }
}, },
*/ */
close () { close() {
this.$emit('close') this.$emit('close')
this.newColumn = {} this.newColumn = {}
}, },
async save () { async save() {
if (!this.$refs.form.validate()) { if (!this.$refs.form.validate()) {
return return
} }
@ -501,7 +501,7 @@ export default {
this.$emit('close') this.$emit('close')
}, },
onDataTypeChange () { onDataTypeChange() {
this.newColumn.rqd = false this.newColumn.rqd = false
this.newColumn.pk = false this.newColumn.pk = false
this.newColumn.ai = false this.newColumn.ai = false
@ -516,7 +516,7 @@ export default {
this.newColumn.altered = this.newColumn.altered || 2 this.newColumn.altered = this.newColumn.altered || 2
}, },
onUiTypeChange () { onUiTypeChange() {
const colProp = this.sqlUi.getDataTypeForUiType(this.newColumn) const colProp = this.sqlUi.getDataTypeForUiType(this.newColumn)
this.newColumn = { this.newColumn = {
...this.newColumn, ...this.newColumn,
@ -534,14 +534,14 @@ export default {
this.newColumn.altered = this.newColumn.altered || 2 this.newColumn.altered = this.newColumn.altered || 2
}, },
focusInput () { focusInput() {
setTimeout(() => { setTimeout(() => {
if (this.$refs.column && this.$refs.column.$el) { if (this.$refs.column && this.$refs.column.$el) {
this.$refs.column.$el.querySelector('input').focus() this.$refs.column.$el.querySelector('input').focus()
} }
}, 100) }, 100)
}, },
async deleteRelation (action = '', column) { async deleteRelation(action = '', column) {
try { try {
if (action === 'showDialog') { if (action === 'showDialog') {
this.relationDeleteDlg = true this.relationDeleteDlg = true

10
packages/nc-gui/components/project/spreadsheet/components/editColumn/customSelectOptions.vue

@ -37,26 +37,26 @@ export default {
localState: [] localState: []
}), }),
computed: { computed: {
colors () { colors() {
return this.$store.state.windows.darkTheme ? colors.dark : colors.light return this.$store.state.windows.darkTheme ? colors.dark : colors.light
} }
}, },
watch: { watch: {
localState: { localState: {
handler (v) { handler(v) {
this.$emit('input', v.map(v => `'${v}'`).join(',')) this.$emit('input', v.map(v => `'${v}'`).join(','))
}, },
deep: true deep: true
}, },
value () { value() {
this.syncState() this.syncState()
} }
}, },
mounted () { mounted() {
this.syncState() this.syncState()
}, },
methods: { methods: {
syncState () { syncState() {
this.localState = (this.value || '').split(',').map(v => v.replace(/^'|'$/g, '')) this.localState = (this.value || '').split(',').map(v => v.replace(/^'|'$/g, ''))
} }
} }

16
packages/nc-gui/components/project/spreadsheet/components/editColumn/linkedToAnotherOptions.vue

@ -119,7 +119,7 @@ export default {
isRefColumnsLoading: false isRefColumnsLoading: false
}), }),
computed: { computed: {
onUpdateDeleteOptions () { onUpdateDeleteOptions() {
if (this.isMSSQL) { if (this.isMSSQL) {
return ['NO ACTION'] return ['NO ACTION']
} }
@ -131,7 +131,7 @@ export default {
'SET DEFAULT' 'SET DEFAULT'
] ]
}, },
tableRules () { tableRules() {
return [ return [
v => !!v || 'Required', v => !!v || 'Required',
(v) => { (v) => {
@ -149,7 +149,7 @@ export default {
] ]
} }
}, },
async created () { async created() {
await this.loadTablesList() await this.loadTablesList()
this.relation = { this.relation = {
childColumn: `${this.meta.tn}_id`, childColumn: `${this.meta.tn}_id`,
@ -163,7 +163,7 @@ export default {
} }
}, },
methods: { methods: {
async loadColumnList () { async loadColumnList() {
this.isRefColumnsLoading = true this.isRefColumnsLoading = true
const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [{ const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [{
env: this.nodes.env, env: this.nodes.env,
@ -186,7 +186,7 @@ export default {
this.isRefColumnsLoading = false this.isRefColumnsLoading = false
}, },
async loadTablesList () { async loadTablesList() {
this.isRefTablesLoading = true this.isRefTablesLoading = true
const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [{ const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [{
@ -197,7 +197,7 @@ export default {
this.refTables = result.data.list.map(({ tn, _tn }) => ({ tn, _tn })) this.refTables = result.data.list.map(({ tn, _tn }) => ({ tn, _tn }))
this.isRefTablesLoading = false this.isRefTablesLoading = false
}, },
async saveManyToMany () { async saveManyToMany() {
// try { // try {
// todo: toast // todo: toast
await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [ await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
@ -218,7 +218,7 @@ export default {
// throw e // throw e
// } // }
}, },
async saveRelation () { async saveRelation() {
if (this.type === 'mm') { if (this.type === 'mm') {
await this.saveManyToMany() await this.saveManyToMany()
return return
@ -281,7 +281,7 @@ export default {
// throw e // throw e
// } // }
}, },
onColumnSelect () { onColumnSelect() {
const col = this.refColumns.find(c => this.relation.parentColumn === c.cn) const col = this.refColumns.find(c => this.relation.parentColumn === c.cn)
this.$emit('onColumnSelect', col) this.$emit('onColumnSelect', col)
} }

18
packages/nc-gui/components/project/spreadsheet/components/editColumn/relationOptions.vue

@ -102,7 +102,7 @@ export default {
}), }),
computed: { computed: {
onUpdateDeleteOptions () { onUpdateDeleteOptions() {
if (this.isMSSQL) { if (this.isMSSQL) {
return [ return [
'NO ACTION'] 'NO ACTION']
@ -117,14 +117,14 @@ export default {
} }
}, },
watch: { watch: {
'column.cn' (c) { 'column.cn'(c) {
this.$set(this.relation, 'childColumn', c) this.$set(this.relation, 'childColumn', c)
}, },
isSQLite (v) { isSQLite(v) {
this.$set(this.relation, 'type', v ? 'virtual' : 'real') this.$set(this.relation, 'type', v ? 'virtual' : 'real')
} }
}, },
async created () { async created() {
await this.loadTablesList() await this.loadTablesList()
this.relation = { this.relation = {
childColumn: this.column.cn, childColumn: this.column.cn,
@ -137,11 +137,11 @@ export default {
type: this.isSQLite ? 'virtual' : 'real' type: this.isSQLite ? 'virtual' : 'real'
} }
}, },
mounted () { mounted() {
this.$set(this.relation, 'type', this.isSqlite ? 'virtual' : 'real') this.$set(this.relation, 'type', this.isSqlite ? 'virtual' : 'real')
}, },
methods: { methods: {
async loadColumnList () { async loadColumnList() {
if (!this.relation.parentTable) { return } if (!this.relation.parentTable) { return }
this.isRefColumnsLoading = true this.isRefColumnsLoading = true
@ -166,7 +166,7 @@ export default {
this.isRefColumnsLoading = false this.isRefColumnsLoading = false
}, },
async loadTablesList () { async loadTablesList() {
this.isRefTablesLoading = true this.isRefTablesLoading = true
const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [{ const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [{
@ -177,7 +177,7 @@ export default {
this.refTables = result.data.list.map(({ tn, _tn }) => ({ tn, _tn })) this.refTables = result.data.list.map(({ tn, _tn }) => ({ tn, _tn }))
this.isRefTablesLoading = false this.isRefTablesLoading = false
}, },
async saveRelation () { async saveRelation() {
// try { // try {
await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [ await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
{ {
@ -191,7 +191,7 @@ export default {
// throw e // throw e
// } // }
}, },
onColumnSelect () { onColumnSelect() {
const col = this.refColumns.find(c => this.relation.parentColumn === c.cn) const col = this.refColumns.find(c => this.relation.parentColumn === c.cn)
this.$emit('onColumnSelect', col) this.$emit('onColumnSelect', col)
} }

12
packages/nc-gui/components/project/spreadsheet/components/editVirtualColumn.vue

@ -55,21 +55,21 @@ export default {
newColumn: {} newColumn: {}
}), }),
watch: { watch: {
column (c) { column(c) {
this.newColumn = { ...c } this.newColumn = { ...c }
} }
}, },
async created () { async created() {
}, },
mounted () { mounted() {
this.newColumn = { ...this.column } this.newColumn = { ...this.column }
}, },
methods: { methods: {
close () { close() {
this.$emit('input', false) this.$emit('input', false)
this.newColumn = {} this.newColumn = {}
}, },
async save () { async save() {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ await this.$store.dispatch('sqlMgr/ActSqlOp', [{
env: this.nodes.env, env: this.nodes.env,
@ -89,7 +89,7 @@ export default {
this.$emit('input', false) this.$emit('input', false)
}, },
focusInput () { focusInput() {
setTimeout(() => { setTimeout(() => {
if (this.$refs.column && this.$refs.column.$el) { if (this.$refs.column && this.$refs.column.$el) {
this.$refs.column.$el.querySelector('input').focus() this.$refs.column.$el.querySelector('input').focus()

14
packages/nc-gui/components/project/spreadsheet/components/editableCell.vue

@ -157,20 +157,20 @@ export default {
destroyed: false destroyed: false
}), }),
mounted () { mounted() {
// this.$refs.input.focus(); // this.$refs.input.focus();
}, },
beforeDestroy () { beforeDestroy() {
if (this.changed && !(this.isAttachment || this.isEnum || this.isBoolean || this.isSet || this.isTime)) { if (this.changed && !(this.isAttachment || this.isEnum || this.isBoolean || this.isSet || this.isTime)) {
this.$emit('change') this.$emit('change')
} }
this.destroyed = true this.destroyed = true
}, },
methods: { methods: {
syncDataDebounce: debounce(async function (self) { syncDataDebounce: debounce(async function(self) {
await self.syncData() await self.syncData()
}, 1000), }, 1000),
syncData () { syncData() {
if (!this.destroyed) { if (!this.destroyed) {
this.$emit('update') this.$emit('update')
} }
@ -178,16 +178,16 @@ export default {
}, },
computed: { computed: {
localState: { localState: {
get () { get() {
return this.value return this.value
}, },
set (val) { set(val) {
this.changed = true this.changed = true
this.$emit('input', val) this.$emit('input', val)
this.syncDataDebounce(this) this.syncDataDebounce(this)
} }
}, },
parentListeners () { parentListeners() {
const $listeners = {} const $listeners = {}
if (this.$listeners.blur) { if (this.$listeners.blur) {

8
packages/nc-gui/components/project/spreadsheet/components/editableCell/booleanCell.vue

@ -13,16 +13,16 @@ export default {
}, },
computed: { computed: {
localState: { localState: {
get () { get() {
return this.value return this.value
}, },
set (val) { set(val) {
this.$emit('input', val) this.$emit('input', val)
// this.$emit('update'); // this.$emit('update');
} }
}, },
parentListeners () { parentListeners() {
const $listeners = {} const $listeners = {}
if (this.$listeners.blur) { if (this.$listeners.blur) {
@ -35,7 +35,7 @@ export default {
return $listeners return $listeners
} }
}, },
mounted () { mounted() {
this.$el.focus() this.$el.focus()
} }
} }

8
packages/nc-gui/components/project/spreadsheet/components/editableCell/datePickerCell.vue

@ -20,14 +20,14 @@ export default {
}, },
computed: { computed: {
localState: { localState: {
get () { get() {
return typeof this.value === 'string' ? this.value.replace(/(\d)T(?=\d)/, '$1 ') : (this.value && new Date(this.value)) return typeof this.value === 'string' ? this.value.replace(/(\d)T(?=\d)/, '$1 ') : (this.value && new Date(this.value))
}, },
set (val) { set(val) {
this.$emit('input', val && new Date(val).toJSON().slice(0, 10)) this.$emit('input', val && new Date(val).toJSON().slice(0, 10))
} }
}, },
parentListeners () { parentListeners() {
const $listeners = {} const $listeners = {}
if (this.$listeners.blur) { if (this.$listeners.blur) {
@ -40,7 +40,7 @@ export default {
return $listeners return $listeners
} }
}, },
mounted () { mounted() {
if (this.$el && this.$el.$el) { if (this.$el && this.$el.$el) {
this.$el.$el.focus() this.$el.$el.focus()
} }

8
packages/nc-gui/components/project/spreadsheet/components/editableCell/dateTimePickerCell.vue

@ -24,7 +24,7 @@ export default {
props: ['value', 'ignoreFocus'], props: ['value', 'ignoreFocus'],
computed: { computed: {
localState: { localState: {
get () { get() {
// todo : time value correction // todo : time value correction
if (/^\d{6,}$/.test(this.value)) { if (/^\d{6,}$/.test(this.value)) {
@ -33,12 +33,12 @@ export default {
return /\dT\d/.test(this.value) ? new Date(this.value.replace(/(\d)T(?=\d)/, '$1 ')) : (this.value && new Date(this.value)) return /\dT\d/.test(this.value) ? new Date(this.value.replace(/(\d)T(?=\d)/, '$1 ')) : (this.value && new Date(this.value))
}, },
set (val) { set(val) {
const uVal = val && new Date(val).toISOString().slice(0, 19).replace('T', ' ').replace(/(\d{1,2}:\d{1,2}):\d{1,2}$/, '$1') const uVal = val && new Date(val).toISOString().slice(0, 19).replace('T', ' ').replace(/(\d{1,2}:\d{1,2}):\d{1,2}$/, '$1')
this.$emit('input', uVal) this.$emit('input', uVal)
} }
}, },
parentListeners () { parentListeners() {
const $listeners = {} const $listeners = {}
if (this.$listeners.blur) { if (this.$listeners.blur) {
@ -51,7 +51,7 @@ export default {
return $listeners return $listeners
} }
}, },
mounted () { mounted() {
if (!this.ignoreFocus) { if (!this.ignoreFocus) {
this.$refs.picker.display = true this.$refs.picker.display = true
} }

24
packages/nc-gui/components/project/spreadsheet/components/editableCell/editableAttachmentCell.vue

@ -223,7 +223,7 @@ export default {
dragOver: false dragOver: false
}), }),
watch: { watch: {
value (val, prev) { value(val, prev) {
try { try {
this.localState = (typeof val === 'string' && val !== prev ? JSON.parse(val) : val) || [] this.localState = (typeof val === 'string' && val !== prev ? JSON.parse(val) : val) || []
} catch (e) { } catch (e) {
@ -236,7 +236,7 @@ export default {
// } // }
// } // }
}, },
created () { created() {
try { try {
this.localState = (typeof this.value === 'string' ? JSON.parse(this.value) : this.value) || [] this.localState = (typeof this.value === 'string' ? JSON.parse(this.value) : this.value) || []
} catch (e) { } catch (e) {
@ -244,30 +244,30 @@ export default {
} }
document.addEventListener('keydown', this.onArrowDown) document.addEventListener('keydown', this.onArrowDown)
}, },
beforeDestroy () { beforeDestroy() {
document.removeEventListener('keydown', this.onArrowDown) document.removeEventListener('keydown', this.onArrowDown)
}, },
mounted () { mounted() {
}, },
methods: { methods: {
openUrl (url, target) { openUrl(url, target) {
window.open(url, target) window.open(url, target)
}, },
isImage, isImage,
hideIfVisible () { hideIfVisible() {
if (this.showImage) { if (this.showImage) {
this.showImage = false this.showImage = false
} }
}, },
selectImage (selectedImage, i) { selectImage(selectedImage, i) {
this.carousel = i this.carousel = i
this.selectedImage = selectedImage this.selectedImage = selectedImage
this.showImage = true this.showImage = true
}, },
addFile () { addFile() {
if (!this.isLocked) { this.$refs.file.click() } if (!this.isLocked) { this.$refs.file.click() }
}, },
async onFileSelection () { async onFileSelection() {
if (!this.$refs.file.files || !this.$refs.file.files.length) { if (!this.$refs.file.files || !this.$refs.file.files.length) {
return return
} }
@ -289,12 +289,12 @@ export default {
this.$emit('input', JSON.stringify(this.localState)) this.$emit('input', JSON.stringify(this.localState))
this.$emit('update') this.$emit('update')
}, },
removeItem (i) { removeItem(i) {
this.localState.splice(i, 1) this.localState.splice(i, 1)
this.$emit('input', JSON.stringify(this.localState)) this.$emit('input', JSON.stringify(this.localState))
this.$emit('update') this.$emit('update')
}, },
onArrowDown (e) { onArrowDown(e) {
if (!this.showImage) { return } if (!this.showImage) { return }
e = e || window.event e = e || window.event
// eslint-disable-next-line eqeqeq // eslint-disable-next-line eqeqeq
@ -305,7 +305,7 @@ export default {
this.carousel = ++this.carousel % this.localState.length this.carousel = ++this.carousel % this.localState.length
} }
}, },
async onFileDrop (e) { async onFileDrop(e) {
this.dragOver = false this.dragOver = false
this.$refs.file.files = e.dataTransfer.files this.$refs.file.files = e.dataTransfer.files
await this.onFileSelection() await this.onFileSelection()

10
packages/nc-gui/components/project/spreadsheet/components/editableCell/enumListEditableCell.vue

@ -50,21 +50,21 @@ export default {
}, },
computed: { computed: {
localState: { localState: {
get () { get() {
return this.value return this.value
}, },
set (val) { set(val) {
this.$emit('input', val) this.$emit('input', val)
this.$emit('update') this.$emit('update')
} }
}, },
enumValues () { enumValues() {
if (this.column && this.column.dtxp) { if (this.column && this.column.dtxp) {
return this.column.dtxp.split(',').map(v => v.replace(/^'|'$/g, '')) return this.column.dtxp.split(',').map(v => v.replace(/^'|'$/g, ''))
} }
return [] return []
}, },
parentListeners () { parentListeners() {
const $listeners = {} const $listeners = {}
if (this.$listeners.blur) { if (this.$listeners.blur) {
@ -77,7 +77,7 @@ export default {
return $listeners return $listeners
} }
}, },
mounted () { mounted() {
// this.$el.focus(); // this.$el.focus();
// let event; // let event;
// event = document.createEvent('MouseEvents'); // event = document.createEvent('MouseEvents');

12
packages/nc-gui/components/project/spreadsheet/components/editableCell/enumRadioEditableCell.vue

@ -25,25 +25,25 @@ export default {
column: Object column: Object
}, },
computed: { computed: {
colors () { colors() {
return this.$store.state.windows.darkTheme ? colors.dark : colors.light return this.$store.state.windows.darkTheme ? colors.dark : colors.light
}, },
localState: { localState: {
get () { get() {
return this.value return this.value
}, },
set (val) { set(val) {
this.$emit('input', val) this.$emit('input', val)
this.$emit('update') this.$emit('update')
} }
}, },
enumValues () { enumValues() {
if (this.column && this.column.dtxp) { if (this.column && this.column.dtxp) {
return this.column.dtxp.split(',').map(v => v.replace(/^'|'$/g, '')) return this.column.dtxp.split(',').map(v => v.replace(/^'|'$/g, ''))
} }
return [] return []
}, },
parentListeners () { parentListeners() {
const $listeners = {} const $listeners = {}
if (this.$listeners.blur) { if (this.$listeners.blur) {
@ -55,7 +55,7 @@ export default {
return $listeners return $listeners
} }
}, },
mounted () { mounted() {
// this.$el.focus(); // this.$el.focus();
// let event; // let event;
// event = document.createEvent('MouseEvents'); // event = document.createEvent('MouseEvents');

8
packages/nc-gui/components/project/spreadsheet/components/editableCell/floatCell.vue

@ -10,14 +10,14 @@ export default {
}, },
computed: { computed: {
localState: { localState: {
get () { get() {
return this.value return this.value
}, },
set (val) { set(val) {
this.$emit('input', +val) this.$emit('input', +val)
} }
}, },
parentListeners () { parentListeners() {
const $listeners = {} const $listeners = {}
if (this.$listeners.blur) { if (this.$listeners.blur) {
@ -30,7 +30,7 @@ export default {
return $listeners return $listeners
} }
}, },
mounted () { mounted() {
this.$el.focus() this.$el.focus()
} }
} }

8
packages/nc-gui/components/project/spreadsheet/components/editableCell/integerCell.vue

@ -10,14 +10,14 @@ export default {
}, },
computed: { computed: {
localState: { localState: {
get () { get() {
return this.value return this.value
}, },
set (val) { set(val) {
this.$emit('input', parseInt(val, 10)) this.$emit('input', parseInt(val, 10))
} }
}, },
parentListeners () { parentListeners() {
const $listeners = {} const $listeners = {}
if (this.$listeners.blur) { if (this.$listeners.blur) {
@ -30,7 +30,7 @@ export default {
return $listeners return $listeners
} }
}, },
mounted () { mounted() {
this.$el.focus() this.$el.focus()
} }
} }

12
packages/nc-gui/components/project/spreadsheet/components/editableCell/jsonCell.vue

@ -31,7 +31,7 @@ export default {
}), }),
computed: { computed: {
parentListeners () { parentListeners() {
const $listeners = {} const $listeners = {}
if (this.$listeners.blur) { if (this.$listeners.blur) {
@ -45,22 +45,22 @@ export default {
} }
}, },
watch: { watch: {
value (val) { value(val) {
this.localState = typeof val === 'string' ? JSON.parse(val) : val this.localState = typeof val === 'string' ? JSON.parse(val) : val
}, },
localState (val) { localState(val) {
if (this.isForm) { if (this.isForm) {
this.$emit('input', JSON.stringify(val)) this.$emit('input', JSON.stringify(val))
} }
} }
}, },
created () { created() {
this.localState = typeof this.value === 'string' ? JSON.parse(this.value) : this.value this.localState = typeof this.value === 'string' ? JSON.parse(this.value) : this.value
}, },
mounted () { mounted() {
}, },
methods: { methods: {
save () { save() {
this.$emit('input', JSON.stringify(this.localState)) this.$emit('input', JSON.stringify(this.localState))
} }
} }

14
packages/nc-gui/components/project/spreadsheet/components/editableCell/setListCheckboxCell.vue

@ -25,28 +25,28 @@ export default {
column: Object, column: Object,
values: Array values: Array
}, },
data () { data() {
}, },
computed: { computed: {
colors () { colors() {
return this.$store.state.windows.darkTheme ? colors.dark : colors.light return this.$store.state.windows.darkTheme ? colors.dark : colors.light
}, },
localState: { localState: {
get () { get() {
return (this.value && this.value.split(',')) || [] return (this.value && this.value.split(',')) || []
}, },
set (val) { set(val) {
this.$emit('input', val.join(',')) this.$emit('input', val.join(','))
this.$emit('update') this.$emit('update')
} }
}, },
setValues () { setValues() {
if (this.column && this.column.dtxp) { if (this.column && this.column.dtxp) {
return this.column.dtxp.split(',').map(v => v.replace(/^'|'$/g, '')) return this.column.dtxp.split(',').map(v => v.replace(/^'|'$/g, ''))
} }
return this.values || [] return this.values || []
}, },
parentListeners () { parentListeners() {
const $listeners = {} const $listeners = {}
if (this.$listeners.blur) { if (this.$listeners.blur) {
@ -59,7 +59,7 @@ export default {
return $listeners return $listeners
} }
}, },
mounted () { mounted() {
this.$el.focus() this.$el.focus()
const event = document.createEvent('MouseEvents') const event = document.createEvent('MouseEvents')
event.initMouseEvent('mousedown', true, true, window) event.initMouseEvent('mousedown', true, true, window)

10
packages/nc-gui/components/project/spreadsheet/components/editableCell/setListEditableCell.vue

@ -54,21 +54,21 @@ export default {
}, },
computed: { computed: {
localState: { localState: {
get () { get() {
return this.value && this.value.split(',') return this.value && this.value.split(',')
}, },
set (val) { set(val) {
this.$emit('input', val.filter(v => this.setValues.includes(v)).join(',')) this.$emit('input', val.filter(v => this.setValues.includes(v)).join(','))
this.$emit('update') this.$emit('update')
} }
}, },
setValues () { setValues() {
if (this.column && this.column.dtxp) { if (this.column && this.column.dtxp) {
return this.column.dtxp.split(',').map(v => v.replace(/^'|'$/g, '')) return this.column.dtxp.split(',').map(v => v.replace(/^'|'$/g, ''))
} }
return [] return []
}, },
parentListeners () { parentListeners() {
const $listeners = {} const $listeners = {}
if (this.$listeners.blur) { if (this.$listeners.blur) {
@ -81,7 +81,7 @@ export default {
return $listeners return $listeners
} }
}, },
mounted () { mounted() {
// this.$el.focus(); // this.$el.focus();
// let event; // let event;
// event = document.createEvent('MouseEvents'); // event = document.createEvent('MouseEvents');

10
packages/nc-gui/components/project/spreadsheet/components/editableCell/textAreaCell.vue

@ -18,14 +18,14 @@ export default {
computed: { computed: {
localState: { localState: {
get () { get() {
return this.value return this.value
}, },
set (val) { set(val) {
this.$emit('input', val) this.$emit('input', val)
} }
}, },
parentListeners () { parentListeners() {
const $listeners = {} const $listeners = {}
if (this.$listeners.blur) { if (this.$listeners.blur) {
@ -38,10 +38,10 @@ export default {
return $listeners return $listeners
} }
}, },
created () { created() {
this.localState = this.value this.localState = this.value
}, },
mounted () { mounted() {
this.$refs.textarea && this.$refs.textarea.focus() this.$refs.textarea && this.$refs.textarea.focus()
} }
} }

12
packages/nc-gui/components/project/spreadsheet/components/editableCell/textAreaCellOld.vue

@ -32,7 +32,7 @@ export default {
}), }),
computed: { computed: {
parentListeners () { parentListeners() {
const $listeners = {} const $listeners = {}
if (this.$listeners.blur) { if (this.$listeners.blur) {
@ -46,23 +46,23 @@ export default {
} }
}, },
watch: { watch: {
value (val) { value(val) {
this.localState = val this.localState = val
}, },
localState (val) { localState(val) {
if (this.isForm) { if (this.isForm) {
this.$emit('input', val) this.$emit('input', val)
} }
} }
}, },
created () { created() {
this.localState = this.value this.localState = this.value
}, },
mounted () { mounted() {
this.$refs.textarea && this.$refs.textarea.focus() this.$refs.textarea && this.$refs.textarea.focus()
}, },
methods: { methods: {
save () { save() {
this.$emit('input', this.localState) this.$emit('input', this.localState)
} }
} }

8
packages/nc-gui/components/project/spreadsheet/components/editableCell/textCell.vue

@ -10,14 +10,14 @@ export default {
}, },
computed: { computed: {
localState: { localState: {
get () { get() {
return this.value return this.value
}, },
set (val) { set(val) {
this.$emit('input', val) this.$emit('input', val)
} }
}, },
parentListeners () { parentListeners() {
const $listeners = {} const $listeners = {}
if (this.$listeners.blur) { if (this.$listeners.blur) {
@ -34,7 +34,7 @@ export default {
return $listeners return $listeners
} }
}, },
mounted () { mounted() {
this.$el.focus() this.$el.focus()
} }
} }

8
packages/nc-gui/components/project/spreadsheet/components/editableCell/timePickerCell.vue

@ -20,14 +20,14 @@ export default {
}, },
computed: { computed: {
localState: { localState: {
get () { get() {
return typeof this.value === 'string' ? this.value.replace(/(\d)T(?=\d)/, '$1 ') : this.value return typeof this.value === 'string' ? this.value.replace(/(\d)T(?=\d)/, '$1 ') : this.value
}, },
set (val) { set(val) {
this.$emit('input', (new Date(val).toJSON() || '').slice(0, 10) || val) this.$emit('input', (new Date(val).toJSON() || '').slice(0, 10) || val)
} }
}, },
parentListeners () { parentListeners() {
const $listeners = {} const $listeners = {}
if (this.$listeners.blur) { if (this.$listeners.blur) {
@ -44,7 +44,7 @@ export default {
return $listeners return $listeners
} }
}, },
mounted () { mounted() {
if (this.$el && this.$el.$el) { if (this.$el && this.$el.$el) {
this.$el.$el.focus() this.$el.$el.focus()
} }

40
packages/nc-gui/components/project/spreadsheet/components/expandedForm.vue

@ -251,7 +251,7 @@ export default {
props: { props: {
breadcrumbs: { breadcrumbs: {
type: Array, type: Array,
default () { default() {
return [] return []
} }
}, },
@ -275,7 +275,7 @@ export default {
queryParams: Object, queryParams: Object,
disabledColumns: { disabledColumns: {
type: Object, type: Object,
default () { default() {
return {} return {}
} }
} }
@ -292,13 +292,13 @@ export default {
showSystemFields: false showSystemFields: false
}), }),
computed: { computed: {
primaryKey () { primaryKey() {
return this.isNew ? '' : this.meta.columns.filter(c => c.pk).map(c => this.localState[c._cn]).join('___') return this.isNew ? '' : this.meta.columns.filter(c => c.pk).map(c => this.localState[c._cn]).join('___')
}, },
edited () { edited() {
return !!Object.keys(this.changedColumns).length return !!Object.keys(this.changedColumns).length
}, },
fields () { fields() {
if (this.availableColumns) { return this.availableColumns } if (this.availableColumns) { return this.availableColumns }
const hideCols = ['created_at', 'updated_at'] const hideCols = ['created_at', 'updated_at']
@ -311,44 +311,44 @@ export default {
) || [] ) || []
} }
}, },
isChanged () { isChanged() {
return Object.values(this.changedColumns).some(Boolean) return Object.values(this.changedColumns).some(Boolean)
}, },
localBreadcrumbs () { localBreadcrumbs() {
return [...this.breadcrumbs, `${this.table} (${this.localState && this.localState[this.primaryValueColumn]})`] return [...this.breadcrumbs, `${this.table} (${this.localState && this.localState[this.primaryValueColumn]})`]
} }
}, },
watch: { watch: {
value (obj) { value(obj) {
this.localState = { ...obj } this.localState = { ...obj }
if (!this.isNew && this.toggleDrawer) { if (!this.isNew && this.toggleDrawer) {
this.getAuditsAndComments() this.getAuditsAndComments()
} }
}, },
isNew (n) { isNew(n) {
if (!n && this.toggleDrawer) { if (!n && this.toggleDrawer) {
this.getAuditsAndComments() this.getAuditsAndComments()
} }
}, },
meta () { meta() {
if (!this.isNew && this.toggleDrawer) { if (!this.isNew && this.toggleDrawer) {
this.getAuditsAndComments() this.getAuditsAndComments()
} }
}, },
toggleDrawer (td) { toggleDrawer(td) {
if (td) { if (td) {
this.getAuditsAndComments() this.getAuditsAndComments()
} }
} }
}, },
created () { created() {
this.localState = { ...this.value } this.localState = { ...this.value }
if (!this.isNew && this.toggleDrawer) { if (!this.isNew && this.toggleDrawer) {
this.getAuditsAndComments() this.getAuditsAndComments()
} }
}, },
methods: { methods: {
isRequired (_columnObj, rowObj) { isRequired(_columnObj, rowObj) {
let columnObj = _columnObj let columnObj = _columnObj
if (columnObj.bt) { if (columnObj.bt) {
columnObj = this.meta.columns.find(c => c.cn === columnObj.bt.cn) columnObj = this.meta.columns.find(c => c.cn === columnObj.bt.cn)
@ -358,14 +358,14 @@ export default {
(rowObj[columnObj._cn] === undefined || rowObj[columnObj._cn] === null) && (rowObj[columnObj._cn] === undefined || rowObj[columnObj._cn] === null) &&
!columnObj.default) !columnObj.default)
}, },
updateCol (_row, _cn, pid) { updateCol(_row, _cn, pid) {
this.$set(this.localState, _cn, pid) this.$set(this.localState, _cn, pid)
this.$set(this.changedColumns, _cn, true) this.$set(this.changedColumns, _cn, true)
}, },
isYou (email) { isYou(email) {
return this.$store.state.users.user && this.$store.state.users.user.email === email return this.$store.state.users.user && this.$store.state.users.user.email === email
}, },
async getAuditsAndComments () { async getAuditsAndComments() {
this.loadingLogs = true this.loadingLogs = true
const data = await this.$store.dispatch('sqlMgr/ActSqlOp', [{ dbAlias: this.dbAlias }, 'xcModelRowAuditAndCommentList', { const data = await this.$store.dispatch('sqlMgr/ActSqlOp', [{ dbAlias: this.dbAlias }, 'xcModelRowAuditAndCommentList', {
model_id: this.meta.columns.filter(c => c.pk).map(c => this.localState[c._cn]).join('___'), model_id: this.meta.columns.filter(c => c.pk).map(c => this.localState[c._cn]).join('___'),
@ -374,7 +374,7 @@ export default {
this.logs = data.list this.logs = data.list
this.loadingLogs = false this.loadingLogs = false
}, },
async save () { async save() {
try { try {
const id = this.meta.columns.filter(c => c.pk).map(c => this.localState[c._cn]).join('___') const id = this.meta.columns.filter(c => c.pk).map(c => this.localState[c._cn]).join('___')
@ -413,7 +413,7 @@ export default {
this.$toast.error(`Failed to update row : ${e.message}`).goAway(3000) this.$toast.error(`Failed to update row : ${e.message}`).goAway(3000)
} }
}, },
async reload () { async reload() {
// const id = this.meta.columns.filter((c) => c.pk).map(c => this.localState[c._cn]).join('___'); // const id = this.meta.columns.filter((c) => c.pk).map(c => this.localState[c._cn]).join('___');
const where = this.meta.columns.filter(c => c.pk).map(c => `(${c._cn},eq,${this.localState[c._cn]})`).join('~and') const where = this.meta.columns.filter(c => c.pk).map(c => `(${c._cn},eq,${this.localState[c._cn]})`).join('~and')
this.$set(this, 'changedColumns', {}) this.$set(this, 'changedColumns', {})
@ -424,10 +424,10 @@ export default {
this.getAuditsAndComments() this.getAuditsAndComments()
} }
}, },
calculateDiff (date) { calculateDiff(date) {
return dayjs.utc(date).fromNow() return dayjs.utc(date).fromNow()
}, },
async saveComment () { async saveComment() {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [ await this.$store.dispatch('sqlMgr/ActSqlOp', [
{ dbAlias: this.dbAlias }, { dbAlias: this.dbAlias },

2
packages/nc-gui/components/project/spreadsheet/components/extras.vue

@ -75,7 +75,7 @@ export default {
data: () => ({ data: () => ({
showCommunity: true showCommunity: true
}), }),
mounted () { mounted() {
setInterval(() => { setInterval(() => {
this.showCommunity = !this.showCommunity this.showCommunity = !this.showCommunity
}, 60000) }, 60000)

24
packages/nc-gui/components/project/spreadsheet/components/fieldsMenu.vue

@ -126,42 +126,42 @@ export default {
fieldsOrderLoc: [] fieldsOrderLoc: []
}), }),
computed: { computed: {
columnMeta () { columnMeta() {
return this.meta && this.meta.columns ? this.meta.columns.reduce((o, c) => ({ ...o, [c._cn]: c }), {}) : {} return this.meta && this.meta.columns ? this.meta.columns.reduce((o, c) => ({ ...o, [c._cn]: c }), {}) : {}
}, },
isAnyFieldHidden () { isAnyFieldHidden() {
return Object.values(this.showFields).some(v => !v) return Object.values(this.showFields).some(v => !v)
}, },
showSystemFieldsLoc: { showSystemFieldsLoc: {
get () { get() {
return this.showSystemFields return this.showSystemFields
}, },
set (v) { set(v) {
this.$emit('update:showSystemFields', v) this.$emit('update:showSystemFields', v)
} }
} }
}, },
watch: { watch: {
fieldList (f) { fieldList(f) {
this.fieldsOrderLoc = [...f] this.fieldsOrderLoc = [...f]
}, },
showFields: { showFields: {
handler (v) { handler(v) {
this.$emit('input', v) this.$emit('input', v)
}, },
deep: true deep: true
}, },
value (v) { value(v) {
this.showFields = v || [] this.showFields = v || []
}, },
fieldsOrder (n, o) { fieldsOrder(n, o) {
if ((n && n.join()) !== (o && o.join())) { if ((n && n.join()) !== (o && o.join())) {
this.fieldsOrderLoc = n this.fieldsOrderLoc = n
} }
}, },
fieldsOrderLoc: { fieldsOrderLoc: {
handler (n, o) { handler(n, o) {
if ((n && n.join()) !== (o && o.join())) { if ((n && n.join()) !== (o && o.join())) {
this.$emit('update:fieldsOrder', n) this.$emit('update:fieldsOrder', n)
} }
@ -169,16 +169,16 @@ export default {
deep: true deep: true
} }
}, },
created () { created() {
this.showFields = this.value this.showFields = this.value
this.fieldsOrderLoc = this.fieldsOrder this.fieldsOrderLoc = this.fieldsOrder
}, },
methods: { methods: {
showAll () { showAll() {
// eslint-disable-next-line no-return-assign,no-sequences // eslint-disable-next-line no-return-assign,no-sequences
this.showFields = Object.keys(this.showFields).reduce((o, k) => (o[k] = true, o), {}) this.showFields = Object.keys(this.showFields).reduce((o, k) => (o[k] = true, o), {})
}, },
hideAll () { hideAll() {
// eslint-disable-next-line no-return-assign,no-sequences // eslint-disable-next-line no-return-assign,no-sequences
this.showFields = Object.keys(this.showFields).reduce((o, k) => (o[k] = false, o), {}) this.showFields = Object.keys(this.showFields).reduce((o, k) => (o[k] = false, o), {})
} }

4
packages/nc-gui/components/project/spreadsheet/components/headerCell.vue

@ -144,7 +144,7 @@ export default {
columnDeleteDialog: false columnDeleteDialog: false
}), }),
methods: { methods: {
async deleteColumn () { async deleteColumn() {
try { try {
const column = { ...this.column, cno: this.column.cn } const column = { ...this.column, cno: this.column.cn }
column.altered = 4 column.altered = 4
@ -164,7 +164,7 @@ export default {
console.log(e) console.log(e)
} }
}, },
async setAsPrimaryValue () { async setAsPrimaryValue() {
// todo: pass only updated fields // todo: pass only updated fields
try { try {
const meta = JSON.parse(JSON.stringify(this.meta)) const meta = JSON.parse(JSON.stringify(this.meta))

2
packages/nc-gui/components/project/spreadsheet/components/lockMenu.vue

@ -85,7 +85,7 @@ export default {
}), }),
methods: { methods: {
changeLockType (type) { changeLockType(type) {
if (type === 'personal') { if (type === 'personal') {
return this.$toast.info('Coming soon').goAway(3000) return this.$toast.info('Coming soon').goAway(3000)
} }

4
packages/nc-gui/components/project/spreadsheet/components/pagination.vue

@ -41,11 +41,11 @@ export default {
page: 1 page: 1
}), }),
watch: { watch: {
value (v) { value(v) {
this.page = v this.page = v
} }
}, },
mounted () { mounted() {
this.page = this.value this.page = this.value
} }
} }

8
packages/nc-gui/components/project/spreadsheet/components/sharedViewsList.vue

@ -50,20 +50,20 @@ export default {
viewsList: null viewsList: null
}), }),
computed: { computed: {
origin () { origin() {
return location.origin return location.origin
} }
}, },
created () { created() {
this.loadSharedViewsList() this.loadSharedViewsList()
}, },
methods: { methods: {
async loadSharedViewsList () { async loadSharedViewsList() {
this.viewsList = await this.$store.dispatch('sqlMgr/ActSqlOp', [{ dbAlias: this.nodes.dbAlias }, 'listSharedViewLinks', { this.viewsList = await this.$store.dispatch('sqlMgr/ActSqlOp', [{ dbAlias: this.nodes.dbAlias }, 'listSharedViewLinks', {
model_name: this.modelName model_name: this.modelName
}]) }])
}, },
async deleteLink (id) { async deleteLink(id) {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [{ dbAlias: this.nodes.dbAlias }, 'deleteSharedViewLink', { await this.$store.dispatch('sqlMgr/ActSqlOp', [{ dbAlias: this.nodes.dbAlias }, 'deleteSharedViewLink', {
id id

8
packages/nc-gui/components/project/spreadsheet/components/sortListMenu.vue

@ -85,20 +85,20 @@ export default {
}), }),
watch: { watch: {
sortList: { sortList: {
handler (v) { handler(v) {
this.$emit('input', v) this.$emit('input', v)
}, },
deep: true deep: true
}, },
value (v) { value(v) {
this.sortList = v || [] this.sortList = v || []
} }
}, },
created () { created() {
this.filters = this.value || [] this.filters = this.value || []
}, },
methods: { methods: {
addSort () { addSort() {
this.sortList.push({ this.sortList.push({
field: '', field: '',
order: '' order: ''

40
packages/nc-gui/components/project/spreadsheet/components/spreadsheetNavDrawer.vue

@ -540,10 +540,10 @@ export default {
}), }),
computed: { computed: {
selectedViewIdLocal: { selectedViewIdLocal: {
get () { get() {
return this.selectedViewId return this.selectedViewId
}, },
set (id) { set(id) {
const selectedView = this.viewsList && this.viewsList.find(v => v.id === id) const selectedView = this.viewsList && this.viewsList.find(v => v.id === id)
let queryParams = {} let queryParams = {}
@ -572,26 +572,26 @@ export default {
} }
}, },
watch: { watch: {
async load (v) { async load(v) {
if (v) { if (v) {
await this.loadViews() await this.loadViews()
} }
} }
}, },
async created () { async created() {
if (this.load) { if (this.load) {
await this.loadViews() await this.loadViews()
} }
}, },
methods: { methods: {
hideMiniSponsorCard () { hideMiniSponsorCard() {
this.$store.commit('windows/MutMiniSponsorCard', Date.now()) this.$store.commit('windows/MutMiniSponsorCard', Date.now())
}, },
openCreateViewDlg (type) { openCreateViewDlg(type) {
this.createViewType = type this.createViewType = type
this.showCreateView = true this.showCreateView = true
}, },
isCentrallyAligned (col) { isCentrallyAligned(col) {
return ![ return ![
'SingleLineText', 'SingleLineText',
'LongText', 'LongText',
@ -605,13 +605,13 @@ export default {
'LastModifiedTime' 'LastModifiedTime'
].includes(col.uidt) ].includes(col.uidt)
}, },
onPasswordProtectChange () { onPasswordProtectChange() {
if (!this.passwordProtect) { if (!this.passwordProtect) {
this.shareLink.password = null this.shareLink.password = null
this.saveShareLinkPassword() this.saveShareLinkPassword()
} }
}, },
async saveShareLinkPassword () { async saveShareLinkPassword() {
try { try {
await this.$store.dispatch('sqlMgr/ActSqlOp', [ await this.$store.dispatch('sqlMgr/ActSqlOp', [
{ dbAlias: this.nodes.dbAlias }, { dbAlias: this.nodes.dbAlias },
@ -626,7 +626,7 @@ export default {
this.$toast.error(e.message).goAway(3000) this.$toast.error(e.message).goAway(3000)
} }
}, },
async loadViews () { async loadViews() {
this.viewsList = await this.sqlOp( this.viewsList = await this.sqlOp(
{ {
dbAlias: this.nodes.dbAlias dbAlias: this.nodes.dbAlias
@ -655,11 +655,11 @@ export default {
// } // }
// this.$emit('loadTableData'); // this.$emit('loadTableData');
// }, // },
copyapiUrlToClipboard () { copyapiUrlToClipboard() {
this.$clipboard(this.currentApiUrl) this.$clipboard(this.currentApiUrl)
this.clipboardSuccessHandler() this.clipboardSuccessHandler()
}, },
async updateViewName (view) { async updateViewName(view) {
try { try {
await this.sqlOp({ dbAlias: this.nodes.dbAlias }, 'xcVirtualTableRename', { await this.sqlOp({ dbAlias: this.nodes.dbAlias }, 'xcVirtualTableRename', {
id: view.id, id: view.id,
@ -673,7 +673,7 @@ export default {
} }
await this.loadViews() await this.loadViews()
}, },
showRenameTextBox (view, i) { showRenameTextBox(view, i) {
this.$set(view, 'edit', true) this.$set(view, 'edit', true)
this.$nextTick(() => { this.$nextTick(() => {
const input = this.$refs[`input${i}`][0] const input = this.$refs[`input${i}`][0]
@ -681,7 +681,7 @@ export default {
input.setSelectionRange(0, input.value.length) input.setSelectionRange(0, input.value.length)
}) })
}, },
async deleteView (view) { async deleteView(view) {
try { try {
await this.sqlOp({ dbAlias: this.nodes.dbAlias }, 'xcVirtualTableDelete', { await this.sqlOp({ dbAlias: this.nodes.dbAlias }, 'xcVirtualTableDelete', {
id: view.id, id: view.id,
@ -694,7 +694,7 @@ export default {
this.$toast.error(e.message).goAway(3000) this.$toast.error(e.message).goAway(3000)
} }
}, },
async genShareLink () { async genShareLink() {
this.showShareModel = true this.showShareModel = true
const sharedViewUrl = await this.$store.dispatch('sqlMgr/ActSqlOp', [ const sharedViewUrl = await this.$store.dispatch('sqlMgr/ActSqlOp', [
{ dbAlias: this.nodes.dbAlias }, { dbAlias: this.nodes.dbAlias },
@ -714,18 +714,18 @@ export default {
]) ])
this.shareLink = sharedViewUrl this.shareLink = sharedViewUrl
}, },
copyView (view, i) { copyView(view, i) {
this.createViewType = view.show_as this.createViewType = view.show_as
this.showCreateView = true this.showCreateView = true
this.copyViewRef = view this.copyViewRef = view
}, },
async onViewCreate (viewMeta) { async onViewCreate(viewMeta) {
this.copyViewRef = null this.copyViewRef = null
await this.loadViews() await this.loadViews()
this.selectedViewIdLocal = viewMeta.id this.selectedViewIdLocal = viewMeta.id
// await this.onViewChange(); // await this.onViewChange();
}, },
clipboard (str) { clipboard(str) {
const el = document.createElement('textarea') const el = document.createElement('textarea')
el.addEventListener('focusin', e => e.stopPropagation()) el.addEventListener('focusin', e => e.stopPropagation())
el.value = str el.value = str
@ -734,10 +734,10 @@ export default {
document.execCommand('copy') document.execCommand('copy')
document.body.removeChild(el) document.body.removeChild(el)
}, },
clipboardSuccessHandler () { clipboardSuccessHandler() {
this.$toast.info('Copied to clipboard').goAway(1000) this.$toast.info('Copied to clipboard').goAway(1000)
}, },
copyShareUrlToClipboard () { copyShareUrlToClipboard() {
this.clipboard(this.shareLink.url) this.clipboard(this.shareLink.url)
this.clipboardSuccessHandler() this.clipboardSuccessHandler()
} }

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save