From 7866a79abd3ddffba3ed3204fcb308e848af8135 Mon Sep 17 00:00:00 2001 From: Martin Schoeler Date: Fri, 24 Mar 2017 13:38:17 -0300 Subject: [PATCH 1/4] convert mapview package to js --- .../rocketchat-mapview/client/mapview.coffee | 26 ---------------- packages/rocketchat-mapview/client/mapview.js | 30 +++++++++++++++++++ packages/rocketchat-mapview/package.js | 5 ++-- .../rocketchat-mapview/server/settings.coffee | 3 -- .../rocketchat-mapview/server/settings.js | 4 +++ 5 files changed, 36 insertions(+), 32 deletions(-) delete mode 100644 packages/rocketchat-mapview/client/mapview.coffee create mode 100644 packages/rocketchat-mapview/client/mapview.js delete mode 100644 packages/rocketchat-mapview/server/settings.coffee create mode 100644 packages/rocketchat-mapview/server/settings.js diff --git a/packages/rocketchat-mapview/client/mapview.coffee b/packages/rocketchat-mapview/client/mapview.coffee deleted file mode 100644 index d7d68179000e..000000000000 --- a/packages/rocketchat-mapview/client/mapview.coffee +++ /dev/null @@ -1,26 +0,0 @@ -### -# MapView is a named function that will replace geolocation in messages with a Google Static Map -# @param {Object} message - The message object -### - -class MapView - constructor: (message) -> - - # get MapView settings - mv_googlekey = RocketChat.settings.get 'MapView_GMapsAPIKey' - - if message.location - - # GeoJSON is reversed - ie. [lng, lat] - longitude = message.location.coordinates[0] - latitude = message.location.coordinates[1] - - # confirm we have an api key set, and generate the html required for the mapview - if mv_googlekey?.length - message.html = '' - else - message.html = ''+TAPi18n.__('Shared_Location')+'' - - return message - -RocketChat.callbacks.add 'renderMessage', MapView, RocketChat.callbacks.priority.HIGH diff --git a/packages/rocketchat-mapview/client/mapview.js b/packages/rocketchat-mapview/client/mapview.js new file mode 100644 index 000000000000..8a4bfa236542 --- /dev/null +++ b/packages/rocketchat-mapview/client/mapview.js @@ -0,0 +1,30 @@ +/* + * MapView is a named function that will replace geolocation in messages with a Google Static Map + * @param {Object} message - The message object + */ + +class MapView { + constructor(message) { + + // get MapView settings + const mv_googlekey = RocketChat.settings.get('MapView_GMapsAPIKey'); + + if (message.location) { + + // GeoJSON is reversed - ie. [lng, lat] + const longitude = message.location.coordinates[0]; + const latitude = message.location.coordinates[1]; + + // confirm we have an api key set, and generate the html required for the mapview + if (mv_googlekey && mv_googlekey.length) { + message.html = ``; + } else { + message.html = `${TAPi18n.__('Shared_Location')}`; + } + } + + return message; + } +} + +RocketChat.callbacks.add('renderMessage', MapView, RocketChat.callbacks.priority.HIGH); diff --git a/packages/rocketchat-mapview/package.js b/packages/rocketchat-mapview/package.js index d91c587ee18f..df453059cc5a 100644 --- a/packages/rocketchat-mapview/package.js +++ b/packages/rocketchat-mapview/package.js @@ -7,12 +7,11 @@ Package.describe({ Package.onUse(function(api) { api.use([ 'ecmascript', - 'coffeescript', 'rocketchat:lib' ]); - api.addFiles('server/settings.coffee', 'server'); + api.addFiles('server/settings.js', 'server'); - api.addFiles('client/mapview.coffee', 'client'); + api.addFiles('client/mapview.js', 'client'); }); diff --git a/packages/rocketchat-mapview/server/settings.coffee b/packages/rocketchat-mapview/server/settings.coffee deleted file mode 100644 index eb7803afa27a..000000000000 --- a/packages/rocketchat-mapview/server/settings.coffee +++ /dev/null @@ -1,3 +0,0 @@ -Meteor.startup -> - RocketChat.settings.add 'MapView_Enabled', false, {type: 'boolean', group: 'Message', section: 'Google Maps', public: true, i18nLabel: 'MapView_Enabled', i18nDescription: 'MapView_Enabled_Description'} - RocketChat.settings.add 'MapView_GMapsAPIKey', '', {type: 'string', group: 'Message', section: 'Google Maps', public: true, i18nLabel: 'MapView_GMapsAPIKey', i18nDescription: 'MapView_GMapsAPIKey_Description'} \ No newline at end of file diff --git a/packages/rocketchat-mapview/server/settings.js b/packages/rocketchat-mapview/server/settings.js new file mode 100644 index 000000000000..7b8c40521b87 --- /dev/null +++ b/packages/rocketchat-mapview/server/settings.js @@ -0,0 +1,4 @@ +Meteor.startup(function() { + RocketChat.settings.add('MapView_Enabled', false, {type: 'boolean', group: 'Message', section: 'Google Maps', public: true, i18nLabel: 'MapView_Enabled', i18nDescription: 'MapView_Enabled_Description'}); + return RocketChat.settings.add('MapView_GMapsAPIKey', '', {type: 'string', group: 'Message', section: 'Google Maps', public: true, i18nLabel: 'MapView_GMapsAPIKey', i18nDescription: 'MapView_GMapsAPIKey_Description'}); +}); From 3a2939d7d39da5f235484c8756ef7c330e7b7514 Mon Sep 17 00:00:00 2001 From: Martin Schoeler Date: Fri, 24 Mar 2017 14:25:47 -0300 Subject: [PATCH 2/4] fix call class as a function --- packages/rocketchat-mapview/client/mapview.js | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/packages/rocketchat-mapview/client/mapview.js b/packages/rocketchat-mapview/client/mapview.js index 8a4bfa236542..181f0c225001 100644 --- a/packages/rocketchat-mapview/client/mapview.js +++ b/packages/rocketchat-mapview/client/mapview.js @@ -3,28 +3,27 @@ * @param {Object} message - The message object */ -class MapView { - constructor(message) { + +function MapView(message) { // get MapView settings - const mv_googlekey = RocketChat.settings.get('MapView_GMapsAPIKey'); + const mv_googlekey = RocketChat.settings.get('MapView_GMapsAPIKey'); - if (message.location) { + if (message.location) { // GeoJSON is reversed - ie. [lng, lat] - const longitude = message.location.coordinates[0]; - const latitude = message.location.coordinates[1]; + const longitude = message.location.coordinates[0]; + const latitude = message.location.coordinates[1]; // confirm we have an api key set, and generate the html required for the mapview - if (mv_googlekey && mv_googlekey.length) { - message.html = ``; - } else { - message.html = `${TAPi18n.__('Shared_Location')}`; - } + if (mv_googlekey && mv_googlekey.length) { + message.html = ``; + } else { + message.html = `${TAPi18n.__('Shared_Location')}`; } - - return message; } + + return message; } RocketChat.callbacks.add('renderMessage', MapView, RocketChat.callbacks.priority.HIGH); From 597b60e13fb5f506ec9d0fd5487be1eb3e57206b Mon Sep 17 00:00:00 2001 From: Martin Schoeler Date: Mon, 27 Mar 2017 10:24:28 -0300 Subject: [PATCH 3/4] fix eslint --- packages/rocketchat-mapview/client/mapview.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/rocketchat-mapview/client/mapview.js b/packages/rocketchat-mapview/client/mapview.js index 181f0c225001..37be854a4613 100644 --- a/packages/rocketchat-mapview/client/mapview.js +++ b/packages/rocketchat-mapview/client/mapview.js @@ -3,7 +3,6 @@ * @param {Object} message - The message object */ - function MapView(message) { // get MapView settings @@ -17,9 +16,9 @@ function MapView(message) { // confirm we have an api key set, and generate the html required for the mapview if (mv_googlekey && mv_googlekey.length) { - message.html = ``; + message.html = ``; } else { - message.html = `${TAPi18n.__('Shared_Location')}`; + message.html = `${ TAPi18n.__('Shared_Location') }`; } } From 09f3283a1cb00d68cdccd4b830fc1df86a2733cd Mon Sep 17 00:00:00 2001 From: Martin Schoeler Date: Tue, 28 Mar 2017 10:18:44 -0300 Subject: [PATCH 4/4] Update mapview.js --- packages/rocketchat-mapview/client/mapview.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/rocketchat-mapview/client/mapview.js b/packages/rocketchat-mapview/client/mapview.js index 37be854a4613..fefce23a8387 100644 --- a/packages/rocketchat-mapview/client/mapview.js +++ b/packages/rocketchat-mapview/client/mapview.js @@ -11,8 +11,7 @@ function MapView(message) { if (message.location) { // GeoJSON is reversed - ie. [lng, lat] - const longitude = message.location.coordinates[0]; - const latitude = message.location.coordinates[1]; + const [longitude, latitude] = message.location.coordinates; // confirm we have an api key set, and generate the html required for the mapview if (mv_googlekey && mv_googlekey.length) {