Skip to content

Commit

Permalink
construct urls properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark committed Jun 5, 2014
1 parent 13416b7 commit 5017d7a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 27 deletions.
2 changes: 1 addition & 1 deletion build.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {
},
configFile: appConfigFile,
development: {
apiRoot: "http://staging.ecosounds.org",
apiRoot: "http://localhost:3000",
siteRoot: "http://localhost:8080",
siteDir: "/"
},
Expand Down
4 changes: 2 additions & 2 deletions src/app/annotationLibrary/annotationItem.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ <h3 class="panel-title pull-left">Details</h3>
<div class="panel-body">
<div class="list-group">
<a data-ng-repeat="tag in annotation.tags"
data-ng-href="{{$parent.createFilterUrl({'tagsPartial': tag.text})}}"
data-ng-href="{{tag.similarPartial}}"
class="list-group-item" title="Tag.">
<span class="glyphicon glyphicon-tags"></span>&nbsp;
<span class="badge">{{tag.typeOfTag.replace('_',' ')}}</span>
Expand All @@ -55,7 +55,7 @@ <h3 class="panel-title pull-left">Details</h3>
{{tag.text}} (ID {{tag.id}})
</a>
<a data-ng-show="annotation.isReference"
data-ng-href="{{$parent.createFilterUrl({'reference': annotation.isReference})}}"
data-ng-href="{{annotation.urls.isReference}}"
class="list-group-item" title="Reference tag.">
<span class="glyphicon glyphicon-book"></span>&nbsp;
Reference Tag
Expand Down
59 changes: 35 additions & 24 deletions src/app/annotationLibrary/annotationLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,25 @@ baw.annotationLibrary.addCalculatedProperties = function addCalculatedProperties
audioEvent.calcOffsetStart = Math.floor(audioEvent.startTimeSeconds / 30) * 30;
audioEvent.calcOffsetEnd = (Math.floor(audioEvent.startTimeSeconds / 30) * 30) + 30;

var roundedDuration = Math.round10(audioEvent.annotationDuration, -3);
var roundedFreqLow = Math.round(audioEvent.lowFrequencyHertz);
var roundedFreqHigh = Math.round(audioEvent.highFrequencyHertz);

audioEvent.urls = {
site: $url.formatUri(paths.api.links.siteAbsolute, {projectId: audioEvent.projects[0].id, siteId: audioEvent.siteId}),
user: $url.formatUri(paths.api.links.userAccountsAbsolute, {userId: audioEvent.ownerId}),
tagSearch: $url.formatUri(paths.site.ngRoutes.libraryAbsolute, {tagsPartial: audioEvent.priorityTag.text}),
isReference: $url.formatUri(paths.site.ngRoutes.libraryAbsolute, {reference: audioEvent.isReference}),
similar: $url.formatUri(paths.site.ngRoutes.libraryAbsolute,
{
annotationDuration: Math.round10(audioEvent.annotationDuration, -3),
freqMin: Math.round(audioEvent.lowFrequencyHertz),
freqMax: Math.round(audioEvent.highFrequencyHertz)
<<<<<<< HEAD
annotationDuration: roundedDuration,
freqMin: roundedFreqLow,
freqMax: roundedFreqHigh
}),
singleItem: $url.formatUri(paths.site.ngRoutes.libraryItemAbsolute,
{
recordingId: audioEvent.audioRecordingId,
audioEventId: audioEvent.audioEventId
audioEventId: audioEvent.audioEventId
}),
listen: $url.formatUri(paths.site.ngRoutes.listenAbsolute,
{
Expand All @@ -37,20 +41,27 @@ baw.annotationLibrary.addCalculatedProperties = function addCalculatedProperties
start: audioEvent.startTimeSeconds,
end: audioEvent.endTimeSeconds
})
=======
}, true),
singleItem: '/library/' + audioEvent.audioRecordingId +
'/audio_events/' + audioEvent.audioEventId,
listen: '/listen/' + audioEvent.audioRecordingId +
'?start=' + audioEvent.calcOffsetStart +
'&end=' + audioEvent.calcOffsetEnd,
listenWithoutPadding: '/listen/' + audioEvent.audioRecordingId +
'?start=' + audioEvent.startTimeSeconds +
'&end=' + audioEvent.endTimeSeconds,
audioRecording: '/library?' + $url.toKeyValue({audioRecordingId: audioEvent.audioRecordingId}, true)
>>>>>>> db959993d22e1447b68a2dbab09da28a1f535c88
};

audioEvent.tags.forEach(
function (currentvalue, index, array) {
currentvalue.similarPartial = $url.formatUri(paths.site.ngRoutes.libraryAbsolute,
{
tagsPartial: currentvalue.text,
annotationDuration: roundedDuration,
freqMin: roundedFreqLow,
freqMax: roundedFreqHigh
});
}
);

audioEvent.projects.forEach(
function (currentvalue, index, array) {
currentvalue.link = $url.formatUri(paths.api.links.projectAbsolute, {projectId: currentvalue.id});
}
);


return audioEvent;
};

Expand Down Expand Up @@ -166,7 +177,7 @@ angular.module('bawApp.annotationLibrary', ['bawApp.configuration'])


$scope.createFilterUrl = function createFilterUrl(paramObj) {
return $url.formatUri(paths.site.ngRoutes.libraryAbsolute,paramObj);
return $url.formatUri(paths.site.ngRoutes.libraryAbsolute, paramObj);
};

function getEmptyFilterSettings() {
Expand Down Expand Up @@ -326,7 +337,7 @@ angular.module('bawApp.annotationLibrary', ['bawApp.configuration'])
id: null,
text: null,
errors: []
};
};

AudioEvent.get(parameters,
function annotationShowSuccess(audioEventValue, responseHeaders) {
Expand Down Expand Up @@ -368,10 +379,10 @@ angular.module('bawApp.annotationLibrary', ['bawApp.configuration'])
});

$scope.createFilterUrl = function createFilterUrl(paramObj) {
return $url.formatUri(paths.site.ngRoutes.libraryAbsolute,paramObj);
return $url.formatUri(paths.site.ngRoutes.libraryAbsolute, paramObj);
};

$scope.createProjectUrl = function createProjectUrl(projectId){
$scope.createProjectUrl = function createProjectUrl(projectId) {
return $url.formatUri(paths.api.links.projectAbsolute, {projectId: projectId});
};

Expand All @@ -380,7 +391,7 @@ angular.module('bawApp.annotationLibrary', ['bawApp.configuration'])
$routeParams.audioEventId + '#' + audioEventCommentId
};

$scope.formatTimeAgo = function formatTimeAgo(time, formatString){
$scope.formatTimeAgo = function formatTimeAgo(time, formatString) {
return moment(time, formatString).fromNow();
};

Expand Down Expand Up @@ -422,7 +433,7 @@ angular.module('bawApp.annotationLibrary', ['bawApp.configuration'])
}
};

$scope.updateComment = function updateComment(audioEventCommentId){
$scope.updateComment = function updateComment(audioEventCommentId) {
AudioEventComment.update(
{
audioEventId: $routeParams.audioEventId,
Expand All @@ -442,7 +453,7 @@ angular.module('bawApp.annotationLibrary', ['bawApp.configuration'])
});
};

$scope.editComment = function editComment(commentText, audioEventCommentId){
$scope.editComment = function editComment(commentText, audioEventCommentId) {
$scope.editComment.id = audioEventCommentId;
$scope.editComment.text = commentText;
};
Expand Down

0 comments on commit 5017d7a

Please sign in to comment.