eztech-core-components 1.0.2 → 1.0.4

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.
@@ -261,7 +261,7 @@ export default {
261
261
  },
262
262
  computed: {
263
263
  ...mapGetters('settings', ['env']),
264
- ...mapGetters('user', ['token']),
264
+ ...mapGetters('user', ['token', 'authType']),
265
265
  isMultiple () {
266
266
  return getFormBoolean(this.col_multiple)
267
267
  },
@@ -464,24 +464,16 @@ export default {
464
464
  const headers = {
465
465
  'Content-Type': 'multipart/form-data'
466
466
  }
467
- // if (this.token) {
468
- // headers.Authorization = `Bearer ${this.token}`
469
- // }
470
- // const instance = axios.create({
471
- // baseURL: this.env.baseUrl,
472
- // headers,
473
- // withCredentials: true
474
- // })
475
-
467
+ if (this.token && this.authType === 'header') {
468
+ headers.Authorization = `Bearer ${this.token}`
469
+ }
476
470
  let uploadUrl = 'file/upload'
477
471
  if (this.unsupportedImageTypes.includes(file.file.type)) {
478
472
  uploadUrl = 'file/upload/image'
479
473
  }
480
474
  // const { data } = await instance.post(uploadUrl, formData)
481
475
  const { data } = await this.$axios.post(uploadUrl, formData, {
482
- headers: {
483
- 'Content-Type': 'multipart/form-data'
484
- },
476
+ headers,
485
477
  withCredentials: true
486
478
  })
487
479
  this.handleAddFile(data, file.url)
@@ -73,8 +73,8 @@
73
73
  import { isEqual, get, has, cloneDeep } from 'lodash'
74
74
  import Schema from 'async-validator'
75
75
  import { getTriggerFields } from '../utils/data-helper'
76
- import { getButtons } from './../utils/role-helper'
77
76
  import { tableData, tableMethods, tableComputed, tableWatch, getAsyncData } from '../utils/table-helper'
77
+ import { getButtons } from './../utils/role-helper'
78
78
  export default {
79
79
  name: 'CoreFormTableInline',
80
80
  props: {
@@ -38,7 +38,7 @@ export default {
38
38
  },
39
39
  computed: {
40
40
  ...mapGetters('settings', ['env', 'unsavedChanges']),
41
- ...mapGetters('user', ['token']),
41
+ ...mapGetters('user', ['token', 'authType']),
42
42
  isDisabledButton () { return this.pdfFiles.length === this.pdfUrls.length }
43
43
  },
44
44
  methods: {
@@ -57,11 +57,13 @@ export default {
57
57
  const headers = { 'Content-Type': 'multipart/form-data' }
58
58
  if (this.ptoken) {
59
59
  headers.Authorization = `Bearer ${this.ptoken}`
60
- } else if (this.token) {
60
+ } else if (this.token && this.authType === 'header') {
61
61
  headers.Authorization = `Bearer ${this.token}`
62
62
  }
63
- const instance = this.$axios.create({ baseURL: this.env.baseUrl, headers })
64
- const { data } = await instance.post(`file/${this.uploadUrl}`, formData)
63
+ const { data } = await this.$axios(`file/${this.uploadUrl}`, formData, {
64
+ headers,
65
+ withCredentials: true
66
+ })
65
67
  this.pdfFiles.push(data)
66
68
  const index = this.pdfUrls.findIndex(c => c.filename === filename)
67
69
  const nextPdfUrl = get(this.pdfUrls, `[${index + 1}]`)
@@ -120,8 +122,10 @@ export default {
120
122
  } else if (this.token) {
121
123
  headers.Authorization = `Bearer ${this.token}`
122
124
  }
123
- const instance = this.$axios.create({ baseURL: this.env.baseUrl, headers })
124
- const { data } = await instance.post(`file/${this.uploadUrl}`, formData)
125
+ const { data } = await this.$axios.post(`file/${this.uploadUrl}`, formData, {
126
+ headers,
127
+ withCredentials: true
128
+ })
125
129
  this.pdfFiles.push(data)
126
130
  }
127
131
  }
@@ -476,8 +476,8 @@ export default {
476
476
  statuses: { type: Array, default: () => { return [] } },
477
477
  statusCount: { type: Object, default: () => { return null } },
478
478
  editFields: { type: Array, default: () => { return [] } },
479
- totalDurationMs: { type: Number, default: () => { return null }},
480
- clientDurationMs: { type: Number, default: () => { return null }}
479
+ totalDurationMs: { type: Number, default: () => { return null } },
480
+ clientDurationMs: { type: Number, default: () => { return null } }
481
481
  },
482
482
  data () {
483
483
  return {
@@ -572,7 +572,7 @@ export default {
572
572
  const list = []
573
573
  const deleteCodes = ['DELETE', 'REMOVE']
574
574
  if (this.actions?.length && this.table_name === 'doc_requests') {
575
- list.push(...this.actions.filter(k => this.level?.actions.some(c => (c.code === k.code) || (deleteCodes.includes(c.code) && deleteCodes.includes(k.code)) )).filter((c) => {
575
+ list.push(...this.actions.filter(k => this.level?.actions.some(c => (c.code === k.code) || (deleteCodes.includes(c.code) && deleteCodes.includes(k.code)))).filter((c) => {
576
576
  if (c.isNotSystem && this.currentRow?.is_system) {
577
577
  return false
578
578
  }
@@ -5,7 +5,7 @@
5
5
  :title="label"
6
6
  >
7
7
  {{ label }}
8
- <!-- {{ col_key }} -->
8
+ <!-- {{ col_key }} -->
9
9
  </div>
10
10
  <div v-if="sortable" class="caret-wrapper w-6">
11
11
  <i class="sort-caret ascending" @click.stop="$emit('sort-change', { prop: col_key, order: 'ascending' })" />
@@ -474,17 +474,12 @@ export default {
474
474
  formData.append('width', file.width)
475
475
  formData.append('height', file.height)
476
476
  formData.append('is_secret', this.isFileSecret)
477
- // const headers = {
478
- // 'Content-Type': 'multipart/form-data'
479
- // }
480
- // if (this.token) {
481
- // headers.Authorization = `Bearer ${this.token}`
482
- // }
483
- // const instance = axios.create({
484
- // baseURL: this.env.baseUrl,
485
- // headers,
486
- // withCredentials: true
487
- // })
477
+ const headers = {
478
+ 'Content-Type': 'multipart/form-data'
479
+ }
480
+ if (this.token && this.authType === 'header') {
481
+ headers.Authorization = `Bearer ${this.token}`
482
+ }
488
483
  file.startDate = new Date()
489
484
  const CancelToken = this.$axios.CancelToken
490
485
  const that = this
@@ -524,9 +519,7 @@ export default {
524
519
  }
525
520
  // const { data } = await instance.post(uploadUrl, formData, config)
526
521
  const { data } = await this.$axios.post(uploadUrl, formData, {
527
- headers: {
528
- 'Content-Type': 'multipart/form-data'
529
- },
522
+ headers,
530
523
  withCredentials: true
531
524
  }, config)
532
525
  this.$emit('input', data)
@@ -72,20 +72,12 @@ export default {
72
72
  try {
73
73
  const formData = new FormData()
74
74
  formData.append('file', file)
75
- // const headers = { 'Content-Type': 'multipart/form-data' }
76
- // if (this.token) {
77
- // headers.Authorization = `Bearer ${this.token}`
78
- // }
79
- // const instance = axios.create({
80
- // baseURL: this.env.baseUrl,
81
- // headers,
82
- // withCredentials: true
83
- // })
84
- // const { data } = await instance.post('file/upload', formData)
75
+ const headers = { 'Content-Type': 'multipart/form-data' }
76
+ if (this.token && this.authType === 'header') {
77
+ headers.Authorization = `Bearer ${this.token}`
78
+ }
85
79
  const { data } = await this.$axios.post('file/upload', formData, {
86
- headers: {
87
- 'Content-Type': 'multipart/form-data'
88
- },
80
+ headers,
89
81
  withCredentials: true
90
82
  })
91
83
  Editor.insertEmbed(cursorLocation, 'image', `${this.env.baseUrl}/file/${data._id}`)
@@ -82,7 +82,6 @@ export default {
82
82
  matches.push(match[1])
83
83
  }
84
84
  }
85
- console.log('matches', matches)
86
85
  return matches
87
86
  }
88
87
  },
package/index.js CHANGED
@@ -1,16 +1,26 @@
1
1
  export default {
2
- install(Vue) {
2
+ install (Vue) {
3
3
  const requireComponent = require.context(
4
4
  './comps',
5
5
  true,
6
6
  /\.vue$/
7
7
  )
8
- requireComponent.keys().forEach(fileName => {
8
+ requireComponent.keys().forEach((fileName) => {
9
9
  const componentConfig = requireComponent(fileName)
10
- const componentName = fileName
11
- .split('/')
12
- .pop()
13
- .replace(/\.\w+$/, '')
10
+ const componentName = fileName.split('/').slice(1).join('').replace(/\.\w+$/, '')
11
+ Vue.component(
12
+ componentName,
13
+ componentConfig.default || componentConfig
14
+ )
15
+ })
16
+ const chartComponent = require.context(
17
+ './charts',
18
+ true,
19
+ /\.vue$/
20
+ )
21
+ chartComponent.keys().forEach((fileName) => {
22
+ const componentConfig = chartComponent(fileName)
23
+ const componentName = fileName.split('/').slice(1).join('').replace(/\.\w+$/, '')
14
24
  Vue.component(
15
25
  componentName,
16
26
  componentConfig.default || componentConfig
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eztech-core-components",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -34,6 +34,7 @@
34
34
  "dependencies": {
35
35
  "axios": "^0.30.0",
36
36
  "vue": "^2.7.10",
37
+ "vue-chartjs": "^3.5.1",
37
38
  "vue-cropperjs": "^4.2.0"
38
39
  },
39
40
  "devDependencies": {
package/plugins/axios.js CHANGED
@@ -20,9 +20,17 @@ export default ({ $axios, query, store, $cookies, redirect, i18n, route, params,
20
20
  // delete $axios.defaults.headers.common.Authorization
21
21
  // }
22
22
  const tokenName = store.getters['user/tokenName']
23
+ const authType = store.getters['user/authType']
23
24
  if (tokenName) {
24
25
  $axios.defaults.headers.common['x-pid'] = tokenName
25
26
  }
27
+ if (authType === 'header') {
28
+ $axios.defaults.headers.common['x-at'] = authType
29
+ const userToken = store.getters['user/token']
30
+ if (userToken) {
31
+ $axios.defaults.headers.common.Autherization = `Bearer ${userToken}`
32
+ }
33
+ }
26
34
  $axios.defaults.headers.common['Accept-Language'] = query.lang || i18n?.locale || 'mn'
27
35
  return config
28
36
  })
package/plugins/chart.js CHANGED
@@ -1,134 +1,5 @@
1
1
  /* eslint-disable */
2
- import Vue from 'vue'
3
- import { Bar, Line, Pie } from 'vue-chartjs'
4
2
  import Chart from 'chart.js'
5
-
6
3
  import ChartDataLabels from 'chartjs-plugin-datalabels'
7
4
  Chart.plugins.register(ChartDataLabels)
8
-
9
- Vue.component('LineChart', {
10
- extends: Line,
11
- props: {
12
- data: {
13
- type: Object,
14
- required: false,
15
- },
16
- options: {
17
- type: Object,
18
- required: false,
19
- default: () => ({
20
- responsive: true,
21
- maintainAspectRatio: false,
22
- legend: {
23
- display: true,
24
- },
25
- interaction: {
26
- mode: 'index',
27
- intersect: false
28
- },
29
- scales: {
30
- yAxes: [{
31
- ticks: {
32
- fontColor: 'rgb(75, 85, 99)',
33
- suggestedMin: 30,
34
- suggestedMax: 50,
35
- },
36
- }],
37
- xAxes: [{
38
- ticks: {
39
- fontColor: 'rgb(75, 85, 99)'
40
- },
41
- }]
42
- },
43
- title: {
44
- display: false,
45
- text: ''
46
- }
47
- })
48
- }
49
- },
50
- watch: {
51
- data() {
52
- this.renderChart(this.data, this.options)
53
- },
54
- },
55
- mounted() {
56
- this.renderChart(this.data, this.options)
57
- },
58
- })
59
- Vue.component('BarChart', {
60
- extends: Bar,
61
- props: {
62
- data: {
63
- type: Object,
64
- required: false,
65
- },
66
- options: {
67
- type: Object,
68
- required: false,
69
- default: () => ({
70
- responsive: true,
71
- maintainAspectRatio: false,
72
- legend: {
73
- display: true,
74
- },
75
- scales: {
76
- yAxes: [{
77
- ticks: {
78
- fontColor: 'rgb(75, 85, 99)'
79
- },
80
- }],
81
- xAxes: [{
82
- ticks: {
83
- fontColor: 'rgb(75, 85, 99)'
84
- },
85
- }]
86
- }
87
- })
88
- }
89
- },
90
- watch: {
91
- data() {
92
- this.renderChart(this.data, this.options)
93
- },
94
- },
95
- mounted() {
96
- this.renderChart(this.data, this.options)
97
- },
98
- })
99
- Vue.component('PieChart', {
100
- extends: Pie,
101
- props: {
102
- data: {
103
- type: Object,
104
- required: false,
105
- },
106
- options: {
107
- type: Object,
108
- required: false,
109
- default: () => ({
110
- responsive: true,
111
- maintainAspectRatio: false,
112
- legend: {
113
- position: 'bottom',
114
- labels: {
115
- // fontColor: 'rgb(75, 85, 99)',
116
- }
117
- },
118
- title: {
119
- display: false,
120
- text: ''
121
- }
122
- })
123
- }
124
- },
125
- watch: {
126
- data() {
127
- this.renderChart(this.data, this.options)
128
- },
129
- },
130
- mounted() {
131
- this.renderChart(this.data, this.options)
132
- },
133
- })
134
5
  /* eslint-enable */
package/store/user.js CHANGED
@@ -9,29 +9,21 @@ export const state = () => ({
9
9
  notificationCount: 0,
10
10
  notificationList: [],
11
11
  isLocked: false,
12
- loginProps: null
12
+ loginProps: null,
13
+ authType: 'cookie'
13
14
  })
14
15
 
15
16
  export const getters = {
16
- user (state) {
17
- return state.user
18
- },
19
- token (state) {
20
- return state.token
21
- },
22
- tokenName (state) {
23
- return state.tokenName
24
- },
25
- hideProfile (state) {
26
- return state.hideProfile
27
- },
28
- projectId (state) {
29
- return state.projectId
30
- },
17
+ user (state) { return state.user },
18
+ token (state) { return state.token },
19
+ tokenName (state) { return state.tokenName },
20
+ hideProfile (state) { return state.hideProfile },
21
+ projectId (state) { return state.projectId },
31
22
  notificationCount (state) { return state.notificationCount },
32
23
  notificationList (state) { return state.notificationList },
33
24
  isLocked (state) { return state.isLocked },
34
- loginProps (state) { return state.loginProps }
25
+ loginProps (state) { return state.loginProps },
26
+ authType (state) { return state.authType }
35
27
  }
36
28
 
37
29
  export const mutations = {
@@ -64,6 +56,9 @@ export const mutations = {
64
56
  },
65
57
  SET_LOGIN_PROPS (state, val) {
66
58
  state.loginProps = val
59
+ },
60
+ SET_AUTH_TYPE (state, val) {
61
+ state.authType = val
67
62
  }
68
63
  }
69
64
 
@@ -72,10 +67,14 @@ export const actions = {
72
67
  const tokenName = process.env.TOKEN_NAME || null
73
68
  const projectId = process.env.PROJECT_ID
74
69
  const loginProps = process.env.LOGIN_PROPS
75
- // const token = query[tokenName] || $cookies.get(tokenName)
76
- // if (token) {
77
- // commit('SET_TOKEN', token)
78
- // }
70
+ const authType = process.env.AUTH_TYPE || 'cookie'
71
+ if (authType === 'header') {
72
+ commit('SET_AUTH_TYPE', 'header')
73
+ const token = query[tokenName] || $cookies.get(tokenName)
74
+ if (token) {
75
+ commit('SET_TOKEN', token)
76
+ }
77
+ }
79
78
  commit('SET_LOGIN_PROPS', loginProps)
80
79
  commit('SET_TOKEN_NAME', tokenName)
81
80
  commit('SET_PROJECT_ID', projectId)
@@ -163,8 +162,10 @@ export const actions = {
163
162
  commit('SET_HIDE_PROFILE', value)
164
163
  },
165
164
  set_token ({ commit, getters }, token) {
166
- // const tokenOptions = { maxAge: 60 * 60 * 24 * 7, path: '/' }
167
- // this.$cookies.set(getters.tokenName, token, tokenOptions)
165
+ if (getters.authType === 'header') {
166
+ const tokenOptions = { maxAge: 60 * 60 * 24 * 7, path: '/' }
167
+ this.$cookies.set(getters.tokenName, token, tokenOptions)
168
+ }
168
169
  commit('SET_TOKEN', token)
169
170
  if (process.client) {
170
171
  localStorage.setItem('forensic_checkLogin', Date.now())
@@ -107,7 +107,7 @@ const toText = (num) => {
107
107
 
108
108
  export const toWords = (num, options) => {
109
109
  if (num >= 1000000000000000) {
110
- console.log('mon_num: The number exceeds the limit of 999999999999999')
110
+ // console.log('mon_num: The number exceeds the limit of 999999999999999')
111
111
  return ''
112
112
  }
113
113
 
@@ -4,7 +4,7 @@ import { getRegexp } from './regexps'
4
4
  import { getFormComponent, getFormWidth, getFormColSpan, getFormRowSpan, getColWidth, getColAlign, isHidden } from './component-helper'
5
5
  import { extractRegisterNum, getFormBoolean, addBusinessDays, getTriggerFields, getTriggerEquals, isValidJSON, getIdcardAddress, getAgeFromDate, getGenderFromName } from './data-helper'
6
6
  import { groupFieldLog } from './role-helper'
7
- import { uuidv4, base64ToBlob } from './helpers'
7
+ import { base64ToBlob } from './helpers'
8
8
  export const tableWatch = {
9
9
  id () {
10
10
  if (this.isCustom) {
@@ -36,7 +36,7 @@ export const tableWatch = {
36
36
  export const tableComputed = {
37
37
  ...mapGetters('settings', ['unsavedChanges', 'loadingWindow', 'env']),
38
38
  ...mapGetters(['user_position_id', 'refs']),
39
- ...mapGetters('user', ['token']),
39
+ ...mapGetters('user', ['token', 'authType']),
40
40
  localeId () {
41
41
  return this.tempLocaleId || this.locale?._id || (this.locales?.length ? this.locales[0]._id : null)
42
42
  },
@@ -793,7 +793,7 @@ export const tableMethods = {
793
793
  this.id = 'create'
794
794
  }
795
795
  },
796
- async handleUpdate (row, updateGroupName = null) {
796
+ handleUpdate (row, updateGroupName = null) {
797
797
  this.updateGroupName = updateGroupName
798
798
  this.tid = row.tid
799
799
  setTimeout(() => {
@@ -1300,9 +1300,13 @@ export const tableMethods = {
1300
1300
  const formData = new FormData()
1301
1301
  formData.append('file', blob)
1302
1302
  const headers = { 'Content-Type': 'multipart/form-data' }
1303
- headers.Authorization = `Bearer ${this.token}`
1304
- const instance = this.$axios.create({ baseURL: this.env.baseUrl, headers })
1305
- const { data } = await instance.post('file/upload', formData)
1303
+ if (this.token && this.authType === 'header') {
1304
+ headers.Authorization = `Bearer ${this.token}`
1305
+ }
1306
+ const { data } = await this.$axios.post('file/upload', formData, {
1307
+ headers,
1308
+ withCredentials: true
1309
+ })
1306
1310
  return data
1307
1311
  }
1308
1312
  }
@@ -1,3 +0,0 @@
1
- import Vue from 'vue'
2
- import CKEditor from 'ckeditor4-vue/dist/legacy.js'
3
- Vue.use(CKEditor)