@live-change/url-frontend 0.2.4 → 0.2.6

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.
@@ -0,0 +1,48 @@
1
+ <template>
2
+ <div class="surface-section px-4 py-8 md:px-6 lg:px-8">
3
+ <div class="text-center code404">
4
+ <span class="bg-white text-pink-500 font-bold text-2xl inline-block px-3">403</span>
5
+ </div>
6
+ <div class="mt-6 mb-5 font-bold text-6xl text-900 text-center">Not authorized</div>
7
+ <p class="text-700 text-3xl mt-0 mb-6 text-center">
8
+ You do not have sufficient privileges to see this page.
9
+ </p>
10
+ <div class="text-center">
11
+ <Button v-if="canGoBack" @click="goBack()"
12
+ class="p-button-text mr-2" label="Go Back" icon="pi pi-arrow-left" />
13
+ <router-link to="/" replace class="no-underline">
14
+ <Button label="Go to Home" icon="pi pi-home" />
15
+ </router-link>
16
+ </div>
17
+ </div>
18
+ </template>
19
+
20
+ <script setup>
21
+
22
+ import Button from "primevue/button"
23
+
24
+ import { computed, ref, onMounted } from 'vue'
25
+
26
+ const isMounted = ref(false)
27
+ onMounted(() => isMounted.value = true)
28
+
29
+ const canGoBack = computed(() => {
30
+ return isMounted.value && history.length > 1
31
+ })
32
+
33
+ import { useRouter } from 'vue-router'
34
+ const router = useRouter()
35
+ function goBack() {
36
+ router.back()
37
+ }
38
+
39
+ import { useResponse } from "@live-change/frontend-base"
40
+ useResponse({ status: 403 })
41
+
42
+ </script>
43
+
44
+ <style scoped>
45
+ .code404 {
46
+ background: radial-gradient(50% 109137.91% at 50% 50%, rgba(233, 30, 99, 0.1) 0%, rgba(254, 244, 247, 0) 100%);
47
+ }
48
+ </style>
@@ -0,0 +1,45 @@
1
+ <template>
2
+ <div class="surface-section px-4 py-8 md:px-6 lg:px-8">
3
+ <div class="text-center code404">
4
+ <span class="bg-white text-pink-500 font-bold text-2xl inline-block px-3">404</span>
5
+ </div>
6
+ <div class="mt-6 mb-5 font-bold text-6xl text-900 text-center">Page Not Found</div>
7
+ <p class="text-700 text-3xl mt-0 mb-6 text-center">Sorry, we couldn't find the page.</p>
8
+ <div class="text-center">
9
+ <Button v-if="canGoBack" @click="goBack()"
10
+ class="p-button-text mr-2" label="Go Back" icon="pi pi-arrow-left" />
11
+ <router-link to="/" replace class="no-underline">
12
+ <Button label="Go to Home" icon="pi pi-home" />
13
+ </router-link>
14
+ </div>
15
+ </div>
16
+ </template>
17
+
18
+ <script setup>
19
+
20
+ import Button from "primevue/button"
21
+
22
+ import { computed, ref, onMounted } from 'vue'
23
+
24
+ const isMounted = ref(false)
25
+ onMounted(() => isMounted.value = true)
26
+
27
+ const canGoBack = computed(() => {
28
+ return isMounted.value && history.length > 1
29
+ })
30
+
31
+ import { useRouter } from 'vue-router'
32
+ const router = useRouter()
33
+ function goBack() {
34
+ router.back()
35
+ }
36
+
37
+ import { useResponse } from "@live-change/frontend-base"
38
+ useResponse({ status: 404 })
39
+ </script>
40
+
41
+ <style scoped>
42
+ .code404 {
43
+ background: radial-gradient(50% 109137.91% at 50% 50%, rgba(233, 30, 99, 0.1) 0%, rgba(254, 244, 247, 0) 100%);
44
+ }
45
+ </style>
@@ -1,25 +1,25 @@
1
1
  <template>
