Author SHA1 Message Date
handte f8d1a96d0b Release 1.0.6
LocationBasedServices/maptology/pipeline/head This commit looks good
2020-08-13 12:01:57 +02:00
handte c5b69a12e7 Update to 1.0.6-SNAPSHOT.
LocationBasedServices/maptology/pipeline/head This commit looks good
2020-08-13 11:02:33 +02:00
handte 08db82b1f7 Release 1.0.5
LocationBasedServices/maptology/pipeline/head This commit looks good
2020-08-13 11:01:02 +02:00
handte fcd899f25f Change carta urls to point to local installation.
LocationBasedServices/maptology/pipeline/head This commit looks good
2020-08-13 10:21:52 +02:00
Marcus Handte 85c026fa8f Upgrade gradle, plugins, android dependencies and angular code generator.
LocationBasedServices/maptology/pipeline/head This commit looks good
Upgrade gralde to latest version recommended by android studio.
Remove outdated android options in gradle properties.
Upgrade outdated gradle plugins to support npm downloads.
Upgrade android app dependencies to latest versions.
Make logger service constants static final.
Replace angular client generator with swagger codegen.
Adapt angular code to new client.
Integrate proxy config and basehref into angular cli configuration.
Change jenkinsfile to only deploy releases.
Change jenkinsfile to use gradle wrapper instead of fixed version.
Remove dots from user emails to not confuse simple email clients.
2020-06-20 10:28:43 +02:00
handte 8f7aeec0ab Update deployment location, add tools.
LocationBasedServices/maptology/pipeline/head This commit looks good
2020-05-01 00:10:59 +02:00
handte d3ba3f570a Rename public tables.
LocationBasedServices/maptology/master This commit looks good
2020-04-23 23:24:44 +02:00
handte 3c63e9530f Rename timestamp columns.
LocationBasedServices/maptology/master This commit looks good
2020-04-23 22:23:56 +02:00
handte cc66a682f0 Added column length definitions.
LocationBasedServices/maptology/master This commit looks good
2020-04-23 21:27:06 +02:00
84 changed files with 597 additions and 509 deletions
Vendored
+9 -7
View File
@@ -7,8 +7,8 @@ node {
def gradleInfo def gradleInfo
def server = Artifactory.server 'project.nes.uni-due.de' def server = Artifactory.server 'project.nes.uni-due.de'
def gradleBuild = Artifactory.newGradleBuild() def gradleBuild = Artifactory.newGradleBuild()
gradleBuild.tool = 'gradle-5.5.1'
gradleBuild.usesPlugin = true gradleBuild.usesPlugin = true
gradleBuild.useWrapper = true
environment { environment {
ANDROID_SDK_ROOT = '/var/lib/android-sdk' ANDROID_SDK_ROOT = '/var/lib/android-sdk'
@@ -21,6 +21,7 @@ node {
} }
def version = '' def version = ''
def release = false
// configure the deployer based on the version // configure the deployer based on the version
stage('Configure') { stage('Configure') {
@@ -28,10 +29,11 @@ node {
println "Version is: '${version}'" println "Version is: '${version}'"
if (version.endsWith("-SNAPSHOT")) { if (version.endsWith("-SNAPSHOT")) {
println "Using internal-snapshots for publication." println "Using internal-snapshots for publication."
gradleBuild.deployer server: server, repo: 'internal-snapshots' gradleBuild.deployer server: server, repo: 'internal-snapshots'
} else { } else {
println "Using internal-releases for publication." println "Using internal-releases for publication."
gradleBuild.deployer server: server, repo: 'internal-releases' gradleBuild.deployer server: server, repo: 'internal-releases'
release = true
} }
} }
@@ -57,13 +59,13 @@ node {
// deploy the build output on the server // deploy the build output on the server
stage ('Deploy') { stage ('Deploy') {
if (env.BRANCH_NAME == "master") { if (env.BRANCH_NAME == "master" && release) {
withCredentials([sshUserPrivateKey(credentialsId: "maptology-server-key", keyFileVariable: "keyfile")]) { withCredentials([sshUserPrivateKey(credentialsId: "maptology-server-key", keyFileVariable: "keyfile")]) {
sh "scp -i ${keyfile} site-ear/build/libs/site-ear-${version}.ear wildfly@srv.nes.uni-due.de:/opt/wildfly-17-maptology/standalone/deployments/maptology.ear" sh "scp -i ${keyfile} site-ear/build/libs/site-ear-${version}.ear wildfly@apps.nes.uni-due.de:/opt/wildfly-17-maptology/standalone/deployments/maptology.ear"
sh "scp -i ${keyfile} android-app/build/outputs/apk/release/*.apk wildfly@srv.nes.uni-due.de:/opt/android/maptology/" sh "scp -i ${keyfile} android-app/build/outputs/apk/release/*.apk wildfly@apps.nes.uni-due.de:/opt/android/maptology/"
} }
} else { } else {
echo "Skipping deployment for non-master branch." echo "Skipping deployment for non-master branch or non-release build."
} }
} }
+9 -9
View File
@@ -3,12 +3,12 @@ description = "Maptology Android App"
dependencies { dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"]) implementation fileTree(dir: "libs", include: ["*.jar"])
implementation project(":android-feign") implementation project(":android-feign")
implementation "androidx.legacy:legacy-support-v4:${versionAndroidx}" implementation "androidx.legacy:legacy-support-v4:${versionAndroidxLegacy}"
implementation "androidx.appcompat:appcompat:${versionAndroidx}" implementation "androidx.appcompat:appcompat:${versionAndroidxCompat}"
implementation "androidx.preference:preference:${versionAndroidx}" implementation "androidx.preference:preference:${versionAndroidxPreference}"
implementation "androidx.cardview:cardview:${versionAndroidx}" implementation "androidx.cardview:cardview:${versionAndroidxCard}"
implementation "androidx.recyclerview:recyclerview:${versionAndroidx}" implementation "androidx.recyclerview:recyclerview:${versionAndroidxRecycler}"
implementation "com.google.android.material:material:${versionAndroidx}" implementation "com.google.android.material:material:${versionAndroidxMaterial}"
implementation "com.google.android.gms:play-services-oss-licenses:${versionPlay}" implementation "com.google.android.gms:play-services-oss-licenses:${versionPlay}"
testImplementation "junit:junit:${versionJunit}" testImplementation "junit:junit:${versionJunit}"
testImplementation "org.robolectric:robolectric:${versionRobolectric}" testImplementation "org.robolectric:robolectric:${versionRobolectric}"
@@ -22,12 +22,12 @@ configurations {
} }
android { android {
compileSdkVersion 28 compileSdkVersion 29
defaultConfig { defaultConfig {
applicationId "com.maptology.android.app" applicationId "com.maptology.android.app"
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 28 targetSdkVersion 29
versionCode 10 versionCode 11
versionName "${version}" versionName "${version}"
buildConfigField "long", "BUILD_TIME", System.currentTimeMillis() + "L" buildConfigField "long", "BUILD_TIME", System.currentTimeMillis() + "L"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -34,22 +34,22 @@ public class LoggerService extends AbstractService {
/** /**
* The key for the detailed gps data. * The key for the detailed gps data.
*/ */
private String METADATA_GPS = "gps"; private static final String METADATA_GPS = "gps";
/** /**
* The key for the acceleration sensor. * The key for the acceleration sensor.
*/ */
private String METADATA_ACCELEROMETER = "accel"; private static final String METADATA_ACCELEROMETER = "accel";
/** /**
* The key for the gyroscope. * The key for the gyroscope.
*/ */
private String METADATA_GYROSCOPE = "gyro"; private static final String METADATA_GYROSCOPE = "gyro";
/** /**
* The key for the magnetometer. * The key for the magnetometer.
*/ */
private String METADATA_MAGNETOMETER = "magnet"; private static final String METADATA_MAGNETOMETER = "magnet";
/** /**
* The notification id of the foreground service indicator. * The notification id of the foreground service indicator.
@@ -547,7 +547,7 @@ public class LoggerService extends AbstractService {
public void setRegistered(boolean registered) { public void setRegistered(boolean registered) {
this.registered = registered; this.registered = registered;
} }
}; }
/** /**
@@ -613,9 +613,8 @@ public class LoggerService extends AbstractService {
@Override @Override
public void onSensorChanged(SensorEvent event) { public void onSensorChanged(SensorEvent event) {
long prev = 0;
if (data.size() > 0) { if (data.size() > 0) {
prev = data.get(data.size() - 1)[0]; long prev = data.get(data.size() - 1)[0];
long diff = event.timestamp / 1000 - prev; long diff = event.timestamp / 1000 - prev;
if (diff / 1000 < SAMPLING_DELAY_SENSOR) return; if (diff / 1000 < SAMPLING_DELAY_SENSOR) return;
} }
@@ -3,6 +3,8 @@ package com.maptology.android.app.fragment;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.locoslab.android.leafless.IMapStateListener; import com.locoslab.android.leafless.IMapStateListener;
import com.locoslab.android.leafless.ITouchListener; import com.locoslab.android.leafless.ITouchListener;
import com.locoslab.android.leafless.MapOptions; import com.locoslab.android.leafless.MapOptions;
@@ -31,18 +33,16 @@ import com.maptology.android.feign.model.Coordinate;
import android.database.Cursor; import android.database.Cursor;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import androidx.fragment.app.FragmentTransaction;
import androidx.collection.LongSparseArray;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.collection.LongSparseArray;
import androidx.fragment.app.FragmentTransaction;
/** /**
* A fragment that displays a map. * A fragment that displays a map.
@@ -288,7 +288,7 @@ public class MapFragment extends AbstractFragment {
// apply the state // apply the state
getRepository().mapState.getValue().applyTo(map); getRepository().mapState.getValue().applyTo(map);
// add a tile layer // add a tile layer
map.addLayer(new TileLayer(new TileLayerOptions("https://cloud.locoslab.com/carta/restful-services/tile/{z}/{x}/{y}.png"))); map.addLayer(new TileLayer(new TileLayerOptions("https://www.maptology.com/carta/tile/{z}/{x}/{y}.png")));
// add map interaction // add map interaction
map.addShortTapListener(new ITouchListener() { map.addShortTapListener(new ITouchListener() {
@Override @Override
@@ -461,7 +461,7 @@ public class MapFragment extends AbstractFragment {
getRepository().mapMode.setValue(MapMode.values()[code]); getRepository().mapMode.setValue(MapMode.values()[code]);
} }
/** /**
* Applies the current map mode. * Applies the current map mode.
*/ */
+9 -4
View File
@@ -1,8 +1,8 @@
buildscript { buildscript {
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.5.2' classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.10.0' classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.10.0'
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.0.Fixed' classpath 'com.google.android.gms:oss-licenses-plugin:0.10.2'
classpath 'org.handte.gradle:gradle-android-eclipse:1.0.0' classpath 'org.handte.gradle:gradle-android-eclipse:1.0.0'
} }
@@ -28,7 +28,7 @@ allprojects {
// set version for our project // set version for our project
group = 'com.maptology' group = 'com.maptology'
version = '1.0.5-SNAPSHOT' version = '1.0.6'
// set versions for our libraries // set versions for our libraries
ext { ext {
@@ -51,7 +51,12 @@ allprojects {
versionThorntail = '2.5.0.Final' versionThorntail = '2.5.0.Final'
// android stuff // android stuff
versionAndroidx = '1.0.0' versionAndroidxCompat = '1.2.0'
versionAndroidxLegacy = '1.0.0'
versionAndroidxPreference = '1.1.1'
versionAndroidxCard = '1.0.0'
versionAndroidxRecycler = '1.1.0'
versionAndroidxMaterial = '1.2.0'
versionRobolectric = '4.3.1' versionRobolectric = '4.3.1'
versionPlay = '17.0.0' versionPlay = '17.0.0'
versionAndroidxTest = '1.2.0' versionAndroidxTest = '1.2.0'
+1 -1
View File
@@ -6,7 +6,7 @@ description = 'Maptology Common Api'
dependencies { dependencies {
testCompile "junit:junit:${versionJunit}" testCompile "junit:junit:${versionJunit}"
compileOnly "javax.xml.bind:jaxb-api:${versionJaxb}" compile "javax.xml.bind:jaxb-api:${versionJaxb}"
compileOnly "jakarta.platform:jakarta.jakartaee-api:${versionJavaee}" compileOnly "jakarta.platform:jakarta.jakartaee-api:${versionJavaee}"
compileOnly "io.swagger:swagger-annotations:${versionSwagger}" compileOnly "io.swagger:swagger-annotations:${versionSwagger}"
compileOnly "com.fasterxml.jackson.core:jackson-annotations:${versionJackson}" compileOnly "com.fasterxml.jackson.core:jackson-annotations:${versionJackson}"
-1
View File
@@ -1,3 +1,2 @@
android.enableJetifier=true android.enableJetifier=true
android.useAndroidX=true android.useAndroidX=true
android.enableR8=true
+2 -2
View File
@@ -1,6 +1,6 @@
#Sun Jul 21 19:24:12 CEST 2019 #Sat Jun 20 07:42:08 CEST 2020
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
@@ -31,7 +31,7 @@ public class LocationConverter extends AbstractConverter<LocationEntity, Locatio
public Location convert(LocationEntity source) { public Location convert(LocationEntity source) {
Location result = create(); Location result = create();
result.setAvailability(source.getAvailability()); result.setAvailability(source.getAvailability());
result.setTimestamp(source.getTimestamp()); result.setTimestamp(source.getMeasurementTime());
result.setCoordinate(convert(source.getCoordinate())); result.setCoordinate(convert(source.getCoordinate()));
return result; return result;
} }
@@ -58,7 +58,7 @@ public class PositionConverter extends AbstractConverter<PositionEntity, Positio
p.setOs(source.getOs()); p.setOs(source.getOs());
p.setProvider(source.getProvider()); p.setProvider(source.getProvider());
p.setSpeed(source.getSpeed()); p.setSpeed(source.getSpeed());
p.setTimestamp(source.getTimestamp()); p.setTimestamp(source.getMeasurementTime());
p.setVersion(source.getVersion()); p.setVersion(source.getVersion());
return p; return p;
} }
@@ -2,6 +2,7 @@ package com.maptology.service.entity;
import java.util.List; import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.EnumType; import javax.persistence.EnumType;
@@ -18,7 +19,7 @@ import javax.persistence.UniqueConstraint;
/** /**
* The entity that represents codes sent out to the user. * The entity that represents codes sent out to the user.
* *
* @author Marcus * @author Marcus
*/ */
@Entity @Entity
@@ -35,31 +36,32 @@ public class CodeEntity extends AbstractEntity {
* Serialization version. * Serialization version.
*/ */
private static final long serialVersionUID = 2477619107225809934L; private static final long serialVersionUID = 2477619107225809934L;
/** /**
* The email to which a code has been sent. * The email to which a code has been sent.
*/ */
@ManyToOne @ManyToOne
@JoinColumn(name="email_id") @JoinColumn(name="email_id")
private EmailEntity email; private EmailEntity email;
/** /**
* The type of code that has been sent out. * The type of code that has been sent out.
*/ */
@Enumerated(EnumType.ORDINAL) @Enumerated(EnumType.ORDINAL)
private CodeType type; private CodeType type;
/** /**
* The value of the code. * The value of the code.
*/ */
@Column(length = 100)
private String value; private String value;
/** /**
* The time when the code expires. * The time when the code expires.
*/ */
private long expirationTime; private long expirationTime;
/** /**
* Returns the email. * Returns the email.
* *
@@ -131,10 +133,10 @@ public class CodeEntity extends AbstractEntity {
public void setExpirationTime(long expirationTime) { public void setExpirationTime(long expirationTime) {
this.expirationTime = expirationTime; this.expirationTime = expirationTime;
} }
/** /**
* Finds a code by value. * Finds a code by value.
* *
* @param em The entity manager. * @param em The entity manager.
* @param value The value to search for. * @param value The value to search for.
* @return The code entity. * @return The code entity.
@@ -148,10 +150,10 @@ public class CodeEntity extends AbstractEntity {
return null; return null;
} }
} }
/** /**
* Returns the active codes of the specified type * Returns the active codes of the specified type
* *
* @param em The entity manager. * @param em The entity manager.
* @param email The email to lookup. * @param email The email to lookup.
* @param type The type. * @param type The type.
@@ -163,5 +165,5 @@ public class CodeEntity extends AbstractEntity {
q.setParameter("email", email); q.setParameter("email", email);
return q.getResultList(); return q.getResultList();
} }
} }
@@ -1,5 +1,6 @@
package com.maptology.service.entity; package com.maptology.service.entity;
import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
@@ -10,7 +11,7 @@ import javax.validation.constraints.Pattern;
/** /**
* An entity to manage email addresses of users. * An entity to manage email addresses of users.
* *
* @author Marcus * @author Marcus
*/ */
@Entity @Entity
@@ -29,19 +30,20 @@ public class EmailEntity extends AbstractEntity {
@ManyToOne @ManyToOne
@JoinColumn(name="user_id") @JoinColumn(name="user_id")
private UserEntity user; private UserEntity user;
/** /**
* The actual email address. * The actual email address.
*/ */
@NotNull @NotNull
@Pattern(regexp=".+@.+\\..+", message="Invalid email address format.") @Pattern(regexp=".+@.+\\..+", message="Invalid email address format.")
@Column(length = 100)
private String address; private String address;
/** /**
* A flag to determine whether this email is verified. * A flag to determine whether this email is verified.
*/ */
private boolean verified; private boolean verified;
/** /**
* A flag to determine whether this email is the primary email. * A flag to determine whether this email is the primary email.
*/ */
@@ -119,5 +121,5 @@ public class EmailEntity extends AbstractEntity {
this.correspondence = correspondence; this.correspondence = correspondence;
} }
} }
@@ -23,10 +23,10 @@ import com.maptology.api.location.Availability;
@Entity @Entity
@Table(name = "location", @Table(name = "location",
indexes = { indexes = {
@Index(columnList = "timestamp", unique = false) @Index(columnList = "measurementTime", unique = false)
}) })
public class LocationEntity extends AbstractEntity { public class LocationEntity extends AbstractEntity {
/** /**
* The serialization version. * The serialization version.
*/ */
@@ -37,7 +37,7 @@ public class LocationEntity extends AbstractEntity {
*/ */
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
private DeviceEntity device; private DeviceEntity device;
/** /**
* The (un-) availability information for the entity. * The (un-) availability information for the entity.
*/ */
@@ -47,8 +47,8 @@ public class LocationEntity extends AbstractEntity {
/** /**
* The measurement time of the location. * The measurement time of the location.
*/ */
private long timestamp; private long measurementTime;
/** /**
* The (optional) coordinate of the location. * The (optional) coordinate of the location.
*/ */
@@ -96,21 +96,21 @@ public class LocationEntity extends AbstractEntity {
} }
/** /**
* Returns the timestamp. * Returns the measurementTime.
* *
* @return The timestamp. * @return The measurementTime.
*/ */
public long getTimestamp() { public long getMeasurementTime() {
return timestamp; return measurementTime;
} }
/** /**
* Sets the timestamp. * Sets the measurementTime.
* *
* @param timestamp The timestamp to set. * @param measurementTime The measurementTime to set.
*/ */
public void setTimestamp(long timestamp) { public void setMeasurementTime(long measurementTime) {
this.timestamp = timestamp; this.measurementTime = measurementTime;
} }
/** /**
@@ -130,5 +130,5 @@ public class LocationEntity extends AbstractEntity {
public void setCoordinate(EmbeddedCoordinate coordinate) { public void setCoordinate(EmbeddedCoordinate coordinate) {
this.coordinate = coordinate; this.coordinate = coordinate;
} }
} }
@@ -15,14 +15,14 @@ import javax.persistence.Table;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
/** /**
* Represents metadata attached to a position. The metadata consist of * Represents metadata attached to a position. The metadata consist of
* a tag-value pair. The value is stored as a clob to allow large metadata * a tag-value pair. The value is stored as a clob to allow large metadata
* items. * items.
* *
* @author Marcus * @author Marcus
*/ */
@Entity @Entity
@Table(name = "metadata", @Table(name = "public_metadata",
indexes = { indexes = {
@Index(columnList = "tag", unique = false) @Index(columnList = "tag", unique = false)
}) })
@@ -31,7 +31,7 @@ import javax.validation.constraints.NotNull;
@IdClass(MetadataId.class) @IdClass(MetadataId.class)
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class MetadataEntity { public class MetadataEntity {
/** /**
* The reference to the position. * The reference to the position.
*/ */
@@ -40,7 +40,7 @@ public class MetadataEntity {
@JoinColumn(name = "position_id") @JoinColumn(name = "position_id")
@ManyToOne(optional = false) @ManyToOne(optional = false)
private PositionEntity position; private PositionEntity position;
/** /**
* The tag to determine the metadata type. * The tag to determine the metadata type.
*/ */
@@ -48,12 +48,12 @@ public class MetadataEntity {
@NotNull @NotNull
@Column(name="tag", length = 64) @Column(name="tag", length = 64)
private String tag; private String tag;
/** /**
* The value with the actual metadata. * The value with the actual metadata.
*/ */
@Lob @Lob
@Column(name="value") @Column(name="value")
private String value; private String value;
/** /**
@@ -108,6 +108,6 @@ public class MetadataEntity {
*/ */
public void setValue(String value) { public void setValue(String value) {
this.value = value; this.value = value;
} }
} }
@@ -37,20 +37,20 @@ import com.maptology.api.location.Availability;
/** /**
* Represents a stored location that has been made available * Represents a stored location that has been made available
* for research purposes. * for research purposes.
* *
* @author Marcus * @author Marcus
*/ */
@Entity @Entity
@Table(name = "position", @Table(name = "public_position",
indexes = { indexes = {
@Index(columnList = "creationTime,timestamp", unique = false), @Index(columnList = "creationTime,measurementTime", unique = false),
@Index(columnList = "device,timestamp", unique = false) @Index(columnList = "device,measurementTime", unique = false)
}) })
@NamedQueries({ @NamedQueries({
@NamedQuery(name="findAllPositions", lockMode=LockModeType.NONE, query="select p from PositionEntity p order by p.id asc"), @NamedQuery(name="findAllPositions", lockMode=LockModeType.NONE, query="select p from PositionEntity p order by p.id asc"),
@NamedQuery(name="getLastPosition", lockMode=LockModeType.NONE, query="select max(p.creationTime) from PositionEntity p"), @NamedQuery(name="getLastPosition", lockMode=LockModeType.NONE, query="select max(p.creationTime) from PositionEntity p"),
@NamedQuery(name="countPositions", lockMode=LockModeType.NONE, query="select count(p) from PositionEntity p"), @NamedQuery(name="countPositions", lockMode=LockModeType.NONE, query="select count(p) from PositionEntity p"),
@NamedQuery(name="findDeviceRangePositions", lockMode=LockModeType.NONE, query="select p from PositionEntity p where p.timestamp>=:minTime and p.timestamp<=:maxTime and p.device in :devices order by p.device, p.timestamp asc"), @NamedQuery(name="findDeviceRangePositions", lockMode=LockModeType.NONE, query="select p from PositionEntity p where p.measurementTime>=:minTime and p.measurementTime<=:maxTime and p.device in :devices order by p.device, p.measurementTime asc"),
@NamedQuery(name="findDevicePositions", lockMode=LockModeType.NONE, query="select p from PositionEntity p where p.device=:device order by p.id asc"), @NamedQuery(name="findDevicePositions", lockMode=LockModeType.NONE, query="select p from PositionEntity p where p.device=:device order by p.id asc"),
@NamedQuery(name="countDevicePositions", lockMode=LockModeType.NONE, query="select count(p) from PositionEntity p where p.device=:device"), @NamedQuery(name="countDevicePositions", lockMode=LockModeType.NONE, query="select count(p) from PositionEntity p where p.device=:device"),
@NamedQuery(name="getLastDevicePosition", lockMode=LockModeType.NONE, query="select max(p.creationTime) from PositionEntity p where p.device=:device") @NamedQuery(name="getLastDevicePosition", lockMode=LockModeType.NONE, query="select max(p.creationTime) from PositionEntity p where p.device=:device")
@@ -68,7 +68,7 @@ public class PositionEntity {
* The id of the device. * The id of the device.
*/ */
private long device; private long device;
/** /**
* The (un-) availability information for the entity. * The (un-) availability information for the entity.
*/ */
@@ -87,17 +87,17 @@ public class PositionEntity {
@Id @Id
@GeneratedValue(strategy = GenerationType.AUTO, generator = "pid_generator") @GeneratedValue(strategy = GenerationType.AUTO, generator = "pid_generator")
private long id; private long id;
/** /**
* The creation time of the position item. * The creation time of the position item.
*/ */
private long creationTime; private long creationTime;
/** /**
* The measurement time of the location. * The measurement time of the location.
*/ */
private long timestamp; private long measurementTime;
/** /**
* The (optional) coordinate of the location. * The (optional) coordinate of the location.
*/ */
@@ -107,43 +107,43 @@ public class PositionEntity {
@AttributeOverride(name="longitude", column=@Column(nullable=true)) @AttributeOverride(name="longitude", column=@Column(nullable=true))
}) })
private EmbeddedCoordinate coordinate; private EmbeddedCoordinate coordinate;
/** /**
* The accuracy in meters. * The accuracy in meters.
*/ */
private Double accuracy; private Double accuracy;
/** /**
* The altitude in meters. * The altitude in meters.
*/ */
private Double altitude; private Double altitude;
/** /**
* The speed in m/s. * The speed in m/s.
*/ */
private Double speed; private Double speed;
/** /**
* The bearing in degree. * The bearing in degree.
*/ */
private Double bearing; private Double bearing;
/** /**
* The location provider. * The location provider.
*/ */
private String provider; private String provider;
/** /**
* The app version. * The app version.
*/ */
private int version; private int version;
/** /**
* Additional meta data collected for the position. * Additional meta data collected for the position.
*/ */
@OneToMany(mappedBy = "position", fetch = FetchType.LAZY) @OneToMany(mappedBy = "position", fetch = FetchType.LAZY)
private Set<MetadataEntity> metadata = new HashSet<>(); private Set<MetadataEntity> metadata = new HashSet<>();
/** /**
* Automatically sets the creation date. * Automatically sets the creation date.
*/ */
@@ -225,21 +225,21 @@ public class PositionEntity {
} }
/** /**
* Returns the timestamp. * Returns the measurementTime.
* *
* @return The timestamp. * @return The measurementTime.
*/ */
public long getTimestamp() { public long getMeasurementTime() {
return timestamp; return measurementTime;
} }
/** /**
* Sets the timestamp. * Sets the measurementTime.
* *
* @param timestamp The timestamp to set. * @param measurementTime The measurementTime to set.
*/ */
public void setTimestamp(long timestamp) { public void setMeasurementTime(long measurementTime) {
this.timestamp = timestamp; this.measurementTime = measurementTime;
} }
/** /**
@@ -367,7 +367,7 @@ public class PositionEntity {
public void setVersion(int version) { public void setVersion(int version) {
this.version = version; this.version = version;
} }
/** /**
* Returns the metadata. * Returns the metadata.
* *
@@ -388,7 +388,7 @@ public class PositionEntity {
/** /**
* Returns the last creation time of the position. * Returns the last creation time of the position.
* *
* @param em The entity manager. * @param em The entity manager.
* @return The maximum time stamp of creation times. * @return The maximum time stamp of creation times.
*/ */
@@ -402,11 +402,11 @@ public class PositionEntity {
return 0; return 0;
} }
} }
/** /**
* Returns the number of positions stored. * Returns the number of positions stored.
* *
* @param em The entity manager. * @param em The entity manager.
* @return The number of positions. * @return The number of positions.
*/ */
@@ -420,10 +420,10 @@ public class PositionEntity {
return 0; return 0;
} }
} }
/** /**
* Finds all positions for the page. * Finds all positions for the page.
* *
* @param em The entity manager. * @param em The entity manager.
* @param page The page config. * @param page The page config.
* @return The positions for the page. * @return The positions for the page.
@@ -434,11 +434,11 @@ public class PositionEntity {
q.setMaxResults(page.getSize()); q.setMaxResults(page.getSize());
return q.getResultList(); return q.getResultList();
} }
/** /**
* Returns the last creation date of a position for the device. * Returns the last creation date of a position for the device.
* *
* @param em The entity manager. * @param em The entity manager.
* @param device The device to search. * @param device The device to search.
* @return The creation time stamp of the last position for the device. * @return The creation time stamp of the last position for the device.
@@ -454,11 +454,11 @@ public class PositionEntity {
return 0; return 0;
} }
} }
/** /**
* Returns the number of positions for a device. * Returns the number of positions for a device.
* *
* @param em The entity manager. * @param em The entity manager.
* @param device The device to search. * @param device The device to search.
* @return The number of positions. * @return The number of positions.
@@ -474,10 +474,10 @@ public class PositionEntity {
return 0; return 0;
} }
} }
/** /**
* Returns a page of positions for the device. * Returns a page of positions for the device.
* *
* @param em The entity manager. * @param em The entity manager.
* @param device The device. * @param device The device.
* @param page The page. * @param page The page.
@@ -490,10 +490,10 @@ public class PositionEntity {
q.setMaxResults(page.getSize()); q.setMaxResults(page.getSize());
return q.getResultList(); return q.getResultList();
} }
/** /**
* Find the positions for a certain set of devices in the specified time range. * Find the positions for a certain set of devices in the specified time range.
* *
* @param em The entity manager. * @param em The entity manager.
* @param devices The devices to search. * @param devices The devices to search.
* @param start The minimum time to return (inclusive) in epoch milliseconds. * @param start The minimum time to return (inclusive) in epoch milliseconds.
@@ -507,5 +507,5 @@ public class PositionEntity {
q.setParameter("maxTime", start + duration); q.setParameter("maxTime", start + duration);
return q.getResultList(); return q.getResultList();
} }
} }
@@ -2,6 +2,7 @@ package com.maptology.service.entity;
import java.util.Set; import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.FetchType; import javax.persistence.FetchType;
@@ -16,7 +17,7 @@ import javax.validation.constraints.NotNull;
/** /**
* An entity to define user roles. * An entity to define user roles.
* *
* @author Marcus * @author Marcus
*/ */
@Entity @Entity
@@ -36,12 +37,14 @@ public class RoleEntity extends AbstractEntity {
* The name of the role. * The name of the role.
*/ */
@NotNull @NotNull
@Column(length = 100)
private String name; private String name;
/** /**
* A human readable description of the role. * A human readable description of the role.
*/ */
@NotNull @NotNull
@Column(length = 100)
private String description; private String description;
/** /**
@@ -94,10 +97,10 @@ public class RoleEntity extends AbstractEntity {
public Set<UserEntity> getUsers() { public Set<UserEntity> getUsers() {
return users; return users;
} }
/** /**
* Finds a role with a given name. * Finds a role with a given name.
* *
* @param name The name. * @param name The name.
* @param em The entity manager. * @param em The entity manager.
* @return The role or null, if it does not exist. * @return The role or null, if it does not exist.
@@ -82,14 +82,14 @@ public class LocationSessionBean extends AbstractPrincipalSessionBean {
Collections.sort(unprocessed, new Comparator<LocationEntity>() { Collections.sort(unprocessed, new Comparator<LocationEntity>() {
@Override @Override
public int compare(LocationEntity o1, LocationEntity o2) { public int compare(LocationEntity o1, LocationEntity o2) {
return Long.compare(o1.getTimestamp(), o2.getTimestamp()); return Long.compare(o1.getMeasurementTime(), o2.getMeasurementTime());
} }
}); });
VisitEntity lastVisit = device.getVisit(); VisitEntity lastVisit = device.getVisit();
LocationEntity lastLocation = device.getLocation(); LocationEntity lastLocation = device.getLocation();
for (ReleasedLocation location: update.getLocations()) { for (ReleasedLocation location: update.getLocations()) {
// check for too old updates (should not happen for a working client) // check for too old updates (should not happen for a working client)
if (lastLocation != null && location.getTimestamp() < lastLocation.getTimestamp()) { if (lastLocation != null && location.getTimestamp() < lastLocation.getMeasurementTime()) {
log.log(Level.SEVERE, "Received an out-of-order location update from device " + device.getId() + ", ignoring it."); log.log(Level.SEVERE, "Received an out-of-order location update from device " + device.getId() + ", ignoring it.");
continue; continue;
} }
@@ -143,7 +143,7 @@ public class LocationSessionBean extends AbstractPrincipalSessionBean {
lastLocation = new LocationEntity(); lastLocation = new LocationEntity();
lastLocation.setAvailability(location.getAvailability()); lastLocation.setAvailability(location.getAvailability());
lastLocation.setDevice(device); lastLocation.setDevice(device);
lastLocation.setTimestamp(location.getTimestamp()); lastLocation.setMeasurementTime(location.getTimestamp());
Coordinate c = location.getCoordinate(); Coordinate c = location.getCoordinate();
if (c != null) { if (c != null) {
lastLocation.setCoordinate(new EmbeddedCoordinate(c.getLongitude(), c.getLatitude())); lastLocation.setCoordinate(new EmbeddedCoordinate(c.getLongitude(), c.getLatitude()));
@@ -440,7 +440,7 @@ public class LocationSessionBean extends AbstractPrincipalSessionBean {
last = in.get(i); last = in.get(i);
} else if (last != null) { } else if (last != null) {
// if we have a reference and current does not have coordinate // if we have a reference and current does not have coordinate
if (last.getTimestamp() - next.getTimestamp() > maxTime) { if (last.getMeasurementTime() - next.getMeasurementTime() > maxTime) {
// ... remove everything that is too old // ... remove everything that is too old
for (int j = i; j >= 0; j--) { for (int j = i; j >= 0; j--) {
out.add(0, in.remove(j)); out.add(0, in.remove(j));
@@ -461,7 +461,7 @@ public class LocationSessionBean extends AbstractPrincipalSessionBean {
private static Long getFirst(List<LocationEntity> in) { private static Long getFirst(List<LocationEntity> in) {
for (int i = 0, s = in.size(); i < s; i++) { for (int i = 0, s = in.size(); i < s; i++) {
if (in.get(i).getCoordinate() != null) { if (in.get(i).getCoordinate() != null) {
return in.get(i).getTimestamp(); return in.get(i).getMeasurementTime();
} }
} }
return null; return null;
@@ -476,7 +476,7 @@ public class LocationSessionBean extends AbstractPrincipalSessionBean {
private static Long getLast(List<LocationEntity> in) { private static Long getLast(List<LocationEntity> in) {
for (int i = in.size() - 1; i >= 0; i--) { for (int i = in.size() - 1; i >= 0; i--) {
if (in.get(i).getCoordinate() != null) { if (in.get(i).getCoordinate() != null) {
return in.get(i).getTimestamp(); return in.get(i).getMeasurementTime();
} }
} }
return null; return null;
@@ -535,7 +535,7 @@ public class LocationSessionBean extends AbstractPrincipalSessionBean {
*/ */
private static boolean isTooOld(LocationEntity current, Location next, long maxDuration) { private static boolean isTooOld(LocationEntity current, Location next, long maxDuration) {
if (current == null || current.getAvailability() == Availability.IDLE) return false; if (current == null || current.getAvailability() == Availability.IDLE) return false;
return (next.getTimestamp() - current.getTimestamp() > maxDuration); return (next.getTimestamp() - current.getMeasurementTime() > maxDuration);
} }
@@ -97,7 +97,7 @@ public class PositionSessionBean implements IPositionSessionBean {
p.setOs(device.getOs()); p.setOs(device.getOs());
p.setProvider(location.getProvider()); p.setProvider(location.getProvider());
p.setSpeed(location.getSpeed()); p.setSpeed(location.getSpeed());
p.setTimestamp(location.getTimestamp()); p.setMeasurementTime(location.getTimestamp());
p.setVersion(location.getVersion()); p.setVersion(location.getVersion());
HashSet<MetadataEntity> metadata = new HashSet<>(); HashSet<MetadataEntity> metadata = new HashSet<>();
if (location.getMetadata() != null) { if (location.getMetadata() != null) {
@@ -257,7 +257,7 @@ public class PositionSessionBean implements IPositionSessionBean {
p.setOs(location.getOs()); p.setOs(location.getOs());
p.setProvider(location.getProvider()); p.setProvider(location.getProvider());
p.setSpeed(location.getSpeed()); p.setSpeed(location.getSpeed());
p.setTimestamp(location.getTimestamp()); p.setMeasurementTime(location.getTimestamp());
p.setVersion(location.getVersion()); p.setVersion(location.getVersion());
em.persist(p); em.persist(p);
if (p.getMetadata() != null) { if (p.getMetadata() != null) {
@@ -5,7 +5,7 @@ we have received a request for a new email address association.
If you have added this email address to your maptology account, If you have added this email address to your maptology account,
please confirm the email address association by visiting please confirm the email address association by visiting
https://www.maptology.com/app/activate/${token}. https://www.maptology.com/app/activate/${token}
If you did not request the association, simply delete this email If you did not request the association, simply delete this email
or contact us. or contact us.
@@ -4,7 +4,7 @@ Dear ${name},
we have received an account request for a new Maptology account. we have received an account request for a new Maptology account.
If you have requested the account, please confirm your email by If you have requested the account, please confirm your email by
visiting https://www.maptology.com/app/activate/${token}. visiting https://www.maptology.com/app/activate/${token}
If you did not request the account, simply delete this email or If you did not request the account, simply delete this email or
contact us. contact us.
@@ -4,7 +4,7 @@ Dear ${name},
we have received a request for a Maptology account reset. we have received a request for a Maptology account reset.
If you have requested the reset, please assign a new password If you have requested the reset, please assign a new password
by visiting https://www.maptology.com/app/reset/${token}. by visiting https://www.maptology.com/app/reset/${token}
If you did not request the reset, simply delete this email or If you did not request the reset, simply delete this email or
contact us. contact us.
@@ -8,7 +8,7 @@ import org.jboss.resteasy.client.jaxrs.engines.URLConnectionEngine;
/** /**
* A simple builder for the geocoder service. * A simple builder for the geocoder service.
* *
* @author Marcus * @author Marcus
*/ */
public class GeocoderBuilder { public class GeocoderBuilder {
@@ -16,26 +16,26 @@ public class GeocoderBuilder {
/** /**
* The default url. * The default url.
*/ */
public static final String GEOCODER_URL = "https://cloud.locoslab.com/carta/restful-services"; public static final String GEOCODER_URL = "https://www.maptology.com/carta";
/** /**
* The url of the service. * The url of the service.
*/ */
public String url = GEOCODER_URL; public String url = GEOCODER_URL;
/** /**
* The socket timeout in seconds. * The socket timeout in seconds.
*/ */
public Long socketTimeout = null; public Long socketTimeout = null;
/** /**
* The connection timeout in seconds. * The connection timeout in seconds.
*/ */
public Long connectionTimeout = null; public Long connectionTimeout = null;
/** /**
* Sets the url. * Sets the url.
* *
* @param url The url to set. * @param url The url to set.
* @return The builder. * @return The builder.
*/ */
@@ -43,10 +43,10 @@ public class GeocoderBuilder {
this.url = url; this.url = url;
return this; return this;
} }
/** /**
* Sets the connection timeout in seconds. * Sets the connection timeout in seconds.
* *
* @param seconds The connection timeout in seconds. * @param seconds The connection timeout in seconds.
* @return The builder. * @return The builder.
*/ */
@@ -54,10 +54,10 @@ public class GeocoderBuilder {
this.connectionTimeout = seconds; this.connectionTimeout = seconds;
return this; return this;
} }
/** /**
* Sets the socket timeout in seconds. * Sets the socket timeout in seconds.
* *
* @param seconds The socket timeout in seconds. * @param seconds The socket timeout in seconds.
* @return The builder. * @return The builder.
*/ */
@@ -0,0 +1,131 @@
package com.maptology.tool;
import java.util.ArrayList;
import java.util.List;
/**
* A delta compression codec based on Google's WGS84 encoder that
* supports multiple data streams to encode other data than latitude
* and longitude values. Callers must supply the number of streams
* encoded in the data and the streams must exhibit the same number
* of data items.
*
* @author Marcus
*/
public class DeltaCodec {
/**
* The number of streams to encode or decode.
*/
private int streams;
/**
* Creates a delta compressor for the specified number of streams.
*
* @param streams The number of streams to encode in the string.
*/
public DeltaCodec(int streams) {
this.streams = streams;
}
/**
* Returns the number of streams expected by this codec.
*
* @return The number of streams.
*/
public int getStreams() {
return streams;
}
/**
* Encodes a list of values into a string.
*
* @param values The values consisting of arrays that represent
* the individual streams.
* @return The string.
*/
public String encode(List<long[]> values) {
StringBuilder builder = new StringBuilder();
long[] previous = new long[streams];
for (int i = 0, s = values.size(); i < s; i++) {
long[] current = values.get(i);
for (int j = 0; j < streams; j++) {
long delta = current[j] - previous[j];
builder.append(encodeSignedNumber(delta));
previous[j] = current[j];
}
}
return builder.toString();
}
/**
* Extracts the list of data from an encoded string.
*
* @param encoded The encoded string.
* @param data An optional list of data items to be reused
* to avoid object allocations. Can be null.
* @return The list of data items representing the streams.
*/
public List<long[]> decode(String encoded, List<long[]> data) {
List<long[]> list = new ArrayList<>();
int index = 0;
int length = encoded.length();
long[] current = new long[streams];
while (index < length) {
long[] next;
if (data != null && data.size() > 0) {
next = data.remove(0);
} else {
next = new long[streams];
}
long c;
for (int i = 0; i < streams; i++) {
long shift = 0;
long result = 0;
do {
c = encoded.charAt(index++) - 63;
result |= (c & 0x1f) << shift;
shift += 5;
} while (c >= 0x20);
long delta = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
current[i] += delta;
next[i] = current[i];
}
list.add(next);
}
return list;
}
/**
* Encodes a signed number as string.
*
* @param num The number.
* @return The string.
*/
private static String encodeSignedNumber(long num) {
long sgn_num = num << 1;
if (num < 0) {
sgn_num = ~(sgn_num);
}
return (encodeNumber(sgn_num));
}
/**
* Encodes an unsigned number as string.
*
* @param num The number.
* @return The string.
*/
private static String encodeNumber(long num) {
StringBuilder encodeString = new StringBuilder();
while (num >= 0x20) {
int nextValue = (int)(0x20 | (num & 0x1f)) + 63;
encodeString.append((char) (nextValue));
num >>= 5;
}
num += 63;
encodeString.append((char) (num));
return encodeString.toString();
}
}
@@ -0,0 +1,50 @@
package com.maptology.tool;
import java.io.File;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.maptology.api.position.Position;
public class GenerateGPSTrace {
public static final long start = new Date(120, 0, 28, 0, 0, 0).getTime();
public static final long end = new Date(120, 2, 3, 23, 59, 59).getTime();
public static void main(String[] args) throws IOException {
System.out.println("EID,Time,Longitude,Latitude");
File folder = new File(ToolUtilities.OUTPUT_FOLDER);
File[] files = folder.listFiles();
for (File input: files) {
if (input.getName().startsWith("device-") && input.getName().endsWith(".json")) {
String deviceId = input.getName().substring(7, input.getName().length() - 5);
//System.out.println("Processing: " + deviceId);
List<Position> positions = ToolUtilities.readPositions(input);
for (Position p: positions) {
if (p.getTimestamp() < start || p.getTimestamp() > end) continue;
if (p.getCoordinate() != null) {
if (p.getMetadata().containsKey("gps")) {
DeltaCodec c = new DeltaCodec(11);
List<long[]> result = c.decode(p.getMetadata().get("gps"), new ArrayList<>());
for (long[] pos: result) {
System.out.println(deviceId + "," + pos[0] + "," + (pos[2] / 10E6) + "," + (pos[3] / 10E6));
}
} else {
System.out.println(deviceId + "," + p.getTimestamp()+ "," + p.getCoordinate().getLongitude()+ "," + p.getCoordinate().getLatitude());
}
}
}
} else {
System.out.println("Skipping: " + input.getName());
}
}
}
}
@@ -1,10 +1,20 @@
package com.maptology.tool; package com.maptology.tool;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.jboss.resteasy.client.jaxrs.BasicAuthentication; import org.jboss.resteasy.client.jaxrs.BasicAuthentication;
import org.jboss.resteasy.client.jaxrs.ResteasyClient; import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.client.jaxrs.engines.URLConnectionEngine; import org.jboss.resteasy.client.jaxrs.engines.URLConnectionEngine;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.maptology.api.position.Position;
/** /**
* The tool configuration and utilities. * The tool configuration and utilities.
* *
@@ -20,7 +30,7 @@ public class ToolUtilities {
/** /**
* The devices * The devices
*/ */
public static long[] DEVICES = new long[] { 361281 }; public static long[] DEVICES = new long[] { 403330, 403336, 403340, 403345, 403349 };
/** /**
* The output folder to write data. * The output folder to write data.
@@ -68,5 +78,28 @@ public class ToolUtilities {
double c = 2 * Math.atan2(Math.sqrt(ax), Math.sqrt(1 - ax)); double c = 2 * Math.atan2(Math.sqrt(ax), Math.sqrt(1 - ax));
return EARTH_RADIUS * c; return EARTH_RADIUS * c;
} }
/**
* Reads all positions from a file.
*
* @param file The file to read.
* @return The positions.
* @throws IOException Thrown if something fails.
*/
public static List<Position> readPositions(File file) throws IOException {
List<Position> result = new ArrayList<Position>();
BufferedReader r = new BufferedReader(new FileReader(file));
try {
ObjectMapper m = new ObjectMapper();
String line;
while ((line = r.readLine()) != null) {
result.add(m.readValue(line, Position.class));
}
} finally {
r.close();
}
return result;
}
} }
@@ -32,12 +32,11 @@ html, body {
// create a map, add polyline set view // create a map, add polyline set view
var mymap = L.map('mapid').setView(polylinePoints[0], 13); var mymap = L.map('mapid').setView(polylinePoints[0], 13);
L.tileLayer('https://cloud.locoslab.com/carta/restful-services/tile/{z}/{x}/{y}.png', { L.tileLayer('https://www.maptology.com/carta/tile/{z}/{x}/{y}.png', {
maxZoom: 20, maxZoom: 20,
attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' + attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' + '<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>', 'Visuals © <a href="https://www.locoslab.com/">LocosLab GmbH</a>'
id: 'mapbox/streets-v11'
}).addTo(mymap); }).addTo(mymap);
var polylineOptions = { var polylineOptions = {
+3 -1
View File
@@ -55,7 +55,9 @@
"serve": { "serve": {
"builder": "@angular-devkit/build-angular:dev-server", "builder": "@angular-devkit/build-angular:dev-server",
"options": { "options": {
"browserTarget": "webapp-ng:build" "baseHref": "/app",
"browserTarget": "webapp-ng:build",
"proxyConfig": "proxy.conf.json"
}, },
"configurations": { "configurations": {
"production": { "production": {
+3
View File
@@ -0,0 +1,3 @@
{
"ngVersion": "9.0.0"
}
+25 -11
View File
@@ -1,9 +1,14 @@
plugins { plugins {
id "com.moowork.node" version "1.3.1" id 'com.github.node-gradle.node' version '2.2.4'
id 'org.hidetake.swagger.generator' version '2.18.1'
} }
description = 'Maptology Web Angular' description = 'Maptology Web Angular'
dependencies {
swaggerCodegen 'io.swagger:swagger-codegen-cli:2.4.12'
}
node { node {
version = '10.16.0' version = '10.16.0'
npmVersion = '6.9.0' npmVersion = '6.9.0'
@@ -17,13 +22,6 @@ class IoNodeTask extends com.moowork.gradle.node.task.NodeTask {
File outputDir; File outputDir;
} }
task genApi(type: IoNodeTask) {
script = file('node_modules/angular4-swagger-client-generator/bin/a4apigen.js')
args = ['-s', '../common-api/build/swagger/maptology.json', '-o', './src/api']
inputFile = project.file('../common-api/build/swagger/maptology.json')
outputDir = project.file('./src/api/')
}
task cleanApi(type: Delete) { task cleanApi(type: Delete) {
delete './src/api', './dist' delete './src/api', './dist'
} }
@@ -35,11 +33,27 @@ task ngBuild(type: IoNodeTask) {
outputDir = project.file('./dist/') outputDir = project.file('./dist/')
} }
swaggerSources {
maptology {
inputFile = file(project(':common-api:').buildDir.path + '/swagger/maptology.json')
code {
outputDir = file("./src/api/")
language = 'typescript-angular'
configFile = file('apiconfig.json')
components = [models: true, apis: 'Default', supportingFiles: 'configuration.ts,encoder.ts,api.ts,models.ts,variables.ts']
wipeOutputDir = true
}
}
}
// require api build to access swagger definition
tasks['resolveSwaggerTemplate'].dependsOn(project(':common-api').tasks['build'])
// make sure that common api is built before generating the api // make sure that common api is built before generating the api
genApi.dependsOn(npmInstall) ngBuild.dependsOn(npmInstall)
genApi.dependsOn(project(":common-api").tasks['build'])
// generate the api before running ng build // generate the api before running ng build
ngBuild.dependsOn("genApi") ngBuild.dependsOn("generateSwaggerCode")
// run ng build whenever the project is built // run ng build whenever the project is built
build.dependsOn("ngBuild") build.dependsOn("ngBuild")
+6 -8
View File
@@ -4,13 +4,12 @@
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
"api": "a4apigen -s ../common-api/build/swagger/maptology.json -o ./src/api", "start": "ng serve --host 0.0.0.0",
"start": "npm run api && ng serve --host 0.0.0.0 --proxy-config proxy.conf.json --base-href=/app/", "build": "ng build",
"build": "npm run api && ng build", "test": "ng test",
"test": "npm run api && ng test", "lint": "ng lint",
"lint": "npm run api && ng lint", "e2e": "ng e2e",
"e2e": "npm run api && ng e2e", "release": "ng b --prod"
"release": "npm run api && ng b --prod"
}, },
"private": true, "private": true,
"dependencies": { "dependencies": {
@@ -45,7 +44,6 @@
"@types/leaflet": "^1.4.6", "@types/leaflet": "^1.4.6",
"@types/node": "^12.11.1", "@types/node": "^12.11.1",
"acorn": "^6.2.0", "acorn": "^6.2.0",
"angular4-swagger-client-generator": "0.1.13",
"codelyzer": "^5.1.2", "codelyzer": "^5.1.2",
"events": "^3.0.0", "events": "^3.0.0",
"jasmine-core": "^2.8.0", "jasmine-core": "^2.8.0",
+5 -2
View File
@@ -1,8 +1,11 @@
{ {
"/api": { "/api": {
"target": "https://maptology.com", "target": "https://maptology.com",
"secure": false, "secure": true,
"ws": true, "ws": true,
"logLevel": "debug" "logLevel": "debug",
"headers" : {
"Host" : "maptology.com"
}
} }
} }
+3
View File
@@ -0,0 +1,3 @@
export * from '../api/api/api';
export * from '../api/model/models';
export * from '../api/configuration';
+3 -3
View File
@@ -51,7 +51,7 @@ import { ToolbarButtonComponent } from './widgets/toolbar-button.component';
import { LoginComponent } from './views/login.component'; import { LoginComponent } from './views/login.component';
import { DelayInterceptor } from './interceptors/delay.interceptor'; import { DelayInterceptor } from './interceptors/delay.interceptor';
import { AuthInterceptor } from './interceptors/auth.interceptor'; import { AuthInterceptor } from './interceptors/auth.interceptor';
import { ApiClientService } from '../api'; import { DefaultService, Configuration} from './api';
import { ConsoleService } from './services/console.service'; import { ConsoleService } from './services/console.service';
import { UserService } from './services/user.service'; import { UserService } from './services/user.service';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
@@ -226,7 +226,7 @@ registerLocaleData(LocaleDE);
], ],
providers: [ providers: [
// injection token for http client // injection token for http client
{ provide: 'domain', useValue: apidomain().http }, { provide: Configuration, useValue: new Configuration({ basePath: apidomain().http }) },
{ provide: 'wsdomain', useValue: apidomain().ws }, { provide: 'wsdomain', useValue: apidomain().ws },
// location stategy for passing that with the router // location stategy for passing that with the router
{ provide: LocationStrategy, useClass: PathLocationStrategy }, { provide: LocationStrategy, useClass: PathLocationStrategy },
@@ -238,7 +238,7 @@ registerLocaleData(LocaleDE);
{ provide: MatPaginatorIntl, useClass: GermanPaginatorProvider }, { provide: MatPaginatorIntl, useClass: GermanPaginatorProvider },
DatePipe, DatePipe,
// add our application services (api access, logging, authentication) // add our application services (api access, logging, authentication)
ApiClientService, ConsoleService, AuthGuard, DefaultService, ConsoleService, AuthGuard,
ResourceService, CredentialService, UserService, VersionService, ExportService, ResourceService, CredentialService, UserService, VersionService, ExportService,
DeviceService, PrivilegeService, PlaceService, NoticeService, PlaceVisitService, DeviceVisitService, DevicePositionService, DeviceService, PrivilegeService, PlaceService, NoticeService, PlaceVisitService, DeviceVisitService, DevicePositionService,
ManageLogService, ManageUserService, ManageNoticeService ManageLogService, ManageUserService, ManageNoticeService
@@ -1,7 +1,4 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { ConsoleService } from './console.service';
import { BehaviorSubject } from 'rxjs';
import { HttpErrorResponse } from '@angular/common/http';
/** /**
* A service to manage the user's credentials. This service only * A service to manage the user's credentials. This service only
@@ -1,8 +1,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable, BehaviorSubject } from 'rxjs'; import { Observable, BehaviorSubject } from 'rxjs';
import { DataSource } from '@angular/cdk/table'; import { DataSource } from '@angular/cdk/table';
import { Device, Position } from '../../api/models'; import { DefaultService, Device, Position } from '../api';
import { ApiClientService } from '../../api';
import { CollectionViewer } from '@angular/cdk/collections'; import { CollectionViewer } from '@angular/cdk/collections';
import { DeltaCodec } from "../utils/deltacodec"; import { DeltaCodec } from "../utils/deltacodec";
@@ -23,7 +22,7 @@ export class DevicePositionService implements DataSource<Position> {
private id: number; private id: number;
private subscriptions = 0; private subscriptions = 0;
constructor(private apiClientService: ApiClientService) { } constructor(private apiClientService: DefaultService) { }
getPositions(): Position[] { getPositions(): Position[] {
return this.elements.getValue(); return this.elements.getValue();
@@ -37,7 +36,7 @@ export class DevicePositionService implements DataSource<Position> {
this.id = id; this.id = id;
if (id != null) { if (id != null) {
this.apiClientService.getDevice(id).subscribe((result) => { this.apiClientService.getDevice(id).subscribe((result) => {
this.device.next(result.body); this.device.next(result);
this.loading.next(false); this.loading.next(false);
this.setDate(this.date.getValue()); this.setDate(this.date.getValue());
}, (error) => { }, (error) => {
@@ -56,7 +55,7 @@ export class DevicePositionService implements DataSource<Position> {
this.date.next(d); this.date.next(d);
this.elements.next([]); this.elements.next([]);
this.apiClientService.getDevicePositionsRange(this.id, millis, 24 * 60 * 60 * 1000, true).subscribe((result) => { this.apiClientService.getDevicePositionsRange(this.id, millis, 24 * 60 * 60 * 1000, true).subscribe((result) => {
this.elements.next(result.body.sort((a, b) => a.timestamp - b.timestamp)); this.elements.next(result.sort((a, b) => a.timestamp - b.timestamp));
this.loading.next(false); this.loading.next(false);
}, (error) => { }, (error) => {
this.elements.next([]); this.elements.next([]);
@@ -1,12 +1,8 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Subject , Observable, BehaviorSubject } from 'rxjs'; import { Observable, BehaviorSubject } from 'rxjs';
import { DataSource } from '@angular/cdk/table'; import { DataSource } from '@angular/cdk/table';
import { Device, DevicePage, Privilege, PrivilegePage, Place, PlacePage, Visit, VisitPage } from '../../api/models'; import { DefaultService, Device, Place, Visit } from '../api';
import { ApiClientService } from '../../api';
import { UserService } from './user.service';
import { CollectionViewer } from '@angular/cdk/collections'; import { CollectionViewer } from '@angular/cdk/collections';
import { AbstractPageService } from '../utils/pagination';
import { HttpResponse } from '@angular/common/http';
/** /**
* A service that handles visits for a particular device and time. * A service that handles visits for a particular device and time.
@@ -24,7 +20,7 @@ export class DeviceVisitService implements DataSource<Visit> {
private id: number; private id: number;
private subscriptions = 0; private subscriptions = 0;
constructor(private apiClientService: ApiClientService) { constructor(private apiClientService: DefaultService) {
} }
getVisits(): Visit[] { getVisits(): Visit[] {
@@ -39,7 +35,7 @@ export class DeviceVisitService implements DataSource<Visit> {
this.id = id; this.id = id;
if (id != null) { if (id != null) {
this.apiClientService.getDevice(id).subscribe((result) => { this.apiClientService.getDevice(id).subscribe((result) => {
this.device.next(result.body); this.device.next(result);
this.loading.next(false); this.loading.next(false);
this.setDate(this.date.getValue()); this.setDate(this.date.getValue());
}, (error) => { }, (error) => {
@@ -58,7 +54,7 @@ export class DeviceVisitService implements DataSource<Visit> {
this.date.next(d); this.date.next(d);
this.elements.next([]); this.elements.next([]);
this.apiClientService.getDeviceVisitsRange(this.id, millis, 24 * 60 * 60 * 1000).subscribe((result) => { this.apiClientService.getDeviceVisitsRange(this.id, millis, 24 * 60 * 60 * 1000).subscribe((result) => {
this.elements.next(result.body); this.elements.next(result);
this.loadPlaces(); this.loadPlaces();
}, (error) => { }, (error) => {
this.elements.next([]); this.elements.next([]);
@@ -84,7 +80,7 @@ export class DeviceVisitService implements DataSource<Visit> {
this.loaders = ids.length; this.loaders = ids.length;
for (const v of ids) { for (const v of ids) {
this.apiClientService.getPlace(v).subscribe((result) => { this.apiClientService.getPlace(v).subscribe((result) => {
this.finishLoading(v, result.body); this.finishLoading(v, result);
}, (error) => { }, (error) => {
this.finishLoading(v, null); this.finishLoading(v, null);
}); });
@@ -1,12 +1,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Subject , Observable, BehaviorSubject } from 'rxjs'; import { Observable } from 'rxjs';
import { DataSource } from '@angular/cdk/table'; import { DefaultService, Device, DevicePage } from '../api';
import { Device, DevicePage } from '../../api/models';
import { ApiClientService } from '../../api';
import { UserService } from './user.service';
import { CollectionViewer } from '@angular/cdk/collections';
import { AbstractPageService } from '../utils/pagination'; import { AbstractPageService } from '../utils/pagination';
import { HttpResponse } from '@angular/common/http';
/** /**
* A service that handles devices. * A service that handles devices.
@@ -14,11 +9,11 @@ import { HttpResponse } from '@angular/common/http';
@Injectable() @Injectable()
export class DeviceService extends AbstractPageService<Device, DevicePage> { export class DeviceService extends AbstractPageService<Device, DevicePage> {
constructor(apiClientService: ApiClientService) { constructor(apiClientService: DefaultService) {
super(apiClientService); super(apiClientService);
} }
protected loadPage(offset: number, size: number): Observable<HttpResponse<DevicePage>> { protected loadPage(offset: number, size: number): Observable<DevicePage> {
return this.apiClientService.getCurrentUserDevices(offset, size); return this.apiClientService.getCurrentUserDevices(offset, size);
} }
@@ -1,10 +1,9 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { BehaviorSubject, empty } from 'rxjs'; import { BehaviorSubject, empty } from 'rxjs';
import { ApiClientService, Order } from '../../api'; import { DefaultService, PlacePage, VisitPage, DevicePage } from '../api';
import { PlacePage, VisitPage, DevicePage } from '../../api/models';
import { Page } from '../utils/pagination'; import { Page } from '../utils/pagination';
import * as JSZip from 'jszip'; import * as JSZip from 'jszip';
import { UserService, UserState } from './user.service'; import { UserService } from './user.service';
/** /**
* A service that handles the download of * A service that handles the download of
* data to create exports. * data to create exports.
@@ -29,7 +28,7 @@ export class ExportService {
return { elements: [], offset: 0, total: -1, size: 0 }; return { elements: [], offset: 0, total: -1, size: 0 };
} }
constructor(private apiClientService: ApiClientService, private userService: UserService) { } constructor(private apiClientService: DefaultService, private userService: UserService) { }
startDownload(): void { startDownload(): void {
if (this.downloading.getValue()) { return; } if (this.downloading.getValue()) { return; }
@@ -44,17 +43,17 @@ export class ExportService {
this.apiClientService.getCurrentUserDevices(this.devices.getValue().offset, ExportService.BATCH_SIZE) this.apiClientService.getCurrentUserDevices(this.devices.getValue().offset, ExportService.BATCH_SIZE)
.subscribe(response => { .subscribe(response => {
if (code === this.request) { if (code === this.request) {
this.devices.next(this.mergePages(response.body, this.devices.getValue())); this.devices.next(this.mergePages(response, this.devices.getValue()));
this.scheduleDownload(code); this.scheduleDownload(code);
} }
}, this.createErrorHandler(code) }, this.createErrorHandler(code)
); );
} else if (this.isIncomplete(this.places.getValue())) { } else if (this.isIncomplete(this.places.getValue())) {
// download more places // download more places
this.apiClientService.getCurrentUserPlaces(Order.IDENTIFIER, this.places.getValue().offset, ExportService.BATCH_SIZE) this.apiClientService.getCurrentUserPlaces('IDENTIFIER', this.places.getValue().offset, ExportService.BATCH_SIZE)
.subscribe(response => { .subscribe(response => {
if (code === this.request) { if (code === this.request) {
this.places.next(this.mergePages(response.body, this.places.getValue())); this.places.next(this.mergePages(response, this.places.getValue()));
this.scheduleDownload(code); this.scheduleDownload(code);
} }
}, this.createErrorHandler(code) }, this.createErrorHandler(code)
@@ -64,7 +63,7 @@ export class ExportService {
this.apiClientService.getCurrentUserVisits(this.visits.getValue().offset, ExportService.BATCH_SIZE) this.apiClientService.getCurrentUserVisits(this.visits.getValue().offset, ExportService.BATCH_SIZE)
.subscribe(response => { .subscribe(response => {
if (code === this.request) { if (code === this.request) {
this.visits.next(this.mergePages(response.body, this.visits.getValue())); this.visits.next(this.mergePages(response, this.visits.getValue()));
this.scheduleDownload(code); this.scheduleDownload(code);
} }
}, this.createErrorHandler(code) }, this.createErrorHandler(code)
@@ -2,7 +2,7 @@ import { Inject, Injectable } from '@angular/core';
import { ConsoleService } from './console.service'; import { ConsoleService } from './console.service';
import { BehaviorSubject, Observable } from 'rxjs'; import { BehaviorSubject, Observable } from 'rxjs';
import { DataSource } from '@angular/cdk/table'; import { DataSource } from '@angular/cdk/table';
import { LogMessage } from '../../api/models'; import { LogMessage } from '../api';
import { CollectionViewer } from '@angular/cdk/collections'; import { CollectionViewer } from '@angular/cdk/collections';
import { CredentialService } from './credential.service'; import { CredentialService } from './credential.service';
@@ -1,9 +1,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { AbstractPageService } from '../utils/pagination'; import { AbstractPageService } from '../utils/pagination';
import { NoticePage, Notice } from '../../api/models'; import { DefaultService, NoticePage, Notice } from '../api';
import { ApiClientService } from '../../api';
import { Observable, BehaviorSubject, Subject } from 'rxjs'; import { Observable, BehaviorSubject, Subject } from 'rxjs';
import { HttpResponse } from '@angular/common/http';
/** /**
* A service that handles notices for admins. * A service that handles notices for admins.
@@ -11,18 +9,18 @@ import { HttpResponse } from '@angular/common/http';
@Injectable() @Injectable()
export class ManageNoticeService extends AbstractPageService<Notice, NoticePage> { export class ManageNoticeService extends AbstractPageService<Notice, NoticePage> {
constructor(apiClientService: ApiClientService) { constructor(apiClientService: DefaultService) {
super(apiClientService); super(apiClientService);
} }
protected loadPage(offset: number, size: number): Observable<HttpResponse<NoticePage>> { protected loadPage(offset: number, size: number): Observable<NoticePage> {
return this.apiClientService.getNotices(offset, size); return this.apiClientService.getNotices(offset, size);
} }
setNotice(notice: Notice): Observable<Notice> { setNotice(notice: Notice): Observable<Notice> {
if (this.loading.getValue()) { return new BehaviorSubject<Notice>(null); } if (this.loading.getValue()) { return new BehaviorSubject<Notice>(null); }
this.loading.next(true); this.loading.next(true);
let call: Observable<HttpResponse<Notice>>; let call: Observable<Notice>;
if (notice.id === 0) { if (notice.id === 0) {
call = this.apiClientService.addNotice(notice); call = this.apiClientService.addNotice(notice);
} else { } else {
@@ -31,7 +29,7 @@ export class ManageNoticeService extends AbstractPageService<Notice, NoticePage>
const result = new Subject<Notice>(); const result = new Subject<Notice>();
call.subscribe((response) => { call.subscribe((response) => {
this.loading.next(false); this.loading.next(false);
result.next(response.body); result.next(response);
this.reload(); this.reload();
}, (error) => { }, (error) => {
this.loading.next(false); this.loading.next(false);
@@ -46,7 +44,7 @@ export class ManageNoticeService extends AbstractPageService<Notice, NoticePage>
this.loading.next(true); this.loading.next(true);
const result = new Subject<Notice>(); const result = new Subject<Notice>();
this.apiClientService.getNotice(id).subscribe((response) => { this.apiClientService.getNotice(id).subscribe((response) => {
result.next(response.body); result.next(response);
this.loading.next(false); this.loading.next(false);
}, (error) => { }, (error) => {
result.next(null); result.next(null);
@@ -1,9 +1,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { AbstractPageService } from '../utils/pagination'; import { AbstractPageService } from '../utils/pagination';
import { User, UserPage } from '../../api/models'; import { DefaultService, User, UserPage } from '../api';
import { ApiClientService } from '../../api';
import { Observable, BehaviorSubject, Subject } from 'rxjs'; import { Observable, BehaviorSubject, Subject } from 'rxjs';
import { HttpResponse } from '@angular/common/http';
/** /**
* A service that handles users for admins. * A service that handles users for admins.
@@ -17,13 +15,13 @@ export class ManageUserService extends AbstractPageService<User, UserPage> {
*/ */
private term: string = null; private term: string = null;
constructor(apiClientService: ApiClientService) { constructor(apiClientService: DefaultService) {
super(apiClientService); super(apiClientService);
} }
protected loadPage(offset: number, size: number): Observable<HttpResponse<UserPage>> { protected loadPage(offset: number, size: number): Observable<UserPage> {
if (this.term != null) { if (this.term != null) {
return this.apiClientService.searchUsers(offset, size, this.term); return this.apiClientService.searchUsers(this.term, offset, size);
} else { } else {
return this.apiClientService.getUsers(offset, size); return this.apiClientService.getUsers(offset, size);
} }
@@ -1,12 +1,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Subject , Observable, BehaviorSubject } from 'rxjs'; import { Observable } from 'rxjs';
import { DataSource } from '@angular/cdk/table'; import { DefaultService, Notice, NoticePage } from '../api';
import { Notice, NoticePage } from '../../api/models';
import { ApiClientService } from '../../api';
import { UserService } from './user.service';
import { CollectionViewer } from '@angular/cdk/collections';
import { AbstractPageService } from '../utils/pagination'; import { AbstractPageService } from '../utils/pagination';
import { HttpResponse } from '@angular/common/http';
/** /**
* A service that handles notices. * A service that handles notices.
@@ -14,11 +9,11 @@ import { HttpResponse } from '@angular/common/http';
@Injectable() @Injectable()
export class NoticeService extends AbstractPageService<Notice, NoticePage> { export class NoticeService extends AbstractPageService<Notice, NoticePage> {
constructor(apiClientService: ApiClientService) { constructor(apiClientService: DefaultService) {
super(apiClientService); super(apiClientService);
} }
protected loadPage(offset: number, size: number): Observable<HttpResponse<NoticePage>> { protected loadPage(offset: number, size: number): Observable<NoticePage> {
return this.apiClientService.getActiveNotices(offset, size); return this.apiClientService.getActiveNotices(offset, size);
} }
@@ -1,12 +1,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Subject , Observable, BehaviorSubject } from 'rxjs'; import { DefaultService, Device, Place, Visit, VisitPage } from '../api';
import { DataSource } from '@angular/cdk/table'; import { AbstractReferencePageService } from '../utils/pagination';
import { Device, DevicePage, Privilege, PrivilegePage, Place, PlacePage, Visit, VisitPage } from '../../api/models'; import { BehaviorSubject, Observable } from 'rxjs';
import { ApiClientService } from '../../api';
import { UserService } from './user.service';
import { CollectionViewer } from '@angular/cdk/collections';
import { AbstractPageService, AbstractReferencePageService } from '../utils/pagination';
import { HttpResponse } from '@angular/common/http';
/** /**
* A service that handles visits for a particular place. * A service that handles visits for a particular place.
@@ -17,7 +12,7 @@ export class PlaceVisitService extends AbstractReferencePageService<Visit, Visit
readonly place = new BehaviorSubject<Place>(null); readonly place = new BehaviorSubject<Place>(null);
private id: number; private id: number;
constructor(apiClientService: ApiClientService) { constructor(apiClientService: DefaultService) {
super(apiClientService); super(apiClientService);
} }
@@ -30,7 +25,7 @@ export class PlaceVisitService extends AbstractReferencePageService<Visit, Visit
this.id = id; this.id = id;
this.loading.next(true); this.loading.next(true);
this.apiClientService.getPlace(id).subscribe((result) => { this.apiClientService.getPlace(id).subscribe((result) => {
this.place.next(result.body); this.place.next(result);
this.loading.next(false); this.loading.next(false);
this.reload(); this.reload();
}, (error) => { }, (error) => {
@@ -46,7 +41,7 @@ export class PlaceVisitService extends AbstractReferencePageService<Visit, Visit
if (this.id == null) { this.page.next(this.emptyPage()); } else { super.getPage(offset, size); } if (this.id == null) { this.page.next(this.emptyPage()); } else { super.getPage(offset, size); }
} }
protected loadPage(offset: number, size: number): Observable<HttpResponse<VisitPage>> { protected loadPage(offset: number, size: number): Observable<VisitPage> {
return this.apiClientService.getPlaceVisits(this.id, offset, size); return this.apiClientService.getPlaceVisits(this.id, offset, size);
} }
@@ -60,7 +55,7 @@ export class PlaceVisitService extends AbstractReferencePageService<Visit, Visit
return result; return result;
} }
protected loadReference(id: number): Observable<HttpResponse<Device>> { protected loadReference(id: number): Observable<Device> {
return this.apiClientService.getDevice(id); return this.apiClientService.getDevice(id);
} }
@@ -1,10 +1,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Subject , Observable, BehaviorSubject } from 'rxjs'; import { Subject , Observable, BehaviorSubject } from 'rxjs';
import { DataSource } from '@angular/cdk/table'; import { DataSource } from '@angular/cdk/table';
import { Device, DevicePage, Privilege, PrivilegePage, Place, PlacePage } from '../../api/models'; import { DefaultService, Place, PlacePage } from '../api';
import { ApiClientService, Order } from '../../api';
import { UserService } from './user.service';
import { CollectionViewer } from '@angular/cdk/collections';
import { AbstractPageService } from '../utils/pagination'; import { AbstractPageService } from '../utils/pagination';
import { HttpResponse } from '@angular/common/http'; import { HttpResponse } from '@angular/common/http';
@@ -14,10 +11,10 @@ import { HttpResponse } from '@angular/common/http';
@Injectable() @Injectable()
export class PlaceService extends AbstractPageService<Place, PlacePage> { export class PlaceService extends AbstractPageService<Place, PlacePage> {
public readonly order = new BehaviorSubject<Order>(Order.TIME); public readonly order = new BehaviorSubject<"TIME" | "IDENTIFIER" | "IMPORTANCE" | "DURATION" | "FREQUENCY">('TIME');
private loaded = this.order.getValue(); private loaded = this.order.getValue();
constructor(apiClientService: ApiClientService) { constructor(apiClientService: DefaultService) {
super(apiClientService); super(apiClientService);
this.order.subscribe(order => { this.order.subscribe(order => {
if (this.loaded !== order) { if (this.loaded !== order) {
@@ -37,7 +34,7 @@ export class PlaceService extends AbstractPageService<Place, PlacePage> {
}); });
} }
protected loadPage(offset: number, size: number): Observable<HttpResponse<PlacePage>> { protected loadPage(offset: number, size: number): Observable<PlacePage> {
this.loaded = this.order.getValue(); this.loaded = this.order.getValue();
return this.apiClientService.getCurrentUserPlaces(this.order.getValue(), offset, size); return this.apiClientService.getCurrentUserPlaces(this.order.getValue(), offset, size);
} }
@@ -1,12 +1,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Subject , Observable, BehaviorSubject } from 'rxjs'; import { Observable } from 'rxjs';
import { DataSource } from '@angular/cdk/table'; import { DefaultService, Privilege, PrivilegePage } from '../api';
import { Device, DevicePage, Privilege, PrivilegePage } from '../../api/models';
import { ApiClientService } from '../../api';
import { UserService } from './user.service';
import { CollectionViewer } from '@angular/cdk/collections';
import { AbstractPageService } from '../utils/pagination'; import { AbstractPageService } from '../utils/pagination';
import { HttpResponse } from '@angular/common/http';
/** /**
* A service that handles privileges. * A service that handles privileges.
@@ -14,11 +9,11 @@ import { HttpResponse } from '@angular/common/http';
@Injectable() @Injectable()
export class PrivilegeService extends AbstractPageService<Privilege, PrivilegePage> { export class PrivilegeService extends AbstractPageService<Privilege, PrivilegePage> {
constructor(apiClientService: ApiClientService) { constructor(apiClientService: DefaultService) {
super(apiClientService); super(apiClientService);
} }
protected loadPage(offset: number, size: number): Observable<HttpResponse<PrivilegePage>> { protected loadPage(offset: number, size: number): Observable<PrivilegePage> {
return this.apiClientService.getCurrentUserPrivileges(offset, size); return this.apiClientService.getCurrentUserPrivileges(offset, size);
} }
@@ -9,8 +9,7 @@ import { BehaviorSubject } from 'rxjs';
import { SatDatepickerRangeValue } from 'saturn-datepicker'; import { SatDatepickerRangeValue } from 'saturn-datepicker';
import { Page } from '../utils/pagination'; import { Page } from '../utils/pagination';
import { ApiClientService } from '../../api'; import { DefaultService, VisitPage, Device, Place, Visit } from '../api';
import { VisitPage, Device, Place, Visit } from '../../api/models';
import { UserService } from './user.service'; import { UserService } from './user.service';
@@ -92,7 +91,7 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
} }
constructor( constructor(
private apiClientService: ApiClientService, private apiClientService: DefaultService,
private userService: UserService private userService: UserService
) { ) {
super([]); super([]);
@@ -216,9 +215,9 @@ export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
private fetchAllVisits(code: number): void { private fetchAllVisits(code: number): void {
if (this.isIncomplete(this.visitsPage)) { if (this.isIncomplete(this.visitsPage)) {
this.apiClientService.getCurrentUserVisits(this.visitsPage.offset, TimeSheetService.BATCH_SIZE) this.apiClientService.getCurrentUserVisits(this.visitsPage.offset, TimeSheetService.BATCH_SIZE)
.subscribe((response: HttpResponse<VisitPage>) => { .subscribe((response) => {
if (code === this.request) { if (code === this.request) {
this.visitsPage = this.mergePages(response.body, this.visitsPage); this.visitsPage = this.mergePages(response, this.visitsPage);
this.fetchAllVisits(code); this.fetchAllVisits(code);
} }
}, },
+5 -7
View File
@@ -3,9 +3,7 @@ import { ConsoleService } from './console.service';
import { BehaviorSubject , Subject, Observable } from 'rxjs'; import { BehaviorSubject , Subject, Observable } from 'rxjs';
import { HttpErrorResponse } from '@angular/common/http'; import { HttpErrorResponse } from '@angular/common/http';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { User } from '../../api/models/user.model'; import { DefaultService, User, UserPassword } from '../api';
import { ApiClientService } from '../../api/index';
import { UserPassword } from '../../api/models/userpassword.model';
import { CredentialService } from './credential.service'; import { CredentialService } from './credential.service';
import { HttpStatusCode } from '../utils/httpcodes'; import { HttpStatusCode } from '../utils/httpcodes';
@@ -81,7 +79,7 @@ export class UserService {
* @param credentailService The credential service to manage the username and password. * @param credentailService The credential service to manage the username and password.
*/ */
constructor(private consoleService: ConsoleService, constructor(private consoleService: ConsoleService,
private apiClientService: ApiClientService, private apiClientService: DefaultService,
private credentailService: CredentialService) { private credentailService: CredentialService) {
if (credentailService.hasCredential()) { if (credentailService.hasCredential()) {
this.login(); this.login();
@@ -147,7 +145,7 @@ export class UserService {
this.state.next(UserState.Changing); this.state.next(UserState.Changing);
this.user.next(null); this.user.next(null);
this.apiClientService.getCurrentUser().subscribe(result => { this.apiClientService.getCurrentUser().subscribe(result => {
this.user.next(result.body); this.user.next(result);
this.state.next(UserState.Available); this.state.next(UserState.Available);
}, this.createErrorHandler()); }, this.createErrorHandler());
return true; return true;
@@ -177,7 +175,7 @@ export class UserService {
this.user.next(null); this.user.next(null);
this.apiClientService.setCurrentPassword({ password: newPassword }).subscribe(result => { this.apiClientService.setCurrentPassword({ password: newPassword }).subscribe(result => {
this.credentailService.setCredential(this.credentailService.getLogin(), newPassword); this.credentailService.setCredential(this.credentailService.getLogin(), newPassword);
this.user.next(result.body); this.user.next(result);
this.state.next(UserState.Available); this.state.next(UserState.Available);
}, this.createErrorHandler()); }, this.createErrorHandler());
return true; return true;
@@ -217,7 +215,7 @@ export class UserService {
this.state.next(UserState.Changing); this.state.next(UserState.Changing);
this.user.next(null); this.user.next(null);
this.apiClientService.setCurrentUser(user).subscribe(result => { this.apiClientService.setCurrentUser(user).subscribe(result => {
this.user.next(result.body); this.user.next(result);
this.state.next(UserState.Available); this.state.next(UserState.Available);
}, error => { }, error => {
if (error instanceof HttpErrorResponse) { if (error instanceof HttpErrorResponse) {
@@ -1,7 +1,6 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Subject , BehaviorSubject, Subscription } from 'rxjs'; import { BehaviorSubject, Subscription } from 'rxjs';
import { BuildVersion } from '../../api/models'; import { DefaultService, BuildVersion } from '../api';
import { ApiClientService } from '../../api';
/** /**
* A service to download the current version * A service to download the current version
@@ -13,13 +12,13 @@ export class VersionService {
private version = new BehaviorSubject<BuildVersion>(null); private version = new BehaviorSubject<BuildVersion>(null);
private loading = false; private loading = false;
constructor(private apiClientService: ApiClientService) { } constructor(private apiClientService: DefaultService) { }
subscribe(handler: (version: BuildVersion) => void): Subscription { subscribe(handler: (version: BuildVersion) => void): Subscription {
if (!this.loading && this.version.getValue() == null) { if (!this.loading && this.version.getValue() == null) {
this.loading = true; this.loading = true;
this.apiClientService.getBuildVersion().subscribe((v) => { this.apiClientService.getBuildVersion().subscribe((v) => {
this.version.next(v.body); this.version.next(v);
this.loading = false; this.loading = false;
}, (e) => { }, (e) => {
this.loading = false; this.loading = false;
+7 -8
View File
@@ -1,8 +1,7 @@
import { DataSource } from '@angular/cdk/table'; import { DataSource } from '@angular/cdk/table';
import { CollectionViewer } from '@angular/cdk/collections'; import { CollectionViewer } from '@angular/cdk/collections';
import { Observable, BehaviorSubject, Subscription } from 'rxjs'; import { Observable, BehaviorSubject, Subscription } from 'rxjs';
import { ApiClientService } from '../../api'; import { DefaultService } from '../api';
import { HttpResponse } from '@angular/common/http';
import { MatPaginator } from '@angular/material/paginator'; import { MatPaginator } from '@angular/material/paginator';
export interface Page<E> { export interface Page<E> {
@@ -45,7 +44,7 @@ export abstract class AbstractPageService<D, P extends Page<D>> extends DataSour
private subscriptions = 0; private subscriptions = 0;
readonly loading = new BehaviorSubject<boolean>(false); readonly loading = new BehaviorSubject<boolean>(false);
constructor(protected apiClientService: ApiClientService) { constructor(protected apiClientService: DefaultService) {
super(); super();
this.page.subscribe((page) => { this.page.subscribe((page) => {
this.elements.next(page.elements); this.elements.next(page.elements);
@@ -56,13 +55,13 @@ export abstract class AbstractPageService<D, P extends Page<D>> extends DataSour
if (this.loading.getValue()) { return; } if (this.loading.getValue()) { return; }
this.loading.next(true); this.loading.next(true);
this.loadPage(offset, size).subscribe((result) => { this.loadPage(offset, size).subscribe((result) => {
this.pageLoaded(result.body); this.pageLoaded(result);
}, (error) => { }, (error) => {
this.pageLoaded(null); this.pageLoaded(null);
}); });
} }
protected abstract loadPage(offset: number, size: number): Observable<HttpResponse<P>>; protected abstract loadPage(offset: number, size: number): Observable<P>;
protected pageLoaded(page: P): void { protected pageLoaded(page: P): void {
this.page.next(page); this.page.next(page);
@@ -93,13 +92,13 @@ export abstract class AbstractReferencePageService<D, P extends Page<D>, R> exte
readonly references: Map<number, R> = new Map<number, R>(); readonly references: Map<number, R> = new Map<number, R>();
private referenceRequests = 0; private referenceRequests = 0;
constructor(protected apiClientService: ApiClientService) { constructor(protected apiClientService: DefaultService) {
super(apiClientService); super(apiClientService);
} }
protected abstract getReferences(page: P): number[]; protected abstract getReferences(page: P): number[];
protected abstract loadReference(id: number): Observable<HttpResponse<R>>; protected abstract loadReference(id: number): Observable<R>;
protected pageLoaded(page: P): void { protected pageLoaded(page: P): void {
this.page.next(page); this.page.next(page);
@@ -108,7 +107,7 @@ export abstract class AbstractReferencePageService<D, P extends Page<D>, R> exte
if (this.getReference(id) == null) { if (this.getReference(id) == null) {
this.referenceRequests += 1; this.referenceRequests += 1;
this.loadReference(id).subscribe(result => { this.loadReference(id).subscribe(result => {
this.referenceLoaded(id, result.body); this.referenceLoaded(id, result);
}, error => { }, error => {
this.referenceLoaded(id, null); this.referenceLoaded(id, null);
}); });
@@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ApiClientService } from '../../api'; import { DefaultService } from '../api';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { MessageDialogComponent } from '../widgets/message-dialog.component'; import { MessageDialogComponent } from '../widgets/message-dialog.component';
@@ -17,7 +17,7 @@ import { ResourceService } from '../services/resource.service';
constructor( constructor(
public res: ResourceService, public res: ResourceService,
private apiClientService: ApiClientService, private apiClientService: DefaultService,
private dialog: MatDialog, private dialog: MatDialog,
private router: Router, private router: Router,
private route: ActivatedRoute) { } private route: ActivatedRoute) { }
@@ -1,16 +1,12 @@
import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core'; import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
import { UserState, UserService } from '../services/user.service';
import { BehaviorSubject, Subscription } from 'rxjs'; import { BehaviorSubject, Subscription } from 'rxjs';
import { Router, ActivatedRoute } from '@angular/router'; import { Router, ActivatedRoute } from '@angular/router';
import { FormErrorCode, FormErrorEncoder } from '../utils/formcodes';
import { LoginFieldComponent } from '../widgets/login-field.component';
import { PasswordFieldComponent } from '../widgets/password-field.component'; import { PasswordFieldComponent } from '../widgets/password-field.component';
import { HttpStatusCode } from '../utils/httpcodes'; import { HttpStatusCode } from '../utils/httpcodes';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { NgForm } from '@angular/forms'; import { NgForm } from '@angular/forms';
import { Snackbars } from '../utils/snackbars'; import { DefaultService } from '../api';
import { ApiClientService } from '../../api';
import { HttpErrorResponse } from '@angular/common/http'; import { HttpErrorResponse } from '@angular/common/http';
import { MessageDialogComponent } from '../widgets/message-dialog.component'; import { MessageDialogComponent } from '../widgets/message-dialog.component';
import { ResourceService } from '../services/resource.service'; import { ResourceService } from '../services/resource.service';
@@ -31,7 +27,7 @@ export class ChangeComponent implements OnInit, OnDestroy {
constructor( constructor(
public res: ResourceService, public res: ResourceService,
private apiClientService: ApiClientService, private apiClientService: DefaultService,
private snackbar: MatSnackBar, private snackbar: MatSnackBar,
private dialog: MatDialog, private dialog: MatDialog,
private router: Router, private router: Router,
@@ -1,16 +1,9 @@
import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit, HostBinding } from '@angular/core'; import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit, HostBinding } from '@angular/core';
import { ApiClientService } from '../../api';
import { MatDialog } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { MessageDialogComponent } from '../widgets/message-dialog.component';
import { HttpErrorResponse } from '@angular/common/http';
import { HttpStatusCode } from '../utils/httpcodes';
import { Subscription, BehaviorSubject } from 'rxjs'; import { Subscription, BehaviorSubject } from 'rxjs';
import { Device, Location } from '../../api/models'; import { DefaultService, Device, Location } from '../api';
import { Snackbars } from '../utils/snackbars'; import { Snackbars } from '../utils/snackbars';
import * as L from 'leaflet';
import { TileMapComponent } from '../widgets/tile-map.component';
import { MarkerMapComponent } from '../widgets/marker-map.component'; import { MarkerMapComponent } from '../widgets/marker-map.component';
import { ResourceService } from '../services/resource.service'; import { ResourceService } from '../services/resource.service';
@@ -33,7 +26,7 @@ import { ResourceService } from '../services/resource.service';
constructor( constructor(
public res: ResourceService, public res: ResourceService,
private snackbar: MatSnackBar, private snackbar: MatSnackBar,
private apiClientService: ApiClientService, private apiClientService: DefaultService,
private route: ActivatedRoute private route: ActivatedRoute
) { } ) { }
@@ -54,7 +47,7 @@ import { ResourceService } from '../services/resource.service';
updateDevice(): void { updateDevice(): void {
if (this.deviceSubscription) { return; } if (this.deviceSubscription) { return; }
this.deviceSubscription = this.apiClientService.getDevice(parseInt(this.id, 10)).subscribe((result) => { this.deviceSubscription = this.apiClientService.getDevice(parseInt(this.id, 10)).subscribe((result) => {
this.device.next(result.body); this.device.next(result);
this.deviceSubscription = null; this.deviceSubscription = null;
}, (error) => { }, (error) => {
Snackbars.showError(this.snackbar, this.res.strings('device_location_device_error')); Snackbars.showError(this.snackbar, this.res.strings('device_location_device_error'));
@@ -65,8 +58,8 @@ import { ResourceService } from '../services/resource.service';
updateLocation(): void { updateLocation(): void {
if (this.locationSubscription) { return; } if (this.locationSubscription) { return; }
this.locationSubscription = this.apiClientService.getDeviceLocation(parseInt(this.id, 10)).subscribe((result) => { this.locationSubscription = this.apiClientService.getDeviceLocation(parseInt(this.id, 10)).subscribe((result) => {
this.location.next(result.body); this.location.next(result);
this.map.setMarkerPosition(result.body.coordinate); this.map.setMarkerPosition(result.coordinate);
this.locationSubscription = null; this.locationSubscription = null;
}, (error) => { }, (error) => {
Snackbars.showError(this.snackbar, this.res.strings('device_location_location_error')); Snackbars.showError(this.snackbar, this.res.strings('device_location_location_error'));
@@ -2,25 +2,17 @@ import {
Component, OnInit, OnDestroy, ViewChild, Component, OnInit, OnDestroy, ViewChild,
AfterViewInit, ElementRef, DoCheck, AfterContentInit, AfterViewInit, ElementRef, DoCheck, AfterContentInit,
} from '@angular/core'; } from '@angular/core';
import { ApiClientService } from '../../api'; import { MatDatepickerInputEvent } from '@angular/material/datepicker';
import { MatDatepicker, MatDatepickerInputEvent } from '@angular/material/datepicker'; import { MatSliderChange } from '@angular/material/slider';
import { MatDialog } from '@angular/material/dialog';
import { MatSliderChange, MatSlider } from '@angular/material/slider';
import { MatSnackBar } from '@angular/material/snack-bar';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { Subscription, BehaviorSubject } from 'rxjs'; import { Subscription, BehaviorSubject } from 'rxjs';
import { Device, Position } from '../../api/models'; import { Device, Position } from '../api';
import { Snackbars } from '../utils/snackbars';
import * as L from 'leaflet'; import * as L from 'leaflet';
import { MarkerMapComponent } from '../widgets/marker-map.component'; import { MarkerMapComponent } from '../widgets/marker-map.component';
import { DeviceVisitService } from '../services/device-visit.service';
import { DataSource } from '@angular/cdk/table'; import { DataSource } from '@angular/cdk/table';
import { ConfirmationDialogComponent } from '../widgets/confirmation-dialog.component';
import { TableColumn, TableHandler } from '../utils/tables';
import { ResourceService } from '../services/resource.service'; import { ResourceService } from '../services/resource.service';
import { DevicePositionService } from '../services/device-position.service'; import { DevicePositionService } from '../services/device-position.service';
import { ValueConverter } from '@angular/compiler/src/render3/view/template'; import { ChartComponent, AxisConfig, Point } from '../widgets/chart.component';
import { ChartComponent, AxisConfig, Point } from "../widgets/chart.component";
@Component({ @Component({
selector: 'app-device-positions', selector: 'app-device-positions',
@@ -1,22 +1,16 @@
import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit, ElementRef, DoCheck } from '@angular/core'; import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit, ElementRef, DoCheck } from '@angular/core';
import { ApiClientService } from '../../api'; import { MatDatepickerInputEvent } from '@angular/material/datepicker';
import { MatDatepicker, MatDatepickerInputEvent } from '@angular/material/datepicker';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { MessageDialogComponent } from '../widgets/message-dialog.component';
import { HttpErrorResponse } from '@angular/common/http';
import { HttpStatusCode } from '../utils/httpcodes';
import { Subscription, BehaviorSubject } from 'rxjs'; import { Subscription, BehaviorSubject } from 'rxjs';
import { Device, Location, Visit } from '../../api/models'; import { Device, DefaultService, Visit } from '../api';
import { Snackbars } from '../utils/snackbars'; import { Snackbars } from '../utils/snackbars';
import * as L from 'leaflet'; import * as L from 'leaflet';
import { TileMapComponent } from '../widgets/tile-map.component';
import { MarkerMapComponent } from '../widgets/marker-map.component'; import { MarkerMapComponent } from '../widgets/marker-map.component';
import { DeviceVisitService } from '../services/device-visit.service'; import { DeviceVisitService } from '../services/device-visit.service';
import { DataSource } from '@angular/cdk/table'; import { DataSource } from '@angular/cdk/table';
import { ConfirmationDialogComponent } from '../widgets/confirmation-dialog.component'; import { ConfirmationDialogComponent } from '../widgets/confirmation-dialog.component';
import { FormControl } from '@angular/forms';
import { TableColumn, TableHandler } from '../utils/tables'; import { TableColumn, TableHandler } from '../utils/tables';
import { ResourceService } from '../services/resource.service'; import { ResourceService } from '../services/resource.service';
@@ -67,7 +61,7 @@ export class DeviceVisitsComponent implements OnInit, AfterViewInit, OnDestroy,
public res: ResourceService, public res: ResourceService,
private snackbar: MatSnackBar, private snackbar: MatSnackBar,
private dialog: MatDialog, private dialog: MatDialog,
private apiClientService: ApiClientService, private apiClientService: DefaultService,
private deviceVisitSerivce: DeviceVisitService, private deviceVisitSerivce: DeviceVisitService,
private route: ActivatedRoute private route: ActivatedRoute
) { ) {
@@ -1,15 +1,13 @@
import { Component, ViewChild, OnInit, OnDestroy, ElementRef, DoCheck } from '@angular/core'; import { Component, ViewChild, OnInit, OnDestroy, ElementRef, DoCheck } from '@angular/core';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { MatPaginator, PageEvent, MatPaginatorIntl } from '@angular/material/paginator'; import { MatPaginator } from '@angular/material/paginator';
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { MatTableDataSource } from '@angular/material/table';
import { DeviceService } from '../services/device.service'; import { DeviceService } from '../services/device.service';
import { Device, DevicePage } from '../../api/models'; import { DefaultService, Device, DevicePage } from '../api';
import { DataSource } from '@angular/cdk/table'; import { DataSource } from '@angular/cdk/table';
import { Subscription, BehaviorSubject } from 'rxjs'; import { BehaviorSubject } from 'rxjs';
import { PaginationHandler } from '../utils/pagination'; import { PaginationHandler } from '../utils/pagination';
import { ConfirmationDialogComponent, ConfirmationDialogResult } from '../widgets/confirmation-dialog.component'; import { ConfirmationDialogComponent } from '../widgets/confirmation-dialog.component';
import { ApiClientService } from '../../api';
import { Snackbars } from '../utils/snackbars'; import { Snackbars } from '../utils/snackbars';
import { TableHandler, TableColumn } from '../utils/tables'; import { TableHandler, TableColumn } from '../utils/tables';
import { ResourceService } from '../services/resource.service'; import { ResourceService } from '../services/resource.service';
@@ -44,7 +42,7 @@ export class DevicesComponent implements OnInit, OnDestroy, DoCheck {
constructor( constructor(
public res: ResourceService, public res: ResourceService,
private userService: UserService, private userService: UserService,
private apiClientService: ApiClientService, private apiClientService: DefaultService,
private deviceSerivce: DeviceService, private deviceSerivce: DeviceService,
private snackbar: MatSnackBar, private snackbar: MatSnackBar,
private dialog: MatDialog) { private dialog: MatDialog) {
@@ -1,19 +1,10 @@
import { Component, ViewChild, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core'; import { Component, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { MatPaginator, PageEvent, MatPaginatorIntl } from '@angular/material/paginator';
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { MatTableDataSource } from '@angular/material/table'; import { Notice, Message } from '../api';
import { DeviceService } from '../services/device.service';
import { Notice, NoticePage, Message } from '../../api/models';
import { DataSource } from '@angular/cdk/table';
import { Subscription, BehaviorSubject } from 'rxjs'; import { Subscription, BehaviorSubject } from 'rxjs';
import { PaginationHandler } from '../utils/pagination';
import { ConfirmationDialogComponent, ConfirmationDialogResult } from '../widgets/confirmation-dialog.component';
import { ApiClientService } from '../../api';
import { Snackbars } from '../utils/snackbars'; import { Snackbars } from '../utils/snackbars';
import { ManageUserService } from '../services/manage-user.service';
import { FormErrorEncoder } from '../utils/formcodes'; import { FormErrorEncoder } from '../utils/formcodes';
import { NgForm } from '@angular/forms';
import { ManageNoticeService } from '../services/manage-notice.service'; import { ManageNoticeService } from '../services/manage-notice.service';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { ResourceService, Language } from '../services/resource.service'; import { ResourceService, Language } from '../services/resource.service';
@@ -1,8 +1,4 @@
import { Component, OnInit, OnDestroy, ViewChild, HostListener } from '@angular/core'; import { Component, OnInit, OnDestroy, HostListener } from '@angular/core';
import { UserState, UserService, UserRole } from '../services/user.service';
import { MatOption } from '@angular/material/core';
import { MatDialog } from '@angular/material/dialog';
import { MatSelect } from '@angular/material/select';
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { ResourceService } from '../services/resource.service'; import { ResourceService } from '../services/resource.service';
import { ExportService } from '../services/export.service'; import { ExportService } from '../services/export.service';
+1 -2
View File
@@ -3,7 +3,6 @@ import { DatePipe } from '@angular/common';
import { UserState, UserService } from '../services/user.service'; import { UserState, UserService } from '../services/user.service';
import { BehaviorSubject, Subscription } from 'rxjs'; import { BehaviorSubject, Subscription } from 'rxjs';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { FormErrorCode, FormErrorEncoder } from '../utils/formcodes';
import { LoginFieldComponent } from '../widgets/login-field.component'; import { LoginFieldComponent } from '../widgets/login-field.component';
import { PasswordFieldComponent } from '../widgets/password-field.component'; import { PasswordFieldComponent } from '../widgets/password-field.component';
import { HttpStatusCode } from '../utils/httpcodes'; import { HttpStatusCode } from '../utils/httpcodes';
@@ -11,7 +10,7 @@ import { MatSnackBar } from '@angular/material/snack-bar';
import { NgForm } from '@angular/forms'; import { NgForm } from '@angular/forms';
import { Snackbars } from '../utils/snackbars'; import { Snackbars } from '../utils/snackbars';
import { VersionService } from '../services/version.service'; import { VersionService } from '../services/version.service';
import { BuildVersion } from '../../api/models'; import { BuildVersion } from '../api';
import { ResourceService } from '../services/resource.service'; import { ResourceService } from '../services/resource.service';
@Component({ @Component({
@@ -1,8 +1,7 @@
import { Component, OnInit, OnDestroy, ViewChild, DoCheck, ElementRef } from '@angular/core'; import { Component, OnInit, OnDestroy, ViewChild, DoCheck, ElementRef } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs'; import { BehaviorSubject } from 'rxjs';
import { DataSource } from '@angular/cdk/table'; import { DataSource } from '@angular/cdk/table';
import { LogMessage } from '../../api/models'; import { LogMessage } from '../api';
import { CollectionViewer } from '@angular/cdk/collections';
import { ManageLogService } from '../services/manage-log.service'; import { ManageLogService } from '../services/manage-log.service';
import { LogDialogComponent } from '../widgets/log-dialog.component'; import { LogDialogComponent } from '../widgets/log-dialog.component';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
@@ -1,19 +1,12 @@
import {Component, ViewChild, OnInit, OnDestroy, ElementRef, HostListener, ContentChild, DoCheck} from '@angular/core'; import {Component, ViewChild, OnInit, OnDestroy, ElementRef, HostListener, ContentChild, DoCheck} from '@angular/core';
import { MatDialog } from '@angular/material/dialog'; import { MatPaginator } from '@angular/material/paginator';
import { MatPaginator, PageEvent, MatPaginatorIntl } from '@angular/material/paginator';
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { MatTableDataSource } from '@angular/material/table'; import { Notice, NoticePage } from '../api';
import { DeviceService } from '../services/device.service';
import { Notice, NoticePage } from '../../api/models';
import { DataSource } from '@angular/cdk/table'; import { DataSource } from '@angular/cdk/table';
import { Subscription, BehaviorSubject } from 'rxjs'; import { BehaviorSubject } from 'rxjs';
import { PaginationHandler } from '../utils/pagination'; import { PaginationHandler } from '../utils/pagination';
import { ConfirmationDialogComponent, ConfirmationDialogResult } from '../widgets/confirmation-dialog.component';
import { ApiClientService } from '../../api';
import { Snackbars } from '../utils/snackbars'; import { Snackbars } from '../utils/snackbars';
import { ManageUserService } from '../services/manage-user.service';
import { FormErrorEncoder } from '../utils/formcodes'; import { FormErrorEncoder } from '../utils/formcodes';
import { NgForm } from '@angular/forms';
import { ManageNoticeService } from '../services/manage-notice.service'; import { ManageNoticeService } from '../services/manage-notice.service';
import { TableHandler, TableColumn } from '../utils/tables'; import { TableHandler, TableColumn } from '../utils/tables';
import { ResourceService, Language } from '../services/resource.service'; import { ResourceService, Language } from '../services/resource.service';
@@ -52,8 +45,7 @@ export class ManageNoticesComponent extends FormErrorEncoder implements OnInit,
constructor( constructor(
public res: ResourceService, public res: ResourceService,
private mangeNoticeService: ManageNoticeService, private mangeNoticeService: ManageNoticeService,
private snackbar: MatSnackBar, private snackbar: MatSnackBar) {
private dialog: MatDialog) {
super(); super();
this.dataSource = mangeNoticeService; this.dataSource = mangeNoticeService;
this.loading = mangeNoticeService.loading; this.loading = mangeNoticeService.loading;
@@ -1,6 +1,6 @@
import { Component, OnInit, OnDestroy, HostListener } from '@angular/core'; import { Component, OnInit, OnDestroy, HostListener } from '@angular/core';
import { SystemStatistic, EntityStatistic, LoadStatistic } from '../../api/models'; import { SystemStatistic, EntityStatistic, LoadStatistic } from '../api';
import { ApiClientService } from '../../api'; import { DefaultService } from '../api';
import { Subscription, Observable, BehaviorSubject } from 'rxjs'; import { Subscription, Observable, BehaviorSubject } from 'rxjs';
import { DataSource } from '@angular/cdk/table'; import { DataSource } from '@angular/cdk/table';
import { CollectionViewer } from '@angular/cdk/collections'; import { CollectionViewer } from '@angular/cdk/collections';
@@ -43,7 +43,7 @@ export class ManageSystemComponent implements OnInit, OnDestroy {
private entityTimer: any = null; private entityTimer: any = null;
private systemTimer: any = null; private systemTimer: any = null;
constructor(public res: ResourceService, private apiClientService: ApiClientService) { } constructor(public res: ResourceService, private apiClientService: DefaultService) { }
@HostListener('window:resize', ['$event']) @HostListener('window:resize', ['$event'])
onResize(event: Event) { onResize(event: Event) {
@@ -80,7 +80,7 @@ export class ManageSystemComponent implements OnInit, OnDestroy {
private updateLoad(): Subscription { private updateLoad(): Subscription {
return this.apiClientService.getLoadStatistic().subscribe((result) => { return this.apiClientService.getLoadStatistic().subscribe((result) => {
this.load = result.body; this.load = result;
this.loadTimer = setTimeout(() => this.loadSubscription = this.updateLoad(), ManageSystemComponent.TIMEOUT_LOAD); this.loadTimer = setTimeout(() => this.loadSubscription = this.updateLoad(), ManageSystemComponent.TIMEOUT_LOAD);
}, (error) => { }, (error) => {
this.loadTimer = setTimeout(() => this.loadSubscription = this.updateLoad(), ManageSystemComponent.TIMEOUT_ERROR); this.loadTimer = setTimeout(() => this.loadSubscription = this.updateLoad(), ManageSystemComponent.TIMEOUT_ERROR);
@@ -89,7 +89,7 @@ export class ManageSystemComponent implements OnInit, OnDestroy {
private updateEntities(): Subscription { private updateEntities(): Subscription {
return this.apiClientService.getEntityStatistics().subscribe((result) => { return this.apiClientService.getEntityStatistics().subscribe((result) => {
this.entities.entities.next(result.body); this.entities.entities.next(result);
this.entityTimer = setTimeout(() => this.entitySubscription = this.updateEntities(), ManageSystemComponent.TIMEOUT_ENTITY); this.entityTimer = setTimeout(() => this.entitySubscription = this.updateEntities(), ManageSystemComponent.TIMEOUT_ENTITY);
}, (error) => { }, (error) => {
this.entityTimer = setTimeout(() => this.entitySubscription = this.updateEntities(), ManageSystemComponent.TIMEOUT_ERROR); this.entityTimer = setTimeout(() => this.entitySubscription = this.updateEntities(), ManageSystemComponent.TIMEOUT_ERROR);
@@ -98,7 +98,7 @@ export class ManageSystemComponent implements OnInit, OnDestroy {
private updateSystem(): Subscription { private updateSystem(): Subscription {
return this.apiClientService.getSystemStatistic().subscribe((result) => { return this.apiClientService.getSystemStatistic().subscribe((result) => {
this.system = result.body; this.system = result;
}, (error) => { }, (error) => {
this.systemTimer = setTimeout(() => this.systemSubscription = this.updateSystem(), ManageSystemComponent.TIMEOUT_ERROR); this.systemTimer = setTimeout(() => this.systemSubscription = this.updateSystem(), ManageSystemComponent.TIMEOUT_ERROR);
}); });
@@ -1,15 +1,11 @@
import {Component, ViewChild, OnInit, OnDestroy, ElementRef, DoCheck} from '@angular/core'; import {Component, ViewChild, OnInit, OnDestroy, ElementRef, DoCheck} from '@angular/core';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { MatPaginator, PageEvent, MatPaginatorIntl } from '@angular/material/paginator'; import { MatPaginator } from '@angular/material/paginator';
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { MatTableDataSource } from '@angular/material/table'; import { DefaultService, User, UserPage } from '../api';
import { DeviceService } from '../services/device.service';
import { Device, DevicePage, User, UserPage } from '../../api/models';
import { DataSource } from '@angular/cdk/table'; import { DataSource } from '@angular/cdk/table';
import { Subscription, BehaviorSubject } from 'rxjs'; import { BehaviorSubject } from 'rxjs';
import { PaginationHandler } from '../utils/pagination'; import { PaginationHandler } from '../utils/pagination';
import { ConfirmationDialogComponent, ConfirmationDialogResult } from '../widgets/confirmation-dialog.component';
import { ApiClientService } from '../../api';
import { Snackbars } from '../utils/snackbars'; import { Snackbars } from '../utils/snackbars';
import { ManageUserService } from '../services/manage-user.service'; import { ManageUserService } from '../services/manage-user.service';
import { FormErrorEncoder } from '../utils/formcodes'; import { FormErrorEncoder } from '../utils/formcodes';
@@ -49,7 +45,7 @@ export class ManageUsersComponent extends FormErrorEncoder implements OnInit, On
constructor( constructor(
public res: ResourceService, public res: ResourceService,
private apiClientService: ApiClientService, private apiClientService: DefaultService,
private userService: UserService, private userService: UserService,
private manageUserService: ManageUserService, private manageUserService: ManageUserService,
private snackbar: MatSnackBar, private snackbar: MatSnackBar,
+3 -12
View File
@@ -1,16 +1,7 @@
import { Component, OnInit, OnDestroy, ViewChild, HostListener } from '@angular/core'; import { Component, OnInit, HostListener } from '@angular/core';
import { UserState, UserService } from '../services/user.service'; import { BehaviorSubject } from 'rxjs';
import { BehaviorSubject, Subscription } from 'rxjs';
import { Router } from '@angular/router';
import { FormErrorCode, FormErrorEncoder } from '../utils/formcodes';
import { LoginFieldComponent } from '../widgets/login-field.component';
import { PasswordFieldComponent } from '../widgets/password-field.component';
import { HttpStatusCode } from '../utils/httpcodes';
import { MatSnackBar } from '@angular/material/snack-bar';
import { NgForm } from '@angular/forms';
import { Snackbars } from '../utils/snackbars';
import { NoticeService } from '../services/notice.service'; import { NoticeService } from '../services/notice.service';
import { NoticePage, Notice } from '../../api/models'; import { NoticePage, Notice } from '../api';
import { ResourceService } from '../services/resource.service'; import { ResourceService } from '../services/resource.service';
@Component({ @Component({
@@ -1,20 +1,14 @@
import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit, ViewEncapsulation, DoCheck, ElementRef, Input } from '@angular/core'; import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit, DoCheck, ElementRef } from '@angular/core';
import { ApiClientService } from '../../api';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { MatPaginator } from '@angular/material/paginator'; import { MatPaginator } from '@angular/material/paginator';
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { MessageDialogComponent } from '../widgets/message-dialog.component';
import { HttpErrorResponse } from '@angular/common/http';
import { HttpStatusCode } from '../utils/httpcodes';
import { Subscription, BehaviorSubject } from 'rxjs'; import { Subscription, BehaviorSubject } from 'rxjs';
import { Device, Location, Place, VisitPage, Visit } from '../../api/models'; import { DefaultService, Place, VisitPage, Visit } from '../api';
import { Snackbars } from '../utils/snackbars'; import { Snackbars } from '../utils/snackbars';
import * as L from 'leaflet';
import { TileMapComponent } from '../widgets/tile-map.component';
import { MarkerMapComponent } from '../widgets/marker-map.component'; import { MarkerMapComponent } from '../widgets/marker-map.component';
import { PlaceVisitService } from '../services/place-visit.service'; import { PlaceVisitService } from '../services/place-visit.service';
import { Page, PaginationHandler } from '../utils/pagination'; import { PaginationHandler } from '../utils/pagination';
import { ConfirmationDialogComponent } from '../widgets/confirmation-dialog.component'; import { ConfirmationDialogComponent } from '../widgets/confirmation-dialog.component';
import { DataSource } from '@angular/cdk/table'; import { DataSource } from '@angular/cdk/table';
import { TableColumn, TableHandler } from '../utils/tables'; import { TableColumn, TableHandler } from '../utils/tables';
@@ -56,7 +50,7 @@ export class PlaceVisitsComponent implements OnInit, AfterViewInit, OnDestroy, D
constructor( constructor(
public res: ResourceService, public res: ResourceService,
private apiClientService: ApiClientService, private apiClientService: DefaultService,
private snackbar: MatSnackBar, private snackbar: MatSnackBar,
private dialog: MatDialog, private dialog: MatDialog,
private placeService: PlaceVisitService, private placeService: PlaceVisitService,
@@ -1,16 +1,14 @@
import {Component, ViewChild, OnInit, OnDestroy, DoCheck, ElementRef} from '@angular/core'; import {Component, ViewChild, OnInit, OnDestroy, DoCheck, ElementRef} from '@angular/core';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { MatPaginator, PageEvent, MatPaginatorIntl } from '@angular/material/paginator'; import { MatPaginator, } from '@angular/material/paginator';
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { MatTableDataSource } from '@angular/material/table'; import { DefaultService, PlacePage, Place } from '../api';
import { Privilege, PrivilegePage, PlacePage, Place } from '../../api/models';
import { DataSource } from '@angular/cdk/table'; import { DataSource } from '@angular/cdk/table';
import { Subscription, BehaviorSubject } from 'rxjs'; import { BehaviorSubject } from 'rxjs';
import { PaginationHandler } from '../utils/pagination'; import { PaginationHandler } from '../utils/pagination';
import { PlaceService } from '../services/place.service'; import { PlaceService } from '../services/place.service';
import { NicknameDialogComponent } from '../widgets/nickname-dialog.component'; import { NicknameDialogComponent } from '../widgets/nickname-dialog.component';
import { ConfirmationDialogComponent } from '../widgets/confirmation-dialog.component'; import { ConfirmationDialogComponent } from '../widgets/confirmation-dialog.component';
import { ApiClientService, Order } from '../../api';
import { Snackbars } from '../utils/snackbars'; import { Snackbars } from '../utils/snackbars';
import { TableHandler, TableColumn } from '../utils/tables'; import { TableHandler, TableColumn } from '../utils/tables';
import { ResourceService } from '../services/resource.service'; import { ResourceService } from '../services/resource.service';
@@ -42,7 +40,7 @@ export class PlacesComponent implements OnInit, OnDestroy, DoCheck {
dataSource: DataSource<Place>; dataSource: DataSource<Place>;
loading: BehaviorSubject<boolean>; loading: BehaviorSubject<boolean>;
order: BehaviorSubject<Order>; order: BehaviorSubject<String>;
deleting = new BehaviorSubject<boolean>(false); deleting = new BehaviorSubject<boolean>(false);
private pageHandler: PaginationHandler<Place, PlacePage>; private pageHandler: PaginationHandler<Place, PlacePage>;
private tableHandler: TableHandler; private tableHandler: TableHandler;
@@ -50,7 +48,7 @@ export class PlacesComponent implements OnInit, OnDestroy, DoCheck {
constructor( constructor(
public res: ResourceService, public res: ResourceService,
private apiClientService: ApiClientService, private apiClientService: DefaultService,
private placeService: PlaceService, private placeService: PlaceService,
private snackbar: MatSnackBar, private snackbar: MatSnackBar,
private dialog: MatDialog) { private dialog: MatDialog) {
@@ -87,12 +85,12 @@ export class PlacesComponent implements OnInit, OnDestroy, DoCheck {
} }
} }
getOrderName(order: Order) { getOrderName(order: String) {
return this.res.strings('places_order_value_' + order.toLowerCase()); return this.res.strings('places_order_value_' + order.toLowerCase());
} }
getOrders(): string[] { getOrders(): string[] {
return [ Order.TIME, Order.IMPORTANCE, Order.DURATION, Order.FREQUENCY, Order.IDENTIFIER ]; return [ 'TIME', 'IMPORTANCE', 'DURATION', 'FREQUENCY', 'IDENTIFIER' ];
} }
ngOnInit() { ngOnInit() {
@@ -1,16 +1,14 @@
import { Component, ViewChild, OnInit, OnDestroy, DoCheck, ElementRef } from '@angular/core'; import { Component, ViewChild, OnInit, OnDestroy, DoCheck, ElementRef } from '@angular/core';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { MatPaginator, PageEvent, MatPaginatorIntl } from '@angular/material/paginator'; import { MatPaginator } from '@angular/material/paginator';
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { MatTableDataSource } from '@angular/material/table';
import { PrivilegeService } from '../services/privilege.service'; import { PrivilegeService } from '../services/privilege.service';
import { Privilege, PrivilegePage } from '../../api/models'; import { DefaultService, Privilege, PrivilegePage } from '../api';
import { DataSource } from '@angular/cdk/table'; import { DataSource } from '@angular/cdk/table';
import { Subscription, BehaviorSubject } from 'rxjs'; import { Subscription, BehaviorSubject } from 'rxjs';
import { PaginationHandler } from '../utils/pagination'; import { PaginationHandler } from '../utils/pagination';
import { ShareDialogComponent } from '../widgets/share-dialog.component'; import { ShareDialogComponent } from '../widgets/share-dialog.component';
import { ConfirmationDialogComponent } from '../widgets/confirmation-dialog.component'; import { ConfirmationDialogComponent } from '../widgets/confirmation-dialog.component';
import { ApiClientService } from '../../api';
import { Snackbars } from '../utils/snackbars'; import { Snackbars } from '../utils/snackbars';
import { ActivatedRoute, Route, Router } from '@angular/router'; import { ActivatedRoute, Route, Router } from '@angular/router';
import { TableColumn, TableHandler } from '../utils/tables'; import { TableColumn, TableHandler } from '../utils/tables';
@@ -44,7 +42,7 @@ export class PrivilegesComponent implements OnInit, OnDestroy, DoCheck {
constructor( constructor(
public res: ResourceService, public res: ResourceService,
private apiClientService: ApiClientService, private apiClientService: DefaultService,
private privilegeService: PrivilegeService, private privilegeService: PrivilegeService,
private router: Router, private router: Router,
private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute,
@@ -1,8 +1,6 @@
import { Component, OnInit, OnDestroy, ViewChild, HostListener } from '@angular/core'; import { Component, OnInit, OnDestroy, ViewChild, HostListener } from '@angular/core';
import { UserState, UserService } from '../services/user.service';
import { BehaviorSubject, Subscription } from 'rxjs'; import { BehaviorSubject, Subscription } from 'rxjs';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { FormErrorCode, FormErrorEncoder } from '../utils/formcodes';
import { LoginFieldComponent } from '../widgets/login-field.component'; import { LoginFieldComponent } from '../widgets/login-field.component';
import { PasswordFieldComponent } from '../widgets/password-field.component'; import { PasswordFieldComponent } from '../widgets/password-field.component';
import { HttpStatusCode } from '../utils/httpcodes'; import { HttpStatusCode } from '../utils/httpcodes';
@@ -11,8 +9,7 @@ import { MatSnackBar } from '@angular/material/snack-bar';
import { NgForm } from '@angular/forms'; import { NgForm } from '@angular/forms';
import { NameFieldComponent } from '../widgets/name-field.component'; import { NameFieldComponent } from '../widgets/name-field.component';
import { EmailFieldComponent } from '../widgets/email-field.component'; import { EmailFieldComponent } from '../widgets/email-field.component';
import { UserRegistration } from '../../api/models'; import { DefaultService, UserRegistration } from '../api';
import { ApiClientService} from '../../api/index';
import { HttpErrorResponse } from '@angular/common/http'; import { HttpErrorResponse } from '@angular/common/http';
import { Snackbars } from '../utils/snackbars'; import { Snackbars } from '../utils/snackbars';
import { MessageDialogComponent } from '../widgets/message-dialog.component'; import { MessageDialogComponent } from '../widgets/message-dialog.component';
@@ -39,7 +36,7 @@ export class RegisterComponent implements OnInit, OnDestroy {
private registrationSubscription: Subscription; private registrationSubscription: Subscription;
constructor(public res: ResourceService, private apiClientService: ApiClientService, constructor(public res: ResourceService, private apiClientService: DefaultService,
private snackbar: MatSnackBar, private router: Router, private dialog: MatDialog) { } private snackbar: MatSnackBar, private router: Router, private dialog: MatDialog) { }
+3 -5
View File
@@ -1,16 +1,14 @@
import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core'; import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
import { UserState, UserService } from '../services/user.service'; import { UserService } from '../services/user.service';
import { BehaviorSubject, Subscription } from 'rxjs'; import { BehaviorSubject, Subscription } from 'rxjs';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { FormErrorCode, FormErrorEncoder } from '../utils/formcodes';
import { LoginFieldComponent } from '../widgets/login-field.component'; import { LoginFieldComponent } from '../widgets/login-field.component';
import { PasswordFieldComponent } from '../widgets/password-field.component';
import { HttpStatusCode } from '../utils/httpcodes'; import { HttpStatusCode } from '../utils/httpcodes';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { NgForm } from '@angular/forms'; import { NgForm } from '@angular/forms';
import { Snackbars } from '../utils/snackbars'; import { Snackbars } from '../utils/snackbars';
import { ApiClientService } from '../../api'; import { DefaultService } from '../api';
import { HttpErrorResponse } from '@angular/common/http'; import { HttpErrorResponse } from '@angular/common/http';
import { MessageDialogComponent } from '../widgets/message-dialog.component'; import { MessageDialogComponent } from '../widgets/message-dialog.component';
import { ResourceService } from '../services/resource.service'; import { ResourceService } from '../services/resource.service';
@@ -31,7 +29,7 @@ export class ResetComponent implements OnInit, OnDestroy {
login: string; login: string;
constructor(public res: ResourceService, private userService: UserService, constructor(public res: ResourceService, private userService: UserService,
private apiClientService: ApiClientService, private snackbar: MatSnackBar, private apiClientService: DefaultService, private snackbar: MatSnackBar,
private dialog: MatDialog, private router: Router) { } private dialog: MatDialog, private router: Router) { }
ngOnInit(): void { ngOnInit(): void {
+5 -12
View File
@@ -1,16 +1,9 @@
import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit } from '@angular/core'; import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit } from '@angular/core';
import { ApiClientService } from '../../api';
import { MatDialog } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { MessageDialogComponent } from '../widgets/message-dialog.component';
import { HttpErrorResponse } from '@angular/common/http';
import { HttpStatusCode } from '../utils/httpcodes';
import { Subscription, BehaviorSubject } from 'rxjs'; import { Subscription, BehaviorSubject } from 'rxjs';
import { Device, Location, ShareInfo } from '../../api/models'; import { DefaultService, Location, ShareInfo } from '../api';
import { Snackbars } from '../utils/snackbars'; import { Snackbars } from '../utils/snackbars';
import * as L from 'leaflet';
import { TileMapComponent } from '../widgets/tile-map.component';
import { MarkerMapComponent } from '../widgets/marker-map.component'; import { MarkerMapComponent } from '../widgets/marker-map.component';
import { ResourceService } from '../services/resource.service'; import { ResourceService } from '../services/resource.service';
@@ -33,7 +26,7 @@ import { ResourceService } from '../services/resource.service';
constructor( constructor(
public res: ResourceService, public res: ResourceService,
private snackbar: MatSnackBar, private snackbar: MatSnackBar,
private apiClientService: ApiClientService, private apiClientService: DefaultService,
private router: Router, private router: Router,
private route: ActivatedRoute private route: ActivatedRoute
) { } ) { }
@@ -68,7 +61,7 @@ import { ResourceService } from '../services/resource.service';
updateInfo(): void { updateInfo(): void {
if (this.infoSubscription) { return; } if (this.infoSubscription) { return; }
this.infoSubscription = this.apiClientService.getShareInfo(this.token).subscribe((result) => { this.infoSubscription = this.apiClientService.getShareInfo(this.token).subscribe((result) => {
this.info.next(result.body); this.info.next(result);
this.infoSubscription = null; this.infoSubscription = null;
this.updateLocation(); this.updateLocation();
}, (error) => { }, (error) => {
@@ -80,8 +73,8 @@ import { ResourceService } from '../services/resource.service';
updateLocation(): void { updateLocation(): void {
if (this.locationSubscription) { return; } if (this.locationSubscription) { return; }
this.locationSubscription = this.apiClientService.getShareLocation(this.token).subscribe((result) => { this.locationSubscription = this.apiClientService.getShareLocation(this.token).subscribe((result) => {
this.location.next(result.body); this.location.next(result);
this.map.setMarkerPosition(result.body.coordinate); this.map.setMarkerPosition(result.coordinate);
this.locationSubscription = null; this.locationSubscription = null;
}, (error) => { }, (error) => {
Snackbars.showError(this.snackbar, this.res.strings('share_no_update_location')); Snackbars.showError(this.snackbar, this.res.strings('share_no_update_location'));
@@ -3,14 +3,12 @@ import { Time, formatDate } from '@angular/common';
import { MatPaginator } from '@angular/material/paginator'; import { MatPaginator } from '@angular/material/paginator';
import { MatTableDataSource } from '@angular/material/table'; import { MatTableDataSource } from '@angular/material/table';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { Subscription } from 'rxjs'; import { Subscription } from 'rxjs';
import { ResourceService } from '../services/resource.service'; import { ResourceService } from '../services/resource.service';
import { DeviceService } from '../services/device.service'; import { DeviceService } from '../services/device.service';
import { TimeSheetService, TimeSheetData, Grouping } from '../services/time-sheet.service'; import { TimeSheetService, TimeSheetData, Grouping } from '../services/time-sheet.service';
import { PlacesDialogComponent } from '../widgets/places-dialog.component'; import { PlacesDialogComponent } from '../widgets/places-dialog.component';
import { Device, Place } from '../../api/models'; import { Device, Place } from '../api';
import { MessageDialogComponent } from '../widgets/message-dialog.component'; import { MessageDialogComponent } from '../widgets/message-dialog.component';
+2 -8
View File
@@ -1,24 +1,18 @@
import { Component, OnInit, OnDestroy, ViewChild, HostListener } from '@angular/core'; import { Component, OnInit, OnDestroy, ViewChild, HostListener } from '@angular/core';
import { UserState, UserService, UserRole } from '../services/user.service'; import { UserService, UserRole } from '../services/user.service';
import { BehaviorSubject, Subscription , Observable } from 'rxjs'; import { BehaviorSubject, Subscription , Observable } from 'rxjs';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { FormErrorCode, FormErrorEncoder } from '../utils/formcodes';
import { LoginFieldComponent } from '../widgets/login-field.component';
import { PasswordFieldComponent } from '../widgets/password-field.component'; import { PasswordFieldComponent } from '../widgets/password-field.component';
import { HttpStatusCode } from '../utils/httpcodes';
import { MatOption } from '@angular/material/core';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { MatSelect } from '@angular/material/select'; import { MatSelect } from '@angular/material/select';
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { NgForm } from '@angular/forms';
import { Snackbars } from '../utils/snackbars'; import { Snackbars } from '../utils/snackbars';
import { User, Email } from '../../api/models'; import { User, Email } from '../api';
import { NameFieldComponent } from '../widgets/name-field.component'; import { NameFieldComponent } from '../widgets/name-field.component';
import { EmailFieldComponent } from '../widgets/email-field.component'; import { EmailFieldComponent } from '../widgets/email-field.component';
import { MessageDialogComponent } from '../widgets/message-dialog.component'; import { MessageDialogComponent } from '../widgets/message-dialog.component';
import { ResourceService } from '../services/resource.service'; import { ResourceService } from '../services/resource.service';
import { ConfirmationDialogComponent } from '../widgets/confirmation-dialog.component'; import { ConfirmationDialogComponent } from '../widgets/confirmation-dialog.component';
import { AuthGuard } from '../guards/auth.guard';
@Component({ @Component({
selector: 'app-user', selector: 'app-user',
@@ -1,8 +1,5 @@
import { Component, OnInit, OnDestroy, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { UserState, UserService } from '../services/user.service'; import { FormErrorEncoder } from '../utils/formcodes';
import { BehaviorSubject, Subscription } from 'rxjs';
import { Router } from '@angular/router';
import { FormErrorCode, FormErrorEncoder } from '../utils/formcodes';
import { ResourceService } from '../services/resource.service'; import { ResourceService } from '../services/resource.service';
/** /**
@@ -1,7 +1,7 @@
import { Component, Inject } from '@angular/core'; import { Component, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material/dialog'; import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material/dialog';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { LogMessage } from '../../api/models'; import { LogMessage } from '../api';
import { ResourceService } from '../services/resource.service'; import { ResourceService } from '../services/resource.service';
@Component({ @Component({
@@ -1,8 +1,5 @@
import { Component, OnInit, OnDestroy, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { UserState, UserService } from '../services/user.service'; import { FormErrorEncoder } from '../utils/formcodes';
import { BehaviorSubject, Subscription } from 'rxjs';
import { Router } from '@angular/router';
import { FormErrorCode, FormErrorEncoder } from '../utils/formcodes';
import { ResourceService } from '../services/resource.service'; import { ResourceService } from '../services/resource.service';
/** /**
@@ -1,14 +1,4 @@
import { Component, OnInit, OnDestroy, ViewChild, AfterContentInit, AfterViewInit, ElementRef } from '@angular/core'; import { Component, ViewChild, AfterViewInit, ElementRef } from '@angular/core';
import { ApiClientService } from '../../api';
import { MatDialog } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar';
import { ActivatedRoute, Router } from '@angular/router';
import { MessageDialogComponent } from '../widgets/message-dialog.component';
import { HttpErrorResponse } from '@angular/common/http';
import { HttpStatusCode } from '../utils/httpcodes';
import { Subscription, BehaviorSubject } from 'rxjs';
import { Device, Location } from '../../api/models';
import { Snackbars } from '../utils/snackbars';
import * as L from 'leaflet'; import * as L from 'leaflet';
import { TileMapComponent } from '../widgets/tile-map.component'; import { TileMapComponent } from '../widgets/tile-map.component';
@@ -1,8 +1,5 @@
import { Component, OnInit, OnDestroy, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { UserState, UserService } from '../services/user.service'; import { FormErrorEncoder } from '../utils/formcodes';
import { BehaviorSubject, Subscription } from 'rxjs';
import { Router } from '@angular/router';
import { FormErrorCode, FormErrorEncoder } from '../utils/formcodes';
import { ResourceService } from '../services/resource.service'; import { ResourceService } from '../services/resource.service';
/** /**
@@ -3,10 +3,9 @@ import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material/dial
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { Observable, Subscription } from 'rxjs'; import { Observable, Subscription } from 'rxjs';
import { NgForm } from '@angular/forms'; import { NgForm } from '@angular/forms';
import { ApiClientService } from '../../api';
import { Snackbars } from '../utils/snackbars'; import { Snackbars } from '../utils/snackbars';
import { FormErrorEncoder } from '../utils/formcodes'; import { FormErrorEncoder } from '../utils/formcodes';
import { Place } from '../../api/models'; import { DefaultService, Place } from '../api';
import { HttpErrorResponse } from '@angular/common/http'; import { HttpErrorResponse } from '@angular/common/http';
import { HttpStatusCode } from '../utils/httpcodes'; import { HttpStatusCode } from '../utils/httpcodes';
import { ResourceService } from '../services/resource.service'; import { ResourceService } from '../services/resource.service';
@@ -34,7 +33,7 @@ import { ResourceService } from '../services/resource.service';
constructor( constructor(
public snackbar: MatSnackBar, public snackbar: MatSnackBar,
public apiClientService: ApiClientService, public apiClientService: DefaultService,
public dialog: MatDialogRef<any, boolean>, public dialog: MatDialogRef<any, boolean>,
@Inject(MAT_DIALOG_DATA) data: Place, @Inject(MAT_DIALOG_DATA) data: Place,
public res: ResourceService public res: ResourceService
@@ -1,4 +1,4 @@
import { Notice, Message } from '../../api/models'; import { Notice, Message } from '../api';
import { Input, Component } from '@angular/core'; import { Input, Component } from '@angular/core';
import { ResourceService } from '../services/resource.service'; import { ResourceService } from '../services/resource.service';
@@ -1,8 +1,5 @@
import { Component, OnInit, OnDestroy, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { UserState, UserService } from '../services/user.service'; import { FormErrorEncoder } from '../utils/formcodes';
import { BehaviorSubject, Subscription } from 'rxjs';
import { Router } from '@angular/router';
import { FormErrorCode, FormErrorEncoder } from '../utils/formcodes';
import { ResourceService } from '../services/resource.service'; import { ResourceService } from '../services/resource.service';
/** /**
@@ -7,8 +7,7 @@ import { Observable, BehaviorSubject } from 'rxjs';
import { ResourceService } from '../services/resource.service'; import { ResourceService } from '../services/resource.service';
import { PlaceService } from '../services/place.service'; import { PlaceService } from '../services/place.service';
import { Order } from '../../api'; import { Place, PlacePage } from '../api';
import { Place, PlacePage } from '../../api/models';
import { PaginationHandler } from '../utils/pagination'; import { PaginationHandler } from '../utils/pagination';
import { TableHandler, TableColumn } from '../utils/tables'; import { TableHandler, TableColumn } from '../utils/tables';
@@ -36,7 +35,7 @@ export class PlacesDialogComponent implements OnInit, OnDestroy {
placesDataSource: MatTableDataSource<PlaceWrapper>; placesDataSource: MatTableDataSource<PlaceWrapper>;
loading: BehaviorSubject<boolean>; loading: BehaviorSubject<boolean>;
order: BehaviorSubject<Order>; order: BehaviorSubject<String>;
selectedPlaces: Place[]; selectedPlaces: Place[];
private pageHandler: PaginationHandler<Place, PlacePage>; private pageHandler: PaginationHandler<Place, PlacePage>;
@@ -113,12 +112,12 @@ export class PlacesDialogComponent implements OnInit, OnDestroy {
return (place.nickname != null && place.nickname.length > 0)? place.nickname : place.address; return (place.nickname != null && place.nickname.length > 0)? place.nickname : place.address;
} }
getOrderName(order: Order): string { getOrderName(order: String): string {
return this.res.strings('places_order_value_' + order.toLowerCase()); return this.res.strings('places_order_value_' + order.toLowerCase());
} }
getOrders(): string[] { getOrders(): string[] {
return [ Order.TIME, Order.IMPORTANCE, Order.DURATION, Order.FREQUENCY, Order.IDENTIFIER ]; return [ 'TIME', 'IMPORTANCE', 'DURATION', 'FREQUENCY', 'IDENTIFIER' ];
} }
} }
@@ -1,6 +1,4 @@
import { Component, Input, OnInit, OnDestroy } from '@angular/core'; import { Component } from '@angular/core';
import { Router, RouterEvent, NavigationEnd } from '@angular/router';
import { Subscription } from 'rxjs';
import { UserService } from '../services/user.service'; import { UserService } from '../services/user.service';
/** /**
@@ -3,7 +3,7 @@ import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material/dial
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { Observable, Subscription } from 'rxjs'; import { Observable, Subscription } from 'rxjs';
import { NgForm } from '@angular/forms'; import { NgForm } from '@angular/forms';
import { ApiClientService } from '../../api'; import { DefaultService } from '../api';
import { Snackbars } from '../utils/snackbars'; import { Snackbars } from '../utils/snackbars';
import { FormErrorEncoder } from '../utils/formcodes'; import { FormErrorEncoder } from '../utils/formcodes';
import { ResourceService } from '../services/resource.service'; import { ResourceService } from '../services/resource.service';
@@ -29,7 +29,7 @@ import { ResourceService } from '../services/resource.service';
constructor( constructor(
public snackbar: MatSnackBar, public snackbar: MatSnackBar,
public apiClientService: ApiClientService, public apiClientService: DefaultService,
public dialog: MatDialogRef<any, boolean>, public dialog: MatDialogRef<any, boolean>,
@Inject(MAT_DIALOG_DATA) data: string, @Inject(MAT_DIALOG_DATA) data: string,
public res: ResourceService public res: ResourceService
@@ -10,7 +10,7 @@ export class TileMapComponent implements OnInit, DoCheck {
private static readonly DEFAULT_LOCATION = new L.LatLng(51.461663, 7.016645); private static readonly DEFAULT_LOCATION = new L.LatLng(51.461663, 7.016645);
private static readonly DEFAULT_ZOOM = 13; private static readonly DEFAULT_ZOOM = 13;
private static readonly DEFAULT_TILE_URL = 'https://cloud.locoslab.com/carta/restful-services/tile/{z}/{x}/{y}.png'; private static readonly DEFAULT_TILE_URL = 'https://www.maptology.com/carta/tile/{z}/{x}/{y}.png';
private static readonly DEFAULT_ICON_SCALE = 0.2; private static readonly DEFAULT_ICON_SCALE = 0.2;
@@ -1,5 +1,5 @@
import { Component, Input, OnInit, OnDestroy } from '@angular/core'; import { Component, Input, OnInit, OnDestroy } from '@angular/core';
import { Router, RouterEvent, NavigationEnd } from '@angular/router'; import { Router, NavigationEnd } from '@angular/router';
import { Subscription } from 'rxjs'; import { Subscription } from 'rxjs';
/** /**