Skip to content

feat: optional description for robots #581

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions public/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@
},
"tooltips": {
"saving": "Workflow wird optimiert und gespeichert"
}
},
"description": "Beschreibung (optional)"
},
"browser_recording": {
"modal": {
Expand Down Expand Up @@ -426,7 +427,8 @@
"created_at": "Erstellungsdatum des Roboters",
"errors": {
"robot_not_found": "Roboterdetails konnten nicht gefunden werden. Bitte versuchen Sie es erneut."
}
},
"description": "Beschreibung (optional)"
},
"robot_edit": {
"title": "Roboter bearbeiten",
Expand Down
9 changes: 7 additions & 2 deletions public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,11 @@
},
"tooltips": {
"saving": "Optimizing and saving the workflow"
}
},

"description": "Description (optional)"


},
"browser_recording": {
"modal": {
Expand Down Expand Up @@ -439,7 +443,8 @@
"created_at": "Robot Created At",
"errors": {
"robot_not_found": "Could not find robot details. Please try again."
}
},
"description":"Description (optional)"
},
"robot_edit": {
"title": "Edit Robot",
Expand Down
6 changes: 4 additions & 2 deletions public/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@
},
"tooltips": {
"saving": "Optimizando y guardando el flujo de trabajo"
}
},
"description": "Descripción (opcional)"
},
"browser_recording": {
"modal": {
Expand Down Expand Up @@ -427,7 +428,8 @@
"created_at": "Fecha de Creación del Robot",
"errors": {
"robot_not_found": "No se pudieron encontrar los detalles del robot. Inténtelo de nuevo."
}
},
"description": "Descripción (opcional)"
},
"robot_edit": {
"title": "Editar Robot",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,8 @@
"created_at": "作成日時",
"errors": {
"robot_not_found": "ロボットの詳細が見つかりませんでした。もう一度試してください。"
}
},
"description": "説明(任意)"
},
"robot_edit": {
"title": "ロボットを編集",
Expand Down
6 changes: 4 additions & 2 deletions public/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@
},
"tooltips": {
"saving": "正在优化并保存工作流程"
}
},
"description": "描述(可选)"
},
"browser_recording": {
"modal": {
Expand Down Expand Up @@ -427,7 +428,8 @@
"created_at": "机器人创建时间",
"errors": {
"robot_not_found": "无法找到机器人详细信息。请重试。"
}
},
"description": "描述(可选)"
},
"robot_edit": {
"title": "编辑机器人",
Expand Down
7 changes: 4 additions & 3 deletions server/src/db/config/database.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const dotenv = require('dotenv');
dotenv.config({ path: './.env' });

require('dotenv').config({ path: './.env' });



// Validate required environment variables
const requiredEnvVars = ['DB_USER', 'DB_PASSWORD', 'DB_NAME', 'DB_HOST', 'DB_PORT'];
Expand All @@ -10,7 +12,6 @@ requiredEnvVars.forEach(envVar => {
}
});


