Procházet zdrojové kódy

feat(device): support spacer play when buffering video

Casper Dai před 2 roky
rodič
revize
8dd7a0f4d5

+ 11 - 0
src/api/external.js

@@ -524,3 +524,14 @@ export function deleteReceivingCard ({ id }) {
     method: 'DELETE'
   }, '该网关')
 }
+
+export function updateReceivingCardTopology (id, topology) {
+  return update({
+    url: '/device/thirdPartyReceiverCard/updateTopology',
+    method: 'POST',
+    data: {
+      receiverCardId: id,
+      list: topology
+    }
+  })
+}

+ 51 - 2
src/api/platform.js

@@ -1,6 +1,17 @@
-import { PublishType } from '@/constant'
-import { tenantRequest } from '@/utils/request'
 import {
+  PublishType,
+  AssetTagInfo,
+  AssetTypeInfo
+} from '@/constant'
+import {
+  parseByte,
+  getAssetThumb,
+  getAssetDiff
+} from '@/utils'
+import request, { tenantRequest } from '@/utils/request'
+import {
+  add,
+  del,
   messageSend,
   addUser,
   addTenant,
@@ -45,3 +56,41 @@ export function saveLogger (data) {
     custom: true
   })
 }
+
+export function getSpacers (data) {
+  return request({
+    url: '/device/spacer/query',
+    method: 'POST',
+    data
+  }).then(({ data: { spacers } }) => {
+    return {
+      data: spacers.map(spacer => {
+        spacer.file = {
+          type: spacer.type,
+          url: spacer.keyName,
+          thumb: getAssetThumb(spacer)
+        }
+        spacer.tagInfo = AssetTagInfo[spacer.tag]
+        spacer.typeInfo = AssetTypeInfo[spacer.type]
+        spacer.sizeInfo = parseByte(spacer.size)
+        spacer.diff = getAssetDiff(spacer)
+        return spacer
+      })
+    }
+  })
+}
+
+export function addSpacers (data) {
+  return add({
+    url: '/device/spacer/set',
+    method: 'POST',
+    data
+  })
+}
+
+export function deleteSpacer ({ id }) {
+  return del({
+    url: `/device/spacer/delete?id=${id}`,
+    method: 'DELETE'
+  })
+}

+ 2 - 11
src/views/external/box/settings/components/AdConfigDialog.vue

@@ -125,10 +125,7 @@
 
 <script>
 import { AssetType } from '@/constant'
