@sigmaott/base-next 1.4.13 → 1.4.14

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/locales/en.yaml CHANGED
@@ -488,7 +488,7 @@ fast_channel:
488
488
  no_input: No Input
489
489
  select_vod: Select VOD
490
490
  forensic:
491
- enter_the_wm_in_hexadecimal_format_e_g_0x64: Enter the WM (in hexadecimal format, e.g. 0x64)
491
+ enter_the_wm_in_hexadecimal_format_e_g_0x64: WM value exceeds maximum length allowed by bit length.
492
492
  type_is_required: Type is required
493
493
  wm_is_required: wm is required
494
494
  form:
package/locales/vi.yaml CHANGED
@@ -491,7 +491,7 @@ fast_channel:
491
491
  no_input: Không có đầu vào
492
492
  select_vod: Chọn VOD
493
493
  forensic:
494
- enter_the_wm_in_hexadecimal_format_e_g_0x64: 'Nhập WM (ở định dạng thập lục phân, dụ: 0x64)'
494
+ enter_the_wm_in_hexadecimal_format_e_g_0x64: Giá trị WM vượt quá độ dài tối đa cho phép theo độ dài bit.
495
495
  type_is_required: Loại là bắt buộc
496
496
  wm_is_required: wm là bắt buộc
497
497
  form:
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sigmaott/base-next",
3
3
  "type": "module",
4
- "version": "1.4.13",
4
+ "version": "1.4.14",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -1,35 +1,52 @@
1
1
  <script setup lang="ts">
2
+ const showModel = ref(false)
3
+ const formRef = ref()
4
+ const { formRef: formForensicRef } = useElFormContext()
5
+ const formPathValue = ref({
6
+ path: '',
7
+ })
2
8
  const { schemaObj } = useAsyncSchema(API_TRANSCODE_API_DOCS_JSON, 'ForensicWatermarkConfigDto')
3
- const { formRef: formRefForensicWatermark } = useElFormContext()
9
+
4
10
  const { t } = useI18n()
11
+ const { formValue } = useElFormContext()
12
+ const isEvent = ref(inject('isEvent'))
13
+ const isPlayout = ref(inject('isPlayout'))
14
+ const { transcodeInput, packageInput } = useGetInputDetail({ formValue, isEvent })
15
+ const input = computed(() => transcodeInput.value || packageInput.value)
5
16
 
6
17
  const [encoderIdValue] = useElField<number>('channelConfig.machineConfig.encoderId')
7
- const [enableValue, enableAttrs] = useElField<boolean>('channelConfig.forensicWatermarkConfig.enable', [
8
- // {
9
- // validator: (rule, value, callback) => {
10
- // if (value && encoderIdValue.value === -1)
11
- // callback(new Error(t('SSConfig.this_feature_is_only_supported_when_using_nvenc_please_switch_to_nvenc_or_disable_the_feature_to_continue')))
12
- // callback()
13
- // },
14
- // trigger: ['blur', 'change'],
15
- // },
16
- ])
18
+ const [enableValue, enableAttrs] = useElField<boolean>('channelConfig.forensicWatermarkConfig.enable', [])
19
+ const [forensicValue] = useElField<boolean>('channelConfig.forensicWatermarkConfig', [])
20
+
21
+ const [modelValue, modelAttrs] = useElField<number>('channelConfig.forensicWatermarkConfig.infoModel.path', [
22
+ {
23
+ required: true,
24
+ message: t('channel.model_is_required'),
25
+ trigger: ['blur', 'change'],
26
+ },
27
+ ], { enabled: enableValue })
28
+
17
29
  const [typeValue, typeAttrs] = useElField<string>('channelConfig.forensicWatermarkConfig.type', {
18
- required: true,
19
30
  message: t('forensic.type_is_required'),
31
+ required: false,
20
32
  }, { enabled: enableValue })
