You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/operate/control/single-page-apps.md
+92-17Lines changed: 92 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,9 @@
1
1
---
2
2
title: "Create a custom web interface"
3
3
linkTitle: "Create a custom web interface"
4
-
weight: 11
5
-
no_list: true
6
-
type: docs
4
+
weight: 5
5
+
layout: "docs"
6
+
type: "docs"
7
7
description: "Create and deploy custom web interfaces for your machines as single-page applications without managing hosting and authentication."
8
8
---
9
9
@@ -13,7 +13,7 @@ Once deployed, apps are accessible from a dedicated URL (`appname_publicnamespac
13
13
When opening an app, users log in and then select a machine they have access to.
14
14
Then your app is rendered and ready for use.
15
15
16
-
{{<imgprocsrc="/operate/spa.png"resize="400x"declaredimensions=truealt="App screen asking for the org, location, and machine."class="imgzoom shadow">}}
16
+
{{<gifwebm_src="/spa.webm"mp4_src="/spa.mp4"alt="Sample web app"max-width="500px">}}
17
17
18
18
## Requirements
19
19
@@ -28,14 +28,14 @@ Then authenticate your CLI session with Viam using one of the following options:
28
28
29
29
{{< /expand >}}
30
30
31
-
## Create a single page app
31
+
## Build a custom web interface
32
32
33
-
{{< table >}}
34
-
{{% tablestep number=1 %}}
33
+
You can build a custom web interface to access your machines using your preferred framework like React, Vue, Angular, or others.
35
34
36
-
**Build your application** using your preferred framework like React, Vue, Angular, or others.
37
-
While you're developing use any machine's credentials.
38
-
For deploying your app you must add code to read the machine API key from your browsers local storage:
35
+
### Access machines from your app
36
+
37
+
Viam apps provide access to a machine by placing its API key in your local storage.
38
+
You can access the data from your browser's local storage as follows:
6. Open the app you are building on localhost and run the resulting script.
121
+
7. Reload your app.
122
+
123
+
### Configure routing
124
+
125
+
When using your deployed application, static files will be accessible at `https://your-app-name_your-public-namespace.viamapplications.com/machine/<machine-id>/`.
126
+
If your HTML file loads other files, use relative paths to ensure your files are accessible.
127
+
128
+
## Deploy your web interface
129
+
130
+
{{< table >}}
131
+
{{% tablestep number=1 %}}
58
132
59
133
**Create a <FILE>meta.json</FILE>** file using this template:
60
134
@@ -123,7 +197,7 @@ The `applications` field is an array of application objects with the following p
123
197
|`entrypoint`| string | The path to the HTML entry point for your application. The `entrypoint` field specifies the path to your application's entry point. For example: <ul><li><code>"dist/index.html"</code>: Static content rooted at the `dist` directory</li><li><code>"dist/foo.html"</code>: Static content rooted at the `dist` directory, with `foo.html` as the entry point</li><li><code>"dist/"</code>: Static content rooted at the `dist` directory (assumes `dist/index.html` exists)</li><li><code>"dist/bar/foo.html"</code>: Static content rooted at `dist/bar` with `foo.html` as the entry point</li></ul> |
124
198
125
199
{{% /tablestep %}}
126
-
{{% tablestep number=3 %}}
200
+
{{% tablestep number=2 %}}
127
201
**Register your module** with Viam:
128
202
129
203
{{< tabs >}}
@@ -144,13 +218,13 @@ viam module create --name="air-quality" --public-namespace="naomi"
144
218
{{< /tabs >}}
145
219
146
220
{{% /tablestep %}}
147
-
{{% tablestep number=4 %}}
221
+
{{% tablestep number=3 %}}
148
222
149
223
**Package your static files and your <FILE>meta.json</FILE> file and upload them** to the Viam Registry:
Copy file name to clipboardExpand all lines: docs/operate/reference/module-configuration.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -285,7 +285,7 @@ The `applications` field is an array of application objects with the following p
285
285
286
286
For more information about Single Page Apps, see the [Single Page Apps documentation](/operate/reference/single-page-apps/).
287
287
288
-
####Environment variables
288
+
### Environment variables
289
289
290
290
Each module has access to the following default environment variables.
291
291
Not all of these variables are automatically available on [local modules](/operate/get-started/other-hardware/#test-your-module-locally); you can manually set variables your module requires if necessary.
0 commit comments