@metano/quasar_rest_auth 1.0.1

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.
Files changed (45) hide show
  1. package/.gitattributes +17 -0
  2. package/LICENSE +21 -0
  3. package/Makefile +18 -0
  4. package/README.md +6 -0
  5. package/boot/alerts.js +152 -0
  6. package/boot/api.js +155 -0
  7. package/boot/app.js +111 -0
  8. package/boot/base.js +242 -0
  9. package/boot/config.js +117 -0
  10. package/boot/cripto.js +35 -0
  11. package/boot/data.js +28 -0
  12. package/boot/storage.js +74 -0
  13. package/components/DefinicoesLayout.vue +34 -0
  14. package/components/FormLogin.vue +217 -0
  15. package/components/LeftMenu.vue +93 -0
  16. package/components/LeftMenuSegundo.vue +96 -0
  17. package/components/MyTest.vue +41 -0
  18. package/components/RightMenu.vue +36 -0
  19. package/components/SearchMenu.vue +88 -0
  20. package/components/SettingsLayout.vue +34 -0
  21. package/components/TopMenu.vue +68 -0
  22. package/components/TopMenuSegundo.vue +85 -0
  23. package/components/footer/Comments.vue +77 -0
  24. package/components/footer/MainFooter.vue +71 -0
  25. package/components/header/HeaderBrand.vue +64 -0
  26. package/components/header/HeaderDarkModeToggle.vue +40 -0
  27. package/components/header/HeaderFullScreen.vue +55 -0
  28. package/components/header/HeaderLanguage.vue +56 -0
  29. package/components/header/HeaderNotifications.vue +53 -0
  30. package/components/header/HeaderServices.vue +118 -0
  31. package/components/header/HeaderUser.vue +210 -0
  32. package/components/header/HeaderUserMenu.vue +0 -0
  33. package/components/header/RegistarEntidade.vue +309 -0
  34. package/gitignore +3 -0
  35. package/help +9 -0
  36. package/index.js +9 -0
  37. package/layouts/AuthLayout.vue +74 -0
  38. package/layouts/MainLayout.vue +190 -0
  39. package/package.json +31 -0
  40. package/pages/auth/LoginPage.vue +32 -0
  41. package/pages/routes.js +33 -0
  42. package/stores/AuthStore.js +587 -0
  43. package/stores/example-store.js +21 -0
  44. package/stores/index.js +20 -0
  45. package/stores/settings.js +12 -0
