Skip to content
Open
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
57 changes: 57 additions & 0 deletions _services/osdf/projects.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,63 @@ <h2 class="mini-bar">By Project</h2>
<div id="wrapper" class="overflow-auto"></div>
</div>

<div class="modal fade" id="project-display" tabindex="-1" aria-labelledby="project-Name" style="display: none;">
<div class="modal-dialog modal-xl modal-fullscreen-lg-down">
<div class="modal-content">
<div class="modal-header justify-content-between">
<h2 id="project-Name" class="mb-0 project-Name"><span class="placeholder bg-light w-100"></span></h2>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" aria-label="Close">Close</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-12 col-md-6">
<div>
<h5 class="mb-1">PI</h5>
<p class="project-PIName placeholder-glow"><span class="placeholder w-100"></span></p>
</div>
<div>
<h5 class="mb-1">Field of Research</h5><p class="project-FieldOfScience placeholder-glow"><span class="placeholder w-100"></span></p>
</div>
<div>
<h5 class="mb-1">Organization </h5><p class="project-Organization placeholder-glow"><span class="placeholder w-100"></span></p>
</div>
</div>
<div class="col-12 col-md-6">
<h5 class="mb-1">Description</h5>
<p class="project-Description placeholder-glow"><span class="placeholder w-100"></span></p>
</div>
</div>
<div class="row py-2 gx-1">
<div class="col-12 col-md-6 placeholder-glow d-flex">
<div class="card text-bg-dark flex-grow-1">
<div class="card-header">
OSDF Objects Transferred
</div>
<div class="card-body d-flex">
<div id="project-osdf-objects" class="graph-slot flex-grow-1">
<span class="placeholder bg-light w-100"></span>
</div>
</div>
</div>
</div>
<div class="col-12 col-md-6 placeholder-glow d-flex">
<div class="card text-bg-dark flex-grow-1">
<div class="card-header">
OSDF Bytes Transferred
</div>
<div class="card-body d-flex">
<div id="project-osdf-bytes" class="graph-slot flex-grow-1">
<span class="placeholder bg-light w-100"></span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

<div class="row mt-3 justify-content-center">
<div class="col-auto mt-3">
<div class="d-flex align-items-center">
Expand Down
33 changes: 32 additions & 1 deletion assets/js/components/ProjectDisplay.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {formatBytes} from "../util.js";
import {PieChart} from "./pie-chart.js";
import {getProjectOverview} from "../adstash.mjs";
import Count from "./Count.mjs";
Expand Down Expand Up @@ -83,4 +84,34 @@ class ProjectDisplay{
}
}

export default ProjectDisplay;
class OSDFProjectDisplay extends ProjectDisplay {
async update({Name, PIName, FieldOfScience, Organization, Description}) {
this.updateTextValue("project-Name", Name)
this.updateTextValue("project-PIName", PIName)
this.updateTextValue("project-FieldOfScience", FieldOfScience)
this.updateTextValue("project-Organization", Organization)
this.updateTextValue("project-Description", Description)
this.setUrl(Name)
this.clearGraphSlots()
this.parentNode.addEventListener("shown.bs.modal", () => {
this.updateGraphs(Name)
}, {once : true})
this.display_modal.show()
}

async updateGraphs(Name){
const data = await this.getData(Name)

const objects = Math.round(Object.values(data).reduce((p, v) => p + v.osdfFileTransferCount, 0));
const bytes = Math.round(Object.values(data).reduce((p, v) => p + v.osdfByteTransferCount, 0));
Count("project-osdf-objects", objects, 100)
Count("project-osdf-bytes", formatBytes(bytes), 100)
}

async updateInstitutionPieChart(_) {
throw new Error("updateInstitutionPieChart not implemented for OSDFProjectDisplay")
}
}

export { OSDFProjectDisplay };
export default ProjectDisplay;
51 changes: 45 additions & 6 deletions assets/js/osdf-project-page-v6.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
localeIntToInt, byteStringToBytes
} from "./util.js";
import Color from "https://colorjs.io/dist/color.js";
import {OSDFProjectDisplay} from "./components/ProjectDisplay.mjs";
import {PieChart} from "./components/pie-chart.js";
import Search from "./Search.mjs";

Expand All @@ -39,13 +40,14 @@ class ProjectCount {
}

class Table {
constructor(wrapper, data_function){
constructor(wrapper, data_function, updateProjectDisplay){

let table = this;

this.grid = undefined
this.data_function = data_function
this.wrapper = wrapper
this.updateProjectDisplay = updateProjectDisplay
this.columns = [
{
id: 'projectName',
Expand Down Expand Up @@ -122,13 +124,20 @@ class Table {
}
}
}).render(table.wrapper);
this.grid.on('rowClick', this.row_click);
}
update = async () => {
let table = this
this.grid.updateConfig({
data: Object.values(await table.data_function()).sort((a, b) => b.osdfFileTransferCount - a.osdfFileTransferCount)
}).forceRender();
}
row_click = async (PointerEvent, e) => {
let data = await this.data_function();
let row_name = e["cells"][0].data
let project = data[row_name]
this.updateProjectDisplay(project)
}
}

class DataManager {
Expand Down Expand Up @@ -169,16 +178,37 @@ class DataManager {
}
}

_getData = async () => {
_fetch = async (url, options = {}) => {
try {
let response = await fetch(url, options)

if(!response.ok){
throw new Error(response.statusText)
}

return response.json()

} catch(error) {
this.error = "Error fetching usage data, learn more on the OSG status page: status.osg-htc.org"
}
}

_getData = async () => {
let topologyData = await this._fetch("https://topology.opensciencegrid.org/miscproject/json")
let usageJson;

try {
usageJson = await getProjects()
} catch(e) {
this.error = "Error fetching usage data, learn more on the status page: status.osg-htc.org"
}

this.data = usageJson
this.data = Object.entries(topologyData).reduce((p, [k,v]) => {
if(k in usageJson){
p[k] = {...v, ...usageJson[k]}
}
return p
}, {})

return this.data
}
Expand Down Expand Up @@ -232,8 +262,11 @@ class ProjectPage{
this.mode = undefined
this.dataManager = new DataManager()

let projectDisplayNode = document.getElementById("project-display")
this.projectDisplay = new OSDFProjectDisplay(projectDisplayNode)

this.wrapper = document.getElementById("wrapper")
this.table = new Table(this.wrapper, this.dataManager.getFilteredData)
this.table = new Table(this.wrapper, this.dataManager.getFilteredData, this.projectDisplay.update.bind(this.projectDisplay))
this.dataManager.consumerToggles.push(this.table.update)

this.search = new Search(Object.values(await this.dataManager.getData()), this.dataManager.toggleConsumers)
Expand Down Expand Up @@ -261,12 +294,18 @@ class ProjectPage{
this.filePieChart = new PieChart(
"project-file-summary",
this.dataManager.reduceByKey.bind(this.dataManager, "projectName", "osdfFileTransferCount"),
"# of Objects Transferred by Project"
"# of Objects Transferred by Project",
({label, value}) => {
this.table.updateProjectDisplay(this.dataManager.data[label])
}
)
this.bytePieChart = new PieChart(
"project-byte-summary",
this.dataManager.reduceByKey.bind(this.dataManager, "projectName", "osdfByteTransferCount"),
"# of Bytes Transferred by Project"
"# of Bytes Transferred by Project",
({label, value}) => {
this.table.updateProjectDisplay(this.dataManager.data[label])
}
)

this.dataManager.consumerToggles.push(this.fosFilePieChart.update)
Expand Down
Loading