Commit 147dd8ed authored by Meet Narendra's avatar Meet Narendra 💬

COmpleted backend

parent a9c964c2
Pipeline #1723 canceled with stages
......@@ -14,7 +14,8 @@
[rowspan]=1>
<mat-card class="mat-issuename-css">
<mat-card-title>
<button mat-button [matMenuTriggerFor]="menu" class="menu-button-css">{{tile.name}}</button>
{{tile.name}}
<button mat-button [matMenuTriggerFor]="menu" class="menu-button-css"><mat-icon>more_vert</mat-icon></button>
<mat-menu #menu="matMenu">
<button mat-menu-item (click)="moveToInProgress(tile.tid, 'to_do')">Move to in progress</button>
<button mat-menu-item (click)="moveToDone(tile.tid, 'to_do')">Mark as done</button>
......@@ -43,7 +44,8 @@
[rowspan]=1>
<mat-card class="mat-issuename-css">
<mat-card-title>
<button mat-button [matMenuTriggerFor]="menu" class="menu-button-css">{{tile.name}}</button>
{{tile.name}}
<button mat-button [matMenuTriggerFor]="menu" class="menu-button-css"><mat-icon>more_vert</mat-icon></button>
<mat-menu #menu="matMenu">
<button mat-menu-item (click)="moveToToDo(tile.tid, 'in_prog')">Move to To Do</button>
<button mat-menu-item (click)="moveToDone(tile.tid, 'in_prog')">Mark as done</button>
......@@ -72,7 +74,8 @@
[rowspan]=1>
<mat-card class="mat-issuename-css">
<mat-card-title>
<button mat-button [matMenuTriggerFor]="menu" class="menu-button-css">{{tile.name}}</button>
{{tile.name}}
<button mat-button [matMenuTriggerFor]="menu" class="menu-button-css"><mat-icon>more_vert</mat-icon></button>
<mat-menu #menu="matMenu">
<button mat-menu-item (click)="moveToToDo(tile.tid, 'done')">Move to To Do</button>
<button mat-menu-item (click)="moveToInProgress(tile.tid, 'done')">Move to In Progress</button>
......@@ -101,7 +104,8 @@
[rowspan]=1>
<mat-card class="mat-issuename-css">
<mat-card-title>
<button mat-button [matMenuTriggerFor]="menu" class="menu-button-css">{{tile.name}}</button>
{{tile.name}}
<button mat-button [matMenuTriggerFor]="menu" class="menu-button-css"><mat-icon>more_vert</mat-icon></button>
<mat-menu #menu="matMenu">
<button mat-menu-item (click)="moveToToDo(tile.tid, 'backlog')">Move to To Do</button>
<button mat-menu-item (click)="moveToInProgress(tile.tid, 'backlog')">Move to In Progress</button>
......
......@@ -3,6 +3,11 @@ import { Component, Inject, OnInit } from '@angular/core';
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { Observable, Observer } 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';
import { HttpClient } from '@angular/common/http';
import { Router } from '@angular/router';
import { CookieService } from 'ngx-cookie-service';
export interface TicketData {
tid: string;
......@@ -28,7 +33,16 @@ export class JiraComponent implements OnInit {
temp_tname = '';
temp_tcontent = '';
temp_tid = '';
constructor(public dialog:MatDialog, private fetcherService: FetcherService) {
pid = "";
col_name = GRID_NAME;
to_do = new Array<ListData>();
in_prog = new Array<ListData>();
done = new Array<ListData>();
backlog = new Array<ListData>();
getJira_stat$ = new Observable<getJiraTicketsResponse>();
updateJira_stat$ = new Observable<updateJiraTicketResponse>();
createJira_stat$ = new Observable<createJiraTicketResponse>();
constructor(public dialog:MatDialog, private fetcherService: FetcherService, private http: HttpClient, private router: Router, private cookieService: CookieService) {
console.log(window.history.state);
this.id = window.history.state.id;
this.name = window.history.state.name;
......@@ -53,7 +67,22 @@ 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,
content: result.tcontent,
status: 'to_do',
});
this.createJira_stat$.subscribe(
(response) => {
console.log(response);
if(response.status == true){
console.log('success');
}
else{
console.log('fail');
}
});
});
}
......@@ -67,20 +96,40 @@ export class JiraComponent implements OnInit {
fetchList(id: number) {
//return dummy data of type entry
if(id == 1){
return TO_DO;
return this.to_do;
}
else if(id == 2){
return IN_PROGRESS;
return this.in_prog;
}
else if(id == 3){
return DONE;
return this.done;
}
else{
return BACKLOG;
return this.backlog;
}
}
updateStatus(tid:string, updated_status: string){
this.updateJira_stat$ = this.http.post<updateJiraTicketResponse>(UPDATE_JIRA_TICKET_API, {
tid: tid,
status: updated_status,
});
this.updateJira_stat$.subscribe(
(response) => {
console.log(response);
if(response.status == true){
console.log('success');
}
else{
console.log('fail');
}
}
);
}
moveToInProgress(tid: string, list_name: string ){
this.updateStatus(tid, 'in_progress');
if (list_name == 'to_do') {
for (let i = 0; i< this.to_do.length; i++){
if( this.to_do[i].tid == tid){
......@@ -116,6 +165,7 @@ export class JiraComponent implements OnInit {
}
moveToDone(tid: string, list_name: string ){
this.updateStatus(tid, 'done');
if (list_name == 'to_do') {
for (let i = 0; i< this.to_do.length; i++){
if( this.to_do[i].tid == tid){
......@@ -147,6 +197,7 @@ export class JiraComponent implements OnInit {
}
moveToToDo(tid: string, list_name: string ){
this.updateStatus(tid, 'to_do');
if (list_name == 'in_prog') {
for (let i = 0; i< this.in_prog.length; i++){
if( this.in_prog[i].tid == tid){
......@@ -181,12 +232,37 @@ export class JiraComponent implements OnInit {
}
ngOnInit(): void {
this.fetcherService.setCurrentProjectId(this.id);
this.pid = this.cookieService.get('pid');
this.getJira_stat$ = this.http.get<getJiraTicketsResponse>(GET_JIRA_TICKETS_API+'?pid='+this.pid)
this.to_do.length = 0;
this.in_prog.length = 0;
this.done.length = 0;
this.backlog.length = 0;
this.getJira_stat$.subscribe(
(data) => {
for(let i =0; i<data.files.length; i++){
if(data.files[i].status == 'to_do'){
this.to_do.push({tid: data.files[i].tid, name: data.files[i].name, content: data.files[i].content});
}
else if(data.files[i].status == 'in_prog'){
this.in_prog.push({tid: data.files[i].tid, name: data.files[i].name, content: data.files[i].content});
}
else if(data.files[i].status == 'done'){
this.done.push({tid: data.files[i].tid, name: data.files[i].name, content: data.files[i].content});
}
else{
this.backlog.push({tid: data.files[i].tid, name: data.files[i].name, content: data.files[i].content});
}
}
}
);
console.log(this.to_do);
console.log(this.in_prog);
console.log(this.done);
console.log(this.backlog);
}
col_name = GRID_NAME;
to_do = TO_DO;
in_prog = IN_PROGRESS;
done = DONE;
backlog = BACKLOG;
}
......@@ -213,28 +289,3 @@ export const GRID_NAME = [
{name: 'DONE', content: 'BLAH BLAH BLAH'},
{name: 'BACKLOG', content: 'BLAH BLAH BLAH'},
]
export var TO_DO = [
{tid: '1', name: 'A', content: 'BLAH BLAH BLAH'},
{tid: '2', name: 'B', content: 'BLAH BLAH BLAH'},
{tid: '3', name: 'C', content: 'BLAH BLAH BLAH'},
{tid: '4', name: 'D', content: 'BLAH BLAH BLAH'},
]
export var IN_PROGRESS = [
{tid: '5', name: 'E', content: 'BLAH BLAH BLAH'},
{tid: '6', name: 'F', content: 'BLAH BLAH BLAH'},
{tid: '7', name: 'G', content: 'BLAH BLAH BLAH'},
{tid: '8', name: 'H', content: 'BLAH BLAH BLAH'},
{tid: '9', name: 'I', content: 'BLAH BLAH BLAH'},
{tid: '10', name: 'J', content: 'BLAH BLAH BLAH'},
]
export var DONE = [
{tid: '11', name: 'K', content: 'BLAH BLAH BLAH'},
{tid: '12', name: 'L', content: 'BLAH BLAH BLAH'},
{tid: '13', name: 'M', content: 'BLAH BLAH BLAH'},
]
export var BACKLOG = [
{tid: '14', name: 'N', content: 'BLAH BLAH BLAH'},
{tid: '15', name: 'O', content: 'BLAH BLAH BLAH'},
{tid: '16', name: 'P', content: 'BLAH BLAH BLAH'},
]
\ No newline at end of file
......@@ -59,3 +59,29 @@ export interface getGitFilesResponse {
export interface postFileChangesResponse {
status: boolean;
}
export interface getJiraTicketsResponse {
files: [
{
tid: string;
name: string;
content: string;
status: string;
pid_id: string;
}
];
status: boolean;
}
export interface updateJiraTicketResponse {
status: boolean;
}
export interface createJiraTicketResponse {
tid: string;
status: boolean;
}
......@@ -75,10 +75,10 @@ class getJiraTicketsViewSet(views.APIView):
def get(self,request):
pid = request.GET.get('pid')
try:
project = Projects.objects.filter(pid=pid)
if project is None:
project = Tickets.objects.filter(pid=pid)
if len(project) == 0:
return Response({'status':False})
return Response({'files':project.values('jira_id'),'status':True})
return Response({'files':project.values(),'status':True})
except Exception as e:
print(e)
return Response({'status':False})
......@@ -113,8 +113,9 @@ class createJiraTicketViewSet(views.APIView):
name = request.data.get('name')
content = request.data.get('content')
status = request.data.get('status')
matching_projects = Projects.objects.filter(pid=pid)
try:
ticket = Tickets.objects.create(pid=pid,name=name,content=content,status=status)
ticket = Tickets.objects.create(pid=matching_projects[0],name=name,content=content,status=status)
return Response({'tid':ticket.tid,'status':True})
except Exception as e:
print(e)
......@@ -123,14 +124,12 @@ class createJiraTicketViewSet(views.APIView):
class updateJiraTicketViewSet(views.APIView):
def post(self,request):
tid = request.data.get('tid')
name = request.data.get('name')
content = request.data.get('content')
status = request.data.get('status')
try:
ticket = Tickets.objects.filter(tid=tid)
if ticket is None:
if len(ticket) == 0:
return Response({'status':False})
ticket.update(name=name,content=content,status=status)
ticket.update(status=status)
return Response({'status':True})
except Exception as e:
print(e)
......@@ -279,7 +278,7 @@ class getConfluencePagesViewSet(views.APIView):
project = Projects.objects.filter(pid=pid)
if project is None:
return Response({'status':False})
return Response({'pages':project.values('confluence_id'),'status':True})
return Response({'pages':project[0].values('confluence_id'),'status':True})
except Exception as e:
print(e)
return Response({'status':False})
......
# Generated by Django 4.1.1 on 2022-11-22 14:35
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
("home", "0007_projects_content_projects_description"),
]
operations = [
migrations.AlterField(
model_name="tickets",
name="pid",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="home.projects"
),
),
]
......@@ -47,7 +47,7 @@ class Tickets(models.Model):
name = models.CharField(max_length=50)
content = models.CharField(max_length=50)
status = models.CharField(max_length=50)
pid = models.CharField(max_length=50)
pid = models.ForeignKey(Projects,on_delete=models.CASCADE)
def __str__(self) -> str:
return f'{self.tid=},{self.name=},{self.content=},{self.status},{self.pid=}'
......
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