log.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { get } from "../config/request";
  2. import axios from "@/config/axios";
  3. import ip from "ip";
  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. const res = await axios.post("/log", { os: osValue(), ipv4: ip.address("public", "ipv4"), ...data }, { headers: { Authorization: token } });
  44. return res.data;
  45. };
  46. export const getLogAdmin = async (token) => {
  47. try {
  48. const res = await axios.get(`/log`, { headers: { Authorization: token } });
  49. return res.data;
  50. } catch (error) {
  51. console.log("error", error);
  52. return false;
  53. }
  54. };