1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-09 00:00:01 +01:00

WIP: IC page customization for kubernetes #302

This commit is contained in:
Laura Fuentes Grau 2021-05-28 01:18:25 +02:00
parent 72972db21b
commit 05a8bb749a
2 changed files with 125 additions and 1 deletions

View file

@ -0,0 +1,114 @@
/**
* This file is part of VILLASweb.
*
* VILLASweb is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VILLASweb is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VILLASweb. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
import React from 'react';
import IconButton from "../../common/icon-button";
import {Col, Container, Row, Table} from "react-bootstrap";
import { refresh, ICParamsTable, rawDataTable } from "../ic"
class KubernetesICPage extends React.Component {
constructor(props) {
super(props);
this.state = {
jobLink: "",
podLinks: []
};
}
static getDerivedStateFromProps(props, state){
let jobLink = "";
let podLinks = [];
//should be configurable via the backend
let rancher_url = "rancher.k8s.eonerc.rwth-aachen.de";
let cluster_name = "local";
//! statusupdateraw properties only placeholders, not the right property names
if(typeof props.statusupdateraw !== "undefined" && typeof props.statusupdateraw.namespace !== "undefined"){
let firstPart = "https://" + rancher_url + "/dashboard/c/" + cluster_name + "/explorer";
if(typeof props.statusupdateraw.name !== "undefined"){
jobLink = firstPart + "/batch.job/" + props.statusupdateraw.namespace + "/" + props.statusupdateraw.job_name;
}
if(typeof props.statusupdateraw.pod_names !== []){
props.statusupdateraw.pod_names.map(name => (
podLinks.push(firstPart + "/pod/" + props.statusupdateraw.namespace + "/" + name)
))
}
}
return {
jobLink: jobLink,
podLinks: podLinks
};
}
render() {
return (<div className='section'>
<h1>{this.props.ic.name}
<span className='icon-button'>
<IconButton
childKey={2}
tooltip='Refresh'
onClick={() => this.props.refresh(this.props.ic, this.props.sessionToken)}
icon='sync-alt'
buttonStyle={this.props.buttonStyle}
iconStyle={this.props.iconStyle}
/>
</span>
</h1>
<Container>
<Row>
<Table striped size="sm">
<tbody>
<tr><td>Rancher UI pages:</td></tr>
{this.state.jobLink !== "" ?
<tr><td>Job:</td><td>{this.state.jobLink}</td></tr>
:
<></>}
{this.state.podLinks !== [] && this.state.podLinks.map(link =>
<tr><td>Pod:</td><td>{link}</td></tr>
)
}
</tbody>
</Table>
</Row>
<Row>
<Col>
{ICParamsTable(this.props.ic)}
</Col>
<Col>
<b>Raw Status</b>
{rawDataTable(this.props.ic.statusupdateraw)}
</Col>
</Row>
</Container>
</div>
)
}
}
export default KubernetesICPage;

View file

@ -26,7 +26,8 @@ import ReactJson from 'react-json-view';
import GatewayVillasNode from './ic-pages/gateway-villas-node'
import ManagerVillasRelay from './ic-pages/manager-villas-relay'
import DefaultICPage from './ic-pages/default-page'
import DefaultManagerPage from './ic-pages/default-manager-page';
import DefaultManagerPage from './ic-pages/default-manager-page'
import KubernetesICPage from './ic-pages/kubernetes-page'
class InfrastructureComponent extends React.Component {
constructor(props) {
@ -181,6 +182,15 @@ class InfrastructureComponent extends React.Component {
buttonStyle = {buttonStyle}
iconStyle = {iconStyle}
/>
} else if (this.state.ic.category === "simulator" && this.state.ic.type === "kubernetes") {
page = <KubernetesICPage
ic={this.state.ic}
ics={this.state.ics}
currentUser={this.state.currentUser}
sessionToken={this.state.sessionToken}
buttonStyle={buttonStyle}
iconStyle={iconStyle}
/>
}else {
page = <DefaultICPage
ic = {this.state.ic}