Forráskód Böngészése

1、同步线上设备;
2、广播动态新增、删除

wennn 3 éve
szülő
commit
f261b0e51e

+ 1 - 0
languages/zh-CN.js

@@ -133,6 +133,7 @@ module.exports = {
     uploadVersionCodeMsg: '版本信息不能为空',
     initialing: '正在初始化,请稍后...',
     deviceFrame: '设备空间',
+    synchroDevice: '同步设备',
     excelFile: '将导出Excel文件,是否继续?',
     statisticalSubTable: '统计子表',
     byPerson: '按人',

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 567 - 207
package-lock.json


+ 3 - 2
package.json

@@ -29,6 +29,7 @@
     "eslint-plugin-html": "^6.2.0",
     "file-saver": "2.0.1",
     "fuse.js": "3.4.4",
+    "jquery": "^3.6.0",
     "js-cookie": "2.2.0",
     "js-md5": "^0.7.3",
     "jsonlint": "1.6.3",
@@ -55,7 +56,7 @@
     "vue-router": "3.0.2",
     "vue-seamless-scroll": "^1.1.23",
     "vue-splitpane": "1.0.4",
-    "vuedraggable": "2.20.0",
+    "vuedraggable": "^2.20.0",
     "vuex": "3.1.0",
     "xlsx": "0.14.1"
   },
@@ -66,7 +67,7 @@
     "@vue/cli-service": "4.4.4",
     "@vue/test-utils": "1.0.0-beta.29",
     "autoprefixer": "9.5.1",
-    "babel-eslint": "10.1.0",
+    "babel-eslint": "^10.1.0",
     "babel-jest": "23.6.0",
     "babel-plugin-dynamic-import-node": "2.3.3",
     "chalk": "2.4.2",

+ 3 - 1
public/index.html

@@ -7,7 +7,9 @@
     <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
     <link rel="icon" href="<%= BASE_URL %>favicon.ico">
     <script src="/domain.js" ></script>
-    <title><%= webpackConfig.name %></title>
+      <script src="/janus.js" ></script>
+      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/webrtc-adapter/6.4.0/adapter.min.js" ></script>
+      <title><%= webpackConfig.name %></title>
   </head>
   <body>
     <div id="app"></div>

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 3634 - 0
public/janus.js


+ 7 - 0
src/api/initialize.js

@@ -39,4 +39,11 @@ export function changeRs485Debug(param) {
     url: `/initialize/change_rs485_debug/${param}`,
     method: 'GET'
   })
+}
+
+export function synchroDevice(unionId, shopId) {
+  return request({
+    url: `/initialize/synchro_device/${unionId}/${shopId}`,
+    method: 'GET'
+  })
 }

+ 2 - 0
src/main.js

@@ -31,6 +31,8 @@ import scroll from 'vue-seamless-scroll/src'
 
 import i18n from './utils/i18n'
 import BaiduMap from 'vue-baidu-map'
+import $ from 'jquery'
+Vue.prototype.$ = $
 /**
  * If you don't want to use mock-server
  * you want to use MockJs for mock api

+ 167 - 71
src/views/ncs-broadcast/index.vue

@@ -160,7 +160,7 @@
 <script>
 /** 广播设置 */
 import { AG_GRID_LOCALE_CN } from '@/utils/AgGridVueLocaleCn'
-import ButtonCellRender from '../../components/AgGridCellRender/ButtonCellRender'
+import ButtonCellRenderList from '@/components/AgGridCellRender/ButtonCellRenderList'
 import * as API_Broadcast from '@/api/calling-broadcast'
 import { unix2Date } from '@/utils/Foundation'
 import * as API_FrameGroup from '@/api/ncs_frameGroup'
@@ -170,9 +170,17 @@ import * as API_BroadcastFiles from '@/api/calling-broadcastFiles'
 // import { serverUrl, DeviceUrl } from '@/utils/domain'
 const serverUrl = domain.serverUrl
 const DeviceUrl = domain.DeviceUrl