2
- <slot v-if="url" :url="url" :target="url.target">
3
- <pre>{{ JSON.stringify(url, null, " ") }}</pre>
4
- </slot>
5
- <slot v-else name="notFound" :path="urlPath">
6
- <div class="surface-section px-4 py-8 md:px-6 lg:px-8">
7
- <div style="background: radial-gradient(50% 109137.91% at 50% 50%, rgba(233, 30, 99, 0.1) 0%, rgba(254, 244, 247, 0) 100%);" class="text-center">
8
- <span class="bg-white text-pink-500 font-bold text-2xl inline-block px-3">404</span>
9
- </div>
10
- <div class="mt-6 mb-5 font-bold text-6xl text-900 text-center">Page Not Found</div>
11
- <p class="text-700 text-3xl mt-0 mb-6 text-center">Sorry, we couldn't find the page.</p>
12
- <div class="text-center">
13
- <Button class="p-button-text mr-2" label="Go Back" icon="pi pi-arrow-left"></Button>
14
- <Button label="Go to Dashboard" icon="pi pi-home"></Button>
15
- </div>
2
+ <slot v-if="url && accessible" :url="url" :target="url.target" :class="clazz" :style="style">
3
+ <div class="w-full surface-card p-4 shadow-2 border-round">
4
+ <h2>Url resolved:</h2>
5
+ <pre>{{ JSON.stringify(url, null, " ") }}</pre>
16
6
  </div>
17
7
  </slot>
18
-
8
+ <slot v-else-if="url">
9
+ <NotAuthorized></NotAuthorized>
10
+ </slot>
11
+ <slot v-else name="notFound" :path="urlPath" :class="clazz" :style="style">
12
+ <NotFound />
13
+ </slot>
19
14
  </template>
20
15
 
21
16
  <script setup>
22
17
 
18
+ import Button from "primevue/button"
19
+
20
+ import NotFound from "./NotFound.vue"
21
+ import NotAuthorized from "./NotAuthorized.vue"
22
+
23
23
  import { computed, watch, ref, onMounted } from 'vue'
24
24
  import { toRefs } from "@vueuse/core"
25
25
  import { useHost } from "@live-change/frontend-base"
@@ -36,12 +36,18 @@
36
36
  type: String,
37
37
  default: 'content_Page'
38
38
  },
39
+ requiredRoles: {
40
+ type: Array,
41
+ default: () => ['reader']
42
+ },
39
43
  fetchMore: {
40
44
  type: Array,
41
45
  default: () => []
42
- }
46
+ },
47
+ class: {},
48
+ style: {}
43
49
  })
44
- const { path: urlPath, targetType, fetchMore } = toRefs(props)
50
+ const { path: urlPath, targetType, fetchMore, class: clazz, style, requiredRoles } = toRefs(props)
45
51
 
46
52
  const urlDomain = useHost()
47
53
 
@@ -53,34 +59,47 @@
53
59
  const p = path()
54
60
 
55
61
  const liveUrlPath = (targetType, domain, urlPath, more) => {
56
- let fetchPath = p.url.urlsByTargetAndPath({targetType, domain, path: urlPath})
62
+ let fetchPath = p.url.urlsByTargetAndPath({ targetType, domain, path: urlPath })
57
63
  //.with(url => p.url.targetOwnedCanonical({ targetType, target: url.target }).bind('canonical'))
58
64
  .with(url => url.type.$switch({
59
65
  'canonical': null,
60
- 'redirect': p.url.targetOwnedCanonical({targetType, target: url.target})
66
+ 'redirect': p.url.targetOwnedCanonical({ targetType, target: url.target })
61
67
  }).$bind('canonical'))
68
+ .with(url => p.accessControl.myAccessTo({ objectType: targetType, object: url.target }).bind('access'))
62
69
  for (let fetch of more) {
63
70
  fetchPath = fetchPath.with(url => fetch(url))
64
71
  }
65
72
  return fetchPath
66
73
  }
