-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(listen) Added recent recordings page for bare listen link
Also served as a platform to test new query builder. Added a library for humanising durations. Added moment and _ services. Added recent recordings page. Added new /filter queries to Site and AudioRecording.
- Loading branch information
Showing
13 changed files
with
224 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#recentRecordingsTable { | ||
tr:hover { | ||
cursor: pointer; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
angular.module("bawApp.recordings.recentRecordings", []) | ||
.controller("RecentRecordingsCtrl", | ||
[ | ||
"$scope", | ||
"$location", | ||
"AudioRecording", | ||
"Site", | ||
"moment", | ||
"conf.paths", | ||
function RecentRecordingsCtrl($scope, $location, AudioRecording, Site, moment, paths) { | ||
$scope.recentRecordings = [ | ||
{ | ||
siteId: 1000, | ||
duration: 123456, | ||
uploaded: new Date(), | ||
id: 1234 | ||
}, | ||
{ | ||
siteId: 1000, | ||
duration: 123456, | ||
uploaded: new Date(), | ||
id: 1234 | ||
}, | ||
{ | ||
siteId: 1000, | ||
duration: 123456, | ||
uploaded: new Date(), | ||
id: 1234 | ||
} | ||
]; | ||
|
||
function audioRecordingsFormat(wrapper) { | ||
$scope.recentRecordings = wrapper.data; | ||
// format return objects for display | ||
$scope.recentRecordings.forEach(function(value, index) { | ||
value.durationHumanized = moment.duration(value.durationSeconds, "seconds").humanizeDuration(); | ||
value.uploadedHumanized = moment(value.createdAt).fromNow(); | ||
value.listenLink = paths.site.ngRoutes.listen.format({recordingId: value.id}); | ||
}); | ||
|
||
return Site.getSitesByIds(); | ||
} | ||
|
||
function sitesFormat(wrapper) { | ||
var sites = wrapper.reduce(function(state, current) { | ||
state[current.id] = current; | ||
return state; | ||
}, {}); | ||
|
||
$scope.audioRecordings.forEach(function (value) { | ||
value.site = sites[value.siteId]; | ||
}); | ||
} | ||
|
||
AudioRecording | ||
.getRecentRecordings() | ||
.then(audioRecordingsFormat) | ||
.then(function gsbiSucccess(data) { | ||
|
||
}) | ||
.catch(function error(reason) { | ||
console.error(reason); | ||
}); | ||
|
||
|
||
|
||
//Site.getNames(); | ||
|
||
$scope.navigate = function navigate(link) { | ||
$location.url(link); | ||
}; | ||
} | ||
] | ||
); |
35 changes: 35 additions & 0 deletions
35
src/app/recordings/recentRecordings/recentRecordings.tpl.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<div id="content"> | ||
<h1>Recent Audio Recordings</h1> | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<span ng-if="recentRecordings.length === 0"> | ||
No recent audio recordings. | ||
</span> | ||
<table id="recentRecordingsTable" class="table table-striped table-hover" ng-if="recentRecordings.length !== 0"> | ||
<thead> | ||
<tr> | ||
<th>Site</th> | ||
<th>Duration</th> | ||
<th>Uploaded</th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr ng-repeat="r in recentRecordings" ng-click="navigate(r.listenLink)"> | ||
<td>{{r.site.name || r.siteId}}</td> | ||
<td>{{r.durationHumanized}}</td> | ||
<td>{{r.uploadedHumanized}}</td> | ||
<td> | ||
<a ng-href="{{r.listenLink}}" class="btn btn-primary btn-small"> | ||
<span class="glyphicon glyphicon-play"></span> Play | ||
</a> | ||
<a ng-href="" class="btn btn-info btn-small" target="_self"> | ||
<span class="glyphicon glyphicon-map-marker"></span> Site | ||
</a> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
var bawssc = bawssc || angular.module("bawApp.services.core", []); | ||
|
||
bawssc.provider("_", function() { | ||
|
||
// TODO: is there a better way to load lodash without requiring it be attached to window? | ||
var _ = window._; | ||
|
||
this.$get = [function lodashFactory() { | ||
return _; | ||
}]; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
var bawssc = bawssc || angular.module("bawApp.services.core", []); | ||
|
||
bawssc.provider("moment", function() { | ||
|
||
// TODO: is there a better way to load moment without requiring it be attached to window? | ||
var moment = window.moment; | ||
|
||
// HACK: add real duration formatting onto moment object! | ||
var humanizeDuration = window.humanizeDuration; | ||
this.$get = [function momentFactory() { | ||
moment.humanizeDuration = humanizeDuration; | ||
|
||
moment.duration.fn.humanizeDuration = function(parameters) { | ||
return humanizeDuration(this.asMilliseconds(), parameters); | ||
}; | ||
|
||
return moment; | ||
}]; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters