Skip to content

Commit

Permalink
Added option to override paging
Browse files Browse the repository at this point in the history
also started adding laoding bars. a site wide loading bar was added
  • Loading branch information
atruskie committed Feb 26, 2015
1 parent f439c0e commit 85afca9
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 10 deletions.
8 changes: 6 additions & 2 deletions buildConfig/build.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ module.exports = {
'vendor/angular-growl-v2/build/angular-growl.js',
'vendor/angular-local-storage/dist/angular-local-storage.js',
'vendor/humanize-duration/humanize-duration.js',
'vendor/round-date/roundDate.js'
'vendor/round-date/roundDate.js',

'vendor/angular-loading-bar/build/loading-bar.js'
],
css: [
// NOTE: bootstrap css imported in application.tpl.scss
Expand All @@ -135,7 +137,9 @@ module.exports = {
//'vendor/select2/select2.css'

'vendor/angular-tags/dist/angular-tags-0.3.1.css',
'vendor/angular-growl-v2/build/angular-growl.css'
'vendor/angular-growl-v2/build/angular-growl.css',

'vendor/angular-loading-bar/build/loading-bar.css'
],
assets: [
// jquery-ui is stoopid, special case
Expand Down
17 changes: 15 additions & 2 deletions src/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ var app = angular.module('baw',
'decipher.tags',
'angular-growl',
'LocalStorageModule',
'angular-loading-bar',
"bawApp.vendorServices", /* Loads all vendor libraries that are automatically wrapped in a module */


Expand Down Expand Up @@ -113,8 +114,8 @@ var app = angular.module('baw',
"bawApp.visualize"
])

.config(['$routeProvider', '$locationProvider', '$httpProvider', 'conf.paths', 'conf.constants', '$sceDelegateProvider', 'growlProvider', 'localStorageServiceProvider', "$urlProvider", "casingTransformers",
function ($routeProvider, $locationProvider, $httpProvider, paths, constants, $sceDelegateProvider, growlProvider, localStorageServiceProvider, $urlProvider, casingTransformers) {
.config(["$provide", '$routeProvider', '$locationProvider', '$httpProvider', 'conf.paths', 'conf.constants', '$sceDelegateProvider', 'growlProvider', 'localStorageServiceProvider', "cfpLoadingBarProvider", "$urlProvider", "casingTransformers",
function ($provide, $routeProvider, $locationProvider, $httpProvider, paths, constants, $sceDelegateProvider, growlProvider, localStorageServiceProvider, cfpLoadingBarProvider, $urlProvider, casingTransformers) {
// adjust security whitelist for resource urls
var currentWhitelist = $sceDelegateProvider.resourceUrlWhitelist();
currentWhitelist.push(paths.api.root+'/**');
Expand Down Expand Up @@ -207,9 +208,21 @@ var app = angular.module('baw',
// configure local storage provider with our own namepspace
localStorageServiceProvider.setPrefix(constants.namespace);

// for compatibility with rails api
$urlProvider.renamer(function(key) {
return casingTransformers.underscore(key);
});

// configure the loader bar
// only show bar after waiting for 200ms
cfpLoadingBarProvider.latencyThreshold = 200;
// add a standard way to add ignores to http objects
$provide.decorator('cfpLoadingBar', function ($delegate) {
$delegate.ignore = function ($httpConfig) {
return $httpConfig && ($httpConfig.ignoreLoadingBar = true, $httpConfig) || $httpConfig;
};
return $delegate;
});
}])


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ angular
},
getTileUrl: function(date, category, tileSizeSeconds, tileSizePixels, datum, index) {
var hourOfDay = date.getHours();
return "/tile_" + hourOfDay + ".png"
return "/tile_" + hourOfDay + ".png";
}
};

Expand Down
8 changes: 7 additions & 1 deletion src/components/services/audioRecording.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ angular

resource.getRecordingsForVisulisation = function (siteIds) {
var query = QueryBuilder.create(function (q) {

// HACK: ask for a ridiculous amount of items since
// paging cap automatically is enabled at 500 items.
// TODO: add an option to disable paging
// track issue here: https://github.com/QutBioacoustics/baw-server/issues/160
return q
.in("siteId", siteIds)
.project({include: ["id", "siteId", "durationSeconds", "recordedDate"]});
.project({include: ["id", "siteId", "durationSeconds", "recordedDate"]})
.page({items: 100000, page: 1});
});

return $http.post(filterUrl, query.toJSON());
Expand Down
14 changes: 10 additions & 4 deletions src/components/services/predictiveCache.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
angular
.module("bawApp.services.predictiveCache", [])
.module("bawApp.services.predictiveCache", ["angular-loading-bar"])
.factory(
"predictiveCacheInterceptor",
[
Expand Down Expand Up @@ -34,7 +34,8 @@ angular
"$http",
"predictiveCacheInterceptor",
"$q",
function ($http, predictiveCacheInterceptor, $q) {
"cfpLoadingBar",
function ($http, predictiveCacheInterceptor, $q, cfpLoadingBar) {

var defaults = {
name: null,
Expand Down Expand Up @@ -169,10 +170,15 @@ angular

function invokeHttp(url) {
console.debug("predictiveCache:promiseResolution enqueued " + url);
return $http({
var config = {
url: url,
method: profile.method
}).then(function (value) {
};
//HACK: this is nasty... only done so unit tests pass
if (cfpLoadingBar.ignore) {
config = cfpLoadingBar.ignore(config);
}
return $http(config).then(function (value) {
console.debug("predictiveCache:promiseResolution completed " + url);
return value;
});
Expand Down
11 changes: 11 additions & 0 deletions src/components/services/predictiveCache.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,18 @@ describe("The predictiveCache service", function () {
$httpProvider = _$httpProvider_;
}));

//beforeEach(module("baw"));

beforeEach(function () {
//
//$provide.decorator('cfpLoadingBar', function ($delegate) {
// $delegate.ignore = function ($httpConfig) {
// return $httpConfig && ($httpConfig.ignoreLoadingBar = true) || $httpConfig;
// };
//
// return $delegate;
//});

testProfile = {
name: "Media cache ahead",
match: /google\.com\?page=(.*)&size=(.*)/,
Expand Down

0 comments on commit 85afca9

Please sign in to comment.