@edgedev/create-edge-app 1.0.61 → 1.0.63

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.
package/app.vue CHANGED
@@ -1,192 +1,10 @@
1
1
  <script setup>
2
- // TODO : ADD CODE FOR NOTIFICATIONS AND DEEP LINKING
3
- // import { useTheme } from 'vuetify'
4
- // const vueTheme = useTheme()
5
- // const changeTheme = (theme) => {
6
- // vueTheme.global.name.value = theme
7
- // }
8
- const edgeFirebase = inject('edgeFirebase')
9
- // const edgeGlobal = inject('edgeGlobal')
10
-
11
- const currentOrganization = computed(() => {
12
- return edgeGlobal.edgeState.currentOrganization
13
- })
14
-
15
- watch(currentOrganization, async () => {
16
- if (currentOrganization.value) {
17
- // RUN STUFF HERE WHEN ORGANIZATION CHANGES LIKE SNAPSHOTS
18
- await projectSetOrg(currentOrganization.value, edgeFirebase, edgeGlobal)
19
-
20
- // KEEP THIS CODE:
21
- const auth = useState('auth')
22
- auth.value = edgeFirebase.user
23
-
24
- const preLoginRoute = useState('preLoginRoute')
25
- const router = useRouter()
26
-
27
- let cleanedRoute = ''
28
- if (preLoginRoute.value) {
29
- cleanedRoute = preLoginRoute.value.endsWith('/') ? preLoginRoute.value.slice(0, -1) : preLoginRoute.value
30
- }
31
-
32
- if (cleanedRoute === ''
33
- || cleanedRoute === '/app'
34
- || cleanedRoute === '/app/login'
35
- || cleanedRoute === '/app/signup') {
36
- router.push('/app/dashboard')
37
- }
38
- else {
39
- router.push(preLoginRoute.value)
40
- }
41
-
42
- console.log(auth.value)
43
- }
44
- if (!currentOrganization.value) {
45
- const auth = useState('auth')
46
- auth.value = ''
47
- const router = useRouter()
48
- router.push('/app/login')
49
- }
50
- })
51
-
52
- const currentOrg = computed(() => edgeFirebase.data[`organizations/${edgeGlobal.edgeState.currentOrganization}`])
53
-
54
- watch (currentOrg, async () => {
55
- if (currentOrg.value) {
56
- edgeGlobal.edgeState = subscribedStatus(currentOrg.value)
57
- }
58
- }, { immediate: true }, { deep: true })
59
-
60
- const orgName = computed(() => {
61
- const org = edgeGlobal.edgeState.organizations.find(org => org.docId === edgeGlobal.edgeState.currentOrganization)
62
- return org?.name
63
- })
64
-
65
- const user = computed(() => {
66
- return edgeFirebase.user
67
- })
68
-
69
- watch (user, async () => {
70
- if (user.value) {
71
- const auth = useState('auth')
72
- auth.value = user.value
73
- }
74
- })
75
- const colorMode = useColorMode()
76
- onMounted(() => {
77
- colorMode.preference = 'system'
78
- // if (edgeGlobal.isDarkMode()) {
79
- // changeTheme('dark')
80
- // }
81
- // else {
82
- // changeTheme('light')
83
- // }
84
- })
85
- edgeFirebase.runFunction('edgeFirebase-initFirestore', {})
86
- edgeGlobal.edgeState.userRoles = [
87
- {
88
- name: 'Admin',
89
- roles: [
90
- {
91
- collectionPath: 'organizationDocPath',
92
- role: 'admin',
93
- },
94
- ],
95
- },
96
- {
97
- name: 'User',
98
- roles: [
99
- {
100
- collectionPath: 'organizationDocPath',
101
- role: 'user',
102
- },
103
- ],
104
- },
105
- ]
106
-
107
- const menuItems = [
108
- {
109
- title: 'Dashboard',
110
- to: '/app/dashboard/things',
111
- icon: 'LayoutDashboard',
112
- },
113
- {
114
- title: 'Sub Things',
115
- to: '/app/dashboard/subthings',
116
- icon: 'Package',
117
- },
118
- ]
119
2
  </script>
120
3
 
121
4
  <template>
