MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / onEnqueue

Function onEnqueue

ui/src/views/devices/DeviceQueue.tsx:168–214  ·  view source on GitHub ↗
(values: FormRules)

Source from the content-addressed store, hash-verified

166 };
167
168 const onEnqueue = (values: FormRules) => {
169 const req = new EnqueueDeviceQueueItemRequest();
170 const item = new DeviceQueueItem();
171
172 item.setDevEui(props.device.getDevEui());
173 item.setFPort(values.fPort);
174 item.setConfirmed(values.confirmed);
175 item.setIsEncrypted(values.isEncrypted);
176 item.setFCntDown(values.fCntDown);
177
178 if (values.expiresAt !== null && values.expiresAt !== undefined && !Array.isArray(values.expiresAt)) {
179 item.setExpiresAt(Timestamp.fromDate(values.expiresAt.toDate()));
180 }
181
182 if (values.hex !== undefined) {
183 item.setData(new Uint8Array(Buffer.from(values.hex, "hex")));
184 }
185
186 if (values.base64 !== undefined) {
187 item.setData(new Uint8Array(Buffer.from(values.base64, "base64")));
188 }
189
190 if (values.json !== undefined) {
191 try {
192 const obj = JSON.parse(values.json);
193 const struct = Struct.fromJavaScript(obj);
194
195 item.setObject(struct);
196 } catch (err) {
197 if (err instanceof Error) {
198 notification.error({
199 message: "Error",
200 description: err.message,
201 duration: 3,
202 });
203 }
204 }
205 }
206
207 req.setQueueItem(item);
208
209 DeviceStore.enqueue(req, _ => {
210 form.resetFields();
211 setIsEncrypted(false);
212 refreshQueue();
213 });
214 };
215
216 const tabItems: TabsProps["items"] = [
217 {

Callers

nothing calls this directly

Calls 3

refreshQueueFunction · 0.70
fromMethod · 0.45
enqueueMethod · 0.45

Tested by

no test coverage detected