21
33
  const [wmValue, wmAttrs] = useElField<string>('channelConfig.forensicWatermarkConfig.wm', [{
22
34
  message: t('forensic.wm_is_required'),
23
35
  required: true,
24
36
  }, {
25
37
  validator: (rule, value, callback) => {
26
- if (!/^0x[a-fA-F0-9]{1,32}$/.test(value))
38
+ const bitLength = forensicValue.value?.infoModel?.bit || 32
39
+ const hexLimit = Math.ceil(bitLength / 4)
40
+
41
+ const regex = new RegExp(`^0x[a-fA-F0-9]{1,${hexLimit}}$`)
42
+ if (!regex.test(value))
27
43
  callback(new Error(t('forensic.enter_the_wm_in_hexadecimal_format_e_g_0x64')))
28
44
  else
29
45
  callback()
30
46
  },
31
47
  trigger: ['blur', 'change'],
32
48
  }], { enabled: enableValue })
49
+ const [wmBValue] = useElField<string>('channelConfig.forensicWatermarkConfig.wmB', [])
33
50
  const [crcValue, crcAttrs] = useElField<number>('channelConfig.forensicWatermarkConfig.crc', {
34
51
  required: false,
35
52
  }, { enabled: enableValue })
@@ -43,16 +60,193 @@ const [bchValue, bchAttrs] = useElField<number>('channelConfig.forensicWatermark
43
60
  required: false,
44
61
  }, { enabled: enableValue })
45
62
 
46
- onMounted(() => {
47
- formRefForensicWatermark.value.validateField('channelConfig.forensicWatermarkConfig.enable')
48
- })
63
+ const loadPathEventMutation = useMutation(
64
+ (payload: {
65
+ machineConfig: any
66
+ path: string
67
+ }) => $transcodeApi('/api/transcode/pte/load-forensic-watermark-models', {
68
+ body: {
69
+ ...payload.machineConfig,
70
+ path: payload.path,
71
+ },
72
+ method: 'POST',
73
+ }),
74
+ )
75
+
76
+ const loadPathPlayoutMutation = useMutation(
77
+ (payload: {
78
+ machineConfig: any
79
+ path: string
80
+ }) => $playoutApi('/api/playout/ai-model/load-forensic-watermark-models', {
81
+ body: {
82
+ ...payload.machineConfig,
83
+ path: payload.path,
84
+ },
85
+ method: 'POST',
86
+ }),
87
+ )
88
+
89
+ const listConfigWatermark = ref([])
90
+ const loadedPath = ref()
91
+ async function onLoadPath() {
92
+ formRef.value.validate(async (valid: boolean) => {
93
+ if (valid) {
94
+ const rs = await (isEvent.value ? loadPathEventMutation : loadPathPlayoutMutation).mutateAsync({
95
+ machineConfig: {
96
+ machineId: input.value?.machineConfig.machineId,
97
+ machineType: input.value?.machineConfig.machineType,
98
+ mode: input.value?.machineConfig.mode,
99
+ specMachineId: input.value?.machineConfig.specMachineId || undefined,
100
+ },
101
+ path: formPathValue.value.path,
102
+ })
103
+ console.log(rs)
104
+ loadedPath.value = formPathValue.value.path
105
+ ElMessage.success(t('base_library.load_path_successfully'))
106
+ if (rs?.length > 0) {
107
+ listConfigWatermark.value = rs
108
+ }
109
+ else {
110
+ listConfigWatermark.value = []
111
+ }
112
+
113
+ // showModel.value = false
114
+ // formPathValue.value.path = ''
115
+ }
116
+ })
117
+ }
118
+
119
+ function onShowModel() {
120
+ if (!input.value) {
121
+ ElMessage({
122
+ message: t('Transcoder.please_configure_the_input'),
123
+ type: 'warning',
124
+ })
125
+ return
126
+ }
127
+ showModel.value = true
128
+ }
129
+
130
+ const defaultTableForensic = ref([
131
+ {
132
+ type: 'normal',
133
+ wm: '0xff',
134
+ alpha: 0.15,
135
+ crc: -1,
136
+ step: 3,
137
+ bch: 1,
138
+ },
139
+ ])
140
+
141
+ async function handleSelectConfig(id: string) {
142
+ const config = listConfigWatermark.value.find(item => item.id === id)
143
+ console.log('🚀 ~ handleSelectConfig ~ config:', config)
144
+
145
+ if (config) {
146
+ forensicValue.value.model = config.model
147
+ forensicValue.value.name = config.name
148
+ forensicValue.value.bit = config.bit
149
+ forensicValue.value.id = config.id
150
+ forensicValue.value.infoModel = config
151
+
152
+ typeValue.value = defaultTableForensic.value[0].type
153
+ wmValue.value = config.wm || defaultTableForensic.value[0].wm
154
+ wmBValue.value = config.wmB || defaultTableForensic.value[0].wmB
155
+ alphaValue.value = config.alpha || defaultTableForensic.value[0].alpha
156
+ crcValue.value = config.crc || defaultTableForensic.value[0].crc
157
+ stepValue.value = config.step || defaultTableForensic.value[0].step
158
+ bchValue.value = config.bch || defaultTableForensic.value[0].bch
159
+
160
+ defaultTableForensic.value[0].wm = config.wm
161
+ defaultTableForensic.value[0].wmB = config.wmB
162
+ defaultTableForensic.value[0].alpha = config.alpha
163
+ defaultTableForensic.value[0].crc = config.crc
164
+ defaultTableForensic.value[0].step = config.step
165
+ defaultTableForensic.value[0].bch = config.bch
166
+
167
+ formPathValue.value.path = ''
168
+ loadedPath.value = ''
169
+ listConfigWatermark.value = []
170
+ showModel.value = false
171
+ }
172
+ else {
173
+ ElMessage.error($t('base_library.please_select_a_model'))
174
+ // ElMessage.error({
175
+ // dangerouslyUseHTMLString: true,
176
+ // message: $t('base_library.feature_mismatch_the_path_cannot_be_used_with_feature-name', ['<strong>Ads detect</strong>']),
177
+ // })
178
+ }
179
+ formForensicRef.value?.validateField('channelConfig.forensicWatermarkConfig.wm')
180
+ }
181
+ const currentRowId = ref()
182
+
183
+ const optionsType = ref([
184
+ {
185
+ label: 'Normal',
186
+ value: 'normal',
187
+ },
188
+ {
189
+ label: 'A/B',
190
+ value: 'a/b',
191
+ },
192
+ ])
193
+ const optionsCrc = ref([
194
+ {
195
+ label: -1,
196
+ value: -1,
197
+ },
198
+ {
199
+ label: 0,
200
+ value: 0,
201
+ },
202
+ {
203
+ label: 8,
204
+ value: 8,
205
+ },
206
+
207
+ {
208
+ label: 16,
209
+ value: 16,
210
+ },
211
+ ])
212
+ const optionsStep = ref([
213
+ {
214
+ label: 1,
215
+ value: 1,
216
+ },
217
+ {
218
+ label: 2,
219
+ value: 2,
220
+ },
221
+ {
222
+ label: 3,
223
+ value: 3,
224
+ },
225
+ ])
226
+ const optionsBch = ref([
227
+ {
228
+ label: 0,
229
+ value: 0,
230
+ },
231
+ {
232
+ label: 1,
233
+ value: 1,
234
+ },
235
+ ])
236
+
237
+ function handleChangeType(value: string) {
238
+ if (value === 'a/b') {
239
+ wmValue.value = defaultTableForensic.value[0].wm
240
+ alphaValue.value = defaultTableForensic.value[0].alpha
241
+ }
242
+ }
49
243
  </script>
50
244
 
51
245
  <template>
52
- <div class="flex flex-wrap gap-48px">
53
- <el-form-item class="w-130px">
246
+ <div class="grid grid-cols-[2fr_2fr_12fr] gap-2">
247
+ <el-form-item>
54
248
  <template #label>
