Skip to content

Commit fb862d6

Browse files
committed
#342 audio data type support
1 parent eccf06a commit fb862d6

File tree

6 files changed

+73
-39
lines changed

6 files changed

+73
-39
lines changed

grails-app/conf/ApplicationResources.groovy

+1
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ modules = {
388388
audio {
389389
dependsOn "modernizr"
390390
resource url: 'js/audio.js'
391+
resource url: 'css/audio-control.css'
391392
resource url: 'vendor/recorderjs/recorder.js'
392393
// resource url: 'vendor/libmp3lame/libmp3lame.min.js'
393394
}

grails-app/taglib/au/org/ala/biocollect/ModelJSTagLib.groovy

+3-1
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,8 @@ class ModelJSTagLib {
559559
}})(data['${col.name}']);
560560
"""
561561
break;
562+
case 'audio':
563+
out << INDENT*3 << "this.${col.name} = new AudioViewModel({downloadUrl: '${grailsApplication.config.grails.serverURL}/download/file?filename='}, data['${col.name}'])\n";
562564

563565
}
564566
modelConstraints(col, out)
@@ -916,7 +918,7 @@ class ModelJSTagLib {
916918
}
917919

918920
def audioModel(model, out) {
919-
out << INDENT*4 << "self.data.${model.name}= new AudioViewModel();\n"
921+
out << INDENT*4 << "self.data.${model.name}= new AudioViewModel({downloadUrl: '${grailsApplication.config.grails.serverURL}/download/file?filename='});\n"
920922
populateAudioList(model, out)
921923
}
922924

grails-app/views/output/_audioDataTypeEditModelTemplate.gsp

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</audio>
1010

1111
<div>
12-
<a href="" data-bind="attr: {href: transients.downloadUrl()}"><i class="fa fa-download">&nbsp;</i>Download</a>
12+
<a href="" data-bind="attr: {href: transients.downloadUrl()}" class="download"><i class="fa fa-download">&nbsp;</i>Download</a>
1313
</div>
1414
</div>
1515

@@ -30,15 +30,16 @@
3030
</label>
3131

3232
<div class="controls">
33-
<input id="attribution" class="input-xxlarge" type="text" data-bind="value: attribution">
33+
<input id="attribution" class="input-xlarge" type="text" data-bind="value: attribution">
3434
</div>
3535
</div>
3636

3737
<div class="control-group">
3838
<label class="control-label" for="notes">Notes:</label>
3939

4040
<div class="controls">
41-
<input id="notes" class="input-xxlarge"type="text" data-bind="value: notes">
41+
<textarea rows="4" class="input-xlarge" id="notes" data-bind="value: notes"></textarea>
42+
%{--<input id="notes" class="input-xxlarge"type="text" data-bind="value: notes">--}%
4243
</div>
4344
</div>
4445

@@ -71,7 +72,7 @@
7172
</div>
7273
</div>
7374

74-
<div id="recordingControls" data-bind="visible: ${name}.transients.html5AudioSupport()" class="inline-block">
75+
<div id="recordingControls" data-bind="visible: ${name}.transients.html5AudioSupport()" class="inline-block" style="display: none">
7576
<span data-bind="click: ${name}.startRecording, visible: !${name}.transients.recording()" class="btn"><span
7677
class="fa fa-circle red">&nbsp;</span>Start recording</span>
7778
<span data-bind="click: ${name}.stopRecording, visible: ${name}.transients.recording()" class="btn"><span

web-app/css/audio-control.css

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
.audio-thumbnail {
2+
border: 1px solid white;
3+
min-width: 350px;
4+
max-width: 350px;
5+
width: 350px;
6+
display: inline-block;
7+
margin-right: 10px;
8+
margin-bottom: 10px;
9+
border-radius: 5px;
10+
vertical-align: top;
11+
}
12+
13+
.audio-thumbnail audio {
14+
padding-left: 25px;
15+
}
16+
17+
.audio-thumbnail .download {
18+
float: right;
19+
}
20+
21+
.output-label {
22+
float: left;
23+
width: 100px;
24+
text-align: right;
25+
font-weight: bold;
26+
padding-right: 10px;
27+
}
28+
29+
table .audio-input-panel .span3, table .audio-input-panel .span2, table .audio-input-panel .span7 {
30+
width: 100%;
31+
}
32+
33+
table .audio-input-panel .btn {
34+
float: right;
35+
margin-right: 20px;
36+
}
37+
38+
table audio {
39+
margin-left: 20px;
40+
}
41+
42+
table .download {
43+
margin-left: 20px;
44+
margin-bottom: 20px;
45+
display: block;
46+
}
47+
48+
.audio-input-panel .control-label {
49+
width: 85px !important;
50+
}
51+
52+
.audio-input-panel .controls {
53+
margin-left: 100px !important;
54+
}

web-app/css/common.css

-33
Original file line numberDiff line numberDiff line change
@@ -361,36 +361,3 @@ th .popover {
361361
padding-top: 10px;
362362
padding-bottom: 5px;
363363
}
364-
365-
audio::before {
366-
content: '\f08e';
367-
font-family: FontAwesome;
368-
}
369-
370-
.audio-thumbnail {
371-
border: 1px solid white;
372-
min-width: 350px;
373-
max-width: 350px;
374-
width: 350px;
375-
display: inline-block;
376-
margin-right: 10px;
377-
margin-bottom: 10px;
378-
border-radius: 5px;
379-
vertical-align: top;
380-
}
381-
382-
.audio-thumbnail audio {
383-
padding-left: 25px;
384-
}
385-
386-
.audio-thumbnail .download {
387-
float: right;
388-
}
389-
390-
.output-label {
391-
float: left;
392-
width: 100px;
393-
text-align: right;
394-
font-weight: bold;
395-
padding-right: 10px;
396-
}

web-app/js/audio.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function AudioViewModel() {
1+
function AudioViewModel(config, files) {
22
var self = this;
33

44
var recorder = null;
@@ -7,6 +7,15 @@ function AudioViewModel() {
77
self.transients.recording = ko.observable(false);
88
self.files = ko.observableArray();
99

10+
if (!_.isUndefined(files) && !_.isEmpty(files)) {
11+
files.forEach(function (file) {
12+
if (_.isUndefined(file.url)) {
13+
file.url = config.downloadUrl + file.filename;
14+
}
15+
self.files.push(new AudioItem(file));
16+
});
17+
}
18+
1019
self.transients.html5AudioSupport = ko.pureComputed(function () {
1120
var supported = false;
1221
if (Modernizr.getusermedia) {

0 commit comments

Comments
 (0)