Skip to content

Commit

Permalink
Merge pull request roundware#286 from hburgund/feature/map-updates
Browse files Browse the repository at this point in the history
Tool updates - Listen Map and Asset Edit Map
  • Loading branch information
hburgund committed May 23, 2016
2 parents db3a02d + c114fa1 commit fadb34d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
9 changes: 8 additions & 1 deletion roundware/api1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import django_filters
from django.http import HttpResponse
from distutils.util import strtobool
from rest_framework import generics
from rest_framework.renderers import JSONRenderer
from rest_framework.views import APIView
Expand All @@ -28,6 +29,8 @@
import logging
logger = logging.getLogger(__name__)

BOOLEAN_CHOICES = (('false', False), ('true', True),
(0, False), (1, True),)

def operations(request):
returned_data = catch_errors(request)
Expand Down Expand Up @@ -115,12 +118,15 @@ def get(self, request, format=None):

class AssetFilter(django_filters.FilterSet):
mediatype__contains = django_filters.CharFilter(name='mediatype', lookup_type='startswith')

submitted = django_filters.TypedChoiceFilter(choices=BOOLEAN_CHOICES, coerce=strtobool)
created__gte = django_filters.DateTimeFilter(name='created', lookup_type='gte')
created__lte = django_filters.DateTimeFilter(name='created', lookup_type='lte')
created__range = django_filters.DateRangeFilter(name='created')
audiolength__lte = django_filters.NumberFilter('audiolength', lookup_type='lte')
audiolength__gte = django_filters.NumberFilter('audiolength', lookup_type='gte')
id = django_filters.NumberFilter()
id__lte = django_filters.NumberFilter('id', lookup_type='lte')
id__gte = django_filters.NumberFilter('id', lookup_type='gte')

class Meta:
model = Asset
Expand All @@ -130,6 +136,7 @@ class Meta:
'project',
'language',
'session',
'id',
]


Expand Down
13 changes: 7 additions & 6 deletions roundware/rw/static/tools/js/listen-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if (!Roundware) {
*/
Roundware.ListenMap = function (opts) {
var options = $.extend({}, {
url: 'http://rwdev.dyndns.org/roundware/',
url: 'http://roundware.dyndns.org/api/1/',
}, opts);


Expand Down Expand Up @@ -60,8 +60,8 @@ Roundware.ListenMap = function (opts) {
* main_callback(), which loops through the methods of RW.workflow to retrieve
* the data and display it.
*
* @param string m_url: URL of the roundware server, e.g. http://siswh.dyndns.org/roundware/
* @param int m_project_id: project PK on the roundware server
* @param string m_url: URL of the roundware server, e.g. http://roundware.dyndns.org/api/1/
* @param int m_project_id: project PK on the Roundware server
* @param google.maps.Map m_map: a Google Map
*/
this.main = function (m_project_id, m_map) {
Expand Down Expand Up @@ -369,9 +369,8 @@ Roundware.ListenMap = function (opts) {
});
});

var fnmp3 = "http://scapesaudio.dyndns.org:8090" + item.asset_url.replace("wav", "mp3");
var fnmp3 = item.asset_url.replace("wav", "mp3");
var id = item.asset_id;
// $wavfilename = substr($wavfilename, 0, strlen($wavfilename)-3) . 'wav';
var iw = create_info_window(item.asset_id, desc.join(' '), fnmp3, item.asset_url, id);
var marker = create_marker(item, iw, 'blue');
var radius = config.project.recording_radius || 5;
Expand Down Expand Up @@ -455,12 +454,14 @@ Roundware.ListenMap = function (opts) {
*/
function add_listening_pin() {
var marker_img = new google.maps.MarkerImage('http://www.google.com/intl/en_us/mapfiles/ms/micons/green-dot.png');
var mapCenter = new google.maps.LatLng(config.project.latitude, config.project.longitude);
listening_pin = new google.maps.Marker({
position: map.getCenter(),
position: mapCenter,
map: map,
icon: marker_img,
draggable: true
});
map.setCenter(mapCenter);

google.maps.event.addListener(listening_pin, "dragend", function (event) {
modify_stream();
Expand Down
16 changes: 15 additions & 1 deletion roundware/rw/templates/tools/asset-map.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,14 @@ <h1>Loading data... please be patient. </h1>

var points = [];

var project = getUrlVars()["project"];
var project = getUrlVars()["project_id"];
var id = getUrlVars()["asset_id"];
var id__gte = getUrlVars()["asset__gte"];
var id__lte = getUrlVars()["asset__lte"];
var audiolength__gte = getUrlVars()["audiolength__gte"];
var audiolength__lte = getUrlVars()["audiolength__lte"];
var submitted = getUrlVars()["submitted"] ? getUrlVars()["submitted"] : 'true';
var mediatype = getUrlVars()["mediatype"] ? getUrlVars()["mediatype"] : 'audio';

$.ajax({
url: url,
Expand All @@ -141,6 +148,13 @@ <h1>Loading data... please be patient. </h1>
data: {
format: "json",
project: project,
id: id,
id__gte: id__gte,
id__lte: id__lte,
audiolength__gte: audiolength__gte,
audiolength__lte: audiolength__lte,
submitted: submitted,
mediatype: mediatype,
limit: 0
},
dataType: "json",
Expand Down
11 changes: 9 additions & 2 deletions roundware/rw/templates/tools/listen-map.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ <h1>Loading data... please be patient. </h1>
<script type="text/javascript">
// Roundware Island
var centerLat = 1;
var centerLon = .7;
var centerLon = 1;

var project = location.search.split('project_id=')[1] ? location.search.split('project_id=')[1] : '1';

Expand All @@ -134,7 +134,14 @@ <h1>Loading data... please be patient. </h1>

var demoMap = new google.maps.Map(document.getElementById("voicemap-block"), myOptions);

var lm = new Roundware.ListenMap({url: window.location.protocol + '//' + window.location.hostname + ":8888/api/1/"});
// add port 8888 if using on localhost in Vagrant VM
if (window.location.hostname == 'localhost') {
var lm_url = window.location.protocol + '//' + window.location.hostname + ":8888/api/1/";
}
else {
var lm_url = window.location.protocol + '//' + window.location.hostname + "/api/1/";
}
var lm = new Roundware.ListenMap({url: lm_url});
lm.main(project, demoMap);

});
Expand Down

0 comments on commit fadb34d

Please sign in to comment.