@davra/ui-core 1.0.0-alpha.1 → 1.0.0-alpha.3

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 (51) hide show
  1. package/package.json +1 -2
  2. package/src/assets/fonts/myfont.woff +0 -0
  3. package/src/assets/main.scss +0 -17
  4. package/src/auto-imports.d.ts +0 -200
  5. package/src/components/ComponentA.vue +0 -13
  6. package/src/components/ComponentB.vue +0 -26
  7. package/src/components/index.ts +0 -7
  8. package/src/constants/MyConstants.ts +0 -1
  9. package/src/constants/index.ts +0 -5
  10. package/src/env.d.ts +0 -8
  11. package/src/index.ts +0 -23
  12. package/src/services/davraApi.ts +0 -18
  13. package/src/services/devicesCountersService.test.ts +0 -209
  14. package/src/services/devicesCountersService.ts +0 -117
  15. package/src/services/devicesService.test.ts +0 -207
  16. package/src/services/devicesService.ts +0 -110
  17. package/src/services/index.ts +0 -22
  18. package/src/services/labelsService.test.ts +0 -124
  19. package/src/services/labelsService.ts +0 -71
  20. package/src/services/metricsCountersService.test.ts +0 -44
  21. package/src/services/metricsCountersService.ts +0 -24
  22. package/src/services/metricsService.test.ts +0 -97
  23. package/src/services/metricsService.ts +0 -54
  24. package/src/services/timeseriesService.test.ts +0 -86
  25. package/src/services/timeseriesService.ts +0 -24
  26. package/src/services/twinTypesService.test.ts +0 -74
  27. package/src/services/twinTypesService.ts +0 -24
  28. package/src/services/twinsCountersService.test.ts +0 -72
  29. package/src/services/twinsCountersService.ts +0 -40
  30. package/src/services/twinsService.test.ts +0 -228
  31. package/src/services/twinsService.ts +0 -137
  32. package/src/services/userSessionService.test.ts +0 -74
  33. package/src/services/userSessionService.ts +0 -82
  34. package/src/stores/alertMessages.test.ts +0 -27
  35. package/src/stores/alertMessages.ts +0 -26
  36. package/src/stores/devices.test.ts +0 -149
  37. package/src/stores/devices.ts +0 -78
  38. package/src/stores/index.ts +0 -12
  39. package/src/stores/labels.test.ts +0 -72
  40. package/src/stores/labels.ts +0 -39
  41. package/src/stores/metrics.test.ts +0 -116
  42. package/src/stores/metrics.ts +0 -71
  43. package/src/stores/twinTypes.test.ts +0 -71
  44. package/src/stores/twinTypes.ts +0 -36
  45. package/src/stores/twins.test.ts +0 -148
  46. package/src/stores/twins.ts +0 -78
  47. package/src/stores/userSession.test.ts +0 -107
  48. package/src/stores/userSession.ts +0 -57
  49. package/src/types.ts +0 -173
  50. package/src/utils/MyUtil.ts +0 -7
  51. package/src/utils/index.ts +0 -5
