Compare commits

...

68 Commits

Author SHA1 Message Date
Fabio Formosa
da8c9d5707 Remove Maven Central badge from README
Removed Maven Central badge from README.
2026-05-08 22:53:46 +02:00
Fabio Formosa
6b245c7eec released v4.1.1 2026-05-08 22:36:40 +02:00
Fabio Formosa
d7653dc73e released v4.1.0 2026-05-08 21:50:38 +02:00
Fabio Formosa
e6a7b35f6a released v4.1.0 2026-05-08 21:48:57 +02:00
Fabio Formosa
3088a2fec1 Merge pull request #129 from fabioformosa/develop
Develop for releasing 4.1.0
2026-05-08 00:39:01 +02:00
Fabio Formosa
bdd0caa026 Merge pull request #128 from fabioformosa/feature/#103_multiple_triggers
Feature/#103 multiple triggers
2026-05-06 23:46:02 +02:00
Fabio Formosa
068b0eed34 #103 fixed a test 2026-05-06 23:43:35 +02:00
Fabio Formosa
b2f9692815 #103 fixed a test 2026-05-06 23:41:08 +02:00
Fabio Formosa
5fc6c56409 Merge branch 'develop' into feature/#103_multiple_triggers
# Conflicts:
#	quartz-manager-parent/.gitignore
2026-05-06 23:26:40 +02:00
Fabio Formosa
d7a78c57ae #103 minor enhancements 2026-05-06 23:13:44 +02:00
Fabio Formosa
31658416f5 #103 final step into multi-trigger feature 2026-05-06 01:22:30 +02:00
Fabio Formosa
1d81e88684 Merge remote-tracking branch 'origin/master' into develop 2026-04-27 23:13:05 +02:00
Fabio Formosa
f55a58b100 Add workflow_dispatch trigger to sonar-java.yml
added the workflow_dispatch to the GitHub Action
2026-04-23 23:26:20 +02:00
Fabio Formosa
902542e480 Update sonar-java.yml
added the workflow_dispatch trigger for the sonar action
2026-04-23 22:39:34 +02:00
Fabio Formosa
c198d32bd5 bump to version 4.0.11-SNAPSHOT 2025-05-23 23:06:34 +02:00
Fabio Formosa
56d9f5d94f bump to version 4.0.10 2025-05-23 23:04:28 +02:00
Fabio Formosa
45f66d51fe Merge remote-tracking branch 'origin/master' into develop 2025-05-23 23:00:37 +02:00
Fabio Formosa
95769248a3 migrated to the new maven central repo 2025-05-23 21:52:30 +02:00
Fabio Formosa
dcbf3eb277 migrated to the new maven central repo 2025-05-23 20:10:53 +02:00
Fabio Formosa
fab977fd7d added the staging and prod env to the delivery pipeline 2024-07-27 17:41:31 +02:00
Fabio Formosa
9d2a01ebbe added the staging and prod env to the delivery pipeline 2024-07-27 17:33:31 +02:00
Fabio Formosa
9a0789cab0 minor commit 2024-07-27 17:08:11 +02:00
Fabio Formosa
e5a6b8b32b minor commit 2024-07-27 16:33:24 +02:00
Fabio Formosa
4537c8e304 minor commit 2024-07-18 23:53:27 +02:00
Fabio Formosa
82ac821b34 minor commit 2024-07-17 00:30:49 +02:00
Fabio Formosa
0a4a31ae65 fixed the chart path 2024-07-17 00:21:24 +02:00
Fabio Formosa
3b325536e8 fixed the dev cluster reference 2024-07-17 00:06:58 +02:00
Fabio Formosa
307c6eab98 fixed the docker image in the cloud deploy pipeline 2024-07-16 23:49:38 +02:00
Fabio Formosa
b1ff70265f added verbosity to cloudbuild.yaml 2024-07-16 23:15:54 +02:00
Fabio Formosa
226296737d added verbosity to cloudbuild.yaml 2024-07-16 23:05:34 +02:00
Fabio Formosa
a5750d1d0d duplicated the helm props replacements 2024-07-16 00:24:10 +02:00
Fabio Formosa
f71c9b20ab minor commit 2024-07-16 00:15:05 +02:00
Fabio Formosa
9cc55492dc fixed the pipeline name 2024-07-15 23:58:08 +02:00
Fabio Formosa
6d36e4620c fixed the path of the pipeline file 2024-07-15 23:47:32 +02:00
Fabio Formosa
4d5e8f62c3 added a google deploy pipeline 2024-07-15 23:39:51 +02:00
Fabio Formosa
8ba33f25b4 fixed copy path in the Dockerfile 2024-07-13 16:00:44 +02:00
Fabio Formosa
7a742d5aea fixed copy path in the Dockerfile 2024-07-13 15:52:40 +02:00
Fabio Formosa
abd25d6158 fixed a wrong path in cloudbuild.yaml 2024-07-13 15:33:10 +02:00
Fabio Formosa
9f46e52564 added a logging policy to cloudbuild.yaml and pushed skaffold.yaml 2024-07-13 15:28:24 +02:00
Fabio Formosa
e6927209e5 added a helm chart to the web-showcase module and cloudbuild.yaml and skaffold.yaml 2024-07-13 13:00:12 +02:00
Fabio Formosa
63fbedbdc8 moved the web-showcase from war to jar and added a dockerfile 2024-07-12 00:36:47 +02:00
Fabio Formosa
0148056b1f Update README.md 2024-03-07 23:32:51 +01:00
Fabio Formosa
ad6a61f3df Update README.md
added a new example for the repo quartz-manager-use-cases
2024-02-07 00:24:21 +01:00
Fabio Formosa
5cb73019de bump version to 4.0.10-SNAPSHOT 2024-02-07 00:19:17 +01:00
Fabio Formosa
8a8e878e47 Update README.md
updated all references to the last release
2024-02-07 00:16:40 +01:00
Fabio Formosa
fae82e1d4e Merge pull request #118 from fabioformosa/develop
Develop to Master
2024-02-07 00:15:44 +01:00
Fabio Formosa
e0011913c2 bump version to 4.0.9 2024-02-06 23:58:07 +01:00
Fabio Formosa
a59b6a6c96 #115 fixed the liquibase DB migration execution 2024-02-06 23:43:54 +01:00
Fabio Formosa
68aaab6ac4 #115 fixed the liquibase DB migration execution 2024-02-06 23:42:38 +01:00
Fabio Formosa
a1d8b12e98 Merge pull request #112 from fabioformosa/feature/#109_configure_trigger_job_data
Feature/#109 configure trigger job data
2024-02-02 23:59:20 +01:00
Fabio Formosa
45d6a4c59a Merge branch 'feature/#109_configure_trigger_job_data' of github.com:fabioformosa/quartz-manager into feature/#109_configure_trigger_job_data 2024-02-02 23:54:31 +01:00
Midhun A Darvin
e6f6fb5f06 feat: configure Trigger JobData
- add `jobDataMap` property to SimpleTriggerInputDTO
- update SimpleTriggerCommandDTOToSimpleTrigger converter
- update SimpleTriggerToSimpleTriggerDTO converter
- update unit tests
- add .idea and .iml to .gitignore for ignoring intellij files
2024-02-02 23:43:27 +01:00
Fabio Formosa
13c438d097 Merge branch 'master' into develop 2024-02-02 23:38:22 +01:00
Fabio Formosa
412e455907 #103 step into accomodating the new trigger logic 2024-02-02 22:58:56 +01:00
Fabio Formosa
75d630aad0 Merge pull request #110 from midhunadarvin/feat/configure-trigger-job-data
feat: configure `Trigger` JobDataMap
2024-02-02 22:56:20 +01:00
Midhun A Darvin
9eddc0b1fd feat: configure Trigger JobData
- add `jobDataMap` property to SimpleTriggerInputDTO
- update SimpleTriggerCommandDTOToSimpleTrigger converter
- update SimpleTriggerToSimpleTriggerDTO converter
- update unit tests
- add .idea and .iml to .gitignore for ignoring intellij files
2024-02-02 13:11:00 +05:30
Fabio Formosa
fa4ede5179 Merge pull request #108 from midhunadarvin/feat/configure-auto-startup
feat: make autoStartup configurable for SchedulerFactoryBean
2024-02-01 00:24:21 +01:00
Fabio Formosa
3aa672031a Updated the sonarcloud.io integration 2024-01-31 23:40:26 +01:00
Midhun A Darvin
82ca186bff feat: make autoStartup configurable for SchedulerFactoryBean
- check property `org.quartz.scheduler.isAutoStartup` and enable autoStartup if it is true
2024-01-31 13:28:15 +05:30
Fabio Formosa
727a11fcea #103 fixed a test 2022-12-21 00:03:39 +01:00
Fabio Formosa
7106dc0fbb #103 clean up 2022-12-21 00:00:29 +01:00
Fabio Formosa
a2c8ecb227 #103 migrated the progress websocket to rx-stomp 2022-12-20 23:59:30 +01:00
Fabio Formosa
e4c771e364 #103 migrated the progress websocket to rx-stomp 2022-12-20 23:58:51 +01:00
Fabio Formosa
261dd8b624 #103 appended the trigger key to the websocket topic 2022-12-20 20:51:10 +01:00
Fabio Formosa
ac63576704 #103 migrated the logs websocket to rx-stomp 2022-12-18 11:58:24 +01:00
Fabio Formosa
a3b92443c4 #103 enabled a dev profile in the angular.json 2022-12-18 11:53:32 +01:00
Fabio Formosa
527ee1200a #103 added some comments 2022-12-11 20:38:55 +01:00
Fabio Formosa
7fd174b313 bump version to 4.0.9-SNAPSHOT 2022-12-10 16:56:05 +01:00
87 changed files with 1754 additions and 550 deletions

2
.dockerignore Normal file
View File

@@ -0,0 +1,2 @@
# .dockerignore
quartz-manager-frontend/node_modules

View File

@@ -19,7 +19,7 @@ jobs:
with: with:
java-version: '11' java-version: '11'
distribution: 'temurin' distribution: 'temurin'
server-id: ossrh server-id: maven-central-release
server-username: MAVEN_USERNAME server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.OSSRH_GPG_SECRET_KEY }} gpg-private-key: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
@@ -31,8 +31,8 @@ jobs:
- name: Publish to maven central - name: Publish to maven central
run: mvn deploy --file quartz-manager-parent/pom.xml --batch-mode -P "release-maven-central,build-webjar" run: mvn deploy --file quartz-manager-parent/pom.xml --batch-mode -P "release-maven-central,build-webjar"
env: env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_TOKEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} MAVEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
- name: Set up Java 11 for publishing to GitHub Packages - name: Set up Java 11 for publishing to GitHub Packages

View File

@@ -7,27 +7,28 @@ on:
# paths: [ 'quartz-manager-parent/**' ] # paths: [ 'quartz-manager-parent/**' ]
pull_request: pull_request:
types: [opened, synchronize, reopened] types: [opened, synchronize, reopened]
workflow_dispatch:
jobs: jobs:
build: build:
name: Build and analyze name: Build and analyze
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11 - name: Set up JDK 17
uses: actions/setup-java@v1 uses: actions/setup-java@v3
with: with:
java-version: 11 java-version: 17
distribution: 'zulu' # Alternative distribution options are available.
- name: Cache SonarCloud packages - name: Cache SonarCloud packages
uses: actions/cache@v1 uses: actions/cache@v3
with: with:
path: ~/.sonar/cache path: ~/.sonar/cache
key: ${{ runner.os }}-sonar key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages - name: Cache Maven packages
uses: actions/cache@v1 uses: actions/cache@v3
with: with:
path: ~/.m2 path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}

2
.gitignore vendored
View File

@@ -1 +1,3 @@
/.project /.project
.idea
*.iml

View File

@@ -1,3 +1,12 @@
## **v4.1.1**
**NEW FEATURE** support for multiple triggers
## **v4.0.10**
Migrated to the new maven central repo
## **v4.0.9**
Fixed a bug which prevented to run the liquibase migration scripts in case of usage of quartz-manager-starter-persistence
## **v4.0.8** ## **v4.0.8**
Upgraded the frontend to angular v14 Upgraded the frontend to angular v14

34
Dockerfile Normal file
View File

