Compare commits
9 Commits
cf9c73635b
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 525e775d1c | |||
| a92eaf66cf | |||
| 155ccd016e | |||
| d0b2373cc1 | |||
| 72508a60bf | |||
| 00f7b4f1ce | |||
| 5f85074653 | |||
| cdfc779bc8 | |||
| 23b403711d |
13
.env.example
13
.env.example
@@ -41,3 +41,16 @@ MONGODB_ELEMENT_SCRIPT_COLLECTION=element_script
|
||||
# true = Script-Element wird im Editor nicht angezeigt
|
||||
# false = Script-Element ist verfügbar (Standard)
|
||||
HIDE_SCRIPT_BLOCK=false
|
||||
|
||||
# --- KI-Workflow-Assistent ---------------------------------------------------
|
||||
# KI-Funktionalität ein-/ausschalten:
|
||||
# true = KI-Assistent ist im Editor verfügbar
|
||||
# false = KI-Assistent ist deaktiviert (Standard)
|
||||
AI_ENABLED=false
|
||||
|
||||
# API-Key für die Claude API (https://platform.claude.com/settings/keys).
|
||||
# Ohne Key ist der KI-Assistent im Editor deaktiviert.
|
||||
ANTHROPIC_API_KEY=
|
||||
|
||||
# Verwendetes Claude-Modell (Standard: claude-opus-4-8):
|
||||
#ANTHROPIC_MODEL=claude-opus-4-8
|
||||
|
||||
3
.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
3
.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
wrapperVersion=3.3.4
|
||||
distributionType=only-script
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip
|
||||
83
docker_push.sh
Executable file
83
docker_push.sh
Executable file
@@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
readonly SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||
readonly REGISTRY_IMAGE="registry.assecutor.org/ait"
|
||||
readonly BACKEND_DIR="${SCRIPT_DIR}"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Verwendung:
|
||||
./docker_push.sh [x.y.z]
|
||||
|
||||
Beispiel:
|
||||
./docker_push.sh 0.9.13
|
||||
./docker_push.sh
|
||||
|
||||
Voraussetzungen:
|
||||
- Docker Buildx ist installiert
|
||||
- Login zur Registry wurde bereits ausgeführt:
|
||||
docker login registry.assecutor.org
|
||||
|
||||
Ohne Versionsargument wird automatisch die Version aus der pom.xml verwendet.
|
||||
EOF
|
||||
}
|
||||
|
||||
fail() {
|
||||
echo "Fehler: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
require_command() {
|
||||
command -v "$1" >/dev/null 2>&1 || fail "'$1' wurde nicht gefunden."
|
||||
}
|
||||
|
||||
resolve_pom_version() {
|
||||
[[ -x "${BACKEND_DIR}/mvnw" ]] || fail "'${BACKEND_DIR}/mvnw' wurde nicht gefunden oder ist nicht ausführbar."
|
||||
|
||||
local version
|
||||
version="$(
|
||||
cd "${BACKEND_DIR}" && ./mvnw -q -DforceStdout help:evaluate -Dexpression=project.version \
|
||||
| awk 'NF { last = $0 } END { print last }'
|
||||
)"
|
||||
|
||||
[[ -n "${version}" ]] || fail "Version konnte nicht aus der pom.xml ermittelt werden."
|
||||
echo "${version}"
|
||||
}
|
||||
|
||||
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
POM_VERSION="$(resolve_pom_version)"
|
||||
VERSION="${1:-${POM_VERSION}}"
|
||||
|
||||
if [[ ! "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
fail "Versionsnummer muss das Format x.y.z haben."
|
||||
fi
|
||||
|
||||
require_command docker
|
||||
docker buildx version >/dev/null 2>&1 || fail "Docker Buildx ist nicht verfügbar."
|
||||
|
||||
cd "${SCRIPT_DIR}"
|
||||
|
||||
echo "Verwende Release-Version ${VERSION}."
|
||||
echo "Baue Production-JAR für Version ${VERSION} ..."
|
||||
(cd "${BACKEND_DIR}" && ./mvnw -Pproduction -DskipTests package)
|
||||
|
||||
JAR_FILE_REL="target/tasklist-editor-${POM_VERSION}.jar"
|
||||
JAR_FILE_ABS="${BACKEND_DIR}/${JAR_FILE_REL}"
|
||||
[[ -f "${JAR_FILE_ABS}" ]] || fail "Release-JAR wurde nicht gefunden: ${JAR_FILE_ABS}"
|
||||
|
||||
echo "Pushe Image ${REGISTRY_IMAGE}:${VERSION} ..."
|
||||
docker buildx build \
|
||||
--platform linux/amd64 \
|
||||
-f "${BACKEND_DIR}/Dockerfile" \
|
||||
--build-arg "JAR_FILE=${JAR_FILE_REL}" \
|
||||
-t "${REGISTRY_IMAGE}:${VERSION}" \
|
||||
--push \
|
||||
"${BACKEND_DIR}"
|
||||
|
||||
echo "Fertig: ${REGISTRY_IMAGE}:${VERSION}"
|
||||
295
mvnw
vendored
Executable file
295
mvnw
vendored
Executable file
@@ -0,0 +1,295 @@
|
||||
#!/bin/sh
|
||||
# ----------------------------------------------------------------------------
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Apache Maven Wrapper startup batch script, version 3.3.4
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# JAVA_HOME - location of a JDK home dir, required when download maven via java source
|
||||
# MVNW_REPOURL - repo url base for downloading maven distribution
|
||||
# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
|
||||
# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
set -euf
|
||||
[ "${MVNW_VERBOSE-}" != debug ] || set -x
|
||||
|
||||
# OS specific support.
|
||||
native_path() { printf %s\\n "$1"; }
|
||||
case "$(uname)" in
|
||||
CYGWIN* | MINGW*)
|
||||
[ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")"
|
||||
native_path() { cygpath --path --windows "$1"; }
|
||||
;;
|
||||
esac
|
||||
|
||||
# set JAVACMD and JAVACCMD
|
||||
set_java_home() {
|
||||
# For Cygwin and MinGW, ensure paths are in Unix format before anything is touched
|
||||
if [ -n "${JAVA_HOME-}" ]; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ]; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
JAVACCMD="$JAVA_HOME/jre/sh/javac"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
JAVACCMD="$JAVA_HOME/bin/javac"
|
||||
|
||||
if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then
|
||||
echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2
|
||||
echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
JAVACMD="$(
|
||||
'set' +e
|
||||
'unset' -f command 2>/dev/null
|
||||
'command' -v java
|
||||
)" || :
|
||||
JAVACCMD="$(
|
||||
'set' +e
|
||||
'unset' -f command 2>/dev/null
|
||||
'command' -v javac
|
||||
)" || :
|
||||
|
||||
if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then
|
||||
echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# hash string like Java String::hashCode
|
||||
hash_string() {
|
||||
str="${1:-}" h=0
|
||||
while [ -n "$str" ]; do
|
||||
char="${str%"${str#?}"}"
|
||||
h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296))
|
||||
str="${str#?}"
|
||||
done
|
||||
printf %x\\n $h
|
||||
}
|
||||
|
||||
verbose() { :; }
|
||||
[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; }
|
||||
|
||||
die() {
|
||||
printf %s\\n "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
trim() {
|
||||
# MWRAPPER-139:
|
||||
# Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds.
|
||||
# Needed for removing poorly interpreted newline sequences when running in more
|
||||
# exotic environments such as mingw bash on Windows.
|
||||
printf "%s" "${1}" | tr -d '[:space:]'
|
||||
}
|
||||
|
||||
scriptDir="$(dirname "$0")"
|
||||
scriptName="$(basename "$0")"
|
||||
|
||||
# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties
|
||||
while IFS="=" read -r key value; do
|
||||
case "${key-}" in
|
||||
distributionUrl) distributionUrl=$(trim "${value-}") ;;
|
||||
distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;;
|
||||
esac
|
||||
done <"$scriptDir/.mvn/wrapper/maven-wrapper.properties"
|
||||
[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
|
||||
|
||||
case "${distributionUrl##*/}" in
|
||||
maven-mvnd-*bin.*)
|
||||
MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/
|
||||
case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in
|
||||
*AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;;
|
||||
:Darwin*x86_64) distributionPlatform=darwin-amd64 ;;
|
||||
:Darwin*arm64) distributionPlatform=darwin-aarch64 ;;
|
||||
:Linux*x86_64*) distributionPlatform=linux-amd64 ;;
|
||||
*)
|
||||
echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2
|
||||
distributionPlatform=linux-amd64
|
||||
;;
|
||||
esac
|
||||
distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip"
|
||||
;;
|
||||
maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;;
|
||||
*) MVN_CMD="mvn${scriptName#mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
|
||||
esac
|
||||
|
||||
# apply MVNW_REPOURL and calculate MAVEN_HOME
|
||||
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
|
||||
[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}"
|
||||
distributionUrlName="${distributionUrl##*/}"
|
||||
distributionUrlNameMain="${distributionUrlName%.*}"
|
||||
distributionUrlNameMain="${distributionUrlNameMain%-bin}"
|
||||
MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}"
|
||||
MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")"
|
||||
|
||||
exec_maven() {
|
||||
unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || :
|
||||
exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD"
|
||||
}
|
||||
|
||||
if [ -d "$MAVEN_HOME" ]; then
|
||||
verbose "found existing MAVEN_HOME at $MAVEN_HOME"
|
||||
exec_maven "$@"
|
||||
fi
|
||||
|
||||
case "${distributionUrl-}" in
|
||||
*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;;
|
||||
*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;;
|
||||
esac
|
||||
|
||||
# prepare tmp dir
|
||||
if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then
|
||||
clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; }
|
||||
trap clean HUP INT TERM EXIT
|
||||
else
|
||||
die "cannot create temp dir"
|
||||
fi
|
||||
|
||||
mkdir -p -- "${MAVEN_HOME%/*}"
|
||||
|
||||
# Download and Install Apache Maven
|
||||
verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
|
||||
verbose "Downloading from: $distributionUrl"
|
||||
verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
|
||||
|
||||
# select .zip or .tar.gz
|
||||
if ! command -v unzip >/dev/null; then
|
||||
distributionUrl="${distributionUrl%.zip}.tar.gz"
|
||||
distributionUrlName="${distributionUrl##*/}"
|
||||
fi
|
||||
|
||||
# verbose opt
|
||||
__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR=''
|
||||
[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v
|
||||
|
||||
# normalize http auth
|
||||
case "${MVNW_PASSWORD:+has-password}" in
|
||||
'') MVNW_USERNAME='' MVNW_PASSWORD='' ;;
|
||||
has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;;
|
||||
esac
|
||||
|
||||
if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then
|
||||
verbose "Found wget ... using wget"
|
||||
wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl"
|
||||
elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then
|
||||
verbose "Found curl ... using curl"
|
||||
curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl"
|
||||
elif set_java_home; then
|
||||
verbose "Falling back to use Java to download"
|
||||
javaSource="$TMP_DOWNLOAD_DIR/Downloader.java"
|
||||
targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName"
|
||||
cat >"$javaSource" <<-END
|
||||
public class Downloader extends java.net.Authenticator
|
||||
{
|
||||
protected java.net.PasswordAuthentication getPasswordAuthentication()
|
||||
{
|
||||
return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() );
|
||||
}
|
||||
public static void main( String[] args ) throws Exception
|
||||
{
|
||||
setDefault( new Downloader() );
|
||||
java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() );
|
||||
}
|
||||
}
|
||||
END
|
||||
# For Cygwin/MinGW, switch paths to Windows format before running javac and java
|
||||
verbose " - Compiling Downloader.java ..."
|
||||
"$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java"
|
||||
verbose " - Running Downloader.java ..."
|
||||
"$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")"
|
||||
fi
|
||||
|
||||
# If specified, validate the SHA-256 sum of the Maven distribution zip file
|
||||
if [ -n "${distributionSha256Sum-}" ]; then
|
||||
distributionSha256Result=false
|
||||
if [ "$MVN_CMD" = mvnd.sh ]; then
|
||||
echo "Checksum validation is not supported for maven-mvnd." >&2
|
||||
echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
|
||||
exit 1
|
||||
elif command -v sha256sum >/dev/null; then
|
||||
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c - >/dev/null 2>&1; then
|
||||
distributionSha256Result=true
|
||||
fi
|
||||
elif command -v shasum >/dev/null; then
|
||||
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then
|
||||
distributionSha256Result=true
|
||||
fi
|
||||
else
|
||||
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2
|
||||
echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ $distributionSha256Result = false ]; then
|
||||
echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2
|
||||
echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# unzip and move
|
||||
if command -v unzip >/dev/null; then
|
||||
unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip"
|
||||
else
|
||||
tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar"
|
||||
fi
|
||||
|
||||
# Find the actual extracted directory name (handles snapshots where filename != directory name)
|
||||
actualDistributionDir=""
|
||||
|
||||
# First try the expected directory name (for regular distributions)
|
||||
if [ -d "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" ]; then
|
||||
if [ -f "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/bin/$MVN_CMD" ]; then
|
||||
actualDistributionDir="$distributionUrlNameMain"
|
||||
fi
|
||||
fi
|
||||
|
||||
# If not found, search for any directory with the Maven executable (for snapshots)
|
||||
if [ -z "$actualDistributionDir" ]; then
|
||||
# enable globbing to iterate over items
|
||||
set +f
|
||||
for dir in "$TMP_DOWNLOAD_DIR"/*; do
|
||||
if [ -d "$dir" ]; then
|
||||
if [ -f "$dir/bin/$MVN_CMD" ]; then
|
||||
actualDistributionDir="$(basename "$dir")"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
set -f
|
||||
fi
|
||||
|
||||
if [ -z "$actualDistributionDir" ]; then
|
||||
verbose "Contents of $TMP_DOWNLOAD_DIR:"
|
||||
verbose "$(ls -la "$TMP_DOWNLOAD_DIR")"
|
||||
die "Could not find Maven distribution directory in extracted archive"
|
||||
fi
|
||||
|
||||
verbose "Found extracted Maven distribution directory: $actualDistributionDir"
|
||||
printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$actualDistributionDir/mvnw.url"
|
||||
mv -- "$TMP_DOWNLOAD_DIR/$actualDistributionDir" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
|
||||
|
||||
clean || :
|
||||
exec_maven "$@"
|
||||
189
mvnw.cmd
vendored
Normal file
189
mvnw.cmd
vendored
Normal file
@@ -0,0 +1,189 @@
|
||||
<# : batch portion
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM http://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Apache Maven Wrapper startup batch script, version 3.3.4
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM MVNW_REPOURL - repo url base for downloading maven distribution
|
||||
@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
|
||||
@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0)
|
||||
@SET __MVNW_CMD__=
|
||||
@SET __MVNW_ERROR__=
|
||||
@SET __MVNW_PSMODULEP_SAVE=%PSModulePath%
|
||||
@SET PSModulePath=
|
||||
@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @(
|
||||
IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B)
|
||||
)
|
||||
@SET PSModulePath=%__MVNW_PSMODULEP_SAVE%
|
||||
@SET __MVNW_PSMODULEP_SAVE=
|
||||
@SET __MVNW_ARG0_NAME__=
|
||||
@SET MVNW_USERNAME=
|
||||
@SET MVNW_PASSWORD=
|
||||
@IF NOT "%__MVNW_CMD__%"=="" ("%__MVNW_CMD__%" %*)
|
||||
@echo Cannot start maven from wrapper >&2 && exit /b 1
|
||||
@GOTO :EOF
|
||||
: end batch / begin powershell #>
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
if ($env:MVNW_VERBOSE -eq "true") {
|
||||
$VerbosePreference = "Continue"
|
||||
}
|
||||
|
||||
# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties
|
||||
$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl
|
||||
if (!$distributionUrl) {
|
||||
Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
|
||||
}
|
||||
|
||||
switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) {
|
||||
"maven-mvnd-*" {
|
||||
$USE_MVND = $true
|
||||
$distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip"
|
||||
$MVN_CMD = "mvnd.cmd"
|
||||
break
|
||||
}
|
||||
default {
|
||||
$USE_MVND = $false
|
||||
$MVN_CMD = $script -replace '^mvnw','mvn'
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
# apply MVNW_REPOURL and calculate MAVEN_HOME
|
||||
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
|
||||
if ($env:MVNW_REPOURL) {
|
||||
$MVNW_REPO_PATTERN = if ($USE_MVND -eq $False) { "/org/apache/maven/" } else { "/maven/mvnd/" }
|
||||
$distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace "^.*$MVNW_REPO_PATTERN",'')"
|
||||
}
|
||||
$distributionUrlName = $distributionUrl -replace '^.*/',''
|
||||
$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$',''
|
||||
|
||||
$MAVEN_M2_PATH = "$HOME/.m2"
|
||||
if ($env:MAVEN_USER_HOME) {
|
||||
$MAVEN_M2_PATH = "$env:MAVEN_USER_HOME"
|
||||
}
|
||||
|
||||
if (-not (Test-Path -Path $MAVEN_M2_PATH)) {
|
||||
New-Item -Path $MAVEN_M2_PATH -ItemType Directory | Out-Null
|
||||
}
|
||||
|
||||
$MAVEN_WRAPPER_DISTS = $null
|
||||
if ((Get-Item $MAVEN_M2_PATH).Target[0] -eq $null) {
|
||||
$MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists"
|
||||
} else {
|
||||
$MAVEN_WRAPPER_DISTS = (Get-Item $MAVEN_M2_PATH).Target[0] + "/wrapper/dists"
|
||||
}
|
||||
|
||||
$MAVEN_HOME_PARENT = "$MAVEN_WRAPPER_DISTS/$distributionUrlNameMain"
|
||||
$MAVEN_HOME_NAME = ([System.Security.Cryptography.SHA256]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join ''
|
||||
$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME"
|
||||
|
||||
if (Test-Path -Path "$MAVEN_HOME" -PathType Container) {
|
||||
Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME"
|
||||
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
|
||||
exit $?
|
||||
}
|
||||
|
||||
if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) {
|
||||
Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl"
|
||||
}
|
||||
|
||||
# prepare tmp dir
|
||||
$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile
|
||||
$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir"
|
||||
$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null
|
||||
trap {
|
||||
if ($TMP_DOWNLOAD_DIR.Exists) {
|
||||
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
|
||||
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
|
||||
}
|
||||
}
|
||||
|
||||
New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null
|
||||
|
||||
# Download and Install Apache Maven
|
||||
Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
|
||||
Write-Verbose "Downloading from: $distributionUrl"
|
||||
Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
|
||||
|
||||
$webclient = New-Object System.Net.WebClient
|
||||
if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) {
|
||||
$webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD)
|
||||
}
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null
|
||||
|
||||
# If specified, validate the SHA-256 sum of the Maven distribution zip file
|
||||
$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum
|
||||
if ($distributionSha256Sum) {
|
||||
if ($USE_MVND) {
|
||||
Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties."
|
||||
}
|
||||
Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash
|
||||
if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) {
|
||||
Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property."
|
||||
}
|
||||
}
|
||||
|
||||
# unzip and move
|
||||
Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null
|
||||
|
||||
# Find the actual extracted directory name (handles snapshots where filename != directory name)
|
||||
$actualDistributionDir = ""
|
||||
|
||||
# First try the expected directory name (for regular distributions)
|
||||
$expectedPath = Join-Path "$TMP_DOWNLOAD_DIR" "$distributionUrlNameMain"
|
||||
$expectedMvnPath = Join-Path "$expectedPath" "bin/$MVN_CMD"
|
||||
if ((Test-Path -Path $expectedPath -PathType Container) -and (Test-Path -Path $expectedMvnPath -PathType Leaf)) {
|
||||
$actualDistributionDir = $distributionUrlNameMain
|
||||
}
|
||||
|
||||
# If not found, search for any directory with the Maven executable (for snapshots)
|
||||
if (!$actualDistributionDir) {
|
||||
Get-ChildItem -Path "$TMP_DOWNLOAD_DIR" -Directory | ForEach-Object {
|
||||
$testPath = Join-Path $_.FullName "bin/$MVN_CMD"
|
||||
if (Test-Path -Path $testPath -PathType Leaf) {
|
||||
$actualDistributionDir = $_.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$actualDistributionDir) {
|
||||
Write-Error "Could not find Maven distribution directory in extracted archive"
|
||||
}
|
||||
|
||||
Write-Verbose "Found extracted Maven distribution directory: $actualDistributionDir"
|
||||
Rename-Item -Path "$TMP_DOWNLOAD_DIR/$actualDistributionDir" -NewName $MAVEN_HOME_NAME | Out-Null
|
||||
try {
|
||||
Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null
|
||||
} catch {
|
||||
if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) {
|
||||
Write-Error "fail to move MAVEN_HOME"
|
||||
}
|
||||
} finally {
|
||||
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
|
||||
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
|
||||
}
|
||||
|
||||
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
|
||||
9
pom.xml
9
pom.xml
@@ -13,7 +13,7 @@
|
||||
|
||||
<groupId>de.assecutor</groupId>
|
||||
<artifactId>tasklist-editor</artifactId>
|
||||
<version>0.2.0</version>
|
||||
<version>0.9.2</version>
|
||||
<name>TaskList Editor</name>
|
||||
<description>n8n-inspired editor for task list workflows</description>
|
||||
|
||||
@@ -57,6 +57,13 @@
|
||||
<version>4.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Offizielles Anthropic-SDK: KI-Workflow-Assistent (Claude API). -->
|
||||
<dependency>
|
||||
<groupId>com.anthropic</groupId>
|
||||
<artifactId>anthropic-java</artifactId>
|
||||
<version>2.48.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
|
||||
@@ -181,6 +181,70 @@ if (Drawflow && Drawflow.prototype) {
|
||||
|
||||
const editors = new WeakMap();
|
||||
|
||||
// --- Undo-Historie ---------------------------------------------------------
|
||||
// Nach jeder Canvas-Änderung wird ein Schnappschuss (Drawflow-Export)
|
||||
// abgelegt; Strg+Z bzw. der Rückgängig-Button stellt den vorherigen
|
||||
// Schnappschuss wieder her. Es sind maximal UNDO_LIMIT Schritte rücknehmbar.
|
||||
const UNDO_LIMIT = 10;
|
||||
|
||||
function currentSnapshot(state) {
|
||||
return JSON.stringify(state.editor.export());
|
||||
}
|
||||
|
||||
// Legt (um einen Tick verzögert) einen Schnappschuss ab. Mehrere Drawflow-
|
||||
// Events derselben Benutzeraktion (z. B. Knoten löschen inkl. seiner
|
||||
// Verbindungen) werden so zu einem einzigen Undo-Schritt zusammengefasst.
|
||||
function recordHistory(state) {
|
||||
if (state.undoSuppressed || state.undoScheduled) return;
|
||||
state.undoScheduled = true;
|
||||
setTimeout(() => {
|
||||
state.undoScheduled = false;
|
||||
if (state.undoSuppressed) return;
|
||||
const snap = currentSnapshot(state);
|
||||
const stack = state.history;
|
||||
if (stack.length && stack[stack.length - 1] === snap) return;
|
||||
stack.push(snap);
|
||||
// Basiszustand + UNDO_LIMIT rücknehmbare Schritte behalten.
|
||||
if (stack.length > UNDO_LIMIT + 1) stack.shift();
|
||||
}, 0);
|
||||
}
|
||||
|
||||
// Setzt die Historie auf den aktuellen Zustand als neuen Basiszustand zurück
|
||||
// (z. B. nach dem Laden eines gespeicherten Canvas).
|
||||
function resetHistory(state) {
|
||||
state.history = [currentSnapshot(state)];
|
||||
}
|
||||
|
||||
// Stellt den vorherigen Schnappschuss wieder her; liefert false, wenn es
|
||||
// nichts zurückzunehmen gibt.
|
||||
function undoLast(state) {
|
||||
const stack = state.history;
|
||||
if (!stack || stack.length < 2) return false;
|
||||
stack.pop(); // aktueller Zustand
|
||||
const previous = stack[stack.length - 1];
|
||||
state.undoSuppressed = true;
|
||||
try {
|
||||
state.editor.import(JSON.parse(previous));
|
||||
} finally {
|
||||
state.undoSuppressed = false;
|
||||
}
|
||||
notifyCanvasRestored(state);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Meldet dem Server die nach einem Undo vorhandenen Knoten, damit dieser
|
||||
// seine BlockInstances (inkl. der Einstellungen wiederhergestellter Blöcke)
|
||||
// abgleichen kann.
|
||||
function notifyCanvasRestored(state) {
|
||||
if (!state.host || !state.host.$server) return;
|
||||
const data = state.editor.drawflow.drawflow[state.editor.module].data;
|
||||
const nodes = Object.keys(data).map(id => ({
|
||||
id: parseInt(id, 10),
|
||||
typeId: data[id].data ? data[id].data.typeId : null
|
||||
}));
|
||||
state.host.$server.onCanvasRestored(JSON.stringify(nodes));
|
||||
}
|
||||
|
||||
if (!window.__taskListEditorDragInit) {
|
||||
window.__taskListEditorDragInit = true;
|
||||
document.addEventListener('dragstart', e => {
|
||||
@@ -194,6 +258,34 @@ if (!window.__taskListEditorDragInit) {
|
||||
}, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Markiert alle Knoten, deren Ein- oder Ausgänge nicht vollständig verdrahtet
|
||||
* sind, mit der CSS-Klasse {@code node-incomplete} (hellroter Hintergrund).
|
||||
* Start-Knoten (kein Eingang) und Abschluss-Knoten (kein Ausgang) werden anhand
|
||||
* ihrer tatsächlich vorhandenen Ports bewertet.
|
||||
*/
|
||||
function refreshValidity(state) {
|
||||
if (!state) return;
|
||||
const editor = state.editor;
|
||||
const data = editor.drawflow.drawflow[editor.module].data;
|
||||
for (const id in data) {
|
||||
const node = data[id];
|
||||
const incomplete = hasOpenPort(node.inputs) || hasOpenPort(node.outputs);
|
||||
const el = state.container.querySelector('#node-' + id);
|
||||
if (el) el.classList.toggle('node-incomplete', incomplete);
|
||||
}
|
||||
}
|
||||
|
||||
/** Liefert true, wenn mindestens einer der vorhandenen Ports keine Verbindung hat. */
|
||||
function hasOpenPort(ports) {
|
||||
if (!ports) return false;
|
||||
for (const key in ports) {
|
||||
const connections = ports[key] && ports[key].connections;
|
||||
if (!connections || connections.length === 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function buildNodeHtml(label, color) {
|
||||
const safe = String(label).replace(/[<>&"']/g, c => ({
|
||||
'<': '<', '>': '>', '&': '&', '"': '"', "'": '''
|
||||
@@ -233,9 +325,14 @@ function attach(host) {
|
||||
const state = {
|
||||
editor,
|
||||
container,
|
||||
registry: new Map()
|
||||
host,
|
||||
registry: new Map(),
|
||||
history: [],
|
||||
undoSuppressed: false,
|
||||
undoScheduled: false
|
||||
};
|
||||
editors.set(host, state);
|
||||
resetHistory(state);
|
||||
|
||||
// Hindernis-bewusste Linienführung. Reroute-Teilsegmente
|
||||
// (type != 'openclose') nutzen die einfache vertikale Kurve.
|
||||
@@ -256,14 +353,12 @@ function attach(host) {
|
||||
const def = state.registry.get(typeId);
|
||||
if (!def) return;
|
||||
|
||||
const rect = container.getBoundingClientRect();
|
||||
const zoom = editor.zoom;
|
||||
// Greif-Offset abziehen, damit der Knoten an seiner gezogenen Position
|
||||
// liegt (linke obere Ecke wie während des Ziehens, nicht an der Maus).
|
||||
const px = (e.clientX - rect.left - editor.canvas_x - dragGrabOffset.x) / zoom;
|
||||
const py = (e.clientY - rect.top - editor.canvas_y - dragGrabOffset.y) / zoom;
|
||||
|
||||
addNodeInternal(host, def, px, py);
|
||||
// Greif-Offset in Canvas-Einheiten abziehen (nicht in Bildschirm-
|
||||
// Pixeln): So bleibt der Mauszeiger in jeder Zoomstufe an derselben
|
||||
// relativen Stelle im erzeugten Knoten, statt dass der Knoten beim
|
||||
// Herauszoomen um den hochgerechneten Offset neben der Maus landet.
|
||||
const { x, y } = toCanvasPoint(state, e.clientX, e.clientY);
|
||||
addNodeInternal(host, def, x - dragGrabOffset.x, y - dragGrabOffset.y);
|
||||
});
|
||||
|
||||
editor.on('nodeSelected', id => {
|
||||
@@ -325,6 +420,23 @@ function attach(host) {
|
||||
}
|
||||
});
|
||||
|
||||
// Unvollständig verdrahtete Elemente (offener Ein- oder Ausgang) hellrot
|
||||
// markieren. Nach jeder strukturellen Änderung neu bewerten.
|
||||
const refresh = () => requestAnimationFrame(() => refreshValidity(state));
|
||||
editor.on('connectionCreated', refresh);
|
||||
editor.on('connectionRemoved', refresh);
|
||||
editor.on('nodeCreated', refresh);
|
||||
editor.on('nodeRemoved', refresh);
|
||||
editor.on('import', refresh);
|
||||
|
||||
// Undo-Historie: jede strukturelle Änderung erzeugt einen Schnappschuss.
|
||||
const record = () => recordHistory(state);
|
||||
editor.on('nodeCreated', record);
|
||||
editor.on('nodeRemoved', record);
|
||||
editor.on('nodeMoved', record);
|
||||
editor.on('connectionCreated', record);
|
||||
editor.on('connectionRemoved', record);
|
||||
|
||||
// Klick in die Nähe einer Verbindung (auf leerem Canvas-Hintergrund) wählt
|
||||
// diese aus – robuster als das exakte Treffen der dünnen Linie. Läuft in der
|
||||
// Capture-Phase vor Drawflow, um das Verschieben/Deselektieren zu verhindern.
|
||||
@@ -339,49 +451,68 @@ function attach(host) {
|
||||
selectConnection(state, path);
|
||||
}, true);
|
||||
|
||||
// Verschieben von Knoten mit der RECHTEN Maustaste. Drawflow zieht Knoten
|
||||
// nur mit links; das Ziehen mit rechts wird hier eigenständig umgesetzt.
|
||||
// Rechte Maustaste: auf einem Knoten wird der Knoten verschoben (Drawflow
|
||||
// zieht Knoten nur mit links), auf dem freien Canvas wird die gesamte
|
||||
// Ansicht verschoben (Panning).
|
||||
let rightDrag = null;
|
||||
let suppressContextMenu = false;
|
||||
let rightPan = null;
|
||||
container.addEventListener('mousedown', e => {
|
||||
if (e.button !== 2) return;
|
||||
const nodeEl = e.target instanceof Element ? e.target.closest('.drawflow-node') : null;
|
||||
if (!nodeEl) return;
|
||||
e.preventDefault();
|
||||
e.stopPropagation(); // Drawflows eigene (Links-)Drag-Logik nicht auslösen
|
||||
const nodeEl = e.target instanceof Element ? e.target.closest('.drawflow-node') : null;
|
||||
if (nodeEl) {
|
||||
rightDrag = {
|
||||
nodeEl,
|
||||
id: nodeEl.id.replace('node-', ''),
|
||||
lastX: e.clientX,
|
||||
lastY: e.clientY
|
||||
};
|
||||
suppressContextMenu = true;
|
||||
} else {
|
||||
rightPan = { lastX: e.clientX, lastY: e.clientY };
|
||||
}
|
||||
}, true);
|
||||
|
||||
const onRightMove = e => {
|
||||
if (rightPan) {
|
||||
editor.canvas_x += e.clientX - rightPan.lastX;
|
||||
editor.canvas_y += e.clientY - rightPan.lastY;
|
||||
rightPan.lastX = e.clientX;
|
||||
rightPan.lastY = e.clientY;
|
||||
editor.precanvas.style.transform =
|
||||
'translate(' + editor.canvas_x + 'px, ' + editor.canvas_y + 'px) scale(' + editor.zoom + ')';
|
||||
return;
|
||||
}
|
||||
if (!rightDrag) return;
|
||||
const zoom = editor.zoom || 1;
|
||||
const newLeft = rightDrag.nodeEl.offsetLeft + (e.clientX - rightDrag.lastX) / zoom;
|
||||
const newTop = rightDrag.nodeEl.offsetTop + (e.clientY - rightDrag.lastY) / zoom;
|
||||
rightDrag.lastX = e.clientX;
|
||||
rightDrag.lastY = e.clientY;
|
||||
rightDrag.moved = true;
|
||||
rightDrag.nodeEl.style.left = newLeft + 'px';
|
||||
rightDrag.nodeEl.style.top = newTop + 'px';
|
||||
const data = editor.drawflow.drawflow[editor.module].data[rightDrag.id];
|
||||
if (data) { data.pos_x = newLeft; data.pos_y = newTop; }
|
||||
editor.updateConnectionNodes('node-' + rightDrag.id);
|
||||
};
|
||||
const onRightUp = () => { rightDrag = null; };
|
||||
const onRightUp = () => {
|
||||
// Ein per Rechts-Drag verschobener Knoten löst Drawflows nodeMoved
|
||||
// nicht aus -> Undo-Schnappschuss hier ablegen.
|
||||
if (rightDrag && rightDrag.moved) recordHistory(state);
|
||||
rightDrag = null;
|
||||
rightPan = null;
|
||||
};
|
||||
document.addEventListener('mousemove', onRightMove);
|
||||
document.addEventListener('mouseup', onRightUp);
|
||||
|
||||
// Browser-Kontextmenü nach einem Rechts-Ziehen auf einem Knoten unterdrücken.
|
||||
// Rechts dient nur zum Verschieben: Browser-Kontextmenü unterdrücken und
|
||||
// das Event in der Capture-Phase stoppen, bevor Drawflows eigener
|
||||
// contextmenu-Handler das Lösch-"x" am selektierten Knoten einblendet.
|
||||
container.addEventListener('contextmenu', e => {
|
||||
if (suppressContextMenu) {
|
||||
e.preventDefault();
|
||||
suppressContextMenu = false;
|
||||
}
|
||||
});
|
||||
e.stopPropagation();
|
||||
}, true);
|
||||
|
||||
// Zoomen mit dem Mausrad (ohne Strg). Läuft in der Capture-Phase und stoppt
|
||||
// die Propagation, damit Drawflows eigenes Strg+Rad-Zoom nicht zusätzlich
|
||||
@@ -418,8 +549,25 @@ function attach(host) {
|
||||
editor.removeConnection();
|
||||
};
|
||||
document.addEventListener('keydown', deleteSelectedConnection);
|
||||
|
||||
// Strg+Z / Cmd+Z: letzte Canvas-Änderung zurücknehmen. Eingaben in
|
||||
// Textfeldern und geöffneten Dialogen bleiben unangetastet.
|
||||
const undoKeyHandler = e => {
|
||||
if (!(e.ctrlKey || e.metaKey) || e.shiftKey || (e.key !== 'z' && e.key !== 'Z')) return;
|
||||
const active = document.activeElement;
|
||||
if (active && (active.tagName === 'INPUT' || active.tagName === 'TEXTAREA'
|
||||
|| active.isContentEditable
|
||||
|| (active.closest && active.closest('vaadin-dialog-overlay')))) {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
undoLast(state);
|
||||
};
|
||||
document.addEventListener('keydown', undoKeyHandler);
|
||||
|
||||
state.cleanup = () => {
|
||||
document.removeEventListener('keydown', deleteSelectedConnection);
|
||||
document.removeEventListener('keydown', undoKeyHandler);
|
||||
document.removeEventListener('mousemove', onRightMove);
|
||||
document.removeEventListener('mouseup', onRightUp);
|
||||
container.removeEventListener('wheel', onWheelZoom, { capture: true });
|
||||
@@ -429,14 +577,16 @@ function attach(host) {
|
||||
}
|
||||
|
||||
// Wandelt Client-Koordinaten in das (unskalierte) Canvas-Koordinatensystem um,
|
||||
// in dem auch die Verbindungspfade definiert sind.
|
||||
// in dem auch die Verbindungspfade definiert sind. Das Rect des precanvas
|
||||
// enthält bereits translate UND scale (inkl. transform-origin in der Mitte),
|
||||
// daher genügt es, den skalierten Abstand zurückzurechnen.
|
||||
function toCanvasPoint(state, clientX, clientY) {
|
||||
const editor = state.editor;
|
||||
const rect = state.container.getBoundingClientRect();
|
||||
const rect = editor.precanvas.getBoundingClientRect();
|
||||
const zoom = editor.zoom || 1;
|
||||
return {
|
||||
x: (clientX - rect.left - editor.canvas_x) / zoom,
|
||||
y: (clientY - rect.top - editor.canvas_y) / zoom,
|
||||
x: (clientX - rect.left) / zoom,
|
||||
y: (clientY - rect.top) / zoom,
|
||||
zoom
|
||||
};
|
||||
}
|
||||
@@ -543,6 +693,8 @@ window.taskListEditor = {
|
||||
editor.removeNodeOutput(nodeId, `output_${current}`);
|
||||
current--;
|
||||
}
|
||||
recordHistory(state);
|
||||
requestAnimationFrame(() => refreshValidity(state));
|
||||
},
|
||||
updateNodeLabel(host, nodeId, label) {
|
||||
const state = editors.get(host);
|
||||
@@ -551,12 +703,23 @@ window.taskListEditor = {
|
||||
if (!node) return;
|
||||
const html = buildNodeHtml(label, state.registry.get(node.data.typeId)?.color || '#444');
|
||||
state.editor.updateNodeDataFromId(nodeId, { ...node.data, label });
|
||||
// Auch das im Graphen hinterlegte HTML aktualisieren, damit Export,
|
||||
// Laden und Undo den neuen Titel anzeigen.
|
||||
const nodeData = state.editor.drawflow.drawflow[state.editor.module].data[nodeId];
|
||||
if (nodeData) nodeData.html = html;
|
||||
const el = state.container.querySelector(`#node-${nodeId} .drawflow_content_node`);
|
||||
if (el) el.innerHTML = html;
|
||||
recordHistory(state);
|
||||
},
|
||||
undo(host) {
|
||||
const state = editors.get(host);
|
||||
return state ? undoLast(state) : false;
|
||||
},
|
||||
clear(host) {
|
||||
const state = editors.get(host);
|
||||
if (state) state.editor.clear();
|
||||
if (!state) return;
|
||||
state.editor.clear();
|
||||
recordHistory(state);
|
||||
},
|
||||
exportGraph(host) {
|
||||
const state = editors.get(host);
|
||||
@@ -596,6 +759,8 @@ window.taskListEditor = {
|
||||
state.editor.addConnection(ids[i], ids[i + 1], 'output_1', 'input_1');
|
||||
}
|
||||
|
||||
// Frisch geladener Stand ist der neue Basiszustand der Undo-Historie.
|
||||
resetHistory(state);
|
||||
return JSON.stringify(ids);
|
||||
},
|
||||
importGraph(host, graphJson) {
|
||||
@@ -603,6 +768,8 @@ window.taskListEditor = {
|
||||
if (!graphJson) return;
|
||||
try {
|
||||
state.editor.import(JSON.parse(graphJson));
|
||||
// Frisch geladener Stand ist der neue Basiszustand der Undo-Historie.
|
||||
resetHistory(state);
|
||||
} catch (e) {
|
||||
console.error('importGraph failed', e);
|
||||
}
|
||||
|
||||
@@ -261,6 +261,12 @@ body, .tasklist-app {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* Unvollständig verdrahtetes Element (offener Ein- oder Ausgang): hellrot. */
|
||||
.drawflow-node.node-incomplete .task-node {
|
||||
background: #ffdede;
|
||||
border-color: #ef4444;
|
||||
}
|
||||
|
||||
.task-node-gear {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
|
||||
@@ -62,6 +62,16 @@ public class NodeEditor extends Div {
|
||||
getElement().executeJs("window.taskListEditor.clear(this)");
|
||||
}
|
||||
|
||||
/**
|
||||
* Nimmt die letzte Canvas-Änderung zurück (maximal 10 Schritte). Der
|
||||
* Callback erhält {@code true}, wenn ein Schritt zurückgenommen wurde,
|
||||
* sonst {@code false}.
|
||||
*/
|
||||
public void undo(SerializableConsumer<Boolean> callback) {
|
||||
getElement().executeJs("return window.taskListEditor.undo(this)")
|
||||
.then(Boolean.class, callback::accept);
|
||||
}
|
||||
|
||||
/**
|
||||
* Liest den aktuellen Drawflow-Graphen (Knoten + Verbindungen) als
|
||||
* JSON-String aus dem Client und übergibt ihn an den Callback.
|
||||
@@ -115,6 +125,10 @@ public class NodeEditor extends Div {
|
||||
return addListener(NodeRemovedEvent.class, listener);
|
||||
}
|
||||
|
||||
public Registration addCanvasRestoredListener(ComponentEventListener<CanvasRestoredEvent> listener) {
|
||||
return addListener(CanvasRestoredEvent.class, listener);
|
||||
}
|
||||
|
||||
@ClientCallable
|
||||
private void onNodeAdded(int nodeId, String typeId) {
|
||||
fireEvent(new NodeAddedEvent(this, nodeId, typeId));
|
||||
@@ -140,6 +154,11 @@ public class NodeEditor extends Div {
|
||||
fireEvent(new NodeRemovedEvent(this, nodeId));
|
||||
}
|
||||
|
||||
@ClientCallable
|
||||
private void onCanvasRestored(String nodesJson) {
|
||||
fireEvent(new CanvasRestoredEvent(this, nodesJson));
|
||||
}
|
||||
|
||||
public static class NodeAddedEvent extends ComponentEvent<NodeEditor> {
|
||||
private final int nodeId;
|
||||
private final String typeId;
|
||||
@@ -192,4 +211,20 @@ public class NodeEditor extends Div {
|
||||
|
||||
public int nodeId() { return nodeId; }
|
||||
}
|
||||
|
||||
/**
|
||||
* Wird nach einem Undo gefeuert und enthält die danach auf dem Canvas
|
||||
* vorhandenen Knoten als JSON-Array aus Objekten mit {@code id} und
|
||||
* {@code typeId}, damit der Server seinen Zustand abgleichen kann.
|
||||
*/
|
||||
public static class CanvasRestoredEvent extends ComponentEvent<NodeEditor> {
|
||||
private final String nodesJson;
|
||||
|
||||
public CanvasRestoredEvent(NodeEditor source, String nodesJson) {
|
||||
super(source, true);
|
||||
this.nodesJson = nodesJson;
|
||||
}
|
||||
|
||||
public String nodesJson() { return nodesJson; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class BlockTypeRegistry {
|
||||
register(new BlockType(
|
||||
"start",
|
||||
"Start",
|
||||
"Virtuelle Markierung für den Beginn des Workflows (wird nicht exportiert).",
|
||||
"Element für den Beginn des Workflows.",
|
||||
"vaadin:play",
|
||||
"#16a34a",
|
||||
START_TASK_TYPE,
|
||||
@@ -47,7 +47,7 @@ public class BlockTypeRegistry {
|
||||
register(new BlockType(
|
||||
"abschluss",
|
||||
"Abschluss",
|
||||
"Virtuelle Markierung für das Ende des Workflows (wird nicht exportiert).",
|
||||
"Element für das Ende des Workflows.",
|
||||
"vaadin:flag-checkered",
|
||||
"#b91c1c",
|
||||
END_TASK_TYPE,
|
||||
@@ -188,7 +188,7 @@ public class BlockTypeRegistry {
|
||||
11,
|
||||
1, 1,
|
||||
List.of(
|
||||
PropertyDefinition.textArea("choices", "Statusoptionen (eine pro Zeile)"),
|
||||
PropertyDefinition.choiceList("choices", "Statusoptionen"),
|
||||
PropertyDefinition.bool("opt", "Optionale Aufgabe", false),
|
||||
PropertyDefinition.bool("reenter", "Erneut bearbeitbar", false)
|
||||
)
|
||||
@@ -208,7 +208,6 @@ public class BlockTypeRegistry {
|
||||
1, 1,
|
||||
List.of(
|
||||
PropertyDefinition.fieldList("fields", "Textfelder (Titel + Platzhalter)"),
|
||||
PropertyDefinition.bool("opt", "Optionale Aufgabe", false),
|
||||
PropertyDefinition.bool("reenter", "Erneut bearbeitbar", false)
|
||||
)
|
||||
));
|
||||
@@ -223,7 +222,6 @@ public class BlockTypeRegistry {
|
||||
1, 1,
|
||||
List.of(
|
||||
PropertyDefinition.fieldList("fields", "Zahlenfelder (Titel + Platzhalter)"),
|
||||
PropertyDefinition.bool("opt", "Optionale Aufgabe", false),
|
||||
PropertyDefinition.bool("reenter", "Erneut bearbeitbar", false)
|
||||
)
|
||||
));
|
||||
@@ -238,7 +236,6 @@ public class BlockTypeRegistry {
|
||||
1, 1,
|
||||
List.of(
|
||||
PropertyDefinition.nameList("entries", "Name der Checkboxen"),
|
||||
PropertyDefinition.bool("opt", "Optionale Aufgabe", false),
|
||||
PropertyDefinition.bool("reenter", "Erneut bearbeitbar", false)
|
||||
)
|
||||
));
|
||||
|
||||
@@ -5,17 +5,18 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
|
||||
/**
|
||||
* Ein einzelnes Eingabefeld eines Listen-Text-Tasks (Typ 12).
|
||||
* Definiert Titel und Platzhalter eines vom Bearbeiter auszufüllenden
|
||||
* Textfeldes.
|
||||
* Definiert Titel, Platzhalter und Pflichtfeld-Kennzeichen eines vom
|
||||
* Bearbeiter auszufüllenden Textfeldes.
|
||||
*
|
||||
* <p>{@code null}-Felder werden ausgelassen.
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({"title", "placeholder"})
|
||||
@JsonPropertyOrder({"title", "placeholder", "required"})
|
||||
public class FieldDto {
|
||||
|
||||
private String title;
|
||||
private String placeholder;
|
||||
private Boolean required;
|
||||
|
||||
public FieldDto() {
|
||||
}
|
||||
@@ -25,6 +26,14 @@ public class FieldDto {
|
||||
this.placeholder = placeholder;
|
||||
}
|
||||
|
||||
public Boolean getRequired() {
|
||||
return required;
|
||||
}
|
||||
|
||||
public void setRequired(Boolean required) {
|
||||
this.required = required;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
@@ -26,4 +26,8 @@ public record PropertyDefinition(String id, String label, PropertyType type, Obj
|
||||
public static PropertyDefinition nameList(String id, String label) {
|
||||
return new PropertyDefinition(id, label, PropertyType.NAME_LIST, List.of());
|
||||
}
|
||||
|
||||
public static PropertyDefinition choiceList(String id, String label) {
|
||||
return new PropertyDefinition(id, label, PropertyType.CHOICE_LIST, List.of());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,5 +8,10 @@ public enum PropertyType {
|
||||
/** Wiederholbare Liste aus Eingabefeldern mit Titel und Platzhalter. */
|
||||
FIELD_LIST,
|
||||
/** Wiederholbare Liste aus reinen Namens-Einträgen (ein Textfeld je Zeile). */
|
||||
NAME_LIST
|
||||
NAME_LIST,
|
||||
/**
|
||||
* Wiederholbare Liste aus Auswahloptionen (ein Textfeld je Zeile,
|
||||
* ohne Pflichtfeld-Kennzeichen).
|
||||
*/
|
||||
CHOICE_LIST
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.assecutor.tasklisteditor.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
@@ -14,6 +15,10 @@ public class TaskEntryDto {
|
||||
@JsonProperty("query_remark")
|
||||
private boolean queryRemark;
|
||||
|
||||
/** Pflichtfeld-Kennzeichen (nur bei Listen-Tasks gesetzt, sonst ausgelassen). */
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private Boolean required;
|
||||
|
||||
public TaskEntryDto() {
|
||||
}
|
||||
|
||||
@@ -46,4 +51,12 @@ public class TaskEntryDto {
|
||||
public void setQueryRemark(boolean queryRemark) {
|
||||
this.queryRemark = queryRemark;
|
||||
}
|
||||
|
||||
public Boolean getRequired() {
|
||||
return required;
|
||||
}
|
||||
|
||||
public void setRequired(Boolean required) {
|
||||
this.required = required;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,22 @@ public class TaskListExporter {
|
||||
}
|
||||
|
||||
public List<TaskDto> export(String drawflowJson, Map<Integer, BlockInstance> instances) {
|
||||
return export(drawflowJson, instances, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Variante für den KI-Assistenten: enthält auch die virtuellen Start-/
|
||||
* Abschluss-Markierungen (damit das Modell den vollständigen Ablauf sieht
|
||||
* und sie im geänderten Workflow erhält) und verzichtet auf die
|
||||
* Vollständigkeits-Validierung, damit auch unfertige Workflows als
|
||||
* Kontext dienen können.
|
||||
*/
|
||||
public List<TaskDto> exportForAssistant(String drawflowJson, Map<Integer, BlockInstance> instances) {
|
||||
return export(drawflowJson, instances, true);
|
||||
}
|
||||
|
||||
private List<TaskDto> export(String drawflowJson, Map<Integer, BlockInstance> instances,
|
||||
boolean forAssistant) {
|
||||
List<TaskDto> tasks = new ArrayList<>();
|
||||
if (drawflowJson == null || drawflowJson.isBlank()) {
|
||||
return tasks;
|
||||
@@ -51,7 +67,9 @@ public class TaskListExporter {
|
||||
}
|
||||
// Ein vollständiger Workflow muss mit einem Start- und einem Abschluss-
|
||||
// Element gerahmt und beide müssen verdrahtet sein.
|
||||
if (!forAssistant) {
|
||||
validateWorkflow(data, instances);
|
||||
}
|
||||
|
||||
if (!data.isObject() || data.isEmpty()) {
|
||||
return tasks;
|
||||
@@ -67,7 +85,7 @@ public class TaskListExporter {
|
||||
}
|
||||
// Rein virtuelle Blöcke (Start/Abschluss) sind nur Workflow-Markierungen
|
||||
// und gehören nicht in die exportierte Task-Liste.
|
||||
if (instance.type().isVirtual()) {
|
||||
if (!forAssistant && instance.type().isVirtual()) {
|
||||
continue;
|
||||
}
|
||||
TaskDto task = toTask(instance);
|
||||
@@ -86,53 +104,63 @@ public class TaskListExporter {
|
||||
* Meldung, falls die Bedingung verletzt ist
|
||||
*/
|
||||
private void validateWorkflow(JsonNode data, Map<Integer, BlockInstance> instances) {
|
||||
List<Integer> startNodes = new ArrayList<>();
|
||||
List<Integer> endNodes = new ArrayList<>();
|
||||
for (Map.Entry<Integer, BlockInstance> entry : instances.entrySet()) {
|
||||
int taskType = entry.getValue().type().taskType();
|
||||
// Es muss mindestens ein Start- und ein Abschluss-Element geben.
|
||||
boolean hasStart = false;
|
||||
boolean hasEnd = false;
|
||||
for (BlockInstance instance : instances.values()) {
|
||||
int taskType = instance.type().taskType();
|
||||
if (taskType == BlockTypeRegistry.START_TASK_TYPE) {
|
||||
startNodes.add(entry.getKey());
|
||||
hasStart = true;
|
||||
} else if (taskType == BlockTypeRegistry.END_TASK_TYPE) {
|
||||
endNodes.add(entry.getKey());
|
||||
hasEnd = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (startNodes.isEmpty()) {
|
||||
if (!hasStart) {
|
||||
throw new IllegalStateException("Es muss ein Start-Element vorhanden sein.");
|
||||
}
|
||||
if (endNodes.isEmpty()) {
|
||||
if (!hasEnd) {
|
||||
throw new IllegalStateException("Es muss ein Abschluss-Element vorhanden sein.");
|
||||
}
|
||||
for (int id : startNodes) {
|
||||
if (!hasConnectedOutput(data, id)) {
|
||||
throw new IllegalStateException("Das Start-Element muss mit dem Ablauf verbunden sein.");
|
||||
}
|
||||
}
|
||||
for (int id : endNodes) {
|
||||
if (!hasConnectedInput(data, id)) {
|
||||
throw new IllegalStateException("Das Abschluss-Element muss mit dem Ablauf verbunden sein.");
|
||||
|
||||
// Jedes Element muss vollständig verdrahtet sein: jeder vorhandene Ein-
|
||||
// und Ausgang muss mit mindestens einer Linie belegt sein. Start besitzt
|
||||
// nur einen Ausgang, Abschluss nur einen Eingang – nicht vorhandene Ports
|
||||
// werden dabei nicht gefordert.
|
||||
List<String> nodeIds = new ArrayList<>();
|
||||
data.fieldNames().forEachRemaining(nodeIds::add);
|
||||
for (String nodeId : nodeIds) {
|
||||
JsonNode node = data.path(nodeId);
|
||||
if (!allPortsConnected(node.path("inputs")) || !allPortsConnected(node.path("outputs"))) {
|
||||
throw new IllegalStateException(
|
||||
"Jedes Element muss vollständig verbunden sein – „"
|
||||
+ nodeLabel(instances, nodeId)
|
||||
+ "“ hat einen offenen Ein- oder Ausgang.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasConnectedOutput(JsonNode data, int nodeId) {
|
||||
JsonNode outputs = data.path(String.valueOf(nodeId)).path("outputs");
|
||||
for (JsonNode output : outputs) {
|
||||
if (output.path("connections").size() > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/** Prüft, ob alle vorhandenen Ports (Ein- oder Ausgänge) mindestens eine Verbindung haben. */
|
||||
private boolean allPortsConnected(JsonNode ports) {
|
||||
for (JsonNode port : ports) {
|
||||
if (port.path("connections").size() == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean hasConnectedInput(JsonNode data, int nodeId) {
|
||||
JsonNode inputs = data.path(String.valueOf(nodeId)).path("inputs");
|
||||
for (JsonNode input : inputs) {
|
||||
if (input.path("connections").size() > 0) {
|
||||
return true;
|
||||
/** Liefert einen sprechenden Namen eines Knotens für Fehlermeldungen. */
|
||||
private String nodeLabel(Map<Integer, BlockInstance> instances, String nodeId) {
|
||||
try {
|
||||
BlockInstance instance = instances.get(Integer.parseInt(nodeId));
|
||||
if (instance != null) {
|
||||
String topic = instance.topic();
|
||||
return (topic == null || topic.isBlank()) ? instance.type().label() : topic;
|
||||
}
|
||||
} catch (NumberFormatException ignored) {
|
||||
// Fällt auf die Knoten-ID zurück.
|
||||
}
|
||||
return false;
|
||||
return "#" + nodeId;
|
||||
}
|
||||
|
||||
private List<Integer> determineOrder(JsonNode data) {
|
||||
@@ -220,7 +248,10 @@ public class TaskListExporter {
|
||||
}
|
||||
|
||||
if (v.containsKey("choices")) {
|
||||
task.setChoices(parseChoices(asText(v.get("choices"))));
|
||||
Object raw = v.get("choices");
|
||||
task.setChoices(raw instanceof List<?> list
|
||||
? parseChoices(list)
|
||||
: parseChoices(asText(raw)));
|
||||
}
|
||||
|
||||
if (v.containsKey("fields")) {
|
||||
@@ -263,13 +294,30 @@ public class TaskListExporter {
|
||||
if (o instanceof Map<?, ?> m) {
|
||||
String text = m.get("title") == null ? "" : m.get("title").toString().trim();
|
||||
if (!text.isEmpty()) {
|
||||
entries.add(new TaskEntryDto(code++, text, queryRemark));
|
||||
TaskEntryDto entry = new TaskEntryDto(code++, text, queryRemark);
|
||||
entry.setRequired(asBool(m.get("required")));
|
||||
entries.add(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
return entries.isEmpty() ? null : entries;
|
||||
}
|
||||
|
||||
/** Variante für den Zeilen-Editor: Liste aus {@code {title}}-Einträgen. */
|
||||
private List<ChoiceDto> parseChoices(List<?> raw) {
|
||||
List<ChoiceDto> choices = new ArrayList<>();
|
||||
int ret = 1;
|
||||
for (Object o : raw) {
|
||||
if (o instanceof Map<?, ?> m) {
|
||||
String text = m.get("title") == null ? "" : m.get("title").toString().trim();
|
||||
if (!text.isEmpty()) {
|
||||
choices.add(new ChoiceDto(text, ret++));
|
||||
}
|
||||
}
|
||||
}
|
||||
return choices.isEmpty() ? null : choices;
|
||||
}
|
||||
|
||||
private List<ChoiceDto> parseChoices(String raw) {
|
||||
if (raw == null || raw.isBlank()) {
|
||||
return null;
|
||||
@@ -295,7 +343,9 @@ public class TaskListExporter {
|
||||
String title = m.get("title") == null ? "" : m.get("title").toString().trim();
|
||||
String placeholder = m.get("placeholder") == null ? "" : m.get("placeholder").toString().trim();
|
||||
if (!title.isEmpty() || !placeholder.isEmpty()) {
|
||||
fields.add(new FieldDto(title, placeholder));
|
||||
FieldDto field = new FieldDto(title, placeholder);
|
||||
field.setRequired(asBool(m.get("required")));
|
||||
fields.add(field);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package de.assecutor.tasklisteditor.service;
|
||||
|
||||
import de.assecutor.tasklisteditor.model.BlockType;
|
||||
import de.assecutor.tasklisteditor.model.BlockTypeRegistry;
|
||||
import de.assecutor.tasklisteditor.model.ChoiceDto;
|
||||
import de.assecutor.tasklisteditor.model.FieldDto;
|
||||
import de.assecutor.tasklisteditor.model.PropertyDefinition;
|
||||
import de.assecutor.tasklisteditor.model.TaskDto;
|
||||
@@ -69,6 +70,7 @@ public class TaskListImporter {
|
||||
Object value = switch (def.type()) {
|
||||
case FIELD_LIST -> fieldRows(task);
|
||||
case NAME_LIST -> entryRows(task);
|
||||
case CHOICE_LIST -> choiceRows(task);
|
||||
default -> scalarValue(def, task);
|
||||
};
|
||||
values.put(def.id(), value);
|
||||
@@ -103,6 +105,7 @@ public class TaskListImporter {
|
||||
Map<String, Object> row = new LinkedHashMap<>();
|
||||
row.put("title", field.getTitle() == null ? "" : field.getTitle());
|
||||
row.put("placeholder", field.getPlaceholder() == null ? "" : field.getPlaceholder());
|
||||
row.put("required", Boolean.TRUE.equals(field.getRequired()));
|
||||
rows.add(row);
|
||||
}
|
||||
return rows;
|
||||
@@ -117,11 +120,28 @@ public class TaskListImporter {
|
||||
for (TaskEntryDto entry : task.getEntries()) {
|
||||
Map<String, Object> row = new LinkedHashMap<>();
|
||||
row.put("title", entry.getText() == null ? "" : entry.getText());
|
||||
row.put("required", Boolean.TRUE.equals(entry.getRequired()));
|
||||
rows.add(row);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
/** {@code choices}-Array (Typ 11) zurück in Zeilen mit Namen ({@code title}). */
|
||||
private List<Map<String, Object>> choiceRows(TaskDto task) {
|
||||
List<Map<String, Object>> rows = new ArrayList<>();
|
||||
if (task.getChoices() != null && !task.getChoices().isEmpty()) {
|
||||
for (ChoiceDto choice : task.getChoices()) {
|
||||
Map<String, Object> row = new LinkedHashMap<>();
|
||||
row.put("title", choice.getTxt() == null ? "" : choice.getTxt());
|
||||
rows.add(row);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
// Altdaten des früheren Typ 11 (Abhol-/Lieferstatus) liefern die
|
||||
// Optionen als entries; diese als Zeilen übernehmen.
|
||||
return entryRows(task);
|
||||
}
|
||||
|
||||
private Object orDefault(Object value, Object fallback) {
|
||||
return value != null ? value : fallback;
|
||||
}
|
||||
|
||||
@@ -56,6 +56,21 @@ public class TaskListService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Baut das Task-JSON des aktuellen Canvas als Kontext für den
|
||||
* KI-Assistenten: inklusive der Start-/Abschluss-Markierungen und ohne
|
||||
* Vollständigkeits-Validierung, damit auch unfertige Workflows geändert
|
||||
* werden können.
|
||||
*/
|
||||
public String buildAssistantContext(String drawflowJson, Map<Integer, BlockInstance> instances) {
|
||||
List<TaskDto> tasks = exporter.exportForAssistant(drawflowJson, instances);
|
||||
try {
|
||||
return objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(tasks);
|
||||
} catch (JsonProcessingException ex) {
|
||||
throw new IllegalStateException("Task-JSON konnte nicht erzeugt werden: " + ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Baut aus dem Editor-Zustand das app-konforme Task-Array, wie es die
|
||||
* stadtbote-App verarbeitet (entspricht der {@code tasks}-Liste einer Tour).
|
||||
|
||||
@@ -0,0 +1,279 @@
|
||||
package de.assecutor.tasklisteditor.service;
|
||||
|
||||
import com.anthropic.client.AnthropicClient;
|
||||
import com.anthropic.client.okhttp.AnthropicOkHttpClient;
|
||||
import com.anthropic.models.messages.ContentBlock;
|
||||
import com.anthropic.models.messages.Message;
|
||||
import com.anthropic.models.messages.MessageCreateParams;
|
||||
import com.anthropic.models.messages.ThinkingConfigAdaptive;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import de.assecutor.tasklisteditor.model.BlockType;
|
||||
import de.assecutor.tasklisteditor.model.BlockTypeRegistry;
|
||||
import de.assecutor.tasklisteditor.model.PropertyDefinition;
|
||||
import de.assecutor.tasklisteditor.model.TaskDto;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* KI-Workflow-Assistent: Übersetzt frei formulierte Benutzerwünsche
|
||||
* (Reihenfolge der Elemente und deren Einstellungen) per Claude API in das
|
||||
* {@code tasks}-JSON des Editors. Optional wird der aktuelle Workflow als
|
||||
* Kontext mitgegeben, sodass Claude gezielte Änderungen daran vornimmt statt
|
||||
* neu zu erzeugen. Das Ergebnis läuft über die vorhandene Import-Pipeline
|
||||
* ({@link TaskListImporter}) und baut so den Canvas auf.
|
||||
*/
|
||||
@Service
|
||||
public class WorkflowAssistantService {
|
||||
|
||||
private final BlockTypeRegistry registry;
|
||||
private final boolean aiEnabled;
|
||||
private final String apiKey;
|
||||
private final String model;
|
||||
private final ObjectMapper lenientMapper;
|
||||
|
||||
private volatile AnthropicClient client;
|
||||
|
||||
public WorkflowAssistantService(BlockTypeRegistry registry,
|
||||
@Value("${tasklist.ai-enabled:false}") boolean aiEnabled,
|
||||
@Value("${tasklist.anthropic-api-key:}") String apiKey,
|
||||
@Value("${tasklist.anthropic-model:claude-opus-4-8}") String model) {
|
||||
this.registry = registry;
|
||||
this.aiEnabled = aiEnabled;
|
||||
this.apiKey = apiKey == null ? "" : apiKey.trim();
|
||||
this.model = model;
|
||||
this.lenientMapper = new ObjectMapper()
|
||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
}
|
||||
|
||||
/** Ergebnis des Assistenten: Workflow-Name plus Tasks in Reihenfolge. */
|
||||
public record WorkflowDraft(String name, List<TaskDto> tasks) {
|
||||
}
|
||||
|
||||
/** Ob der Assistent nutzbar ist (AI_ENABLED=true und API-Key in der .env). */
|
||||
public boolean isEnabled() {
|
||||
return aiEnabled && !apiKey.isBlank();
|
||||
}
|
||||
|
||||
/**
|
||||
* Erzeugt aus dem Benutzerwunsch einen neuen Workflow-Entwurf. Blockiert
|
||||
* bis zur Antwort der Claude API (typisch einige Sekunden bis wenige
|
||||
* Minuten) und sollte daher außerhalb des UI-Threads aufgerufen werden.
|
||||
*
|
||||
* @throws IllegalStateException wenn kein API-Key konfiguriert ist oder
|
||||
* die Antwort nicht verwertbar ist
|
||||
*/
|
||||
public WorkflowDraft generateWorkflow(String wish) {
|
||||
return generateWorkflow(wish, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Erzeugt oder ändert einen Workflow. Ist {@code currentTasksJson}
|
||||
* gesetzt, erhält Claude den aktuellen Workflow als Kontext, wendet die
|
||||
* beschriebenen Änderungen darauf an und liefert den vollständigen,
|
||||
* aktualisierten Workflow zurück. Blockiert bis zur Antwort der Claude API
|
||||
* und sollte daher außerhalb des UI-Threads aufgerufen werden.
|
||||
*
|
||||
* @param currentName Name des aktuellen Workflows (optional)
|
||||
* @param currentTasksJson Task-JSON des aktuellen Canvas oder {@code null}
|
||||
* für einen neuen Workflow
|
||||
* @throws IllegalStateException wenn kein API-Key konfiguriert ist oder
|
||||
* die Antwort nicht verwertbar ist
|
||||
*/
|
||||
public WorkflowDraft generateWorkflow(String wish, String currentName, String currentTasksJson) {
|
||||
if (!isEnabled()) {
|
||||
throw new IllegalStateException(
|
||||
"KI-Assistent deaktiviert: AI_ENABLED=true und ANTHROPIC_API_KEY "
|
||||
+ "in der .env-Datei setzen.");
|
||||
}
|
||||
if (wish == null || wish.isBlank()) {
|
||||
throw new IllegalStateException("Bitte einen Workflow-Wunsch eingeben.");
|
||||
}
|
||||
|
||||
MessageCreateParams params = MessageCreateParams.builder()
|
||||
.model(model)
|
||||
.maxTokens(16000L)
|
||||
.thinking(ThinkingConfigAdaptive.builder().build())
|
||||
.system(buildSystemPrompt())
|
||||
.addUserMessage(buildUserMessage(wish, currentName, currentTasksJson))
|
||||
.build();
|
||||
|
||||
Message message = client().messages().create(params);
|
||||
String text = extractText(message);
|
||||
if (text.isBlank()) {
|
||||
throw new IllegalStateException("Die KI hat keine verwertbare Antwort geliefert"
|
||||
+ " (Stop-Grund: " + message.stopReason() + ").");
|
||||
}
|
||||
return parseDraft(text);
|
||||
}
|
||||
|
||||
private AnthropicClient client() {
|
||||
AnthropicClient existing = client;
|
||||
if (existing != null) {
|
||||
return existing;
|
||||
}
|
||||
synchronized (this) {
|
||||
if (client == null) {
|
||||
client = AnthropicOkHttpClient.builder()
|
||||
.apiKey(apiKey)
|
||||
.build();
|
||||
}
|
||||
return client;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Baut die Benutzernachricht: nur der Wunsch (neuer Workflow) oder der
|
||||
* aktuelle Workflow als Kontext plus die gewünschten Änderungen.
|
||||
*/
|
||||
private String buildUserMessage(String wish, String currentName, String currentTasksJson) {
|
||||
if (currentTasksJson == null || currentTasksJson.isBlank()) {
|
||||
return wish;
|
||||
}
|
||||
StringBuilder msg = new StringBuilder("Aktueller Workflow");
|
||||
if (currentName != null && !currentName.isBlank()) {
|
||||
msg.append(" „").append(currentName).append('“');
|
||||
}
|
||||
return msg.append(":\n").append(currentTasksJson)
|
||||
.append("\n\nGewünschte Änderungen:\n").append(wish)
|
||||
.toString();
|
||||
}
|
||||
|
||||
private String extractText(Message message) {
|
||||
StringBuilder text = new StringBuilder();
|
||||
for (ContentBlock block : message.content()) {
|
||||
block.text().ifPresent(t -> text.append(t.text()));
|
||||
}
|
||||
return text.toString().trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parst die Modell-Antwort. Erwartet ein JSON-Objekt
|
||||
* {@code {"name": "...", "tasks": [...]}}; Markdown-Zäune und umgebender
|
||||
* Text werden toleriert.
|
||||
*/
|
||||
private WorkflowDraft parseDraft(String text) {
|
||||
String json = extractJsonObject(text);
|
||||
try {
|
||||
JsonNode root = lenientMapper.readTree(json);
|
||||
JsonNode tasksNode = root.path("tasks");
|
||||
if (!tasksNode.isArray() || tasksNode.isEmpty()) {
|
||||
throw new IllegalStateException("Die KI-Antwort enthält kein tasks-Array.");
|
||||
}
|
||||
List<TaskDto> tasks = new ArrayList<>();
|
||||
for (JsonNode taskNode : tasksNode) {
|
||||
tasks.add(lenientMapper.treeToValue(taskNode, TaskDto.class));
|
||||
}
|
||||
String name = root.path("name").asText("");
|
||||
return new WorkflowDraft(name.isBlank() ? null : name, tasks);
|
||||
} catch (IllegalStateException ex) {
|
||||
throw ex;
|
||||
} catch (Exception ex) {
|
||||
throw new IllegalStateException(
|
||||
"Die KI-Antwort konnte nicht als Workflow gelesen werden: " + ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
/** Schneidet das erste JSON-Objekt aus der Antwort (entfernt ```-Zäune u. Ä.). */
|
||||
private String extractJsonObject(String text) {
|
||||
int start = text.indexOf('{');
|
||||
int end = text.lastIndexOf('}');
|
||||
if (start < 0 || end <= start) {
|
||||
throw new IllegalStateException("Die KI-Antwort enthält kein JSON-Objekt.");
|
||||
}
|
||||
return text.substring(start, end + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Baut die Systemanweisung: beschreibt die verfügbaren Elemente (aus der
|
||||
* {@link BlockTypeRegistry}, inkl. benutzerdefinierter Typen) und das
|
||||
* erwartete JSON-Format.
|
||||
*/
|
||||
private String buildSystemPrompt() {
|
||||
StringBuilder prompt = new StringBuilder();
|
||||
prompt.append("""
|
||||
Du bist der Workflow-Assistent eines grafischen Editors für Auftrags-Workflows
|
||||
(Task-Listen der stadtbote-App). Der Benutzer beschreibt in freier Sprache,
|
||||
welche Elemente sein Workflow in welcher Reihenfolge enthalten soll und wie
|
||||
sie eingestellt sein sollen. Du übersetzt das in ein Task-JSON.
|
||||
|
||||
Es gibt zwei Fälle:
|
||||
- Neuer Workflow: Die Nachricht enthält nur die Wünsche des Benutzers.
|
||||
- Änderung: Der Nachricht ist unter „Aktueller Workflow“ das bestehende
|
||||
Task-JSON vorangestellt. Wende die gewünschten Änderungen darauf an und
|
||||
gib den VOLLSTÄNDIGEN aktualisierten Workflow zurück: Übernimm alle nicht
|
||||
betroffenen Tasks unverändert – inklusive aller vorhandenen Felder, auch
|
||||
hier nicht dokumentierter (z. B. "script") –, und vergib die "s_id"-Werte
|
||||
anschließend lückenlos neu ab 1. Auch der geänderte Workflow muss mit dem
|
||||
Start-Marker (type -1) beginnen und mit dem Abschluss-Marker (type -2)
|
||||
enden – ergänze sie, falls sie im aktuellen Workflow fehlen. Behalte den
|
||||
bisherigen Workflow-Namen bei, sofern der Benutzer keinen neuen verlangt.
|
||||
|
||||
Antworte AUSSCHLIESSLICH mit einem einzigen JSON-Objekt in dieser Form,
|
||||
ohne Markdown-Zäune und ohne erklärenden Text:
|
||||
{"name": "<kurzer, sprechender Workflow-Name>", "tasks": [ <Task-Objekte in Ablauf-Reihenfolge> ]}
|
||||
|
||||
Regeln für die Tasks:
|
||||
- Jeder Task hat "s_id" (fortlaufend ab 1), "type" (Typnummer, siehe Liste)
|
||||
und "topic" (kurze, dem Bearbeiter angezeigte Bezeichnung; nutze die Angaben
|
||||
des Benutzers, sonst die Standardbezeichnung des Typs).
|
||||
- Der erste Task ist immer der Start-Marker (type -1, topic "Start"), der
|
||||
letzte immer der Abschluss-Marker (type -2, topic "Abschluss"), sofern der
|
||||
Benutzer nichts anderes verlangt.
|
||||
- Setze nur die Felder, die für den jeweiligen Typ dokumentiert sind, und nur
|
||||
wenn sie vom Standard abweichen oder der Benutzer sie nennt.
|
||||
- "opt" (boolean) markiert eine insgesamt optionale Aufgabe, "reenter"
|
||||
(boolean) erlaubt erneutes Bearbeiten.
|
||||
- Listenfelder:
|
||||
* "fields": Array aus {"title": "...", "placeholder": "...", "required": true|false}
|
||||
(Text-/Zahlenlisten, Typ 12/13).
|
||||
* "entries": Array aus {"code": <fortlaufend ab 1>, "text": "...", "required": true|false}
|
||||
(Checkbox-Liste, Typ 14).
|
||||
* "choices": Array aus {"txt": "...", "ret": <fortlaufend ab 1>}
|
||||
(Statusauswahl, Typ 11).
|
||||
Kennzeichne Einträge nur dann mit "required": true, wenn der Benutzer sie
|
||||
als Pflicht bezeichnet.
|
||||
- Erfinde keine Elemente, die der Benutzer nicht verlangt hat; wähle bei
|
||||
unklaren Angaben die naheliegendste, einfache Lösung.
|
||||
|
||||
Verfügbare Element-Typen:
|
||||
""");
|
||||
|
||||
for (BlockType type : registry.all()) {
|
||||
if ("script".equals(type.id())) {
|
||||
continue; // Script-Blöcke kann der Assistent nicht sinnvoll konfigurieren.
|
||||
}
|
||||
prompt.append("- type ").append(type.taskType())
|
||||
.append(" „").append(type.label()).append('“');
|
||||
if (type.description() != null && !type.description().isBlank()) {
|
||||
prompt.append(": ").append(type.description());
|
||||
}
|
||||
String fields = fieldDocs(type);
|
||||
if (!fields.isEmpty()) {
|
||||
prompt.append(" Felder: ").append(fields);
|
||||
}
|
||||
prompt.append('\n');
|
||||
}
|
||||
return prompt.toString();
|
||||
}
|
||||
|
||||
private String fieldDocs(BlockType type) {
|
||||
List<String> docs = new ArrayList<>();
|
||||
for (PropertyDefinition def : type.properties()) {
|
||||
String doc = switch (def.type()) {
|
||||
case BOOLEAN -> "\"" + def.id() + "\" (boolean – " + def.label() + ")";
|
||||
case NUMBER -> "\"" + def.id() + "\" (Zahl – " + def.label() + ")";
|
||||
case TEXT, TEXTAREA -> "\"" + def.id() + "\" (Text – " + def.label() + ")";
|
||||
case FIELD_LIST -> "\"fields\" (" + def.label() + ")";
|
||||
case NAME_LIST -> "\"entries\" (" + def.label() + ")";
|
||||
case CHOICE_LIST -> "\"choices\" (" + def.label() + ")";
|
||||
};
|
||||
docs.add(doc);
|
||||
}
|
||||
return String.join(", ", docs);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.assecutor.tasklisteditor.view;
|
||||
|
||||
import com.vaadin.flow.component.Component;
|
||||
import com.vaadin.flow.component.UI;
|
||||
import com.vaadin.flow.component.button.Button;
|
||||
import com.vaadin.flow.component.button.ButtonVariant;
|
||||
import com.vaadin.flow.component.checkbox.Checkbox;
|
||||
@@ -18,6 +19,7 @@ import com.vaadin.flow.component.notification.Notification;
|
||||
import com.vaadin.flow.component.orderedlayout.FlexComponent;
|
||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||
import com.vaadin.flow.component.progressbar.ProgressBar;
|
||||
import com.vaadin.flow.component.textfield.IntegerField;
|
||||
import com.vaadin.flow.component.textfield.TextArea;
|
||||
import com.vaadin.flow.component.textfield.TextField;
|
||||
@@ -33,6 +35,7 @@ import de.assecutor.tasklisteditor.model.BlockType;
|
||||
import de.assecutor.tasklisteditor.model.BlockTypeRegistry;
|
||||
import de.assecutor.tasklisteditor.model.CanvasBlockState;
|
||||
import de.assecutor.tasklisteditor.model.PropertyDefinition;
|
||||
import de.assecutor.tasklisteditor.model.TaskDto;
|
||||
import de.assecutor.tasklisteditor.model.TaskListPayload;
|
||||
import de.assecutor.tasklisteditor.document.CanvasDocument;
|
||||
import de.assecutor.tasklisteditor.service.CanvasService;
|
||||
@@ -41,11 +44,13 @@ import de.assecutor.tasklisteditor.service.ElementSettingsService;
|
||||
import de.assecutor.tasklisteditor.service.PendingImportStore;
|
||||
import de.assecutor.tasklisteditor.service.TaskListImporter;
|
||||
import de.assecutor.tasklisteditor.service.TaskListService;
|
||||
import de.assecutor.tasklisteditor.service.WorkflowAssistantService;
|
||||
import elemental.json.Json;
|
||||
import elemental.json.JsonArray;
|
||||
import elemental.json.JsonObject;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
@@ -59,9 +64,11 @@ import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Route("")
|
||||
@PageTitle("TaskList Editor")
|
||||
@PageTitle("Workflow Editor")
|
||||
public class MainView extends VerticalLayout implements BeforeEnterObserver {
|
||||
|
||||
/** Query-Parameter des Deep-Links, der das Übergabe-Token enthält. */
|
||||
@@ -74,12 +81,25 @@ public class MainView extends VerticalLayout implements BeforeEnterObserver {
|
||||
private final CanvasService canvasService;
|
||||
private final CustomTypeService customTypeService;
|
||||
private final ElementSettingsService elementSettingsService;
|
||||
private final WorkflowAssistantService workflowAssistantService;
|
||||
private final ObjectMapper objectMapper;
|
||||
private final NodeEditor nodeEditor;
|
||||
private final Map<Integer, BlockInstance> instances = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Zuletzt vom Canvas entfernte Blöcke. Stellt ein Undo einen Knoten wieder
|
||||
* her, werden seine Einstellungen von hier zurückgeholt (begrenzt, damit
|
||||
* die Session nicht unbegrenzt wächst).
|
||||
*/
|
||||
private final Map<Integer, BlockInstance> removedInstances = new LinkedHashMap<>() {
|
||||
@Override
|
||||
protected boolean removeEldestEntry(Map.Entry<Integer, BlockInstance> eldest) {
|
||||
return size() > 100;
|
||||
}
|
||||
};
|
||||
private Div palettePanel;
|
||||
private Component paletteDivider;
|
||||
private String currentListName;
|
||||
private final String appVersion;
|
||||
|
||||
public MainView(BlockTypeRegistry registry,
|
||||
TaskListService taskListService,
|
||||
@@ -88,7 +108,10 @@ public class MainView extends VerticalLayout implements BeforeEnterObserver {
|
||||
CanvasService canvasService,
|
||||
CustomTypeService customTypeService,
|
||||
ElementSettingsService elementSettingsService,
|
||||
ObjectMapper objectMapper) {
|
||||
WorkflowAssistantService workflowAssistantService,
|
||||
ObjectMapper objectMapper,
|
||||
@Value("${tasklist.app-version:}") String appVersion) {
|
||||
this.appVersion = appVersion;
|
||||
this.registry = registry;
|
||||
this.taskListService = taskListService;
|
||||
this.taskListImporter = taskListImporter;
|
||||
@@ -96,6 +119,7 @@ public class MainView extends VerticalLayout implements BeforeEnterObserver {
|
||||
this.canvasService = canvasService;
|
||||
this.customTypeService = customTypeService;
|
||||
this.elementSettingsService = elementSettingsService;
|
||||
this.workflowAssistantService = workflowAssistantService;
|
||||
this.objectMapper = objectMapper;
|
||||
setSizeFull();
|
||||
setPadding(false);
|
||||
@@ -132,7 +156,52 @@ public class MainView extends VerticalLayout implements BeforeEnterObserver {
|
||||
openSettingsDialog(instance);
|
||||
}
|
||||
});
|
||||
nodeEditor.addNodeRemovedListener(e -> instances.remove(e.nodeId()));
|
||||
nodeEditor.addNodeRemovedListener(e -> {
|
||||
BlockInstance removed = instances.remove(e.nodeId());
|
||||
if (removed != null) {
|
||||
removedInstances.put(e.nodeId(), removed);
|
||||
}
|
||||
});
|
||||
nodeEditor.addCanvasRestoredListener(e -> reconcileAfterUndo(e.nodesJson()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gleicht die serverseitigen BlockInstances nach einem Undo mit den auf dem
|
||||
* Canvas vorhandenen Knoten ab: Verschwundene Knoten wandern in den
|
||||
* Papierkorb, wieder aufgetauchte werden von dort (inkl. ihrer
|
||||
* Einstellungen) wiederhergestellt.
|
||||
*/
|
||||
private void reconcileAfterUndo(String nodesJson) {
|
||||
Map<Integer, String> present = new LinkedHashMap<>();
|
||||
try {
|
||||
JsonNode nodes = objectMapper.readTree(nodesJson);
|
||||
for (JsonNode node : nodes) {
|
||||
present.put(node.path("id").asInt(), node.path("typeId").asText());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
return;
|
||||
}
|
||||
instances.entrySet().removeIf(entry -> {
|
||||
if (present.containsKey(entry.getKey())) {
|
||||
return false;
|
||||
}
|
||||
removedInstances.put(entry.getKey(), entry.getValue());
|
||||
return true;
|
||||
});
|
||||
present.forEach((id, typeId) -> {
|
||||
if (instances.containsKey(id)) {
|
||||
return;
|
||||
}
|
||||
BlockInstance restored = removedInstances.remove(id);
|
||||
if (restored == null) {
|
||||
BlockType type = registry.find(typeId).orElse(null);
|
||||
if (type == null) {
|
||||
return;
|
||||
}
|
||||
restored = new BlockInstance(id, type);
|
||||
}
|
||||
instances.put(id, restored);
|
||||
});
|
||||
}
|
||||
|
||||
private Component buildHeader() {
|
||||
@@ -143,32 +212,53 @@ public class MainView extends VerticalLayout implements BeforeEnterObserver {
|
||||
header.setPadding(true);
|
||||
header.setSpacing(true);
|
||||
|
||||
H2 title = new H2("TaskList Editor");
|
||||
H2 title = new H2("Workflow Editor");
|
||||
title.addClassName("tasklist-title");
|
||||
title.getStyle().set("white-space", "nowrap");
|
||||
|
||||
Span subtitle = new Span("Funktionsblöcke per Drag & Drop in eine Reihenfolge bringen");
|
||||
subtitle.addClassName("tasklist-subtitle");
|
||||
if (appVersion != null && !appVersion.isBlank() && !appVersion.startsWith("@")) {
|
||||
Span version = new Span(" (v" + appVersion + ")");
|
||||
version.getStyle()
|
||||
.set("font-size", "0.7em")
|
||||
.set("color", "var(--lumo-secondary-text-color)")
|
||||
.set("white-space", "nowrap");
|
||||
title.add(version);
|
||||
}
|
||||
|
||||
Button clear = new Button("Canvas leeren", new Icon(VaadinIcon.TRASH));
|
||||
Button assistant = new Button("KI-Assistent", new Icon(VaadinIcon.MAGIC));
|
||||
assistant.addThemeVariants(ButtonVariant.LUMO_TERTIARY);
|
||||
assistant.setTooltipText("Workflow aus einer Beschreibung erzeugen oder ändern (Claude)");
|
||||
assistant.addClickListener(e -> openAssistantDialog());
|
||||
// KI-Funktionalität per .env (AI_ENABLED) abschaltbar.
|
||||
assistant.setVisible(workflowAssistantService.isEnabled());
|
||||
|
||||
Button undo = new Button("Rückgängig", new Icon(VaadinIcon.ARROW_BACKWARD));
|
||||
undo.addThemeVariants(ButtonVariant.LUMO_TERTIARY);
|
||||
undo.setTooltipText("Letzte Canvas-Änderung zurücknehmen (Strg+Z, max. 10 Schritte)");
|
||||
undo.addClickListener(e -> nodeEditor.undo(undone -> {
|
||||
if (!Boolean.TRUE.equals(undone)) {
|
||||
Notification.show("Nichts zum Rückgängigmachen.");
|
||||
}
|
||||
}));
|
||||
|
||||
Button clear = new Button("Workflow löschen", new Icon(VaadinIcon.TRASH));
|
||||
clear.addThemeVariants(ButtonVariant.LUMO_TERTIARY);
|
||||
clear.addClickListener(e -> {
|
||||
nodeEditor.clear();
|
||||
// In den Papierkorb statt verwerfen: Undo kann das Leeren zurücknehmen.
|
||||
removedInstances.putAll(instances);
|
||||
instances.clear();
|
||||
Notification.show("Canvas geleert");
|
||||
});
|
||||
|
||||
Button saveCanvas = new Button("Canvas speichern", new Icon(VaadinIcon.HARDDRIVE));
|
||||
Button saveCanvas = new Button("Workflow speichern", new Icon(VaadinIcon.HARDDRIVE));
|
||||
saveCanvas.addThemeVariants(ButtonVariant.LUMO_TERTIARY);
|
||||
saveCanvas.addClickListener(e -> saveCanvas());
|
||||
|
||||
Button loadCanvas = new Button("Canvas laden", new Icon(VaadinIcon.FOLDER_OPEN));
|
||||
Button loadCanvas = new Button("Worklow laden", new Icon(VaadinIcon.FOLDER_OPEN));
|
||||
loadCanvas.addThemeVariants(ButtonVariant.LUMO_TERTIARY);
|
||||
loadCanvas.addClickListener(e -> openLoadCanvasDialog());
|
||||
|
||||
Button appJson = new Button("App-JSON (stadtbote)", new Icon(VaadinIcon.MOBILE));
|
||||
appJson.addThemeVariants(ButtonVariant.LUMO_SUCCESS);
|
||||
appJson.addClickListener(e -> previewAppJson());
|
||||
|
||||
Button export = new Button("JSON erzeugen & speichern", new Icon(VaadinIcon.DOWNLOAD));
|
||||
export.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||
export.addClickListener(e -> exportTasks());
|
||||
@@ -176,7 +266,7 @@ public class MainView extends VerticalLayout implements BeforeEnterObserver {
|
||||
Span spacer = new Span();
|
||||
spacer.getStyle().set("flex", "1");
|
||||
|
||||
header.add(title, subtitle, spacer, clear, saveCanvas, loadCanvas, appJson, export);
|
||||
header.add(title, spacer, assistant, undo, clear, saveCanvas, loadCanvas, export);
|
||||
return header;
|
||||
}
|
||||
|
||||
@@ -193,18 +283,28 @@ public class MainView extends VerticalLayout implements BeforeEnterObserver {
|
||||
hint.addClassName("panel-hint");
|
||||
panel.add(hint);
|
||||
|
||||
// Standardelemente
|
||||
for (BlockType type : registry.all()) {
|
||||
if (!isCustomType(type)) {
|
||||
panel.add(buildPaletteItem(type));
|
||||
}
|
||||
}
|
||||
|
||||
// Trenner und "Eigenen Typ anlegen"-Button: immer unter den
|
||||
// Standardelementen und vor den selbst definierten Typen.
|
||||
panel.add(buildPaletteDivider());
|
||||
|
||||
Button customType = new Button("Eigenen Typ anlegen", new Icon(VaadinIcon.PLUS));
|
||||
customType.addThemeVariants(ButtonVariant.LUMO_SMALL, ButtonVariant.LUMO_TERTIARY);
|
||||
customType.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||
customType.addClassName("palette-add-type");
|
||||
customType.setWidthFull();
|
||||
customType.addClickListener(e -> openCustomTypeDialog());
|
||||
panel.add(customType);
|
||||
|
||||
// Selbst definierte Elemente
|
||||
for (BlockType type : registry.all()) {
|
||||
if (isCustomType(type)) {
|
||||
addCustomPaletteItem(type);
|
||||
} else {
|
||||
panel.add(buildPaletteItem(type));
|
||||
}
|
||||
}
|
||||
return panel;
|
||||
@@ -214,12 +314,8 @@ public class MainView extends VerticalLayout implements BeforeEnterObserver {
|
||||
return type.taskType() >= BlockTypeRegistry.CUSTOM_TYPE_START;
|
||||
}
|
||||
|
||||
/** Fügt ein benutzerdefiniertes Element hinzu und blendet davor einmalig einen Trenner ein. */
|
||||
/** Fügt ein benutzerdefiniertes Element ans Ende der Palette an (nach dem Button). */
|
||||
private void addCustomPaletteItem(BlockType type) {
|
||||
if (paletteDivider == null) {
|
||||
paletteDivider = buildPaletteDivider();
|
||||
palettePanel.add(paletteDivider);
|
||||
}
|
||||
palettePanel.add(buildPaletteItem(type));
|
||||
}
|
||||
|
||||
@@ -412,11 +508,6 @@ public class MainView extends VerticalLayout implements BeforeEnterObserver {
|
||||
+ ex.getMessage());
|
||||
}
|
||||
palettePanel.remove(tile);
|
||||
// Trenner entfernen, wenn kein benutzerdefinierter Typ mehr vorhanden ist.
|
||||
if (paletteDivider != null && registry.all().stream().noneMatch(this::isCustomType)) {
|
||||
palettePanel.remove(paletteDivider);
|
||||
paletteDivider = null;
|
||||
}
|
||||
nodeEditor.registerBlockTypes(registry.all());
|
||||
Notification.show("Typ " + type.taskType() + " „" + type.label() + "“ gelöscht.");
|
||||
}
|
||||
@@ -450,7 +541,7 @@ public class MainView extends VerticalLayout implements BeforeEnterObserver {
|
||||
private void openBlockDialog(BlockInstance instance) {
|
||||
Dialog dialog = new Dialog();
|
||||
dialog.setHeaderTitle(instance.type().label());
|
||||
dialog.setWidth("440px");
|
||||
dialog.setWidth("585px");
|
||||
|
||||
Paragraph desc = new Paragraph(instance.type().description());
|
||||
desc.addClassName("properties-desc");
|
||||
@@ -721,23 +812,48 @@ public class MainView extends VerticalLayout implements BeforeEnterObserver {
|
||||
return box;
|
||||
}
|
||||
case FIELD_LIST -> {
|
||||
return buildRowList(instance, def, current, true);
|
||||
return buildRowList(instance, def, current, true, true);
|
||||
}
|
||||
case NAME_LIST -> {
|
||||
return buildRowList(instance, def, current, false);
|
||||
return buildRowList(instance, def, current, false, true);
|
||||
}
|
||||
case CHOICE_LIST -> {
|
||||
return buildRowList(instance, def, legacyLinesToRows(current), false, false);
|
||||
}
|
||||
}
|
||||
return new Span();
|
||||
}
|
||||
|
||||
/**
|
||||
* Wandelt den früheren Textarea-Wert der Statusauswahl (eine Option pro
|
||||
* Zeile) in die vom Zeilen-Editor erwartete Struktur um. Listen werden
|
||||
* unverändert durchgereicht.
|
||||
*/
|
||||
private Object legacyLinesToRows(Object current) {
|
||||
if (!(current instanceof String s)) {
|
||||
return current;
|
||||
}
|
||||
List<Map<String, Object>> rows = new ArrayList<>();
|
||||
for (String line : s.split("\\r?\\n")) {
|
||||
String text = line.trim();
|
||||
if (!text.isEmpty()) {
|
||||
Map<String, Object> row = new LinkedHashMap<>();
|
||||
row.put("title", text);
|
||||
rows.add(row);
|
||||
}
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor für eine wiederholbare Liste von Eingabefeldern. Jede Zeile besteht
|
||||
* aus einem Titel und – falls {@code withPlaceholder} – zusätzlich einem
|
||||
* Platzhalter. Der Wert wird als {@code List<Map<String,Object>>} unter der
|
||||
* Platzhalter sowie – falls {@code withRequired} – einer Pflichtfeld-
|
||||
* Checkbox. Der Wert wird als {@code List<Map<String,Object>>} unter der
|
||||
* Property-ID abgelegt (rundläuft über Mongo und Export).
|
||||
*/
|
||||
private Component buildRowList(BlockInstance instance, PropertyDefinition def, Object current,
|
||||
boolean withPlaceholder) {
|
||||
boolean withPlaceholder, boolean withRequired) {
|
||||
List<Map<String, Object>> rows = new ArrayList<>();
|
||||
if (current instanceof List<?> list) {
|
||||
for (Object o : list) {
|
||||
@@ -747,6 +863,11 @@ public class MainView extends VerticalLayout implements BeforeEnterObserver {
|
||||
if (withPlaceholder) {
|
||||
row.put("placeholder", m.get("placeholder") == null ? "" : m.get("placeholder").toString());
|
||||
}
|
||||
if (withRequired) {
|
||||
row.put("required", m.get("required") instanceof Boolean b
|
||||
? b
|
||||
: Boolean.parseBoolean(String.valueOf(m.get("required"))));
|
||||
}
|
||||
rows.add(row);
|
||||
}
|
||||
}
|
||||
@@ -800,6 +921,15 @@ public class MainView extends VerticalLayout implements BeforeEnterObserver {
|
||||
line.add(placeholder);
|
||||
line.setFlexGrow(1, placeholder);
|
||||
}
|
||||
if (withRequired) {
|
||||
Checkbox required = new Checkbox("Pflicht");
|
||||
required.setValue(Boolean.TRUE.equals(row.get("required")));
|
||||
required.addValueChangeListener(e -> {
|
||||
row.put("required", e.getValue());
|
||||
commit.run();
|
||||
});
|
||||
line.add(required);
|
||||
}
|
||||
line.add(remove);
|
||||
line.setAlignItems(FlexComponent.Alignment.BASELINE);
|
||||
rowsBox.add(line);
|
||||
@@ -814,6 +944,9 @@ public class MainView extends VerticalLayout implements BeforeEnterObserver {
|
||||
if (withPlaceholder) {
|
||||
row.put("placeholder", "");
|
||||
}
|
||||
if (withRequired) {
|
||||
row.put("required", false);
|
||||
}
|
||||
rows.add(row);
|
||||
commit.run();
|
||||
render[0].run();
|
||||
@@ -837,11 +970,23 @@ public class MainView extends VerticalLayout implements BeforeEnterObserver {
|
||||
|
||||
/** Baut den Canvas aus den per Deep-Link übergebenen Daten auf. */
|
||||
private void loadPayload(TaskListPayload payload) {
|
||||
List<TaskListImporter.ResolvedTask> resolved = taskListImporter.resolve(payload.getTasks());
|
||||
buildCanvasFromTasks(payload.getTasks(), payload.getName(), "aus Deep-Link geladen");
|
||||
}
|
||||
|
||||
/**
|
||||
* Baut den Canvas aus einer Task-Liste neu auf (Knoten in Reihenfolge plus
|
||||
* Verkettung) und legt die zugehörigen {@link BlockInstance}s an. Wird vom
|
||||
* Deep-Link-Import und vom KI-Assistenten genutzt.
|
||||
*/
|
||||
private void buildCanvasFromTasks(List<TaskDto> tasks, String name, String successHint) {
|
||||
List<TaskListImporter.ResolvedTask> resolved = taskListImporter.resolve(tasks);
|
||||
if (resolved.isEmpty()) {
|
||||
Notification.show("Keine verwertbaren Elemente gefunden.");
|
||||
return;
|
||||
}
|
||||
currentListName = payload.getName();
|
||||
if (name != null && !name.isBlank()) {
|
||||
currentListName = name;
|
||||
}
|
||||
|
||||
JsonArray descriptors = Json.createArray();
|
||||
for (int i = 0; i < resolved.size(); i++) {
|
||||
@@ -852,12 +997,15 @@ public class MainView extends VerticalLayout implements BeforeEnterObserver {
|
||||
descriptors.set(i, obj);
|
||||
}
|
||||
|
||||
// In den Papierkorb statt verwerfen: Undo kann den Neuaufbau zurücknehmen.
|
||||
removedInstances.putAll(instances);
|
||||
instances.clear();
|
||||
|
||||
nodeEditor.importTasks(descriptors, idsJson -> applyImportedIds(idsJson, resolved));
|
||||
nodeEditor.importTasks(descriptors, idsJson -> applyImportedIds(idsJson, resolved, successHint));
|
||||
}
|
||||
|
||||
private void applyImportedIds(String idsJson, List<TaskListImporter.ResolvedTask> resolved) {
|
||||
private void applyImportedIds(String idsJson, List<TaskListImporter.ResolvedTask> resolved,
|
||||
String successHint) {
|
||||
int[] ids;
|
||||
try {
|
||||
ids = objectMapper.readValue(idsJson, int[].class);
|
||||
@@ -873,7 +1021,142 @@ public class MainView extends VerticalLayout implements BeforeEnterObserver {
|
||||
task.values().forEach(instance::set);
|
||||
instances.put(ids[i], instance);
|
||||
}
|
||||
Notification.show(count + " Task(s) aus Deep-Link geladen.");
|
||||
Notification.show(count + " Task(s) " + successHint + ".");
|
||||
}
|
||||
|
||||
// --- KI-Workflow-Assistent (Claude API) ---
|
||||
|
||||
/**
|
||||
* Dialog des KI-Assistenten: Der Benutzer beschreibt in freier Sprache die
|
||||
* gewünschten Elemente, deren Reihenfolge und Einstellungen; Claude
|
||||
* übersetzt das in eine Task-Liste, aus der der Canvas aufgebaut wird.
|
||||
* Liegt bereits ein Workflow auf dem Canvas, wird er als Kontext
|
||||
* mitgegeben und die Beschreibung als Änderungswunsch angewendet.
|
||||
*/
|
||||
private void openAssistantDialog() {
|
||||
if (!workflowAssistantService.isEnabled()) {
|
||||
Notification.show("KI-Assistent nicht verfügbar: Bitte AI_ENABLED=true und "
|
||||
+ "ANTHROPIC_API_KEY in der .env-Datei hinterlegen und die "
|
||||
+ "Anwendung neu starten.");
|
||||
return;
|
||||
}
|
||||
boolean modifying = !instances.isEmpty();
|
||||
|
||||
Dialog dialog = new Dialog();
|
||||
dialog.setHeaderTitle(modifying
|
||||
? "KI-Assistent: Workflow ändern"
|
||||
: "KI-Assistent: Workflow erzeugen");
|
||||
dialog.setWidth("640px");
|
||||
|
||||
Paragraph hint = new Paragraph(modifying
|
||||
? "Beschreibe die gewünschten Änderungen am aktuellen Workflow. Beispiel: "
|
||||
+ "„Nach der Ankunft zwei Pflicht-Fotos einfügen, die Bemerkung optional "
|
||||
+ "machen und die Statusauswahl um ‚Beschädigt‘ ergänzen.“"
|
||||
: "Beschreibe den gewünschten Workflow: welche Elemente "
|
||||
+ "in welcher Reihenfolge und mit welchen Einstellungen. Beispiel: "
|
||||
+ "„Ankunft mit GPS erfassen, dann drei Pflicht-Fotos, Statusauswahl "
|
||||
+ "mit ‚OK‘ und ‚Beschädigt‘, zum Schluss Unterschrift.“");
|
||||
hint.addClassName("properties-desc");
|
||||
|
||||
TextArea wishes = new TextArea(modifying
|
||||
? "Gewünschte Änderungen"
|
||||
: "Wünsche für den Workflow");
|
||||
wishes.setWidthFull();
|
||||
wishes.setMinHeight("160px");
|
||||
wishes.setPlaceholder(modifying
|
||||
? "z. B. Unterschrift ans Ende verschieben, Fotos als Pflicht markieren …"
|
||||
: "z. B. Ankunft melden, danach Fotos (mind. 2), Bemerkung optional …");
|
||||
|
||||
ProgressBar progress = new ProgressBar();
|
||||
progress.setIndeterminate(true);
|
||||
progress.setVisible(false);
|
||||
Span progressLabel = new Span(modifying
|
||||
? "Claude ändert den Workflow – das kann einen Moment dauern …"
|
||||
: "Claude erstellt den Workflow – das kann einen Moment dauern …");
|
||||
progressLabel.setVisible(false);
|
||||
|
||||
VerticalLayout content = new VerticalLayout(hint, wishes, progress, progressLabel);
|
||||
content.setPadding(false);
|
||||
content.setSpacing(true);
|
||||
dialog.add(content);
|
||||
|
||||
Button cancel = new Button("Abbrechen", ev -> dialog.close());
|
||||
cancel.addThemeVariants(ButtonVariant.LUMO_TERTIARY);
|
||||
|
||||
Button generate = new Button(modifying ? "Änderungen anwenden" : "Workflow erzeugen",
|
||||
new Icon(VaadinIcon.MAGIC));
|
||||
generate.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||
generate.addClickListener(ev -> {
|
||||
String wish = wishes.getValue();
|
||||
if (wish == null || wish.isBlank()) {
|
||||
Notification.show(modifying
|
||||
? "Bitte zuerst die gewünschten Änderungen beschreiben."
|
||||
: "Bitte zuerst die Wünsche für den Workflow beschreiben.");
|
||||
return;
|
||||
}
|
||||
generate.setEnabled(false);
|
||||
wishes.setReadOnly(true);
|
||||
progress.setVisible(true);
|
||||
progressLabel.setVisible(true);
|
||||
|
||||
UI ui = UI.getCurrent();
|
||||
ui.setPollInterval(500);
|
||||
if (modifying) {
|
||||
// Aktuellen Canvas als Task-JSON exportieren und als Kontext mitgeben.
|
||||
nodeEditor.exportGraph(graphJson -> {
|
||||
String currentJson;
|
||||
try {
|
||||
currentJson = taskListService.buildAssistantContext(graphJson, instances);
|
||||
} catch (Exception ex) {
|
||||
ui.setPollInterval(-1);
|
||||
Notification.show("KI-Assistent fehlgeschlagen: " + ex.getMessage());
|
||||
generate.setEnabled(true);
|
||||
wishes.setReadOnly(false);
|
||||
progress.setVisible(false);
|
||||
progressLabel.setVisible(false);
|
||||
return;
|
||||
}
|
||||
runAssistant(dialog, generate, wishes, progress, progressLabel, ui,
|
||||
"per KI-Assistent geändert",
|
||||
() -> workflowAssistantService.generateWorkflow(wish, currentListName, currentJson));
|
||||
});
|
||||
} else {
|
||||
runAssistant(dialog, generate, wishes, progress, progressLabel, ui,
|
||||
"per KI-Assistent erstellt",
|
||||
() -> workflowAssistantService.generateWorkflow(wish));
|
||||
}
|
||||
});
|
||||
|
||||
dialog.getFooter().add(cancel, generate);
|
||||
dialog.open();
|
||||
wishes.focus();
|
||||
}
|
||||
|
||||
/**
|
||||
* Führt den Claude-Aufruf im Hintergrund aus (dauert typisch einige
|
||||
* Sekunden bis Minuten); Polling holt das Ergebnis in die UI. Bei Erfolg
|
||||
* wird der Canvas aus dem gelieferten Entwurf neu aufgebaut.
|
||||
*/
|
||||
private void runAssistant(Dialog dialog, Button generate, TextArea wishes,
|
||||
ProgressBar progress, Span progressLabel, UI ui,
|
||||
String successHint,
|
||||
Supplier<WorkflowAssistantService.WorkflowDraft> call) {
|
||||
CompletableFuture
|
||||
.supplyAsync(call)
|
||||
.whenComplete((draft, error) -> ui.access(() -> {
|
||||
ui.setPollInterval(-1);
|
||||
if (error != null) {
|
||||
Throwable cause = error.getCause() != null ? error.getCause() : error;
|
||||
Notification.show("KI-Assistent fehlgeschlagen: " + cause.getMessage());
|
||||
generate.setEnabled(true);
|
||||
wishes.setReadOnly(false);
|
||||
progress.setVisible(false);
|
||||
progressLabel.setVisible(false);
|
||||
return;
|
||||
}
|
||||
buildCanvasFromTasks(draft.tasks(), draft.name(), successHint);
|
||||
dialog.close();
|
||||
}));
|
||||
}
|
||||
|
||||
// --- Canvas speichern / laden (MongoDB) ---
|
||||
@@ -1056,60 +1339,4 @@ public class MainView extends VerticalLayout implements BeforeEnterObserver {
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
/**
|
||||
* Erzeugt das vollständige, von der stadtbote-App verarbeitbare Job-JSON
|
||||
* (Job → Tour → Tasks) und zeigt es in einem Dialog an.
|
||||
*/
|
||||
private void previewAppJson() {
|
||||
if (instances.isEmpty()) {
|
||||
Notification.show("Es sind keine Funktionsblöcke auf dem Canvas.");
|
||||
return;
|
||||
}
|
||||
nodeEditor.exportGraph(graphJson -> {
|
||||
try {
|
||||
TaskListService.AppJobResult result =
|
||||
taskListService.buildAppJob(currentListName, graphJson, instances);
|
||||
if (result.taskCount() == 0) {
|
||||
Notification.show("Keine app-verarbeitbaren Tasks gefunden.");
|
||||
return;
|
||||
}
|
||||
openAppJsonDialog(result);
|
||||
} catch (Exception ex) {
|
||||
Notification.show("App-JSON fehlgeschlagen: " + ex.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void openAppJsonDialog(TaskListService.AppJobResult result) {
|
||||
Dialog dialog = new Dialog();
|
||||
dialog.setHeaderTitle("App-JSON für stadtbote (" + result.taskCount() + " Tasks)");
|
||||
dialog.setWidth("720px");
|
||||
|
||||
Paragraph hint = new Paragraph("Task-Array, das von der stadtbote-App fehlerfrei "
|
||||
+ "verarbeitet wird. Script-Blöcke werden ausgelassen.");
|
||||
hint.addClassName("properties-desc");
|
||||
|
||||
TextArea json = new TextArea("App-JSON (tasks-Array)");
|
||||
json.setWidthFull();
|
||||
json.setHeight("420px");
|
||||
json.setReadOnly(true);
|
||||
json.setValue(result.json());
|
||||
|
||||
VerticalLayout content = new VerticalLayout(hint, json);
|
||||
content.setPadding(false);
|
||||
content.setSpacing(true);
|
||||
dialog.add(content);
|
||||
|
||||
Button copy = new Button("In Zwischenablage kopieren", new Icon(VaadinIcon.COPY), ev -> {
|
||||
getElement().executeJs("navigator.clipboard.writeText($0)", result.json());
|
||||
Notification.show("JSON in die Zwischenablage kopiert.");
|
||||
});
|
||||
copy.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||
|
||||
Button close = new Button("Schließen", ev -> dialog.close());
|
||||
close.addThemeVariants(ButtonVariant.LUMO_TERTIARY);
|
||||
|
||||
dialog.getFooter().add(close, copy);
|
||||
dialog.open();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
server.port=8080
|
||||
|
||||
# Anwendungsversion: wird beim Build per Maven-Resource-Filtering
|
||||
# (spring-boot-starter-parent, @...@-Delimiter) aus der pom.xml gefüllt.
|
||||
tasklist.app-version=@project.version@
|
||||
|
||||
vaadin.launch-browser=true
|
||||
vaadin.allowed-packages=de.assecutor.tasklisteditor
|
||||
|
||||
@@ -26,6 +30,14 @@ management.health.mongo.enabled=false
|
||||
# Wird per .env (HIDE_SCRIPT_BLOCK) gesteuert.
|
||||
tasklist.hide-script-block=${HIDE_SCRIPT_BLOCK:false}
|
||||
|
||||
# --- KI-Workflow-Assistent (Claude API) --------------------------------------
|
||||
# Ein-/Ausschalter, API-Key und Modell kommen aus der .env-Datei (AI_ENABLED,
|
||||
# ANTHROPIC_API_KEY, ANTHROPIC_MODEL). Der Assistent ist nur verfügbar, wenn
|
||||
# AI_ENABLED=true gesetzt UND ein Key hinterlegt ist (Standard: aus).
|
||||
tasklist.ai-enabled=${AI_ENABLED:false}
|
||||
tasklist.anthropic-api-key=${ANTHROPIC_API_KEY:}
|
||||
tasklist.anthropic-model=${ANTHROPIC_MODEL:claude-opus-4-8}
|
||||
|
||||
# --- Collections je Element-Typ ---------------------------------------------
|
||||
# Einstellungen der einzelnen Elemente werden beim Canvas-Speichern zusätzlich
|
||||
# je Element-Typ in eine eigene Collection geschrieben. Namen aus der .env
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
"noUnusedParameters": false,
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"ignoreDeprecations": "6.0",
|
||||
"ignoreDeprecations": "5.0",
|
||||
"baseUrl": "src/main/frontend",
|
||||
"paths": {
|
||||
"@vaadin/flow-frontend": ["generated/jar-resources"],
|
||||
|
||||
Reference in New Issue
Block a user