Skip to content

Commit

Permalink
Remove referings to bing map #259 (#451)
Browse files Browse the repository at this point in the history
- Removes BingMapService (backend)
- Removes bingMapKey field in MapSettings model
- Removes front reference to bing map Key
  • Loading branch information
beesaferoot authored Dec 23, 2024
1 parent fe053be commit fa63d9e
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 132 deletions.
5 changes: 0 additions & 5 deletions src/backend/app/Exceptions/InvalidBingApiKeyException.php

This file was deleted.

18 changes: 3 additions & 15 deletions src/backend/app/Http/Controllers/MapSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,11 @@

namespace App\Http\Controllers;

use App\Exceptions\InvalidBingApiKeyException;
use App\Http\Resources\ApiResource;
use App\Models\MapSettings;
use App\Services\BingMapApiService;

class MapSettingsController extends Controller {
private $bingMapApiService;

public function __construct(BingMapApiService $bingMapApiService) {
$this->bingMapApiService = $bingMapApiService;
}
public function __construct() {}

public function index(): ApiResource {
return new ApiResource(MapSettings::all());
Expand All @@ -27,20 +21,14 @@ public function update($id): ApiResource {
'latitude' => request('latitude'),
'longitude' => request('longitude'),
'provider' => request('provider'),
'bingMapApiKey' => request('bingMapApiKey'),
]
);

return new ApiResource([$mapSettings->fresh()]);
}

// TODO: remove this method and associated route references when docs can be updated
public function checkBingApiKey($key): ApiResource {
try {
$apiAuthentication = $this->bingMapApiService->checkAuthenticationKey($key);
} catch (InvalidBingApiKeyException $exception) {
$apiAuthentication = false;
}

return ApiResource::make(['authentication' => $apiAuthentication]);
return ApiResource::make(['authentication' => '']);
}
}
39 changes: 0 additions & 39 deletions src/backend/app/Services/BingMapApiService.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public function up() {
$table->double('latitude', 10);
$table->double('longitude', 10);
$table->string('provider')->nullable();
$table->string('bingMapApiKey')->nullable();
$table->timestamps();
});

Expand Down
20 changes: 4 additions & 16 deletions src/frontend/src/mixins/mapSharing.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,10 @@ export const sharedMap = {
this.nonEditableLayer = new L.FeatureGroup()
},
setTileLayer() {
if (this.mapProvider) {
L.tileLayer
.bing(this.bingMapApiKey, {
maxZoom: this.maxZoom,
attribution: this.osmAttrib,
})
.addTo(this.map)
} else {
L.tileLayer(this.osmUrl, {
maxZoom: this.maxZoom,
attribution: this.osmAttrib,
}).addTo(this.map)
}
L.tileLayer(this.osmUrl, {
maxZoom: this.maxZoom,
attribution: this.osmAttrib,
}).addTo(this.map)
},
reGenerateMap(mutatingCenter) {
this.map.flyTo(mutatingCenter, this.zoom, this.drawingOptions)
Expand Down Expand Up @@ -182,9 +173,6 @@ export const sharedMap = {
mapProvider() {
return store.getters["settings/getMapSettings"].provider === "Bing Maps"
},
bingMapApiKey() {
return store.getters["settings/getMapSettings"].bingMapApiKey
},
},
watch: {
mutatingCenter() {
Expand Down
39 changes: 0 additions & 39 deletions src/frontend/src/modules/Settings/MapSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,6 @@
</md-select>
</md-field>
</div>
<div
class="md-layout-item md-size-34 md-small-size-100"
v-if="bingMapsProviderSelected"
>
<md-field :class="{ 'md-invalid': errors.has('Bing Api Key') }">
<label for="apiKey" class="bing-api-key">
Bing Map Api Key (Click
<b>
<a href="https://www.bingmapsportal.com/" target="_blank">here</a>
</b>
to get api key.)
</label>
<md-input
id="apiKey"
name="Bing Api Key"
v-model="mapSettingsService.mapSettings.bingMapApiKey"
v-validate="'required|min:3'"
></md-input>
<span class="md-error">
{{ errors.first("Bing Api Key") }}
</span>
</md-field>
</div>
<div class="md-layout-item md-size-100 md-small-size-100">
<md-subheader>Set Map Starting Points</md-subheader>
</div>
Expand Down Expand Up @@ -162,17 +139,6 @@ export default {
return
}
if (
this.bingMapsProviderSelected &&
!(await this.mapSettingsService.checkBingMapApiKey())
) {
this.alertNotify(
"error",
"Bing Map Api Key is wrong, please check again",
)
this.hideLoadingIndicator()
return
}
try {
await this.mapSettingsService.update()
this.updateMapSettingsStore()
Expand Down Expand Up @@ -223,11 +189,6 @@ export default {
this.mapKey++
},
},
computed: {
bingMapsProviderSelected() {
return this.mapSettingsService.mapSettings.provider === "Bing Maps"
},
},
}
</script>

Expand Down
3 changes: 0 additions & 3 deletions src/frontend/src/repositories/MapSettingsRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,4 @@ export default {
update(id, mapSettings) {
return Client.put(`${resource}/${id}`, mapSettings)
},
checkBingApiKey(key) {
return Client.get(`${resource}/key/${key}`)
},
}
14 changes: 0 additions & 14 deletions src/frontend/src/services/MapSettingsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export class MapSettingsService {
latitude: null,
longitude: null,
provider: null,
bingMapApiKey: null,
}
}

Expand All @@ -32,7 +31,6 @@ export class MapSettingsService {
latitude: this.mapSettings.latitude,
longitude: this.mapSettings.longitude,
provider: this.mapSettings.provider,
bingMapApiKey: this.mapSettings.bingMapApiKey,
}
let response = await this.repository.update(
mapSettingsPm.id,
Expand All @@ -49,25 +47,13 @@ export class MapSettingsService {
}
}

async checkBingMapApiKey() {
try {
const { data } = await this.repository.checkBingApiKey(
this.mapSettings.bingMapApiKey,
)
return data.data.authentication
} catch (error) {
return new ErrorHandler(error.response.data.message, "http")
}
}

fromJson(mapSettings) {
this.mapSettings = {
id: mapSettings.id,
zoom: mapSettings.zoom,
latitude: mapSettings.latitude,
longitude: mapSettings.longitude,
provider: mapSettings.provider,
bingMapApiKey: mapSettings.bingMapApiKey,
}
return this.mapSettings
}
Expand Down

0 comments on commit fa63d9e

Please sign in to comment.