55
- <SSInformationLabel :label="$t('SSConfig.form.label.enable')" :info="schemaObj.enable" />
249
+ <SSInformationLabel :label="$t('EventChannel.form.label.enable')" :info="schemaObj.enable" />
56
250
  </template>
57
251
  <el-switch
58
252
  v-model="enableValue"
@@ -61,92 +255,218 @@ onMounted(() => {
61
255
  :disabled="encoderIdValue === -1 && !enableValue"
62
256
  />
63
257
  </el-form-item>
64
- <el-form-item label="Type" v-bind="typeAttrs" class="min-w-80px flex-1">
65
- <template #label>
66
- <SSInformationLabel label="Type" :info="schemaObj.type" />
67
- </template>
68
- <el-select
69
- v-model="typeValue"
258
+ <el-form-item v-bind="modelAttrs" class="w-80px">
259
+ <el-input v-model="modelValue" class="hidden" />
260
+ <el-button
261
+ class="w-full"
262
+ type="primary"
70
263
  :disabled="!enableValue"
264
+ @click="onShowModel"
71
265
  >
72
- <el-option
73
- v-for="item in ['normal', 'a/b']"
74
- :key="item"
75
- :label="item"
76
- :value="item"
77
- />
78
- </el-select>
266
+ {{ $t('transcode.load') }}
267
+ </el-button>
79
268
  </el-form-item>
80
- <el-form-item v-bind="wmAttrs" class="flex-1/5">
81
- <template #label>
82
- <SSInformationLabel label="wm" :info="schemaObj.wm" />
83
- </template>
84
- <el-input
85
- v-model.trim="wmValue"
86
- placeholder="Hex (e.g. 0x64)"
87
- />
88
- </el-form-item>
89
- <el-form-item label="crc" v-bind="crcAttrs" class="flex-1">
90
- <template #label>
91
- <SSInformationLabel label="crc" :info="schemaObj.crc" />
92
- </template>
93
- <el-select
94
- v-model="crcValue"
95
- :disabled="!enableValue"
96
- >
97
- <el-option
98
- v-for="item in [-1, 0, 8, 16]"
99
- :key="item"
100
- :label="item"
101
- :value="item"
102
- />
103
- </el-select>
269
+ <el-form-item v-if="forensicValue?.infoModel?.path" label="Path Model">
270
+ <el-text>{{ forensicValue?.infoModel?.path }}</el-text>
104
271
  </el-form-item>
105
- <el-form-item label="step" v-bind="stepAttrs" class="flex-1">
106
- <template #label>
107
- <SSInformationLabel label="step" :info="schemaObj.step" />
108
- </template>
109
- <el-select
110
- v-model="stepValue"
111
- placeholder="Select"
112
- :disabled="!enableValue"
272
+ </div>
273
+ <template v-if="modelValue">
274
+ <div class="grid grid-cols-[2fr_2fr_2fr_2fr] gap-2">
275
+ <el-form-item label="Model" v-bind="scoreAttrs">
276
+ <template #label>
277
+ <SSInformationLabel label="Model" :info="schemaObj?.model" />
278
+ </template>
279
+ <SSTooltipEllipsis :content="forensicValue?.infoModel?.model" />
280
+ </el-form-item>
281
+ <el-form-item label="Name" v-bind="scoreAttrs">
282
+ <template #label>
283
+ <SSInformationLabel label="Name" :info="schemaObj?.action" />
284
+ </template>
285
+ <el-text>{{ forensicValue?.infoModel?.name }}</el-text>
286
+ </el-form-item>
287
+ <el-form-item>
288
+ <template #label>
289
+ <SSInformationLabel label="Model ID" :info="schemaObj?.model" />
290
+ </template>
291
+ <el-text truncate>
292
+ {{ forensicValue?.infoModel?.id }}
293
+ </el-text>
294
+ </el-form-item>
295
+ <el-form-item>
296
+ <template #label>
297
+ <SSInformationLabel label="Bit length" :info="schemaObj?.bit" />
298
+ </template>
299
+ <el-text truncate>
300
+ {{ forensicValue?.infoModel?.bit }}
301
+ </el-text>
302
+ </el-form-item>
303
+ </div>
304
+ <el-table :data="defaultTableForensic || []" border style="width: 100%">
305
+ <el-table-column prop="type" label="Type">
306
+ <template #header>
307
+ <SSInformationLabel label="Type" :info="schemaObj?.type" />
308
+ </template>
309
+ <template #default="{ row }">
310
+ <el-select
311
+ v-model="typeValue"
312
+ placeholder="Select"
313
+ :disabled="!enableValue"
314
+ @change="handleChangeType"
315
+ >
316
+ <el-option
317
+ v-for="item in optionsType"
318
+ :key="item.value"
319
+ :label="item.label"
320
+ :value="item.value"
321
+ />
322
+ </el-select>
323
+ </template>
324
+ </el-table-column>
325
+ <el-table-column prop="wm" label="wm">
326
+ <template #header>
327
+ <SSInformationLabel label="wm" :info="schemaObj?.wm" />
328
+ </template>
329
+ <template #default="{ row }">
330
+ <el-form-item v-bind="wmAttrs" class="pt-2 [&_.el-form-item\_\_label]:hidden [&_.el-input-number]:!w-full">
331
+ <el-input
332
+ v-model.trim="wmValue"
333
+ :disabled="typeValue !== 'normal' || !enableValue"
334
+ :placeholder="t('forensic.enter_the_wm_in_hexadecimal_format_e_g_0x64')"
335
+ />
336
+ </el-form-item>
337
+ </template>
338
+ </el-table-column>
339
+ <el-table-column prop="alpha" label="alpha">
340
+ <template #header>
341
+ <SSInformationLabel label="alpha" :info="schemaObj?.alpha" />
342
+ </template>
343
+ <template #default="{ row }">
344
+ <el-input-number
345
+ v-model="alphaValue"
346
+ controls-position="right"
347
+ :min="0.05"
348
+ :max="0.3"
349
+ :precision="2"
350
+ :step="0.01"
351
+ :disabled="typeValue !== 'normal' || !enableValue"
352
+ />
353
+ </template>
354
+ </el-table-column>
355
+ <el-table-column prop="crc" label="crc">
356
+ <template #header>
357
+ <SSInformationLabel label="crc" :info="schemaObj?.crc" />
358
+ </template>
359
+ <template #default="{ row }">
360
+ <el-select v-model="crcValue" placeholder="Select" :disabled="!enableValue">
361
+ <el-option
362
+ v-for="item in optionsCrc"
363
+ :key="item.value"
364
+ :label="item.label"
365
+ :value="item.value"
366
+ />
367
+ </el-select>
368
+ </template>
369
+ </el-table-column>
370
+ <el-table-column prop="step" label="step ">
371
+ <template #header>
372
+ <SSInformationLabel label="step" :info="schemaObj?.step" />
373
+ </template>
374
+ <template #default="{ row }">
375
+ <el-select v-model="stepValue" placeholder="Select" :disabled="!enableValue">
376
+ <el-option
377
+ v-for="item in optionsStep"
378
+ :key="item.value"
379
+ :label="item.label"
380
+ :value="item.value"
381
+ />
382
+ </el-select>
383
+ </template>
384
+ </el-table-column>
385
+ <el-table-column prop="bch" label="bch">
386
+ <template #header>
387
+ <SSInformationLabel label="bch" :info="schemaObj?.bch" />
388
+ </template>
389
+ <template #default="{ row }">
390
+ <el-select v-model="bchValue" placeholder="Select" :disabled="!enableValue">
391
+ <el-option
392
+ v-for="item in optionsBch"
393
+ :key="item.value"
394
+ :label="item.label"
395
+ :value="item.value"
396
+ />
397
+ </el-select>
398
+ </template>
399
+ </el-table-column>
400
+ </el-table>
401
+ </template>
402
+ <el-dialog v-model="showModel" width="700" destroy-on-close>
403
+ <el-form
404
+ ref="formRef"
405
+ :model="formPathValue"
406
+ label-width="auto"
407
+ @submit.prevent
408
+ >
409
+ <el-form-item
410
+ prop="path"
411
+ :rules="[
412
+ {
413
+ required: true,
414
+ message: $t('transcode.please_input_path_model'),
415
+ trigger: ['blur', 'change'],
416
+ },
417
+ ]"
113
418
  >
114
- <el-option
115
- v-for="item in [1, 2, 3]"
116
- :key="item"
117
- :label="item"
118
- :value="item"
119
- />
120
- </el-select>
121
- </el-form-item>
122
- <el-form-item label="alpha" v-bind="alphaAttrs" class="flex-1">
123
- <template #label>
124
- <SSInformationLabel label="alpha" :info="schemaObj.alpha" />
125
- </template>
126
- <el-input-number
127
- v-model="alphaValue"
128
- :min="0.05"
129
- :max="0.30"
130
- :step="0.01"
131
- :precision="2"
132
- :disabled="!enableValue"
133
- />
134
- </el-form-item>
135
- <el-form-item label="bch" v-bind="bchAttrs" class="flex-1">
136
- <template #label>
137
- <SSInformationLabel label="bch" :info="schemaObj.bch" />
138
- </template>
139
- <el-select
140
- v-model="bchValue"
141
- :disabled="!enableValue"
419
+ <template #label>
420
+ <SSInformationLabel :label="$t('transcode.path_model')" :info="schemaObj.model" />
421
+ </template>
422
+ <div class="w-full flex justify-between gap-2">
423
+ <el-input v-model="formPathValue.path" :placeholder="$t('example_path_to_model')" />
424
+ <el-button type="primary" @click="onLoadPath">
425
+ {{ $t('transcode.load') }}
426
+ </el-button>
427
+ </div>
428
+ </el-form-item>
429
+ </el-form>
430
+
431
+ <div class="mt-4 text-14px text-#606266 font-bold dark:text-#CFD3DC">
432
+ {{ $t('library.model_list') }}
433
+ </div>
434
+ <div>
435
+ {{ $t('base_library.loaded_from') }}: <span class="font-bold">{{ loadedPath }}</span>
436
+ </div>
437
+ <el-radio-group v-model="currentRowId" class="w-full">
438
+ <el-table
439
+ row-key="id"
440
+ :current-row-key="currentRowId"
441
+ :data="listConfigWatermark"
442
+ border
443
+ :empty-text
444
+ @row-click="(row) => currentRowId = row.id"
142
445
  >
143
- <el-option
144
- v-for="item in [0, 1]"
145
- :key="item"
146
- :label="item"
147
- :value="item"
148
- />
149
- </el-select>
150
- </el-form-item>
151
- </div>
446
+ <el-table-column label="#" width="40">
447
+ <template #default="{ row }">
448
+ <el-radio :label="row.id">
449
+ &nbsp;
450
+ </el-radio>
451
+ </template>
452
+ </el-table-column>
453
+ <el-table-column prop="name" label="Name" />
454
+ <el-table-column prop="path" label="Path" show-overflow-tooltip />
455
+ <el-table-column align="center" prop="bit" label="Bit length" />
456
+ </el-table>
457
+ </el-radio-group>
458
+ <template #footer>
459
+ <div class="dialog-footer">
460
+ <el-button :disabled="!currentRowId" type="primary" @click="handleSelectConfig(currentRowId)">
461
+ {{ $t('base_library.select') }}
462
+ </el-button>
463
+ </div>
464
+ </template>
465
+ </el-dialog>
152
466
  </template>
467
+
468
+ <style scoped>
469
+ .el-input-number {
470
+ width: 100%;
471
+ }
472
+ </style>