-
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.
- Loading branch information
Mark Cottman-Fields
committed
Sep 14, 2014
1 parent
456b231
commit 7d12450
Showing
5 changed files
with
250 additions
and
171 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,71 @@ | ||
var bawD3 = bawD3 || angular.module("bawApp.d3", []); | ||
bawD3.controller('D3TestPageCtrl', ['$scope', 'conf.paths', '$http', function ($scope, paths, $http) { | ||
bawD3.controller('D3TestPageCtrl', ['$scope', 'conf.paths', '$http', '$routeParams', 'Site', '$location', | ||
function ($scope, paths, $http, $routeParams, Site, $location) { | ||
|
||
// use the REST API in here | ||
// use the REST API in here | ||
// assign the resulting data to scope (not great but it will do for now) | ||
|
||
// assign the resulting data to scope (not great but it will do for now) | ||
$scope.basicData = [0, 1, 2, 3, 4, 5]; | ||
// get the site id (from route params or a default) | ||
$scope.siteId = $routeParams.siteId ? $routeParams.siteId : 398; | ||
|
||
$scope.siteId = 643; | ||
|
||
var request_filter = { | ||
"filter": { | ||
"site_id":{ | ||
"eq":$scope.siteId | ||
// set up the $scope.siteId watcher after getting query string, so the location isn't changed. | ||
// subsequent changes will change the url | ||
$scope.$watch(function () { | ||
return $scope.currentSiteInfo; | ||
}, function (newValue, oldValue) { | ||
if(newValue && oldValue && newValue.id != oldValue.id){ | ||
//console.log(newValue, oldValue); | ||
window.location = '/d3Test?siteId='+newValue.id; | ||
} | ||
}, | ||
"projection": { | ||
"include": ["id", "recorded_date", "duration_seconds", "site_id"] | ||
}//, | ||
//"paging":{ | ||
// "page":2, | ||
// "items":30 | ||
//} | ||
}; | ||
|
||
$http.post(paths.api.routes.audioRecording.filterAbsolute, request_filter) | ||
.success(function (data, status, headers, config) { | ||
|
||
$scope.filteredAudioRecordings = data; | ||
}) | ||
.error(function (data, status, headers, config) { | ||
$scope.filteredAudioRecordings = data; | ||
console.warn('Filtered audio recordings failed.', data, status, headers, config); | ||
}); | ||
|
||
// populate select with options | ||
Site.getAllSites().then(function(result){ | ||
$scope.sites = result.data.data; | ||
console.log('success', arguments); | ||
}, function(error){ | ||
console.log('error', arguments); | ||
}, function(){ | ||
console.log('notify', arguments); | ||
}); | ||
|
||
// get the selected site details | ||
Site.get({siteId: $scope.siteId}, {}, function getSiteSuccess(value) { | ||
|
||
value.links = value.projectIds.map(function (id) { | ||
return paths.api.routes.site.nestedAbsolute.format({"siteId": value.id, "projectId": id}); | ||
}); | ||
|
||
$scope.currentSiteInfo = value; | ||
}, function getSiteError() { | ||
console.log("retrieval of site json failed"); | ||
}); | ||
|
||
// get audio recording info for the current site | ||
var request_filter = { | ||
"filter": { | ||
"site_id": { | ||
"eq": $scope.siteId | ||
} | ||
}, | ||
"projection": { | ||
"include": ["id", "recorded_date", "duration_seconds", "site_id"] | ||
}//, | ||
//"paging":{ | ||
// "page":2, | ||
// "items":30 | ||
//} | ||
}; | ||
|
||
|
||
$http.post(paths.api.routes.audioRecording.filterAbsolute, request_filter) | ||
.success(function (data, status, headers, config) { | ||
|
||
$scope.filteredAudioRecordings = data; | ||
}) | ||
.error(function (data, status, headers, config) { | ||
$scope.filteredAudioRecordings = data; | ||
console.warn('Filtered audio recordings failed.', data, status, headers, config); | ||
}); | ||
|
||
}]); | ||
}]); |
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
Oops, something went wrong.