diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index a9a71a4..6c87088 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -21,11 +21,11 @@ jobs: - name: Upload Artifact - Make Directory run: | mkdir -p finalApproach; - cp server/target/server-1.1.4.jar finalApproach/server.jar; - cp updater/target/updater-1.1.4-jar-with-dependencies.jar finalApproach/launcher.jar; - cp updater/target/updater-1.1.4-jar-with-dependencies.jar finalApproach/newlauncher.jar; + cp server/target/server-1.1.5.jar finalApproach/server.jar; + cp updater/target/updater-1.1.5-jar-with-dependencies.jar finalApproach/launcher.jar; + cp updater/target/updater-1.1.5-jar-with-dependencies.jar finalApproach/newlauncher.jar; cp scripts/start.bat finalApproach/; - uses: actions/upload-artifact@v3 with: - name: final-approach-1.1.4 + name: final-approach-1.1.5 path: finalApproach diff --git a/.gitignore b/.gitignore index 274162a..76d0e65 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,4 @@ territory.db.* /territory*.db /uploads/ /server/src/main/resources/territoryMap/ +/territories.pdf diff --git a/README.md b/README.md index a868de2..47efc76 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ The application is intended to be run *"offline"*, not as a server, because it l - Register territory (as processed again by the preacher) - Upload the assigned territory via FTP (SFTP) to your private hosted webpage - Send a Whatsapp message with a list of assigned territories to a preacher +- Dashboard of all territories - Download maps as KML file - Print statistics and tables (PDF) diff --git a/pom.xml b/pom.xml index 1a4aa06..312be0c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,8 +6,8 @@ pom - 1.1.4 - Removed NitriteDB as main database, instead using ObjectMapper and plain JSON (faster and stable) + 1.1.5 + Improvements like Search and Repair Function, Dashboard ${revision} diff --git a/server/pom.xml b/server/pom.xml index 1c0c05b..5783ab4 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -12,7 +12,7 @@ - 1.1.4 + 1.1.5 de.pietro.lusso server diff --git a/server/src/main/java/de/pietro/lusso/territory/adapter/CongregationAdapter.java b/server/src/main/java/de/pietro/lusso/territory/adapter/CongregationAdapter.java index a168b0b..df2a014 100644 --- a/server/src/main/java/de/pietro/lusso/territory/adapter/CongregationAdapter.java +++ b/server/src/main/java/de/pietro/lusso/territory/adapter/CongregationAdapter.java @@ -103,6 +103,14 @@ public Message reexportTerritoryData(@PathVariable String number) throws Excepti return msg; } + @PostMapping("reexportTerritoryData") + public Message reexportTerritoryData() throws Exception { + databaseService.reexportFailedTerritoryData(); + Message msg = new Message(); + msg.setMsg("Failed territories data reexported!"); + return msg; + } + @PostMapping("exportTerritoryData") public void exportTerritoryData() throws Exception { databaseService.exportTerritoryData(); diff --git a/server/src/main/java/de/pietro/lusso/territory/domain/Congregation.java b/server/src/main/java/de/pietro/lusso/territory/domain/Congregation.java index 344448e..5e6cd46 100644 --- a/server/src/main/java/de/pietro/lusso/territory/domain/Congregation.java +++ b/server/src/main/java/de/pietro/lusso/territory/domain/Congregation.java @@ -27,6 +27,7 @@ public class Congregation { private List territoriesArchived = new ArrayList<>(); private List protocol = new ArrayList<>(); + private int counterFtpUploadFailed = 0; public UUID getUuid() { return uuid; @@ -139,4 +140,12 @@ public List getProtocol() { public void setProtocol(List protocol) { this.protocol = protocol; } + + public int getCounterFtpUploadFailed() { + return counterFtpUploadFailed; + } + + public void setCounterFtpUploadFailed(int counterFtpUploadFailed) { + this.counterFtpUploadFailed = counterFtpUploadFailed; + } } diff --git a/server/src/main/java/de/pietro/lusso/territory/services/DatabaseService.java b/server/src/main/java/de/pietro/lusso/territory/services/DatabaseService.java index 9aaeb71..1a55f27 100644 --- a/server/src/main/java/de/pietro/lusso/territory/services/DatabaseService.java +++ b/server/src/main/java/de/pietro/lusso/territory/services/DatabaseService.java @@ -68,7 +68,7 @@ public class DatabaseService { @PostConstruct public void initService() throws Exception { - System.out.println(Charset.defaultCharset()); + logger.info(Charset.defaultCharset()); objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); @@ -340,8 +340,14 @@ private Congregation enhanceCongregationData(Congregation congregation) throws I } } + congregation.setCounterFtpUploadFailed(0); + for (Territory territory : congregation.getTerritoryList()) { + if (!territory.isFtpExported()) { + congregation.setCounterFtpUploadFailed(congregation.getCounterFtpUploadFailed() + 1); + } + if (mapsActive.contains(territory.getNumber())) { territory.setMapExist(true); territory.setUrl(settings.getSettings().get("ftp.httpHost") + "?id=" + territory.getUuid()); @@ -458,7 +464,11 @@ public int compare(Preacher o1, Preacher o2) { territoryInfos.setAssignDate(lastRegistryEntry.getAssignDate()); territoryInfos.setReturnDate(lastRegistryEntry.getReturnDate()); TerritoryMap territoryMap = getTerritoryMapByNumber(territoryNumber); - territoryInfos.setSimpleFeatureData(territoryMap.getSimpleFeatureData()); + if (territoryMap == null) { + logger.error("No territory available for number " + territoryNumber); + } else { + territoryInfos.setSimpleFeatureData(territoryMap.getSimpleFeatureData()); + } dashboard.getTerritories().add(territoryInfos); } @@ -793,6 +803,7 @@ public void exportTerritoryData(String number, boolean onlyRepair) throws Except territory.setFtpExported(true); } catch (Exception e) { logger.error("FTP Upload of new territory failed", e); + territory.setFtpExported(false); } saveCongregation(congregation); @@ -1221,4 +1232,19 @@ public void registerTerritory(String number) throws IOException { territory.getRegistryEntryList().add(registration); saveCongregation(congregation); } + + public void reexportFailedTerritoryData() throws IOException { + + Congregation congregation = loadCongregation(); + resetTerritoryList(congregation); + List territories = congregation.getTerritoryList(); + territories.forEach(territory -> { + if (territory.isFtpExported()) return; + try { + exportTerritoryData(territory.getNumber(), true); + } catch (Exception e) { + logger.error(e); + } + }); + } } diff --git a/server/src/main/java/de/pietro/lusso/territory/services/FtpService.java b/server/src/main/java/de/pietro/lusso/territory/services/FtpService.java index 1ca8588..6fb6e72 100644 --- a/server/src/main/java/de/pietro/lusso/territory/services/FtpService.java +++ b/server/src/main/java/de/pietro/lusso/territory/services/FtpService.java @@ -60,14 +60,14 @@ public void init() throws IOException { getSftpClient().ls("."); initialized = true; } catch (Exception e) { - e.printStackTrace(); + logger.error("Initializing SFTP error", e); } } else { try { getFtpClient().listFiles(""); initialized = true; } catch (Exception e) { - e.printStackTrace(); + logger.error("Initializing FTP error", e); } } } @@ -173,49 +173,44 @@ public void delete(String path) throws Exception { private FTPClient getFtpClient() throws Exception { + initialized = false; FTPClient ftp = new FTPClient(); if ("NOT_SET" == ftpHost) return null; - try { - ftp.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out))); - System.out.print(" connecting to ftp " + ftpHost + ":" + ftpPort + " ... "); - ftp.connect(ftpHost, ftpPort); - int replyCode = ftp.getReplyCode(); - - if (!FTPReply.isPositiveCompletion(replyCode)) { - logger.error("Connect failed"); - return null; - } - logger.info("Connected!"); - System.out.print(ftp.getReplyString()); + ftp.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out))); + logger.info(" connecting to ftp " + ftpHost + ":" + ftpPort + " ... "); + ftp.connect(ftpHost, ftpPort); + int replyCode = ftp.getReplyCode(); - //after connecting to the server set the local passive mode - ftp.enterLocalPassiveMode(); + if (!FTPReply.isPositiveCompletion(replyCode)) { + logger.error("Connect failed"); + return null; + } + logger.info("Connected!"); + logger.info(ftp.getReplyString()); - System.out.print(" login to ftp with user " + ftpUser + " and password ****** ... "); - boolean success = ftp.login(ftpUser, ftpPassword); + //after connecting to the server set the local passive mode + ftp.enterLocalPassiveMode(); - if (!success) { - logger.error("Could not login to the server"); - return null; - } + logger.info(" login to ftp with user " + ftpUser + " and password ****** ... "); + boolean success = ftp.login(ftpUser, ftpPassword); - logger.info("Login was successful!"); + if (!success) { + logger.error("Could not login to the server"); + return null; + } - int reply = ftp.getReplyCode(); + logger.info("Login was successful!"); - if (!FTPReply.isPositiveCompletion(reply)) { - ftp.disconnect(); - logger.error("FTP server refused connection."); - } + int reply = ftp.getReplyCode(); - return ftp; - } catch (IOException e) { - e.printStackTrace(); + if (!FTPReply.isPositiveCompletion(reply)) { + ftp.disconnect(); + logger.error("FTP server refused connection."); } - - return null; + initialized = true; + return ftp; } private ChannelSftp getSftpClient() throws JSchException { diff --git a/server/src/main/territoryMap/src/app/components/map/map.component.ts b/server/src/main/territoryMap/src/app/components/map/map.component.ts index d70e537..96b896c 100644 --- a/server/src/main/territoryMap/src/app/components/map/map.component.ts +++ b/server/src/main/territoryMap/src/app/components/map/map.component.ts @@ -119,7 +119,7 @@ export class MapComponent implements OnInit { style: function (feature: any) { let style = that.styleRedOutline; // @ts-ignore - if (that.map.getView().getZoom() > 14) { + if (that.map.getView().getZoom() > 10) { style.getText().setText(feature.get('name')); } else { style.getText().setText(''); @@ -176,6 +176,7 @@ export class MapComponent implements OnInit { }) this.extent = this.source.getExtent(); this.map?.getView().fit(this.extent); + this.map?.getView().setZoom(13) this.title.setTitle('DASHBOARD TERRITORIES'); }) } @@ -212,7 +213,7 @@ export class MapComponent implements OnInit { this.extent = this.source.getExtent(); this.map?.getView().fit(this.extent); - + this.map?.getView().setZoom(16) }); } diff --git a/server/src/main/ui2/src/app/app.module.ts b/server/src/main/ui2/src/app/app.module.ts index 80ddca4..4979d54 100644 --- a/server/src/main/ui2/src/app/app.module.ts +++ b/server/src/main/ui2/src/app/app.module.ts @@ -20,7 +20,7 @@ import {BackupComponent} from './components/backup/backup.component'; import {VideosComponent} from './components/videos/videos.component'; import {MatDatepickerModule} from "@angular/material/datepicker"; import {MatFormFieldModule} from "@angular/material/form-field"; -import {MatNativeDateModule} from "@angular/material/core"; +import {MAT_DATE_FORMATS, MatNativeDateModule} from "@angular/material/core"; import {MatInputModule} from "@angular/material/input"; @NgModule({ diff --git a/server/src/main/ui2/src/app/components/app/app.component.html b/server/src/main/ui2/src/app/components/app/app.component.html index c208b61..630f54c 100644 --- a/server/src/main/ui2/src/app/components/app/app.component.html +++ b/server/src/main/ui2/src/app/components/app/app.component.html @@ -45,14 +45,6 @@

Server is offline!

- - Choose a date - - MM/DD/YYYY - - - -
diff --git a/server/src/main/ui2/src/app/components/territories/territories.component.html b/server/src/main/ui2/src/app/components/territories/territories.component.html index 84900e9..6ee6f1f 100644 --- a/server/src/main/ui2/src/app/components/territories/territories.component.html +++ b/server/src/main/ui2/src/app/components/territories/territories.component.html @@ -124,7 +124,8 @@

PRINT PDF + +

Protocol:

    @@ -145,6 +146,7 @@

    {{territory.number}} {{territory.name}}

    Name Assigned Returned + Actions @@ -152,6 +154,7 @@

    {{territory.number}} {{territory.name}}

    {{registryEntry.preacher.name}} {{registryEntry.assignDate | date:'dd-MM-yy'}} {{registryEntry.returnDate | date:'dd-MM-yy'}} + @@ -183,26 +186,50 @@

    {{territory.number}} {{territory.name}}

-
- - - - - - - - -
-
-
+
+ + + + + +
+ + Assign date in past + + + + + + + Return date in past + + + + +
+
+ +
+ + + + + + + + +
+
+
+