Skip to content

Commit

Permalink
Dropped 'fictive' 'follow' and 'recordTrace' properties from the 'Dev…
Browse files Browse the repository at this point in the history
…ice' entity
  • Loading branch information
vitalidze committed Dec 7, 2015
1 parent 8866bc7 commit bfe1e1b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,35 +81,6 @@ public DeviceController(MapController mapController,
this.deviceGeoFences = deviceGeoFences;
this.groupStore = groupStore;

this.deviceStore.addStoreRecordChangeHandler(new StoreRecordChangeEvent.StoreRecordChangeHandler<Device>() {
@Override
public void onRecordChange(StoreRecordChangeEvent<Device> event) {
if (event.getProperty().getPath().equals("follow")) {
boolean follow = (Boolean) event.getRecord().getValue(event.getProperty());
Device device = event.getRecord().getModel();
if (follow) {
ApplicationContext.getInstance().follow(device);
for (int i = 0; i < deviceStore.size(); i++) {
Device next = deviceStore.get(i);
if (next.getId() != device.getId()) {
ApplicationContext.getInstance().stopFollowing(next);
deviceStore.getRecord(next).revert(event.getProperty());
}
}
} else {
ApplicationContext.getInstance().stopFollowing(device);
}
} else if (event.getProperty().getPath().equals("recordTrace")) {
boolean recordTrace = (Boolean) event.getRecord().getValue(event.getProperty());
Device device = event.getRecord().getModel();
if (recordTrace) {
ApplicationContext.getInstance().recordTrace(device);
} else {
ApplicationContext.getInstance().stopRecordingTrace(device);
}
}
}
});
deviceView = new DeviceView(this, geoFenceHandler, commandHandler, deviceStore, geoFenceStore, groupStore);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ public interface DeviceProperties extends PropertyAccess<Device> {
@Path("name")
LabelProvider<Device> label();

ValueProvider<Device, Boolean> follow();

ValueProvider<Device, Boolean> recordTrace();

ValueProvider<Device, Double> odometer();

ValueProvider<Device, Boolean> autoUpdateOdometer();
Expand Down
46 changes: 42 additions & 4 deletions src/main/java/org/traccar/web/client/view/DeviceView.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.sencha.gxt.cell.core.client.form.CheckBoxCell;
import com.sencha.gxt.core.client.ToStringValueProvider;
import com.sencha.gxt.core.client.ValueProvider;
import com.sencha.gxt.core.client.XTemplates;
import com.sencha.gxt.data.shared.SortInfo;
import com.sencha.gxt.data.shared.Store;
Expand Down Expand Up @@ -359,16 +360,53 @@ public void onBrowserEvent(Context context, Element parent, String value, Native
Resources resources = GWT.create(Resources.class);
HeaderIconTemplate headerTemplate = GWT.create(HeaderIconTemplate.class);

ColumnConfig<Device, Boolean> colFollow = new ColumnConfig<>(deviceProperties.follow(), 50,
headerTemplate.render(AbstractImagePrototype.create(resources.follow()).getSafeHtml()));
ColumnConfig<Device, Boolean> colFollow = new ColumnConfig<>(new ValueProvider<Device, Boolean>() {

@Override
public Boolean getValue(Device device) {
return ApplicationContext.getInstance().isFollowing(device);
}

@Override
public void setValue(Device device, Boolean value) {
if (value) {
ApplicationContext.getInstance().follow(device);
} else {
ApplicationContext.getInstance().stopFollowing(device);
}
}

@Override
public String getPath() {
return "follow";
}
}, 50, headerTemplate.render(AbstractImagePrototype.create(resources.follow()).getSafeHtml()));
colFollow.setCell(new CheckBoxCell());
colFollow.setFixed(true);
colFollow.setResizable(false);
colFollow.setToolTip(new SafeHtmlBuilder().appendEscaped(i18n.follow()).toSafeHtml());
columnConfigList.add(colFollow);

ColumnConfig<Device, Boolean> colRecordTrace = new ColumnConfig<>(deviceProperties.recordTrace(), 50,
headerTemplate.render(AbstractImagePrototype.create(resources.footprints()).getSafeHtml()));
ColumnConfig<Device, Boolean> colRecordTrace = new ColumnConfig<>(new ValueProvider<Device, Boolean>() {
@Override
public Boolean getValue(Device device) {
return ApplicationContext.getInstance().isRecordingTrace(device);
}

@Override
public void setValue(Device device, Boolean value) {
if (value) {
ApplicationContext.getInstance().recordTrace(device);
} else {
ApplicationContext.getInstance().stopRecordingTrace(device);
}
}

@Override
public String getPath() {
return "recordTrace";
}
}, 50, headerTemplate.render(AbstractImagePrototype.create(resources.footprints()).getSafeHtml()));
colRecordTrace.setCell(new CheckBoxCell());
colRecordTrace.setFixed(true);
colRecordTrace.setResizable(false);
Expand Down
22 changes: 0 additions & 22 deletions src/main/java/org/traccar/web/shared/model/Device.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,28 +124,6 @@ public void setDescription(String description) {
this.description = description;
}

@JsonIgnore
private transient boolean follow;

public boolean isFollow() {
return follow;
}

public void setFollow(boolean follow) {
this.follow = follow;
}

@JsonIgnore
private transient boolean recordTrace;

public boolean isRecordTrace() {
return recordTrace;
}

public void setRecordTrace(boolean recordTrace) {
this.recordTrace = recordTrace;
}

/**
* Consider device offline after 'timeout' seconds spent from last position
*/
Expand Down

0 comments on commit bfe1e1b

Please sign in to comment.