@@ -0,0 +1,34 @@
FROM maven:3.9.8-eclipse-temurin-21 AS build
# Set the working directory
WORKDIR /app
# Copy the pom.xml and download dependencies
COPY quartz-manager-parent/pom.xml ./quartz-manager-parent/
COPY quartz-manager-parent/lombok.config ./quartz-manager-parent/
COPY quartz-manager-parent/quartz-manager-common ./quartz-manager-parent/quartz-manager-common/
COPY quartz-manager-parent/quartz-manager-starter-api ./quartz-manager-parent/quartz-manager-starter-api/
COPY quartz-manager-parent/quartz-manager-starter-persistence ./quartz-manager-parent/quartz-manager-starter-persistence/
COPY quartz-manager-parent/quartz-manager-starter-security ./quartz-manager-parent/quartz-manager-starter-security/
COPY quartz-manager-parent/quartz-manager-starter-ui ./quartz-manager-parent/quartz-manager-starter-ui/
COPY quartz-manager-parent/quartz-manager-web-showcase ./quartz-manager-parent/quartz-manager-web-showcase/
COPY quartz-manager-parent/lombok.config ./quartz-manager-parent/
COPY quartz-manager-frontend ./quartz-manager-frontend/
WORKDIR /app/quartz-manager-parent
RUN mvn clean package -DskipTests -P=build-webjar
# Stage 2: Create the final image
FROM openjdk:11-jre-slim
# Set the working directory
WORKDIR /app
# Copy the JAR file from the build stage
COPY --from=build /app/quartz-manager-parent/quartz-manager-web-showcase/target/*-SNAPSHOT.jar app.jar
# Expose the application port
EXPOSE 8080
# Run the application
ENTRYPOINT ["java", "-jar", "app.jar"]

View File

@@ -1,8 +1,9 @@
[![Java CI with Maven](https://github.com/fabioformosa/quartz-manager/actions/workflows/maven.yml/badge.svg)](https://github.com/fabioformosa/quartz-manager/actions/workflows/maven.yml) [![Java CI with Maven](https://github.com/fabioformosa/quartz-manager/actions/workflows/maven.yml/badge.svg)](https://github.com/fabioformosa/quartz-manager/actions/workflows/maven.yml)
[![npm CI](https://github.com/fabioformosa/quartz-manager/actions/workflows/npm.yml/badge.svg)](https://github.com/fabioformosa/quartz-manager/actions/workflows/npm.yml) [![npm CI](https://github.com/fabioformosa/quartz-manager/actions/workflows/npm.yml/badge.svg)](https://github.com/fabioformosa/quartz-manager/actions/workflows/npm.yml)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/it.fabioformosa.quartz-manager/quartz-manager-starter-api/badge.svg)](https://maven-badges.herokuapp.com/maven-central/it.fabioformosa.quartz-manager/quartz-manager-starter-api)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=fabioformosa_quartz-manager&metric=coverage)](https://sonarcloud.io/summary/new_code?id=fabioformosa_quartz-manager) [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=fabioformosa_quartz-manager&metric=bugs)](https://sonarcloud.io/summary/new_code?id=fabioformosa_quartz-manager) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=fabioformosa_quartz-manager&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=fabioformosa_quartz-manager) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=fabioformosa_quartz-manager&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=fabioformosa_quartz-manager) [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=fabioformosa_quartz-manager&metric=coverage)](https://sonarcloud.io/summary/new_code?id=fabioformosa_quartz-manager) [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=fabioformosa_quartz-manager&metric=bugs)](https://sonarcloud.io/summary/new_code?id=fabioformosa_quartz-manager) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=fabioformosa_quartz-manager&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=fabioformosa_quartz-manager) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=fabioformosa_quartz-manager&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=fabioformosa_quartz-manager)
# Table Of Contents
[QUARTZ MANAGER](https://github.com/fabioformosa/quartz-manager#quartz-manager) [QUARTZ MANAGER](https://github.com/fabioformosa/quartz-manager#quartz-manager)
    [Quartz Manager UI](https://github.com/fabioformosa/quartz-manager#quartz-manager-ui)     [Quartz Manager UI](https://github.com/fabioformosa/quartz-manager#quartz-manager-ui)
@@ -80,12 +81,12 @@ Add the dependency, make eligible for Quart Manager the job classes and set the
<dependency> <dependency>
<groupId>it.fabioformosa.quartz-manager</groupId> <groupId>it.fabioformosa.quartz-manager</groupId>
<artifactId>quartz-manager-starter-api</artifactId> <artifactId>quartz-manager-starter-api</artifactId>
<version>4.0.8</version> <version>4.0.9</version>
</dependency> </dependency>
``` ```
#### Gradle #### Gradle
``` ```
implementation group: 'it.fabioformosa.quartz-manager', name: 'quartz-manager-starter-api', version: '4.0.8' implementation group: 'it.fabioformosa.quartz-manager', name: 'quartz-manager-starter-api', version: '4.0.9'
``` ```
### Step 2. Quartz Manager Job Classes ### Step 2. Quartz Manager Job Classes
@@ -168,12 +169,12 @@ You can optionally import the following dependency to have the UI Dashboard to i
<dependency> <dependency>
<groupId>it.fabioformosa.quartz-manager</groupId> <groupId>it.fabioformosa.quartz-manager</groupId>
<artifactId>quartz-manager-starter-ui</artifactId> <artifactId>quartz-manager-starter-ui</artifactId>
<version>4.0.8</version> <version>4.0.9</version>
</dependency> </dependency>
``` ```
#### Gradle #### Gradle
``` ```
implementation group: 'it.fabioformosa.quartz-manager', name: 'quartz-manager-starter-ui', version: '4.0.8' implementation group: 'it.fabioformosa.quartz-manager', name: 'quartz-manager-starter-ui', version: '4.0.9'
``` ```
### Reach out the UI Console at URL ### Reach out the UI Console at URL
@@ -203,14 +204,14 @@ Future development: the Quart Manager Security OAuth2 client.
<dependency> <dependency>
<groupId>it.fabioformosa.quartz-manager</groupId> <groupId>it.fabioformosa.quartz-manager</groupId>
<artifactId>quartz-manager-starter-security</artifactId> <artifactId>quartz-manager-starter-security</artifactId>
<version>4.0.8</version> <version>4.0.9</version>
</dependency> </dependency>
``` ```
#### Gradle #### Gradle
``` ```
compile group: 'it.fabioformosa.quartz-manager', name: 'quartz-manager-starter-security', version: '4.0.8' compile group: 'it.fabioformosa.quartz-manager', name: 'quartz-manager-starter-security', version: '4.0.9'
``` ```
@@ -240,14 +241,14 @@ The pre-requesite is the availability of Postgresql database where Quartz Manage
<dependency> <dependency>
<groupId>it.fabioformosa.quartz-manager</groupId> <groupId>it.fabioformosa.quartz-manager</groupId>
<artifactId>quartz-manager-starter-persistence</artifactId> <artifactId>quartz-manager-starter-persistence</artifactId>
<version>4.0.8</version> <version>4.0.9</version>
</dependency> </dependency>
``` ```
#### Gradle #### Gradle
``` ```
compile group: 'it.fabioformosa.quartz-manager', name: 'quartz-manager-starter-persistence', version: '4.0.8' compile group: 'it.fabioformosa.quartz-manager', name: 'quartz-manager-starter-persistence', version: '4.0.9'
``` ```
### Quartz Manager Persistence Lib - App Props ### Quartz Manager Persistence Lib - App Props
@@ -269,6 +270,7 @@ You can find some examples of different scenarios of projects which import Quart
* *existing-security-header-based* - It demonstrates how Quartz Manager Security can coexists with another Spring Security Config present in your project. Imported libraries: Quartz Manager API, Quartz Manager UI and Quartz Manager Security. * *existing-security-header-based* - It demonstrates how Quartz Manager Security can coexists with another Spring Security Config present in your project. Imported libraries: Quartz Manager API, Quartz Manager UI and Quartz Manager Security.
* *existing-quartz* - It demonstrates how to Quartz Manager can coexist with a Quartz instance already present in your project Imported libraries: Quartz Manager API, Quartz Manager UI. * *existing-quartz* - It demonstrates how to Quartz Manager can coexist with a Quartz instance already present in your project Imported libraries: Quartz Manager API, Quartz Manager UI.
* *existing-quartz-and-storage* - It demonstrates how to Quartz Manager Persistence can coexist with a Quartz instance already present in your project. Imported libraries: Quartz Manager API, Quartz Manager UI and Quartz Manager Persistence. * *existing-quartz-and-storage* - It demonstrates how to Quartz Manager Persistence can coexist with a Quartz instance already present in your project. Imported libraries: Quartz Manager API, Quartz Manager UI and Quartz Manager Persistence.
* *with-persistence* - It demonstrates how to import the Quartz Manager Persistence and get created the quartz tables automatically at the bootstrap
## Limitations ## Limitations

45
cloudbuild.yaml Normal file
View File

@@ -0,0 +1,45 @@
substitutions:
_REGION: europe-west8
steps:
# Step 1: Google Cloud Build - Docker build&push
- name: 'gcr.io/k8s-skaffold/skaffold'
entrypoint: 'sh'
args:
- -xe
- -c
- |
# Build and push images
sed -i s/_IMAGE_TAG_POLICY/$SHORT_SHA/g skaffold.yaml
sed -i s/_HELM_APP_VERSION/$SHORT_SHA/g ./quartz-manager-parent/quartz-manager-web-showcase/helm/Chart.yaml
skaffold build --file-output=/workspace/artifacts.json \
--default-repo=${_REGION}-docker.pkg.dev/quartz-manager-test/quartz-manager/quartz-manager-standalone \
--push=true
# Step 2: Google Cloud Deploy - deploy
- name: 'google/cloud-sdk:latest'
entrypoint: 'sh'
args:
- -xe
- -c
- |
sed -i s/_HELM_APP_VERSION/$SHORT_SHA/g ./quartz-manager-parent/quartz-manager-web-showcase/helm/Chart.yaml
gcloud config set deploy/region ${_REGION}
gcloud deploy apply --file ./quartz-manager-parent/quartz-manager-web-showcase/deploy/pipeline.yaml
gcloud deploy apply --file ./quartz-manager-parent/quartz-manager-web-showcase/deploy/dev.yaml
gcloud deploy apply --file ./quartz-manager-parent/quartz-manager-web-showcase/deploy/staging.yaml
gcloud deploy apply --file ./quartz-manager-parent/quartz-manager-web-showcase/deploy/prod.yaml
gcloud deploy releases create rel-${SHORT_SHA} \
--delivery-pipeline quartz-manager-pipeline \
--description "$(git log -1 --pretty='%s')" \
--build-artifacts /workspace/artifacts.json \
--verbosity=debug \
--annotations "commit_ui=https://source.cloud.google.com/$PROJECT_ID/quartz-manager-standalone/+/$COMMIT_SHA"
artifacts:
objects:
location: 'gs://$PROJECT_ID-gcdeploy-artifacts/'
paths:
- '/workspace/artifacts.json'
options:
logging: CLOUD_LOGGING_ONLY

View File

@@ -0,0 +1,19 @@
{
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": [
"plugin:sonarjs/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"plugins": [
"sonarjs"
],
"root": true
}

View File

@@ -3,7 +3,7 @@
"version": 1, "version": 1,
"newProjectRoot": "projects", "newProjectRoot": "projects",
"projects": { "projects": {
"angular-spring-starter": { "quartz-manager-ui": {
"root": "", "root": "",
"prefix": "qrzmng", "prefix": "qrzmng",
"sourceRoot": "src", "sourceRoot": "src",
@@ -19,7 +19,7 @@
"tsConfig": "src/tsconfig.app.json", "tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts", "polyfills": "src/polyfills.ts",
"allowedCommonJsDependencies": [ "allowedCommonJsDependencies": [
"stompjs", "sockjs-client", "moment" "stompjs", "sockjs-client", "moment", "angular2-uuid"
], ],
"assets": [ "assets": [
"src/assets", "src/assets",
@@ -31,6 +31,14 @@
"scripts": [] "scripts": []
}, },
"configurations": { "configurations": {
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
},
"production": { "production": {
"budgets": [ "budgets": [
{ {
@@ -58,18 +66,18 @@
"serve": { "serve": {
"builder": "@angular-devkit/build-angular:dev-server", "builder": "@angular-devkit/build-angular:dev-server",
"options": { "options": {
"browserTarget": "angular-spring-starter:build" "browserTarget": "quartz-manager-ui:build:development"
}, },
"configurations": { "configurations": {
"production": { "production": {
"browserTarget": "angular-spring-starter:build:production" "browserTarget": "quartz-manager-ui:build:production"
} }
} }
}, },
"extract-i18n": { "extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n", "builder": "@angular-devkit/build-angular:extract-i18n",
"options": { "options": {
"browserTarget": "angular-spring-starter:build" "browserTarget": "quartz-manager-ui:build"
} }
}, },
"lint": { "lint": {
@@ -81,7 +89,7 @@
} }
} }
}, },
"angular-spring-starter-e2e": { "quartz-manager-ui-e2e": {
"root": "e2e", "root": "e2e",
"sourceRoot": "e2e", "sourceRoot": "e2e",
"projectType": "application", "projectType": "application",
@@ -90,7 +98,7 @@
"builder": "@angular-devkit/build-angular:protractor", "builder": "@angular-devkit/build-angular:protractor",
"options": { "options": {
"protractorConfig": "./protractor.conf.js", "protractorConfig": "./protractor.conf.js",
"devServerTarget": "angular-spring-starter:serve" "devServerTarget": "quartz-manager-ui:serve"
} }
}, },
"lint": { "lint": {

View File

@@ -27,7 +27,7 @@
"@fortawesome/fontawesome": "^1.1.4", "@fortawesome/fontawesome": "^1.1.4",
"@fortawesome/fontawesome-free-regular": "^5.0.8", "@fortawesome/fontawesome-free-regular": "^5.0.8",
"@fortawesome/fontawesome-free-solid": "^5.0.8", "@fortawesome/fontawesome-free-solid": "^5.0.8",
"@stomp/ng2-stompjs": "^0.6.3", "@stomp/rx-stomp": "1.2.0",
"core-js": "2.5.1", "core-js": "2.5.1",
"hammerjs": "2.0.8", "hammerjs": "2.0.8",
"moment": "^2.29.1", "moment": "^2.29.1",
@@ -62,6 +62,7 @@
"eslint-config-prettier": "^8.5.0", "eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0", "eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-sonarjs": "^0.16.0",
"jasmine-core": "~4.5.0", "jasmine-core": "~4.5.0",
"jasmine-spec-reporter": "~7.0.0", "jasmine-spec-reporter": "~7.0.0",
"jest": "28.1.3", "jest": "28.1.3",
@@ -4229,19 +4230,19 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/@stomp/ng2-stompjs": { "node_modules/@stomp/rx-stomp": {
"version": "0.6.4", "version": "1.2.0",
"license": "MIT", "resolved": "https://registry.npmjs.org/@stomp/rx-stomp/-/rx-stomp-1.2.0.tgz",
"integrity": "sha512-QLzPe3q0EwLB+cVWdUFEO4z5tyR+kPnXJANKN2UvB7Spz/oViHF959cydmXdQWaK7NHp86VO54TgFfXbHVnSLg==",
"dependencies": { "dependencies": {
"@stomp/stompjs": "^4.0.0 >=4.0.2" "@stomp/stompjs": "^6.0.0 >=6.1.1",
"angular2-uuid": "^1.1.1"
} }
}, },
"node_modules/@stomp/stompjs": { "node_modules/@stomp/rx-stomp/node_modules/@stomp/stompjs": {
"version": "4.0.8", "version": "6.1.2",
"license": "Apache-2.0", "resolved": "https://registry.npmjs.org/@stomp/stompjs/-/stompjs-6.1.2.tgz",
"optionalDependencies": { "integrity": "sha512-FHDTrIFM5Ospi4L3Xhj6v2+NzCVAeNDcBe95YjUWhWiRMrBF6uN3I7AUOlRgT6jU/2WQvvYK8ZaIxFfxFp+uHQ=="
"websocket": "^1.0.24"
}
}, },
"node_modules/@tootallnate/once": { "node_modules/@tootallnate/once": {
"version": "2.0.0", "version": "2.0.0",
@@ -5419,6 +5420,11 @@
"ajv": "^8.8.2" "ajv": "^8.8.2"
} }
}, },
"node_modules/angular2-uuid": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/angular2-uuid/-/angular2-uuid-1.1.1.tgz",
"integrity": "sha512-6AXPyii9q8KBFGagybLNVmdGJLPcVZAhmv3odNGSJIA18LuJ3xOe6uN9GvjlQsGfdmYeuxlsGnFEUu7gPhkc+g=="
},
"node_modules/ansi-colors": { "node_modules/ansi-colors": {
"version": "4.1.3", "version": "4.1.3",
"resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz",
@@ -8599,6 +8605,18 @@
} }
} }
}, },
"node_modules/eslint-plugin-sonarjs": {
"version": "0.16.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-0.16.0.tgz",
"integrity": "sha512-al8ojAzcQW8Eu0tWn841ldhPpPcjrJ59TzzTfAVWR45bWvdAASCmrGl8vK0MWHyKVDdC0i17IGbtQQ1KgxLlVA==",
"dev": true,
"engines": {
"node": ">=14"
},
"peerDependencies": {
"eslint": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
}
},
"node_modules/eslint-scope": { "node_modules/eslint-scope": {
"version": "5.1.1", "version": "5.1.1",
"dev": true, "dev": true,
@@ -22763,16 +22781,20 @@
"version": "3.1.0", "version": "3.1.0",
"dev": true "dev": true
}, },
"@stomp/ng2-stompjs": { "@stomp/rx-stomp": {
"version": "0.6.4", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/@stomp/rx-stomp/-/rx-stomp-1.2.0.tgz",
"integrity": "sha512-QLzPe3q0EwLB+cVWdUFEO4z5tyR+kPnXJANKN2UvB7Spz/oViHF959cydmXdQWaK7NHp86VO54TgFfXbHVnSLg==",
"requires": { "requires": {
"@stomp/stompjs": "^4.0.0 >=4.0.2" "@stomp/stompjs": "^6.0.0 >=6.1.1",
} "angular2-uuid": "^1.1.1"
}, },
"@stomp/stompjs": { "dependencies": {
"version": "4.0.8", "@stomp/stompjs": {
"requires": { "version": "6.1.2",
"websocket": "^1.0.24" "resolved": "https://registry.npmjs.org/@stomp/stompjs/-/stompjs-6.1.2.tgz",
"integrity": "sha512-FHDTrIFM5Ospi4L3Xhj6v2+NzCVAeNDcBe95YjUWhWiRMrBF6uN3I7AUOlRgT6jU/2WQvvYK8ZaIxFfxFp+uHQ=="
}
} }
}, },
"@tootallnate/once": { "@tootallnate/once": {
@@ -23670,6 +23692,11 @@
"fast-deep-equal": "^3.1.3" "fast-deep-equal": "^3.1.3"
} }
}, },
"angular2-uuid": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/angular2-uuid/-/angular2-uuid-1.1.1.tgz",
"integrity": "sha512-6AXPyii9q8KBFGagybLNVmdGJLPcVZAhmv3odNGSJIA18LuJ3xOe6uN9GvjlQsGfdmYeuxlsGnFEUu7gPhkc+g=="
},
"ansi-colors": { "ansi-colors": {
"version": "4.1.3", "version": "4.1.3",
"resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz",
@@ -26034,6 +26061,13 @@
"prettier-linter-helpers": "^1.0.0" "prettier-linter-helpers": "^1.0.0"
} }
}, },
"eslint-plugin-sonarjs": {
"version": "0.16.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-0.16.0.tgz",
"integrity": "sha512-al8ojAzcQW8Eu0tWn841ldhPpPcjrJ59TzzTfAVWR45bWvdAASCmrGl8vK0MWHyKVDdC0i17IGbtQQ1KgxLlVA==",
"dev": true,
"requires": {}
},
"eslint-scope": { "eslint-scope": {
"version": "5.1.1", "version": "5.1.1",
"dev": true, "dev": true,

View File

@@ -8,6 +8,8 @@
"build": "ng build --configuration production", "build": "ng build --configuration production",
"test": "jest", "test": "jest",
"lint": "ng lint", "lint": "ng lint",
"lint:sonar": "eslint --no-eslintrc -c .eslintrc.sonar.json \"src/**/*.ts\"",
"lint:sonar:fix": "eslint --no-eslintrc -c .eslintrc.sonar.json \"src/**/*.ts\" --fix",
"e2e": "ng e2e" "e2e": "ng e2e"
}, },
"private": true, "private": true,
@@ -30,7 +32,7 @@
"@fortawesome/fontawesome": "^1.1.4", "@fortawesome/fontawesome": "^1.1.4",
"@fortawesome/fontawesome-free-regular": "^5.0.8", "@fortawesome/fontawesome-free-regular": "^5.0.8",
"@fortawesome/fontawesome-free-solid": "^5.0.8", "@fortawesome/fontawesome-free-solid": "^5.0.8",
"@stomp/ng2-stompjs": "^0.6.3", "@stomp/rx-stomp": "1.2.0",
"core-js": "2.5.1", "core-js": "2.5.1",
"hammerjs": "2.0.8", "hammerjs": "2.0.8",
"moment": "^2.29.1", "moment": "^2.29.1",
@@ -65,6 +67,7 @@
"eslint-config-prettier": "^8.5.0", "eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0", "eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-sonarjs": "^0.16.0",
"jasmine-core": "~4.5.0", "jasmine-core": "~4.5.0",
"jasmine-spec-reporter": "~7.0.0", "jasmine-spec-reporter": "~7.0.0",
"jest": "28.1.3", "jest": "28.1.3",

View File

@@ -13,8 +13,8 @@ import {
} from '@angular/platform-browser-dynamic/testing'; } from '@angular/platform-browser-dynamic/testing';
// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
declare var __karma__: any; declare let __karma__: any;
declare var require: any; declare let require: any;
// Prevent Karma from running prematurely. // Prevent Karma from running prematurely.
__karma__.loaded = function () {}; __karma__.loaded = function () {};

View File

@@ -43,7 +43,8 @@ import {
SchedulerControlComponent, SchedulerControlComponent,
LogsPanelComponent, LogsPanelComponent,
ProgressPanelComponent, ProgressPanelComponent,
TriggerListComponent TriggerListComponent,
SimpleTriggerConfigComponent
} from './components'; } from './components';
import { import {
@@ -52,14 +53,13 @@ import {
UserService, UserService,
SchedulerService, SchedulerService,
ConfigService, ConfigService,
ProgressWebsocketService,
LogsWebsocketService,
getHtmlBaseUrl, getHtmlBaseUrl,
LogsRxWebsocketService,
ProgressRxWebsocketService,
TriggerService TriggerService
} from './services'; } from './services';
import { ForbiddenComponent } from './views/forbidden/forbidden.component'; import { ForbiddenComponent } from './views/forbidden/forbidden.component';
import { APP_BASE_HREF } from '@angular/common'; import { APP_BASE_HREF } from '@angular/common';
import {SimpleTriggerConfigComponent} from './components/simple-trigger-config';
import JobService from './services/job.service'; import JobService from './services/job.service';
import {GenericErrorComponent} from './views/error/genericError.component'; import {GenericErrorComponent} from './views/error/genericError.component';
@@ -67,31 +67,6 @@ export function initUserFactory(userService: UserService) {
return () => userService.fetchLoggedUser(); return () => userService.fetchLoggedUser();
} }
// const stompConfig: StompConfig = {
// // Which server?
// url: 'ws://localhost:8080/quartz-manager/progress',
// // Headers
// // Typical keys: login, passcode, host
// headers: {
// login: 'admin',
// passcode: 'admin'
// },
// // How often to heartbeat?
// // Interval in milliseconds, set to 0 to disable
// heartbeat_in: 0, // Typical value 0 - disabled
// heartbeat_out: 20000, // Typical value 20000 - every 20 seconds
// // Wait in milliseconds before attempting auto reconnect
// // Set to 0 to disable
// // Typical value 5000 (5 seconds)
// reconnect_delay: 5000,
// // Will log diagnostics on console
// debug: true
// };
export function jwtOptionsFactory(apiService: ApiService) { export function jwtOptionsFactory(apiService: ApiService) {
return { return {
tokenGetter: () => { tokenGetter: () => {
@@ -168,19 +143,13 @@ export function jwtOptionsFactory(apiService: ApiService) {
SchedulerService, SchedulerService,
JobService, JobService,
TriggerService, TriggerService,
ProgressWebsocketService, ProgressRxWebsocketService,
LogsWebsocketService, LogsRxWebsocketService,
AuthService, AuthService,
ApiService, ApiService,
UserService, UserService,
ConfigService, ConfigService,
MatIconRegistry MatIconRegistry
// StompService,
// ServerSocket
// {
// provide: StompConfig,
// useValue: stompConfig
// }
], ],
bootstrap: [AppComponent] bootstrap: [AppComponent]
}) })

View File

@@ -5,3 +5,4 @@ export * from './logs-panel';
export * from './scheduler-control'; export * from './scheduler-control';
export * from './progress-panel'; export * from './progress-panel';
export * from './trigger-list'; export * from './trigger-list';
export * from './simple-trigger-config';

View File

@@ -3,12 +3,16 @@
<mat-card-subtitle><b>JOB LOGS</b></mat-card-subtitle> <mat-card-subtitle><b>JOB LOGS</b></mat-card-subtitle>
</mat-card-header> </mat-card-header>
<mat-card-content style="position: relative; height: calc(100% - 3em);"> <mat-card-content style="position: relative; height: calc(100% - 3em);">
<div *ngIf="!logs || logs.length == 0" fxLayout="row" fxFlexAlign="center stretch" style="text-align: center"> <div *ngIf="!selectedTriggerName && (!logs || logs.length == 0)" fxLayout="row" fxFlexAlign="center stretch" style="text-align: center">
<div fxFill style="height: 100%;"> <div fxFill style="height: 100%;">
<img src="assets/image/logs.svg" alt="no logs" width="320" style="margin-top: 6em;" /> <img src="assets/image/logs.svg" alt="no logs" width="320" style="margin-top: 6em;" />
</div> </div>
</div> </div>
<div id="logs" style="overflow-y: auto; position: absolute; left: 0; right: 0; top: 0; bottom: 0; overflow: auto;"> <div *ngIf="isWaitingForLogs()" class="waitingLogs" fxLayout="column" fxLayoutAlign="center center" fxLayoutGap="12px">
<mat-spinner diameter="36"></mat-spinner>
<div>Waiting for logs from {{selectedTriggerName}}...</div>
</div>
<div id="logs" style="overflow-y: auto; position: absolute; left: 0; right: 0; top: 0; bottom: 0; overflow: auto;">
<div <div
*ngFor = "let log of logs; let first = first" fxLayout="row" fxLayout.xs="column" fxLayoutAlign="start" fxLayoutGap="10px"> *ngFor = "let log of logs; let first = first" fxLayout="row" fxLayout.xs="column" fxLayoutAlign="start" fxLayoutGap="10px">
<div fxFlex="0 1 300px"> <div fxFlex="0 1 300px">

View File

@@ -9,11 +9,18 @@
color: gold; color: gold;
} }
#logs{ #logs{
font-size: 1em; font-size: 1em;
} }
/* ===== Scrollbar CSS ===== */ .waitingLogs {
color: #6b7280;
height: 100%;
min-height: 180px;
text-align: center;
}
/* ===== Scrollbar CSS ===== */
/* Firefox */ /* Firefox */
* { * {
scrollbar-width: auto; scrollbar-width: auto;

View File

@@ -0,0 +1,113 @@
import {Subject} from 'rxjs';
import {LogsPanelComponent} from './logs-panel.component';
import {TriggerKey} from '../../model/triggerKey.model';
import {jest} from '@jest/globals';
describe('LogsPanelComponent', () => {
it('should subscribe to the selected trigger logs topic', () => {
const messages = new Subject<any>();
const logsRxWebsocketService = {
watch: jest.fn(() => messages.asObservable())
};
const component = new LogsPanelComponent(logsRxWebsocketService as any, null);
component.triggerKey = new TriggerKey('trigger-1', null);
expect(logsRxWebsocketService.watch).toHaveBeenCalledWith('/topic/logs/trigger-1');
expect(component.selectedTriggerName).toEqual('trigger-1');
expect(component.isWaitingForLogs()).toBeTruthy();
const logRecord = {
date: new Date(),
type: 'INFO',
message: 'job completed',
threadName: 'worker-1'
};
messages.next({body: JSON.stringify(logRecord)});
expect(component.logs[0]).toEqual({
time: logRecord.date.toISOString(),
type: 'INFO',
msg: 'job completed',
threadName: 'worker-1'
});
expect(component.isWaitingForLogs()).toBeFalsy();
});
it('should unsubscribe from the previous topic when the trigger changes', () => {
const firstMessages = new Subject<any>();
const secondMessages = new Subject<any>();
const logsRxWebsocketService = {
watch: jest.fn()
.mockReturnValueOnce(firstMessages.asObservable())
.mockReturnValueOnce(secondMessages.asObservable())
};
const component = new LogsPanelComponent(logsRxWebsocketService as any, null);
component.triggerKey = new TriggerKey('trigger-1', null);
const firstSubscription = component.topicSubscription;
jest.spyOn(firstSubscription, 'unsubscribe');
component.triggerKey = new TriggerKey('trigger-2', null);
expect(firstSubscription.unsubscribe).toHaveBeenCalled();
expect(logsRxWebsocketService.watch).toHaveBeenCalledWith('/topic/logs/trigger-2');
});
it('should clear logs when the trigger changes', () => {
const firstMessages = new Subject<any>();
const secondMessages = new Subject<any>();
const logsRxWebsocketService = {
watch: jest.fn()
.mockReturnValueOnce(firstMessages.asObservable())
.mockReturnValueOnce(secondMessages.asObservable())
.mockReturnValueOnce(firstMessages.asObservable())
};
const component = new LogsPanelComponent(logsRxWebsocketService as any, null);
component.triggerKey = new TriggerKey('trigger-1', null);
firstMessages.next({body: JSON.stringify({date: new Date(), type: 'INFO', message: 'first log', threadName: 'worker-1'})});
expect(component.logs.length).toEqual(1);
component.triggerKey = new TriggerKey('trigger-2', null);
expect(component.logs).toEqual([]);
expect(component.selectedTriggerName).toEqual('trigger-2');
expect(component.isWaitingForLogs()).toBeTruthy();
secondMessages.next({body: JSON.stringify({date: new Date(), type: 'INFO', message: 'second log', threadName: 'worker-2'})});
expect(component.logs.length).toEqual(1);
component.triggerKey = new TriggerKey('trigger-1', null);
expect(component.logs).toEqual([]);
expect(component.selectedTriggerName).toEqual('trigger-1');
expect(component.isWaitingForLogs()).toBeTruthy();
});
it('should clear logs when no trigger is selected', () => {
const messages = new Subject<any>();
const logsRxWebsocketService = {
watch: jest.fn(() => messages.asObservable())
};
const component = new LogsPanelComponent(logsRxWebsocketService as any, null);
component.triggerKey = new TriggerKey('trigger-1', null);
messages.next({body: JSON.stringify({date: new Date(), type: 'INFO', message: 'first log', threadName: 'worker-1'})});
component.triggerKey = null;
expect(component.logs).toEqual([]);
expect(component.selectedTriggerName).toBeNull();
expect(component.isWaitingForLogs()).toBeFalsy();
});
it('should ignore destroy when no topic was selected', () => {
const logsRxWebsocketService = {
watch: jest.fn()
};
const component = new LogsPanelComponent(logsRxWebsocketService as any, null);
expect(() => component.ngOnDestroy()).not.toThrow();
});
});

View File

@@ -1,42 +1,84 @@
import {Component, OnInit, Input, Output, EventEmitter} from '@angular/core'; import {Component, Input, OnDestroy, OnInit} from '@angular/core';
import {ApiService} from '../../services';
import {LogsRxWebsocketService} from '../../services/logs.rx-websocket.service';
import {map} from 'rxjs/operators';
import {TriggerKey} from '../../model/triggerKey.model';
import {LogsWebsocketService, ApiService} from '../../services';
import {Observable} from 'rxjs';
@Component({ @Component({
selector: 'logs-panel', selector: 'logs-panel',
templateUrl: './logs-panel.component.html', templateUrl: './logs-panel.component.html',
styleUrls: ['./logs-panel.component.scss'] styleUrls: ['./logs-panel.component.scss']
}) })
export class LogsPanelComponent implements OnInit { export class LogsPanelComponent implements OnInit, OnDestroy {
MAX_LOGS = 30; MAX_LOGS = 30;
logs = new Array(); logs = new Array();
selectedTriggerName: string;
topicSubscription;
private selectedTriggerKey: TriggerKey;
constructor( constructor(
private logsWebsocketService: LogsWebsocketService, private logsRxWebsocketService: LogsRxWebsocketService,
private apiService: ApiService private apiService: ApiService
) { ) {
} }
@Input()
set triggerKey(triggerKey: TriggerKey) {
if (!triggerKey || !triggerKey.name) {
this._unsubscribeFromTopic();
this.selectedTriggerKey = null;
this.selectedTriggerName = null;
this._resetLogs();
return;
}
if (this.selectedTriggerKey?.name === triggerKey.name) {
return;
}
this._resetLogs();
this.selectedTriggerKey = {...triggerKey} as TriggerKey;
this.selectedTriggerName = triggerKey.name;
this._subscribeToTheTopic(this.selectedTriggerKey);
}
isWaitingForLogs = (): boolean => !!this.selectedTriggerName && (!this.logs || this.logs.length === 0);
ngOnInit() { ngOnInit() {
const obs = this.logsWebsocketService.getObservable()
obs.subscribe({
'next': this.onNewLogMsg,
'error': (err) => {
console.log(err)
}
});
} }
onNewLogMsg = (receivedMsg) => { private _subscribeToTheTopic = (triggerKey: TriggerKey) => {
if (receivedMsg.type === 'SUCCESS') { this._unsubscribeFromTopic();
this._showNewLog(receivedMsg.message); this.topicSubscription = this.logsRxWebsocketService.watch(`/topic/logs/${triggerKey.name}`)
} else if (receivedMsg.type === 'ERROR') { .pipe(map((msg: any) => JSON.parse(msg.body)))
this._refreshSession(); .subscribe(this._showNewLog, (err) => {
} // if websocket has been closed for session expiration, try to refresh it console.log(err);
}; // TODO in case of 401
// this.apiService.get('/quartz-manager/session/refresh');
});
};
ngOnDestroy() {
this._unsubscribeFromTopic();
}
private _unsubscribeFromTopic() {
if (this.topicSubscription) {
this.topicSubscription.unsubscribe();
this.topicSubscription = null;
}
}
private _resetLogs() {
this.logs = [];
}
_showNewLog = (logRecord) => { _showNewLog = (logRecord) => {
if (this.logs.length > this.MAX_LOGS) { if (this.logs.length > this.MAX_LOGS) {

View File

@@ -6,12 +6,12 @@
</div> </div>
</div> --> </div> -->
<mat-card style="padding-bottom: 0"> <mat-card style="padding-bottom: 0" [ngClass]="{'progress-updated': progressUpdated}">
<mat-card-header> <mat-card-header>
<mat-card-subtitle><b>JOB PROGRESS</b></mat-card-subtitle> <mat-card-subtitle><b>JOB PROGRESS</b></mat-card-subtitle>
</mat-card-header> </mat-card-header>
<mat-card-content> <mat-card-content>
<div id="progressBarBox" *ngIf="progress.percentage !== -1"> <div id="progressBarBox" *ngIf="progress.percentage !== -1">
<mat-progress-bar mode="determinate" value="{{progress.percentage}}"></mat-progress-bar> <mat-progress-bar mode="determinate" value="{{progress.percentage}}"></mat-progress-bar>
{{percentageStr}} {{percentageStr}}
</div> </div>

View File

@@ -31,3 +31,21 @@
.fireBoxContent{ .fireBoxContent{
text-align: center; text-align: center;
} }
.progress-updated {
animation: progressUpdatePulse 700ms ease-out;
}
@keyframes progressUpdatePulse {
0% {
box-shadow: 0 0 0 0 rgba(63, 81, 181, 0.35);
}
45% {
box-shadow: 0 0 0 6px rgba(63, 81, 181, 0.16);
}
100% {
box-shadow: 0 0 0 0 rgba(63, 81, 181, 0);
}
}

View File

@@ -0,0 +1,102 @@
import {Subject} from 'rxjs';
import {ProgressPanelComponent} from './progress-panel.component';
import {TriggerKey} from '../../model/triggerKey.model';
import {jest} from '@jest/globals';
describe('ProgressPanelComponent', () => {
it('should subscribe to the selected trigger progress topic', () => {
jest.useFakeTimers();
const messages = new Subject<any>();
const progressRxWebsocketService = {
watch: jest.fn(() => messages.asObservable())
};
const component = new ProgressPanelComponent(progressRxWebsocketService as any);
component.triggerKey = new TriggerKey('trigger-1', null);
expect(progressRxWebsocketService.watch).toHaveBeenCalledWith('/topic/progress/trigger-1');
messages.next({body: JSON.stringify({percentage: 75, timesTriggered: 3})});
jest.runOnlyPendingTimers();
expect(component.progress.percentage).toEqual(75);
expect(component.percentageStr).toEqual('75%');
expect(component.progressUpdated).toBeTruthy();
jest.useRealTimers();
});
it('should unsubscribe from the previous topic when the trigger changes', () => {
const firstMessages = new Subject<any>();
const secondMessages = new Subject<any>();
const progressRxWebsocketService = {
watch: jest.fn()
.mockReturnValueOnce(firstMessages.asObservable())
.mockReturnValueOnce(secondMessages.asObservable())
};
const component = new ProgressPanelComponent(progressRxWebsocketService as any);
component.triggerKey = new TriggerKey('trigger-1', null);
const firstSubscription = component.topicSubscription;
jest.spyOn(firstSubscription, 'unsubscribe');
component.triggerKey = new TriggerKey('trigger-2', null);
expect(firstSubscription.unsubscribe).toHaveBeenCalled();
expect(progressRxWebsocketService.watch).toHaveBeenCalledWith('/topic/progress/trigger-2');
});
it('should reset progress when the trigger changes', () => {
const firstMessages = new Subject<any>();
const secondMessages = new Subject<any>();
const progressRxWebsocketService = {
watch: jest.fn()
.mockReturnValueOnce(firstMessages.asObservable())
.mockReturnValueOnce(secondMessages.asObservable())
.mockReturnValueOnce(firstMessages.asObservable())
};
const component = new ProgressPanelComponent(progressRxWebsocketService as any);
component.triggerKey = new TriggerKey('trigger-1', null);
firstMessages.next({body: JSON.stringify({percentage: 75, timesTriggered: 3})});
expect(component.progress.percentage).toEqual(75);
component.triggerKey = new TriggerKey('trigger-2', null);
expect(component.progress.percentage).toEqual(-1);
expect(component.percentageStr).toBeNull();
expect(component.progressUpdated).toBeFalsy();
secondMessages.next({body: JSON.stringify({percentage: 20, timesTriggered: 1})});
expect(component.progress.percentage).toEqual(20);
component.triggerKey = new TriggerKey('trigger-1', null);
expect(component.progress.percentage).toEqual(-1);
});
it('should reset progress when no trigger is selected', () => {
const messages = new Subject<any>();
const progressRxWebsocketService = {
watch: jest.fn(() => messages.asObservable())
};
const component = new ProgressPanelComponent(progressRxWebsocketService as any);
component.triggerKey = new TriggerKey('trigger-1', null);
messages.next({body: JSON.stringify({percentage: 75, timesTriggered: 3})});
component.triggerKey = null;
expect(component.progress.percentage).toEqual(-1);
expect(component.percentageStr).toBeNull();
expect(component.progressUpdated).toBeFalsy();
});
it('should ignore destroy when no topic was selected', () => {
const progressRxWebsocketService = {
watch: jest.fn()
};
const component = new ProgressPanelComponent(progressRxWebsocketService as any);
expect(() => component.ngOnDestroy()).not.toThrow();
});
});

View File

@@ -1,84 +1,91 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core' import {Component, Input, OnDestroy, OnInit} from '@angular/core'
import {ProgressWebsocketService, QuartzManagerWebsocketMessage} from '../../services';
import { Observable } from 'rxjs';
import TriggerFiredBundle from '../../model/trigger-fired-bundle.model'; import TriggerFiredBundle from '../../model/trigger-fired-bundle.model';
// import {Message} from '@stomp/stompjs'; import {TriggerKey} from '../../model/triggerKey.model';
import {ProgressRxWebsocketService} from '../../services/progress.rx-websocket.service';
// import { Subscription } from 'rxjs/Subscription'; import {map} from 'rxjs/operators';
// import {StompService} from '@stomp/ng2-stompjs';
// import { QueueingSubject } from 'queueing-subject'
// import websocketConnect from 'rxjs-websockets'
// import 'rxjs/add/operator/share'
// import {ServerSocket} from '../../services/qz.socket.service'
@Component({ @Component({
selector: 'progress-panel', selector: 'progress-panel',
templateUrl: './progress-panel.component.html', templateUrl: './progress-panel.component.html',
styleUrls: ['./progress-panel.component.scss'] styleUrls: ['./progress-panel.component.scss']
}) })
export class ProgressPanelComponent implements OnInit { export class ProgressPanelComponent implements OnInit, OnDestroy {
progress: TriggerFiredBundle = new TriggerFiredBundle(); progress: TriggerFiredBundle = ProgressPanelComponent._buildEmptyProgress();
percentageStr: string; percentageStr: string;
progressUpdated = false;
// // Stream of messages
// private subscription: Subscription;
// public messages: Observable<Message>;
// // Subscription status
// public subscribed: boolean;
// // Array of historic message (bodies)
// public mq: Array<string> = [];
topicSubscription;
private selectedTriggerKey: TriggerKey;
constructor( constructor(
private progressWebsocketService: ProgressWebsocketService, private progressRxWebsocketService: ProgressRxWebsocketService
// private _stompService: StompService,
// private serverSocket : ServerSocket
) { } ) { }
onNewProgressMsg = (receivedMsg: QuartzManagerWebsocketMessage) => { @Input()
if (receivedMsg.type === 'SUCCESS') { set triggerKey(triggerKey: TriggerKey) {
const newStatus = receivedMsg.message; if (!triggerKey || !triggerKey.name) {
this.progress = newStatus; this._unsubscribeFromTopic();
this.percentageStr = this.progress.percentage + '%'; this.selectedTriggerKey = null;
} this._resetProgress();
} return;
}
if (this.selectedTriggerKey?.name === triggerKey.name) {
return;
}
this._resetProgress();
this.selectedTriggerKey = {...triggerKey} as TriggerKey;
this._subscribeToTheTopic(this.selectedTriggerKey);
}
private _subscribeToTheTopic = (triggerKey: TriggerKey) => {
this._unsubscribeFromTopic();
this.topicSubscription = this.progressRxWebsocketService.watch(`/topic/progress/${triggerKey.name}`)
.pipe(map((msg: any) => JSON.parse(msg.body)))
.subscribe(this.onNewProgressMsg, (err) => {
console.log(err);
// TODO in case of 401
// this.apiService.get('/quartz-manager/session/refresh');
});
};
onNewProgressMsg = (receivedMsg) => {
this.progress = receivedMsg;
this.percentageStr = this.progress.percentage + '%';
this._markProgressUpdated();
}
ngOnInit() { ngOnInit() {
const obs = this.progressWebsocketService.getObservable() }
obs.subscribe({
'next' : this.onNewProgressMsg, ngOnDestroy() {
'error' : (err) => {console.log(err)} this._unsubscribeFromTopic();
}); }
// this.subscribed = false; private _unsubscribeFromTopic() {
// this.subscribe(); if (this.topicSubscription) {
this.topicSubscription.unsubscribe();
// this.serverSocket.connect() this.topicSubscription = null;
// this.socketSubscription = this.serverSocket.messages.subscribe((message: string) => { }
// console.log('received message from server: ', message) }
// })
} private _resetProgress() {
this.progress = ProgressPanelComponent._buildEmptyProgress();
// public subscribe() { this.percentageStr = null;
// if (this.subscribed) { this.progressUpdated = false;
// return; }
// }
private _markProgressUpdated() {
// // Stream of messages this.progressUpdated = false;
// this.messages = this._stompService.subscribe('/topic/progress'); setTimeout(() => this.progressUpdated = true);
}
// // Subscribe a function to be run on_next message
// this.subscription = this.messages.subscribe(this.on_next); private static _buildEmptyProgress() {
const progress = new TriggerFiredBundle();
// this.subscribed = true; progress.percentage = -1;
// } return progress;
}
// public on_next = (message: Message) => {
// this.mq.push(message.body + '\n'); }
// console.log(message);
// }
}

View File

@@ -13,6 +13,12 @@ import {MatDividerModule} from '@angular/material/divider';
describe('SchedulerControlComponent', () => { describe('SchedulerControlComponent', () => {
const schedulerUrl = '/quartz-manager/scheduler';
const schedulerButtonSelector = '#schedulerControllerBtn';
const schedulerName = 'test-scheduler';
const schedulerId = 'test-id';
const stoppedStatus = 'STOPPED';
let component: SchedulerControlComponent; let component: SchedulerControlComponent;
let fixture: ComponentFixture<SchedulerControlComponent>; let fixture: ComponentFixture<SchedulerControlComponent>;
@@ -38,16 +44,16 @@ describe('SchedulerControlComponent', () => {
it('should display the play button at the beginning since the scheduler is stopped', () => { it('should display the play button at the beginning since the scheduler is stopped', () => {
expect(component).toBeDefined(); expect(component).toBeDefined();
const getSchedulerReq = httpTestingController.expectOne('/quartz-manager/scheduler'); const getSchedulerReq = httpTestingController.expectOne(schedulerUrl);
const mockScheduler = new Scheduler('test-scheduler', 'test-id', 'STOPPED', []); const mockScheduler = new Scheduler(schedulerName, schedulerId, stoppedStatus, []);
getSchedulerReq.flush(mockScheduler); getSchedulerReq.flush(mockScheduler);
expect(component.scheduler).toEqual(mockScheduler); expect(component.scheduler).toEqual(mockScheduler);
expect(component.scheduler.status).toEqual('STOPPED'); expect(component.scheduler.status).toEqual(stoppedStatus);
fixture.detectChanges(); fixture.detectChanges();
const schedulerControlComponentDe: DebugElement = fixture.debugElement; const schedulerControlComponentDe: DebugElement = fixture.debugElement;
const schedulerBtnDe = schedulerControlComponentDe.query(By.css('#schedulerControllerBtn')); const schedulerBtnDe = schedulerControlComponentDe.query(By.css(schedulerButtonSelector));
expect(schedulerBtnDe).toBeTruthy(); expect(schedulerBtnDe).toBeTruthy();
const playIconDe = schedulerBtnDe.query(By.css('.fa-play')); const playIconDe = schedulerBtnDe.query(By.css('.fa-play'));
@@ -56,13 +62,13 @@ describe('SchedulerControlComponent', () => {
it('should switch the button to pause when the scheduler is started', () => { it('should switch the button to pause when the scheduler is started', () => {
expect(component).toBeDefined(); expect(component).toBeDefined();
const getSchedulerReq = httpTestingController.expectOne('/quartz-manager/scheduler'); const getSchedulerReq = httpTestingController.expectOne(schedulerUrl);
const mockScheduler = new Scheduler('test-scheduler', 'test-id', 'STOPPED', []); const mockScheduler = new Scheduler(schedulerName, schedulerId, stoppedStatus, []);
getSchedulerReq.flush(mockScheduler); getSchedulerReq.flush(mockScheduler);
fixture.detectChanges(); fixture.detectChanges();
const schedulerControlComponentDe: DebugElement = fixture.debugElement; const schedulerControlComponentDe: DebugElement = fixture.debugElement;
let schedulerBtnDe = schedulerControlComponentDe.query(By.css('#schedulerControllerBtn')); let schedulerBtnDe = schedulerControlComponentDe.query(By.css(schedulerButtonSelector));
expect(schedulerBtnDe).toBeTruthy(); expect(schedulerBtnDe).toBeTruthy();
const playIconDe = schedulerBtnDe.query(By.css('.fa-play')); const playIconDe = schedulerBtnDe.query(By.css('.fa-play'));
expect(playIconDe).toBeTruthy(); expect(playIconDe).toBeTruthy();
@@ -72,7 +78,7 @@ describe('SchedulerControlComponent', () => {
startSchedulerReq.flush(null); startSchedulerReq.flush(null);
fixture.detectChanges(); fixture.detectChanges();
schedulerBtnDe = schedulerControlComponentDe.query(By.css('#schedulerControllerBtn')); schedulerBtnDe = schedulerControlComponentDe.query(By.css(schedulerButtonSelector));
const pauseIconDe = schedulerBtnDe.query(By.css('.fa-pause')); const pauseIconDe = schedulerBtnDe.query(By.css('.fa-pause'));
expect(pauseIconDe).toBeTruthy(); expect(pauseIconDe).toBeTruthy();
@@ -80,13 +86,13 @@ describe('SchedulerControlComponent', () => {
it('should switch the button to play when the scheduler is stopped', () => { it('should switch the button to play when the scheduler is stopped', () => {
expect(component).toBeDefined(); expect(component).toBeDefined();
const getSchedulerReq = httpTestingController.expectOne('/quartz-manager/scheduler'); const getSchedulerReq = httpTestingController.expectOne(schedulerUrl);
const mockScheduler = new Scheduler('test-scheduler', 'test-id', 'RUNNING', []); const mockScheduler = new Scheduler(schedulerName, schedulerId, 'RUNNING', []);
getSchedulerReq.flush(mockScheduler); getSchedulerReq.flush(mockScheduler);
fixture.detectChanges(); fixture.detectChanges();
const schedulerControlComponentDe: DebugElement = fixture.debugElement; const schedulerControlComponentDe: DebugElement = fixture.debugElement;
let schedulerBtnDe = schedulerControlComponentDe.query(By.css('#schedulerControllerBtn')); let schedulerBtnDe = schedulerControlComponentDe.query(By.css(schedulerButtonSelector));
expect(schedulerBtnDe).toBeTruthy(); expect(schedulerBtnDe).toBeTruthy();
const pauseIconDe = schedulerBtnDe.query(By.css('.fa-pause')); const pauseIconDe = schedulerBtnDe.query(By.css('.fa-pause'));
expect(pauseIconDe).toBeTruthy(); expect(pauseIconDe).toBeTruthy();
@@ -96,7 +102,7 @@ describe('SchedulerControlComponent', () => {
startSchedulerReq.flush(null); startSchedulerReq.flush(null);
fixture.detectChanges(); fixture.detectChanges();
schedulerBtnDe = schedulerControlComponentDe.query(By.css('#schedulerControllerBtn')); schedulerBtnDe = schedulerControlComponentDe.query(By.css(schedulerButtonSelector));
const playIconDe = schedulerBtnDe.query(By.css('.fa-play')); const playIconDe = schedulerBtnDe.query(By.css('.fa-play'));
expect(playIconDe).toBeTruthy(); expect(playIconDe).toBeTruthy();

View File

@@ -23,6 +23,11 @@ import {MisfireInstruction} from '../../model/misfire-instruction.model';
describe('SimpleTriggerConfig', () => { describe('SimpleTriggerConfig', () => {
const submitButtonSelector = 'form button[color="primary"]';
const repeatIntervalSelector = '#repeatInterval';
const testTriggerName = 'test-trigger';
const testJobName = 'TestJob';
let component: SimpleTriggerConfigComponent; let component: SimpleTriggerConfigComponent;
let fixture: ComponentFixture<SimpleTriggerConfigComponent>; let fixture: ComponentFixture<SimpleTriggerConfigComponent>;
@@ -91,16 +96,16 @@ describe('SimpleTriggerConfig', () => {
fixture.detectChanges(); fixture.detectChanges();
const getJobsReq = httpTestingController.expectOne(`${CONTEXT_PATH}/jobs`); const getJobsReq = httpTestingController.expectOne(`${CONTEXT_PATH}/jobs`);
getJobsReq.flush(['TestJob']); getJobsReq.flush([testJobName]);
const componentDe: DebugElement = fixture.debugElement; const componentDe: DebugElement = fixture.debugElement;
const submitButton = componentDe.query(By.css('form button[color="primary"]')); const submitButton = componentDe.query(By.css(submitButtonSelector));
expect(submitButton.nativeElement.textContent.trim()).toEqual('Submit'); expect(submitButton.nativeElement.textContent.trim()).toEqual('Submit');
expect(submitButton.nativeElement.getAttribute('disabled')).toEqual(''); expect(submitButton.nativeElement.getAttribute('disabled')).toEqual('');
setInputValue(componentDe, '#triggerName', 'test-trigger'); setInputValue(componentDe, '#triggerName', testTriggerName);
expect(component.simpleTriggerReactiveForm.controls.triggerName.value).toEqual('test-trigger'); expect(component.simpleTriggerReactiveForm.controls.triggerName.value).toEqual(testTriggerName);
expect(submitButton.nativeElement.getAttribute('disabled')).toEqual(''); expect(submitButton.nativeElement.getAttribute('disabled')).toEqual('');
setMatSelectValueByIndex(componentDe, '#misfireInstruction', 0); setMatSelectValueByIndex(componentDe, '#misfireInstruction', 0);
expect(component.simpleTriggerReactiveForm.controls.misfireInstruction.value).toEqual('MISFIRE_INSTRUCTION_FIRE_NOW'); expect(component.simpleTriggerReactiveForm.controls.misfireInstruction.value).toEqual('MISFIRE_INSTRUCTION_FIRE_NOW');
@@ -111,7 +116,7 @@ describe('SimpleTriggerConfig', () => {
setInputValue(componentDe, '#repeatCount', '1000'); setInputValue(componentDe, '#repeatCount', '1000');
expect(submitButton.nativeElement.getAttribute('disabled')).toEqual(''); expect(submitButton.nativeElement.getAttribute('disabled')).toEqual('');
setInputValue(componentDe, '#repeatInterval', '2000'); setInputValue(componentDe, repeatIntervalSelector, '2000');
expect(submitButton.nativeElement.getAttribute('disabled')).toEqual(null); expect(submitButton.nativeElement.getAttribute('disabled')).toEqual(null);
} }
@@ -122,18 +127,18 @@ describe('SimpleTriggerConfig', () => {
it('should emit an event when a new trigger is submitted', () => { it('should emit an event when a new trigger is submitted', () => {
const componentDe: DebugElement = fixture.debugElement; const componentDe: DebugElement = fixture.debugElement;
const mockTrigger = new Trigger(); const mockTrigger = new Trigger();
mockTrigger.triggerKeyDTO = new TriggerKey('test-trigger', null); mockTrigger.triggerKeyDTO = new TriggerKey(testTriggerName, null);
mockTrigger.jobDetailDTO = <JobDetail>{jobClassName: 'TestJob', description: null}; mockTrigger.jobDetailDTO = <JobDetail>{jobClassName: testJobName, description: null};
mockTrigger.misfireInstruction = MisfireInstruction.MISFIRE_INSTRUCTION_FIRE_NOW; mockTrigger.misfireInstruction = MisfireInstruction.MISFIRE_INSTRUCTION_FIRE_NOW;
openFormAndFillAllMandatoryFields(); openFormAndFillAllMandatoryFields();
setInputValue(componentDe, '#repeatInterval', '2000'); setInputValue(componentDe, repeatIntervalSelector, '2000');
expect(component.simpleTriggerReactiveForm.controls.triggerRecurrence.value.repeatInterval).toEqual(2000); expect(component.simpleTriggerReactiveForm.controls.triggerRecurrence.value.repeatInterval).toEqual(2000);
setInputValue(componentDe, '#repeatCount', '100'); setInputValue(componentDe, '#repeatCount', '100');
expect(component.simpleTriggerReactiveForm.controls.triggerRecurrence.value.repeatCount).toEqual(100); expect(component.simpleTriggerReactiveForm.controls.triggerRecurrence.value.repeatCount).toEqual(100);
const submitButton = componentDe.query(By.css('form button[color="primary"]')); const submitButton = componentDe.query(By.css(submitButtonSelector));
expect(submitButton.nativeElement.textContent.trim()).toEqual('Submit'); expect(submitButton.nativeElement.textContent.trim()).toEqual('Submit');
let actualNewTrigger; let actualNewTrigger;
@@ -141,28 +146,28 @@ describe('SimpleTriggerConfig', () => {
submitButton.nativeElement.click(); submitButton.nativeElement.click();
const postSimpleTriggerReq = httpTestingController.expectOne(`${CONTEXT_PATH}/simple-triggers/test-trigger`); const postSimpleTriggerReq = httpTestingController.expectOne(`${CONTEXT_PATH}/simple-triggers/${testTriggerName}`);
postSimpleTriggerReq.flush(mockTrigger); postSimpleTriggerReq.flush(mockTrigger);
expect(actualNewTrigger).toEqual(mockTrigger); expect(actualNewTrigger).toEqual(mockTrigger);
}); });
it('should not emit an event when an existing trigger is edited', () => { it('should not emit an event when an existing trigger is edited', () => {
const mockTriggerKey = new TriggerKey('test-trigger', null); const mockTriggerKey = new TriggerKey(testTriggerName, null);
component.triggerKey = mockTriggerKey; component.triggerKey = mockTriggerKey;
fixture.detectChanges(); fixture.detectChanges();
const mockTrigger = new SimpleTrigger(); const mockTrigger = new SimpleTrigger();
mockTrigger.triggerKeyDTO = new TriggerKey('test-trigger', null); mockTrigger.triggerKeyDTO = new TriggerKey(testTriggerName, null);
mockTrigger.jobDetailDTO = <JobDetail>{jobClassName: 'TestJob', description: null}; mockTrigger.jobDetailDTO = <JobDetail>{jobClassName: testJobName, description: null};
mockTrigger.mayFireAgain = true; mockTrigger.mayFireAgain = true;
mockTrigger.misfireInstruction = MisfireInstruction.MISFIRE_INSTRUCTION_FIRE_NOW; mockTrigger.misfireInstruction = MisfireInstruction.MISFIRE_INSTRUCTION_FIRE_NOW;
const getSimpleTriggerReq = httpTestingController.expectOne(`${CONTEXT_PATH}/simple-triggers/test-trigger`); const getSimpleTriggerReq = httpTestingController.expectOne(`${CONTEXT_PATH}/simple-triggers/${testTriggerName}`);
getSimpleTriggerReq.flush(mockTrigger); getSimpleTriggerReq.flush(mockTrigger);
component.simpleTriggerReactiveForm.setValue({ component.simpleTriggerReactiveForm.setValue({
triggerName: 'test-trigger', triggerName: testTriggerName,
jobClass: 'TestJob', jobClass: testJobName,
triggerRecurrence: { triggerRecurrence: {
repeatInterval: 2000, repeatInterval: 2000,
repeatCount: 100, repeatCount: 100,
@@ -178,10 +183,10 @@ describe('SimpleTriggerConfig', () => {
fixture.detectChanges(); fixture.detectChanges();
const componentDe: DebugElement = fixture.debugElement; const componentDe: DebugElement = fixture.debugElement;
setInputValue(componentDe, '#repeatInterval', '4000'); setInputValue(componentDe, repeatIntervalSelector, '4000');
expect(component.simpleTriggerReactiveForm.controls.triggerRecurrence.value.repeatInterval).toEqual(4000); expect(component.simpleTriggerReactiveForm.controls.triggerRecurrence.value.repeatInterval).toEqual(4000);
const submitButton = componentDe.query(By.css('form button[color="primary"]')); const submitButton = componentDe.query(By.css(submitButtonSelector));
expect(submitButton.nativeElement.textContent.trim()).toEqual('Submit'); expect(submitButton.nativeElement.textContent.trim()).toEqual('Submit');
let actualNewTrigger; let actualNewTrigger;
@@ -189,7 +194,7 @@ describe('SimpleTriggerConfig', () => {
submitButton.nativeElement.click(); submitButton.nativeElement.click();
const putSimpleTriggerReq = httpTestingController.expectOne(`${CONTEXT_PATH}/simple-triggers/test-trigger`); const putSimpleTriggerReq = httpTestingController.expectOne(`${CONTEXT_PATH}/simple-triggers/${testTriggerName}`);
putSimpleTriggerReq.flush(mockTrigger); putSimpleTriggerReq.flush(mockTrigger);
expect(actualNewTrigger).toBeUndefined(); expect(actualNewTrigger).toBeUndefined();
@@ -220,8 +225,34 @@ describe('SimpleTriggerConfig', () => {
fixture.detectChanges(); fixture.detectChanges();
const componentDe: DebugElement = fixture.debugElement; const componentDe: DebugElement = fixture.debugElement;
const submitButton = componentDe.query(By.css('form button[color="primary"]')); const submitButton = componentDe.query(By.css(submitButtonSelector));
expect(submitButton.nativeElement.textContent.trim()).toEqual('Submit'); expect(submitButton.nativeElement.textContent.trim()).toEqual('Submit');
expect(component.simpleTriggerReactiveForm.value.triggerName).toBeNull();
});
it('should reset the form when a new trigger is selected', () => {
const mockTriggerKey = new TriggerKey(testTriggerName, null);
component.triggerKey = mockTriggerKey;
const mockTrigger = new SimpleTrigger();
mockTrigger.triggerKeyDTO = mockTriggerKey;
mockTrigger.jobDetailDTO = <JobDetail>{jobClassName: testJobName, description: null};
mockTrigger.mayFireAgain = true;
mockTrigger.misfireInstruction = MisfireInstruction.MISFIRE_INSTRUCTION_FIRE_NOW;
const getSimpleTriggerReq = httpTestingController.expectOne(`${CONTEXT_PATH}/simple-triggers/${testTriggerName}`);
getSimpleTriggerReq.flush(mockTrigger);
expect(component.simpleTriggerReactiveForm.value.triggerName).toEqual(testTriggerName);
component.triggerKey = null;
expect(component.simpleTriggerReactiveForm.value.triggerName).toBeNull();
expect(component.simpleTriggerReactiveForm.value.jobClass).toBeNull();
expect(component.shouldShowTheTriggerCardContent()).toBeTruthy();
}); });
it('should display the warning if there are no eligible jobs', () => { it('should display the warning if there are no eligible jobs', () => {

View File

@@ -34,9 +34,8 @@ export class SimpleTriggerConfigComponent implements OnInit {
scheduler: Scheduler; scheduler: Scheduler;
triggerLoading = true; triggerLoading = false;
private fetchedTriggers = false;
private triggerInProgress = false; private triggerInProgress = false;
private selectedTriggerKey: TriggerKey; private selectedTriggerKey: TriggerKey;
@@ -48,6 +47,9 @@ export class SimpleTriggerConfigComponent implements OnInit {
@Output() @Output()
onNewTrigger = new EventEmitter<SimpleTrigger>(); onNewTrigger = new EventEmitter<SimpleTrigger>();
@Output()
triggerFormOpenChange = new EventEmitter<boolean>();
constructor( constructor(
private formBuilder: UntypedFormBuilder, private formBuilder: UntypedFormBuilder,
private schedulerService: SchedulerService, private schedulerService: SchedulerService,
@@ -65,18 +67,37 @@ export class SimpleTriggerConfigComponent implements OnInit {
openTriggerForm() { openTriggerForm() {
this.enabledTriggerForm = true; this.enabledTriggerForm = true;
this.triggerFormOpenChange.emit(this.enabledTriggerForm);
} }
private closeTriggerForm() { private closeTriggerForm() {
this.enabledTriggerForm = false; this.enabledTriggerForm = false;
this.triggerFormOpenChange.emit(this.enabledTriggerForm);
} }
@Input() @Input()
set triggerKey(triggerKey: TriggerKey) { set triggerKey(triggerKey: TriggerKey) {
this.selectedTriggerKey = {...triggerKey} as TriggerKey; if (!triggerKey) {
this.fetchSelectedTrigger(); this.openNewTriggerForm();
} else if (!this.selectedTriggerKey || this.selectedTriggerKey.name !== triggerKey.name) {
this._resetTheTrigger();
this.selectedTriggerKey = {...triggerKey} as TriggerKey;
this.fetchSelectedTrigger();
this.closeTriggerForm();
}
} }
openNewTriggerForm() {
this._resetTheTrigger();
this.openTriggerForm();
}
private _resetTheTrigger() {
this.trigger = null;
this.triggerInProgress = false;
this.selectedTriggerKey = null;
this.simpleTriggerReactiveForm.reset(new SimpleTriggerReactiveForm());
}
fetchSelectedTrigger = () => { fetchSelectedTrigger = () => {
this.triggerLoading = true; this.triggerLoading = true;
@@ -94,7 +115,11 @@ export class SimpleTriggerConfigComponent implements OnInit {
existsATriggerInProgress = (): boolean => this.trigger && this.triggerInProgress; existsATriggerInProgress = (): boolean => this.trigger && this.triggerInProgress;
onResetReactiveForm = () => { onResetReactiveForm = () => {
this.simpleTriggerReactiveForm.setValue(this._fromTriggerToReactiveForm(this.trigger)); if (this.trigger) {
this.simpleTriggerReactiveForm.setValue(this._fromTriggerToReactiveForm(this.trigger));
} else {
this.simpleTriggerReactiveForm.reset(new SimpleTriggerReactiveForm());
}
this.closeTriggerForm(); this.closeTriggerForm();
}; };
@@ -103,13 +128,13 @@ export class SimpleTriggerConfigComponent implements OnInit {
this.schedulerService.updateSimpleTriggerConfig : this.schedulerService.saveSimpleTriggerConfig; this.schedulerService.updateSimpleTriggerConfig : this.schedulerService.saveSimpleTriggerConfig;
const simpleTriggerCommand = this._fromReactiveFormToCommand(); const simpleTriggerCommand = this._fromReactiveFormToCommand();
this.triggerLoading = true;
schedulerServiceCall(simpleTriggerCommand) schedulerServiceCall(simpleTriggerCommand)
.subscribe((retTrigger: SimpleTrigger) => { .subscribe((retTrigger: SimpleTrigger) => {
this.trigger = retTrigger; this.trigger = retTrigger;
this.simpleTriggerReactiveForm.setValue(this._fromTriggerToReactiveForm(retTrigger)); this.simpleTriggerReactiveForm.setValue(this._fromTriggerToReactiveForm(retTrigger));
this.fetchedTriggers = true;
this.triggerInProgress = this.trigger.mayFireAgain; this.triggerInProgress = this.trigger.mayFireAgain;
if (schedulerServiceCall === this.schedulerService.saveSimpleTriggerConfig) { if (schedulerServiceCall === this.schedulerService.saveSimpleTriggerConfig) {
@@ -118,8 +143,13 @@ export class SimpleTriggerConfigComponent implements OnInit {
this.closeTriggerForm(); this.closeTriggerForm();
}, error => { }, error => {
this.simpleTriggerReactiveForm.setValue(this._fromTriggerToReactiveForm(this.trigger)); if (this.trigger) {
}); this.simpleTriggerReactiveForm.setValue(this._fromTriggerToReactiveForm(this.trigger));
}
this.triggerLoading = false;
}, () => {
this.triggerLoading = false
});
} }

View File

@@ -9,7 +9,9 @@
<mat-card-content style="position: relative; height: 100%"> <mat-card-content style="position: relative; height: 100%">
<mat-nav-list style="overflow-y: auto; position: absolute; left: 0; right: 0; top: 0; bottom: 0; overflow: auto; height: calc(100% - 3em)"> <mat-nav-list style="overflow-y: auto; position: absolute; left: 0; right: 0; top: 0; bottom: 0; overflow: auto; height: calc(100% - 3em)">
<mat-list-item *ngFor="let triggerKey of getTriggerKeyList()" class="triggerItemList" <mat-list-item *ngFor="let triggerKey of getTriggerKeyList()" class="triggerItemList"
[ngClass]="{'selectedTrigger': selectedTrigger && selectedTrigger.name==triggerKey.name}"> [ngClass]="{'selectedTrigger': selectedTrigger && selectedTrigger.name==triggerKey.name}"
(click)="selectTrigger(triggerKey)"
>
<a matLine>{{ triggerKey.name }}</a> <a matLine>{{ triggerKey.name }}</a>
</mat-list-item> </mat-list-item>
</mat-nav-list> </mat-nav-list>

View File

@@ -81,16 +81,17 @@ export class TriggerListComponent implements OnInit {
} }
onNewTriggerBtnClicked() { onNewTriggerBtnClicked() {
if (this.getTriggerKeyList() && this.getTriggerKeyList().length > 0) { this.onNewTriggerClicked.emit();
this.dialog.open(UnsupportedMultipleJobsDialog) // if (this.getTriggerKeyList() && this.getTriggerKeyList().length > 0) {
} else { // this.dialog.open(UnsupportedMultipleJobsDialog)
this.onNewTriggerClicked.emit(); // } else {
} // this.onNewTriggerClicked.emit();
// }
} }
onNewTrigger(newTrigger: SimpleTrigger) { onNewTrigger(newTrigger: SimpleTrigger) {
this.newTriggers = [newTrigger, ...this.newTriggers]; this.newTriggers = [newTrigger, ...this.newTriggers];
this.selectedTrigger = newTrigger.triggerKeyDTO; this.selectTrigger(newTrigger.triggerKeyDTO);
} }
} }

View File

@@ -14,7 +14,7 @@
* Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
*/ */
/*************************************************************************************************** /** *************************************************************************************************
* BROWSER POLYFILLS * BROWSER POLYFILLS
*/ */
@@ -51,14 +51,14 @@ import 'core-js/es7/reflect';
/*************************************************************************************************** /** *************************************************************************************************
* Zone JS is required by Angular itself. * Zone JS is required by Angular itself.
*/ */
import 'zone.js/dist/zone'; // Included with Angular CLI. import 'zone.js/dist/zone'; // Included with Angular CLI.
/*************************************************************************************************** /** *************************************************************************************************
* APPLICATION IMPORTS * APPLICATION IMPORTS
*/ */
@@ -68,7 +68,7 @@ import 'zone.js/dist/zone'; // Included with Angular CLI.
*/ */
// import 'intl'; // Run `npm install --save intl`. // import 'intl'; // Run `npm install --save intl`.
/*************************************************************************************************** /** *************************************************************************************************
* MATERIAL 2 * MATERIAL 2
*/ */
import 'hammerjs/hammer'; import 'hammerjs/hammer';

View File

@@ -3,9 +3,8 @@ export * from './user.service';
export * from './config.service'; export * from './config.service';
export * from './auth.service'; export * from './auth.service';
export * from './scheduler.service'; export * from './scheduler.service';
export * from './websocket.service'; export * from './progress.rx-websocket.service';
export * from './progress.websocket.service'; export * from './logs.rx-websocket.service';
export * from './logs.websocket.service';
export * from './trigger.service' export * from './trigger.service'
export * from './job.service' export * from './job.service'

View File

@@ -0,0 +1,39 @@
import { TestBed } from '@angular/core/testing';
import { LogsRxWebsocketService } from './logs.rx-websocket.service';
import {ApiService} from './api.service';
import {RxStomp} from '@stomp/rx-stomp';
import {jest} from '@jest/globals';
describe('LogsRxWebsocketService', () => {
let service: LogsRxWebsocketService;
let configureSpy;
let activateSpy;
beforeEach(() => {
configureSpy = jest.spyOn(RxStomp.prototype, 'configure');
activateSpy = jest.spyOn(RxStomp.prototype, 'activate').mockImplementation(() => undefined);
TestBed.configureTestingModule({
providers: [
{provide: ApiService, useValue: {getToken: () => 'test-token'}}
]
});
service = TestBed.inject(LogsRxWebsocketService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
it('should configure rx-stomp with the logs websocket endpoint', () => {
expect(configureSpy).toHaveBeenCalled();
expect(activateSpy).toHaveBeenCalled();
const config = configureSpy.mock.calls[configureSpy.mock.calls.length - 1][0];
expect(config.heartbeatIncoming).toEqual(0);
expect(config.heartbeatOutgoing).toEqual(20000);
expect(config.reconnectDelay).toEqual(200);
expect(config.webSocketFactory.toString()).toContain('/logs?access_token=');
});
});

View File

@@ -0,0 +1,23 @@
import { Injectable } from '@angular/core';
import {RxStompService} from './rx-stomp.service';
import {ApiService} from './api.service';
import SockJS from 'sockjs-client';
import {CONTEXT_PATH, getBaseUrl} from './config.service';
@Injectable({
providedIn: 'root'
})
export class LogsRxWebsocketService extends RxStompService {
constructor(private apiService: ApiService) {
super({
webSocketFactory: () => new SockJS(`${getBaseUrl()}${CONTEXT_PATH}/logs?access_token=${this.apiService.getToken()}`),
heartbeatIncoming: 0,
heartbeatOutgoing: 20000,
reconnectDelay: 200,
debug: (msg: string): void => {
console.log(new Date(), msg);
}
});
}
}

View File

@@ -1,12 +0,0 @@
import {Injectable} from '@angular/core';
import {WebsocketService, ApiService, getBaseUrl, CONTEXT_PATH} from '.';
import {SocketOption} from '../model/SocketOption.model';
@Injectable()
export class LogsWebsocketService extends WebsocketService {
constructor(private apiService: ApiService) {
super(new SocketOption(getBaseUrl() + `${CONTEXT_PATH}/logs`, '/topic/logs', apiService.getToken))
}
}

View File

@@ -0,0 +1,39 @@
import { TestBed } from '@angular/core/testing';
import {RxStomp} from '@stomp/rx-stomp';
import {jest} from '@jest/globals';
import { ProgressRxWebsocketService } from './progress.rx-websocket.service';
import {ApiService} from './api.service';
describe('ProgressRxWebsocketService', () => {
let service: ProgressRxWebsocketService;
let configureSpy;
let activateSpy;
beforeEach(() => {
configureSpy = jest.spyOn(RxStomp.prototype, 'configure');
activateSpy = jest.spyOn(RxStomp.prototype, 'activate').mockImplementation(() => undefined);
TestBed.configureTestingModule({
providers: [
{provide: ApiService, useValue: {getToken: () => 'test-token'}}
]
});
service = TestBed.inject(ProgressRxWebsocketService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
it('should configure rx-stomp with the progress websocket endpoint', () => {
expect(configureSpy).toHaveBeenCalled();
expect(activateSpy).toHaveBeenCalled();
const config = configureSpy.mock.calls[configureSpy.mock.calls.length - 1][0];
expect(config.heartbeatIncoming).toEqual(0);
expect(config.heartbeatOutgoing).toEqual(20000);
expect(config.reconnectDelay).toEqual(200);
expect(config.webSocketFactory.toString()).toContain('/progress?access_token=');
});
});

View File

@@ -0,0 +1,23 @@
import { Injectable } from '@angular/core';
import {RxStompService} from './rx-stomp.service';
import {ApiService} from './api.service';
import SockJS from 'sockjs-client';
import {CONTEXT_PATH, getBaseUrl} from './config.service';
@Injectable({
providedIn: 'root'
})
export class ProgressRxWebsocketService extends RxStompService {
constructor(private apiService: ApiService) {
super({
webSocketFactory: () => new SockJS(`${getBaseUrl()}${CONTEXT_PATH}/progress?access_token=${this.apiService.getToken()}`),
heartbeatIncoming: 0,
heartbeatOutgoing: 20000,
reconnectDelay: 200,
debug: (msg: string): void => {
console.log(new Date(), msg);
}
});
}
}

View File

@@ -1,12 +0,0 @@
import {Injectable} from '@angular/core';
import {WebsocketService, ApiService, getBaseUrl, CONTEXT_PATH} from '.';
import {SocketOption} from '../model/SocketOption.model';
@Injectable()
export class ProgressWebsocketService extends WebsocketService {
constructor(private apiService: ApiService) {
super(new SocketOption(getBaseUrl() + `${CONTEXT_PATH}/progress`, '/topic/progress', apiService.getToken))
}
}

View File

@@ -0,0 +1,12 @@
import {RxStomp} from '@stomp/rx-stomp';
import {RxStompConfig} from '@stomp/rx-stomp/esm6/rx-stomp-config';
export class RxStompService extends RxStomp {
constructor(rxStompConfig: RxStompConfig) {
super();
super.configure(rxStompConfig);
super.activate();
}
}

View File

@@ -35,7 +35,7 @@ export class UserService {
this.currentUser = user; this.currentUser = user;
this.router.initialNavigation(); this.router.initialNavigation();
}, err => { }, err => {
console.log(`error retrieving current user due to ` + JSON.stringify(err)); console.log('error retrieving current user due to ' + JSON.stringify(err));
const httpErrorResponse = err as HttpErrorResponse; const httpErrorResponse = err as HttpErrorResponse;
if (httpErrorResponse.status === 404) { if (httpErrorResponse.status === 404) {
this.isAnAnonymousUser = true; this.isAnAnonymousUser = true;

View File

@@ -1,136 +0,0 @@
import {Observable, Subscriber} from 'rxjs';
import {SocketEndpoint} from '../model/SocketEndpoint.model'
import Stomp from 'stompjs';
import SockJS from 'sockjs-client';
import {SocketOption} from '../model/SocketOption.model';
interface WebsocketSubscriber {
index: number,
observer: Subscriber<any>
}
export interface QuartzManagerWebsocketMessage {
type: string;
message: any;
headers: any;
self: boolean;
}
export class WebsocketService {
_options: SocketOption;
_socket: SocketEndpoint = new SocketEndpoint();
observableStompConnection: Observable<any>;
subscribers: Array<WebsocketSubscriber> = [];
subscriberIndex = 0;
_messageIds: Array<any> = [];
reconnectionPromise: any;
constructor(options: SocketOption) {
this._options = options
this.createObservableSocket();
this.connect();
}
getOptions = () => {
}
private createObservableSocket = () => {
this.observableStompConnection = new Observable((observer) => {
const subscriberIndex = this.subscriberIndex++;
this.addToSubscribers({index: subscriberIndex, observer});
return () => this.removeFromSubscribers(subscriberIndex);
});
}
private addToSubscribers = (subscriber) => {
this.subscribers.push(subscriber);
}
private removeFromSubscribers = (index) => {
this.subscribers = this.subscribers.filter(subscriber => subscriber.index !== index);
}
getObservable = () => {
return this.observableStompConnection;
};
getMessage = function (data): QuartzManagerWebsocketMessage {
const out: QuartzManagerWebsocketMessage = <QuartzManagerWebsocketMessage>{};
out.type = 'SUCCESS';
out.message = JSON.parse(data.body);
out.headers = {};
out.headers.messageId = data.headers['message-id'];
const messageIdIndex = this._messageIds.indexOf(out.headers.messageId);
if (messageIdIndex > -1) {
out.self = true;
this._messageIds = this._messageIds.splice(messageIdIndex, 1);
}
return out;
};
_socketListener = (frame) => {
console.log('Connected: ' + frame);
this._socket.stomp.subscribe(
this._options.topicName,
data => this.subscribers.forEach(subscriber => subscriber.observer.next(this.getMessage(data)))
);
}
_onSocketError = (errorMsg) => {
const out: any = {};
out.type = 'ERROR';
out.message = errorMsg;
this.subscribers.forEach(subscriber => subscriber.observer.error(out));
this.scheduleReconnection();
}
scheduleReconnection = () => {
this.reconnectionPromise = setTimeout(() => {
console.log('Socket reconnecting... (if it fails, next attempt in ' + this._options.reconnectionTimeout + ' msec)');
this.connect();
}, this._options.reconnectionTimeout);
}
reconnectNow = function () {
this._socket.stomp.disconnect();
if (this.reconnectionPromise && this.reconnectionPromise.cancel) {
this.reconnectionPromise.cancel();
}
this.connect();
};
send = (message) => {
const id = Math.floor(Math.random() * 1000000);
this._socket.stomp.send(this._options.brokerName, {
priority: 9
}, JSON.stringify({
message: message,
id: id
}));
this._messageIds.push(id);
};
connect = () => {
const headers = {};
let socketUrl = this._options.socketUrl;
if (this._options.getAccessToken()) {
socketUrl += `?access_token=${this._options.getAccessToken()}`;
}
this._socket.client = new SockJS(socketUrl);
this._socket.stomp = Stomp.over(this._socket.client);
this._socket.stomp.connect(headers, this._socketListener, this._onSocketError);
this._socket.stomp.onclose = this.scheduleReconnection;
}
}

View File

@@ -19,18 +19,25 @@
<div fxFlex="1 1 350px"> <div fxFlex="1 1 350px">
<div fxLayout="row" fxFill> <div fxLayout="row" fxFill>
<div fxLayout="column" fxFill> <div fxLayout="column" fxFill>
<qrzmng-simple-trigger-config fxFill <qrzmng-simple-trigger-config fxFill
[triggerKey]="selectedTriggerKey" [triggerKey]="selectedTriggerKey"
(onNewTrigger)="onNewTriggerCreated($event)"> (triggerFormOpenChange)="setNewTriggerFormOpened($event)"
</qrzmng-simple-trigger-config> (onNewTrigger)="onNewTriggerCreated($event)">
</qrzmng-simple-trigger-config>
</div> </div>
</div> </div>
</div> </div>
<div fxFlex="1 1 auto" style="margin-left: 20px;"> <div fxFlex="1 1 auto" style="margin-left: 20px;">
<div fxFlex="1 1 auto" fxLayout="column" fxLayoutAlign="start stretch" fxLayoutGap="6px"> <div fxFlex="1 1 auto" fxLayout="column" fxLayoutAlign="start stretch" fxLayoutGap="6px">
<progress-panel></progress-panel> <progress-panel
<logs-panel fxFlex="1 1 auto" fxFill></logs-panel> [triggerKey]=selectedTriggerKey
>
</progress-panel>
<logs-panel fxFlex="1 1 auto" fxFill
[triggerKey]=selectedTriggerKey
>
</logs-panel>
</div> </div>
</div> </div>

View File

@@ -1,8 +1,4 @@
import {Component, OnInit, ViewChild} from '@angular/core'; import {Component, OnInit, ViewChild} from '@angular/core';
import {
ConfigService,
UserService
} from '../../services';
import {SimpleTrigger} from '../../model/simple-trigger.model'; import {SimpleTrigger} from '../../model/simple-trigger.model';
import {TriggerKey} from '../../model/triggerKey.model'; import {TriggerKey} from '../../model/triggerKey.model';
import {SimpleTriggerConfigComponent} from '../../components/simple-trigger-config'; import {SimpleTriggerConfigComponent} from '../../components/simple-trigger-config';
@@ -32,15 +28,25 @@ export class ManagerComponent implements OnInit {
} }
onNewTriggerRequested() { onNewTriggerRequested() {
this.triggerConfigComponent.openTriggerForm(); this.selectedTriggerKey = null;
this.newTriggerFormOpened = true;
if (this.triggerConfigComponent) {
this.triggerConfigComponent.openNewTriggerForm();
}
} }
onNewTriggerCreated(newTrigger: SimpleTrigger) { onNewTriggerCreated(newTrigger: SimpleTrigger) {
this.triggerListComponent.onNewTrigger(newTrigger); this.triggerListComponent.onNewTrigger(newTrigger);
this.newTriggerFormOpened = false;
} }
setSelectedTrigger(triggerKey: TriggerKey) { setSelectedTrigger(triggerKey: TriggerKey) {
this.selectedTriggerKey = triggerKey; this.selectedTriggerKey = triggerKey;
this.newTriggerFormOpened = false;
}
setNewTriggerFormOpened(opened: boolean) {
this.newTriggerFormOpened = opened;
} }
} }

View File

@@ -14,7 +14,7 @@
* Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
*/ */
/*************************************************************************************************** /** *************************************************************************************************
* BROWSER POLYFILLS * BROWSER POLYFILLS
*/ */
@@ -50,7 +50,7 @@ import 'core-js/es6/reflect';
/*************************************************************************************************** /** *************************************************************************************************
* Zone JS is required by Angular itself. * Zone JS is required by Angular itself.
*/ */
import 'zone.js/dist/zone'; // Included with Angular CLI. import 'zone.js/dist/zone'; // Included with Angular CLI.
@@ -59,7 +59,7 @@ import 'zone.js/dist/zone'; // Included with Angular CLI.
/*************************************************************************************************** /** *************************************************************************************************
* APPLICATION IMPORTS * APPLICATION IMPORTS
*/ */
@@ -69,7 +69,7 @@ import 'zone.js/dist/zone'; // Included with Angular CLI.
*/ */
// import 'intl'; // Run `npm install --save intl`. // import 'intl'; // Run `npm install --save intl`.
/*************************************************************************************************** /** *************************************************************************************************
* MATERIAL 2 * MATERIAL 2
*/ */
import 'hammerjs/hammer'; import 'hammerjs/hammer';

View File

@@ -1,5 +1,5 @@
/* SystemJS module definition */ /* SystemJS module definition */
declare var module: NodeModule; declare let module: NodeModule;
interface NodeModule { interface NodeModule {
id: string; id: string;
} }

View File

@@ -4,3 +4,4 @@
.classpath .classpath
.project .project
.idea .idea
/**/*.iml

View File

@@ -10,7 +10,7 @@
<groupId>it.fabioformosa.quartz-manager</groupId> <groupId>it.fabioformosa.quartz-manager</groupId>
<artifactId>quartz-manager-parent</artifactId> <artifactId>quartz-manager-parent</artifactId>
<version>4.0.8</version> <version>4.1.1</version>
<packaging>pom</packaging> <packaging>pom</packaging>
@@ -43,6 +43,7 @@
<properties> <properties>
<java.version>9</java.version> <java.version>9</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<org.projectlombok.version>1.18.30</org.projectlombok.version>
<maven-surefire-plugin.version>2.22.0</maven-surefire-plugin.version> <maven-surefire-plugin.version>2.22.0</maven-surefire-plugin.version>
<maven-failsafe-plugin.version>2.22.0</maven-failsafe-plugin.version> <maven-failsafe-plugin.version>2.22.0</maven-failsafe-plugin.version>
<jacoco-maven-plugin.version>0.8.8</jacoco-maven-plugin.version> <jacoco-maven-plugin.version>0.8.8</jacoco-maven-plugin.version>
@@ -50,6 +51,7 @@
<nexus-staging-maven-plugin.version>1.6.7</nexus-staging-maven-plugin.version> <nexus-staging-maven-plugin.version>1.6.7</nexus-staging-maven-plugin.version>
<maven-release-plugin.version>2.5.3</maven-release-plugin.version> <maven-release-plugin.version>2.5.3</maven-release-plugin.version>
<maven-gpg-plugin.version>3.0.1</maven-gpg-plugin.version> <maven-gpg-plugin.version>3.0.1</maven-gpg-plugin.version>
<sonar-maven-plugin.version>3.11.0.3922</sonar-maven-plugin.version>
<sonar.organization>fabioformosa</sonar.organization> <sonar.organization>fabioformosa</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url> <sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.exclusions> <sonar.exclusions>
@@ -78,27 +80,32 @@
<dependency> <dependency>
<groupId>it.fabioformosa.quartz-manager</groupId> <groupId>it.fabioformosa.quartz-manager</groupId>
<artifactId>quartz-manager-common</artifactId> <artifactId>quartz-manager-common</artifactId>
<version>4.0.8</version> <version>4.1.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>it.fabioformosa.quartz-manager</groupId> <groupId>it.fabioformosa.quartz-manager</groupId>
<artifactId>quartz-manager-starter-api</artifactId> <artifactId>quartz-manager-starter-api</artifactId>
<version>4.0.8</version> <version>4.1.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>it.fabioformosa.quartz-manager</groupId> <groupId>it.fabioformosa.quartz-manager</groupId>
<artifactId>quartz-manager-starter-security</artifactId> <artifactId>quartz-manager-starter-security</artifactId>
<version>4.0.8</version> <version>4.1.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>it.fabioformosa.quartz-manager</groupId> <groupId>it.fabioformosa.quartz-manager</groupId>
<artifactId>quartz-manager-starter-persistence</artifactId> <artifactId>quartz-manager-starter-persistence</artifactId>
<version>4.0.8</version> <version>4.1.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>it.fabioformosa.quartz-manager</groupId> <groupId>it.fabioformosa.quartz-manager</groupId>
<artifactId>quartz-manager-starter-ui</artifactId> <artifactId>quartz-manager-starter-ui</artifactId>
<version>4.0.8</version> <version>4.1.1</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${org.projectlombok.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
@@ -133,6 +140,11 @@
<artifactId>maven-failsafe-plugin</artifactId> <artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-failsafe-plugin.version}</version> <version>${maven-failsafe-plugin.version}</version>
</plugin> </plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>${sonar-maven-plugin.version}</version>
</plugin>
<plugin> <plugin>
<groupId>org.jacoco</groupId> <groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId> <artifactId>jacoco-maven-plugin</artifactId>
@@ -240,26 +252,25 @@
</activation> </activation>
<distributionManagement> <distributionManagement>
<snapshotRepository> <snapshotRepository>
<id>ossrh</id> <id>maven-central-release</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url> <url>https://central.sonatype.com/repository/maven-snapshots/</url>
</snapshotRepository> </snapshotRepository>
<repository> <repository>
<id>ossrh</id> <id>maven-central-release</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/ <url>https://central.sonatype.com</url>
</url>
</repository> </repository>
</distributionManagement> </distributionManagement>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.sonatype.plugins</groupId> <groupId>org.sonatype.central</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId> <artifactId>central-publishing-maven-plugin</artifactId>
<version>${nexus-staging-maven-plugin.version}</version> <version>0.10.0</version>
<extensions>true</extensions> <extensions>true</extensions>
<configuration> <configuration>
<serverId>ossrh</serverId> <publishingServerId>maven-central-release</publishingServerId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl> <autoPublish>true</autoPublish>
<autoReleaseAfterClose>true</autoReleaseAfterClose> <waitUntil>published</waitUntil>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>

View File

@@ -3,10 +3,14 @@
<parent> <parent>
<groupId>it.fabioformosa.quartz-manager</groupId> <groupId>it.fabioformosa.quartz-manager</groupId>
<artifactId>quartz-manager-parent</artifactId> <artifactId>quartz-manager-parent</artifactId>
<version>4.0.8</version> <version>4.1.1</version>
</parent> </parent>
<artifactId>quartz-manager-common</artifactId> <artifactId>quartz-manager-common</artifactId>
<name>Quartz Manager Common</name>
<description>Common components shared by Quartz Manager modules</description>
<url>https://github.com/fabioformosa/quartz-manager</url>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>it.fabioformosa.quartz-manager</groupId> <groupId>it.fabioformosa.quartz-manager</groupId>
<artifactId>quartz-manager-parent</artifactId> <artifactId>quartz-manager-parent</artifactId>
<version>4.0.8</version> <version>4.1.1</version>
</parent> </parent>
<artifactId>quartz-manager-starter-api</artifactId> <artifactId>quartz-manager-starter-api</artifactId>

View File

@@ -55,7 +55,8 @@ public class SchedulerConfig {
if (quartzProperties != null && quartzProperties.size() > 0) if (quartzProperties != null && quartzProperties.size() > 0)
mergedProperties.putAll(quartzProperties); mergedProperties.putAll(quartzProperties);
factory.setQuartzProperties(mergedProperties); factory.setQuartzProperties(mergedProperties);
factory.setAutoStartup(false); boolean isAutoStartup = mergedProperties.getProperty("org.quartz.scheduler.isAutoStartup") != null && mergedProperties.getProperty("org.quartz.scheduler.isAutoStartup").equals("true");
factory.setAutoStartup(isAutoStartup);
return factory; return factory;
} }
} }

View File

@@ -1,5 +1,6 @@
package it.fabioformosa.quartzmanager.api.configuration; package it.fabioformosa.quartzmanager.api.configuration;
import it.fabioformosa.quartzmanager.api.common.config.QuartzManagerPaths;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry; import org.springframework.messaging.simp.config.MessageBrokerRegistry;
@@ -14,14 +15,16 @@ public class WebsocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
@Override @Override
public void configureMessageBroker(MessageBrokerRegistry config) { public void configureMessageBroker(MessageBrokerRegistry config) {
config.enableSimpleBroker("/topic"); config.enableSimpleBroker("/topic"); //enable a simple memory-based message broker
config.setApplicationDestinationPrefixes("/job"); // on destinations prefixed with /topic
config.setApplicationDestinationPrefixes("/job"); // it designates the prefix for messages
// that are bound for methods annotated with @MessageMapping
} }
@Override @Override
public void registerStompEndpoints(StompEndpointRegistry registry) { public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/quartz-manager/logs").setAllowedOrigins("/**").withSockJS(); registry.addEndpoint(QuartzManagerPaths.QUARTZ_MANAGER_BASE_CONTEXT_PATH + "/logs").setAllowedOrigins("/**").withSockJS();
registry.addEndpoint("/quartz-manager/progress").setAllowedOrigins("/**").withSockJS(); registry.addEndpoint(QuartzManagerPaths.QUARTZ_MANAGER_BASE_CONTEXT_PATH + "/progress").setAllowedOrigins("/**").withSockJS();
} }
} }

View File

@@ -8,7 +8,10 @@ import org.springframework.stereotype.Controller;
@Controller @Controller
public class WebsocketController { public class WebsocketController {
@MessageMapping({ QuartzManagerPaths.QUARTZ_MANAGER_BASE_CONTEXT_PATH + "/logs", QuartzManagerPaths.QUARTZ_MANAGER_BASE_CONTEXT_PATH + "/progress" }) @MessageMapping({
QuartzManagerPaths.QUARTZ_MANAGER_BASE_CONTEXT_PATH + "/logs",
QuartzManagerPaths.QUARTZ_MANAGER_BASE_CONTEXT_PATH + "/progress"
})
@SendTo("/topic/logs") @SendTo("/topic/logs")
public String subscribe() { public String subscribe() {
return "subscribed"; return "subscribed";

View File

@@ -2,6 +2,7 @@ package it.fabioformosa.quartzmanager.api.converters;
import it.fabioformosa.quartzmanager.api.dto.SimpleTriggerCommandDTO; import it.fabioformosa.quartzmanager.api.dto.SimpleTriggerCommandDTO;
import org.quartz.JobDataMap;
import org.quartz.SimpleScheduleBuilder; import org.quartz.SimpleScheduleBuilder;
import org.quartz.SimpleTrigger; import org.quartz.SimpleTrigger;
import org.quartz.Trigger; import org.quartz.Trigger;
@@ -19,6 +20,8 @@ public class SimpleTriggerCommandDTOToSimpleTrigger implements Converter<SimpleT
if (triggerCommandDTO.getSimpleTriggerInputDTO().getEndDate() != null) if (triggerCommandDTO.getSimpleTriggerInputDTO().getEndDate() != null)
triggerTriggerBuilder.endAt(triggerCommandDTO.getSimpleTriggerInputDTO().getEndDate()); triggerTriggerBuilder.endAt(triggerCommandDTO.getSimpleTriggerInputDTO().getEndDate());
if (triggerCommandDTO.getSimpleTriggerInputDTO().getJobDataMap() != null)
triggerTriggerBuilder.usingJobData(new JobDataMap(triggerCommandDTO.getSimpleTriggerInputDTO().getJobDataMap()));
SimpleScheduleBuilder scheduleBuilder = SimpleScheduleBuilder.simpleSchedule(); SimpleScheduleBuilder scheduleBuilder = SimpleScheduleBuilder.simpleSchedule();
if (triggerCommandDTO.getSimpleTriggerInputDTO().getRepeatInterval() != null) if (triggerCommandDTO.getSimpleTriggerInputDTO().getRepeatInterval() != null)

View File

@@ -14,6 +14,7 @@ public class SimpleTriggerToSimpleTriggerDTO extends TriggerToTriggerDTO<SimpleT
target.setRepeatCount(source.getRepeatCount()); target.setRepeatCount(source.getRepeatCount());
target.setRepeatInterval(source.getRepeatInterval()); target.setRepeatInterval(source.getRepeatInterval());
target.setMisfireInstruction(source.getMisfireInstruction()); target.setMisfireInstruction(source.getMisfireInstruction());
target.setJobDataMap(source.getJobDataMap());
} }
@Override @Override

View File

@@ -3,8 +3,9 @@ package it.fabioformosa.quartzmanager.api.dto;
import it.fabioformosa.quartzmanager.api.validators.ValidTriggerRepetition; import it.fabioformosa.quartzmanager.api.validators.ValidTriggerRepetition;
import lombok.*; import lombok.*;
import lombok.experimental.SuperBuilder; import lombok.experimental.SuperBuilder;
import javax.annotation.Nullable;
import javax.validation.constraints.Positive; import javax.validation.constraints.Positive;
import java.util.Map;
@ValidTriggerRepetition @ValidTriggerRepetition
@SuperBuilder @SuperBuilder
@@ -18,4 +19,7 @@ public class SimpleTriggerInputDTO extends TriggerCommandDTO implements TriggerR
@Positive @Positive
private Long repeatInterval; private Long repeatInterval;
@Nullable
private Map<String, ?> jobDataMap;
} }

View File

@@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder; import lombok.experimental.SuperBuilder;
import org.quartz.JobDataMap;
import java.util.Date; import java.util.Date;
@@ -23,4 +24,5 @@ public class TriggerDTO {
private JobKeyDTO jobKeyDTO; private JobKeyDTO jobKeyDTO;
private JobDetailDTO jobDetailDTO; private JobDetailDTO jobDetailDTO;
private boolean mayFireAgain; private boolean mayFireAgain;
private JobDataMap jobDataMap;
} }

View File

@@ -38,11 +38,13 @@ public abstract class AbstractQuartzManagerJob implements Job {
LogRecord logMsg = doIt(jobExecutionContext); LogRecord logMsg = doIt(jobExecutionContext);
log.info(logMsg.getMessage()); log.info(logMsg.getMessage());
String triggerName = jobExecutionContext.getTrigger().getKey().getName();
logMsg.setThreadName(Thread.currentThread().getName()); logMsg.setThreadName(Thread.currentThread().getName());
webSocketLogsNotifier.send(logMsg); webSocketLogsNotifier.send(triggerName, logMsg);
TriggerFiredBundleDTO triggerFiredBundleDTO = WebSocketProgressNotifier.buildTriggerFiredBundle(jobExecutionContext); TriggerFiredBundleDTO triggerFiredBundleDTO = WebSocketProgressNotifier.buildTriggerFiredBundle(jobExecutionContext);
webSocketProgressNotifier.send(triggerFiredBundleDTO); webSocketProgressNotifier.send(triggerName, triggerFiredBundleDTO);
} }
} }

View File

@@ -14,7 +14,7 @@ public class WebSocketLogsNotifier implements WebhookSender<LogRecord> {
private SimpMessageSendingOperations messagingTemplate; private SimpMessageSendingOperations messagingTemplate;
@Override @Override
public void send(LogRecord logRecord) { public void send(String triggerName, LogRecord logRecord) {
messagingTemplate.convertAndSend(TOPIC_LOGS, logRecord); messagingTemplate.convertAndSend(TOPIC_LOGS + "/" + triggerName, logRecord);
} }
} }

View File

@@ -20,8 +20,8 @@ public class WebSocketProgressNotifier implements WebhookSender<TriggerFiredBund
private SimpMessageSendingOperations messagingTemplate; private SimpMessageSendingOperations messagingTemplate;
@Override @Override
public void send(TriggerFiredBundleDTO triggerFiredBundleDTO) { public void send(String triggerName, TriggerFiredBundleDTO triggerFiredBundleDTO) {
messagingTemplate.convertAndSend(TOPIC_PROGRESS, triggerFiredBundleDTO); messagingTemplate.convertAndSend(TOPIC_PROGRESS + "/" + triggerName, triggerFiredBundleDTO);
} }
public static TriggerFiredBundleDTO buildTriggerFiredBundle(JobExecutionContext jobExecutionContext) { public static TriggerFiredBundleDTO buildTriggerFiredBundle(JobExecutionContext jobExecutionContext) {

View File

@@ -9,6 +9,6 @@ package it.fabioformosa.quartzmanager.api.websockets;
*/ */
public interface WebhookSender<T> { public interface WebhookSender<T> {
void send(T message); void send(String triggerName, T message);
} }

View File

@@ -21,7 +21,8 @@ import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import java.util.Date; import java.util.Date;
import java.util.Map;
import static java.util.Map.entry;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
@@ -68,6 +69,10 @@ class SimpleTriggerControllerTest {
} }
private SimpleTriggerInputDTO buildACompleteSimpleTriggerCommandDTO() { private SimpleTriggerInputDTO buildACompleteSimpleTriggerCommandDTO() {
Map<String, ?> triggerJobDataMap = Map.ofEntries(
entry("customTriggerData1", "value1"),
entry("customTriggerData2", "value2")
);
return SimpleTriggerInputDTO.builder() return SimpleTriggerInputDTO.builder()
.jobClass("it.fabioformosa.quartzmanager.api.jobs.SampleJob") .jobClass("it.fabioformosa.quartzmanager.api.jobs.SampleJob")
.startDate(new Date()) .startDate(new Date())
@@ -75,6 +80,7 @@ class SimpleTriggerControllerTest {
.misfireInstruction(MisfireInstruction.MISFIRE_INSTRUCTION_FIRE_NOW) .misfireInstruction(MisfireInstruction.MISFIRE_INSTRUCTION_FIRE_NOW)
.repeatCount(5) .repeatCount(5)
.repeatInterval(1000L * 60 * 60) .repeatInterval(1000L * 60 * 60)
.jobDataMap(triggerJobDataMap)
.build(); .build();
} }

View File

@@ -2,12 +2,23 @@ package it.fabioformosa.quartzmanager.api.controllers.utils;
import it.fabioformosa.quartzmanager.api.common.utils.DateUtils; import it.fabioformosa.quartzmanager.api.common.utils.DateUtils;
import it.fabioformosa.quartzmanager.api.dto.*; import it.fabioformosa.quartzmanager.api.dto.*;
import org.quartz.JobDataMap;
import org.quartz.SimpleScheduleBuilder;
import org.quartz.SimpleTrigger;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Date;
import java.util.Map;
import static java.util.Map.entry;
public class TriggerUtils { public class TriggerUtils {
static public TriggerDTO getTriggerInstance(String triggerName){ static public TriggerDTO getTriggerInstance(String triggerName) {
return TriggerDTO.builder() return TriggerDTO.builder()
.description("sample trigger") .description("sample trigger")
.endTime(DateUtils.addHoursToNow(2L)) .endTime(DateUtils.addHoursToNow(2L))
@@ -28,7 +39,7 @@ public class TriggerUtils {
.build(); .build();
} }
static public SimpleTriggerDTO getSimpleTriggerInstance(String triggerName, SimpleTriggerInputDTO simpleTriggerInputDTO){ static public SimpleTriggerDTO getSimpleTriggerInstance(String triggerName, SimpleTriggerInputDTO simpleTriggerInputDTO) {
return SimpleTriggerDTO.builder() return SimpleTriggerDTO.builder()
.description("simple trigger") .description("simple trigger")
.repeatCount(simpleTriggerInputDTO.getRepeatCount()) .repeatCount(simpleTriggerInputDTO.getRepeatCount())
@@ -48,10 +59,11 @@ public class TriggerUtils {
.nextFireTime(DateUtils.addHoursToNow(1L)) .nextFireTime(DateUtils.addHoursToNow(1L))
.priority(1) .priority(1)
.startTime(DateUtils.fromLocalDateTimeToDate(LocalDateTime.now())) .startTime(DateUtils.fromLocalDateTimeToDate(LocalDateTime.now()))
.jobDataMap(new JobDataMap(simpleTriggerInputDTO.getJobDataMap()))
.build(); .build();
} }
static public SimpleTriggerDTO getSimpleTriggerInstance(String triggerName){ static public SimpleTriggerDTO getSimpleTriggerInstance(String triggerName) {
return SimpleTriggerDTO.builder() return SimpleTriggerDTO.builder()
.description("simple trigger") .description("simple trigger")
.repeatCount(2) .repeatCount(2)
@@ -71,6 +83,44 @@ public class TriggerUtils {
.nextFireTime(DateUtils.addHoursToNow(1L)) .nextFireTime(DateUtils.addHoursToNow(1L))
.priority(1) .priority(1)
.startTime(DateUtils.fromLocalDateTimeToDate(LocalDateTime.now())) .startTime(DateUtils.fromLocalDateTimeToDate(LocalDateTime.now()))
.jobDataMap(new JobDataMap(Map.ofEntries(entry("customTriggerData1", "value1"))))
.build();
}
static public SimpleTrigger buildSimpleTrigger() {
TriggerBuilder<Trigger> triggerTriggerBuilder = TriggerBuilder.newTrigger();
triggerTriggerBuilder.startAt(new Date());
triggerTriggerBuilder.endAt(DateUtils.addHoursToNow(1));
triggerTriggerBuilder.usingJobData(new JobDataMap(Map.ofEntries(entry("data", "value"))));
SimpleScheduleBuilder scheduleBuilder = SimpleScheduleBuilder.simpleSchedule();
scheduleBuilder.withIntervalInMilliseconds(1000);
scheduleBuilder.withRepeatCount(1);
scheduleBuilder.withMisfireHandlingInstructionFireNow();
return triggerTriggerBuilder.withSchedule(
scheduleBuilder
)
.withIdentity("simpleTrigger").build();
}
static public SimpleTriggerCommandDTO buildSimpleTriggerCommandDTO(String triggerName) throws ParseException {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date startDate = dateFormat.parse("2024-02-02");
Date endDate = dateFormat.parse("2024-03-02");
SimpleTriggerInputDTO triggerInputDTO = SimpleTriggerInputDTO.builder()
.misfireInstruction(MisfireInstruction.MISFIRE_INSTRUCTION_FIRE_NOW)
.jobClass("sample.jobClass")
.repeatCount(1)
.repeatInterval(1000L)
.startDate(startDate)
.endDate(endDate)
.jobDataMap(Map.ofEntries(entry("data", "value")))
.build();
return SimpleTriggerCommandDTO.builder()
.triggerName(triggerName)
.simpleTriggerInputDTO(triggerInputDTO)
.build(); .build();
} }

View File

@@ -0,0 +1,41 @@
package it.fabioformosa.quartzmanager.api.converters;
import it.fabioformosa.quartzmanager.api.controllers.utils.TriggerUtils;
import it.fabioformosa.quartzmanager.api.dto.SimpleTriggerCommandDTO;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.quartz.SimpleTrigger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.convert.ConversionService;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@SpringBootTest
class SimpleTriggerCommandDTOToSimpleTriggerTest {
@Autowired
private ConversionService conversionService;
@Order(1)
@Test
void givenSimpleTriggerCommandDTO_whenItIsConverted_thenASimpleTriggerIsReturned() throws ParseException {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date startDate = dateFormat.parse("2024-02-02");
Date endDate = dateFormat.parse("2024-03-02");
SimpleTriggerCommandDTO simpleTriggerCommandDTO = TriggerUtils.buildSimpleTriggerCommandDTO("mytrigger");
SimpleTrigger simpleTrigger = conversionService.convert(simpleTriggerCommandDTO, SimpleTrigger.class);
Assertions.assertThat(simpleTrigger).isNotNull();
Assertions.assertThat(simpleTrigger.getRepeatCount()).isEqualTo(simpleTriggerCommandDTO.getSimpleTriggerInputDTO().getRepeatCount());
Assertions.assertThat(simpleTrigger.getRepeatInterval()).isEqualTo(simpleTriggerCommandDTO.getSimpleTriggerInputDTO().getRepeatInterval());
Assertions.assertThat(simpleTrigger.getJobDataMap()).containsEntry("data", "value");
Assertions.assertThat(simpleTrigger.getStartTime()).isEqualTo(startDate);
Assertions.assertThat(simpleTrigger.getEndTime()).isEqualTo(endDate);
}
}

View File

@@ -0,0 +1,36 @@
package it.fabioformosa.quartzmanager.api.converters;
import it.fabioformosa.quartzmanager.api.controllers.utils.TriggerUtils;
import it.fabioformosa.quartzmanager.api.dto.SimpleTriggerDTO;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.quartz.SimpleTrigger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.convert.ConversionService;
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@SpringBootTest
class SimpleTriggerToSimpleTriggerDTOTest {
@Autowired
private ConversionService conversionService;
@Order(1)
@Test
void givenSimpleTrigger_whenItIsConverted_thenADtoIsReturned() {
SimpleTrigger simpleTrigger = TriggerUtils.buildSimpleTrigger();
SimpleTriggerDTO simpleTriggerDTO = conversionService.convert(simpleTrigger, SimpleTriggerDTO.class);
Assertions.assertThat(simpleTriggerDTO).isNotNull();
Assertions.assertThat(simpleTriggerDTO.getRepeatCount()).isEqualTo(simpleTrigger.getRepeatCount());
Assertions.assertThat(simpleTriggerDTO.getRepeatInterval()).isEqualTo(simpleTrigger.getRepeatInterval());
Assertions.assertThat(simpleTriggerDTO.getJobDataMap()).containsEntry("data", "value");
Assertions.assertThat(simpleTriggerDTO.getStartTime()).isEqualTo(simpleTrigger.getStartTime());
Assertions.assertThat(simpleTriggerDTO.getEndTime()).isEqualTo(simpleTrigger.getEndTime());
}
}

View File

@@ -4,16 +4,26 @@ import it.fabioformosa.quartzmanager.api.dto.TriggerFiredBundleDTO;
import it.fabioformosa.quartzmanager.api.jobs.entities.LogRecord; import it.fabioformosa.quartzmanager.api.jobs.entities.LogRecord;
import it.fabioformosa.quartzmanager.api.websockets.WebhookSender; import it.fabioformosa.quartzmanager.api.websockets.WebhookSender;
import org.assertj.core.api.Assertions; import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.InjectMocks; import org.mockito.InjectMocks;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.mockito.MockitoAnnotations; import org.mockito.junit.jupiter.MockitoExtension;
import org.quartz.*; import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobKey;
import org.quartz.ScheduleBuilder;
import org.quartz.SimpleScheduleBuilder;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq;
@ExtendWith(MockitoExtension.class)
class SampleJobTest { class SampleJobTest {
@InjectMocks @InjectMocks
@@ -24,14 +34,16 @@ class SampleJobTest {
@Mock @Mock
private WebhookSender<LogRecord> webSocketLogsNotifier; private WebhookSender<LogRecord> webSocketLogsNotifier;
@BeforeEach @Captor
void setUp() { private ArgumentCaptor<LogRecord> logRecordCaptor;
MockitoAnnotations.openMocks(this);
} @Captor
private ArgumentCaptor<TriggerFiredBundleDTO> triggerFiredBundleDTOCaptor;
@Test @Test
void givenASampleJob_whenTheJobIsExecuted_thenTheWebhookSendersAreCalled() { void givenASampleJob_whenTheJobIsExecuted_thenTheWebhookSendersAreCalled() {
JobExecutionContext jobExecutionContext = Mockito.mock(JobExecutionContext.class); JobExecutionContext jobExecutionContext = Mockito.mock(JobExecutionContext.class);
String triggerName = "test-trigger";
ScheduleBuilder schedulerBuilder = SimpleScheduleBuilder.simpleSchedule() ScheduleBuilder schedulerBuilder = SimpleScheduleBuilder.simpleSchedule()
.withRepeatCount(5) .withRepeatCount(5)
@@ -40,6 +52,7 @@ class SampleJobTest {
.newJob(SampleJob.class).withIdentity(JobKey.jobKey("test-job")) .newJob(SampleJob.class).withIdentity(JobKey.jobKey("test-job"))
.build(); .build();
Trigger trigger = TriggerBuilder.newTrigger() Trigger trigger = TriggerBuilder.newTrigger()
.withIdentity(triggerName)
.forJob(jobDetail) .forJob(jobDetail)
.withSchedule(schedulerBuilder) .withSchedule(schedulerBuilder)
.build(); .build();
@@ -47,24 +60,23 @@ class SampleJobTest {
Mockito.when(jobExecutionContext.getJobDetail()).thenReturn(jobDetail); Mockito.when(jobExecutionContext.getJobDetail()).thenReturn(jobDetail);
sampleJob.execute(jobExecutionContext); sampleJob.execute(jobExecutionContext);
Mockito.verify(webSocketLogsNotifier).send(argThat(actualLogRecord -> { Mockito.verify(webSocketLogsNotifier).send(eq(triggerName), logRecordCaptor.capture());
Assertions.assertThat(actualLogRecord.getMessage()).isEqualTo("Hello!"); LogRecord actualLogRecord = logRecordCaptor.getValue();
Assertions.assertThat(actualLogRecord.getType()).isEqualTo(LogRecord.LogType.INFO); Assertions.assertThat(actualLogRecord.getMessage()).isEqualTo("Hello!");
Assertions.assertThat(actualLogRecord.getDate()).isNotNull(); Assertions.assertThat(actualLogRecord.getType()).isEqualTo(LogRecord.LogType.INFO);
Assertions.assertThat(actualLogRecord.getThreadName()).isNotNull(); Assertions.assertThat(actualLogRecord.getDate()).isNotNull();
return true; Assertions.assertThat(actualLogRecord.getThreadName()).isNotNull();
}));
Mockito.verify(webSocketProgressNotifier).send(argThat(triggerFiredBundleDTO -> { Mockito.verify(webSocketProgressNotifier).send(eq(triggerName), triggerFiredBundleDTOCaptor.capture());
Assertions.assertThat(triggerFiredBundleDTO.getJobKey()).isEqualTo("test-job"); TriggerFiredBundleDTO triggerFiredBundleDTO = triggerFiredBundleDTOCaptor.getValue();
Assertions.assertThat(triggerFiredBundleDTO.getRepeatCount()).isEqualTo(6); Assertions.assertThat(triggerFiredBundleDTO.getJobKey()).isEqualTo("test-job");
Assertions.assertThat(triggerFiredBundleDTO.getJobClass()).isEqualTo(SampleJob.class.getName()); Assertions.assertThat(triggerFiredBundleDTO.getRepeatCount()).isEqualTo(6);
Assertions.assertThat(triggerFiredBundleDTO.getTimesTriggered()).isZero(); Assertions.assertThat(triggerFiredBundleDTO.getJobClass()).isEqualTo(SampleJob.class.getName());
Assertions.assertThat(triggerFiredBundleDTO.getNextFireTime()).isNull(); Assertions.assertThat(triggerFiredBundleDTO.getTimesTriggered()).isZero();
Assertions.assertThat(triggerFiredBundleDTO.getPercentage()).isZero(); Assertions.assertThat(triggerFiredBundleDTO.getNextFireTime()).isNull();
Assertions.assertThat(triggerFiredBundleDTO.getFinalFireTime()).isNotNull(); Assertions.assertThat(triggerFiredBundleDTO.getPercentage()).isZero();
Assertions.assertThat(triggerFiredBundleDTO.getPreviousFireTime()).isNull(); Assertions.assertThat(triggerFiredBundleDTO.getFinalFireTime()).isNotNull();
return true; Assertions.assertThat(triggerFiredBundleDTO.getPreviousFireTime()).isNull();
}));
} }
@Test @Test

View File

@@ -18,13 +18,17 @@ import java.util.Date;
@SpringBootTest @SpringBootTest
class SimpleTriggerServiceIntegrationTest { class SimpleTriggerServiceIntegrationTest {
private static final String SAMPLE_JOB_CLASS = "it.fabioformosa.quartzmanager.api.jobs.SampleJob";
private static final String SAMPLE_EXTRA_JOB_CLASS = "it.fabioformosa.samplepackage.SampleExtraJob";
private static final String FIRST_TRIGGER_SUFFIX = "A";
private static final String SECOND_TRIGGER_SUFFIX = "B";
@Autowired @Autowired
private SimpleTriggerService simpleTriggerService; private SimpleTriggerService simpleTriggerService;
@Test @Test
void givenASimpleTriggerCommandDTOWithAllData_whenANewSimpleTriggerIsScheduled_thenShouldGetATriggertDTO() throws SchedulerException, ClassNotFoundException { void givenASimpleTriggerCommandDTOWithAllData_whenANewSimpleTriggerIsScheduled_thenShouldGetATriggertDTO() throws SchedulerException, ClassNotFoundException {
String simpleTriggerTestName = "simpleTriggerWithAllData"; String simpleTriggerTestName = "simpleTriggerWithAllData";
String jobClass = "it.fabioformosa.quartzmanager.api.jobs.SampleJob";
Date startDate = new Date(); Date startDate = new Date();
Date endDate = DateUtils.addHoursToNow(5); Date endDate = DateUtils.addHoursToNow(5);
int repeatCount = 3; int repeatCount = 3;
@@ -41,7 +45,7 @@ class SimpleTriggerServiceIntegrationTest {
.repeatCount(repeatCount) .repeatCount(repeatCount)
.repeatInterval(repeatInterval) .repeatInterval(repeatInterval)
.misfireInstruction(misfireInstructionFireNow) .misfireInstruction(misfireInstructionFireNow)
.jobClass(jobClass) .jobClass(SAMPLE_JOB_CLASS)
.build()) .build())
.build(); .build();
SimpleTriggerDTO simpleTriggerDTO = simpleTriggerService.scheduleSimpleTrigger(simpleTriggerCommand); SimpleTriggerDTO simpleTriggerDTO = simpleTriggerService.scheduleSimpleTrigger(simpleTriggerCommand);
@@ -61,12 +65,11 @@ class SimpleTriggerServiceIntegrationTest {
@Test @Test
void givenASimpleTriggerCommandDTOWithMissingOptionalField_whenANewSimpleTriggerIsScheduled_thenShouldGetATriggertDTO() throws SchedulerException, ClassNotFoundException { void givenASimpleTriggerCommandDTOWithMissingOptionalField_whenANewSimpleTriggerIsScheduled_thenShouldGetATriggertDTO() throws SchedulerException, ClassNotFoundException {
String simpleTriggerTestName = "simpleTriggerWithoutOptionalData"; String simpleTriggerTestName = "simpleTriggerWithoutOptionalData";
String jobClass = "it.fabioformosa.quartzmanager.api.jobs.SampleJob";
SimpleTriggerCommandDTO simpleTriggerCommand = SimpleTriggerCommandDTO.builder() SimpleTriggerCommandDTO simpleTriggerCommand = SimpleTriggerCommandDTO.builder()
.triggerName(simpleTriggerTestName) .triggerName(simpleTriggerTestName)
.simpleTriggerInputDTO(SimpleTriggerInputDTO.builder() .simpleTriggerInputDTO(SimpleTriggerInputDTO.builder()
.jobClass(jobClass) .jobClass(SAMPLE_JOB_CLASS)
.build()) .build())
.build(); .build();
SimpleTriggerDTO simpleTriggerDTO = simpleTriggerService.scheduleSimpleTrigger(simpleTriggerCommand); SimpleTriggerDTO simpleTriggerDTO = simpleTriggerService.scheduleSimpleTrigger(simpleTriggerCommand);
@@ -81,4 +84,49 @@ class SimpleTriggerServiceIntegrationTest {
Assertions.assertThat(simpleTriggerDTO.getRepeatInterval()).isZero(); Assertions.assertThat(simpleTriggerDTO.getRepeatInterval()).isZero();
} }
@Test
void givenTwoSimpleTriggerCommandDTOsForTheSameJob_whenScheduled_thenShouldCreateTwoTriggers() throws SchedulerException, ClassNotFoundException {
String triggerNamePrefix = "sameJobTrigger" + System.nanoTime();
SimpleTriggerDTO firstTrigger = simpleTriggerService.scheduleSimpleTrigger(
buildSimpleTriggerCommand(triggerNamePrefix + FIRST_TRIGGER_SUFFIX, SAMPLE_JOB_CLASS)
);
SimpleTriggerDTO secondTrigger = simpleTriggerService.scheduleSimpleTrigger(
buildSimpleTriggerCommand(triggerNamePrefix + SECOND_TRIGGER_SUFFIX, SAMPLE_JOB_CLASS)
);
Assertions.assertThat(firstTrigger.getTriggerKeyDTO().getName()).isEqualTo(triggerNamePrefix + FIRST_TRIGGER_SUFFIX);
Assertions.assertThat(secondTrigger.getTriggerKeyDTO().getName()).isEqualTo(triggerNamePrefix + SECOND_TRIGGER_SUFFIX);
Assertions.assertThat(firstTrigger.getJobDetailDTO().getJobClassName()).isEqualTo(SAMPLE_JOB_CLASS);
Assertions.assertThat(secondTrigger.getJobDetailDTO().getJobClassName()).isEqualTo(SAMPLE_JOB_CLASS);
Assertions.assertThat(firstTrigger.getJobKeyDTO().getName()).isNotEqualTo(secondTrigger.getJobKeyDTO().getName());
}
@Test
void givenTwoSimpleTriggerCommandDTOsForDifferentJobs_whenScheduled_thenShouldCreateTwoTriggers() throws SchedulerException, ClassNotFoundException {
String triggerNamePrefix = "differentJobTrigger" + System.nanoTime();
SimpleTriggerDTO firstTrigger = simpleTriggerService.scheduleSimpleTrigger(
buildSimpleTriggerCommand(triggerNamePrefix + FIRST_TRIGGER_SUFFIX, SAMPLE_JOB_CLASS)
);
SimpleTriggerDTO secondTrigger = simpleTriggerService.scheduleSimpleTrigger(
buildSimpleTriggerCommand(triggerNamePrefix + SECOND_TRIGGER_SUFFIX, SAMPLE_EXTRA_JOB_CLASS)
);
Assertions.assertThat(firstTrigger.getTriggerKeyDTO().getName()).isEqualTo(triggerNamePrefix + FIRST_TRIGGER_SUFFIX);
Assertions.assertThat(secondTrigger.getTriggerKeyDTO().getName()).isEqualTo(triggerNamePrefix + SECOND_TRIGGER_SUFFIX);
Assertions.assertThat(firstTrigger.getJobDetailDTO().getJobClassName()).isEqualTo(SAMPLE_JOB_CLASS);
Assertions.assertThat(secondTrigger.getJobDetailDTO().getJobClassName()).isEqualTo(SAMPLE_EXTRA_JOB_CLASS);
}
private static SimpleTriggerCommandDTO buildSimpleTriggerCommand(String triggerName, String jobClass) {
return SimpleTriggerCommandDTO.builder()
.triggerName(triggerName)
.simpleTriggerInputDTO(SimpleTriggerInputDTO.builder()
.jobClass(jobClass)
.startDate(DateUtils.addHoursToNow(1))
.build())
.build();
}
} }

View File

@@ -0,0 +1,48 @@
package it.fabioformosa.quartzmanager.api.websockets;
import it.fabioformosa.quartzmanager.api.dto.TriggerFiredBundleDTO;
import it.fabioformosa.quartzmanager.api.jobs.entities.LogRecord;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.springframework.messaging.simp.SimpMessageSendingOperations;
import static org.mockito.MockitoAnnotations.openMocks;
class WebSocketNotifierTest {
@InjectMocks
private WebSocketLogsNotifier webSocketLogsNotifier;
@InjectMocks
private WebSocketProgressNotifier webSocketProgressNotifier;
@Mock
private SimpMessageSendingOperations messagingTemplate;
@BeforeEach
void setUp() {
openMocks(this);
}
@Test
void givenATriggerName_whenALogIsSent_thenShouldSendItToTheTriggerLogsTopic() {
LogRecord logRecord = new LogRecord(LogRecord.LogType.INFO, "Hello!");
webSocketLogsNotifier.send("trigger-1", logRecord);
Mockito.verify(messagingTemplate).convertAndSend("/topic/logs/trigger-1", logRecord);
}
@Test
void givenATriggerName_whenProgressIsSent_thenShouldSendItToTheTriggerProgressTopic() {
TriggerFiredBundleDTO triggerFiredBundleDTO = new TriggerFiredBundleDTO();
webSocketProgressNotifier.send("trigger-1", triggerFiredBundleDTO);
Mockito.verify(messagingTemplate).convertAndSend("/topic/progress/trigger-1", triggerFiredBundleDTO);
}
}

View File

@@ -3,12 +3,12 @@
<parent> <parent>
<groupId>it.fabioformosa.quartz-manager</groupId> <groupId>it.fabioformosa.quartz-manager</groupId>
<artifactId>quartz-manager-parent</artifactId> <artifactId>quartz-manager-parent</artifactId>
<version>4.0.8</version> <version>4.1.1</version>
</parent> </parent>
<artifactId>quartz-manager-starter-persistence</artifactId> <artifactId>quartz-manager-starter-persistence</artifactId>
<name>Quartz Manager Starter Security</name> <name>Quartz Manager Starter Persistence</name>
<description>Persist quartz jobs into a database</description> <description>Persist quartz jobs into a database</description>
<url>https://github.com/fabioformosa/quartz-manager</url> <url>https://github.com/fabioformosa/quartz-manager</url>

View File

@@ -11,7 +11,6 @@ import org.springframework.context.annotation.*;
import javax.sql.DataSource; import javax.sql.DataSource;
@Configuration @Configuration
@PropertySource("classpath:quartz-persistence.properties")
public class PersistenceConfig { public class PersistenceConfig {
@Value("${quartz-manager.persistence.quartz.datasource.url}") @Value("${quartz-manager.persistence.quartz.datasource.url}")
@@ -57,7 +56,7 @@ public class PersistenceConfig {
@Primary @Primary
@Bean @Bean
public DataSource quartzManagerDatasource(PersistenceDatasourceProps persistenceDatasourceProps) { public DataSource quartzManagerDatasource() {
return DataSourceBuilder.create() return DataSourceBuilder.create()
.url(quartzDatasourceUrl) .url(quartzDatasourceUrl)
.driverClassName("org.postgresql.Driver") .driverClassName("org.postgresql.Driver")

View File

@@ -5,6 +5,6 @@
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd"> http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
<includeAll path="./migrations" relativeToChangelogFile="true"/> <includeAll path="classpath:db/quartz-scheduler/migrations" relativeToChangelogFile="false" errorIfMissingOrEmpty="true"/>
</databaseChangeLog> </databaseChangeLog>

View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>it.fabioformosa.quartz-manager</groupId> <groupId>it.fabioformosa.quartz-manager</groupId>
<artifactId>quartz-manager-parent</artifactId> <artifactId>quartz-manager-parent</artifactId>
<version>4.0.8</version> <version>4.1.1</version>
</parent> </parent>
<artifactId>quartz-manager-starter-security</artifactId> <artifactId>quartz-manager-starter-security</artifactId>

View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>it.fabioformosa.quartz-manager</groupId> <groupId>it.fabioformosa.quartz-manager</groupId>
<artifactId>quartz-manager-parent</artifactId> <artifactId>quartz-manager-parent</artifactId>
<version>4.0.8</version> <version>4.1.1</version>
</parent> </parent>
<artifactId>quartz-manager-starter-ui</artifactId> <artifactId>quartz-manager-starter-ui</artifactId>

View File

@@ -0,0 +1,9 @@
apiVersion: deploy.cloud.google.com/v1
kind: Target
metadata:
name: dev
annotations: {}
labels: {}
description: dev
gke:
cluster: projects/quartz-manager-test/locations/europe-west8-a/clusters/gke-cluster

View File

@@ -0,0 +1,18 @@
apiVersion: deploy.cloud.google.com/v1
kind: DeliveryPipeline
metadata:
name: quartz-manager-pipeline
labels:
app: quartz-manager-standalone
description: quartz-manager-standalone delivery pipeline
serialPipeline:
stages:
- targetId: dev
profiles:
- dev
- targetId: staging
profiles:
- staging
- targetId: prod
profiles:
- prod

View File

@@ -0,0 +1,10 @@
apiVersion: deploy.cloud.google.com/v1
kind: Target
metadata:
name: prod
annotations: {}
labels: {}
description: prod
requireApproval: true
gke:
cluster: projects/quartz-manager-test/locations/europe-west8-a/clusters/gke-cluster

View File

@@ -0,0 +1,10 @@
apiVersion: deploy.cloud.google.com/v1
kind: Target
metadata:
name: staging
annotations: {}
labels: {}
description: staging
requireApproval: true
gke:
cluster: projects/quartz-manager-test/locations/europe-west8-a/clusters/gke-cluster

View File

@@ -0,0 +1,24 @@
apiVersion: v2
name: quartz-manager-standalone
description: A Helm chart for Kubernetes
# A chart can be either an 'application' or a 'library' chart.
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.0.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "_HELM_APP_VERSION"

View File

@@ -0,0 +1,22 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "quartzmanager-standalone.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "quartzmanager-standalone.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "quartzmanager-standalone.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "quartzmanager-standalone.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}

View File

@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "quartzmanager-standalone.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "quartzmanager-standalone.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "quartzmanager-standalone.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "quartzmanager-standalone.labels" -}}
helm.sh/chart: {{ include "quartzmanager-standalone.chart" . }}
{{ include "quartzmanager-standalone.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "quartzmanager-standalone.selectorLabels" -}}
app.kubernetes.io/name: {{ include "quartzmanager-standalone.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "quartzmanager-standalone.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "quartzmanager-standalone.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,9 @@
apiVersion: "v1"
kind: "ConfigMap"
metadata:
name: {{ include "quartzmanager-standalone.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
app: {{ .Chart.Name }}
data:
envName: {{ .Values.config.envName | quote }}

View File

@@ -0,0 +1,68 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "quartzmanager-standalone.fullname" . }}
labels:
{{- include "quartzmanager-standalone.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "quartzmanager-standalone.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "quartzmanager-standalone.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "quartzmanager-standalone.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
{{/* livenessProbe:*/}}
{{/* initialDelaySeconds: 30*/}}
{{/* timeoutSeconds: 10*/}}
{{/* httpGet:*/}}
{{/* path: /*/}}
{{/* port: 8080*/}}
{{/* readinessProbe:*/}}
{{/* initialDelaySeconds: 30*/}}
{{/* timeoutSeconds: 10*/}}
{{/* httpGet:*/}}
{{/* path: /*/}}
{{/* port: 8080*/}}
resources:
{{- toYaml .Values.resources | nindent 12 }}
envFrom:
- configMapRef:
name: {{ include "quartzmanager-standalone.fullname" . }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View File

@@ -0,0 +1,28 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "quartzmanager-standalone.fullname" . }}
labels:
{{- include "quartzmanager-standalone.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "quartzmanager-standalone.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,61 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "quartzmanager-standalone.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "quartzmanager-standalone.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "quartzmanager-standalone.fullname" . }}
labels:
{{- include "quartzmanager-standalone.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "quartzmanager-standalone.selectorLabels" . | nindent 4 }}

View File

@@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "quartzmanager-standalone.serviceAccountName" . }}
labels:
{{- include "quartzmanager-standalone.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,83 @@
# Default values for hello-world.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: "europe-west8-docker.pkg.dev/quartz-manager-test/quartz-manager/quartz-manager-standalone/quartz-manager-standalone"
pullPolicy: IfNotPresent
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
serviceAccount:
# Specifies whether a service account should be created
create: false
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""
podAnnotations: {}
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
service:
type: ClusterIP
port: 8080
ingress:
enabled: false
className: ""
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths:
- path: /
pathType: ImplementationSpecific
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
nodeSelector: {}
tolerations: []
affinity: {}
config:
envName: NA

View File

@@ -5,12 +5,12 @@
<parent> <parent>
<groupId>it.fabioformosa.quartz-manager</groupId> <groupId>it.fabioformosa.quartz-manager</groupId>
<artifactId>quartz-manager-parent</artifactId> <artifactId>quartz-manager-parent</artifactId>
<version>4.0.8</version> <version>4.1.1</version>
</parent> </parent>
<artifactId>quartz-manager-web-showcase</artifactId> <packaging>jar</packaging>
<packaging>war</packaging> <artifactId>quartz-manager-web-showcase</artifactId>
<name>Quartz Manager Web Showcase</name> <name>Quartz Manager Web Showcase</name>
<description>A webapp that imports Quartz Manager API lib and the frontend webjar</description> <description>A webapp that imports Quartz Manager API lib and the frontend webjar</description>
@@ -49,15 +49,10 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId> <artifactId>spring-boot-devtools</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId> <artifactId>spring-boot-configuration-processor</artifactId>
<scope>provided</scope> <optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
@@ -123,30 +118,28 @@
<build> <build>
<pluginManagement> <plugins>
<plugins> <plugin>
<plugin> <groupId>org.springframework.boot</groupId>
<groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId>
<artifactId>spring-boot-maven-plugin</artifactId> <executions>
<executions> <execution>
<execution> <goals>
<goals> <goal>repackage</goal>
<goal>repackage</goal> </goals>
</goals> </execution>
</execution> </executions>
</executions> </plugin>
</plugin> <plugin>
<plugin> <groupId>org.apache.maven.plugins</groupId>
<groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId>
<artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version>
<version>3.8.0</version> <configuration>
<configuration> <source>9</source>
<source>9</source> <target>9</target>
<target>9</target> </configuration>
</configuration> </plugin>
</plugin> </plugins>
</plugins>
</pluginManagement>
</build> </build>

View File

@@ -1,21 +0,0 @@
package it.fabioformosa;
import lombok.Generated;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
/**
* ServletInitializer needs to deploy quartz-manager into a servlet container as a war file
*
* @author Fabio Formosa
*
*/
@Generated
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(QuartzManagerDemoApplication.class);
}
}

46
skaffold.yaml Normal file
View File

@@ -0,0 +1,46 @@
apiVersion: skaffold/v4beta7
kind: Config
build:
tagPolicy:
envTemplate:
template: "_IMAGE_TAG_POLICY"
artifacts:
- image: quartz-manager-standalone
context: ./
profiles:
- name: dev
deploy:
helm:
releases:
- name: quartzmanager-standalone
createNamespace: true
namespace: quartzmanager-dev
chartPath: quartz-manager-parent/quartz-manager-web-showcase/helm
# valuesFiles:
# - helm/envs/dev/values.yaml
setValueTemplates:
image.tag: "_IMAGE_TAG_POLICY"
- name: staging
deploy:
helm:
releases:
- name: quartzmanager-standalone
createNamespace: true
namespace: quartzmanager-staging
chartPath: quartz-manager-parent/quartz-manager-web-showcase/helm
# valuesFiles:
# - helm/envs/dev/values.yaml
setValueTemplates:
image.tag: "_IMAGE_TAG_POLICY"
- name: prod
deploy:
helm:
releases:
- name: quartzmanager-standalone
createNamespace: true
namespace: quartzmanager-prod
chartPath: quartz-manager-parent/quartz-manager-web-showcase/helm
# valuesFiles:
# - helm/envs/dev/values.yaml
setValueTemplates:
image.tag: "_IMAGE_TAG_POLICY"