Skip to content

Commit

Permalink
feat(tasksEvaluationPage): Made a new Page - Tasks Evaluation
Browse files Browse the repository at this point in the history
Signed-off-by: sid-bagwe <[email protected]>
  • Loading branch information
sid-bagwe committed Oct 2, 2021
1 parent 099e62b commit ef4557f
Show file tree
Hide file tree
Showing 13 changed files with 551 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .firebaserc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"projects": {
"default": "worktrolly"
"default": "my-first-project-d8086"
},
"targets": {
"worktrolly": {
Expand Down
2 changes: 2 additions & 0 deletions functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const { organization } = require("./model/organization/organization");
const { teams } = require("./model/teams/teams");
const { sprints } = require("./model/sprints/sprints");
const { patch } = require("./model/patch/patch");
const { tasksEvaluation } = require("./model/tasksEvaluation/tasksEvaluation");
// const updateSprintStatusAPI = require("./updateSprintStatusAPI");
// const createNewOrgAPI = require("./createNewOrgAPI");
// const patch1API = require("./patch1API");
Expand Down Expand Up @@ -65,6 +66,7 @@ exports.organization = organization;
exports.teams = teams;
exports.sprints = sprints;
exports.patch = patch;
exports.tasksEvaluation = tasksEvaluation;
// exports.updateSprintStatus = updateSprintStatusAPI.updateSprintStatus;
// exports.createNewOrganization = createNewOrgAPI.createNewOrganization;
// exports.createNewTeamWithLabels = createNewOrgAPI.createNewTeamWithLabels;
Expand Down
72 changes: 72 additions & 0 deletions functions/model/tasksEvaluation/readTasksEvalulationData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/* eslint-disable linebreak-style */
/* eslint-disable require-jsdoc */
/* eslint-disable object-curly-spacing */
// /* eslint-disable no-undef */
/* eslint-disable eol-last */
/* eslint-disable indent */
/* eslint-disable max-len */
// eslint-disable-next-line no-dupe-else-if

const { db } = require('../application/lib');

exports.readTasksEvaluationData = function(request, response) {
const orgDomain = request.body.data.OrganizationDomain;
const teamId = request.body.data.TeamId;
const sprintNumber = request.body.data.SprintNumber;
const pageToLoad = request.body.data.PageToLoad;
const lastInResultTaskId = request.body.data.LastInResultTaskId;
const firstInResultTaskId = request.body.data.FirstInResultTaskId;
const startAt = request.body.data.StartAt;
let tasks = [];
let status = 200;
let disableNext = false;
let disablePrev = false;
let promise;
let query = db.collection("Organizations").doc(orgDomain).collection("Tasks").where('TeamId', '==', teamId).orderBy('Id', 'desc');

if (sprintNumber) {
query = query.where('SprintNumber', '==', sprintNumber);
}

if(pageToLoad == 'initial') {
query = query.limit(20);
} else if(pageToLoad == 'next') {
query = query.startAfter(lastInResultTaskId).limit(20);
} else if(pageToLoad == 'previous') {
query = query.startAt(startAt).endBefore(firstInResultTaskId).limit(20);
}

promise = query.get().then(snapshot => {
snapshot.docs.forEach(doc => {
tasks.push(doc.data());
});
let p1;
if(pageToLoad == 'next') {
p1 = db.collection("Organizations").doc(orgDomain).collection("Tasks").where('TeamId', '==', teamId).orderBy('Id', 'desc').startAfter(tasks[tasks.length - 1].Id).get().then(docs => {
if(docs.empty) {
disableNext = true;
}
});
} else if(pageToLoad == 'previous') {
p1 = db.collection("Organizations").doc(orgDomain).collection("Tasks").where('TeamId', '==', teamId).orderBy('Id', 'desc').endBefore(tasks[0].Id).get().then(docs => {
if(docs.empty) {
disablePrev = true;
}
});
}
return Promise.resolve(p1);
}).catch(error => {
console.log(error);
status = 500;
});

return Promise.resolve(promise).then(() => {
result = { data: {Tasks: tasks, DisableNext: disableNext, DisablePrev: disablePrev} };
console.log("Read Task Evaluation Page Data Successfully");
return response.status(status).send(result);
}).catch(err => {
result = { data: err };
console.log("Error occured");
return response.status(status).send(result);
});
};
18 changes: 18 additions & 0 deletions functions/model/tasksEvaluation/tasksEvaluation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* eslint-disable linebreak-style */
/* eslint-disable object-curly-spacing */
/* eslint-disable eol-last */
/* eslint-disable indent */
/* eslint-disable max-len */
// eslint-disable-next-line no-dupe-else-if

const { functions, cors } = require("../application/lib");
const { readTasksEvaluationData } = require("./readTasksEvalulationData");

exports.tasksEvaluation = functions.https.onRequest((request, response) => {
cors(request, response, () => {
const mode = request.body.data.mode;
if(mode == 'readTasksEvaluationData') {
return readTasksEvaluationData(request, response);
}
});
});
2 changes: 2 additions & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { SetupComponent } from './body/setup/setup.component';
import { HomeComponent } from './body/home/home.component';
import { ViewOrganizationDetailsComponent } from './body/view-organization-details/view-organization-details.component';
import { PagenotfoundComponent } from './pagenotfound/pagenotfound.component';
import { TasksEvaluationComponent } from './body/tasks-evaluation/tasks-evaluation.component';

const redirectLoggedInToDashboard = () => redirectLoggedInTo(['MyDashboard']);

Expand All @@ -29,6 +30,7 @@ const routes: Routes = [
{ path: 'CreateNewSession', component: CreateNewSessionComponent, canActivate: [AngularFireAuthGuard] },
{ path: 'StartNewSprint', component: CreateNewSprintComponent, canActivate: [AngularFireAuthGuard] },
{ path: 'Tasks/:teamId/:currentSprintName', component: TasksComponent, canActivate: [AngularFireAuthGuard] },
{ path: 'TasksEvaluation', component: TasksEvaluationComponent, canActivate: [AngularFireAuthGuard] },
{ path: 'TaskDetails/:taskId', component: TaskDetailsComponent, canActivate: [AngularFireAuthGuard] },
{ path: 'MyDashboard', component: MyDashBoardComponent, canActivate: [AngularFireAuthGuard] },
{ path: 'CreateNewOrganization', component: CreateNewOrganizationComponent, canActivate: [AngularFireAuthGuard] },
Expand Down
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import { ViewOrganizationDetailsComponent } from './body/view-organization-detai
import { Patch4Component } from './patches/patch4/patch4.component';
import { WarningComponent } from './body/common-tools/warning/warning.component';
import { DifficultyIconsComponent } from './icons/difficulty-icons/difficulty-icons.component';
import { TasksEvaluationComponent } from './body/tasks-evaluation/tasks-evaluation.component';


@NgModule({
Expand Down Expand Up @@ -133,7 +134,8 @@ import { DifficultyIconsComponent } from './icons/difficulty-icons/difficulty-ic
ViewOrganizationDetailsComponent,
Patch4Component,
WarningComponent,
DifficultyIconsComponent
DifficultyIconsComponent,
TasksEvaluationComponent
],
imports: [
BrowserModule,
Expand Down
103 changes: 103 additions & 0 deletions src/app/body/tasks-evaluation/tasks-evaluation.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#navbarMenu {
background-color: var(--primary-color);
color: var(--button-text);
}

.container {
background-color: var(--secondary-bg);
box-shadow: var(--box-shadow-bottom);
color: var(--text);
}

.table th {
color: var(--text);
}

.table td:not(:last-child){
color: var(--text);
cursor: pointer;
}

#moveBtn, #dropdownButton {
background-color: var(--secondary-color);
color: var(--button-text);
}

#moveBtn:hover:disabled {
background-color: var(--secondary-color);
color: var(--button-text);
}

#moveBtn:hover {
background-color: var(--primary-color);
color: var(--button-text);
}

.dropdown #button {
color: var(--button-text);
}

