mirror of
				https://github.com/Fabio286/antares.git
				synced 2025-06-05 21:59:22 +02:00 
			
		
		
		
	perf: improved refresh of data tables
This commit is contained in:
		| @@ -3,7 +3,7 @@ | |||||||
|       <summary |       <summary | ||||||
|          class="accordion-header database-name pb-0" |          class="accordion-header database-name pb-0" | ||||||
|          :class="{'text-bold': breadcrumbs.schema === database.name}" |          :class="{'text-bold': breadcrumbs.schema === database.name}" | ||||||
|          @click="changeBreadcrumbs({schema: database.name, table:null})" |          @click="changeBreadcrumbs({schema: database.name, table: null})" | ||||||
|          @contextmenu.prevent="showDatabaseContext($event, database.name)" |          @contextmenu.prevent="showDatabaseContext($event, database.name)" | ||||||
|       > |       > | ||||||
|          <i class="icon mdi mdi-18px mdi-chevron-right" /> |          <i class="icon mdi mdi-18px mdi-chevron-right" /> | ||||||
| @@ -22,7 +22,7 @@ | |||||||
|                   @contextmenu.prevent="showTableContext($event, table.TABLE_NAME)" |                   @contextmenu.prevent="showTableContext($event, table.TABLE_NAME)" | ||||||
|                > |                > | ||||||
|                   <a class="table-name"> |                   <a class="table-name"> | ||||||
|                      <i class="table-icon mdi mdi-18px mdi-table mr-1" /> |                      <i class="table-icon mdi mdi-18px mr-1" :class="table.TABLE_TYPE === 'VIEW' ? 'mdi-table-eye' : 'mdi-table'" /> | ||||||
|                      <span>{{ table.TABLE_NAME }}</span> |                      <span>{{ table.TABLE_NAME }}</span> | ||||||
|                   </a> |                   </a> | ||||||
|                </li> |                </li> | ||||||
|   | |||||||
| @@ -4,7 +4,7 @@ | |||||||
|          <div class="workspace-query-runner-footer"> |          <div class="workspace-query-runner-footer"> | ||||||
|             <div class="workspace-query-buttons"> |             <div class="workspace-query-buttons"> | ||||||
|                <button |                <button | ||||||
|                   class="btn btn-link btn-sm" |                   class="btn btn-link btn-sm mr-0 pr-0" | ||||||
|                   :class="{'loading':isQuering}" |                   :class="{'loading':isQuering}" | ||||||
|                   title="F5" |                   title="F5" | ||||||
|                   @click="reloadTable" |                   @click="reloadTable" | ||||||
| @@ -14,7 +14,6 @@ | |||||||
|                </button> |                </button> | ||||||
|                <button |                <button | ||||||
|                   class="btn btn-link btn-sm" |                   class="btn btn-link btn-sm" | ||||||
|                   :class="{'disabled':isQuering}" |  | ||||||
|                   @click="showAddModal" |                   @click="showAddModal" | ||||||
|                > |                > | ||||||
|                   <span>{{ $t('word.add') }}</span> |                   <span>{{ $t('word.add') }}</span> | ||||||
| @@ -34,7 +33,6 @@ | |||||||
|       <div class="workspace-query-results column col-12"> |       <div class="workspace-query-results column col-12"> | ||||||
|          <WorkspaceQueryTable |          <WorkspaceQueryTable | ||||||
|             v-if="results" |             v-if="results" | ||||||
|             v-show="!isQuering" |  | ||||||
|             ref="queryTable" |             ref="queryTable" | ||||||
|             :results="results" |             :results="results" | ||||||
|             :tab-uid="tabUid" |             :tab-uid="tabUid" | ||||||
| @@ -123,10 +121,14 @@ export default { | |||||||
|       async getTableData () { |       async getTableData () { | ||||||
|          if (!this.table) return; |          if (!this.table) return; | ||||||
|          this.isQuering = true; |          this.isQuering = true; | ||||||
|          this.results = []; |  | ||||||
|          const fieldsArr = []; |          const fieldsArr = []; | ||||||
|          const keysArr = []; |          const keysArr = []; | ||||||
|  |  | ||||||
|  |          // if table changes clear cached values | ||||||
|  |          if (this.lastTable !== this.table) { | ||||||
|  |             this.results = []; | ||||||
|             this.setTabFields({ cUid: this.connection.uid, tUid: this.tabUid, fields: [] }); |             this.setTabFields({ cUid: this.connection.uid, tUid: this.tabUid, fields: [] }); | ||||||
|  |          } | ||||||
|  |  | ||||||
|          const params = { |          const params = { | ||||||
|             uid: this.connection.uid, |             uid: this.connection.uid, | ||||||
| @@ -147,18 +149,6 @@ export default { | |||||||
|             this.addNotification({ status: 'error', message: err.stack }); |             this.addNotification({ status: 'error', message: err.stack }); | ||||||
|          } |          } | ||||||
|  |  | ||||||
|          try { // Table data |  | ||||||
|             const { status, response } = await Tables.getTableData(params); |  | ||||||
|  |  | ||||||
|             if (status === 'success') |  | ||||||
|                this.results = [response]; |  | ||||||
|             else |  | ||||||
|                this.addNotification({ status: 'error', message: response }); |  | ||||||
|          } |  | ||||||
|          catch (err) { |  | ||||||
|             this.addNotification({ status: 'error', message: err.stack }); |  | ||||||
|          } |  | ||||||
|  |  | ||||||
|          try { // Key usage (foreign keys) |          try { // Key usage (foreign keys) | ||||||
|             const { status, response } = await Tables.getKeyUsage(params); |             const { status, response } = await Tables.getKeyUsage(params); | ||||||
|  |  | ||||||
| @@ -173,15 +163,28 @@ export default { | |||||||
|             this.addNotification({ status: 'error', message: err.stack }); |             this.addNotification({ status: 'error', message: err.stack }); | ||||||
|          } |          } | ||||||
|  |  | ||||||
|  |          try { // Table data | ||||||
|  |             const { status, response } = await Tables.getTableData(params); | ||||||
|  |  | ||||||
|  |             if (status === 'success') | ||||||
|  |                this.results = [response]; | ||||||
|  |             else | ||||||
|  |                this.addNotification({ status: 'error', message: response }); | ||||||
|  |          } | ||||||
|  |          catch (err) { | ||||||
|  |             this.addNotification({ status: 'error', message: err.stack }); | ||||||
|  |          } | ||||||
|  |  | ||||||
|          this.setTabFields({ cUid: this.connection.uid, tUid: this.tabUid, fields: fieldsArr }); |          this.setTabFields({ cUid: this.connection.uid, tUid: this.tabUid, fields: fieldsArr }); | ||||||
|          this.setTabKeyUsage({ cUid: this.connection.uid, tUid: this.tabUid, keyUsage: keysArr }); |          this.setTabKeyUsage({ cUid: this.connection.uid, tUid: this.tabUid, keyUsage: keysArr }); | ||||||
|  |  | ||||||
|          this.isQuering = false; |          this.isQuering = false; | ||||||
|       }, |       }, | ||||||
|       getTable () { |       getTable () { | ||||||
|          return this.table; |          return this.table; | ||||||
|       }, |       }, | ||||||
|       reloadTable () { |       reloadTable () { | ||||||
|          if (!this.isQuering) this.getTableData(); |          this.getTableData(); | ||||||
|       }, |       }, | ||||||
|       showAddModal () { |       showAddModal () { | ||||||
|          this.isAddModal = true; |          this.isAddModal = true; | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| .column-key { | .column-key { | ||||||
|   transform: rotate(90deg); |   transform: rotate(45deg); | ||||||
|   font-size: 0.7rem; |   font-size: 0.7rem; | ||||||
|   line-height: 1.5; |   line-height: 1.5; | ||||||
|   margin-right: 0.2rem; |   margin-right: 0.2rem; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user