@castlabs/ui 7.10.0 → 7.12.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.
@@ -1,4 +1,4 @@
1
- /* @castlabs/ui v7.10.0 */
1
+ /* @castlabs/ui v7.12.0 */
2
2
 
3
3
  /*!
4
4
  * Bootstrap v5.3.8 (https://getbootstrap.com/)
@@ -114,8 +114,17 @@ function clSidenavInitiallyOpen () {
114
114
 
115
115
  const cookieName = 'cl_banner_nok'
116
116
 
117
- function clCookieBannerSetup () {
118
- clMatomoSetup()
117
+ function clCookieBannerSetup (siteId = 1, forced = false) {
118
+ if (
119
+ !window.location.hostname.match(/castlabs.com$/) &&
120
+ !window.location.search.match('mtm=DEBUG') &&
121
+ !forced
122
+ ) {
123
+ console.info(`skipping cookie banner on ${window.location.hostname ?? 'unknown domain'}`)
124
+ return
125
+ }
126
+
127
+ clMatomoSetup(siteId)
119
128
  let show = true
120
129
  for (const cookie of document?.cookie?.split(/; */) ?? []) {
121
130
  const [name, value] = cookie.split('=')
@@ -188,17 +197,17 @@ function clCookieBannerShow (accept = clCookieBannerAccept, decline = clCookieBa
188
197
  document.getElementById('cl-button-cookie-decline').addEventListener('click', decline)
189
198
  }
190
199
 
191
- function clMatomoSetup () {
200
+ function clMatomoSetup (siteId = 1, domain = 'castlabs.com') {
192
201
  const _paq = (window._paq = window._paq || [])
193
202
  _paq.push(['requireCookieConsent'])
194
203
  _paq.push(['setDocumentTitle', document.domain + '/' + document.title])
195
- _paq.push(['setCookieDomain', '*.castlabs.com'])
196
- _paq.push(['setDomains', ['*.castlabs.com']])
204
+ _paq.push(['setCookieDomain', `*.${domain}`])
205
+ _paq.push(['setDomains', [`*.${domain}`]])
197
206
  _paq.push(['trackPageView'])
198
207
  _paq.push(['enableLinkTracking'])
199
208
  ;(function () {
200
209
  _paq.push(['setTrackerUrl', 'https://castlabs.matomo.cloud/matomo.php'])
201
- _paq.push(['setSiteId', '1'])
210
+ _paq.push(['setSiteId', `${siteId}`])
202
211
  const g = document.createElement('script')
203
212
  const s = document.getElementsByTagName('script')[0]
204
213
  g.async = true
@@ -473,30 +482,12 @@ const PLAN = {
473
482
  CUSTOM: 3
474
483
  }
475
484
 
476
- const CS = {
477
- SERVICE,
478
- ROLE,
479
- STATE,
480
- LICENSE_STATE,
481
- PLAN
482
- }
483
-
484
- // ----------------------------------------------------------------------------------------
485
-
486
- function urlCS (env, oid, path) {
487
- return getDevTestUrl(
488
- env,
489
- `https://account.test.cs.castlabs.com/o/${oid ?? ''}${path ?? ''}`,
490
- `https://account.castlabs.com/o/${oid ?? ''}${path ?? ''}`
491
- )
492
- }
493
-
494
- const NAV = {
485
+ const APPS = {
495
486
  CP: {
496
487
  id: 'CP',
497
488
  subtitle: SERVICE.CP_TAGLINE,
498
489
  title: SERVICE.CP,
499
- services: [CS.SERVICE.CP_URN],
490
+ services: [SERVICE.CP_URN],
500
491
  roles: [ROLE.CP_USER_URN],
501
492
  urlManage: (env, oid) =>
502
493
  getEnvUrl(
@@ -512,7 +503,7 @@ const NAV = {
512
503
  id: 'CS',
513
504
  subtitle: SERVICE.CS_TAGLINE,
514
505
  title: SERVICE.CS,
515
- services: [CS.SERVICE.CS_URN],
506
+ services: [SERVICE.CS_URN],
516
507
  roles: [],
517
508
  urlManage: (env, oid) => urlCS(env, oid),
518
509
  urlPlan: (env, oid) => urlCS(env, oid),
@@ -523,7 +514,7 @@ const NAV = {
523
514
  id: 'DT',
524
515
  subtitle: SERVICE.DT_TAGLINE,
525
516
  title: SERVICE.DT,
526
- services: [CS.SERVICE.DT_URN],
517
+ services: [SERVICE.DT_URN],
527
518
  roles: [
528
519
  ROLE.DT_MEMBERS_URN,
529
520
  ROLE.DT_SUBORGS_URN,
@@ -547,7 +538,7 @@ const NAV = {
547
538
  id: 'DTO',
548
539
  subtitle: SERVICE.DTO_TAGLINE,
549
540
  title: SERVICE.DTO,
550
- services: [CS.SERVICE.DTO_URN],
541
+ services: [SERVICE.DTO_URN],
551
542
  roles: [
552
543
  ROLE.DTO_DEVICES_URN,
553
544
  ROLE.DTO_KEYBOX_URN,
@@ -564,7 +555,7 @@ const NAV = {
564
555
  id: 'DTS',
565
556
  subtitle: SERVICE.DTS_TAGLINE,
566
557
  title: SERVICE.DTS,
567
- services: [CS.SERVICE.DTS_URN],
558
+ services: [SERVICE.DTS_URN],
568
559
  roles: [
569
560
  ROLE.DTS_MEMBERS_URN,
570
561
  ROLE.DTS_SUBORGS_URN,
@@ -589,13 +580,13 @@ const NAV = {
589
580
  subtitle: SERVICE.PP_TAGLINE,
590
581
  title: SERVICE.PP,
591
582
  services: [
592
- CS.SERVICE.PP_URN,
593
- CS.SERVICE.PP_URN_ANDROID,
594
- CS.SERVICE.PP_URN_BROWSER,
595
- CS.SERVICE.PP_URN_GSTREAMER,
596
- CS.SERVICE.PP_URN_IOS,
597
- CS.SERVICE.PP_URN_REACTNATIVE,
598
- CS.SERVICE.PP_URN_WEBRTC
583
+ SERVICE.PP_URN,
584
+ SERVICE.PP_URN_ANDROID,
585
+ SERVICE.PP_URN_BROWSER,
586
+ SERVICE.PP_URN_GSTREAMER,
587
+ SERVICE.PP_URN_IOS,
588
+ SERVICE.PP_URN_REACTNATIVE,
589
+ SERVICE.PP_URN_WEBRTC
599
590
  ],
600
591
  roles: [ROLE.PP_USER_URN, ROLE.PP_ADMIN_URN],
601
592
  urlManage: (env, oid) =>
@@ -611,7 +602,7 @@ const NAV = {
611
602
  id: 'WM',
612
603
  subtitle: SERVICE.WM_TAGLINE,
613
604
  title: SERVICE.WM,
614
- services: [CS.SERVICE.WM_URN],
605
+ services: [SERVICE.WM_URN],
615
606
  roles: [ROLE.WM_DEMO_URN, ROLE.WM_EXTRACTION_URN],
616
607
  urlManage: (env, oid) =>
617
608
  getEnvUrl(
@@ -626,7 +617,7 @@ const NAV = {
626
617
  VTK: {
627
618
  id: 'VTK',
628
619
  subtitle: SERVICE.VTK_TAGLINE,
629
- services: [CS.SERVICE.VTK_URN],
620
+ services: [SERVICE.VTK_URN],
630
621
  roles: [ROLE.VTK_USER_URN, ROLE.VTK_ADMIN_URN],
631
622
  title: SERVICE.VTK,
632
623
  urlManage: (env, oid) =>
@@ -636,6 +627,27 @@ const NAV = {
636
627
  }
637
628
  }
638
629
 
630
+ // ----------------------------------------------------------------------------------------
631
+
632
+ const CS = {
633
+ SERVICE,
634
+ ROLE,
635
+ STATE,
636
+ LICENSE_STATE,
637
+ PLAN,
638
+ APPS
639
+ }
640
+
641
+ // ----------------------------------------------------------------------------------------
642
+
643
+ function urlCS (env, oid, path) {
644
+ return getDevTestUrl(
645
+ env,
646
+ `https://account.test.cs.castlabs.com/o/${oid ?? ''}${path ?? ''}`,
647
+ `https://account.castlabs.com/o/${oid ?? ''}${path ?? ''}`
648
+ )
649
+ }
650
+
639
651
  function getDevTestUrl (env, urlDevTest, urlOther) {
640
652
  return getEnvUrl(env, urlDevTest, urlOther, [ENV.DEV, ENV.TEST])
641
653
  }
@@ -740,7 +752,7 @@ function variant (service, license, oid, env, hasRole) {
740
752
  // no license = show subscribe ad
741
753
  if (!license) {
742
754
  // some items are hidden if there is no license
743
- if ([NAV.DTS.id].includes(service.id)) return null
755
+ if ([APPS.DTS.id].includes(service.id)) return null
744
756
 
745
757
  // other items we hint the user to subscribe
746
758
  return subscribe(service, oid, env)
@@ -772,14 +784,14 @@ function csGetNavVariant (membership, service, oid, env) {
772
784
  }
773
785
 
774
786
  function csParseMembership (membership, oid, env) {
775
- const nav = [subscribed(NAV.CS, oid, env)]
787
+ const nav = [subscribed(APPS.CS, oid, env)]
776
788
 
777
- nav.push(csGetNavVariant(membership, NAV.DT, oid, env))
778
- const dts = csGetNavVariant(membership, NAV.DTS, oid, env)
789
+ nav.push(csGetNavVariant(membership, APPS.DT, oid, env))
790
+ const dts = csGetNavVariant(membership, APPS.DTS, oid, env)
779
791
  if (dts) nav.push(dts)
780
- nav.push(csGetNavVariant(membership, NAV.PP, oid, env))
781
- nav.push(csGetNavVariant(membership, NAV.WM, oid, env))
782
- nav.push(csGetNavVariant(membership, NAV.VTK, oid, env))
792
+ nav.push(csGetNavVariant(membership, APPS.PP, oid, env))
793
+ nav.push(csGetNavVariant(membership, APPS.WM, oid, env))
794
+ nav.push(csGetNavVariant(membership, APPS.VTK, oid, env))
783
795
 
784
796
  return nav
785
797
  }
@@ -804,11 +816,11 @@ function csGetNav (memberships, oid, env) {
804
816
 
805
817
  return [
806
818
  // static nav
807
- subscribed(NAV.CS),
808
- disabled(NAV.DT),
809
- disabled(NAV.PP),
810
- disabled(NAV.WM),
811
- disabled(NAV.VTK)
819
+ subscribed(APPS.CS),
820
+ disabled(APPS.DT),
821
+ disabled(APPS.PP),
822
+ disabled(APPS.WM),
823
+ disabled(APPS.VTK)
812
824
  ]
813
825
  }
814
826
 
@@ -1637,22 +1649,6 @@ function clSleep (ms) {
1637
1649
  return new Promise(resolve => setTimeout(resolve, ms))
1638
1650
  }
1639
1651
 
1640
- // -----------------------------------------------------------------------------
1641
- // --- $ref typescript cast methods --------------------------------------------
1642
- // -----------------------------------------------------------------------------
1643
-
1644
- function clRefClField (ref) {
1645
- return ref
1646
- }
1647
-
1648
- function clRefClFieldGroup (ref) {
1649
- return ref
1650
- }
1651
-
1652
- function clRefHTMLElement (ref) {
1653
- return ref
1654
- }
1655
-
1656
1652
  const NBSP = '✺' // non-breakable space for searching substrings
1657
1653
 
1658
1654
  let cache = {}
@@ -1815,16 +1811,16 @@ function clGetServices () {
1815
1811
  // static nav items if no CS integration is available
1816
1812
  return [
1817
1813
  // sorted alphabeticaly by title
1818
- NAV.CS,
1819
- NAV.CP,
1820
- NAV.DT,
1821
- NAV.DTS,
1822
- NAV.DTO,
1823
- NAV.PP,
1824
- NAV.WM,
1825
- NAV.VTK
1814
+ CS.APPS.CS,
1815
+ CS.APPS.CP,
1816
+ CS.APPS.DT,
1817
+ CS.APPS.DTS,
1818
+ CS.APPS.DTO,
1819
+ CS.APPS.PP,
1820
+ CS.APPS.WM,
1821
+ CS.APPS.VTK
1826
1822
  ]
1827
1823
  }
1828
1824
 
1829
1825
  // compatibility export with previous ui-lib versions
1830
- const NAV = nav
1826
+ const NAV = CS.APPS