New version API collaboration and tested for Project
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import panelModel from "../../V1Models/Vizualization/panelmodel.ts";
|
||||
import zoneModel from "../../V1Models/Builder/zoneModel.ts";
|
||||
import widgetModel from "../../V1Models/Vizualization/widgemodel.ts";
|
||||
import { existingUser } from "../helpers/v1projecthelperFns.ts";
|
||||
import {
|
||||
existingProjectById,
|
||||
existingUser,
|
||||
} from "../helpers/v1projecthelperFns.ts";
|
||||
interface IResult {
|
||||
status: string;
|
||||
data?: object;
|
||||
@@ -32,6 +35,12 @@ export const AddPanel = async (data: IAddPanel): Promise<IResult> => {
|
||||
const { organization, zoneId, panelOrder, 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 existingZone = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
isArchive: false,
|
||||
@@ -97,6 +106,12 @@ export const DelPanel = async (data: IPanel): Promise<IResult> => {
|
||||
const { organization, zoneId, panelName, 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 existingZone = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
isArchive: false,
|
||||
@@ -156,6 +171,12 @@ export const ClearPanel = async (data: IPanel): Promise<IResult> => {
|
||||
const { organization, zoneId, panelName, 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 existingZone = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
isArchive: false,
|
||||
@@ -219,6 +240,12 @@ export const LockedPanel = async (data: ILockedPanel): Promise<IResult> => {
|
||||
const { organization, zoneId, lockedPanel, 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 existingZone = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
isArchive: false,
|
||||
@@ -267,6 +294,8 @@ const getZoneAndPanelData = async (
|
||||
projectId: string
|
||||
) => {
|
||||
try {
|
||||
|
||||
|
||||
const existingZone = await zoneModel(organization)
|
||||
.findOne({
|
||||
zoneId: zoneId,
|
||||
|
||||
Reference in New Issue
Block a user