AdminStorage.vue 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249
  1. <template lang='pug'>
  2. q-page.admin-storage
  3. .row.q-pa-md.items-center
  4. .col-auto
  5. img.admin-icon.animated.fadeInLeft(src='/_assets/icons/fluent-ssd.svg')
  6. .col.q-pl-md
  7. .text-h5.text-primary.animated.fadeInLeft {{ t('admin.storage.title') }}
  8. .text-subtitle1.text-grey.animated.fadeInLeft.wait-p2s {{ t('admin.storage.subtitle') }}
  9. .col-auto.flex
  10. q-spinner-tail.q-mr-md(
  11. v-show='state.loading > 0'
  12. color='accent'
  13. size='sm'
  14. )
  15. q-btn-toggle.q-mr-md(
  16. v-model='state.displayMode'
  17. push
  18. no-caps
  19. toggle-color='black'
  20. :options=`[
  21. { label: t('admin.storage.targets'), value: 'targets' },
  22. { label: t('admin.storage.deliveryPaths'), value: 'delivery' }
  23. ]`
  24. )
  25. q-separator.q-mr-md(vertical)
  26. q-btn.q-mr-sm.acrylic-btn(
  27. icon='las la-question-circle'
  28. flat
  29. color='grey'
  30. href='https://docs.js.wiki/admin/storage'
  31. target='_blank'
  32. type='a'
  33. )
  34. q-btn(
  35. unelevated
  36. icon='fa-solid fa-check'
  37. :label='t(`common.actions.apply`)'
  38. color='secondary'
  39. @click='save'
  40. :loading='state.loading > 0'
  41. )
  42. q-separator(inset)
  43. //- ==========================================
  44. //- TARGETS
  45. //- ==========================================
  46. .row.q-pa-md.q-col-gutter-md(v-if='state.displayMode === `targets`')
  47. .col-auto
  48. q-card.rounded-borders.bg-dark
  49. q-list(
  50. style='min-width: 350px;'
  51. padding
  52. dark
  53. )
  54. q-item(
  55. v-for='tgt of state.targets'
  56. :key='tgt.key'
  57. active-class='bg-primary text-white'
  58. :active='state.selectedTarget === tgt.id'
  59. :to='`/_admin/` + adminStore.currentSiteId + `/storage/` + tgt.id'
  60. clickable
  61. )
  62. q-item-section(side)
  63. q-icon(
  64. :name='`img:` + tgt.icon'
  65. )
  66. q-item-section
  67. q-item-label {{tgt.title}}
  68. q-item-label(caption, :class='getTargetSubtitleColor(tgt)') {{getTargetSubtitle(tgt)}}
  69. q-item-section(side)
  70. q-spinner-rings(:color='tgt.isEnabled ? `positive` : `negative`', size='sm')
  71. .col(v-if='state.target')
  72. //- -----------------------
  73. //- Content Types
  74. //- -----------------------
  75. q-card.shadow-1.q-pb-sm
  76. q-card-section
  77. .text-subtitle1 {{t('admin.storage.contentTypes')}}
  78. .text-body2.text-grey {{ t('admin.storage.contentTypesHint') }}
  79. q-item(tag='label')
  80. q-item-section(avatar)
  81. q-checkbox(
  82. v-model='state.target.contentTypes.activeTypes'
  83. :color='state.target.module === `db` ? `grey` : `primary`'
  84. val='pages'
  85. :aria-label='t(`admin.storage.contentTypePages`)'
  86. :disable='state.target.module === `db`'
  87. )
  88. q-item-section
  89. q-item-label {{t(`admin.storage.contentTypePages`)}}
  90. q-item-label(caption) {{t(`admin.storage.contentTypePagesHint`)}}
  91. q-item(tag='label')
  92. q-item-section(avatar)
  93. q-checkbox(
  94. v-model='state.target.contentTypes.activeTypes'
  95. color='primary'
  96. val='images'
  97. :aria-label='t(`admin.storage.contentTypeImages`)'
  98. )
  99. q-item-section
  100. q-item-label {{t(`admin.storage.contentTypeImages`)}}
  101. q-item-label(caption) {{t(`admin.storage.contentTypeImagesHint`)}}
  102. q-item(tag='label')
  103. q-item-section(avatar)
  104. q-checkbox(
  105. v-model='state.target.contentTypes.activeTypes'
  106. color='primary'
  107. val='documents'
  108. :aria-label='t(`admin.storage.contentTypeDocuments`)'
  109. )
  110. q-item-section
  111. q-item-label {{t(`admin.storage.contentTypeDocuments`)}}
  112. q-item-label(caption) {{t(`admin.storage.contentTypeDocumentsHint`)}}
  113. q-item(tag='label')
  114. q-item-section(avatar)
  115. q-checkbox(
  116. v-model='state.target.contentTypes.activeTypes'
  117. color='primary'
  118. val='others'
  119. :aria-label='t(`admin.storage.contentTypeOthers`)'
  120. )
  121. q-item-section
  122. q-item-label {{t(`admin.storage.contentTypeOthers`)}}
  123. q-item-label(caption) {{t(`admin.storage.contentTypeOthersHint`)}}
  124. q-item(tag='label')
  125. q-item-section(avatar)
  126. q-checkbox(
  127. v-model='state.target.contentTypes.activeTypes'
  128. color='primary'
  129. val='large'
  130. :aria-label='t(`admin.storage.contentTypeLargeFiles`)'
  131. )
  132. q-item-section
  133. q-item-label {{t(`admin.storage.contentTypeLargeFiles`)}}
  134. q-item-label(caption) {{t(`admin.storage.contentTypeLargeFilesHint`)}}
  135. q-item-label.text-deep-orange(v-if='state.target.module === `db`', caption) {{t(`admin.storage.contentTypeLargeFilesDBWarn`)}}
  136. q-item-section(side)
  137. q-input(
  138. outlined
  139. :label='t(`admin.storage.contentTypeLargeFilesThreshold`)'
  140. v-model='state.target.contentTypes.largeThreshold'
  141. style='min-width: 150px;'
  142. dense
  143. )
  144. //- -----------------------
  145. //- Content Delivery
  146. //- -----------------------
  147. q-card.shadow-1.q-pb-sm.q-mt-md
  148. q-card-section
  149. .text-subtitle1 {{t('admin.storage.assetDelivery')}}
  150. .text-body2.text-grey {{ t('admin.storage.assetDeliveryHint') }}
  151. q-item(:tag='state.target.assetDelivery.isStreamingSupported ? `label` : null')
  152. q-item-section(avatar)
  153. q-checkbox(
  154. v-model='state.target.assetDelivery.streaming'
  155. :color='state.target.module === `db` || !state.target.assetDelivery.isStreamingSupported ? `grey` : `primary`'
  156. :aria-label='t(`admin.storage.contentTypePages`)'
  157. :disable='state.target.module === `db` || !state.target.assetDelivery.isStreamingSupported'
  158. )
  159. q-item-section
  160. q-item-label {{t(`admin.storage.assetStreaming`)}}
  161. q-item-label(caption) {{t(`admin.storage.assetStreamingHint`)}}
  162. q-item-label.text-deep-orange(v-if='!state.target.assetDelivery.isStreamingSupported', caption) {{t(`admin.storage.assetStreamingNotSupported`)}}
  163. q-item(:tag='state.target.assetDelivery.isDirectAccessSupported ? `label` : null')
  164. q-item-section(avatar)
  165. q-checkbox(
  166. v-model='state.target.assetDelivery.directAccess'
  167. :color='!state.target.assetDelivery.isDirectAccessSupported ? `grey` : `primary`'
  168. :aria-label='t(`admin.storage.contentTypePages`)'
  169. :disable='!state.target.assetDelivery.isDirectAccessSupported'
  170. )
  171. q-item-section
  172. q-item-label {{t(`admin.storage.assetDirectAccess`)}}
  173. q-item-label(caption) {{t(`admin.storage.assetDirectAccessHint`)}}
  174. q-item-label.text-deep-orange(v-if='!state.target.assetDelivery.isDirectAccessSupported', caption) {{t(`admin.storage.assetDirectAccessNotSupported`)}}
  175. //- -----------------------
  176. //- Setup
  177. //- -----------------------
  178. q-card.shadow-1.q-pb-sm.q-mt-md(v-if='state.target.setup && state.target.setup.handler && state.target.setup.state !== `configured`')
  179. q-card-section
  180. .text-subtitle1 {{t('admin.storage.setup')}}
  181. .text-body2.text-grey {{ t('admin.storage.setupHint') }}
  182. template(v-if='state.target.setup.handler === `github` && state.target.setup.state === `notconfigured`')
  183. q-item
  184. blueprint-icon(icon='test-account')
  185. q-item-section
  186. q-item-label GitHub Account Type
  187. q-item-label(caption) Whether to use an organization or personal GitHub account during setup.
  188. q-item-section.col-auto
  189. q-btn-toggle(
  190. v-model='state.target.setup.values.accountType'
  191. push
  192. glossy
  193. no-caps
  194. toggle-color='primary'
  195. :options=`[
  196. { label: t('admin.storage.githubAccTypeOrg'), value: 'org' },
  197. { label: t('admin.storage.githubAccTypePersonal'), value: 'personal' }
  198. ]`
  199. )
  200. q-separator.q-my-sm(inset)
  201. template(v-if='state.target.setup.values.accountType === `org`')
  202. q-item
  203. blueprint-icon(icon='github')
  204. q-item-section
  205. q-item-label {{ t('admin.storage.githubOrg') }}
  206. q-item-label(caption) {{ t('admin.storage.githubOrgHint') }}
  207. q-item-section
  208. q-input(
  209. outlined
  210. v-model='state.target.setup.values.org'
  211. dense
  212. :aria-label='t(`admin.storage.githubOrg`)'
  213. )
  214. q-separator.q-my-sm(inset)
  215. q-item
  216. blueprint-icon(icon='dns')
  217. q-item-section
  218. q-item-label {{ t('admin.storage.githubPublicUrl') }}
  219. q-item-label(caption) {{ t('admin.storage.githubPublicUrlHint') }}
  220. q-item-section
  221. q-input(
  222. outlined
  223. v-model='state.target.setup.values.publicUrl'
  224. dense
  225. :aria-label='t(`admin.storage.githubPublicUrl`)'
  226. )
  227. q-card-section.q-pt-sm.text-right
  228. form(
  229. ref='githubSetupForm'
  230. method='POST'
  231. :action='setupCfg.action'
  232. )
  233. input(
  234. type='hidden'
  235. name='manifest'
  236. :value='setupCfg.manifest'
  237. )
  238. q-btn(
  239. unelevated
  240. icon='las la-angle-double-right'
  241. :label='t(`admin.storage.startSetup`)'
  242. color='secondary'
  243. @click='setupGitHub'
  244. :loading='setupCfg.loading'
  245. )
  246. template(v-else-if='state.target.setup.handler === `github` && state.target.setup.state === `pendinginstall`')
  247. q-card-section.q-py-none
  248. q-banner(
  249. rounded
  250. :class='$q.dark.isActive ? `bg-teal-9 text-white` : `bg-teal-1 text-teal-9`'
  251. ) {{t('admin.storage.githubFinish')}}
  252. q-card-section.q-pt-sm.text-right
  253. q-btn.q-mr-sm(
  254. unelevated
  255. icon='las la-times-circle'
  256. :label='t(`admin.storage.cancelSetup`)'
  257. color='negative'
  258. @click='setupDestroy'
  259. )
  260. q-btn(
  261. unelevated
  262. icon='las la-angle-double-right'
  263. :label='t(`admin.storage.finishSetup`)'
  264. color='secondary'
  265. @click='setupGitHubStep(`verify`)'
  266. :loading='setupCfg.loading'
  267. )
  268. q-card.shadow-1.q-pb-sm.q-mt-md(v-if='state.target.setup && state.target.setup.handler && state.target.setup.state === `configured`')
  269. q-card-section
  270. .text-subtitle1 {{t('admin.storage.setup')}}
  271. .text-body2.text-grey {{ t('admin.storage.setupConfiguredHint') }}
  272. q-item
  273. blueprint-icon.self-start(icon='matches', :hue-rotate='140')
  274. q-item-section
  275. q-item-label Uninstall
  276. q-item-label(caption) Delete the active configuration and start over the setup process.
  277. q-item-label.text-red(caption): strong This action cannot be undone!
  278. q-item-section(side)
  279. q-btn.acrylic-btn(
  280. flat
  281. icon='las la-arrow-circle-right'
  282. color='negative'
  283. @click='setupDestroy'
  284. :label='t(`admin.storage.uninstall`)'
  285. )
  286. //- -----------------------
  287. //- Configuration
  288. //- -----------------------
  289. q-card.shadow-1.q-pb-sm.q-mt-md
  290. q-card-section
  291. .text-subtitle1 {{t('admin.storage.config')}}
  292. q-banner.q-mt-md(
  293. v-if='!state.target.config || Object.keys(state.target.config).length < 1'
  294. rounded
  295. :class='$q.dark.isActive ? `bg-negative text-white` : `bg-grey-2 text-grey-7`'
  296. ) {{t('admin.storage.noConfigOption')}}
  297. template(
  298. v-for='(cfg, cfgKey, idx) in state.target.config'
  299. )
  300. template(
  301. v-if='configIfCheck(cfg.if)'
  302. )
  303. q-separator.q-my-sm(inset, v-if='idx > 0')
  304. q-item(v-if='cfg.type === `Boolean`', tag='label')
  305. blueprint-icon(:icon='cfg.icon', :hue-rotate='cfg.readOnly ? -45 : 0')
  306. q-item-section
  307. q-item-label {{cfg.title}}
  308. q-item-label(caption) {{cfg.hint}}
  309. q-item-section(avatar)
  310. q-toggle(
  311. v-model='cfg.value'
  312. color='primary'
  313. checked-icon='las la-check'
  314. unchecked-icon='las la-times'
  315. :aria-label='t(`admin.general.allowComments`)'
  316. :disable='cfg.readOnly'
  317. )
  318. q-item(v-else)
  319. blueprint-icon(:icon='cfg.icon', :hue-rotate='cfg.readOnly ? -45 : 0')
  320. q-item-section
  321. q-item-label {{cfg.title}}
  322. q-item-label(caption) {{cfg.hint}}
  323. q-item-section(
  324. :style='cfg.type === `Number` ? `flex: 0 0 150px;` : ``'
  325. :class='{ "col-auto": cfg.enum && cfg.enumDisplay === `buttons` }'
  326. )
  327. q-btn-toggle(
  328. v-if='cfg.enum && cfg.enumDisplay === `buttons`'
  329. v-model='cfg.value'
  330. push
  331. glossy
  332. no-caps
  333. toggle-color='primary'
  334. :options=`cfg.enum`
  335. :disable='cfg.readOnly'
  336. )
  337. q-select(
  338. v-else-if='cfg.enum'
  339. outlined
  340. v-model='cfg.value'
  341. :options='cfg.enum'
  342. emit-value
  343. map-options
  344. dense
  345. options-dense
  346. :aria-label='cfg.title'
  347. :disable='cfg.readOnly'
  348. )
  349. q-input(
  350. v-else
  351. outlined
  352. v-model='cfg.value'
  353. dense
  354. :type='cfg.multiline ? `textarea` : `input`'
  355. :aria-label='cfg.title'
  356. :disable='cfg.readOnly'
  357. )
  358. //- -----------------------
  359. //- Sync
  360. //- -----------------------
  361. q-card.shadow-1.q-pb-sm.q-mt-md(v-if='state.target.sync && Object.keys(state.target.sync).length > 0')
  362. q-card-section
  363. .text-subtitle1 {{t('admin.storage.sync')}}
  364. q-banner.q-mt-md(
  365. rounded
  366. :class='$q.dark.isActive ? `bg-negative text-white` : `bg-grey-2 text-grey-7`'
  367. ) {{t('admin.storage.noSyncModes')}}
  368. //- -----------------------
  369. //- Actions
  370. //- -----------------------
  371. q-card.shadow-1.q-pb-sm.q-mt-md
  372. q-card-section
  373. .text-subtitle1 {{t('admin.storage.actions')}}
  374. q-banner.q-mt-md(
  375. v-if='!state.target.actions || state.target.actions.length < 1'
  376. rounded
  377. :class='$q.dark.isActive ? `bg-negative text-white` : `bg-grey-2 text-grey-7`'
  378. ) {{t('admin.storage.noActions')}}
  379. q-banner.q-mt-md(
  380. v-else-if='!state.target.isEnabled'
  381. rounded
  382. :class='$q.dark.isActive ? `bg-negative text-white` : `bg-grey-2 text-grey-7`'
  383. ) {{t('admin.storage.actionsInactiveWarn')}}
  384. template(
  385. v-if='state.target.isEnabled'
  386. v-for='(act, idx) in state.target.actions'
  387. )
  388. q-separator.q-my-sm(inset, v-if='idx > 0')
  389. q-item
  390. blueprint-icon.self-start(:icon='act.icon', :hue-rotate='45')
  391. q-item-section
  392. q-item-label {{act.label}}
  393. q-item-label(caption) {{act.hint}}
  394. q-item-label.text-red(v-if='act.warn', caption): strong {{act.warn}}
  395. q-item-section(side)
  396. q-btn.acrylic-btn(
  397. flat
  398. icon='las la-arrow-circle-right'
  399. color='primary'
  400. @click=''
  401. :label='t(`common.actions.proceed`)'
  402. )
  403. .col-auto(v-if='state.target')
  404. //- -----------------------
  405. //- Infobox
  406. //- -----------------------
  407. q-card.rounded-borders.q-pb-md(style='width: 350px;')
  408. q-card-section
  409. .text-subtitle1 {{state.target.title}}
  410. q-img.q-mt-sm.rounded-borders(
  411. :src='target.banner'
  412. fit='cover'
  413. no-spinner
  414. )
  415. .text-body2.q-mt-md {{state.target.description}}
  416. q-separator.q-mb-sm(inset)
  417. q-item
  418. q-item-section
  419. q-item-label.text-grey {{t(`admin.storage.vendor`)}}
  420. q-item-label {{state.target.vendor}}
  421. q-separator.q-my-sm(inset)
  422. q-item
  423. q-item-section
  424. q-item-label.text-grey {{t(`admin.storage.vendorWebsite`)}}
  425. q-item-label: a(:href='state.target.website', target='_blank', rel='noreferrer') {{state.target.website}}
  426. //- -----------------------
  427. //- Status
  428. //- -----------------------
  429. q-card.rounded-borders.q-pb-md.q-mt-md(style='width: 350px;')
  430. q-card-section
  431. .text-subtitle1 Status
  432. template(v-if='state.target.module !== `db` && !(state.target.setup && state.target.setup.handler && state.target.setup.state !== `configured`)')
  433. q-item(tag='label')
  434. q-item-section
  435. q-item-label {{t(`admin.storage.enabled`)}}
  436. q-item-label(caption) {{t(`admin.storage.enabledHint`)}}
  437. q-item-label.text-deep-orange(v-if='state.target.module === `db`', caption) {{t(`admin.storage.enabledForced`)}}
  438. q-item-section(avatar)
  439. q-toggle(
  440. v-model='state.target.isEnabled'
  441. :disable='state.target.module === `db` || (state.target.setup && state.target.setup.handler && state.target.setup.state !== `configured`)'
  442. color='primary'
  443. checked-icon='las la-check'
  444. unchecked-icon='las la-times'
  445. :aria-label='t(`admin.general.allowSearch`)'
  446. )
  447. q-separator.q-my-sm(inset)
  448. q-item
  449. q-item-section
  450. q-item-label.text-grey {{t(`admin.storage.currentState`)}}
  451. q-item-label.text-positive No issues detected.
  452. //- -----------------------
  453. //- Versioning
  454. //- -----------------------
  455. q-card.rounded-borders.q-pb-md.q-mt-md(style='width: 350px;')
  456. q-card-section
  457. .text-subtitle1 {{t(`admin.storage.versioning`)}}
  458. .text-body2.text-grey {{t(`admin.storage.versioningHint`)}}
  459. q-item(:tag='state.target.versioning.isSupported ? `label` : null')
  460. q-item-section
  461. q-item-label {{t(`admin.storage.useVersioning`)}}
  462. q-item-label(caption) {{t(`admin.storage.useVersioningHint`)}}
  463. q-item-label.text-deep-orange(v-if='!state.target.versioning.isSupported', caption) {{t(`admin.storage.versioningNotSupported`)}}
  464. q-item-label.text-deep-orange(v-if='state.target.versioning.isForceEnabled', caption) {{t(`admin.storage.versioningForceEnabled`)}}
  465. q-item-section(avatar)
  466. q-toggle(
  467. v-model='state.target.versioning.enabled'
  468. :disable='!state.target.versioning.isSupported || state.target.versioning.isForceEnabled'
  469. color='primary'
  470. checked-icon='las la-check'
  471. unchecked-icon='las la-times'
  472. :aria-label='t(`admin.storage.useVersioning`)'
  473. )
  474. //- ==========================================
  475. //- DELIVERY PATHS
  476. //- ==========================================
  477. .row.q-pa-md.q-col-gutter-md(v-if='state.displayMode === `delivery`')
  478. .col
  479. q-card.rounded-borders
  480. q-card-section.flex.items-center
  481. .text-caption.q-mr-sm {{ t('admin.storage.deliveryPathsLegend') }}
  482. q-chip(square, dense, color='blue-1', text-color='blue-8')
  483. q-avatar(icon='las la-ellipsis-h', color='blue', text-color='white')
  484. span.text-caption.q-px-sm {{ t('admin.storage.deliveryPathsUserRequest') }}
  485. q-chip(square, dense, color='teal-1', text-color='teal-8')
  486. q-avatar(icon='las la-ellipsis-h', color='positive', text-color='white')
  487. span.text-caption.q-px-sm {{ t('admin.storage.deliveryPathsPushToOrigin') }}
  488. q-chip(square, dense, color='red-1', text-color='red-8')
  489. q-avatar(icon='las la-minus', color='negative', text-color='white')
  490. span.text-caption.q-px-sm {{ t('admin.storage.missingOrigin') }}
  491. q-separator
  492. v-network-graph(
  493. :zoom-level='2'
  494. :configs='state.deliveryConfig'
  495. :nodes='state.deliveryNodes'
  496. :edges='state.deliveryEdges'
  497. :paths='state.deliveryPaths'
  498. :layouts='state.deliveryLayouts'
  499. style='height: 600px;'
  500. )
  501. template(#override-node='{ nodeId, scale, config, ...slotProps }')
  502. rect(
  503. :rx='config.borderRadius * scale'
  504. :x='-config.radius * scale'
  505. :y='-config.radius * scale'
  506. :width='config.radius * scale * 2'
  507. :height='config.radius * scale * 2'
  508. :fill='config.color'
  509. v-bind='slotProps'
  510. )
  511. image(
  512. v-if='state.deliveryNodes[nodeId].icon && state.deliveryNodes[nodeId].icon.endsWith(`.svg`)'
  513. :x='(-config.radius + 5) * scale'
  514. :y='(-config.radius + 5) * scale'
  515. :width='(config.radius - 5) * scale * 2'
  516. :height='(config.radius - 5) * scale * 2'
  517. :xlink:href='state.deliveryNodes[nodeId].icon'
  518. )
  519. text(
  520. v-if='state.deliveryNodes[nodeId].icon && state.deliveryNodes[nodeId].iconText'
  521. :class='state.deliveryNodes[nodeId].icon'
  522. :font-size='22 * scale'
  523. fill='#ffffff'
  524. text-anchor='middle'
  525. dominant-baseline='central'
  526. v-html='state.deliveryNodes[nodeId].iconText'
  527. )
  528. //- .overline.my-5 {{t('admin.storage.syncDirection')}}
  529. //- .body-2.ml-3 {{t('admin.storage.syncDirectionSubtitle')}}
  530. //- .pr-3.pt-3
  531. //- v-radio-group.ml-3.py-0(v-model='target.mode')
  532. //- v-radio(
  533. //- :label='t(`admin.storage.syncDirBi`)'
  534. //- color='primary'
  535. //- value='sync'
  536. //- :disabled='target.supportedModes.indexOf(`sync`) < 0'
  537. //- )
  538. //- v-radio(
  539. //- :label='t(`admin.storage.syncDirPush`)'
  540. //- color='primary'
  541. //- value='push'
  542. //- :disabled='target.supportedModes.indexOf(`push`) < 0'
  543. //- )
  544. //- v-radio(
  545. //- :label='t(`admin.storage.syncDirPull`)'
  546. //- color='primary'
  547. //- value='pull'
  548. //- :disabled='target.supportedModes.indexOf(`pull`) < 0'
  549. //- )
  550. //- .body-2.ml-3
  551. //- strong {{t('admin.storage.syncDirBi')}} #[em.red--text.text--lighten-2(v-if='target.supportedModes.indexOf(`sync`) < 0') {{t('admin.storage.unsupported')}}]
  552. //- .pb-3 {{t('admin.storage.syncDirBiHint')}}
  553. //- strong {{t('admin.storage.syncDirPush')}} #[em.red--text.text--lighten-2(v-if='target.supportedModes.indexOf(`push`) < 0') {{t('admin.storage.unsupported')}}]
  554. //- .pb-3 {{t('admin.storage.syncDirPushHint')}}
  555. //- strong {{t('admin.storage.syncDirPull')}} #[em.red--text.text--lighten-2(v-if='target.supportedModes.indexOf(`pull`) < 0') {{t('admin.storage.unsupported')}}]
  556. //- .pb-3 {{t('admin.storage.syncDirPullHint')}}
  557. //- template(v-if='target.hasSchedule')
  558. //- v-divider.mt-3
  559. //- .overline.my-5 {{t('admin.storage.syncSchedule')}}
  560. //- .body-2.ml-3 {{t('admin.storage.syncScheduleHint')}}
  561. //- .pa-3
  562. //- duration-picker(v-model='target.syncInterval')
  563. //- i18next.caption.mt-3(path='admin.storage.syncScheduleCurrent', tag='div')
  564. //- strong(place='schedule') {{getDefaultSchedule(target.syncInterval)}}
  565. //- i18next.caption(path='admin.storage.syncScheduleDefault', tag='div')
  566. //- strong(place='schedule') {{getDefaultSchedule(target.syncIntervalDefault)}}
  567. </template>
  568. <script setup>
  569. import find from 'lodash/find'
  570. import cloneDeep from 'lodash/cloneDeep'
  571. import gql from 'graphql-tag'
  572. import transform from 'lodash/transform'
  573. import * as VNetworkGraph from 'v-network-graph'
  574. import { useI18n } from 'vue-i18n'
  575. import { useMeta, useQuasar } from 'quasar'
  576. import { computed, nextTick, onMounted, reactive, ref, watch } from 'vue'
  577. import { useRouter, useRoute } from 'vue-router'
  578. import { useAdminStore } from 'src/stores/admin'
  579. import { useSiteStore } from 'src/stores/site'
  580. import { useDataStore } from 'src/stores/data'
  581. import GithubSetupInstallDialog from '../components/GithubSetupInstallDialog.vue'
  582. // QUASAR
  583. const $q = useQuasar()
  584. // STORES
  585. const adminStore = useAdminStore()
  586. const siteStore = useSiteStore()
  587. const dataStore = useDataStore()
  588. // ROUTER
  589. const router = useRouter()
  590. const route = useRoute()
  591. // I18N
  592. const { t } = useI18n()
  593. // META
  594. useMeta({
  595. title: t('admin.storage.title')
  596. })
  597. // DATA
  598. const state = reactive({
  599. loading: 0,
  600. displayMode: 'targets',
  601. runningAction: false,
  602. runningActionHandler: '',
  603. selectedTarget: '',
  604. desiredTarget: '',
  605. target: null,
  606. targets: [],
  607. setupCfg: {
  608. action: '',
  609. manifest: '',
  610. loading: false
  611. },
  612. deliveryNodes: {},
  613. deliveryEdges: {},
  614. deliveryLayouts: {
  615. nodes: {}
  616. },
  617. deliveryPaths: [],
  618. deliveryConfig: VNetworkGraph.defineConfigs({
  619. view: {
  620. layoutHandler: new VNetworkGraph.GridLayout({ grid: 15 }),
  621. fit: true,
  622. mouseWheelZoomEnabled: false,
  623. grid: {
  624. visible: true,
  625. interval: 2.5,
  626. thickIncrements: 0
  627. }
  628. },
  629. node: {
  630. draggable: false,
  631. selectable: true,
  632. normal: {
  633. type: 'rect',
  634. color: node => node.color || '#1976D2',
  635. borderRadius: node => node.borderRadius || 5
  636. },
  637. label: {
  638. margin: 8
  639. }
  640. },
  641. edge: {
  642. normal: {
  643. width: 3,
  644. dasharray: edge => edge.animate === false ? 20 : 3,
  645. animate: edge => !(edge.animate === false),
  646. animationSpeed: edge => edge.animationSpeed || 50,
  647. color: edge => edge.color || '#1976D2'
  648. },
  649. type: 'straight',
  650. gap: 7,
  651. margin: 4,
  652. marker: {
  653. source: {
  654. type: 'none'
  655. },
  656. target: {
  657. type: 'none'
  658. }
  659. }
  660. },
  661. path: {
  662. visible: true,
  663. end: 'edgeOfNode',
  664. margin: 4,
  665. path: {
  666. width: 7,
  667. color: p => p.color,
  668. linecap: 'square'
  669. }
  670. }
  671. })
  672. })
  673. // REFS
  674. const githubSetupForm = ref(null)
  675. // WATCHERS
  676. watch(() => adminStore.currentSiteId, async (newValue) => {
  677. await load()
  678. nextTick(() => {
  679. router.replace(`/_admin/${newValue}/storage/${state.selectedTarget}`)
  680. })
  681. })
  682. watch(() => state.displayMode, (newValue) => {
  683. if (newValue === 'delivery') {
  684. generateGraph()
  685. }
  686. })
  687. watch(() => state.selectedTarget, (newValue) => {
  688. state.target = find(state.targets, ['id', newValue]) || null
  689. })
  690. watch(() => state.targets, (newValue) => {
  691. if (newValue && newValue.length > 0) {
  692. if (state.desiredTarget) {
  693. state.selectedTarget = state.desiredTarget
  694. state.desiredTarget = ''
  695. } else {
  696. state.selectedTarget = find(state.targets, ['module', 'db'])?.id || null
  697. if (!route.params.id) {
  698. router.replace(`/_admin/${adminStore.currentSiteId}/storage/${state.selectedTarget}`)
  699. }
  700. }
  701. handleSetupCallback()
  702. }
  703. })
  704. watch(() => route, (to, from) => {
  705. if (!to.params.id) {
  706. return
  707. }
  708. if (state.targets.length < 1) {
  709. state.desiredTarget = to.params.id
  710. } else {
  711. state.selectedTarget = to.params.id
  712. }
  713. })
  714. // METHODS
  715. async function load () {
  716. state.loading++
  717. $q.loading.show()
  718. try {
  719. const resp = await APOLLO_CLIENT.query({
  720. query: gql`
  721. query getStorageTargets (
  722. $siteId: UUID!
  723. ) {
  724. storageTargets (
  725. siteId: $siteId
  726. ) {
  727. id
  728. isEnabled
  729. module
  730. title
  731. description
  732. icon
  733. banner
  734. vendor
  735. website
  736. contentTypes
  737. assetDelivery
  738. versioning
  739. sync
  740. status
  741. setup
  742. config
  743. actions
  744. }
  745. }`,
  746. variables: {
  747. siteId: adminStore.currentSiteId
  748. },
  749. fetchPolicy: 'network-only'
  750. })
  751. state.targets = cloneDeep(resp?.data?.storageTargets)
  752. } catch (err) {
  753. $q.notify({
  754. type: 'negative',
  755. message: 'Failed to load storage configuration.',
  756. caption: err.message,
  757. timeout: 20000
  758. })
  759. }
  760. $q.loading.hide()
  761. state.loading--
  762. }
  763. function configIfCheck (ifs) {
  764. if (!ifs || ifs.length < 1) { return true }
  765. return ifs.every(s => state.target.config[s.key]?.value === s.eq)
  766. }
  767. async function refresh () {
  768. await load()
  769. $q.notify({
  770. type: 'positive',
  771. message: 'List of storage targets has been refreshed.'
  772. })
  773. }
  774. async function save ({ silent }) {
  775. let saveSuccess = false
  776. if (!silent) { $q.loading.show() }
  777. try {
  778. const resp = await APOLLO_CLIENT.mutate({
  779. mutation: gql`
  780. mutation (
  781. $siteId: UUID!
  782. $targets: [StorageTargetInput]!
  783. ) {
  784. updateStorageTargets(
  785. siteId: $siteId
  786. targets: $targets
  787. ) {
  788. status {
  789. succeeded
  790. message
  791. }
  792. }
  793. }
  794. `,
  795. variables: {
  796. siteId: adminStore.currentSiteId,
  797. targets: state.targets.map(tgt => ({
  798. id: tgt.id,
  799. module: tgt.module,
  800. isEnabled: tgt.isEnabled,
  801. contentTypes: tgt.contentTypes.activeTypes,
  802. largeThreshold: tgt.contentTypes.largeThreshold,
  803. assetDeliveryFileStreaming: tgt.assetDelivery.streaming,
  804. assetDeliveryDirectAccess: tgt.assetDelivery.directAccess,
  805. useVersioning: tgt.versioning.enabled,
  806. config: transform(tgt.config, (r, v, k) => { r[k] = v.value }, {})
  807. }))
  808. }
  809. })
  810. if (resp?.data?.updateStorageTargets?.status?.succeeded) {
  811. saveSuccess = true
  812. if (!silent) {
  813. $q.notify({
  814. type: 'positive',
  815. message: t('admin.storage.saveSuccess')
  816. })
  817. }
  818. } else {
  819. throw new Error(resp?.data?.updateStorageTargets?.status?.message || 'Unexpected error')
  820. }
  821. } catch (err) {
  822. $q.notify({
  823. type: 'negative',
  824. message: t('admin.storage.saveFailed'),
  825. caption: err.message
  826. })
  827. }
  828. if (!silent) { $q.loading.hide() }
  829. return saveSuccess
  830. }
  831. function getTargetSubtitle (target) {
  832. if (!target.isEnabled) {
  833. return t('admin.storage.inactiveTarget')
  834. }
  835. const hasPages = target.contentTypes?.activeTypes?.includes('pages')
  836. const hasAssets = target.contentTypes?.activeTypes?.filter(c => c !== 'pages')?.length > 0
  837. if (hasPages && hasAssets) {
  838. return t('admin.storage.pagesAndAssets')
  839. } else if (hasPages) {
  840. return t('admin.storage.pagesOnly')
  841. } else if (hasAssets) {
  842. return t('admin.storage.assetsOnly')
  843. } else {
  844. return t('admin.storage.notConfigured')
  845. }
  846. }
  847. function getTargetSubtitleColor (target) {
  848. if (state.selectedTarget === target.id) {
  849. return 'text-blue-2'
  850. } else if (target.isEnabled) {
  851. return 'text-positive'
  852. } else {
  853. return 'text-grey-7'
  854. }
  855. }
  856. function getDefaultSchedule (val) {
  857. if (!val) { return 'N/A' }
  858. return '' // moment.duration(val).format('y [years], M [months], d [days], h [hours], m [minutes]')
  859. }
  860. async function executeAction (targetKey, handler) {
  861. // this.$store.commit('loadingStart', 'admin-storage-executeaction')
  862. // this.runningAction = true
  863. // this.runningActionHandler = handler
  864. // try {
  865. // await this.$apollo.mutate({
  866. // mutation: gql`{}`,
  867. // variables: {
  868. // targetKey,
  869. // handler
  870. // }
  871. // })
  872. // this.$store.commit('showNotification', {
  873. // message: 'Action completed.',
  874. // style: 'success',
  875. // icon: 'check'
  876. // })
  877. // } catch (err) {
  878. // console.warn(err)
  879. // }
  880. // this.runningAction = false
  881. // this.runningActionHandler = ''
  882. // this.$store.commit('loadingStop', 'admin-storage-executeaction')
  883. }
  884. async function handleSetupCallback () {
  885. if (state.targets.length < 1 || !state.selectedTarget) { return }
  886. nextTick(() => {
  887. if (state.target?.setup?.handler === 'github' && route.query.code) {
  888. setupGitHubStep('connect', route.query.code)
  889. }
  890. })
  891. }
  892. async function setupDestroy () {
  893. $q.dialog({
  894. title: t('admin.storage.destroyConfirm'),
  895. message: t('admin.storage.destroyConfirmInfo'),
  896. cancel: true,
  897. persistent: true
  898. }).onOk(async () => {
  899. $q.loading.show({
  900. message: t('admin.storage.destroyingSetup')
  901. })
  902. try {
  903. const resp = await APOLLO_CLIENT.mutate({
  904. mutation: gql`
  905. mutation (
  906. $targetId: UUID!
  907. ) {
  908. destroyStorageTargetSetup(
  909. targetId: $targetId
  910. ) {
  911. status {
  912. succeeded
  913. message
  914. }
  915. }
  916. }
  917. `,
  918. variables: {
  919. targetId: state.selectedTarget
  920. }
  921. })
  922. if (resp?.data?.destroyStorageTargetSetup?.status?.succeeded) {
  923. state.target.setup.state = 'notconfigured'
  924. setTimeout(() => {
  925. $q.loading.hide()
  926. $q.notify({
  927. type: 'positive',
  928. message: t('admin.storage.githubSetupDestroySuccess')
  929. })
  930. }, 2000)
  931. } else {
  932. throw new Error(resp?.data?.destroyStorageTargetSetup?.status?.message || 'Unexpected error')
  933. }
  934. } catch (err) {
  935. $q.notify({
  936. type: 'negative',
  937. message: t('admin.storage.githubSetupDestroyFailed'),
  938. caption: err.message
  939. })
  940. $q.loading.hide()
  941. }
  942. })
  943. }
  944. async function setupGitHub () {
  945. // -> Format values
  946. state.target.setup.values.publicUrl = state.target.setup.values.publicUrl.toLowerCase()
  947. // -> Basic input check
  948. if (state.target.setup.values.accountType === 'org' && state.target.setup.values.org.length < 1) {
  949. return $q.notify({
  950. type: 'negative',
  951. message: 'Invalid GitHub Organization',
  952. caption: 'Enter a valid github organization.'
  953. })
  954. }
  955. if (state.target.setup.values.publicUrl.length < 11 || !/^https?:\/\/.{4,}$/.test(state.target.setup.values.publicUrl)) {
  956. return $q.notify({
  957. type: 'negative',
  958. message: 'Invalid Wiki Public URL',
  959. caption: 'Enter a valid public URL for your wiki.'
  960. })
  961. }
  962. if (state.target.setup.values.publicUrl.endsWith('/')) {
  963. state.target.setup.values.publicUrl = state.target.setup.values.publicUrl.slice(0, -1)
  964. }
  965. // -> Generate manifest
  966. state.setupCfg.loading = true
  967. if (state.target.setup.values.accountType === 'org') {
  968. state.setupCfg.action = `https://github.com/organizations/${state.target.setup.values.org}/settings/apps/new`
  969. } else {
  970. state.setupCfg.action = 'https://github.com/settings/apps/new'
  971. }
  972. state.setupCfg.manifest = JSON.stringify({
  973. name: `Wiki.js - ${adminStore.currentSiteId.slice(-12)}`,
  974. description: 'Connects your Wiki.js to GitHub repositories and synchronize their contents.',
  975. url: state.target.setup.values.publicUrl,
  976. hook_attributes: {
  977. url: `${state.target.setup.values.publicUrl}/_github/${adminStore.currentSiteId}/events`
  978. },
  979. redirect_url: `${state.target.setup.values.publicUrl}/_admin/${adminStore.currentSiteId}/storage/${state.target.id}`,
  980. callback_urls: [
  981. `${state.target.setup.values.publicUrl}/_admin/${adminStore.currentSiteId}/storage/${state.target.id}`
  982. ],
  983. public: false,
  984. default_permissions: {
  985. contents: 'write',
  986. metadata: 'read',
  987. members: 'read'
  988. },
  989. default_events: [
  990. 'create',
  991. 'delete',
  992. 'push'
  993. ]
  994. })
  995. $q.loading.show({
  996. message: t('admin.storage.githubPreparingManifest')
  997. })
  998. if (await save({ silent: true })) {
  999. githubSetupForm.value.submit()
  1000. } else {
  1001. state.setupCfg.loading = false
  1002. $q.loading.hide()
  1003. }
  1004. }
  1005. async function setupGitHubStep (step, code) {
  1006. $q.loading.show({
  1007. message: t('admin.storage.githubVerifying')
  1008. })
  1009. try {
  1010. const resp = await APOLLO_CLIENT.mutate({
  1011. mutation: gql`
  1012. mutation (
  1013. $targetId: UUID!
  1014. $state: JSON!
  1015. ) {
  1016. setupStorageTarget(
  1017. targetId: $targetId
  1018. state: $state
  1019. ) {
  1020. status {
  1021. succeeded
  1022. message
  1023. }
  1024. state
  1025. }
  1026. }
  1027. `,
  1028. variables: {
  1029. targetId: this.selectedTarget,
  1030. state: {
  1031. step,
  1032. ...code && { code }
  1033. }
  1034. }
  1035. })
  1036. if (resp?.data?.setupStorageTarget?.status?.succeeded) {
  1037. switch (resp.data.setupStorageTarget.state?.nextStep) {
  1038. case 'installApp': {
  1039. router.replace({ query: null })
  1040. $q.loading.hide()
  1041. $q.dialog({
  1042. component: GithubSetupInstallDialog,
  1043. persistent: true
  1044. }).onOk(() => {
  1045. $q.loading.show({
  1046. message: t('admin.storage.githubRedirecting')
  1047. })
  1048. window.location.assign(resp.data.setupStorageTarget.state?.url)
  1049. }).onCancel(() => {
  1050. throw new Error('Setup was aborted prematurely.')
  1051. })
  1052. break
  1053. }
  1054. case 'completed': {
  1055. this.target.isEnabled = true
  1056. this.target.setup.state = 'configured'
  1057. setTimeout(() => {
  1058. $q.loading.hide()
  1059. $q.notify({
  1060. type: 'positive',
  1061. message: t('admin.storage.githubSetupSuccess')
  1062. })
  1063. }, 2000)
  1064. break
  1065. }
  1066. default: {
  1067. throw new Error('Unknown Setup Step')
  1068. }
  1069. }
  1070. } else {
  1071. throw new Error(resp?.data?.setupStorageTarget?.status?.message || 'Unexpected error')
  1072. }
  1073. } catch (err) {
  1074. $q.loading.hide()
  1075. $q.notify({
  1076. type: 'negative',
  1077. message: t('admin.storage.githubSetupFailed'),
  1078. caption: err.message
  1079. })
  1080. }
  1081. }
  1082. function generateGraph () {
  1083. const types = [
  1084. { key: 'images', label: t('admin.storage.contentTypeImages'), icon: 'las', iconText: '&#xf1c5;' },
  1085. { key: 'documents', label: t('admin.storage.contentTypeDocuments'), icon: 'las', iconText: '&#xf1c1;' },
  1086. { key: 'others', label: t('admin.storage.contentTypeOthers'), icon: 'las', iconText: '&#xf15b;' },
  1087. { key: 'large', label: t('admin.storage.contentTypeLargeFiles'), icon: 'las', iconText: '&#xf1c6;' }
  1088. ]
  1089. // -> Create PagesNodes
  1090. state.deliveryNodes = {
  1091. user: { name: t('admin.storage.deliveryPathsUser'), borderRadius: 16, icon: '/_assets/icons/fluent-account.svg' },
  1092. pages: { name: t('admin.storage.contentTypePages'), color: '#3f51b5', icon: 'las', iconText: '&#xf15c;' },
  1093. pages_wiki: { name: 'Wiki.js', icon: '/_assets/logo-wikijs.svg', color: '#161b22' }
  1094. }
  1095. state.deliveryEdges = {
  1096. user_pages: { source: 'user', target: 'pages' },
  1097. pages_in: { source: 'pages', target: 'pages_wiki' },
  1098. pages_out: { source: 'pages_wiki', target: 'pages' }
  1099. }
  1100. state.deliveryLayouts.nodes = {
  1101. user: { x: -30, y: 30 },
  1102. pages: { x: 0, y: 0 },
  1103. pages_wiki: { x: 60, y: 0 }
  1104. }
  1105. state.deliveryPaths = []
  1106. // -> Create Asset Nodes
  1107. for (const [i, tp] of types.entries()) {
  1108. state.deliveryNodes[tp.key] = { name: tp.label, color: '#3f51b5', icon: tp.icon, iconText: tp.iconText }
  1109. state.deliveryEdges[`user_${tp.key}`] = { source: 'user', target: t.key }
  1110. state.deliveryLayouts.nodes[tp.key] = { x: 0, y: (i + 1) * 15 }
  1111. // -> Find target with direct access
  1112. const dt = find(state.targets, tgt => {
  1113. return tgt.module !== 'db' && tgt.contentTypes.activeTypes.includes(tp.key) && tgt.isEnabled && tgt.assetDelivery.isDirectAccessSupported && tgt.assetDelivery.directAccess
  1114. })
  1115. if (dt) {
  1116. state.deliveryNodes[`${tp.key}_${dt.module}`] = { name: dt.title, icon: dt.icon }
  1117. state.deliveryNodes[`${tp.key}_wiki`] = { name: 'Wiki.js', icon: '/_assets/logo-wikijs.svg', color: '#161b22' }
  1118. state.deliveryLayouts.nodes[`${tp.key}_${dt.module}`] = { x: 60, y: (i + 1) * 15 }
  1119. state.deliveryLayouts.nodes[`${tp.key}_wiki`] = { x: 120, y: (i + 1) * 15 }
  1120. state.deliveryEdges[`${tp.key}_${dt.module}_in`] = { source: tp.key, target: `${tp.key}_${dt.module}` }
  1121. state.deliveryEdges[`${tp.key}_${dt.module}_out`] = { source: `${tp.key}_${dt.module}`, target: tp.key }
  1122. state.deliveryEdges[`${tp.key}_${dt.module}_wiki`] = { source: `${tp.key}_wiki`, target: `${tp.key}_${dt.module}`, color: '#02c39a', animationSpeed: 25 }
  1123. continue
  1124. }
  1125. // -> Find target with streaming
  1126. const st = find(state.targets, tgt => {
  1127. return tgt.module !== 'db' && tgt.contentTypes.activeTypes.includes(tp.key) && tgt.isEnabled && tgt.assetDelivery.isStreamingSupported && tgt.assetDelivery.streaming
  1128. })
  1129. if (st) {
  1130. state.deliveryNodes[`${tp.key}_${st.module}`] = { name: st.title, icon: st.icon }
  1131. state.deliveryNodes[`${tp.key}_wiki`] = { name: 'Wiki.js', icon: '/_assets/logo-wikijs.svg', color: '#161b22' }
  1132. state.deliveryLayouts.nodes[`${tp.key}_${st.module}`] = { x: 120, y: (i + 1) * 15 }
  1133. state.deliveryLayouts.nodes[`${tp.key}_wiki`] = { x: 60, y: (i + 1) * 15 }
  1134. state.deliveryEdges[`${tp.key}_wiki_in`] = { source: tp.key, target: `${tp.key}_wiki` }
  1135. state.deliveryEdges[`${tp.key}_wiki_out`] = { source: `${tp.key}_wiki`, target: tp.key }
  1136. state.deliveryEdges[`${tp.key}_${st.module}_out`] = { source: `${tp.key}_${st.module}`, target: `${tp.key}_wiki` }
  1137. state.deliveryEdges[`${tp.key}_${st.module}_in`] = { source: `${tp.key}_wiki`, target: `${tp.key}_${st.module}` }
  1138. state.deliveryEdges[`${tp.key}_${st.module}_wiki`] = { source: `${tp.key}_wiki`, target: `${tp.key}_${st.module}`, color: '#02c39a', animationSpeed: 25 }
  1139. continue
  1140. }
  1141. // -> Check DB fallback
  1142. const dbt = find(state.targets, ['module', 'db'])
  1143. if (dbt.contentTypes.activeTypes.includes(tp.key)) {
  1144. state.deliveryNodes[`${tp.key}_wiki`] = { name: 'Wiki.js', icon: '/_assets/logo-wikijs.svg', color: '#161b22' }
  1145. state.deliveryLayouts.nodes[`${tp.key}_wiki`] = { x: 60, y: (i + 1) * 15 }
  1146. state.deliveryEdges[`${tp.key}_db_in`] = { source: tp.key, target: `${tp.key}_wiki` }
  1147. state.deliveryEdges[`${tp.key}_db_out`] = { source: `${tp.key}_wiki`, target: tp.key }
  1148. } else {
  1149. state.deliveryNodes[`${tp.key}_wiki`] = { name: t('admin.storage.missingOrigin'), color: '#f03a47', icon: 'las', iconText: '&#xf071;' }
  1150. state.deliveryLayouts.nodes[`${tp.key}_wiki`] = { x: 60, y: (i + 1) * 15 }
  1151. state.deliveryEdges[`${tp.key}_db_in`] = { source: tp.key, target: `${tp.key}_wiki`, color: '#f03a47', animate: false }
  1152. state.deliveryPaths.push({ edges: [`${tp.key}_db_in`], color: '#f03a4755' })
  1153. }
  1154. }
  1155. }
  1156. // MOUNTED
  1157. onMounted(() => {
  1158. if (!state.selectedTarget && route.params.id) {
  1159. if (state.targets.length < 1) {
  1160. state.desiredTarget = route.params.id
  1161. } else {
  1162. state.selectedTarget = route.params.id
  1163. }
  1164. }
  1165. if (adminStore.currentSiteId) {
  1166. load()
  1167. }
  1168. handleSetupCallback()
  1169. })
  1170. </script>
  1171. <style lang='scss' scoped>
  1172. .admin-storage-logo {
  1173. border-radius: 5px;
  1174. }
  1175. </style>