From fc2b254e2fedb3ba5c2c47eef35f6506563dfbd7 Mon Sep 17 00:00:00 2001 From: paulteyssier Date: Thu, 24 Aug 2017 16:16:54 -0700 Subject: [PATCH 1/5] Language updates --- README.md | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index d1f069d..b7b86df 100644 --- a/README.md +++ b/README.md @@ -41,17 +41,23 @@ titled "Hello." Click on this to open the app in the Symphony grid. Explore the The Hello World app subscribes to the ‘entity’ Service of the Extension API, which allows the application to render Structured Objects. To use the service to render your own Structured Objects, you’ll need to send either a JCurl or Postman POST messagev4 to a room in the pod where you’ll be running the application. Here is an example of a REST payload that can be used to send a custom entity that will be rendered by the app: +message: +``` + +
+ [Object Presentation: Please install the Hello World application to render this entity.] +
+
+ +``` +data: ``` { -     message: "
Please install the Hello World application to - render this entity.
" -     data: { -         "timer": { -             "type": "com.symphony.timer", - "version": "1.0" - } - } -} + "timer": { + "type": "com.symphony.timer", + "version": "1.0" + } +} ``` When the message is sent, the default rendering will be “Please install the Hello World application to render this entity.” However, the following function tells the message controller render method to look for messages containing a Structured Object of the type ‘com.symphony.timer’: From f2a9a3dab6166cc593afec325d8c1beef6c60ffd Mon Sep 17 00:00:00 2001 From: brybailey Date: Fri, 25 Aug 2017 10:55:44 -0700 Subject: [PATCH 2/5] leading 0 and bold numbers --- README.md | 1 + src/javascript/controller.js | 70 +++++++++++++++++++----------------- 2 files changed, 38 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 80568c9..53ba7bd 100644 --- a/README.md +++ b/README.md @@ -36,3 +36,4 @@ and in turn your application can listen and react to click events on those butto You've successfully installed the Hello World application. You'll notice a new entry on the left nav titled "Hello." Click on this to open the app in the Symphony grid. Explore the source code in `src/javascript` to understand how the application works. + diff --git a/src/javascript/controller.js b/src/javascript/controller.js index bfa2e58..f678339 100644 --- a/src/javascript/controller.js +++ b/src/javascript/controller.js @@ -1,21 +1,21 @@ /** -* Licensed to the Symphony Software Foundation (SSF) under one -* or more contributor license agreements. See the NOTICE file -* distributed with this work for additional information -* regarding copyright ownership. The SSF licenses this file -* to you under the Apache License, Version 2.0 (the -* "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -**/ + * Licensed to the Symphony Software Foundation (SSF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The SSF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + **/ // Create our own local controller service. // We have namespaced local services with "hello:" @@ -153,13 +153,17 @@ SYMPHONY.remote.hello().then(function(data) { days-=yrs*365; hrs-=((yrs*365*24)+(days*24)); var diff = { - sec : sec, - min : min, - hrs : hrs, - days : days, - yrs : yrs - }; - return diff; + sec : this.pad(sec), + min : this.pad(min), + hrs : this.pad(hrs), + days : this.pad(days), + yrs : this.pad(yrs) + }; + return diff; + }, + + pad: function(n) { + return (n<10) ? ("0" + n) : n; }, // Track each entity indexed by its instance id @@ -169,8 +173,8 @@ SYMPHONY.remote.hello().then(function(data) { // Rerender a tracked entity every 'tick' tick: function(instanceId) { - entity = this.tracked[instanceId]; - this.rerender(entity); + entity = this.tracked[instanceId]; + this.rerender(entity); }, // Use the entity data to update the rendering of the message through the entity service @@ -195,7 +199,7 @@ SYMPHONY.remote.hello().then(function(data) { if(version == "1.0") { return this.getTimeData(entityData); - // Dynamic rendering + // Dynamic rendering } else if (version == "2.0") { // Track each entity setTimeout(function () { @@ -227,10 +231,10 @@ SYMPHONY.remote.hello().then(function(data) { template = `
The time from the initial rendering at is - years, - days, - minutes, and - seconds
+ years, + days, + minutes, and + seconds,
` } @@ -243,8 +247,8 @@ SYMPHONY.remote.hello().then(function(data) { hrs: "" + diff.hrs, min: "" + diff.min, sec: "" + diff.sec, - timeAtRender: renderTime.toLocaleTimeString() + " on " + renderTime.toLocaleDateString() - } + timeAtRender: renderTime.toLocaleTimeString() + " on " + renderTime.toLocaleDateString()}, + entityInstanceId: entityData.instanceId } } }); From 528758ebb15019164574c535fd37b685401eaba0 Mon Sep 17 00:00:00 2001 From: Bryan Bailey Date: Fri, 25 Aug 2017 12:12:52 -0700 Subject: [PATCH 3/5] Update README.md --- README.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0e11e02..25ded9e 100644 --- a/README.md +++ b/README.md @@ -37,11 +37,9 @@ You've successfully installed the Hello World application. You'll notice a new e titled "Hello." Click on this to open the app in the Symphony grid. Explore the source code in `src/javascript` to understand how the application works. -<<<<<<< HEAD -======= ## A note on entity renderers -The Hello World app subscribes to the ‘entity’ Service of the Extension API, which allows the application to render Structured Objects. To use the service to render your own Structured Objects, you’ll need to send either a JCurl or Postman POST messagev4 to a room in the pod where you’ll be running the application. Here is an example of a REST payload that can be used to send a custom entity that will be rendered by the app: +The Hello World app subscribes to the ‘entity’ Service of the Extension API, which allows the application to render Structured Objects. To use the service to render your own Structured Objects, you’ll need to send either a JCurl or Postman POST messagev4 to a room in the pod where you’ll be running the application. Here is an example of a REST payload that can be used to send a custom entity that will be rendered by the app (Note: payload 'Content-Type' must be of type 'form-data'): message: ``` @@ -57,16 +55,14 @@ data: { "timer": { "type": "com.symphony.timer", - "version": "1.0" + "version": "1.0", + "date": "01/01/2050" } } ``` -When the message is sent, the default rendering will be “Please install the Hello World application to render this entity.” However, the following function tells the message controller render method to look for messages containing a Structured Object of the type ‘com.symphony.timer’: +Version "1.0" executes the static renderer, while version "2.0" executes the dynamic renderer. When the message is sent, the default rendering will be “Please install the Hello World application to render this entity.” However, the following function tells the message controller render method to look for messages containing a Structured Object of the type ‘com.symphony.timer’: `entityService.registerRenderer( "com.symphony.timer",{}, "message:controller");` When the app is running, that default rendering will be superseded by the custom template in controller.js. For more information about the message format for Structured Objects, see https://rest-api.symphony.com/docs/objects#sending-structured-objects-in-messages. - - ->>>>>>> bda42a05d84cea8601171d83c29263b2d5dc1751 From 2b71c3873fb6be2a9488f7ff5f24f6046379ca11 Mon Sep 17 00:00:00 2001 From: brybailey Date: Fri, 25 Aug 2017 16:26:54 -0700 Subject: [PATCH 4/5] countdown to emoji day --- src/javascript/controller.js | 41 ++++++++++++------------------------ 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/src/javascript/controller.js b/src/javascript/controller.js index f678339..8fa5d29 100644 --- a/src/javascript/controller.js +++ b/src/javascript/controller.js @@ -141,8 +141,8 @@ SYMPHONY.remote.hello().then(function(data) { messageControllerService.implement({ // Calculate how much time has passed since the entity's initial render - calculateDifference: function(initial, current) { - var ms = current-initial; + calculateDifference: function(countdown, current) { + var ms = countdown-current; var hrs = Math.floor(ms/1000/60/60); ms -= hrs * 1000 * 60 * 60; var min = Math.floor(ms/1000/60); @@ -181,7 +181,6 @@ SYMPHONY.remote.hello().then(function(data) { rerender: function(tracked) { var entityData = tracked.entityData; var timeData = this.getTimeData(entityData); - return entityService.update(timeData.entityInstanceId, timeData.template, timeData.data); }, @@ -192,9 +191,6 @@ SYMPHONY.remote.hello().then(function(data) { // Consider how to translate uuids as list indexing for more robust id marking var instanceId = Math.floor(Math.random()*1000000); entityData.instanceId = instanceId; - var renderTime = new Date(); - entityData.renderTime = renderTime; - // Static rendering if(version == "1.0") { return this.getTimeData(entityData); @@ -217,27 +213,17 @@ SYMPHONY.remote.hello().then(function(data) { // Render the template using the current timestamp and the specified date from entity data getTimeData: function(entityData) { - var renderTime = entityData.renderTime; var current = new Date(); - var diff = this.calculateDifference(renderTime, current); - var template; - if( entityData.version === "1.0" ) { - template = ` - -
The time at the initial rendering was
-
+ var diff = this.calculateDifference(new Date(2067, 6, 27), current); + var template = ` +
The time until is + years, + days, + hours, + minutes, and + seconds +
` - } else if( entityData.version === "2.0" ) { - template = ` - -
The time from the initial rendering at is - years, - days, - minutes, and - seconds,
-
-
` - } return { // Use a custom template to utilise data sent with the message in entityData in our messageML message template: template, @@ -247,8 +233,9 @@ SYMPHONY.remote.hello().then(function(data) { hrs: "" + diff.hrs, min: "" + diff.min, sec: "" + diff.sec, - timeAtRender: renderTime.toLocaleTimeString() + " on " + renderTime.toLocaleDateString()}, - entityInstanceId: entityData.instanceId + countdownString: entityData.countdownString + }, + entityInstanceId: entityData.instanceId } } }); From 3b3b43e5851281c3d079ed2bdebdaaee2a65e009 Mon Sep 17 00:00:00 2001 From: Bryan Bailey Date: Fri, 25 Aug 2017 16:30:01 -0700 Subject: [PATCH 5/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 25ded9e..912c4a8 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ data: "timer": { "type": "com.symphony.timer", "version": "1.0", - "date": "01/01/2050" + "countdownString": "July 27, 2067" } } ```