.dropdown #button:hover {
background-color: var(--secondary-color);
}

select {
background: none;
border: none;
color: var(--button-text);
}

select:hover {
background-color: var(--secondary-color);
}

select option {
background-color: var(--secondary-color);
}

.pagination li a:hover {
cursor: pointer;
background-color: var(--secondary-bg);
}

.pagination li a:focus {
box-shadow: none;
outline: none 0;
}

.pagination li a {
color: var(--secondary-color);
background-color: var(--secondary-bg);
}

.pagination .disabled a {
color: var(--text);
}

#filterMenu {
background-color: var(--secondary-bg);
padding-right: 35px;
padding-left: 5px;
}

.modal-header {
background-color: var(--primary-color);
}

.modal-content {
background-color: var(--secondary-bg);
border: var(--primary-border);
color: var(--text);
}

.head {
font-weight: bolder;
}

.btn-secondary {
background-color: var(--button-hover-bg);
}

.btn-secondary:hover {
background-color: var(--button-bg);
}
139 changes: 139 additions & 0 deletions src/app/body/tasks-evaluation/tasks-evaluation.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<div class="container">
<div class="row align-items-center py-2" id="navbarMenu">
<div class="col-8">
<h5 style="font-weight:bolder">Tasks</h5>
</div>
<div class="col-3 text-right">
<select class="form-select form-control-lg p-2" [(ngModel)]="selectedTeamId" (ngModelChange)="readTasks()">
<ng-container *ngFor="let teamId of teamIds">
<option>{{ teamId }}</option>
</ng-container>
</select>
</div>
<div class="col-1 text-right">
<div class="dropdown float-right">
<button class="btn material-icons" type="button" id="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">filter_list</button>
<div class="dropdown-menu dropdown-menu-right py-4" id="filterMenu" aria-labelledby="dropdownMenuButton">
<div class="input-group">
<input class="form-control" style="font-size: 11px;" type="number" id="filterSprintNumberInput" [(ngModel)]="filterSprintNumber">
<div class="col-md-3 col-3">
<button class="btn" id="dropdownButton" style="font-size: 10px;" (click)="readTasks()">Filter</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row pt-1">
<ng-container>
<div class="col">
<ng-container>
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th colspan="1">Status</th>
<th colspan="1">Priority</th>
<th colspan="1">Difficulty</th>
<th colspan="1">Task Id</th>
<th colspan="3">Title</th>
<th colspan="2">Assignee</th>
<th colspan="1">Sprint</th>
<th colspan="2">Move to Current Sprint?</th>
</tr>
</thead>
<tbody>
<ng-container *ngIf="!tasks.length && !showLoader;">
<tr>
<td colspan="12" class="text-center">No tasks available</td>
</tr>
</ng-container>
<ng-container *ngIf="tasks.length && !showLoader;">
<ng-container *ngFor="let item of tasks">
<tr>
<td colspan="1">
<app-status-icons [Status]="item.Status"></app-status-icons>
</td>
<td colspan="1">
<app-priority-icons [Priority]="item.Priority"></app-priority-icons>
</td>
<td colspan="1">
<app-difficulty-icons [Difficulty]="item.Difficulty"></app-difficulty-icons>
</td>
<td colspan="1"><span style="font-weight:bold;" data-toggle="tooltip" data-placement="top" title="task.id">{{item.Id}}</span></td>
<td colspan="3">{{item.Title}}</td>
<td colspan="2"><span class="material-icons" data-toggle="tooltip" style="vertical-align: middle;" data-placement="top" title="Assignee">perm_identity</span> {{item.Assignee}}</td>
<td colspan="1">{{ getSprintName(item.SprintNumber) }}</td>
<td colspan="2" class="text-center">
<button class="btn" id="moveBtn" [disabled]="item.SprintNumber == teamCurrentSprint" (click)="moveToCurrentSprint(item)" data-bs-toggle="tooltip" data-bs-placement="top" data-toggle="modal" data-target="#Modal">Move</button>
</td>
</tr>
</ng-container>
</ng-container>
<ng-container *ngIf="showLoader">
<tr>
<td colspan="12" class="text-center"><app-loader></app-loader></td>
</tr>
</ng-container>
<tr>
<td colspan="12" class="pb-0">
<nav id="pagination">
<ul class="pagination justify-content-end">
<li [ngClass]="disable_prev ? 'page-item disabled' : 'page-item'" (click)="prevPage()">
<a class="page-link" tabindex="-1">Previous</a>
</li>
<li [ngClass]="disable_next ? 'page-item disabled' : 'page-item'" (click)="nextPage()">
<a class="page-link">Next</a>
</li>
</ul>
</nav>
</td>
</tr>
</tbody>
</table>
</div>
</ng-container>
</div>
</ng-container>
</div>
</div>
<div class="modal fade" id="Modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<nav class="modal-header navbar navbar-expand navbar-dark" id="navbarMenu">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<h5 class="active nav-link head" id="ModalLabel">Moving to Current Sprint</h5>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="nav-item">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true" class="material-icons text-light">close</span>
</button>
</li>
</ul>
</nav>
<ng-container *ngIf="showModalLoader">
<div class="container pt-2">
<div class="row">
<div class="col"><app-loader></app-loader></div>
</div>
</div>
</ng-container>
<ng-container *ngIf="!showModalLoader">
<div class="container pt-2">
<div class="row">
<div class="col">Successfully Moved to Current Sprint!</div>
</div>
<div class="row">
<div class="col-md-9"></div>
<div class="col-md-3 pb-2 px-4">
<button class="btn btn-secondary" type="button" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</ng-container>
</div>
</div>
</div>
Loading

0 comments on commit ef4557f

Please sign in to comment.