feat: add get remotes in web interface
This commit is contained in:
parent
83ab71f845
commit
f83ffac0ce
@ -1,4 +1,4 @@
|
||||
function Remote({ id, title, commands } = {}) {
|
||||
function Remote({ id, title, commands = [] } = {}) {
|
||||
let _id = id;
|
||||
let _title = title;
|
||||
let _commands = commands;
|
||||
|
||||
@ -68,7 +68,11 @@ const Serializer = (function () {
|
||||
}
|
||||
|
||||
function deserializeRemote(object) {
|
||||
return new Remote(object);
|
||||
return new Remote({
|
||||
id: object.id,
|
||||
title: object.title,
|
||||
commands: deserializeCommands(object.commands),
|
||||
});
|
||||
}
|
||||
|
||||
function deserializeRemotes(objects) {
|
||||
|
||||
@ -3,7 +3,20 @@ import Serializer from "../data/serializer";
|
||||
import Net from "../tools/net";
|
||||
|
||||
function RemoteService() {
|
||||
let remotes = [];
|
||||
async function getRemote(remoteId) {
|
||||
let response = await Net.sendRequest({
|
||||
method: "GET",
|
||||
url: "/api/remotes/" + remoteId,
|
||||
});
|
||||
|
||||
if (response.status !== 200) {
|
||||
let responseData = JSON.parse(response.data);
|
||||
throw new Error(responseData.error);
|
||||
}
|
||||
|
||||
let remoteObject = JSON.parse(response.data);
|
||||
return Serializer.deserializeRemote(remoteObject);
|
||||
}
|
||||
|
||||
async function getRemotes() {
|
||||
let response = await Net.sendRequest({
|
||||
@ -92,6 +105,7 @@ function RemoteService() {
|
||||
}
|
||||
|
||||
return {
|
||||
getRemote,
|
||||
getRemotes,
|
||||
createRemote,
|
||||
deleteRemote,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user