Skip to content

Commit

Permalink
Version 1.1.5 improvements like search and repair function
Browse files Browse the repository at this point in the history
  • Loading branch information
hydrogen2oxygen committed Nov 5, 2023
1 parent 0ee0c4b commit ae5c172
Show file tree
Hide file tree
Showing 19 changed files with 185 additions and 79 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ territory.db.*
/territory*.db
/uploads/
/server/src/main/resources/territoryMap/
/territories.pdf
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<packaging>pom</packaging>

<properties>
<revision>1.1.4</revision>
<version.info>Removed NitriteDB as main database, instead using ObjectMapper and plain JSON (faster and stable)</version.info>
<revision>1.1.5</revision>
<version.info>Improvements like Search and Repair Function, Dashboard</version.info>
</properties>

<version>${revision}</version>
Expand Down
2 changes: 1 addition & 1 deletion server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<relativePath/> <!-- lookup parent from repository -->
</parent>

<version>1.1.4</version>
<version>1.1.5</version>
<groupId>de.pietro.lusso</groupId>
<artifactId>server</artifactId>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class Congregation {
private List<Territory> territoriesArchived = new ArrayList<>();

private List<String> protocol = new ArrayList<>();
private int counterFtpUploadFailed = 0;

public UUID getUuid() {
return uuid;
Expand Down Expand Up @@ -139,4 +140,12 @@ public List<String> getProtocol() {
public void setProtocol(List<String> protocol) {
this.protocol = protocol;
}

public int getCounterFtpUploadFailed() {
return counterFtpUploadFailed;
}

public void setCounterFtpUploadFailed(int counterFtpUploadFailed) {
this.counterFtpUploadFailed = counterFtpUploadFailed;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<Territory> territories = congregation.getTerritoryList();
territories.forEach(territory -> {
if (territory.isFtpExported()) return;
try {
exportTerritoryData(territory.getNumber(), true);
} catch (Exception e) {
logger.error(e);
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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('');
Expand Down Expand Up @@ -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');
})
}
Expand Down Expand Up @@ -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)
});
}

Expand Down
2 changes: 1 addition & 1 deletion server/src/main/ui2/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
8 changes: 0 additions & 8 deletions server/src/main/ui2/src/app/components/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ <h1 class="badge bg-danger">Server is offline!</h1>
<img src="assets/startServer.png">
</div>

<mat-form-field class="example-full-width" appearance="fill">
<mat-label>Choose a date</mat-label>
<input matInput [matDatepicker]="picker">
<mat-hint>MM/DD/YYYY</mat-hint>
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker touchUi #picker></mat-datepicker>
</mat-form-field>

<div *ngIf="showSearch" class="content centeredSearch">
<div>
<input #centeredSearch [formControl]="searchField" class="form-control" (keyup)="search()" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ <h4 class="collapseHeader" data-bs-toggle="collapse" href="#sorted" role="button
+ congregation.territoriesToBeAssigned.length
}}
<hr>
<button class="btn btn-success" (click)="printPDF()">PRINT PDF</button>
<button class="btn btn-sm btn-success" (click)="printPDF()">PRINT PDF</button>
<button *ngIf="congregation.counterFtpUploadFailed > 0" class="btn btn-sm btn-danger" style="margin-left: 0.5rem; font-weight: bolder" (click)="repairFtpUploads()">REPAIR FTP UPLOADS <i class="bi bi-cloud-slash" style="margin-left: 0.25rem"></i> {{congregation.counterFtpUploadFailed}} failed uploads</button>
<hr>
<h3>Protocol:</h3>
<ul>
Expand All @@ -145,13 +146,15 @@ <h3 class="text-dark">{{territory.number}} {{territory.name}}</h3>
<th>Name</th>
<th>Assigned</th>
<th>Returned</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let registryEntry of territory.registryEntryList; index as i" class="col-auto" [class.registered]="registryEntry.registration">
<td>{{registryEntry.preacher.name}}</td>
<td>{{registryEntry.assignDate | date:'dd-MM-yy'}}</td>
<td>{{registryEntry.returnDate | date:'dd-MM-yy'}}</td>
<td><button *ngIf="territory.registryEntryList.length > 1 && i > 0" class="btn btn-xs btn-danger" (click)="removeRegistryEntry(registryEntry)" title="Delete Registry Entry">DEL</button></td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -183,26 +186,50 @@ <h3 class="text-dark">{{territory.number}} {{territory.name}}</h3>
</div>
</div>

<div class="ng-autocomplete" style="width:75%">
<ng-autocomplete
[data]="preacherList"
[searchKeyword]="keyword"
placeHolder="Enter the Preacher Name"
(selected)='selectEvent($event)'
(inputChanged)='onChangeSearch($event)'
(inputFocused)='onFocused($event)'
[itemTemplate]="itemTemplate"
[notFoundTemplate]="notFoundTemplate">
</ng-autocomplete>

<ng-template #itemTemplate let-item>
<a [innerHTML]="item.name"></a>
</ng-template>

<ng-template #notFoundTemplate let-notFound>
<div [innerHTML]="notFound"></div>
</ng-template>
</div>
<div class="input-group mb-3">
<table>
<tr>
<td>
<mat-form-field class="modal-body" >
<mat-label>Assign date in past</mat-label>
<input matInput [matDatepicker]="picker1" style="color: #0a53be" [formControl]="preDateAssigned">
<mat-datepicker-toggle matSuffix [for]="picker1"></mat-datepicker-toggle>
<mat-datepicker #picker1></mat-datepicker>
</mat-form-field>
</td>
<td>
<mat-form-field class="modal-body" >
<mat-label>Return date in past</mat-label>
<input matInput [matDatepicker]="picker2" style="color: #0a53be" [formControl]="preDateReturned">
<mat-datepicker-toggle matSuffix [for]="picker2"></mat-datepicker-toggle>
<mat-datepicker #picker2></mat-datepicker>
</mat-form-field>
</td>
</tr>
</table>
</div>

<div class="ng-autocomplete" style="width: 75%">
<ng-autocomplete
[data]="preacherList"
[searchKeyword]="keyword"
placeHolder="Enter the Preacher Name"
(selected)='selectEvent($event)'
(inputChanged)='onChangeSearch($event)'
(inputFocused)='onFocused($event)'
[itemTemplate]="itemTemplate"
[notFoundTemplate]="notFoundTemplate">
</ng-autocomplete>

<ng-template #itemTemplate let-item>
<a [innerHTML]="item.name"></a>
</ng-template>

<ng-template #notFoundTemplate let-notFound>
<div [innerHTML]="notFound"></div>
</ng-template>
</div>

</div>

<div class="modal-footer" *ngIf="territory">
Expand Down
Loading

0 comments on commit ae5c172

Please sign in to comment.