module.exports = {
development: {
username: process.env.DB_USER,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn('robot', 'description', {
type: Sequelize.TEXT,
allowNull: true
});
},

down: async (queryInterface, Sequelize) => {
await queryInterface.removeColumn('robot', 'description');
}
};
28 changes: 17 additions & 11 deletions server/src/models/Robot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,19 @@ interface WebhookConfig {
interface RobotAttributes {
id: string;
userId?: number;
description?: string | null;
recording_meta: RobotMeta;
recording: RobotWorkflow;
google_sheet_email?: string | null;
google_sheet_name?: string | null;
google_sheet_id?: string | null;
google_access_token?: string | null;
google_refresh_token?: string | null;
airtable_base_id?: string | null;
airtable_base_name?: string | null;
airtable_table_name?: string | null;
airtable_access_token?: string | null;
airtable_refresh_token?: string | null;
airtable_base_id?: string | null;
airtable_base_name?: string | null;
airtable_table_name?: string | null;
airtable_access_token?: string | null;
airtable_refresh_token?: string | null;
schedule?: ScheduleConfig | null;
airtable_table_id?: string | null;
webhooks?: WebhookConfig[] | null;
Expand All @@ -66,19 +67,20 @@ interface RobotCreationAttributes extends Optional<RobotAttributes, 'id'> { }
class Robot extends Model<RobotAttributes, RobotCreationAttributes> implements RobotAttributes {
public id!: string;
public userId!: number;
public description!: string | null;
public recording_meta!: RobotMeta;
public recording!: RobotWorkflow;
public google_sheet_email!: string | null;
public google_sheet_name!: string | null;
public google_sheet_id!: string | null;
public google_access_token!: string | null;
public google_refresh_token!: string | null;
public airtable_base_id!: string | null;
public airtable_base_name!: string | null;
public airtable_table_name!: string | null;
public airtable_access_token!: string | null;
public airtable_refresh_token!: string | null;
public airtable_table_id!: string | null;
public airtable_base_id!: string | null;
public airtable_base_name!: string | null;
public airtable_table_name!: string | null;
public airtable_access_token!: string | null;
public airtable_refresh_token!: string | null;
public airtable_table_id!: string | null;
public schedule!: ScheduleConfig | null;
public webhooks!: WebhookConfig[] | null;
}
Expand All @@ -94,6 +96,10 @@ Robot.init(
type: DataTypes.INTEGER,
allowNull: false,
},
description: {
type: DataTypes.TEXT,
allowNull: true,
},
recording_meta: {
type: DataTypes.JSONB,
allowNull: false,
Expand Down
15 changes: 11 additions & 4 deletions server/src/routes/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,12 @@ function handleWorkflowActions(workflow: any[], credentials: Credentials) {
router.put('/recordings/:id', requireSignIn, async (req: AuthenticatedRequest, res) => {
try {
const { id } = req.params;
const { name, limits, credentials, targetUrl } = req.body;

const { name, limit, credentials, targetUrl,description } = req.body;


// Validate input
if (!name && !limits && !credentials && !targetUrl) {
if (!name && !limit && !credentials && !targetUrl) {
return res.status(400).json({ error: 'Either "name", "limits", "credentials" or "target_url" must be provided.' });
}

Expand All @@ -272,6 +274,10 @@ router.put('/recordings/:id', requireSignIn, async (req: AuthenticatedRequest, r
if (name) {
robot.set('recording_meta', { ...robot.recording_meta, name });
}

if(description){
robot.set('description', description);
}

if (targetUrl) {
const updatedWorkflow = [...robot.recording.workflow];
Expand All @@ -294,6 +300,7 @@ router.put('/recordings/:id', requireSignIn, async (req: AuthenticatedRequest, r
}
}
}

}

await robot.save();
Expand All @@ -304,8 +311,8 @@ router.put('/recordings/:id', requireSignIn, async (req: AuthenticatedRequest, r
workflow = handleWorkflowActions(workflow, credentials);
}

if (limits && Array.isArray(limits) && limits.length > 0) {
for (const limitInfo of limits) {
if (limit && Array.isArray(limit) && limit.length > 0) {
for (const limitInfo of limit) {
const { pairIndex, actionIndex, argIndex, limit } = limitInfo;

const pair = workflow[pairIndex];
Expand Down
12 changes: 7 additions & 5 deletions server/src/workflow-management/classes/Generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ export class WorkflowGenerator {
*/
private registerEventHandlers = (socket: Socket) => {
socket.on('save', (data) => {
const { fileName, userId, isLogin, robotId } = data;
const { fileName, userId, isLogin, robotId,description } = data;
logger.log('debug', `Saving workflow ${fileName} for user ID ${userId}`);
this.saveNewWorkflow(fileName, userId, isLogin, robotId);
this.saveNewWorkflow(fileName, userId, isLogin, robotId,description);
});
socket.on('new-recording', (data) => {
this.workflowRecord = {
Expand Down Expand Up @@ -767,7 +767,7 @@ export class WorkflowGenerator {
* @param fileName The name of the file.
* @returns {Promise<void>}
*/
public saveNewWorkflow = async (fileName: string, userId: number, isLogin: boolean, robotId?: string) => {
public saveNewWorkflow = async (fileName: string, userId: number, isLogin: boolean, robotId?: string,description?: string) => {
const recording = this.optimizeWorkflow(this.workflowRecord);
let actionType = 'saved';

Expand All @@ -784,10 +784,11 @@ export class WorkflowGenerator {
params: this.getParams() || [],
updatedAt: new Date().toLocaleString(),
},
description: description,
})

actionType = 'retrained';
logger.log('info', `Robot retrained with id: ${robot.id}`);
logger.log('info', `Robot retrained with id: ${robot.id} and name: ${robot.description}`);
}
} else {
this.recordingMeta = {
Expand All @@ -803,6 +804,7 @@ export class WorkflowGenerator {
userId,
recording_meta: this.recordingMeta,
recording: recording,
description: description,
});
capture(
'maxun-oss-robot-created',
Expand All @@ -813,7 +815,7 @@ export class WorkflowGenerator {
)

actionType = 'saved';
logger.log('info', `Robot saved with id: ${robot.id}`);
logger.log('info', `Robot saved with id: ${robot.id} with description: ${robot.description}`);
}
}
catch (e) {
Expand Down
9 changes: 3 additions & 6 deletions src/api/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ export const getStoredRecordings = async (): Promise<string[] | null> => {
}
};

export const updateRecording = async (id: string, data: {
name?: string;
limits?: Array<{pairIndex: number, actionIndex: number, argIndex: number, limit: number}>;
credentials?: Credentials;
targetUrl?: string
}): Promise<boolean> => {

export const updateRecording = async (id: string, data: { name?: string; limit?: number, credentials?: Credentials, targetUrl?: string,description?:string }): Promise<boolean> => {

try {
const response = await axios.put(`${apiUrl}/storage/recordings/${id}`, data);
if (response.status === 200) {
Expand Down
4 changes: 4 additions & 0 deletions src/components/recorder/AddWhereCondModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ export const AddWhereCondModal = ({ isOpen, onClose, pair, index }: AddWhereCond
)
}





export const modalStyle = {
top: '40%',
left: '50%',
Expand Down
Loading