Skip to content

Commit

Permalink
aHandle setp and units from configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
volterra79 committed Jan 31, 2023
1 parent 94c8c81 commit e30bbef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion components/sidebar/sidebaritem.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function Sidebaritem({service, options={}}={}){
return {
layers,
panel,
step: 1,
step: layers[0].options.step,
format: 'YYYY-MM-DD HH:mm:ss',
min_date: layers[0].start_date,
max_date: layers[0].end_date,
Expand Down Expand Up @@ -52,6 +52,7 @@ export default function Sidebaritem({service, options={}}={}){
*/
initLayerTimeseries(){
this.status = 0;
this.min_date = this.layer.start_date;
this.currentLayerDateTimeIndex = this.layer.start_date;
this.range.value = 0;
this.range.min = 0;
Expand Down
9 changes: 5 additions & 4 deletions service.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ function PluginService(){
this.addProjectLayerFromConfigProject = function(){
this.project.getConfigLayers().forEach(layerConfig => {
if (toRawType(layerConfig.qtimeseries) === 'Object') {
let {field, duration=1, units='d', start_date=null, end_date=null} = layerConfig.qtimeseries;
let {field, step=1, units='d', start_date=null, end_date=null} = layerConfig.qtimeseries;
const startDateTimeZoneOffset = new Date(start_date).getTimezoneOffset();
const endDateTimeZoneOffset = new Date(end_date).getTimezoneOffset();
start_date = moment(start_date).add(startDateTimeZoneOffset, 'minutes');
Expand All @@ -192,6 +192,7 @@ function PluginService(){
options: {
range_max: moment(end_date).diff(moment(start_date), stepunit) - 1,
format,
step, //added
stepunit,
stepunitmultiplier,
field
Expand Down Expand Up @@ -264,11 +265,11 @@ function PluginService(){
}
};

this.resetTimeLayer = function(layer){
this.resetTimeLayer = function(layer, hideInfo=false){
return new Promise((resolve, reject) => {
if (layer.timed){
const mapLayerToUpdate = this.mapService.getMapLayerByLayerId(layer.id);
mapLayerToUpdate.once('loadend', () => {
hideInfo && mapLayerToUpdate.once('loadend', () => {
this.mapService.showMapInfo();
resolve();
});
Expand All @@ -292,7 +293,7 @@ function PluginService(){
*/
this.close = function(){
const layer = this.state.layers.find(layer => layer.timed);
layer && this.resetTimeLayer(layer);
layer && this.resetTimeLayer(layer, true);
this.state.panel.open = false;
this.deactiveChartInteraction();
};
Expand Down

0 comments on commit e30bbef

Please sign in to comment.