Skip to content

Commit

Permalink
Annotation library work
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Cottman-Fields committed Feb 14, 2014
1 parent f517a8d commit db78ee9
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 21 deletions.
48 changes: 31 additions & 17 deletions src/app/annotationLibrary/annotationLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,40 @@ angular.module('bawApp.annotationLibrary', ['bawApp.configuration'])
function ($scope, $location, $resource, $routeParams, AudioEvent) {

$scope.filterSettings = {
tagsPartial: $routeParams.tagsPartial,
reference: $routeParams.reference,
duration: $routeParams.duration,
freqMin: $routeParams.freqMin,
freqMax: $routeParams.freqMax,
page: $routeParams.page,
items: $routeParams.items
tagsPartial: null,
reference: null,
annotationDuration: null,
freqMin: null,
freqMax: null,
page: null,
items: null
};

$scope.setFilter = function setFilter() {
// update the url from the filter settings
var newUrl = '/library?' + baw.angularCopies.toKeyValue($scope.filterSettings);
if ($scope.filterSettings.tagsPartial !== undefined) {
newUrl = newUrl + '&tags_partial=' + $scope.filterSettings.tagsPartial;
}
console.log(newUrl);
//$location.path(newUrl);
// get the results from the server
$location.path('/library').search($scope.createQuery($scope.filterSettings));
};
$scope.loadFilter = function loadFilter() {
$scope.filterSettings = $scope.createQuery($routeParams);
$scope.library = AudioEvent.library($scope.filterSettings);
};

$scope.setFilter();
$scope.createQuery = function createQuery(params) {
var hash = {};
for (var key in params) {
if (params.hasOwnProperty(key)) {
var value = params[key];
if (value !== undefined && value !== null && (typeof(value) === "string" ? value.length > 0 : true)) {
hash[key] = value;
}
}
}
console.log(hash);
return hash;
};
$scope.calcOffsetStart = function calcOffsetStart(startOffset) {
return Math.floor(startOffset / 30) * 30;
};
$scope.calcOffsetEnd = function calcOffsetEnd(startOffset) {
return (Math.floor(startOffset / 30) * 30) + 30;
};
$scope.loadFilter();
}]);
9 changes: 5 additions & 4 deletions src/app/annotationLibrary/annotationLibrary.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h1>Annotation Library</h1>

<div class="col-sm-2">
<input type="number" class="form-control" id="refLibraryDuration" placeholder="Duration"
ng-model="filterSettings.duration">
ng-model="filterSettings.annotationDuration">
</div>

<label for="refLibraryFreqMin" class="col-sm-1 control-label">Min Frequency</label>
Expand Down Expand Up @@ -79,7 +79,8 @@ <h1>Annotation Library</h1>
</form>
</div>
</div>
<div ng-repeat="item in library">
{{item}}
</div>
<a ng-repeat="item in library"
ng-href="/listen/{{item.audioRecordingId}}?start={{calcOffsetStart(item.startTimeSeconds)}}&end={{calcOffsetEnd(item.startTimeSeconds)}}">
<span ng-repeat="tag in item.tags">{{tag.text}}&nbsp;&nbsp;</span><br>
</a>
</div>
2 changes: 2 additions & 0 deletions src/components/services/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@
}

var baseLibraryUri = paths.api.routes.audioEvent.libraryAbsolute;
//'http://localhost:3000'+paths.api.routes.audioEvent.library;
//paths.api.routes.audioEvent.libraryAbsolute;

var resource = resourcePut($resource, uriConvert(paths.api.routes.audioEvent.showAbsolute),
{
Expand Down

0 comments on commit db78ee9

Please sign in to comment.