Skip to content

Commit

Permalink
add simple list
Browse files Browse the repository at this point in the history
  • Loading branch information
codetricity committed Nov 9, 2024
1 parent 8a01e19 commit 6796d57
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
Binary file added docs/images/tutorial/simple-list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/tutorial/split-pane.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,3 +424,59 @@ In `index.html`.
Tip: Add the ui object into the viewer at time of instantiation.

![button challenge](images/tutorial/button_challenge.png)

The split pane button will work.

![split pane](images/tutorial/split-pane.png)

Solution is in the tutorial folder in `button-challenge.html`.

### simple list of content

We're passing a single image contentId into the HTML.
Modifer the code to show a simple list.

![simple list](images/tutorial/simple-list.png)

In the server Python file

```python

# Function to query content from the RICOH360 API
def get_content():
cloud_content_token = get_token_for_cloud_content()
# Fetch content using the token
content_headers = {"Authorization": f"Bearer {cloud_content_token}"}
content_response = requests.get(
"https://api.ricoh360.com/contents?limit=10", headers=content_headers
)
content_data = content_response.json()
return content_data

@app.route("/")
def index():
token = create_token()
content_data = get_content()
contentIds = []
for single_content in content_data:
contentIds.append(single_content["content_id"])
return render_template("simple-list-challenge.html", token=token, contentIds=contentIds)
```

in the HTML file

```html
...
...
viewer.start({
contentId: "{{contentIds[0]}}"
});
</script>

{% for contentId in contentIds %}
<button onclick="viewer.switchScene({ contentId: '{{contentId}}'})"> {{ loop.index }}</button>
{% endfor %}
```

Solution in the tutorial folder on GitHub.

0 comments on commit 6796d57

Please sign in to comment.