Skip to content

Commit

Permalink
Merge pull request #94 from ni/guides
Browse files Browse the repository at this point in the history
WebVI CSS Guide first release of common examples for NXG 3.1
  • Loading branch information
rajsite authored Jul 2, 2019
2 parents fda3381 + 13c7e8b commit 39dc313
Show file tree
Hide file tree
Showing 19 changed files with 1,490 additions and 206 deletions.
File renamed without changes.
7 changes: 7 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"default": true,
"line-length": false,
"no-bare-urls": false,
"no-empty-links": false,
"no-trailing-punctuation": false
}
95 changes: 95 additions & 0 deletions .spelling
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# markdown-spellcheck spelling configuration file
# Format - lines beginning # are comments
# global dictionary is at the start, file overrides afterwards
# one word per line, to define a file override use ' - filename'
# where filename is relative to this configuration file

# General language
amongst
i.e.
e.g.
lossy
learnability
unflatten
checkbox
checkboxes
checkmark
checkmarks

# General Technical Terminology
api
apis
enum
enums
CSV
YML
timestamp
timestamps
namespace
namespaces
dequeue
subdiagram
subdiagrams
subfolder
subfolders
i8
i16
i32
i64
u8
u16
u32
u64
boolean
losslessly
utf-8
utf-16
Uint8Array
async

# Web Terminology
JSON
CSS
UI
CORS
F12
hostname
LDAP
WebSocket
WebSockets
HTTP
HTTPS
IETF
iframe
iframes
url
urls
TypedArray
TypedArrays
polyfill

# NI Terminology
LabVIEW
VI
VIs
GVI
GVIs
SubVI
SubVIs
NXG
nipkg
ni
ni.com
SSP
SystemDesigner

# Web Module Terminology
WebVI
WebVIs
JSLI
SystemLink

# Example Terminology
webvi-examples
USGS
DataQueue
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: node_js
node_js:
- "lts/*"
34 changes: 23 additions & 11 deletions Call3rdPartyWebService/Readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Call 3rd Party Web Service

