Skip to content

Latest commit

 

History

History

customize-home-templates

OpenFin Workspace Example Application -- Customizing Home Search Result Templates Via API

ℹ️ OpenFin Workspace: OpenFin Workspace is a commercial product and this repo is for evaluation purposes (See LICENSE.MD). Use of the OpenFin Container and OpenFin Workspace components is only granted pursuant to a license from OpenFin (see manifest). Please contact us if you would like to request a developer evaluation key or to discuss a production license.

Customize Home Templates

OpenFin Workspace empowers you to feed content & apps to OpenFin Home via our API. This gives you the choice of fetching your list of applications from a Content Discovery Service or somewhere else.

This application you are about to install is a simple example of plugging in your own content or app. This example assumes you have already set up your development environment

Running the Sample

To run this sample you can:

  • Clone this repo and follow the instructions below. This will let you customize the sample to learn more about our APIs.
  • Launch the Github hosted version of this sample to interact with it by going to the following link:

Github Workspace Starter Customize Home Templates

Getting Started

  1. Install dependencies and do the initial build. Note that these examples assume you are in the sub-directory for the example.
npm run setup
  1. Optional (if you wish to pin the version of OpenFin Workspace to version 20.0.0 and you are on Windows) - Set Windows registry key for Desktop Owner Settings. This example runs a utility dos.mjs that adds the Windows registry key for you, pointing to a local desktop owner settings file so you can test these settings. If you already have a desktop owner settings file, this script prompts to overwrite the location. Be sure to capture the existing location so you can update the key when you are done using this example.

    (WARNING: This script kills all open OpenFin processes. This is not something you should do in production to close apps as force killing processes could kill an application while it's trying to save state/perform an action).

npm run dos
  1. Start the test server in a new window.
npm run start
  1. Start Your Workspace Platform (this starts Workspace if it isn't already running).
npm run client
  1. Type any character into the search box to show the default list of Applications. You can now use the custom commands e.g. `/price MSFT.

  2. If you modify the project and wish to rebuild you can run setup again or the build command below:

npm run build

Note About The App

This is a headless application. If you wish to debug it then you can update the manifest file and set platform.autoShow to true. Otherwise you can use Process Manager (which is included in your list of apps).

How it works

The Server in this example serves the sample and serves files from the common folder.

How this example works

This example is based on the Register With Home example, for full details on how registering with home works you can find more details there.

The additional commands are added through home.ts and custom templates for the commands are defined in templates.ts.

The commands implemented are:

? - which displays a list of all the commands with help
/templates
/quote <symbol>
/emoji <code>
/contacts <contact name>
/contacts-sync <contact name>
/contacts-partial <contact name>
/tree-inline
/tree-query
/loading
/error

The /templates command demonstrates a template containing all the different kinds of fragments that can be display in a home template.

The /quote command demonstrates a template that is built dynamically with a graph image.

The /emoji command demonstrates performing a search and returning multiple results with custom actions.

The contacts commands demonstrate different approaches to retrieving data.

  • /contacts-sync - Retrieves the contact list and all the contact details in one go, which ends up with a noticeable delay in the UI

  • /contacts-partial - Retrieves the contact list asynchronously and then retrieves all the contact details in the background, updating the results when it has the detailed data

  • /contacts - Retrieves the contact list asynchronously and then only retrieves the details for an item when they are selected, using the additional Loading template as a placeholder while the data is loaded. Also by searching for a contact starting with the letter E it will initially show the Error template, the contact will work when selecting reload.

  • /tree-inline and /tree-query The tree commands do not actually perform any function other than showing the help. To search for tree structured use a query such as Acme, Bee, Chad, Dock. This then demonstrates how to navigate through a tree like data structure and back up.

  • /loading Demonstrates how to use the built-in loading template to show a busy spinner, and then replace the result when it is no longer needed.

  • /error Demonstrates how to use the built-in error template to show an error result with a reload button, and then replace the result when it is no longer needed or reloaded.

  • desserts Demonstrates using returning suggestions and handling the isSuggestion flag.

e.g.

/templates

Customize Home Template Fragments

e.g.

/quote MSFT
/quote APPL

Customize Home Template Quote

e.g.

/emoji man
/emoji coffee

Customize Home Template Emoji

e.g.

Acme
Bee
Chad
Dock

Customize Home Template Tree

e.g.

/loading

Customize Home Template Loading

e.g.

/error

Customize Home Template error

e.g.

desserts

Customize Home Template Suggestion

Contact data

The contact details in the sample are random generated from https://www.mockaroo.com/

Note About This Example

This is an example of how to use our APIs to configure OpenFin Workspace. It's purpose is to provide an example and provide suggestions. This is not a production application and shouldn't be treated as such. Please use this as a guide and provide feedback. Thanks!


Read more about working with Workspace