122
- <Toaster />
123
- <div class="flex flex-col h-screen">
124
- <div class="flex h-full w-full">
125
- <SidebarProvider>
126
- <div class="h-full">
127
- <edge-side-menu
128
- v-if="edgeFirebase.user.loggedIn"
129
- :menu-items="menuItems"
130
- >
131
- <template #header>
132
- <SidebarMenu>
133
- <SidebarMenuItem>
134
- <SidebarMenuButton style="padding-left: 4px !important;">
135
- <Package class="!h-6 !w-6" /> <span class="text-xl">{{ orgName }}</span>
136
- </SidebarMenuButton>
137
- </SidebarMenuItem>
138
- </SidebarMenu>
139
- </template>
140
- <template #footer="slotProps">
141
- <Card v-if="slotProps.sideBarState === 'expanded'">
142
- <CardHeader class="p-2 pt-0 md:p-4">
143
- <CardTitle>Upgrade to Pro</CardTitle>
144
- <CardDescription>
145
- Unlock all features and get unlimited access to our support
146
- team.
147
- </CardDescription>
148
- </CardHeader>
149
- <CardContent class="p-2 pt-0 md:p-4 md:pt-0">
150
- <Button size="sm" class="w-full">
151
- Upgrade
152
- </Button>
153
- </CardContent>
154
- </Card>
155
- </template>
156
- </edge-side-menu>
157
- </div>
158
- <div class="grow h-full flex flex-col h-screen">
159
- <edge-menu
160
- v-if="edgeFirebase.user.loggedIn"
161
- type="nav"
162
- nav-class="justify-left mr-8"
163
- :menu-items="menuItems"
164
- >
165
- <template #start>
166
- <SidebarTrigger class="-ml-2 mr-2 h-4 w-4" />
167
- <Package class="h-6 w-6 mr-2" />
168
- <h1 class="text-xl font-bold">
169
- {{ orgName }}
170
- </h1>
171
- </template>
172
- </edge-menu>
173
- <NuxtPage class="flex-1 flex flex-col overflow-y-auto p-3" keepalive />
174
- <edge-menu
175
- v-if="edgeFirebase.user.loggedIn"
176
- type="footer"
177
- nav-class="justify-end mr-8"
178
- :menu-items="menuItems"
179
- >
180
- <template #start>
181
- <div class="text-xs text-muted-foreground">
182
- Copyright {{ new Date().getFullYear() }}
183
- </div>
184
- </template>
185
- </edge-menu>
186
- </div>
187
- </SidebarProvider>
188
- </div>
189
- </div>
5
+ <NuxtLayout>
6
+ <NuxtPage />
7
+ </NuxtLayout>
190
8
  </template>
191
9
 
192
10
  <style lang="scss">
@@ -1,12 +1,8 @@
1
1
  <script setup lang="ts">
2
+ import { SIDEBAR_WIDTH_MOBILE, useSidebar } from './utils'
2
3
  import type { SidebarProps } from '.'
3
4
  import { Sheet, SheetContent } from '@/components/ui/sheet'
4
5
  import { cn } from '@/lib/utils'
5
- import { SIDEBAR_WIDTH_MOBILE, useSidebar } from './utils'
6
-
7
- defineOptions({
8
- inheritAttrs: false,
9
- })
10
6
 