@@ -1,228 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
2
- import TwinsService from '~/services/twinsService'
3
-
4
- const mockGet = vi.fn()
5
- const mockPost = vi.fn()
6
- vi.mock('./davraApi', () => {
7
- return {
8
- default: vi.fn(() => ({
9
- get: mockGet,
10
- post: mockPost,
11
- })),
12
- }
13
- })
14
-
15
- describe('Twins Service', () => {
16
- beforeEach(() => {
17
-
18
- })
19
-
20
- afterEach(() => {
21
-
22
- })
23
-
24
- it('getTwins success', async () => {
25
- const mockTwins = [
26
- {
27
- _id: '63a1d1f4dc0df42c6af2eebd',
28
- name: 'testQuentin',
29
- description: '',
30
- labels: { stateful_incident: '3d54e4f7-cf42-4d9e-969f-29cbbc083689' },
31
- digitalTwinType: 'e8cc8e7d-900b-49da-b3df-43dceb101690',
32
- customAttributes: {},
33
- tenantId: 'ruban',
34
- deviceType: 'digitalTwin',
35
- UUID: '3d54e4f7-cf42-4d9e-969f-29cbbc083689',
36
- createdTime: 1671549428165,
37
- owner: '451e5a4868b3fd5bda206fc82e436ac3',
38
- digitalTwinTypeName: 'stateful_incident',
39
- },
40
- ]
41
- const axiosGet = mockGet.mockResolvedValueOnce({ data: mockTwins, status: 200, headers: { 'com-davra-total-results': '1' } })
42
-
43
- const result = await TwinsService.getTwins(0, 10, 'name', 'name=test')
44
-
45
- expect(axiosGet).toHaveBeenCalledWith('/api/v1/twins?start=0&limit=10&sort=name&name=test', {
46
- headers: {
47
- Accept: 'application/json',
48
- },
49
- })
50
-
51
- expect(result).toEqual({ totalRecords: 1, records: mockTwins })
52
- })
53
-
54
- it('getTwins api unkown error', async () => {
55
- const axiosGet = mockGet.mockRejectedValueOnce('')
56
-
57
- await expect(TwinsService.getTwins(0, 10, 'name', 'name=test')).rejects.toThrow(new Error('Twins API Error'))
58
- expect(axiosGet).toHaveBeenCalledWith('/api/v1/twins?start=0&limit=10&sort=name&name=test', {
59
- headers: {
60
- Accept: 'application/json',
61
- },
62
- })
63
- })
64
-
65
- it('queryTwins success', async () => {
66
- const mockTwins = [
67
- {
68
- _id: '63a1d1f4dc0df42c6af2eebd',
69
- name: 'testQuentin',
70
- description: '',
71
- labels: { stateful_incident: '3d54e4f7-cf42-4d9e-969f-29cbbc083689' },
72
- digitalTwinType: 'e8cc8e7d-900b-49da-b3df-43dceb101690',
73
- customAttributes: {},
74
- tenantId: 'ruban',
75
- deviceType: 'digitalTwin',
76
- UUID: '3d54e4f7-cf42-4d9e-969f-29cbbc083689',
77
- createdTime: 1671549428165,
78
- owner: '451e5a4868b3fd5bda206fc82e436ac3',
79
- digitalTwinTypeName: 'stateful_incident',
80
- },
81
- ]
82
- const axiosPost = mockPost.mockResolvedValueOnce({ data: mockTwins, status: 200, headers: { 'com-davra-total-results': '1' } })
83
-
84
- const result = await TwinsService.queryTwins({ start: 0, limit: 20000, gpsLastSeen: { $exists: true } })
85
-
86
- expect(axiosPost).toHaveBeenCalledWith('/api/v1/twins/query', { start: 0, limit: 20000, gpsLastSeen: { $exists: true } }, {
87
- headers: {
88
- Accept: 'application/json',
89
- },
90
- })
91
-
92
- expect(result).toEqual({ totalRecords: 1, records: mockTwins })
93
- })
94
-
95
- it('queryTwins api unkown error', async () => {
96
- const axiosPost = mockPost.mockRejectedValueOnce('')
97
-
98
- await expect(TwinsService.queryTwins({ start: 0, limit: 20000, gpsLastSeen: { $exists: true } })).rejects.toThrow(new Error('Twins API Error'))
99
- expect(axiosPost).toHaveBeenCalledWith('/api/v1/twins/query', { start: 0, limit: 20000, gpsLastSeen: { $exists: true } }, {
100
- headers: {
101
- Accept: 'application/json',
102
- },
103
- })
104
- })
105
- it('getTwinsByTypeName success', async () => {
106
- const mockTwins = [
107
- {
108
- _id: '63a1d1f4dc0df42c6af2eebd',
109
- name: 'testQuentin',
110
- description: '',
111
- labels: { stateful_incident: '3d54e4f7-cf42-4d9e-969f-29cbbc083689' },
112
- digitalTwinType: 'e8cc8e7d-900b-49da-b3df-43dceb101690',
113
- customAttributes: {},
114
- tenantId: 'ruban',
115
- deviceType: 'digitalTwin',
116
- UUID: '3d54e4f7-cf42-4d9e-969f-29cbbc083689',
117
- createdTime: 1671549428165,
118
- owner: '451e5a4868b3fd5bda206fc82e436ac3',
119
- digitalTwinTypeName: 'stateful_incident',
120
- },
121
- ]
122
- const axiosGet = mockGet.mockResolvedValueOnce({ data: mockTwins, status: 200, headers: { 'com-davra-total-results': '1' } })
123
-
124
- const result = await TwinsService.getTwinsByTypeName('stateful_incident')
125
-
126
- expect(axiosGet).toHaveBeenCalledWith('/api/v1/twins/?digitalTwinTypeName=stateful_incident&limit=1000&start=0', {
127
- headers: {
128
- Accept: 'application/json',
129
- },
130
- })
131
-
132
- expect(result).toEqual({ totalRecords: 1, records: mockTwins })
133
- })
134
-
135
- it('getTwinsByTypeName api unkown error', async () => {
136
- const axiosGet = mockGet.mockRejectedValueOnce('')
137
-
138
- await expect(TwinsService.getTwinsByTypeName('stateful_incident')).rejects.toThrow(new Error('Twins API Error'))
139
- expect(axiosGet).toHaveBeenCalledWith('/api/v1/twins/?digitalTwinTypeName=stateful_incident&limit=1000&start=0', {
140
- headers: {
141
- Accept: 'application/json',
142
- },
143
- })
144
- await expect(TwinsService.getTwinByUUID('abc123')).rejects.toThrow(new Error('Twins API Error'))
145
- })
146
-
147
- it('should return an array of twins when given an array of uuids', async () => {
148
- const uuids = ['uuid1', 'uuid2', 'uuid3']
149
- const data = [{ uuid: 'uuid1' }, { uuid: 'uuid2' }, { uuid: 'uuid3' }]
150
-
151
- mockGet.mockResolvedValueOnce({ data, headers: { 'com-davra-total-results': '3' } })
152
-
153
- const result = await TwinsService.getTwinByUUIDs(uuids)
154
-
155
- expect(result).toEqual({ totalRecords: 3, records: data })
156
- expect(mockGet).toHaveBeenCalledWith(
157
- '/api/v1/twins?arrayUUIDs=uuid1,uuid2,uuid3',
158
- {
159
- headers: {
160
- Accept: 'application/json',
161
- },
162
- },
163
- )
164
- })
165
-
166
- it('should return an empty array when an error occurs', async () => {
167
- const uuids = ['uuid1', 'uuid2', 'uuid3']
168
- const error = new Error('API Error')
169
-
170
- mockGet.mockRejectedValueOnce(error)
171
-
172
- await expect(TwinsService.getTwinByUUIDs(uuids)).rejects.toThrow(new Error('Twins API Error'))
173
-
174
- expect(mockGet).toHaveBeenCalledWith(
175
- '/api/v1/twins?arrayUUIDs=uuid1,uuid2,uuid3',
176
- {
177
- headers: {
178
- Accept: 'application/json',
179
- },
180
- },
181
- )
182
- })
183
-
184
- it('should return the twin data when successful', async () => {
185
- const mockResponse = { data: { uuid: 'abc123', name: 'test twin' } }
186
- mockGet.mockResolvedValueOnce(mockResponse)
187
-
188
- const result = await TwinsService.getTwinByUUID('abc123')
189
- expect(mockGet).toHaveBeenCalledWith('/api/v1/twins/abc123', {
190
- headers: {
191
- Accept: 'application/json',
192
- },
193
- })
194
- expect(result).toEqual(mockResponse.data)
195
- })
196
-
197
- it('should return null when the API call fails', async () => {
198
- const mockError = new Error('API error')
199
- mockGet.mockRejectedValueOnce(mockError)
200
-
201
- await expect(TwinsService.getTwinByUUID('abc123')).rejects.toThrow(new Error('Twins API Error'))
202
- })
203
-
204
- it('getTwinAttachements success', async () => {
205
- const axiosGet = mockGet.mockResolvedValueOnce({ data: '', status: 200, headers: { 'com-davra-total-results': '1' } })
206
-
207
- const result = await TwinsService.getTwinAttachements('uuid111')
208
-
209
- expect(axiosGet).toHaveBeenCalledWith('/api/v1/twins/uuid111/attachments', {
210
- headers: {
211
- Accept: 'application/json',
212
- },
213
- })
214
-
215
- expect(result).toEqual('')
216
- })
217
-
218
- it('getTwinAttachements api unkown error', async () => {
219
- const axiosGet = mockGet.mockRejectedValueOnce('')
220
-
221
- await expect(TwinsService.getTwinAttachements('uuid111')).rejects.toThrow(new Error('Twins API Error'))
222
- expect(axiosGet).toHaveBeenCalledWith('/api/v1/twins/uuid111/attachments', {
223
- headers: {
224
- Accept: 'application/json',
225
- },
226
- })
227
- })
228
- })
@@ -1,137 +0,0 @@
1
- import {DavraApiClient} from './davraApi'
2
-
3
- import type { Twin } from '~/types'
4
-
5
- const getTwins = async (start = 0, limit = 1000, sort?: string, filters?: string): Promise< { totalRecords: number; records: Twin[] } > => {
6
- const params = []
7
- params.push(`start=${start || 0}`)
8
-
9
- if (limit)
10
- params.push(`limit=${limit}`)
11
- if (sort)
12
- params.push(`sort=${sort}`)
13
- if (filters)
14
- params.push(filters)
15
-
16
- try {
17
- const { data, headers } = await DavraApiClient().get<any>(
18
- `/api/v1/twins?${params.join('&')}`,
19
- {
20
- headers: {
21
- Accept: 'application/json',
22
- },
23
- },
24
-
25
- )
26
- return { totalRecords: parseInt(headers['com-davra-total-results']), records: data }
27
- }
28
- catch (error) {
29
- throw new Error('Twins API Error')
30
- }
31
- }
32
-
33
- const queryTwins = async (query: any) => {
34
- try {
35
- const { data, headers } = await DavraApiClient().post<any>(
36
- '/api/v1/twins/query',
37
- query,
38
- {
39
- headers: {
40
- Accept: 'application/json',
41
- },
42
- },
43
-
44
- )
45
- return { totalRecords: parseInt(headers['com-davra-total-results']), records: data }
46
- }
47
- catch (error) {
48
- throw new Error('Twins API Error')
49
- }
50
- }
51
- // to be replace by twin query
52
- const getTwinByUUIDs = async (uuids: string[]): Promise<{ totalRecords: number; records: Twin[] }> => {
53
- try {
54
- const { data, headers } = await DavraApiClient().get<any>(
55
- `/api/v1/twins?arrayUUIDs=${uuids.join(',')}`,
56
- {
57
- headers: {
58
- Accept: 'application/json',
59
- },
60
- },
61
-
62
- )
63
- return { totalRecords: parseInt(headers['com-davra-total-results']), records: data }
64
- }
65
- catch (error) {
66
- throw new Error('Twins API Error')
67
- }
68
- }
69
- const getTwinsByTypeName = async (twinTypeName: string, start = 0, limit = 1000, sort?: string, searchString?: string): Promise<{ totalRecords: number; records: Twin[] }> => {
70
- const params = [`digitalTwinTypeName=${twinTypeName}`, `limit=${limit}`, `start=${start}`]
71
- if (sort)
72
- params.push(`sort=${sort}`)
73
-
74
- if (searchString)
75
- params.push(`name=~${searchString}`)
76
-
77
- try {
78
- const { data, headers } = await DavraApiClient().get<any>(
79
- `/api/v1/twins/?${params.join('&')}`,
80
- {
81
- headers: {
82
- Accept: 'application/json',
83
- },
84
- },
85
-
86
- )
87
- return { totalRecords: parseInt(headers['com-davra-total-results']), records: data }
88
- }
89
- catch (error) {
90
- throw new Error('Twins API Error')
91
- }
92
- }
93
-
94
- const getTwinByUUID = async (uuid: string): Promise<Twin | null> => {
95
- try {
96
- const { data } = await DavraApiClient().get<any>(
97
- `/api/v1/twins/${uuid}`,
98
- {
99
- headers: {
100
- Accept: 'application/json',
101
- },
102
- },
103
-
104
- )
105
- return data
106
- }
107
- catch (error) {
108
- throw new Error('Twins API Error')
109
- }
110
- }
111
-
112
- const getTwinAttachements = async (uuid: string): Promise<any> => {
113
- try {
114
- const { data } = await DavraApiClient().get<any>(
115
- `/api/v1/twins/${uuid}/attachments`,
116
- {
117
- headers: {
118
- Accept: 'application/json',
119
- },
120
- },
121
-
122
- )
123
- return data
124
- }
125
- catch {
126
- throw new Error('Twins API Error')
127
- }
128
- }
129
-
130
- export default {
131
- getTwins,
132
- getTwinsByTypeName,
133
- getTwinByUUID,
134
- getTwinByUUIDs,
135
- getTwinAttachements,
136
- queryTwins,
137
- }
@@ -1,74 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
2
- import UserSessionService from '~/services/userSessionService'
3
-
4
- const mockGet = vi.fn()
5
- const mockPost = vi.fn()
6
- vi.mock('./davraApi', () => {
7
- return {
8
- DavraApiClient: vi.fn(() => ({
9
- get: mockGet,
10
- post: mockPost,
11
- })),
12
- }
13
- })
14
-
15
- describe('Tenant Settings Service', () => {
16
- beforeEach(() => {
17
- })
18
-
19
- afterEach(() => {
20
-
21
- })
22
-
23
- it('getUser success', async () => {
24
- const mockUser = { _id: '631b1b74abf76669a84d0d54', name: 'admin', UUID: '451e5a4868b3fd5bda206fc82e436ac3', roles: ['6e4a4605-548e-4afb-a887-dfbf7a3232ea'], tenantId: 'ruban', tenants: ['ruban'], creationTime: '2022-09-09T10:54:44.904Z', id: 'admin', displayName: 'admin', modifiedTime: '2022-10-27T08:51:10.622Z', sso: null, isAdmin: true, isAdministrator: true }
25
-
26
- const axiosGet = mockGet.mockResolvedValue({ data: mockUser, status: 200 })
27
-
28
- const result = await UserSessionService.getUser()
29
-
30
- expect(axiosGet).toHaveBeenCalledWith('/user', {
31
- headers: {
32
- Accept: 'application/json',
33
- },
34
- })
35
-
36
- expect(result).toEqual(mockUser)
37
- })
38
-
39
- it('getUser api error', async () => {
40
- mockGet.mockRejectedValueOnce(new Error('Get user error'))
41
-
42
- await expect(UserSessionService.getUser()).rejects.toThrow(new Error('Get user error'))
43
- })
44
-
45
- it('getUserPermissions success', async () => {
46
- const mockUserPermissions = [{ Action: 'devices.ACCESS', Allowed: true }, { Action: 'devices.CREATE_DEVICE', Allowed: true }, { Action: 'devicetypes.CREATE_DEVICE_TYPE', Allowed: true }, { Action: 'devices.DELETE', Allowed: true }, { Action: 'metrics.ACCESS', Allowed: true }, { Action: 'metrics.CREATE_METRIC', Allowed: true }, { Action: 'users.ACCESS', Allowed: true }, { Action: 'users.CREATE_USER', Allowed: true }, { Action: 'applications.ACCESS', Allowed: true }, { Action: 'applications.CREATE_APPLICATION', Allowed: true }, { Action: 'rulesengine.ACCESS', Allowed: true }, { Action: 'rulesengine.CREATE_RULE', Allowed: true }, { Action: 'microservices.ACCESS', Allowed: true }, { Action: 'microservices.CREATE_MICROSERVICE', Allowed: true }, { Action: 'componenttoolkit.ACCESS', Allowed: true }, { Action: 'componenttoolkit.CREATE_WIDGET', Allowed: true }, { Action: 'authorization.roles.ACCESS', Allowed: true }, { Action: 'authorization.roles.CREATE_ROLE', Allowed: true }, { Action: 'jobs.ACCESS', Allowed: true }, { Action: 'jobs.CREATE_JOB', Allowed: true }, { Action: 'files.ACCESS', Allowed: true }, { Action: 'files.CREATE_FILE', Allowed: true }, { Action: 'auditlogs.ACCESS', Allowed: true }, { Action: 'twintypes.ACCESS', Allowed: true }, { Action: 'twintypes.CREATE_TWINTYPE', Allowed: true }, { Action: 'twins.ACCESS', Allowed: true }, { Action: 'twins.CREATE_TWIN', Allowed: true }, { Action: 'features.ACCESS', Allowed: true }, { Action: 'features.CREATE_FEATURE', Allowed: true }, { Action: 'oauthclients.ACCESS', Allowed: true }, { Action: 'oauthclients.CREATE', Allowed: true }, { Action: 'digitalSignatures.ACCESS' }, { Action: 'digitalSignatures.CREATE_DIGITAL_SIGNATURE' }]
47
-
48
- const axiosPost = mockPost.mockResolvedValue({ data: mockUserPermissions, status: 200 })
49
-
50
- const result = await UserSessionService.getUserPermissions()
51
-
52
- expect(axiosPost).toHaveBeenCalledWith('/api/v1/authorization/policy/check', UserSessionService.permissionList, {
53
- headers: {
54
- Accept: 'application/json',
55
- },
56
- })
57
-
58
- expect(result).toEqual(mockUserPermissions)
59
- })
60
-
61
- it('getUserPermissions api unknown error', async () => {
62
- const axiosPost = mockPost.mockRejectedValueOnce('')
63
-
64
- const result = await UserSessionService.getUserPermissions()
65
-
66
- expect(axiosPost).toHaveBeenCalledWith('/api/v1/authorization/policy/check', UserSessionService.permissionList, {
67
- headers: {
68
- Accept: 'application/json',
69
- },
70
- })
71
-
72
- expect(result).toEqual([])
73
- })
74
- })
@@ -1,82 +0,0 @@
1
- import {DavraApiClient} from './davraApi'
2
- import type { Permission, User } from '~/types'
3
-
4
- const getUser = async (): Promise<User | null> => {
5
- try {
6
- const { data } = await DavraApiClient().get<User>(
7
- '/user',
8
- {
9
- headers: {
10
- Accept: 'application/json',
11
- },
12
- },
13
- )
14
-
15
- return data
16
- }
17
- catch (error) {
18
- throw error
19
- }
20
- }
21
- const permissionList = [{ Action: 'devices.ACCESS' },
22
- { Action: 'devices.CREATE_DEVICE' },
23
- { Action: 'devicetypes.CREATE_DEVICE_TYPE' },
24
- { Action: 'devices.DELETE' },
25
- { Action: 'metrics.ACCESS' },
26
- { Action: 'metrics.CREATE_METRIC' },
27
- { Action: 'users.ACCESS' },
28
- { Action: 'users.CREATE_USER' },
29
- { Action: 'applications.ACCESS' },
30
- { Action: 'applications.CREATE_APPLICATION' },
31
- { Action: 'rulesengine.ACCESS' },
32
- { Action: 'rulesengine.CREATE_RULE' },
33
- { Action: 'microservices.ACCESS' },
34
- { Action: 'microservices.CREATE_MICROSERVICE' },
35
- { Action: 'componenttoolkit.ACCESS' },
36
- { Action: 'componenttoolkit.CREATE_WIDGET' },
37
- { Action: 'authorization.roles.ACCESS' },
38
- { Action: 'authorization.roles.CREATE_ROLE' },
39
- { Action: 'jobs.ACCESS' },
40
- { Action: 'jobs.CREATE_JOB' },
41
- { Action: 'files.ACCESS' },
42
- { Action: 'files.CREATE_FILE' },
43
- { Action: 'auditlogs.ACCESS' },
44
- { Action: 'twintypes.ACCESS' },
45
- { Action: 'twintypes.CREATE_TWINTYPE' },
46
- { Action: 'twins.ACCESS' },
47
- { Action: 'twins.CREATE_TWIN' },
48
- { Action: 'features.ACCESS' },
49
- { Action: 'features.CREATE_FEATURE' },
50
- { Action: 'oauthclients.ACCESS' },
51
- { Action: 'oauthclients.CREATE' },
52
- { Action: 'digitalSignatures.ACCESS' },
53
- { Action: 'digitalSignatures.CREATE_DIGITAL_SIGNATURE' },
54
- { Action: 'dashboards.ACCESS' },
55
- { Action: 'dashboards.CREATE_DASHBOARD' },
56
- { Action: 'integrations.ACCESS' },
57
- ]
58
-
59
- const getUserPermissions = async (permissions: { Action: string; Resource: string }[] = []): Promise<Permission[]> => {
60
- try {
61
- const { data } = await DavraApiClient().post<Permission[]>(
62
- '/api/v1/authorization/policy/check',
63
- permissions.length ? permissions : permissionList,
64
- {
65
- headers: {
66
- Accept: 'application/json',
67
- },
68
- },
69
- )
70
-
71
- return data
72
- }
73
- catch (error) {
74
- return []
75
- }
76
- }
77
-
78
- export default {
79
- getUser,
80
- getUserPermissions,
81
- permissionList,
82
- }
@@ -1,27 +0,0 @@
1
- import { createPinia, setActivePinia } from 'pinia'
2
- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
3
- import { useAlertMessagesStore } from './alertMessages'
4
-
5
- describe('Devices Store', () => {
6
- beforeEach(() => {
7
- // creates a fresh pinia and make it active so it's automatically picked
8
- // up by any useStore() call without having to pass it to it:
9
- // `useStore(pinia)`
10
- setActivePinia(createPinia())
11
- })
12
-
13
- it('should setSnackbarMessage', async () => {
14
- const store = useAlertMessagesStore()
15
-
16
- store.setSnackbarMessage('hello', 'info', 1000)
17
-
18
- expect(store.snackbar).toEqual(true)
19
- expect(store.snackbarText).toEqual('hello')
20
- expect(store.snackbarSeverity).toEqual('info')
21
- expect(store.snackbarTimeout).toEqual(1000)
22
- })
23
-
24
- afterEach(() => {
25
- vi.restoreAllMocks()
26
- })
27
- })
@@ -1,26 +0,0 @@
1
- import { acceptHMRUpdate, defineStore } from 'pinia'
2
-
3
- export const useAlertMessagesStore = defineStore('alertMessages', () => {
4
- const snackbar = ref<boolean>(false)
5
- const snackbarText = ref<string>('')
6
- const snackbarSeverity = ref<string>('')
7
- const snackbarTimeout = ref<number>(5000)
8
-
9
- const setSnackbarMessage = (text = '', severity = '', timeout = 5000) => {
10
- snackbarText.value = text
11
- snackbarSeverity.value = severity
12
- snackbarTimeout.value = timeout
13
- snackbar.value = true
14
- }
15
-
16
- return {
17
- snackbar,
18
- snackbarText,
19
- snackbarSeverity,
20
- snackbarTimeout,
21
- setSnackbarMessage,
22
- }
23
- })
24
- if (import.meta.hot)
25
- import.meta.hot.accept(acceptHMRUpdate(useAlertMessagesStore, import.meta.hot))
26
-