Skip to content
This repository has been archived by the owner on Dec 24, 2019. It is now read-only.

Commit

Permalink
#346 add support to 'delete connector'
Browse files Browse the repository at this point in the history
  • Loading branch information
ambpro committed Sep 17, 2019
1 parent ca21e9f commit d1e2997
Show file tree
Hide file tree
Showing 10 changed files with 746 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ <h2>Register project</h2>
formControlName="description">
</div>
<div class="form-group">
<label for="compressedFileExtension">compressedFileExtension</label>
<label for="compressedFileExtension">Compressed File Extension</label>
<input type="text" class="form-control" id="compressedFileExtension"
name="compressedFileExtension"
formControlName="compressedFileExtension">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<form name="addForm" (ngSubmit)="save(sourceInfo, project)" #addForm="ngForm">
<div class="modal-header">
<h4 class="modal-title">Add connector</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" (click)="clear()">&times;</button>
</div>
<div class="modal-body">
<div>
<div class="form-group">
<label for="loginOption">VCS Repository</label> <br>
<select name="gitRepository._type" [(ngModel)]="gitRepository._type" class="form-control">
<option value="org.eclipse.scava.repository.model.vcs.git.GitRepository">Git</option>
<option value="org.eclipse.scava.repository.model.documentation.gitbased.GitRepository">Git based documentation</option>
<option value="org.eclipse.scava.repository.model.vcs.svn.SvnRepository">Svn</option>
</select>
</div>
<div class="form-group">
<label for="url">URL</label>
<input type="text" class="form-control" id="gitRepository.url" name="gitRepository.url" [(ngModel)]="gitRepository.url">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-dark btn-sm" data-dismiss="modal" (click)="clear()">
<span class="fa fa-ban"></span>&nbsp;<span>Cancel</span>
</button>
<button type="submit" [disabled]="addForm.form.invalid" class="btn btn-outline-dark btn-sm">
<span class="fa fa-save"></span>&nbsp;<span>Save</span>
</button>
</div>
</form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Component, OnInit } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { VersionControlSystems } from '../../create-project/version-control-system.model';
import { Project } from '../../../project.model';

@Component({
selector: 'app-add-connector',
templateUrl: './add-connector-dialog.component.html'
})
export class ConnectorMgmtAddDialogComponent implements OnInit {

public isSaving: boolean;
public gitRepository: any;
constructor(
public activeModal: NgbActiveModal
) { }

ngOnInit() {
this.isSaving = true;
this.gitRepository = new Object();
this.gitRepository._id = null;
}

clear() {
this.activeModal.dismiss('cancel');
}

save(sourceInfo: string, project: Project) {
this.isSaving = true;
switch (sourceInfo) {
case "vcs":
project.vcsRepositories.push(this.gitRepository);
break;
case "bts":
project.bugTrackingSystems.push();
break;
case "cc":
project.communicationChannels.push();
break;
default:
break;
}
this.activeModal.dismiss(true);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<form name="deleteForm" (ngSubmit)="confirmDelete(sourceInfo, target, project)">
<div class="modal-header">
<h4 class="modal-title">Confirm delete operation</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" (click)="clear()">&times;</button>
</div>
<div class="modal-body">
<p>Are you sure you want to delete this connector?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-dark btn-sm" data-dismiss="modal" (click)="clear()">
<i class="fa fa-ban"></i>&nbsp;<span>Cancel</span>
</button>&nbsp;
<button type="submit" class="btn btn-outline-dark btn-sm">
<i class="fa fa-times"></i>&nbsp;<span>Delete</span>
</button>
</div>
</form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Component, OnInit } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Project } from '../../../project.model';

