From d1a09c018049db021036a6ef7f54b60883c7da05 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 29 May 2015 14:51:16 -0700 Subject: [PATCH 01/26] [Telemetry] Remove linear search Remove linear search for unused positions when queuing telemetry updates; instead, track available positions such that insertion is more performant at a modest cost (bound to the number of subscriptions) of retrieval. Additionally, add implementation notes in-line. WTD-1202. --- platform/telemetry/src/TelemetryQueue.js | 60 ++++++++++++++++++++---- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/platform/telemetry/src/TelemetryQueue.js b/platform/telemetry/src/TelemetryQueue.js index bd463b61be..cf82d08ff8 100644 --- a/platform/telemetry/src/TelemetryQueue.js +++ b/platform/telemetry/src/TelemetryQueue.js @@ -35,28 +35,68 @@ define( * @constructor */ function TelemetryQueue() { - var queue = []; + // General approach here: + // * Maintain a queue as an array of objects containing key-value + // pairs. Putting values into the queue will assign to the + // earliest-available queue position for the associated key + // (appending to the array if necessary.) + // * Maintain a set of counts for each key, such that determining + // the next available queue position is easy; O(1) insertion. + // * When retrieving objects, pop off the queue and decrement + // counts. This provides O(n+k) or O(k) retrieval for a queue + // of length n with k unique keys; this depends on whether + // the browser's implementation of Array.prototype.shift is + // O(n) or O(1). + + // Graphically (indexes at top, keys along side, values as *'s), + // if we have a queue that looks like: + // 0 1 2 3 4 + // a * * * * * + // b * * + // c * * * + // + // And we put a new value for b, we expect: + // 0 1 2 3 4 + // a * * * * * + // b * * * + // c * * * + var queue = [], + counts = {}; // Look up an object in the queue that does not have a value // assigned to this key (or, add a new one) function getFreeObject(key) { - var index = 0, object; + var index = counts[key] || 0, object; - // Look for an existing queue position where we can store - // a value to this key without overwriting an existing value. - for (index = 0; index < queue.length; index += 1) { - if (queue[index][key] === undefined) { - return queue[index]; - } + // Track the largest free position for this key + counts[key] = index + 1; + + // If it's before the end of the queue, add it there + if (index < queue.length) { + return queue[index]; } - // If we made it through the loop, values have been assigned + // Otherwise, values have been assigned // to that key in all queued containers, so we need to queue // up a new container for key-value pairs. object = {}; queue.push(object); return object; } + + // Decrement counts for a specific key + function decrementCount(key) { + if (counts[key] < 2) { + delete counts[key]; + } else { + counts[key] -= 1; + } + } + + // Decrement all counts + function decrementCounts() { + Object.keys(counts).forEach(decrementCount); + } return { /** @@ -74,6 +114,8 @@ define( * @return {object} key-value pairs */ poll: function () { + // Decrement counts for the object that will be popped + decrementCounts(); return queue.shift(); }, /** From e06d11dcb2c2c10c2be4446f2875846f20d3f64d Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 29 May 2015 15:50:30 -0700 Subject: [PATCH 02/26] [Core] Add throttle service Add service for throttling function calls; specifically supports reducing tick mark recalculation, WTD-1202. --- platform/core/bundle.json | 5 ++ platform/core/src/services/Throttle.js | 63 +++++++++++++++++++++ platform/core/test/services/ThrottleSpec.js | 49 ++++++++++++++++ platform/core/test/suite.json | 1 + 4 files changed, 118 insertions(+) create mode 100644 platform/core/src/services/Throttle.js create mode 100644 platform/core/test/services/ThrottleSpec.js diff --git a/platform/core/bundle.json b/platform/core/bundle.json index 5a2727eb75..3f7376f3f3 100644 --- a/platform/core/bundle.json +++ b/platform/core/bundle.json @@ -180,6 +180,11 @@ { "key": "now", "implementation": "services/Now.js" + }, + { + "key": "throttle", + "implementation": "services/Throttle.js", + "depends": [ "$timeout" ] } ], "roots": [ diff --git a/platform/core/src/services/Throttle.js b/platform/core/src/services/Throttle.js new file mode 100644 index 0000000000..619f53161e --- /dev/null +++ b/platform/core/src/services/Throttle.js @@ -0,0 +1,63 @@ +/*global define*/ + +define( + [], + function () { + "use strict"; + + /** + * Throttler for function executions, registered as the `throttle` + * service. + * + * Usage: + * + * throttle(fn, delay, [apply]) + * + * Returns a function that, when invoked, will invoke `fn` after + * `delay` milliseconds, only if no other invocations are pending. + * The optional argument `apply` determines whether. + * + * The returned function will itself return a `Promise` which will + * resolve to the returned value of `fn` whenever that is invoked. + * + * @returns {Function} + */ + function Throttle($timeout) { + /** + * Throttle this function. + * @param {Function} fn the function to throttle + * @param {number} [delay] the delay, in milliseconds, before + * executing this function; defaults to 0. + * @param {boolean} apply true if a `$apply` call should be + * invoked after this function executes; defaults to + * `false`. + */ + return function (fn, delay, apply) { + var activeTimeout; + + // Clear active timeout, so that next invocation starts + // a new one. + function clearActiveTimeout() { + activeTimeout = undefined; + } + + // Defaults + delay = delay || 0; + apply = apply || false; + + return function () { + // Start a timeout if needed + if (!activeTimeout) { + activeTimeout = $timeout(fn, delay, apply); + activeTimeout.then(clearActiveTimeout); + } + // Return whichever timeout is active (to get + // a promise for the results of fn) + return activeTimeout; + }; + }; + } + + return Throttle; + } +); \ No newline at end of file diff --git a/platform/core/test/services/ThrottleSpec.js b/platform/core/test/services/ThrottleSpec.js new file mode 100644 index 0000000000..ccd6644eb7 --- /dev/null +++ b/platform/core/test/services/ThrottleSpec.js @@ -0,0 +1,49 @@ +/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ + +define( + ["../../src/services/Throttle"], + function (Throttle) { + "use strict"; + + describe("The 'throttle' service", function () { + var throttle, + mockTimeout, + mockFn, + mockPromise; + + beforeEach(function () { + mockTimeout = jasmine.createSpy("$timeout"); + mockPromise = jasmine.createSpyObj("promise", ["then"]); + mockFn = jasmine.createSpy("fn"); + mockTimeout.andReturn(mockPromise); + throttle = new Throttle(mockTimeout); + }); + + it("provides functions which run on a timeout", function () { + var throttled = throttle(mockFn); + // Verify precondition: Not called at throttle-time + expect(mockTimeout).not.toHaveBeenCalled(); + expect(throttled()).toEqual(mockPromise); + expect(mockTimeout).toHaveBeenCalledWith(mockFn, 0, false); + }); + + it("schedules only one timeout at a time", function () { + var throttled = throttle(mockFn); + throttled(); + throttled(); + throttled(); + expect(mockTimeout.calls.length).toEqual(1); + }); + + it("schedules additional invocations after resolution", function () { + var throttled = throttle(mockFn); + throttled(); + mockPromise.then.mostRecentCall.args[0](); // Resolve timeout + throttled(); + mockPromise.then.mostRecentCall.args[0](); + throttled(); + expect(mockTimeout.calls.length).toEqual(3); + }); + }); + } +); \ No newline at end of file diff --git a/platform/core/test/suite.json b/platform/core/test/suite.json index 36f3e81980..5fd8f97810 100644 --- a/platform/core/test/suite.json +++ b/platform/core/test/suite.json @@ -23,6 +23,7 @@ "objects/DomainObjectProvider", "services/Now", + "services/Throttle", "types/MergeModels", "types/TypeCapability", From 35b5fbefd0801a3dd0d77e012ebc599ca2d70738 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 29 May 2015 16:35:14 -0700 Subject: [PATCH 03/26] [Plot] Throttle updates Throttle plot updates to subplots; WTD-1202. --- platform/features/plot/bundle.json | 2 +- platform/features/plot/src/PlotController.js | 13 +++++++++---- platform/features/plot/src/modes/PlotOverlayMode.js | 2 -- platform/features/plot/src/modes/PlotStackMode.js | 2 -- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/platform/features/plot/bundle.json b/platform/features/plot/bundle.json index ab8cf89b7c..21d98cc4e7 100644 --- a/platform/features/plot/bundle.json +++ b/platform/features/plot/bundle.json @@ -22,7 +22,7 @@ { "key": "PlotController", "implementation": "PlotController.js", - "depends": [ "$scope", "telemetryFormatter", "telemetryHandler" ] + "depends": [ "$scope", "telemetryFormatter", "telemetryHandler", "throttle" ] } ] } diff --git a/platform/features/plot/src/PlotController.js b/platform/features/plot/src/PlotController.js index 0f06ddccb4..fcce051968 100644 --- a/platform/features/plot/src/PlotController.js +++ b/platform/features/plot/src/PlotController.js @@ -51,13 +51,14 @@ define( * * @constructor */ - function PlotController($scope, telemetryFormatter, telemetryHandler) { + function PlotController($scope, telemetryFormatter, telemetryHandler, throttle) { var subPlotFactory = new SubPlotFactory(telemetryFormatter), modeOptions = new PlotModeOptions([], subPlotFactory), subplots = [], cachedObjects = [], updater, handle, + scheduleUpdate, domainOffset; // Populate the scope with axis information (specifically, options @@ -89,9 +90,7 @@ define( // Update all sub-plots function update() { - modeOptions.getModeHandler() - .getSubPlots() - .forEach(updateSubplot); + scheduleUpdate(); } // Reinstantiate the plot updater (e.g. because we have a @@ -162,6 +161,12 @@ define( // Unsubscribe when the plot is destroyed $scope.$on("$destroy", releaseSubscription); + + // Create a throttled update function + scheduleUpdate = throttle(function () { + modeOptions.getModeHandler().getSubPlots() + .forEach(updateSubplot); + }); return { /** diff --git a/platform/features/plot/src/modes/PlotOverlayMode.js b/platform/features/plot/src/modes/PlotOverlayMode.js index ec32f2300d..501d4b0e78 100644 --- a/platform/features/plot/src/modes/PlotOverlayMode.js +++ b/platform/features/plot/src/modes/PlotOverlayMode.js @@ -62,8 +62,6 @@ define( points: buf.getLength() }; }); - - subplot.update(); } return { diff --git a/platform/features/plot/src/modes/PlotStackMode.js b/platform/features/plot/src/modes/PlotStackMode.js index 4b6c5cbbb9..5d54b461f1 100644 --- a/platform/features/plot/src/modes/PlotStackMode.js +++ b/platform/features/plot/src/modes/PlotStackMode.js @@ -58,8 +58,6 @@ define( color: PlotPalette.getFloatColor(0), points: buffer.getLength() }]; - - subplot.update(); } function plotTelemetry(prepared) { From 500d88b5a195691f5bae2bfcb9f8558844f590ca Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 10 Jun 2015 17:02:16 -0700 Subject: [PATCH 04/26] [Plot] Update spec Update spec for PlotController to account for usage of the throttle service, WTD-1202. --- platform/features/plot/test/PlotControllerSpec.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/platform/features/plot/test/PlotControllerSpec.js b/platform/features/plot/test/PlotControllerSpec.js index 1cd4b43331..138071d339 100644 --- a/platform/features/plot/test/PlotControllerSpec.js +++ b/platform/features/plot/test/PlotControllerSpec.js @@ -33,6 +33,7 @@ define( var mockScope, mockFormatter, mockHandler, + mockThrottle, mockHandle, mockDomainObject, mockSeries, @@ -56,6 +57,7 @@ define( "telemetrySubscriber", ["handle"] ); + mockThrottle = jasmine.createSpy("throttle"); mockHandle = jasmine.createSpyObj( "subscription", [ @@ -73,12 +75,18 @@ define( ); mockHandler.handle.andReturn(mockHandle); + mockThrottle.andCallFake(function (fn) { return fn; }); mockHandle.getTelemetryObjects.andReturn([mockDomainObject]); mockHandle.getMetadata.andReturn([{}]); mockHandle.getDomainValue.andReturn(123); mockHandle.getRangeValue.andReturn(42); - controller = new PlotController(mockScope, mockFormatter, mockHandler); + controller = new PlotController( + mockScope, + mockFormatter, + mockHandler, + mockThrottle + ); }); it("provides plot colors", function () { @@ -224,4 +232,4 @@ define( }); }); } -); \ No newline at end of file +); From 60296b532357e349e8bddcda783f334ecf031384 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 10 Jun 2015 17:05:28 -0700 Subject: [PATCH 05/26] [Core] Add newlines Add newlines to scripts added to core for WTD-1202. --- platform/core/src/services/Throttle.js | 18 +++++++++--------- platform/core/test/services/ThrottleSpec.js | 10 +++++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/platform/core/src/services/Throttle.js b/platform/core/src/services/Throttle.js index 619f53161e..0c86a403c7 100644 --- a/platform/core/src/services/Throttle.js +++ b/platform/core/src/services/Throttle.js @@ -4,7 +4,7 @@ define( [], function () { "use strict"; - + /** * Throttler for function executions, registered as the `throttle` * service. @@ -13,7 +13,7 @@ define( * * throttle(fn, delay, [apply]) * - * Returns a function that, when invoked, will invoke `fn` after + * Returns a function that, when invoked, will invoke `fn` after * `delay` milliseconds, only if no other invocations are pending. * The optional argument `apply` determines whether. * @@ -28,36 +28,36 @@ define( * @param {Function} fn the function to throttle * @param {number} [delay] the delay, in milliseconds, before * executing this function; defaults to 0. - * @param {boolean} apply true if a `$apply` call should be + * @param {boolean} apply true if a `$apply` call should be * invoked after this function executes; defaults to * `false`. */ return function (fn, delay, apply) { var activeTimeout; - + // Clear active timeout, so that next invocation starts // a new one. function clearActiveTimeout() { activeTimeout = undefined; } - + // Defaults delay = delay || 0; apply = apply || false; - + return function () { // Start a timeout if needed if (!activeTimeout) { activeTimeout = $timeout(fn, delay, apply); activeTimeout.then(clearActiveTimeout); } - // Return whichever timeout is active (to get + // Return whichever timeout is active (to get // a promise for the results of fn) return activeTimeout; }; }; } - + return Throttle; } -); \ No newline at end of file +); diff --git a/platform/core/test/services/ThrottleSpec.js b/platform/core/test/services/ThrottleSpec.js index ccd6644eb7..173fad8006 100644 --- a/platform/core/test/services/ThrottleSpec.js +++ b/platform/core/test/services/ThrottleSpec.js @@ -10,7 +10,7 @@ define( mockTimeout, mockFn, mockPromise; - + beforeEach(function () { mockTimeout = jasmine.createSpy("$timeout"); mockPromise = jasmine.createSpyObj("promise", ["then"]); @@ -18,7 +18,7 @@ define( mockTimeout.andReturn(mockPromise); throttle = new Throttle(mockTimeout); }); - + it("provides functions which run on a timeout", function () { var throttled = throttle(mockFn); // Verify precondition: Not called at throttle-time @@ -26,7 +26,7 @@ define( expect(throttled()).toEqual(mockPromise); expect(mockTimeout).toHaveBeenCalledWith(mockFn, 0, false); }); - + it("schedules only one timeout at a time", function () { var throttled = throttle(mockFn); throttled(); @@ -34,7 +34,7 @@ define( throttled(); expect(mockTimeout.calls.length).toEqual(1); }); - + it("schedules additional invocations after resolution", function () { var throttled = throttle(mockFn); throttled(); @@ -46,4 +46,4 @@ define( }); }); } -); \ No newline at end of file +); From 05a114cc75c84373b7b2891065606cb25d734f89 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Mon, 15 Jun 2015 13:01:43 -0700 Subject: [PATCH 06/26] [Forms] Use MM-DD in date-time control Use month and day instead of day-of-year in date-time control, WTD-1272. --- platform/forms/res/templates/controls/datetime.html | 6 +++--- platform/forms/src/controllers/DateTimeController.js | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/platform/forms/res/templates/controls/datetime.html b/platform/forms/res/templates/controls/datetime.html index 6dae89eb8a..8c61fb9861 100644 --- a/platform/forms/res/templates/controls/datetime.html +++ b/platform/forms/res/templates/controls/datetime.html @@ -35,8 +35,8 @@ @@ -80,4 +80,4 @@ - \ No newline at end of file + diff --git a/platform/forms/src/controllers/DateTimeController.js b/platform/forms/src/controllers/DateTimeController.js index c026e98935..e37e3a8f71 100644 --- a/platform/forms/src/controllers/DateTimeController.js +++ b/platform/forms/src/controllers/DateTimeController.js @@ -26,7 +26,7 @@ define( function () { "use strict"; - var DATE_FORMAT = "YYYY-DDD"; + var DATE_FORMAT = "YYYY-MM-DD"; /** * Controller for the `datetime` form control. @@ -92,6 +92,9 @@ define( $scope.$watch("datetime.min", update); $scope.$watch("datetime.sec", update); + // Expose format string for placeholder + $scope.format = DATE_FORMAT; + // Initialize forms values updateDateTime( ($scope.ngModel && $scope.field) ? @@ -102,4 +105,4 @@ define( return DateTimeController; } -); \ No newline at end of file +); From 6aff6d8d2bb74de61d24780d9a919d9e8e3396f0 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Mon, 15 Jun 2015 13:05:37 -0700 Subject: [PATCH 07/26] [Forms] Update spec for date-time control WTD-1272. --- .../forms/test/controllers/DateTimeControllerSpec.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/platform/forms/test/controllers/DateTimeControllerSpec.js b/platform/forms/test/controllers/DateTimeControllerSpec.js index 11c97ada07..720d23480b 100644 --- a/platform/forms/test/controllers/DateTimeControllerSpec.js +++ b/platform/forms/test/controllers/DateTimeControllerSpec.js @@ -47,7 +47,7 @@ define( it("converts date-time input into a timestamp", function () { mockScope.ngModel = {}; mockScope.field = "test"; - mockScope.datetime.date = "2014-332"; + mockScope.datetime.date = "2014-11-28"; mockScope.datetime.hour = 22; mockScope.datetime.min = 55; mockScope.datetime.sec = 13; @@ -63,7 +63,7 @@ define( // as required. mockScope.ngModel = {}; mockScope.field = "test"; - mockScope.datetime.date = "2014-332"; + mockScope.datetime.date = "2014-11-28"; mockScope.datetime.hour = 22; mockScope.datetime.min = 55; // mockScope.datetime.sec = 13; @@ -84,6 +84,11 @@ define( // Should have cleared out the time stamp expect(mockScope.ngModel.test).toBeUndefined(); }); + + it("exposes date-time format for placeholder", function () { + expect(mockScope.format).toEqual(jasmine.any(String)); + expect(mockScope.format.length).toBeGreaterThan(0); + }); }); } -); \ No newline at end of file +); From f24db1561e5eec53862fc5b24b0e2fb8afd1aa1e Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 16 Jun 2015 13:00:03 -0700 Subject: [PATCH 08/26] [Addressability] Get IDs from URL Add a route parameter to Browse mode which includes domain object identifiers. WTD-1149. --- platform/commonUI/browse/bundle.json | 6 +++--- platform/commonUI/browse/src/BrowseController.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/platform/commonUI/browse/bundle.json b/platform/commonUI/browse/bundle.json index dcf1ba9a38..014f09effa 100644 --- a/platform/commonUI/browse/bundle.json +++ b/platform/commonUI/browse/bundle.json @@ -2,7 +2,7 @@ "extensions": { "routes": [ { - "when": "/browse", + "when": "/browse/:id*", "templateUrl": "templates/browse.html" }, { @@ -14,7 +14,7 @@ { "key": "BrowseController", "implementation": "BrowseController.js", - "depends": [ "$scope", "objectService", "navigationService" ] + "depends": [ "$scope", "$routeParams", "objectService", "navigationService" ] }, { "key": "CreateMenuController", @@ -150,4 +150,4 @@ } ] } -} \ No newline at end of file +} diff --git a/platform/commonUI/browse/src/BrowseController.js b/platform/commonUI/browse/src/BrowseController.js index e2c2484e1b..291986f7ba 100644 --- a/platform/commonUI/browse/src/BrowseController.js +++ b/platform/commonUI/browse/src/BrowseController.js @@ -40,7 +40,7 @@ define( * * @constructor */ - function BrowseController($scope, objectService, navigationService) { + function BrowseController($scope, $routeParams, objectService, navigationService) { // Callback for updating the in-scope reference to the object // that is currently navigated-to. function setNavigation(domainObject) { @@ -91,4 +91,4 @@ define( return BrowseController; } -); \ No newline at end of file +); From 8f18d887052f029f81e07fddd304e323899db9e1 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 16 Jun 2015 13:14:10 -0700 Subject: [PATCH 09/26] [Addressability] Navigate down path from params Traverse down the path from route parameters to initially navigate to a domain object in Browse mode. WTD-1149. --- platform/commonUI/browse/bundle.json | 2 +- .../commonUI/browse/src/BrowseController.js | 61 +++++++++++++------ 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/platform/commonUI/browse/bundle.json b/platform/commonUI/browse/bundle.json index 014f09effa..a4b6678541 100644 --- a/platform/commonUI/browse/bundle.json +++ b/platform/commonUI/browse/bundle.json @@ -2,7 +2,7 @@ "extensions": { "routes": [ { - "when": "/browse/:id*", + "when": "/browse/:ids*", "templateUrl": "templates/browse.html" }, { diff --git a/platform/commonUI/browse/src/BrowseController.js b/platform/commonUI/browse/src/BrowseController.js index 291986f7ba..83f5b4061c 100644 --- a/platform/commonUI/browse/src/BrowseController.js +++ b/platform/commonUI/browse/src/BrowseController.js @@ -29,7 +29,7 @@ define( function () { "use strict"; - var ROOT_OBJECT = "ROOT"; + var DEFAULT_PATH = "ROOT/mine"; /** * The BrowseController is used to populate the initial scope in Browse @@ -41,6 +41,8 @@ define( * @constructor */ function BrowseController($scope, $routeParams, objectService, navigationService) { + var path = ($routeParams.ids || DEFAULT_PATH).split("/"); + // Callback for updating the in-scope reference to the object // that is currently navigated-to. function setNavigation(domainObject) { @@ -49,26 +51,51 @@ define( navigationService.setNavigation(domainObject); } + function navigateTo(domainObject) { + // Check if an object has been navigated-to already... + if (!navigationService.getNavigation()) { + // If not, pick a default as the last + // root-level component (usually "mine") + navigationService.setNavigation(domainObject); + } else { + // Otherwise, just expose it in the scope + $scope.navigatedObject = navigationService.getNavigation(); + } + } + + function findObject(domainObjects, id) { + var i; + for (i = 0; i < domainObjects.length; i += 1) { + if (domainObjects[i].getId() === id) { + return domainObjects[i]; + } + } + } + + // Navigate to the domain object identified by path[index], + // which we expect to find in the composition of the passed + // domain object. + function doNavigate(domainObject, index) { + var composition = domainObject.useCapability("composition"); + if (composition) { + composition.then(function (c) { + var nextObject = findObject(c, path[index]); + if (index + 1 >= path.length) { + navigateTo(nextObject); + } else { + doNavigate(nextObject, index + 1); + } + }); + } + } + // Load the root object, put it in the scope. // Also, load its immediate children, and (possibly) // navigate to one of them, so that navigation state has // a useful initial value. - objectService.getObjects([ROOT_OBJECT]).then(function (objects) { - var composition = objects[ROOT_OBJECT].useCapability("composition"); - $scope.domainObject = objects[ROOT_OBJECT]; - if (composition) { - composition.then(function (c) { - // Check if an object has been navigated-to already... - if (!navigationService.getNavigation()) { - // If not, pick a default as the last - // root-level component (usually "mine") - navigationService.setNavigation(c[c.length - 1]); - } else { - // Otherwise, just expose it in the scope - $scope.navigatedObject = navigationService.getNavigation(); - } - }); - } + objectService.getObjects([path[0]]).then(function (objects) { + $scope.domainObject = objects[path[0]]; + doNavigate($scope.domainObject, 1); }); // Provide a model for the tree to modify From 9fae2db04a65b7279b1f7a9c02015dff8c4d825f Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 16 Jun 2015 13:16:55 -0700 Subject: [PATCH 10/26] [Addressability] Infer ROOT Treat the path element for the root domain object as implicit, such that it does not appear in the full URL. WTD-1149. --- platform/commonUI/browse/src/BrowseController.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platform/commonUI/browse/src/BrowseController.js b/platform/commonUI/browse/src/BrowseController.js index 83f5b4061c..9bd118e458 100644 --- a/platform/commonUI/browse/src/BrowseController.js +++ b/platform/commonUI/browse/src/BrowseController.js @@ -29,7 +29,8 @@ define( function () { "use strict"; - var DEFAULT_PATH = "ROOT/mine"; + var ROOT_ID = "ROOT", + DEFAULT_PATH = "mine"; /** * The BrowseController is used to populate the initial scope in Browse @@ -41,7 +42,9 @@ define( * @constructor */ function BrowseController($scope, $routeParams, objectService, navigationService) { - var path = ($routeParams.ids || DEFAULT_PATH).split("/"); + var path = [ROOT_ID].concat( + ($routeParams.ids || DEFAULT_PATH).split("/") + ); // Callback for updating the in-scope reference to the object // that is currently navigated-to. From 084d6b68591a4f1a0797399af76dcdb1302b8a6a Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 16 Jun 2015 13:28:19 -0700 Subject: [PATCH 11/26] [Addressability] Update path on navigation Update path in browse mode when navigation state changes. WTD-1149. --- platform/commonUI/browse/bundle.json | 2 +- platform/commonUI/browse/src/BrowseController.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/platform/commonUI/browse/bundle.json b/platform/commonUI/browse/bundle.json index a4b6678541..b367d02510 100644 --- a/platform/commonUI/browse/bundle.json +++ b/platform/commonUI/browse/bundle.json @@ -14,7 +14,7 @@ { "key": "BrowseController", "implementation": "BrowseController.js", - "depends": [ "$scope", "$routeParams", "objectService", "navigationService" ] + "depends": [ "$scope", "$route", "$location", "objectService", "navigationService" ] }, { "key": "CreateMenuController", diff --git a/platform/commonUI/browse/src/BrowseController.js b/platform/commonUI/browse/src/BrowseController.js index 9bd118e458..eebd11faf9 100644 --- a/platform/commonUI/browse/src/BrowseController.js +++ b/platform/commonUI/browse/src/BrowseController.js @@ -41,17 +41,28 @@ define( * * @constructor */ - function BrowseController($scope, $routeParams, objectService, navigationService) { + function BrowseController($scope, $routeParams, $location, objectService, navigationService) { var path = [ROOT_ID].concat( ($routeParams.ids || DEFAULT_PATH).split("/") ); + function updateRoute(domainObject) { + var context = domainObject.getCapability('context'), + objectPath = context.getPath(), + ids = objectPath.map(function (domainObject) { + return domainObject.getId(); + }); + + $location.path("/browse/" + ids.slice(1).join("/")); + } + // Callback for updating the in-scope reference to the object // that is currently navigated-to. function setNavigation(domainObject) { $scope.navigatedObject = domainObject; $scope.treeModel.selectedObject = domainObject; navigationService.setNavigation(domainObject); + updateRoute(domainObject); } function navigateTo(domainObject) { From 3738ea16d76ffa1167bc63941b7841c1de1af6ec Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 16 Jun 2015 13:44:35 -0700 Subject: [PATCH 12/26] [Addressability] Update route without reinstantiating Work around normal behavior of Angular when path changes; instead of reinstantiating controller for Browse mode when Browse-initiated path changes occur, act as if the route hadn't changed (so that the URL updates but the currently-displayed state, e.g. tree expansion, is preserved.) WTD-1149. --- platform/commonUI/browse/src/BrowseController.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/platform/commonUI/browse/src/BrowseController.js b/platform/commonUI/browse/src/BrowseController.js index eebd11faf9..79a4c6d48d 100644 --- a/platform/commonUI/browse/src/BrowseController.js +++ b/platform/commonUI/browse/src/BrowseController.js @@ -41,9 +41,9 @@ define( * * @constructor */ - function BrowseController($scope, $routeParams, $location, objectService, navigationService) { + function BrowseController($scope, $route, $location, objectService, navigationService) { var path = [ROOT_ID].concat( - ($routeParams.ids || DEFAULT_PATH).split("/") + ($route.current.ids || DEFAULT_PATH).split("/") ); function updateRoute(domainObject) { @@ -51,6 +51,12 @@ define( objectPath = context.getPath(), ids = objectPath.map(function (domainObject) { return domainObject.getId(); + }), + priorRoute = $route.current, + // Act as if params HADN'T changed to avoid page reload + unlisten = $scope.$on('$locationChangeSuccess', function () { + $route.current = priorRoute; + unlisten(); }); $location.path("/browse/" + ids.slice(1).join("/")); From d7b79b6b69ffa6e926ba7e2ed6de83b7c2a8f2a7 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 16 Jun 2015 14:29:22 -0700 Subject: [PATCH 13/26] [Addressability] Preserve nav. state on leaving Edit Preserve navigation state when leaving Edit mode, in the context of addressability changes. WTD-1149. --- platform/commonUI/browse/src/BrowseController.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/platform/commonUI/browse/src/BrowseController.js b/platform/commonUI/browse/src/BrowseController.js index 79a4c6d48d..f705319d5b 100644 --- a/platform/commonUI/browse/src/BrowseController.js +++ b/platform/commonUI/browse/src/BrowseController.js @@ -43,7 +43,7 @@ define( */ function BrowseController($scope, $route, $location, objectService, navigationService) { var path = [ROOT_ID].concat( - ($route.current.ids || DEFAULT_PATH).split("/") + ($route.current.params.ids || DEFAULT_PATH).split("/") ); function updateRoute(domainObject) { @@ -73,13 +73,16 @@ define( function navigateTo(domainObject) { // Check if an object has been navigated-to already... - if (!navigationService.getNavigation()) { + // If not, or if an ID path has been explicitly set in the URL, + // navigate to the URL-specified object. + if (!navigationService.getNavigation() || $route.current.params.ids) { // If not, pick a default as the last // root-level component (usually "mine") navigationService.setNavigation(domainObject); } else { - // Otherwise, just expose it in the scope + // Otherwise, just expose the currently navigated object. $scope.navigatedObject = navigationService.getNavigation(); + updateRoute($scope.navigatedObject); } } From 26fd56a00354231d7d377fd6d785e00e417e981a Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 16 Jun 2015 14:35:15 -0700 Subject: [PATCH 14/26] [Addressability] Handle bad paths Handle paths that cannot be completely followed, WTD-1149. --- platform/commonUI/browse/src/BrowseController.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/platform/commonUI/browse/src/BrowseController.js b/platform/commonUI/browse/src/BrowseController.js index f705319d5b..826493f6a6 100644 --- a/platform/commonUI/browse/src/BrowseController.js +++ b/platform/commonUI/browse/src/BrowseController.js @@ -103,12 +103,22 @@ define( if (composition) { composition.then(function (c) { var nextObject = findObject(c, path[index]); - if (index + 1 >= path.length) { - navigateTo(nextObject); + if (nextObject) { + if (index + 1 >= path.length) { + navigateTo(nextObject); + } else { + doNavigate(nextObject, index + 1); + } } else { - doNavigate(nextObject, index + 1); + // Couldn't find the next element of the path + // so navigate to the last path object we did find + navigateTo(domainObject); } }); + } else { + // Similar to above case; this object has no composition, + // so navigate to it instead of subsequent path elements. + navigateTo(domainObject); } } From fec6f06849bb947ae531c8202960a8bec31169a2 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 16 Jun 2015 14:58:03 -0700 Subject: [PATCH 15/26] [Addressability] Obey view query string param Obey the query string parameter for a view, if present. WTD-1149. --- platform/commonUI/browse/bundle.json | 5 ++ .../browse/res/templates/browse-object.html | 4 +- .../browse/src/BrowseObjectController.js | 55 +++++++++++++++++++ .../src/controllers/ViewSwitcherController.js | 16 +++--- 4 files changed, 71 insertions(+), 9 deletions(-) create mode 100644 platform/commonUI/browse/src/BrowseObjectController.js diff --git a/platform/commonUI/browse/bundle.json b/platform/commonUI/browse/bundle.json index b367d02510..1f019991e9 100644 --- a/platform/commonUI/browse/bundle.json +++ b/platform/commonUI/browse/bundle.json @@ -16,6 +16,11 @@ "implementation": "BrowseController.js", "depends": [ "$scope", "$route", "$location", "objectService", "navigationService" ] }, + { + "key": "BrowseObjectController", + "implementation": "BrowseObjectController.js", + "depends": [ "$scope", "$location" ] + }, { "key": "CreateMenuController", "implementation": "creation/CreateMenuController", diff --git a/platform/commonUI/browse/res/templates/browse-object.html b/platform/commonUI/browse/res/templates/browse-object.html index d88f32c18b..6730d5a186 100644 --- a/platform/commonUI/browse/res/templates/browse-object.html +++ b/platform/commonUI/browse/res/templates/browse-object.html @@ -19,7 +19,7 @@ this source code distribution or the Licensing information page available at runtime from the About dialog for additional information. --> - +
@@ -44,4 +44,4 @@ mct-object="representation.selected.key && domainObject">
- \ No newline at end of file + diff --git a/platform/commonUI/browse/src/BrowseObjectController.js b/platform/commonUI/browse/src/BrowseObjectController.js new file mode 100644 index 0000000000..2385a153d1 --- /dev/null +++ b/platform/commonUI/browse/src/BrowseObjectController.js @@ -0,0 +1,55 @@ +/***************************************************************************** + * Open MCT Web, Copyright (c) 2014-2015, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT Web is licensed 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. + * + * Open MCT Web includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ +/*global define,Promise*/ + +define( + [], + function () { + "use strict"; + + /** + * Controller for the `browse-object` representation of a domain + * object (the right-hand side of Browse mode.) + * @constructor + */ + function BrowseObjectController($scope, $location) { + function setViewForDomainObject(domainObject) { + var locationViewKey = $location.search().view; + + function selectViewIfMatching(view) { + if (view.key === locationViewKey) { + $scope.representation.selected = view; + } + } + + if (locationViewKey) { + ((domainObject && domainObject.useCapability('view')) || []) + .forEach(selectViewIfMatching); + } + } + + $scope.$watch('domainObject', setViewForDomainObject); + } + + return BrowseObjectController; + } +); diff --git a/platform/commonUI/general/src/controllers/ViewSwitcherController.js b/platform/commonUI/general/src/controllers/ViewSwitcherController.js index a821d1f326..69674013d5 100644 --- a/platform/commonUI/general/src/controllers/ViewSwitcherController.js +++ b/platform/commonUI/general/src/controllers/ViewSwitcherController.js @@ -53,12 +53,14 @@ define( // Get list of views, read from capability function updateOptions(views) { - $timeout(function () { - $scope.ngModel.selected = findMatchingOption( - views || [], - ($scope.ngModel || {}).selected - ); - }, 0); + if (Array.isArray(views)) { + $timeout(function () { + $scope.ngModel.selected = findMatchingOption( + views, + ($scope.ngModel || {}).selected + ); + }, 0); + } } // Update view options when the in-scope results of using the @@ -68,4 +70,4 @@ define( return ViewSwitcherController; } -); \ No newline at end of file +); From d559dae1e2b7d91b3dc4030d060477d7b26f59bb Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 16 Jun 2015 15:09:42 -0700 Subject: [PATCH 16/26] [Addressability] Expose current view in query param Expose the currently selected view as a query string parameter, WTD-1149. --- platform/commonUI/browse/src/BrowseObjectController.js | 7 +++++++ .../general/src/controllers/ViewSwitcherController.js | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/platform/commonUI/browse/src/BrowseObjectController.js b/platform/commonUI/browse/src/BrowseObjectController.js index 2385a153d1..9a95c7ea97 100644 --- a/platform/commonUI/browse/src/BrowseObjectController.js +++ b/platform/commonUI/browse/src/BrowseObjectController.js @@ -47,7 +47,14 @@ define( } } + function updateQueryParam(viewKey) { + if (viewKey) { + $location.search('view', viewKey); + } + } + $scope.$watch('domainObject', setViewForDomainObject); + $scope.$watch('representation.selected.key', updateQueryParam); } return BrowseObjectController; diff --git a/platform/commonUI/general/src/controllers/ViewSwitcherController.js b/platform/commonUI/general/src/controllers/ViewSwitcherController.js index 69674013d5..3bf14d8640 100644 --- a/platform/commonUI/general/src/controllers/ViewSwitcherController.js +++ b/platform/commonUI/general/src/controllers/ViewSwitcherController.js @@ -53,7 +53,7 @@ define( // Get list of views, read from capability function updateOptions(views) { - if (Array.isArray(views)) { + if (Array.isArray(views) && !($scope.ngModel || {}).selected) { $timeout(function () { $scope.ngModel.selected = findMatchingOption( views, From 9942e2403967d9e4a1da07897ae5e6a9ecddf15a Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 16 Jun 2015 15:23:55 -0700 Subject: [PATCH 17/26] [Addressability] Work around reload again Work around Angular's page refresh on URL change to avoid unintended effects when chosen view changes (such as tree collapse), WTD-1149. --- platform/commonUI/browse/bundle.json | 8 +++++--- platform/commonUI/browse/src/BrowseController.js | 5 +++-- platform/commonUI/browse/src/BrowseObjectController.js | 8 +++++++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/platform/commonUI/browse/bundle.json b/platform/commonUI/browse/bundle.json index 1f019991e9..7b98571441 100644 --- a/platform/commonUI/browse/bundle.json +++ b/platform/commonUI/browse/bundle.json @@ -3,11 +3,13 @@ "routes": [ { "when": "/browse/:ids*", - "templateUrl": "templates/browse.html" + "templateUrl": "templates/browse.html", + "reloadOnSearch": false }, { "when": "", - "templateUrl": "templates/browse.html" + "templateUrl": "templates/browse.html", + "reloadOnSearch": false } ], "controllers": [ @@ -19,7 +21,7 @@ { "key": "BrowseObjectController", "implementation": "BrowseObjectController.js", - "depends": [ "$scope", "$location" ] + "depends": [ "$scope", "$location", "$route" ] }, { "key": "CreateMenuController", diff --git a/platform/commonUI/browse/src/BrowseController.js b/platform/commonUI/browse/src/BrowseController.js index 826493f6a6..c1cd84c908 100644 --- a/platform/commonUI/browse/src/BrowseController.js +++ b/platform/commonUI/browse/src/BrowseController.js @@ -47,8 +47,9 @@ define( ); function updateRoute(domainObject) { - var context = domainObject.getCapability('context'), - objectPath = context.getPath(), + var context = domainObject && + domainObject.getCapability('context'), + objectPath = context ? context.getPath() : [], ids = objectPath.map(function (domainObject) { return domainObject.getId(); }), diff --git a/platform/commonUI/browse/src/BrowseObjectController.js b/platform/commonUI/browse/src/BrowseObjectController.js index 9a95c7ea97..ed94fe0c01 100644 --- a/platform/commonUI/browse/src/BrowseObjectController.js +++ b/platform/commonUI/browse/src/BrowseObjectController.js @@ -31,7 +31,7 @@ define( * object (the right-hand side of Browse mode.) * @constructor */ - function BrowseObjectController($scope, $location) { + function BrowseObjectController($scope, $location, $route) { function setViewForDomainObject(domainObject) { var locationViewKey = $location.search().view; @@ -48,8 +48,14 @@ define( } function updateQueryParam(viewKey) { + var unlisten, priorRoute = $route.current; + if (viewKey) { $location.search('view', viewKey); + unlisten = $scope.$on('$locationChangeSuccess', function () { + $route.current = priorRoute; + unlisten(); + }); } } From 699cd3bd90865f90792eb4adb2531b3552d3da0b Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 16 Jun 2015 15:35:40 -0700 Subject: [PATCH 18/26] [Addressability] Update spec for BrowseController Update spec to reflect changes for BrowseController to support addressability of domain objects, WTD-1149. --- .../browse/test/BrowseControllerSpec.js | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/platform/commonUI/browse/test/BrowseControllerSpec.js b/platform/commonUI/browse/test/BrowseControllerSpec.js index e0e885aa85..f41f40a8ab 100644 --- a/platform/commonUI/browse/test/BrowseControllerSpec.js +++ b/platform/commonUI/browse/test/BrowseControllerSpec.js @@ -31,6 +31,8 @@ define( describe("The browse controller", function () { var mockScope, + mockRoute, + mockLocation, mockObjectService, mockNavigationService, mockRootObject, @@ -50,6 +52,11 @@ define( "$scope", [ "$on", "$watch" ] ); + mockRoute = { current: { params: {} } }; + mockLocation = jasmine.createSpyObj( + "$location", + [ "path" ] + ); mockObjectService = jasmine.createSpyObj( "objectService", [ "getObjects" ] @@ -75,21 +82,25 @@ define( mockObjectService.getObjects.andReturn(mockPromise({ ROOT: mockRootObject })); - + mockRootObject.useCapability.andReturn(mockPromise([ + mockDomainObject + ])); + mockDomainObject.getId.andReturn("mine"); controller = new BrowseController( mockScope, + mockRoute, + mockLocation, mockObjectService, mockNavigationService ); }); it("uses composition to set the navigated object, if there is none", function () { - mockRootObject.useCapability.andReturn(mockPromise([ - mockDomainObject - ])); controller = new BrowseController( mockScope, + mockRoute, + mockLocation, mockObjectService, mockNavigationService ); @@ -98,12 +109,11 @@ define( }); it("does not try to override navigation", function () { - // This behavior is needed if object navigation has been - // determined by query string parameters - mockRootObject.useCapability.andReturn(mockPromise([null])); mockNavigationService.getNavigation.andReturn(mockDomainObject); controller = new BrowseController( mockScope, + mockRoute, + mockLocation, mockObjectService, mockNavigationService ); @@ -132,4 +142,4 @@ define( }); } -); \ No newline at end of file +); From bcb4e9c49563e5940acc6fc0c1f1128cc2b088bf Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 16 Jun 2015 15:40:19 -0700 Subject: [PATCH 19/26] [Addressability] Remove excessive check Remove unneeded check from ViewSwitcherController; not necessary to avoid overwriting query string selection of view. WTD-1149. --- .../commonUI/general/src/controllers/ViewSwitcherController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/commonUI/general/src/controllers/ViewSwitcherController.js b/platform/commonUI/general/src/controllers/ViewSwitcherController.js index 3bf14d8640..69674013d5 100644 --- a/platform/commonUI/general/src/controllers/ViewSwitcherController.js +++ b/platform/commonUI/general/src/controllers/ViewSwitcherController.js @@ -53,7 +53,7 @@ define( // Get list of views, read from capability function updateOptions(views) { - if (Array.isArray(views) && !($scope.ngModel || {}).selected) { + if (Array.isArray(views)) { $timeout(function () { $scope.ngModel.selected = findMatchingOption( views, From c1c633db80172051bb364c493ee0a0ea5d04ae65 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 16 Jun 2015 15:57:08 -0700 Subject: [PATCH 20/26] [Addressability] Add test cases Add test cases to BrowseController which reflect changes for addressability, WTD-1149. --- .../commonUI/browse/src/BrowseController.js | 1 + .../browse/test/BrowseControllerSpec.js | 80 +++++++++++++++++++ 2 files changed, 81 insertions(+) diff --git a/platform/commonUI/browse/src/BrowseController.js b/platform/commonUI/browse/src/BrowseController.js index c1cd84c908..a5713eaeca 100644 --- a/platform/commonUI/browse/src/BrowseController.js +++ b/platform/commonUI/browse/src/BrowseController.js @@ -80,6 +80,7 @@ define( // If not, pick a default as the last // root-level component (usually "mine") navigationService.setNavigation(domainObject); + $scope.navigatedObject = domainObject; } else { // Otherwise, just expose the currently navigated object. $scope.navigatedObject = navigationService.getNavigation(); diff --git a/platform/commonUI/browse/test/BrowseControllerSpec.js b/platform/commonUI/browse/test/BrowseControllerSpec.js index f41f40a8ab..335e2f94eb 100644 --- a/platform/commonUI/browse/test/BrowseControllerSpec.js +++ b/platform/commonUI/browse/test/BrowseControllerSpec.js @@ -37,6 +37,7 @@ define( mockNavigationService, mockRootObject, mockDomainObject, + mockNextObject, controller; function mockPromise(value) { @@ -78,6 +79,10 @@ define( "domainObject", [ "getId", "getCapability", "getModel", "useCapability" ] ); + mockNextObject = jasmine.createSpyObj( + "nextObject", + [ "getId", "getCapability", "getModel", "useCapability" ] + ); mockObjectService.getObjects.andReturn(mockPromise({ ROOT: mockRootObject @@ -85,6 +90,11 @@ define( mockRootObject.useCapability.andReturn(mockPromise([ mockDomainObject ])); + mockDomainObject.useCapability.andReturn(mockPromise([ + mockNextObject + ])); + mockNextObject.useCapability.andReturn(undefined); + mockNextObject.getId.andReturn("next"); mockDomainObject.getId.andReturn("mine"); controller = new BrowseController( @@ -140,6 +150,76 @@ define( ); }); + it("uses route parameters to choose initially-navigated object", function () { + mockRoute.current.params.ids = "mine/next"; + controller = new BrowseController( + mockScope, + mockRoute, + mockLocation, + mockObjectService, + mockNavigationService + ); + expect(mockScope.navigatedObject).toBe(mockNextObject); + expect(mockNavigationService.setNavigation) + .toHaveBeenCalledWith(mockNextObject); + }); + + it("handles invalid IDs by going as far as possible", function () { + // Idea here is that if we get a bad path of IDs, + // browse controller should traverse down it until + // it hits an invalid ID. + mockRoute.current.params.ids = "mine/junk"; + controller = new BrowseController( + mockScope, + mockRoute, + mockLocation, + mockObjectService, + mockNavigationService + ); + expect(mockScope.navigatedObject).toBe(mockDomainObject); + expect(mockNavigationService.setNavigation) + .toHaveBeenCalledWith(mockDomainObject); + }); + + it("handles compositionless objects by going as far as possible", function () { + // Idea here is that if we get a path which passes + // through an object without a composition, browse controller + // should stop at it since remaining IDs cannot be loaded. + mockRoute.current.params.ids = "mine/next/junk"; + controller = new BrowseController( + mockScope, + mockRoute, + mockLocation, + mockObjectService, + mockNavigationService + ); + expect(mockScope.navigatedObject).toBe(mockNextObject); + expect(mockNavigationService.setNavigation) + .toHaveBeenCalledWith(mockNextObject); + }); + + it("updates the displayed route to reflect current navigation", function () { + var mockContext = jasmine.createSpyObj('context', ['getPath']), + mockUnlisten = jasmine.createSpy('unlisten'); + + mockContext.getPath.andReturn( + [mockRootObject, mockDomainObject, mockNextObject] + ); + mockNextObject.getCapability.andCallFake(function (c) { + return c === 'context' && mockContext; + }); + mockScope.$on.andReturn(mockUnlisten); + // Provide a navigation change + mockNavigationService.addListener.mostRecentCall.args[0]( + mockNextObject + ); + expect(mockLocation.path).toHaveBeenCalledWith("/browse/mine/next"); + + // Exercise the Angular workaround + mockScope.$on.mostRecentCall.args[1](); + expect(mockUnlisten).toHaveBeenCalled(); + }); + }); } ); From 5849f8afe26147474d38a5380239b02ad7fe3c25 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 16 Jun 2015 16:09:22 -0700 Subject: [PATCH 21/26] [Addressability] Add spec for BrowseObjectController Add spec for BrowseObjectController, added to track current view selection from/to query string params, WTD-1149. --- .../browse/src/BrowseObjectController.js | 1 + .../browse/test/BrowseObjectControllerSpec.js | 99 +++++++++++++++++++ platform/commonUI/browse/test/suite.json | 3 +- 3 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 platform/commonUI/browse/test/BrowseObjectControllerSpec.js diff --git a/platform/commonUI/browse/src/BrowseObjectController.js b/platform/commonUI/browse/src/BrowseObjectController.js index ed94fe0c01..c511898871 100644 --- a/platform/commonUI/browse/src/BrowseObjectController.js +++ b/platform/commonUI/browse/src/BrowseObjectController.js @@ -37,6 +37,7 @@ define( function selectViewIfMatching(view) { if (view.key === locationViewKey) { + $scope.representation = $scope.representation || {}; $scope.representation.selected = view; } } diff --git a/platform/commonUI/browse/test/BrowseObjectControllerSpec.js b/platform/commonUI/browse/test/BrowseObjectControllerSpec.js new file mode 100644 index 0000000000..e498c1dc12 --- /dev/null +++ b/platform/commonUI/browse/test/BrowseObjectControllerSpec.js @@ -0,0 +1,99 @@ +/***************************************************************************** + * Open MCT Web, Copyright (c) 2014-2015, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT Web is licensed 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. + * + * Open MCT Web includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ +/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ + + +define( + ["../src/BrowseObjectController"], + function (BrowseObjectController) { + "use strict"; + + describe("The browse object controller", function () { + var mockScope, + mockLocation, + mockRoute, + mockUnlisten, + controller; + + // Utility function; look for a $watch on scope and fire it + function fireWatch(expr, value) { + mockScope.$watch.calls.forEach(function (call) { + if (call.args[0] === expr) { + call.args[1](value); + } + }); + } + + beforeEach(function () { + mockScope = jasmine.createSpyObj( + "$scope", + [ "$on", "$watch" ] + ); + mockRoute = { current: { params: {} } }; + mockLocation = jasmine.createSpyObj( + "$location", + [ "path", "search" ] + ); + mockUnlisten = jasmine.createSpy("unlisten"); + + mockScope.$on.andReturn(mockUnlisten); + + controller = new BrowseObjectController( + mockScope, + mockLocation, + mockRoute + ); + }); + + it("updates query parameters when selected view changes", function () { + fireWatch("representation.selected.key", "xyz"); + expect(mockLocation.search).toHaveBeenCalledWith('view', "xyz"); + + // Exercise the Angular workaround + mockScope.$on.mostRecentCall.args[1](); + expect(mockUnlisten).toHaveBeenCalled(); + }); + + it("sets the active view from query parameters", function () { + var mockDomainObject = jasmine.createSpyObj( + "domainObject", + ['getId', 'getModel', 'getCapability', 'useCapability'] + ), + testViews = [ + { key: 'abc' }, + { key: 'def', someKey: 'some value' }, + { key: 'xyz' } + ]; + + mockDomainObject.useCapability.andCallFake(function (c) { + return (c === 'view') && testViews; + }); + mockLocation.search.andReturn({ view: 'def' }); + + fireWatch('domainObject', mockDomainObject); + expect(mockScope.representation.selected) + .toEqual(testViews[1]); + }); + + }); + } +); diff --git a/platform/commonUI/browse/test/suite.json b/platform/commonUI/browse/test/suite.json index 21d76dae05..e36f345caa 100644 --- a/platform/commonUI/browse/test/suite.json +++ b/platform/commonUI/browse/test/suite.json @@ -1,5 +1,6 @@ [ "BrowseController", + "BrowseObjectController", "creation/CreateAction", "creation/CreateActionProvider", "creation/CreateMenuController", @@ -10,4 +11,4 @@ "navigation/NavigationService", "windowing/FullscreenAction", "windowing/WindowTitler" -] \ No newline at end of file +] From ee69eb3a01a2bc63ab65cad29f090dd517a15458 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 16 Jun 2015 16:10:31 -0700 Subject: [PATCH 22/26] [Addressability] Fix code style Change code style to satisfy JSLint for changes from WTD-1149. --- platform/commonUI/browse/src/BrowseController.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/platform/commonUI/browse/src/BrowseController.js b/platform/commonUI/browse/src/BrowseController.js index a5713eaeca..241c39bb47 100644 --- a/platform/commonUI/browse/src/BrowseController.js +++ b/platform/commonUI/browse/src/BrowseController.js @@ -55,10 +55,12 @@ define( }), priorRoute = $route.current, // Act as if params HADN'T changed to avoid page reload - unlisten = $scope.$on('$locationChangeSuccess', function () { - $route.current = priorRoute; - unlisten(); - }); + unlisten; + + unlisten = $scope.$on('$locationChangeSuccess', function () { + $route.current = priorRoute; + unlisten(); + }); $location.path("/browse/" + ids.slice(1).join("/")); } From 7d911a3fe0c95763d663d28e5a2309898c3ba1a3 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Thu, 18 Jun 2015 10:59:10 -0700 Subject: [PATCH 23/26] [Workers] Add worker service Add service for running WebWorkers, #12. --- bundles.json | 1 + platform/execution/README.md | 1 + platform/execution/bundle.json | 10 +++ platform/execution/src/WorkerService.js | 68 +++++++++++++++++ platform/execution/test/WorkerServiceSpec.js | 77 ++++++++++++++++++++ platform/execution/test/suite.json | 3 + 6 files changed, 160 insertions(+) create mode 100644 platform/execution/README.md create mode 100644 platform/execution/bundle.json create mode 100644 platform/execution/src/WorkerService.js create mode 100644 platform/execution/test/WorkerServiceSpec.js create mode 100644 platform/execution/test/suite.json diff --git a/bundles.json b/bundles.json index 0486bdf24b..6e28332374 100644 --- a/bundles.json +++ b/bundles.json @@ -9,6 +9,7 @@ "platform/commonUI/general", "platform/commonUI/inspect", "platform/containment", + "platform/execution", "platform/telemetry", "platform/features/layout", "platform/features/pages", diff --git a/platform/execution/README.md b/platform/execution/README.md new file mode 100644 index 0000000000..2188e5f909 --- /dev/null +++ b/platform/execution/README.md @@ -0,0 +1 @@ +Contains services which manage execution and flow control (e.g. for concurrency.) diff --git a/platform/execution/bundle.json b/platform/execution/bundle.json new file mode 100644 index 0000000000..ce12852ee9 --- /dev/null +++ b/platform/execution/bundle.json @@ -0,0 +1,10 @@ +{ + "extensions": { + "services": [ + { + "key": "workerService", + "depends": [ "$window", "workers[]" ] + } + ] + } +} diff --git a/platform/execution/src/WorkerService.js b/platform/execution/src/WorkerService.js new file mode 100644 index 0000000000..b8f24ee614 --- /dev/null +++ b/platform/execution/src/WorkerService.js @@ -0,0 +1,68 @@ +/***************************************************************************** + * Open MCT Web, Copyright (c) 2014-2015, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT Web is licensed 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. + * + * Open MCT Web includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ +/*global define*/ + +define( + [], + function () { + "use strict"; + + /** + * Handles the execution of WebWorkers. + * @constructor + */ + function WorkerService($window, workers) { + var workerUrls = {}, + Worker = $window.Worker; + + function addWorker(worker) { + var key = worker.key; + if (!workerUrls[key]) { + workerUrls[key] = [ + worker.bundle.path, + worker.bundle.sources, + worker.scriptUrl + ].join("/"); + } + } + + (workers || []).forEach(addWorker); + + return { + /** + * Start running a new web worker. This will run a worker + * that has been registered under the `workers` category + * of extension. + * + * @param {string} key symbolic identifier for the worker + * @returns {Worker} the running Worker + */ + run: function (key) { + var scriptUrl = workerUrls[key]; + return scriptUrl && Worker && new Worker(scriptUrl); + } + }; + } + + return WorkerService; + } +); diff --git a/platform/execution/test/WorkerServiceSpec.js b/platform/execution/test/WorkerServiceSpec.js new file mode 100644 index 0000000000..24abab6e81 --- /dev/null +++ b/platform/execution/test/WorkerServiceSpec.js @@ -0,0 +1,77 @@ +/***************************************************************************** + * Open MCT Web, Copyright (c) 2014-2015, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT Web is licensed 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. + * + * Open MCT Web includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ +/*global define,describe,it,expect,beforeEach,jasmine*/ + +define( + ["../src/WorkerService"], + function (WorkerService) { + "use strict"; + + describe("The worker service", function () { + var mockWindow, + testWorkers, + mockWorker, + service; + + beforeEach(function () { + mockWindow = jasmine.createSpyObj('$window', ['Worker']); + testWorkers = [ + { + key: 'abc', + scriptUrl: 'c.js', + bundle: { path: 'a', sources: 'b' } + }, + { + key: 'xyz', + scriptUrl: 'z.js', + bundle: { path: 'x', sources: 'y' } + }, + { + key: 'xyz', + scriptUrl: 'bad.js', + bundle: { path: 'bad', sources: 'bad' } + } + ]; + mockWorker = {}; + + mockWindow.Worker.andReturn(mockWorker); + + service = new WorkerService(mockWindow, testWorkers); + }); + + it("instantiates workers at registered paths", function () { + expect(service.run('abc')).toBe(mockWorker); + expect(mockWindow.Worker).toHaveBeenCalledWith('a/b/c.js'); + }); + + it("prefers the first worker when multiple keys are found", function () { + expect(service.run('xyz')).toBe(mockWorker); + expect(mockWindow.Worker).toHaveBeenCalledWith('x/y/z.js'); + }); + + it("returns undefined for unknown workers", function () { + expect(service.run('def')).toBeUndefined(); + }); + + }); + } +); diff --git a/platform/execution/test/suite.json b/platform/execution/test/suite.json new file mode 100644 index 0000000000..d14a0714c5 --- /dev/null +++ b/platform/execution/test/suite.json @@ -0,0 +1,3 @@ +[ + "WorkerService" +] From 640a399278c2633fc885b522238b25ce88c4e864 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Thu, 18 Jun 2015 11:21:00 -0700 Subject: [PATCH 24/26] [Workers] Add example worker Add an example worker which inefficiently calculates fibonacci numbers outside of the UI thread, for #12. --- example/worker/README.md | 1 + example/worker/bundle.json | 16 ++++++ example/worker/src/FibonacciIndicator.js | 70 ++++++++++++++++++++++++ example/worker/src/FibonacciWorker.js | 15 +++++ platform/execution/bundle.json | 1 + 5 files changed, 103 insertions(+) create mode 100644 example/worker/README.md create mode 100644 example/worker/bundle.json create mode 100644 example/worker/src/FibonacciIndicator.js create mode 100644 example/worker/src/FibonacciWorker.js diff --git a/example/worker/README.md b/example/worker/README.md new file mode 100644 index 0000000000..811539ddeb --- /dev/null +++ b/example/worker/README.md @@ -0,0 +1 @@ +Example of running a Web Worker using the `workerService`. diff --git a/example/worker/bundle.json b/example/worker/bundle.json new file mode 100644 index 0000000000..2241aca2a6 --- /dev/null +++ b/example/worker/bundle.json @@ -0,0 +1,16 @@ +{ + "extensions": { + "indicators": [ + { + "implementation": "FibonacciIndicator.js", + "depends": [ "workerService", "$rootScope" ] + } + ], + "workers": [ + { + "key": "example.fibonacci", + "scriptUrl": "FibonacciWorker.js" + } + ] + } +} diff --git a/example/worker/src/FibonacciIndicator.js b/example/worker/src/FibonacciIndicator.js new file mode 100644 index 0000000000..77a55bc531 --- /dev/null +++ b/example/worker/src/FibonacciIndicator.js @@ -0,0 +1,70 @@ +/***************************************************************************** + * Open MCT Web, Copyright (c) 2014-2015, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT Web is licensed 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. + * + * Open MCT Web includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ +/*global define*/ + +define( + [], + function () { + "use strict"; + + /** + * Displays Fibonacci numbers in the status area. + * @constructor + */ + function FibonacciIndicator(workerService, $rootScope) { + var latest, + counter = 0, + worker = workerService.run('example.fibonacci'); + + function requestNext() { + worker.postMessage([counter]); + counter += 1; + } + + function handleResponse(event) { + latest = event.data; + $rootScope.$apply(); + requestNext(); + } + + worker.onmessage = handleResponse; + requestNext(); + + return { + getGlyph: function () { + return "?"; + }, + getText: function () { + return latest; + }, + getGlyphClass: function () { + return ""; + }, + getDescription: function () { + return ""; + } + }; + } + + return FibonacciIndicator; + } +); diff --git a/example/worker/src/FibonacciWorker.js b/example/worker/src/FibonacciWorker.js new file mode 100644 index 0000000000..2d0d5832a6 --- /dev/null +++ b/example/worker/src/FibonacciWorker.js @@ -0,0 +1,15 @@ +/*global onmessage,postMessage*/ +(function () { + "use strict"; + + // Calculate fibonacci numbers inefficiently. + // We can do this because we're on a background thread, and + // won't halt the UI. + function fib(n) { + return n < 2 ? n : (fib(n - 1) + fib(n - 2)); + } + + onmessage = function (event) { + postMessage(fib(event.data)); + }; +}()); diff --git a/platform/execution/bundle.json b/platform/execution/bundle.json index ce12852ee9..6e6ea83eee 100644 --- a/platform/execution/bundle.json +++ b/platform/execution/bundle.json @@ -3,6 +3,7 @@ "services": [ { "key": "workerService", + "implementation": "WorkerService.js", "depends": [ "$window", "workers[]" ] } ] From eb2cddc063377d14470be663992711a28bf8f255 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Thu, 18 Jun 2015 11:30:47 -0700 Subject: [PATCH 25/26] [Workers] Satisfy JSLint Modify example worker script to satisfy JSLint. #12. --- example/worker/src/FibonacciWorker.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/example/worker/src/FibonacciWorker.js b/example/worker/src/FibonacciWorker.js index 2d0d5832a6..2ad8e7f2af 100644 --- a/example/worker/src/FibonacciWorker.js +++ b/example/worker/src/FibonacciWorker.js @@ -1,4 +1,4 @@ -/*global onmessage,postMessage*/ +/*global self*/ (function () { "use strict"; @@ -9,7 +9,7 @@ return n < 2 ? n : (fib(n - 1) + fib(n - 2)); } - onmessage = function (event) { - postMessage(fib(event.data)); + self.onmessage = function (event) { + self.postMessage(fib(event.data)); }; }()); From 0201a4bcf83ebe6c5e904054d01cde6db1db1fb0 Mon Sep 17 00:00:00 2001 From: Charles Hacskaylo Date: Thu, 18 Jun 2015 15:18:42 -0700 Subject: [PATCH 26/26] [Frontend] Fix to prevent infobubbles from preventing clicks GitHub-12 Added CSS class "bubble-container" to BUBBLE_TEMPLATE; bubble-container utilizes CSS "pointer-events: none"; Changed INFO_HOVER_DELAY constant from 500ms to 2000ms; --- .../general/res/css/theme-espresso.css | 74 ++++++++++--------- .../general/res/sass/helpers/_bubbles.scss | 7 ++ platform/commonUI/inspect/bundle.json | 2 +- .../commonUI/inspect/res/info-bubble.html | 8 +- .../commonUI/inspect/src/InfoConstants.js | 3 +- 5 files changed, 54 insertions(+), 40 deletions(-) diff --git a/platform/commonUI/general/res/css/theme-espresso.css b/platform/commonUI/general/res/css/theme-espresso.css index 5a8bcac07a..84a3ed5925 100644 --- a/platform/commonUI/general/res/css/theme-espresso.css +++ b/platform/commonUI/general/res/css/theme-espresso.css @@ -84,7 +84,7 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/* line 5, ../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */ +/* line 5, ../../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, @@ -105,38 +105,38 @@ time, mark, audio, video { font-size: 100%; vertical-align: baseline; } -/* line 22, ../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */ +/* line 22, ../../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */ html { line-height: 1; } -/* line 24, ../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */ +/* line 24, ../../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */ ol, ul { list-style: none; } -/* line 26, ../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */ +/* line 26, ../../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */ table { border-collapse: collapse; border-spacing: 0; } -/* line 28, ../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */ +/* line 28, ../../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */ caption, th, td { text-align: left; font-weight: normal; vertical-align: middle; } -/* line 30, ../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */ +/* line 30, ../../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */ q, blockquote { quotes: none; } - /* line 103, ../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */ + /* line 103, ../../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */ q:before, q:after, blockquote:before, blockquote:after { content: ""; content: none; } -/* line 32, ../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */ +/* line 32, ../../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */ a img { border: none; } -/* line 116, ../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */ +/* line 116, ../../../../../../../../../../Library/Ruby/Gems/2.0.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */ article, aside, details, figcaption, figure, footer, header, hgroup, main, menu, nav, section, summary { display: block; } @@ -4219,51 +4219,55 @@ input[type="text"] { * at runtime from the About dialog for additional information. *****************************************************************************/ /* line 24, ../sass/helpers/_bubbles.scss */ +.bubble-container { + pointer-events: none; } + +/* line 31, ../sass/helpers/_bubbles.scss */ .l-infobubble-wrapper { -moz-box-shadow: rgba(0, 0, 0, 0.4) 0 1px 5px; -webkit-box-shadow: rgba(0, 0, 0, 0.4) 0 1px 5px; box-shadow: rgba(0, 0, 0, 0.4) 0 1px 5px; position: relative; z-index: 50; } - /* line 29, ../sass/helpers/_bubbles.scss */ + /* line 36, ../sass/helpers/_bubbles.scss */ .l-infobubble-wrapper .l-infobubble { display: inline-block; min-width: 100px; max-width: 300px; padding: 5px 10px; } - /* line 34, ../sass/helpers/_bubbles.scss */ + /* line 41, ../sass/helpers/_bubbles.scss */ .l-infobubble-wrapper .l-infobubble:before { content: ""; position: absolute; width: 0; height: 0; } - /* line 40, ../sass/helpers/_bubbles.scss */ + /* line 47, ../sass/helpers/_bubbles.scss */ .l-infobubble-wrapper .l-infobubble table { width: 100%; } - /* line 43, ../sass/helpers/_bubbles.scss */ + /* line 50, ../sass/helpers/_bubbles.scss */ .l-infobubble-wrapper .l-infobubble table tr td { padding: 2px 0; vertical-align: top; } - /* line 50, ../sass/helpers/_bubbles.scss */ + /* line 57, ../sass/helpers/_bubbles.scss */ .l-infobubble-wrapper .l-infobubble table tr td.label { padding-right: 10px; white-space: nowrap; } - /* line 54, ../sass/helpers/_bubbles.scss */ + /* line 61, ../sass/helpers/_bubbles.scss */ .l-infobubble-wrapper .l-infobubble table tr td.value { white-space: nowrap; } - /* line 58, ../sass/helpers/_bubbles.scss */ + /* line 65, ../sass/helpers/_bubbles.scss */ .l-infobubble-wrapper .l-infobubble table tr td.align-wrap { white-space: normal; } - /* line 64, ../sass/helpers/_bubbles.scss */ + /* line 71, ../sass/helpers/_bubbles.scss */ .l-infobubble-wrapper .l-infobubble .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 5px; } - /* line 71, ../sass/helpers/_bubbles.scss */ + /* line 78, ../sass/helpers/_bubbles.scss */ .l-infobubble-wrapper.arw-left { margin-left: 20px; } - /* line 73, ../sass/helpers/_bubbles.scss */ + /* line 80, ../sass/helpers/_bubbles.scss */ .l-infobubble-wrapper.arw-left .l-infobubble::before { right: 100%; width: 0; @@ -4271,10 +4275,10 @@ input[type="text"] { border-top: 6.66667px solid transparent; border-bottom: 6.66667px solid transparent; border-right: 10px solid #ddd; } - /* line 79, ../sass/helpers/_bubbles.scss */ + /* line 86, ../sass/helpers/_bubbles.scss */ .l-infobubble-wrapper.arw-right { margin-right: 20px; } - /* line 81, ../sass/helpers/_bubbles.scss */ + /* line 88, ../sass/helpers/_bubbles.scss */ .l-infobubble-wrapper.arw-right .l-infobubble::before { left: 100%; width: 0; @@ -4282,16 +4286,16 @@ input[type="text"] { border-top: 6.66667px solid transparent; border-bottom: 6.66667px solid transparent; border-left: 10px solid #ddd; } - /* line 88, ../sass/helpers/_bubbles.scss */ + /* line 95, ../sass/helpers/_bubbles.scss */ .l-infobubble-wrapper.arw-top .l-infobubble::before { top: 20px; } - /* line 94, ../sass/helpers/_bubbles.scss */ + /* line 101, ../sass/helpers/_bubbles.scss */ .l-infobubble-wrapper.arw-btm .l-infobubble::before { bottom: 20px; } - /* line 99, ../sass/helpers/_bubbles.scss */ + /* line 106, ../sass/helpers/_bubbles.scss */ .l-infobubble-wrapper.arw-down { margin-bottom: 10px; } - /* line 101, ../sass/helpers/_bubbles.scss */ + /* line 108, ../sass/helpers/_bubbles.scss */ .l-infobubble-wrapper.arw-down .l-infobubble::before { left: 50%; top: 100%; @@ -4299,21 +4303,21 @@ input[type="text"] { border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 7.5px solid #ddd; } - /* line 110, ../sass/helpers/_bubbles.scss */ + /* line 117, ../sass/helpers/_bubbles.scss */ .l-infobubble-wrapper .arw { z-index: 2; } - /* line 113, ../sass/helpers/_bubbles.scss */ + /* line 120, ../sass/helpers/_bubbles.scss */ .l-infobubble-wrapper.arw-up .arw.arw-down, .l-infobubble-wrapper.arw-down .arw.arw-up { display: none; } -/* line 120, ../sass/helpers/_bubbles.scss */ +/* line 127, ../sass/helpers/_bubbles.scss */ .l-thumbsbubble-wrapper .arw-up { width: 0; height: 0; border-left: 6.66667px solid transparent; border-right: 6.66667px solid transparent; border-bottom: 10px solid #4d4d4d; } -/* line 123, ../sass/helpers/_bubbles.scss */ +/* line 130, ../sass/helpers/_bubbles.scss */ .l-thumbsbubble-wrapper .arw-down { width: 0; height: 0; @@ -4321,7 +4325,7 @@ input[type="text"] { border-right: 6.66667px solid transparent; border-top: 10px solid #4d4d4d; } -/* line 127, ../sass/helpers/_bubbles.scss */ +/* line 134, ../sass/helpers/_bubbles.scss */ .s-infobubble { -moz-border-radius: 2px; -webkit-border-radius: 2px; @@ -4332,22 +4336,22 @@ input[type="text"] { background: #ddd; color: #666; font-size: 0.8rem; } - /* line 134, ../sass/helpers/_bubbles.scss */ + /* line 141, ../sass/helpers/_bubbles.scss */ .s-infobubble .title { color: #333333; font-weight: bold; } - /* line 139, ../sass/helpers/_bubbles.scss */ + /* line 146, ../sass/helpers/_bubbles.scss */ .s-infobubble tr td { border-top: 1px solid #c4c4c4; font-size: 0.9em; } - /* line 143, ../sass/helpers/_bubbles.scss */ + /* line 150, ../sass/helpers/_bubbles.scss */ .s-infobubble tr:first-child td { border-top: none; } - /* line 147, ../sass/helpers/_bubbles.scss */ + /* line 154, ../sass/helpers/_bubbles.scss */ .s-infobubble .value { color: #333333; } -/* line 152, ../sass/helpers/_bubbles.scss */ +/* line 159, ../sass/helpers/_bubbles.scss */ .s-thumbsbubble { background: #4d4d4d; color: #b3b3b3; } diff --git a/platform/commonUI/general/res/sass/helpers/_bubbles.scss b/platform/commonUI/general/res/sass/helpers/_bubbles.scss index e9648523c4..5b174ba6da 100644 --- a/platform/commonUI/general/res/sass/helpers/_bubbles.scss +++ b/platform/commonUI/general/res/sass/helpers/_bubbles.scss @@ -19,6 +19,13 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ + +//************************************************* GENERAL +.bubble-container { + pointer-events: none; +} + + //************************************************* LAYOUT .l-infobubble-wrapper { diff --git a/platform/commonUI/inspect/bundle.json b/platform/commonUI/inspect/bundle.json index 07506d0983..51244b2bf2 100644 --- a/platform/commonUI/inspect/bundle.json +++ b/platform/commonUI/inspect/bundle.json @@ -44,7 +44,7 @@ "constants": [ { "key": "INFO_HOVER_DELAY", - "value": 500 + "value": 2000 } ] } diff --git a/platform/commonUI/inspect/res/info-bubble.html b/platform/commonUI/inspect/res/info-bubble.html index 1deeeade15..82545cb29e 100644 --- a/platform/commonUI/inspect/res/info-bubble.html +++ b/platform/commonUI/inspect/res/info-bubble.html @@ -1,6 +1,8 @@ - + diff --git a/platform/commonUI/inspect/src/InfoConstants.js b/platform/commonUI/inspect/src/InfoConstants.js index 86570911c6..5e43a1b618 100644 --- a/platform/commonUI/inspect/src/InfoConstants.js +++ b/platform/commonUI/inspect/src/InfoConstants.js @@ -23,7 +23,8 @@ define({ BUBBLE_TEMPLATE: "" + + "bubble-layout=\"{{bubbleLayout}}\" " + + "class=\"bubble-container\">" + "" + "" + "",