[![Call 3rd Party Web Service Demo Link](https://img.shields.io/badge/Details-Demo_Link-green.svg)](https://ni.github.io/webvi-examples/Call3rdPartyWebService/Builds/WebApp_Web%20Server/)
[![Call 3rd Party Web Service README Link](https://img.shields.io/badge/Details-README_Link-orange.svg)]()

Expand All @@ -10,51 +11,62 @@ On the panel, this WebVI displays a summary of the results in a data grid and a

![Screenshot of Demo](readme_files/Screenshot.gif)

# Dependencies
## Dependencies

- LabVIEW NXG Web Module

# Setup
## Setup

1. Clone the [ni/webvi-examples](https://github.com/ni/webvi-examples) repository to your machine.
2. Open `Call3rdPartyWebService/Call3rdPartyWebService.lvproject`
3. Open `index.gviweb` and click the **Run** button.
4. Build the web application.
a. Open `WebApp.gcomp`.
b. On the **Document** tab, click **Build**.

**Note:** To view the build output on your machine, click **Locate Directory in Windows Explorer** on the **Document** tab once your application finishes building. You can automatically launch and view the Web application locally by going to **System Designer** >> **Web Server** >> right-click **WebApp.gcomp** >> **Run**
**Note:** To view the build output on your machine, click **Locate Directory in Windows Explorer** on the **Document** tab once your application finishes building. You can automatically launch and view the Web application locally by going to **System Designer** >> **Web Server** >> right-click `WebApp.gcomp` >> **Run**

# Hosting
You can manually the move the build output found at `\Call3rdPartyWebService\Builds` to any web server. This project also includes a Distribution (WebApp.lvdist) that can be used to build a package (.nipkg). Packages utilize NI Package Manager to automated the process of installing, upgrading, or removing the web app. A package is also a requirement for hosting a Web application on SystemLink Cloud.
## Hosting

You can manually the move the build output found at `\Call3rdPartyWebService\Builds` to any web server. This project also includes a Distribution (`WebApp.lvdist`) that can be used to build a package (.nipkg). Packages utilize NI Package Manager to automated the process of installing, upgrading, or removing the web app. A package is also a requirement for hosting a Web application on SystemLink Cloud.

### SystemLink Cloud Web App Hosting

## SystemLink Cloud Web App Hosting
The following steps can be used to host the web app on SystemLink Cloud

1. Open `Call3rdPartyWebService.lvproject`.
2. Open `WebApp.lvdist`.
3. Click the build icon in the top command bar of this distribution document
4. Open a Web browser and navigate to https://www.systemlinkcloud.com/webapphosting
5. Click the **Choose nipkg** button and select the nipkg built in step 3.
6. When the upload is complete, click on your newly uploaded Web app from your list of Web apps

## Local Hosting
### Local Hosting

The following steps can be used to host the web app on a local web server
### Hosting on the NI Web Server with a nipkg

#### Hosting on the NI Web Server with a nipkg

1. Open `Call3rdPartyWebService.lvproject`
2. Open `WebApp.lvdist`.
3. Click the build icon in the top command bar of this distribution document
4. Double-click the nipkg and follow the on screen instructions
5. Open a web browser and navigate to `http://localhost:9090/call3rdpartywebservice/`

### Hosting on the NI Web Server by manually moving files
#### Hosting on the NI Web Server by manually moving files

1. Open `C:\Program Files\National Instruments\Shared\Web Server\htdocs`
2. Copy the `WebApp_Web Server` directory into the `htdocs` directory
3. Open a web browser and navigate to `http://localhost:9090/WebApp_Web%20Server/`

### Hosting on the LabVIEW 2009-2017 Web Server
#### Hosting on the LabVIEW 2009-2017 Web Server

1. Open `C:\Program Files (x86)\National Instruments\Shared\NI WebServer\www`
2. Copy the `WebApp_Web Server` directory into the `www` directory
3. Open a web browser and navigate to `http://localhost:8080/WebApp_Web%20Server/`

# Details
## Details

A web service is a collection of functions that can be called through the web to trigger behavior or return data. Many websites offer these APIs as a way for third-party developers to build new applications using the website's underlying data or functionality.

Many web services are open and public like the Earthquake API. Others require registration and API keys that restrict access to specific users and limit the load on the service.
Expand Down
50 changes: 35 additions & 15 deletions CallJavaScriptFromAWebVI/Readme.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,86 @@
# Call JavaScript From a WebVI

[![Call JavaScript From a WebVI Demo Link](https://img.shields.io/badge/Details-Demo_Link-green.svg)](https://ni.github.io/webvi-examples/CallJavaScriptFromAWebVI/Builds/WebApp_Web%20Server/)
[![Call JavaScript From a WebVI README Link](https://img.shields.io/badge/Details-README_Link-orange.svg)]()

This example is a simple 4-bit calculator using the JavaScript Library Interface (JSLI). The math functions and Log to Console button illustrate different methods of using the JSLI. Add (JSLI) and Multiply (JSLI) use external JavaScript files to implement their functions. The Log to Console button logs text to the browser debug console using the browser-supported console.log function. After building and deploying the WebVI to a browser, open the browser developer tools (Press F12 in most browsers) and select the Console tab to view the console log.
This example is a simple 4-bit calculator using the JavaScript Library Interface (JSLI). The math functions and Log to Console button illustrate different methods of using the JSLI. Add (JSLI) and Multiply (JSLI) use external JavaScript files to implement their functions. The Log to Console button logs text to the browser debug console using the browser-supported `console.log` function. After building and deploying the WebVI to a browser, open the browser developer tools (Press F12 in most browsers) and select the Console tab to view the console log.

On the panel, this WebVI has X and Y binary inputs. The user clicks these to change the numerical values of the inputs. The Outputs of X+Y and X*Y are updated with binary and numerical indicators.

![Screenshot of Demo](readme_files/Screenshot.gif)

# Dependencies
## Dependencies

- LabVIEW NXG Web Module

# Setup
## Setup

1. Clone the [ni/webvi-examples](https://github.com/ni/webvi-examples) repository to your machine.
2. Open `CallJavaScriptFromAWebVI\CallJavaScriptFromAWebVI.lvproject`
3. Open `index.gviweb` and click the **Run** button.
4. Build the web application.
a. Open `WebApp.gcomp`.
b. On the **Document** tab, click **Build**.

**Note:** To view the build output on your machine, click **Locate Directory in Windows Explorer** on the **Document** tab once your application finishes building. You can automatically launch and view the Web application locally by going to **System Designer** >> **Web Server** >> right-click **WebApp.gcomp** >> **Run**
**Note:** To view the build output on your machine, click **Locate Directory in Windows Explorer** on the **Document** tab once your application finishes building. You can automatically launch and view the Web application locally by going to **System Designer** >> **Web Server** >> right-click `WebApp.gcomp` >> **Run**

# Hosting
You can manually the move the build output found at `\CallJavaScriptFromAWebVI\Builds` to any web server. This project also includes a Distribution (WebApp.lvdist) that can be used to build a package (.nipkg). Packages utilize NI Package Manager to automated the process of installing, upgrading, or removing the web app. A package is also a requirement for hosting a Web application on SystemLink Cloud.
## Hosting

You can manually the move the build output found at `\CallJavaScriptFromAWebVI\Builds` to any web server. This project also includes a Distribution (`WebApp.lvdist`) that can be used to build a package (.nipkg). Packages utilize NI Package Manager to automated the process of installing, upgrading, or removing the web app. A package is also a requirement for hosting a Web application on SystemLink Cloud.

### SystemLink Cloud Web App Hosting

## SystemLink Cloud Web App Hosting
The following steps can be used to host the web app on SystemLink Cloud

1. Open `CallJavaScriptFromAWebVI.lvproject`.
2. Open `WebApp.lvdist`.
3. Click the build icon in the top command bar of this distribution document
4. Open a Web browser and navigate to https://systemlinkcloud.com/
5. Click the **Choose nipkg** button and select the nipkg built in step 3.
6. When the upload is complete, click on your newly uploaded Web app from your list of Web apps

## Local Hosting
### Local Hosting

The following steps can be used to host the web app on a local web server
### Hosting on the NI Web Server with a nipkg

#### Hosting on the NI Web Server with a nipkg

1. Open `CallJavaScriptFromAWebVI.lvproject`
2. Open `WebApp.lvdist`.
3. Click the build icon in the top command bar of this distribution document
4. Double-click the nipkg and follow the on screen instructions
5. Open a web browser and navigate to `http://localhost:9090/CallJavaScriptFromAWebVI/`

### Hosting on the NI Web Server by manually moving files
#### Hosting on the NI Web Server by manually moving files

1. Open `C:\Program Files\National Instruments\Shared\Web Server\htdocs`
2. Copy the `WebApp_Web Server` directory into the `htdocs` directory
3. Open a web browser and navigate to `http://localhost:9090/WebApp_Web%20Server/`

### Hosting on the LabVIEW 2009-2017 Web Server
#### Hosting on the LabVIEW 2009-2017 Web Server

1. Open `C:\Program Files (x86)\National Instruments\Shared\NI WebServer\www`
2. Copy the `WebApp_Web Server` directory into the `www` directory
3. Open a web browser and navigate to `http://localhost:8080/WebApp_Web%20Server/`

# Details
This WebVI uses the JSLI to interface with simple functions defined in Add.js and Multiply.js, and compares the results with the LabVIEW NXG built-in functions. A single JSLI wraps JavaScript functions in the two external JavaScript files. The external functions are referenced by using the Function prototype symbol, or name, used in the JavaScript file. For example, AddWithJSLI is a function defined in Add.js. The corresponding JSLI function references the Symbol 'AddWithJSLI' to link the JavaScript function to the JSLI function.
## Details

This WebVI uses the JSLI to interface with simple functions defined in `Add.js` and `Multiply.js`, and compares the results with the LabVIEW NXG built-in functions.
A single JSLI wraps JavaScript functions in the two external JavaScript files.
The external functions are referenced by using the Function prototype symbol, or name, used in the JavaScript file.
For example, `AddWithJSLI` is a function defined in `Add.js`.
The corresponding JSLI function references the Symbol `AddWithJSLI` to link the JavaScript function to the JSLI function.

![JSLI Node Functions](readme_files/JSLI.png)

The Add and Multiply nodes output the JSLI and built-in function results to the index WebVI. The Multiply.js file demonstrates a simple, external JavaScript function, and the Add.js file demonstrates a more complex JavaScript function. See these files for comments about the functions themselves.
The Add and Multiply nodes output the JSLI and built-in function results to the index WebVI.
The `Multiply.js` file demonstrates a simple, external JavaScript function, and the `Add.js` file demonstrates a more complex JavaScript function.
See these files for comments about the functions themselves.

![Add and Multiply Nodes](readme_files/nodes.png)

The Log to Console button logs text to the browser debug console using the browser-supported console.log function. After building and deploying the WebVI to a browser, open the browser developer tools (Press F12 in most browsers) and select the Console tab to view the console log. The log allows the user to see messages that can potentially help debug their application.
The Log to Console button logs text to the browser debug console using the browser-supported `console.log` function.
After building and deploying the WebVI to a browser, open the browser developer tools (Press F12 in most browsers) and select the Console tab to view the console log.
The log allows the user to see messages that can potentially help debug their application.

![Log to Console](readme_files/log.png)
Loading

0 comments on commit 39dc313

Please sign in to comment.