bruce-cesium 4.2.9 → 4.3.0

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");
@@ -23259,6 +23263,83 @@
23259
23263
  tabButton.appendChild(buttonBookmarksIcon);
23260
23264
  this._element.appendChild(tabButton);
23261
23265
  };
23266
+ /**
23267
+ * User profile handled separately.
23268
+ * This is because for a while it will be just an indicator of logged in user session.
23269
+ * It won't have a tab content.
23270
+ */
23271
+ WidgetLeftPanel.prototype._addUserProfileTab = function () {
23272
+ var tabButton = document.createElement("div");
23273
+ tabButton.className = "NextspaceLeftPanelButton";
23274
+ tabButton.setAttribute("title", "Not logged in");
23275
+ tabButton.setAttribute("no-content", "true");
23276
+ var buttonBookmarksIcon = document.createElement("div");
23277
+ buttonBookmarksIcon.className = "NextspaceLeftPanelButtonIcon";
23278
+ 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 ";
23279
+ buttonBookmarksIcon.innerHTML = LOGGED_OUT_ICON;
23280
+ tabButton.appendChild(buttonBookmarksIcon);
23281
+ this._element.appendChild(tabButton);
23282
+ function getInitials(name) {
23283
+ var nameSplit = name.split(" ");
23284
+ if (nameSplit.length > 1) {
23285
+ return nameSplit[0][0] + nameSplit[1][0];
23286
+ }
23287
+ else {
23288
+ return nameSplit[0][0];
23289
+ }
23290
+ }
23291
+ function GetColorForString(str) {
23292
+ var stringUniqueHash = [].concat(str).reduce(function (acc, char) { return char.charCodeAt(0) + ((acc << 5) - acc); }, 0);
23293
+ return "hsl(".concat(stringUniqueHash % 360, ", 95%, 35%)");
23294
+ }
23295
+ /**
23296
+ * Updates the tab button based on the current user session.
23297
+ */
23298
+ function updateProfile() {
23299
+ var _a;
23300
+ return __awaiter(this, void 0, void 0, function () {
23301
+ var session, isLoggedIn, userName, initials, e_2;
23302
+ return __generator(this, function (_b) {
23303
+ switch (_b.label) {
23304
+ case 0:
23305
+ _b.trys.push([0, 2, , 3]);
23306
+ return [4 /*yield*/, BModels.Session.Get({
23307
+ sessionId: BModels.ENVIRONMENT.PARAMS.sessionId ? BModels.ENVIRONMENT.PARAMS.sessionId : "anonymous",
23308
+ })];
23309
+ case 1:
23310
+ session = (_b.sent()).session;
23311
+ isLoggedIn = session.ID != "anonymous" && ((_a = session.User) === null || _a === void 0 ? void 0 : _a.ID) != "anonymous";
23312
+ userName = session.User.FullName ? session.User.FullName : session.User.ID;
23313
+ tabButton.setAttribute("title", isLoggedIn ? userName : "Not logged in");
23314
+ // Draw a circle with the user's initials.
23315
+ if (isLoggedIn) {
23316
+ initials = getInitials(userName);
23317
+ 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 ");
23318
+ }
23319
+ else {
23320
+ buttonBookmarksIcon.innerHTML = LOGGED_OUT_ICON;
23321
+ }
23322
+ return [3 /*break*/, 3];
23323
+ case 2:
23324
+ e_2 = _b.sent();
23325
+ console.error(e_2);
23326
+ tabButton.setAttribute("title", "Not logged in");
23327
+ buttonBookmarksIcon.innerHTML = LOGGED_OUT_ICON;
23328
+ return [3 /*break*/, 3];
23329
+ case 3: return [2 /*return*/];
23330
+ }
23331
+ });
23332
+ });
23333
+ }
23334
+ if (this.envSubRemoval) {
23335
+ this.envSubRemoval();
23336
+ this.envSubRemoval = null;
23337
+ }
23338
+ this.envSubRemoval = BModels.ENVIRONMENT.OnParamsChange.Subscribe(function () {
23339
+ updateProfile();
23340
+ });
23341
+ updateProfile();
23342
+ };
23262
23343
  /**
23263
23344
  * Updates the panel styles based on the current state.
23264
23345
  * Eg: if a tab is enabled, the button should be highlighted.
@@ -23267,8 +23348,14 @@
23267
23348
  var _this = this;
23268
23349
  var buttons = this._element.querySelectorAll(".NextspaceLeftPanelButton");
23269
23350
  buttons.forEach(function (button) {
23270
- var isEnabled = button.getAttribute("widget-left-panel-tab") === _this._enabledPanelTab;
23351
+ var buttonTab = button.getAttribute("widget-left-panel-tab");
23352
+ var isEnabled = buttonTab === _this._enabledPanelTab;
23271
23353
  button.setAttribute("is-enabled", isEnabled ? "true" : "false");
23354
+ // Disable for specific tabs.
23355
+ // Eg: bookmarks require a viewId.
23356
+ if (buttonTab === "bookmarks") {
23357
+ button.setAttribute("is-disabled", !_this._viewId ? "true" : "false");
23358
+ }
23272
23359
  });
23273
23360
  // Make the tab content visible/invisible based on the current state.
23274
23361
  var contentDisplayState = this._enabledPanelTab ? "flex" : "none";
@@ -23295,6 +23382,10 @@
23295
23382
  });
23296
23383
  break;
23297
23384
  default:
23385
+ if (this.customTabs.has(this._enabledPanelTab) === false) {
23386
+ console.error("Tab ".concat(this._enabledPanelTab, " not found."));
23387
+ return;
23388
+ }
23298
23389
  tabContent = new (this.customTabs.get(this._enabledPanelTab)({
23299
23390
  widget: this,
23300
23391
  container: container
@@ -26259,7 +26350,7 @@
26259
26350
  ViewerUtils.AssertIonToken = AssertIonToken;
26260
26351
  })(exports.ViewerUtils || (exports.ViewerUtils = {}));
26261
26352
 
26262
- var VERSION = "4.2.9";
26353
+ var VERSION = "4.3.0";
26263
26354
 
26264
26355
  exports.VERSION = VERSION;
26265
26356
  exports.CesiumParabola = CesiumParabola;