log.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { get } from "../config/request";
  2. import axios from "@/config/axios";
  3. import axios2 from "axios";
  4. import osValue from "../utils/osValue";
  5. export const getLog = async (token, laporan_id) => {
  6. try {
  7. let url = `/pemantauan/${laporan_id}`;
  8. const res = await axios.get(url, {
  9. headers: {
  10. Authorization: token,
  11. },
  12. });
  13. return res.data;
  14. } catch (error) {
  15. console.log("error", error);
  16. return false;
  17. }
  18. };
  19. export const getLogPT = async (token) => {
  20. try {
  21. let url = `/pemantauan/pt`;
  22. const res = await axios.get(url, {
  23. headers: {
  24. Authorization: token,
  25. },
  26. });
  27. return res.data;
  28. } catch (error) {
  29. console.log("error", error);
  30. return false;
  31. }
  32. };
  33. export const getLogPublic = async ({ no_hp, no_laporan }) => {
  34. try {
  35. const res = await axios.get(`/public/pemantauan?no_hp=${no_hp}&no_laporan=${no_laporan}`);
  36. return res.data;
  37. } catch (error) {
  38. console.log("error", error);
  39. return false;
  40. }
  41. };
  42. export const createLog = async (token, data) => {
  43. try {
  44. const jsonip = await axios2.get("https://jsonip.com", { mode: "cors" });
  45. const res = await axios.post("/log", { os: window.navigator.platform, ipv4: jsonip.data.ip, ...data }, { headers: { Authorization: token } });
  46. return res.data;
  47. } catch (error) {
  48. console.log("error", error);
  49. return false;
  50. }
  51. };
  52. export const getLogAdmin = async (token) => {
  53. try {
  54. const res = await axios.get(`/log`, { headers: { Authorization: token } });
  55. return res.data;
  56. } catch (error) {
  57. console.log("error", error);
  58. return false;
  59. }
  60. };