Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf1cdb653b | ||
|
|
850f8add53 | ||
|
|
0d577ee938 | ||
|
|
fc7f9f0ed4 | ||
|
|
6d140284fa | ||
|
|
4e31cdcad7 | ||
|
|
2d1bf8a3bc | ||
|
|
c49fe8fcb4 | ||
|
|
cf74b4fdc8 | ||
|
|
bf90db3620 | ||
|
|
6bd1076e75 | ||
|
|
0772ea42d8 | ||
|
|
751f3f17e6 | ||
|
|
7885c7bb3c | ||
|
|
899b651ab1 | ||
|
|
4d40e47492 | ||
|
|
281831dbc9 | ||
|
|
2e9107dbc0 | ||
|
|
fa4714169a | ||
|
|
3ff2bf8d21 | ||
|
|
b728be2f86 | ||
|
|
d10ceef29b | ||
|
|
92f7027ca4 | ||
|
|
afe4776f59 | ||
|
|
06fb703f31 | ||
|
|
a1fc342862 | ||
|
|
ac06575858 | ||
|
|
58485d2db2 | ||
|
|
0abb3e2663 | ||
|
|
9c2934926f | ||
|
|
9a9bc07051 | ||
|
|
bf635a00ed | ||
|
|
4c5ff0d9e1 | ||
|
|
80f3195e32 |
@@ -27,7 +27,7 @@ android {
|
||||
applicationId "com.maptology.android.app"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 28
|
||||
versionCode 9
|
||||
versionCode 10
|
||||
versionName "${version}"
|
||||
buildConfigField "long", "BUILD_TIME", System.currentTimeMillis() + "L"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
@@ -28,12 +28,12 @@ allprojects {
|
||||
|
||||
// set version for our project
|
||||
group = 'com.maptology'
|
||||
version = '1.0.4'
|
||||
version = '1.0.5-SNAPSHOT'
|
||||
|
||||
// set versions for our libraries
|
||||
ext {
|
||||
// api dependencies
|
||||
versionJavaee = '7.0'
|
||||
versionJavaee = '8.0.0'
|
||||
versionJaxb = '2.3.1'
|
||||
versionAnnotation = '1.3.2'
|
||||
versionSwagger = '1.5.22'
|
||||
|
||||
@@ -6,8 +6,8 @@ description = 'Maptology Common Api'
|
||||
|
||||
dependencies {
|
||||
testCompile "junit:junit:${versionJunit}"
|
||||
compileOnly "javax.xml.bind:jaxb-api:${versionJaxb}"
|
||||
compileOnly "javax:javaee-api:${versionJavaee}"
|
||||
compileOnly "javax.xml.bind:jaxb-api:${versionJaxb}"
|
||||
compileOnly "jakarta.platform:jakarta.jakartaee-api:${versionJavaee}"
|
||||
compileOnly "io.swagger:swagger-annotations:${versionSwagger}"
|
||||
compileOnly "com.fasterxml.jackson.core:jackson-annotations:${versionJackson}"
|
||||
}
|
||||
@@ -34,21 +34,21 @@ swagger {
|
||||
'com.maptology.api.history.IHistoryService'
|
||||
]
|
||||
schemes = [ 'http', 'https']
|
||||
host = 'localhost'
|
||||
host = 'www.maptology.com'
|
||||
basePath = '/api'
|
||||
info {
|
||||
title = 'Maptology Service'
|
||||
version = "${version}"
|
||||
description = 'Maptology Service'
|
||||
version = project.version
|
||||
description = 'The application programming interface of Maptology.'
|
||||
termsOfService = 'https://maptology.com/terms-of-service'
|
||||
contact {
|
||||
email = 'nes-admin@uni-due.de'
|
||||
name = 'NES Universität Duisburg-Essen'
|
||||
name = 'Networked Embedded Systems'
|
||||
url = 'https://www.nes.uni-due.de'
|
||||
}
|
||||
license {
|
||||
url = 'https://www.maptology.com/license'
|
||||
name = 'Proprietary'
|
||||
name = 'Maptology License'
|
||||
}
|
||||
}
|
||||
swaggerFileName = 'maptology'
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
description = 'Maptology Service Ejb'
|
||||
|
||||
dependencies {
|
||||
compileOnly "javax:javaee-api:${versionJavaee}"
|
||||
compileOnly "jakarta.platform:jakarta.jakartaee-api:${versionJavaee}"
|
||||
compileOnly "com.fasterxml.jackson.core:jackson-annotations:${versionJackson}"
|
||||
compile project(':common-api')
|
||||
compile project(':service-geocode')
|
||||
|
||||
testCompile "javax:javaee-api:${versionJavaee}"
|
||||
testCompile "jakarta.platform:jakarta.jakartaee-api:${versionJavaee}"
|
||||
testCompile "javax.xml.bind:jaxb-api:${versionJaxb}"
|
||||
testCompile "com.fasterxml.jackson.core:jackson-databind:${versionJackson}"
|
||||
testCompile "junit:junit:${versionJunit}"
|
||||
@@ -26,7 +26,8 @@ jar {
|
||||
'Created-By' : "Gradle ${gradle.gradleVersion}",
|
||||
'Build-Jdk' : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
|
||||
'Build-OS' : "${System.properties['os.name']} ${System.properties['os.arch']} ${System.properties['os.version']}",
|
||||
'Implementation-Build' : "${System.properties['jenkins.build.number']}"
|
||||
'Implementation-Build' : "${System.properties['jenkins.build.number']}",
|
||||
'Implementation-Version' : project.version
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 445 B After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 2.6 KiB |
@@ -1,103 +1,61 @@
|
||||
<!-- HTML for static distribution bundle build -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Swagger UI</title>
|
||||
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700" rel="stylesheet">
|
||||
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
|
||||
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
|
||||
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
|
||||
<style>
|
||||
html
|
||||
{
|
||||
box-sizing: border-box;
|
||||
overflow: -moz-scrollbars-vertical;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
*,
|
||||
*:before,
|
||||
*:after
|
||||
{
|
||||
box-sizing: inherit;
|
||||
}
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Maptology Api</title>
|
||||
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
|
||||
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
|
||||
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
|
||||
<style>
|
||||
html
|
||||
{
|
||||
box-sizing: border-box;
|
||||
overflow: -moz-scrollbars-vertical;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
body {
|
||||
margin:0;
|
||||
background: #fafafa;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
*,
|
||||
*:before,
|
||||
*:after
|
||||
{
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
<body>
|
||||
body
|
||||
{
|
||||
margin:0;
|
||||
background: #fffcf7;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<script>
|
||||
if(window.navigator.userAgent.indexOf("Edge") > -1) {
|
||||
console.log("Removing native Edge fetch implementation")
|
||||
window.fetch = undefined
|
||||
<body>
|
||||
<div id="swagger-ui"></div>
|
||||
|
||||
<script src="./swagger-ui-bundle.js"> </script>
|
||||
<script src="./swagger-ui-standalone-preset.js"> </script>
|
||||
<script>
|
||||
window.onload = function() {
|
||||
// Begin Swagger UI call region
|
||||
const ui = SwaggerUIBundle({
|
||||
url: "swagger.json",
|
||||
dom_id: '#swagger-ui',
|
||||
validatorUrl: null,
|
||||
deepLinking: true,
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIStandalonePreset
|
||||
],
|
||||
plugins: [
|
||||
SwaggerUIBundle.plugins.DownloadUrl
|
||||
],
|
||||
layout: "StandaloneLayout"
|
||||
})
|
||||
// End Swagger UI call region
|
||||
|
||||
window.ui = ui
|
||||
}
|
||||
</script>
|
||||
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="position:absolute;width:0;height:0">
|
||||
<defs>
|
||||
<symbol viewBox="0 0 20 20" id="unlocked">
|
||||
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V6h2v-.801C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8z"></path>
|
||||
</symbol>
|
||||
|
||||
<symbol viewBox="0 0 20 20" id="locked">
|
||||
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8zM12 8H8V5.199C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol viewBox="0 0 20 20" id="close">
|
||||
<path d="M14.348 14.849c-.469.469-1.229.469-1.697 0L10 11.819l-2.651 3.029c-.469.469-1.229.469-1.697 0-.469-.469-.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-.469-.469-.469-1.228 0-1.697.469-.469 1.228-.469 1.697 0L10 8.183l2.651-3.031c.469-.469 1.228-.469 1.697 0 .469.469.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c.469.469.469 1.229 0 1.698z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol viewBox="0 0 20 20" id="large-arrow">
|
||||
<path d="M13.25 10L6.109 2.58c-.268-.27-.268-.707 0-.979.268-.27.701-.27.969 0l7.83 7.908c.268.271.268.709 0 .979l-7.83 7.908c-.268.271-.701.27-.969 0-.268-.269-.268-.707 0-.979L13.25 10z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol viewBox="0 0 20 20" id="large-arrow-down">
|
||||
<path d="M17.418 6.109c.272-.268.709-.268.979 0s.271.701 0 .969l-7.908 7.83c-.27.268-.707.268-.979 0l-7.908-7.83c-.27-.268-.27-.701 0-.969.271-.268.709-.268.979 0L10 13.25l7.418-7.141z"/>
|
||||
</symbol>
|
||||
|
||||
|
||||
<symbol viewBox="0 0 24 24" id="jump-to">
|
||||
<path d="M19 7v4H5.83l3.58-3.59L8 6l-6 6 6 6 1.41-1.41L5.83 13H21V7z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol viewBox="0 0 24 24" id="expand">
|
||||
<path d="M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"/>
|
||||
</symbol>
|
||||
|
||||
</defs>
|
||||
</svg>
|
||||
|
||||
<div id="swagger-ui"></div>
|
||||
|
||||
<script src="./swagger-ui-bundle.js"> </script>
|
||||
<script src="./swagger-ui-standalone-preset.js"> </script>
|
||||
<script>
|
||||
window.onload = function() {
|
||||
|
||||
// Build a system
|
||||
const ui = SwaggerUIBundle({
|
||||
url: "swagger.json",
|
||||
dom_id: '#swagger-ui',
|
||||
deepLinking: true,
|
||||
validatorUrl: null,
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIStandalonePreset
|
||||
],
|
||||
plugins: [
|
||||
SwaggerUIBundle.plugins.DownloadUrl
|
||||
],
|
||||
layout: "StandaloneLayout"
|
||||
})
|
||||
|
||||
window.ui = ui
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<!doctype html>
|
||||
<html lang="en-US">
|
||||
<title>Swagger UI: OAuth2 Redirect</title>
|
||||
<body onload="run()">
|
||||
</body>
|
||||
</html>
|
||||
@@ -45,11 +46,18 @@
|
||||
oauth2.auth.code = qp.code;
|
||||
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
|
||||
} else {
|
||||
let oauthErrorMsg
|
||||
if (qp.error) {
|
||||
oauthErrorMsg = "["+qp.error+"]: " +
|
||||
(qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
|
||||
(qp.error_uri ? "More info: "+qp.error_uri : "");
|
||||
}
|
||||
|
||||
oauth2.errCb({
|
||||
authId: oauth2.auth.name,
|
||||
source: "auth",
|
||||
level: "error",
|
||||
message: "Authorization failed: no accessCode received from the server"
|
||||
message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server"
|
||||
});
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"sources":[],"names":[],"mappings":"","file":"swagger-ui.css","sourceRoot":""}
|
||||
@@ -0,0 +1,8 @@
|
||||
description = 'Maptology Service Tool'
|
||||
|
||||
dependencies {
|
||||
compile project(':common-api')
|
||||
compile "org.jboss.resteasy:resteasy-client:${versionResteasy}"
|
||||
compile "org.jboss.resteasy:resteasy-jackson2-provider:${versionResteasy}"
|
||||
testCompile "junit:junit:${versionJunit}"
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.maptology.tool;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.maptology.api.PageConfig;
|
||||
import com.maptology.api.position.IPositionService;
|
||||
import com.maptology.api.position.Position;
|
||||
import com.maptology.api.position.PositionPage;
|
||||
import com.maptology.api.user.IUserService;
|
||||
import com.maptology.api.user.User;
|
||||
|
||||
/**
|
||||
* Downloads all data available for a particular device.
|
||||
*
|
||||
* @author Marcus
|
||||
*/
|
||||
public class DownloadDeviceData {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Runs the program.
|
||||
*
|
||||
* @param args Ignored.
|
||||
* @throws Exception Thrown if something fails.
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
IPositionService positionService = null;
|
||||
User user = null;
|
||||
while (user == null) {
|
||||
String username = null;
|
||||
while (username == null || username.length() == 0) {
|
||||
System.out.println("Username: ");
|
||||
username = scanner.nextLine().trim();
|
||||
}
|
||||
String password = null;
|
||||
while (password == null || password.length() == 0) {
|
||||
System.out.println("Password: ");
|
||||
password = scanner.nextLine().trim();
|
||||
}
|
||||
IUserService userService = ToolUtilities.getProxy(IUserService.class, username, password);
|
||||
Response r = userService.getCurrentUser();
|
||||
if (r.getStatusInfo() == Status.OK) {
|
||||
user = r.readEntity(User.class);
|
||||
positionService = ToolUtilities.getProxy(IPositionService.class, username, password);
|
||||
} else {
|
||||
System.out.println("Login failed.");
|
||||
}
|
||||
}
|
||||
scanner.close();
|
||||
System.out.println("Using user: " + user.getName());
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
File folder = new File(ToolUtilities.OUTPUT_FOLDER);
|
||||
folder.mkdirs();
|
||||
System.out.println("Using output folder: " + folder.getAbsolutePath());
|
||||
for (long device: ToolUtilities.DEVICES) {
|
||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(folder, "device-" + device + ".json")), StandardCharsets.UTF_8));
|
||||
System.out.println("Downloading device positions for: " + device);
|
||||
int offset = 0;
|
||||
int remaining = 0;
|
||||
int count = 0;
|
||||
do {
|
||||
System.out.println("Downloading page for offset: " + offset);
|
||||
Response r = positionService.getDevicePositions(device, new PageConfig(offset, 100), true);
|
||||
if (r.getStatusInfo() == Status.OK) {
|
||||
PositionPage page = r.readEntity(PositionPage.class);
|
||||
List<Position> positions = page.getElements();
|
||||
for (Position p: positions) {
|
||||
writer.write(mapper.writeValueAsString(p));
|
||||
writer.newLine();
|
||||
}
|
||||
offset += page.getSize();
|
||||
remaining = page.getTotal() - offset;
|
||||
count += positions.size();
|
||||
} else {
|
||||
System.out.println("Fetch failed.");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
} while (remaining > 0);
|
||||
writer.close();
|
||||
System.out.println("Downloaded " + count + " positions.");
|
||||
}
|
||||
System.out.println("Download complete.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.maptology.tool;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.maptology.api.position.Position;
|
||||
import com.maptology.tool.util.DeltaCodec;
|
||||
|
||||
/**
|
||||
* Generates the polyline of a particular device by decoding
|
||||
* the gps data and if available, the metadata.
|
||||
*
|
||||
* @author Marcus
|
||||
*/
|
||||
public class GenerateDevicePolyline {
|
||||
|
||||
/**
|
||||
* Runs the program.
|
||||
*
|
||||
* @param args Ignored.
|
||||
* @throws Exception Thrown if something fails.
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
File folder = new File(ToolUtilities.OUTPUT_FOLDER);
|
||||
for (long device: ToolUtilities.DEVICES) {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(new File(folder, "device-" + device + ".json")), StandardCharsets.UTF_8));
|
||||
String line = null;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
Position position = mapper.readValue(line, Position.class);
|
||||
if (position.getCoordinate() != null) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
if (position.getMetadata().containsKey("gps")) {
|
||||
DeltaCodec codec = new DeltaCodec(11);
|
||||
List<long[]> result = codec.decode(position.getMetadata().get("gps"), new ArrayList<long[]>());
|
||||
for (long[] value: result) {
|
||||
b.append("[" + value[3] * (double)10e-8 + ", " + value[2] * (double)10e-8 + "], ");
|
||||
}
|
||||
// compute some statistics
|
||||
double mdx = 0;
|
||||
long mtx = 0;
|
||||
double asx = 0;
|
||||
for (int i = 1; i < result.size(); i++) {
|
||||
long[] x = result.get(i - 1);
|
||||
long[] y = result.get(i);
|
||||
double d = ToolUtilities.getDistance(x[2] * (double)10e-8, x[3] * (double)10e-8, y[2] * (double)10e-8, y[3] * (double)10e-8);
|
||||
mdx = Math.max(mdx, d);
|
||||
mtx = Math.max(mtx, Math.abs(x[0] - y[0]));
|
||||
if (y[0] - x[0] > 0)
|
||||
asx += (d * 1000 / (y[0] - x[0])) / (result.size() - 1);
|
||||
}
|
||||
System.out.println(mdx + "\t" + mtx + "\t" + asx);
|
||||
} else {
|
||||
b.append("[" + position.getCoordinate().getLatitude() + ", " + position.getCoordinate().getLongitude() + "], ");
|
||||
}
|
||||
System.out.println(b.toString());
|
||||
}
|
||||
}
|
||||
reader.close();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.maptology.tool;
|
||||
|
||||
import org.jboss.resteasy.client.jaxrs.BasicAuthentication;
|
||||
import org.jboss.resteasy.client.jaxrs.ResteasyClient;
|
||||
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
|
||||
import org.jboss.resteasy.client.jaxrs.engines.URLConnectionEngine;
|
||||
|
||||
/**
|
||||
* The tool configuration and utilities.
|
||||
*
|
||||
* @author Marcus
|
||||
*/
|
||||
public class ToolUtilities {
|
||||
|
||||
/**
|
||||
* The url of the maptology api.
|
||||
*/
|
||||
public static String API_URL = "https://www.maptology.com/api";
|
||||
|
||||
/**
|
||||
* The devices
|
||||
*/
|
||||
public static long[] DEVICES = new long[] { 361281 };
|
||||
|
||||
/**
|
||||
* The output folder to write data.
|
||||
*/
|
||||
public static String OUTPUT_FOLDER = "temp";
|
||||
|
||||
|
||||
/**
|
||||
* The earth's radius in meters.
|
||||
*/
|
||||
public static final int EARTH_RADIUS = 6371000;
|
||||
|
||||
/**
|
||||
* Returns a proxy for the service with the specified login data.
|
||||
*
|
||||
* @param <T> The type of the service.
|
||||
* @param service The class representing the service interface.
|
||||
* @param username The user name.
|
||||
* @param password The user password.
|
||||
* @return The proxy for the service.
|
||||
*/
|
||||
public static <T> T getProxy(Class<T> service, String username, String password) {
|
||||
ResteasyClientBuilder builder = new ResteasyClientBuilder();
|
||||
builder.httpEngine(new URLConnectionEngine());
|
||||
ResteasyClient client = builder.build();
|
||||
return client.register(new BasicAuthentication(username, password)).target(API_URL).proxy(service);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the distance in meters between the two wgs coordinates specified by
|
||||
* alon, alat and blon, blat.
|
||||
*
|
||||
* @param alon The longitude of the first point.
|
||||
* @param alat The latitude of the first point.
|
||||
* @param blon The longitude of the second point.
|
||||
* @param blat The latitude of the second point.
|
||||
* @return The distance in meters.
|
||||
*/
|
||||
public static double getDistance(double alon, double alat, double blon, double blat) {
|
||||
double dlong = Math.toRadians(blon - alon);
|
||||
double dlat = Math.toRadians(blat - alat);
|
||||
double ax = Math.pow(Math.sin(dlat / 2.0), 2) + Math.cos(Math.toRadians(alat)) * Math.cos(Math.toRadians(blat))
|
||||
* Math.pow(Math.sin(dlong / 2.0), 2);
|
||||
double c = 2 * Math.atan2(Math.sqrt(ax), Math.sqrt(1 - ax));
|
||||
return EARTH_RADIUS * c;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package com.maptology.tool.util;
|
||||
|
||||
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,57 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Trace Visualization</title>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css" integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ==" crossorigin=""/>
|
||||
<script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js" integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew==" crossorigin=""></script>
|
||||
</head>
|
||||
<body>
|
||||
<style>
|
||||
html, body {
|
||||
height: 100%;
|
||||
margin: 0px;
|
||||
}
|
||||
#mapid {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<div id="mapid"></div>
|
||||
<script>
|
||||
|
||||
// add your points to draw into the array
|
||||
var polylinePoints = [
|
||||
[50.774138199999996, 7.0871493999999995], [50.774135199999996, 7.0871102], [50.7741407, 7.0871035]
|
||||
];
|
||||
|
||||
// create a map, add polyline set view
|
||||
var mymap = L.map('mapid').setView(polylinePoints[0], 13);
|
||||
|
||||
L.tileLayer('https://cloud.locoslab.com/carta/restful-services/tile/{z}/{x}/{y}.png', {
|
||||
maxZoom: 20,
|
||||
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
|
||||
'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
|
||||
'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
|
||||
id: 'mapbox/streets-v11'
|
||||
}).addTo(mymap);
|
||||
|
||||
var polylineOptions = {
|
||||
color: 'blue',
|
||||
weight: 6,
|
||||
opacity: 0.9
|
||||
};
|
||||
|
||||
var polyline = new L.Polyline(polylinePoints, polylineOptions);
|
||||
polyline.addTo(mymap);
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -9,7 +9,7 @@ dependencies {
|
||||
testCompile "junit:junit:${versionJunit}"
|
||||
testCompile "org.jboss.arquillian.junit:arquillian-junit-container:${versionArquillianJunit}"
|
||||
testCompile "org.wildfly.arquillian:wildfly-arquillian-container-managed:${versionArquillianContainer}"
|
||||
providedCompile "javax:javaee-api:${versionJavaee}"
|
||||
providedCompile "jakarta.platform:jakarta.jakartaee-api:${versionJavaee}"
|
||||
providedCompile "com.fasterxml.jackson.core:jackson-databind:${versionJackson}"
|
||||
providedCompile "org.jboss.resteasy:resteasy-client:${versionResteasy}"
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 445 B After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 2.6 KiB |
@@ -1,103 +1,61 @@
|
||||
<!-- HTML for static distribution bundle build -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Swagger UI</title>
|
||||
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700" rel="stylesheet">
|
||||
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
|
||||
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
|
||||
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
|
||||
<style>
|
||||
html
|
||||
{
|
||||
box-sizing: border-box;
|
||||
overflow: -moz-scrollbars-vertical;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
*,
|
||||
*:before,
|
||||
*:after
|
||||
{
|
||||
box-sizing: inherit;
|
||||
}
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Maptology Api</title>
|
||||
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
|
||||
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
|
||||
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
|
||||
<style>
|
||||
html
|
||||
{
|
||||
box-sizing: border-box;
|
||||
overflow: -moz-scrollbars-vertical;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
body {
|
||||
margin:0;
|
||||
background: #fafafa;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
*,
|
||||
*:before,
|
||||
*:after
|
||||
{
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
<body>
|
||||
body
|
||||
{
|
||||
margin:0;
|
||||
background: #fffcf7;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<script>
|
||||
if(window.navigator.userAgent.indexOf("Edge") > -1) {
|
||||
console.log("Removing native Edge fetch implementation")
|
||||
window.fetch = undefined
|
||||
<body>
|
||||
<div id="swagger-ui"></div>
|
||||
|
||||
<script src="./swagger-ui-bundle.js"> </script>
|
||||
<script src="./swagger-ui-standalone-preset.js"> </script>
|
||||
<script>
|
||||
window.onload = function() {
|
||||
// Begin Swagger UI call region
|
||||
const ui = SwaggerUIBundle({
|
||||
url: "maptology.json",
|
||||
dom_id: '#swagger-ui',
|
||||
validatorUrl: null,
|
||||
deepLinking: true,
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIStandalonePreset
|
||||
],
|
||||
plugins: [
|
||||
SwaggerUIBundle.plugins.DownloadUrl
|
||||
],
|
||||
layout: "StandaloneLayout"
|
||||
})
|
||||
// End Swagger UI call region
|
||||
|
||||
window.ui = ui
|
||||
}
|
||||
</script>
|
||||
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="position:absolute;width:0;height:0">
|
||||
<defs>
|
||||
<symbol viewBox="0 0 20 20" id="unlocked">
|
||||
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V6h2v-.801C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8z"></path>
|
||||
</symbol>
|
||||
|
||||
<symbol viewBox="0 0 20 20" id="locked">
|
||||
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8zM12 8H8V5.199C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol viewBox="0 0 20 20" id="close">
|
||||
<path d="M14.348 14.849c-.469.469-1.229.469-1.697 0L10 11.819l-2.651 3.029c-.469.469-1.229.469-1.697 0-.469-.469-.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-.469-.469-.469-1.228 0-1.697.469-.469 1.228-.469 1.697 0L10 8.183l2.651-3.031c.469-.469 1.228-.469 1.697 0 .469.469.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c.469.469.469 1.229 0 1.698z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol viewBox="0 0 20 20" id="large-arrow">
|
||||
<path d="M13.25 10L6.109 2.58c-.268-.27-.268-.707 0-.979.268-.27.701-.27.969 0l7.83 7.908c.268.271.268.709 0 .979l-7.83 7.908c-.268.271-.701.27-.969 0-.268-.269-.268-.707 0-.979L13.25 10z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol viewBox="0 0 20 20" id="large-arrow-down">
|
||||
<path d="M17.418 6.109c.272-.268.709-.268.979 0s.271.701 0 .969l-7.908 7.83c-.27.268-.707.268-.979 0l-7.908-7.83c-.27-.268-.27-.701 0-.969.271-.268.709-.268.979 0L10 13.25l7.418-7.141z"/>
|
||||
</symbol>
|
||||
|
||||
|
||||
<symbol viewBox="0 0 24 24" id="jump-to">
|
||||
<path d="M19 7v4H5.83l3.58-3.59L8 6l-6 6 6 6 1.41-1.41L5.83 13H21V7z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol viewBox="0 0 24 24" id="expand">
|
||||
<path d="M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"/>
|
||||
</symbol>
|
||||
|
||||
</defs>
|
||||
</svg>
|
||||
|
||||
<div id="swagger-ui"></div>
|
||||
|
||||
<script src="./swagger-ui-bundle.js"> </script>
|
||||
<script src="./swagger-ui-standalone-preset.js"> </script>
|
||||
<script>
|
||||
window.onload = function() {
|
||||
|
||||
// Build a system
|
||||
const ui = SwaggerUIBundle({
|
||||
url: "maptology.json",
|
||||
dom_id: '#swagger-ui',
|
||||
deepLinking: true,
|
||||
validatorUrl: null,
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIStandalonePreset
|
||||
],
|
||||
plugins: [
|
||||
SwaggerUIBundle.plugins.DownloadUrl
|
||||
],
|
||||
layout: "StandaloneLayout"
|
||||
})
|
||||
|
||||
window.ui = ui
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<!doctype html>
|
||||
<html lang="en-US">
|
||||
<title>Swagger UI: OAuth2 Redirect</title>
|
||||
<body onload="run()">
|
||||
</body>
|
||||
</html>
|
||||
@@ -45,11 +46,18 @@
|
||||
oauth2.auth.code = qp.code;
|
||||
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
|
||||
} else {
|
||||
let oauthErrorMsg
|
||||
if (qp.error) {
|
||||
oauthErrorMsg = "["+qp.error+"]: " +
|
||||
(qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
|
||||
(qp.error_uri ? "More info: "+qp.error_uri : "");
|
||||
}
|
||||
|
||||
oauth2.errCb({
|
||||
authId: oauth2.auth.name,
|
||||
source: "auth",
|
||||
level: "error",
|
||||
message: "Authorization failed: no accessCode received from the server"
|
||||
message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server"
|
||||
});
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"sources":[],"names":[],"mappings":"","file":"swagger-ui.css","sourceRoot":""}
|
||||
@@ -7,6 +7,7 @@ include(':service-geocode')
|
||||
include(':service-ejb')
|
||||
include(':service-war')
|
||||
include(':service-thorntail')
|
||||
include(':service-tool')
|
||||
include(':web-angular')
|
||||
include(':web-war')
|
||||
include(':site-ear')
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-angular:browser",
|
||||
"options": {
|
||||
"aot": true,
|
||||
"outputPath": "dist",
|
||||
"index": "src/index.html",
|
||||
"main": "src/main.ts",
|
||||
@@ -27,6 +28,12 @@
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"budgets": [
|
||||
{
|
||||
"type": "anyComponentStyle",
|
||||
"maximumWarning": "6kb"
|
||||
}
|
||||
],
|
||||
"optimization": true,
|
||||
"outputHashing": "all",
|
||||
"sourceMap": false,
|
||||
@@ -123,7 +130,7 @@
|
||||
"schematics": {
|
||||
"@schematics/angular:component": {
|
||||
"prefix": "app",
|
||||
"styleext": "scss"
|
||||
"style": "scss"
|
||||
},
|
||||
"@schematics/angular:directive": {
|
||||
"prefix": "app"
|
||||
|
||||
@@ -14,39 +14,39 @@
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "^8.1.2",
|
||||
"@angular/cdk": "^8.1.1",
|
||||
"@angular/common": "^8.1.2",
|
||||
"@angular/compiler": "^8.1.2",
|
||||
"@angular/core": "^8.1.2",
|
||||
"@angular/flex-layout": "^8.0.0-beta.26",
|
||||
"@angular/forms": "^8.1.2",
|
||||
"@angular/material": "^8.1.1",
|
||||
"@angular/platform-browser": "^8.1.2",
|
||||
"@angular/platform-browser-dynamic": "^8.1.2",
|
||||
"@angular/router": "^8.1.2",
|
||||
"@angular/animations": "^9.0.1",
|
||||
"@angular/cdk": "^9.0.0",
|
||||
"@angular/common": "^9.0.1",
|
||||
"@angular/compiler": "^9.0.1",
|
||||
"@angular/core": "^9.0.1",
|
||||
"@angular/flex-layout": "^9.0.0-beta.29",
|
||||
"@angular/forms": "^9.0.1",
|
||||
"@angular/material": "^9.0.0",
|
||||
"@angular/platform-browser": "^9.0.1",
|
||||
"@angular/platform-browser-dynamic": "^9.0.1",
|
||||
"@angular/router": "^9.0.1",
|
||||
"@types/jszip": "^3.1.6",
|
||||
"core-js": "^2.6.9",
|
||||
"hammerjs": "^2.0.8",
|
||||
"jszip": "^3.2.2",
|
||||
"leaflet": "^1.5.1",
|
||||
"ngx-gauge": "^1.0.0-beta.10",
|
||||
"ngx-gauge": "^1.0.0",
|
||||
"rxjs": "^6.5.2",
|
||||
"saturn-datepicker": "^8.0.1",
|
||||
"tslib": "^1.10.0",
|
||||
"zone.js": "^0.9.1"
|
||||
"zone.js": "~0.10.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "~0.801.2",
|
||||
"@angular/cli": "^8.1.2",
|
||||
"@angular/compiler-cli": "^8.1.2",
|
||||
"@angular/language-service": "^8.1.2",
|
||||
"@angular-devkit/build-angular": "~0.900.2",
|
||||
"@angular/cli": "^9.0.2",
|
||||
"@angular/compiler-cli": "^9.0.1",
|
||||
"@angular/language-service": "^9.0.1",
|
||||
"@types/jasmine": "^2.8.16",
|
||||
"@types/jasminewd2": "^2.0.6",
|
||||
"@types/leaflet": "^1.4.6",
|
||||
"@types/node": "^6.14.7",
|
||||
"@types/node": "^12.11.1",
|
||||
"acorn": "^6.2.0",
|
||||
"angular4-swagger-client-generator": "0.1.13",
|
||||
"codelyzer": "^5.0.1",
|
||||
"codelyzer": "^5.1.2",
|
||||
"events": "^3.0.0",
|
||||
"jasmine-core": "^2.8.0",
|
||||
"jasmine-spec-reporter": "^4.2.1",
|
||||
@@ -58,6 +58,6 @@
|
||||
"protractor": "^6.0.0",
|
||||
"ts-node": "~4.1.0",
|
||||
"tslint": "~5.9.1",
|
||||
"typescript": "~3.4.5"
|
||||
"typescript": "~3.7.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,16 +5,33 @@ import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
import { NgxGaugeModule } from 'ngx-gauge';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
|
||||
import { MatButtonModule, MatIconModule,
|
||||
MatCheckboxModule, MatSidenavModule,
|
||||
MatToolbarModule, MatTooltipModule, MatCardModule,
|
||||
MatInputModule, MatFormFieldModule,
|
||||
MatProgressBarModule, MatProgressSpinnerModule,
|
||||
MatSnackBarModule, MatDialogModule,
|
||||
MatListModule, MatPaginatorModule, MatTableModule,
|
||||
MatPaginatorIntl, MatExpansionModule, MatSelectModule,
|
||||
MatDatepickerModule, MatNativeDateModule,
|
||||
MatTabsModule, MatGridListModule, MatSliderModule } from '@angular/material';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||
import { MatNativeDateModule } from '@angular/material/core';
|
||||
import { MatDatepickerModule } from '@angular/material/datepicker';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { MatExpansionModule } from '@angular/material/expansion';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatGridListModule } from '@angular/material/grid-list';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatListModule } from '@angular/material/list';
|
||||
import { MatMenuModule } from '@angular/material/menu';
|
||||
import { MatPaginatorModule, MatPaginatorIntl } from '@angular/material/paginator';
|
||||
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { MatSidenavModule } from '@angular/material/sidenav';
|
||||
import { MatSliderModule } from '@angular/material/slider';
|
||||
import { MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import { MatTabsModule } from '@angular/material/tabs';
|
||||
import { MatToolbarModule } from '@angular/material/toolbar';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { MatButtonToggleModule } from "@angular/material/button-toggle";
|
||||
import { CdkTableModule } from "@angular/cdk/table";
|
||||
import { SatDatepickerModule, SatNativeDateModule } from 'saturn-datepicker'
|
||||
|
||||
import { LocationStrategy, PathLocationStrategy, registerLocaleData, DatePipe } from '@angular/common';
|
||||
import LocaleDE from '@angular/common/locales/de';
|
||||
@@ -89,6 +106,10 @@ import { ExportComponent } from './views/export.component';
|
||||
import { ExportService } from './services/export.service';
|
||||
import { DevicePositionService } from './services/device-position.service';
|
||||
import { DevicePositionsComponent } from './views/device-positions.component';
|
||||
import { ChartComponent } from './widgets/chart.component';
|
||||
import { TimeSheetComponent } from './views/time-sheet.component';
|
||||
import { PlacesDialogComponent } from "./widgets/places-dialog.component";
|
||||
|
||||
|
||||
/**
|
||||
* Computes the api domain from the browser location.
|
||||
@@ -157,6 +178,9 @@ registerLocaleData(LocaleDE);
|
||||
ManageNoticesComponent,
|
||||
EditNoticeComponent,
|
||||
UseParentFormDirective,
|
||||
ChartComponent,
|
||||
TimeSheetComponent,
|
||||
PlacesDialogComponent,
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
@@ -189,7 +213,12 @@ registerLocaleData(LocaleDE);
|
||||
MatNativeDateModule,
|
||||
MatTabsModule,
|
||||
MatGridListModule,
|
||||
MatMenuModule,
|
||||
CdkTableModule,
|
||||
AppRoutingModule,
|
||||
SatDatepickerModule,
|
||||
SatNativeDateModule,
|
||||
MatButtonToggleModule
|
||||
],
|
||||
providers: [
|
||||
// injection token for http client
|
||||
@@ -209,8 +238,15 @@ registerLocaleData(LocaleDE);
|
||||
ResourceService, CredentialService, UserService, VersionService, ExportService,
|
||||
DeviceService, PrivilegeService, PlaceService, NoticeService, PlaceVisitService, DeviceVisitService, DevicePositionService,
|
||||
ManageLogService, ManageUserService, ManageNoticeService
|
||||
],
|
||||
entryComponents: [MessageDialogComponent, ConfirmationDialogComponent, ShareDialogComponent, NicknameDialogComponent, LogDialogComponent],
|
||||
],
|
||||
entryComponents: [
|
||||
MessageDialogComponent,
|
||||
ConfirmationDialogComponent,
|
||||
ShareDialogComponent,
|
||||
NicknameDialogComponent,
|
||||
LogDialogComponent,
|
||||
PlacesDialogComponent,
|
||||
],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
export class AppModule { }
|
||||
|
||||
@@ -26,6 +26,7 @@ import { ManageNoticesComponent } from './views/manage-notices.component';
|
||||
import { EditNoticeComponent } from './views/edit-notice.component';
|
||||
import { ExportComponent } from './views/export.component';
|
||||
import { DevicePositionsComponent } from './views/device-positions.component';
|
||||
import { TimeSheetComponent } from "./views/time-sheet.component";
|
||||
|
||||
export const routes: Routes = [
|
||||
{ path: '', canActivate: [AuthGuard], canActivateChild: [AuthGuard], children: [
|
||||
@@ -55,6 +56,9 @@ export const routes: Routes = [
|
||||
{ path: 'export', component: InsideComponent, children: [
|
||||
{ path: '', component: ExportComponent }
|
||||
]},
|
||||
{ path: 'timesheet', component: InsideComponent, children: [
|
||||
{ path: '', component: TimeSheetComponent }
|
||||
]},
|
||||
/// inside (admin)
|
||||
{ path: 'manage', component: InsideComponent, children: [
|
||||
{ path: 'logs', component: ManageLogComponent },
|
||||
|
||||
@@ -12,7 +12,7 @@ export class AuthGuard implements CanActivate, CanActivateChild {
|
||||
];
|
||||
|
||||
private static readonly USER: string[] = [
|
||||
'/devices', '/notices', '/privileges', '/profile', '/places', '/export'
|
||||
'/devices', '/notices', '/privileges', '/profile', '/places', '/export', '/timesheet'
|
||||
];
|
||||
|
||||
private static readonly ADMIN: string[] = [
|
||||
|
||||
@@ -1,67 +1,51 @@
|
||||
<mat-list class="mat-typography">
|
||||
<mat-nav-list class="mat-typography" style="display: flex; flex: 1 1 auto; flex-direction: column;">
|
||||
<h3 mat-subheader>{{res.strings('drawer_navigation')}}</h3>
|
||||
<mat-list-item>
|
||||
<button mat-button routerLink="/notices">
|
||||
<mat-icon class="icon-button">message</mat-icon>
|
||||
<span class="mat-button">{{ res.strings('notices_title') }}</span>
|
||||
</button>
|
||||
</mat-list-item>
|
||||
<mat-list-item>
|
||||
<button mat-button routerLink="/privileges">
|
||||
<mat-icon class="icon-button">share</mat-icon>
|
||||
<span class="mat-button">{{ res.strings('privileges_title') }}</span>
|
||||
</button>
|
||||
</mat-list-item>
|
||||
<mat-list-item>
|
||||
<button mat-button routerLink="/devices">
|
||||
<mat-icon class="icon-button">devices</mat-icon>
|
||||
<span class="mat-button">{{ res.strings('devices_title') }}</span>
|
||||
</button>
|
||||
</mat-list-item>
|
||||
<mat-list-item>
|
||||
<button mat-button routerLink="/places">
|
||||
<mat-icon class="icon-button">pie_chart_outlined</mat-icon>
|
||||
<span class="mat-button">{{ res.strings('places_title') }}</span>
|
||||
</button>
|
||||
</mat-list-item>
|
||||
<mat-list-item>
|
||||
<button mat-button routerLink="/export">
|
||||
<mat-icon class="icon-button">cloud_download</mat-icon>
|
||||
<span class="mat-button">{{ res.strings('export_title') }}</span>
|
||||
</button>
|
||||
</mat-list-item>
|
||||
<a mat-list-item routerLink="/notices">
|
||||
<mat-icon class="icon-button">message</mat-icon>
|
||||
<span class="mat-button">{{ res.strings('notices_title') }}</span>
|
||||
</a>
|
||||
<a mat-list-item routerLink="/privileges">
|
||||
<mat-icon class="icon-button">share</mat-icon>
|
||||
<span class="mat-button">{{ res.strings('privileges_title') }}</span>
|
||||
</a>
|
||||
<a mat-list-item routerLink="/devices">
|
||||
<mat-icon class="icon-button">devices</mat-icon>
|
||||
<span class="mat-button">{{ res.strings('devices_title') }}</span>
|
||||
</a>
|
||||
<a mat-list-item routerLink="/places">
|
||||
<mat-icon class="icon-button">pie_chart_outlined</mat-icon>
|
||||
<span class="mat-button">{{ res.strings('places_title') }}</span>
|
||||
</a>
|
||||
<a mat-list-item routerLink="/export">
|
||||
<mat-icon class="icon-button">cloud_download</mat-icon>
|
||||
<span class="mat-button">{{ res.strings('export_title') }}</span>
|
||||
</a>
|
||||
<a mat-list-item routerLink="/timesheet">
|
||||
<mat-icon class="icon-button">access_time_icon</mat-icon>
|
||||
<span class="mat-button">{{ res.strings('time_sheet_title') }}</span>
|
||||
</a>
|
||||
<h3 mat-subheader>{{res.strings('drawer_settings')}}</h3>
|
||||
<mat-list-item>
|
||||
<button mat-button routerLink="/profile">
|
||||
<mat-icon class="icon-button">perm_identity</mat-icon>
|
||||
<span class="mat-button">{{ res.strings('user_title') }}</span>
|
||||
</button>
|
||||
</mat-list-item>
|
||||
<a mat-list-item routerLink="/profile">
|
||||
<mat-icon class="icon-button">perm_identity</mat-icon>
|
||||
<span class="mat-button">{{ res.strings('user_title') }}</span>
|
||||
</a>
|
||||
<ng-container *ngIf="admin">
|
||||
<h3 mat-subheader>{{res.strings('drawer_management')}}</h3>
|
||||
<mat-list-item>
|
||||
<button mat-button routerLink="/manage/system">
|
||||
<mat-icon class="icon-button">equalizer</mat-icon>
|
||||
<span class="mat-button">{{ res.strings('manage_system_title') }}</span>
|
||||
</button>
|
||||
</mat-list-item>
|
||||
<mat-list-item>
|
||||
<button mat-button routerLink="/manage/logs">
|
||||
<mat-icon class="icon-button">subject</mat-icon>
|
||||
<span class="mat-button">{{ res.strings('manage_logs_title') }}</span>
|
||||
</button>
|
||||
</mat-list-item>
|
||||
<mat-list-item>
|
||||
<button mat-button routerLink="/manage/users">
|
||||
<mat-icon class="icon-button">people</mat-icon>
|
||||
<span class="mat-button">{{ res.strings('manage_users_title') }}</span>
|
||||
</button>
|
||||
</mat-list-item>
|
||||
<mat-list-item>
|
||||
<button mat-button routerLink="/manage/notices">
|
||||
<mat-icon class="icon-button">forum</mat-icon>
|
||||
<span class="mat-button">{{ res.strings('manage_notices_title') }}</span>
|
||||
</button>
|
||||
</mat-list-item>
|
||||
<a mat-list-item routerLink="/manage/system">
|
||||
<mat-icon class="icon-button">equalizer</mat-icon>
|
||||
<span class="mat-button">{{ res.strings('manage_system_title') }}</span>
|
||||
</a>
|
||||
<a mat-list-item routerLink="/manage/logs">
|
||||
<mat-icon class="icon-button">subject</mat-icon>
|
||||
<span class="mat-button">{{ res.strings('manage_logs_title') }}</span>
|
||||
</a>
|
||||
<a mat-list-item routerLink="/manage/users">
|
||||
<mat-icon class="icon-button">people</mat-icon>
|
||||
<span class="mat-button">{{ res.strings('manage_users_title') }}</span>
|
||||
</a>
|
||||
<a mat-list-item routerLink="/manage/notices">
|
||||
<mat-icon class="icon-button">forum</mat-icon>
|
||||
<span class="mat-button">{{ res.strings('manage_notices_title') }}</span>
|
||||
</a>
|
||||
</ng-container>
|
||||
</mat-list>
|
||||
</mat-nav-list>
|
||||
@@ -2,7 +2,7 @@ import { Component, OnInit, OnDestroy, HostListener, ViewChild } from '@angular/
|
||||
import { Router } from '@angular/router';
|
||||
import { UserService, UserState } from '../services/user.service';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { MatSidenavContainer, MatSidenav } from '@angular/material';
|
||||
import { MatSidenavContainer, MatSidenav } from '@angular/material/sidenav';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@Component({
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { MatPaginatorIntl } from '@angular/material';
|
||||
import { MatPaginatorIntl } from '@angular/material/paginator';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
import { Inject } from '@angular/core';
|
||||
import { Inject, Injectable } from '@angular/core';
|
||||
|
||||
@Injectable()
|
||||
export class GermanPaginatorProvider extends MatPaginatorIntl {
|
||||
|
||||
constructor(@Inject(ResourceService) public res: ResourceService) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import { DataSource } from '@angular/cdk/table';
|
||||
import { Device, Position } from '../../api/models';
|
||||
import { ApiClientService } from '../../api';
|
||||
import { CollectionViewer } from '@angular/cdk/collections';
|
||||
import { DeltaCodec } from "../utils/deltacodec";
|
||||
|
||||
/**
|
||||
* A service that handles visits for a particular device and time.
|
||||
@@ -16,12 +17,13 @@ export class DevicePositionService implements DataSource<Position> {
|
||||
readonly date = new BehaviorSubject<Date>(new Date());
|
||||
private elements = new BehaviorSubject<Position[]>([]);
|
||||
|
||||
private readonly streams = 5;
|
||||
private readonly deltaCodec = new DeltaCodec(this.streams);
|
||||
|
||||
private id: number;
|
||||
private subscriptions = 0;
|
||||
|
||||
constructor(private apiClientService: ApiClientService) {
|
||||
}
|
||||
constructor(private apiClientService: ApiClientService) { }
|
||||
|
||||
getPositions(): Position[] {
|
||||
return this.elements.getValue();
|
||||
@@ -53,7 +55,7 @@ export class DevicePositionService implements DataSource<Position> {
|
||||
const millis = d.getTime();
|
||||
this.date.next(d);
|
||||
this.elements.next([]);
|
||||
this.apiClientService.getDevicePositionsRange(this.id, millis, 24 * 60 * 60 * 1000, false).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.loading.next(false);
|
||||
}, (error) => {
|
||||
@@ -71,4 +73,25 @@ export class DevicePositionService implements DataSource<Position> {
|
||||
this.subscriptions -= 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the accelerator string of the given position if present.
|
||||
*
|
||||
* The accelerator string is decoded into an array of 5 tuples by the DeltaCodec.
|
||||
* -> (timestamp, accuracy, x, y, z).
|
||||
* -> timestamp is given in microseconds.
|
||||
* -> x, y & z need to be shiftet 7 digits to the left (multiply with 10^-7).
|
||||
*
|
||||
* @param currPosition Current position object.
|
||||
* @return A multidimensional array of numbers.
|
||||
*/
|
||||
decodeAccelData(currPosition: Position): number[][] {
|
||||
if (!currPosition.metadata.accel) return null;
|
||||
let data = this.deltaCodec.decode(currPosition.metadata.accel as string, null);
|
||||
data.forEach((value: number[], idx: number, arr: number[][]) => {
|
||||
value[2] *= 0.0000001;
|
||||
value[3] *= 0.0000001;
|
||||
value[4] *= 0.0000001;
|
||||
})
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,6 +404,10 @@ export class ResourceService {
|
||||
'devices_location_tooltip': 'Standort anzeigen',
|
||||
'devices_history_tooltip': 'Verlauf anzeigen',
|
||||
'devices_position_tooltip': 'Aktualisierungen anzeigen',
|
||||
'devices_position_chart_header': 'Accelerometer',
|
||||
'devices_position_chart_y_axis_label': 'Daten',
|
||||
'devices_position_chart_x_axis_label': 'Sek.',
|
||||
'devices_position_chart_acceleration': 'Beschleunigung',
|
||||
'devices_delete_tooltip': 'Gerät löschen',
|
||||
'device_location_device_error': 'Die Geräteinformationen konnten nicht geladen werden.',
|
||||
'device_location_location_error': 'Der Standort konte nicht abgerufen werden.',
|
||||
@@ -441,6 +445,42 @@ export class ResourceService {
|
||||
'activate_error_badlink': 'Der Aktivierungslink ist ungültig. Falls Du ihn aus Deinem Emailprogramm in die '
|
||||
+ 'Adressleiste Deines Browsers kopiert hast, stell sicher, dass der Link vollständig ist.',
|
||||
'activate_error_expiredlink': 'Der Aktivierungslink ist nicht mehr gültig. Entweder wurder er schon benutzt oder er ist abgelaufen.',
|
||||
// TODO: Time Sheet labels DE
|
||||
'time_sheet_update_btn_tooltip': 'Aktualisieren',
|
||||
'time_sheet_export_btn_tooltip': 'Exportieren',
|
||||
'time_sheet_export_as_csv_label': 'als CSV',
|
||||
'time_sheet_export_as_json_label': 'als JSON',
|
||||
'time_sheet_export_error_msg_title': 'Fehler!',
|
||||
'time_sheet_export_error_msg': 'Es ist ein unerwarteter Fehler aufgetreten. Der Export ist fehlgeschlagen.',
|
||||
'time_sheet_title': 'Stundenzettel',
|
||||
'time_sheet_table_row_dialog_title': 'Zeitinfo',
|
||||
'time_sheet_table_date': 'Datum',
|
||||
'time_sheet_table_from': 'von',
|
||||
'time_sheet_table_to': 'bis',
|
||||
'time_sheet_table_working_time': 'Arbeitszeit',
|
||||
'time_sheet_table_place': 'Arbeitsplatz',
|
||||
'time_sheet_table_device': 'Gerät',
|
||||
'time_sheet_config_label': 'Konfiguration',
|
||||
'time_sheet_toggle_default_label': 'Arbeit',
|
||||
'time_sheet_toggle_default_tooltip': 'Gedeckelte & zusammengefasste Arbeitszeit je Tag.',
|
||||
'time_sheet_toggle_acc_label': 'Normal',
|
||||
'time_sheet_toggle_acc_tooltip': 'Ungedeckelte & zusammengefasste Zeiteinträge je Tag.',
|
||||
'time_sheet_toggle_by_days_label': 'Nach Tagen',
|
||||
'time_sheet_toggle_by_days_tooltip': 'Alle Zeiteinträge je Tag.',
|
||||
'time_sheet_toggle_raw_label': 'Rohdaten',
|
||||
'time_sheet_toggle_raw_tooltip': 'Rohdaten',
|
||||
'time_sheet_select_device_label': 'Gerät',
|
||||
'time_sheet_select_device_tooltip': 'Filtert die Zeiteinträge auf das ausgewählte Gerät.',
|
||||
'time_sheet_no_device_selected': 'Keins',
|
||||
'time_sheet_break_time_label': 'Pausendauer',
|
||||
'time_sheet_break_time_tooltip': 'Gibt an, ab welcher Dauer die Abwesenheit vom Arbeitsplatz als Pausendauer '
|
||||
+ 'zu werten ist und somit nicht zum Zeiteintrag hinzugerechnet wird.',
|
||||
'time_sheet_break_time_minutes': 'Minuten',
|
||||
'time_sheet_no_break_time_selected': 'Keine',
|
||||
'time_sheet_time_period_label': 'Zeitraum',
|
||||
'time_sheet_time_period_tooltip': 'Markiert den Zeitraum für die auszuwertendend Daten.',
|
||||
'time_sheet_workplace_button': 'Arbeitsplatz auswählen',
|
||||
'time_sheet_workplace_clear_list': 'Liste leeren',
|
||||
// layouts
|
||||
'drawer_navigation': 'Navigation',
|
||||
'drawer_settings': 'Einstellungen',
|
||||
@@ -845,6 +885,10 @@ export class ResourceService {
|
||||
'devices_location_tooltip': 'Show current location',
|
||||
'devices_history_tooltip': 'Show location history',
|
||||
'devices_position_tooltip': 'Show individual updates',
|
||||
'devices_position_chart_header': 'Accelerometer',
|
||||
'devices_position_chart_y_axis_label': 'Data',
|
||||
'devices_position_chart_x_axis_label': 'Sec.',
|
||||
'devices_position_chart_acceleration': 'Acceleration',
|
||||
'devices_delete_tooltip': 'Delete device',
|
||||
'device_location_device_error': 'Failed to load the device information.',
|
||||
'device_location_location_error': 'Failed to load the device location.',
|
||||
@@ -879,6 +923,42 @@ export class ResourceService {
|
||||
'activate_error_badlink': 'The activation link was invalid. If you copied it from your email program into the browser, '
|
||||
+ 'make sure to copy it completely.',
|
||||
'activate_error_expiredlink': 'The activation link is no longer valid. Did you already use it?',
|
||||
// TODO: Time Sheet labels EN
|
||||
'time_sheet_update_btn_tooltip': 'Update',
|
||||
'time_sheet_export_btn_tooltip': 'Export',
|
||||
'time_sheet_export_as_csv_label': 'as CSV',
|
||||
'time_sheet_export_as_json_label': 'as JSON',
|
||||
'time_sheet_export_error_msg_title': 'Error!',
|
||||
'time_sheet_export_error_msg': 'An unexpected error has occurred. The export has failed.',
|
||||
'time_sheet_title': 'Time Sheet',
|
||||
'time_sheet_table_row_dialog_title': 'Time Info',
|
||||
'time_sheet_table_date': 'Date',
|
||||
'time_sheet_table_from': 'from',
|
||||
'time_sheet_table_to': 'to',
|
||||
'time_sheet_table_working_time': 'Working Hours',
|
||||
'time_sheet_table_place': 'Workplace',
|
||||
'time_sheet_table_device': 'Device',
|
||||
'time_sheet_config_label': 'Configuration',
|
||||
'time_sheet_toggle_default_label': 'Work',
|
||||
'time_sheet_toggle_default_tooltip': 'Capped & accumulated working time per day.',
|
||||
'time_sheet_toggle_acc_label': 'Normal',
|
||||
'time_sheet_toggle_acc_tooltip': 'Uncapped & accumulated time entries per day.',
|
||||
'time_sheet_toggle_by_days_label': 'By Days',
|
||||
'time_sheet_toggle_by_days_tooltip': 'All time entries per day.',
|
||||
'time_sheet_toggle_raw_label': 'Raw',
|
||||
'time_sheet_toggle_raw_tooltip': 'Raw data.',
|
||||
'time_sheet_select_device_label': 'Device',
|
||||
'time_sheet_select_device_tooltip': 'Filters the time entries to the selected device.',
|
||||
'time_sheet_no_device_selected': 'None',
|
||||
'time_sheet_break_time_label': 'Break Time',
|
||||
'time_sheet_break_time_tooltip': 'Specifies the duration from which the absence from the work '
|
||||
+ 'place is to be valuated as a break duration and is therefore not added to the time entry.',
|
||||
'time_sheet_break_time_minutes': 'Minutes',
|
||||
'time_sheet_no_break_time_selected': 'None',
|
||||
'time_sheet_time_period_label': 'Time Period',
|
||||
'time_sheet_time_period_tooltip': 'Marks the period for the data to be evaluated.',
|
||||
'time_sheet_workplace_button': 'Select Workplace',
|
||||
'time_sheet_workplace_clear_list': 'Clear List',
|
||||
// layouts
|
||||
'drawer_navigation': 'Navigation',
|
||||
'drawer_settings': 'Settings',
|
||||
|
||||
@@ -0,0 +1,616 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Time, formatDate } from '@angular/common';
|
||||
import { HttpResponse } from '@angular/common/http';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatSort } from '@angular/material/sort';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { SatDatepickerRangeValue } from 'saturn-datepicker';
|
||||
|
||||
import { Page } from '../utils/pagination';
|
||||
import { ApiClientService } from '../../api';
|
||||
import { VisitPage, Device, Place, Visit } from '../../api/models';
|
||||
import { UserService } from './user.service';
|
||||
|
||||
|
||||
/**
|
||||
* Data model for the TimeSheetService.
|
||||
*/
|
||||
export interface TimeSheetData {
|
||||
overlappingDays: boolean; /* True if contained data is overlapping two or more days. */
|
||||
beginDate: Date; /* Start date */
|
||||
endDate: Date; /* End date */
|
||||
duration: Time; /* Duration time */
|
||||
placeId?: number; /* The id of the place. Null if placesSet is set. */
|
||||
deviceId?: number; /* The id of the device. Null if devicesSet is set. */
|
||||
placesSet?: Set<number>; /* A set of Places. Null if placeId is set. */
|
||||
devicesSet?: Set<number>; /* A set of Devices. Null if deviceId is set. */
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines how the TimeSheetData
|
||||
* of the service is grouped.
|
||||
*/
|
||||
export enum Grouping {
|
||||
DEFAULT = 1, /* Capped & accumulated working time per day. */
|
||||
BY_DAY_ACC = 2, /* Uncapped & accumulated working time per day. */
|
||||
BY_DAY = 3, /* All time entries per day. */
|
||||
RAW = 4 /* Raw data which was extracted from the call to the '/users/current/visits' api */
|
||||
}
|
||||
|
||||
type DateRange = { range?: SatDatepickerRangeValue<Date>, begin?: number, end?: number };
|
||||
|
||||
const COLUMN_SEPARATOR = ';';
|
||||
const LINE_SEPARATOR = '\r\n';
|
||||
|
||||
/**
|
||||
* A service which is fetching data from the '/users/current/visits'
|
||||
* api and transforms it to TimeSheetData.
|
||||
*/
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class TimeSheetService extends MatTableDataSource<TimeSheetData> {
|
||||
|
||||
private static readonly BATCH_SIZE = 500;
|
||||
|
||||
private static readonly DAY_IN_MILLI = 86_400_000;
|
||||
|
||||
/* Properties representing the current progress in
|
||||
* fetching Visit data from the server. */
|
||||
fetching$ = new BehaviorSubject<boolean>(false);
|
||||
error$ = new BehaviorSubject<boolean>(false);
|
||||
|
||||
private _visitsAvailable: boolean = false;
|
||||
private visitsPage: VisitPage = TimeSheetService.emptyPage();
|
||||
private request = 0;
|
||||
|
||||
/* These Properties are used to filter the Visit data which then,
|
||||
* in turn can be composed to the final timeSheet data shown
|
||||
* to the user.
|
||||
* At least the dateRange & workPlaces have to contain
|
||||
* valid values to start the composition process.
|
||||
* Remark: The prefixed _prev... values serve as a workaround
|
||||
* for a known bug in angular, where mat-selection is fireing
|
||||
* a "selectionChange" event twice when the selected value is null. */
|
||||
private _grouped: Grouping = Grouping.DEFAULT;
|
||||
private _device: Device = null;
|
||||
private _prevDevice: Device = null;
|
||||
private _breakTime: number = null;
|
||||
private _prevBreakTime: number = null;
|
||||
private _dateRange: DateRange = {};
|
||||
private _workPlaces: Place[] = [];
|
||||
|
||||
/** Creates an empty page. */
|
||||
private static emptyPage() {
|
||||
return { elements: [], offset: 0, total: -1, size: 0 };
|
||||
}
|
||||
|
||||
constructor(
|
||||
private apiClientService: ApiClientService,
|
||||
private userService: UserService
|
||||
) {
|
||||
super([]);
|
||||
}
|
||||
|
||||
get isTimeSheetReady(): boolean {
|
||||
return this.visitsAvailable === true && this.dateRange !== null && this.workPlaces.length > 0;
|
||||
}
|
||||
|
||||
private get visitsAvailable(): boolean {
|
||||
return this._visitsAvailable;
|
||||
}
|
||||
|
||||
private set visitsAvailable(available: boolean) {
|
||||
this._visitsAvailable = available;
|
||||
this.updateTimeSheet();
|
||||
}
|
||||
|
||||
get grouped(): Grouping {
|
||||
return this._grouped;
|
||||
}
|
||||
|
||||
set grouped(grouped: Grouping) {
|
||||
if (grouped != null) {
|
||||
if (this._grouped !== grouped) {
|
||||
if ((this._grouped === Grouping.DEFAULT || this.grouped === Grouping.BY_DAY_ACC) && this._breakTime)
|
||||
this._breakTime = null;
|
||||
this._grouped = grouped;
|
||||
this.updateTimeSheet();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get device(): Device | null {
|
||||
return this._device;
|
||||
}
|
||||
|
||||
set device(device: Device | null) {
|
||||
this._prevDevice = this._device;
|
||||
this._device = device;
|
||||
if (this._prevDevice === null && device === null)
|
||||
return;
|
||||
this.updateTimeSheet();
|
||||
}
|
||||
|
||||
get breakTime(): number | null {
|
||||
return this._breakTime;
|
||||
}
|
||||
|
||||
set breakTime(breakTime: number | null) {
|
||||
this._prevBreakTime = this._breakTime;
|
||||
this._breakTime = breakTime;
|
||||
if (this._prevBreakTime === null && breakTime === null)
|
||||
return;
|
||||
this.updateTimeSheet();
|
||||
}
|
||||
|
||||
get dateRange(): SatDatepickerRangeValue<Date> | null {
|
||||
return this._dateRange.range;
|
||||
}
|
||||
|
||||
set dateRange(dateRange: SatDatepickerRangeValue<Date> | null) {
|
||||
if (dateRange !== null) {
|
||||
const beginMillis = dateRange.begin.getTime();
|
||||
const endMillis = new Date(dateRange.end.getTime() + TimeSheetService.DAY_IN_MILLI).getTime();
|
||||
this._dateRange = {
|
||||
range: dateRange,
|
||||
begin: beginMillis,
|
||||
end: endMillis
|
||||
};
|
||||
} else {
|
||||
this._dateRange = {};
|
||||
}
|
||||
this.updateTimeSheet();
|
||||
}
|
||||
|
||||
get workPlaces(): Place[] {
|
||||
return this._workPlaces;
|
||||
}
|
||||
|
||||
set workPlaces(workPlaces: Place[]) {
|
||||
this._workPlaces = workPlaces;
|
||||
this.updateTimeSheet();
|
||||
}
|
||||
|
||||
setup(paginator?: MatPaginator, sort?: MatSort): void{
|
||||
this.paginator = paginator;
|
||||
this.sort = sort;
|
||||
this.fetchData();
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
this.paginator = null;
|
||||
this.sort = null;
|
||||
this.resetService(false);
|
||||
this.resetFilters();
|
||||
}
|
||||
|
||||
fetchData(): void {
|
||||
if (this.fetching$.getValue()) return;
|
||||
this.resetService(true);
|
||||
this.fetchAllVisits(this.request);
|
||||
}
|
||||
|
||||
private resetService(isFetch: boolean): void {
|
||||
this.request += 1;
|
||||
this.fetching$.next(isFetch);
|
||||
this.visitsAvailable = false;
|
||||
this.visitsPage = TimeSheetService.emptyPage();
|
||||
}
|
||||
|
||||
private resetFilters(): void {
|
||||
this._grouped = Grouping.RAW;
|
||||
this._device = null;
|
||||
this._breakTime = null;
|
||||
this._dateRange = {};
|
||||
this._workPlaces = [];
|
||||
this.updateTimeSheet();
|
||||
}
|
||||
|
||||
private fetchAllVisits(code: number): void {
|
||||
if (this.isIncomplete(this.visitsPage)) {
|
||||
this.apiClientService.getCurrentUserVisits(this.visitsPage.offset, TimeSheetService.BATCH_SIZE)
|
||||
.subscribe((response: HttpResponse<VisitPage>) => {
|
||||
if (code === this.request) {
|
||||
this.visitsPage = this.mergePages(response.body, this.visitsPage);
|
||||
this.fetchAllVisits(code);
|
||||
}
|
||||
},
|
||||
this.createErrorHandler(code)
|
||||
);
|
||||
} else {
|
||||
this.fetching$.next(false);
|
||||
this.visitsAvailable = true;
|
||||
}
|
||||
}
|
||||
|
||||
private isIncomplete(page: Page<any>): boolean {
|
||||
return page.total < 0 || page.total > page.offset;
|
||||
}
|
||||
|
||||
private mergePages<T>(source: Page<T>, destination: Page<T>): Page<T> {
|
||||
const result = TimeSheetService.emptyPage();
|
||||
result.total = source.total;
|
||||
result.size = destination.size + source.elements.length;
|
||||
result.elements = destination.elements.concat(source.elements);
|
||||
result.offset = destination.offset + TimeSheetService.BATCH_SIZE;
|
||||
return result;
|
||||
}
|
||||
|
||||
private createErrorHandler(code: number): (error: any) => void {
|
||||
return (error: any) => {
|
||||
if (code === this.request) {
|
||||
this.error$.next(true);
|
||||
this.fetching$.next(false);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the member data of the MatTableDataSource if some of the properties change.
|
||||
* The data is only updated if the property "isTimeSheetReady" is true.
|
||||
*/
|
||||
private updateTimeSheet(): void {
|
||||
let timeSheet: TimeSheetData[] = [];
|
||||
if (this.isTimeSheetReady) {
|
||||
/* Filter all relevant places and dates. */
|
||||
let filteredVisits = this.visitsPage.elements.filter((visit: Visit) => {
|
||||
if (this._dateRange.begin <= visit.beginTime && visit.endTime < this._dateRange.end
|
||||
&& this.workPlaces.some(place => place.id === visit.place)) {
|
||||
return visit;
|
||||
}
|
||||
});
|
||||
/* Filter for specified device. */
|
||||
if (this.device != null)
|
||||
filteredVisits = filteredVisits.filter(visit => visit.device === this.device.id);
|
||||
|
||||
/* Map filtered visits to TimeSheetData */
|
||||
if (filteredVisits.length > 0) {
|
||||
switch (this.grouped) {
|
||||
case Grouping.DEFAULT:
|
||||
case Grouping.BY_DAY_ACC:
|
||||
timeSheet = this.accumulateV2TsByDay(filteredVisits);
|
||||
break;
|
||||
case Grouping.BY_DAY:
|
||||
let tsMap = this.mapV2TsByDay(filteredVisits);
|
||||
tsMap.forEach((ts: TimeSheetData[]) => {
|
||||
if (ts.length > 0)
|
||||
timeSheet.push(...ts);
|
||||
});
|
||||
break;
|
||||
case Grouping.RAW:
|
||||
timeSheet = this.mapVisitsToTimeSheet(filteredVisits);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.data = timeSheet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mapping the passed Visit objects to raw TimeSheetData objects.
|
||||
*
|
||||
* @param visits Visits to map.
|
||||
* @return List of the corresponding TimeSheetData objects.
|
||||
*/
|
||||
private mapVisitsToTimeSheet(visits: Visit[]): TimeSheetData[] {
|
||||
return visits.map(visit => {
|
||||
const workingTime = this.getWorkingTime(visit.beginTime, visit.endTime);
|
||||
const midnight = this.getMidnightDate(visit.beginTime);
|
||||
const overlapping = (visit.endTime - midnight.getTime()) >= TimeSheetService.DAY_IN_MILLI;
|
||||
|
||||
return {
|
||||
overlappingDays: overlapping,
|
||||
beginDate: new Date(visit.beginTime),
|
||||
endDate: new Date(visit.endTime),
|
||||
duration: workingTime,
|
||||
placeId: visit.place,
|
||||
deviceId: visit.device
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Mapping the passed Visit objects to TimeSheetData objects which are grouped by days
|
||||
* represented as Unix timestamps starting at midnight.
|
||||
* E.g.:
|
||||
* timestamp: 1580425200000
|
||||
* GMT: Thursday, 30. January 2020 23:00:00
|
||||
* Germany: Freitag, 31. Januar 2020 00:00:00 GMT+01:00
|
||||
*
|
||||
* @param visits Visits to map.
|
||||
* @return Map of TimeSheetData objects grouped by days.
|
||||
*/
|
||||
private mapV2TsByDay(visits: Visit[]): Map<number, TimeSheetData[]> {
|
||||
const timeSheetMap = new Map<number, TimeSheetData[]>();
|
||||
const rawTimeSheet: TimeSheetData[] = this.mapVisitsToTimeSheet(visits);
|
||||
const putInMap = (map: Map<number, TimeSheetData[]>, key: number, value: TimeSheetData) => {
|
||||
if (map.has(key))
|
||||
map.get(key).push(value);
|
||||
else
|
||||
map.set(key, [value]);
|
||||
};
|
||||
|
||||
if (rawTimeSheet.length > 0) {
|
||||
return rawTimeSheet
|
||||
.reduce((prevMap: Map<number, TimeSheetData[]>, currTS: TimeSheetData) => {
|
||||
let beginMidnight = this.getMidnightDate(currTS.beginDate.getTime()).getTime();
|
||||
let endMidnight = this.getMidnightDate(currTS.endDate.getTime()).getTime();
|
||||
|
||||
if (beginMidnight === endMidnight) {
|
||||
putInMap(prevMap, beginMidnight, currTS);
|
||||
}
|
||||
else {
|
||||
/* If beginDate & endDate are overlapping two or more days then split
|
||||
* object into multiple TimeSheetData objects till endDate is reached. */
|
||||
const DAY = TimeSheetService.DAY_IN_MILLI;
|
||||
for (let j = beginMidnight + DAY; j <= endMidnight; j += DAY) {
|
||||
const begin = (j == beginMidnight + DAY) ? currTS.beginDate.getTime() : j - DAY;
|
||||
const end = j;
|
||||
const newTS = {
|
||||
overlappingDays: false,
|
||||
beginDate: new Date(begin),
|
||||
endDate: new Date(end),
|
||||
duration: this.getWorkingTime(begin, end),
|
||||
placeId: currTS.placeId,
|
||||
deviceId: currTS.deviceId
|
||||
};
|
||||
putInMap(prevMap, end - DAY, newTS);
|
||||
}
|
||||
|
||||
const newTS = {
|
||||
overlappingDays: false,
|
||||
beginDate: new Date(endMidnight),
|
||||
endDate: currTS.endDate,
|
||||
duration: this.getWorkingTime(endMidnight, currTS.endDate.getTime()),
|
||||
placeId: currTS.placeId,
|
||||
deviceId: currTS.deviceId
|
||||
};
|
||||
putInMap(prevMap, endMidnight, newTS);
|
||||
}
|
||||
return prevMap;
|
||||
}, timeSheetMap);
|
||||
} else {
|
||||
return timeSheetMap;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps a list of Visits to a list of TimeSheetData which in turn
|
||||
* is containing only accumulated TimeSheetData object each
|
||||
* representing a single day.
|
||||
*
|
||||
* @param visits Visits to map.
|
||||
* @param workingTimeAcc Function to accumulate the working time.
|
||||
* @returns List of accumulated TimeSheetData.
|
||||
*/
|
||||
private accumulateV2TsByDay(visits: Visit[]): TimeSheetData[] {
|
||||
const timeSheet: TimeSheetData[] = [];
|
||||
const tsMap = this.mapV2TsByDay(visits);
|
||||
tsMap.forEach((tsList: TimeSheetData[]) => {
|
||||
if (tsList.length > 0) {
|
||||
const erliestBegin = tsList
|
||||
.map((ts: TimeSheetData) => ts.beginDate.getTime())
|
||||
.reduce((prev, curr) => prev < curr ? prev : curr, Number.MAX_SAFE_INTEGER);
|
||||
const latestEnd = tsList
|
||||
.map((ts: TimeSheetData) => ts.endDate.getTime())
|
||||
.reduce((prev, curr) => prev > curr ? prev : curr, Number.MIN_SAFE_INTEGER);
|
||||
const places = new Set<number>();
|
||||
const devices = new Set<number>();
|
||||
tsList.forEach((ts: TimeSheetData) => {
|
||||
if (ts.placeId) places.add(ts.placeId);
|
||||
if (ts.deviceId) devices.add(ts.deviceId);
|
||||
});
|
||||
|
||||
const btThreshold = (this.breakTime) ? this.breakTime * 60_000 : 0;
|
||||
const timeAccumulation = tsList
|
||||
.reduce((prev: { sheet?: TimeSheetData, acc: Time, breakAcc: Time }, curr: TimeSheetData) => {
|
||||
if (prev.sheet) {
|
||||
let addToBreakAcc = true;
|
||||
const time = this.getWorkingTime(prev.sheet.endDate.getTime(), curr.beginDate.getTime());
|
||||
if (btThreshold > 0) {
|
||||
if (curr.beginDate.getTime() - prev.sheet.endDate.getTime() <= btThreshold) {
|
||||
prev.acc.hours += time.hours;
|
||||
prev.acc.minutes += time.minutes;
|
||||
addToBreakAcc = false;
|
||||
}
|
||||
}
|
||||
if (addToBreakAcc) {
|
||||
prev.breakAcc.hours += time.hours;
|
||||
prev.breakAcc.minutes += time.minutes;
|
||||
}
|
||||
}
|
||||
prev.acc.hours += curr.duration.hours;
|
||||
prev.acc.minutes += curr.duration.minutes;
|
||||
prev.sheet = curr;
|
||||
return prev;
|
||||
},
|
||||
{ sheet: null, acc: { hours: 0, minutes: 0 }, breakAcc: { hours: 0, minutes: 0} }
|
||||
);
|
||||
const accWorkingHours = this.processWorkingHours(timeAccumulation.acc, timeAccumulation.breakAcc);
|
||||
|
||||
timeSheet.push({
|
||||
overlappingDays: false,
|
||||
beginDate: new Date(erliestBegin),
|
||||
endDate: new Date(latestEnd),
|
||||
duration: accWorkingHours,
|
||||
placesSet: places,
|
||||
devicesSet: devices
|
||||
});
|
||||
}
|
||||
});
|
||||
return timeSheet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the work and break time. If Grouping is DEFAULT, the break time is evaluated
|
||||
* and has to fit the legal requirements of having at least a 30 or 45 minutes break when
|
||||
* working more than 6 or 9 hours respectively.
|
||||
*
|
||||
* @param working The time that is counting as work time.
|
||||
* @param breaking The time between the single work time entries
|
||||
* which can be seen as break time.
|
||||
* @return The normalized and processed work time.
|
||||
*/
|
||||
private processWorkingHours(working: Time, breaking: Time): Time {
|
||||
working = this.normalizeTime(working);
|
||||
if (this.grouped === Grouping.DEFAULT) {
|
||||
let subtrahend = 0;
|
||||
breaking = this.normalizeTime(breaking);
|
||||
if (working.hours >= 6 && breaking.hours === 0 && breaking.minutes < 30)
|
||||
subtrahend = 30 - breaking.minutes;
|
||||
else if (working.hours >= 9 && breaking.hours === 0 && breaking.minutes < 45)
|
||||
subtrahend = 45 - breaking.minutes;
|
||||
working.minutes -= subtrahend;
|
||||
if (working.minutes < 0) {
|
||||
--working.hours;
|
||||
working.minutes = 60 - working.minutes;
|
||||
}
|
||||
|
||||
/* Rounds up the minutes to a multiple of 15. */
|
||||
if (working.minutes !== 0)
|
||||
working.minutes += Math.floor(15 - working.minutes % 15);
|
||||
if (working.minutes === 60) {
|
||||
++working.hours;
|
||||
working.minutes = 0;
|
||||
}
|
||||
if (working.hours >= 10)
|
||||
working = { hours: 10, minutes: 0 };
|
||||
}
|
||||
return working;
|
||||
}
|
||||
|
||||
private normalizeTime(time: Time): Time {
|
||||
time.hours += Math.floor(time.minutes / 60);
|
||||
time.minutes = time.minutes % 60;
|
||||
return time;
|
||||
}
|
||||
|
||||
private getMidnightDate(tstp: number): Date {
|
||||
let midnight = new Date(tstp);
|
||||
midnight.setHours(0, 0, 0, 0);
|
||||
return midnight;
|
||||
};
|
||||
|
||||
private getWorkingTime(beginMillis: number, endMillis: number): Time {
|
||||
const beginMinutes = Math.floor(beginMillis/1000/60);
|
||||
const endMinutes = Math.floor(endMillis/1000/60);
|
||||
const totalMinutes = endMinutes - beginMinutes;
|
||||
const totalHours = totalMinutes / 60;
|
||||
|
||||
let hours = Math.floor(totalHours);
|
||||
let minutes = Math.round(60 * (totalHours - hours));
|
||||
if (minutes >= 60) {
|
||||
const additionalHours = Math.floor(minutes / 60);
|
||||
hours += additionalHours;
|
||||
minutes = minutes - (60 * additionalHours);
|
||||
}
|
||||
return { hours, minutes };
|
||||
}
|
||||
|
||||
getWorkplaceName(place: Place): string {
|
||||
return (place.nickname != null && place.nickname.length > 0)? place.nickname : place.address;
|
||||
}
|
||||
|
||||
getWorkplaceString(data: TimeSheetData): string {
|
||||
let res = '';
|
||||
if (data.placeId) {
|
||||
const place = this.workPlaces.find(place => place.id === data.placeId);
|
||||
res = this.getWorkplaceName(place);
|
||||
} else {
|
||||
data.placesSet.forEach(id => {
|
||||
const place = this.workPlaces.find(place => place.id === id);
|
||||
res += this.getWorkplaceName(place) + ', '
|
||||
});
|
||||
res = res.slice(0, res.length - 2);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
getDate(data: TimeSheetData): string {
|
||||
if (this.grouped == Grouping.RAW) {
|
||||
let prefix = '';
|
||||
let date = formatDate(data.endDate, 'dd.LL.yyyy', 'de');
|
||||
if (data.overlappingDays) {
|
||||
prefix = formatDate(data.beginDate, 'dd', 'de') + ' - ';
|
||||
}
|
||||
return prefix + date;
|
||||
} else {
|
||||
return formatDate(data.beginDate, 'dd.LL.yyyy', 'de');
|
||||
}
|
||||
}
|
||||
|
||||
exportTimeSheet(type: string): boolean {
|
||||
let exportStr: string;
|
||||
switch (type) {
|
||||
case 'csv':
|
||||
exportStr = this.createCSV();
|
||||
break;
|
||||
case 'json':
|
||||
exportStr = this.createJSON();
|
||||
break;
|
||||
}
|
||||
if (!exportStr) return false;
|
||||
|
||||
/* '\ufeff' -> UTF-8 Header Byte prepended. */
|
||||
const blob = new Blob(['\ufeff', exportStr], { type: `text/${type};` });
|
||||
const login = this.userService.getLogin();
|
||||
let name = 'timesheet-export';
|
||||
if (login != null) name += '-' + login;
|
||||
name += '-' + Date.now();
|
||||
this.saveAs(`${name}.${type}`, blob);
|
||||
return true;
|
||||
}
|
||||
|
||||
private saveAs(name: string, blob: Blob): void {
|
||||
if (navigator.msSaveBlob) {
|
||||
navigator.msSaveBlob(blob, name);
|
||||
} else {
|
||||
const link = document.createElement('a');
|
||||
(<any>link).download = name;
|
||||
link.href = URL.createObjectURL(blob);
|
||||
link.click();
|
||||
setTimeout(() => {
|
||||
URL.revokeObjectURL(link.href);
|
||||
link.remove();
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
|
||||
private createCSV(): string | null {
|
||||
if (this.data.length === 0)
|
||||
return null;
|
||||
let result = '';
|
||||
result += 'DATE' + COLUMN_SEPARATOR;
|
||||
result += 'FROM' + COLUMN_SEPARATOR;
|
||||
result += 'TO' + COLUMN_SEPARATOR;
|
||||
result += 'WORKING_TIME' + COLUMN_SEPARATOR;
|
||||
result += 'PLACES' + COLUMN_SEPARATOR;
|
||||
result += LINE_SEPARATOR;
|
||||
this.data.forEach((td: TimeSheetData) => {
|
||||
result += this.getDate(td) + COLUMN_SEPARATOR;
|
||||
result += formatDate(td.beginDate, 'H:mm', 'de') + COLUMN_SEPARATOR;
|
||||
result += formatDate(td.endDate, 'H:mm', 'de') + COLUMN_SEPARATOR;
|
||||
result += `${td.duration.hours} h ${td.duration.minutes} m` + COLUMN_SEPARATOR;
|
||||
result += this.getWorkplaceString(td) + COLUMN_SEPARATOR;
|
||||
result += LINE_SEPARATOR;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
private createJSON(): string | null {
|
||||
return JSON.stringify(
|
||||
this.data.map((td: TimeSheetData) => {
|
||||
return {
|
||||
date: this.getDate(td),
|
||||
from: formatDate(td.beginDate, 'H:mm', 'de'),
|
||||
to: formatDate(td.endDate, 'H:mm', 'de'),
|
||||
workingTime: `${td.duration.hours} h ${td.duration.minutes} m`,
|
||||
workplaces: this.getWorkplaceString(td)
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* Copied the DeltaCodec class from the `android-app project` and
|
||||
* ported to TypeScript.
|
||||
*
|
||||
* @author Adriano
|
||||
*/
|
||||
export class DeltaCodec {
|
||||
|
||||
/**
|
||||
* Creates a delta compressor for the specified number of streams.
|
||||
*
|
||||
* @param streams The number of streams to encode in the string.
|
||||
*/
|
||||
constructor(private streams: number) { }
|
||||
|
||||
/**
|
||||
* Returns the number of streams expected by this codec.
|
||||
*
|
||||
* @return The number of streams.
|
||||
*/
|
||||
getStreams(): number {
|
||||
return this.streams;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes a list of values into a string.
|
||||
*
|
||||
* @param values The values consisting of arrays that represent
|
||||
* the individual streams.
|
||||
* @return The string.
|
||||
*/
|
||||
encode(values: number[][]): string {
|
||||
let builder: string = '';
|
||||
let previous: number[] = new Array(this.streams).fill(0);
|
||||
for (const current of values) {
|
||||
for (let i = 0; i < this.streams; i++) {
|
||||
const delta: number = current[i] - previous[i];
|
||||
builder += DeltaCodec.encodeSignedNumber(delta);
|
||||
previous[i] = current[i];
|
||||
}
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
decode(encoded: string, data: number[][]): number[][] {
|
||||
let list: number[][] = [];
|
||||
let index: number = 0;
|
||||
let length: number = encoded.length;
|
||||
let current: number[] = new Array(this.streams).fill(0);
|
||||
while (index < length) {
|
||||
let next: number[];
|
||||
if (data !== null && data.length > 0) {
|
||||
next = data.shift();
|
||||
} else {
|
||||
next = new Array(this.streams).fill(0);
|
||||
}
|
||||
let c: number;
|
||||
for (let i = 0; i < this.streams; i++) {
|
||||
let shift: number = 0;
|
||||
let result: number = 0;
|
||||
do {
|
||||
c = encoded.charCodeAt(index++) - 63;
|
||||
result |= (c & 0x1f) << shift;
|
||||
shift += 5;
|
||||
} while (c >= 0x20);
|
||||
const delta: number = ((result & 1) !== 0) ? ~(result >> 1) : (result >> 1);
|
||||
current[i] += delta;
|
||||
next[i] = current[i];
|
||||
}
|
||||
list.push(next);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes a signed number as string.
|
||||
*
|
||||
* @param num The number.
|
||||
* @return The string.
|
||||
*/
|
||||
private static encodeSignedNumber(num: number): string {
|
||||
let sgn_num: number = num << 1;
|
||||
if (num < 0) {
|
||||
sgn_num = ~(sgn_num);
|
||||
}
|
||||
return (DeltaCodec.encodeNumber(sgn_num));
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes an unsigned number as string.
|
||||
*
|
||||
* @param num The number.
|
||||
* @return The string.
|
||||
*/
|
||||
private static encodeNumber(num: number): string {
|
||||
let encodeString: string = '';
|
||||
while (num >= 0x20) {
|
||||
let nextValue: number = (0x20 | (num & 0x1f)) + 63;
|
||||
encodeString += String.fromCharCode(nextValue);
|
||||
num >>= 5;
|
||||
}
|
||||
num += 63;
|
||||
encodeString += String.fromCharCode(num);
|
||||
return encodeString;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import { CollectionViewer } from '@angular/cdk/collections';
|
||||
import { Observable, BehaviorSubject, Subscription } from 'rxjs';
|
||||
import { ApiClientService } from '../../api';
|
||||
import { HttpResponse } from '@angular/common/http';
|
||||
import { MatPaginator } from '@angular/material';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
|
||||
export interface Page<E> {
|
||||
offset: number;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { MatSnackBar } from '@angular/material';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
|
||||
export class Snackbars {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { MatTable } from '@angular/material';
|
||||
import { MatTable } from '@angular/material/table';
|
||||
import { ElementRef } from '@angular/core';
|
||||
|
||||
export interface TableColumn {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ApiClientService } from '../../api';
|
||||
import { MatDialog } from '@angular/material';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { MessageDialogComponent } from '../widgets/message-dialog.component';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
|
||||
@@ -6,7 +6,8 @@ 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, MatDialog } from '@angular/material';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { NgForm } from '@angular/forms';
|
||||
import { Snackbars } from '../utils/snackbars';
|
||||
import { ApiClientService } from '../../api';
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit, HostBinding } from '@angular/core';
|
||||
import { ApiClientService } from '../../api';
|
||||
import { MatDialog, MatSnackBar } from '@angular/material';
|
||||
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';
|
||||
|
||||
@@ -65,4 +65,17 @@
|
||||
</button>
|
||||
</mat-card-footer>
|
||||
</mat-card>
|
||||
<mat-card class="sidebar" [ngStyle]="getPanelWidth()" style="margin-right:10px;margin-top:10px">
|
||||
<mat-card-title style="font-size: 14px;text-align: center;">
|
||||
{{ res.strings('devices_position_chart_header') }}
|
||||
</mat-card-title>
|
||||
<mat-divider></mat-divider>
|
||||
<mat-card-content style="padding-top: 10px;">
|
||||
<app-chart [width]="300" [height]="300"
|
||||
[xAxisConfig]="getXAxisConfig()"
|
||||
[yAxisConfig]="getYAxisConfig()"
|
||||
[horizontalGrid]="true"
|
||||
[verticalGrid]="true"></app-chart>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</app-marker-map>
|
||||
@@ -1,6 +1,12 @@
|
||||
import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit, ElementRef, DoCheck } from '@angular/core';
|
||||
import {
|
||||
Component, OnInit, OnDestroy, ViewChild,
|
||||
AfterViewInit, ElementRef, DoCheck, AfterContentInit,
|
||||
} from '@angular/core';
|
||||
import { ApiClientService } from '../../api';
|
||||
import { MatDialog, MatSnackBar, MatDatepicker, MatDatepickerInputEvent, MatSliderChange, MatSlider } from '@angular/material';
|
||||
import { MatDatepicker, MatDatepickerInputEvent } from '@angular/material/datepicker';
|
||||
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 { Subscription, BehaviorSubject } from 'rxjs';
|
||||
import { Device, Position } from '../../api/models';
|
||||
@@ -14,6 +20,7 @@ import { TableColumn, TableHandler } from '../utils/tables';
|
||||
import { ResourceService } from '../services/resource.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";
|
||||
|
||||
@Component({
|
||||
selector: 'app-device-positions',
|
||||
@@ -23,6 +30,7 @@ export class DevicePositionsComponent implements OnInit, AfterViewInit, OnDestro
|
||||
|
||||
@ViewChild(MarkerMapComponent, { static: true }) map: MarkerMapComponent;
|
||||
@ViewChild('table', { read: ElementRef, static: true }) table: ElementRef;
|
||||
@ViewChild(ChartComponent, { static: true }) chart: ChartComponent;
|
||||
|
||||
id: string;
|
||||
|
||||
@@ -131,6 +139,26 @@ export class DevicePositionsComponent implements OnInit, AfterViewInit, OnDestro
|
||||
}
|
||||
}
|
||||
|
||||
getXAxisConfig(): AxisConfig {
|
||||
return {
|
||||
label: this.res.strings('devices_position_chart_x_axis_label'),
|
||||
from: 0,
|
||||
to: 60,
|
||||
stride: 5,
|
||||
fontSize: 28
|
||||
};
|
||||
}
|
||||
|
||||
getYAxisConfig(): AxisConfig {
|
||||
return {
|
||||
label: this.res.strings('devices_position_chart_y_axis_label'),
|
||||
from: -20,
|
||||
to: 20,
|
||||
stride: 2,
|
||||
fontSize: 28
|
||||
};
|
||||
}
|
||||
|
||||
ngDoCheck(): void {
|
||||
this.compact = (this.map.getWidth() < 900);
|
||||
}
|
||||
@@ -184,6 +212,7 @@ export class DevicePositionsComponent implements OnInit, AfterViewInit, OnDestro
|
||||
private updateSelectedPosition(): void {
|
||||
if (this.loading.getValue() || this.devicePositionService.getPositions().length === 0) {
|
||||
this.selectedPosition.remove();
|
||||
this.updateChart();
|
||||
} else {
|
||||
const date = new Date(this.selectedDate);
|
||||
date.setHours(Math.floor(this.sliderValue / 60));
|
||||
@@ -218,7 +247,7 @@ export class DevicePositionsComponent implements OnInit, AfterViewInit, OnDestro
|
||||
}
|
||||
this.selectedPosition.addTo(this.map.map.map);
|
||||
}
|
||||
|
||||
this.updateChart(after, before);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,5 +282,110 @@ export class DevicePositionsComponent implements OnInit, AfterViewInit, OnDestro
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the acceleration data for the given position and minute.
|
||||
* Depending on what parameters are passed, the method clears the chart
|
||||
* and draws either the before or after position or interpolates between them
|
||||
* if the date of both positions is present.
|
||||
*
|
||||
* This data is summarized into x, y, z and the respective timestamp
|
||||
* delta which starts with the first measurement with second 0.
|
||||
* Furthermore it also calculates the summerized Acceleration of the x, y
|
||||
* & z values.
|
||||
*
|
||||
* @param after Position data of the after position.
|
||||
* @param before Position data of the before position.
|
||||
*/
|
||||
private updateChart(after?: Position, before?: Position): void {
|
||||
this.chart.clearChartLines();
|
||||
if (!before && !after) return;
|
||||
|
||||
const beforePoints = before ? this.processChartData(this.devicePositionService.decodeAccelData(before)) : null;
|
||||
const afterPoints = after ? this.processChartData(this.devicePositionService.decodeAccelData(after)) : null;
|
||||
if (!beforePoints && afterPoints) {
|
||||
this.drawChart(afterPoints);
|
||||
} else if (beforePoints && !afterPoints) {
|
||||
this.drawChart(beforePoints);
|
||||
} else if (beforePoints && afterPoints) {
|
||||
const interpolated = { x: [], y: [], z: [], accel: [] };
|
||||
const len = Math.min(beforePoints.x.length, afterPoints.x.length);
|
||||
for (let i = 0; i < len; i++) {
|
||||
interpolated.x.push(
|
||||
[(beforePoints.x[i][0] + afterPoints.x[i][0]) / 2,
|
||||
(beforePoints.x[i][1] + afterPoints.x[i][1]) / 2]
|
||||
);
|
||||
interpolated.y.push(
|
||||
[(beforePoints.y[i][0] + afterPoints.y[i][0]) / 2,
|
||||
(beforePoints.y[i][1] + afterPoints.y[i][1]) / 2]
|
||||
);
|
||||
interpolated.z.push(
|
||||
[(beforePoints.z[i][0] + afterPoints.z[i][0]) / 2,
|
||||
(beforePoints.z[i][1] + afterPoints.z[i][1]) / 2]
|
||||
);
|
||||
interpolated.accel.push(
|
||||
[(beforePoints.accel[i][0] + afterPoints.accel[i][0]) / 2,
|
||||
(beforePoints.accel[i][1] + afterPoints.accel[i][1]) / 2]
|
||||
);
|
||||
}
|
||||
this.drawChart(interpolated);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The acceleration sample data is processed to show the rate of change within one minute.
|
||||
* Multiple samples are summarized into one second which is represented by a Point object
|
||||
* containing the current second and the rate of change.
|
||||
*
|
||||
* @param data The acceleration data which is pre-processed and formatted.
|
||||
*/
|
||||
private processChartData(data: number[][])
|
||||
: { x: Point[], y: Point[], z: Point[], accel: Point[] } {
|
||||
if (!data || data.length === 0) return;
|
||||
|
||||
const THRESHOLD = 1_000_000;
|
||||
const chartPoints = { x: [], y: [], z: [], accel: [] };
|
||||
let startTime = data[0][0];
|
||||
let lastTimestampDelta = 0;
|
||||
let second = 0;
|
||||
let count = 1;
|
||||
let x = data[0][2], y = data[0][3], z = data[0][4];
|
||||
let accel = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2));
|
||||
for (const value of data) {
|
||||
let timestampDelta = value[0] - startTime;
|
||||
if (timestampDelta > THRESHOLD || timestampDelta < lastTimestampDelta || second === 0) {
|
||||
chartPoints.x.push([second, x / count]);
|
||||
chartPoints.y.push([second, y / count]);
|
||||
chartPoints.z.push([second, z / count]);
|
||||
chartPoints.accel.push([second, accel / count]);
|
||||
startTime = value[0];
|
||||
count = x = y = z = accel = 0;
|
||||
++second;
|
||||
}
|
||||
if (second > 60) break;
|
||||
|
||||
lastTimestampDelta = timestampDelta;
|
||||
++count;
|
||||
x += value[2];
|
||||
y += value[3];
|
||||
z += value[4];
|
||||
accel += Math.sqrt(
|
||||
Math.pow(value[2], 2) + Math.pow(value[3], 2) + Math.pow(value[4], 2)
|
||||
);
|
||||
}
|
||||
return chartPoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the current Lines onto the chart.
|
||||
*
|
||||
* @param chartData Object containing Point arrays representing the lines to be drawn.
|
||||
*/
|
||||
private drawChart(chartData: { x: Point[], y: Point[], z: Point[], accel: Point[] }): void {
|
||||
this.chart.addChartLine(chartData.x, 'x', 'red', 4);
|
||||
this.chart.addChartLine(chartData.y, 'y', 'green', 4);
|
||||
this.chart.addChartLine(chartData.z, 'z', 'blue', 4);
|
||||
this.chart.addChartLine(
|
||||
chartData.accel, this.res.strings('devices_position_chart_acceleration'), 'purple', 4
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit, ElementRef, DoCheck } from '@angular/core';
|
||||
import { ApiClientService } from '../../api';
|
||||
import { MatDialog, MatSnackBar, MatDatepicker, MatDatepickerInputEvent } from '@angular/material';
|
||||
import { MatDatepicker, MatDatepickerInputEvent } from '@angular/material/datepicker';
|
||||
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';
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { Component, ViewChild, OnInit, OnDestroy, ElementRef, DoCheck } from '@angular/core';
|
||||
import { MatPaginator, MatTableDataSource, PageEvent, MatPaginatorIntl, MatDialog, MatSnackBar } from '@angular/material';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatPaginator, PageEvent, MatPaginatorIntl } from '@angular/material/paginator';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
import { DeviceService } from '../services/device.service';
|
||||
import { Device, DevicePage } from '../../api/models';
|
||||
import { DataSource } from '@angular/cdk/table';
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { Component, ViewChild, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core';
|
||||
import { MatPaginator, MatTableDataSource, PageEvent, MatPaginatorIntl, MatDialog, MatSnackBar } from '@angular/material';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatPaginator, PageEvent, MatPaginatorIntl } from '@angular/material/paginator';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
import { DeviceService } from '../services/device.service';
|
||||
import { Notice, NoticePage, Message } from '../../api/models';
|
||||
import { DataSource } from '@angular/cdk/table';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { Component, OnInit, OnDestroy, ViewChild, HostListener } from '@angular/core';
|
||||
import { UserState, UserService, UserRole } from '../services/user.service';
|
||||
import { MatSnackBar, MatDialog, MatSelect, MatOption } from '@angular/material';
|
||||
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 { ResourceService } from '../services/resource.service';
|
||||
import { ExportService } from '../services/export.service';
|
||||
import { Page } from '../utils/pagination';
|
||||
|
||||
@@ -7,7 +7,7 @@ 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';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { NgForm } from '@angular/forms';
|
||||
import { Snackbars } from '../utils/snackbars';
|
||||
import { VersionService } from '../services/version.service';
|
||||
|
||||
@@ -5,7 +5,7 @@ import { LogMessage } from '../../api/models';
|
||||
import { CollectionViewer } from '@angular/cdk/collections';
|
||||
import { ManageLogService } from '../services/manage-log.service';
|
||||
import { LogDialogComponent } from '../widgets/log-dialog.component';
|
||||
import { MatDialog } from '@angular/material';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { TableColumn, TableHandler } from '../utils/tables';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import {Component, ViewChild, OnInit, OnDestroy, ElementRef, HostListener, ContentChild, DoCheck} from '@angular/core';
|
||||
import {MatPaginator, MatTableDataSource, PageEvent, MatPaginatorIntl, MatDialog, MatSnackBar} from '@angular/material';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatPaginator, PageEvent, MatPaginatorIntl } from '@angular/material/paginator';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
import { DeviceService } from '../services/device.service';
|
||||
import { Notice, NoticePage } from '../../api/models';
|
||||
import { DataSource } from '@angular/cdk/table';
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import {Component, ViewChild, OnInit, OnDestroy, ElementRef, DoCheck} from '@angular/core';
|
||||
import {MatPaginator, MatTableDataSource, PageEvent, MatPaginatorIntl, MatDialog, MatSnackBar} from '@angular/material';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatPaginator, PageEvent, MatPaginatorIntl } from '@angular/material/paginator';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
import { DeviceService } from '../services/device.service';
|
||||
import { Device, DevicePage, User, UserPage } from '../../api/models';
|
||||
import { DataSource } from '@angular/cdk/table';
|
||||
|
||||
@@ -6,7 +6,7 @@ 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';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { NgForm } from '@angular/forms';
|
||||
import { Snackbars } from '../utils/snackbars';
|
||||
import { NoticeService } from '../services/notice.service';
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit, ViewEncapsulation, DoCheck, ElementRef, Input } from '@angular/core';
|
||||
import { ApiClientService } from '../../api';
|
||||
import { MatDialog, MatSnackBar, MatPaginator } from '@angular/material';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
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';
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import {Component, ViewChild, OnInit, OnDestroy, DoCheck, ElementRef} from '@angular/core';
|
||||
import {MatPaginator, MatTableDataSource, PageEvent, MatPaginatorIntl, MatDialog, MatSnackBar} from '@angular/material';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatPaginator, PageEvent, MatPaginatorIntl } from '@angular/material/paginator';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
import { Privilege, PrivilegePage, PlacePage, Place } from '../../api/models';
|
||||
import { DataSource } from '@angular/cdk/table';
|
||||
import { Subscription, BehaviorSubject } from 'rxjs';
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { Component, ViewChild, OnInit, OnDestroy, DoCheck, ElementRef } from '@angular/core';
|
||||
import { MatPaginator, MatTableDataSource, PageEvent, MatPaginatorIntl, MatDialog, MatSnackBar } from '@angular/material';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatPaginator, PageEvent, MatPaginatorIntl } from '@angular/material/paginator';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
import { PrivilegeService } from '../services/privilege.service';
|
||||
import { Privilege, PrivilegePage } from '../../api/models';
|
||||
import { DataSource } from '@angular/cdk/table';
|
||||
|
||||
@@ -6,7 +6,8 @@ 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, MatDialog } from '@angular/material';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { NgForm } from '@angular/forms';
|
||||
import { NameFieldComponent } from '../widgets/name-field.component';
|
||||
import { EmailFieldComponent } from '../widgets/email-field.component';
|
||||
|
||||
@@ -6,7 +6,8 @@ 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, MatDialog } from '@angular/material';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { NgForm } from '@angular/forms';
|
||||
import { Snackbars } from '../utils/snackbars';
|
||||
import { ApiClientService } from '../../api';
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit } from '@angular/core';
|
||||
import { ApiClientService } from '../../api';
|
||||
import { MatDialog, MatSnackBar } from '@angular/material';
|
||||
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';
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
<ng-container>
|
||||
<mat-toolbar style="display: flex; background:transparent;">
|
||||
<mat-icon style="margin-left: 5px;">access_time_icon</mat-icon>
|
||||
<span style="margin-left: 10px">{{ res.strings('time_sheet_title') }}</span>
|
||||
|
||||
<div flexLayout="row" fxLayoutAlign="end center" fxFlex="1 1 auto" fxLayoutGap="10px">
|
||||
<button mat-icon-button
|
||||
[matTooltip]="res.strings('time_sheet_update_btn_tooltip')"
|
||||
(click)="updateTimeSheetTable()">
|
||||
<mat-icon style="font-size: 18px;">update_icon</mat-icon>
|
||||
</button>
|
||||
|
||||
<mat-menu #exportMenu="matMenu" class="mat-elevation-z1">
|
||||
<ng-template matMenuContent>
|
||||
<button mat-menu-item
|
||||
(click)="exportTimeSheet('csv')"
|
||||
[disabled]="!timeSheetService.isTimeSheetReady">
|
||||
{{ res.strings('time_sheet_export_as_csv_label') }}
|
||||
</button>
|
||||
<button mat-menu-item
|
||||
(click)="exportTimeSheet('json')"
|
||||
[disabled]="!timeSheetService.isTimeSheetReady">
|
||||
{{ res.strings('time_sheet_export_as_json_label') }}
|
||||
</button>
|
||||
</ng-template>
|
||||
</mat-menu>
|
||||
<button mat-icon-button
|
||||
[matMenuTriggerFor]="exportMenu"
|
||||
[matTooltip]="res.strings('time_sheet_export_btn_tooltip')">
|
||||
<mat-icon >import_export</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
</mat-toolbar>
|
||||
|
||||
<!-- Configuration Side Panel -->
|
||||
<div class="timesheet-container">
|
||||
<div class="timesheet-config">
|
||||
<mat-list class="config-col">
|
||||
<h3 mat-subheader class="flex-center">{{ res.strings('time_sheet_config_label') }}</h3>
|
||||
<mat-list-item class="flex-center toggle-btn">
|
||||
<mat-button-toggle-group
|
||||
[(value)]="timeSheetService.grouped"
|
||||
name="groupingChoice"
|
||||
aria-label="Grouping Choice">
|
||||
<mat-button-toggle [value]="1" [matTooltip]="res.strings('time_sheet_toggle_default_tooltip')">
|
||||
{{ res.strings('time_sheet_toggle_default_label') }}</mat-button-toggle>
|
||||
<mat-button-toggle [value]="2" [matTooltip]="res.strings('time_sheet_toggle_acc_tooltip')">
|
||||
{{ res.strings('time_sheet_toggle_acc_label') }}</mat-button-toggle>
|
||||
<mat-button-toggle [value]="3" [matTooltip]="res.strings('time_sheet_toggle_by_days_tooltip')">
|
||||
{{ res.strings('time_sheet_toggle_by_days_label') }}</mat-button-toggle>
|
||||
<mat-button-toggle [value]="4" [matTooltip]="res.strings('time_sheet_toggle_raw_tooltip')" hidden>
|
||||
{{ res.strings('time_sheet_toggle_raw_label') }}</mat-button-toggle>
|
||||
</mat-button-toggle-group>
|
||||
</mat-list-item>
|
||||
<mat-form-field class="config-item" [matTooltip]="res.strings('time_sheet_select_device_tooltip')">
|
||||
<mat-label>{{ res.strings('time_sheet_select_device_label') }}</mat-label>
|
||||
<mat-select
|
||||
[(value)]="timeSheetService.device">
|
||||
<mat-option [value]="null">{{ res.strings('time_sheet_no_device_selected') }}</mat-option>
|
||||
<ng-container *ngIf="devices">
|
||||
<mat-option *ngFor="let device of devices" [value]="device">
|
||||
{{ device.model }}
|
||||
</mat-option>
|
||||
</ng-container>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field class="config-item" [matTooltip]="res.strings('time_sheet_break_time_tooltip')">
|
||||
<mat-label>{{ res.strings('time_sheet_break_time_label') }}</mat-label>
|
||||
<mat-select
|
||||
[(value)]="timeSheetService.breakTime"
|
||||
[disabled]="timeSheetService.grouped > 2">
|
||||
<mat-option [value]="null">{{ res.strings('time_sheet_no_break_time_selected') }}</mat-option>
|
||||
<mat-option *ngFor="let opt of breakTimeOptions" [value]="opt">
|
||||
{{ opt + ' ' + res.strings('time_sheet_break_time_minutes') }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field class="config-item" [matTooltip]="res.strings('time_sheet_time_period_tooltip')">
|
||||
<input matInput
|
||||
[placeholder]="res.strings('time_sheet_time_period_label')"
|
||||
[satDatepicker]="picker"
|
||||
[value]="timeSheetService.dateRange"
|
||||
(dateChange)="timeSheetService.dateRange = $event.target.value">
|
||||
<sat-datepicker #picker [rangeMode]="true" orderPeriodLabel="month"></sat-datepicker>
|
||||
<sat-datepicker-toggle matSuffix [for]="picker"></sat-datepicker-toggle>
|
||||
</mat-form-field>
|
||||
</mat-list>
|
||||
|
||||
<mat-divider class="divider"></mat-divider>
|
||||
|
||||
<mat-list class="config-col">
|
||||
<button mat-subheader mat-button class="config-item" (click)="openWorkPlacesDialog()">
|
||||
<mat-icon class="icon-button">list_icon</mat-icon>
|
||||
<span>{{ res.strings('time_sheet_workplace_button') }}</span>
|
||||
</button>
|
||||
<ng-container *ngIf="workPlaces.length > 0">
|
||||
<mat-divider class="divider"></mat-divider>
|
||||
|
||||
<div class="config-item" *ngFor="let workPlace of workPlaces">
|
||||
<button mat-icon-button (click)="deleteWorkPlaceEntry(workPlace)">
|
||||
<mat-icon class="icon-button">clear_icon</mat-icon>
|
||||
</button>
|
||||
<span fxLayoutAlign="center" fxFlex="1 1 auto">{{ getWorkplaceName(workPlace) }}</span>
|
||||
</div>
|
||||
|
||||
<mat-divider class="divider"></mat-divider>
|
||||
|
||||
<button mat-button style="margin-bottom: 10px;" (click)="clearWorkPlaceList()" color="primary">
|
||||
<mat-icon class="icon-button" style="margin-left: 12px">delete_icon</mat-icon>
|
||||
<span>{{ res.strings('time_sheet_workplace_clear_list') }}</span>
|
||||
</button>
|
||||
</ng-container>
|
||||
</mat-list>
|
||||
</div>
|
||||
|
||||
<!-- Table Content -->
|
||||
<ng-container *ngIf="false">
|
||||
<mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar>
|
||||
</ng-container>
|
||||
<mat-card class="main-content mat-elevation-z2">
|
||||
<mat-card-content>
|
||||
<table mat-table #timeSheet class="main-table" [dataSource]="timeSheetDataSource">
|
||||
|
||||
<ng-container matColumnDef="date">
|
||||
<th mat-header-cell *matHeaderCellDef>{{ res.strings('time_sheet_table_date') }}</th>
|
||||
<td mat-cell *matCellDef="let data">{{ getDate(data) }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="from-time">
|
||||
<th mat-header-cell *matHeaderCellDef>{{ res.strings('time_sheet_table_from') }}</th>
|
||||
<td mat-cell *matCellDef="let data">
|
||||
{{ data.beginDate | date:'H:mm' }}
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="to-time">
|
||||
<th mat-header-cell *matHeaderCellDef>{{ res.strings('time_sheet_table_to') }}</th>
|
||||
<td mat-cell *matCellDef="let data">
|
||||
{{ data.endDate | date:'H:mm' }}
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="time">
|
||||
<th mat-header-cell *matHeaderCellDef>{{ res.strings('time_sheet_table_working_time') }}</th>
|
||||
<td mat-cell *matCellDef="let data">{{ getWorkingTime(data.duration) }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="place">
|
||||
<th mat-header-cell *matHeaderCellDef>{{ res.strings('time_sheet_table_place') }}</th>
|
||||
<td mat-cell *matCellDef="let data">{{ getWorkplaceString(data) }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="device">
|
||||
<th mat-header-cell *matHeaderCellDef>{{ res.strings('time_sheet_table_device') }}</th>
|
||||
<td mat-cell *matCellDef="let data">{{ getDeviceNameString(data) }}</td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;" (click)="showTimeSheetRowInfo(row)"></tr>
|
||||
</table>
|
||||
<mat-paginator #paginator [pageSizeOptions]="[10, 20, 50, 100]" showFirstLastButtons></mat-paginator>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</div>
|
||||
</ng-container>
|
||||
@@ -0,0 +1,202 @@
|
||||
import { Component, OnInit, HostListener, ViewChild, OnDestroy, AfterViewInit } from '@angular/core';
|
||||
import { Time, formatDate } from '@angular/common';
|
||||
import { MatPaginator } from "@angular/material/paginator";
|
||||
import { MatTableDataSource } from "@angular/material/table";
|
||||
import { MatDialog } from "@angular/material/dialog";
|
||||
|
||||
import { Subscription } from "rxjs";
|
||||
|
||||
import { ResourceService } from "../services/resource.service";
|
||||
import { DeviceService } from "../services/device.service";
|
||||
import { TimeSheetService, TimeSheetData, Grouping } from '../services/time-sheet.service';
|
||||
import { PlacesDialogComponent } from "../widgets/places-dialog.component";
|
||||
import { Device, Place } from '../../api/models';
|
||||
import { MessageDialogComponent } from '../widgets/message-dialog.component';
|
||||
|
||||
|
||||
/**
|
||||
* A view that offers the functionality to generate a timesheet by filtering on the
|
||||
* time period and the places a device has been.
|
||||
* It offers three modes:
|
||||
* 1. Default -> Shows the time entries per day processed in terms of legal working requirements.
|
||||
* It also offers the functionality of defining a filter at which point the
|
||||
* absence from a defined "working place" should be booked as a break.
|
||||
* 2. Summed -> Shows the time entries per day without any processing at all.
|
||||
* 3. By Day -> Shows every single time entry. Due to that a single day can occure frequently.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-time-sheet',
|
||||
templateUrl: './time-sheet.component.html',
|
||||
styles: [
|
||||
`.flex-center { display: flex; flex: 1 1 auto; justify-content: center; }`,
|
||||
`.divider { margin: 16px; }`,
|
||||
`.timesheet-container {
|
||||
display: flex;
|
||||
flex-flow: row-reverse wrap;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
}`,
|
||||
`.timesheet-config { width: 350px; max-width: 350px; }`,
|
||||
`.config-col { display: flex; flex: 1 1 auto; flex-direction: column; justify-content: center; }`,
|
||||
`.config-col .config-item { margin-left: 32px; margin-right: 32px; }`,
|
||||
'.config-col .toggle-btn { font-size: 14px; margin: 20px 0px }',
|
||||
`.main-content { flex: 1 1 auto; margin: 4px; padding: 8px 16px; }`,
|
||||
`.main-content .main-table { width: 100%; }`,
|
||||
`.main-content .mat-column-date { width: 16% !important; }`,
|
||||
`.main-content .mat-column-to-time, .mat-column-from-time { width: 7% !important; }`,
|
||||
`.main-content .mat-column-time { width: 10% !important; }`,
|
||||
`.main-content .mat-column-device { width: 20% !important; }`,
|
||||
`.main-content .mat-column-place { width: 40% !important; }`
|
||||
],
|
||||
})
|
||||
export class TimeSheetComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
|
||||
private static readonly LAYOUT_BREAKPOINT = 960;
|
||||
readonly breakTimeOptions = [5, 10, 15, 20, 30, 45, 60, 90, 120, 150, 180];
|
||||
|
||||
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
|
||||
|
||||
compact = false;
|
||||
static readonly normalDisplayCol = ['date', 'from-time', 'to-time', 'time', 'device', 'place'];
|
||||
static readonly compactDisplayCol = ['date', 'time'];
|
||||
displayedColumns = TimeSheetComponent.normalDisplayCol;
|
||||
|
||||
workPlaces: Place[];
|
||||
devices: Device[];
|
||||
timeSheetDataSource: MatTableDataSource<TimeSheetData>;
|
||||
|
||||
private subscriptions: Subscription;
|
||||
|
||||
constructor(
|
||||
public res: ResourceService,
|
||||
private deviceService: DeviceService,
|
||||
public timeSheetService: TimeSheetService,
|
||||
private dialog: MatDialog
|
||||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.workPlaces = this.timeSheetService.workPlaces;
|
||||
this.timeSheetDataSource = this.timeSheetService;
|
||||
this.updateDisplayedColumns(window.innerWidth);
|
||||
|
||||
this.subscriptions = this.deviceService.connect(null)
|
||||
.subscribe((devices: Device[]) => this.devices = devices);
|
||||
|
||||
this.deviceService.reload();
|
||||
}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
this.timeSheetService.setup(this.paginator);
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.deviceService.disconnect(null);
|
||||
this.timeSheetService.reset();
|
||||
this.subscriptions.unsubscribe();
|
||||
}
|
||||
|
||||
@HostListener('window:resize', ['$event'])
|
||||
onResize(event: Event): void {
|
||||
this.updateDisplayedColumns((event.target as Window).innerWidth);
|
||||
}
|
||||
|
||||
updateTimeSheetTable(): void {
|
||||
if (!this.timeSheetService.fetching$.getValue())
|
||||
this.timeSheetService.fetchData();
|
||||
}
|
||||
|
||||
exportTimeSheet(type: string): void {
|
||||
if (!this.timeSheetService.exportTimeSheet(type))
|
||||
this.openMessageDialog(
|
||||
this.res.strings('time_sheet_export_error_msg_title'),
|
||||
this.res.strings('time_sheet_export_error_msg')
|
||||
);
|
||||
}
|
||||
|
||||
showTimeSheetRowInfo(data: TimeSheetData): void {
|
||||
if (!this.compact) return;
|
||||
|
||||
const res_values = [
|
||||
'time_sheet_table_date', 'time_sheet_table_from', 'time_sheet_table_to',
|
||||
'time_sheet_table_working_time', 'time_sheet_table_place', 'time_sheet_table_device'
|
||||
];
|
||||
const data_values = [
|
||||
`${this.getDate(data)}`, `${formatDate(data.beginDate, 'H:mm', 'de')}`,
|
||||
`${formatDate(data.endDate, 'H:mm', 'de')}`, `${this.getWorkingTime(data.duration)}`,
|
||||
`${this.getWorkplaceString(data)}`,`${this.getWorkplaceString(data)}`
|
||||
];
|
||||
let msg = '';
|
||||
res_values.forEach((val: string, idx: number, _) => msg += `${this.res.strings(val)}: ${data_values[idx]}; `)
|
||||
this.openMessageDialog(this.res.strings('time_sheet_table_row_dialog_title'), msg.slice(0, msg.length - 2));
|
||||
}
|
||||
|
||||
openWorkPlacesDialog(): void {
|
||||
const dialogSubscription = PlacesDialogComponent.open(this.dialog, this.timeSheetService.workPlaces)
|
||||
.subscribe((selectedPlaces: Place[]) => {
|
||||
this.workPlaces = selectedPlaces;
|
||||
this.timeSheetService.workPlaces = selectedPlaces;
|
||||
dialogSubscription.unsubscribe();
|
||||
});
|
||||
}
|
||||
|
||||
getWorkplaceName(place: Place): string {
|
||||
return this.timeSheetService.getWorkplaceName(place);
|
||||
}
|
||||
|
||||
getWorkplaceString(data: TimeSheetData): string {
|
||||
return this.timeSheetService.getWorkplaceString(data);
|
||||
}
|
||||
|
||||
getDeviceNameString(data: TimeSheetData): string {
|
||||
let res = '';
|
||||
if (data.deviceId) {
|
||||
const device = this.devices.find(device => device.id === data.deviceId);
|
||||
res = device.model;
|
||||
} else {
|
||||
data.devicesSet.forEach(id => {
|
||||
const device = this.devices.find(place => place.id === id);
|
||||
res += device.model + '; '
|
||||
});
|
||||
res = res.slice(0, res.length - 2);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
getWorkingTime(time: Time): string {
|
||||
let res = '';
|
||||
if (time.hours != 0) res += String(time.hours) + ' h ';
|
||||
if (time.minutes != 0) res += String(time.minutes) + ' m';
|
||||
if (res === '') res = '-';
|
||||
return res;
|
||||
}
|
||||
|
||||
deleteWorkPlaceEntry(workPlace: Place): void {
|
||||
this.workPlaces = this.workPlaces.filter(place => workPlace !== place);
|
||||
this.timeSheetService.workPlaces = this.workPlaces;
|
||||
}
|
||||
|
||||
clearWorkPlaceList(): void {
|
||||
this.workPlaces = [];
|
||||
this.timeSheetService.workPlaces = [];
|
||||
}
|
||||
|
||||
getDate(data: TimeSheetData): string {
|
||||
return this.timeSheetService.getDate(data);
|
||||
}
|
||||
|
||||
private openMessageDialog(title: string, message: string): void {
|
||||
const dialogSubscription = MessageDialogComponent.open(this.dialog, { title, message })
|
||||
.subscribe(() => dialogSubscription.unsubscribe());
|
||||
}
|
||||
|
||||
private updateDisplayedColumns(width: number): void {
|
||||
if (width < TimeSheetComponent.LAYOUT_BREAKPOINT && !this.compact) {
|
||||
this.compact = true;
|
||||
this.displayedColumns = TimeSheetComponent.compactDisplayCol;
|
||||
this.timeSheetService.grouped = Grouping.BY_DAY_ACC;
|
||||
} else if (width >= TimeSheetComponent.LAYOUT_BREAKPOINT && this.compact) {
|
||||
this.compact = false;
|
||||
this.displayedColumns = TimeSheetComponent.normalDisplayCol;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,10 @@ 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, MatDialog, MatSelect, MatOption } from '@angular/material';
|
||||
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 { NgForm } from '@angular/forms';
|
||||
import { Snackbars } from '../utils/snackbars';
|
||||
import { User, Email } from '../../api/models';
|
||||
@@ -23,18 +26,18 @@ import { AuthGuard } from '../guards/auth.guard';
|
||||
})
|
||||
export class UserComponent implements OnInit, OnDestroy {
|
||||
|
||||
@ViewChild(NameFieldComponent, { static: false }) nameField: NameFieldComponent;
|
||||
@ViewChild(MatSelect, { static: false }) emailSelect: MatSelect;
|
||||
@ViewChild(NameFieldComponent) nameField: NameFieldComponent;
|
||||
@ViewChild(MatSelect) emailSelect: MatSelect;
|
||||
|
||||
// add email
|
||||
@ViewChild(EmailFieldComponent, { static: false }) emailField: EmailFieldComponent;
|
||||
@ViewChild(EmailFieldComponent) emailField: EmailFieldComponent;
|
||||
|
||||
// change passwords
|
||||
@ViewChild('oldPassword', { static: false }) oldPasswordField: PasswordFieldComponent;
|
||||
@ViewChild('newPassword', { static: false }) newPasswordField: PasswordFieldComponent;
|
||||
@ViewChild('oldPassword') oldPasswordField: PasswordFieldComponent;
|
||||
@ViewChild('newPassword') newPasswordField: PasswordFieldComponent;
|
||||
|
||||
// delete account
|
||||
@ViewChild('deletePassword', { static: false }) deletePasswordField: PasswordFieldComponent;
|
||||
@ViewChild('deletePassword') deletePasswordField: PasswordFieldComponent;
|
||||
|
||||
readonly idle = new BehaviorSubject<boolean>(true);
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
<svg [attr.width]="width" [attr.height]="height" [attr.viewBox]="viewBox">
|
||||
|
||||
<!-- X-Axis -->
|
||||
<g *ngIf="xAxis">
|
||||
<polyline class="axis" [attr.id]="xAxis.id" [attr.points]="xAxis.axisPolyline" />
|
||||
|
||||
<polyline class="grid" *ngFor="let points of xAxis.gridPolylines" [attr.points]="points"/>
|
||||
|
||||
<text *ngFor="let label of xAxis.axisLineLabels"
|
||||
[attr.x]="label.x" [attr.y]="label.y"
|
||||
[attr.font-size]="label.fontSize"
|
||||
[attr.fill]="label.fill"
|
||||
[attr.text-anchor]="xtextAnchor">{{ label }}</text>
|
||||
|
||||
<text [attr.x]="xAxis.axisLabel.x" [attr.y]="xAxis.axisLabel.y"
|
||||
[attr.font-size]="xAxis.axisLabel.fontSize"
|
||||
[attr.fill]="xAxis.axisLabel.fill"
|
||||
text-anchor="end">{{ xAxis.axisLabel }}</text>
|
||||
</g>
|
||||
|
||||
<!-- Y-Axis -->
|
||||
<g *ngIf="yAxis">
|
||||
<polyline class="axis" [attr.id]="yAxis.id" [attr.points]="yAxis.axisPolyline" />
|
||||
|
||||
<polyline class="grid" *ngFor="let points of yAxis.gridPolylines" [attr.points]="points"/>
|
||||
|
||||
<text *ngFor="let label of yAxis.axisLineLabels"
|
||||
[attr.x]="label.x" [attr.y]="label.y"
|
||||
[attr.font-size]="label.fontSize"
|
||||
[attr.fill]="label.fill"
|
||||
[attr.text-anchor]="ytextAnchor">{{ label }}</text>
|
||||
|
||||
<text [attr.x]="yAxis.axisLabel.x" [attr.y]="yAxis.axisLabel.y"
|
||||
[attr.font-size]="yAxis.axisLabel.fontSize"
|
||||
[attr.fill]="yAxis.axisLabel.fill"
|
||||
text-anchor="middle">{{ yAxis.axisLabel }}</text>
|
||||
</g>
|
||||
|
||||
<!-- ChartLines -->
|
||||
<polyline *ngFor="let line of chartLines" [attr.id]="line.id" [attr.points]="line" [ngStyle]="line.pointsStyle"/>
|
||||
</svg>
|
||||
<div *ngIf="chartLines.length > 0" class="flex-container" [ngStyle]="getLegendWidth()">
|
||||
<p *ngFor="let line of chartLines" [ngStyle]="line.labelStyle">{{ line.label }}</p>
|
||||
</div>
|
||||
|
After Width: | Height: | Size: 1.8 KiB |
@@ -0,0 +1,410 @@
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
|
||||
/**
|
||||
* Represents a single point in a coordinate system.
|
||||
* Used to draw the polylines onto the inline svg.
|
||||
*/
|
||||
export type Point = [number, number];
|
||||
|
||||
/**
|
||||
* Specifies the configuration of a single axis of the Chart.
|
||||
*/
|
||||
export interface AxisConfig {
|
||||
label: string;
|
||||
from: number;
|
||||
to: number;
|
||||
stride: number;
|
||||
fontSize?: number;
|
||||
fill?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Chart component which draws an inline SVG with the specified configurations.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-chart',
|
||||
templateUrl: './chart.component.html',
|
||||
styles: [
|
||||
'.axis { fill: none; stroke: black; stroke-width: 3px; }',
|
||||
'.grid { fill: none; stroke: grey; stroke-width: 0.5px; }',
|
||||
'.flex-container { display: flex; flex-wrap: wrap; margin-top: 0px }'
|
||||
]
|
||||
})
|
||||
export class ChartComponent implements OnInit {
|
||||
/**
|
||||
* Width of the entire inline svg. Mandatory!
|
||||
*/
|
||||
@Input() width: number;
|
||||
/**
|
||||
* Height of the entire inline svg. Mandatory!
|
||||
*/
|
||||
@Input() height: number;
|
||||
/**
|
||||
* Configuration for the X-Axis line. Mandatory!
|
||||
*/
|
||||
@Input() xAxisConfig: AxisConfig;
|
||||
/**
|
||||
* Configuration for the Y-Axis line. Mandatory!
|
||||
*/
|
||||
@Input() yAxisConfig: AxisConfig;
|
||||
/**
|
||||
* Factor which specifies the zoom of the whole chart.
|
||||
* Default value is 2.
|
||||
*/
|
||||
@Input() zoomFactor: number;
|
||||
/**
|
||||
* The padding from the axes to the border of the svg.
|
||||
* Default value is 50px.
|
||||
*/
|
||||
@Input() borderPadding: number;
|
||||
/**
|
||||
* If true, there are horizontally drawn lines along the
|
||||
* labeled Y-Axis line values.
|
||||
*/
|
||||
@Input() horizontalGrid: boolean;
|
||||
/**
|
||||
* If true, there are vertically drawn lines along the
|
||||
* labeled X-Axis line values.
|
||||
*/
|
||||
@Input() verticalGrid: boolean;
|
||||
/**
|
||||
* Specfies how the X-Axis line values are anchored.
|
||||
*/
|
||||
readonly xtextAnchor = 'end';
|
||||
/**
|
||||
* Specfies how the Y-Axis line values are anchored.
|
||||
*/
|
||||
readonly ytextAnchor = 'end';
|
||||
/**
|
||||
* Represents the actual length of each axis in pixels where the
|
||||
* border padding is already taken in account.
|
||||
*/
|
||||
private effectiveScreenLength: { xAxis: number, yAxis: number };
|
||||
/**
|
||||
* Represents the ratio in which one stride is converted into pixels.
|
||||
*/
|
||||
private axisRatio: { x: number, y: number };
|
||||
/**
|
||||
* Represents the origin of the chart. So to speak, it's the
|
||||
* position where x and y are 0.
|
||||
*/
|
||||
private origin: { x: number, y: number };
|
||||
/**
|
||||
* The viewBox configuration of the inline svg.
|
||||
*/
|
||||
viewBox: ViewBox;
|
||||
/**
|
||||
* The X-Axis line object.
|
||||
*/
|
||||
xAxis: AxisLine;
|
||||
/**
|
||||
* The Y-Axis line object.
|
||||
*/
|
||||
yAxis: AxisLine;
|
||||
/**
|
||||
* The lines which are drawn onto the chart.
|
||||
*/
|
||||
chartLines: ChartLine[];
|
||||
|
||||
ngOnInit(): void {
|
||||
this.checkInput();
|
||||
this.chartLines = [];
|
||||
|
||||
if (!this.zoomFactor) this.zoomFactor = 2;
|
||||
if (!this.borderPadding) this.borderPadding = 50;
|
||||
|
||||
let xAxisAbsolutRange = Math.abs(this.xAxisConfig.from) + Math.abs(this.xAxisConfig.to);
|
||||
let yAxisAbsolutRange = Math.abs(this.yAxisConfig.from) + Math.abs(this.yAxisConfig.to);
|
||||
this.effectiveScreenLength = {
|
||||
xAxis: this.width * this.zoomFactor,
|
||||
yAxis: this.height * this.zoomFactor
|
||||
};
|
||||
this.axisRatio = {
|
||||
x: this.effectiveScreenLength.xAxis / xAxisAbsolutRange,
|
||||
y: this.effectiveScreenLength.yAxis / yAxisAbsolutRange
|
||||
};
|
||||
this.origin = {
|
||||
x: Math.abs(this.xAxisConfig.from) * this.axisRatio.x,
|
||||
// Needs to be 'to' because svg origin starts at the upper left corner.
|
||||
y: Math.abs(this.yAxisConfig.to) * this.axisRatio.y
|
||||
};
|
||||
this.viewBox = new ViewBox(
|
||||
-this.borderPadding,
|
||||
-this.borderPadding,
|
||||
this.effectiveScreenLength.xAxis + this.borderPadding * 2,
|
||||
this.effectiveScreenLength.yAxis + this.borderPadding * 2
|
||||
);
|
||||
|
||||
let labelPadding = this.borderPadding / 2;
|
||||
let markerPadding = this.borderPadding * 0.4;
|
||||
this.xAxis = new AxisLine(
|
||||
'X-Axis',
|
||||
this.xAxisConfig,
|
||||
this.origin.y,
|
||||
this.effectiveScreenLength.xAxis,
|
||||
this.axisRatio.x,
|
||||
labelPadding,
|
||||
markerPadding,
|
||||
true,
|
||||
this.verticalGrid
|
||||
);
|
||||
this.yAxis = new AxisLine(
|
||||
'Y-Axis',
|
||||
this.yAxisConfig,
|
||||
this.origin.x,
|
||||
this.effectiveScreenLength.yAxis,
|
||||
this.axisRatio.y,
|
||||
-labelPadding,
|
||||
-5,
|
||||
false,
|
||||
this.horizontalGrid
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a ChartLine object onto the chart.
|
||||
*
|
||||
* @param points Points which are drawn onto the Chart and representing the ChartLine.
|
||||
* @param label The name which is associated with the ChartLine.
|
||||
* @param color The color of the ChartLine.
|
||||
* @param strokeWidth The stroke width of the Chartline
|
||||
*/
|
||||
addChartLine(points: Point[], label: string, color: string, strokeWidth: number): void {
|
||||
let processed = this.processingPoints(points);
|
||||
this.chartLines.push(new ChartLine(
|
||||
label,
|
||||
processed,
|
||||
{ fill: 'none', stroke: color, 'stroke-width': `${strokeWidth}px` },
|
||||
label,
|
||||
{ 'margin': '1px', 'padding-left': '10px', 'padding-top': '1px', color: color }
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleares the chart from all ChartLines.
|
||||
*/
|
||||
clearChartLines(): void {
|
||||
this.chartLines = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the width of the legend box where the
|
||||
* names of every single ChartLine is displayed.
|
||||
*/
|
||||
getLegendWidth() {
|
||||
return { width: `${this.width}px` };
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the mandatory Input is specified.
|
||||
*/
|
||||
private checkInput() {
|
||||
if (!this.width) throw new TypeError(`'width' is required!`);
|
||||
if (!this.height) throw new TypeError(`'height' is required!`);
|
||||
if (!this.xAxisConfig) throw new TypeError(`'xAxisConfig' is required!`);
|
||||
if (!this.yAxisConfig) throw new TypeError(`'yAxisConfig' is required!`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the given Point array to fit onto the chart's svg ratio properly.
|
||||
*
|
||||
* @param points The points that should be displayed as a polyline on the chart.
|
||||
*/
|
||||
private processingPoints(points: Point[]): Point[] {
|
||||
if (points.length === 0) return;
|
||||
|
||||
let res: Point[] = [];
|
||||
let curr: Point;
|
||||
for (let i = 0; i < points.length; i++) {
|
||||
curr = points[i];
|
||||
let processedPoints = [0, 0] as Point;
|
||||
processedPoints[0] = this.origin.x + curr[0] * this.axisRatio.x;
|
||||
processedPoints[1] = this.origin.y - curr[1] * this.axisRatio.y;
|
||||
res.push(processedPoints);
|
||||
}
|
||||
return res
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A SVG element representation of <polyline>.
|
||||
* Mor infos on: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/polyline
|
||||
*/
|
||||
class Polyline {
|
||||
constructor(public readonly points: Point[]) { }
|
||||
|
||||
public toString(): string {
|
||||
let res = '';
|
||||
for(let point of this.points)
|
||||
res += point[0] + ',' + point[1] + ' ';
|
||||
return res.trim();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A SVG attribute representation of viewBox.
|
||||
* More infos on: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/viewBox
|
||||
*/
|
||||
class ViewBox {
|
||||
constructor(
|
||||
public readonly x: number,
|
||||
public readonly y: number,
|
||||
public readonly width: number,
|
||||
public readonly height: number
|
||||
) { }
|
||||
|
||||
public toString(): string {
|
||||
return `${this.x} ${this.y} ${this.width} ${this.height}`;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A SVG element representation of <text>.
|
||||
* More infos on: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/text
|
||||
*/
|
||||
class Text {
|
||||
readonly x: number;
|
||||
readonly y: number;
|
||||
|
||||
constructor(
|
||||
public readonly text: string,
|
||||
public readonly fontSize: number,
|
||||
public readonly fill: string,
|
||||
point: Point
|
||||
) {
|
||||
this.x = point[0];
|
||||
this.y = point[1];
|
||||
}
|
||||
|
||||
public toString(): string {
|
||||
return this.text;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A custom class representing a chart line which is drawn onto the chart.
|
||||
* While it is drawn as a polyline onto the inline SVG it contians furthermore
|
||||
* information about the line like the label or the style.
|
||||
*/
|
||||
class ChartLine extends Polyline {
|
||||
constructor(
|
||||
public readonly id: string,
|
||||
public readonly points: Point[],
|
||||
public readonly pointsStyle: any,
|
||||
public readonly label: string,
|
||||
public readonly labelStyle: any
|
||||
) {
|
||||
super(points);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A custom class representing an axis line with all necessary informations.
|
||||
*/
|
||||
class AxisLine {
|
||||
|
||||
static readonly FONT_SIZE = 25;
|
||||
|
||||
readonly axisPolyline: Polyline;
|
||||
readonly gridPolylines: Polyline[];
|
||||
readonly axisLineLabels: Text[];
|
||||
readonly axisLabel: Text;
|
||||
|
||||
constructor(
|
||||
readonly id: string,
|
||||
readonly config: AxisConfig,
|
||||
readonly fixture: number,
|
||||
readonly length: number,
|
||||
readonly ration: number,
|
||||
readonly labelPadding: number,
|
||||
readonly markerPadding: number,
|
||||
readonly isX: boolean,
|
||||
readonly withGrid?: boolean
|
||||
) {
|
||||
this.axisLineLabels = [];
|
||||
this.gridPolylines = [];
|
||||
|
||||
const fontSize = config.fontSize ? config.fontSize : AxisLine.FONT_SIZE;
|
||||
const fill = config.fill ? config.fill : 'black';
|
||||
|
||||
let points: Point[] = [];
|
||||
let yMarkerDownShift: number;
|
||||
let axisPointIndex: number;
|
||||
let axisMarkerStart: number;
|
||||
let axisMarkerStep: number;
|
||||
let axisMarkerCheck: (val: number) => boolean;
|
||||
if (isX) {
|
||||
yMarkerDownShift = 0;
|
||||
axisPointIndex = 0;
|
||||
axisMarkerStart = config.from;
|
||||
axisMarkerStep = config.stride;
|
||||
axisMarkerCheck = (val: number): boolean => val <= config.to;
|
||||
} else {
|
||||
yMarkerDownShift = fontSize / 5;
|
||||
axisPointIndex = 1;
|
||||
axisMarkerStart = config.to;
|
||||
axisMarkerStep = -config.stride;
|
||||
axisMarkerCheck = (val: number): boolean => val >= config.from;
|
||||
}
|
||||
|
||||
for (
|
||||
let i = 0, axisMarkerLabel = axisMarkerStart;
|
||||
i <= length && axisMarkerCheck(axisMarkerLabel);
|
||||
i += (ration * config.stride), axisMarkerLabel += axisMarkerStep
|
||||
) {
|
||||
points.push(this.createPoint(axisPointIndex, fixture, i));
|
||||
if (axisMarkerLabel !== 0) {
|
||||
this.axisLineLabels.push(
|
||||
new Text(
|
||||
String(axisMarkerLabel),
|
||||
fontSize * (3/4),
|
||||
fill,
|
||||
this.createPoint(axisPointIndex, fixture + markerPadding, i + yMarkerDownShift)
|
||||
)
|
||||
);
|
||||
if (withGrid) {
|
||||
let gridPoints: Point[] = [];
|
||||
gridPoints.push(this.createPoint(axisPointIndex, 0, i));
|
||||
gridPoints.push(this.createPoint(axisPointIndex, length, i))
|
||||
this.gridPolylines.push(new Polyline(gridPoints));
|
||||
}
|
||||
}
|
||||
}
|
||||
this.axisPolyline = new Polyline(points);
|
||||
|
||||
let axisLineMarker: Text;
|
||||
let labelPos: number;
|
||||
let labelFixture: number;
|
||||
if (isX) {
|
||||
axisLineMarker = this.axisLineLabels[this.axisLineLabels.length - 1];
|
||||
labelPos = axisLineMarker.x - config.label.length;
|
||||
labelFixture = axisLineMarker.y + labelPadding;
|
||||
} else {
|
||||
axisLineMarker = this.axisLineLabels[0];
|
||||
labelPos = axisLineMarker.y + labelPadding;
|
||||
labelFixture = axisLineMarker.x;
|
||||
}
|
||||
this.axisLabel = new Text(
|
||||
config.label, fontSize, fill,
|
||||
this.createPoint(axisPointIndex, labelFixture, labelPos)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a point which is part of the points array of the drawn polyline
|
||||
* representing the axis or the location of the axis label.
|
||||
*
|
||||
* @param axisPointIndex Determines the index of the Point tuple to which
|
||||
* the variable value is written.
|
||||
* @param fixture The fixture value that determinse on which axis the Point relates to.
|
||||
* -> e.g. When writing on the X-Axis the fixture value is y = maximal height.
|
||||
* @param value The value on the axis.
|
||||
* @return A Point object.
|
||||
*/
|
||||
private createPoint(axisPointIndex: number, fixture: number, value: number): Point {
|
||||
let p: Point = [0, 0];
|
||||
p[axisPointIndex++] = value;
|
||||
p[axisPointIndex % 2] = fixture;
|
||||
return p;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material/dialog';
|
||||
import { Observable } from 'rxjs';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material/dialog';
|
||||
import { Observable } from 'rxjs';
|
||||
import { LogMessage } from '../../api/models';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Component, OnInit, OnDestroy, ViewChild, AfterContentInit, AfterViewInit, ElementRef } from '@angular/core';
|
||||
import { ApiClientService } from '../../api';
|
||||
import { MatDialog, MatSnackBar } from '@angular/material';
|
||||
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';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material/dialog';
|
||||
import { Observable } from 'rxjs';
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Component, Inject, ViewChild } from '@angular/core';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog, MatSnackBar } from '@angular/material';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material/dialog';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { Observable, Subscription } from 'rxjs';
|
||||
import { NgForm } from '@angular/forms';
|
||||
import { ApiClientService } from '../../api';
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<mat-toolbar mat-dialog-title style="vertical-align: middle;">
|
||||
<mat-toolbar-row>
|
||||
<mat-icon>pie_chart_outlined</mat-icon>
|
||||
<span style="margin-left: 10px">{{ res.strings('places_title') }}</span>
|
||||
<div style="padding-top:20px;" flexLayout="row" fxLayoutAlign="end center" fxFlex="1 1 auto" fxLayoutGap="10px">
|
||||
<form style="font-size: 12px;" fxLayoutAlign="center center" flexLayout="row">
|
||||
<mat-form-field fxFlex="1 1 180px">
|
||||
<mat-select [placeholder]="res.strings('places_order_placeholder')" [value]="order.getValue()" (selectionChange)="order.next($event.source.value)">
|
||||
<mat-option *ngFor="let o of getOrders()" [value]="o">
|
||||
<span>{{ getOrderName(o) }}</span>
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</form>
|
||||
</div>
|
||||
</mat-toolbar-row>
|
||||
</mat-toolbar>
|
||||
<mat-dialog-content>
|
||||
<ng-container *ngIf="loading.getValue()">
|
||||
<mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar>
|
||||
</ng-container>
|
||||
<mat-table #table [dataSource]="placesDataSource">
|
||||
<ng-container matColumnDef="name">
|
||||
<mat-header-cell *matHeaderCellDef [ngStyle]="getStyle('name')"> {{ res.strings('places_name') }} </mat-header-cell>
|
||||
<mat-cell *matCellDef="let element" [ngStyle]="getStyle('name')"> {{ getWorkplaceName(element.place) }} </mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<mat-row *matRowDef="let row; columns: ['name'];"
|
||||
(click)="onPlaceSelected(row)"
|
||||
[ngClass]="{ 'data-selected': row.isSelected }">
|
||||
</mat-row>
|
||||
</mat-table>
|
||||
</mat-dialog-content>
|
||||
<mat-dialog-actions fxFlexLayout="row" fxLayoutAlign="space-around center">
|
||||
<mat-paginator #paginator [pageSizeOptions]="[6, 10, 20, 50, 100]" [showFirstLastButtons]="true"></mat-paginator>
|
||||
<button mat-raised-button color="primary" (click)="onClose()" (keyup.enter)="onClose(); false" cdkFocusInitial>
|
||||
<mat-icon class="icon-button">close</mat-icon>
|
||||
<span>{{res.strings('button_close')}}</span>
|
||||
</button>
|
||||
</mat-dialog-actions>
|
||||
@@ -0,0 +1,124 @@
|
||||
import { Component, OnInit, ViewChild, ElementRef, OnDestroy, Inject } from '@angular/core';
|
||||
import { MatDialogRef, MatDialog, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
|
||||
import { Observable, BehaviorSubject } from 'rxjs';
|
||||
|
||||
import { ResourceService } from '../services/resource.service';
|
||||
import { PlaceService } from '../services/place.service';
|
||||
import { Order } from '../../api';
|
||||
import { Place, PlacePage } from '../../api/models';
|
||||
import { PaginationHandler } from '../utils/pagination';
|
||||
import { TableHandler, TableColumn } from '../utils/tables';
|
||||
|
||||
|
||||
interface PlaceWrapper {
|
||||
isSelected: boolean;
|
||||
place: Place;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-places-dialog',
|
||||
templateUrl: 'places-dialog.component.html',
|
||||
styles: [
|
||||
'.data-selected { background-color: #0085ed40; border-radius: 25px; }'
|
||||
]
|
||||
})
|
||||
export class PlacesDialogComponent implements OnInit, OnDestroy {
|
||||
|
||||
private static COLUMNS: TableColumn[] = [
|
||||
{ name: 'name', dropPriority: 0, width: 130 }
|
||||
];
|
||||
|
||||
@ViewChild('table', { read: ElementRef, static: true }) table: ElementRef;
|
||||
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
|
||||
|
||||
placesDataSource: MatTableDataSource<PlaceWrapper>;
|
||||
loading: BehaviorSubject<boolean>;
|
||||
order: BehaviorSubject<Order>;
|
||||
selectedPlaces: Place[];
|
||||
|
||||
private pageHandler: PaginationHandler<Place, PlacePage>;
|
||||
private tableHandler: TableHandler;
|
||||
|
||||
constructor(
|
||||
public dialog: MatDialogRef<PlacesDialogComponent, Place[]>,
|
||||
@Inject(MAT_DIALOG_DATA) private data: Place[],
|
||||
public res: ResourceService,
|
||||
private placeService: PlaceService
|
||||
) { }
|
||||
|
||||
public static open<T>(dialog: MatDialog, d: T[], w?: string, maxH?: string)
|
||||
: Observable<Place[]> {
|
||||
if (w == null) w = '500px';
|
||||
if (maxH == null) maxH = '700px';
|
||||
const ref = dialog.open(PlacesDialogComponent, {
|
||||
data: d,
|
||||
width: w,
|
||||
maxHeight: maxH
|
||||
});
|
||||
return ref.afterClosed();
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.selectedPlaces = [];
|
||||
this.selectedPlaces.push(...this.data);
|
||||
this.placesDataSource = new MatTableDataSource([]);
|
||||
this.loading = this.placeService.loading;
|
||||
this.order = this.placeService.order;
|
||||
this.tableHandler = new TableHandler(this.table, PlacesDialogComponent.COLUMNS);
|
||||
this.pageHandler = new PaginationHandler(this.paginator, this.placeService);
|
||||
|
||||
this.placeService.page.next({ offset: 0, size: 6, total: 0, elements: [] } as PlacePage);
|
||||
this.placeService.page.subscribe((page: PlacePage) => {
|
||||
const tmp: PlaceWrapper[] = [];
|
||||
page.elements.forEach((place: Place) => {
|
||||
tmp.push({
|
||||
isSelected: this.selectedPlaces.some((p: Place) => p.id === place.id),
|
||||
place: place
|
||||
})
|
||||
});
|
||||
this.placesDataSource.data = tmp;
|
||||
})
|
||||
this.placeService.reload();
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.placeService.page.next({ offset: 0, size: 20, total: 0, elements: [] } as PlacePage);
|
||||
this.pageHandler.destroy();
|
||||
}
|
||||
|
||||
onPlaceSelected(wrapper: PlaceWrapper): void {
|
||||
if (!wrapper.isSelected)
|
||||
this.selectedPlaces.push(wrapper.place);
|
||||
else
|
||||
this.selectedPlaces = this.selectedPlaces.filter((p: Place) => p.id !== wrapper.place.id);
|
||||
wrapper.isSelected = !wrapper.isSelected;
|
||||
}
|
||||
|
||||
onClose(): void {
|
||||
this.dialog.close(this.selectedPlaces);
|
||||
}
|
||||
|
||||
getStyle(column: string): any {
|
||||
return this.tableHandler.getColumnStyle(column);
|
||||
}
|
||||
|
||||
getColumns(): string[] {
|
||||
return this.tableHandler.getDisplayColumns();
|
||||
}
|
||||
|
||||
getWorkplaceName(place: Place): string {
|
||||
return (place.nickname != null && place.nickname.length > 0)? place.nickname : place.address;
|
||||
}
|
||||
|
||||
getOrderName(order: Order): string {
|
||||
return this.res.strings('places_order_value_' + order.toLowerCase());
|
||||
}
|
||||
|
||||
getOrders(): string[] {
|
||||
return [ Order.TIME, Order.IMPORTANCE, Order.DURATION, Order.FREQUENCY, Order.IDENTIFIER ];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Component, Inject, ViewChild } from '@angular/core';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog, MatSnackBar } from '@angular/material';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material/dialog';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { Observable, Subscription } from 'rxjs';
|
||||
import { NgForm } from '@angular/forms';
|
||||
import { ApiClientService } from '../../api';
|
||||
|
||||
@@ -4,8 +4,6 @@ import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
import { AppModule } from './app/app.module';
|
||||
import { environment } from './environments/environment';
|
||||
|
||||
import 'hammerjs';
|
||||
|
||||
if (environment.production) {
|
||||
enableProdMode();
|
||||
}
|
||||
|
||||
@@ -185,6 +185,16 @@ mat-form-field {
|
||||
margin:10px;
|
||||
}
|
||||
|
||||
// TODO: Check if needed
|
||||
.time-sheet-card {
|
||||
flex: 1;
|
||||
// max-width:1280px;
|
||||
// min-height:580px;
|
||||
width: 80%;
|
||||
height: 85%;
|
||||
margin: 2px;
|
||||
}
|
||||
|
||||
// fab position on marker map
|
||||
.fab {
|
||||
position:absolute;
|
||||
@@ -203,4 +213,8 @@ mat-form-field {
|
||||
.long-checkbox .mat-checkbox-layout {
|
||||
padding-top: 20px;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.flex-spacer {
|
||||
flex-grow: 1;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { TimeSheetService } from '../../app/services/time-sheet.service';
|
||||
|
||||
describe('TimeSheetService', () => {
|
||||
beforeEach(() => TestBed.configureTestingModule({}));
|
||||
|
||||
it('should be created', () => {
|
||||
const service: TimeSheetService = TestBed.get(TimeSheetService);
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,68 @@
|
||||
import { DeltaCodec } from "../../app/utils/deltacodec";
|
||||
|
||||
/**
|
||||
* Generates a data frame for the DeltaCodec with random numbers.
|
||||
*
|
||||
* @param streamLength The length of a single stream.
|
||||
* @param dataLength The length of the complete data frame.
|
||||
*/
|
||||
function generateTestData(streamLength: number, dataLength: number): number[][] {
|
||||
let res: number[][] = [];
|
||||
for (let i = 0; i < dataLength; i++) {
|
||||
res.push([] as number[]);
|
||||
for (let j = 0; j < streamLength; j++) {
|
||||
res[i][j] = Math.floor(Math.random() * 100);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the content of the data frames is equal.
|
||||
*
|
||||
* @param expected The expected content of the data frame.
|
||||
* @param decoded The data frame decoded by the DeltaCodec.
|
||||
*/
|
||||
function assertEqual(expected: number[][], decoded: number[][]): boolean {
|
||||
if (expected.length !== decoded.length) return false;
|
||||
|
||||
for (let i = 0; i < expected.length; i++)
|
||||
for (let j = 0; j < expected[i].length; j++)
|
||||
if (expected[i][j] !== decoded[i][j])
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
describe('DeltaCodec', () => {
|
||||
const STREAMS = 5;
|
||||
let codec: DeltaCodec;
|
||||
|
||||
for (let i = 0; i < STREAMS; i++) {
|
||||
it(`should #decode() & #encode() on random values with up to ${i} streams.`, () => {
|
||||
// const { codec, expected } = setup(i + 1, 100);
|
||||
codec = new DeltaCodec(i + 1);
|
||||
const expected = generateTestData(i + 1, 100);
|
||||
const encoded = codec.encode(expected);
|
||||
const decoded = codec.decode(encoded, null);
|
||||
expect(assertEqual(expected, decoded)).toBe(true);
|
||||
});
|
||||
}
|
||||
|
||||
it('should #decode() gps data correctly.', () => {
|
||||
codec = new DeltaCodec(2);
|
||||
// Values need to be shiftet 5 times to the left
|
||||
// to get the latitude and longitude.
|
||||
// E.g.: 4185073 -> 41.85073 && -8765126 -> -87.65126
|
||||
const expected = [
|
||||
[4185073, -8765126],
|
||||
[4185229, -8765132],
|
||||
[4185258, -8765141]
|
||||
];
|
||||
|
||||
const encoded = 'a~l~Fjk~uOwHJy@P';
|
||||
const decoded = codec.decode(encoded, null);
|
||||
console.log(decoded);
|
||||
expect(assertEqual(expected, decoded)).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { TimeSheetComponent } from '../../app/views/time-sheet.component';
|
||||
|
||||
describe('TimeSheetComponent', () => {
|
||||
let component: TimeSheetComponent;
|
||||
let fixture: ComponentFixture<TimeSheetComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ TimeSheetComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(TimeSheetComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,135 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { MatProgressSpinnerModule } from "@angular/material/progress-spinner";
|
||||
|
||||
|
||||
import { ChartComponent, Point } from '../../app/widgets/chart.component';
|
||||
|
||||
|
||||
describe('ChartComponent Simple Creation', () => {
|
||||
let component: ChartComponent;
|
||||
let fixture: ComponentFixture<ChartComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ MatProgressSpinnerModule ],
|
||||
declarations: [ ChartComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ChartComponent);
|
||||
component = fixture.componentInstance;
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
component.width = 300;
|
||||
component.height = 300;
|
||||
component.xAxisConfig = {
|
||||
label: 'X-Axis',
|
||||
from: -30,
|
||||
to: 30,
|
||||
stride: 5
|
||||
};
|
||||
component.yAxisConfig = {
|
||||
label: 'Y-Axis',
|
||||
from: -30,
|
||||
to: 30,
|
||||
stride: 5
|
||||
};
|
||||
fixture.detectChanges();
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
type AxisRatio = { x: number, y: number };
|
||||
type Origin = { x: number, y: number };
|
||||
|
||||
function processingPoints(points: Point[], origin: Origin, axisRation: AxisRatio): Point[] {
|
||||
let expectedPoints: Point[] = [];
|
||||
for (const point of points) {
|
||||
let processedPoint = [0, 0] as Point;
|
||||
processedPoint[0] = origin.x + point[0] * axisRation.x;
|
||||
processedPoint[1] = origin.y - point[1] * axisRation.y;
|
||||
expectedPoints.push(processedPoint);
|
||||
}
|
||||
return expectedPoints;
|
||||
}
|
||||
|
||||
describe('ChartComponent Advanced Tests', () => {
|
||||
let component: ChartComponent;
|
||||
let fixture: ComponentFixture<ChartComponent>;
|
||||
|
||||
let axisRatio: AxisRatio;
|
||||
let origin: Origin;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ MatProgressSpinnerModule ],
|
||||
declarations: [ ChartComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ChartComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.width = 300;
|
||||
component.height = 300;
|
||||
component.xAxisConfig = {
|
||||
label: 'X-Axis',
|
||||
from: -30,
|
||||
to: 30,
|
||||
stride: 5
|
||||
};
|
||||
component.yAxisConfig = {
|
||||
label: 'Y-Axis',
|
||||
from: -30,
|
||||
to: 30,
|
||||
stride: 5
|
||||
};
|
||||
fixture.detectChanges();
|
||||
|
||||
let xAxisAbsolutRange = Math.abs(component.xAxisConfig.from) + Math.abs(component.xAxisConfig.to);
|
||||
let yAxisAbsolutRange = Math.abs(component.yAxisConfig.from) + Math.abs(component.yAxisConfig.to);
|
||||
let effectiveScreenLength = {
|
||||
xAxis: component.width * component.zoomFactor,
|
||||
yAxis: component.height * component.zoomFactor
|
||||
};
|
||||
axisRatio = {
|
||||
x: effectiveScreenLength.xAxis / xAxisAbsolutRange,
|
||||
y: effectiveScreenLength.yAxis / yAxisAbsolutRange
|
||||
};
|
||||
origin = {
|
||||
x: Math.abs(component.xAxisConfig.from) * axisRatio.x,
|
||||
y: Math.abs(component.yAxisConfig.to) * axisRatio.y
|
||||
};
|
||||
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should add one red line to chart.', () => {
|
||||
// Add line to chart.
|
||||
let points: Point[] = [
|
||||
[-20, -5], [-7, 3], [0, 11], [5, 6], [22, 27]
|
||||
];
|
||||
component.addChartLine(points, 'Test', 'red', 4);
|
||||
fixture.detectChanges();
|
||||
|
||||
// Pre-processing given points.
|
||||
let expectedPoints = processingPoints(points, origin, axisRatio);
|
||||
|
||||
// Checking the points of the red <polyline> that was added to the chart.
|
||||
let element: HTMLElement = fixture.nativeElement;
|
||||
let polylines: NodeListOf<SVGPolylineElement> = element.querySelectorAll('polyline');
|
||||
let redPolyline = polylines.item(polylines.length - 1);
|
||||
let expectedPointsStr = '', pointsStr = '';
|
||||
for(let i = 0; i < expectedPoints.length; i++) {
|
||||
expectedPointsStr += (expectedPoints[i][0] + ',' + expectedPoints[i][1] + ' ');
|
||||
pointsStr += (redPolyline.points.getItem(i).x + ',' + redPolyline.points.getItem(i).y + ' ');
|
||||
}
|
||||
expectedPointsStr = expectedPointsStr.trim();
|
||||
pointsStr = pointsStr.trim();
|
||||
expect(pointsStr).toEqual(expectedPointsStr);
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,5 @@
|
||||
@import '~@angular/material/theming';
|
||||
@import '~saturn-datepicker/theming';
|
||||
// Plus imports for other components in your app.
|
||||
|
||||
// Include the common styles for Angular Material. We include this here so that you only
|
||||
@@ -13,13 +14,22 @@ $app-primary: mat-palette($mat-light-blue, 900);
|
||||
$app-accent: mat-palette($mat-yellow, 800);
|
||||
$app-accent-dark: mat-palette($mat-yellow, 800);
|
||||
|
||||
// Colors for the dark theme.
|
||||
$dark-primary: mat-palette($mat-blue-grey);
|
||||
$dark-accent: mat-palette($mat-amber, A200, A100, A400);
|
||||
$dark-warn: mat-palette($mat-deep-orange);
|
||||
|
||||
// The warn palette is optional (defaults to red).
|
||||
$app-warn: mat-palette($mat-red);
|
||||
|
||||
// Create the theme object (a Sass map containing all of the palettes).
|
||||
// light theme
|
||||
$app-theme: mat-light-theme($app-primary, $app-accent, $app-warn);
|
||||
// dark theme
|
||||
// $app-theme: mat-dark-theme($dark-primary, $dark-accent, $dark-warn);
|
||||
|
||||
// Include theme styles for core and each component used in your app.
|
||||
// Alternatively, you can import and @include the theme mixins for each component
|
||||
// that you are using.
|
||||
@include angular-material-theme($app-theme);
|
||||
@include sat-datepicker-theme($app-theme);
|
||||
|
||||
@@ -5,8 +5,11 @@
|
||||
"baseUrl": "./",
|
||||
"types": []
|
||||
},
|
||||
"exclude": [
|
||||
"test.ts",
|
||||
"**/*.spec.ts"
|
||||
"files": [
|
||||
"main.ts",
|
||||
"polyfills.ts"
|
||||
],
|
||||
"include": [
|
||||
"src/**/*.d.ts"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ plugins {
|
||||
description = 'Maptology Web Webapp'
|
||||
|
||||
dependencies {
|
||||
providedCompile "javax:javaee-api:${versionJavaee}"
|
||||
providedCompile "jakarta.platform:jakarta.jakartaee-api:${versionJavaee}"
|
||||
testCompile "junit:junit:${versionJunit}"
|
||||
}
|
||||
|
||||
|
||||