11
7
  const props = withDefaults(defineProps<SidebarProps>(), {
12
8
  side: 'left',
@@ -14,6 +10,10 @@ const props = withDefaults(defineProps<SidebarProps>(), {
14
10
  collapsible: 'offcanvas',
15
11
  })
16
12
 
13
+ defineOptions({
14
+ inheritAttrs: false,
15
+ })
16
+
17
17
  const { isMobile, state, openMobile, setOpenMobile } = useSidebar()
18
18
  </script>
19
19
 
@@ -31,7 +31,7 @@ const { isMobile, state, openMobile, setOpenMobile } = useSidebar()
31
31
  data-sidebar="sidebar"
32
32
  data-mobile="true"
33
33
  :side="side"
34
- class="w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden"
34
+ :class="cn('w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden', props.class)"
35
35
  :style="{
36
36
  '--sidebar-width': SIDEBAR_WIDTH_MOBILE,
37
37
  }"
@@ -0,0 +1,14 @@
1
+ <script setup>
2
+ </script>
3
+
4
+ <template>
5
+ <div class="flex min-h-screen w-full flex-col">
6
+ <main class="flex flex-1 flex-col gap-4 px-4 pb-4 md:gap-8 md:px-8 md:pb-8">
7
+ <slot />
8
+ </main>
9
+ </div>
10
+ </template>
11
+
12
+ <style>
13
+
14
+ </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edgedev/create-edge-app",
3
- "version": "1.0.61",
3
+ "version": "1.0.63",
4
4
  "description": "Create Edge Starter App",
5
5
  "bin": {
6
6
  "create-edge-app": "./bin/cli.js"
@@ -57,7 +57,7 @@ const page = computed(() => {
57
57
  <div
58
58
  v-if="edgeFirebase?.user?.loggedIn"
59
59
  >
60
- <Card class="w-full flex-1 bg-muted/50 max-w-7xl m-auto ">
60
+ <Card class="w-full flex-1 bg-muted/50 m-auto">
61
61
  <edge-organization-settings v-if="page === 'organization-settings'" :subscribe-options="subscribeOptions" :form-schema="orgSchema" :org-fields="orgFields" />
62
62
  <edge-my-account v-if="page === 'my-account'" />
63
63
  <edge-my-profile v-if="page === 'my-profile'" :form-schema="metaSchema" :meta-fields="metaFields" />
@@ -0,0 +1,73 @@
1
+ <script setup>
2
+ const edgeFirebase = inject('edgeFirebase')
3
+ const isAdmin = computed(() => {
4
+ const orgRole = edgeFirebase?.user?.roles.find(role =>
5
+ role.collectionPath === edgeGlobal.edgeState.organizationDocPath.replaceAll('/', '-'),
6
+ )
7
+ return orgRole && orgRole.role === 'admin'
8
+ })
9
+
10
+ const adminMenuItems = [
11
+ {
12
+ title: 'Organization',
13
+ to: '/app/account/organization-settings',
14
+ icon: 'Settings',
15
+ },
16
+ {
17
+ title: 'Members',
18
+ to: '/app/account/organization-members',
19
+ icon: 'Users',
20
+ },
21
+ ]
22
+
23
+ const menuItems = [
24
+ {
25
+ title: 'Profile',
26
+ to: '/app/account/my-profile',
27
+ icon: 'User',
28
+ },
29
+ {
30
+ title: 'Account',
31
+ to: '/app/account/my-account',
32
+ icon: 'CircleUser',
33
+ },
34
+ {
35
+ title: 'Organizations',
36
+ to: '/app/account/my-organizations',
37
+ icon: 'Group',
38
+ },
39
+ ]
40
+ </script>
41
+
42
+ <template>
43
+ <div
44
+ v-if="edgeGlobal.edgeState.organizationDocPath"
45
+ >
46
+ <div class="h-full p-0">
47
+ <SidebarProvider class="min-h-full">
48
+ <div class="h-full md:w-[180px]">
49
+ <edge-side-menu
50
+ :menu-items="menuItems"
51
+ :settings-menu-items="isAdmin ? adminMenuItems : []"
52
+ collapsible="submenu"
53
+ class="bg-background text-foreground border-none w-[180px] absolute shadow-none"
54
+ :show-settings-section="false"
55
+ title="My Settings"
56
+ settings-title="Organization Settings"
57
+ group-label-classes="text-foreground/70"
58
+ >
59
+ <template #header>
60
+ <h1 class="text-xl">
61
+ Settings
62
+ </h1>
63
+ </template>
64
+ </edge-side-menu>
65
+ </div>
66
+ <NuxtPage class="flex-1 flex flex-col overflow-y-auto p-3" keepalive />
67
+ </SidebarProvider>
68
+ </div>
69
+ </div>
70
+ </template>
71
+
72
+ <style lang="scss">
73
+ </style>
package/pages/app.vue ADDED
@@ -0,0 +1,191 @@
1
+ <script setup>
2
+ const edgeFirebase = inject('edgeFirebase')
3
+ // const edgeGlobal = inject('edgeGlobal')
4
+
5
+ const currentOrganization = computed(() => {
6
+ return edgeGlobal.edgeState.currentOrganization
7
+ })
8
+
9
+ watch(currentOrganization, async () => {
10
+ if (currentOrganization.value) {
11
+ // RUN STUFF HERE WHEN ORGANIZATION CHANGES LIKE SNAPSHOTS
12
+ await projectSetOrg(currentOrganization.value, edgeFirebase, edgeGlobal)
13
+
14
+ // KEEP THIS CODE:
15
+ const auth = useState('auth')
16
+ auth.value = edgeFirebase.user
17
+
18
+ const preLoginRoute = useState('preLoginRoute')
19
+ const router = useRouter()
20
+
21
+ let cleanedRoute = ''
22
+ if (preLoginRoute.value) {
23
+ cleanedRoute = preLoginRoute.value.endsWith('/') ? preLoginRoute.value.slice(0, -1) : preLoginRoute.value
24
+ }
25
+
26
+ if (cleanedRoute === ''
27
+ || cleanedRoute === '/app'
28
+ || cleanedRoute === '/app/login'
29
+ || cleanedRoute === '/app/signup') {
30
+ router.push('/app/dashboard')
31
+ }
32
+ else {
33
+ router.push(preLoginRoute.value)
34
+ }
35
+
36
+ console.log(auth.value)
37
+ }
38
+ if (!currentOrganization.value) {
39
+ const auth = useState('auth')
40
+ auth.value = ''
41
+ const router = useRouter()
42
+ router.push('/app/login')
43
+ }
44
+ })
45
+
46
+ const currentOrg = computed(() => edgeFirebase.data[`organizations/${edgeGlobal.edgeState.currentOrganization}`])
47
+
48
+ watch (currentOrg, async () => {
49
+ if (currentOrg.value) {
50
+ edgeGlobal.edgeState = subscribedStatus(currentOrg.value)
51
+ }
52
+ }, { immediate: true }, { deep: true })
53
+
54
+ const orgName = computed(() => {
55
+ const org = edgeGlobal.edgeState.organizations.find(org => org.docId === edgeGlobal.edgeState.currentOrganization)
56
+ return org?.name
57
+ })
58
+
59
+ const user = computed(() => {
60
+ return edgeFirebase.user
61
+ })
62
+
63
+ watch (user, async () => {
64
+ if (user.value) {
65
+ const auth = useState('auth')
66
+ auth.value = user.value
67
+ }
68
+ })
69
+ const colorMode = useColorMode()
70
+ onMounted(() => {
71
+ colorMode.preference = 'system'
72
+ // if (edgeGlobal.isDarkMode()) {
73
+ // changeTheme('dark')
74
+ // }
75
+ // else {
76
+ // changeTheme('light')
77
+ // }
78
+ })
79
+ edgeFirebase.runFunction('edgeFirebase-initFirestore', {})
80
+ edgeGlobal.edgeState.userRoles = [
81
+ {
82
+ name: 'Admin',
83
+ roles: [
84
+ {
85
+ collectionPath: 'organizationDocPath',
86
+ role: 'admin',
87
+ },
88
+ ],
89
+ },
90
+ {
91
+ name: 'User',
92
+ roles: [
93
+ {
94
+ collectionPath: 'organizationDocPath',
95
+ role: 'user',
96
+ },
97
+ ],
98
+ },
99
+ ]
100
+
101
+ const menuItems = [
102
+ {
103
+ title: 'Dashboard',
104
+ to: '/app/dashboard/things',
105
+ icon: 'LayoutDashboard',
106
+ },
107
+ {
108
+ title: 'Sub Things',
109
+ to: '/app/dashboard/subthings',
110
+ icon: 'Package',
111
+ },
112
+ ]
113
+ </script>
114
+
115
+ <template>
116
+ <Toaster />
117
+ <div class="flex flex-col h-screen">
118
+ <div class="flex h-full w-full">
119
+ <SidebarProvider>
120
+ <div class="h-full">
121
+ <edge-side-menu
122
+ v-if="edgeFirebase.user.loggedIn"
123
+ :menu-items="menuItems"
124
+ >
125
+ <template #header>
126
+ <SidebarMenu>
127
+ <SidebarMenuItem>
128
+ <SidebarMenuButton style="padding-left: 4px !important;">
129
+ <Package class="!h-6 !w-6" /> <span class="text-xl">{{ orgName }}</span>
130
+ </SidebarMenuButton>
131
+ </SidebarMenuItem>
132
+ </SidebarMenu>
133
+ </template>
134
+ <template #footer="slotProps">
135
+ <Card v-if="slotProps.sideBarState === 'expanded'">
136
+ <CardHeader class="p-2 pt-0 md:p-4">
137
+ <CardTitle>Upgrade to Pro</CardTitle>
138
+ <CardDescription>
139
+ Unlock all features and get unlimited access to our support
140
+ team.
141
+ </CardDescription>
142
+ </CardHeader>
143
+ <CardContent class="p-2 pt-0 md:p-4 md:pt-0">
144
+ <Button size="sm" class="w-full">
145
+ Upgrade
146
+ </Button>
147
+ </CardContent>
148
+ </Card>
149
+ </template>
150
+ </edge-side-menu>
151
+ </div>
152
+ <div class="grow h-full flex flex-col h-screen">
153
+ <edge-menu
154
+ v-if="edgeFirebase.user.loggedIn"
155
+ type="nav"
156
+ nav-class="justify-left mr-8"
157
+ :menu-items="menuItems"
158
+ >
159
+ <template #start>
160
+ <SidebarTrigger class="-ml-2 mr-2 h-4 w-4" />
161
+ <Package class="h-6 w-6 mr-2" />
162
+ <h1 class="text-xl font-bold">
163
+ {{ orgName }}
164
+ </h1>
165
+ </template>
166
+ </edge-menu>
167
+ <NuxtPage class="flex-1 flex flex-col overflow-y-auto p-3" keepalive />
168
+ <edge-menu
169
+ v-if="edgeFirebase.user.loggedIn"
170
+ type="footer"
171
+ nav-class="justify-end mr-8"
172
+ :menu-items="menuItems"
173
+ >
174
+ <template #start>
175
+ <div class="text-xs text-muted-foreground">
176
+ Copyright {{ new Date().getFullYear() }}
177
+ </div>
178
+ </template>
179
+ </edge-menu>
180
+ </div>
181
+ </SidebarProvider>
182
+ </div>
183
+ </div>
184
+ </template>
185
+
186
+ <style lang="scss">
187
+ .firebase-emulator-warning { display: none; }
188
+ html, body {
189
+ overflow: hidden;
190
+ }
191
+ </style>