-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
47 changed files
with
469 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
class Api::ControlsController < ApplicationController | ||
expose :control | ||
expose :controls, -> { Control.all } | ||
|
||
# @route GET /api/options/controls (api_controls_options) | ||
def options | ||
authorize controls | ||
render json: controls.render(view: :options), status: :ok | ||
end | ||
|
||
def execute | ||
authorize control | ||
|
||
control.create_activity key: :slug, owner: current_user | ||
|
||
SendOscCommandsJob.perform_later(control) | ||
|
||
render json: control, status: :accepted | ||
end | ||
|
||
# @route POST /api/controls (api_controls) | ||
def create | ||
if control.save | ||
render json: control.render, status: :created | ||
else | ||
render json: { errors: control.errors }, status: :not_acceptable | ||
end | ||
end | ||
|
||
# @route PATCH /api/controls/:slug (api_control) | ||
# @route PUT /api/controls/:slug (api_control) | ||
def update | ||
if control.save | ||
render json: control.render, status: :created | ||
else | ||
render json: { errors: control.errors }, status: :not_acceptable | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,40 @@ | ||
class Api::ProtocolsController < ApplicationController | ||
expose :protocol | ||
expose :protocols, -> { Protocol.all } | ||
|
||
# @route GET /api/options/protocols (api_protocols_options) | ||
def options | ||
authorize protocols | ||
render json: protocols.render(view: :options), status: :ok | ||
end | ||
|
||
# @route PUT /api/protocol/:id/execute (api_execute_protocol) | ||
def execute | ||
authorize protocol | ||
|
||
protocol.create_activity key: :slug, owner: current_user | ||
|
||
SendOscCommandsJob.perform_later(protocol) | ||
|
||
render json: protocol, status: :accepted | ||
end | ||
|
||
# @route POST /api/protocols (api_protocols) | ||
def create | ||
if protocol.save | ||
render json: protocol.render, status: :created | ||
else | ||
render json: { errors: protocol.errors }, status: :not_acceptable | ||
end | ||
end | ||
|
||
# @route PATCH /api/protocols/:slug (api_protocol) | ||
# @route PUT /api/protocols/:slug (api_protocol) | ||
def update | ||
if protocol.save | ||
render json: protocol.render, status: :created | ||
else | ||
render json: { errors: protocol.errors }, status: :not_acceptable | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,29 @@ | ||
import React from 'react' | ||
import React, { forwardRef } from 'react' | ||
import { Select } from '@/Components/Form' | ||
import { type IAsyncDropdown } from '.' | ||
import { protocolsOptionsQuery } from '@/queries' | ||
|
||
interface ProtocolDropdownProps extends Omit<IAsyncDropdown<Schema.ProtocolsOptions>, 'onSelect'> { | ||
onSelect?: (data: Schema.ProtocolsOptions) => void | ||
} | ||
|
||
const ProtocolDropdown = forwardRef<HTMLInputElement, ProtocolDropdownProps>(( | ||
{ label = 'Protocol', name = 'protocol_id', initialData = [], value, onSelect, ...props }, | ||
ref, | ||
) => { | ||
const { data } = protocolsOptionsQuery() | ||
|
||
const ProocolDropdown = () => { | ||
return ( | ||
<div>ProocolDropdown</div> | ||
<Select | ||
label={ label } | ||
name={ name } | ||
options={ !data ? [] : data.map(protocol => ({ | ||
label: protocol.title, | ||
value: protocol.slug, | ||
})) } | ||
{ ...props } | ||
/> | ||
) | ||
} | ||
}) | ||
|
||
export default ProocolDropdown | ||
export default ProtocolDropdown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { vars, theme } from '@/lib/theme' | ||
import { rem } from '@mantine/core' | ||
import { css } from '@linaria/core' | ||
|
||
export const form = css` | ||
.field { | ||
margin-bottom: ${vars.spacing.md} | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ export { | |
} from 'react-icons/bs' | ||
|
||
export { | ||
FaHome as HomeIcon, | ||
} from 'react-icons/fa' | ||
|
||
export { | ||
|
Oops, something went wrong.