+
+const server = "ws://192.168.1.55:8188/janus";
+let janus = null;
+let streaming = null;
+let opaqueId = "streamingtest-"+Janus.randomString(12);
+let bitrateTimer = null;
+let spinner = null;
+
 export default {
   name: 'Index',
-  components: { ButtonCellRender, ListFilter, RadioFilter },
+  components: { ButtonCellRenderList, ListFilter, RadioFilter },
   data() {
     return {
       tableData: [],
@@ -317,55 +325,36 @@ export default {
       },
       {
         headerName: this.$t('action.edit'), field: 'shop_id',
-        cellRendererFramework: 'ButtonCellRender',
-        cellRendererParams: {
-          onClick: this.handEdit,
-          label: this.$t('action.edit'),
-          buttonType: 'primary',
-          buttonSize: 'mini'
-        },
-        filter: false,
-        pinned: 'right',
-        lockPinned: true,
-        width: 100,
-        resizable: false,
-        sortable: false
-      },
-      {
-        headerName: this.$t('action.delete'), field: 'shop_id',
-        cellRendererFramework: 'ButtonCellRender',
+        cellRendererFramework: 'ButtonCellRenderList',
         cellRendererParams: param => {
           return {
-            onClick: this.deleteSingle,
-            label: this.$t('action.delete'),
-            buttonType: 'danger',
-            buttonSize: 'mini'
-          }
+            list: [
+              {
+                onClick: this.handEdit,
+                label: this.$t('action.edit'),
+                buttonType: 'primary',
+                buttonSize: 'mini'
+              },
+              {
+                onClick: this.deleteSingle,
+                label: this.$t('action.delete'),
+                buttonType: 'danger',
+                buttonSize: 'mini'
+              },
+              {
+                onClick: () => { param.data.playing ? this.stopBroadcast(param.data) : this.playBroadcast(param.data) },
+                label: param.data.playing ? this.$t('broadcast.stop') : this.$t('broadcast.play'),
+                buttonType: param.data.playing ? 'danger' : 'primary',
+                buttonSize: 'mini',
+                disabled: param.data.broadcast_mode !== 1 || !param.data.status
+              }
+            ]}
         },
-        pinned: 'right',
-        lockPinned: true,
-        width: 100,
-        resizable: false,
         filter: false,
-        sortable: false
-      },
-      {
-        headerName: this.$t('broadcast.play'), field: 'id',
-        cellRendererFramework: 'ButtonCellRender',
-        cellRendererParams: param => {
-          return {
-            onClick: () => { param.data.playing ? this.stopBroadcast(param.data) : this.playBroadcast(param.data) },
-            label: param.data.playing ? this.$t('broadcast.stop') : this.$t('broadcast.play'),
-            buttonType: param.data.playing ? 'danger' : 'primary',
-            buttonSize: 'mini',
-            disabled: param.data.broadcast_mode !== 1 || !param.data.status
-          }
-        },
         pinned: 'right',
         lockPinned: true,
-        width: 100,
+        width: 220,
         resizable: false,
-        filter: false,
         sortable: false
       }
     ]
@@ -404,6 +393,7 @@ export default {
         _this.initWebSocket()
       }
     }, 60000)
