Skip to content

Commit

Permalink
fix: fixed the log and file artifact issue (#890)
Browse files Browse the repository at this point in the history
This fixes: 

1. user can now see file artifacts 
2. user can switch between logs for each service.
  • Loading branch information
Peeeekay committed Jul 17, 2023
1 parent 5b9d067 commit 7f7fe7b
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 28 deletions.
69 changes: 49 additions & 20 deletions engine/frontend/src/api/container.js
Expand Up @@ -16,30 +16,59 @@ export const runStarlarkPackage = async (url, packageId) => {
return stream;
}

const getDataFromApiContainer = async (request, process) => {
const data = await request()
return process(data)
}

export const getEnclaveInformation = async (url) => {
const containerClient = new ApiContainerServicePromiseClient(url);
const serviceArgs = new GetServicesArgs();
const responseFromGrpc = await containerClient.getServices(serviceArgs, null)
const response = responseFromGrpc.toObject();
const services = response.serviceInfoMap.map(service => {
const ports = service[1].maybePublicPortsMap.map((publicPort, index) => {
const privatePort = service[1].privatePortsMap[index];

const makeGetServiceRequest = async () => {
const serviceArgs = new GetServicesArgs();
const responseFromGrpc = await containerClient.getServices(serviceArgs, null)
return responseFromGrpc.toObject()
}

const makeFileArtifactRequest = async () => {
const fileArtifactResponse = await containerClient.listFilesArtifactNamesAndUuids(new google_protobuf_empty_pb.Empty, null)
return fileArtifactResponse.toObject();
}

const processServiceRequest = (data) => {
return data.serviceInfoMap.map(service => {
const ports = service[1].maybePublicPortsMap.map((publicPort, index) => {
const privatePort = service[1].privatePortsMap[index];
return {
publicPortNumber:publicPort[1].number,
privatePortNumber: privatePort[1].number,
applicationProtocol: privatePort[1].maybeApplicationProtocol,
portName: privatePort[0],
transportProtocol: TransportProtocolEnum[privatePort[1].transportProtocol]
}
})

return {
publicPortNumber:publicPort[1].number,
privatePortNumber: privatePort[1].number,
applicationProtocol: privatePort[1].maybeApplicationProtocol,
portName: privatePort[0],
transportProtocol: TransportProtocolEnum[privatePort[1].transportProtocol]
name: service[0],
uuid: service[1].serviceUuid,
privateIpAddr: service[1].privateIpAddr,
ports: ports,
}
})
}

const processFileArtifactRequest = (data) => {
return data.fileNamesAndUuidsList.map(artifact => {
return {
name: artifact.filename,
uuid: artifact.fileuuid,
}
})
}

return {
name: service[0],
uuid: service[1].serviceUuid,
privateIpAddr: service[1].privateIpAddr,
ports: ports,
}
})
const servicesPromise = getDataFromApiContainer(makeGetServiceRequest, processServiceRequest)
const fileArtifactsPromise = getDataFromApiContainer(makeFileArtifactRequest, processFileArtifactRequest)

return services;
}
const [services, artifacts] = await Promise.all([servicesPromise, fileArtifactsPromise])
return { services, artifacts}
}
3 changes: 1 addition & 2 deletions engine/frontend/src/api/enclave.js
Expand Up @@ -58,7 +58,6 @@ export const createEnclave = async () => {
}

export const runStarlark = async(apiClient, packageId) => {
console.log(apiClient, packageId)
const stream = await runStarlarkPackage(apiClient, packageId)
return stream;
}
}
2 changes: 1 addition & 1 deletion engine/frontend/src/components/CreateEnclaveView.js
Expand Up @@ -15,7 +15,7 @@ export const CreateEnclaveView = ({packageId, enclaveInfo}) => {
const [services, setServices] = useState([])

const getServices = async (apiClient) => {
const services = await getEnclaveInformation(apiClient);
const {services} = await getEnclaveInformation(apiClient);
setServices(services)
}

Expand Down
3 changes: 3 additions & 0 deletions engine/frontend/src/components/ServiceInfo.js
Expand Up @@ -26,6 +26,9 @@ const ServiceInfo = () => {
return () => {
if (stream) {
stream.cancel();
// need to do this - this means that we are getting logs from
// different service
setLogs([])
};
};
}, [serviceUuid])
Expand Down
3 changes: 2 additions & 1 deletion engine/frontend/src/components/Services.js
Expand Up @@ -83,8 +83,9 @@ const Services = () => {
//const response = await axios.get(`http://localhost:5050/enclaves/${name}/services`)
//setFileArtifacts(response.data.body.fileArtifacts)
const selected = enclaves.filter(enclave => enclave.name === name);
const services = await getEnclaveInformation(selected[0].apiClient);
const {services, artifacts} = await getEnclaveInformation(selected[0].apiClient);
setServices(services)
setFileArtifacts(artifacts)
}
fetch()
}, [name])
Expand Down
6 changes: 3 additions & 3 deletions engine/server/webapp/asset-manifest.json
@@ -1,13 +1,13 @@
{
"files": {
"main.css": "/static/css/main.7b6afa70.css",
"main.js": "/static/js/main.caf7863c.js",
"main.js": "/static/js/main.2f3b687c.js",
"index.html": "/index.html",
"main.7b6afa70.css.map": "/static/css/main.7b6afa70.css.map",
"main.caf7863c.js.map": "/static/js/main.caf7863c.js.map"
"main.2f3b687c.js.map": "/static/js/main.2f3b687c.js.map"
},
"entrypoints": [
"static/css/main.7b6afa70.css",
"static/js/main.caf7863c.js"
"static/js/main.2f3b687c.js"
]
}
2 changes: 1 addition & 1 deletion engine/server/webapp/index.html
@@ -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"/><title>Kurtosis Frontend</title><script defer="defer" src="/static/js/main.caf7863c.js"></script><link href="/static/css/main.7b6afa70.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"/><title>Kurtosis Frontend</title><script defer="defer" src="/static/js/main.2f3b687c.js"></script><link href="/static/css/main.7b6afa70.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
3 changes: 3 additions & 0 deletions engine/server/webapp/static/js/main.2f3b687c.js

Large diffs are not rendered by default.

63 changes: 63 additions & 0 deletions engine/server/webapp/static/js/main.2f3b687c.js.LICENSE.txt
@@ -0,0 +1,63 @@
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */

/**
* @license React
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @remix-run/router v1.7.1
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/

/**
* React Router v6.14.1
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
1 change: 1 addition & 0 deletions engine/server/webapp/static/js/main.2f3b687c.js.map

Large diffs are not rendered by default.

0 comments on commit 7f7fe7b

Please sign in to comment.