From f0c8ff797a0e9055a7536a2c4541b59b5854dca4 Mon Sep 17 00:00:00 2001 From: Anthony Truskinger Date: Tue, 5 Nov 2013 16:20:08 +1000 Subject: [PATCH] General bug fixes Updated ng-resource dependency. Fixed Angular whitelist bug when updating version. Some basic work trying to add annotations. --- bower.json | 9 +++------ build.config.js | 2 +- src/app/app.js | 10 +++++----- src/app/listen/listen.js | 16 ++++++++++------ src/app/listen/listen.tpl.html | 4 ++-- src/components/models/annotation.js | 18 ++++++++++++++++-- src/sass/_layout.scss | 14 +++++++------- 7 files changed, 44 insertions(+), 29 deletions(-) diff --git a/bower.json b/bower.json index 29c025de..59f899ea 100644 --- a/bower.json +++ b/bower.json @@ -8,16 +8,13 @@ "angular-bootstrap": "~0.6.0", "angular-ui-router": "~0.0.1", "angular-ui-utils": "latest", - "sass-bootstrap": "~3.0.0", + "sass-bootstrap": "3.0.0", "hint.css": "https://github.com/chinchang/hint.css.git", "underscore": "~1.5.2", - "angular-resource": "~1.0.8", + "angular-resource": "~1.2.0", "modernizr": "~2.6.2", "jquery-ui": "~1.10.3", "momentjs": "~2.3.0" }, - "dependencies": {}, - "resolutions": { - "angular": "~1.2.0" - } + "dependencies": {} } diff --git a/build.config.js b/build.config.js index 9dacd45f..6f1d8304 100644 --- a/build.config.js +++ b/build.config.js @@ -15,7 +15,7 @@ module.exports = { build_configs: { configFile: appConfigFile, development: { - apiRoot: "http://staging.ecosounds.org", + apiRoot: "http://131.181.33.143:3000", //"http://staging.ecosounds.org", siteRoot: "localhost:8080", siteDir: "/" }, diff --git a/src/app/app.js b/src/app/app.js index 7694b43b..c39cfff4 100644 --- a/src/app/app.js +++ b/src/app/app.js @@ -90,7 +90,7 @@ var app = angular.module('baw', function ($routeProvider, $locationProvider, $httpProvider, paths, $sceDelegateProvider) { // adjust security whitelist for resource urls var currentWhitelist = $sceDelegateProvider.resourceUrlWhitelist(); - currentWhitelist.push('^'+paths.api.root+'/.*'); + currentWhitelist.push(paths.api.root+'/**'); $sceDelegateProvider.resourceUrlWhitelist(currentWhitelist); @@ -257,12 +257,12 @@ var app = angular.module('baw', function AppCtrl($scope, $location) { $scope.showDebugUi = function() { - var r = window.cssRules.getCssRule(".debug-UI") + var r = window.cssRules.getCssRule(".debug-UI"); r.style.display = ""; - } + }; $scope.hideDebugUi = function() { - var r = window.cssRules.getCssRule(".debug-UI") + var r = window.cssRules.getCssRule(".debug-UI"); r.style.display = "none"; - } + }; }]); diff --git a/src/app/listen/listen.js b/src/app/listen/listen.js index 65c7e90f..be20489c 100644 --- a/src/app/listen/listen.js +++ b/src/app/listen/listen.js @@ -331,15 +331,19 @@ angular.module('bawApp.listen', []) $scope.addAnnotation = function createAnnotation() { // BUG: ONLY SAVES FIRST ONE - var a = angular.copy(this.$scope.model.selectedAudioEvents[0]); + var a = $scope.model.selectedAudioEvents[0]; + //TODO: BROKEN! + var a = $scope.model; // prep tags - a.audio_event_tags_attributes = a.audioEventTags.map(function (v) { - return {tag_id: v}; - }); - delete a.audioEventTtags; +// a.audio_event_tags_attributes = a.audioEventTags.map(function (v) { +// return {tag_id: v}; +// }); +// delete a.audioEventTags; - a.audio_recording_id = recordingId; + if (a.audioRecordingId != recordingId) { + throw "The audioRecordingId should have been set way earlier!"; + } AudioEvent.save({audioEventId: null}, a, function createAnnotationSuccess(response, getResponseHeaders) { diff --git a/src/app/listen/listen.tpl.html b/src/app/listen/listen.tpl.html index 6f849b13..1a9485d9 100644 --- a/src/app/listen/listen.tpl.html +++ b/src/app/listen/listen.tpl.html @@ -100,7 +100,7 @@

Site: {{model.audioRecording.siteId}}, @@ -136,7 +136,7 @@

- +
diff --git a/src/components/models/annotation.js b/src/components/models/annotation.js index f01fe36f..50c32fed 100644 --- a/src/components/models/annotation.js +++ b/src/components/models/annotation.js @@ -18,13 +18,13 @@ throw new Error("Constructor called as a function"); } - var now = new Date(); - this.__temporaryId__ = localId || Number.Unique(); this._selected = false; this.audioEventTags = []; if (localId) { + var now = new Date(); + this.audioRecordingId = audioRecordingId; this.createdAt = now; @@ -38,6 +38,7 @@ } + // ensure JSON values taken from a resource have nicely formatted values if (resource) { angular.extend(this, resource); @@ -49,8 +50,21 @@ this.lowFrequencyHertz = parseFloat(this.lowFrequencyHertz); this.startTimeSeconds = parseFloat(this.startTimeSeconds); + this.audioEventTags = {}; angular.forEach(this.audioEventTags, function(value, key) { this.audioEventTags[key] = new baw.AudioEventTag(value); }, this); } + + // strip out unnecessary values; + this.create = function() { + // NO-OP + return this; + }; +// +// this.toJSON = function() { +// return { +// +// } +// }; }; diff --git a/src/sass/_layout.scss b/src/sass/_layout.scss index 5caa81ed..a8094d95 100644 --- a/src/sass/_layout.scss +++ b/src/sass/_layout.scss @@ -230,13 +230,13 @@ header { //} /* stick footer Opera Fix */ -body:before { - content:""; - height:100%; - float:left; - width:0; - margin-top:-32767px; -} +//body:before { +// content:""; +// height:100%; +// float:left; +// width:0; +// margin-top:-32767px; +//} /* General Classes -----------------------------------------------------------------------------*/