Commit 3ec2e2ef authored by Jan Marchel's avatar Jan Marchel
Browse files

moving delete method to service

parent 2ec1ae07
Pipeline #16199 passed with stages
in 6 minutes and 22 seconds
......@@ -11,11 +11,14 @@ import {CpSolutionViewComponent} from '../cp-solution-view/cp-solution-view.comp
import {CpVariablesViewComponent} from '../cp-variables-view/cp-variables-view.component';
import {DeploymentDifferenceComponent} from '../deployment-difference/deployment-difference.component';
import {AppConfigService} from '../../app-config/service/app-config.service';
import {ConfirmationDialogComponent} from "../../common-template/confirmation-dialog/confirmation-dialog.component";
import {Observable} from "rxjs";
import {tap} from "rxjs/operators";
import {HttpClient} from "@angular/common/http";
import {ConfirmationDialogComponent} from '../../common-template/confirmation-dialog/confirmation-dialog.component';
import {Observable} from 'rxjs';
import {tap} from 'rxjs/operators';
import {HttpClient, HttpHeaders} from '@angular/common/http';
const httpOptions = {
headers: new HttpHeaders({'Content-Type': 'application/json'})
};
@Component({
selector: 'app-process-view',
......@@ -28,8 +31,7 @@ export class ProcessViewComponent implements OnInit, AfterViewInit, OnDestroy {
@ViewChild(CpVariablesViewComponent) cpVariablesViewComponent: CpVariablesViewComponent;
@ViewChild(DeploymentDifferenceComponent) deploymentDifferenceComponent: DeploymentDifferenceComponent;
private http : HttpClient
apiUrl = `${AppConfigService.settings.apiUrl}/auth/environment`;
apiUrl = `${AppConfigService.settings.apiUrl}/auth/process`;
currentProcessVariables: ProcessVariables;
deploymentCompleted = false;
stopMonitoring = false;
......@@ -44,6 +46,7 @@ export class ProcessViewComponent implements OnInit, AfterViewInit, OnDestroy {
confirmationDialog: MatDialogRef<ConfirmationDialogComponent>;
constructor(private route: ActivatedRoute,
private http: HttpClient,
private router: Router,
private processService: ProcessService,
private processHelperService: ProcessHelperService,
......@@ -323,10 +326,7 @@ export class ProcessViewComponent implements OnInit, AfterViewInit, OnDestroy {
}
isProblemWithFindingNodes(): boolean {
if (this.counter === 7) {
return true;
}
return false;
return this.counter === 2;
}
getNumberOfColsForWideWindow(): number {
......@@ -386,7 +386,7 @@ export class ProcessViewComponent implements OnInit, AfterViewInit, OnDestroy {
|| this.totalNumberOffers === 0)) {
this.loadingNumberOfOffersInProgress = true;
this.processService.getTotalOffersNumber().subscribe(value => {
if (this.isProblemWithFindingNodes()) this.openProblemWithFindingNodesDialog(this.currentProcessVariables.applicationId);
if (this.isProblemWithFindingNodes()) { this.openProblemWithFindingNodesDialog(this.currentProcessVariables.applicationId); }
this.counter += 1;
this.totalNumberOffers = value;
this.loadingNumberOfOffersInProgress = false;
......@@ -429,34 +429,22 @@ export class ProcessViewComponent implements OnInit, AfterViewInit, OnDestroy {
}
private openProblemWithFindingNodesDialog(applicationId: string) {
this.confirmationDialog = this.createConfirmationDialog();
this.confirmationDialog = this.dialog.open(ConfirmationDialogComponent, {
hasBackdrop: false,
data: {
activeProcess: applicationId
activeProcess: applicationId,
title: 'Problem with finding Nodes',
message: `Do you want to stop process and change providers settings?`
},
});
this.confirmationDialog.afterClosed().subscribe(value => {
if (value) {
console.log(`Confirmed deletion of process`);
this.deleteProcess(applicationId);
this.processService.deleteProcess(localStorage.getItem('processId'));
} else {
console.log(`Cancel deletion of process `);
console.log(`Cancel deletion of process`);
}
});
}
deleteProcess(applicationId): Observable<{}> {
const url = `${this.apiUrl}/{processId}`;
return this.http.delete(url, applicationId).pipe(
tap(() => console.log('Process deletion started.'),
e => {
console.error(`Error by deletion of process: `, e)
this.snackBar.open(`Problem by starting cleaning databases: ${e.error.message}. Please, try again.`, 'Close',
{duration: 10000});
}
)
)
}
}
......@@ -65,4 +65,11 @@ export class ProcessService {
e => console.log(`Error by getting deployment difference:`, e))
);
}
deleteProcess(applicationId: string) {
const requestUrl = `${this.apiUrl}/${applicationId}`;
this.http.delete(requestUrl, httpOptions).subscribe(
() => console.log('Deletion of process with id: {} was successful', applicationId),
error => console.log('Error by deletion of process: {}', error));
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment