From d45f2d5438251b0d5c77f863afc1d12bde07e43b Mon Sep 17 00:00:00 2001 From: Jonathan Pevarnek Date: Wed, 6 May 2015 12:01:54 -0400 Subject: [PATCH 01/24] Make user.isOnline public This makes it possible for other files to check whether a given user is online at the moment. The change is relatively unimportant but will be used later. --- src/generic_ui/scripts/user.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/generic_ui/scripts/user.ts b/src/generic_ui/scripts/user.ts index 7d61aebdb7..d641808a49 100644 --- a/src/generic_ui/scripts/user.ts +++ b/src/generic_ui/scripts/user.ts @@ -50,7 +50,7 @@ export class User implements social.BaseUser { public sharingConsentState :SharingConsentState = SharingConsentState.NO_OFFER_OR_REQUEST; - private isOnline_ :boolean = false; + public isOnline :boolean = false; /** * Initialize the user to an 'empty' default. @@ -127,7 +127,7 @@ export class User implements social.BaseUser { this.allInstanceIds = payload.allInstanceIds; this.updateInstanceDescriptions(); this.consent_ = payload.consent; - this.isOnline_ = payload.isOnline; + this.isOnline = payload.isOnline; // Update gettingConsentState, used to display correct getting buttons. if (this.offeringInstances.length > 0) { @@ -223,7 +223,7 @@ export class User implements social.BaseUser { } // Convert booleans into strings. - var isOnlineString = this.isOnline_ ? 'online' : 'offline'; + var isOnlineString = this.isOnline ? 'online' : 'offline'; var gettingTrustString = 'UntrustedUproxy'; if (isPendingForGetting) { gettingTrustString = 'Pending'; From fb4a8799d4b486e2273535305a96626f0d4dcc9e Mon Sep 17 00:00:00 2001 From: Jonathan Pevarnek Date: Wed, 6 May 2015 12:02:54 -0400 Subject: [PATCH 02/24] Sort contacts based on whether getting/giving access to them On the buddy list, we want to sort contacts based on whether or not we are getting or giving access to them, with those we are at the top of the list. In order to accomplish this, we make a few changes. First of all, for the actual sorting, this will look for changes on any of the contacts we have and re-do the sort. The actual sort is done by concatenating onilne and offline contacts and then sorting on whether we are getting and sharing with the contact followed by the online status. In order to check for getting/sharing, we needed to have a way to know what tab was being used. Historically, we have relied on which tab the user was currently on to determine what to do, however, this would cause us to re-sort the contacts every time the user switches tabs; completely unnecessary considering they live separate from each other. To get around this, we now pass the mode that the roster is on down so that we are able to determine the actual sort order that should be used for a specific roster-group. Because of the way polymer watchers work, there is unfortunately no way to watch for properties of objects in an array changing. In order to get around this, we have the uproxy-contact Polymer element fire a contact-changed event whenever any of the fields we care about change. Fixes #1308 --- src/generic_ui/polymer/contact.ts | 10 ++++++++ src/generic_ui/polymer/root.html | 6 +++-- src/generic_ui/polymer/roster-group.html | 14 ++++-------- src/generic_ui/polymer/roster-group.ts | 29 +++++++++++++++++++++++- src/generic_ui/polymer/roster.html | 14 +++++++----- 5 files changed, 54 insertions(+), 19 deletions(-) diff --git a/src/generic_ui/polymer/contact.ts b/src/generic_ui/polymer/contact.ts index 7fc11ee42e..1549713a25 100644 --- a/src/generic_ui/polymer/contact.ts +++ b/src/generic_ui/polymer/contact.ts @@ -65,4 +65,14 @@ Polymer({ hasInstance: function(instanceId :string) { return instanceId && _.contains(this.contact.allInstanceIds, instanceId); }, + fireChanged: function() { + // this is needed as a slight hack since the observer on the contacts array + // a level up does not pick up on changes in contact properties + this.fire('contact-changed'); + }, + observe: { + 'contact.isSharingWithMe': 'fireChanged', + 'contact.isGettingFromMe': 'fireChanged', + 'contact.isOnline': 'fireChanged', + }, }); diff --git a/src/generic_ui/polymer/root.html b/src/generic_ui/polymer/root.html index 2a81dcf99f..4992eef6b7 100644 --- a/src/generic_ui/polymer/root.html +++ b/src/generic_ui/polymer/root.html @@ -286,11 +286,13 @@

Welcome to uProxy!

+ contacts='{{model.contacts.getAccessContacts}}' + mode='{{ui_constants.Mode.GET}}'> + contacts='{{model.contacts.shareAccessContacts}}' + mode='{{ui_constants.Mode.SHARE}}'>
diff --git a/src/generic_ui/polymer/roster-group.html b/src/generic_ui/polymer/roster-group.html index ad92f23063..95dfc1dc51 100644 --- a/src/generic_ui/polymer/roster-group.html +++ b/src/generic_ui/polymer/roster-group.html @@ -2,7 +2,7 @@ + attributes='onlineContacts, offlineContacts, groupTitle, searchQuery, mode'> diff --git a/src/generic_ui/polymer/settings.html b/src/generic_ui/polymer/settings.html index b664529669..50f670f664 100644 --- a/src/generic_ui/polymer/settings.html +++ b/src/generic_ui/polymer/settings.html @@ -1,5 +1,4 @@ - @@ -111,21 +110,6 @@ #metricsCheckbox paper-checkbox, uproxy-faq-link { display: table-cell; } - #advancedSettingsDecorator { - height: 190px; - } - #advancedSettingsPaperTextarea { - height: 190px; - margin: 0em; - } - paper-autogrow-textarea::shadow .textarea-container { - padding: 0.25em; - background-color: rgb(240,240,240); - } - paper-autogrow-textarea::shadow .mirror-text { - white-space: pre-wrap; /* css-3 */ - white-space: -moz-pre-wrap; /* Mozilla, since 1999 */ - } #settingsLinks core-icon { height: 20px; width: 20px; diff --git a/src/generic_ui/polymer/settings.ts b/src/generic_ui/polymer/settings.ts index c222d289b2..50d3c648d8 100644 --- a/src/generic_ui/polymer/settings.ts +++ b/src/generic_ui/polymer/settings.ts @@ -5,8 +5,6 @@ var core = ui_context.core; var model = ui_context.model; Polymer({ - displayAdvancedSettings: false, - advancedSettings: JSON.stringify(model.globalSettings, null, ' '), logOut: function() { ui.logout({name: model.onlineNetwork.name, userId: model.onlineNetwork.userId}).then(() => { diff --git a/src/generic_ui/scripts/ui.ts b/src/generic_ui/scripts/ui.ts index 3f705b4898..27e5f3a234 100644 --- a/src/generic_ui/scripts/ui.ts +++ b/src/generic_ui/scripts/ui.ts @@ -40,6 +40,8 @@ export var model :Model = { offlineUntrustedUproxy: [] } }, + // It would be nice to initialize this in shared code, but these settings + // will be overwritten by a message from the core. globalSettings: { version: 0, description: '', @@ -49,7 +51,6 @@ export var model :Model = { mode : ui_constants.Mode.GET, allowNonUnicast: false, statsReportingEnabled: false, - // TODO: Reviewer, can we initialize this and globals in one place? consoleFilter: 2 // loggingTypes.Level.warn }, reconnecting: false From e204eae1bd11209eb299395dcba8541d45feb39a Mon Sep 17 00:00:00 2001 From: John Sarapata Date: Tue, 12 May 2015 15:36:05 -0400 Subject: [PATCH 08/24] Final polishing before pull request. --- src/generic_ui/polymer/advanced-settings.html | 8 ++++---- src/generic_ui/polymer/advanced-settings.ts | 5 ++++- src/generic_ui/scripts/ui.ts | 1 - 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/generic_ui/polymer/advanced-settings.html b/src/generic_ui/polymer/advanced-settings.html index 3ad2bd9b50..d64d57740f 100644 --- a/src/generic_ui/polymer/advanced-settings.html +++ b/src/generic_ui/polymer/advanced-settings.html @@ -97,7 +97,7 @@ - +
@@ -106,9 +106,9 @@

