Skip to content

Commit

Permalink
feat: fix aws store dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
FacerAin committed Aug 10, 2023
1 parent 8b42372 commit 6455fe0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 25 deletions.
9 changes: 0 additions & 9 deletions src/components/aws/DrawerInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,10 @@ import PublicSubnetDrawer from '@/components/aws/drawer/PublicSubnetDrawer.vue';
import SGDrawer from '@/components/aws/drawer/SGDrawer.vue';
import VPCDrawer from '@/components/aws/drawer/VPCDrawer.vue';
let instance_items = [];
let currentNodeData = reactive({});
const nodeType = ref('');
const props = defineProps(['drawer']);
store.dispatch('aws/getInstanceTypes').then((res) => {
const instance_type = store.state.aws.instance_types;
for (let value of instance_type) {
instance_items.push(value.InstanceType);
}
instance_items.sort();
});
const emit = defineEmits(['handleRightDrawer']);
const closeForm = () => {
Expand Down
9 changes: 1 addition & 8 deletions src/components/aws/drawer/ASGDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,7 @@ const handleClose = () => {
onMounted(() => {
tempNodeData = reactive({ ...props.currentNodeData });
store.dispatch('aws/getInstanceTypes').then((res) => {
const instance_type = store.state.aws.instance_types;
for (let value of instance_type) {
instance_items.push(value.InstanceType);
}
instance_items.sort();
});
store.dispatch('aws/getAMI');
instance_items = store.getters['aws/getInstanceValue'];
});
const handleUpdate = (newTextValue, arg, type) => {
Expand Down
8 changes: 1 addition & 7 deletions src/components/aws/drawer/EC2Drawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@ const handleClose = () => {
onMounted(() => {
tempNodeData = reactive({ ...props.currentNodeData });
store.dispatch('aws/getInstanceTypes').then((res) => {
const instance_type = store.state.aws.instance_types;
for (let value of instance_type) {
instance_items.push(value.InstanceType);
}
instance_items.sort();
});
instance_items = store.getters['aws/getInstanceValue'];
});
const handleUpdate = (newTextValue, arg, type) => {
Expand Down
9 changes: 9 additions & 0 deletions src/components/node/NodePlane.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ const {
nodes: [],
});
onMounted(() => {
if (!store.getters['aws/getInstanceValue']) {
store.dispatch('aws/getInstanceTypes');
}
if (!store.getters['aws/getAMIValue']) {
store.dispatch('aws/getAMI');
}
});
onNodeClick((MouseEvent) => {
nodeClicked();
store.dispatch('node/setSelectedNode', getSelectedNodes.value[0]);
Expand Down
7 changes: 6 additions & 1 deletion src/store/modules/aws.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ const state = () => ({
// 외부에서 가져갈 수 있는 get 부분
const getters = {
getInstanceValue: function (state) {
return state.instance_types;
let instance_items = [];
for (let value of state.instance_types) {
instance_items.push(value.InstanceType);
}
instance_items.sort();
return instance_items;
},
getAMIValue: function (state) {
return state.ami;
Expand Down

0 comments on commit 6455fe0

Please sign in to comment.