package/.gitattributes ADDED
@@ -0,0 +1,17 @@
1
+ # Audio files
2
+ *.wav filter=lfs diff=lfs merge=lfs -text
3
+ *.mp3 filter=lfs diff=lfs merge=lfs -text
4
+ *.m4a filter=lfs diff=lfs merge=lfs -text
5
+ *.ogg filter=lfs diff=lfs merge=lfs -text
6
+ *.webm filter=lfs diff=lfs merge=lfs -text
7
+
8
+ # Video files
9
+ *.mp4 filter=lfs diff=lfs merge=lfs -text
10
+ *.avi filter=lfs diff=lfs merge=lfs -text
11
+ *.mov filter=lfs diff=lfs merge=lfs -text
12
+ *.mkv filter=lfs diff=lfs merge=lfs -text
13
+
14
+ # Image files over 1MB should use LFS
15
+ *.jpg filter=lfs diff=lfs merge=lfs -text
16
+ *.jpeg filter=lfs diff=lfs merge=lfs -text
17
+ *.png filter=lfs diff=lfs merge=lfs -text
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 metanochava
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/Makefile ADDED
@@ -0,0 +1,18 @@
1
+ up:
2
+ npm version patch --no-git-tag-version; \
3
+ git add .; \
4
+ VERSION=$$(node -p "require('./package.json').version"); \
5
+ read -p "Mensagem do release: " m; \
6
+ git commit -m "release: v$$VERSION - $$m"; \
7
+ git push origin main; \
8
+ npm publish
9
+ upv:
10
+ npm version patch --no-git-tag-version; \
11
+ git add .; \
12
+ VERSION=$$(node -p "require('./package.json').version"); \
13
+ read -p "Mensagem do release: " m; \
14
+ git commit -m "release: v$$VERSION - $$m"; \
15
+ git tag v$$VERSION; \
16
+ git push origin main; \
17
+ git push origin v$$VERSION; \
18
+ npm publish
package/README.md ADDED
@@ -0,0 +1,6 @@
1
+ # quasar
2
+
3
+ # Fernando 847213584 cell julia
4
+ # Comandos de Compilacao e publicacao
5
+ ### npm pack
6
+ ##
package/boot/alerts.js ADDED
@@ -0,0 +1,152 @@
1
+
2
+ import { Notify } from 'quasar'
3
+ import { tdc } from './app'
4
+ import { AlertStore } from '../stores/AuthStore'
5
+
6
+ const AlertSuccess = (data) => {
7
+ let sms = data
8
+ let tipo = 'success'
9
+ let go = false
10
+ if (typeof data !== 'string') {
11
+ if (data?.status === 201) {
12
+ sms = tdc('Criado com sucesso!')
13
+ go = true
14
+ }
15
+ if (data?.status === 202) {
16
+ sms = tdc('Processado com sucesso!')
17
+ go = true
18
+ }
19
+ if (data?.status === 203) {
20
+ sms = tdc('Modificado com sucesso!')
21
+ go = true
22
+ }
23
+
24
+ if (data?.status === 204) {
25
+ sms = tdc('Apagado com sucesso!')
26
+ go = true
27
+ }
28
+
29
+ if (data?.status === 413) {
30
+ sms = tdc('Request Entity Too Large')
31
+ go = true
32
+ }
33
+
34
+ if (Object.keys(data?.data).includes('alert_success')) {
35
+ sms = data?.data?.alert_success
36
+ go = true
37
+ }
38
+ if (Object.keys(data?.data).includes('alert_info')) {
39
+ tipo = 'info'
40
+ sms = data?.data?.alert_info
41
+ go = true
42
+ }
43
+ }
44
+
45
+ if (typeof data === 'string') {
46
+ go = true
47
+ }
48
+
49
+ if (go) {
50
+ Alerta = AlertStore()
51
+ Alerta.add({id: crypto.randomUUID(), sms: tdc(sms), type: tipo })
52
+ Notify.create({
53
+ type: 'positive',
54
+ message: tdc(sms),
55
+ position: 'top-right',
56
+ html: true,
57
+ actions: [
58
+ { icon: 'close', color: 'white', round: true, handler: () => { } }
59
+ ]
60
+ })
61
+ }
62
+ }
63
+
64
+ const AlertError = (data) => {
65
+ let sms = data
66
+ tipo = 'error'
67
+ let go = false
68
+ if (typeof data !== 'string') {
69
+ data = data?.response
70
+
71
+ if (data?.status === 400) {
72
+ sms = tdc(data?.data)
73
+ go = true
74
+ }
75
+ if (data?.status === 401) {
76
+ sms = tdc(data?.data)
77
+ go = true
78
+ }
79
+
80
+ if (data?.status === 403) {
81
+ sms = tdc(data?.data)
82
+ go = true
83
+ }
84
+
85
+ if (data?.status === 404) {
86
+ sms = tdc(data?.data)
87
+ go = true
88
+ if (Object.keys(data?.data).includes('detail')) {
89
+ sms = tdc(data?.data?.detail)
90
+ go = true
91
+ }
92
+ }
93
+
94
+ if (data?.status === 413) {
95
+ sms = tdc('Request Entity Too Large')
96
+ go = true
97
+ }
98
+
99
+ if (data?.status === 500) {
100
+ try {
101
+ sms = tdc(data?.data?.replaceAll('h1', 'b').replace('p', ''))
102
+ } catch (error) {
103
+
104
+ }
105
+ go = true
106
+ }
107
+
108
+ if (data) {
109
+ if (Object.keys(data?.data).includes('alert_error')) {
110
+ sms = tdc(data?.data?.alert_error)
111
+ go = true
112
+ }
113
+ }
114
+ }
115
+
116
+ if (typeof data === 'string') {
117
+ go = true
118
+ }
119
+
120
+ if (go) {
121
+ Alerta.add({id: crypto.randomUUID(), sms: tdc(sms), type: tipo })
122
+ Notify.create({
123
+ type: 'negative',
124
+ message: tdc(sms),
125
+ position: 'top-right',
126
+ html: true,
127
+ actions: [
128
+ { icon: 'close', color: 'white', round: true, handler: () => { } }
129
+ ]
130
+ })
131
+ }
132
+ }
133
+
134
+ const AlertInfo = (data) => {
135
+
136
+ Alerta.add({id: crypto.randomUUID(), sms: tdc(sms), type: 'info' })
137
+ Notify.create({
138
+ type: 'info',
139
+ position: 'top-right',
140
+ message: tdc(data),
141
+ html: true,
142
+ actions: [
143
+ { icon: 'close', color: 'white', round: true, handler: () => { } }
144
+ ]
145
+ })
146
+ }
147
+
148
+ const Alert= (data) => {
149
+ console.log(data)
150
+ }
151
+
152
+ export { AlertError, AlertInfo, AlertSuccess, Alert }
package/boot/api.js ADDED
@@ -0,0 +1,155 @@
1
+ import axios from 'axios'
2
+ import { getStorage, setStorage } from './storage'
3
+ import { AuthStore, UserStore } from '../stores/AuthStore'
4
+ import { LoadStore } from '../stores/AuthStore'
5
+
6
+ import { Alert, AlertError, AlertSuccess } from './alerts'
7
+
8
+ const apiBaseUrl = process.env.API
9
+ axios.defaults.baseURL = apiBaseUrl
10
+ axios.defaults.withCredentials = false
11
+
12
+
13
+ function safeParse (value) {
14
+ try {
15
+ return value ? JSON.parse(value) : null
16
+ } catch {
17
+ return null
18
+ }
19
+ }
20
+
21
+ export const url = (payload = {type: 'u', url: '', params: {} }) => {
22
+ let tipoEntidadeNome = AuthStore?.TipoEntidate?.nome
23
+
24
+ let urlFinal = ''
25
+
26
+ if (payload.type === 'u') {
27
+ urlFinal = apiBaseUrl + '/' + payload.url
28
+ }
29
+
30
+ if (payload.type === 'nu') {
31
+ urlFinal = apiBaseUrl + '/' + tipoEntidadeNome.toLowerCase() + '/' + payload.url
32
+ }
33
+
34
+ const Auth = AuthStore()
35
+ let lang = Auth?.Idioma
36
+
37
+ urlFinal = urlFinal + '?format=json&lang=' + lang?.nome
38
+ for (const [key, value] of Object.entries(payload?.params)) {
39
+ urlFinal = urlFinal + `&${key}=${value}`
40
+ }
41
+ return urlFinal
42
+ }
43
+
44
+ axios.defaults.headers = {
45
+ Accept: 'application/json'
46
+ }
47
+
48
+ export const wsApi = process.env.API.replace('http', 'ws') + '/' + apiBaseUrl
49
+
50
+ // const TOKKEN = JSON.parse(getStorage('c', 'user'))?.tokens?.access
51
+
52
+ export const HTTPClient = axios.create({
53
+ baseURL: process.env.API,
54
+ headers: {
55
+ FEK: process.env.FRONT_END_KEY,
56
+ FEP: process.env.FRONT_END_PASSWORD
57
+ }
58
+ })
59
+
60
+ export const HTTPClientBlob = axios.create({
61
+ baseURL: process.env.API,
62
+ headers: {
63
+ FEK: process.env.FRONT_END_KEY,
64
+ FEP: process.env.FRONT_END_PASSWORD
65
+ }
66
+ })
67
+
68
+ export const HTTPAuth = axios.create({
69
+ baseURL: process.env.API,
70
+
71
+ headers: {
72
+ FEK: process.env.FRONT_END_KEY,
73
+ FEP: process.env.FRONT_END_PASSWORD,
74
+ Accept: 'application/json',
75
+ 'Content-Type': 'application/json'
76
+ }
77
+ })
78
+
79
+ export const HTTPAuthBlob = axios.create({
80
+ baseURL: process.env.API,
81
+ headers: {
82
+ FEK: process.env.FRONT_END_KEY,
83
+ FEP: process.env.FRONT_END_PASSWORD,
84
+ Accept: 'application/json'
85
+ },
86
+ responseType: 'blob'
87
+ })
88
+
89
+
90
+
91
+ HTTPAuth.interceptors.request.use(async config => {
92
+ const User = UserStore()
93
+ config.withCredentials = false
94
+ if (config.headers.Cookie) {
95
+ delete config.headers.Cookie
96
+ }
97
+
98
+ if (config.data instanceof FormData) {
99
+ config.headers['Content-Type'] = 'multipart/form-data'
100
+ }
101
+ const headersMap = {
102
+ E: 'userEntidade',
103
+ S: 'userSucursal',
104
+ G: 'userGrupo',
105
+ ET: 'tipoEntidade'
106
+ }
107
+
108
+ config.headers.Authorization = `Bearer ${getStorage('c', 'access') || ''}`
109
+
110
+ Object.entries(headersMap).forEach(([key, storage]) => {
111
+ const data = safeParse(getStorage('c', storage))
112
+ if (data?.id) config.headers[key] = data.id
113
+ })
114
+ const Load = LoadStore()
115
+ Load.inc
116
+
117
+ return config
118
+ })
119
+
120
+ HTTPAuth.interceptors.response.use(
121
+ (response) => {
122
+ const User = UserStore()
123
+ const Load = LoadStore()
124
+ Load.dec
125
+ Alert(response)
126
+ return response
127
+ },
128
+ (error) => {
129
+ const User = UserStore()
130
+ const Load = LoadStore()
131
+ Load.dec
132
+ if (error.response) {
133
+ Alert(error.response)
134
+ const status = error.response.status
135
+
136
+ if (status === 401 || status === 403) {
137
+ User.logout('N')
138
+ }
139
+ }
140
+ return Promise.reject(error)
141
+ }
142
+ )
143
+
144
+
145
+
146
+ HTTPAuthBlob.interceptors.request.use(async config => {
147
+ store.commit('load/SET_LOAD', 1)
148
+ const user = JSON.parse(getStorage('c', 'user'))
149
+ setStorage('c', 'user', JSON.stringify(user), 365)
150
+ config.headers.Authorization = 'Bearer ' + user?.tokens?.access
151
+
152
+ const Load = LoadStore()
153
+ Load.inc
154
+ return config
155
+ })
package/boot/app.js ADDED
@@ -0,0 +1,111 @@
1
+ import { traducao } from './base'
2
+ import { dateSplit } from './data'
3
+
4
+ let result = false
5
+
6
+ export const api = 'api'
7
+ export const thumbStyle = {
8
+ right: '5px',
9
+ borderRadius: '8px',
10
+ backgroundColor: '#027be3',
11
+ width: '8px',
12
+ opacity: 0.75
13
+ }
14
+
15
+ export const barStyle = {
16
+ right: '2px ',
17
+ borderRadius: '14px',
18
+ backgroundColor: '#027be3',
19
+ width: '14px',
20
+ opacity: 0.2,
21
+ marginTop: '-3px',
22
+ marginBottom: '-3px',
23
+ paddingTop: '3px',
24
+ paddingBottom: '3px'
25
+ }
26
+
27
+
28
+ // Initialize the annoying-background directive.
29
+ export const IsAuthorized = {
30
+ bind (el, binding, vnode) {
31
+ const store = vnode.context.$store
32
+ const permissions = store.getters['auth/getPermissions']
33
+ permissions.forEach(element => {
34
+ if (element.nome === binding.value) {
35
+ result = true
36
+ }
37
+ })
38
+ if (!result) {
39
+ el.style.display = 'none'
40
+ }
41
+ }
42
+ }
43
+
44
+ export const pegaDominio = function () {
45
+ let pagelocalurl = location.href // pega endereço que esta no navegador
46
+ pagelocalurl = pagelocalurl.split('/') // quebra o endeço de acordo com a / (barra)
47
+ const dominiourl = pagelocalurl[0] + '//' + pagelocalurl[2]
48
+ return dominiourl // retorna a parte www.endereco.com.brs@
49
+ }
50
+
51
+ export const MeIsAuthorized = function (permissions, permission) {
52
+ // const store = useStore()
53
+ let result = false
54
+ if (Array.isArray(permissions)) {
55
+ permissions.forEach(element => {
56
+ if (element.nome === permission) {
57
+ result = true
58
+ } else {
59
+ // store?.commit('auth/SET_PAGEPERMISSOES', permission)
60
+ }
61
+ })
62
+ }
63
+ return result
64
+ }
65
+
66
+ export const tdc = traducao
67
+ export const ds = dateSplit
68
+
69
+ // Initialize the annoying-background directive.
70
+ export const IsTipoEntidade = {
71
+ bind (el, binding, _vnode) {
72
+ if (el) {
73
+ const ite = decrypt(localStorage.getItem(('tipo_entidade_nome')) + '')
74
+
75
+ if (!(binding.value === ite)) {
76
+ el.style.display = 'none'
77
+ }
78
+ }
79
+ }
80
+ }
81
+
82
+ export const isTipoEntidadeMe = function (x) {
83
+ const ite = decrypt(localStorage.getItem(('tipo_entidade_nome')) + '')
84
+ if (x === ite) { return true } else { return false }
85
+ }
86
+
87
+ export const urlBase = (url = '') => {
88
+ if (url === '') {
89
+ return process.env.API
90
+ }
91
+
92
+ if (url != null) {
93
+ if (url[0] === '/') {
94
+ return process.env.API + url
95
+ }
96
+ if (url[0] === 'h') {
97
+ return url
98
+ }
99
+ }
100
+ }
101
+
102
+
103
+
104
+
105
+ export const MeIsTipoEntidade = (nome) => {
106
+ let result = false
107
+ if (JSON.parse(getStorage('c', 'tipoEntidade'))?.nome === nome) {
108
+ result = true
109
+ }
110
+ return result
111
+ }