Skip to content

Commit

Permalink
Merge pull request #56 from versx/guild-map-settings
Browse files Browse the repository at this point in the history
Map Settings per Guild
  • Loading branch information
versx authored Jun 1, 2021
2 parents 661ef22 + e8a5ceb commit 903e6c3
Show file tree
Hide file tree
Showing 18 changed files with 230 additions and 23 deletions.
13 changes: 8 additions & 5 deletions src/config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,21 @@
"roles": [
"000000000000000000"
],
"geofences": []
"geofences": [],
"startLat": 4,
"startLon": -100,
"startZoom": 11
},
{
"name": "Guild Name2",
"id": "222222222222222222",
"roles": [
"000000000000000000"
],
"geofences": []
"geofences": [],
"startLat": 5,
"startLon": -200,
"startZoom": 11
}
],
"userIdWhitelist": []
Expand All @@ -66,9 +72,6 @@
{ "name": "Shuffle" }
],
"map": {
"startLat": 4,
"startLon": -100,
"startZoom": 10,
"minZoom": 8,
"maxZoom": 18,
"tileserver": "https://{s}.basemaps.cartocdn.com/rastertiles/voyager_labels_under/{z}/{x}/{y}{r}.png;Map tiles by Carto, under CC BY 3.0. Data by <a href='https://www.openstreetmap.org/'>OpenStreetMap</a>, under ODbL."
Expand Down
3 changes: 0 additions & 3 deletions src/data/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ data.sizes = [
{ name: 'Big', value: 5, },
];
// Leaflet map properties
data.start_lat = config.map.startLat;
data.start_lon = config.map.startLon;
data.start_zoom = config.map.startZoom;
data.min_zoom = config.map.minZoom;
data.max_zoom = config.map.maxZoom;
data.tileserver = config.map.tileserver;
Expand Down
2 changes: 1 addition & 1 deletion src/models/subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Subscription.init({
status: {
type: DataTypes.SMALLINT(5).UNSIGNED,
require: true,
defaultValue: 0,
defaultValue: NotificationStatusType.All,
},
iconStyle: {
type: DataTypes.TEXT,
Expand Down
17 changes: 17 additions & 0 deletions src/routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,23 @@ router.post('/server/:guild_id/user/:user_id', async (req, res) => {
},
});
break;
case 'get_map_settings':
const guild = config.discord.guilds.find(x => x.id === guild_id);
if (!guild) {
// Failed to get guild map settings
return null;
}
res.json({
data: {
start_lat: guild.startLat,
start_lon: guild.startLon,
start_zoom: guild.startZoom,
min_zoom: config.map.minZoom,
max_zoom: config.map.maxZoom,
tileserver: config.map.tileserver,
},
});
break;
}
});

