Alex Tran 1 anno fa
parent
commit
2d489b33e3

+ 23 - 2
web/src/lib/components/admin-page/settings/map-settings/map-settings.svelte

@@ -29,6 +29,9 @@
   async function saveSetting() {
     try {
       const { data: current } = await api.systemConfigApi.getConfig();
+      console.log('current', current.reverseGeocoding);
+
+      console.log('update', config.reverseGeocoding.useMapbox);
       const { data: updated } = await api.systemConfigApi.updateConfig({
         systemConfigDto: {
           ...current,
@@ -40,6 +43,8 @@
           reverseGeocoding: {
             enabled: config.reverseGeocoding.enabled,
             citiesFileOverride: config.reverseGeocoding.citiesFileOverride,
+            useMapbox: config.reverseGeocoding.useMapbox,
+            mapboxAccessToken: config.reverseGeocoding.mapboxAccessToken,
           },
         },
       });
@@ -149,8 +154,24 @@
                 isEdited={config.reverseGeocoding.citiesFileOverride !==
                   savedConfig.reverseGeocoding.citiesFileOverride}
               />
-            </div></SettingAccordion
-          >
+              <SettingSwitch
+                title="Use Mapbox"
+                {disabled}
+                subtitle="Use Mapbox for reverse geocoding"
+                bind:checked={config.reverseGeocoding.useMapbox}
+              />
+
+              <SettingInputField
+                inputType={SettingInputFieldType.TEXT}
+                label="URL"
+                desc="URL of the machine learning server"
+                bind:value={config.reverseGeocoding.mapboxAccessToken}
+                required={true}
+                disabled={disabled || !config.reverseGeocoding.useMapbox}
+                isEdited={config.reverseGeocoding.mapboxAccessToken !== savedConfig.reverseGeocoding.mapboxAccessToken}
+              />
+            </div>
+          </SettingAccordion>
 
           <SettingButtonsRow
             on:reset={reset}