@Component({
selector: 'app-delete-connector',
templateUrl: './delete-connector-dialog.component.html'
})
export class ConnectorMgmtDeleteDialogComponent implements OnInit {

projectId: string;

constructor(
public activeModal: NgbActiveModal
) { }

ngOnInit() {
}

clear() {
this.activeModal.dismiss('cancel');
}

confirmDelete(sourceInfo: string, target: number, project: Project) {
switch (sourceInfo) {
case "vcs":
project.vcsRepositories.splice(target, 1);
break;
case "bts":
project.bugTrackingSystems.splice(target, 1);
break;
case "cc":
project.communicationChannels.splice(target, 1);
break;
default:
break;
}
this.activeModal.dismiss(true);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,20 @@ <h2>Edit Project <b>{{project?.shortName}}</b></h2>
</table>
<table style="width: 100%;">
<tr *ngIf="project?.vcsRepositories.length>0">
<td><Strong>VCS Repositories</Strong></td>
<td>
<Strong>VCS Repositories</Strong>
<span style="float: right"><i class="fa fa-plus" title="Add new connector" (click)="addConnector('vcs',i)"></i></span>
</td>
</tr>
<tbody *ngFor="let vcs of project?.vcsRepositories;let i=index;">
<tr><td>Version Control System {{i + 1}}</td></tr>
<tr>
<td>
<span>Version Control System {{i + 1}} : {{vcs._type.split(".")[vcs._type.split(".").length-1]}}</span>
<span style="float: right">
<i class="fa fa-remove" title="Remove connector" (click)="removeConnector('vcs',i)"></i>
</span>
</td>
</tr>
<tr *ngIf="vcs?.url != null" class="row">
<td class="col-2">&nbsp;&nbsp;&nbsp;&nbsp;Url: </td>
<td class="col-10">
Expand All @@ -113,10 +123,20 @@ <h2>Edit Project <b>{{project?.shortName}}</b></h2>
</tr>
</tbody>
<tr *ngIf="project?.bugTrackingSystems.length>0">
<td><strong>Bug Tracking Systems</strong></td>
<td>
<strong>Bug Tracking Systems</strong>
<span style="float: right"><i class="fa fa-plus" title="Add new connector" (click)="addConnector('vcs',i)"></i></span>
</td>
</tr>
<tbody *ngFor="let bts of project?.bugTrackingSystems;let i=index;">
<tr><td>Bug Tracking System {{i + 1}}</td></tr>
<tr>
<td>
<span>Bug Tracking System {{i + 1}} : {{bts?._type.split(".")[bts?._type.split(".").length-1]}}</span>
<span style="float: right">
<i class="fa fa-remove" title="Remove connector" (click)="removeConnector('bts',i)"></i>
</span>
</td>
</tr>
<tr *ngIf="bts?.url != null" class="row">
<td class="col-2">&nbsp;&nbsp;&nbsp;&nbsp;Url: </td>
<td class="col-10">
Expand Down Expand Up @@ -173,10 +193,20 @@ <h2>Edit Project <b>{{project?.shortName}}</b></h2>
</tr>
</tbody>
<tr *ngIf="project?.communicationChannels.length>0">
<td><strong>Communication Channels</strong></td>
<td>
<strong>Communication Channels</strong>
<span style="float: right"><i class="fa fa-plus" title="Add new connector" (click)="addConnector('cc',i)"></i></span>
</td>
</tr>
<tbody *ngFor="let cc of project?.communicationChannels;let i=index;">
<tr><td>Communication Channel {{i + 1}}</td></tr>
<tr>
<td>
<span>Communication Channel {{i + 1}} : {{cc?._type.split(".")[cc?._type.split(".").length-1]}}</span>
<span style="float: right">
<i class="fa fa-remove" title="Remove connector" (click)="removeConnector('cc',i)"></i>
</span>
</td>
</tr>
<tr *ngIf="cc?.url != null" class="row">
<td class="col-2">&nbsp;&nbsp;&nbsp;&nbsp;Url: </td>
<td class="col-10">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { ListProjectService } from '../../../../shared/services/project-service/
import { RoleAuthorities } from '../../../../shared/services/authentication/role-authorities';
import { Project } from '../../project.model';
import { EditProjectService } from '../../../../shared/services/project-service/edit-project.service';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { ConnectorMgmtDeleteDialogComponent } from './delete-connector/delete-connector-dialog.component';
import { ConnectorMgmtAddDialogComponent } from './add-connector/add-connector-dialog.component';


@Component({
Expand All @@ -20,6 +23,7 @@ export class EditProjectComponent implements OnInit {
private route: ActivatedRoute,
private listProjectService: ListProjectService,
private editProjectService: EditProjectService,
public modalService: NgbModal,
public roleAuthorities: RoleAuthorities,
private router: Router
) {
Expand Down Expand Up @@ -55,7 +59,19 @@ export class EditProjectComponent implements OnInit {
}
)
this.previousState();
console.log(this.project)
}

addConnector(sourceInfo: string) {
const modalRef = this.modalService.open(ConnectorMgmtAddDialogComponent, { size: 'lg', backdrop: 'static' });
modalRef.componentInstance.project = this.project;
modalRef.componentInstance.sourceInfo = sourceInfo;
}

removeConnector(sourceInfo: string, target: number) {
const modalRef = this.modalService.open(ConnectorMgmtDeleteDialogComponent, { size: 'lg', backdrop: 'static' });
modalRef.componentInstance.project = this.project;
modalRef.componentInstance.sourceInfo = sourceInfo;
modalRef.componentInstance.target = target;
}

previousState() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import { EditProjectComponent } from './components/edit-project/edit-project.com
import { CdkTableModule } from '@angular/cdk/table';
import { CdkTreeModule } from '@angular/cdk/tree';
import { ProjectMgmtDeleteDialogComponent } from './components/delete-project/delete-project-dialog.component';
import { ConnectorMgmtDeleteDialogComponent } from './components/edit-project/delete-connector/delete-connector-dialog.component';
import { ConnectorMgmtAddDialogComponent } from './components/edit-project/add-connector/add-connector-dialog.component';

@NgModule({
imports: [
Expand Down Expand Up @@ -89,12 +91,16 @@ import { ProjectMgmtDeleteDialogComponent } from './components/delete-project/de
AnalysisTaskMgmtDeleteDialogComponent,
MetricProvidersMgmtInfoDialogComponent,
EditProjectComponent,
ProjectMgmtDeleteDialogComponent
ProjectMgmtDeleteDialogComponent,
ConnectorMgmtDeleteDialogComponent,
ConnectorMgmtAddDialogComponent
],
entryComponents: [
AnalysisTaskMgmtDeleteDialogComponent,
MetricProvidersMgmtInfoDialogComponent,
ProjectMgmtDeleteDialogComponent
ProjectMgmtDeleteDialogComponent,
ConnectorMgmtDeleteDialogComponent,
ConnectorMgmtAddDialogComponent
],
providers: [
NgbModal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ public static void main(String[] args) throws Exception {

for (JsonNode vcs : (ArrayNode)json.get("vcsRepositories")) {
VcsRepository repo = null;
if (vcs.get("type").asText().equals("git")) {
if (vcs.get("type").asText().equals("svn")) {
repo = new SvnRepository();
} else if (vcs.get("type").asText().equals("svn")) {
} else if (vcs.get("type").asText().equals("git")) {
repo = new GitRepository();
}
repo.setName(vcs.get("name").asText());
Expand Down
Loading

0 comments on commit d1e2997

Please sign in to comment.