mirror of
				https://github.com/Fabio286/antares.git
				synced 2025-06-05 21:59:22 +02:00 
			
		
		
		
	Additions, again
This commit is contained in:
		| @@ -60,4 +60,15 @@ export default () => { | |||||||
|       connections[uid].destroy(); |       connections[uid].destroy(); | ||||||
|       delete connections[uid]; |       delete connections[uid]; | ||||||
|    }); |    }); | ||||||
|  |  | ||||||
|  |    ipcMain.handle('refresh', async (event, uid) => { | ||||||
|  |       try { | ||||||
|  |          structure = await InformationSchema.getStructure(connection); | ||||||
|  |       } | ||||||
|  |       catch (err) { | ||||||
|  |          return { status: 'error', response: err.toString() }; | ||||||
|  |       } | ||||||
|  |  | ||||||
|  |       return { status: 'success', response: structure }; | ||||||
|  |    }); | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -22,7 +22,6 @@ | |||||||
|  |  | ||||||
| <script> | <script> | ||||||
| import { mapActions } from 'vuex'; | import { mapActions } from 'vuex'; | ||||||
| import Connection from '@/ipc-api/Connection'; |  | ||||||
|  |  | ||||||
| export default { | export default { | ||||||
|    name: 'DatabaseConnectPanel', |    name: 'DatabaseConnectPanel', | ||||||
| @@ -37,20 +36,11 @@ export default { | |||||||
|    methods: { |    methods: { | ||||||
|       ...mapActions({ |       ...mapActions({ | ||||||
|          addNotification: 'notifications/addNotification', |          addNotification: 'notifications/addNotification', | ||||||
|          addConnected: 'workspaces/addConnected' |          connectWorkspace: 'workspaces/connectWorkspace' | ||||||
|       }), |       }), | ||||||
|       async startConnection () { |       async startConnection () { | ||||||
|          this.isConnecting = true; |          this.isConnecting = true; | ||||||
|          try { |          await this.connectWorkspace(this.connection); | ||||||
|             const { status, response } = await Connection.connect(this.connection); |  | ||||||
|             if (status === 'error') |  | ||||||
|                this.addNotification({ status, message: response }); |  | ||||||
|             else |  | ||||||
|                this.addConnected(this.connection.uid); |  | ||||||
|          } |  | ||||||
|          catch (err) { |  | ||||||
|             this.addNotification({ status: 'error', message: err.stack }); |  | ||||||
|          } |  | ||||||
|          this.isConnecting = false; |          this.isConnecting = false; | ||||||
|       } |       } | ||||||
|    } |    } | ||||||
|   | |||||||
| @@ -20,11 +20,6 @@ export default { | |||||||
|    props: { |    props: { | ||||||
|       connection: Object |       connection: Object | ||||||
|    }, |    }, | ||||||
|    data () { |  | ||||||
|       return { |  | ||||||
|          structure: null |  | ||||||
|       }; |  | ||||||
|    }, |  | ||||||
|    computed: { |    computed: { | ||||||
|       ...mapGetters({ |       ...mapGetters({ | ||||||
|          selectedWorkspace: 'workspaces/getSelected', |          selectedWorkspace: 'workspaces/getSelected', | ||||||
| @@ -34,26 +29,14 @@ export default { | |||||||
|    async created () { |    async created () { | ||||||
|       this.addWorkspace(this.connection.uid); |       this.addWorkspace(this.connection.uid); | ||||||
|       const isInitiated = await Connection.checkConnection(this.connection.uid); |       const isInitiated = await Connection.checkConnection(this.connection.uid); | ||||||
|       if (isInitiated) { |       if (isInitiated) | ||||||
|          try { |          this.connectWorkspace(this.connection); | ||||||
|             const { status, response } = await Connection.connect(this.connection); |  | ||||||
|             if (status === 'success') { |  | ||||||
|                this.structure = response; |  | ||||||
|                this.addConnected(this.connection.uid); |  | ||||||
|             } |  | ||||||
|             else |  | ||||||
|                this.addNotification({ status, message: response }); |  | ||||||
|          } |  | ||||||
|          catch (err) { |  | ||||||
|             this.addNotification({ status: 'error', message: err.toString() }); |  | ||||||
|          } |  | ||||||
|       } |  | ||||||
|    }, |    }, | ||||||
|    methods: { |    methods: { | ||||||
|       ...mapActions({ |       ...mapActions({ | ||||||
|          addNotification: 'notifications/addNotification', |          addNotification: 'notifications/addNotification', | ||||||
|          addWorkspace: 'workspaces/addWorkspace', |          addWorkspace: 'workspaces/addWorkspace', | ||||||
|          addConnected: 'workspaces/addConnected', |          connectWorkspace: 'workspaces/connectWorkspace', | ||||||
|          removeConnected: 'workspaces/removeConnected' |          removeConnected: 'workspaces/removeConnected' | ||||||
|       }) |       }) | ||||||
|    } |    } | ||||||
|   | |||||||
| @@ -18,6 +18,7 @@ export default class { | |||||||
|       return ipcRenderer.invoke('disconnect', uid); |       return ipcRenderer.invoke('disconnect', uid); | ||||||
|    } |    } | ||||||
|  |  | ||||||
|    // TODO: refresh |    static refresh (uid) { | ||||||
|    // TODO: disconnect |       return ipcRenderer.invoke('refresh', uid); | ||||||
|  |    } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ export default { | |||||||
|    strict: true, |    strict: true, | ||||||
|    state: { |    state: { | ||||||
|       workspaces: [], |       workspaces: [], | ||||||
|       connected_workspaces: [], |       connected_workspaces: [], // TODO: move to state.workspaces | ||||||
|       selected_workspace: null |       selected_workspace: null | ||||||
|    }, |    }, | ||||||
|    getters: { |    getters: { | ||||||
| @@ -22,11 +22,13 @@ export default { | |||||||
|       SELECT_WORKSPACE (state, uid) { |       SELECT_WORKSPACE (state, uid) { | ||||||
|          state.selected_workspace = uid; |          state.selected_workspace = uid; | ||||||
|       }, |       }, | ||||||
|       ADD_CONNECTED (state, uid) { |       ADD_CONNECTED (state, { uid, structure }) { | ||||||
|          state.connected_workspaces.push(uid); |          state.connected_workspaces.push(uid); | ||||||
|  |          state.workspaces = state.workspaces.map(workspace => workspace.uid === uid ? { ...workspace, structure } : workspace); | ||||||
|       }, |       }, | ||||||
|       REMOVE_CONNECTED (state, uid) { |       REMOVE_CONNECTED (state, uid) { | ||||||
|          state.connected_workspaces = state.connected_workspaces.filter(value => value !== uid); |          state.connected_workspaces = state.connected_workspaces.filter(value => value !== uid); | ||||||
|  |          state.workspaces = state.workspaces.map(workspace => workspace.uid === uid ? { ...workspace, structure: {} } : workspace); | ||||||
|       }, |       }, | ||||||
|       ADD_WORKSPACE (state, workspace) { |       ADD_WORKSPACE (state, workspace) { | ||||||
|          state.workspaces.push(workspace); |          state.workspaces.push(workspace); | ||||||
| @@ -36,8 +38,17 @@ export default { | |||||||
|       selectWorkspace ({ commit }, uid) { |       selectWorkspace ({ commit }, uid) { | ||||||
|          commit('SELECT_WORKSPACE', uid); |          commit('SELECT_WORKSPACE', uid); | ||||||
|       }, |       }, | ||||||
|       addConnected ({ commit }, uid) { |       async connectWorkspace ({ dispatch, commit }, connection) { | ||||||
|          commit('ADD_CONNECTED', uid); |          try { | ||||||
|  |             const { status, response } = await Connection.connect(connection); | ||||||
|  |             if (status === 'error') | ||||||
|  |                dispatch('notifications/addNotification', { status, message: response }, { root: true }); | ||||||
|  |             else | ||||||
|  |                commit('ADD_CONNECTED', { uid: connection.uid, structure: response }); | ||||||
|  |          } | ||||||
|  |          catch (err) { | ||||||
|  |             dispatch('notifications/addNotification', { status: 'error', message: err.stack }, { root: true }); | ||||||
|  |          } | ||||||
|       }, |       }, | ||||||
|       async removeConnected ({ commit }, uid) { |       async removeConnected ({ commit }, uid) { | ||||||
|          Connection.disconnect(uid); |          Connection.disconnect(uid); | ||||||
| @@ -46,7 +57,9 @@ export default { | |||||||
|       addWorkspace ({ commit }, uid) { |       addWorkspace ({ commit }, uid) { | ||||||
|          const workspace = { |          const workspace = { | ||||||
|             uid, |             uid, | ||||||
|             tabs: [] |             connected: false, | ||||||
|  |             tabs: [], | ||||||
|  |             structure: {} | ||||||
|          }; |          }; | ||||||
|          commit('ADD_WORKSPACE', workspace); |          commit('ADD_WORKSPACE', workspace); | ||||||
|       } |       } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user