Files
Dwinzo-Beta-Backend/src/API/routes/widgetRoute.ts

144 lines
3.9 KiB
TypeScript

import * as express from "express";
import { widgetService } from "../service/widgetService.ts";
const router = express.Router();
/**
* @swagger
* tags:
* - name: Widgets
* description: API operations related to widgets
*/
/**
* @swagger
* components:
* schemas:
* Widget:
* type: object
* properties:
* _id:
* type: string
* example: "60d0fe4f5311236168a109cd"
* widgetName:
* type: string
* example: "Temperature Widget"
* widgetside:
* type: string
* example: "right"
* widgetID:
* type: string
* example: "wid-12345"
* widgetOrder:
* type: string
* example: "1"
* elementType:
* type: string
* example: "chart"
* elementColor:
* type: string
* example: "#FF5733"
* fontFamily:
* type: string
* example: "Arial"
* fontStyle:
* type: string
* example: "bold"
* fontWeight:
* type: string
* example: "600"
* isArchive:
* type: boolean
* example: false
* panelID:
* type: string
* example: "67e3d030ed12ffa47b4eade3"
* Data:
* type: array
* items:
* type: object
* example: []
* required:
* - widgetName
* - widgetID
* - widgetOrder
* - elementType
* - panelID
*
*/
/**
* @swagger
* /widget/save:
* post:
* summary: Create a new widget inside a panel
* tags: [Widgets]
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* properties:
* organization:
* type: string
* example: "NEWORG"
* panelID:
* type: string
* example: "67e3d030ed12ffa47b4eade3"
* widgetName:
* type: string
* example: "Temperature Widget"
* widgetOrder:
* type: string
* example: "1"
* type:
* type: string
* example: "chart"
* widgetID:
* type: string
* example: "wid-12345"
* panel:
* type: string
* example: "right"
* responses:
* 201:
* description: Widget created successfully
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* example: "Widget created successfully"
* widgetID:
* type: string
* example: "60d0fe4f5311236168a109cd"
* 404:
* description: Panel not found
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* example: "PanelID not found"
* 409:
* description: Widget with the given widgetID already exists
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* example: "Widget already exists for the widgetID"
* 500:
* description: Server error
*/
router.post("/widget/save", widgetService.addWidget);
router.patch("/widget/delete", widgetService.deleteWidget);
router.get(
"/WidgetData/:widgetID/:organization",
widgetService.getDatafromWidget
);
export default router;