Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5691ef3a3 | ||
|
|
8e3dc80fb8 | ||
|
|
20108b282d | ||
|
|
aac6c5f5f3 | ||
|
|
3b644cece3 | ||
|
|
6b5f01a573 | ||
|
|
98212476f4 | ||
|
|
eac84438f1 | ||
|
|
dfacfd4ff4 | ||
|
|
301578f241 | ||
|
|
41dc0030c3 | ||
|
|
73ea8185a4 | ||
|
|
ff89c9a7cc | ||
|
|
7451e492c6 | ||
|
|
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"
|
applicationId "com.maptology.android.app"
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode 9
|
versionCode 10
|
||||||
versionName "${version}"
|
versionName "${version}"
|
||||||
buildConfigField "long", "BUILD_TIME", System.currentTimeMillis() + "L"
|
buildConfigField "long", "BUILD_TIME", System.currentTimeMillis() + "L"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|||||||
@@ -28,12 +28,12 @@ allprojects {
|
|||||||
|
|
||||||
// set version for our project
|
// set version for our project
|
||||||
group = 'com.maptology'
|
group = 'com.maptology'
|
||||||
version = '1.0.4'
|
version = '1.0.5-SNAPSHOT'
|
||||||
|
|
||||||
// set versions for our libraries
|
// set versions for our libraries
|
||||||
ext {
|
ext {
|
||||||
// api dependencies
|
// api dependencies
|
||||||
versionJavaee = '7.0'
|
versionJavaee = '8.0.0'
|
||||||
versionJaxb = '2.3.1'
|
versionJaxb = '2.3.1'
|
||||||
versionAnnotation = '1.3.2'
|
versionAnnotation = '1.3.2'
|
||||||
versionSwagger = '1.5.22'
|
versionSwagger = '1.5.22'
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ description = 'Maptology Common Api'
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testCompile "junit:junit:${versionJunit}"
|
testCompile "junit:junit:${versionJunit}"
|
||||||
compileOnly "javax.xml.bind:jaxb-api:${versionJaxb}"
|
compileOnly "javax.xml.bind:jaxb-api:${versionJaxb}"
|
||||||
compileOnly "javax:javaee-api:${versionJavaee}"
|
compileOnly "jakarta.platform:jakarta.jakartaee-api:${versionJavaee}"
|
||||||
compileOnly "io.swagger:swagger-annotations:${versionSwagger}"
|
compileOnly "io.swagger:swagger-annotations:${versionSwagger}"
|
||||||
compileOnly "com.fasterxml.jackson.core:jackson-annotations:${versionJackson}"
|
compileOnly "com.fasterxml.jackson.core:jackson-annotations:${versionJackson}"
|
||||||
}
|
}
|
||||||
@@ -34,21 +34,21 @@ swagger {
|
|||||||
'com.maptology.api.history.IHistoryService'
|
'com.maptology.api.history.IHistoryService'
|
||||||
]
|
]
|
||||||
schemes = [ 'http', 'https']
|
schemes = [ 'http', 'https']
|
||||||
host = 'localhost'
|
host = 'www.maptology.com'
|
||||||
basePath = '/api'
|
basePath = '/api'
|
||||||
info {
|
info {
|
||||||
title = 'Maptology Service'
|
title = 'Maptology Service'
|
||||||
version = "${version}"
|
version = project.version
|
||||||
description = 'Maptology Service'
|
description = 'The application programming interface of Maptology.'
|
||||||
termsOfService = 'https://maptology.com/terms-of-service'
|
termsOfService = 'https://maptology.com/terms-of-service'
|
||||||
contact {
|
contact {
|
||||||
email = 'nes-admin@uni-due.de'
|
email = 'nes-admin@uni-due.de'
|
||||||
name = 'NES Universität Duisburg-Essen'
|
name = 'Networked Embedded Systems'
|
||||||
url = 'https://www.nes.uni-due.de'
|
url = 'https://www.nes.uni-due.de'
|
||||||
}
|
}
|
||||||
license {
|
license {
|
||||||
url = 'https://www.maptology.com/license'
|
url = 'https://www.maptology.com/license'
|
||||||
name = 'Proprietary'
|
name = 'Maptology License'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
swaggerFileName = 'maptology'
|
swaggerFileName = 'maptology'
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
description = 'Maptology Service Ejb'
|
description = 'Maptology Service Ejb'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly "javax:javaee-api:${versionJavaee}"
|
compileOnly "jakarta.platform:jakarta.jakartaee-api:${versionJavaee}"
|
||||||
compileOnly "com.fasterxml.jackson.core:jackson-annotations:${versionJackson}"
|
compileOnly "com.fasterxml.jackson.core:jackson-annotations:${versionJackson}"
|
||||||
compile project(':common-api')
|
compile project(':common-api')
|
||||||
compile project(':service-geocode')
|
compile project(':service-geocode')
|
||||||
|
|
||||||
testCompile "javax:javaee-api:${versionJavaee}"
|
testCompile "jakarta.platform:jakarta.jakartaee-api:${versionJavaee}"
|
||||||
testCompile "javax.xml.bind:jaxb-api:${versionJaxb}"
|
testCompile "javax.xml.bind:jaxb-api:${versionJaxb}"
|
||||||
testCompile "com.fasterxml.jackson.core:jackson-databind:${versionJackson}"
|
testCompile "com.fasterxml.jackson.core:jackson-databind:${versionJackson}"
|
||||||
testCompile "junit:junit:${versionJunit}"
|
testCompile "junit:junit:${versionJunit}"
|
||||||
@@ -26,7 +26,8 @@ jar {
|
|||||||
'Created-By' : "Gradle ${gradle.gradleVersion}",
|
'Created-By' : "Gradle ${gradle.gradleVersion}",
|
||||||
'Build-Jdk' : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
|
'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']}",
|
'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 -->
|
<!-- HTML for static distribution bundle build -->
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Swagger UI</title>
|
<title>Maptology Api</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="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-32x32.png" sizes="32x32" />
|
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
|
||||||
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
|
<style>
|
||||||
<style>
|
html
|
||||||
html
|
{
|
||||||
{
|
box-sizing: border-box;
|
||||||
box-sizing: border-box;
|
overflow: -moz-scrollbars-vertical;
|
||||||
overflow: -moz-scrollbars-vertical;
|
overflow-y: scroll;
|
||||||
overflow-y: scroll;
|
}
|
||||||
}
|
|
||||||
*,
|
|
||||||
*:before,
|
|
||||||
*:after
|
|
||||||
{
|
|
||||||
box-sizing: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
*,
|
||||||
margin:0;
|
*:before,
|
||||||
background: #fafafa;
|
*:after
|
||||||
}
|
{
|
||||||
</style>
|
box-sizing: inherit;
|
||||||
</head>
|
}
|
||||||
|
|
||||||
<body>
|
body
|
||||||
|
{
|
||||||
|
margin:0;
|
||||||
|
background: #fffcf7;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
<script>
|
<body>
|
||||||
if(window.navigator.userAgent.indexOf("Edge") > -1) {
|
<div id="swagger-ui"></div>
|
||||||
console.log("Removing native Edge fetch implementation")
|
|
||||||
window.fetch = undefined
|
<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>
|
</script>
|
||||||
|
</body>
|
||||||
<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>
|
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en-US">
|
<html lang="en-US">
|
||||||
|
<title>Swagger UI: OAuth2 Redirect</title>
|
||||||
<body onload="run()">
|
<body onload="run()">
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -45,11 +46,18 @@
|
|||||||
oauth2.auth.code = qp.code;
|
oauth2.auth.code = qp.code;
|
||||||
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
|
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
|
||||||
} else {
|
} 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({
|
oauth2.errCb({
|
||||||
authId: oauth2.auth.name,
|
authId: oauth2.auth.name,
|
||||||
source: "auth",
|
source: "auth",
|
||||||
level: "error",
|
level: "error",
|
||||||
message: "Authorization failed: no accessCode received from the server"
|
message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} 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 "junit:junit:${versionJunit}"
|
||||||
testCompile "org.jboss.arquillian.junit:arquillian-junit-container:${versionArquillianJunit}"
|
testCompile "org.jboss.arquillian.junit:arquillian-junit-container:${versionArquillianJunit}"
|
||||||
testCompile "org.wildfly.arquillian:wildfly-arquillian-container-managed:${versionArquillianContainer}"
|
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 "com.fasterxml.jackson.core:jackson-databind:${versionJackson}"
|
||||||
providedCompile "org.jboss.resteasy:resteasy-client:${versionResteasy}"
|
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 -->
|
<!-- HTML for static distribution bundle build -->
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Swagger UI</title>
|
<title>Maptology Api</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="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-32x32.png" sizes="32x32" />
|
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
|
||||||
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
|
<style>
|
||||||
<style>
|
html
|
||||||
html
|
{
|
||||||
{
|
box-sizing: border-box;
|
||||||
box-sizing: border-box;
|
overflow: -moz-scrollbars-vertical;
|
||||||
overflow: -moz-scrollbars-vertical;
|
overflow-y: scroll;
|
||||||
overflow-y: scroll;
|
}
|
||||||
}
|
|
||||||
*,
|
|
||||||
*:before,
|
|
||||||
*:after
|
|
||||||
{
|
|
||||||
box-sizing: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
*,
|
||||||
margin:0;
|
*:before,
|
||||||
background: #fafafa;
|
*:after
|
||||||
}
|
{
|
||||||
</style>
|
box-sizing: inherit;
|
||||||
</head>
|
}
|
||||||
|
|
||||||
<body>
|
body
|
||||||
|
{
|
||||||
|
margin:0;
|
||||||
|
background: #fffcf7;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
<script>
|
<body>
|
||||||
if(window.navigator.userAgent.indexOf("Edge") > -1) {
|
<div id="swagger-ui"></div>
|
||||||
console.log("Removing native Edge fetch implementation")
|
|
||||||
window.fetch = undefined
|
<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>
|
</script>
|
||||||
|
</body>
|
||||||
<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>
|
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en-US">
|
<html lang="en-US">
|
||||||
|
<title>Swagger UI: OAuth2 Redirect</title>
|
||||||
<body onload="run()">
|
<body onload="run()">
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -45,11 +46,18 @@
|
|||||||
oauth2.auth.code = qp.code;
|
oauth2.auth.code = qp.code;
|
||||||
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
|
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
|
||||||
} else {
|
} 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({
|
oauth2.errCb({
|
||||||
authId: oauth2.auth.name,
|
authId: oauth2.auth.name,
|
||||||
source: "auth",
|
source: "auth",
|
||||||
level: "error",
|
level: "error",
|
||||||
message: "Authorization failed: no accessCode received from the server"
|
message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} 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-ejb')
|
||||||
include(':service-war')
|
include(':service-war')
|
||||||
include(':service-thorntail')
|
include(':service-thorntail')
|
||||||
|
include(':service-tool')
|
||||||
include(':web-angular')
|
include(':web-angular')
|
||||||
include(':web-war')
|
include(':web-war')
|
||||||
include(':site-ear')
|
include(':site-ear')
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
"build": {
|
"build": {
|
||||||
"builder": "@angular-devkit/build-angular:browser",
|
"builder": "@angular-devkit/build-angular:browser",
|
||||||
"options": {
|
"options": {
|
||||||
|
"aot": true,
|
||||||
"outputPath": "dist",
|
"outputPath": "dist",
|
||||||
"index": "src/index.html",
|
"index": "src/index.html",
|
||||||
"main": "src/main.ts",
|
"main": "src/main.ts",
|
||||||
@@ -27,6 +28,12 @@
|
|||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"production": {
|
"production": {
|
||||||
|
"budgets": [
|
||||||
|
{
|
||||||
|
"type": "anyComponentStyle",
|
||||||
|
"maximumWarning": "6kb"
|
||||||
|
}
|
||||||
|
],
|
||||||
"optimization": true,
|
"optimization": true,
|
||||||
"outputHashing": "all",
|
"outputHashing": "all",
|
||||||
"sourceMap": false,
|
"sourceMap": false,
|
||||||
@@ -123,7 +130,7 @@
|
|||||||
"schematics": {
|
"schematics": {
|
||||||
"@schematics/angular:component": {
|
"@schematics/angular:component": {
|
||||||
"prefix": "app",
|
"prefix": "app",
|
||||||
"styleext": "scss"
|
"style": "scss"
|
||||||
},
|
},
|
||||||
"@schematics/angular:directive": {
|
"@schematics/angular:directive": {
|
||||||
"prefix": "app"
|
"prefix": "app"
|
||||||
|
|||||||
@@ -14,39 +14,39 @@
|
|||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/animations": "^8.1.2",
|
"@angular/animations": "^9.0.1",
|
||||||
"@angular/cdk": "^8.1.1",
|
"@angular/cdk": "^9.0.0",
|
||||||
"@angular/common": "^8.1.2",
|
"@angular/common": "^9.0.1",
|
||||||
"@angular/compiler": "^8.1.2",
|
"@angular/compiler": "^9.0.1",
|
||||||
"@angular/core": "^8.1.2",
|
"@angular/core": "^9.0.1",
|
||||||
"@angular/flex-layout": "^8.0.0-beta.26",
|
"@angular/flex-layout": "^9.0.0-beta.29",
|
||||||
"@angular/forms": "^8.1.2",
|
"@angular/forms": "^9.0.1",
|
||||||
"@angular/material": "^8.1.1",
|
"@angular/material": "^9.0.0",
|
||||||
"@angular/platform-browser": "^8.1.2",
|
"@angular/platform-browser": "^9.0.1",
|
||||||
"@angular/platform-browser-dynamic": "^8.1.2",
|
"@angular/platform-browser-dynamic": "^9.0.1",
|
||||||
"@angular/router": "^8.1.2",
|
"@angular/router": "^9.0.1",
|
||||||
"@types/jszip": "^3.1.6",
|
"@types/jszip": "^3.1.6",
|
||||||
"core-js": "^2.6.9",
|
"core-js": "^2.6.9",
|
||||||
"hammerjs": "^2.0.8",
|
|
||||||
"jszip": "^3.2.2",
|
"jszip": "^3.2.2",
|
||||||
"leaflet": "^1.5.1",
|
"leaflet": "^1.5.1",
|
||||||
"ngx-gauge": "^1.0.0-beta.10",
|
"ngx-gauge": "^1.0.0",
|
||||||
"rxjs": "^6.5.2",
|
"rxjs": "^6.5.2",
|
||||||
|
"saturn-datepicker": "^8.0.1",
|
||||||
"tslib": "^1.10.0",
|
"tslib": "^1.10.0",
|
||||||
"zone.js": "^0.9.1"
|
"zone.js": "~0.10.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular-devkit/build-angular": "~0.801.2",
|
"@angular-devkit/build-angular": "~0.900.2",
|
||||||
"@angular/cli": "^8.1.2",
|
"@angular/cli": "^9.0.2",
|
||||||
"@angular/compiler-cli": "^8.1.2",
|
"@angular/compiler-cli": "^9.0.1",
|
||||||
"@angular/language-service": "^8.1.2",
|
"@angular/language-service": "^9.0.1",
|
||||||
"@types/jasmine": "^2.8.16",
|
"@types/jasmine": "^2.8.16",
|
||||||
"@types/jasminewd2": "^2.0.6",
|
"@types/jasminewd2": "^2.0.6",
|
||||||
"@types/leaflet": "^1.4.6",
|
"@types/leaflet": "^1.4.6",
|
||||||
"@types/node": "^6.14.7",
|
"@types/node": "^12.11.1",
|
||||||
"acorn": "^6.2.0",
|
"acorn": "^6.2.0",
|
||||||
"angular4-swagger-client-generator": "0.1.13",
|
"angular4-swagger-client-generator": "0.1.13",
|
||||||
"codelyzer": "^5.0.1",
|
"codelyzer": "^5.1.2",
|
||||||
"events": "^3.0.0",
|
"events": "^3.0.0",
|
||||||
"jasmine-core": "^2.8.0",
|
"jasmine-core": "^2.8.0",
|
||||||
"jasmine-spec-reporter": "^4.2.1",
|
"jasmine-spec-reporter": "^4.2.1",
|
||||||
@@ -58,6 +58,6 @@
|
|||||||
"protractor": "^6.0.0",
|
"protractor": "^6.0.0",
|
||||||
"ts-node": "~4.1.0",
|
"ts-node": "~4.1.0",
|
||||||
"tslint": "~5.9.1",
|
"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 { NgxGaugeModule } from 'ngx-gauge';
|
||||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
|
|
||||||
import { MatButtonModule, MatIconModule,
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
MatCheckboxModule, MatSidenavModule,
|
import { MatCardModule } from '@angular/material/card';
|
||||||
MatToolbarModule, MatTooltipModule, MatCardModule,
|
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||||
MatInputModule, MatFormFieldModule,
|
import { MatNativeDateModule } from '@angular/material/core';
|
||||||
MatProgressBarModule, MatProgressSpinnerModule,
|
import { MatDatepickerModule } from '@angular/material/datepicker';
|
||||||
MatSnackBarModule, MatDialogModule,
|
import { MatDialogModule } from '@angular/material/dialog';
|
||||||
MatListModule, MatPaginatorModule, MatTableModule,
|
import { MatExpansionModule } from '@angular/material/expansion';
|
||||||
MatPaginatorIntl, MatExpansionModule, MatSelectModule,
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||||
MatDatepickerModule, MatNativeDateModule,
|
import { MatGridListModule } from '@angular/material/grid-list';
|
||||||
MatTabsModule, MatGridListModule, MatSliderModule } from '@angular/material';
|
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 { LocationStrategy, PathLocationStrategy, registerLocaleData, DatePipe } from '@angular/common';
|
||||||
import LocaleDE from '@angular/common/locales/de';
|
import LocaleDE from '@angular/common/locales/de';
|
||||||
@@ -27,6 +44,8 @@ import { AppComponent } from './app.component';
|
|||||||
import { InsideComponent } from './layouts/inside.component';
|
import { InsideComponent } from './layouts/inside.component';
|
||||||
import { OutsideComponent } from './layouts/outside.component';
|
import { OutsideComponent } from './layouts/outside.component';
|
||||||
import { FooterComponent } from './layouts/footer.component';
|
import { FooterComponent } from './layouts/footer.component';
|
||||||
|
import { ContentLayoutComponent } from './layouts/content-layout.component';
|
||||||
|
import { ContentHeaderComponent } from './layouts/content-header.component';
|
||||||
|
|
||||||
import { ToolbarButtonComponent } from './widgets/toolbar-button.component';
|
import { ToolbarButtonComponent } from './widgets/toolbar-button.component';
|
||||||
import { LoginComponent } from './views/login.component';
|
import { LoginComponent } from './views/login.component';
|
||||||
@@ -89,6 +108,10 @@ import { ExportComponent } from './views/export.component';
|
|||||||
import { ExportService } from './services/export.service';
|
import { ExportService } from './services/export.service';
|
||||||
import { DevicePositionService } from './services/device-position.service';
|
import { DevicePositionService } from './services/device-position.service';
|
||||||
import { DevicePositionsComponent } from './views/device-positions.component';
|
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.
|
* Computes the api domain from the browser location.
|
||||||
@@ -157,6 +180,11 @@ registerLocaleData(LocaleDE);
|
|||||||
ManageNoticesComponent,
|
ManageNoticesComponent,
|
||||||
EditNoticeComponent,
|
EditNoticeComponent,
|
||||||
UseParentFormDirective,
|
UseParentFormDirective,
|
||||||
|
ChartComponent,
|
||||||
|
TimeSheetComponent,
|
||||||
|
PlacesDialogComponent,
|
||||||
|
ContentLayoutComponent,
|
||||||
|
ContentHeaderComponent,
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
@@ -189,7 +217,12 @@ registerLocaleData(LocaleDE);
|
|||||||
MatNativeDateModule,
|
MatNativeDateModule,
|
||||||
MatTabsModule,
|
MatTabsModule,
|
||||||
MatGridListModule,
|
MatGridListModule,
|
||||||
|
MatMenuModule,
|
||||||
|
CdkTableModule,
|
||||||
AppRoutingModule,
|
AppRoutingModule,
|
||||||
|
SatDatepickerModule,
|
||||||
|
SatNativeDateModule,
|
||||||
|
MatButtonToggleModule
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
// injection token for http client
|
// injection token for http client
|
||||||
@@ -209,8 +242,15 @@ registerLocaleData(LocaleDE);
|
|||||||
ResourceService, CredentialService, UserService, VersionService, ExportService,
|
ResourceService, CredentialService, UserService, VersionService, ExportService,
|
||||||
DeviceService, PrivilegeService, PlaceService, NoticeService, PlaceVisitService, DeviceVisitService, DevicePositionService,
|
DeviceService, PrivilegeService, PlaceService, NoticeService, PlaceVisitService, DeviceVisitService, DevicePositionService,
|
||||||
ManageLogService, ManageUserService, ManageNoticeService
|
ManageLogService, ManageUserService, ManageNoticeService
|
||||||
],
|
],
|
||||||
entryComponents: [MessageDialogComponent, ConfirmationDialogComponent, ShareDialogComponent, NicknameDialogComponent, LogDialogComponent],
|
entryComponents: [
|
||||||
|
MessageDialogComponent,
|
||||||
|
ConfirmationDialogComponent,
|
||||||
|
ShareDialogComponent,
|
||||||
|
NicknameDialogComponent,
|
||||||
|
LogDialogComponent,
|
||||||
|
PlacesDialogComponent,
|
||||||
|
],
|
||||||
bootstrap: [AppComponent]
|
bootstrap: [AppComponent]
|
||||||
})
|
})
|
||||||
export class AppModule { }
|
export class AppModule { }
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import { ManageNoticesComponent } from './views/manage-notices.component';
|
|||||||
import { EditNoticeComponent } from './views/edit-notice.component';
|
import { EditNoticeComponent } from './views/edit-notice.component';
|
||||||
import { ExportComponent } from './views/export.component';
|
import { ExportComponent } from './views/export.component';
|
||||||
import { DevicePositionsComponent } from './views/device-positions.component';
|
import { DevicePositionsComponent } from './views/device-positions.component';
|
||||||
|
import { TimeSheetComponent } from "./views/time-sheet.component";
|
||||||
|
|
||||||
export const routes: Routes = [
|
export const routes: Routes = [
|
||||||
{ path: '', canActivate: [AuthGuard], canActivateChild: [AuthGuard], children: [
|
{ path: '', canActivate: [AuthGuard], canActivateChild: [AuthGuard], children: [
|
||||||
@@ -55,6 +56,9 @@ export const routes: Routes = [
|
|||||||
{ path: 'export', component: InsideComponent, children: [
|
{ path: 'export', component: InsideComponent, children: [
|
||||||
{ path: '', component: ExportComponent }
|
{ path: '', component: ExportComponent }
|
||||||
]},
|
]},
|
||||||
|
{ path: 'timesheet', component: InsideComponent, children: [
|
||||||
|
{ path: '', component: TimeSheetComponent }
|
||||||
|
]},
|
||||||
/// inside (admin)
|
/// inside (admin)
|
||||||
{ path: 'manage', component: InsideComponent, children: [
|
{ path: 'manage', component: InsideComponent, children: [
|
||||||
{ path: 'logs', component: ManageLogComponent },
|
{ path: 'logs', component: ManageLogComponent },
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export class AuthGuard implements CanActivate, CanActivateChild {
|
|||||||
];
|
];
|
||||||
|
|
||||||
private static readonly USER: string[] = [
|
private static readonly USER: string[] = [
|
||||||
'/devices', '/notices', '/privileges', '/profile', '/places', '/export'
|
'/devices', '/notices', '/privileges', '/profile', '/places', '/export', '/timesheet'
|
||||||
];
|
];
|
||||||
|
|
||||||
private static readonly ADMIN: string[] = [
|
private static readonly ADMIN: string[] = [
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<mat-toolbar id="content-toolbar" [ngClass]="headerClass" [ngStyle]="headerStyle">
|
||||||
|
<ng-content select=".header-title"></ng-content>
|
||||||
|
<ng-content select=".header-actions"></ng-content>
|
||||||
|
</mat-toolbar>
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import { Component, Input } from '@angular/core';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple content header component which is containing the name of the page on
|
||||||
|
* the left side and the action buttons on the right side.
|
||||||
|
*
|
||||||
|
* @author Adriano
|
||||||
|
*/
|
||||||
|
@Component({
|
||||||
|
selector: 'app-content-header',
|
||||||
|
templateUrl: './content-header.component.html'
|
||||||
|
})
|
||||||
|
export class ContentHeaderComponent {
|
||||||
|
|
||||||
|
/* Attributes which are forwarding the styles and classes
|
||||||
|
* to the mat-toolbar which where specified on the app-content-header.*/
|
||||||
|
@Input() headerStyle?: { [klass: string]: any; };
|
||||||
|
@Input() headerClass?: string | string[] | Set<string> | { [klass: string]: any; };
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<div class="outer-container" [ngClass]="layoutClass" [ngStyle]="layoutStyle">
|
||||||
|
<ng-content select="app-content-header"></ng-content>
|
||||||
|
|
||||||
|
<div #mainDiv class="inner-container">
|
||||||
|
<ng-content select="aside"></ng-content>
|
||||||
|
<ng-content select="main"></ng-content>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import { Component, AfterViewInit, ViewChild, ElementRef, Input } from '@angular/core';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Content layout component which displays an <app-header>
|
||||||
|
* on the top, a <main> on the left and an <aside> on the right side
|
||||||
|
* through angular projection.
|
||||||
|
* The <main> tag is mandatory and the other two can be omitted if necessary.
|
||||||
|
*
|
||||||
|
* @author Adriano
|
||||||
|
*/
|
||||||
|
@Component({
|
||||||
|
selector: 'app-content-layout',
|
||||||
|
templateUrl: './content-layout.component.html'
|
||||||
|
})
|
||||||
|
export class ContentLayoutComponent implements AfterViewInit {
|
||||||
|
|
||||||
|
/* Attributes which are forwarding the styles and classes
|
||||||
|
* to the div.outer-container which where specified on the app-content-layout.*/
|
||||||
|
@Input() layoutStyle?: { [klass: string]: any; };
|
||||||
|
@Input() layoutClass?: string | string[] | Set<string> | { [klass: string]: any; };
|
||||||
|
|
||||||
|
@ViewChild('mainDiv') mainDiv: ElementRef;
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
ngAfterViewInit(): void {
|
||||||
|
const div: HTMLDivElement = this.mainDiv.nativeElement;
|
||||||
|
if (div.getElementsByTagName('main').length === 0) {
|
||||||
|
throw new Error('<main> tag not specified!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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>
|
<h3 mat-subheader>{{res.strings('drawer_navigation')}}</h3>
|
||||||
<mat-list-item>
|
<a mat-list-item routerLink="/notices">
|
||||||
<button mat-button routerLink="/notices">
|
<mat-icon class="icon-button">message</mat-icon>
|
||||||
<mat-icon class="icon-button">message</mat-icon>
|
<span class="mat-button">{{ res.strings('notices_title') }}</span>
|
||||||
<span class="mat-button">{{ res.strings('notices_title') }}</span>
|
</a>
|
||||||
</button>
|
<a mat-list-item routerLink="/privileges">
|
||||||
</mat-list-item>
|
<mat-icon class="icon-button">share</mat-icon>
|
||||||
<mat-list-item>
|
<span class="mat-button">{{ res.strings('privileges_title') }}</span>
|
||||||
<button mat-button routerLink="/privileges">
|
</a>
|
||||||
<mat-icon class="icon-button">share</mat-icon>
|
<a mat-list-item routerLink="/timesheet">
|
||||||
<span class="mat-button">{{ res.strings('privileges_title') }}</span>
|
<mat-icon class="icon-button">access_time_icon</mat-icon>
|
||||||
</button>
|
<span class="mat-button">{{ res.strings('time_sheet_title') }}</span>
|
||||||
</mat-list-item>
|
</a>
|
||||||
<mat-list-item>
|
<a mat-list-item routerLink="/devices">
|
||||||
<button mat-button routerLink="/devices">
|
<mat-icon class="icon-button">devices</mat-icon>
|
||||||
<mat-icon class="icon-button">devices</mat-icon>
|
<span class="mat-button">{{ res.strings('devices_title') }}</span>
|
||||||
<span class="mat-button">{{ res.strings('devices_title') }}</span>
|
</a>
|
||||||
</button>
|
<a mat-list-item routerLink="/places">
|
||||||
</mat-list-item>
|
<mat-icon class="icon-button">pie_chart_outlined</mat-icon>
|
||||||
<mat-list-item>
|
<span class="mat-button">{{ res.strings('places_title') }}</span>
|
||||||
<button mat-button routerLink="/places">
|
</a>
|
||||||
<mat-icon class="icon-button">pie_chart_outlined</mat-icon>
|
<a mat-list-item routerLink="/export">
|
||||||
<span class="mat-button">{{ res.strings('places_title') }}</span>
|
<mat-icon class="icon-button">cloud_download</mat-icon>
|
||||||
</button>
|
<span class="mat-button">{{ res.strings('export_title') }}</span>
|
||||||
</mat-list-item>
|
</a>
|
||||||
<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>
|
|
||||||
<h3 mat-subheader>{{res.strings('drawer_settings')}}</h3>
|
<h3 mat-subheader>{{res.strings('drawer_settings')}}</h3>
|
||||||
<mat-list-item>
|
<a mat-list-item routerLink="/profile">
|
||||||
<button mat-button routerLink="/profile">
|
<mat-icon class="icon-button">perm_identity</mat-icon>
|
||||||
<mat-icon class="icon-button">perm_identity</mat-icon>
|
<span class="mat-button">{{ res.strings('user_title') }}</span>
|
||||||
<span class="mat-button">{{ res.strings('user_title') }}</span>
|
</a>
|
||||||
</button>
|
|
||||||
</mat-list-item>
|
|
||||||
<ng-container *ngIf="admin">
|
<ng-container *ngIf="admin">
|
||||||
<h3 mat-subheader>{{res.strings('drawer_management')}}</h3>
|
<h3 mat-subheader>{{res.strings('drawer_management')}}</h3>
|
||||||
<mat-list-item>
|
<a mat-list-item routerLink="/manage/system">
|
||||||
<button mat-button routerLink="/manage/system">
|
<mat-icon class="icon-button">equalizer</mat-icon>
|
||||||
<mat-icon class="icon-button">equalizer</mat-icon>
|
<span class="mat-button">{{ res.strings('manage_system_title') }}</span>
|
||||||
<span class="mat-button">{{ res.strings('manage_system_title') }}</span>
|
</a>
|
||||||
</button>
|
<a mat-list-item routerLink="/manage/logs">
|
||||||
</mat-list-item>
|
<mat-icon class="icon-button">subject</mat-icon>
|
||||||
<mat-list-item>
|
<span class="mat-button">{{ res.strings('manage_logs_title') }}</span>
|
||||||
<button mat-button routerLink="/manage/logs">
|
</a>
|
||||||
<mat-icon class="icon-button">subject</mat-icon>
|
<a mat-list-item routerLink="/manage/users">
|
||||||
<span class="mat-button">{{ res.strings('manage_logs_title') }}</span>
|
<mat-icon class="icon-button">people</mat-icon>
|
||||||
</button>
|
<span class="mat-button">{{ res.strings('manage_users_title') }}</span>
|
||||||
</mat-list-item>
|
</a>
|
||||||
<mat-list-item>
|
<a mat-list-item routerLink="/manage/notices">
|
||||||
<button mat-button routerLink="/manage/users">
|
<mat-icon class="icon-button">forum</mat-icon>
|
||||||
<mat-icon class="icon-button">people</mat-icon>
|
<span class="mat-button">{{ res.strings('manage_notices_title') }}</span>
|
||||||
<span class="mat-button">{{ res.strings('manage_users_title') }}</span>
|
</a>
|
||||||
</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>
|
|
||||||
</ng-container>
|
</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 { Router } from '@angular/router';
|
||||||
import { UserService, UserState } from '../services/user.service';
|
import { UserService, UserState } from '../services/user.service';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
import { MatSidenavContainer, MatSidenav } from '@angular/material';
|
import { MatSidenavContainer, MatSidenav } from '@angular/material/sidenav';
|
||||||
import { ResourceService } from '../services/resource.service';
|
import { ResourceService } from '../services/resource.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { MatPaginatorIntl } from '@angular/material';
|
import { MatPaginatorIntl } from '@angular/material/paginator';
|
||||||
import { ResourceService } from '../services/resource.service';
|
import { ResourceService } from '../services/resource.service';
|
||||||
import { Inject } from '@angular/core';
|
import { Inject, Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
export class GermanPaginatorProvider extends MatPaginatorIntl {
|
export class GermanPaginatorProvider extends MatPaginatorIntl {
|
||||||
|
|
||||||
constructor(@Inject(ResourceService) public res: ResourceService) {
|
constructor(@Inject(ResourceService) public res: ResourceService) {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { DataSource } from '@angular/cdk/table';
|
|||||||
import { Device, Position } from '../../api/models';
|
import { Device, Position } from '../../api/models';
|
||||||
import { ApiClientService } from '../../api';
|
import { ApiClientService } from '../../api';
|
||||||
import { CollectionViewer } from '@angular/cdk/collections';
|
import { CollectionViewer } from '@angular/cdk/collections';
|
||||||
|
import { DeltaCodec } from "../utils/deltacodec";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A service that handles visits for a particular device and time.
|
* 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());
|
readonly date = new BehaviorSubject<Date>(new Date());
|
||||||
private elements = new BehaviorSubject<Position[]>([]);
|
private elements = new BehaviorSubject<Position[]>([]);
|
||||||
|
|
||||||
|
private readonly streams = 5;
|
||||||
|
private readonly deltaCodec = new DeltaCodec(this.streams);
|
||||||
|
|
||||||
private id: number;
|
private id: number;
|
||||||
private subscriptions = 0;
|
private subscriptions = 0;
|
||||||
|
|
||||||
constructor(private apiClientService: ApiClientService) {
|
constructor(private apiClientService: ApiClientService) { }
|
||||||
}
|
|
||||||
|
|
||||||
getPositions(): Position[] {
|
getPositions(): Position[] {
|
||||||
return this.elements.getValue();
|
return this.elements.getValue();
|
||||||
@@ -53,7 +55,7 @@ export class DevicePositionService implements DataSource<Position> {
|
|||||||
const millis = d.getTime();
|
const millis = d.getTime();
|
||||||
this.date.next(d);
|
this.date.next(d);
|
||||||
this.elements.next([]);
|
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.elements.next(result.body.sort((a, b) => a.timestamp - b.timestamp));
|
||||||
this.loading.next(false);
|
this.loading.next(false);
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
@@ -71,4 +73,25 @@ export class DevicePositionService implements DataSource<Position> {
|
|||||||
this.subscriptions -= 1;
|
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_location_tooltip': 'Standort anzeigen',
|
||||||
'devices_history_tooltip': 'Verlauf anzeigen',
|
'devices_history_tooltip': 'Verlauf anzeigen',
|
||||||
'devices_position_tooltip': 'Aktualisierungen 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',
|
'devices_delete_tooltip': 'Gerät löschen',
|
||||||
'device_location_device_error': 'Die Geräteinformationen konnten nicht geladen werden.',
|
'device_location_device_error': 'Die Geräteinformationen konnten nicht geladen werden.',
|
||||||
'device_location_location_error': 'Der Standort konte nicht abgerufen 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 '
|
'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.',
|
+ '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.',
|
'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
|
// layouts
|
||||||
'drawer_navigation': 'Navigation',
|
'drawer_navigation': 'Navigation',
|
||||||
'drawer_settings': 'Einstellungen',
|
'drawer_settings': 'Einstellungen',
|
||||||
@@ -845,6 +885,10 @@ export class ResourceService {
|
|||||||
'devices_location_tooltip': 'Show current location',
|
'devices_location_tooltip': 'Show current location',
|
||||||
'devices_history_tooltip': 'Show location history',
|
'devices_history_tooltip': 'Show location history',
|
||||||
'devices_position_tooltip': 'Show individual updates',
|
'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',
|
'devices_delete_tooltip': 'Delete device',
|
||||||
'device_location_device_error': 'Failed to load the device information.',
|
'device_location_device_error': 'Failed to load the device information.',
|
||||||
'device_location_location_error': 'Failed to load the device location.',
|
'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, '
|
'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.',
|
+ 'make sure to copy it completely.',
|
||||||
'activate_error_expiredlink': 'The activation link is no longer valid. Did you already use it?',
|
'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
|
// layouts
|
||||||
'drawer_navigation': 'Navigation',
|
'drawer_navigation': 'Navigation',
|
||||||
'drawer_settings': 'Settings',
|
'drawer_settings': 'Settings',
|
||||||
|
|||||||
@@ -0,0 +1,619 @@
|
|||||||
|
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 */
|
||||||
|
}
|
||||||
|
|
||||||
|
interface 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 = 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:
|
||||||
|
const 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) => {
|
||||||
|
const beginMidnight = this.getMidnightDate(currTS.beginDate.getTime()).getTime();
|
||||||
|
const 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 newTimeSheet = {
|
||||||
|
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, newTimeSheet);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
|
const 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(p => p.id === data.placeId);
|
||||||
|
res = this.getWorkplaceName(place);
|
||||||
|
} else {
|
||||||
|
data.placesSet.forEach(id => {
|
||||||
|
const place = this.workPlaces.find(p => p.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 = '';
|
||||||
|
const 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 { Observable, BehaviorSubject, Subscription } from 'rxjs';
|
||||||
import { ApiClientService } from '../../api';
|
import { ApiClientService } from '../../api';
|
||||||
import { HttpResponse } from '@angular/common/http';
|
import { HttpResponse } from '@angular/common/http';
|
||||||
import { MatPaginator } from '@angular/material';
|
import { MatPaginator } from '@angular/material/paginator';
|
||||||
|
|
||||||
export interface Page<E> {
|
export interface Page<E> {
|
||||||
offset: number;
|
offset: number;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { MatSnackBar } from '@angular/material';
|
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||||
|
|
||||||
export class Snackbars {
|
export class Snackbars {
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { MatTable } from '@angular/material';
|
import { MatTable } from '@angular/material/table';
|
||||||
import { ElementRef } from '@angular/core';
|
import { ElementRef } from '@angular/core';
|
||||||
|
|
||||||
export interface TableColumn {
|
export interface TableColumn {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ApiClientService } from '../../api';
|
import { ApiClientService } from '../../api';
|
||||||
import { MatDialog } from '@angular/material';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { MessageDialogComponent } from '../widgets/message-dialog.component';
|
import { MessageDialogComponent } from '../widgets/message-dialog.component';
|
||||||
import { HttpErrorResponse } from '@angular/common/http';
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ import { FormErrorCode, FormErrorEncoder } from '../utils/formcodes';
|
|||||||
import { LoginFieldComponent } from '../widgets/login-field.component';
|
import { LoginFieldComponent } from '../widgets/login-field.component';
|
||||||
import { PasswordFieldComponent } from '../widgets/password-field.component';
|
import { PasswordFieldComponent } from '../widgets/password-field.component';
|
||||||
import { HttpStatusCode } from '../utils/httpcodes';
|
import { HttpStatusCode } from '../utils/httpcodes';
|
||||||
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 { NgForm } from '@angular/forms';
|
||||||
import { Snackbars } from '../utils/snackbars';
|
import { Snackbars } from '../utils/snackbars';
|
||||||
import { ApiClientService } from '../../api';
|
import { ApiClientService } from '../../api';
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit, HostBinding } from '@angular/core';
|
import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit, HostBinding } from '@angular/core';
|
||||||
import { ApiClientService } from '../../api';
|
import { 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 { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { MessageDialogComponent } from '../widgets/message-dialog.component';
|
import { MessageDialogComponent } from '../widgets/message-dialog.component';
|
||||||
import { HttpErrorResponse } from '@angular/common/http';
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
|
|||||||
@@ -65,4 +65,17 @@
|
|||||||
</button>
|
</button>
|
||||||
</mat-card-footer>
|
</mat-card-footer>
|
||||||
</mat-card>
|
</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>
|
</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 { 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 { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { Subscription, BehaviorSubject } from 'rxjs';
|
import { Subscription, BehaviorSubject } from 'rxjs';
|
||||||
import { Device, Position } from '../../api/models';
|
import { Device, Position } from '../../api/models';
|
||||||
@@ -14,6 +20,7 @@ import { TableColumn, TableHandler } from '../utils/tables';
|
|||||||
import { ResourceService } from '../services/resource.service';
|
import { ResourceService } from '../services/resource.service';
|
||||||
import { DevicePositionService } from '../services/device-position.service';
|
import { DevicePositionService } from '../services/device-position.service';
|
||||||
import { ValueConverter } from '@angular/compiler/src/render3/view/template';
|
import { ValueConverter } from '@angular/compiler/src/render3/view/template';
|
||||||
|
import { ChartComponent, AxisConfig, Point } from "../widgets/chart.component";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-device-positions',
|
selector: 'app-device-positions',
|
||||||
@@ -23,6 +30,7 @@ export class DevicePositionsComponent implements OnInit, AfterViewInit, OnDestro
|
|||||||
|
|
||||||
@ViewChild(MarkerMapComponent, { static: true }) map: MarkerMapComponent;
|
@ViewChild(MarkerMapComponent, { static: true }) map: MarkerMapComponent;
|
||||||
@ViewChild('table', { read: ElementRef, static: true }) table: ElementRef;
|
@ViewChild('table', { read: ElementRef, static: true }) table: ElementRef;
|
||||||
|
@ViewChild(ChartComponent, { static: true }) chart: ChartComponent;
|
||||||
|
|
||||||
id: string;
|
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 {
|
ngDoCheck(): void {
|
||||||
this.compact = (this.map.getWidth() < 900);
|
this.compact = (this.map.getWidth() < 900);
|
||||||
}
|
}
|
||||||
@@ -184,6 +212,7 @@ export class DevicePositionsComponent implements OnInit, AfterViewInit, OnDestro
|
|||||||
private updateSelectedPosition(): void {
|
private updateSelectedPosition(): void {
|
||||||
if (this.loading.getValue() || this.devicePositionService.getPositions().length === 0) {
|
if (this.loading.getValue() || this.devicePositionService.getPositions().length === 0) {
|
||||||
this.selectedPosition.remove();
|
this.selectedPosition.remove();
|
||||||
|
this.updateChart();
|
||||||
} else {
|
} else {
|
||||||
const date = new Date(this.selectedDate);
|
const date = new Date(this.selectedDate);
|
||||||
date.setHours(Math.floor(this.sliderValue / 60));
|
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.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 { Component, OnInit, OnDestroy, ViewChild, AfterViewInit, ElementRef, DoCheck } from '@angular/core';
|
||||||
import { ApiClientService } from '../../api';
|
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 { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { MessageDialogComponent } from '../widgets/message-dialog.component';
|
import { MessageDialogComponent } from '../widgets/message-dialog.component';
|
||||||
import { HttpErrorResponse } from '@angular/common/http';
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
<div style="margin: 20px;">
|
<app-content-layout [layoutClass]="'table-page'">
|
||||||
<mat-toolbar>
|
<app-content-header>
|
||||||
<mat-icon>devices</mat-icon>
|
<div class="header-title">
|
||||||
<span style="margin-left: 10px">{{ res.strings('devices_title') }}</span>
|
<mat-icon>devices</mat-icon>
|
||||||
</mat-toolbar>
|
<span>{{ res.strings('devices_title') }}</span>
|
||||||
<div class="mat-elevation-z2">
|
</div>
|
||||||
|
</app-content-header>
|
||||||
|
|
||||||
|
<main class="mat-elevation-z2">
|
||||||
<ng-container *ngIf="loading.getValue()">
|
<ng-container *ngIf="loading.getValue()">
|
||||||
<mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar>
|
<mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
@@ -65,6 +68,5 @@
|
|||||||
|
|
||||||
<mat-paginator #paginator [pageSize]="20" [pageSizeOptions]="[1, 10, 20, 50]" [showFirstLastButtons]="true">
|
<mat-paginator #paginator [pageSize]="20" [pageSizeOptions]="[1, 10, 20, 50]" [showFirstLastButtons]="true">
|
||||||
</mat-paginator>
|
</mat-paginator>
|
||||||
</div>
|
</main>
|
||||||
|
</app-content-layout>
|
||||||
</div>
|
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
import { Component, ViewChild, OnInit, OnDestroy, ElementRef, DoCheck } from '@angular/core';
|
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 { DeviceService } from '../services/device.service';
|
||||||
import { Device, DevicePage } from '../../api/models';
|
import { Device, DevicePage } from '../../api/models';
|
||||||
import { DataSource } from '@angular/cdk/table';
|
import { DataSource } from '@angular/cdk/table';
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import { Component, ViewChild, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core';
|
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 { DeviceService } from '../services/device.service';
|
||||||
import { Notice, NoticePage, Message } from '../../api/models';
|
import { Notice, NoticePage, Message } from '../../api/models';
|
||||||
import { DataSource } from '@angular/cdk/table';
|
import { DataSource } from '@angular/cdk/table';
|
||||||
|
|||||||
@@ -1,63 +1,61 @@
|
|||||||
<ng-container>
|
<app-content-layout>
|
||||||
<div style="flex: 1 1 100%;">
|
<app-content-header [headerClass]="'header-transparent'">
|
||||||
<mat-toolbar style="margin-top:20px;background:transparent">
|
<div class="header-title">
|
||||||
<mat-icon style="margin-left:20px;">cloud_download</mat-icon>
|
<mat-icon>cloud_download</mat-icon>
|
||||||
<span style="margin-left: 10px">{{ res.strings('export_title') }}</span>
|
<span>{{ res.strings('export_title') }}</span>
|
||||||
</mat-toolbar>
|
</div>
|
||||||
<mat-grid-list [cols]="columns" gutterSize="10" rowHeight="450" class="grid-layout">
|
</app-content-header>
|
||||||
<mat-grid-tile>
|
|
||||||
<mat-card class="mat-typography" class="user-card">
|
<main class="flex-row-wrap justify-space-evenly">
|
||||||
<mat-card-title-group>
|
<mat-card class="mat-typography user-card">
|
||||||
<mat-card-title>{{ res.strings('export_explain_title') }}</mat-card-title>
|
<mat-card-title-group>
|
||||||
<mat-card-subtitle>{{ res.strings('export_explain_subtitle') }}</mat-card-subtitle>
|
<mat-card-title>{{ res.strings('export_explain_title') }}</mat-card-title>
|
||||||
</mat-card-title-group>
|
<mat-card-subtitle>{{ res.strings('export_explain_subtitle') }}</mat-card-subtitle>
|
||||||
<mat-card-content style="min-height:130px">
|
</mat-card-title-group>
|
||||||
<p class="mat-body">{{ res.strings('export_explain_content') }}</p>
|
<mat-card-content>
|
||||||
<p class="mat-body">{{ res.strings('export_explain_process') }}</p>
|
<p class="mat-body">{{ res.strings('export_explain_content') }}</p>
|
||||||
</mat-card-content>
|
<p class="mat-body">{{ res.strings('export_explain_process') }}</p>
|
||||||
<mat-card-actions fxFlexLayout="row" fxLayoutAlign="space-around center">
|
</mat-card-content>
|
||||||
<ng-container *ngIf="exportService.downloading | async; else exportButton">
|
<mat-card-actions fxFlexLayout="row" fxLayoutAlign="space-around center">
|
||||||
<button mat-raised-button color="accent" (click)="exportService.stopDownload()">
|
<ng-container *ngIf="exportService.downloading | async; else exportButton">
|
||||||
<mat-icon class="icon-button">cancel</mat-icon>
|
<button mat-raised-button color="accent" (click)="exportService.stopDownload()">
|
||||||
<span>{{ res.strings('button_cancel') }}</span>
|
<mat-icon class="icon-button">cancel</mat-icon>
|
||||||
</button>
|
<span>{{ res.strings('button_cancel') }}</span>
|
||||||
</ng-container>
|
</button>
|
||||||
<ng-template #exportButton>
|
</ng-container>
|
||||||
<button mat-raised-button color="primary" (click)="exportService.startDownload()">
|
<ng-template #exportButton>
|
||||||
<mat-icon class="icon-button">import_export</mat-icon>
|
<button mat-raised-button color="primary" (click)="exportService.startDownload()">
|
||||||
<span>{{ res.strings('button_export') }}</span>
|
<mat-icon class="icon-button">import_export</mat-icon>
|
||||||
</button>
|
<span>{{ res.strings('button_export') }}</span>
|
||||||
</ng-template>
|
</button>
|
||||||
</mat-card-actions>
|
</ng-template>
|
||||||
</mat-card>
|
</mat-card-actions>
|
||||||
</mat-grid-tile>
|
</mat-card>
|
||||||
<mat-grid-tile>
|
|
||||||
<mat-card class="mat-typography" class="user-card">
|
<mat-card class="mat-typography user-card">
|
||||||
<mat-card-title-group>
|
<mat-card-title-group>
|
||||||
<mat-card-title>{{ res.strings('export_download_title') }}</mat-card-title>
|
<mat-card-title>{{ res.strings('export_download_title') }}</mat-card-title>
|
||||||
<mat-card-subtitle>{{ res.strings('export_download_subtitle') }}</mat-card-subtitle>
|
<mat-card-subtitle>{{ res.strings('export_download_subtitle') }}</mat-card-subtitle>
|
||||||
</mat-card-title-group>
|
</mat-card-title-group>
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<mat-list>
|
<mat-list>
|
||||||
<mat-divider></mat-divider>
|
<mat-divider></mat-divider>
|
||||||
<mat-list-item>
|
<mat-list-item>
|
||||||
<mat-label style="font-size:85%" matLine>{{ res.strings('export_devices') }}<div style="float: right;">{{ (exportService.devices | async)?.size }}</div></mat-label>
|
<mat-label class="progress-label" matLine>{{ res.strings('export_devices') }}<div class="progress-float">{{ (exportService.devices | async)?.size }}</div></mat-label>
|
||||||
<mat-progress-bar mode="determinate" [value]="progressValue(exportService.devices | async)" matLine></mat-progress-bar>
|
<mat-progress-bar mode="determinate" [value]="progressValue(exportService.devices | async)" matLine></mat-progress-bar>
|
||||||
</mat-list-item>
|
</mat-list-item>
|
||||||
<mat-divider></mat-divider>
|
<mat-divider></mat-divider>
|
||||||
<mat-list-item>
|
<mat-list-item>
|
||||||
<mat-label style="font-size:85%" matLine>{{ res.strings('export_places') }}<div style="float: right;">{{ (exportService.places | async)?.size }}</div></mat-label>
|
<mat-label class="progress-label" matLine>{{ res.strings('export_places') }}<div class="progress-float">{{ (exportService.places | async)?.size }}</div></mat-label>
|
||||||
<mat-progress-bar mode="determinate" [value]="progressValue(exportService.places | async)" matLine></mat-progress-bar>
|
<mat-progress-bar mode="determinate" [value]="progressValue(exportService.places | async)" matLine></mat-progress-bar>
|
||||||
</mat-list-item>
|
</mat-list-item>
|
||||||
<mat-divider></mat-divider>
|
<mat-divider></mat-divider>
|
||||||
<mat-list-item>
|
<mat-list-item>
|
||||||
<mat-label style="font-size:85%" matLine>{{ res.strings('export_visits') }}<div style="float: right;">{{ (exportService.visits | async)?.size }}</div></mat-label>
|
<mat-label class="progress-label" matLine>{{ res.strings('export_visits') }}<div class="progress-float">{{ (exportService.visits | async)?.size }}</div></mat-label>
|
||||||
<mat-progress-bar mode="determinate" [value]="progressValue(exportService.visits | async)" matLine></mat-progress-bar>
|
<mat-progress-bar mode="determinate" [value]="progressValue(exportService.visits | async)" matLine></mat-progress-bar>
|
||||||
</mat-list-item>
|
</mat-list-item>
|
||||||
</mat-list>
|
</mat-list>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
</mat-grid-tile>
|
</main>
|
||||||
</mat-grid-list>
|
</app-content-layout>
|
||||||
</div>
|
|
||||||
</ng-container>
|
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
import { Component, OnInit, OnDestroy, ViewChild, HostListener } from '@angular/core';
|
import { Component, OnInit, OnDestroy, ViewChild, HostListener } from '@angular/core';
|
||||||
import { UserState, UserService, UserRole } from '../services/user.service';
|
import { 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 { ResourceService } from '../services/resource.service';
|
||||||
import { ExportService } from '../services/export.service';
|
import { ExportService } from '../services/export.service';
|
||||||
import { Page } from '../utils/pagination';
|
import { Page } from '../utils/pagination';
|
||||||
@@ -9,7 +12,11 @@ import { Snackbars } from '../utils/snackbars';
|
|||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-export',
|
selector: 'app-export',
|
||||||
templateUrl: './export.component.html'
|
templateUrl: './export.component.html',
|
||||||
|
styles: [
|
||||||
|
`.progress-label { font-size: 85% !important; }`,
|
||||||
|
`.progress-float { float: right; }`
|
||||||
|
]
|
||||||
})
|
})
|
||||||
export class ExportComponent implements OnInit, OnDestroy {
|
export class ExportComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { FormErrorCode, FormErrorEncoder } from '../utils/formcodes';
|
|||||||
import { LoginFieldComponent } from '../widgets/login-field.component';
|
import { LoginFieldComponent } from '../widgets/login-field.component';
|
||||||
import { PasswordFieldComponent } from '../widgets/password-field.component';
|
import { PasswordFieldComponent } from '../widgets/password-field.component';
|
||||||
import { HttpStatusCode } from '../utils/httpcodes';
|
import { HttpStatusCode } from '../utils/httpcodes';
|
||||||
import { MatSnackBar } from '@angular/material';
|
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||||
import { NgForm } from '@angular/forms';
|
import { NgForm } from '@angular/forms';
|
||||||
import { Snackbars } from '../utils/snackbars';
|
import { Snackbars } from '../utils/snackbars';
|
||||||
import { VersionService } from '../services/version.service';
|
import { VersionService } from '../services/version.service';
|
||||||
|
|||||||
@@ -1,20 +1,32 @@
|
|||||||
<mat-toolbar style="margin-top:20px;background:transparent">
|
<app-content-layout [layoutClass]="'table-page'">
|
||||||
<mat-icon style="margin-left:20px;">subject</mat-icon>
|
<app-content-header>
|
||||||
<span style="margin-left: 10px">Logs</span>
|
<div class="header-title">
|
||||||
<div flexLayout="row" fxLayoutAlign="end center" fxFlex="1 1 auto" fxLayoutGap="10px">
|
<mat-icon>subject</mat-icon>
|
||||||
<button mat-icon-button [matTooltip]="res.strings('manage_logs_connect_tooltip')" (click)="onConnect()" [disabled]="connected || (connecting | async)">
|
<span>Logs</span>
|
||||||
<mat-icon>play_circle_outline</mat-icon>
|
</div>
|
||||||
|
<div class="header-actions">
|
||||||
|
<button mat-icon-button
|
||||||
|
[matTooltip]="res.strings('manage_logs_connect_tooltip')"
|
||||||
|
(click)="onConnect()"
|
||||||
|
[disabled]="connected || (connecting | async)">
|
||||||
|
<mat-icon>play_circle_outline</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
<button mat-icon-button [matTooltip]="res.strings('manage_logs_disconnect_tooltip')" (click)="onDisconnect()" [disabled]="!connected || (connecting | async)">
|
<button mat-icon-button
|
||||||
<mat-icon>pause_circle_outline</mat-icon>
|
[matTooltip]="res.strings('manage_logs_disconnect_tooltip')"
|
||||||
|
(click)="onDisconnect()"
|
||||||
|
[disabled]="!connected || (connecting | async)">
|
||||||
|
<mat-icon>pause_circle_outline</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
<button mat-icon-button [matTooltip]="res.strings('manage_logs_clear_tooltip')" (click)="onClear()" [disabled]="(connecting | async)">
|
<button mat-icon-button
|
||||||
<mat-icon>not_interested</mat-icon>
|
[matTooltip]="res.strings('manage_logs_clear_tooltip')"
|
||||||
|
(click)="onClear()"
|
||||||
|
[disabled]="(connecting | async)">
|
||||||
|
<mat-icon>not_interested</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</mat-toolbar>
|
</app-content-header>
|
||||||
<div style="margin: 20px;">
|
|
||||||
<div class="mat-elevation-z2">
|
<main class="mat-elevation-z2">
|
||||||
<ng-container *ngIf="connecting | async">
|
<ng-container *ngIf="connecting | async">
|
||||||
<mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar>
|
<mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
@@ -66,6 +78,5 @@
|
|||||||
<mat-header-row *matHeaderRowDef="getColumns()"></mat-header-row>
|
<mat-header-row *matHeaderRowDef="getColumns()"></mat-header-row>
|
||||||
<mat-row *matRowDef="let row; columns: getColumns();"></mat-row>
|
<mat-row *matRowDef="let row; columns: getColumns();"></mat-row>
|
||||||
</mat-table>
|
</mat-table>
|
||||||
|
</main>
|
||||||
</div>
|
</app-content-layout>
|
||||||
</div>
|
|
||||||
@@ -5,7 +5,7 @@ import { LogMessage } from '../../api/models';
|
|||||||
import { CollectionViewer } from '@angular/cdk/collections';
|
import { CollectionViewer } from '@angular/cdk/collections';
|
||||||
import { ManageLogService } from '../services/manage-log.service';
|
import { ManageLogService } from '../services/manage-log.service';
|
||||||
import { LogDialogComponent } from '../widgets/log-dialog.component';
|
import { LogDialogComponent } from '../widgets/log-dialog.component';
|
||||||
import { MatDialog } from '@angular/material';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { TableColumn, TableHandler } from '../utils/tables';
|
import { TableColumn, TableHandler } from '../utils/tables';
|
||||||
import { ResourceService } from '../services/resource.service';
|
import { ResourceService } from '../services/resource.service';
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
<div style="margin: 20px;">
|
<app-content-layout [layoutClass]="'table-page'">
|
||||||
<mat-toolbar>
|
<app-content-header>
|
||||||
<mat-icon>forum</mat-icon>
|
<div class="header-title">
|
||||||
<span style="margin-left: 10px">Hinweise</span>
|
<mat-icon>forum</mat-icon>
|
||||||
<div flexLayout="row" fxLayoutAlign="end center" fxFlex="1 1 auto" fxLayoutGap="10px">
|
<span>{{ res.strings('manage_notices_title') }}</span>
|
||||||
<app-language-select style="padding-top:5px;" [value]="language" (change)="language = $event"></app-language-select>
|
</div>
|
||||||
|
<div class="header-actions flex-row-nowrap align-center">
|
||||||
|
<app-language-select [value]="language" (change)="language = $event"></app-language-select>
|
||||||
<button mat-icon-button matTooltip="Hinweis hinzufügen" routerLink="0" [disabled]="loading.getValue()">
|
<button mat-icon-button matTooltip="Hinweis hinzufügen" routerLink="0" [disabled]="loading.getValue()">
|
||||||
<mat-icon>add_circle_outline</mat-icon>
|
<mat-icon>add_circle_outline</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</mat-toolbar>
|
</app-content-header>
|
||||||
<div class="mat-elevation-z2">
|
|
||||||
|
<main class="mat-elevation-z2">
|
||||||
<ng-container *ngIf="loading.getValue()">
|
<ng-container *ngIf="loading.getValue()">
|
||||||
<mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar>
|
<mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
@@ -90,6 +93,5 @@
|
|||||||
|
|
||||||
<mat-paginator #paginator [pageSize]="20" [pageSizeOptions]="[1, 10, 20, 50]" [showFirstLastButtons]="true">
|
<mat-paginator #paginator [pageSize]="20" [pageSizeOptions]="[1, 10, 20, 50]" [showFirstLastButtons]="true">
|
||||||
</mat-paginator>
|
</mat-paginator>
|
||||||
</div>
|
</main>
|
||||||
|
</app-content-layout>
|
||||||
</div>
|
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
import {Component, ViewChild, OnInit, OnDestroy, ElementRef, HostListener, ContentChild, DoCheck} from '@angular/core';
|
import {Component, ViewChild, OnInit, OnDestroy, ElementRef, HostListener, ContentChild, DoCheck} from '@angular/core';
|
||||||
import {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 { DeviceService } from '../services/device.service';
|
||||||
import { Notice, NoticePage } from '../../api/models';
|
import { Notice, NoticePage } from '../../api/models';
|
||||||
import { DataSource } from '@angular/cdk/table';
|
import { DataSource } from '@angular/cdk/table';
|
||||||
|
|||||||
@@ -1,29 +1,40 @@
|
|||||||
<div style="margin: 20px;">
|
<app-content-layout [layoutClass]="'table-page'">
|
||||||
<mat-toolbar>
|
<app-content-header>
|
||||||
<mat-icon>people</mat-icon>
|
<div class="header-title">
|
||||||
<span style="margin-left: 10px">{{ res.strings('manage_users_title') }}</span>
|
<mat-icon>people</mat-icon>
|
||||||
<div flexLayout="row" fxLayoutAlign="end center" fxFlex="1 1 auto" fxLayoutGap="10px">
|
<span>{{ res.strings('manage_users_title') }}</span>
|
||||||
<div style="padding-top:15px;">
|
</div>
|
||||||
<form #searchForm="ngForm" style="font-size: 12px">
|
<div class="header-actions flex-row-nowrap">
|
||||||
<mat-form-field style="max-width:120px">
|
<form #searchForm="ngForm" style="font-size: 12px">
|
||||||
<input matInput #termField="ngModel" maxlength="64" name="term" [placeholder]="res.strings('manage_users_term_placeholder')" [(ngModel)]="term" pattern="([A-Za-z]|[\u00C0-\u00FF]| ){0,64}"
|
<mat-form-field style="max-width:120px">
|
||||||
[disabled]="loading.getValue()" (keyup.enter)="onSearch()">
|
<input matInput #termField="ngModel"
|
||||||
<mat-error *ngIf="termField.invalid">
|
maxlength="64" name="term"
|
||||||
<ng-container [ngSwitch]="encode(termField.errors)">
|
[placeholder]="res.strings('manage_users_term_placeholder')"
|
||||||
<ng-container *ngSwitchCase="FormErrorCode.REQUIRED">{{res.strings('manage_users_term_required')}}</ng-container>
|
[(ngModel)]="term"
|
||||||
<ng-container *ngSwitchCase="FormErrorCode.PATTERN">{{res.strings('manage_users_term_pattern')}}</ng-container>
|
pattern="([A-Za-z]|[\u00C0-\u00FF]| ){0,64}"
|
||||||
|
[disabled]="loading.getValue()" (keyup.enter)="onSearch()">
|
||||||
|
<mat-error *ngIf="termField.invalid">
|
||||||
|
<ng-container [ngSwitch]="encode(termField.errors)">
|
||||||
|
<ng-container *ngSwitchCase="FormErrorCode.REQUIRED">
|
||||||
|
{{res.strings('manage_users_term_required')}}
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</mat-error>
|
<ng-container *ngSwitchCase="FormErrorCode.PATTERN">
|
||||||
</mat-form-field>
|
{{res.strings('manage_users_term_pattern')}}
|
||||||
</form>
|
</ng-container>
|
||||||
</div>
|
</ng-container>
|
||||||
<button mat-icon-button [matTooltip]="res.strings('manage_users_search_tooltip')" (click)="onSearch()" [disabled]="loading.getValue()">
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</form>
|
||||||
|
<button mat-icon-button
|
||||||
|
[matTooltip]="res.strings('manage_users_search_tooltip')"
|
||||||
|
(click)="onSearch()"
|
||||||
|
[disabled]="loading.getValue()">
|
||||||
<mat-icon>search</mat-icon>
|
<mat-icon>search</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</app-content-header>
|
||||||
|
|
||||||
</mat-toolbar>
|
<main class="mat-elevation-z2">
|
||||||
<div class="mat-elevation-z2">
|
|
||||||
<ng-container *ngIf="loading.getValue()">
|
<ng-container *ngIf="loading.getValue()">
|
||||||
<mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar>
|
<mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
@@ -112,6 +123,5 @@
|
|||||||
|
|
||||||
<mat-paginator #paginator [pageSize]="20" [pageSizeOptions]="[1, 10, 20, 50]" [showFirstLastButtons]="true">
|
<mat-paginator #paginator [pageSize]="20" [pageSizeOptions]="[1, 10, 20, 50]" [showFirstLastButtons]="true">
|
||||||
</mat-paginator>
|
</mat-paginator>
|
||||||
</div>
|
</main>
|
||||||
|
</app-content-layout>
|
||||||
</div>
|
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
import {Component, ViewChild, OnInit, OnDestroy, ElementRef, DoCheck} from '@angular/core';
|
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 { DeviceService } from '../services/device.service';
|
||||||
import { Device, DevicePage, User, UserPage } from '../../api/models';
|
import { Device, DevicePage, User, UserPage } from '../../api/models';
|
||||||
import { DataSource } from '@angular/cdk/table';
|
import { DataSource } from '@angular/cdk/table';
|
||||||
|
|||||||
@@ -4,21 +4,24 @@
|
|||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-template #content>
|
<ng-template #content>
|
||||||
<div style="flex: 1 1 100%;">
|
<app-content-layout>
|
||||||
<mat-toolbar style="margin-top:20px;background:transparent">
|
<app-content-header [headerClass]="'header-transparent'">
|
||||||
<mat-icon style="margin-left:20px">message</mat-icon>
|
<div class="header-title">
|
||||||
<span style="margin-left: 10px">{{ res.strings('notices_title') }}</span>
|
<mat-icon>message</mat-icon>
|
||||||
</mat-toolbar>
|
<span>{{ res.strings('notices_title') }}</span>
|
||||||
<div>
|
</div>
|
||||||
<mat-grid-list [cols]="columns" gutterSize="10" rowHeight="480" class="grid-layout">
|
</app-content-header>
|
||||||
<ng-container *ngFor="let n of page.getValue().elements">
|
|
||||||
<ng-container *ngIf="canShow(n, getLanguage())">
|
<main class="flex-row-wrap justify-space-evenly">
|
||||||
<mat-grid-tile colspan="1" rowspan="1">
|
<ng-container *ngFor="let n of page.getValue().elements">
|
||||||
<app-notice-card [language]="getLanguage()" [notice]="n" class="notice-card"></app-notice-card>
|
<ng-container *ngIf="canShow(n, getLanguage())">
|
||||||
</mat-grid-tile>
|
<app-notice-card
|
||||||
</ng-container>
|
[language]="getLanguage()"
|
||||||
|
[notice]="n"
|
||||||
|
class="flex-notice-card">
|
||||||
|
</app-notice-card>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</mat-grid-list>
|
</ng-container>
|
||||||
</div>
|
</main>
|
||||||
</div>
|
</app-content-layout>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
@@ -6,7 +6,7 @@ import { FormErrorCode, FormErrorEncoder } from '../utils/formcodes';
|
|||||||
import { LoginFieldComponent } from '../widgets/login-field.component';
|
import { LoginFieldComponent } from '../widgets/login-field.component';
|
||||||
import { PasswordFieldComponent } from '../widgets/password-field.component';
|
import { PasswordFieldComponent } from '../widgets/password-field.component';
|
||||||
import { HttpStatusCode } from '../utils/httpcodes';
|
import { HttpStatusCode } from '../utils/httpcodes';
|
||||||
import { MatSnackBar } from '@angular/material';
|
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||||
import { NgForm } from '@angular/forms';
|
import { NgForm } from '@angular/forms';
|
||||||
import { Snackbars } from '../utils/snackbars';
|
import { Snackbars } from '../utils/snackbars';
|
||||||
import { NoticeService } from '../services/notice.service';
|
import { NoticeService } from '../services/notice.service';
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit, ViewEncapsulation, DoCheck, ElementRef, Input } from '@angular/core';
|
import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit, ViewEncapsulation, DoCheck, ElementRef, Input } from '@angular/core';
|
||||||
import { ApiClientService } from '../../api';
|
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 { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { MessageDialogComponent } from '../widgets/message-dialog.component';
|
import { MessageDialogComponent } from '../widgets/message-dialog.component';
|
||||||
import { HttpErrorResponse } from '@angular/common/http';
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
|
|||||||
@@ -1,20 +1,26 @@
|
|||||||
<div style="margin: 20px;">
|
<app-content-layout [layoutClass]="'table-page'">
|
||||||
<mat-toolbar>
|
<app-content-header>
|
||||||
<mat-icon>pie_chart_outlined</mat-icon>
|
<div class="header-title">
|
||||||
<span style="margin-left: 10px">{{ res.strings('places_title') }}</span>
|
<mat-icon>pie_chart_outlined</mat-icon>
|
||||||
<div style="padding-top:20px;" flexLayout="row" fxLayoutAlign="end center" fxFlex="1 1 auto" fxLayoutGap="10px">
|
<span>{{ res.strings('places_title') }}</span>
|
||||||
<form style="font-size: 12px;" fxLayoutAlign="center center" flexLayout="row">
|
</div>
|
||||||
<mat-form-field fxFlex="1 1 180px">
|
|
||||||
<mat-select [placeholder]="res.strings('places_order_placeholder')" [value]="order.getValue()" (selectionChange)="order.next($event.source.value)">
|
<div class="header-actions">
|
||||||
<mat-option *ngFor="let o of getOrders()" [value]="o">
|
<form style="font-size: 12px;">
|
||||||
<span>{{ getOrderName(o) }}</span>
|
<mat-form-field>
|
||||||
</mat-option>
|
<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-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</mat-toolbar>
|
</app-content-header>
|
||||||
<div class="mat-elevation-z2">
|
|
||||||
|
<main class="mat-elevation-z2">
|
||||||
<ng-container *ngIf="loading.getValue() || deleting.getValue()">
|
<ng-container *ngIf="loading.getValue() || deleting.getValue()">
|
||||||
<mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar>
|
<mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
@@ -72,6 +78,5 @@
|
|||||||
|
|
||||||
<mat-paginator #paginator [pageSize]="20" [pageSizeOptions]="[1, 10, 20, 50]" [showFirstLastButtons]="true">
|
<mat-paginator #paginator [pageSize]="20" [pageSizeOptions]="[1, 10, 20, 50]" [showFirstLastButtons]="true">
|
||||||
</mat-paginator>
|
</mat-paginator>
|
||||||
</div>
|
</main>
|
||||||
|
</app-content-layout>
|
||||||
</div>
|
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
import {Component, ViewChild, OnInit, OnDestroy, DoCheck, ElementRef} from '@angular/core';
|
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 { Privilege, PrivilegePage, PlacePage, Place } from '../../api/models';
|
||||||
import { DataSource } from '@angular/cdk/table';
|
import { DataSource } from '@angular/cdk/table';
|
||||||
import { Subscription, BehaviorSubject } from 'rxjs';
|
import { Subscription, BehaviorSubject } from 'rxjs';
|
||||||
|
|||||||
@@ -1,15 +1,20 @@
|
|||||||
<div style="margin: 20px;">
|
<app-content-layout [layoutClass]="'table-page'">
|
||||||
<mat-toolbar>
|
<app-content-header>
|
||||||
<mat-icon>share</mat-icon>
|
<div class="header-title">
|
||||||
<span style="margin-left: 10px">{{ res.strings('privileges_title') }}</span>
|
<mat-icon>share</mat-icon>
|
||||||
<div flexLayout="row" fxLayoutAlign="end center" fxFlex="1 1 auto" fxLayoutGap="10px">
|
<span>{{ res.strings('privileges_title') }}</span>
|
||||||
<button mat-icon-button [matTooltip]="res.strings('privileges_add_tooltip')" (click)="onAdd()" [disabled]="loading.getValue() || deleting.getValue()">
|
</div>
|
||||||
<mat-icon>add_circle_outline</mat-icon>
|
<div class="header-actions">
|
||||||
|
<button mat-icon-button
|
||||||
|
[matTooltip]="res.strings('privileges_add_tooltip')"
|
||||||
|
(click)="onAdd()"
|
||||||
|
[disabled]="loading.getValue() || deleting.getValue()">
|
||||||
|
<mat-icon>add_circle_outline</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</app-content-header>
|
||||||
|
|
||||||
</mat-toolbar>
|
<main class="mat-elevation-z2">
|
||||||
<div class="mat-elevation-z2">
|
|
||||||
<ng-container *ngIf="loading.getValue() || deleting.getValue()">
|
<ng-container *ngIf="loading.getValue() || deleting.getValue()">
|
||||||
<mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar>
|
<mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
@@ -68,6 +73,5 @@
|
|||||||
|
|
||||||
<mat-paginator #paginator [pageSize]="20" [pageSizeOptions]="[1, 10, 20, 50]" [showFirstLastButtons]="true">
|
<mat-paginator #paginator [pageSize]="20" [pageSizeOptions]="[1, 10, 20, 50]" [showFirstLastButtons]="true">
|
||||||
</mat-paginator>
|
</mat-paginator>
|
||||||
</div>
|
</main>
|
||||||
|
</app-content-layout>
|
||||||
</div>
|
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
import { Component, ViewChild, OnInit, OnDestroy, DoCheck, ElementRef } from '@angular/core';
|
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 { PrivilegeService } from '../services/privilege.service';
|
||||||
import { Privilege, PrivilegePage } from '../../api/models';
|
import { Privilege, PrivilegePage } from '../../api/models';
|
||||||
import { DataSource } from '@angular/cdk/table';
|
import { DataSource } from '@angular/cdk/table';
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ import { FormErrorCode, FormErrorEncoder } from '../utils/formcodes';
|
|||||||
import { LoginFieldComponent } from '../widgets/login-field.component';
|
import { LoginFieldComponent } from '../widgets/login-field.component';
|
||||||
import { PasswordFieldComponent } from '../widgets/password-field.component';
|
import { PasswordFieldComponent } from '../widgets/password-field.component';
|
||||||
import { HttpStatusCode } from '../utils/httpcodes';
|
import { HttpStatusCode } from '../utils/httpcodes';
|
||||||
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 { NgForm } from '@angular/forms';
|
||||||
import { NameFieldComponent } from '../widgets/name-field.component';
|
import { NameFieldComponent } from '../widgets/name-field.component';
|
||||||
import { EmailFieldComponent } from '../widgets/email-field.component';
|
import { EmailFieldComponent } from '../widgets/email-field.component';
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ import { FormErrorCode, FormErrorEncoder } from '../utils/formcodes';
|
|||||||
import { LoginFieldComponent } from '../widgets/login-field.component';
|
import { LoginFieldComponent } from '../widgets/login-field.component';
|
||||||
import { PasswordFieldComponent } from '../widgets/password-field.component';
|
import { PasswordFieldComponent } from '../widgets/password-field.component';
|
||||||
import { HttpStatusCode } from '../utils/httpcodes';
|
import { HttpStatusCode } from '../utils/httpcodes';
|
||||||
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 { NgForm } from '@angular/forms';
|
||||||
import { Snackbars } from '../utils/snackbars';
|
import { Snackbars } from '../utils/snackbars';
|
||||||
import { ApiClientService } from '../../api';
|
import { ApiClientService } from '../../api';
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit } from '@angular/core';
|
import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit } from '@angular/core';
|
||||||
import { ApiClientService } from '../../api';
|
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 { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { MessageDialogComponent } from '../widgets/message-dialog.component';
|
import { MessageDialogComponent } from '../widgets/message-dialog.component';
|
||||||
import { HttpErrorResponse } from '@angular/common/http';
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
|
|||||||
@@ -0,0 +1,173 @@
|
|||||||
|
<app-content-layout>
|
||||||
|
<app-content-header [headerClass]="'header-transparent'">
|
||||||
|
<div class="header-title">
|
||||||
|
<mat-icon>access_time_icon</mat-icon>
|
||||||
|
<span>{{ res.strings('time_sheet_title') }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="header-actions">
|
||||||
|
<button mat-icon-button
|
||||||
|
[matTooltip]="res.strings('time_sheet_update_btn_tooltip')"
|
||||||
|
(click)="updateTimeSheetTable()">
|
||||||
|
<mat-icon>update_icon</mat-icon>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button mat-icon-button
|
||||||
|
[matMenuTriggerFor]="exportMenu"
|
||||||
|
[matTooltip]="res.strings('time_sheet_export_btn_tooltip')">
|
||||||
|
<mat-icon>import_export</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>
|
||||||
|
</div>
|
||||||
|
</app-content-header>
|
||||||
|
|
||||||
|
<!-- Configuration Side Panel -->
|
||||||
|
<aside>
|
||||||
|
<mat-list>
|
||||||
|
<mat-list-item class="flex-vrt-center">
|
||||||
|
<h3 mat-subheader>{{ res.strings('time_sheet_config_label') }}</h3>
|
||||||
|
</mat-list-item>
|
||||||
|
<mat-list-item class="flex-vrt-center">
|
||||||
|
<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-list-item class="vrt-margin">
|
||||||
|
<mat-form-field class="hrz-margin" [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-list-item>
|
||||||
|
<mat-list-item class="vrt-margin">
|
||||||
|
<mat-form-field class="hrz-margin" [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-list-item>
|
||||||
|
<mat-list-item class="vrt-margin">
|
||||||
|
<mat-form-field class="hrz-margin" [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-item>
|
||||||
|
|
||||||
|
<mat-divider class="divider"></mat-divider>
|
||||||
|
|
||||||
|
<mat-list-item class="flex-vrt-center">
|
||||||
|
<button mat-subheader mat-button (click)="openWorkPlacesDialog()">
|
||||||
|
<mat-icon class="icon-button">list_icon</mat-icon>
|
||||||
|
<span>{{ res.strings('time_sheet_workplace_button') }}</span>
|
||||||
|
</button>
|
||||||
|
</mat-list-item>
|
||||||
|
<ng-container *ngIf="workPlaces.length > 0">
|
||||||
|
<mat-divider class="divider"></mat-divider>
|
||||||
|
|
||||||
|
<mat-list-item class="hrz-margin" *ngFor="let workPlace of workPlaces">
|
||||||
|
<button mat-icon-button (click)="deleteWorkPlaceEntry(workPlace)">
|
||||||
|
<mat-icon class="icon-button">clear_icon</mat-icon>
|
||||||
|
</button>
|
||||||
|
<span>{{ getWorkplaceName(workPlace) }}</span>
|
||||||
|
</mat-list-item>
|
||||||
|
|
||||||
|
<mat-divider class="divider"></mat-divider>
|
||||||
|
|
||||||
|
<mat-list-item>
|
||||||
|
<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>
|
||||||
|
</mat-list-item>
|
||||||
|
</ng-container>
|
||||||
|
</mat-list>
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
<!-- Table Content -->
|
||||||
|
<main class="mat-elevation-z2">
|
||||||
|
<ng-container *ngIf="false">
|
||||||
|
<mat-progress-bar mode="indeterminate" color="accent"></mat-progress-bar>
|
||||||
|
</ng-container>
|
||||||
|
<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>
|
||||||
|
</main>
|
||||||
|
</app-content-layout>
|
||||||
@@ -0,0 +1,196 @@
|
|||||||
|
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.
|
||||||
|
*
|
||||||
|
* @author Adriano
|
||||||
|
*/
|
||||||
|
@Component({
|
||||||
|
selector: 'app-time-sheet',
|
||||||
|
templateUrl: './time-sheet.component.html',
|
||||||
|
styles: [
|
||||||
|
`mat-list .hrz-margin { width: 100%; margin-left: 32px; margin-right: 32px; }`,
|
||||||
|
`mat-list .vrt-margin { margin-top: 20px; margin-bottom: 20px; }`,
|
||||||
|
`mat-list .divider { margin: 16px; }`,
|
||||||
|
`.main-table { width: 100%; }`,
|
||||||
|
`.main-table .mat-column-date { width: 16% !important; }`,
|
||||||
|
`.main-table .mat-column-to-time, .mat-column-from-time { width: 7% !important; }`,
|
||||||
|
`.main-table .mat-column-time { width: 10% !important; }`,
|
||||||
|
`.main-table .mat-column-device { width: 20% !important; }`,
|
||||||
|
`.main-table .mat-column-place { width: 40% !important; }`
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class TimeSheetComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||||
|
|
||||||
|
private static readonly LAYOUT_BREAKPOINT = 960;
|
||||||
|
static readonly normalDisplayCol = ['date', 'from-time', 'to-time', 'time', 'device', 'place'];
|
||||||
|
static readonly compactDisplayCol = ['date', 'time'];
|
||||||
|
readonly breakTimeOptions = [5, 10, 15, 20, 30, 45, 60, 90, 120, 150, 180];
|
||||||
|
|
||||||
|
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||||
|
|
||||||
|
compact = false;
|
||||||
|
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(d => d.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,116 +1,111 @@
|
|||||||
<ng-container *ngIf="idle | async;else progressBar">
|
<app-content-layout *ngIf="idle | async;else progressBar">
|
||||||
<div *ngIf="user | async as u;else progressBar" style="flex: 1 1 100%;">
|
<app-content-header [headerClass]="'header-transparent'">
|
||||||
<mat-toolbar style="margin-top:20px;background:transparent">
|
<div class="header-title">
|
||||||
<mat-icon style="margin-left:20px;">perm_identity</mat-icon>
|
<mat-icon>perm_identity</mat-icon>
|
||||||
<span style="margin-left: 10px">{{ res.strings('user_title') }}</span>
|
<span>{{ res.strings('user_title') }}</span>
|
||||||
</mat-toolbar>
|
</div>
|
||||||
<mat-grid-list [cols]="columns" gutterSize="10" rowHeight="350" class="grid-layout">
|
</app-content-header>
|
||||||
<mat-grid-tile>
|
|
||||||
<mat-card class="mat-typography" class="user-card">
|
<main *ngIf="user | async as u;else progressBar" class="flex-row-wrap justify-space-evenly">
|
||||||
<mat-card-title-group>
|
<mat-card class="mat-typography" class="user-card">
|
||||||
<mat-card-title>{{ res.strings('user_change_title') }}</mat-card-title>
|
<mat-card-title-group>
|
||||||
<mat-card-subtitle>{{ res.strings('user_change_subtitle') }}</mat-card-subtitle>
|
<mat-card-title>{{ res.strings('user_change_title') }}</mat-card-title>
|
||||||
</mat-card-title-group>
|
<mat-card-subtitle>{{ res.strings('user_change_subtitle') }}</mat-card-subtitle>
|
||||||
<mat-card-content>
|
</mat-card-title-group>
|
||||||
<form #userForm="ngForm">
|
<mat-card-content>
|
||||||
<app-name-field [name]="u.name" (keyup.enter)="userForm.valid && onChangeUser()"></app-name-field>
|
<form #userForm="ngForm">
|
||||||
<mat-form-field style="width: 100%;">
|
<app-name-field [name]="u.name" (keyup.enter)="userForm.valid && onChangeUser()"></app-name-field>
|
||||||
<mat-select [placeholder]="res.strings('user_change_primary')" name="email" [(ngModel)]="correspondence" style="width: 100%;">
|
<mat-form-field style="width: 100%;">
|
||||||
<mat-select-trigger>
|
<mat-select [placeholder]="res.strings('user_change_primary')" name="email" [(ngModel)]="correspondence" style="width: 100%;">
|
||||||
{{ correspondence.address }}
|
<mat-select-trigger>
|
||||||
</mat-select-trigger>
|
{{ correspondence.address }}
|
||||||
<ng-container *ngFor="let email of emails">
|
</mat-select-trigger>
|
||||||
<mat-option [value]="email" [disabled]="!email.verified">
|
<ng-container *ngFor="let email of emails">
|
||||||
<mat-icon class="icon-button">{{ email.verified?"mail":"send" }}</mat-icon>{{email.address}}
|
<mat-option [value]="email" [disabled]="!email.verified">
|
||||||
</mat-option>
|
<mat-icon class="icon-button">{{ email.verified?"mail":"send" }}</mat-icon>{{email.address}}
|
||||||
</ng-container>
|
</mat-option>
|
||||||
</mat-select>
|
|
||||||
</mat-form-field>
|
|
||||||
</form>
|
|
||||||
</mat-card-content>
|
|
||||||
<mat-card-actions fxFlexLayout="row" fxLayoutAlign="space-around center">
|
|
||||||
<button #loginButton mat-raised-button color="primary" [disabled]="userForm.pristine || userForm.invalid" (click)="onChangeUser()">
|
|
||||||
<mat-icon class="icon-button">save</mat-icon>
|
|
||||||
<span>{{ res.strings('button_save') }}</span>
|
|
||||||
</button>
|
|
||||||
</mat-card-actions>
|
|
||||||
</mat-card>
|
|
||||||
</mat-grid-tile>
|
|
||||||
<mat-grid-tile>
|
|
||||||
<mat-card class="mat-typography" class="user-card">
|
|
||||||
<mat-card-title>{{ res.strings('user_password_title') }}</mat-card-title>
|
|
||||||
<mat-card-subtitle>{{ res.strings('user_password_subtitle') }}</mat-card-subtitle>
|
|
||||||
<mat-card-content class="caption" style="flex:1">
|
|
||||||
<form #passwordForm="ngForm">
|
|
||||||
<app-password-field #oldPassword name="oldPassword" [label]="res.strings('user_password_old')" [hint]="res.strings('user_password_old_hint')"></app-password-field>
|
|
||||||
<app-password-field #newPassword name="newPassword" [label]="res.strings('user_password_new')" [hint]="res.strings('user_password_new_hint')" (keyup.enter)="passwordForm.valid && onChangePassword()"></app-password-field>
|
|
||||||
</form>
|
|
||||||
</mat-card-content>
|
|
||||||
<mat-card-actions fxFlexLayout="row" fxLayoutAlign="space-around center">
|
|
||||||
<button mat-raised-button color="primary" (click)="onChangePassword()" [disabled]="passwordForm.pristine || passwordForm.invalid">
|
|
||||||
<mat-icon class="icon-button">lock_outline</mat-icon>
|
|
||||||
<span>{{ res.strings('button_change') }}</span>
|
|
||||||
</button>
|
|
||||||
</mat-card-actions>
|
|
||||||
</mat-card>
|
|
||||||
</mat-grid-tile>
|
|
||||||
<mat-grid-tile>
|
|
||||||
<mat-card class="mat-typography" class="user-card">
|
|
||||||
<mat-card-title>{{ res.strings('user_add_email_title') }}</mat-card-title>
|
|
||||||
<mat-card-subtitle>{{ res.strings('user_add_email_subtitle') }}</mat-card-subtitle>
|
|
||||||
<mat-card-content class="caption" style="flex:1">
|
|
||||||
<form #emailForm="ngForm">
|
|
||||||
<app-email-field (keyup.enter)="emailForm.valid && onAddEmail()"></app-email-field>
|
|
||||||
</form>
|
|
||||||
<div style="height:70px"></div>
|
|
||||||
</mat-card-content>
|
|
||||||
<mat-card-actions fxFlexLayout="row" fxLayoutAlign="space-around center">
|
|
||||||
<button mat-raised-button color="primary" (click)="onAddEmail()" [disabled]="emailForm.pristine || emailForm.invalid">
|
|
||||||
<mat-icon class="icon-button">add</mat-icon>
|
|
||||||
<span>{{ res.strings('button_add') }}</span>
|
|
||||||
</button>
|
|
||||||
</mat-card-actions>
|
|
||||||
</mat-card>
|
|
||||||
</mat-grid-tile>
|
|
||||||
<mat-grid-tile>
|
|
||||||
<mat-card class="mat-typography" class="user-card">
|
|
||||||
<mat-card-title>{{ res.strings('user_del_email_title') }}</mat-card-title>
|
|
||||||
<mat-card-subtitle>{{ res.strings('user_del_email_subtitle') }}</mat-card-subtitle>
|
|
||||||
<mat-card-content class="caption" style="flex:1">
|
|
||||||
<mat-list class="mat-typography">
|
|
||||||
<ng-container *ngFor="let e of emails">
|
|
||||||
<ng-container *ngIf="!e.correspondence">
|
|
||||||
<mat-list-item>
|
|
||||||
<button mat-icon-button [matTooltip]="res.strings('user_del_email_tooltip')" (click)="onDeleteEmail(e.id)">
|
|
||||||
<mat-icon>delete</mat-icon>
|
|
||||||
</button>{{ e.address }}</mat-list-item>
|
|
||||||
</ng-container>
|
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</mat-list>
|
</mat-select>
|
||||||
</mat-card-content>
|
</mat-form-field>
|
||||||
</mat-card>
|
</form>
|
||||||
</mat-grid-tile>
|
</mat-card-content>
|
||||||
<mat-grid-tile>
|
<mat-card-actions class="flex-vrt-center">
|
||||||
<mat-card class="mat-typography" class="user-card">
|
<button #loginButton mat-raised-button color="primary" [disabled]="userForm.pristine || userForm.invalid" (click)="onChangeUser()">
|
||||||
<mat-card-title>{{ res.strings('user_delete_title') }}</mat-card-title>
|
<mat-icon class="icon-button">save</mat-icon>
|
||||||
<mat-card-subtitle>{{ res.strings('user_delete_subtitle') }}</mat-card-subtitle>
|
<span>{{ res.strings('button_save') }}</span>
|
||||||
<mat-card-content class="caption" style="flex:1">
|
</button>
|
||||||
<form #deleteForm="ngForm">
|
</mat-card-actions>
|
||||||
<app-password-field #deletePassword name="deletePassword" [label]="res.strings('user_delete_password')" [hint]="res.strings('user_delete_password_hint')" (keyup.enter)="deleteForm.valid && onDeleteUser()"></app-password-field>
|
</mat-card>
|
||||||
</form>
|
|
||||||
<div style="height:70px"></div>
|
<mat-card class="mat-typography" class="user-card">
|
||||||
</mat-card-content>
|
<mat-card-title>{{ res.strings('user_password_title') }}</mat-card-title>
|
||||||
<mat-card-actions fxFlexLayout="row" fxLayoutAlign="space-around center">
|
<mat-card-subtitle>{{ res.strings('user_password_subtitle') }}</mat-card-subtitle>
|
||||||
<button mat-raised-button color="primary" (click)="onDeleteUser()" [disabled]="deleteForm.pristine || deleteForm.invalid">
|
<mat-card-content class="caption" style="flex:1">
|
||||||
<mat-icon class="icon-button">delete</mat-icon>
|
<form #passwordForm="ngForm">
|
||||||
<span>{{ res.strings('button_delete') }}</span>
|
<app-password-field #oldPassword name="oldPassword" [label]="res.strings('user_password_old')" [hint]="res.strings('user_password_old_hint')"></app-password-field>
|
||||||
</button>
|
<app-password-field #newPassword name="newPassword" [label]="res.strings('user_password_new')" [hint]="res.strings('user_password_new_hint')" (keyup.enter)="passwordForm.valid && onChangePassword()"></app-password-field>
|
||||||
</mat-card-actions>
|
</form>
|
||||||
</mat-card>
|
</mat-card-content>
|
||||||
</mat-grid-tile>
|
<mat-card-actions class="flex-vrt-center">
|
||||||
</mat-grid-list>
|
<button mat-raised-button color="primary" (click)="onChangePassword()" [disabled]="passwordForm.pristine || passwordForm.invalid">
|
||||||
</div>
|
<mat-icon class="icon-button">lock_outline</mat-icon>
|
||||||
</ng-container>
|
<span>{{ res.strings('button_change') }}</span>
|
||||||
|
</button>
|
||||||
|
</mat-card-actions>
|
||||||
|
</mat-card>
|
||||||
|
|
||||||
|
<mat-card class="mat-typography" class="user-card">
|
||||||
|
<mat-card-title>{{ res.strings('user_add_email_title') }}</mat-card-title>
|
||||||
|
<mat-card-subtitle>{{ res.strings('user_add_email_subtitle') }}</mat-card-subtitle>
|
||||||
|
<mat-card-content class="caption" style="flex:1">
|
||||||
|
<form #emailForm="ngForm">
|
||||||
|
<app-email-field (keyup.enter)="emailForm.valid && onAddEmail()"></app-email-field>
|
||||||
|
</form>
|
||||||
|
<div style="height:70px"></div>
|
||||||
|
</mat-card-content>
|
||||||
|
<mat-card-actions class="flex-vrt-center">
|
||||||
|
<button mat-raised-button color="primary" (click)="onAddEmail()" [disabled]="emailForm.pristine || emailForm.invalid">
|
||||||
|
<mat-icon class="icon-button">add</mat-icon>
|
||||||
|
<span>{{ res.strings('button_add') }}</span>
|
||||||
|
</button>
|
||||||
|
</mat-card-actions>
|
||||||
|
</mat-card>
|
||||||
|
|
||||||
|
<mat-card class="mat-typography" class="user-card">
|
||||||
|
<mat-card-title>{{ res.strings('user_del_email_title') }}</mat-card-title>
|
||||||
|
<mat-card-subtitle>{{ res.strings('user_del_email_subtitle') }}</mat-card-subtitle>
|
||||||
|
<mat-card-content class="caption" style="flex:1">
|
||||||
|
<mat-list class="mat-typography">
|
||||||
|
<ng-container *ngFor="let e of emails">
|
||||||
|
<ng-container *ngIf="!e.correspondence">
|
||||||
|
<mat-list-item>
|
||||||
|
<button mat-icon-button [matTooltip]="res.strings('user_del_email_tooltip')" (click)="onDeleteEmail(e.id)">
|
||||||
|
<mat-icon>delete</mat-icon>
|
||||||
|
</button>{{ e.address }}</mat-list-item>
|
||||||
|
</ng-container>
|
||||||
|
</ng-container>
|
||||||
|
</mat-list>
|
||||||
|
</mat-card-content>
|
||||||
|
</mat-card>
|
||||||
|
|
||||||
|
<mat-card class="mat-typography" class="user-card">
|
||||||
|
<mat-card-title>{{ res.strings('user_delete_title') }}</mat-card-title>
|
||||||
|
<mat-card-subtitle>{{ res.strings('user_delete_subtitle') }}</mat-card-subtitle>
|
||||||
|
<mat-card-content class="caption" style="flex:1">
|
||||||
|
<form #deleteForm="ngForm">
|
||||||
|
<app-password-field #deletePassword name="deletePassword" [label]="res.strings('user_delete_password')" [hint]="res.strings('user_delete_password_hint')" (keyup.enter)="deleteForm.valid && onDeleteUser()"></app-password-field>
|
||||||
|
</form>
|
||||||
|
<div style="height:70px"></div>
|
||||||
|
</mat-card-content>
|
||||||
|
<mat-card-actions class="flex-vrt-center">
|
||||||
|
<button mat-raised-button color="primary" (click)="onDeleteUser()" [disabled]="deleteForm.pristine || deleteForm.invalid">
|
||||||
|
<mat-icon class="icon-button">delete</mat-icon>
|
||||||
|
<span>{{ res.strings('button_delete') }}</span>
|
||||||
|
</button>
|
||||||
|
</mat-card-actions>
|
||||||
|
</mat-card>
|
||||||
|
</main>
|
||||||
|
</app-content-layout>
|
||||||
<ng-template #progressBar>
|
<ng-template #progressBar>
|
||||||
<div fxFlexFill fxLayoutAlign="space-around center">
|
<div fxFlexFill fxLayoutAlign="space-around center">
|
||||||
<mat-spinner [diameter]="100"></mat-spinner>
|
<mat-spinner [diameter]="100"></mat-spinner>
|
||||||
|
|||||||
@@ -6,7 +6,10 @@ import { FormErrorCode, FormErrorEncoder } from '../utils/formcodes';
|
|||||||
import { LoginFieldComponent } from '../widgets/login-field.component';
|
import { LoginFieldComponent } from '../widgets/login-field.component';
|
||||||
import { PasswordFieldComponent } from '../widgets/password-field.component';
|
import { PasswordFieldComponent } from '../widgets/password-field.component';
|
||||||
import { HttpStatusCode } from '../utils/httpcodes';
|
import { HttpStatusCode } from '../utils/httpcodes';
|
||||||
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 { NgForm } from '@angular/forms';
|
||||||
import { Snackbars } from '../utils/snackbars';
|
import { Snackbars } from '../utils/snackbars';
|
||||||
import { User, Email } from '../../api/models';
|
import { User, Email } from '../../api/models';
|
||||||
@@ -23,18 +26,18 @@ import { AuthGuard } from '../guards/auth.guard';
|
|||||||
})
|
})
|
||||||
export class UserComponent implements OnInit, OnDestroy {
|
export class UserComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
@ViewChild(NameFieldComponent, { static: false }) nameField: NameFieldComponent;
|
@ViewChild(NameFieldComponent) nameField: NameFieldComponent;
|
||||||
@ViewChild(MatSelect, { static: false }) emailSelect: MatSelect;
|
@ViewChild(MatSelect) emailSelect: MatSelect;
|
||||||
|
|
||||||
// add email
|
// add email
|
||||||
@ViewChild(EmailFieldComponent, { static: false }) emailField: EmailFieldComponent;
|
@ViewChild(EmailFieldComponent) emailField: EmailFieldComponent;
|
||||||
|
|
||||||
// change passwords
|
// change passwords
|
||||||
@ViewChild('oldPassword', { static: false }) oldPasswordField: PasswordFieldComponent;
|
@ViewChild('oldPassword') oldPasswordField: PasswordFieldComponent;
|
||||||
@ViewChild('newPassword', { static: false }) newPasswordField: PasswordFieldComponent;
|
@ViewChild('newPassword') newPasswordField: PasswordFieldComponent;
|
||||||
|
|
||||||
// delete account
|
// delete account
|
||||||
@ViewChild('deletePassword', { static: false }) deletePasswordField: PasswordFieldComponent;
|
@ViewChild('deletePassword') deletePasswordField: PasswordFieldComponent;
|
||||||
|
|
||||||
readonly idle = new BehaviorSubject<boolean>(true);
|
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 { 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 { Observable } from 'rxjs';
|
||||||
import { ResourceService } from '../services/resource.service';
|
import { ResourceService } from '../services/resource.service';
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Component, Inject } from '@angular/core';
|
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 { Observable } from 'rxjs';
|
||||||
import { LogMessage } from '../../api/models';
|
import { LogMessage } from '../../api/models';
|
||||||
import { ResourceService } from '../services/resource.service';
|
import { ResourceService } from '../services/resource.service';
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Component, OnInit, OnDestroy, ViewChild, AfterContentInit, AfterViewInit, ElementRef } from '@angular/core';
|
import { Component, OnInit, OnDestroy, ViewChild, AfterContentInit, AfterViewInit, ElementRef } from '@angular/core';
|
||||||
import { ApiClientService } from '../../api';
|
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 { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { MessageDialogComponent } from '../widgets/message-dialog.component';
|
import { MessageDialogComponent } from '../widgets/message-dialog.component';
|
||||||
import { HttpErrorResponse } from '@angular/common/http';
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Component, Inject } from '@angular/core';
|
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 { Observable } from 'rxjs';
|
||||||
import { ResourceService } from '../services/resource.service';
|
import { ResourceService } from '../services/resource.service';
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Component, Inject, ViewChild } from '@angular/core';
|
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 { Observable, Subscription } from 'rxjs';
|
||||||
import { NgForm } from '@angular/forms';
|
import { NgForm } from '@angular/forms';
|
||||||
import { ApiClientService } from '../../api';
|
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 { 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 { Observable, Subscription } from 'rxjs';
|
||||||
import { NgForm } from '@angular/forms';
|
import { NgForm } from '@angular/forms';
|
||||||
import { ApiClientService } from '../../api';
|
import { ApiClientService } from '../../api';
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
|||||||
import { AppModule } from './app/app.module';
|
import { AppModule } from './app/app.module';
|
||||||
import { environment } from './environments/environment';
|
import { environment } from './environments/environment';
|
||||||
|
|
||||||
import 'hammerjs';
|
|
||||||
|
|
||||||
if (environment.production) {
|
if (environment.production) {
|
||||||
enableProdMode();
|
enableProdMode();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,10 +145,10 @@ mat-form-field {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.notice-card {
|
.notice-card {
|
||||||
position:relative;
|
position: relative;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
width: 100%;
|
max-width: 100%;
|
||||||
height: 100%;
|
max-height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.notice-card-element {
|
.notice-card-element {
|
||||||
@@ -179,10 +179,11 @@ mat-form-field {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.user-card {
|
.user-card {
|
||||||
flex:1;
|
flex: 1;
|
||||||
max-width:500px;
|
flex-basis: 400px;
|
||||||
min-height:280px;
|
max-width: 500px;
|
||||||
margin:10px;
|
min-height: 280px;
|
||||||
|
margin: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fab position on marker map
|
// fab position on marker map
|
||||||
@@ -203,4 +204,125 @@ mat-form-field {
|
|||||||
.long-checkbox .mat-checkbox-layout {
|
.long-checkbox .mat-checkbox-layout {
|
||||||
padding-top: 20px;
|
padding-top: 20px;
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Basic layout styles
|
||||||
|
.table-page { margin: 10px; }
|
||||||
|
|
||||||
|
.header-transparent { background-color: transparent !important; }
|
||||||
|
|
||||||
|
.flex-spacer { flex-grow: 1; }
|
||||||
|
|
||||||
|
.flex {
|
||||||
|
display: flex !important;
|
||||||
|
&-row {
|
||||||
|
@extend .flex;
|
||||||
|
flex-direction: row !important;
|
||||||
|
&-wrap {
|
||||||
|
@extend .flex-row;
|
||||||
|
flex-wrap: wrap !important;
|
||||||
|
}
|
||||||
|
&-nowrap {
|
||||||
|
@extend .flex-row;
|
||||||
|
flex-wrap: nowrap !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-row-reverse {
|
||||||
|
@extend .flex;
|
||||||
|
flex-direction: row-reverse !important;
|
||||||
|
&-wrap {
|
||||||
|
@extend .flex-row-reverse;
|
||||||
|
flex-wrap: wrap !important;
|
||||||
|
}
|
||||||
|
&-nowrap {
|
||||||
|
@extend .flex-row;
|
||||||
|
flex-wrap: nowrap !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-col {
|
||||||
|
@extend .flex;
|
||||||
|
flex-direction: column !important;
|
||||||
|
&-wrap {
|
||||||
|
@extend .flex-col;
|
||||||
|
flex-wrap: wrap !important;
|
||||||
|
}
|
||||||
|
&-nowrap {
|
||||||
|
@extend .flex-col;
|
||||||
|
flex-wrap: nowrap !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.justify-space-evenly { justify-content: space-evenly !important; }
|
||||||
|
|
||||||
|
.justify-space-between { justify-content: space-between !important; }
|
||||||
|
|
||||||
|
.align-center { align-items: center !important; }
|
||||||
|
|
||||||
|
.flex-vrt-center {
|
||||||
|
@extend .flex-col-nowrap;
|
||||||
|
@extend .align-center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flex-notice-card {
|
||||||
|
@extend .flex;
|
||||||
|
flex: 1 1 400px !important;
|
||||||
|
max-height: 30% !important;
|
||||||
|
padding: 8px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cont-padding: 8px;
|
||||||
|
app-content-layout {
|
||||||
|
div.outer-container {
|
||||||
|
@extend .flex;
|
||||||
|
@extend .flex-col-nowrap;
|
||||||
|
justify-content: flex-start;
|
||||||
|
overflow: hidden;
|
||||||
|
app-content-header {
|
||||||
|
padding-top: $cont-padding;
|
||||||
|
padding-right: $cont-padding;
|
||||||
|
padding-left: $cont-padding;
|
||||||
|
}
|
||||||
|
div.inner-container {
|
||||||
|
@extend .flex;
|
||||||
|
@extend .flex-row-reverse-wrap;
|
||||||
|
height: auto;
|
||||||
|
justify-content: space-evenly;
|
||||||
|
align-items: flex-start;
|
||||||
|
overflow: hidden;
|
||||||
|
padding-right: $cont-padding;
|
||||||
|
padding-bottom: $cont-padding;
|
||||||
|
padding-left: $cont-padding;
|
||||||
|
main {
|
||||||
|
flex: 1 1 600px;
|
||||||
|
}
|
||||||
|
aside {
|
||||||
|
flex: 0 1 350px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
app-content-header {
|
||||||
|
#content-toolbar {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding-top: 20px;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
.header-title {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-around;
|
||||||
|
> * {
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.header-actions > * {
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ContentHeaderComponent } from '../../app/layouts/content-header.component';
|
||||||
|
|
||||||
|
describe('HeaderComponent', () => {
|
||||||
|
let component: ContentHeaderComponent;
|
||||||
|
let fixture: ComponentFixture<ContentHeaderComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ ContentHeaderComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(ContentHeaderComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ContentLayoutComponent } from './../../app/layouts/content-layout.component';
|
||||||
|
|
||||||
|
describe('MainContentComponent', () => {
|
||||||
|
let component: ContentLayoutComponent;
|
||||||
|
let fixture: ComponentFixture<ContentLayoutComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ ContentLayoutComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(ContentLayoutComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||