+    // this.initJanus()
   },
   methods: {
     windowResize() {
@@ -438,8 +428,20 @@ export default {
     },
     deleteSingle(row) {
       this.handlerDelete(row.id)
+      let body = {
+        request: "destroy",
+        id: row.id,
+        permanent: true
+      };
+      Janus.debug("Sending message:", body);
+      streaming.send({message:body, success: function(result){
+          if(!result) {
+            bootbox.alert("Got no response to our query");
+            return;
+          }
+          Janus.debug("receiving message:", result);
+        }});
     },
-
     playBroadcast(row) {
       // API_BroadcastFiles.getAllFileByBroadcastId(row.id).then(res => {
       //   if (Array.isArray(res)) {
@@ -454,7 +456,6 @@ export default {
       //   this.gridApi.redrawRows()
       // })
     },
-
     stopBroadcast(row) {
       this.websock.send(JSON.stringify({ 'command': 'stop', 'broadcast_id': row.id }))
       // API_Broadcast.stopBroadcast(row.id).then(() => {
@@ -462,7 +463,6 @@ export default {
       //   this.gridApi.redrawRows()
       // })
     },
-
     /**
              * 创建广播
              */
@@ -481,7 +481,6 @@ export default {
       this.params.page_size = size
       this.getList()
     },
-
     /** 分页页数发生改变 */
     handlePageCurrentChange(page) {
       this.params.page_no = page
@@ -535,7 +534,6 @@ export default {
       if (!param.value) return ''
       return unix2Date(param.value * 1000)
     },
-
     radioFilterFormatter(params, array) {
       const item = array.filter(p => p.value === params.value)[0]
       if (item) {
@@ -548,7 +546,6 @@ export default {
         return ''
       }
     },
-
     statusFormatter(params) {
       console.log('para', params)
       const item = this.broadcastStatus.filter(p => (p.value === (!params.value ? false : params.value)))[0] // params.value === null 时,要返回false的记录
@@ -616,25 +613,61 @@ export default {
              * @param formname
              */
     handlerFormSubmit(formName) {
-      this.$refs[formName].validate((valid) => {
-        if (valid) {
-          /** 新增 */
-          delete this.formmodel.id
-          this.formmodel.part_id = this.$store.getters.partId
-          // const starttime = new Date(this.timeRange[0]).toLocaleTimeString('chinese', { hour12: false })
-          // const endtime = new Date(this.timeRange[1]).toLocaleTimeString('chinese', { hour12: false })
-          // this.formmodel.play_start = starttime
-          // this.formmodel.play_end = endtime
+      let body = {
+        request: "create",
+        type: "rtp",
+        id: 142,
+        description: this.formmodel.title,
+        metadata: "okokok",
+        permanent: true,
+        audio: true,
+        video: false,
+        audioport : 5001,
+        audiopt : 111,
+        audiortpmap : "opus/48000/2"
+      };
+      Janus.debug("Sending message:", body);
+      streaming.send({message:body, success: function(result){
+// 		error: "Error creating 'rtp' stream"
+// error_code: 456
+// streaming: "event"
 
-          API_Broadcast.add(this.formmodel).then(() => {
-            this.formshow = false
-            this.$message.success(this.$t('action.saveSuccess'))
-            this.getList()
-          })
-        } else {
-          this.$message.error(this.$t('action.fromError'))
-        }
-      })
+// created: "mp-308"
+// permanent: true
+// stream:
+// audio_port: 50023
+// description: "abcdefg"
+// id: 308
+// is_private: false
+// type: "live"
+// [[Prototype]]: Object
+// streaming: "created"
+          console.log('result===', result)
+          if(!result) {
+            bootbox.alert("Got no response to our query");
+            return;
+          }
+          Janus.debug("receiving message:", result);
+        }});
+      // this.$refs[formName].validate((valid) => {
+      //   if (valid) {
+      //     /** 新增 */
+      //     delete this.formmodel.id
+      //     this.formmodel.part_id = this.$store.getters.partId
+      //     // const starttime = new Date(this.timeRange[0]).toLocaleTimeString('chinese', { hour12: false })
+      //     // const endtime = new Date(this.timeRange[1]).toLocaleTimeString('chinese', { hour12: false })
+      //     // this.formmodel.play_start = starttime
+      //     // this.formmodel.play_end = endtime
+      //
+      //     API_Broadcast.add(this.formmodel).then(() => {
+      //       this.formshow = false
+      //       this.$message.success(this.$t('action.saveSuccess'))
+      //       this.getList()
+      //     })
+      //   } else {
+      //     this.$message.error(this.$t('action.fromError'))
+      //   }
+      // })
     },
     broadcastModeChanage(val) { // 变换广播模式,手动模式可以不选择播放模式,自动模式需要选择播放模式,定时播放或者定次播放
       if (val === 1) { // 手动模式
@@ -683,7 +716,6 @@ export default {
         console.log('groups', this.frameGroups)
       })
     },
-
     initWebSocket: function() {
       const stockbase = DeviceUrl.replace('http', 'ws')
       this.websock = new WebSocket(stockbase + '/broadcast/status/' + this.$store.getters.uuid)
@@ -702,11 +734,9 @@ export default {
       this.scheduledIds = JSON.parse(e.data)
       this.refreshPlayStatus()
     },
-
     websocketclose: function(e) {
       console.log('connection closed (' + e.code + ')')
     },
-
     refreshPlayStatus() {
       if (this.rowData !== null) {
         this.rowData.forEach(item => {
@@ -719,6 +749,72 @@ export default {
         })
         this.gridApi.redrawRows()
       }
+    },
+    initJanus() {
+      const _this = this
+      _this.$(document).ready(function() {
+        // Initialize the library (all console debuggers enabled)
+        Janus.init({debug: "all", callback: function() {
+            // Use a button to start the demo
+            _this.$(this).attr('disabled', true).unbind('click');
+            // Make sure the browser supports WebRTC
+            if(!Janus.isWebrtcSupported()) {
+              bootbox.alert("No WebRTC support... ");
+              return;
+            }
+            // Create session
+            janus = new Janus(
+                {
+                  server: server,
+                  success: function() {
+                    // Attach to Streaming plugin
+                    janus.attach(
+                        {
+                          plugin: "janus.plugin.streaming",
+                          opaqueId: opaqueId,
+                          success: function(pluginHandle) {
+                            _this.$('#details').remove();
+                            streaming = pluginHandle;
+                            Janus.log("Plugin attached! (" + streaming.getPlugin() + ", id=" + streaming.getId() + ")");
+                          },
+                          error: function(error) {
+                            Janus.error("  -- Error attaching plugin... ", error);
+                            bootbox.alert("Error attaching plugin... " + error);
+                          },
+                          iceState: function(state) {
+                            Janus.log("ICE state changed to " + state);
+                          },
+                          webrtcState: function(on) {
+                            Janus.log("Janus says our WebRTC PeerConnection is " + (on ? "up" : "down") + " now");
+                          },
+                          onmessage: function(msg, jsep) {
+                            Janus.debug(" ::: Got a message :::", msg);
+                          },
+                          onremotestream: function(stream) {
+                            Janus.debug(" ::: Got a remote stream :::", stream);
+                          },
+                          ondataopen: function(data) {
+                          },
+                          ondata: function(data) {
+                            Janus.debug("We got data from the DataChannel!", data);
+                          },
+                          oncleanup: function() {
+                            Janus.log(" ::: Got a cleanup notification :::");
+                          }
+                        });
+                  },
+                  error: function(error) {
+                    Janus.error(error);
+                    bootbox.alert(error, function() {
+                      window.location.reload();
+                    });
+                  },
+                  destroyed: function() {
+                    window.location.reload();
+                  }
+                });
+          }});
+      });
     }
 
   }

+ 10 - 5
src/views/ncs-orginazition/index.vue

@@ -105,7 +105,7 @@ import * as API_PartInfo from '@/api/ncs_partInfo'
 import { unix2Date } from '@/utils/Foundation'
 import ButtonCellRender from '../../components/AgGridCellRender/ButtonCellRender'
 import ButtonCellRenderList from '@/components/AgGridCellRender/ButtonCellRenderList'
-import { initData } from '@/api/initialize'
+import {initData, synchroDevice} from '@/api/initialize'
 export default {
   name: 'Index',
   components: { ButtonCellRender, ButtonCellRenderList },
@@ -222,11 +222,11 @@ export default {
                 buttonSize: 'mini'
               },
               {
-                onClick: this.deviceBind,
-                label: this.$t('action.deviceFrame'),
-                buttonType: 'success',
+                onClick: param.data['shop_type'] === '5' ? this.deviceBind : this.synchroDevice,
+                label: param.data['shop_type'] === '5' ? this.$t('action.deviceFrame') : this.$t('action.synchroDevice'),
+                buttonType: param.data['shop_type'] === '5' ? 'success' : 'warning',
                 buttonSize: 'mini',
-                disabled: param.data['shop_type'] !== '5'
+                // disabled: param.data['shop_type'] !== '5'
               },{
                 onClick: this.deleteSingle,
                 label: this.$t('action.delete'),
@@ -509,6 +509,11 @@ export default {
     deviceBind(row) {
       console.log('--------------------', row.shop_id, row.parent_id)
       this.$router.push({ name: 'device-frame', params: { id: row.shop_id, parent_id: row.parent_id }})
+    },
+    synchroDevice(row) { // 同步线上设备
+      synchroDevice(row.union_id, row.shop_id).then(res => {
+        this.$message.info(this.$t('action.initialing'))
+      })
     }
   }
 }