Skip to content

Commit

Permalink
feat: add dispatch unassigned status
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Trost <[email protected]>
  • Loading branch information
galexrt committed Jul 15, 2023
1 parent 80a9cb7 commit ceda5a6
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 36 deletions.
50 changes: 27 additions & 23 deletions gen/go/proto/resources/dispatch/dispatches.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions gen/go/proto/services/centrum/dispatches.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,16 @@ func (s *Server) AssignDispatch(ctx context.Context, req *AssignDispatchRequest)
for k := 0; k < len(req.ToRemove); k++ {
if dsp.Units[i].UnitId == req.ToRemove[k] {
dsp.Units = utils.RemoveFromSlice(dsp.Units, i)

if _, err := s.updateDispatchStatus(ctx, userInfo, dsp, &dispatch.DispatchStatus{
DispatchId: dsp.Id,
UnitId: req.ToRemove[k],
UserId: &userInfo.UserId,
Status: dispatch.DISPATCH_STATUS_UNIT_UNASSIGNED,
}); err != nil {
return nil, ErrFailedQuery
}

break
}
}
Expand Down Expand Up @@ -474,6 +484,15 @@ func (s *Server) AssignDispatch(ctx context.Context, req *AssignDispatchRequest)
DispatchId: dsp.Id,
Unit: unit,
})

if _, err := s.updateDispatchStatus(ctx, userInfo, dsp, &dispatch.DispatchStatus{
DispatchId: dsp.Id,
UnitId: unit.Id,
UserId: &userInfo.UserId,
Status: dispatch.DISPATCH_STATUS_UNIT_ASSIGNED,
}); err != nil {
return nil, ErrFailedQuery
}
}
}

Expand Down
20 changes: 12 additions & 8 deletions gen/ts/resources/dispatch/dispatches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,21 +162,25 @@ export enum DISPATCH_STATUS {
*/
UNIT_ASSIGNED = 3,
/**
* @generated from protobuf enum value: EN_ROUTE = 4;
* @generated from protobuf enum value: UNIT_UNASSIGNED = 4;
*/
EN_ROUTE = 4,
UNIT_UNASSIGNED = 4,
/**
* @generated from protobuf enum value: AT_SCENE = 5;
* @generated from protobuf enum value: EN_ROUTE = 5;
*/
AT_SCENE = 5,
EN_ROUTE = 5,
/**
* @generated from protobuf enum value: NEED_ASSISTANCE = 6;
* @generated from protobuf enum value: AT_SCENE = 6;
*/
NEED_ASSISTANCE = 6,
AT_SCENE = 6,
/**
* @generated from protobuf enum value: COMPLETED = 7;
* @generated from protobuf enum value: NEED_ASSISTANCE = 7;
*/
COMPLETED = 7
NEED_ASSISTANCE = 7,
/**
* @generated from protobuf enum value: COMPLETED = 8;
*/
COMPLETED = 8
}
// @generated message type with reflection information, may provide speed optimized methods
class Dispatch$Type extends MessageType<Dispatch> {
Expand Down
9 changes: 5 additions & 4 deletions proto/resources/dispatch/dispatches.proto
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ enum DISPATCH_STATUS {
DECLINED = 1;
UNASSIGNED = 2;
UNIT_ASSIGNED = 3;
EN_ROUTE = 4;
AT_SCENE = 5;
NEED_ASSISTANCE = 6;
COMPLETED = 7;
UNIT_UNASSIGNED = 4;
EN_ROUTE = 5;
AT_SCENE = 6;
NEED_ASSISTANCE = 7;
COMPLETED = 8;
}

message DispatchStatus {
Expand Down
2 changes: 1 addition & 1 deletion src/components/centrum/Centrum.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ async function startStream(): Promise<void> {
if (idx === -1) {
dispatches.value?.unshift(resp.change.dispatchAssigned);
} else {
dispatches.value![idx].units = resp.change.dispatchAssigned.units;
dispatches.value![idx] = resp.change.dispatchAssigned;
}
} else if (resp.change.oneofKind === 'unitUpdate') {
const id = resp.change.unitUpdate.id;
Expand Down

0 comments on commit ceda5a6

Please sign in to comment.