67
74
 
68
-
69
75
  const livePathWithDomain = computed(
70
76
  () => liveUrlPath(targetType.value, urlDomain, urlPath.value, fetchMore.value)
71
77
  )
72
78
  const livePathWithoutDomain = computed(
73
79
  () => liveUrlPath(targetType.value, '', urlPath.value, fetchMore.value)
74
80
  )
75
- const [domainUrls, globalUrls] = await Promise.all([
76
- live(livePathWithDomain),
81
+
82
+ const [/*domainUrls,*/ globalUrls] = await Promise.all([
83
+ // live(livePathWithDomain),
77
84
  live(livePathWithoutDomain)
78
85
  ])
86
+ const domainUrls = ref([])
87
+ console.log("OK!", domainUrls.value, globalUrls.value)
79
88
  const url = computed(() => {
80
89
  if(domainUrls.value.length > 0) return domainUrls.value[0]
81
90
  if(globalUrls.value.length > 0) return globalUrls.value[0]
82
91
  return null
83
92
  })
93
+ const accessible = computed(() => {
94
+ if(!(requiredRoles?.value?.length)) return true
95
+ if(!url.value) return undefined
96
+ const clientRoles = url.value.access?.roles ?? []
97
+ for(const requiredRolesOption of requiredRoles.value) {
98
+ if((Array.isArray(requiredRolesOption) ? requiredRolesOption : [requiredRolesOption])
99
+ .every(role => clientRoles.includes(role))
100
+ ) return true
101
+ }
102
+ })
84
103
 
85
104
  if(typeof window != 'undefined') {
86
105
  watch(() => url && isMounted.value, async () => {
@@ -79,8 +79,6 @@
79
79
  import { useConfirm } from 'primevue/useconfirm'
80
80
  const confirm = useConfirm()
81
81
 
82
- import { synchronized, synchronizedList } from "@live-change/vue3-components"
83
-
84
82
  import { computed, watch, ref, onMounted } from 'vue'
85
83
 
86
84
  const isMounted = ref(false)
@@ -0,0 +1,55 @@
1
+ <template>
2
+ <div class="flex">
3
+ <i class="pi pi-globe mr-2"></i>
4
+ <template v-if="canonical">
5
+ <span class="font-bold mr-2">Url:</span>
6
+ <span class="mr-1 font-normal">{{ canonical.domain || '*' }}</span>
7
+ <span class="text-overflow-ellipsis overflow-hidden font-normal flex-grow-1">
8
+ {{props.prefix}}{{ canonical.path }}
9
+ </span>
10
+
11
+ </template>
12
+ <span v-else>No Url</span>
13
+ <template v-if="redirects.length">
14
+ <i class="pi pi-arrow-up-right mr-1 ml-3"></i>
15
+ <span class="font-bold">{{ redirects.length }}</span>
16
+ </template>
17
+ </div>
18
+ </template>
19
+
20
+ <script setup>
21
+ const props = defineProps({
22
+ target: {
23
+ type: String,
24
+ required: true
25
+ },
26
+ targetType: {
27
+ type: String,
28
+ required: true
29
+ },
30
+ prefix: {
31
+ type: String,
32
+ default: '/'
33
+ }
34
+ })
35
+
36
+ import { computed } from 'vue'
37
+
38
+ import { path, live } from '@live-change/vue3-ssr'
39
+ const p = path()
40
+ const canonicalLivePath = computed(
41
+ () => p.url.targetOwnedCanonical({ targetType: props.targetType, target: props.target })
42
+ )
43
+ const redirectsLivePath = computed(
44
+ () => p.url.targetOwnedRedirects({ targetType: props.targetType, target: props.target })
45
+ )
46
+ const [canonical, redirects] = await Promise.all([
47
+ live(canonicalLivePath),
48
+ live(redirectsLivePath)
49
+ ])
50
+
51
+ </script>
52
+
53
+ <style scoped>
54
+
55
+ </style>
package/index.js CHANGED
@@ -1,6 +1,9 @@
1
1
  import Urls from "./front/src/components/Urls.vue"
2
2
  export { Urls }
3
3
 
4
+ import UrlsInfo from "./front/src/components/UrlsInfo.vue"
5
+ export { UrlsInfo }
6
+
4
7
  import TakeUrlForm from "./front/src/components/TakeUrlForm.vue"
5
8
  export { TakeUrlForm }
6
9
 
@@ -10,5 +13,8 @@ export { GenerateUrlForm }
10
13
  import ResolveUrl from "./front/src/components/ResolveUrl.vue"
11
14
  export { ResolveUrl }
12
15
 
16
+ import NotFound from "./front/src/components/NotFound.vue"
17
+ export { NotFound }
18
+
13
19
  import sitemap from "./front/src/sitemap.js"
14
20
  export { sitemap }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/url-frontend",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "scripts": {
5
5
  "memDev": "lcli memDev --enableSessions --initScript ./init.js --dbAccess",
6
6
  "localDevInit": "rm tmp.db; lcli localDev --enableSessions --initScript ./init.js",
@@ -21,16 +21,16 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@fortawesome/fontawesome-free": "^6.1.1",
24
- "@live-change/cli": "0.6.14",
25
- "@live-change/dao": "0.5.6",
26
- "@live-change/dao-vue3": "0.5.6",
27
- "@live-change/dao-websocket": "0.5.6",
28
- "@live-change/framework": "0.6.14",
29
- "@live-change/password-authentication-service": "0.2.51",
30
- "@live-change/prosemirror-service": "0.2.51",
31
- "@live-change/secret-code-service": "0.2.51",
32
- "@live-change/secret-link-service": "0.2.51",
33
- "@live-change/session-service": "0.2.51",
24
+ "@live-change/cli": "0.7.4",
25
+ "@live-change/dao": "0.5.8",
26
+ "@live-change/dao-vue3": "0.5.8",
27
+ "@live-change/dao-websocket": "0.5.8",
28
+ "@live-change/framework": "0.7.4",
29
+ "@live-change/password-authentication-service": "0.3.2",
30
+ "@live-change/prosemirror-service": "0.3.2",
31
+ "@live-change/secret-code-service": "0.3.2",
32
+ "@live-change/secret-link-service": "0.3.2",
33
+ "@live-change/session-service": "0.3.2",
34
34
  "@live-change/vue3-components": "0.2.15",
35
35
  "@live-change/vue3-ssr": "0.2.15",
36
36
  "@tiptap/extension-blockquote": "^2.0.0-beta.29",
@@ -60,8 +60,8 @@
60
60
  "cross-env": "^7.0.3",
61
61
  "get-port-sync": "1.0.1",
62
62
  "primeflex": "^3.2.1",
63
- "primeicons": "^5.0.0",
64
- "primevue": "^3.15.0",
63
+ "primeicons": "^6.0.1",
64
+ "primevue": "^3.18.1",
65
65
  "prosemirror-collab": "^1.3.0",
66
66
  "rollup-plugin-node-builtins": "^2.1.2",
67
67
  "rollup-plugin-visualizer": "5.6.0",
@@ -73,7 +73,7 @@
73
73
  "vue3-scroll-border": "0.1.2"
74
74
  },
75
75
  "devDependencies": {
76
- "@live-change/codeceptjs-helper": "0.6.14",
76
+ "@live-change/codeceptjs-helper": "0.7.4",
77
77
  "@wdio/selenium-standalone-service": "^7.20.8",
78
78
  "codeceptjs": "^3.3.4",
79
79
  "generate-password": "1.7.0",
@@ -85,5 +85,5 @@
85
85
  "author": "",
86
86
  "license": "ISC",
87
87
  "description": "",
88
- "gitHead": "f4696b12b62875bdca61a3b3c3b584c3992792c8"
88
+ "gitHead": "323185f6d910912093b3c92df102d0f938cef367"
89
89
  }