diff --git a/openapi-internal.yaml b/openapi-internal.yaml index bb057c9..664295a 100644 --- a/openapi-internal.yaml +++ b/openapi-internal.yaml @@ -629,6 +629,7 @@ components: - AssetID - AssetVersion - TargetAssetID + - Description type: object properties: OperationID: @@ -661,6 +662,9 @@ components: type: integer format: int64 minimum: 0 + Description: + type: string + maxLength: 256 SubmissionCreate: required: - OperationID diff --git a/openapi.yaml b/openapi.yaml index 16869ba..abb3424 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -1440,7 +1440,7 @@ components: - Completed - TargetAssetID - StatusID - - StatusMessage + - Description type: object properties: ID: @@ -1487,7 +1487,7 @@ components: type: integer format: int32 minimum: 0 - StatusMessage: + Description: type: string maxLength: 256 Mapfixes: @@ -1508,6 +1508,7 @@ components: required: - AssetID - TargetAssetID + - Description type: object properties: AssetID: @@ -1518,6 +1519,9 @@ components: type: integer format: int64 minimum: 0 + Description: + type: string + maxLength: 256 Operation: required: - OperationID @@ -1566,7 +1570,6 @@ components: - Completed # - UploadedAssetID - StatusID - - StatusMessage type: object properties: ID: @@ -1621,9 +1624,6 @@ components: type: integer format: int32 minimum: 0 - StatusMessage: - type: string - maxLength: 256 Submissions: required: - Total diff --git a/pkg/api/oas_json_gen.go b/pkg/api/oas_json_gen.go index 6d63001..11defac 100644 --- a/pkg/api/oas_json_gen.go +++ b/pkg/api/oas_json_gen.go @@ -602,8 +602,8 @@ func (s *Mapfix) encodeFields(e *jx.Encoder) { e.Int32(s.StatusID) } { - e.FieldStart("StatusMessage") - e.Str(s.StatusMessage) + e.FieldStart("Description") + e.Str(s.Description) } } @@ -620,7 +620,7 @@ var jsonFieldsNameOfMapfix = [13]string{ 9: "Completed", 10: "TargetAssetID", 11: "StatusID", - 12: "StatusMessage", + 12: "Description", } // Decode decodes Mapfix from json. @@ -776,17 +776,17 @@ func (s *Mapfix) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "decode field \"StatusID\"") } - case "StatusMessage": + case "Description": requiredBitSet[1] |= 1 << 4 if err := func() error { v, err := d.Str() - s.StatusMessage = string(v) + s.Description = string(v) if err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"StatusMessage\"") + return errors.Wrap(err, "decode field \"Description\"") } default: return d.Skip() @@ -862,11 +862,16 @@ func (s *MapfixTriggerCreate) encodeFields(e *jx.Encoder) { e.FieldStart("TargetAssetID") e.Int64(s.TargetAssetID) } + { + e.FieldStart("Description") + e.Str(s.Description) + } } -var jsonFieldsNameOfMapfixTriggerCreate = [2]string{ +var jsonFieldsNameOfMapfixTriggerCreate = [3]string{ 0: "AssetID", 1: "TargetAssetID", + 2: "Description", } // Decode decodes MapfixTriggerCreate from json. @@ -902,6 +907,18 @@ func (s *MapfixTriggerCreate) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "decode field \"TargetAssetID\"") } + case "Description": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + v, err := d.Str() + s.Description = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"Description\"") + } default: return d.Skip() } @@ -912,7 +929,7 @@ func (s *MapfixTriggerCreate) Decode(d *jx.Decoder) error { // Validate required fields. var failures []validate.FieldError for i, mask := range [1]uint8{ - 0b00000011, + 0b00000111, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -2851,13 +2868,9 @@ func (s *Submission) encodeFields(e *jx.Encoder) { e.FieldStart("StatusID") e.Int32(s.StatusID) } - { - e.FieldStart("StatusMessage") - e.Str(s.StatusMessage) - } } -var jsonFieldsNameOfSubmission = [15]string{ +var jsonFieldsNameOfSubmission = [14]string{ 0: "ID", 1: "DisplayName", 2: "Creator", @@ -2872,7 +2885,6 @@ var jsonFieldsNameOfSubmission = [15]string{ 11: "Completed", 12: "UploadedAssetID", 13: "StatusID", - 14: "StatusMessage", } // Decode decodes Submission from json. @@ -3046,18 +3058,6 @@ func (s *Submission) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "decode field \"StatusID\"") } - case "StatusMessage": - requiredBitSet[1] |= 1 << 6 - if err := func() error { - v, err := d.Str() - s.StatusMessage = string(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"StatusMessage\"") - } default: return d.Skip() } @@ -3069,7 +3069,7 @@ func (s *Submission) Decode(d *jx.Decoder) error { var failures []validate.FieldError for i, mask := range [2]uint8{ 0b11111111, - 0b01101001, + 0b00101001, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. diff --git a/pkg/api/oas_schemas_gen.go b/pkg/api/oas_schemas_gen.go index b54f84e..54d2557 100644 --- a/pkg/api/oas_schemas_gen.go +++ b/pkg/api/oas_schemas_gen.go @@ -349,7 +349,7 @@ type Mapfix struct { Completed bool `json:"Completed"` TargetAssetID int64 `json:"TargetAssetID"` StatusID int32 `json:"StatusID"` - StatusMessage string `json:"StatusMessage"` + Description string `json:"Description"` } // GetID returns the value of ID. @@ -412,9 +412,9 @@ func (s *Mapfix) GetStatusID() int32 { return s.StatusID } -// GetStatusMessage returns the value of StatusMessage. -func (s *Mapfix) GetStatusMessage() string { - return s.StatusMessage +// GetDescription returns the value of Description. +func (s *Mapfix) GetDescription() string { + return s.Description } // SetID sets the value of ID. @@ -477,15 +477,16 @@ func (s *Mapfix) SetStatusID(val int32) { s.StatusID = val } -// SetStatusMessage sets the value of StatusMessage. -func (s *Mapfix) SetStatusMessage(val string) { - s.StatusMessage = val +// SetDescription sets the value of Description. +func (s *Mapfix) SetDescription(val string) { + s.Description = val } // Ref: #/components/schemas/MapfixTriggerCreate type MapfixTriggerCreate struct { - AssetID int64 `json:"AssetID"` - TargetAssetID int64 `json:"TargetAssetID"` + AssetID int64 `json:"AssetID"` + TargetAssetID int64 `json:"TargetAssetID"` + Description string `json:"Description"` } // GetAssetID returns the value of AssetID. @@ -498,6 +499,11 @@ func (s *MapfixTriggerCreate) GetTargetAssetID() int64 { return s.TargetAssetID } +// GetDescription returns the value of Description. +func (s *MapfixTriggerCreate) GetDescription() string { + return s.Description +} + // SetAssetID sets the value of AssetID. func (s *MapfixTriggerCreate) SetAssetID(val int64) { s.AssetID = val @@ -508,6 +514,11 @@ func (s *MapfixTriggerCreate) SetTargetAssetID(val int64) { s.TargetAssetID = val } +// SetDescription sets the value of Description. +func (s *MapfixTriggerCreate) SetDescription(val string) { + s.Description = val +} + // Ref: #/components/schemas/Mapfixes type Mapfixes struct { Total int64 `json:"Total"` @@ -1163,7 +1174,6 @@ type Submission struct { Completed bool `json:"Completed"` UploadedAssetID OptInt64 `json:"UploadedAssetID"` StatusID int32 `json:"StatusID"` - StatusMessage string `json:"StatusMessage"` } // GetID returns the value of ID. @@ -1236,11 +1246,6 @@ func (s *Submission) GetStatusID() int32 { return s.StatusID } -// GetStatusMessage returns the value of StatusMessage. -func (s *Submission) GetStatusMessage() string { - return s.StatusMessage -} - // SetID sets the value of ID. func (s *Submission) SetID(val int64) { s.ID = val @@ -1311,11 +1316,6 @@ func (s *Submission) SetStatusID(val int32) { s.StatusID = val } -// SetStatusMessage sets the value of StatusMessage. -func (s *Submission) SetStatusMessage(val string) { - s.StatusMessage = val -} - // Ref: #/components/schemas/SubmissionTriggerCreate type SubmissionTriggerCreate struct { AssetID int64 `json:"AssetID"` diff --git a/pkg/api/oas_validators_gen.go b/pkg/api/oas_validators_gen.go index 1443d54..456bf4d 100644 --- a/pkg/api/oas_validators_gen.go +++ b/pkg/api/oas_validators_gen.go @@ -408,13 +408,13 @@ func (s *Mapfix) Validate() error { Email: false, Hostname: false, Regex: nil, - }).Validate(string(s.StatusMessage)); err != nil { + }).Validate(string(s.Description)); err != nil { return errors.Wrap(err, "string") } return nil }(); err != nil { failures = append(failures, validate.FieldError{ - Name: "StatusMessage", + Name: "Description", Error: err, }) } @@ -470,6 +470,25 @@ func (s *MapfixTriggerCreate) Validate() error { Error: err, }) } + if err := func() error { + if err := (validate.String{ + MinLength: 0, + MinLengthSet: false, + MaxLength: 256, + MaxLengthSet: true, + Email: false, + Hostname: false, + Regex: nil, + }).Validate(string(s.Description)); err != nil { + return errors.Wrap(err, "string") + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "Description", + Error: err, + }) + } if len(failures) > 0 { return &validate.Error{Fields: failures} } @@ -1751,25 +1770,6 @@ func (s *Submission) Validate() error { Error: err, }) } - if err := func() error { - if err := (validate.String{ - MinLength: 0, - MinLengthSet: false, - MaxLength: 256, - MaxLengthSet: true, - Email: false, - Hostname: false, - Regex: nil, - }).Validate(string(s.StatusMessage)); err != nil { - return errors.Wrap(err, "string") - } - return nil - }(); err != nil { - failures = append(failures, validate.FieldError{ - Name: "StatusMessage", - Error: err, - }) - } if len(failures) > 0 { return &validate.Error{Fields: failures} } diff --git a/pkg/internal/oas_json_gen.go b/pkg/internal/oas_json_gen.go index 4de742d..e89d035 100644 --- a/pkg/internal/oas_json_gen.go +++ b/pkg/internal/oas_json_gen.go @@ -166,9 +166,13 @@ func (s *MapfixCreate) encodeFields(e *jx.Encoder) { e.FieldStart("TargetAssetID") e.Int64(s.TargetAssetID) } + { + e.FieldStart("Description") + e.Str(s.Description) + } } -var jsonFieldsNameOfMapfixCreate = [8]string{ +var jsonFieldsNameOfMapfixCreate = [9]string{ 0: "OperationID", 1: "AssetOwner", 2: "DisplayName", @@ -177,6 +181,7 @@ var jsonFieldsNameOfMapfixCreate = [8]string{ 5: "AssetID", 6: "AssetVersion", 7: "TargetAssetID", + 8: "Description", } // Decode decodes MapfixCreate from json. @@ -184,7 +189,7 @@ func (s *MapfixCreate) Decode(d *jx.Decoder) error { if s == nil { return errors.New("invalid: unable to decode MapfixCreate to nil") } - var requiredBitSet [1]uint8 + var requiredBitSet [2]uint8 if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { @@ -284,6 +289,18 @@ func (s *MapfixCreate) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "decode field \"TargetAssetID\"") } + case "Description": + requiredBitSet[1] |= 1 << 0 + if err := func() error { + v, err := d.Str() + s.Description = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"Description\"") + } default: return d.Skip() } @@ -293,8 +310,9 @@ func (s *MapfixCreate) Decode(d *jx.Decoder) error { } // Validate required fields. var failures []validate.FieldError - for i, mask := range [1]uint8{ + for i, mask := range [2]uint8{ 0b11111111, + 0b00000001, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. diff --git a/pkg/internal/oas_schemas_gen.go b/pkg/internal/oas_schemas_gen.go index f8c3cd4..cb3ca30 100644 --- a/pkg/internal/oas_schemas_gen.go +++ b/pkg/internal/oas_schemas_gen.go @@ -106,6 +106,7 @@ type MapfixCreate struct { AssetID int64 `json:"AssetID"` AssetVersion int64 `json:"AssetVersion"` TargetAssetID int64 `json:"TargetAssetID"` + Description string `json:"Description"` } // GetOperationID returns the value of OperationID. @@ -148,6 +149,11 @@ func (s *MapfixCreate) GetTargetAssetID() int64 { return s.TargetAssetID } +// GetDescription returns the value of Description. +func (s *MapfixCreate) GetDescription() string { + return s.Description +} + // SetOperationID sets the value of OperationID. func (s *MapfixCreate) SetOperationID(val int32) { s.OperationID = val @@ -188,6 +194,11 @@ func (s *MapfixCreate) SetTargetAssetID(val int64) { s.TargetAssetID = val } +// SetDescription sets the value of Description. +func (s *MapfixCreate) SetDescription(val string) { + s.Description = val +} + // Ref: #/components/schemas/MapfixID type MapfixID struct { MapfixID int64 `json:"MapfixID"` diff --git a/pkg/internal/oas_validators_gen.go b/pkg/internal/oas_validators_gen.go index 083e5c3..159c9f4 100644 --- a/pkg/internal/oas_validators_gen.go +++ b/pkg/internal/oas_validators_gen.go @@ -227,6 +227,25 @@ func (s *MapfixCreate) Validate() error { Error: err, }) } + if err := func() error { + if err := (validate.String{ + MinLength: 0, + MinLengthSet: false, + MaxLength: 256, + MaxLengthSet: true, + Email: false, + Hostname: false, + Regex: nil, + }).Validate(string(s.Description)); err != nil { + return errors.Wrap(err, "string") + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "Description", + Error: err, + }) + } if len(failures) > 0 { return &validate.Error{Fields: failures} } diff --git a/pkg/model/mapfix.go b/pkg/model/mapfix.go index a296359..950c6ec 100644 --- a/pkg/model/mapfix.go +++ b/pkg/model/mapfix.go @@ -39,4 +39,5 @@ type Mapfix struct { Completed bool // Has this version of the map been completed at least once on maptest TargetAssetID uint64 // where to upload map fix. if the TargetAssetID is 0, it's a new map. StatusID MapfixStatus + Description string // mapfix description } diff --git a/pkg/model/nats.go b/pkg/model/nats.go index 0808a89..91c0453 100644 --- a/pkg/model/nats.go +++ b/pkg/model/nats.go @@ -15,6 +15,7 @@ type CreateMapfixRequest struct { OperationID int32 ModelID uint64 TargetAssetID uint64 + Description string } diff --git a/pkg/service/mapfixes.go b/pkg/service/mapfixes.go index 0d37705..8c42171 100644 --- a/pkg/service/mapfixes.go +++ b/pkg/service/mapfixes.go @@ -114,6 +114,7 @@ func (svc *Service) CreateMapfix(ctx context.Context, request *api.MapfixTrigger OperationID: operation.ID, ModelID: ModelID, TargetAssetID: TargetAssetID, + Description: request.Description, } j, err := json.Marshal(create_request) @@ -154,6 +155,7 @@ func (svc *Service) GetMapfix(ctx context.Context, params api.GetMapfixParams) ( Completed: mapfix.Completed, TargetAssetID: int64(mapfix.TargetAssetID), StatusID: int32(mapfix.StatusID), + Description: mapfix.Description, }, nil } @@ -213,6 +215,7 @@ func (svc *Service) ListMapfixes(ctx context.Context, params api.ListMapfixesPar Completed: item.Completed, TargetAssetID: int64(item.TargetAssetID), StatusID: int32(item.StatusID), + Description: item.Description, }) } diff --git a/pkg/service_internal/mapfixes.go b/pkg/service_internal/mapfixes.go index c52c533..0785aeb 100644 --- a/pkg/service_internal/mapfixes.go +++ b/pkg/service_internal/mapfixes.go @@ -347,6 +347,7 @@ func (svc *Service) CreateMapfix(ctx context.Context, request *internal.MapfixCr Completed: false, TargetAssetID: TargetAssetID, StatusID: model.MapfixStatusUnderConstruction, + Description: request.Description, }) if err != nil { return nil, err diff --git a/validation/api/src/types.rs b/validation/api/src/types.rs index 671b6d1..2a329fc 100644 --- a/validation/api/src/types.rs +++ b/validation/api/src/types.rs @@ -73,6 +73,7 @@ pub struct CreateMapfixRequest<'a>{ pub AssetID:u64, pub AssetVersion:u64, pub TargetAssetID:u64, + pub Description:&'a str, } #[allow(nonstandard_style)] #[derive(Clone,Debug,serde::Deserialize)] diff --git a/validation/src/create_mapfix.rs b/validation/src/create_mapfix.rs index e735af6..010df43 100644 --- a/validation/src/create_mapfix.rs +++ b/validation/src/create_mapfix.rs @@ -31,6 +31,7 @@ impl crate::message_handler::MessageHandler{ AssetID:create_info.ModelID, AssetVersion:create_request.AssetVersion, TargetAssetID:create_info.TargetAssetID, + Description:create_info.Description.as_str(), }).await.map_err(Error::ApiActionMapfixCreate)?; Ok(()) diff --git a/validation/src/nats_types.rs b/validation/src/nats_types.rs index a1126ae..bca6646 100644 --- a/validation/src/nats_types.rs +++ b/validation/src/nats_types.rs @@ -18,6 +18,7 @@ pub struct CreateMapfixRequest{ pub OperationID:i32, pub ModelID:u64, pub TargetAssetID:u64, + pub Description:String, } #[allow(nonstandard_style)] diff --git a/web/src/app/mapfixes/[mapfixId]/_comments.tsx b/web/src/app/mapfixes/[mapfixId]/_comments.tsx index 80f1046..ca46e40 100644 --- a/web/src/app/mapfixes/[mapfixId]/_comments.tsx +++ b/web/src/app/mapfixes/[mapfixId]/_comments.tsx @@ -14,6 +14,7 @@ interface CreatorAndReviewStatus { review: MapfixInfo["StatusID"], submitter: MapfixInfo["Submitter"], target_asset_id: MapfixInfo["TargetAssetID"], + description: MapfixInfo["Description"], comments: Comment[], name: string } diff --git a/web/src/app/mapfixes/[mapfixId]/page.tsx b/web/src/app/mapfixes/[mapfixId]/page.tsx index 1cc7d60..6d17840 100644 --- a/web/src/app/mapfixes/[mapfixId]/page.tsx +++ b/web/src/app/mapfixes/[mapfixId]/page.tsx @@ -54,6 +54,7 @@ function TitleAndComments(stats: CreatorAndReviewStatus) { <p className="submitter">Submitter {stats.submitter}</p> <p className="asset-id">Model Asset ID {stats.asset_id}</p> <p className="target-asset-id">Target Asset ID {stats.target_asset_id}</p> + <p className="description">Description: {stats.description}</p> <span className="spacer"></span> <Comments comments_data={stats}/> </main> @@ -85,7 +86,16 @@ export default function MapfixInfoPage() { <main className="map-page-main"> <section className="review-section"> <RatingArea mapfixId={dynamicId.mapfixId} mapfixStatus={mapfix.StatusID} mapfixSubmitter={mapfix.Submitter} mapfixAssetId={mapfix.AssetID} mapfixTargetAssetId={mapfix.TargetAssetID} /> - <TitleAndComments name={mapfix.DisplayName} creator={mapfix.Creator} review={mapfix.StatusID} asset_id={mapfix.AssetID} submitter={mapfix.Submitter} target_asset_id={mapfix.TargetAssetID} comments={[]}/> + <TitleAndComments + name={mapfix.DisplayName} + creator={mapfix.Creator} + review={mapfix.StatusID} + asset_id={mapfix.AssetID} + submitter={mapfix.Submitter} + target_asset_id={mapfix.TargetAssetID} + description={mapfix.Description} + comments={[]} + /> </section> </main> </Webpage> diff --git a/web/src/app/maps/[mapId]/fix/page.tsx b/web/src/app/maps/[mapId]/fix/page.tsx index e6c58f0..adac6c2 100644 --- a/web/src/app/maps/[mapId]/fix/page.tsx +++ b/web/src/app/maps/[mapId]/fix/page.tsx @@ -11,6 +11,7 @@ import "./(styles)/page.scss" interface MapfixPayload { AssetID: number; TargetAssetID: number; + Description: string; } interface IdResponse { OperationID: number; @@ -28,6 +29,7 @@ export default function MapfixInfoPage() { const payload: MapfixPayload = { AssetID: Number((formData.get("asset-id") as string) ?? "0"), TargetAssetID: Number(dynamicId.mapId), + Description: (formData.get("description") as string) ?? "unknown", // TEMPORARY! TODO: Change }; console.log(payload) @@ -70,6 +72,7 @@ export default function MapfixInfoPage() { <form onSubmit={handleSubmit}> {/* TODO: Add form data for mapfixes, such as changes they did, and any times that need to be deleted & what styles */} <TextField className="form-field" id="asset-id" name="asset-id" label="Asset ID" variant="outlined"/> + <TextField className="form-field" id="description" name="description" label="Describe the Mapfix" variant="outlined"/> <span className="spacer form-spacer"></span> <Button type="submit" variant="contained" startIcon={<SendIcon/>} sx={{ width: "400px", diff --git a/web/src/app/ts/Mapfix.ts b/web/src/app/ts/Mapfix.ts index 93de092..c4a9bce 100644 --- a/web/src/app/ts/Mapfix.ts +++ b/web/src/app/ts/Mapfix.ts @@ -26,6 +26,7 @@ interface MapfixInfo { readonly Completed: boolean, readonly TargetAssetID: number, readonly StatusID: MapfixStatus, + readonly Description: string, } interface MapfixList {