@castlabs/ui 7.18.0 → 7.19.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.
@@ -1,4 +1,4 @@
1
- /* @castlabs/ui v7.18.0 */
1
+ /* @castlabs/ui v7.19.1 */
2
2
 
3
3
  /*!
4
4
  * Bootstrap v5.3.8 (https://getbootstrap.com/)
@@ -360,6 +360,9 @@ const SERVICE = {
360
360
  CP: 'Content Platform',
361
361
  CP_TAGLINE: 'Access the Content Platform, manage, encode and watermark assets',
362
362
  CP_URN: 'urn:janus:service:76b6e8558263431d9d766779987d6410',
363
+ CPS: 'Content Platform Staging',
364
+ CPS_TAGLINE: 'Access the Content Platform, manage, encode and watermark assets',
365
+ CPS_URN: 'urn:janus:service:f57f4728d2a54a0d99b77b9bb7e04bf6',
363
366
  CS: 'Castlabs hub',
364
367
  CS_TAGLINE: 'Manage organizations, plans, downloads',
365
368
  CS_URN: 'urn:janus:service:OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO',
@@ -384,6 +387,9 @@ const SERVICE = {
384
387
  VTK: 'Video Toolkit',
385
388
  VTK_TAGLINE: 'Cloud encoding, packaging, watermarking',
386
389
  VTK_URN: 'urn:janus:service:a50e21d6a5e246809b636854abfbd34d',
390
+ VTKS: 'Video Toolkit Staging',
391
+ VTKS_TAGLINE: 'Cloud encoding, packaging, watermarking',
392
+ VTKS_URN: 'urn:janus:service:ca5bb34e8f39459796778e74fa097248',
387
393
  WM: 'STARDUSTmark',
388
394
  WM_TAGLINE: 'Video & image forensic watermarking',
389
395
  WM_URN: 'urn:janus:service:76b6e8558263431d9d766779987d64c4'
@@ -446,8 +452,6 @@ const ROLE = {
446
452
  DTS_DELIVERIES: 'Deliveries',
447
453
  DTS_DELIVERIES_URN: 'urn:janus:role:e79a8f99a96a45238283b3c049e7374b',
448
454
 
449
- VTK_ADMIN: 'Video Toolkit admin',
450
- VTK_ADMIN_URN: 'urn:janus:role:8ff40a162b834e96a36f7ddbfda475ef',
451
455
  VTK_USER: 'Video Toolkit user',
452
456
  VTK_USER_URN: 'urn:janus:role:33c9c2001ca14dde9c3b310d0748b8b4',
453
457
 
@@ -500,6 +504,17 @@ const APPS = {
500
504
  sidenav: false
501
505
  },
502
506
 
507
+ CPS: {
508
+ id: 'CPS',
509
+ subtitle: SERVICE.CPS_TAGLINE,
510
+ title: SERVICE.CPS,
511
+ services: [SERVICE.CPS_URN],
512
+ roles: [ROLE.CP_USER_URN],
513
+ urlManage: (env, oid) => `https://platform.content-stag.castlabs.com/#/o/${oid ?? ''}`,
514
+ urlPlan: (env, oid) => urlCS(env, oid),
515
+ sidenav: false
516
+ },
517
+
503
518
  CS: {
504
519
  id: 'CS',
505
520
  subtitle: SERVICE.CS_TAGLINE,
@@ -619,7 +634,7 @@ const APPS = {
619
634
  id: 'VTK',
620
635
  subtitle: SERVICE.VTK_TAGLINE,
621
636
  services: [SERVICE.VTK_URN],
622
- roles: [ROLE.VTK_USER_URN, ROLE.VTK_ADMIN_URN],
637
+ roles: [ROLE.VTK_USER_URN],
623
638
  title: SERVICE.VTK,
624
639
  urlManage: (env, oid) =>
625
640
  getEnvUrl(
@@ -629,6 +644,17 @@ const APPS = {
629
644
  ),
630
645
  urlPlan: (env, oid) => urlCS(env, oid, '/plans/vtk'),
631
646
  sidenav: true
647
+ },
648
+
649
+ VTKS: {
650
+ id: 'VTKS',
651
+ subtitle: SERVICE.VTKS_TAGLINE,
652
+ title: SERVICE.VTKS,
653
+ services: [SERVICE.VTKS_URN],
654
+ roles: [ROLE.VTK_USER_URN],
655
+ urlManage: (env, oid) => `https://vtks.castlabs.com/${oid}/jobs/`,
656
+ urlPlan: (env, oid) => urlCS(env, oid, '/plans/vtk'),
657
+ sidenav: false
632
658
  }
633
659
  }
634
660
 
@@ -757,7 +783,7 @@ function variant (service, license, oid, env, hasRole) {
757
783
  // no license = show subscribe ad
758
784
  if (!license) {
759
785
  // some items are hidden if there is no license
760
- if ([APPS.DTS.id].includes(service.id)) return null
786
+ if ([APPS.DTS.id, APPS.CPS.id, APPS.VTKS.id].includes(service.id)) return null
761
787
 
762
788
  // other items we hint the user to subscribe
763
789
  return subscribe(service, oid, env)
@@ -791,12 +817,16 @@ function csGetNavVariant (membership, service, oid, env) {
791
817
  function csParseMembership (membership, oid, env) {
792
818
  const nav = [subscribed(APPS.CS, oid, env)]
793
819
 
820
+ const cps = csGetNavVariant(membership, APPS.CPS, oid, env)
821
+ if (cps) nav.push(cps)
794
822
  nav.push(csGetNavVariant(membership, APPS.DT, oid, env))
795
823
  const dts = csGetNavVariant(membership, APPS.DTS, oid, env)
796
824
  if (dts) nav.push(dts)
797
825
  nav.push(csGetNavVariant(membership, APPS.PP, oid, env))
798
826
  nav.push(csGetNavVariant(membership, APPS.WM, oid, env))
799
827
  nav.push(csGetNavVariant(membership, APPS.VTK, oid, env))
828
+ const vtks = csGetNavVariant(membership, APPS.VTKS, oid, env)
829
+ if (vtks) nav.push(vtks)
800
830
 
801
831
  return nav
802
832
  }
@@ -910,6 +940,41 @@ function clScrollToId (id, smooth = true) {
910
940
  }, 0)
911
941
  }
912
942
 
943
+ function setDomainCookieJson (name, value, maxAge = 60 * 60 * 24 * (365 + 30)) {
944
+ const b64 = btoa(JSON.stringify(value))
945
+ document.cookie = `${name}=${b64}; max-age=${maxAge}; domain=${getDomain()}; path=/; SameSite=Lax;`
946
+ }
947
+
948
+ function getDomainCookieJson (name) {
949
+ for (const cookie of document?.cookie?.split(/; */) ?? []) {
950
+ const [key, value] = cookie.split('=')
951
+ if (key === name) {
952
+ try {
953
+ return JSON.parse(atob(value))
954
+ } catch (e) {
955
+ e.ignore?.() // ignore reason
956
+ return {}
957
+ }
958
+ }
959
+ }
960
+ return {}
961
+ }
962
+
963
+ function getDomain () {
964
+ if (window.location.hostname.match(/^[0-9]+.[0-9]+.[0-9]+.[0-9]+$/)) {
965
+ // IP domain
966
+ return window.location.hostname
967
+ }
968
+ const parts = window.location.hostname.split('.').reverse()
969
+ if (parts.length > 1) {
970
+ // regular multi-part domain name
971
+ return `.${parts[1]}.${parts[0]}`
972
+ } else {
973
+ // single-name domain like 'localhost'
974
+ return parts[0]
975
+ }
976
+ }
977
+
913
978
  // -----------------------------------------------------------------------------
