Skip to content

Commit

Permalink
API updates mostly patched.
Browse files Browse the repository at this point in the history
- Fixed Media tests
- Refactored Media model - it is now a proper ng module
- Patched various broken features because of API update
- Refactored rails resource - the case-changing functions are now exported in their constant so unit tests can use them
- NOTE: server side error means audio d/l failing. Not fully tested yet.
  • Loading branch information
atruskie committed Sep 8, 2014
1 parent 838d935 commit b616459
Show file tree
Hide file tree
Showing 13 changed files with 295 additions and 349 deletions.
17 changes: 8 additions & 9 deletions src/app/annotationLibrary/annotationLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ baw.annotationLibrary.addCalculatedProperties = function addCalculatedProperties
return audioEvent;
};

baw.annotationLibrary.getBoundSettings = function getBoundSettings(audioEvent, constants, unitConverter, Media) {
baw.annotationLibrary.getBoundSettings = function getBoundSettings(audioEvent, constants, unitConverter, MediaService, Media) {

var minDuration = 0;
var audioDurationSeconds =
Expand All @@ -56,21 +56,20 @@ baw.annotationLibrary.getBoundSettings = function getBoundSettings(audioEvent, c
format: "json"
};

Media.get(
MediaService.get(
mediaItemParameters,
function mediaGetSuccess(mediaValue, responseHeaders) {

Media.formatPaths(mediaValue, audioEvent.id);
audioEvent.media = mediaValue = new baw.Media(mediaValue);
audioEvent.media = mediaValue = new Media(mediaValue.data);

// create properties that depend on Media
audioEvent.converters = unitConverter.getConversions({
sampleRate: audioEvent.media.sampleRate,
spectrogramWindowSize: audioEvent.media.availableImageFormats.png.window,
spectrogramWindowSize: audioEvent.media.available.image.png.windowSize,
endOffset: audioEvent.media.endOffset,
startOffset: audioEvent.media.startOffset,
imageElement: null,
audioRecordingAbsoluteStartDate: audioEvent.media.datetime
audioRecordingAbsoluteStartDate: audioEvent.media.recordedDate
});

audioEvent.bounds = {
Expand Down Expand Up @@ -124,8 +123,8 @@ baw.annotationLibrary.getBoundSettings = function getBoundSettings(audioEvent, c
angular.module('bawApp.annotationLibrary', ['bawApp.configuration'])
.controller('AnnotationLibraryCtrl', ['$scope', '$location', '$resource', '$routeParams', '$url',
'conf.paths', 'conf.constants', 'bawApp.unitConverter',
'AudioEvent', 'Tag', 'Media',
function ($scope, $location, $resource, $routeParams, $url, paths, constants, unitConverter, AudioEvent, Tag, Media) {
'AudioEvent', 'Tag', 'Media', 'baw.models.Media',
function ($scope, $location, $resource, $routeParams, $url, paths, constants, unitConverter, AudioEvent, Tag, MediaService, Media) {

$scope.status = 'idle';

Expand Down Expand Up @@ -278,7 +277,7 @@ angular.module('bawApp.annotationLibrary', ['bawApp.configuration'])
var annotation = angular.extend({}, audioEventValue);
annotation.priorityTag = Tag.selectSinglePriorityTag(annotation.tags);
baw.annotationLibrary.addCalculatedProperties(annotation, $url, paths);
baw.annotationLibrary.getBoundSettings(annotation, constants, unitConverter, Media);
baw.annotationLibrary.getBoundSettings(annotation, constants, unitConverter, MediaService, Media);
this.push(annotation);
}, $scope.annotations);

Expand Down
90 changes: 45 additions & 45 deletions src/app/annotationLibrary/annotationLibrary.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h3>Annotation Library</h3>

<div class="col-sm-5">
<input type="text" class="form-control" id="refLibraryTags" placeholder="Tags"
data-ng-model="filterSettings.tagsPartial">
ng-model="filterSettings.tagsPartial">
</div>

<p class="help-block text-muted col-sm-3">Use comma (,) to separate tags.</p>
Expand All @@ -20,7 +20,7 @@ <h3>Annotation Library</h3>
<div style="display: none" class="col-sm-2">
<input type="text" class="form-control" id="refLibraryAudioRecordingId"
placeholder="Audio Recording Id" step="1" min="1"
data-ng-model="filterSettings.audioRecordingId">
ng-model="filterSettings.audioRecordingId">
</div>

</div>
Expand All @@ -30,21 +30,21 @@ <h3>Annotation Library</h3>
<div class="col-sm-3">
<input type="number" class="form-control" id="refLibraryDuration"
placeholder="Duration (in seconds)" step="any"
data-ng-model="filterSettings.annotationDuration">
ng-model="filterSettings.annotationDuration">
</div>

<label for="refLibraryFreqMin" class="col-sm-2 control-label">Min Frequency</label>

<div class="col-sm-2">
<input type="number" class="form-control" id="refLibraryFreqMin" step="any"
placeholder="Minimum Frequency" data-ng-model="filterSettings.freqMin">
placeholder="Minimum Frequency" ng-model="filterSettings.freqMin">
</div>

<label for="refLibraryFreqMax" class="col-sm-2 control-label">Max Frequency</label>

<div class="col-sm-2">
<input type="number" class="form-control" id="refLibraryFreqMax" step="any"
placeholder="Maximum Frequency" data-ng-model="filterSettings.freqMax">
placeholder="Maximum Frequency" ng-model="filterSettings.freqMax">
</div>
</div>
<!-- Block disabled for simplicity in testing -->
Expand All @@ -54,80 +54,80 @@ <h3>Annotation Library</h3>
<div class="col-sm-4">
<label class="radio-inline">
<input type="radio" name="refLibraryReference" id="refLibraryReference1" disabled title="Coming soon to movie theaters near you..."
value="" checked data-ng-model="filterSettings.reference"> All
value="" checked ng-model="filterSettings.reference"> All
</label>

<label class="radio-inline">
<input type="radio" name="refLibraryReference" id="refLibraryReference2"
value="true" data-ng-model="filterSettings.reference"> Only Reference
value="true" ng-model="filterSettings.reference"> Only Reference
</label>

<label class="radio-inline">
<input type="radio" name="refLibraryReference" id="refLibraryReference3" disabled title="Coming soon to movie theaters near you..."
value="false" data-ng-model="filterSettings.reference"> Not Reference
value="false" ng-model="filterSettings.reference"> Not Reference
</label>
</div>

<label for="refLibraryPage" class="col-sm-1 control-label">Page</label>

<div class="col-sm-1">
<input type="number" class="form-control" id="refLibraryPage" placeholder="Page"
data-ng-model="filterSettings.page" step="1" min="1">
ng-model="filterSettings.page" step="1" min="1">
</div>

<label for="refLibraryItems" class="col-sm-1 control-label">Items</label>

<div class="col-sm-1">
<input type="number" class="form-control" id="refLibraryItems" placeholder="Items"
data-ng-model="filterSettings.items" step="1" min="1">
ng-model="filterSettings.items" step="1" min="1">
</div>

<label for="refLibraryUserId" class="col-sm-1 control-label">User Id</label>

<div class="col-sm-1">
<input type="number" class="form-control" id="refLibraryUserId" placeholder="User Id"
data-ng-model="filterSettings.userId" step="1" min="1">
ng-model="filterSettings.userId" step="1" min="1">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-1 col-sm-2">
<button type="submit" class="btn btn-primary" data-ng-click="searchFilter()">Filter</button>
<button type="submit" class="btn btn-warning" data-ng-click="clearFilter()">Clear</button>
<button type="submit" class="btn btn-primary" ng-click="searchFilter()">Filter</button>
<button type="submit" class="btn btn-warning" ng-click="clearFilter()">Clear</button>
</div>
<div class="col-sm-2">
<span data-ng-show="status == 'loaded'">{{paging.total}} results</span>
<span data-ng-show="status == 'loaded' && paging.total < 1">The filter did not match any annotations.</span>
<span data-ng-show="status == 'loading'">Loading results...</span>
<span data-ng-show="status == 'error'">Results could not be loaded.</span>
<span ng-show="status == 'loaded'">{{paging.total}} results</span>
<span ng-show="status == 'loaded' && paging.total < 1">The filter did not match any annotations.</span>
<span ng-show="status == 'loading'">Loading results...</span>
<span ng-show="status == 'error'">Results could not be loaded.</span>
</div>
<div class="col-sm-7">
<ul class="pagination annotation-paging" data-ng-show="status == 'loaded' && paging.total > paging.items">
<li data-ng-show="paging.page != paging.minPageNumber">
<a data-ng-href="{{paging.links.prev}}">&laquo;</a>
<ul class="pagination annotation-paging" ng-show="status == 'loaded' && paging.total > paging.items">
<li ng-show="paging.page != paging.minPageNumber">
<a ng-href="{{paging.links.prev}}">&laquo;</a>
</li>
<li data-ng-show="paging.page != paging.minPageNumber">
<a data-ng-href="{{paging.links.first}}">{{paging.minPageNumber}}</a>
<li ng-show="paging.page != paging.minPageNumber">
<a ng-href="{{paging.links.first}}">{{paging.minPageNumber}}</a>
</li>
<li data-ng-show="paging.minCount > paging.minPageNumber">
<li ng-show="paging.minCount > paging.minPageNumber">
<span>&hellip;</span>
</li>
<li data-ng-repeat="pageItem in paging.links.before">
<a data-ng-href="{{pageItem.link}}">{{pageItem.page}}</a>
<li ng-repeat="pageItem in paging.links.before">
<a ng-href="{{pageItem.link}}">{{pageItem.page}}</a>
</li>
<li class="active">
<a data-ng-href="{{paging.current}}">{{paging.page}}</a>
<a ng-href="{{paging.current}}">{{paging.page}}</a>
</li>
<li data-ng-repeat="pageItem in paging.links.after">
<a data-ng-href="{{pageItem.link}}">{{pageItem.page}}</a>
<li ng-repeat="pageItem in paging.links.after">
<a ng-href="{{pageItem.link}}">{{pageItem.page}}</a>
</li>
<li data-ng-show="paging.maxCount < paging.maxPageNumber">
<li ng-show="paging.maxCount < paging.maxPageNumber">
<span>&hellip;</span>
</li>
<li data-ng-show="paging.page != paging.maxPageNumber">
<a data-ng-href="{{paging.links.last}}">{{paging.maxPageNumber}}</a>
<li ng-show="paging.page != paging.maxPageNumber">
<a ng-href="{{paging.links.last}}">{{paging.maxPageNumber}}</a>
</li>
<li data-ng-show="paging.page != paging.maxPageNumber">
<a data-ng-href="{{paging.links.next}}">&raquo;</a>
<li ng-show="paging.page != paging.maxPageNumber">
<a ng-href="{{paging.links.next}}">&raquo;</a>
</li>
</ul>
</div>
Expand All @@ -137,46 +137,46 @@ <h3>Annotation Library</h3>
</div>

<div class="annotation-library">
<div data-ng-repeat="item in annotations" class="pull-left library-item thumbnail">
<div ng-repeat="item in annotations" class="pull-left library-item thumbnail">
<div class="library-spectrogram">
<img data-ng-src="{{item.media.availableImageFormats.png.url}}"
data-ng-style="{width: item.converters.conversions.enforcedImageWidth, height: item.converters.conversions.enforcedImageHeight}">
<img ng-src="{{item.media.available.image.png.url}}" src=""
ng-style="{width: item.converters.conversions.enforcedImageWidth, height: item.converters.conversions.enforcedImageHeight}">
<grid-lines configuration="item.gridConfig" class="library-spectrogram-grid"></grid-lines>
<div class="library-spectrogram-bounds"
data-ng-style="{top: item.bounds.top, left: item.bounds.left, width: item.bounds.width, height: item.bounds.height}"></div>
ng-style="{top: item.bounds.top, left: item.bounds.left, width: item.bounds.width, height: item.bounds.height}"></div>
</div>

<div class="library-item-info"
data-ng-style="{'min-width':150, width:item.converters.conversions.enforcedImageWidth}">
ng-style="{'min-width':150, width:item.converters.conversions.enforcedImageWidth}">
<audio id="annotationLibraryItemInfoAudio{{$index}}" controls
data-ng-style="{width:item.converters.conversions.enforcedImageWidth}">
<source data-ng-repeat="resource in item.media.availableAudioFormats" data-ng-src="{{resource.url}}" src=""
ng-style="{width:item.converters.conversions.enforcedImageWidth}">
<source ng-repeat="resource in item.media.available.audio" ng-src="{{resource.url}}" src=""
type="{{resource.mimeType}}">
Your browser does not support the audio element.
</audio>
<span data-ng-show="item.tags.length > 0">
<span ng-show="item.tags.length > 0">
<span class="info-entry">
<span class="glyphicon glyphicon-tags"></span>
<a data-ng-href="{{item.urls.tagSearch}}">
<a ng-href="{{item.urls.tagSearch}}">
{{item.priorityTag.text}}
</a>
</span>
</span>
<span class="info-entry">
<span class="glyphicon glyphicon-map-marker"></span>
<a data-ng-href="{{item.urls.site}}">
<a ng-href="{{item.urls.site}}">
{{item.siteName}}
</a>
</span>
<span class="info-entry">
<span class="glyphicon glyphicon-record"></span>
<a data-ng-href="{{item.urls.listen}}">
<a ng-href="{{item.urls.listen}}">
{{item.audioEventStartDate | date: 'MMM d, yyyy HH:mm'}}
</a>
</span>
<span class="info-entry">
<span class="glyphicon glyphicon-info-sign"></span>
<a data-ng-href="{{item.urls.singleItem}}" style="cursor: pointer;">
<a ng-href="{{item.urls.singleItem}}" style="cursor: pointer;">
More info
</a>
</span>
Expand Down
1 change: 1 addition & 0 deletions src/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ var app = angular.module('baw',
'bawApp.filters', /* our filters.js */
'bawApp.services', /* our services.js */
'bawApp.services.unitConverter',
"baw.models",
'audio-control',
'draggabilly',

Expand Down
Loading

0 comments on commit b616459

Please sign in to comment.