From f30b0fb57a2637701e961ad8cbc3779ffce00029 Mon Sep 17 00:00:00 2001 From: Pierre ROTH Date: Thu, 28 Apr 2016 10:40:28 +0200 Subject: [PATCH] Add button to restore PubNub default settings --- app/js/views/settings_view.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/js/views/settings_view.js b/app/js/views/settings_view.js index 40e3847..ecf1de5 100644 --- a/app/js/views/settings_view.js +++ b/app/js/views/settings_view.js @@ -1,11 +1,14 @@ import { SettingsStorageAPI } from '../lib/storage'; +import * as PNSettings from '../constants/pubnub_const.js'; + export class SettingsView extends Backbone.View { constructor(options) { super(options); this.events = { 'click #save-settings': 'saveSettings', + 'click #restore-default-settings': 'restoreDefaultSettings' }; this.setElement('#settings-popup'); this.api = new SettingsStorageAPI('pubnub'); @@ -60,6 +63,7 @@ export class SettingsView extends Backbone.View { @@ -73,6 +77,17 @@ export class SettingsView extends Backbone.View { const downStreamChannel = $('#pubnub-downstream-channel').val(); const subscribeKey = $('#pubnub-subscribe-key').val(); const publishKey = $('#pubnub-publish-key').val(); + this.storeSettings(upStreamChannel, downStreamChannel, subscribeKey, publishKey); + } + + restoreDefaultSettings() { + this.storeSettings(PNSettings.PUBNUB_DEFAULT_UPSTREAM_CHANNEL, + PNSettings.PUBNUB_DEFAULT_DOWNSTREAM_CHANNEL, + PNSettings.PUBNUB_DEFAULT_SUBSCRIBE_KEY, + PNSettings.PUBNUB_DEFAULT_PUBLISH_KEY); + } + + storeSettings(upStreamChannel, downStreamChannel, subscribeKey, publishKey) { this.api.store({ upStreamChannel, downStreamChannel, subscribeKey, publishKey }); Backbone.Mediator.publish('settings:new'); $('#pubnub-setttings').modal('hide');