From 9669e1c8683244943f1f6dea9b0f0a6252ebd1f6 Mon Sep 17 00:00:00 2001
From: hiendc <hiendc@snine.vn>
Date: Thu, 8 Aug 2024 15:53:00 +0700
Subject: [PATCH] Can't load js here

---
 .gitignore                                 |  2 ++
 s_attendance/controllers/attendance_api.py |  5 -----
 s_attendance/static/src/js/here_map.js     | 18 +++---------------
 3 files changed, 5 insertions(+), 20 deletions(-)

diff --git a/.gitignore b/.gitignore
index 11a8ec3..ec05cb9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -49,3 +49,5 @@ package.json
 /man/
 /share/
 /src/
+
+/s_attendance/static/src/js/config.js
diff --git a/s_attendance/controllers/attendance_api.py b/s_attendance/controllers/attendance_api.py
index 043aab3..3d43104 100644
--- a/s_attendance/controllers/attendance_api.py
+++ b/s_attendance/controllers/attendance_api.py
@@ -170,8 +170,3 @@ class TimeKeepingAttendance(odoo.http.Controller):
         if employee_ids and onsite_id and onsite_id.employee_id.id in employee_ids.ids:
             return onsite_id, onsite_id.employee_id
         return None
-
-    @route('/get_api_key', type='http', auth='public', cors='*')
-    def get_api_key(self):
-        api_key = request.env['ir.config_parameter'].sudo().get_param('s_attendance.revgeocode_key')
-        return json.dumps({'api_key': api_key})
diff --git a/s_attendance/static/src/js/here_map.js b/s_attendance/static/src/js/here_map.js
index d74d781..2eeed97 100644
--- a/s_attendance/static/src/js/here_map.js
+++ b/s_attendance/static/src/js/here_map.js
@@ -1,16 +1,4 @@
-async function getApiKey() {
-    try {
-        const baseUrl = window.location.origin;
-        const response = await fetch(`${baseUrl}/get_api_key`, {
-            method: 'GET',
-            headers: {'Content-Type': 'application/json',},
-        });
-        const data = await response.json();
-        return data.api_key;
-    } catch (error) {
-        console.error('Error fetching API key:', error);
-    }
-}
+const apiKey = require('./config.js');
 
 function getQueryParameter(name) {
     const urlParams = new URLSearchParams(window.location.search);
@@ -69,7 +57,7 @@ function addDraggableMarker(map, behavior) {
 }
 
 var platform = new H.service.Platform({
-    apikey: getApiKey(),
+    apikey: apiKey,
 });
 
 var defaultLayers = platform.createDefaultLayers();
@@ -79,7 +67,7 @@ var map = new H.Map(
     defaultLayers.vector.normal.map,
     {
         center: { lat: lat, lng: lng },
-        zoom: 12,
+        zoom: 25,
         pixelRatio: window.devicePixelRatio || 1,
     }
 );
-- 
GitLab