-import {
-  getAssetsByQuery,
-  getAssetUrl
-} from '@/api/asset'
+import { getAssetUrl } from '@/api/asset'
 import {
   getAdAttributes,
   updateAdAttributes,
@@ -142,12 +139,6 @@ export default {
       isAdd: false,
       attributes: {},
       files: [],
-      schema: {
-        list: getAssetsByQuery,
-        cols: [
-          { prop: 'file', label: '', type: 'asset' }
-        ]
-      },
       tagOptions: [
         { label: '不限', value: '' },
         { label: '商圈百货', value: '1' },
@@ -272,7 +263,7 @@ export default {
     align-items: center;
     border: 1px dashed #ccc;
 
-    &:hover{
+    &:hover {
       border: 1px dashed $primary;
     }
   }

+ 100 - 0
src/views/realm/settings/components/SpacerConfigDialog.vue

@@ -0,0 +1,100 @@
+<template>
+  <table-dialog
+    ref="dialog"
+    title="垫片"
+    :schema="schema"
+  >
+    <single-asset-dialog
+      ref="assetDialog"
+      :choosen="onChoosenAsset"
+      @directory-changed="onAssetDirectoryChanged"
+      @view="onViewAsset"
+    />
+    <preview-dialog ref="previewDialog" />
+  </table-dialog>
+</template>
+
+<script>
+import { mapGetters } from 'vuex'
+import { AssetType } from '@/constant'
+import {
+  getSpacers,
+  addSpacers,
+  deleteSpacer
+} from '@/api/platform'
+
+export default {
+  name: 'SpacerTenantConfigDialog',
+  data () {
+    return {
+      schema: {
+        nonPagination: true,
+        list: this.getSpacers,
+        buttons: [
+          { type: 'add', label: '新增图片', on: this.onAddImage },
+          { type: 'add', label: '新增视频', on: this.onAddVideo }
+        ],
+        cols: [
+          { prop: 'tagInfo', label: '类型', width: 80 },
+          { prop: 'typeInfo', label: '资源', align: 'center', width: 72 },
+          { prop: 'file', label: '', type: 'asset', on: this.onViewAsset },
+          { prop: 'sizeInfo', label: '资源大小', 'align': 'right' },
+          { prop: 'diff', label: '其他', 'align': 'right' },
+          { type: 'invoke', render: [
+            { label: '查看', on: this.onViewAsset },
+            { label: '删除', on: this.onDel }
+          ] }
+        ]
+      }
+    }
+  },
+  computed: {
+    ...mapGetters(['tenant'])
+  },
+  methods: {
+    show () {
+      this.$refs.dialog.show()
+    },
+    getSpacers () {
+      return getSpacers({
+        targetType: 2,
+        targetKey: this.tenant
+      })
+    },
+    onAddImage () {
+      this.$refs.assetDialog.show(
+        AssetType.IMAGE,
+        this.directoryOption
+      )
+    },
+    onAddVideo () {
+      this.$refs.assetDialog.show(
+        AssetType.VIDEO,
+        this.directoryOption
+      )
+    },
+    onAssetDirectoryChanged (directory) {
+      this.directoryOption = directory
+    },
+    onViewAsset ({ file }) {
+      this.$refs.previewDialog.show(file)
+    },
+    onChoosenAsset ({ tag, type, keyName, size, duration, md5 }) {
+      return addSpacers({
+        targetType: 2,
+        targetKey: this.tenant,
+        spacers: [
+          { tag, type, keyName, size, duration, md5 }
+        ]
+      }).then(() => {
+        this.$refs.dialog.getTable().pageTo(1)
+      })
+    },
+    onDel (spacer) {
+      deleteSpacer(spacer).then(() => {
+        this.$refs.dialog.getTable().decrease(1)
+      })
+    }
+  }
+}
+</script>

+ 18 - 3
src/views/realm/settings/index.vue

@@ -47,12 +47,22 @@
         位移传感器阈值
       </button>
     </div>
+    <span class="c-sibling-item--v u-font-size--sm u-bold">播控器配置</span>
+    <div class="c-sibling-item--v l-grid--info mini">
+      <button
+        class="o-button"
+        @click="onSpacerConfig"
+      >
+        视频缓冲垫片
+      </button>
+    </div>
     <alarm-strat-config-dialog ref="alarmStratConfigDialog" />
     <auto-restart-config-dialog ref="autoRestartConfigDialog" />
     <power-config-dialog ref="powerConfigDialog" />
     <unattend-config-dialog ref="unattendConfigDialog" />
     <temperature-Threshold-config-dialog ref="temperatureThresholdConfigDialog" />
-    <deviation-Threshold-config-dialog ref="DeviationThresholdConfigDialog" />
+    <deviation-Threshold-config-dialog ref="deviationThresholdConfigDialog" />
+    <spacer-config-dialog ref="spacerConfigDialog" />
   </wrapper>
 </template>
 
@@ -63,6 +73,7 @@ import PowerConfigDialog from './components/PowerConfigDialog.vue'
 import UnattendConfigDialog from './components/UnattendConfigDialog.vue'
 import TemperatureThresholdConfigDialog from './components/TemperatureThresholdConfigDialog.vue'
 import DeviationThresholdConfigDialog from './components/DeviationThresholdConfigDialog.vue'
+import SpacerConfigDialog from './components/SpacerConfigDialog.vue'
 
 export default {
   name: 'TenantSettings',
@@ -72,7 +83,8 @@ export default {
     PowerConfigDialog,
     UnattendConfigDialog,
     TemperatureThresholdConfigDialog,
-    DeviationThresholdConfigDialog
+    DeviationThresholdConfigDialog,
+    SpacerConfigDialog
   },
   methods: {
     onAlarmStratConfig () {
@@ -91,7 +103,10 @@ export default {
       this.$refs.temperatureThresholdConfigDialog.show()
     },
     onDeviationThresholdConfig () {
-      this.$refs.DeviationThresholdConfigDialog.show()
+      this.$refs.deviationThresholdConfigDialog.show()
+    },
+    onSpacerConfig () {
+      this.$refs.spacerConfigDialog.show()
     }
   }
 }