914
979
  // --- modals ------------------------------------------------------------------
915
980
  // -----------------------------------------------------------------------------
@@ -1716,46 +1781,23 @@ function clSleep (ms) {
1716
1781
  // -----------------------------------------------------------------------------
1717
1782
 
1718
1783
  function clThemeSetup () {
1719
- let dark = null
1720
-
1721
- // try to load settings
1722
- try {
1723
- switch (localStorage.getItem('themeDark')) {
1724
- case 'true':
1725
- dark = true
1726
- break
1727
- case 'false':
1728
- dark = false
1729
- break
1730
- default:
1731
- dark = null
1732
- }
1733
- } catch (e) {
1734
- e.ignore?.()
1735
- } // catch & ignore private mode
1736
-
1737
- // use OS default if unknown
1738
- if (dark === null) {
1739
- const darkModeMql = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)')
1740
- if (darkModeMql?.matches) {
1741
- dark = true
1742
- } else {
1743
- dark = false
1744
- }
1784
+ const settings = getDomainCookieJson('cl_ui_settings')
1785
+ const dark = settings?.theme === 'dark'
1786
+ clThemeSetDark(dark) // re-set to prolong expiration
1787
+ const checkbox = document.querySelector('#cl-mode-dark')
1788
+ if (checkbox) {
1789
+ checkbox.checked = dark
1790
+ checkbox.addEventListener('change', () => {
1791
+ clThemeSetDark(checkbox.checked)
1792
+ })
1745
1793
  }
1746
-
1747
- // persist value
1748
- clThemeSetDark(dark)
1749
-
1750
1794
  return dark
1751
1795
  }
1752
1796
 
1753
1797
  function clThemeSetDark (dark) {
1754
- try {
1755
- localStorage.setItem('themeDark', dark)
1756
- } catch (e) {
1757
- e.ignore?.()
1758
- } // catch & ignore private mode
1798
+ const settings = getDomainCookieJson('cl_ui_settings')
1799
+ settings.theme = dark ? 'dark' : 'light'
1800
+ setDomainCookieJson('cl_ui_settings', settings)
1759
1801
  }
1760
1802
 
1761
1803
  const NBSP = '✺' // non-breakable space for searching substrings