Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Drawer component #338

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 57 additions & 45 deletions web/static/cluster-tasks.mjs
Original file line number Diff line number Diff line change
@@ -1,33 +1,48 @@
import { LitElement, html, css } from 'https://cdn.jsdelivr.net/gh/lit/dist@3/all/lit-all.min.js';
import {LitElement, html, css} from 'https://cdn.jsdelivr.net/gh/lit/dist@3/all/lit-all.min.js';
import RPCCall from '/lib/jsonrpc.mjs';

customElements.define('cluster-tasks', class ClusterTasks extends LitElement {
static get properties() {
return {
data: { type: Array },
showBackgroundTasks: { type: Boolean },
};
}
class ClusterTasks extends LitElement {
static get properties() {
return {
data: { type: Array },
showBackgroundTasks: { type: Boolean },
};
}

constructor() {
super();
this.data = [];
this.showBackgroundTasks = false;
this.loadData();
}
static get styles() {
return css`
th, td {
&:nth-child(1) { width: 8ch; }
&:nth-child(2) { width: 16ch; }
&:nth-child(3) { width: 10ch; }
&:nth-child(4) { width: 10ch; }
&:nth-child(5) { min-width: 20ch; }

overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
`
}

async loadData() {
this.data = (await RPCCall('ClusterTaskSummary')) || [];
setTimeout(() => this.loadData(), 1000);
this.requestUpdate();
}
constructor() {
super();
this.data = [];
this.showBackgroundTasks = false;
this.loadData();
}

toggleShowBackgroundTasks(e) {
this.showBackgroundTasks = e.target.checked;
}
async loadData() {
this.data = (await RPCCall('ClusterTaskSummary')) || [];
setTimeout(() => this.loadData(), 1000);
this.requestUpdate();
}

render() {
return html`
toggleShowBackgroundTasks(e) {
this.showBackgroundTasks = e.target.checked;
}

render() {
return html`
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
rel="stylesheet"
Expand All @@ -40,18 +55,18 @@ customElements.define('cluster-tasks', class ClusterTasks extends LitElement {
onload="document.body.style.visibility = 'initial'"
/>

<!-- Toggle for showing background tasks -->
<label>
<input
type="checkbox"
@change=${this.toggleShowBackgroundTasks}
?checked=${this.showBackgroundTasks}
/>
Show background tasks
</label>

<table class="table table-dark">
<thead>
<!-- Toggle for showing background tasks -->
<label>
<input
type="checkbox"
@change=${this.toggleShowBackgroundTasks}
?checked=${this.showBackgroundTasks}
/>
Show background tasks
</label>
<table class="table table-dark">
<thead>
<tr>
<th>SpID</th>
<th style="min-width: 128px">Task</th>
Expand All @@ -62,10 +77,7 @@ customElements.define('cluster-tasks', class ClusterTasks extends LitElement {
</thead>
<tbody>
${this.data
.filter(
(entry) =>
this.showBackgroundTasks || !entry.Name.startsWith('bg:')
)
.filter((entry) =>this.showBackgroundTasks || !entry.Name.startsWith('bg:'))
.map(
(entry) => html`
<tr>
Expand All @@ -75,9 +87,7 @@ customElements.define('cluster-tasks', class ClusterTasks extends LitElement {
<td>${entry.SincePostedStr}</td>
<td>
${entry.OwnerID
? html`<a href="/pages/node_info/?id=${entry.OwnerID}"
>${entry.Owner}</a
>`
? html`<a href="/pages/node_info/?id=${entry.OwnerID}">${entry.Owner}</a>`
: ''}
</td>
</tr>
Expand All @@ -86,5 +96,7 @@ customElements.define('cluster-tasks', class ClusterTasks extends LitElement {
</tbody>
</table>
`;
}
});
}
}

customElements.define('cluster-tasks', ClusterTasks);
38 changes: 24 additions & 14 deletions web/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,24 @@
<script type="module" src="pipeline-porep.mjs"></script>
<script type="module" src="actor-summary.mjs"></script>
<script type="module" src="/ux/curio-ux.mjs"></script>
<script type="module" src="/ux/components/Drawer.mjs"></script>
<style>
.logo {
display: inline-block;
.drawer {
display: block;
}

.dash-tile {
display: flex;
flex-direction: column;
padding: 0.75rem;
background: #3f3f3f;
.wide-content {
display: none;
}

@media (min-width: 2210px) {
.drawer {
display: none;
}

& b {
padding-bottom: 0.5rem;
color: deeppink;
}
.wide-content {
display: block;
}
}
</style>
</head>
Expand Down Expand Up @@ -109,8 +112,15 @@ <h2>24h task counts</h2>
<div class="row">
<div class="col-md-auto" style="max-width: 1000px">
<div class="info-block">
<h2>Cluster Tasks</h2>
<cluster-tasks></cluster-tasks>
<div class="wide-content">
<h2>Cluster Tasks</h2>
<cluster-tasks></cluster-tasks>
</div>

<ui-drawer class="drawer" label="Cluster Tasks">
<h2 slot="title">Cluster Tasks</h2>
<cluster-tasks slot="content"></cluster-tasks>
</ui-drawer>
</div>
</div>
<div class="col-md-auto">
Expand All @@ -120,4 +130,4 @@ <h2>Cluster Tasks</h2>
</curio-ux>
</body>

</html>
</html>
Loading
Loading