Skip to content

Commit

Permalink
Mockup/site page (#247)
Browse files Browse the repository at this point in the history
* #238: added mock up page for site details

* #244: updated the yellow tera core ring

* #244: added site HAWI and connections

* #244: updated site name mapping

* #233: updated map and detail table to show Maintenance node

* #233: completed site maintenance info display on resources page and site detail page

* #233: added site detail page link to Slice Builder

* #233: updated portal release number

* #233: updated link to resources page on Slice Builder with site param

* #244: updated international links
  • Loading branch information
yaxue1123 authored Feb 22, 2023
1 parent dd60fcc commit 966cfee
Show file tree
Hide file tree
Showing 21 changed files with 438 additions and 82 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fabric-portal",
"version": "1.4.3",
"version": "1.4.4",
"private": true,
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.32",
Expand Down
2 changes: 2 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import SliceViewer from "./pages/SliceViewer";
import NewSliceForm from "./pages/NewSliceForm";
import User from "./pages/User";
import PublicUserProfile from "./components/UserProfile/PublicUserProfile.jsx";
import SiteDetailPage from "./components/Resource/SiteDetailPage.jsx";
import NotFound from "./pages/NotFound";
import Help from "./pages/Help";
import Header from "./components/Header";
Expand Down Expand Up @@ -123,6 +124,7 @@ class App extends React.Component {
<Route path="/login" component={Home} />
<Route path="/logout" component={Home} />
<Route path="/aup" component={AUP} />
<Route path="/sites/:id" component={SiteDetailPage} />
<Route path="/cookie-policy" component={CookiePolicy} />
<Route path="/privacy-policy" component={PrivacyPolicy} />
<Route path="/signup/:id" component={Signup} />
Expand Down
4 changes: 2 additions & 2 deletions src/components/Experiment/Slices.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class Slices extends React.Component {
</div>
<div className="alert alert-warning mt-3" role="alert">
<p className="mt-2">
You have no slice in this project. Please create slices in Portal or&nbsp;
You have no slices in this project. Please create slices in Portal or&nbsp;
<a
href={this.jupyterLinkMap[checkPortalType(window.location.href)]}
target="_blank"
Expand All @@ -210,7 +210,7 @@ class Slices extends React.Component {
</div> :
<div className="alert alert-warning mt-3" role="alert">
<p className="mt-2">
We couldn't find your slice. Please create slices in Portal or &nbsp;
We couldn't find your slices. Please create slices in Portal or &nbsp;
<a
href={this.jupyterLinkMap[checkPortalType(window.location.href)]}
target="_blank"
Expand Down
88 changes: 80 additions & 8 deletions src/components/Resource/DetailTable.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import ProgressBar from '../common/ProgressBar';
import { sitesNameMapping } from "../../data/sites";
import { Link } from "react-router-dom";

const generateProgressBar = (total, free) => {
const generateProgressBar = (total, free, color, labelColor) => {
return (
<ProgressBar
now={total > 0 ? Math.round(free * 100/ total) : 0}
label={`${free}/${total}`}
color={color}
labelColor={labelColor}
/>
)
}

const DetailTable = props => {
const {name, resource} = props;
const {name, resource, parent} = props;
const rows = [
["Cores", "totalCore", "freeCore"],
["Disk (GB)", "totalDisk", "freeDisk"],
Expand All @@ -22,13 +25,69 @@ const DetailTable = props => {
["SharedNIC", "totalSharedNIC", "freeSharedNIC"],
["FPGA", "totalFPGA", "freeFPGA"],
]

const statusMapping = {
"Maint": {
state: "Maintenance",
colorName: "danger",
colorHex: "#b00020",
labelColorHex: "#fff"
},
"PreMaint": {
state: "Pre-Maintenance",
colorName: "info",
colorHex: "#ffb670",
labelColorHex: "#212529"
},
"Active": {
state: "Active",
colorName: "primary",
colorHex: "#68b3d1",
labelColorHex: "#212529"
}
}

return (
<div>
<table className="table">
<thead>
<tr>
<th scope="col" colSpan="2" className="text-center">
{`${sitesNameMapping.shortNameToAcronym[name]} (${sitesNameMapping.shortToLongName[name]})`}
{
!resource && parent !== "sitepage" &&
`${sitesNameMapping.shortNameToAcronym[name]} (${sitesNameMapping.shortToLongName[name]})`
}
{
!resource && parent === "sitepage" &&
`${sitesNameMapping.acronymToShortName[name]} (${sitesNameMapping.acronymToLongName[name]})`
}
{
resource && parent !== "sitepage" &&
<Link
to={
{
pathname:`/sites/${resource.id}`,
state: { siteData: resource }
}
}>
{`${sitesNameMapping.shortNameToAcronym[name]} (${sitesNameMapping.shortToLongName[name]})`}
</Link>
}
{
resource && parent === "sitepage" && sitesNameMapping.acronymToShortName[name] &&
<Link
to={
{
pathname:`/sites/${resource.id}`,
state: { siteData: resource }
}
}>
{`${sitesNameMapping.acronymToShortName[name]} (${sitesNameMapping.acronymToLongName[name]})`}
</Link>
}
{
resource && parent === "sitepage" && !sitesNameMapping.acronymToShortName[name] && name
}
</th>
</tr>
</thead>
Expand All @@ -37,11 +96,19 @@ const DetailTable = props => {
<td>Status</td>
<td className="align-middle text-center">
{
resource ? (
<span className="badge badge-pill badge-primary px-2">Up</span>
) : (<span className="badge badge-pill badge-danger px-2">Down</span>)
!resource &&
<span className="badge badge-pill badge-secondary px-2">
Down
</span>
}
{
resource &&
<span
className={`badge badge-pill badge-${statusMapping[resource.status.state].colorName} px-2`}
>
{ statusMapping[resource.status.state].state }
</span>
}

</td>
</tr>
{
Expand All @@ -50,7 +117,12 @@ const DetailTable = props => {
<tr key={`resource-detail-${index}`}>
<td>{row[0]}</td>
<td className="align-middle w-75">
{generateProgressBar(resource[row[1]], resource[row[2]])}
{
generateProgressBar(resource[row[1]],
resource[row[2]],
statusMapping[resource.status.state].colorHex,
statusMapping[resource.status.state].labelColorHex)
}
</td>
</tr>
)
Expand Down
124 changes: 124 additions & 0 deletions src/components/Resource/SiteDetailPage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import React from "react";
import DetailTable from "./DetailTable";
import { sitesNameMapping } from "../../data/sites";
import utcToLocalTimeParser from "../../utils/utcToLocalTimeParser.js";
import { default as portalData } from "../../services/portalData.json";
import { Link } from "react-router-dom";

const SiteDetailPage = props => {
const statusMapping = {
"Maint": {
state: "Maintenance",
color: "warning",
explanation: "no requests would be accepted"
},
"PreMaint": {
state: "Pre-Maintenance",
color: "warning",
explanation: "requests will be expected until the deadline"
},
"Active": {
state: "Active",
color: "primary",
explanation: ""

}
}

const { state } = props.location;

return (
<div className="container">
<div className="d-flex flex-row justify-content-between">
<h1>Site - {state.siteData.name}</h1>
<Link to="/resources">
<button
className="btn btn-sm btn-outline-primary my-3"
>
<i className="fa fa-sign-in mr-2"></i>
Back to Resources Overview
</button>
</Link>
</div>
{
["Maint", "PreMaint"].includes(state.siteData.status["state"]) &&
<div className="alert alert-primary mb-2" role="alert">
<i className="fa fa-exclamation-triangle mr-2"></i>
Please check the <i className="fa fa-sign-in ml-1 mr-2"></i>
<a href={portalData.knowledgeBaseForumLink} target="_blank" rel="noopener noreferrer">
FABRIC Announcements Forum
</a> for more detailed site maintenance information.
</div>
}
<div className="mt-4">
<h2>Basic Information</h2>
<table className="table table-sm table-striped table-bordered mb-4">
<tbody>
{
sitesNameMapping.acronymToShortName[state.siteData.name] &&
<tr>
<th>Name</th>
<td>{ sitesNameMapping.acronymToShortName[state.siteData.name] }</td>
</tr>
}
<tr>
<th>Acronym</th>
<td>{ state.siteData.name }</td>
</tr>
<tr>
<th>Status</th>
<td>
{
state.siteData.status["state"] !== "Active" ?
`${statusMapping[state.siteData.status["state"]].state} (${statusMapping[state.siteData.status["state"]].explanation})` :
statusMapping[state.siteData.status["state"]].state
}
</td>
</tr>
{
state.siteData.status["state"] === "Maint" &&
<tr>
<th>Expected End Time</th>
<td>
{
state.siteData.status["expected_end"] ?
utcToLocalTimeParser(state.siteData.status["expected_end"]) : "Unknown"
}
</td>
</tr>
}
{
state.siteData.status["state"] === "PreMaint" &&
<tr>
<th>Deadline</th>
<td>
{
state.siteData.status["deadline"] ?
utcToLocalTimeParser(state.siteData.status["deadline"]) : "Unknown"
}
</td>
</tr>
}
{
state.siteData.location &&
<tr>
<th>Rack Location</th>
<td>{ JSON.parse(state.siteData.location).postal }</td>
</tr>
}
</tbody>
</table>
</div>
<div className="mt-4">
<h2>Resource Availabilities</h2>
<DetailTable
name={ state.siteData.name }
resource={ state.siteData }
parent="sitepage"
/>
</div>
</div>
)
}

export default SiteDetailPage;
31 changes: 30 additions & 1 deletion src/components/Resource/SummaryTable.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,39 @@
import React, { Component } from "react";
import Table from "../common/Table";
import { Link } from "react-router-dom";

class SummaryTable extends Component {
columns = [
{
path: "name",
content: (resource) => (
<div>
<Link
to={
{
pathname:`/sites/${resource.id}`,
state: { siteData: resource }
}
}>
{resource.name}
</Link>
{
resource.status && resource.status.state === "Maint" &&
<div>
<span className="badge badge-pill badge-danger px-2">
Maintenance
</span>
</div>
}
{
resource.status && resource.status.state === "PreMaint" &&
<div>
<span className="badge badge-pill badge-info px-2">
Pre-Maintenance
</span>
</div>
}
</div>
),
label: "Site",
},
{ path: ["freeCore", "totalCore"], label: "Cores" },
Expand Down
Loading

0 comments on commit 966cfee

Please sign in to comment.