This is a crosspost from VanessaSaurus, dinosaurs, programming, and parsnips. See the original post here.
I was having a chat with the amazing, the diabolical griznog, and he had an idea up his sleeve for some kind of online form where a user could make selections, and filter down to some set of resources. I loved the idea, and decided to give it a shot.
Insert struggles with JavaScript frameworks…
This resulted in drumroll…
The resource explorer!!
If you don’t want to read about it, just see it here or use the code for your own group.
It’s really quite simple - it allows for interactive selection of a storage, compute, service, or other resource provided by your group. In the implementation linked here, we use resources and services relevant for research computing. I want to note that while I plan to deploy a version of this for my group, this particular instance is for demonstration purposes only and does not fully represent what we offer! I need the help of my group to finish up the details, and we will be deploying a “for realsies” resource explorer likely at our documentation portal. For now, let’s walk through how it works.
The resource-explorer.js file contains both the script and the data structures that drive it. At the top, you’ll see variables for questions and resources that drive the logic of the interface. The user will be presented with a series of easy to answer questions, and the selection of resources will be narrowed down based on the answers. Specifically:
Include multiple-choice, single-choice, boolean, and enumerate (maximum or minumum) choices.
In the above, an enumerate choice (minimum or maximum) implies there is an ordering to the logic. The user might want a minimum or maximum amount of memory, for example. Each question should be under the questions variable (a list), and have a title, description, required (true or false) and then options. For example, here is a question from the list:
{
"title": "Who is the resource for?",
"id": "q-who",
"description": "Select one or more groups that the resource is needed for.",
"required": false,
"type": "multiple-choice",
"options": [
{
"name": "faculty",
"id": "who-faculty"
},
{
"name": "staff",
"id": "who-staff"
},
{
"name": "student",
"id": "who-student"
}
]
}
For a minimum-* or maximum-* choice, the ids must end in an integer value:
{
"title": "What size of storage are you looking for?",
"id": "q-size",
"description": "If applicable, give an approximate unit of storage.",
"required": false,
"type": "minimum-choice",
"options": [
{
"name": "gigabytes",
"id": "size-gigabytes-1"
},
{
"name": "terabytes",
"id": "size-terabytes-2"
},
{
"name": "petabytes",
"id": "size-petabytes-3"
}
]
},
We do this so we can parse the ids and then rank order them. For a boolean choice, you can just use a single-choice with two choices:
{
"title": "Do you require backup?",
"id": "q-backups",
"description": "Some or all of your files will be copied on a regular basis in case you need restore.",
"required": false,
"type": "single-choice",
"options": [
{
"name": "backups",
"id": "backups-true"
},
{
"name": "no backups",
"id": "backups-false"
}
]
},
Notice that each choice has a unique id associated with it. These will be used as tags associated with each resource to help with the filtering.
A typical resource looks like this:
{
"title": "Nero",
"id": "nero",
"url": "https://nero-docs.stanford.edu",
"attributes": {
"q-kind": ["kind-compute", "kind-cloud"],
"q-service": [],
"q-who": ["who-faculty"], // only faculty allowed
// domain is left out, implying all domains
// size is left out, implying all sizes
"q-framework": ["framework-kubernetes", "framework-containers"],
"q-backups": ["backups-true"]
}
},
Note that we require a title (a user friendly print-able value), an id (for the object in the DOM), a url to link to, and then a list of attributes. For each attribute, the key corresponds to an id for a question, and then the list of values is a list of responses that, if chosen by the user, would make it a valid choice. Specifically:
For the above, this would mean that:
The repository serves only as an example, and doesn’t reflect the actual state of Stanford resources (but stay tuned, we will make one, as soon as I can get feedback from my colleages!)