mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	ui: allow copying password from notification (#7985)
* ui: allow copying password from notification Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com> * fix warnings, use clipboard lib Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com> * fix for deploy vm Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com> --------- Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
		
							parent
							
								
									1bda2343f3
								
							
						
					
					
						commit
						8939ebbf4e
					
				| @ -517,6 +517,7 @@ | ||||
| "label.copy.clipboard": "Copy to clipboard", | ||||
| "label.copy.consoleurl": "Copy console URL to clipboard", | ||||
| "label.copyid": "Copy ID", | ||||
| "label.copy.password": "Copy password", | ||||
| "label.core": "Core", | ||||
| "label.core.zone.type": "Core zone type", | ||||
| "label.counter": "Counter", | ||||
|  | ||||
| @ -370,7 +370,13 @@ export default { | ||||
|           message: 'message.action.instance.reset.password', | ||||
|           dataView: true, | ||||
|           show: (record) => { return ['Stopped'].includes(record.state) && record.passwordenabled }, | ||||
|           response: (result) => { return result.virtualmachine && result.virtualmachine.password ? `The password of VM <b>${result.virtualmachine.displayname}</b> is <b>${result.virtualmachine.password}</b>` : null } | ||||
|           response: (result) => { | ||||
|             return { | ||||
|               message: result.virtualmachine && result.virtualmachine.password ? `The password of VM <b>${result.virtualmachine.displayname}</b> is <b>${result.virtualmachine.password}</b>` : null, | ||||
|               copybuttontext: result.virtualmachine.password ? 'label.copy.password' : null, | ||||
|               copytext: result.virtualmachine.password ? result.virtualmachine.password : null | ||||
|             } | ||||
|           } | ||||
|         }, | ||||
|         { | ||||
|           api: 'resetSSHKeyForVirtualMachine', | ||||
|  | ||||
| @ -444,7 +444,8 @@ | ||||
| </template> | ||||
| 
 | ||||
| <script> | ||||
| import { ref, reactive, toRaw } from 'vue' | ||||
| import { ref, reactive, toRaw, h } from 'vue' | ||||
| import { Button } from 'ant-design-vue' | ||||
| import { api } from '@/api' | ||||
| import { mixinDevice } from '@/utils/mixin.js' | ||||
| import { genericCompare } from '@/utils/sort.js' | ||||
| @ -1301,13 +1302,30 @@ export default { | ||||
|               eventBus.emit('update-resource-state', { selectedItems: this.selectedItems, resource, state: 'success' }) | ||||
|             } | ||||
|             if (action.response) { | ||||
|               const description = action.response(result.jobresult) | ||||
|               if (description) { | ||||
|                 this.$notification.info({ | ||||
|                   message: this.$t(action.label), | ||||
|                   description: (<span v-html={description}></span>), | ||||
|                   duration: 0 | ||||
|                 }) | ||||
|               const response = action.response(result.jobresult) | ||||
|               if (response) { | ||||
|                 if (typeof response === 'object') { | ||||
|                   this.$notification.info({ | ||||
|                     message: this.$t(action.label), | ||||
|                     description: (<span v-html={response.message}></span>), | ||||
|                     btn: () => h( | ||||
|                       Button, | ||||
|                       { | ||||
|                         type: 'primary', | ||||
|                         size: 'small', | ||||
|                         onClick: () => this.copyToClipboard(response.copytext) | ||||
|                       }, | ||||
|                       () => [this.$t(response.copybuttontext)] | ||||
|                     ), | ||||
|                     duration: 0 | ||||
|                   }) | ||||
|                 } else { | ||||
|                   this.$notification.info({ | ||||
|                     message: this.$t(action.label), | ||||
|                     description: (<span v-html={response}></span>), | ||||
|                     duration: 0 | ||||
|                   }) | ||||
|                 } | ||||
|               } | ||||
|             } | ||||
|             if ('successMethod' in action) { | ||||
| @ -1903,6 +1921,14 @@ export default { | ||||
|       if (screenWidth <= 768) { | ||||
|         this.modalWidth = '450px' | ||||
|       } | ||||
|     }, | ||||
|     copyToClipboard (txt) { | ||||
|       const parent = this | ||||
|       this.$copyText(txt, document.body, function (err) { | ||||
|         if (!err) { | ||||
|           parent.$message.success(parent.$t('label.copied.clipboard')) | ||||
|         } | ||||
|       }) | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -840,7 +840,8 @@ | ||||
| </template> | ||||
| 
 | ||||
| <script> | ||||
| import { ref, reactive, toRaw, nextTick } from 'vue' | ||||
| import { ref, reactive, toRaw, nextTick, h } from 'vue' | ||||
| import { Button } from 'ant-design-vue' | ||||
| import { api } from '@/api' | ||||
| import _ from 'lodash' | ||||
| import { mixin, mixinDevice } from '@/utils/mixin.js' | ||||
| @ -2191,6 +2192,15 @@ export default { | ||||
|                   this.$notification.success({ | ||||
|                     message: password + ` ${this.$t('label.for')} ` + name, | ||||
|                     description: vm.password, | ||||
|                     btn: () => h( | ||||
|                       Button, | ||||
|                       { | ||||
|                         type: 'primary', | ||||
|                         size: 'small', | ||||
|                         onClick: () => this.copyToClipboard(vm.password) | ||||
|                       }, | ||||
|                       () => [this.$t('label.copy.password')] | ||||
|                     ), | ||||
|                     duration: 0 | ||||
|                   }) | ||||
|                 } | ||||
| @ -2690,6 +2700,14 @@ export default { | ||||
|         } | ||||
|       } | ||||
|       return networks | ||||
|     }, | ||||
|     copyToClipboard (txt) { | ||||
|       const parent = this | ||||
|       this.$copyText(txt, document.body, function (err) { | ||||
|         if (!err) { | ||||
|           parent.$message.success(parent.$t('label.copied.clipboard')) | ||||
|         } | ||||
|       }) | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user