Edit your settings below

- - - diff --git a/src/generic_ui/polymer/advanced-settings.ts b/src/generic_ui/polymer/advanced-settings.ts index 9fc52b1e93..e9faa7bb1d 100644 --- a/src/generic_ui/polymer/advanced-settings.ts +++ b/src/generic_ui/polymer/advanced-settings.ts @@ -7,15 +7,18 @@ Polymer({ }, open: function(e :Event, detail :{ includeLogs: boolean }) { this.settings = JSON.stringify(ui_context.model.globalSettings, null, ' '); + this.$.failedSetAdvancedSettings.hidden = true; + this.$.confirmSetAdvancedSettings.hidden = true; this.$.advancedSettingsPanel.open(); }, setAdvancedSettings: function() { try { - ui_context.model.globalSettings = JSON.parse(this.settings); + ui_context.model.globalSettings = JSON.parse(this.settings); } catch (e) { this.$.failedSetAdvancedSettings.hidden = false; this.$.confirmSetAdvancedSettings.hidden = true; + return; } ui_context.core.updateGlobalSettings(ui_context.model.globalSettings); diff --git a/src/generic_ui/scripts/ui.ts b/src/generic_ui/scripts/ui.ts index 27e5f3a234..6e85cbcef2 100644 --- a/src/generic_ui/scripts/ui.ts +++ b/src/generic_ui/scripts/ui.ts @@ -10,7 +10,6 @@ import Persistent = require('../../interfaces/persistent'); import CoreConnector = require('./core_connector'); import uproxy_core_api = require('../../interfaces/uproxy_core_api'); import browser_api = require('../../interfaces/browser_api'); -// import loggingTypes = require('../../../third_party/uproxy-lib/loggingprovider/loggingprovider.types'); import BrowserAPI = browser_api.BrowserAPI; import net = require('../../../../third_party/uproxy-lib/net/net.types'); import noreConnector = require('./core_connector'); From ce3bcdb6caa68c6026e7958fd01b162cd959859b Mon Sep 17 00:00:00 2001 From: John Sarapata Date: Thu, 14 May 2015 11:51:48 -0400 Subject: [PATCH 09/24] Responding to pull request comments. --- src/generic_ui/polymer/advanced-settings.html | 14 ++-- src/generic_ui/polymer/advanced-settings.ts | 72 +++++++++++++++---- 2 files changed, 69 insertions(+), 17 deletions(-) diff --git a/src/generic_ui/polymer/advanced-settings.html b/src/generic_ui/polymer/advanced-settings.html index d64d57740f..03025ef8ce 100644 --- a/src/generic_ui/polymer/advanced-settings.html +++ b/src/generic_ui/polymer/advanced-settings.html @@ -7,7 +7,7 @@ - +