bruce-cesium 4.2.9 → 4.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23167,6 +23167,10 @@
23167
23167
  };
23168
23168
  WidgetLeftPanel.prototype.Dispose = function () {
23169
23169
  _super.prototype.Dispose.call(this);
23170
+ if (this.envSubRemoval) {
23171
+ this.envSubRemoval();
23172
+ this.envSubRemoval = null;
23173
+ }
23170
23174
  if (this._enabledTabContent) {
23171
23175
  this._enabledTabContent.Dispose();
23172
23176
  this._enabledTabContent = null;
@@ -23179,7 +23183,7 @@
23179
23183
  }
23180
23184
  var style = document.createElement("style");
23181
23185
  style.id = this.STYLESHEET_ID;
23182
- style.innerHTML = "\n .NextspaceLeftPanel {\n align-items: center;\n background-color: #21272a;\n cursor: default;\n display: flex;\n flex-direction: column;\n flex-shrink: 0;\n height: 100%;\n padding-top: 15px;\n position: absolute;\n width: 50px;\n z-index: 1;\n top: 0;\n left: 0;\n box-sizing: border-box;\n }\n\n .NextspaceLeftPanel * {\n box-sizing: border-box;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelBreaker {\n background-color: hsla(0,0%,50%,.231);\n flex-shrink: 0;\n height: 2px;\n margin-bottom: 15px;\n width: calc(100% - 8px);\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelBottomBreaker {\n margin-top: auto;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton {\n border-radius: 3px;\n color: #fff;\n cursor: pointer;\n font-size: 18px;\n height: 32px;\n overflow: hidden;\n width: 32px;\n margin-bottom: 15px;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton:first-of-type {\n margin-bottom: 8px;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton >.NextspaceLeftPanelButtonIcon {\n align-items: center;\n display: flex;\n justify-content: center;\n position: relative;\n transition: .3s ease;\n height: 100%;\n width: 100%;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton >.NextspaceLeftPanelButtonIcon:hover {\n transform: scale(1.2);\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton >.NextspaceLeftPanelButtonIcon >svg {\n cursor: pointer;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton[is-enabled=\"true\"] >.NextspaceLeftPanelButtonIcon {\n background-color: #fff;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton[is-enabled=\"true\"] >.NextspaceLeftPanelButtonIcon >svg {\n filter: invert(1);\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelTabContent {\n display: none;\n width: 300px;\n height: 100%;\n position: absolute;\n top: 0;\n left: 50px;\n background-color: #21272a;\n padding: 40px 30px 30px;\n flex-direction: column;\n flex-grow: 1;\n flex-shrink: 1;\n overflow: hidden;\n }\n\n .NextspaceLeftPanel .NextspaceLeftPanelTabContentCloseButton {\n color: #fff;\n cursor: pointer;\n opacity: .7;\n position: absolute;\n right: 22px;\n top: 14px;\n transition: transform .3s ease;\n z-index: 1;\n }\n\n .NextspaceLeftPanel .NextspaceLeftPanelTabContentCloseButton:hover {\n transform: scale(1.2);\n }\n ";
23186
+ style.innerHTML = "\n .NextspaceLeftPanel {\n align-items: center;\n background-color: #21272a;\n cursor: default;\n display: flex;\n flex-direction: column;\n flex-shrink: 0;\n height: 100%;\n padding-top: 15px;\n position: absolute;\n width: 50px;\n z-index: 1;\n top: 0;\n left: 0;\n box-sizing: border-box;\n }\n\n .NextspaceLeftPanel * {\n box-sizing: border-box;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelBreaker {\n background-color: hsla(0,0%,50%,.231);\n flex-shrink: 0;\n height: 2px;\n margin-bottom: 15px;\n width: calc(100% - 8px);\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelBottomBreaker {\n margin-top: auto;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton {\n border-radius: 3px;\n color: #fff;\n cursor: pointer;\n font-size: 18px;\n height: 32px;\n overflow: hidden;\n width: 32px;\n margin-bottom: 15px;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton:first-of-type {\n margin-bottom: 8px;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton >.NextspaceLeftPanelButtonIcon {\n align-items: center;\n display: flex;\n justify-content: center;\n position: relative;\n transition: .3s ease;\n height: 100%;\n width: 100%;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton >.NextspaceLeftPanelButtonIcon:hover {\n transform: scale(1.2);\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton[no-content=\"true\"] {\n cursor: default;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton[no-content=\"true\"] >.NextspaceLeftPanelButtonIcon:hover {\n transform: none;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton >.NextspaceLeftPanelButtonIcon >svg {\n cursor: pointer;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton[is-enabled=\"true\"] >.NextspaceLeftPanelButtonIcon {\n background-color: #fff;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton[is-enabled=\"true\"] >.NextspaceLeftPanelButtonIcon >svg {\n filter: invert(1);\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton[is-disabled=\"true\"] {\n opacity: .5;\n pointer-events: none\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelTabContent {\n display: none;\n width: 300px;\n height: 100%;\n position: absolute;\n top: 0;\n left: 50px;\n background-color: #21272a;\n padding: 40px 30px 30px;\n flex-direction: column;\n flex-grow: 1;\n flex-shrink: 1;\n overflow: hidden;\n }\n\n .NextspaceLeftPanel .NextspaceLeftPanelTabContentCloseButton {\n color: #fff;\n cursor: pointer;\n opacity: .7;\n position: absolute;\n right: 22px;\n top: 14px;\n transition: transform .3s ease;\n z-index: 1;\n }\n\n .NextspaceLeftPanel .NextspaceLeftPanelTabContentCloseButton:hover {\n transform: scale(1.2);\n }\n ";
23183
23187
  document.head.appendChild(style);
23184
23188
  };
