mirror of
				https://github.com/Fabio286/antares.git
				synced 2025-06-05 21:59:22 +02:00 
			
		
		
		
	feat(UI): database version in app footer
This commit is contained in:
		| @@ -94,6 +94,17 @@ export default connections => { | |||||||
|       } |       } | ||||||
|    }); |    }); | ||||||
|  |  | ||||||
|  |    ipcMain.handle('get-version', async (event, uid) => { | ||||||
|  |       try { | ||||||
|  |          const result = await connections[uid].getVersion(); | ||||||
|  |  | ||||||
|  |          return { status: 'success', response: result }; | ||||||
|  |       } | ||||||
|  |       catch (err) { | ||||||
|  |          return { status: 'error', response: err.toString() }; | ||||||
|  |       } | ||||||
|  |    }); | ||||||
|  |  | ||||||
|    ipcMain.handle('use-schema', async (event, { uid, schema }) => { |    ipcMain.handle('use-schema', async (event, { uid, schema }) => { | ||||||
|       if (!schema) return; |       if (!schema) return; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -920,6 +920,35 @@ export class MySQLClient extends AntaresCore { | |||||||
|       }); |       }); | ||||||
|    } |    } | ||||||
|  |  | ||||||
|  |    /** | ||||||
|  |     * SHOW VARIABLES LIKE '%vers%' | ||||||
|  |     * | ||||||
|  |     * @returns {Array.<Object>} version parameters | ||||||
|  |     * @memberof MySQLClient | ||||||
|  |     */ | ||||||
|  |    async getVersion () { | ||||||
|  |       const sql = 'SHOW VARIABLES LIKE "%vers%"'; | ||||||
|  |       const { rows } = await this.raw(sql); | ||||||
|  |  | ||||||
|  |       return rows.reduce((acc, curr) => { | ||||||
|  |          switch (curr.Variable_name) { | ||||||
|  |             case 'version': | ||||||
|  |                acc.number = curr.Value.split('-')[0]; | ||||||
|  |                break; | ||||||
|  |             case 'version_comment': | ||||||
|  |                acc.name = curr.Value.replace('(GPL)', ''); | ||||||
|  |                break; | ||||||
|  |             case 'version_compile_machine': | ||||||
|  |                acc.arch = curr.Value; | ||||||
|  |                break; | ||||||
|  |             case 'version_compile_os': | ||||||
|  |                acc.os = curr.Value; | ||||||
|  |                break; | ||||||
|  |          } | ||||||
|  |          return acc; | ||||||
|  |       }, {}); | ||||||
|  |    } | ||||||
|  |  | ||||||
|    /** |    /** | ||||||
|     * CREATE TABLE |     * CREATE TABLE | ||||||
|     * |     * | ||||||
| @@ -1231,7 +1260,7 @@ export class MySQLClient extends AntaresCore { | |||||||
|                               const response = await this.getTableColumns(paramObj); |                               const response = await this.getTableColumns(paramObj); | ||||||
|                               remappedFields = remappedFields.map(field => { |                               remappedFields = remappedFields.map(field => { | ||||||
|                                  const detailedField = response.find(f => f.name === field.name); |                                  const detailedField = response.find(f => f.name === field.name); | ||||||
|                                  if (field.orgTable === paramObj.table && field.schema === paramObj.schema && detailedField.name === field.orgName) |                                  if (detailedField && field.orgTable === paramObj.table && field.schema === paramObj.schema && detailedField.name === field.orgName) | ||||||
|                                     field = { ...detailedField, ...field }; |                                     field = { ...detailedField, ...field }; | ||||||
|                                  return field; |                                  return field; | ||||||
|                               }); |                               }); | ||||||
|   | |||||||
| @@ -2,9 +2,9 @@ | |||||||
|    <div id="footer" class="text-light"> |    <div id="footer" class="text-light"> | ||||||
|       <div class="footer-left-elements"> |       <div class="footer-left-elements"> | ||||||
|          <ul class="footer-elements"> |          <ul class="footer-elements"> | ||||||
|             <li class="footer-element" :title="$t('word.version')"> |             <li class="footer-element"> | ||||||
|                <i class="mdi mdi-18px mdi-memory mr-1" /> |                <i class="mdi mdi-18px mdi-database mr-1" /> | ||||||
|                <small>{{ appVersion }}</small> |                <small>{{ versionString }}</small> | ||||||
|             </li> |             </li> | ||||||
|          </ul> |          </ul> | ||||||
|       </div> |       </div> | ||||||
| @@ -34,9 +34,18 @@ export default { | |||||||
|    name: 'TheFooter', |    name: 'TheFooter', | ||||||
|    computed: { |    computed: { | ||||||
|       ...mapGetters({ |       ...mapGetters({ | ||||||
|          appName: 'application/appName', |          workspace: 'workspaces/getSelected', | ||||||
|  |          getWorkspace: 'workspaces/getWorkspace', | ||||||
|          appVersion: 'application/appVersion' |          appVersion: 'application/appVersion' | ||||||
|       }) |       }), | ||||||
|  |       version () { | ||||||
|  |          return this.getWorkspace(this.workspace) ? this.getWorkspace(this.workspace).version : null; | ||||||
|  |       }, | ||||||
|  |       versionString () { | ||||||
|  |          if (this.version) | ||||||
|  |             return `${this.version.name} ${this.version.number} (${this.version.arch} ${this.version.os})`; | ||||||
|  |          return ''; | ||||||
|  |       } | ||||||
|    }, |    }, | ||||||
|    methods: { |    methods: { | ||||||
|       ...mapActions({ |       ...mapActions({ | ||||||
|   | |||||||
| @@ -34,6 +34,10 @@ export default class { | |||||||
|       return ipcRenderer.invoke('get-engines', uid); |       return ipcRenderer.invoke('get-engines', uid); | ||||||
|    } |    } | ||||||
|  |  | ||||||
|  |    static getVersion (uid) { | ||||||
|  |       return ipcRenderer.invoke('get-version', uid); | ||||||
|  |    } | ||||||
|  |  | ||||||
|    static useSchema (params) { |    static useSchema (params) { | ||||||
|       return ipcRenderer.invoke('use-schema', params); |       return ipcRenderer.invoke('use-schema', params); | ||||||
|    } |    } | ||||||
|   | |||||||
| @@ -51,7 +51,7 @@ export default { | |||||||
|       SELECT_WORKSPACE (state, uid) { |       SELECT_WORKSPACE (state, uid) { | ||||||
|          state.selected_workspace = uid; |          state.selected_workspace = uid; | ||||||
|       }, |       }, | ||||||
|       ADD_CONNECTED (state, { uid, client, dataTypes, indexTypes, structure }) { |       ADD_CONNECTED (state, { uid, client, dataTypes, indexTypes, structure, version }) { | ||||||
|          state.workspaces = state.workspaces.map(workspace => workspace.uid === uid |          state.workspaces = state.workspaces.map(workspace => workspace.uid === uid | ||||||
|             ? { |             ? { | ||||||
|                ...workspace, |                ...workspace, | ||||||
| @@ -59,7 +59,8 @@ export default { | |||||||
|                dataTypes, |                dataTypes, | ||||||
|                indexTypes, |                indexTypes, | ||||||
|                structure, |                structure, | ||||||
|                connected: true |                connected: true, | ||||||
|  |                version | ||||||
|             } |             } | ||||||
|             : workspace); |             : workspace); | ||||||
|       }, |       }, | ||||||
| @@ -245,12 +246,22 @@ export default { | |||||||
|                      indexTypes = require('common/index-types/mysql'); |                      indexTypes = require('common/index-types/mysql'); | ||||||
|                      break; |                      break; | ||||||
|                } |                } | ||||||
|  |  | ||||||
|  |                const { status, response: version } = await Database.getVersion(connection.uid); | ||||||
|  |  | ||||||
|  |                if (status === 'error') | ||||||
|  |                   dispatch('notifications/addNotification', { status, message: version }, { root: true }); | ||||||
|  |                else { | ||||||
|  |                   // | ||||||
|  |                } | ||||||
|  |  | ||||||
|                commit('ADD_CONNECTED', { |                commit('ADD_CONNECTED', { | ||||||
|                   uid: connection.uid, |                   uid: connection.uid, | ||||||
|                   client: connection.client, |                   client: connection.client, | ||||||
|                   dataTypes, |                   dataTypes, | ||||||
|                   indexTypes, |                   indexTypes, | ||||||
|                   structure: response |                   structure: response, | ||||||
|  |                   version | ||||||
|                }); |                }); | ||||||
|                dispatch('refreshCollations', connection.uid); |                dispatch('refreshCollations', connection.uid); | ||||||
|                dispatch('refreshVariables', connection.uid); |                dispatch('refreshVariables', connection.uid); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user