Skip to content

Commit

Permalink
Merge pull request #883 from Worktez/dev-angular
Browse files Browse the repository at this point in the history
Internal Release 7.7
  • Loading branch information
simran142002 authored Jan 7, 2023
2 parents d376b79 + b37f22f commit 522a3c2
Show file tree
Hide file tree
Showing 53 changed files with 2,629 additions and 117 deletions.
4 changes: 3 additions & 1 deletion functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const { meet } = require("./model/meet/meet");
const { payment } = require("./model/payment/payment");
const { subscriptions } = require("./model/subscriptions/subscriptions");
const { scheduledSubFnManually } = require("./model/scheduledCheckSub/scheduledCheckSub");
const { makeRelease } = require("./model/makeRelease/makeRelease");

exports.users = users;
exports.tasks = tasks;
Expand All @@ -70,4 +71,5 @@ exports.requestDemo = requestDemo;
exports.meet = meet;
exports.payment = payment;
exports.subscriptions = subscriptions;
exports.scheduledSubFnManually = scheduledSubFnManually;
exports.scheduledSubFnManually = scheduledSubFnManually;
exports.makeRelease = makeRelease;
105 changes: 105 additions & 0 deletions functions/model/makeRelease/lib.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/* eslint-disable valid-jsdoc */
/** *********************************************************
* Copyright (C) 2022
* Worktez
* Author : Simran Nigam <[email protected]>
*
* 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.
***********************************************************/
/* eslint-disable max-len */
const {db} = require("../application/lib");

/**
* Description
* @param {any} description
* @param {any} releaseName
* @param {any} tagName
* @param {any} targetBranch
* @param {any} ifDraft
* @param {any} preRelease
* @param {any} generateRelease
* @param {any} ownerName
* @param {any} repoName
* @param {any} teamId
* @param {any} releaseId
* @param {any} orgDomain
* @param {any} releaseDate
* @param {any} title
* @return {any}
*/
exports.setRelease = function(description, releaseName, tagName, targetBranch, ifDraft, preRelease, generateRelease, teamId, releaseId, orgDomain, releaseDate, title) {
const setReleasePromise = db.collection("Organizations").doc(orgDomain).collection("Releases").doc(releaseId).set({
Description: description,
ReleaseName: releaseName,
TagName: tagName,
TargetBranch: targetBranch,
IfDraft: ifDraft,
PreRelease: preRelease,
GenerateRelease: generateRelease,
TeamId: teamId,
ReleaseDate: releaseDate,
ReleaseId: releaseId,
Title: title,
Status: "OK",
});
return Promise.resolve(setReleasePromise);
};

/**
* Description
* @param {any} orgDomain
* @param {any} teamId
* @return {any}
*/
exports.getAllReleaseData = function(orgDomain, teamId="") {
let query = db.collection("Organizations").doc(orgDomain).collection("Releases").where("Status", "==", "OK");
if (teamId != "") {
query = query.where("TeamId", "==", teamId);
}

const promise = query.get().then((doc) => {
const data=[];
doc.forEach((element) => {
if (element.exists) {
data.push(element.data());
}
});
return data;
});
return Promise.resolve(promise);
};

/**
* Description
* @param {any} orgDomain
* @param {any} teamId
* @param {any} releaseId
* @return {any}
*/
exports.updateRelease = function(updateReleaseToJson, orgDomain, releaseId) {
const updateReleasePromise = db.collection("Organizations").doc(orgDomain).collection("Releases").doc(releaseId).update(updateReleaseToJson);
return Promise.resolve(updateReleasePromise);
};

/**
* Description
* @param {any} orgDomain
* @param {any} releaseId
* @return {any}
*/
exports.getReleaseData = function(orgDomain, releaseId) {
const getReleaseDataPromise = db.collection("Organizations").doc(orgDomain).collection("Releases").doc(releaseId).get().then((doc) => {
if (doc.exists) {
return doc.data();
} else {
return;
}
});
return Promise.resolve(getReleaseDataPromise);
};
91 changes: 91 additions & 0 deletions functions/model/makeRelease/makeRelease.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/* eslint-disable max-len */
/** *********************************************************
* Copyright (C) 2022
* Worktez
* Author : Simran Nigam <[email protected]>
* 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 {functions, cors, fastify, requestHandler} = require("../application/lib");
const {addRelease} = require("./tark/addRelease");
const {getAllReleases} = require("./tark/getAllReleases");
const {getRelease} = require("./tark/getRelease");
const {deleteRelease} = require("./tark/deleteRelease");
const {editRelease} = require("./tark/editRelease");

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

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

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

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

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

/**
* Description
* @param {any} req
* @param {any} res
* @returns {any}
*/
exports.makeRelease = functions.https.onRequest((req, res) => {
cors(req, res, () => {
fastify.ready((err) => {
if (err) throw err;
requestHandler(req, res);
});
});
});
57 changes: 57 additions & 0 deletions functions/model/makeRelease/tark/addRelease.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/** *********************************************************
* Copyright (C) 2022
* Worktez
* Author : Simran Nigam <[email protected]>
*
* 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.
***********************************************************/
/* eslint-disable max-len */
const {getAllReleaseData} = require("../lib");
const {setRelease} = require("../lib");

