@bagelink/vue 1.4.184 → 1.4.188

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,32 +1,47 @@
1
1
  import type { AxiosResponse } from 'axios'
2
2
  import type { BglFile, BglFilePatch, UploadOptions } from './upload.types.d.ts'
3
3
  import axios from 'axios'
4
+ import { getBagelInstance } from '../../../../composables/useBagel'
5
+
6
+ // Helper to get file version from config
7
+ const getFileVersion = () => getBagelInstance()?.fileVersion ?? 'files_v2'
4
8
 
5
9
  export const files = {
6
10
  setBaseUrl: (baseUrl?: string) => {
7
- if (!baseUrl) return
11
+ if (baseUrl === undefined || baseUrl === '') return
8
12
  baseUrl = baseUrl.replace(/\/$/, '')
9
13
  axios.defaults.baseURL = baseUrl
10
14
  },
11
15
 
12
- get: async (pathKey?: string): Promise<AxiosResponse<BglFile>> => { return axios.get('/files_v2/', { params: { path_key: pathKey } }) },
16
+ get: async (pathKey?: string): Promise<AxiosResponse<BglFile>> => {
17
+ return axios.get(`/${getFileVersion()}/`, { params: { path_key: pathKey } })
18
+ },
13
19
 
14
- put: async (bglFilePatch: BglFilePatch, pathKey?: string): Promise<AxiosResponse<BglFile>> => { return axios.put('/files_v2/', bglFilePatch, { params: { path_key: pathKey } }) },
20
+ put: async (
21
+ bglFilePatch: BglFilePatch,
22
+ pathKey?: string
23
+ ): Promise<AxiosResponse<BglFile>> => {
24
+ return axios.put(`/${getFileVersion()}/`, bglFilePatch, { params: { path_key: pathKey } })
25
+ },
15
26
 
16
- delete: async (pathKey?: string) => { return axios.delete('/files_v2/', { params: { path_key: pathKey } }) },
27
+ delete: async (pathKey?: string) => {
28
+ return axios.delete(`/${getFileVersion()}/`, { params: { path_key: pathKey } })
29
+ },
17
30
 
18
- upload: async (file: File, options?: UploadOptions & { dirPath?: string, tags?: string[] }): Promise<AxiosResponse<BglFile>> => {
31
+ upload: async (
32
+ file: File,
33
+ options?: UploadOptions & { dirPath?: string, tags?: string[] }
34
+ ): Promise<AxiosResponse<BglFile>> => {
19
35
  const formData = new FormData()
20
36
  formData.append('upload', file)
21
- return axios.post('/files_v2/upload', formData, {
37
+ return axios.post(`/${getFileVersion()}/upload`, formData, {
22
38
  headers: { 'Content-Type': 'multipart/form-data' },
23
-
24
39
  onUploadProgress: options?.onUploadProgress,
25
40
  params: { dir_path: options?.dirPath, tags: options?.tags },
26
-
27
- }) },
41
+ })
42
+ },
28
43
 
29
44
  list: async (dirPath?: string): Promise<AxiosResponse<BglFile[]>> => {
30
- return axios.get('/files_v2/list', { params: { dir_path: dirPath } })
45
+ return axios.get(`/${getFileVersion()}/list`, { params: { dir_path: dirPath } })
31
46
  }
32
47
  }
@@ -4,14 +4,14 @@ import { Btn, Icon } from '@bagelink/vue'
4
4
  import { inject, computed, ref, watch } from 'vue'
5
5
  import { useRoute } from 'vue-router'
6
6
 
