Skip to content

Commit

Permalink
Merge pull request #655 from Worktez/dev-angular
Browse files Browse the repository at this point in the history
Internal Release 6.3
  • Loading branch information
simran142002 authored Aug 13, 2022
2 parents 81bd747 + f71ddeb commit 4571e12
Show file tree
Hide file tree
Showing 24 changed files with 517 additions and 37 deletions.
12 changes: 12 additions & 0 deletions functions/model/librarian/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ exports.setProfilePicToUserDocument = function(inputJson, uid, orgFileDocumentNa
return Promise.resolve(setProfilePicToUserDocumentPromise);
};

/**
* Description
* @param {any} inputJson
* @param {any} uid
* @param {any} imageFileName
* @return {any}
*/
exports.setPostImages = function(inputJson, uid, imageFileName) {
const setPostImagesPromise = db.collection("Social").doc(postId).collection("postImages").doc(imageFileName).set(inputJson);
return Promise.resolve(setPostImagesPromise);
};

/**
* Description
* @param {any} uid
Expand Down
11 changes: 11 additions & 0 deletions functions/model/librarian/librarian.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,17 @@ fastify.post("/uploadUserProfilePic", (req, res) => {
uploadProfilePicToUserDoc(req, res);
});

/**
* Description
* @param {any} "/uploadPostImages"
* @param {any} req
* @param {any} res
* @returns {any}
*/
fastify.post("/uploadPostImages", (req, res) => {
uploadPostImagesDoc(req, res);
});

/**
* Description
* @param {any} "/uploadUserProfilePic"
Expand Down
74 changes: 74 additions & 0 deletions functions/model/librarian/tark/uploadPostImages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/* eslint-disable linebreak-style */
/* eslint-disable max-len */
/* eslint-disable no-trailing-spaces */
/* eslint-disable object-curly-spacing */
/* eslint-disable no-unused-vars */
/** *********************************************************
* Copyright (C) 2022
* Worktez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the MIT License
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the MIT License for more details.
***********************************************************/

const { setPostImages } = require("../lib");
const { getPost, updatePost } = require("../../users/lib");

