MediaServer.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import axios from 'axios';
  2. class MediaServer{
  3. constructor() {
  4. this.$axios = axios;
  5. }
  6. getOnlineMediaServerList(callback){
  7. this.$axios({
  8. method: 'get',
  9. url:`/api/server/media_server/online/list`,
  10. }).then(function (res) {
  11. if (typeof (callback) == "function") callback(res.data)
  12. }).catch(function (error) {
  13. console.log(error);
  14. });
  15. }
  16. getMediaServerList(callback){
  17. this.$axios({
  18. method: 'get',
  19. url:`/api/server/media_server/list`,
  20. }).then(function (res) {
  21. if (typeof (callback) == "function") callback(res.data)
  22. }).catch(function (error) {
  23. console.log(error);
  24. });
  25. }
  26. getMediaServer(id, callback){
  27. this.$axios({
  28. method: 'get',
  29. url:`/api/server/media_server/one/` + id,
  30. }).then(function (res) {
  31. if (typeof (callback) == "function") callback(res.data)
  32. }).catch(function (error) {
  33. console.log(error);
  34. });
  35. }
  36. checkServer(param, callback){
  37. this.$axios({
  38. method: 'get',
  39. url:`/api/server/media_server/check`,
  40. params: {
  41. ip: param.ip,
  42. port: param.httpPort,
  43. secret: param.secret
  44. }
  45. }).then(function (res) {
  46. if (typeof (callback) == "function") callback(res.data)
  47. }).catch(function (error) {
  48. console.log(error);
  49. });
  50. }
  51. checkRecordServer(param, callback){
  52. this.$axios({
  53. method: 'get',
  54. url:`/api/server/media_server/record/check`,
  55. params: {
  56. ip: param.ip,
  57. port: param.recordAssistPort
  58. }
  59. }).then(function (res) {
  60. if (typeof (callback) == "function") callback(res.data)
  61. }).catch(function (error) {
  62. console.log(error);
  63. });
  64. }
  65. addServer(param, callback){
  66. this.$axios({
  67. method: 'post',
  68. url:`/api/server/media_server/save`,
  69. data: param
  70. }).then(function (res) {
  71. if (typeof (callback) == "function") callback(res.data)
  72. }).catch(function (error) {
  73. console.log(error);
  74. });
  75. }
  76. delete(id, callback) {
  77. this.$axios({
  78. method: 'delete',
  79. url:`/api/server/media_server/delete`,
  80. params: {
  81. id: id
  82. }
  83. }).then(function (res) {
  84. if (typeof (callback) == "function") callback(res.data)
  85. }).catch(function (error) {
  86. console.log(error);
  87. });
  88. }
  89. }
  90. export default MediaServer;