Config.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <template>
  2. <div class="container-fluid no-padding">
  3. <section class="content">
  4. <div class="nav-tabs-custom col-lg-offset-2 col-lg-8 no-padding">
  5. <ul class="nav nav-tabs">
  6. <li class="active"><a href="#base-config" data-toggle="tab">{{logoText}} 信令服务配置</a></li>
  7. <li @click.prevent="getSMSList"><a href="#sms-config" data-toggle="tab">{{logoText}} 流媒体服务配置</a></li>
  8. </ul>
  9. <div class="tab-content">
  10. <div class="tab-pane active" id="base-config">
  11. <form role="form" class="form-horizontal" autocomplete="off" @submit.prevent="onSubmit">
  12. <div :class="['form-group' , {'has-error': errors.has('Serial')}]">
  13. <label for="sip-serial" class="col-sm-4 control-label">SIP ID</label>
  14. <div class="col-sm-7">
  15. <input id="sip-serial" type="text" class="form-control" name="Serial" data-vv-as="SIP ID" v-validate="'required'" v-model.trim="Serial">
  16. <span class="help-block">{{errors.first('Serial')}}</span>
  17. </div>
  18. </div>
  19. <div :class="['form-group' , {'has-error': errors.has('Realm')}]">
  20. <label for="sip-realm" class="col-sm-4 control-label">SIP 域</label>
  21. <div class="col-sm-7">
  22. <input id="sip-realm" type="text" class="form-control" name="Realm" data-vv-as="SIP 域" v-validate="'required'" v-model.trim="Realm">
  23. <span class="help-block">{{errors.first('Realm')}}</span>
  24. </div>
  25. </div>
  26. <div :class="['form-group' , {'has-error': errors.has('Host')}]">
  27. <label for="sip-host" class="col-sm-4 control-label">SIP Host</label>
  28. <div class="col-sm-7">
  29. <input type="text" id="sip-host" class="form-control" name="Host" data-vv-as="SIP Host" v-validate="'required'" v-model.trim="Host">
  30. <span class="help-block">{{errors.first('Host')}}</span>
  31. </div>
  32. </div>
  33. <div :class="['form-group' , {'has-error': errors.has('Port')}]">
  34. <label for="sip-port" class="col-sm-4 control-label">SIP 端口</label>
  35. <div class="col-sm-7">
  36. <input type="text" id="sip-port" class="form-control" name="Port" data-vv-as="SIP 端口" v-validate="'required|numeric'" v-model.trim="Port">
  37. <span class="help-block">{{errors.first('Port')}}</span>
  38. </div>
  39. </div>
  40. <div :class="['form-group' , {'has-error': errors.has('DevicePassword')}]">
  41. <label for="sip-dev-pwd" class="col-sm-4 control-label">设备统一接入密码</label>
  42. <div class="col-sm-7">
  43. <input type="text" id="sip-dev-pwd" class="form-control" name="DevicePassword" data-vv-as="设备统一接入密码" v-model.trim="DevicePassword">
  44. <span class="help-block">{{errors.first('DevicePassword')}}</span>
  45. </div>
  46. </div>
  47. <div :class="['form-group', {'has-error': errors.has('PreferStreamFmt')}]" title="配置直播流优先使用的播放格式">
  48. <label for="prefer-stream-fmt" class="col-sm-4 control-label">首选直播格式</label>
  49. <div class="col-sm-7">
  50. <select id="prefer-stream-fmt" name="PreferStreamFmt" class="form-control" v-model.trim="PreferStreamFmt">
  51. <option value="">自动选择</option>
  52. <option value="FLV">FLV</option>
  53. <option value="WS_FLV">WS_FLV</option>
  54. <option value="WEBRTC">WEBRTC</option>
  55. <option value="HLS">HLS</option>
  56. <option value="RTMP">RTMP</option>
  57. </select>
  58. <span class="help-block">{{errors.first('PreferStreamFmt')}}</span>
  59. </div>
  60. </div>
  61. <div :class="['form-group' , {'has-error': errors.has('TimeServer')}]">
  62. <label for="sip-time-server" class="col-sm-4 control-label">校时源(可选)</label>
  63. <div class="col-sm-7">
  64. <input type="text" id="sip-time-server" class="form-control" name="TimeServer" data-vv-as="校时源" v-validate="" v-model.trim="TimeServer" placeholder="上级国标编号/NTP">
  65. <span class="help-block">{{errors.first('TimeServer')}}</span>
  66. </div>
  67. </div>
  68. <div class="form-group">
  69. <label for="black-ip-list" class="col-sm-4 control-label">黑名单 IP(可选)</label>
  70. <div class="col-sm-7">
  71. <input type="text" id="black-ip-list" class="form-control" name="BlackIPList" data-vv-as="黑名单 IP" v-model.trim="BlackIPList" placeholder="选填">
  72. <span class="help-block"></span>
  73. </div>
  74. </div>
  75. <div class="form-group">
  76. <label for="black-ua-list" class="col-sm-4 control-label">黑名单 UA(可选)</label>
  77. <div class="col-sm-7">
  78. <input type="text" id="black-ua-list" class="form-control" name="BlackUAList" data-vv-as="黑名单 UA" v-model.trim="BlackUAList" placeholder="选填">
  79. <span class="help-block"></span>
  80. </div>
  81. </div>
  82. <div :class="{'form-group': true, 'has-error': errors.has('HTTPSPort')}" title="配置为0, 表示不开启HTTPS">
  83. <label for="base-https-port" class="col-sm-4 control-label">HTTPS 端口(可选)</label>
  84. <div class="col-sm-7">
  85. <input id="base-https-port" type="text" class="form-control" name="HTTPSPort" data-vv-as="HTTPS 端口" v-validate="'numeric'" v-model.trim="HTTPSPort" placeholder="默认不开启HTTPS">
  86. <span class="help-block">{{errors.first('HTTPSPort')}}</span>
  87. </div>
  88. </div>
  89. <div :class="{'form-group': true, 'has-error': errors.has('HTTPSCertFile')}" title="配置 Cert 证书路径,绝对路径" v-if="HTTPSPort && HTTPSPort != '0'">
  90. <label for="base-https-cert-file" class="col-sm-4 control-label">HTTPS Cert 证书路径</label>
  91. <div class="col-sm-7">
  92. <input id="base-https-cert-file" type="text" class="form-control" spellcheck="false" autocomplete="off" name="HTTPSCertFile" v-model.trim="HTTPSCertFile" placeholder="配置cert证书绝对路径">
  93. <span class="help-block">{{errors.first('HTTPSCertFile')}}</span>
  94. </div>
  95. </div>
  96. <div :class="{'form-group': true, 'has-error': errors.has('HTTPSKeyFile')}" title="配置 Cert 证书路径,绝对路径" v-if="HTTPSPort && HTTPSPort != '0'">
  97. <label for="base-https-key-file" class="col-sm-4 control-label">HTTPS Key 证书路径</label>
  98. <div class="col-sm-7">
  99. <input id="base-https-key-file" type="text" class="form-control" spellcheck="false" autocomplete="off" name="HTTPSKeyFile" v-model.trim="HTTPSKeyFile" placeholder="配置key证书绝对路径">
  100. <span class="help-block">{{errors.first('HTTPSKeyFile')}}</span>
  101. </div>
  102. </div>
  103. <div class="form-group">
  104. <label class="col-sm-4 control-label">其他配置</label>
  105. <div class="col-sm-7 checkbox">
  106. <el-checkbox title="开启后接口调用会校验登录" style="margin-left:-19px;margin-top:-5px;" size="small" v-model.trim="APIAuth" name="APIAuth">HTTP 接口鉴权</el-checkbox>
  107. &nbsp;&nbsp;&nbsp;&nbsp;
  108. <el-checkbox style="margin-left:-19px;margin-top:-5px;" size="small" v-model.trim="SIPLog" name="SIPLog">信令日志</el-checkbox>
  109. &nbsp;&nbsp;&nbsp;&nbsp;
  110. <router-link :to="`/black/1`">
  111. <i title="设备接入黑名单维护" class="fa fa-list cfg-black-list" aria-hidden="true">&nbsp;&nbsp;黑名单</i>
  112. </router-link>
  113. &nbsp;&nbsp;&nbsp;&nbsp;
  114. <router-link :to="`/white/1`">
  115. <i title="设备接入白名单维护" class="fa fa-server cfg-white-list" aria-hidden="true">&nbsp;&nbsp;白名单</i>
  116. </router-link>
  117. <span class="help-block"></span>
  118. </div>
  119. </div>
  120. <div class="form-group">
  121. <div class="col-sm-offset-4 col-sm-7">
  122. <button type="submit" class="btn btn-primary" :disabled="isBasicNoChange || errors.any() || bCommitting">保存</button>
  123. </div>
  124. </div>
  125. </form>
  126. </div>
  127. <div class="tab-pane" id="sms-config">
  128. <form role="form" class="form-horizontal" autocomplete="off">
  129. <div class="form-group" v-if="smss.length > 0">
  130. <label class="col-sm-4 control-label">SMS 服务</label>
  131. <div class="col-sm-7">
  132. <select class="form-control" v-model.trim="smsserial" @change="smschange">
  133. <option v-for="(c, idx) in smss" :value="c.Serial" :key="idx">{{c.Serial}}</option>
  134. </select>
  135. </div>
  136. </div>
  137. <div class="form-group" v-if="smss.length <= 0">
  138. <div class="col-sm-12">
  139. <div class="alert text-center no-margin">SMS {{smstip}}</div>
  140. </div>
  141. </div>
  142. </form>
  143. <form v-if="smsbaseconfig.Host != undefined && smss.length > 0" role="form" class="form-horizontal" autocomplete="off" @submit.prevent="onSubmitSMS">
  144. <div :class="['form-group' , {'has-error': errors.has('smsSerial')}]" title="内部通信使用">
  145. <label class="col-sm-4 control-label">SIP ID</label>
  146. <div class="col-sm-7">
  147. <input type="text" class="form-control" name="smsSerial" data-vv-as="SIP ID" v-validate="'required'" v-model.trim="smsbaseconfig.Serial">
  148. <span class="help-block">{{errors.first('smsSerial')}}</span>
  149. </div>
  150. </div>
  151. <div :class="['form-group' , {'has-error': errors.has('smsRealm')}]" title="内部通信使用">
  152. <label class="col-sm-4 control-label">SIP 域</label>
  153. <div class="col-sm-7">
  154. <input type="text" class="form-control" name="smsRealm" data-vv-as="SIP 域" v-validate="'required'" v-model.trim="smsbaseconfig.Realm">
  155. <span class="help-block">{{errors.first('smsRealm')}}</span>
  156. </div>
  157. </div>
  158. <div :class="['form-group' , {'has-error': errors.has('smsPort')}]" title="内部通信使用">
  159. <label class="col-sm-4 control-label">SIP 端口</label>
  160. <div class="col-sm-7">
  161. <input type="text" class="form-control" name="smsPort" data-vv-as="SIP 端口" v-validate="'required|numeric'" v-model.trim="smsbaseconfig.Port">
  162. <span class="help-block">{{errors.first('smsPort')}}</span>
  163. </div>
  164. </div>
  165. <div :class="['form-group' , {'has-error': errors.has('smsHost')}]" title="内部通信收流. 启用外网IP收流后, 此处配置信令服务可访问的局域网IP如:127.0.0.1">
  166. <label class="col-sm-4 control-label">本地|内网 IP</label>
  167. <div class="col-sm-7">
  168. <input type="text" class="form-control" placeholder="内部通信收流. 启用外网IP收流后, 此处配置信令服务可访问的局域网IP如:127.0.0.1" name="smsHost" data-vv-as="本地|内网 IP" v-validate="'required'" v-model.trim="smsbaseconfig.Host">
  169. <span class="help-block">{{errors.first('smsHost')}}</span>
  170. </div>
  171. </div>
  172. <div :class="['form-group' , {'has-error': errors.has('WanIP')}]">
  173. <label class="col-sm-4 control-label">外网 IP(可选)</label>
  174. <div class="col-sm-7">
  175. <input type="text" class="form-control" name="WanIP" data-vv-as="外网 IP" v-model.trim="smsbaseconfig.WanIP" placeholder="选填">
  176. <span class="help-block">{{errors.first('WanIP')}}</span>
  177. </div>
  178. </div>
  179. <div class="form-group">
  180. <label class="col-sm-4 control-label">RTSP 端口(可选)</label>
  181. <div class="col-sm-7">
  182. <input type="text" class="form-control" name="RTSPPort" data-vv-as="RTSP 端口" v-validate="'numeric'" v-model.trim="smsbaseconfig.RTSPPort" placeholder="选填">
  183. <span class="help-block">{{errors.first('RTSPPort')}}</span>
  184. </div>
  185. </div>
  186. <div :class="['form-group' , {'has-error': errors.has('RTMPPort')}]">
  187. <label class="col-sm-4 control-label">RTMP 端口</label>
  188. <div class="col-sm-7">
  189. <input type="text" class="form-control" name="RTMPPort" data-vv-as="RTMP 端口" v-validate="'required|numeric'" v-model.trim="smsbaseconfig.RTMPPort">
  190. <span class="help-block">{{errors.first('RTMPPort')}}</span>
  191. </div>
  192. </div>
  193. <div :class="['form-group' , {'has-error': errors.has('RecordDir')}]">
  194. <label class="col-sm-4 control-label">云录像目录</label>
  195. <div class="col-sm-7">
  196. <input type="text" class="form-control" name="RecordDir" data-vv-as="云录像目录" v-model.trim="smsbaseconfig.RecordDir">
  197. <span class="help-block">{{errors.first('RecordDir')}}</span>
  198. </div>
  199. </div>
  200. <div class="form-group">
  201. <label class="col-sm-4 control-label">其他配置</label>
  202. <div class="col-sm-7 checkbox">
  203. <el-checkbox title="加快启播速度,相应也会增大一点延时" style="margin-left:-19px;margin-top:-5px;" size="small" v-model.trim="smsbaseconfig.GOPCache" name="GOPCache">直播秒开</el-checkbox>
  204. &nbsp;&nbsp;&nbsp;&nbsp;
  205. <el-checkbox style="margin-left:-19px;margin-top:-5px;" size="small" v-model.trim="smsbaseconfig.HLS" name="HLS">HLS</el-checkbox>
  206. &nbsp;&nbsp;&nbsp;&nbsp;
  207. <el-checkbox style="margin-left:-19px;margin-top:-5px;" size="small" v-model.trim="smsbaseconfig.SIPLog" name="SIPLog">信令日志</el-checkbox>
  208. &nbsp;&nbsp;&nbsp;&nbsp;
  209. <el-checkbox style="margin-left:-19px;margin-top:-5px;" size="small" v-model.trim="smsbaseconfig.UseWanIPRecvStream" name="UseWanIPRecvStream">外网 IP 收流</el-checkbox>
  210. </div>
  211. </div>
  212. <div class="form-group">
  213. <div class="col-sm-offset-4 col-sm-7">
  214. <button type="submit" class="btn btn-primary" :disabled="isSMSNoChange || errors.any() || bCommitting">保存</button>
  215. </div>
  216. </div>
  217. </form>
  218. </div>
  219. </div>
  220. <!-- /.tab-content -->
  221. </div>
  222. </section>
  223. </div>
  224. </template>
  225. <script>
  226. import $ from "jquery";
  227. import {
  228. mapState,
  229. mapActions
  230. } from "vuex"
  231. export default {
  232. data() {
  233. return {
  234. bCommitting: false,
  235. Serial: "",
  236. Realm: "",
  237. Host: "",
  238. Port: 0,
  239. DevicePassword: "",
  240. TimeServer: "",
  241. PreferStreamFmt: "",
  242. AckTimeout: 0,
  243. KeepaliveTimeout: 0,
  244. APIAuth: false,
  245. SIPLog: false,
  246. BlackIPList: "",
  247. BlackUAList: "",
  248. remoteBasicData: "",
  249. remoteSMSData: "",
  250. smsserial: "",
  251. smss: [],
  252. sms: {},
  253. smsbaseconfig: {},
  254. smstip: "流媒体服务尚未启动",
  255. HTTPSPort: "",
  256. HTTPSCertFile: "",
  257. HTTPSKeyFile: "",
  258. };
  259. },
  260. mounted() {
  261. this.getBaseConfig()
  262. },
  263. methods: {
  264. async onSubmit() {
  265. var ok = await this.$validator.validateAll();
  266. if (!ok) {
  267. var e = this.errors.items[0];
  268. this.$message({
  269. type: "error",
  270. message: e.msg
  271. });
  272. $(`[name=${e.field}]`).focus();
  273. return;
  274. }
  275. this.bCommitting = true;
  276. $.get("/api/v1/setbaseconfig", this.getBasicCommitObject()).then(data => {
  277. this.$message({
  278. type: "success",
  279. message: "配置成功!"
  280. });
  281. }).always(() => {
  282. this.getBaseConfig()
  283. this.bCommitting = false;
  284. })
  285. },
  286. async onSubmitSMS() {
  287. var ok = await this.$validator.validateAll();
  288. if (!ok) {
  289. var e = this.errors.items[0];
  290. this.$message({
  291. type: "error",
  292. message: e.msg
  293. });
  294. $(`[name=${e.field}]`).focus();
  295. return;
  296. }
  297. this.bCommitting = true;
  298. $.get("/api/v1/sms/setbaseconfig", this.smsbaseconfig).then(data => {
  299. this.$message({
  300. type: "success",
  301. message: "配置保存中,请稍后..."
  302. });
  303. }).always(() => {
  304. this.smstip = "配置保存中,请稍后..."
  305. this.smsserial = "";
  306. this.getSMSList()
  307. this.bCommitting = false;
  308. })
  309. },
  310. getBasicCommitObject() {
  311. return {
  312. Serial: this.Serial,
  313. Realm: this.Realm,
  314. Host: this.Host,
  315. Port: this.Port,
  316. DevicePassword: this.DevicePassword,
  317. TimeServer: this.TimeServer,
  318. PreferStreamFmt: this.PreferStreamFmt,
  319. AckTimeout: this.AckTimeout,
  320. KeepaliveTimeout: this.KeepaliveTimeout,
  321. APIAuth: this.APIAuth,
  322. SIPLog: this.SIPLog,
  323. BlackIPList: this.BlackIPList,
  324. BlackUAList: this.BlackUAList,
  325. HTTPSPort: this.HTTPSPort,
  326. HTTPSCertFile: this.HTTPSCertFile,
  327. HTTPSKeyFile: this.HTTPSKeyFile,
  328. };
  329. },
  330. getBaseConfig() {
  331. $.get("/api/v1/getbaseconfig").then(ret => {
  332. this.Serial = ret.Serial;
  333. this.Realm = ret.Realm;
  334. this.Host = ret.Host;
  335. this.Port = ret.Port;
  336. this.DevicePassword = ret.DevicePassword;
  337. this.TimeServer = ret.TimeServer;
  338. this.PreferStreamFmt = ret.PreferStreamFmt;
  339. this.AckTimeout = ret.AckTimeout;
  340. this.KeepaliveTimeout = ret.KeepaliveTimeout;
  341. this.APIAuth = ret.APIAuth;
  342. this.SIPLog = ret.SIPLog;
  343. this.BlackIPList = ret.BlackIPList;
  344. this.BlackUAList = ret.BlackUAList;
  345. this.HTTPSPort = ret.HTTPSPort || "";
  346. this.HTTPSCertFile = ret.HTTPSCertFile;
  347. this.HTTPSKeyFile = ret.HTTPSKeyFile;
  348. this.remoteBasicData = JSON.stringify(this.getBasicCommitObject());
  349. });
  350. },
  351. getSMSList() {
  352. if (this.smsserial == "") {
  353. $.get("/api/v1/sms/list").then(ret => {
  354. this.smss = ret
  355. if (ret.length > 0) {
  356. this.sms = ret[0]
  357. this.smsserial = ret[0].Serial
  358. }
  359. this.getSMSInfo();
  360. if (this.smsserial == "") {
  361. setTimeout(() => {
  362. this.getSMSList()
  363. }, 1000);
  364. } else {
  365. this.smstip = "流媒体服务尚未启动"
  366. }
  367. })
  368. }
  369. },
  370. getSMSInfo() {
  371. if (this.smsserial != "") {
  372. $.get("/api/v1/sms/getbaseconfig", {
  373. serial: this.smsserial
  374. }).then(ret => {
  375. this.smsbaseconfig = ret;
  376. this.smsbaseconfig["RTSPPort"] = this.smsbaseconfig["RTSPPort"] || "";
  377. this.smsbaseconfig["RTMPPort"] = this.smsbaseconfig["RTMPPort"] || "";
  378. this.smsbaseconfig["PreSerial"] = this.smsserial;
  379. this.remoteSMSData = JSON.stringify(this.smsbaseconfig);
  380. })
  381. }
  382. },
  383. smschange() {
  384. this.getSMSInfo()
  385. }
  386. },
  387. computed: {
  388. ...mapState([
  389. "logoText",
  390. "logoMiniText",
  391. "menus",
  392. "serverInfo"
  393. ]),
  394. isBasicNoChange() {
  395. var localeData = JSON.stringify(this.getBasicCommitObject());
  396. return this.remoteBasicData.localeCompare(localeData) == 0;
  397. },
  398. isSMSNoChange() {
  399. this.smsbaseconfig["PreSerial"] = this.smsserial;
  400. var localeData = JSON.stringify(this.smsbaseconfig);
  401. return this.remoteSMSData.localeCompare(localeData) == 0;
  402. }
  403. }
  404. };
  405. </script>
  406. <style lang="less" scoped>
  407. .fa.cfg-black-list, .fa.cfg-white-list {
  408. font-size: 14px;
  409. line-height: 19px;
  410. display: inline-block;
  411. color: #606266;
  412. }
  413. </style>