exports.uploadProfilePicToUserDoc = function(request, response) {
const fileName = request.body.data.FileName;
const fileUrl = request.body.data.FileUrl;
const lastModified = request.body.data.LastModified;
const size = request.body.data.Size;
const date = request.body.data.Date;
const time = request.body.data.Time;
const basePath = request.body.data.BasePath;
const uid = request.body.data.Uid;

let result;
let status = 200;

const promise = getPost(postId).then((data) => {
let photoCounter = data.TotalPhotoCounter;
photoCounter++;

const updateUserDocJson = {
TotalPhotoCounter: photoCounter,
};
updatePost(updateUserDocJson, postId);

const imageFileName = "P" + photoCounter;
const updateUserFileJson = {
FileName: fileName,
FileUrl: fileUrl,
LastModified: lastModified,
Size: size,
Date: date,
Time: time,
OrgFileDocumentName: orgFileDocumentName,
BasePath: basePath,
FileStatus: "OK",
};
setPostImages(updateUserFileJson, postId, imageFileName);
}).catch((error) => {
status = 500;
console.log("Error:", error);
});

Promise.resolve(promise).then(() => {
result = { data: { status: "OK" } };
console.log("Image Uploaded Successfully");
return response.status(status).send(result);
})
.catch((error) => {
result = { data: error };
console.error("Error Uploading Image", error);
return response.status(status).send(result);
});
};

Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ exports.getPerformanceChartData = function(request, response) {
const teamId = data.TeamId;
const assignee = data.Assignee;
const sprintRange = data.SprintNumberRange;
const sprintRange1 = sprintRange["SprintRange1"];
const sprintRange2 = sprintRange["SprintRange2"];

let teamName;
let result;
let status = 200;
Expand Down Expand Up @@ -60,7 +63,10 @@ exports.getPerformanceChartData = function(request, response) {
result = {data: {status: "ERROR", data: "undefined"}};
} else {
for (const i in doc) {
responseData.push([i, doc[i]]);
const j=i.slice(1);
if (j>=sprintRange1 && j<=sprintRange2) {
responseData.push([i, doc[i]]);
}
}
console.log(responseData);
result = { data: { status: "OK", data: responseData } };
Expand Down
18 changes: 16 additions & 2 deletions functions/model/socialPage/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ const { db } = require("../application/lib");
* @param {any} postId
* @param {any} lastUpdatedDate
* @param {any} lastUpdatedTime
* @param {any} photoURLs
* @return {any}
*/
exports.setPost = function(uid, post, postId, lastUpdatedDate, lastUpdatedTime) {
exports.setPost = function(uid, post, postId, lastUpdatedDate, lastUpdatedTime, photoURLs) {
const addPostPromise = db.collection("Social").doc(postId).set({
Uid: uid,
Post: post,
PostId: postId,
ImagesUrl: photoURLs,
Reach: 0,
Reactions: 0,
// ReactionCounter: 0,
Expand All @@ -51,7 +53,7 @@ exports.setPost = function(uid, post, postId, lastUpdatedDate, lastUpdatedTime)
*/
exports.getAllPosts = function() {
const query = db.collection("Social");
const getAllPosts = query.get();
const getAllPosts = query.where("Status","==","OK").get();
return Promise.resolve(getAllPosts);
};

Expand All @@ -67,6 +69,18 @@ exports.getPost = function(postId) {
return Promise.resolve(getPostDetails);
};

/**
* Description
* @param {any} updatePostToJson
* @param {any} PostId
* @param {any} uid
* @return {any}
*/
exports.deleteUserPost = function(updatePostToJson, postId) {
const deletePostPromise = db.collection("Social").doc(postId).update(updatePostToJson);
return Promise.resolve(deletePostPromise);
};

/**
* Description
* @param {any} uid
Expand Down
12 changes: 12 additions & 0 deletions functions/model/socialPage/socialPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const { addPostComment } = require("./tark/addPostComment");
const { getPosts } = require("./tark/getPosts");
const { addReaction } = require("./tark/addReaction");
const { getComments } = require("./tark/getComments");
const { deletePost } = require("./tark/deletePost");

/**
* Description
Expand Down Expand Up @@ -58,6 +59,17 @@ fastify.post("/getAllPosts", (req, res) => {
getPosts(req, res);
});

/**
* Description
* @param {any} "/deletePost"
* @param {any} req
* @param {any} res
* @returns {any}
*/
fastify.post("/deletePost", (req, res) => {
deletePost(req, res);
});

/**
* Description
* @param {any} "/addReaction"
Expand Down
5 changes: 3 additions & 2 deletions functions/model/socialPage/tark/addPost.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ const { incrementNumberofPostsforUser } = require("../../users/tark/incrementUse
exports.addPost = function(request, response) {
const uid = request.body.data.Uid;
const post = request.body.data.Post;
const postId = request.body.data.PostId;

const lastUpdatedDate = request.body.data.LastUpdatedDate;
const lastUpdatedTime = request.body.data.LastUpdatedTime;

const photoURLs = request.body.data.Urls;
let result;
let status = 200;

Expand All @@ -43,7 +44,7 @@ exports.addPost = function(request, response) {
postcounter = postcounter + 1;
const postId = "P" + postcounter;

setPost(uid, post, postId, lastUpdatedDate, lastUpdatedTime).then((postData) => {
setPost(uid, post, postId, lastUpdatedDate, lastUpdatedTime, photoURLs).then((postData) => {
incrementNumberofPostsforUser(uid);
}).catch((error) => {
result = { data: error };
Expand Down
56 changes: 56 additions & 0 deletions functions/model/socialPage/tark/deletePost.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/* eslint-disable linebreak-style */
/* eslint-disable no-unused-vars */
/** *********************************************************
* Copyright (C) 2022
* Worktez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the MIT License
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the MIT License for more details.
***********************************************************/
const {deleteUserPost, getPost} = require("../lib");
const {getUser, updateUser} = require("../../users/lib");

exports.deletePost = function(request, response) {
const uid = request.body.data.Uid;
const postId = request.body.data.PostId;

let result;
let status = 200;

const promise = getUser(uid, "").then((doc) => {
const p1 = getPost(postId).then((postData) => {
if (postData == undefined) {
result = {data: {status: "Post doesn't exist"}};
} else {
const updatePostToJson = {
Status: "DELETED",
};
deleteUserPost(updatePostToJson,postId);


}
}).catch((error) => {s
status = 500;
console.log("Error:", error);
});

return Promise.resolve(p1);
});

Promise.resolve(promise).then(() => {
result = {data: {status: "OK"}};
console.log("Post Deleted Successfully");
return response.status(status).send(result);
})
.catch((error) => {
result = {data: error};
console.error("Error Deleting", error);
return response.status(status).send(result);
});
};
8 changes: 5 additions & 3 deletions functions/model/socialPage/tark/getPosts.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ exports.getPosts = function(request, response) {

const promises = [getPostsPromise];
Promise.all(promises).then(() => {
result = { data: { status: "OK", data: postsData } };
console.log("Got Posts Sucessfully");
return response.status(status).send(result);
if (postsData) {
result = { data: { status: "OK", data: postsData } };
console.log("Got Posts Sucessfully");
return response.status(status).send(result);
}
})
.catch((error) => {
console.error("Error Getting Posts", error);
Expand Down
4 changes: 4 additions & 0 deletions src/app/Interface/SocialInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ export interface Post{
CreationTime: string;
CreationDate: string;
Post: string;
PostStatus: number;
Reach: number;
Reactions: number;
CommentCounter: number;
PostId: string;
Status: string;
ImagesUrl:[];
}

export interface Comment {
Expand All @@ -17,4 +19,6 @@ export interface Comment {
Content: string;
Status: string;
PostId: string;
ImagesUrl:[];
PostStatus: number;
}
10 changes: 10 additions & 0 deletions src/app/body/filter-task/filter-task.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,14 @@ input:focus {
#dropdownMenu {
background-color: var(--secondary-bg);
border-color: var(--primary-color);
}

.form-control {
display: inline-block;
}

.dropdown-menu{
height: auto;
max-height: 300px;
overflow-y: auto;
}
21 changes: 19 additions & 2 deletions src/app/body/filter-task/filter-task.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the MIT License for more details.
***********************************************************/ -->
<div class="row">
<div class="row" *ngIf="filtersReady">
<div class="col-md-2 col-1">
<br>
<div class="dropdown">
Expand Down Expand Up @@ -120,8 +120,25 @@
</ng-container>
<div class="col">
<br>
<button type="submit" class="btn submitButton" id="button" style="font-size: 10px;" (click)="filterByProperties()">Filter</button>
<button type="submit" class="btn submitButton" id="button" style="font-size: 10px;" (click)="filterByProperties()">Apply</button>
</div>
<ng-container >
<div class="row">
<div class="col">
<span class="ml-2 text-muted" style="font-size:0.8rem;" id="dropdownMenuButton" >Custom Filter</span>
<select class="form-control form-control-sm" [(ngModel)]="this.filters.FilterName" [ngModelOptions]="{standalone: true}" >
<option [ngValue]="Null" [disabled]="true">Select Filter</option>
<ng-container *ngFor='let item of this.filters'>
<option>{{ item.FilterName }}</option>
</ng-container>
</select>
</div>
<div class="col">
<br>
<button type="submit" class="btn submitButton" id="button" style="font-size: 10px;" (click)="customfilterByProperties(this.filters.FilterName)">Apply</button>
</div>
</div>
</ng-container>
</div>
</div>
<br>
Expand Down
Loading

0 comments on commit 4571e12

Please sign in to comment.