Commit 6ef45bc5 authored by Abuhujair Javed's avatar Abuhujair Javed

Comments added for JIRA Component

parent 12283dfe
Pipeline #1726 canceled with stages
import { DialogRef } from '@angular/cdk/dialog';
import { Component, Inject, OnInit } from '@angular/core';
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { Observable, Observer } from 'rxjs';
import { Observable } from 'rxjs';
import { FetcherService } from '../fetcher.service';
import { GET_JIRA_TICKETS_API, CREATE_JIRA_TICKET_API, UPDATE_JIRA_TICKET_API } from '../urls';
import { getJiraTicketsResponse, createJiraTicketResponse, updateJiraTicketResponse } from '../responses';
......@@ -22,6 +21,9 @@ export interface ListData{
content: string;
}
/**
* This component list the JIRA tickets in four columns as TO DO, IN PROGRESS, DONE, and BACKLOG.
*/
@Component({
selector: 'app-jira',
templateUrl: './jira.component.html',
......@@ -39,6 +41,10 @@ export class JiraComponent implements OnInit {
in_prog = new Array<ListData>();
done = new Array<ListData>();
backlog = new Array<ListData>();
/**
* Creating observable component to get, update and create tickets.
*/
getJira_stat$ = new Observable<getJiraTicketsResponse>();
updateJira_stat$ = new Observable<updateJiraTicketResponse>();
createJira_stat$ = new Observable<createJiraTicketResponse>();
......@@ -58,6 +64,9 @@ export class JiraComponent implements OnInit {
}
}
/**
* Open dialog box to create JIRA tickets. and Post the same to DB.
*/
openDialog(){
const dialogRef = this.dialog.open(CreateTicketDialog, {
data: {tid: this.temp_tid, pname:this.name, tname: this.temp_tname, tcontent: this.temp_tcontent,
......@@ -65,8 +74,6 @@ export class JiraComponent implements OnInit {
});
dialogRef.afterClosed().subscribe(result => {
console.log('Dialog result:', result.tname, result.tcontent);
this.to_do.push({tid: '10', name: result.tname, content: result.tcontent});
this.createJira_stat$ = this.http.post<createJiraTicketResponse>(CREATE_JIRA_TICKET_API, {
pid: this.pid.replace("'",''),
name: result.tname,
......@@ -77,7 +84,7 @@ export class JiraComponent implements OnInit {
(response) => {
console.log(response);
if(response.status == true){
console.log('success');
this.to_do.push({tid: response.tid, name: result.tname, content: result.tcontent});
}
else{
console.log('fail');
......@@ -93,8 +100,10 @@ export class JiraComponent implements OnInit {
return str;
}
/**
* Returns list to HTML page
*/
fetchList(id: number) {
//return dummy data of type entry
if(id == 1){
return this.to_do;
}
......@@ -110,6 +119,10 @@ export class JiraComponent implements OnInit {
}
/**
* Update the status Jira Ticket and Post the same to Backend Server.
* This is called from the move to button, and their respective function calls in the next the three functions.
*/
updateStatus(tid:string, updated_status: string){
this.updateJira_stat$ = this.http.post<updateJiraTicketResponse>(UPDATE_JIRA_TICKET_API, {
tid: tid,
......@@ -117,12 +130,9 @@ export class JiraComponent implements OnInit {
});
this.updateJira_stat$.subscribe(
(response) => {
console.log(response);
if(response.status == true){
console.log('success');
}
else{
console.log('fail');
}
}
);
......@@ -135,7 +145,6 @@ export class JiraComponent implements OnInit {
if( this.to_do[i].tid == tid){
this.in_prog.push(this.to_do[i]);
this.to_do.splice(i,1);
console.log(this.to_do);
break;
}
}
......@@ -144,7 +153,6 @@ export class JiraComponent implements OnInit {
if( this.done[i].tid == tid){
this.in_prog.push(this.done[i]);
this.done.splice(i,1);
console.log(this.done);
break;
}
}
......@@ -153,15 +161,10 @@ export class JiraComponent implements OnInit {
if( this.backlog[i].tid == tid){
this.in_prog.push(this.backlog[i]);
this.backlog.splice(i,1);
console.log(this.backlog);
break;
}
}
}
console.log(list_name);
console.log(tid);
console.log('Move to In Progress');
}
moveToDone(tid: string, list_name: string ){
......@@ -171,7 +174,6 @@ export class JiraComponent implements OnInit {
if( this.to_do[i].tid == tid){
this.done.push(this.to_do[i]);
this.to_do.splice(i,1);
console.log(this.to_do);
break;
}
}
......@@ -180,7 +182,6 @@ export class JiraComponent implements OnInit {
if( this.in_prog[i].tid == tid){
this.done.push(this.in_prog[i]);
this.in_prog.splice(i,1);
console.log(this.in_prog);
break;
}
}
......@@ -189,7 +190,6 @@ export class JiraComponent implements OnInit {
if( this.backlog[i].tid == tid){
this.done.push(this.backlog[i]);
this.backlog.splice(i,1);
console.log(this.backlog);
break;
}
}
......@@ -203,7 +203,6 @@ export class JiraComponent implements OnInit {
if( this.in_prog[i].tid == tid){
this.to_do.push(this.in_prog[i]);
this.in_prog.splice(i,1);
console.log(this.in_prog);
break;
}
}
......@@ -212,7 +211,6 @@ export class JiraComponent implements OnInit {
if( this.done[i].tid == tid){
this.to_do.push(this.done[i]);
this.done.splice(i,1);
console.log(this.done);
break;
}
}
......@@ -221,15 +219,15 @@ export class JiraComponent implements OnInit {
if( this.backlog[i].tid == tid){
this.to_do.push(this.backlog[i]);
this.backlog.splice(i,1);
console.log(this.backlog);
break;
}
}
}
console.log(list_name);
console.log(tid);
console.log('Move to ToDo');
}
/**
* On initialization, fetch JIRA tickets for the respective project from DB and divide them into TO DO, IN PROGRESS, DONE and BACKLOG.
*/
ngOnInit(): void {
this.fetcherService.setCurrentProjectId(this.id);
this.pid = this.cookieService.get('pid');
......@@ -257,15 +255,14 @@ export class JiraComponent implements OnInit {
}
}
);
console.log(this.to_do);
console.log(this.in_prog);
console.log(this.done);
console.log(this.backlog);
}
}
/**
* This component handles the dialog box for Create Ticket. It injects the data items to be modified.
* It modifies the TicketData and return the same.
*/
@Component({
selector: 'create-ticket-dialog',
templateUrl: './create-ticket-dialog.html',
......
Markdown is supported
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