7
- // Extended interface for footer links that can have actions
8
- interface FooterLink extends NavLink {
7
+ // Extended interface for links that can have actions
8
+ interface LinkWithAction extends NavLink {
9
9
  action?: () => void
10
10
  }
11
11
 
12
12
  interface Props {
13
- navLinks: NavLink[]
14
- footerLinks?: FooterLink[]
13
+ navLinks: LinkWithAction[]
14
+ footerLinks?: LinkWithAction[]
15
15
  logo?: string
16
16
  logoAlt?: string
17
17
  card?: boolean
@@ -73,47 +73,34 @@ const sidebarStyles = computed(() => {
73
73
  width,
74
74
  }
75
75
  })
76
-
77
- function logout() {
78
- console.log('Logging out...')
79
- // Add your logout logic here
80
- }
81
76
  </script>
82
77
 
83
78
  <template>
84
- <aside
85
- class="app-sidebar transition-400 fixed start top bottom h-100vh z-99" :class="{
86
- 'sidebar-mobile-open': menuState.isMobile.value && menuState.isOpen.value,
87
- 'sidebar-mobile-closed':
88
- menuState.isMobile.value && !menuState.isOpen.value,
89
- 'transitioning': isTransitioning,
90
- 'p-05': props.card,
91
- 'sidebar-collapsed': !menuState.isMobile.value && !menuState.isOpen.value,
92
- }" :style="sidebarStyles"
93
- >
94
- <div
95
- :style="{
96
- backgroundColor: props.bgColor,
97
- color: props.textColor,
98
- ...(props.card && { borderRadius: 'var(--card-border-radius)' }),
99
- }" :class="{
79
+ <aside class="app-sidebar transition-400 fixed start top bottom h-100vh z-99" :class="{
80
+ 'sidebar-mobile-open': menuState.isMobile.value && menuState.isOpen.value,
81
+ 'sidebar-mobile-closed':
82
+ menuState.isMobile.value && !menuState.isOpen.value,
83
+ 'transitioning': isTransitioning,
84
+ 'p-05': props.card,
85
+ 'sidebar-collapsed': !menuState.isMobile.value && !menuState.isOpen.value,
86
+ }" :style="sidebarStyles">
87
+ <div :style="{
88
+ backgroundColor: props.bgColor,
89
+ color: props.textColor,
90
+ ...(props.card && { borderRadius: 'var(--card-border-radius)' }),
91
+ }" :class="{
100
92
  'card cardWrapSide': props.card,
101
93
  'ps-05': !menuState.isOpen.value,
102
94
  'scrollbar-gutter-both': menuState.isOpen.value,
103
95
  'aside_frame': props.frame,
104
- }" class="overflow-hidden flex column flex-stretch gap-1 w100p pt-1 pb-05 h-100p"
105
- >
96
+ }" class="overflow-hidden flex column flex-stretch gap-1 w100p pt-1 pb-05 h-100p">
106
97
  <!-- Logo/Brand -->
107
- <router-link
108
- to="/" class="decoration-none flex px-05" :class="{
109
- 'gap-05': menuState.isOpen.value,
110
- 'gap-0': !menuState.isOpen.value,
111
- }"
112
- >
113
- <img
114
- v-if="props.logo" :src="props.logo" :alt="props.logoAlt" class="contain"
115
- :style="{ height: props.logoHeight }"
116
- >
98
+ <router-link to="/" class="decoration-none flex px-05" :class="{
99
+ 'gap-05': menuState.isOpen.value,
100
+ 'gap-0': !menuState.isOpen.value,
101
+ }">
102
+ <img v-if="props.logo" :src="props.logo" :alt="props.logoAlt" class="contain"
103
+ :style="{ height: props.logoHeight }">
117
104
  <span class="nav-text">
118
105
  {{ props.name }}
119
106
  </span>
@@ -121,17 +108,15 @@ function logout() {
121
108
 
122
109
  <!-- Navigation Links -->
123
110
  <nav class="sidebar-nav flex column flex-stretch gap-025 align-items-start scrollbar-gutter-stable">
124
- <Btn
125
- v-for="link in props.navLinks" :key="link.to" :title="!menuState.isOpen.value && !menuState.isMobile.value
126
- ? link.label
127
- : ''
111
+ <Btn v-for="link in props.navLinks" :key="link.to" :title="!menuState.isOpen.value && !menuState.isMobile.value
112
+ ? link.label
113
+ : ''
128
114
  " fullWidth alignTxt="start" class="flex-shrink-0 px-1" :class="{ 'nav-btn-active': route.path === link.to }"
129
115
  :style="{
130
116
  backgroundColor:
131
117
  route.path === link.to ? props.activeColor : props.bgColor,
132
118
  color: route.path === link.to ? 'white' : props.textColor,
133
- }" :to="link.to || '/'"
134
- >
119
+ }" :to="link.to || '/'" @click="link.action">
135
120
  <Icon :name="link.icon" size="1.2" />
136
121
  <span class="nav-text">
137
122
  {{ link.label }}
@@ -140,28 +125,16 @@ function logout() {
140
125
  </nav>
141
126
  <!-- Footer -->
142
127
  <div
143
- class="sidebar-footer flex column flex-stretch gap-025 align-items-start mt-auto scrollbar-gutter-stable"
144
- >
128
+ class="sidebar-footer flex column flex-stretch gap-025 align-items-start mt-auto scrollbar-gutter-stable">
145
129
  <!-- Footer Links -->
146
- <Btn
147
- v-for="link in props.footerLinks" :key="link.to || link.label" :title="!menuState.isOpen.value && !menuState.isMobile.value
148
- ? link.label
149
- : ''
150
- " alignTxt="start" fullWidth flat :icon="link.icon" class="flex-shrink-0 px-1" :to="link.to" @click="link.action"
151
- >
130
+ <Btn v-for="link in props.footerLinks" :key="link.to || link.label" :title="!menuState.isOpen.value && !menuState.isMobile.value
131
+ ? link.label
132
+ : ''
133
+ " alignTxt="start" fullWidth flat :icon="link.icon" class="flex-shrink-0 px-1" :to="link.to" @click="link.action">
152
134
  <span class="nav-text">
153
135
  {{ link.label }}
154
136
  </span>
155
137
  </Btn>
156
-
157
- <!-- Default Logout Button if no footer links provided -->
158
- <Btn
159
- v-if="props.footerLinks.length === 0" :title="!menuState.isOpen.value && !menuState.isMobile.value ? 'Logout' : ''
160
- " alignTxt="start" fullWidth flat icon="logout" class="flex-shrink-0 px-1" @click="logout"
161
- >
162
- <span class="nav-text"> Logout </span>
163
- </Btn>
164
-
165
138
  <!-- Custom Footer Content Slot -->
166
139
  <slot name="footer" />
167
140
  </div>
@@ -189,6 +162,7 @@ function logout() {
189
162
  overflow-y: auto;
190
163
  flex: 1;
191
164
  }
165
+
192
166
  /* הסתרת גלילה בזמן שינוי גודל */
193
167
  .app-sidebar.transitioning .sidebar-nav {
194
168
  scrollbar-width: none;
@@ -267,8 +241,8 @@ function logout() {
267
241
  transform: translateX(-100%);
268
242
  }
269
243
 
270
- [dir="rtl"] .sidebar-mobile-closed,
271
- .rtl .sidebar-mobile-closed {
244
+ [dir="rtl"] .sidebar-mobile-closed,
245
+ .rtl .sidebar-mobile-closed {
272
246
  transform: translateX(100%);
273
247
  }
274
248
  }
@@ -24,13 +24,19 @@ export interface BagelOptions {
24
24
  language?: string
25
25
  host?: string
26
26
  fileBaseUrl?: string
27
+ fileVersion?: string
27
28
  onError?: (err: Error) => void
28
29
 
29
30
  i18nT?: (key: string) => string
30
31
  }
31
32
  export const BagelVue: Plugin<BagelOptions> = {
32
33
  install: (app, options) => {
33
- const bagel = new Bagel({ host: options.host, fileBaseUrl: options.fileBaseUrl, onError: options.onError })
34
+ const bagel = new Bagel({
35
+ host: options.host,
36
+ fileBaseUrl: options.fileBaseUrl,
37
+ fileVersion: options.fileVersion,
38
+ onError: options.onError
39
+ })
34
40
 
35
41
  // Set global Bagel instance for the composable
36
42
  setBagelInstance(bagel)