/**
* Description
* @param {any} request
* @param {any} response
*/
exports.addRelease = function(request, response) {
let result;
let status = 200;
const description = request.body.data.Description;
const releaseName = request.body.data.ReleaseName;
const tagName = request.body.data.TagName;
const targetBranch = request.body.data.TargetBranch;
const ifDraft = request.body.data.IfDraft;
const preRelease = request.body.data.PreRelease;
const generateRelease = request.body.data.GenerateRelease;
const releaseDate = request.body.data.ReleaseDate;
const teamId = request.body.data.TeamId;
const orgDomain = request.body.data.OrgDomain;
const title = request.body.data.Title;

const promise = getAllReleaseData(orgDomain).then((data) => {
this.releaseData = data;
const releaseId = "R" + (this.releaseData.length +1);

setRelease(description, releaseName, tagName, targetBranch, ifDraft, preRelease, generateRelease, teamId, releaseId, orgDomain, releaseDate, title).catch(
(error) => {
result = {data: error};
status = 500;
console.error("Error", error);
});
Promise.resolve(promise).then(() => {
console.log("Release added Successfully");
result = {data: "Release added Successfully"};
return response.status(status).send(result);
}).catch((error) => {
console.error("Error adding release", error);
return response.status(status).send(result);
});
});
};
45 changes: 45 additions & 0 deletions functions/model/makeRelease/tark/deleteRelease.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/** *********************************************************
* Copyright (C) 2022
* Worktez
* Author : Simran Nigam <[email protected]>
*
* 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 {getReleaseData, updateRelease} = require("../lib");

exports.deleteRelease = function(request, response) {
const orgDomain = request.body.data.OrgDomain;
const releaseId = request.body.data.ReleaseId;
let result;
let status = 200;
console.log(orgDomain, releaseId);
const promise = getReleaseData(orgDomain, releaseId).then((releaseData) => {
if (releaseData == undefined) {
result = {data: {status: "Release does not exist"}};
} else {
const updateReleaseToJson={
Status: "DELETED",
};
updateRelease(updateReleaseToJson, orgDomain, releaseId);
}
}).catch((error) => {
status = 500;
console.log("Error:", error);
});

Promise.resolve(promise).then(() => {
result = {data: {status: "OK"}};
console.log("Release Deleted Successfully");
return response.status.send(result);
}).catch((error) => {
result = {data: error};
console.error("Error Deleting", error);
return response.status(status).send(result);
});
};
48 changes: 48 additions & 0 deletions functions/model/makeRelease/tark/editRelease.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const {getReleaseData, updateRelease} = require("../lib");

exports.editRelease = function(request, response) {
const orgDomain = request.body.data.OrgDomain;
const releaseId = request.body.data.ReleaseId;
const releaseName = request.body.data.ReleaseName;
const tagName = request.body.data.TagName;
const targetBranch = request.body.data.TargetBranch;
const description = request.body.data.Description;
const ifDraft = request.body.data.IfDraft;
const preRelease = request.body.data.PreRelease;
const generateRelease = request.body.data.GenerateRelease;
const teamId = request.body.data.TeamId;

let result;
let status = 200;

const promise = getReleaseData(orgDomain, releaseId).then((releaseData) => {
if (releaseData == undefined) {
result = {data: {status: "Release does not exist"}};
} else {
const inputJson = {
ReleaseName: releaseName,
Description: description,
TagName: tagName,
TargetBranch: targetBranch,
IfDraft: ifDraft,
PreRelease: preRelease,
GenerateRelease: generateRelease,
TeamId: teamId,
};
updateRelease(inputJson, orgDomain, releaseId);
}
}).catch((error) => {
status = 500;
console.log("Error:", error);
});

Promise.resolve(promise).then(() => {
result = {data: {status: "OK"}};
console.log("release edited Successfully");
return response.status(status).send(result);
}).catch((error) => {
result = {data: error};
console.error("Error editing Release", error);
return response.status(status).send(result);
});
};
Loading

0 comments on commit 522a3c2

Please sign in to comment.