Skip to content
This repository has been archived by the owner on Sep 7, 2018. It is now read-only.

OpenFin Notifications #7

Merged
merged 4 commits into from Mar 10, 2017

Conversation

BenLambertNcl
Copy link
Collaborator

@BenLambertNcl BenLambertNcl commented Mar 10, 2017

Basic implementation of the OpenFin notifications.

The OpenFin API requires a html template to use as its notification. I have included a very simple html template that resembles the default electron notification. OpenFin does not support native notifications.

OpenFin does not allow preload scripts like electron. Because of this, npm posinstall copies the API into the src directory, which is accessed via a script tag. I also included a blank index.js file in the specification project to avoid any 404 errors from electron/browsers.

npm install ssf-desktop-api-openfin --save
```

You need to include this code into the project by loading the javascript file directly (as Openfin does not support preloading).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JavaScript
OpenFin

Yes, I really am that pedantic!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beat me to it! 😄

Copy link
Collaborator

@ColinEberhardt ColinEberhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from a very pedantic comment about capitalisation, looks good to me 👍

Copy link
Collaborator

@jleft jleft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of questions and some very minor comments, but overall looking really good to me!

"author": "",
"license": "Apache-2.0",
"dependencies": {
"bootstrap": "^3.3.7",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is used - remove?

"license": "Apache-2.0",
"dependencies": {
"bootstrap": "^3.3.7",
"jquery": "^3.1.1",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is used - remove?

"description": "",
"name": "SSF API Demo Openfin"
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: add newline at the end of the file

@@ -0,0 +1,13 @@
# Symphony API for Openfin
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Openfin => OpenFin

@@ -0,0 +1,13 @@
# Symphony API for Openfin

This project provides an implementation of the Symphony Desktop Wrapper API Specification for Openfin
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Openfin => OpenFin

@@ -0,0 +1,11 @@
# Symphony API for Openfin Demo
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Openfin has the f capitalised. Please can Openfin be changed to OpenFin?

@@ -0,0 +1,11 @@
# Symphony API for Openfin Demo

This project provides a demonstration of the Symphony Desktop Wrapper API within Openfin.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Openfin => OpenFin

@@ -0,0 +1,13 @@
/* globals fin */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be required in multiple files in the future - can this be added to a .eslintrc.json file at the root of this package, packages/api-openfin/?

{
    "globals": {
        "fin": true
    }
}

window.Notification = function(title, options) {
const message = {
title: title,
options: options
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will these options do anything?

I.e. if I look in our API specification, the options include dir, lang etc. If they don't do anything then I think we can omit them from the object passed to OpenFin and only pass the message, but keep options in our API and we can add support for dir, lang` etc. later.

@@ -0,0 +1,11 @@
<h5 id="message">Message</h5>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming that this page needs to be valid HTML, worth updating to something like this?

<!DOCTYPE html>
<meta charset="utf-8">
<title></title>
<style>
  html {
    border: solid 2px black;
  }
</style>
<h5 id="message"></h5>
<script>
  function onNotificationMessage(message) {
    document.getElementById('message').innerText = message.title;
  }
</script>

Might be worth keeping the h5 empty too, without the text Message?

<h5 id="message"></h5>

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenFin notifications are html pages in their own right, and this is just injected inside the body of that page. I can still change it to be like this (but without the <!DOCTYPE html>) if you prefer?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenFin notifications are html pages in their own right, and this is just injected inside the body of that page.

Are you sure that this is just injected into the body? From the docs and examples it looks like it's the entire HTML page.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

This is the output from the notification box, with extra tags for html, body and head that were not included in the template (This is with the changes you suggested, bar the doctype).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK that's just the way Chrome handles minimal HTML5 documents. It adds in the html, head, body elements in the correct locations.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see - when using dev tools, you're not seeing the original HTML source of the page which has been loaded - it's showing the DOM, the browsers interpretation of the HTML.

The browser will try to add missing elements, correct invalid markup etc. Therefore the original HTML can differ from the DOM shown in the dev tools. I don't OpenFin is injecting the template into the body here, I think it's just the browser.

It's still very minor, as the browser can correct it, but I think it's worth ensuring the HTML is valid, with doctype et. al.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. 👍

@BenLambertNcl BenLambertNcl changed the title Openfin notifications OpenFin Notifications Mar 10, 2017
@BenLambertNcl BenLambertNcl force-pushed the Openfin-Notifications branch 2 times, most recently from 82940cc to 94db671 Compare March 10, 2017 15:12
@jleft jleft merged commit 6f38156 into symphonyoss:master Mar 10, 2017
@BenLambertNcl BenLambertNcl deleted the Openfin-Notifications branch March 10, 2017 15:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants