w-web-sso 1.0.0

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 (102) hide show
  1. package/.editorconfig +9 -0
  2. package/.eslintignore +3 -0
  3. package/.eslintrc.js +55 -0
  4. package/.github/workflows/ci-test.yml +24 -0
  5. package/.jsdoc +25 -0
  6. package/.vscode/launch.json +20 -0
  7. package/LICENSE +21 -0
  8. package/README.md +25 -0
  9. package/SECURITY.md +5 -0
  10. package/babel.config.js +15 -0
  11. package/dist/css/app.969ad1db.css +1 -0
  12. package/dist/index.tmp +3 -0
  13. package/dist/js/app-legacy.ff64be1c.js +2 -0
  14. package/dist/js/app-legacy.ff64be1c.js.map +1 -0
  15. package/dist/js/app.ff64be1c.js +2 -0
  16. package/dist/js/app.ff64be1c.js.map +1 -0
  17. package/dist/js/chunk-vendors-legacy.0bb7a31b.js +13 -0
  18. package/dist/js/chunk-vendors-legacy.0bb7a31b.js.map +1 -0
  19. package/dist/js/chunk-vendors.0bb7a31b.js +13 -0
  20. package/dist/js/chunk-vendors.0bb7a31b.js.map +1 -0
  21. package/dist/w-web-sso.umd.js +7 -0
  22. package/dist/w-web-sso.umd.js.map +1 -0
  23. package/docs/WWebSso.html +938 -0
  24. package/docs/WWebSso.mjs.html +721 -0
  25. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  26. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  27. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  28. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  29. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  30. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  31. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  32. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  33. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  34. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  35. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  36. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  37. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  38. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  39. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  40. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  41. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  42. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  43. package/docs/index.html +84 -0
  44. package/docs/scripts/collapse.js +39 -0
  45. package/docs/scripts/commonNav.js +28 -0
  46. package/docs/scripts/linenumber.js +25 -0
  47. package/docs/scripts/nav.js +12 -0
  48. package/docs/scripts/polyfill.js +4 -0
  49. package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  50. package/docs/scripts/prettify/lang-css.js +2 -0
  51. package/docs/scripts/prettify/prettify.js +28 -0
  52. package/docs/scripts/search.js +99 -0
  53. package/docs/styles/jsdoc.css +776 -0
  54. package/docs/styles/prettify.css +80 -0
  55. package/g.backupDb.mjs +10 -0
  56. package/g.getSettings.mjs +17 -0
  57. package/g.initialData.mjs +94 -0
  58. package/g.initialTestData.mjs +21 -0
  59. package/g.mOrm.mjs +24 -0
  60. package/g.provideUsers.mjs +45 -0
  61. package/package.json +70 -0
  62. package/public/index.html +30 -0
  63. package/script.txt +22 -0
  64. package/server/WWebSso.mjs +649 -0
  65. package/server/hashPassword.mjs +27 -0
  66. package/server/proc.mjs +543 -0
  67. package/server/provideUsers.mjs +68 -0
  68. package/src/App.vue +123 -0
  69. package/src/components/Common/CheckYes.vue +85 -0
  70. package/src/components/Common/CheckYesNo.vue +91 -0
  71. package/src/components/Common/LabelItem.vue +106 -0
  72. package/src/components/Common/LoadingWinBar.vue +115 -0
  73. package/src/components/Layout.vue +160 -0
  74. package/src/components/LayoutContent.vue +193 -0
  75. package/src/components/LayoutContentUsers.vue +498 -0
  76. package/src/components/LayoutState.vue +91 -0
  77. package/src/components/PageLogin.vue +524 -0
  78. package/src/components/VeUser.vue +446 -0
  79. package/src/components/ruleGroup.vue +645 -0
  80. package/src/main.js +97 -0
  81. package/src/plugins/mDataSelectorSchema.mjs +30 -0
  82. package/src/plugins/mDataSupport.mjs +23 -0
  83. package/src/plugins/mShare.mjs +229 -0
  84. package/src/plugins/mUI.mjs +229 -0
  85. package/src/schema/gi.mjs +8 -0
  86. package/src/schema/index.mjs +18 -0
  87. package/src/schema/tables/tokens.mjs +70 -0
  88. package/src/schema/tables/users.mjs +110 -0
  89. package/src/store/actions.mjs +1 -0
  90. package/src/store/getters.mjs +1 -0
  91. package/src/store/index.mjs +25 -0
  92. package/src/store/mutations.mjs +333 -0
  93. package/src/store/types.mjs +15 -0
  94. package/srv.mjs +84 -0
  95. package/tableTags-web-sso.json +1 -0
  96. package/test/all.test.mjs +10 -0
  97. package/toolg/addVersion.mjs +4 -0
  98. package/toolg/cleanFolder.mjs +4 -0
  99. package/toolg/gDistRollup.mjs +36 -0
  100. package/toolg/genEntry.mjs +23 -0
  101. package/toolg/modifyReadme.mjs +4 -0
  102. package/vue.config.js +15 -0
@@ -0,0 +1,193 @@
1
+ <template>
2
+ <div
3
+ style="height:100%; width:100%;"
4
+ v-domresize
5
+ @domresize="resize"
6
+ >
7
+
8
+ <template v-if="syncState">
9
+
10
+ <WDrawer
11
+ :style="`height:${panelHeight}px; width:100%;`"
12
+ v-model="drawer"
13
+ :drawerWidth.sync="drawerWidth"
14
+ :drawerWidthMin="drawerWidthMin"
15
+ :drawerWidthMax="drawerWidthMax"
16
+ :mode="'from-left'"
17
+ :dragDrawerWidth="true"
18
+ :autoSwitch="true"
19
+ :switchWidth="drawerWidth*2.3"
20
+ >
21
+
22
+ <template v-slot:drawer="props">
23
+ <div :style="`height:${props.height}px; background:#fff; position:relative;`">
24
+
25
+ <WListVertical
26
+ style="height:100%;"
27
+ :items="menus"
28
+ :itemActive="menuActive"
29
+ :item-text-color="'#222'"
30
+ :item-text-color-hover="'#444'"
31
+ :item-text-color-active="'#EF6C00'"
32
+ :item-icon-color="'#222'"
33
+ :item-icon-color-hover="'#444'"
34
+ :item-icon-color-active="'#EF6C00'"
35
+ :item-background-color="'#fff'"
36
+ :item-background-color-hover="'#f2f2f2'"
37
+ :item-background-color-active="'#FFF3E0'"
38
+ :paddingStyle="{v:15,h:15}"
39
+ @click="(menu)=>{menuKey=menu.key}"
40
+ ></WListVertical>
41
+
42
+ <div
43
+ :style="`position:absolute; top:1px; right:4px;`"
44
+ v-if="drawer"
45
+ >
46
+ <WButtonCircle
47
+ :paddingStyle="{v:3,h:3}"
48
+ :icon="'mdi-arrow-left'"
49
+ :iconSize="16"
50
+ :backgroundColor="'#fff'"
51
+ :backgroundColorHover="'#eee'"
52
+ :backgroundColorFocus="'#fff'"
53
+ :borderColor="'transparent'"
54
+ :borderColorHover="'#eee'"
55
+ :borderColorFocus="'#eee'"
56
+ :tooltip="$t('menuTreeHide')"
57
+ :shadow="true"
58
+ @click="drawer=false"
59
+ ></WButtonCircle>
60
+ </div>
61
+
62
+ </div>
63
+ </template>
64
+
65
+ <template v-slot:content="props">
66
+ <div :style="`height:${props.height}px; width:${props.width}px; position:relative;`">
67
+
68
+ <template>
69
+
70
+ <LayoutContentUsers
71
+ v-if="menuKey==='users'"
72
+ ></LayoutContentUsers>
73
+
74
+ </template>
75
+
76
+ <div
77
+ :style="`position:absolute; top:1px; left:4px;`"
78
+ v-if="!drawer"
79
+ >
80
+ <WButtonCircle
81
+ :paddingStyle="{v:3,h:3}"
82
+ :icon="'mdi-arrow-right'"
83
+ :iconSize="16"
84
+ :backgroundColor="'#fff'"
85
+ :backgroundColorHover="'#eee'"
86
+ :backgroundColorFocus="'#fff'"
87
+ :borderColor="'transparent'"
88
+ :borderColorHover="'#eee'"
89
+ :borderColorFocus="'#eee'"
90
+ :tooltip="$t('menuTreeShow')"
91
+ :shadow="true"
92
+ @click="drawer=true"
93
+ ></WButtonCircle>
94
+ </div>
95
+
96
+ </div>
97
+ </template>
98
+
99
+ </WDrawer>
100
+
101
+ </template>
102
+
103
+ <template v-else>
104
+ <div
105
+ style="padding:20px; font-size:0.9rem;"
106
+ >
107
+ {{$t('waitingData')}}
108
+ </div>
109
+ </template>
110
+
111
+ </div>
112
+ </template>
113
+
114
+ <script>
115
+ import { mdiGamepadCircle, mdiStackOverflow, mdiAccountGroupOutline } from '@mdi/js/mdi.js'
116
+ import get from 'lodash-es/get.js'
117
+ import find from 'lodash-es/find.js'
118
+ import WDrawer from 'w-component-vue/src/components/WDrawer.vue'
119
+ import WButtonCircle from 'w-component-vue/src/components/WButtonCircle.vue'
120
+ import WListVertical from 'w-component-vue/src/components/WListVertical.vue'
121
+ import LayoutContentUsers from './LayoutContentUsers.vue'
122
+
123
+
124
+ export default {
125
+ components: {
126
+ WDrawer,
127
+ WButtonCircle,
128
+ WListVertical,
129
+ LayoutContentUsers,
130
+ },
131
+ props: {
132
+ },
133
+ data: function() {
134
+ return {
135
+
136
+ menuKey: 'targets',
137
+
138
+ panelWidth: 0,
139
+ panelHeight: 0,
140
+
141
+ drawer: true,
142
+ drawerWidth: 180,
143
+ drawerWidthMin: 150,
144
+ drawerWidthMax: 300,
145
+
146
+ }
147
+ },
148
+ computed: {
149
+
150
+ syncState: function() {
151
+ return get(this, '$store.state.syncState')
152
+ },
153
+
154
+ menus: function() {
155
+ let vo = this
156
+ let ms = [
157
+ {
158
+ key: 'users',
159
+ text: 'bbb',
160
+ icon: mdiAccountGroupOutline,
161
+ },
162
+ ]
163
+ return ms
164
+ },
165
+
166
+ menuActive: function() {
167
+ let vo = this
168
+ let r = find(vo.menus, { key: vo.menuKey })
169
+ // console.log(r)
170
+ return r
171
+ },
172
+
173
+ },
174
+ methods: {
175
+
176
+ resize: function(msg) {
177
+ // console.log('methods resize', msg)
178
+
179
+ let vo = this
180
+
181
+ //save
182
+ vo.panelWidth = msg.snew.clientWidth
183
+ vo.panelHeight = msg.snew.clientHeight
184
+ // console.log('vo.panelHeight', vo.panelHeight)
185
+
186
+ },
187
+
188
+ }
189
+ }
190
+ </script>
191
+
192
+ <style scoped>
193
+ </style>
@@ -0,0 +1,498 @@
1
+ <template>
2
+ <div
3
+ style="height:100%;"
4
+ v-domresize
5
+ @domresize="resizePanel"
6
+ :changeUsers="changeUsers"
7
+ >
8
+
9
+ <div
10
+ style="border-bottom:1px solid #ddd; background:#fff;"
11
+ v-domresize
12
+ @domresize="resizeHead"
13
+ >
14
+
15
+ <!-- 標題區 -->
16
+ <div style="display:inline-block; vertical-align:top; padding:10px 0px 5px 20px;">
17
+ <div style="display:flex; align-items:center; padding:5px 15px 5px 5px; border-bottom:3px solid #FF9100;">
18
+
19
+ <WIcon
20
+ :icon="mdiAccountGroupOutline"
21
+ :color="'#FF9800'"
22
+ ></WIcon>
23
+
24
+ <div style="padding-left:10px; font-size:1.3rem; color:#d3912c;">
25
+ bbb
26
+ </div>
27
+
28
+ </div>
29
+ </div>
30
+
31
+ <!-- 編輯設定區 -->
32
+ <div style="display:inline-block; vertical-align:top;">
33
+
34
+ <div style="padding:15px 20px 15px 20px; background:#fff;">
35
+
36
+ <div style="display:flex;">
37
+ <WSwitch
38
+ :text="$t('isEditabled')"
39
+ :checkedSwitchCircleColor="'#D81B60'"
40
+ :checkedSwitchCircleColorHover="'#f26'"
41
+ :checkedSwitchBarColor="'#F8BBD0'"
42
+ :checkedSwitchBarColorHover="'#F8BBD0'"
43
+ v-model="isOperatable"
44
+ ></WSwitch>
45
+ </div>
46
+
47
+ <div style="padding-top:5px; font-size:0.8rem; _color:#f26;" v-if="isOperatable">
48
+ <div style="padding:3px 0px;">
49
+ 1. {{$t('userMsg1')}}
50
+ </div>
51
+ <div style="padding:3px 0px;">
52
+ 2. {{$t('userMsg2')}}
53
+ </div>
54
+ </div>
55
+
56
+ </div>
57
+
58
+ </div>
59
+
60
+ <!-- 儲存變更提示區 -->
61
+ <div
62
+ style="padding:10px 10px 12px 10px; border-top:1px solid #F48FB1; border-bottom:1px solid #F48FB1; background:#FCE4EC; display:flex; align-items:center; justify-content:flex-end;"
63
+ v-if="isModified"
64
+ >
65
+
66
+ <WButtonChip
67
+ :paddingStyle="{v:0,h:11}"
68
+ :text="$t('saveChanges')"
69
+ :icon="mdiCloudUploadOutline"
70
+ :backgroundColor="'rgba(255,0,50,0.7)'"
71
+ :backgroundColorHover="'rgba(255,0,50,0.8)'"
72
+ :textColor="'#eee'"
73
+ :textColorHover="'#fff'"
74
+ :iconColor="'#eee'"
75
+ :iconColorHover="'#fff'"
76
+ @click="saveGroups"
77
+ ></WButtonChip>
78
+
79
+ </div>
80
+
81
+ </div>
82
+
83
+ <div
84
+ :style="`padding:${spacePading}px;`"
85
+ v-if="!firstLoading"
86
+ >
87
+
88
+ <div style="background:#fff; box-shadow:0 3px 1px -2px rgba(0,0,0,.2), 0 2px 2px 0 rgba(0,0,0,.14), 0 1px 5px 0 rgba(0,0,0,.12);">
89
+
90
+ <div
91
+ style="padding:20px 10px 10px 20px; border-bottom:3px solid #ddd;"
92
+ v-domresize
93
+ @domresize="resizeGroupInfor"
94
+ >
95
+
96
+ <div style="padding:0px 10px 10px 0px; display:inline-block; vertical-align:middle; color:#666; font-size:1.1rem;">
97
+ {{$t('userList')}}
98
+ </div>
99
+
100
+ <div
101
+ style="padding:0px 10px 10px 0px; display:inline-block; vertical-align:middle;"
102
+ v-if="isOperatable"
103
+ >
104
+
105
+ <WButtonChip
106
+ :paddingStyle="{v:0,h:11}"
107
+ :text="$t('addUser')"
108
+ :icon="mdiAccountPlusOutline"
109
+ :backgroundColor="'rgba(255,0,50,0.7)'"
110
+ :backgroundColorHover="'rgba(255,0,50,0.8)'"
111
+ :textColor="'#eee'"
112
+ :textColorHover="'#fff'"
113
+ :iconColor="'#eee'"
114
+ :iconColorHover="'#fff'"
115
+ @click="clickAddUser"
116
+ ></WButtonChip>
117
+
118
+ </div>
119
+
120
+ </div>
121
+
122
+ <WPanelScrolly
123
+ :style="`height:${usersGroupsHeight}px; _overflow-y:auto;`"
124
+ >
125
+ <div style="padding:10px;">
126
+
127
+ <div
128
+ style="padding:10px;"
129
+ :key="'kus:'+kus"
130
+ v-for="(us,kus) in usersGroups"
131
+ >
132
+
133
+ <div style="padding-bottom:5px; display:flex; align-items:center; border-bottom:1px dashed #ddd;">
134
+ <div style="padding-right:5px; color:#888; font-size:0.8rem;">
135
+ {{$t('from')}}:
136
+ </div>
137
+ <div style="color:#000; font-size:0.8rem;">
138
+ {{getFrom(kus)}}
139
+ </div>
140
+ </div>
141
+
142
+ <div style="padding-top:10px;">
143
+
144
+ <div
145
+ style="display:inline-block; margin:0px 10px 10px 0px;"
146
+ :key="'ku:'+ku"
147
+ v-for="(u,ku) in us"
148
+ >
149
+
150
+ <WButtonChip
151
+ :text="u.name"
152
+ :paddingStyle="{
153
+ v: 2,
154
+ h: 12,
155
+ }"
156
+ :icon="getIsAdmin(u)?mdiChessRook:''"
157
+ :backgroundColor="getIsNotActive(u)?'rgba(130,130,130,0.8)':getIsAdmin(u)?'rgba(216, 27, 96, 0.8)':'rgba(50,110,230,0.8)'"
158
+ :backgroundColorHover="getIsNotActive(u)?'rgba(130,130,130,0.9)':getIsAdmin(u)?'rgba(216, 27, 96, 0.9)':'rgba(50,110,230,0.9)'"
159
+ :textColor="'#eee'"
160
+ :textColorHover="'#fff'"
161
+ :iconColor="'#eee'"
162
+ :iconColorHover="'#fff'"
163
+ :close="isOperatable"
164
+ @click="clickEditUser(u)"
165
+ @click-close="clickRemoveUser(u)"
166
+ ></WButtonChip>
167
+
168
+ </div>
169
+
170
+ </div>
171
+
172
+ </div>
173
+
174
+ </div>
175
+ </WPanelScrolly>
176
+
177
+ </div>
178
+
179
+ </div>
180
+
181
+ <div style="padding:10px 15px; font-size:0.8rem;" v-else>
182
+ {{$t('waitingData')}}
183
+ </div>
184
+
185
+ </div>
186
+ </template>
187
+
188
+ <script>
189
+ import { mdiAccountGroupOutline, mdiAccountPlusOutline, mdiCheckboxMarkedCircle, mdiChessRook } from '@mdi/js/mdi.js'
190
+ import get from 'lodash-es/get.js'
191
+ import each from 'lodash-es/each.js'
192
+ import keys from 'lodash-es/keys.js'
193
+ import sortBy from 'lodash-es/sortBy.js'
194
+ import find from 'lodash-es/find.js'
195
+ import size from 'lodash-es/size.js'
196
+ import groupBy from 'lodash-es/groupBy.js'
197
+ import genID from 'wsemi/src/genID.mjs'
198
+ import isestr from 'wsemi/src/isestr.mjs'
199
+ import iseobj from 'wsemi/src/iseobj.mjs'
200
+ import waitFun from 'wsemi/src/waitFun.mjs'
201
+ import WIcon from 'w-component-vue/src/components/WIcon.vue'
202
+ import WButtonChip from 'w-component-vue/src/components/WButtonChip.vue'
203
+ import WSwitch from 'w-component-vue/src/components/WSwitch.vue'
204
+ import WPanelScrolly from 'w-component-vue/src/components/WPanelScrolly.vue'
205
+
206
+
207
+ export default {
208
+ components: {
209
+ WIcon,
210
+ WButtonChip,
211
+ WSwitch,
212
+ WPanelScrolly,
213
+ },
214
+ props: {
215
+ },
216
+ data: function() {
217
+ return {
218
+ mdiAccountGroupOutline,
219
+ mdiAccountPlusOutline,
220
+ mdiCheckboxMarkedCircle,
221
+ mdiChessRook,
222
+
223
+ panelWidth: 100,
224
+ panelHeight: 100,
225
+ headHeight: 100,
226
+ groupInforHeight: 100,
227
+
228
+ firstLoading: true,
229
+ isOperatable: true,
230
+ isModified: false,
231
+
232
+ pickGroupId: '',
233
+
234
+ }
235
+ },
236
+ computed: {
237
+
238
+ users: function() {
239
+ return get(this, `$store.state.users`)
240
+ },
241
+
242
+ usersGroups: function() {
243
+ let gs = groupBy(this.users, 'from')
244
+ let ks = keys(gs)
245
+ ks = sortBy(ks)
246
+ let gsTemp = {}
247
+ each(ks, (k) => {
248
+ gsTemp[k] = gs[k]
249
+ })
250
+ gs = gsTemp
251
+ return gs
252
+ },
253
+
254
+ changeUsers: function() {
255
+ // console.log('computed changeUsers')
256
+
257
+ let vo = this
258
+
259
+ //check
260
+ if (size(vo.users) === 0) {
261
+ return ''
262
+ }
263
+
264
+ //firstLoading
265
+ vo.firstLoading = false
266
+
267
+ return ''
268
+ },
269
+
270
+ spacePading: function() {
271
+ let vo = this
272
+ if (vo.panelWidth < 400) {
273
+ return 0
274
+ }
275
+ else if (vo.panelWidth < 800) {
276
+ return 10
277
+ }
278
+ return 20
279
+ },
280
+
281
+ usersGroupsHeight: function() {
282
+ let vo = this
283
+
284
+ //h
285
+ let h = vo.panelHeight - vo.headHeight - 2 * vo.spacePading - vo.groupInforHeight
286
+ h = Math.max(h, 0)
287
+
288
+ return h
289
+ },
290
+
291
+ },
292
+ methods: {
293
+
294
+ resizePanel: function(msg) {
295
+ // console.log('methods resizePanel', msg)
296
+
297
+ let vo = this
298
+
299
+ //panelWidth, panelHeight
300
+ vo.panelWidth = msg.snew.offsetWidth
301
+ vo.panelHeight = msg.snew.offsetHeight
302
+
303
+ },
304
+
305
+ resizeHead: function(msg) {
306
+ // console.log('methods resizeHead', msg)
307
+
308
+ let vo = this
309
+
310
+ //headHeight
311
+ vo.headHeight = msg.snew.offsetHeight
312
+
313
+ },
314
+
315
+ resizeGroupInfor: function(msg) {
316
+ // console.log('methods resizeGroupInfor', msg)
317
+
318
+ let vo = this
319
+
320
+ //groupInforHeight
321
+ vo.groupInforHeight = msg.snew.offsetHeight
322
+
323
+ },
324
+
325
+ getFrom: function(kus) {
326
+ // console.log('methods getFrom', kus)
327
+ let vo = this
328
+ if (!isestr(kus)) {
329
+ kus = vo.$t('empty')
330
+ }
331
+ return kus
332
+ },
333
+
334
+ getIsAdmin: function(u) {
335
+ return get(u, 'isAdmin') === 'y'
336
+ },
337
+
338
+ getIsNotActive: function(u) {
339
+ return get(u, 'isActive') === 'n'
340
+ },
341
+
342
+ clickAddUser: function() {
343
+ // console.log('methods clickAddUser')
344
+
345
+ let vo = this
346
+
347
+ async function core() {
348
+ let errTemp = null
349
+
350
+ //show loading
351
+ vo.$ui.updateLoading(true)
352
+
353
+ //u
354
+ let u = {
355
+ id: genID(),
356
+ name: vo.$t('newUser'),
357
+ from: '',
358
+ isAdmin: 'n',
359
+ isActive: 'y',
360
+ }
361
+
362
+ //save
363
+ await vo.$fapi.users.insert(u)
364
+ .catch((err) => {
365
+ errTemp = err
366
+ })
367
+
368
+ //check
369
+ if (errTemp !== null) {
370
+ vo.$alert(`${vo.$t('failedToAddUser')}: ${errTemp}`, { type: 'error' })
371
+ }
372
+
373
+ //un
374
+ let un = null
375
+ await waitFun(() => {
376
+ un = find(vo.users, { id: u.id })
377
+ return iseobj(un) //確認g.id已存在
378
+ })
379
+ // console.log('un', un)
380
+
381
+ //showVeUser
382
+ vo.$dg.showVeUser(un)
383
+ .catch(() => {})
384
+
385
+ //alert
386
+ vo.$alert(vo.$t('successfulToAddUser'))
387
+
388
+ }
389
+
390
+ //core
391
+ core()
392
+ // .then((res) => {
393
+ // console.log('then', res)
394
+ // })
395
+ .catch((err) => {
396
+ console.log('catch', err)
397
+ vo.$alert(vo.$t('anUnexpectedErrorOccurred'), { type: 'error' })
398
+ })
399
+ .finally(() => {
400
+
401
+ //hide loading
402
+ vo.$ui.updateLoading(false)
403
+
404
+ })
405
+
406
+ },
407
+
408
+ clickRemoveUser: function(u) {
409
+ // console.log('methods clickRemoveUser', u)
410
+
411
+ let vo = this
412
+
413
+ async function core() {
414
+ let errTemp = null
415
+
416
+ //showCheckYesNo
417
+ let bExit = false
418
+ let t_confirmToDeleteUser = vo.$t('confirmToDeleteUser')
419
+ t_confirmToDeleteUser = t_confirmToDeleteUser.replace('{name}', u.name)
420
+ await vo.$dg.showCheckYesNo(t_confirmToDeleteUser)
421
+ .catch(() => {
422
+ bExit = true
423
+ })
424
+ if (bExit) {
425
+ return
426
+ }
427
+
428
+ //show loading
429
+ vo.$ui.updateLoading(true)
430
+
431
+ //save
432
+ await vo.$fapi.users.del(u)
433
+ .catch((err) => {
434
+ errTemp = err
435
+ })
436
+
437
+ //check
438
+ if (errTemp !== null) {
439
+ vo.$alert(`${vo.$t('failedToDeleteUser')}: ${errTemp}`, { type: 'error' })
440
+ return
441
+ }
442
+
443
+ //un
444
+ let un = null
445
+ await waitFun(() => {
446
+ un = find(vo.users, (v) => {
447
+ return v.id === u.id
448
+ })
449
+ return !iseobj(un) //確認g.id已不存在
450
+ })
451
+ // console.log('un', un)
452
+
453
+ //alert
454
+ vo.$alert(vo.$t('successfulToDeleteUser'))
455
+
456
+ }
457
+
458
+ //core
459
+ core()
460
+ // .then((res) => {
461
+ // console.log('then', res)
462
+ // })
463
+ .catch((err) => {
464
+ console.log('catch', err)
465
+ vo.$alert(vo.$t('anUnexpectedErrorOccurred'), { type: 'error' })
466
+ })
467
+ .finally(() => {
468
+
469
+ //hide loading
470
+ vo.$ui.updateLoading(false)
471
+
472
+ })
473
+
474
+ },
475
+
476
+ clickEditUser: function(u) {
477
+ // console.log('clickEditGroup', u)
478
+
479
+ let vo = this
480
+
481
+ //check
482
+ if (!vo.isOperatable) {
483
+ vo.$alert(vo.$t('cannotShowUserDetailsInViewMode'), { type: 'error' })
484
+ return
485
+ }
486
+
487
+ //showVeUser
488
+ vo.$dg.showVeUser(u)
489
+ .catch(() => {})
490
+
491
+ },
492
+
493
+ }
494
+ }
495
+ </script>
496
+
497
+ <style scoped>
498
+ </style>