Skip to content

Commit

Permalink
Merge pull request #445 from ddps-lab/front-demo
Browse files Browse the repository at this point in the history
Using Query Association in Server (GCP)
  • Loading branch information
j-myeong authored Aug 22, 2023
2 parents 5ab46f2 + b262ffd commit 7946b26
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 33 deletions.
6 changes: 3 additions & 3 deletions frontend/build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"files": {
"main.css": "/static/css/main.92131942.css",
"main.js": "/static/js/main.512fbe11.js",
"main.js": "/static/js/main.78fbe3bd.js",
"static/js/787.771a6a4c.chunk.js": "/static/js/787.771a6a4c.chunk.js",
"static/media/logo.svg": "/static/media/logo.6ce24c58023cc2f8fd88fe9d219db6c6.svg",
"index.html": "/index.html",
"main.92131942.css.map": "/static/css/main.92131942.css.map",
"main.512fbe11.js.map": "/static/js/main.512fbe11.js.map",
"main.78fbe3bd.js.map": "/static/js/main.78fbe3bd.js.map",
"787.771a6a4c.chunk.js.map": "/static/js/787.771a6a4c.chunk.js.map"
},
"entrypoints": [
"static/css/main.92131942.css",
"static/js/main.512fbe11.js"
"static/js/main.78fbe3bd.js"
]
}
2 changes: 1 addition & 1 deletion frontend/build/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><title>Spot Lake</title><script defer="defer" src="/static/js/main.512fbe11.js"></script><link href="/static/css/main.92131942.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><title>Spot Lake</title><script defer="defer" src="/static/js/main.78fbe3bd.js"></script><link href="/static/css/main.92131942.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

50 changes: 26 additions & 24 deletions frontend/src/components/QuerySection/Query.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as style from "../../pages/demo/styles";
import { FormControl } from "@mui/material";
import React, { useEffect, useState } from "react";
import axios from "axios";
import gcp_association from "../../pages/demo/gcp_association.json";

const AWS_INSTANCE = {};
const AWS_REGION = {};
Expand All @@ -12,6 +11,9 @@ const AZURE_INSTANCE = {};
const AZURE_REGION = {};
const AZURE_TIER = {};

const GCP_INSTANCE = {};
const GCP_REGION = {};

const Query = ({
vendor,
selectedData,
Expand Down Expand Up @@ -46,24 +48,16 @@ const Query = ({
const filterSort = (V) => {
// V : vendor
if (V === 'AWS') {
setInstance(Object.keys(AWS_INSTANCE));
setRegion(['ALL', ...Object.keys(AWS_REGION)]);
setAZ(['ALL']);
setInstance(Object.keys(AWS_INSTANCE));
setRegion(['ALL', ...Object.keys(AWS_REGION)]);
setAZ(['ALL']);
} else if (V === 'AZURE') {
setInstance(Object.keys(AZURE_INSTANCE));
setRegion(['ALL', ...Object.keys(AZURE_REGION)]);
setAssoTier(['ALL', ...Object.keys(AZURE_TIER)]);
} else {
let list = []
let inst = []
gcp_association.map((e) => {
let key = Object.keys(e)
list = list.concat(key)
inst = inst.length < e[key].length ? e[key] : inst
})
setRegion(['ALL'].concat(list))
setInstance(inst)
setAZ(['ALL'])
} else { // GCP
setInstance(Object.keys(GCP_INSTANCE));
setRegion(['ALL', ...Object.keys(GCP_REGION)]);
}
}
const setFilter = ({ target }) => { //filter value 저장
Expand Down Expand Up @@ -92,7 +86,7 @@ const Query = ({
setAssoTier(['ALL', ...newAssoTier]);
} catch (e) { console.log(e) }
} else { //gcp
setAssoInstance(gcp_association[region.indexOf(value) - 1][value])
setAssoInstance([...GCP_REGION[value].Instance]);
}
} else if (name === 'instance') {
let includeRegion = []
Expand All @@ -103,13 +97,7 @@ const Query = ({
includeRegion = [...AZURE_INSTANCE[value]['Region']];
setAssoTier(['ALL', ...AZURE_INSTANCE[value]['InstanceTier']]);
} else { // gcp
region.map((r) => {
try {
if (r !== 'ALL' && gcp_association[region.indexOf(r) - 1][r].includes(value)) {
includeRegion.push(r)
}
} catch (e) { console.log(e) }
});
includeRegion = [...GCP_INSTANCE[value]];
}
setAssoRegion(['ALL'].concat(includeRegion));
}
Expand Down Expand Up @@ -182,9 +170,10 @@ const Query = ({
}
}

const setFilterData = async () => { // fecth Query Association JSON (now only AWS, AZURE)
const setFilterData = async () => { // fecth Query Association JSON
let assoAWS = await axios.get('https://spotlake.s3.us-west-2.amazonaws.com/query-selector/associated/association_aws.json');
let assoAzure = await axios.get('https://spotlake.s3.us-west-2.amazonaws.com/query-selector/associated/association_azure.json');
let assoGCP = await axios.get('https://spotlake.s3.us-west-2.amazonaws.com/query-selector/associated/association_gcp.json');
if (assoAWS && assoAWS.data) {
assoAWS = assoAWS.data[0];
Object.keys(assoAWS).map((instance) => {
Expand Down Expand Up @@ -225,6 +214,19 @@ const Query = ({
});
});
}
if (assoGCP && assoGCP.data) {
assoGCP = assoGCP.data[0];
assoGCP.map((obj) => {
let region = Object.keys(obj)[0];
GCP_REGION[region] = {
Instance: obj[region],
};
obj[region].map((instance) => {
if (!GCP_INSTANCE[instance]) GCP_INSTANCE[instance] = new Set();
GCP_INSTANCE[instance].add(region);
});
});
}
filterSort(vendor);
}

Expand Down
1 change: 0 additions & 1 deletion frontend/src/pages/demo/gcp_association.json

This file was deleted.

0 comments on commit 7946b26

Please sign in to comment.