Skip to content

Commit 10127a2

Browse files
authored
Merge pull request #28 from Ecotrust/merge2025
Portal Sync - Merge 2025
2 parents a495514 + 22602b0 commit 10127a2

15 files changed

Lines changed: 427 additions & 150 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ mp_visualize.egg-info
22
*.pyc
33
.DS_Store
44
.idea
5+
Icon*
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Generated by Django 4.2 on 2024-02-28 18:46
2+
3+
from django.conf import settings
4+
from django.db import migrations, models
5+
import django.db.models.deletion
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('contenttypes', '0002_remove_content_type_name'),
12+
('auth', '0012_alter_user_first_name_max_length'),
13+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
14+
('visualize', '0011_auto_20221102_1744'),
15+
]
16+
17+
operations = [
18+
migrations.AlterField(
19+
model_name='bookmark',
20+
name='content_type',
21+
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(app_label)s_%(class)s_related', to='contenttypes.contenttype'),
22+
),
23+
migrations.AlterField(
24+
model_name='bookmark',
25+
name='sharing_groups',
26+
field=models.ManyToManyField(blank=True, editable=False, related_name='%(app_label)s_%(class)s_related', to='auth.group', verbose_name='Share with the following groups'),
27+
),
28+
migrations.AlterField(
29+
model_name='bookmark',
30+
name='user',
31+
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(app_label)s_%(class)s_related', to=settings.AUTH_USER_MODEL),
32+
),
33+
migrations.AlterField(
34+
model_name='userlayer',
35+
name='content_type',
36+
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(app_label)s_%(class)s_related', to='contenttypes.contenttype'),
37+
),
38+
migrations.AlterField(
39+
model_name='userlayer',
40+
name='sharing_groups',
41+
field=models.ManyToManyField(blank=True, editable=False, related_name='%(app_label)s_%(class)s_related', to='auth.group', verbose_name='Share with the following groups'),
42+
),
43+
migrations.AlterField(
44+
model_name='userlayer',
45+
name='user',
46+
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(app_label)s_%(class)s_related', to=settings.AUTH_USER_MODEL),
47+
),
48+
]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Generated by Django 4.2 on 2024-04-11 21:35
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('visualize', '0012_alter_bookmark_content_type_and_more'),
10+
('visualize', '0012_userlayer_password_protected'),
11+
]
12+
13+
operations = [
14+
]

visualize/static/assets/openlayers/ol8/ol.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

visualize/static/js/bookmarks.js

Lines changed: 55 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,17 @@ function bookmarksModel(options) {
159159

160160
self.getCurrentBookmarkURL = function() {
161161
if ( self.sharingBookmark() ) {
162-
self.shrinkBookmarkURL(true);
163-
return self.useShortBookmarkURL();
164-
// return self.sharingBookmark().getBookmarkUrl();
162+
if (self.shrinkBookmarkURL()) {
163+
// If "Short URL" is checked, get the shortened URL
164+
self.useShortBookmarkURL(); // This will update currentBookmarkURL with the shortened URL
165+
} else {
166+
// If "Short URL" is unchecked, use the long URL
167+
self.currentBookmarkURL(self.sharingBookmark().getBookmarkUrl());
168+
}
165169
} else {
166-
return '';
170+
self.currentBookmarkURL('');
167171
}
172+
return self.currentBookmarkURL();
168173
};
169174

170175
self.shrinkBookmarkURL = ko.observable(true);
@@ -195,33 +200,56 @@ function bookmarksModel(options) {
195200
};
196201

197202
self.useShortBookmarkURL = function() {
198-
var bitly_access_token = '227d50a9d70140483b003a70b1f449e00514c053';
199-
long_url = self.sharingBookmark().getBookmarkUrl();
200-
params = {
201-
"group_guid": "Bec5n80dm93",
202-
"domain": "bit.ly",
203-
"long_url": long_url
204-
};
203+
// var bitly_access_token = '227d50a9d70140483b003a70b1f449e00514c053';
204+
// long_url = self.sharingBookmark().getBookmarkUrl();
205+
// params = {
206+
// "group_guid": "Bec5n80dm93",
207+
// "domain": "bit.ly",
208+
// "long_url": long_url
209+
// };
210+
211+
// $.ajax({
212+
// type: "POST",
213+
// url: "https://api-ssl.bitly.com/v4/shorten",
214+
// data: JSON.stringify(params),
215+
// success: function(response){
216+
// if (response.link != undefined) {
217+
// $('.in #short-url')[0].value = response.link;
218+
// } else {
219+
// $('.in #short-url')[0].value = long_url;
220+
// }
221+
// },
222+
// dataType: 'json',
223+
// contentType: "application/json",
224+
// beforeSend: function(xhr){
225+
// xhr.setRequestHeader("Authorization", "Bearer " + bitly_access_token);
226+
// }
227+
// });
228+
var long_url = self.sharingBookmark().getBookmarkUrl();
229+
230+
var params = {
231+
"url": long_url,
232+
"csrfmiddlewaretoken": $('input[name="csrfmiddlewaretoken"]').val() // Including CSRF token for Django's CSRF protection
233+
}
205234

206235
$.ajax({
207-
type: "POST",
208-
url: "https://api-ssl.bitly.com/v4/shorten",
209-
data: JSON.stringify(params),
210-
success: function(response){
211-
if (response.link != undefined) {
212-
$('.in #short-url')[0].value = response.link;
213-
} else {
214-
$('.in #short-url')[0].value = long_url;
215-
}
216-
},
217-
dataType: 'json',
218-
contentType: "application/json",
219-
beforeSend: function(xhr){
220-
xhr.setRequestHeader("Authorization", "Bearer " + bitly_access_token);
221-
}
236+
type: "POST",
237+
url: "/url_shortener/",
238+
data: params,
239+
success: function(response) {
240+
console.log(response)
241+
if (response.shortened_url != undefined) {
242+
self.currentBookmarkURL(response.shortened_url); // Set the value directly
243+
}
244+
},
245+
error: function(xhr, status, error) {
246+
console.log("Error shortening URL:", error);
247+
},
248+
dataType: 'json',
249+
contentType: "application/x-www-form-urlencoded", // Use URL encoding for the data
222250
});
223251
};
224-
252+
self.currentBookmarkURL = ko.observable('');
225253
self.setBookmarkIFrameHTML = function() {
226254
var bookmarkState = self.sharingBookmark().getBookmarkHash();
227255
$('.in #bookmark-iframe-html')[0].value = app.viewModel.mapLinks.getIFrameHTML(bookmarkState);

visualize/static/js/map.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ app.addLayerToMap = function(layer) {
559559
app.addWmsLayerToMap(layer);
560560
} else if (layer.type === 'VectorTile') {
561561
app.addVectorTileLayerToMap(layer);
562-
} else if (layer.type === 'XYZ'){ //if XYZ with no utfgrid
562+
} else if (layer.type === 'XYZ' || layer.type === "slider"){ //if XYZ with no utfgrid
563563
app.addXyzLayerToMap(layer);
564564
}
565565
}

0 commit comments

Comments
 (0)