Expand Down
16 changes: 15 additions & 1 deletion src/views/invasions/edit.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,19 @@
if (guilds) {
guilds.forEach(guild => guild.hidden = false);
}
initMap([{{start_lat}}, {{start_lon}}], {{start_zoom}}, {{min_zoom}}, {{max_zoom}}, "{{{tileserver}}}", {{{cities}}});
$.ajax({
url: '/api/server/' + $('#server_selector').val() + '/user/{{user_id}}?type=get_map_settings',
method: 'POST',
type: 'json',
success: function(result) {
initMap(
[result.data.start_lat, result.data.start_lon],
result.data.start_zoom,
result.data.min_zoom,
result.data.max_zoom,
result.data.tileserver,
{{{cities}}}
);
},
});
</script>
15 changes: 14 additions & 1 deletion src/views/invasions/new.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,20 @@
if (guilds) {
guilds.forEach(guild => guild.hidden = false);
}
initMap([{{start_lat}}, {{start_lon}}], {{start_zoom}}, {{min_zoom}}, {{max_zoom}}, "{{{tileserver}}}");
$.ajax({
url: '/api/server/' + $('#server_selector').val() + '/user/{{user_id}}?type=get_map_settings',
method: 'POST',
type: 'json',
success: function(result) {
initMap(
[result.data.start_lat, result.data.start_lon],
result.data.start_zoom,
result.data.min_zoom,
result.data.max_zoom,
result.data.tileserver
);
},
});
fetchLocations($('#server_selector').val(), '{{user_id}}', function(result) {
for (const location of result.data.locations) {
Expand Down
17 changes: 16 additions & 1 deletion src/views/locations/edit.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,20 @@
<script type='text/javascript'>
$('#guild_id').val(guildId);
$('#server_selector').prop('disabled', true);
initMap([{{start_lat}}, {{start_lon}}], {{start_zoom}}, {{min_zoom}}, {{max_zoom}}, "{{{tileserver}}}", "{{location}}", "{{distance}}");
$.ajax({
url: '/api/server/' + $('#server_selector').val() + '/user/{{user_id}}?type=get_map_settings',
method: 'POST',
type: 'json',
success: function(result) {
initMap(
[result.data.start_lat, result.data.start_lon],
result.data.start_zoom,
result.data.min_zoom,
result.data.max_zoom,
result.data.tileserver,
"{{location}}",
"{{distance}}"
);
},
});
</script>
15 changes: 14 additions & 1 deletion src/views/locations/new.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,18 @@
<script type='text/javascript'>
$('#guild_id').val(guildId);
$('#server_selector').prop('disabled', true);
initMap([{{start_lat}}, {{start_lon}}], {{start_zoom}}, {{min_zoom}}, {{max_zoom}}, "{{{tileserver}}}");
$.ajax({
url: '/api/server/' + $('#server_selector').val() + '/user/{{user_id}}?type=get_map_settings',
method: 'POST',
type: 'json',
success: function(result) {
initMap(
[result.data.start_lat, result.data.start_lon],
result.data.start_zoom,
result.data.min_zoom,
result.data.max_zoom,
result.data.tileserver
);
},
});
</script>
16 changes: 15 additions & 1 deletion src/views/lures/edit.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,19 @@
if (guilds) {
guilds.forEach(guild => guild.hidden = false);
}
initMap([{{start_lat}}, {{start_lon}}], {{start_zoom}}, {{min_zoom}}, {{max_zoom}}, "{{{tileserver}}}", {{{cities}}});
$.ajax({
url: '/api/server/' + $('#server_selector').val() + '/user/{{user_id}}?type=get_map_settings',
method: 'POST',
type: 'json',
success: function(result) {
initMap(
[result.data.start_lat, result.data.start_lon],
result.data.start_zoom,
result.data.min_zoom,
result.data.max_zoom,
result.data.tileserver,
{{{cities}}}
);
},
});
</script>
15 changes: 14 additions & 1 deletion src/views/lures/new.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,20 @@
if (guilds) {
guilds.forEach(guild => guild.hidden = false);
}
initMap([{{start_lat}}, {{start_lon}}], {{start_zoom}}, {{min_zoom}}, {{max_zoom}}, "{{{tileserver}}}");
$.ajax({
url: '/api/server/' + $('#server_selector').val() + '/user/{{user_id}}?type=get_map_settings',
method: 'POST',
type: 'json',
success: function(result) {
initMap(
[result.data.start_lat, result.data.start_lon],
result.data.start_zoom,
result.data.min_zoom,
result.data.max_zoom,
result.data.tileserver
);
},
});
fetchLocations($('#server_selector').val(), '{{user_id}}', function(result) {
for (const location of result.data.locations) {
Expand Down
16 changes: 15 additions & 1 deletion src/views/pokemon/edit.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,19 @@
$('#iv_list').change(function() {
$('#iv').prop('disabled', this.value.length > 0);
});
initMap([{{start_lat}}, {{start_lon}}], {{start_zoom}}, {{min_zoom}}, {{max_zoom}}, "{{{tileserver}}}", {{{cities}}});
$.ajax({
url: '/api/server/' + $('#server_selector').val() + '/user/{{user_id}}?type=get_map_settings',
method: 'POST',
type: 'json',
success: function(result) {
initMap(
[result.data.start_lat, result.data.start_lon],
result.data.start_zoom,
result.data.min_zoom,
result.data.max_zoom,
result.data.tileserver,
{{{cities}}}
);
},
});
</script>
15 changes: 14 additions & 1 deletion src/views/pokemon/new.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,20 @@
$('#iv_list').change(function() {
$('#iv').prop('disabled', this.value.length > 0);
});
initMap([{{start_lat}}, {{start_lon}}], {{start_zoom}}, {{min_zoom}}, {{max_zoom}}, "{{{tileserver}}}");
$.ajax({
url: '/api/server/' + $('#server_selector').val() + '/user/{{user_id}}?type=get_map_settings',
method: 'POST',
type: 'json',
success: function(result) {
initMap(
[result.data.start_lat, result.data.start_lon],
result.data.start_zoom,
result.data.min_zoom,
result.data.max_zoom,
result.data.tileserver
);
},
});
fetchLocations($('#server_selector').val(), '{{user_id}}', function(result) {
for (const location of result.data.locations) {
Expand Down
16 changes: 15 additions & 1 deletion src/views/pvp/edit.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,19 @@
if (guilds) {
guilds.forEach(guild => guild.hidden = false);
}
initMap([{{start_lat}}, {{start_lon}}], {{start_zoom}}, {{min_zoom}}, {{max_zoom}}, "{{{tileserver}}}", {{{cities}}});
$.ajax({
url: '/api/server/' + $('#server_selector').val() + '/user/{{user_id}}?type=get_map_settings',
method: 'POST',
type: 'json',
success: function(result) {
initMap(
[result.data.start_lat, result.data.start_lon],
result.data.start_zoom,
result.data.min_zoom,
result.data.max_zoom,
result.data.tileserver,
{{{cities}}}
);
},
});
</script>
15 changes: 14 additions & 1 deletion src/views/pvp/new.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,20 @@
if (guilds) {
guilds.forEach(guild => guild.hidden = false);
}
initMap([{{start_lat}}, {{start_lon}}], {{start_zoom}}, {{min_zoom}}, {{max_zoom}}, "{{{tileserver}}}");
$.ajax({
url: '/api/server/' + $('#server_selector').val() + '/user/{{user_id}}?type=get_map_settings',
method: 'POST',
type: 'json',
success: function(result) {
initMap(
[result.data.start_lat, result.data.start_lon],
result.data.start_zoom,
result.data.min_zoom,
result.data.max_zoom,
result.data.tileserver
);
},
});
fetchLocations($('#server_selector').val(), '{{user_id}}', function(result) {
for (const location of result.data.locations) {
Expand Down
16 changes: 15 additions & 1 deletion src/views/quests/edit.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,19 @@
if (guilds) {
guilds.forEach(guild => guild.hidden = false);
}
initMap([{{start_lat}}, {{start_lon}}], {{start_zoom}}, {{min_zoom}}, {{max_zoom}}, "{{{tileserver}}}", {{{cities}}});
$.ajax({
url: '/api/server/' + $('#server_selector').val() + '/user/{{user_id}}?type=get_map_settings',
method: 'POST',
type: 'json',
success: function(result) {
initMap(
[result.data.start_lat, result.data.start_lon],
result.data.start_zoom,
result.data.min_zoom,
result.data.max_zoom,
result.data.tileserver,
{{{cities}}}
);
},
});
</script>
15 changes: 14 additions & 1 deletion src/views/quests/new.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,20 @@
if (guilds) {
guilds.forEach(guild => guild.hidden = false);
}
initMap([{{start_lat}}, {{start_lon}}], {{start_zoom}}, {{min_zoom}}, {{max_zoom}}, "{{{tileserver}}}");
$.ajax({
url: '/api/server/' + $('#server_selector').val() + '/user/{{user_id}}?type=get_map_settings',
method: 'POST',
type: 'json',
success: function(result) {
initMap(
[result.data.start_lat, result.data.start_lon],
result.data.start_zoom,
result.data.min_zoom,
result.data.max_zoom,
result.data.tileserver
);
},
});
fetchLocations($('#server_selector').val(), '{{user_id}}', function(result) {
for (const location of result.data.locations) {
Expand Down
16 changes: 15 additions & 1 deletion src/views/raids/edit.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,19 @@
if (guilds) {
guilds.forEach(guild => guild.hidden = false);
}
initMap([{{start_lat}}, {{start_lon}}], {{start_zoom}}, {{min_zoom}}, {{max_zoom}}, "{{{tileserver}}}", {{{cities}}});
$.ajax({
url: '/api/server/' + $('#server_selector').val() + '/user/{{user_id}}?type=get_map_settings',
method: 'POST',
type: 'json',
success: function(result) {
initMap(
[result.data.start_lat, result.data.start_lon],
result.data.start_zoom,
result.data.min_zoom,
result.data.max_zoom,
result.data.tileserver,
{{{cities}}}
);
},
});
</script>
15 changes: 14 additions & 1 deletion src/views/raids/new.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,20 @@
if (guilds) {
guilds.forEach(guild => guild.hidden = false);
}
initMap([{{start_lat}}, {{start_lon}}], {{start_zoom}}, {{min_zoom}}, {{max_zoom}}, "{{{tileserver}}}");
$.ajax({
url: '/api/server/' + $('#server_selector').val() + '/user/{{user_id}}?type=get_map_settings',
method: 'POST',
type: 'json',
success: function(result) {
initMap(
[result.data.start_lat, result.data.start_lon],
result.data.start_zoom,
result.data.min_zoom,
result.data.max_zoom,
result.data.tileserver
);
},
});
fetchLocations($('#server_selector').val(), '{{user_id}}', function(result) {
for (const location of result.data.locations) {
Expand Down

0 comments on commit 903e6c3

Please sign in to comment.