@afeefa/vue-app 0.0.112 → 0.0.114
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/.afeefa/package/release/version.txt +1 -1
- package/package.json +1 -1
- package/src-admin/AfeefaAdmin.js +114 -0
- package/src-admin/components/App.vue +10 -7
- package/src-admin/config/{AppConfig.js → AdminConfig.js} +2 -2
- package/src-admin/plugins/AuthPlugin.js +4 -2
- package/src-admin/bootstrap.js +0 -74
|
@@ -1 +1 @@
|
|
|
1
|
-
0.0.
|
|
1
|
+
0.0.114
|
package/package.json
CHANGED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import './config/components'
|
|
2
|
+
import './directives'
|
|
3
|
+
|
|
4
|
+
import { apiResourcesPlugin } from '@a-vue/plugins/api-resources/ApiResourcesPlugin'
|
|
5
|
+
import { eventBusPlugin } from '@a-vue/plugins/event-bus/EventBusPlugin'
|
|
6
|
+
import { hasOptionsPlugin } from '@a-vue/plugins/has-options/HasOptionsPlugin'
|
|
7
|
+
import { timeout } from '@a-vue/utils/timeout'
|
|
8
|
+
import Vue from 'vue'
|
|
9
|
+
|
|
10
|
+
import { adminConfig } from './config/AdminConfig'
|
|
11
|
+
import routeConfigPlugin from './config/routing'
|
|
12
|
+
import vuetify from './config/vuetify'
|
|
13
|
+
import { authPlugin } from './plugins/AuthPlugin'
|
|
14
|
+
|
|
15
|
+
Vue.config.productionTip = false
|
|
16
|
+
|
|
17
|
+
export class AfeefaAdmin {
|
|
18
|
+
_appConfig = {}
|
|
19
|
+
_routeConfigCallback = null
|
|
20
|
+
_apiConfig = null
|
|
21
|
+
_authService = null
|
|
22
|
+
_initCallback = null
|
|
23
|
+
_components = {}
|
|
24
|
+
|
|
25
|
+
app (appConfig) {
|
|
26
|
+
this._appConfig = appConfig
|
|
27
|
+
return this
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
routing (routeConfigCallback) {
|
|
31
|
+
this._routeConfigCallback = routeConfigCallback
|
|
32
|
+
return this
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
api (apiConfig) {
|
|
36
|
+
this._apiConfig = apiConfig
|
|
37
|
+
return this
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
auth (authService) {
|
|
41
|
+
this._authService = authService
|
|
42
|
+
return this
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
init (initCallback) {
|
|
46
|
+
this._initCallback = initCallback
|
|
47
|
+
return this
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async run () {
|
|
51
|
+
// set app config
|
|
52
|
+
adminConfig.app = this._appConfig
|
|
53
|
+
|
|
54
|
+
// authenticate current user before doing any gui-voodo
|
|
55
|
+
if (this._authService) {
|
|
56
|
+
adminConfig.authService = this._authService
|
|
57
|
+
|
|
58
|
+
const authenticated = await this._authService.authenticate()
|
|
59
|
+
if (!authenticated) {
|
|
60
|
+
return // redirects to login
|
|
61
|
+
}
|
|
62
|
+
Vue.use(authPlugin)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// auth went well, show splash screen
|
|
66
|
+
const splash = new Vue({
|
|
67
|
+
vuetify,
|
|
68
|
+
el: '#splash',
|
|
69
|
+
template: '<splash />',
|
|
70
|
+
components: {
|
|
71
|
+
Splash: adminConfig.app.components.Splash
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
// plugins
|
|
76
|
+
Vue.use(hasOptionsPlugin)
|
|
77
|
+
Vue.use(eventBusPlugin)
|
|
78
|
+
|
|
79
|
+
// load auth resources
|
|
80
|
+
if (this._authService) {
|
|
81
|
+
await this._authService.init()
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// setup api resources
|
|
85
|
+
apiResourcesPlugin.register(this._apiConfig.models, this._apiConfig.apis)
|
|
86
|
+
Vue.use(apiResourcesPlugin)
|
|
87
|
+
await apiResourcesPlugin.schemasLoaded()
|
|
88
|
+
|
|
89
|
+
// load initial data
|
|
90
|
+
if (this._initCallback) {
|
|
91
|
+
await this._initCallback()
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// setup router, routes and breadcrumb
|
|
95
|
+
this._routeConfigCallback(routeConfigPlugin)
|
|
96
|
+
const router = await routeConfigPlugin.getRouter()
|
|
97
|
+
|
|
98
|
+
// routeConfigPlugin.dumpRoutes()
|
|
99
|
+
// routeConfigPlugin.dumbBreadcrumbs()
|
|
100
|
+
|
|
101
|
+
// remove splash show app
|
|
102
|
+
timeout(() => {
|
|
103
|
+
new Vue({
|
|
104
|
+
vuetify,
|
|
105
|
+
router,
|
|
106
|
+
el: '#app',
|
|
107
|
+
template: '<start :splash="splash" />',
|
|
108
|
+
data: {
|
|
109
|
+
splash
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
}, 300)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
>
|
|
10
10
|
<v-container
|
|
11
11
|
flex-column
|
|
12
|
-
align-
|
|
12
|
+
align-center
|
|
13
13
|
fill-height
|
|
14
14
|
>
|
|
15
15
|
<router-link
|
|
@@ -50,6 +50,9 @@
|
|
|
50
50
|
<div>
|
|
51
51
|
<div class="accountName">
|
|
52
52
|
{{ account.first_name }}
|
|
53
|
+
<template v-if="$auth.roles()[0]">
|
|
54
|
+
({{ $auth.roles()[0].title }})
|
|
55
|
+
</template>
|
|
53
56
|
</div>
|
|
54
57
|
|
|
55
58
|
<div class="body-2 d-flex align-center">
|
|
@@ -120,7 +123,7 @@
|
|
|
120
123
|
<script>
|
|
121
124
|
import { Component, Vue, Watch } from '@a-vue'
|
|
122
125
|
import { LoadingEvent } from '@a-vue/events'
|
|
123
|
-
import {
|
|
126
|
+
import { adminConfig } from '@a-admin/config/AdminConfig'
|
|
124
127
|
import { sleep } from '@a-vue/utils/timeout'
|
|
125
128
|
import AppBarButtons from './app/AppBarButtons'
|
|
126
129
|
import AppBarTitleContainer from './app/AppBarTitleContainer'
|
|
@@ -151,11 +154,11 @@ export default class App extends Vue {
|
|
|
151
154
|
}
|
|
152
155
|
|
|
153
156
|
get SidebarMenu () {
|
|
154
|
-
return
|
|
157
|
+
return adminConfig.app.components.SidebarMenu
|
|
155
158
|
}
|
|
156
159
|
|
|
157
160
|
get logoUrl () {
|
|
158
|
-
return
|
|
161
|
+
return adminConfig.app.logo
|
|
159
162
|
}
|
|
160
163
|
|
|
161
164
|
get account () {
|
|
@@ -166,15 +169,15 @@ export default class App extends Vue {
|
|
|
166
169
|
}
|
|
167
170
|
|
|
168
171
|
get title () {
|
|
169
|
-
return
|
|
172
|
+
return adminConfig.app.title
|
|
170
173
|
}
|
|
171
174
|
|
|
172
175
|
get loaderColor () {
|
|
173
|
-
return
|
|
176
|
+
return adminConfig.app.loaderColor
|
|
174
177
|
}
|
|
175
178
|
|
|
176
179
|
get rootRouteName () {
|
|
177
|
-
return
|
|
180
|
+
return adminConfig.app.rootRouteName || 'root'
|
|
178
181
|
}
|
|
179
182
|
|
|
180
183
|
startLoading () {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { adminConfig } from '../config/AdminConfig'
|
|
2
2
|
|
|
3
3
|
class AuthPlugin {
|
|
4
4
|
install (Vue) {
|
|
5
|
-
const authService =
|
|
5
|
+
const authService = adminConfig.authService
|
|
6
6
|
const $auth = {
|
|
7
7
|
account: authService.getCurrentAccount(),
|
|
8
8
|
|
|
@@ -10,6 +10,8 @@ class AuthPlugin {
|
|
|
10
10
|
|
|
11
11
|
hasRole: name => authService.currentAccountHasRole(name),
|
|
12
12
|
|
|
13
|
+
roles: () => authService.getCurrentAccountRoles(),
|
|
14
|
+
|
|
13
15
|
logout: () => authService.forwardToLogoutEndpoint()
|
|
14
16
|
}
|
|
15
17
|
|
package/src-admin/bootstrap.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import './config/event-bus'
|
|
2
|
-
import './config/components'
|
|
3
|
-
import './directives'
|
|
4
|
-
|
|
5
|
-
import { authPlugin } from '@a-admin/plugins/AuthPlugin'
|
|
6
|
-
import { translationPlugin } from '@a-admin/plugins/translation/TranslationPlugin'
|
|
7
|
-
import { apiResourcesPlugin } from '@a-vue/plugins/api-resources/ApiResourcesPlugin'
|
|
8
|
-
import { hasOptionsPlugin } from '@a-vue/plugins/has-options/HasOptionsPlugin'
|
|
9
|
-
import { timeout } from '@a-vue/utils/timeout'
|
|
10
|
-
import Vue from 'vue'
|
|
11
|
-
|
|
12
|
-
import { appConfig } from './config/AppConfig'
|
|
13
|
-
import routeConfigPlugin from './config/routing'
|
|
14
|
-
import vuetify from './config/vuetify'
|
|
15
|
-
|
|
16
|
-
Vue.use(apiResourcesPlugin)
|
|
17
|
-
Vue.use(hasOptionsPlugin)
|
|
18
|
-
Vue.use(translationPlugin)
|
|
19
|
-
|
|
20
|
-
Vue.config.productionTip = false
|
|
21
|
-
|
|
22
|
-
export async function bootstrap ({ apis, models, routing, authService, getTranslations, app, components }) {
|
|
23
|
-
appConfig.authService = authService
|
|
24
|
-
appConfig.app = app
|
|
25
|
-
appConfig.components = components
|
|
26
|
-
|
|
27
|
-
if (authService) {
|
|
28
|
-
const authenticated = await authService.authenticate()
|
|
29
|
-
if (!authenticated) {
|
|
30
|
-
return
|
|
31
|
-
}
|
|
32
|
-
Vue.use(authPlugin)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const splash = new Vue({
|
|
36
|
-
vuetify,
|
|
37
|
-
el: '#splash',
|
|
38
|
-
template: '<splash />',
|
|
39
|
-
components: {
|
|
40
|
-
Splash: components.Splash
|
|
41
|
-
}
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
if (authService) {
|
|
45
|
-
await authService.init()
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
apiResourcesPlugin.register(models, apis)
|
|
49
|
-
|
|
50
|
-
routing(routeConfigPlugin)
|
|
51
|
-
const router = await routeConfigPlugin.getRouter()
|
|
52
|
-
|
|
53
|
-
await apiResourcesPlugin.schemasLoaded()
|
|
54
|
-
|
|
55
|
-
if (getTranslations) {
|
|
56
|
-
const translations = await getTranslations(apiResourcesPlugin.apiResources)
|
|
57
|
-
translationPlugin.setTranslations(translations.models)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// routeConfigPlugin.dumpRoutes()
|
|
61
|
-
// routeConfigPlugin.dumbBreadcrumbs()
|
|
62
|
-
|
|
63
|
-
timeout(() => {
|
|
64
|
-
new Vue({
|
|
65
|
-
vuetify,
|
|
66
|
-
router,
|
|
67
|
-
el: '#app',
|
|
68
|
-
template: '<start :splash="splash" />',
|
|
69
|
-
data: {
|
|
70
|
-
splash
|
|
71
|
-
}
|
|
72
|
-
})
|
|
73
|
-
}, 300)
|
|
74
|
-
}
|