New version API collaboration and tested for Project
This commit is contained in:
@@ -3,7 +3,10 @@ import panelModel from "../../V1Models/Vizualization/panelmodel.ts";
|
||||
import zoneModel from "../../V1Models/Builder/zoneModel.ts";
|
||||
import widgetModel from "../../V1Models/Vizualization/widgemodel.ts";
|
||||
import floatWidgetModel from "../../V1Models/Vizualization/floatWidget.ts";
|
||||
import { existingUser } from "../helpers/v1projecthelperFns.ts";
|
||||
import {
|
||||
existingProjectById,
|
||||
existingUser,
|
||||
} from "../helpers/v1projecthelperFns.ts";
|
||||
interface IResult {
|
||||
status: string;
|
||||
data?: object;
|
||||
@@ -45,6 +48,12 @@ export const AddTemplate = async (data: IAddTemplate): Promise<IResult> => {
|
||||
const { organization, template, projectId, userId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
projectId,
|
||||
organization,
|
||||
userId
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const existingTemplate = await templateModel(organization).findOne({
|
||||
templateID: template.id,
|
||||
isArchive: false,
|
||||
@@ -96,6 +105,12 @@ export const AddTemplateToZone = async (
|
||||
const { organization, templateID, projectId, zoneId, userId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
projectId,
|
||||
organization,
|
||||
userId
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const existingZone = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
isArchive: false,
|
||||
@@ -238,6 +253,12 @@ export const TemplateDelete = async (data: ITemplate): Promise<IResult> => {
|
||||
const { templateID, projectId, userId, organization } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
projectId,
|
||||
organization,
|
||||
userId
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const existingTemplate = await templateModel(organization).findOne({
|
||||
templateID: templateID,
|
||||
isArchive: false,
|
||||
@@ -275,6 +296,12 @@ export const GetAllTemplates = async (data: IGetTemplate): Promise<IResult> => {
|
||||
const { organization, userId, projectId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
projectId,
|
||||
organization,
|
||||
userId
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const templateDatas = await templateModel(organization)
|
||||
.find({ projectId: projectId, isArchive: false })
|
||||
.select("-_id -__v -isArchive -createdAt -updatedAt");
|
||||
|
||||
Reference in New Issue
Block a user