Skip to content

Commit

Permalink
Merge pull request #165 from stanford-crfm/front-page-features
Browse files Browse the repository at this point in the history
add front page features
  • Loading branch information
rishibommasani authored Apr 9, 2024
2 parents bdbf952 + 4f696a6 commit 17c851d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
1 change: 0 additions & 1 deletion .github/workflows/collate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ name: Collate
"on":
workflow_dispatch:
push:
branches: main
paths:
- assets/**

Expand Down
4 changes: 3 additions & 1 deletion components/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ <h1 class="fs-1">graphs</h1>

<div class="center-block text-center m-9">
<a href="index.html?mode=table" class="btn btn-lg btn-primary m-3 px-5" role="button">VIEW</a>
<a href="https://github.com/stanford-crfm/ecosystem-graphs" class="btn btn-lg btn-primary m-3 px-5" role="button">GITHUB</a>
<a href="https://github.com/stanford-crfm/ecosystem-graphs" class="btn btn-lg btn-primary m-3 px-5" role="button">CODE</a>
<button class="btn btn-lg btn-primary m-3 px-4" role="button" id="download-csv" onclick="downloadCSV()">DOWNLOAD</button>
</div>


</div>

</div>
2 changes: 1 addition & 1 deletion components/table.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<input class="search-box m-3 px-3 py-2" type="text" id="table-search" placeholder="Search table">
</div>
<div class="col-xs-6">
<button class="btn btn-md btn-secondary" role="button" id="table-toggle-explanation" onclick="toggleExplanation(this)">Show Field Details</button>
<button class="btn btn-md btn-secondary" role="button" id="download-csv" onclick="downloadCSV()">Download Assets CSV</button>
</div>
</div>

Expand Down
16 changes: 11 additions & 5 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,9 @@ function renderFieldName(fieldName) {
// Capitalizes and removes '_' from a fieldName (which should be a field name
// from the schema, such as created_date, name, etc.)
const capitalized = fieldName.charAt(0).toUpperCase() + fieldName.slice(1);
if (capitalized === 'Modality') {
return 'Modality (In; Out)'
}
return capitalized.replace('_', ' ');
}

Expand Down Expand Up @@ -419,7 +422,7 @@ function renderCustomTable(selectedAssets, allNameToAsset, columnNames) {
function renderAssetsTable(nameToAsset) {
// Render the table
const columnNames = [
'type', 'name', 'organization', 'created_date', 'size', 'access', 'license',
'type', 'name', 'organization', 'created_date', 'size', 'modality', 'access', 'license',
'dependencies',
];
const assets = Object.keys(nameToAsset).map((key) => (nameToAsset[key]));
Expand Down Expand Up @@ -550,10 +553,13 @@ function renderAssetsGraph(nameToAsset) {

// UI Helpers

function toggleExplanation(button) {
const newText = $(button).text() === "Show Field Details" ? "Hide Field Details" : "Show Field Details"
$(".field-explanation").toggle();
$(button).text(newText);
function downloadCSV() {
var downloadLink = document.createElement('a');
downloadLink.href = 'resources/all_assets.csv';
downloadLink.download = 'assets.csv';
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
}

function setUpSearch() {
Expand Down

0 comments on commit 17c851d

Please sign in to comment.