-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #883 from Worktez/dev-angular
Internal Release 7.7
- Loading branch information
Showing
53 changed files
with
2,629 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}; |
Oops, something went wrong.