Skip to content

Commit

Permalink
audio query with time zone; audio allow empty time zone; creator entr…
Browse files Browse the repository at this point in the history
…ies with time zone timestamps; update java dependencies; update js dependencies
  • Loading branch information
swoellauer committed Apr 21, 2023
1 parent 3e7460a commit eee0789
Show file tree
Hide file tree
Showing 16 changed files with 137 additions and 54 deletions.
36 changes: 18 additions & 18 deletions AudioApp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 26 additions & 6 deletions AudioApp/src/components/browser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ export default defineComponent({
requestError: false,
filteredLocations: [],
filteredTimestamps: [],
timestamps_all_locations: undefined,
timestamps_of_location: undefined,
requestMetaLoading: false,
requestMetaError: false,
Expand Down Expand Up @@ -296,11 +297,11 @@ export default defineComponent({
return t.timestamp <= 0 ? {date: '(unknown)', value: 0, year: '(unknown)', month: '(unknown)', day: '(unknown)'} : {date: t.date, time: t.time, value: t.timestamp, year: t.year, month: t.month<10 ? '0'+t.month : ''+t.month, day: t.day<10 ? '0'+t.day : ''+t.day};
});
} else {
const d = this.$store.state.project.data;
if(d === undefined || d.dates === undefined || d.dates.length === 0) {
const d = this.timestamps_all_locations;
if(d === undefined || d.length === 0) {
return [{date: '(no timestamps)', value: undefined}];
}
return d.dates.map(t => {
return d.map(t => {
return t.timestamp <= 0 ? {date: '(unknown)', value: 0, year: '(unknown)', month: '(unknown)', day: '(unknown)'} : {date: t.date, value: t.timestamp, year: t.year, month: t.month<10 ? '0'+t.month : ''+t.month, day: t.day<10 ? '0'+t.day : ''+t.day};
});
}
Expand Down Expand Up @@ -398,6 +399,12 @@ export default defineComponent({
}
}
},
time_zone() {
if(this.time_zone) {
this.requestRefreshMeta();
this.requestRefresh();
}
},
},
methods: {
async querySamples() {
Expand Down Expand Up @@ -482,7 +489,13 @@ export default defineComponent({
if(this.selectedLocation) {
//params.timestamps_of_location = this.selectedLocation.value;
params.dates_of_location = this.selectedLocation.value;
} else {
params.dates = true;
}
if(this.time_zone) {
params.tz = this.time_zone;
}
//this.timestamps_all_locations = undefined; // no clear
this.timestamps_of_location = undefined;
this.requestMetaError = false;
this.requestMetaLoading = true;
Expand All @@ -496,6 +509,10 @@ export default defineComponent({
}
this.timestamps_of_location = tol;
}
var td = response.data.project.dates;
if(td !== undefined) {
this.timestamps_all_locations = td;
}
} catch(e) {
this.requestMetaError = true;
this.requestMetaLoading = false;
Expand All @@ -504,19 +521,22 @@ export default defineComponent({
},
locationfilterFn(val, update, abort) {
update(() => {
const needle = val.toLowerCase()
const needle = val.toLowerCase();
this.filteredLocations = this.locations.filter(v => v.label.toLowerCase().indexOf(needle) > -1)
});
},
timestampfilterFn(val, update, abort) {
update(() => {
const needle = val.toLowerCase()
const needle = val.toLowerCase();
this.filteredTimestamps = this.timestamps.filter(v => v.date.toLowerCase().indexOf(needle) > -1)
});
},
},
mounted() {
this.requestRefresh();
if(this.time_zone !== undefined) {
this.requestRefreshMeta();
this.requestRefresh();
}
},
});
</script>
Expand Down
6 changes: 5 additions & 1 deletion AudioApp/src/pages/project/list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
</a>
<span style="padding-left: 10px;" v-if="sample.location">{{sample.location}}</span>
<span style="padding-left: 10px;" v-if="sample.date">{{sample.date}}</span>
<span style="padding-left: 5px;" v-if="sample.time">{{sample.time}}</span>
<span style="padding-left: 5px;" v-if="sample.time">{{sample.time}} <span style="font-size: 0.7em;">{{time_zone}}</span></span>
<span style="padding-left: 10px; font-family: monospace;" v-if="(sample.location === undefined || sample.date === undefined) && sample.device">{{sample.device}}</span>
<span style="padding-left: 10px;" v-if="(!sample.location || !sample.device) && sample.date === undefined">{{sample.id}}</span>
<!--<span style="padding-left: 20px;">{{workingEntry.start}} - {{workingEntry.end}}</span>-->
Expand Down Expand Up @@ -429,6 +429,7 @@ export default defineComponent({
player_fft_intensity_max: state => state.project.player_fft_intensity_max,
//player_spectrum_shrink_Factor: state => state.project.player_spectrum_shrink_Factor,
player_time_expansion_factor: state => state.project.player_time_expansion_factor,
time_zone: state => state.project.time_zone,
}),
listId() {
return this.$route.query.list;
Expand Down Expand Up @@ -617,6 +618,9 @@ export default defineComponent({
this.setActionStatus(true, undefined);
var urlPath = 'samples2/' + this.workingEntry.sample;
var params = {sample_rate: true, labels: true};
if(this.time_zone) {
params.tz = this.time_zone;
}
var response = await this.$api.get(urlPath, {params});
this.sample = response.data.sample;
this.setActionStatus(false, undefined);
Expand Down
16 changes: 8 additions & 8 deletions AudioApp/src/pages/project/main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<q-space></q-space>
<div v-if="sample !== undefined">
<q-btn :icon="$refs.browser.movePrevSelectedSampleRequested ? 'recycling' : 'navigate_before'" padding="xs" :class="{'element-hidden': $refs.browser.movePrevSelectedSampleRequested || !$refs.browser.hasSelectedSamplePrev}" @click="if(userSelectedLabelNamesChanged) {onSaveLabels();} $refs.browser.movePrevSelectedSampleRequested = true" title="Move to previous sample on the browsed list of samples"/>
<span class="text-weight-bold" v-if="sample.location"><q-icon name="home"/>{{sample.location}}</span>
<span class="text-weight-regular text-grey-9" style="padding-left: 10px;" v-if="sample.date"><q-icon name="calendar_today"/>{{sample.date}}</span>
<span class="text-weight-light text-grey-9" style="padding-left: 5px;" v-if="sample.time"><q-icon name="query_builder"/>{{sample.time}} <span class="text-weight-light text-grey-7" style="font-size: 0.7em;">{{time_zone}}</span></span>
<span class="text-weight-thin text-grey-6" style="padding-left: 10px; font-family: monospace;" v-if="sample.device"><q-icon name="memory"/>{{sample.device}}</span>
<span class="text-weight-bold" v-if="(!sample.location || !sample.device) && sample.date === undefined"><q-icon name="fingerprint"/>{{sample.id}}</span>
<span class="text-weight-thin text-grey-6" style="padding-left: 10px;" v-if="sampleRate"><q-icon name="leaderboard"/>{{Math.trunc(sampleRate/1000)}}<sup style="font-size: 0.8em">.{{sampleRatemhz}}</sup> kHz</span>
<span class="text-weight-thin text-grey-6" style="padding-left: 10px;" v-if="duration !== undefined"><q-icon name="alarm"/><span v-if="durationHH !== '00'">{{durationHH}}:</span><span class="text-grey-8">{{durationMM}}</span><span class="text-grey-6">:{{durationSS}}</span><sup class="text-grey-5" style="font-size: 0.7em" v-if="durationMS !== '000'">.{{durationMS}}</sup></span>
<span class="text-weight-bold" v-if="sample.location"><q-icon name="home"/> {{sample.location}}</span>
<span class="text-weight-regular text-grey-9" style="padding-left: 10px;" v-if="sample.date"><q-icon name="calendar_today"/> {{sample.date}}</span>
<span class="text-weight-light text-grey-9" style="padding-left: 5px;" v-if="sample.time"><q-icon name="query_builder"/> {{sample.time}} <span class="text-weight-light text-grey-7" style="font-size: 0.7em;">{{time_zone}}</span></span>
<span class="text-weight-thin text-grey-6" style="padding-left: 10px; font-family: monospace;" v-if="sample.device"> <q-icon name="memory"/>{{sample.device}}</span>
<span class="text-weight-bold" v-if="(!sample.location || !sample.device) && sample.date === undefined"> <q-icon name="fingerprint"/>{{sample.id}}</span>
<span class="text-weight-thin text-grey-6" style="padding-left: 10px;" v-if="sampleRate"><q-icon name="leaderboard"/> {{Math.trunc(sampleRate/1000)}}<sup style="font-size: 0.8em">.{{sampleRatemhz}}</sup> kHz</span>
<span class="text-weight-thin text-grey-6" style="padding-left: 10px;" v-if="duration !== undefined"> <q-icon name="alarm"/><span v-if="durationHH !== '00'">{{durationHH}}:</span><span class="text-grey-8">{{durationMM}}</span><span class="text-grey-6">:{{durationSS}}</span><sup class="text-grey-5" style="font-size: 0.7em" v-if="durationMS !== '000'">.{{durationMS}}</sup></span>
<q-btn :icon="$refs.browser.moveNextSelectedSampleRequested ? 'recycling' : 'navigate_next'" padding="xs" :class="{'element-hidden': $refs.browser.moveNextSelectedSampleRequested || !$refs.browser.hasSelectedSampleNext}" @click="if(userSelectedLabelNamesChanged) {onSaveLabels();} $refs.browser.moveNextSelectedSampleRequested = true" title="Move to next sample on the browsed list of samples"/>
</div>
<div v-if="sample === undefined">
Expand Down Expand Up @@ -485,7 +485,7 @@
<tr v-for="(label, index) in selectedLabel.labels" :key="index">
<td class="text-left">{{label.name}}</td>
<td class="text-left">{{label.creator}}</td>
<td class="text-left">{{label.creation_date === undefined ? '' : label.creation_date.slice(0,16)}}</td>
<td class="text-left" :title="label.creation_date">{{label.creation_date === undefined ? '' : label.creation_date.slice(0,16)}}</td>
</tr>
</tbody>
</q-markup-table>
Expand Down
2 changes: 1 addition & 1 deletion AudioApp/src/store/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ actions: {
params.locations = true;
params.devices = true;
//params.timestamps = true;
params.dates = true;
//params.dates = true; // not static because of time zone
params.samples_table_count = true;
var response = await rootState.api.get('projects/' + rootState.projectId, {params});
commit('setData', response.data);
Expand Down
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ dependencies {
implementation group: 'org.tinylog', name: 'tinylog-impl', version: '2.6.1'
runtimeOnly group: 'org.tinylog', name: 'slf4j-tinylog', version: '2.6.1'

implementation group: 'org.eclipse.jetty', name: 'jetty-server', version: '11.0.14'
implementation group: 'org.eclipse.jetty', name: 'jetty-security', version: '11.0.14'
implementation group: 'org.eclipse.jetty.http2', name: 'http2-server', version: '11.0.14'
implementation group: 'org.eclipse.jetty', name: 'jetty-alpn-java-server', version: '11.0.14'
//implementation group: 'org.eclipse.jetty', name: 'jetty-alpn-conscrypt-server', version: '11.0.14' // ALPN support for Java 8
implementation group: 'org.eclipse.jetty', name: 'jetty-server', version: '11.0.15'
implementation group: 'org.eclipse.jetty', name: 'jetty-security', version: '11.0.15'
implementation group: 'org.eclipse.jetty.http2', name: 'http2-server', version: '11.0.15'
implementation group: 'org.eclipse.jetty', name: 'jetty-alpn-java-server', version: '11.0.15'
//implementation group: 'org.eclipse.jetty', name: 'jetty-alpn-conscrypt-server', version: '11.0.15' // ALPN support for Java 8

implementation group: 'org.json', name: 'json', version: '20230227'
implementation group: 'org.yaml', name: 'snakeyaml', version: '1.33'
Expand Down
2 changes: 1 addition & 1 deletion src/audio/AudioProjectConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static class Builder {
public Map<String, AudioProfile> profileMap = null;

public int audio_cache_max_files = 20;
public String time_zone = "UTC";
public String time_zone = ""; // possible values UTC, UTC+1, UTC-1, UTC+2 etc. missing value or empty string means no time zone, internally this is UTC but without time zone label.

public Builder() {}

Expand Down
2 changes: 1 addition & 1 deletion src/audio/MetaCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static boolean createYaml(File file, Path yamlPath) {
Vec<Object> logList = new Vec<Object>();
LinkedHashMap<String, Object> logO = new LinkedHashMap<String, Object>();
logO.put("action", "create_yaml");
logO.put("date", LocalDateTime.now().format(ISO_FORMATTER));
logO.put("date", AudioTimeUtil.timeTextOfNow());
logList.add(logO);
m.put("log", logList);
YamlUtil.writeSafeYamlMap(yamlPath, m);
Expand Down
44 changes: 44 additions & 0 deletions src/audio/SampleManagerConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,21 @@ public static enum SQL {
QUERY_TIMESTAMPS_ALL("SELECT DISTINCT TIMESTAMP FROM SAMPLE ORDER BY TIMESTAMP"),

QUERY_DATES_ALL("SELECT DISTINCT (TIMESTAMP - (TIMESTAMP % 86400)) AS DATE FROM SAMPLE ORDER BY DATE"),

QUERY_ZONED_DATES_ALL("SELECT DISTINCT ((TIMESTAMP + ?) - ((TIMESTAMP + ?) % 86400)) AS DATE FROM SAMPLE ORDER BY DATE"),

QUERY_TIMESTAMPS_AT_LOCATION("SELECT DISTINCT TIMESTAMP FROM SAMPLE WHERE LOCATION = ? ORDER BY TIMESTAMP"),

QUERY_DATES_AT_LOCATION("SELECT DISTINCT (TIMESTAMP - (TIMESTAMP % 86400)) AS DATE FROM SAMPLE WHERE LOCATION = ? ORDER BY DATE"),

QUERY_ZONED_DATES_AT_LOCATION("SELECT DISTINCT ((TIMESTAMP + ?) - ((TIMESTAMP + ?) % 86400)) AS DATE FROM SAMPLE WHERE LOCATION = ? ORDER BY DATE"),

QUERY_TIMESTAMPS_AT_LOCATION_NULL("SELECT DISTINCT TIMESTAMP FROM SAMPLE WHERE LOCATION IS NULL ORDER BY TIMESTAMP"),

QUERY_DATES_AT_LOCATION_NULL("SELECT DISTINCT (TIMESTAMP - (TIMESTAMP % 86400)) AS DATE FROM SAMPLE WHERE LOCATION IS NULL ORDER BY DATE"),

QUERY_ZONED_DATES_AT_LOCATION_NULL("SELECT DISTINCT ((TIMESTAMP + ?) - ((TIMESTAMP + ?) % 86400)) AS DATE FROM SAMPLE WHERE LOCATION IS NULL ORDER BY DATE"),


QUERY_DEVICES_ALL("SELECT DISTINCT DEVICE FROM SAMPLE WHERE NOT LOCKED ORDER BY DEVICE"),

Expand Down Expand Up @@ -397,6 +403,21 @@ public void forEachDate(LongConsumer consumer) {
throw new RuntimeException(e);
}
}

public void forEachZonedDate(int timeZoneOffsetSeconds, LongConsumer consumer) {
try {
PreparedStatement stmt = getStatement(SQL.QUERY_ZONED_DATES_ALL);
stmt.setInt(1, timeZoneOffsetSeconds);
stmt.setInt(2, timeZoneOffsetSeconds);
ResultSet res = stmt.executeQuery();
while(res.next()) {
long timestamp = res.getLong(1) - timeZoneOffsetSeconds; // convert back to UTC
consumer.accept(timestamp);
}
} catch (SQLException e) {
throw new RuntimeException(e);
}
}

public void forEachTimestamp(String location, LongConsumer consumer) {
PreparedStatement stmt;
Expand Down Expand Up @@ -435,6 +456,29 @@ public void forEachDate(String location, LongConsumer consumer) {
throw new RuntimeException(e);
}
}

public void forEachZonedDate(String location, int timeZoneOffsetSeconds, LongConsumer consumer) {
PreparedStatement stmt;
try {
if(location == null) {
stmt = getStatement(SQL.QUERY_ZONED_DATES_AT_LOCATION_NULL);
stmt.setInt(1, timeZoneOffsetSeconds);
stmt.setInt(2, timeZoneOffsetSeconds);
} else {
stmt = getStatement(SQL.QUERY_ZONED_DATES_AT_LOCATION);
stmt.setInt(1, timeZoneOffsetSeconds);
stmt.setInt(2, timeZoneOffsetSeconds);
stmt.setString(3, location);
}
ResultSet res = stmt.executeQuery();
while(res.next()) {
long timestamp = res.getLong(1) - timeZoneOffsetSeconds; // convert back to UTC
consumer.accept(timestamp);
}
} catch (SQLException e) {
throw new RuntimeException(e);
}
}

public int count() {
try {
Expand Down
6 changes: 5 additions & 1 deletion src/audio/server/Webserver.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.TimeZone;
import java.util.stream.StreamSupport;

import jakarta.servlet.ServletException;
Expand Down Expand Up @@ -62,6 +65,7 @@
import audio.server.api.WebAuthnHandler;
import audio.server.api.WorklistsHandler;
import photo2.api.PhotoDB2Handler;
import util.AudioTimeUtil;

public class Webserver {

Expand Down Expand Up @@ -213,7 +217,7 @@ public static void main(String[] args) throws Exception {
if(httpsPort > 0) {
s += " [at HTTPS port " + httpsPort + "]";
}
Logger.info(s);
Logger.info(s);
server.join();
Logger.info("*** Server stopped ***");
}
Expand Down
Loading

0 comments on commit eee0789

Please sign in to comment.