Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
5 changes: 2 additions & 3 deletions server/src/db/config/database.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import dotenv from 'dotenv';
dotenv.config({ path: './.env' });
// CommonJS format for database.js
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 +10,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 @@ -18,18 +18,19 @@ interface RobotWorkflow {
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;
}
Expand All @@ -52,19 +53,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;
}

Expand All @@ -79,6 +81,10 @@ Robot.init(
type: DataTypes.INTEGER,
allowNull: false,
},
description: {
type: DataTypes.TEXT,
allowNull: true,
},
recording_meta: {
type: DataTypes.JSONB,
allowNull: false,
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
21 changes: 20 additions & 1 deletion src/components/recorder/SaveRecording.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const SaveRecording = ({ fileName }: SaveRecordingProps) => {
const [openModal, setOpenModal] = useState<boolean>(false);
const [needConfirm, setNeedConfirm] = useState<boolean>(false);
const [saveRecordingName, setSaveRecordingName] = useState<string>(fileName);
const [saveRecordingDescription, setSaveRecordingDescription] = useState<string>("");
const [waitingForSave, setWaitingForSave] = useState<boolean>(false);

const { browserId, setBrowserId, notify, recordings, isLogin, recordingName, retrainRobotId } = useGlobalInfoStore();
Expand All @@ -42,6 +43,11 @@ export const SaveRecording = ({ fileName }: SaveRecordingProps) => {
setSaveRecordingName(value);
}

const handleChangeOfDescription = (event: React.ChangeEvent<HTMLInputElement>) => {
const { value } = event.target;
setSaveRecordingDescription(value);
}

const handleSaveRecording = async (event: React.SyntheticEvent) => {
event.preventDefault();
if (recordings.includes(saveRecordingName)) {
Expand Down Expand Up @@ -108,10 +114,13 @@ export const SaveRecording = ({ fileName }: SaveRecordingProps) => {
userId: user.id,
isLogin: isLogin,
robotId: retrainRobotId,
description: saveRecordingDescription,
};

console.log(payload)
socket?.emit('save', payload);
setWaitingForSave(true);
console.log(`Saving the recording as ${saveRecordingName || recordingName} for userId ${user.id}`);
console.log(`Saving the recording as ${saveRecordingName || recordingName} for userId ${user.id} with description: ${saveRecordingDescription}`);
} else {
console.error(t('save_recording.notifications.user_not_logged'));
}
Expand Down Expand Up @@ -153,6 +162,16 @@ export const SaveRecording = ({ fileName }: SaveRecordingProps) => {
variant="outlined"
value={saveRecordingName}
/>
<TextField
sx={{ width: '300px', margin: '15px 0px' }}
onChange={handleChangeOfDescription}
id="description"
label={t('save_recording.description')}
variant="outlined"
value={saveRecordingDescription}
multiline
rows={2}
/>
{needConfirm
?
(<React.Fragment>
Expand Down