DeviceTree.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  1. <template>
  2. <div class="box box-primary">
  3. <div class="box-header">
  4. <h4 class="text-primary text-center">设备树</h4>
  5. </div>
  6. <div class="box-body">
  7. <form class="form-inline" autocomplete="off" spellcheck="false">
  8. <div class="form-group form-group-sm">
  9. <label>搜索</label>
  10. <input type="text" class="form-control" placeholder="关键字" v-model.trim="q" @keydown.enter.prevent ref="q">
  11. </div>
  12. <span class="hidden-xs">&nbsp;&nbsp;</span>
  13. <div class="form-group pull-right">
  14. <router-link :to="`/devices/1`" class="btn btn-default btn-sm">
  15. <i class="fa fa-table"></i> 列表视图
  16. </router-link>
  17. </div>
  18. </form>
  19. <br>
  20. <div class="clearfix"></div>
  21. <div class="content">
  22. <div :class="[{'col-md-3': hasAnyRole(serverInfo, userInfo, '管理员', '操作员'), 'col-md-4': !hasAnyRole(serverInfo, userInfo, '管理员', '操作员')}]">
  23. <ul class="nav nav-tabs">
  24. <li class="active"><a href="#dev-tree-wrapper" data-toggle="tab">设备树</a></li>
  25. <li><a href="#group-tree-wrapper" data-toggle="tab">分 组</a></li>
  26. </ul>
  27. <div class="tab-content" style="margin: 10px 0;" id="tab-tree-wrapper">
  28. <div class="tab-pane active" ref="devTreeWrapper" id="dev-tree-wrapper">
  29. <el-tree ref="devTree" id="dev-tree" node-key="key" v-if="showTree" :style="`${isMobile() ? 'max-height:200px;' : ''};min-height:200px;overflow:auto;`"
  30. :props="treeProps" :load="treeLoad" :filter-node-method="treeFilter" lazy
  31. @node-click="treeNodeClick" @node-contextmenu="treeNodeRightClick" >
  32. <span class="custom-tree-node" slot-scope="{node, data}">
  33. <span :class="{'text-green': treeLeaf(data) && data.status === 'ON'}">
  34. <i :class="['fa', {
  35. 'fa-sitemap' : !treeLeaf(data),
  36. 'fa-camera': treeLeaf(data)
  37. }]"></i>
  38. <span class="ellipsis" :title="node.label">{{node.label}}</span>
  39. </span>
  40. </span>
  41. </el-tree>
  42. </div>
  43. <div class="tab-pane" ref="groupTreeWrapper" id="group-tree-wrapper">
  44. <el-tree ref="groupTree" id="group-tree" node-key="key" v-if="showGroupTree" :style="`${isMobile() ? 'max-height:200px;' : ''};min-height:200px;overflow:auto;`"
  45. :props="treeProps" :load="groupTreeLoad" :filter-node-method="treeFilter" lazy
  46. @node-click="treeNodeClick" @node-contextmenu="treeNodeRightClick" >
  47. <span class="custom-tree-node" slot-scope="{node, data}">
  48. <span :class="{'text-green': data.status === 'ON' && data.subCount === 0 && data.code && data.serial && !data.custom}">
  49. <i :class="['fa', {
  50. 'fa-home': !data.code,
  51. 'fa-sitemap' : data.code && !treeLeaf(data),
  52. 'fa-camera': treeLeaf(data)
  53. }]"></i>
  54. <span class="ellipsis" :title="node.label">{{node.label}}</span>
  55. </span>
  56. </span>
  57. </el-tree>
  58. </div>
  59. </div>
  60. </div>
  61. <VueContextMenu class="right-menu" :target="contextMenuTarget" :show="contextMenuVisible" @update:show="(show) => contextMenuVisible = show">
  62. <a href="javascript:;" @click="treeRefresh" v-show="contextMenuNodeData">
  63. <i class="fa fa-refresh"></i> 刷新节点
  64. </a>
  65. <a href="javascript:;" @click="showNodeAddDlg" v-show="contextMenuNodeData && contextMenuNodeData.custom">
  66. <i class="fa fa-plus"></i> 新建节点
  67. </a>
  68. <a href="javascript:;" @click="showCustomListDlg" v-show="contextMenuNodeData && contextMenuNodeData.custom && contextMenuNodeData.code">
  69. <i class="fa fa-check"></i> 选择通道
  70. </a>
  71. <a href="javascript:;" @click="showNodeEditDlg" v-show="contextMenuNodeData && !(contextMenuNodeData.custom && !contextMenuNodeData.code)">
  72. <i class="fa fa-edit"></i> 编辑节点
  73. </a>
  74. <a href="javascript:;" @click="removeCustomNode" v-show="contextMenuNodeData && contextMenuNodeData.custom && contextMenuNodeData.code">
  75. <i class="fa fa-remove"></i> 删除节点
  76. </a>
  77. </VueContextMenu>
  78. <div id="dev-tree-right" :class="['row', {'col-md-9': hasAnyRole(serverInfo, userInfo, '管理员', '操作员'), 'col-md-8': !hasAnyRole(serverInfo, userInfo, '管理员', '操作员')}]" data-sticky-wrap data-sticky-for="1000" data-sticky-class="sticky">
  79. <div class="col-md-9 col-lg-10" id="dev-tree-player">
  80. <div class="view-list row">
  81. <div class="video-show">
  82. <div>
  83. <div class="no-margin no-padding video col-sm-6" @click="clickPlayer(player, index, $event)" :class="{'active': index == playerIdx, 'col-sm-12': playersLength == 1,'col-sm-6': playersLength == 4,'col-sm-4': playersLength == 9,'col-sm-3': playersLength == 16}" v-for="(player,index) in players" :key="index" @mousemove="resetCloseTimer(player)" @touchstart="resetCloseTimer(player)">
  84. <LivePlayer :videoUrl="player.url" :poster="player.poster" live muted stretch v-loading="player.bLoading" element-loading-text="加载中..." element-loading-background="#000" :loading.sync="player.bLoading" @message="$message"></LivePlayer>
  85. <div class="video-close" v-show="player.url && player.bCloseShow" v-on:click="closeVideo(player)">关闭</div>
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. <!-- <div class="no-margin no-padding video" @mousemove="resetCloseTimer()" @touchstart="resetCloseTimer()">
  91. <LivePlayer :videoUrl="player.url" :poster="player.poster" live muted stretch v-loading="player.bLoading" element-loading-text="加载中..." element-loading-background="#000" @message="$message"></LivePlayer>
  92. <div class="video-close" v-show="player.url && player.bCloseShow" v-on:click="closeVideo()">关闭</div>
  93. </div> -->
  94. <br>
  95. <br>
  96. </div>
  97. <div class="col-md-3 col-lg-2" id="dev-tree-ptz" v-if="hasAnyRole(serverInfo, userInfo, '管理员', '操作员')">
  98. <div class="ptz-block">
  99. <div class="ptz-cell ptz-up" :class="{'readonly': !playing }" command="up" title="上" @mousedown.prevent="ptzControl">
  100. <i class="fa fa-chevron-up"></i>
  101. </div>
  102. <div class="ptz-cell ptz-left" :class="{'readonly': !playing }" command="left" title="左" @mousedown.prevent="ptzControl">
  103. <i class="fa fa-chevron-left"></i>
  104. </div>
  105. <div class="ptz-cell ptz-center" title="云台控制">
  106. <i class="fa fa-microphone" :class="{'readonly': !playing }" title="按住喊话" @mousedown.prevent="talkStart" v-if="canTalk() && serverInfo.VersionType == '旗舰版'"></i>
  107. <i class="fa fa-microphone-slash" :class="{'readonly': !playing }" title="由于浏览器安全策略, 非 HTTPS 或 localhost 访问, 对讲不可用" v-if="!canTalk() && serverInfo.VersionType == '旗舰版'"></i>
  108. </div>
  109. <div class="ptz-cell ptz-right" :class="{'readonly': !playing }" command="right" title="右" @mousedown.prevent="ptzControl">
  110. <i class="fa fa-chevron-right"></i>
  111. </div>
  112. <div class="ptz-cell ptz-down" :class="{'readonly': !playing }" command="down" title="下" @mousedown.prevent="ptzControl">
  113. <i class="fa fa-chevron-down"></i>
  114. </div>
  115. <div class="ptz-cell ptz-zoomin" :class="{'readonly': !playing }" command="zoomin" title="放大" @mousedown.prevent="ptzControl">
  116. <i class="fa fa-plus"></i>
  117. </div>
  118. <div class="ptz-cell ptz-zoomout" :class="{'readonly': !playing }" command="zoomout" title="缩小" @mousedown.prevent="ptzControl">
  119. <i class="fa fa-minus"></i>
  120. </div>
  121. </div>
  122. </div>
  123. </div>
  124. <div class="clearfix"></div>
  125. <div class="text-center text-gray" v-if="isDemoUser(serverInfo, userInfo)">
  126. <br>
  127. 提示: 演示系统限制匿名登录播放时间, 若需测试长时间播放, 请<a target="_blank" href="//www.liveqing.com/docs/download/LiveGBS.html">下载使用</a>
  128. </div>
  129. <br>
  130. </div>
  131. </div>
  132. <!-- <div class="box-footer">
  133. </div> -->
  134. <DeviceTreeNodeEditDlg ref="nodeEditDlg" @submit="treeRefresh" style="z-index:2001;"></DeviceTreeNodeEditDlg>
  135. <ChannelCustomListDlg ref="customListDlg" @hide="treeRefresh" style="z-index:2001;" size="modal-lg" :title="customListDlgTitle"></ChannelCustomListDlg>
  136. <!-- <resize-observer @notify="resetTreeMaxHeight"/> -->
  137. </div>
  138. </template>
  139. <script>
  140. import Sticky from "sticky-js";
  141. import _ from "lodash";
  142. import url from "url";
  143. import { mapState } from "vuex"
  144. import LivePlayer from '@liveqing/liveplayer'
  145. import { component as VueContextMenu } from '@xunlei/vue-context-menu'
  146. import DeviceTreeNodeEditDlg from 'components/DeviceTreeNodeEditDlg.vue'
  147. import ChannelCustomListDlg from 'components/ChannelCustomListDlg.vue'
  148. export default {
  149. props: {},
  150. data() {
  151. return {
  152. q: "",
  153. loading: false,
  154. showTree: true,
  155. showGroupTree: true,
  156. playerIdx: 0,
  157. playersLength: 4,
  158. players: [],
  159. pnode: null,
  160. contextMenuTarget: null,
  161. contextMenuVisible: false,
  162. contextMenuNodeData: null,
  163. treeProps: {
  164. label: (data, node) => {
  165. node.serial = data.serial;
  166. node.code = data.code;
  167. var label = (data.customName || data.name || data.id);
  168. if(!this.treeLeaf(data) && data.subCount > 0) {
  169. label += ` [${data.onlineSubCount}/${data.subCount}]`;
  170. }
  171. return label;
  172. },
  173. isLeaf: (data, node) => {
  174. return this.treeLeaf(data);
  175. },
  176. disabled: (data, node) => {
  177. return this.treeLeaf(data) && data.status != "ON";
  178. }
  179. },
  180. customListDlgTitle: "选择通道",
  181. sticky: null,
  182. };
  183. },
  184. components: {
  185. LivePlayer, VueContextMenu, DeviceTreeNodeEditDlg, ChannelCustomListDlg
  186. },
  187. computed: {
  188. ...mapState(['userInfo', 'serverInfo']),
  189. playing() {
  190. var player = this.players[this.playerIdx]||{};
  191. return !!player.url;
  192. },
  193. canPTZ() {
  194. var player = this.players[this.playerIdx]||{};
  195. return !!player.url && (player.ptzType === 0 || player.ptzType === 1);
  196. }
  197. },
  198. mounted() {
  199. this.setPlayersLength(this.playersLength);
  200. this.contextMenuTarget = document.querySelector('#tab-tree-wrapper');
  201. $(document).on("mouseup touchend", this.ctrlStop);
  202. $(document).on('expanded.pushMenu collapsed.pushMenu', this.updateSticky);
  203. this.sticky = new Sticky("#dev-tree-right");
  204. },
  205. beforeDestroy() {
  206. this.ctrlStop();
  207. $(document).off("mouseup touchend", this.ctrlStop);
  208. $(document).off('expanded.pushMenu collapsed.pushMenu', this.updateSticky);
  209. this.clearVideos();
  210. if (this.sticky) {
  211. this.sticky.destroy();
  212. this.sticky = null;
  213. }
  214. },
  215. beforeRouteLeave(to, from, next) {
  216. this.ctrlStop();
  217. this.clearVideos();
  218. next();
  219. },
  220. beforeRouteUpdate(to, from, next) {
  221. this.ctrlStop();
  222. this.clearVideos();
  223. next();
  224. },
  225. watch: {
  226. q: function(newVal, oldVal) {
  227. this.$refs['devTree'].filter(newVal);
  228. this.$refs['groupTree'].filter(newVal);
  229. },
  230. },
  231. methods: {
  232. treeLoad(data, resolve) {
  233. var serial = data.serial||"";
  234. var pcode = data.code||"";
  235. $.get("/api/v1/device/channeltree", {
  236. serial: serial,
  237. pcode: pcode
  238. }).then(ret => {
  239. resolve((ret||[]).map(v => {
  240. return Object.assign(v, {
  241. key: v.id,
  242. })
  243. }));
  244. this.$refs['devTree'].filter(this.q);
  245. })
  246. },
  247. groupTreeLoad(data, resolve) {
  248. var serial = data.serial||"";
  249. var pcode = data.code||"";
  250. $.get("/api/v1/device/grouptree", {
  251. serial: serial,
  252. pcode: pcode
  253. }).then(ret => {
  254. resolve((ret||[]).map(v => {
  255. return Object.assign(v, {
  256. key: v.id,
  257. })
  258. }));
  259. this.$refs['groupTree'].filter(this.q);
  260. })
  261. },
  262. treeFilter(value, data) {
  263. if (!value) return true;
  264. return data.name.indexOf(value) !== -1 || data.customName.indexOf(value) !== -1 || data.id.indexOf(value) !== -1;
  265. },
  266. treeNodeRefresh(key) {
  267. let node = this.$refs['devTree'].getNode(key);
  268. if(!node) return;
  269. node.loaded = false;
  270. node.expand();
  271. },
  272. treeNodeRightClick(event, data, node, c) {
  273. if(!this.hasAnyRole(this.serverInfo, this.userInfo, '管理员')) return;
  274. this.contextMenuNodeData = data;
  275. this.pnode = node.parent;
  276. var new_event;
  277. if(typeof(MouseEvent) === 'function') {
  278. new_event = new MouseEvent(event.type, event);
  279. } else {
  280. new_event = document.createEvent('MouseEvents');
  281. new_event.initMouseEvent(event.type, true, true, event.view, event.detail,
  282. event.screenX, event.screenY, event.clientX, event.clientY,
  283. event.ctrlKey, event.altKey, event.shiftKey, event.metaKey, event.button, event);
  284. }
  285. this.contextMenuTarget.dispatchEvent(new_event);
  286. },
  287. treeNodeClick(data, node, c) {
  288. this.contextMenuNodeData = null;
  289. if(this.treeLeaf(data) && data.status === "ON") {
  290. var player = this.players[this.playerIdx]||{};
  291. if(player.bLoading) return;
  292. this.closeVideo(player);
  293. player.serial = data.serial;
  294. player.code = data.code;
  295. player.ptzType = data.ptzType;
  296. player.bLoading = true;
  297. $.get("/api/v1/stream/start", {
  298. serial: data.serial,
  299. code: data.code,
  300. }).then(streamInfo => {
  301. streamInfo = streamInfo || {};
  302. var videoUrl = this.isMobile() ? streamInfo.HLS : streamInfo.RTMP;
  303. var protocol = this.isMobile() ? "HLS" : "RTMP";
  304. if(this.flvSupported()) {
  305. if(streamInfo.WS_FLV) {
  306. videoUrl = streamInfo.WS_FLV;
  307. protocol = "WS_FLV";
  308. } else if(streamInfo.FLV) {
  309. videoUrl = streamInfo.FLV;
  310. protocol = "FLV";
  311. }
  312. }
  313. player.protocol = protocol;
  314. player.poster = protocol == "RTMP" ? "" : streamInfo.SnapURL;
  315. this.$nextTick(() => {
  316. player.url = videoUrl || "";
  317. });
  318. }).always(() => {
  319. player.bLoading = false;
  320. })
  321. this.setPlayerIdx(this.playerIdx + 1);
  322. }
  323. },
  324. showNodeEditDlg() {
  325. this.contextMenuVisible = false;
  326. var data = Object.assign({}, this.contextMenuNodeData, { parent: this.getParentData(), add: false});
  327. this.$refs['nodeEditDlg'].show(data);
  328. },
  329. showNodeAddDlg() {
  330. this.contextMenuVisible = false;
  331. var data = Object.assign({
  332. serial: this.contextMenuNodeData.serial||'',
  333. code: '',
  334. name: '',
  335. customName: '',
  336. }, { parent: this.contextMenuNodeData, add: true});
  337. this.$refs['nodeEditDlg'].show(data);
  338. },
  339. showCustomListDlg() {
  340. this.contextMenuVisible = false;
  341. this.customListDlgTitle = `选择通道(${this.contextMenuNodeData.customName || this.contextMenuNodeData.name || this.contextMenuNodeData.code})`;
  342. this.$refs['customListDlg'].show(this.contextMenuNodeData.code);
  343. },
  344. removeCustomNode() {
  345. this.contextMenuVisible = false;
  346. if(!this.contextMenuNodeData) return;
  347. var name = this.contextMenuNodeData.customName || this.contextMenuNodeData.name || this.contextMenuNodeData.id;
  348. this.$confirm(`确认删除 ${name}`, "提示").then(() => {
  349. $.get("/api/v1/channel/remove", {
  350. serial: this.contextMenuNodeData.serial,
  351. code: this.contextMenuNodeData.code,
  352. }).always(() => {
  353. this.treeNodeRefresh(this.pnode);
  354. });
  355. }).catch(() => {});
  356. },
  357. treeRefresh() {
  358. this.contextMenuVisible = false;
  359. if(this.pnode) {
  360. this.treeNodeRefresh(this.pnode);
  361. return;
  362. }
  363. this.showTree = false;
  364. this.$nextTick(() => {
  365. this.showTree = true;
  366. })
  367. },
  368. treeLeaf(data) {
  369. if (data && data.subCount == 0 && data.serial && data.code && !data.custom) {
  370. if (!data.parental || data.manufacturer != 'LiveQing') {
  371. if (data.code.length != 20 || data.code.substring(10, 13) != "216" || data.code.substring(10, 13) != "215") {
  372. return true;
  373. }
  374. }
  375. }
  376. return false;
  377. },
  378. getParentData() {
  379. if(!this.contextMenuNodeData) return null;
  380. if(!this.$refs["devTree"]) return null;
  381. var pNode = this.$refs["devTree"].getNode(this.contextMenuNodeData);
  382. if(!pNode) return null;
  383. if(!pNode.parent) return null;
  384. return pNode.parent.data;
  385. },
  386. resetCloseTimer(player) {
  387. if(!player) return;
  388. player.bCloseShow = true;
  389. if (player.closeTimer) {
  390. clearTimeout(player.closeTimer)
  391. }
  392. player.closeTimer = setTimeout(() => {
  393. player.bCloseShow = false;
  394. }, 2000);
  395. },
  396. closeVideo(player) {
  397. if(!player) return;
  398. player.bLoading = false;
  399. player.bCloseShow = false;
  400. player.poster = "";
  401. player.url = "";
  402. },
  403. clearVideos() {
  404. for(var idx in this.players) {
  405. this.closeVideo(this.players[idx]);
  406. }
  407. },
  408. setPlayersLength(len) {
  409. if(len == this.players.length) {
  410. return
  411. }
  412. this.clearVideos();
  413. this.players = [];
  414. this.playersLength = len;
  415. for(var i=0; i < len; i++) {
  416. this.players.push({
  417. serial: "",
  418. code: "",
  419. url: "",
  420. protocol: "",
  421. poster: "",
  422. bLoading: false,
  423. bCloseShow: false,
  424. })
  425. }
  426. },
  427. setPlayerIdx(idx) {
  428. this.ctrlStop();
  429. this.playerIdx = idx % this.players.length;
  430. },
  431. clickPlayer(player, idx, event) {
  432. if(!$(event.target).hasClass("video-close")) {
  433. this.setPlayerIdx(idx);
  434. }
  435. },
  436. ptzControl(e) {
  437. var player = this.players[this.playerIdx];
  438. if(!player || !player.serial || !player.code) return;
  439. var $target = $(e.currentTarget);
  440. $.get("/api/v1/control/ptz", {
  441. serial: player.serial,
  442. code: player.code,
  443. command: $target.attr("command")
  444. });
  445. $target.addClass("active");
  446. },
  447. ptzStop() {
  448. var player = this.players[this.playerIdx];
  449. if(!player || !player.serial || !player.code) return;
  450. if ($(this.$el).find(".ptz-cell.active").length > 0) {
  451. $.get("/api/v1/control/ptz", {
  452. serial: player.serial,
  453. code: player.code,
  454. command: "stop"
  455. });
  456. $(this.$el).find(".ptz-cell.active").removeClass("active");
  457. }
  458. },
  459. talkStart(e) {
  460. if(!this.ws) {
  461. var talkURL = this.wsTalkURL();
  462. if(!talkURL) return;
  463. var ws = new WebSocket(talkURL);
  464. ws.onopen = evt => {
  465. console.log("ws talk open");
  466. this.ws = ws;
  467. }
  468. ws.onclose = evt => {
  469. console.log("ws talk close");
  470. }
  471. ws.onerror = evt => {
  472. console.log("ws talk error", evt);
  473. }
  474. }
  475. var $target = $(e.currentTarget);
  476. if(this.recorder) {
  477. $target.addClass("active");
  478. this.recorder.start();
  479. return;
  480. }
  481. LiveRecorder.get((rec, err) => {
  482. if(err) {
  483. alert(err);
  484. return
  485. }
  486. // this.$refs["player"].setMuted(true);
  487. $target.addClass("active");
  488. this.recorder = rec;
  489. this.recorder.start();
  490. }, {
  491. sampleBits: 16,
  492. sampleRate: 8000,
  493. pcmCallback: pcm => {
  494. // binary to base64 string
  495. var reader = new window.FileReader();
  496. reader.onloadend = () => {
  497. var base64 = reader.result;
  498. var base64 = base64.split(',')[1];
  499. if(this.ws) {
  500. this.ws.send(base64);
  501. }
  502. }
  503. reader.readAsDataURL(pcm);
  504. }
  505. })
  506. },
  507. talkStop() {
  508. if(this.recorder) {
  509. this.recorder.stop();
  510. // this.recorder = null;
  511. $(this.$el).find(".fa-microphone.active").removeClass("active");
  512. // this.$refs["player"].setMuted(false);
  513. }
  514. if(this.ws) {
  515. this.ws.close();
  516. this.ws = null;
  517. }
  518. },
  519. ctrlStop() {
  520. this.talkStop();
  521. this.ptzStop();
  522. },
  523. wsTalkURL() {
  524. var player = this.players[this.playerIdx];
  525. if(!player || !player.serial || !player.code) return '';
  526. var protocal = "ws:";
  527. if(location.protocol.startsWith("https")) {
  528. protocal = "wss:";
  529. }
  530. //url query param "format=pcm|g711"
  531. return `${protocal}//${location.host}/api/v1/control/ws-talk/${player.serial}/${player.code}?format=pcm`;
  532. },
  533. resetTreeMaxHeight() {
  534. var $tree = $("#dev-tree, #group-tree");
  535. if(this.isMobile()) {
  536. $tree.css("max-height", 200);
  537. } else {
  538. this.$nextTick(() => {
  539. var ph = $("#dev-tree-player").height() - 90;
  540. var wh = $(window).height() - 450;
  541. var th = wh > ph ? wh : ph;
  542. $tree.css("max-height", th);
  543. })
  544. }
  545. },
  546. updateSticky() {
  547. this.sticky && this.sticky.update();
  548. },
  549. }
  550. };
  551. </script>
  552. <style lang="less" scoped>
  553. .right-menu {
  554. position: fixed;
  555. background: #fff;
  556. border: solid 1px rgba(0, 0, 0, .2);
  557. border-radius: 3px;
  558. z-index: 999;
  559. display: none;
  560. }
  561. .right-menu a {
  562. width: 100px;
  563. height: 28px;
  564. line-height: 28px;
  565. text-align: center;
  566. display: block;
  567. color: #1a1a1a;
  568. }
  569. .right-menu a:hover {
  570. background: #eee;
  571. color: #fff;
  572. }
  573. .right-menu {
  574. border: 1px solid #eee;
  575. box-shadow: 0 0.5em 1em 0 rgba(0,0,0,.1);
  576. border-radius: 1px;
  577. }
  578. a {
  579. text-decoration: none;
  580. }
  581. .right-menu a {
  582. padding: 2px;
  583. }
  584. .right-menu a:hover {
  585. background: #42b983;
  586. }
  587. .video {
  588. position: relative;
  589. .video-close {
  590. position: absolute;
  591. top: 5px;
  592. right: 5px;
  593. color: white;
  594. font-size: 12px;
  595. background-color: fade(gray, 50%);
  596. padding: 2px 5px;
  597. cursor: pointer;
  598. border-radius: 2px;
  599. max-width: 120px;
  600. overflow: hidden;
  601. white-space: nowrap;
  602. text-overflow: ellipsis;
  603. }
  604. }
  605. .ptz-block {
  606. width: 150px;
  607. height: 180px;
  608. margin: 0 auto;
  609. text-align: center;
  610. position: relative;
  611. font-size: 24px;
  612. }
  613. .ptz-cell {
  614. width: 50px;
  615. height: 50px;
  616. line-height: 50px;
  617. position: absolute;
  618. }
  619. .ptz-cell.active {
  620. color: #ccc;
  621. font-size: 26px;
  622. }
  623. .ptz-cell.readonly {
  624. color: #ddd;
  625. }
  626. .fa-microphone.active {
  627. color: #FFF;
  628. }
  629. .fa-microphone.readonly {
  630. color: #ddd;
  631. }
  632. .fa-microphone-slash.readonly {
  633. color: #ddd;
  634. }
  635. .ptz-center {
  636. top: 50px;
  637. left: 50px;
  638. border-radius: 25px;
  639. background-color: #ccc;
  640. }
  641. .ptz-up {
  642. top: 0;
  643. left: 50px;
  644. }
  645. .ptz-left {
  646. top: 50px;
  647. left: 0;
  648. }
  649. .ptz-right {
  650. top: 50px;
  651. left: 100px;
  652. }
  653. .ptz-down {
  654. top: 100px;
  655. left: 50px;
  656. }
  657. .ptz-zoomin {
  658. top: 150px;
  659. left: 20px;
  660. }
  661. .ptz-zoomout {
  662. top: 150px;
  663. left: 80px;
  664. }
  665. .ptz-up,
  666. .ptz-left,
  667. .ptz-right,
  668. .ptz-down,
  669. .ptz-center > .fa-microphone,
  670. .ptz-zoomin,
  671. .ptz-zoomout {
  672. cursor: pointer;
  673. &.readonly {
  674. cursor: auto;
  675. }
  676. }
  677. </style>
  678. <style lang="less">
  679. #dev-tree-player {
  680. .view-list {
  681. .video-show {
  682. .video {
  683. border: 1px solid #fff;
  684. &.active .video-inner {
  685. border: 2px solid red;
  686. }
  687. }
  688. .col-sm-12 {
  689. &:nth-child(1) {
  690. border: 0;
  691. }
  692. }
  693. .col-sm-6 {
  694. &:nth-child(1),
  695. &:nth-child(2) {
  696. border-top-color: transparent;
  697. }
  698. &:nth-child(2),
  699. &:nth-child(4) {
  700. border-right-color: transparent;
  701. }
  702. &:nth-child(1),
  703. &:nth-child(3) {
  704. border-left-color: transparent;
  705. }
  706. &:nth-child(3),
  707. &:nth-child(4) {
  708. border-bottom-color: transparent;
  709. }
  710. }
  711. .col-sm-4 {
  712. &:nth-child(1),
  713. &:nth-child(2),
  714. &:nth-child(3) {
  715. border-top-color: transparent;
  716. }
  717. &:nth-child(3),
  718. &:nth-child(6),
  719. &:nth-child(9) {
  720. border-right-color: transparent;
  721. }
  722. &:nth-child(7),
  723. &:nth-child(8),
  724. &:nth-child(9) {
  725. border-bottom-color: transparent;
  726. }
  727. &:nth-child(1),
  728. &:nth-child(4),
  729. &:nth-child(7) {
  730. border-left-color: transparent;
  731. }
  732. }
  733. .col-sm-3 {
  734. &:nth-child(1),
  735. &:nth-child(2),
  736. &:nth-child(3),
  737. &:nth-child(4) {
  738. border-top-color: transparent;
  739. }
  740. &:nth-child(4),
  741. &:nth-child(8),
  742. &:nth-child(12),
  743. &:nth-child(16) {
  744. border-right-color: transparent;
  745. }
  746. &:nth-child(13),
  747. &:nth-child(14),
  748. &:nth-child(15),
  749. &:nth-child(16) {
  750. border-bottom-color: transparent;
  751. }
  752. &:nth-child(1),
  753. &:nth-child(5),
  754. &:nth-child(9),
  755. &:nth-child(13) {
  756. border-left-color: transparent;
  757. }
  758. }
  759. }
  760. }
  761. }
  762. </style>