23185
23189
  WidgetLeftPanel.prototype._generateElement = function () {
@@ -23196,7 +23200,7 @@
23196
23200
  var bottomBreaker = document.createElement("div");
23197
23201
  bottomBreaker.className = "NextspaceLeftPanelBottomBreaker";
23198
23202
  this._element.appendChild(bottomBreaker);
23199
- this._addPlaceholderTab("Profile", "\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M12 12C14.21 12 16 10.21 16 8C16 5.79 14.21 4 12 4C9.79 4 8 5.79 8 8C8 10.21 9.79 12 12 12ZM12 14C9.33 14 4 15.34 4 18V19C4 19.55 4.45 20 5 20H19C19.55 20 20 19.55 20 19V18C20 15.34 14.67 14 12 14Z\" fill=\"white\"/>\n </svg>\n ");
23203
+ this._addUserProfileTab();
23200
23204
  var panelContent = document.createElement("div");
23201
23205
  panelContent.className = "NextspaceLeftPanelTabContent";
23202
23206
  var panelContentCloseButton = document.createElement("div");
@@ -23218,9 +23222,12 @@
23218
23222
  */
23219
23223
  WidgetLeftPanel.prototype.AddPanelTab = function (params) {
23220
23224
  this.customTabs.set(params.tab, params.content);
23221
- this._addPanelTab(params.tab, params.title, params.svgStr);
23225
+ // We insert before the bottom breaker.
23226
+ var bottomBreaker = this._element.querySelector(".NextspaceLeftPanelBottomBreaker");
23227
+ var afterElement = bottomBreaker ? bottomBreaker.previousElementSibling : null;
23228
+ this._addPanelTab(params.tab, params.title, params.svgStr, afterElement);
23222
23229
  };
23223
- WidgetLeftPanel.prototype._addPanelTab = function (tab, title, svgStr) {
23230
+ WidgetLeftPanel.prototype._addPanelTab = function (tab, title, svgStr, afterElement) {
23224
23231
  var _this = this;
23225
23232
  var tabButton = document.createElement("div");
23226
23233
  tabButton.setAttribute("widget-left-panel-tab", tab);
@@ -23245,7 +23252,17 @@
23245
23252
  _this._updatePanelContent();
23246
23253
  _this._updatePanelStyles();
23247
23254
  };
23248
- this._element.appendChild(tabButton);
23255
+ if (afterElement && afterElement.parentElement) {
23256
+ if (afterElement.nextSibling) {
23257
+ afterElement.parentElement.insertBefore(tabButton, afterElement.nextSibling);
23258
+ }
23259
+ else {
23260
+ afterElement.parentElement.appendChild(tabButton);
23261
+ }
23262
+ }
23263
+ else {
23264
+ this._element.appendChild(tabButton);
23265
+ }
23249
23266
  };
23250
23267
  WidgetLeftPanel.prototype._addPlaceholderTab = function (title, svgStr) {
23251
23268
  var tabButton = document.createElement("div");
@@ -23259,6 +23276,83 @@
23259
23276
  tabButton.appendChild(buttonBookmarksIcon);
23260
23277
  this._element.appendChild(tabButton);
23261
23278
  };
23279
+ /**
23280
+ * User profile handled separately.
23281
+ * This is because for a while it will be just an indicator of logged in user session.
23282
+ * It won't have a tab content.
23283
+ */
23284
+ WidgetLeftPanel.prototype._addUserProfileTab = function () {
23285
+ var tabButton = document.createElement("div");
23286
+ tabButton.className = "NextspaceLeftPanelButton";
23287
+ tabButton.setAttribute("title", "Not logged in");
23288
+ tabButton.setAttribute("no-content", "true");
23289
+ var buttonBookmarksIcon = document.createElement("div");
23290
+ buttonBookmarksIcon.className = "NextspaceLeftPanelButtonIcon";
23291
+ var LOGGED_OUT_ICON = "\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M12 12C14.21 12 16 10.21 16 8C16 5.79 14.21 4 12 4C9.79 4 8 5.79 8 8C8 10.21 9.79 12 12 12ZM12 14C9.33 14 4 15.34 4 18V19C4 19.55 4.45 20 5 20H19C19.55 20 20 19.55 20 19V18C20 15.34 14.67 14 12 14Z\" fill=\"white\"/>\n </svg>\n ";
23292
+ buttonBookmarksIcon.innerHTML = LOGGED_OUT_ICON;
23293
+ tabButton.appendChild(buttonBookmarksIcon);
23294
+ this._element.appendChild(tabButton);
23295
+ function getInitials(name) {
23296
+ var nameSplit = name.split(" ");
23297
+ if (nameSplit.length > 1) {
23298
+ return nameSplit[0][0] + nameSplit[1][0];
23299
+ }
23300
+ else {
23301
+ return nameSplit[0][0];
23302
+ }
23303
+ }
23304
+ function GetColorForString(str) {
23305
+ var stringUniqueHash = [].concat(str).reduce(function (acc, char) { return char.charCodeAt(0) + ((acc << 5) - acc); }, 0);
23306
+ return "hsl(".concat(stringUniqueHash % 360, ", 95%, 35%)");
23307
+ }
23308
+ /**
23309
+ * Updates the tab button based on the current user session.
23310
+ */
23311
+ function updateProfile() {
23312
+ var _a;
23313
+ return __awaiter(this, void 0, void 0, function () {
23314
+ var session, isLoggedIn, userName, initials, e_2;
23315
+ return __generator(this, function (_b) {
23316
+ switch (_b.label) {
23317
+ case 0:
23318
+ _b.trys.push([0, 2, , 3]);
23319
+ return [4 /*yield*/, BModels.Session.Get({
23320
+ sessionId: BModels.ENVIRONMENT.PARAMS.sessionId ? BModels.ENVIRONMENT.PARAMS.sessionId : "anonymous",
23321
+ })];
23322
+ case 1:
23323
+ session = (_b.sent()).session;
23324
+ isLoggedIn = session.ID != "anonymous" && ((_a = session.User) === null || _a === void 0 ? void 0 : _a.ID) != "anonymous";
23325
+ userName = session.User.FullName ? session.User.FullName : session.User.ID;
23326
+ tabButton.setAttribute("title", isLoggedIn ? userName : "Not logged in");
23327
+ // Draw a circle with the user's initials.
23328
+ if (isLoggedIn) {
23329
+ initials = getInitials(userName);
23330
+ buttonBookmarksIcon.innerHTML = "\n <div \n style=\"\n background-color: ".concat(GetColorForString(userName), "; \n color: white;\n border-radius: 50%;\n display: flex; \n align-items: center; \n justify-content: center; \n font-size: 12px;\n font-family: Arial;\n height: 100%; \n width: 100%;\">\n ").concat(initials, "\n </div>\n ");
23331
+ }
23332
+ else {
23333
+ buttonBookmarksIcon.innerHTML = LOGGED_OUT_ICON;
23334
+ }
23335
+ return [3 /*break*/, 3];
23336
+ case 2:
23337
+ e_2 = _b.sent();
23338
+ console.error(e_2);
23339
+ tabButton.setAttribute("title", "Not logged in");
23340
+ buttonBookmarksIcon.innerHTML = LOGGED_OUT_ICON;
23341
+ return [3 /*break*/, 3];
23342
+ case 3: return [2 /*return*/];
23343
+ }
23344
+ });
23345
+ });
23346
+ }
23347
+ if (this.envSubRemoval) {
23348
+ this.envSubRemoval();
23349
+ this.envSubRemoval = null;
23350
+ }
23351
+ this.envSubRemoval = BModels.ENVIRONMENT.OnParamsChange.Subscribe(function () {
23352
+ updateProfile();
23353
+ });
23354
+ updateProfile();
23355
+ };
23262
23356
  /**
23263
23357
  * Updates the panel styles based on the current state.
23264
23358
  * Eg: if a tab is enabled, the button should be highlighted.
@@ -23267,8 +23361,14 @@
23267
23361
  var _this = this;
23268
23362
  var buttons = this._element.querySelectorAll(".NextspaceLeftPanelButton");
23269
23363
  buttons.forEach(function (button) {
23270
- var isEnabled = button.getAttribute("widget-left-panel-tab") === _this._enabledPanelTab;
23364
+ var buttonTab = button.getAttribute("widget-left-panel-tab");
23365
+ var isEnabled = buttonTab === _this._enabledPanelTab;
23271
23366
  button.setAttribute("is-enabled", isEnabled ? "true" : "false");
23367
+ // Disable for specific tabs.
23368
+ // Eg: bookmarks require a viewId.
23369
+ if (buttonTab === "bookmarks") {
23370
+ button.setAttribute("is-disabled", !_this._viewId ? "true" : "false");
23371
+ }
23272
23372
  });
23273
23373
  // Make the tab content visible/invisible based on the current state.
23274
23374
  var contentDisplayState = this._enabledPanelTab ? "flex" : "none";
@@ -23295,10 +23395,15 @@
23295
23395
  });
23296
23396
  break;
23297
23397
  default:
23298
- tabContent = new (this.customTabs.get(this._enabledPanelTab)({
23398
+ if (this.customTabs.has(this._enabledPanelTab) === false) {
23399
+ console.error("Tab ".concat(this._enabledPanelTab, " not found."));
23400
+ return;
23401
+ }
23402
+ var clazz = this.customTabs.get(this._enabledPanelTab);
23403
+ tabContent = new clazz({
23299
23404
  widget: this,
23300
23405
  container: container
23301
- }));
23406
+ });
23302
23407
  break;
23303
23408
  }
23304
23409
  this._enabledTabContent = tabContent;
@@ -26259,7 +26364,7 @@
26259
26364
  ViewerUtils.AssertIonToken = AssertIonToken;
26260
26365
  })(exports.ViewerUtils || (exports.ViewerUtils = {}));
26261
26366
 
26262
- var VERSION = "4.2.9";
26367
+ var VERSION = "4.3.1";
26263
26368
 
26264
26369
  exports.VERSION = VERSION;
26265
26370
  exports.CesiumParabola = CesiumParabola;