fixed launch

This commit is contained in:
IDONTSUDO 2024-09-23 14:18:48 +03:00
parent c0a23c31f7
commit e2cd7af032
4 changed files with 42 additions and 10 deletions

View file

@ -1,4 +1,5 @@
import { Schema, model } from "mongoose"; import { Schema, model } from "mongoose";
import { Launch } from "../../../core/models/skill_model";
export interface ISkillsModel {} export interface ISkillsModel {}
@ -12,6 +13,9 @@ export const SkillsSchema = new Schema({
BTAction: { BTAction: {
type: Schema.Types.Mixed, type: Schema.Types.Mixed,
}, },
Launch: {
type: Schema.Types.Mixed,
},
topicsOut: { topicsOut: {
type: Schema.Types.Mixed, type: Schema.Types.Mixed,
}, },
@ -19,13 +23,14 @@ export const SkillsSchema = new Schema({
type: Schema.Types.Mixed, type: Schema.Types.Mixed,
}, },
bgColor: { bgColor: {
type:Schema.Types.String, type: Schema.Types.String,
},
borderColor: {
type: Schema.Types.String,
}, },
borderColor:{
type:Schema.Types.String
}
}).plugin(require("mongoose-autopopulate")); }).plugin(require("mongoose-autopopulate"));
export const skillsSchema = "skills"; export const skillsSchema = "skills";
export const SkillsDBModel = model<ISkillsModel>(skillsSchema, SkillsSchema); export const SkillsDBModel = model<ISkillsModel>(skillsSchema, SkillsSchema);

View file

@ -177,6 +177,14 @@ export class BTAction implements IBTAction {
export class Launch implements ILaunch { export class Launch implements ILaunch {
@IsString() @IsString()
executable: string; executable: string;
@IsString()
package: string;
constructor(executable: string, plage: string) {
this.executable = executable;
this.package = plage;
}
static empty = () => new Launch("", "");
} }
export class Ros2 implements IRos2 { export class Ros2 implements IRos2 {
@IsString() @IsString()
@ -224,11 +232,14 @@ export class SkillModel extends ValidationModel implements ISkill {
@Type(() => BtActionViewModel) @Type(() => BtActionViewModel)
BTAction: BtActionViewModel[]; BTAction: BtActionViewModel[];
topicsOut: TopicViewModel[] = []; topicsOut: TopicViewModel[] = [];
@Type(() => Launch)
Launch: Launch;
static empty() { static empty() {
const skillModel = new SkillModel(); const skillModel = new SkillModel();
skillModel.BTAction = []; skillModel.BTAction = [];
skillModel.SkillPackage = SkillPackage.empty(); skillModel.SkillPackage = SkillPackage.empty();
skillModel.Module = Module.empty(); skillModel.Module = Module.empty();
skillModel.Launch = Launch.empty();
return skillModel; return skillModel;
} }
public static isEmpty(skill: SkillModel): Result<void, SkillModel> { public static isEmpty(skill: SkillModel): Result<void, SkillModel> {
@ -477,4 +488,4 @@ export class Skills {
() => Result.error(false) () => Result.error(false)
); );
} }

View file

@ -11,10 +11,17 @@ export class ValidationModel {
if (errors.isNotEmpty()) { if (errors.isNotEmpty()) {
const message = errors.map((error: ValidationError) => { const message = errors.map((error: ValidationError) => {
if (error.constraints) return Object.values(error.constraints).join(", "); let result = "";
return ""; if (error.children)
error.children.map((el) => {
if (el.constraints) {
result += Object.values(el.constraints).join(", ");
}
});
if (error.constraints) result += Object.values(error.constraints).join(", ");
return result;
}); });
console.log(message);
return Result.error(message.join(", \n")); return Result.error(message.join(", \n"));
} else { } else {
return Result.ok(this as unknown as T); return Result.ok(this as unknown as T);

View file

@ -100,10 +100,19 @@ export const SkillsScreen = observer(() => {
label={"Module name"} label={"Module name"}
onChange={(text) => store.updateForm({ Module: Object.assign(store.viewModel.Module, { name: text }) })} onChange={(text) => store.updateForm({ Module: Object.assign(store.viewModel.Module, { name: text }) })}
/> />
<CoreInput <CoreInput
label="Module node name" label={"Module node name"}
onChange={(text) => store.updateForm({ Module: Object.assign(store.viewModel.Module, { node_name: text }) })} onChange={(text) => store.updateForm({ Module: Object.assign(store.viewModel.Module, { node_name: text }) })}
/> />
<CoreInput
label="Launch package"
onChange={(text) => store.updateForm({ Launch: Object.assign(store.viewModel.Launch, { package: text }) })}
/>
<CoreInput
label="Launch executable"
onChange={(text) => store.updateForm({ Launch: Object.assign(store.viewModel.Launch, { executable: text }) })}
/>
<CoreText <CoreText
text={`Topics ${store.viewModel.topicsOut.length}`} text={`Topics ${store.viewModel.topicsOut.length}`}
type={CoreTextType.large} type={CoreTextType.large}