Compare commits
No commits in common. "fa89bd904f70e35856eb8c5a62b43039f0def189" and "62ced0773141c0ce7fe98ba4e840560b5ebb266f" have entirely different histories.
fa89bd904f
...
62ced07731
@ -1,11 +0,0 @@
|
|||||||
import { mergeProps } from "solid-js";
|
|
||||||
|
|
||||||
function ListManager(props) {
|
|
||||||
props = mergeProps(
|
|
||||||
{ items: [], availableItems: [], itemToString: () => "" },
|
|
||||||
props
|
|
||||||
);
|
|
||||||
return <></>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ListManager;
|
|
||||||
@ -2,7 +2,6 @@ import PlaybackDevice from "./playback-device.js";
|
|||||||
import User from "./user.js";
|
import User from "./user.js";
|
||||||
import Integration from "./integration.js";
|
import Integration from "./integration.js";
|
||||||
import Command from "./command.js";
|
import Command from "./command.js";
|
||||||
import Remote from "./remote.js";
|
|
||||||
|
|
||||||
const Serializer = (function () {
|
const Serializer = (function () {
|
||||||
function deserializeUser(object) {
|
function deserializeUser(object) {
|
||||||
@ -40,15 +39,6 @@ const Serializer = (function () {
|
|||||||
if (!objects) return [];
|
if (!objects) return [];
|
||||||
return objects.map((object) => deserializeCommand(object));
|
return objects.map((object) => deserializeCommand(object));
|
||||||
}
|
}
|
||||||
|
|
||||||
function deserializeRemote(object) {
|
|
||||||
return new Remote(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
function deserializeRemotes(objects) {
|
|
||||||
if (!objects) return [];
|
|
||||||
return objects.map((object) => deserializeRemote(object));
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
deserializeUser,
|
deserializeUser,
|
||||||
@ -59,8 +49,6 @@ const Serializer = (function () {
|
|||||||
deserializeIntegrations,
|
deserializeIntegrations,
|
||||||
deserializeCommand,
|
deserializeCommand,
|
||||||
deserializeCommands,
|
deserializeCommands,
|
||||||
deserializeRemote,
|
|
||||||
deserializeRemotes,
|
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { createEffect, createMemo, createSignal } from "solid-js";
|
import { createEffect, createMemo, createSignal } from "solid-js";
|
||||||
import ValidatedTextInput from "../components/validated-text-input.jsx";
|
import ValidatedTextInput from "../modules/validated-text-input.jsx";
|
||||||
import EventEmitter from "../tools/event-emitter.js";
|
import EventEmitter from "../tools/event-emitter.js";
|
||||||
import ModalHandler from "./modal-handler.js";
|
import ModalHandler from "./modal-handler.js";
|
||||||
import Modal from "./modal.jsx";
|
import Modal from "./modal.jsx";
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { createEffect, createSignal } from "solid-js";
|
import { createEffect, createSignal } from "solid-js";
|
||||||
import Modal from "./modal.jsx";
|
import Modal from "./modal.jsx";
|
||||||
import EventEmitter from "../tools/event-emitter.js";
|
import EventEmitter from "../tools/event-emitter.js";
|
||||||
import ValidatedTextInput from "../components/validated-text-input.jsx";
|
import ValidatedTextInput from "../modules/validated-text-input.jsx";
|
||||||
import ModalHandler from "./modal-handler.js";
|
import ModalHandler from "./modal-handler.js";
|
||||||
import DeviceService from "../services/device-service.js";
|
import DeviceService from "../services/device-service.js";
|
||||||
|
|
||||||
|
|||||||
@ -1,98 +0,0 @@
|
|||||||
import { createMemo, createResource, createSignal } from "solid-js";
|
|
||||||
import ValidatedTextInput from "../components/validated-text-input.jsx";
|
|
||||||
import RemotesService from "../services/remotes-service.js";
|
|
||||||
import EventEmitter from "../tools/event-emitter.js";
|
|
||||||
import ModalHandler from "./modal-handler.js";
|
|
||||||
import Modal from "./modal.jsx";
|
|
||||||
import ListManager from "../components/list-manager.jsx";
|
|
||||||
|
|
||||||
const eventEmitter = new EventEmitter();
|
|
||||||
const REMOTE_CREATED_EVENT = "success";
|
|
||||||
const MIN_TITLE_LENGTH = 3;
|
|
||||||
|
|
||||||
function CreateRemoteModal(props) {
|
|
||||||
const [title, setTitle] = createSignal("");
|
|
||||||
const [commands, setCommands] = createSignal([]);
|
|
||||||
const [availableCommands] = createResource(RemotesService.getCommands);
|
|
||||||
const [error, setError] = createSignal("");
|
|
||||||
|
|
||||||
const isTitleValid = createMemo(() => title().length >= MIN_TITLE_LENGTH);
|
|
||||||
|
|
||||||
const isFormValid = createMemo(() => isTitleValid());
|
|
||||||
|
|
||||||
async function handleCreateRemote() {
|
|
||||||
let remote;
|
|
||||||
try {
|
|
||||||
remote = await RemotesService.createRemote({
|
|
||||||
title: title(),
|
|
||||||
commands: commands(),
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
setError(e.message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
resetFields();
|
|
||||||
CreateRemoteModal.Handler.hide();
|
|
||||||
eventEmitter.dispatchEvent(REMOTE_CREATED_EVENT, remote);
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetFields() {
|
|
||||||
setTitle("");
|
|
||||||
setCommands([]);
|
|
||||||
setError("");
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Modal
|
|
||||||
ref={props.ref}
|
|
||||||
id="createRemoteModal"
|
|
||||||
modalTitle="New Remote"
|
|
||||||
centered={true}
|
|
||||||
>
|
|
||||||
<div class="modal-body" style="overflow-y:inherit !important;">
|
|
||||||
<Show when={error() !== ""}>
|
|
||||||
<div class="alert alert-danger" role="alert">
|
|
||||||
{error()}
|
|
||||||
</div>
|
|
||||||
</Show>
|
|
||||||
<div class="mb-3 row">
|
|
||||||
<label for="new_remote_title" class="col-form-label col-sm-3">
|
|
||||||
Title
|
|
||||||
</label>
|
|
||||||
<ValidatedTextInput
|
|
||||||
class="col-sm-9"
|
|
||||||
id="new_remote_title"
|
|
||||||
valid={isTitleValid()}
|
|
||||||
value={title()}
|
|
||||||
onInput={(e) => setTitle(e.target.value)}
|
|
||||||
errorText={`Title must be at least ${MIN_TITLE_LENGTH} characters long`}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<ListManager
|
|
||||||
items={commands()}
|
|
||||||
availableItems={availableCommands()}
|
|
||||||
itemToString={(command) => command.getName()}
|
|
||||||
/>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
|
|
||||||
Cancel
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={handleCreateRemote}
|
|
||||||
class="btn btn-primary"
|
|
||||||
disabled={!isFormValid()}
|
|
||||||
>
|
|
||||||
Create
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</Modal>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
CreateRemoteModal.Handler = new ModalHandler();
|
|
||||||
CreateRemoteModal.onRemoteCreated = (callback) =>
|
|
||||||
eventEmitter.on(REMOTE_CREATED_EVENT, callback);
|
|
||||||
|
|
||||||
export default CreateRemoteModal;
|
|
||||||
@ -2,7 +2,7 @@ import { createEffect, createSignal } from "solid-js";
|
|||||||
import Modal from "./modal.jsx";
|
import Modal from "./modal.jsx";
|
||||||
import UserService from "../services/user-service.js";
|
import UserService from "../services/user-service.js";
|
||||||
import EventEmitter from "../tools/event-emitter.js";
|
import EventEmitter from "../tools/event-emitter.js";
|
||||||
import ValidatedTextInput from "../components/validated-text-input.jsx";
|
import ValidatedTextInput from "../modules/validated-text-input.jsx";
|
||||||
import ModalHandler from "./modal-handler.js";
|
import ModalHandler from "./modal-handler.js";
|
||||||
|
|
||||||
const [users, setUsers] = createSignal([]);
|
const [users, setUsers] = createSignal([]);
|
||||||
|
|||||||
@ -1,9 +1,12 @@
|
|||||||
import { createSignal } from "solid-js";
|
import { createEffect, createSignal } from "solid-js";
|
||||||
|
import Modal from "./modal.jsx";
|
||||||
|
import UserService from "../services/user-service.js";
|
||||||
|
import EventEmitter from "../tools/event-emitter.js";
|
||||||
|
import User from "../data/user.js";
|
||||||
|
import ValidatedTextInput from "../modules/validated-text-input.jsx";
|
||||||
|
import ModalHandler from "./modal-handler.js";
|
||||||
import Integration from "../data/integration.js";
|
import Integration from "../data/integration.js";
|
||||||
import DeviceService from "../services/device-service.js";
|
import DeviceService from "../services/device-service.js";
|
||||||
import EventEmitter from "../tools/event-emitter.js";
|
|
||||||
import ModalHandler from "./modal-handler.js";
|
|
||||||
import Modal from "./modal.jsx";
|
|
||||||
|
|
||||||
const [integration, setIntegration] = createSignal(new Integration());
|
const [integration, setIntegration] = createSignal(new Integration());
|
||||||
const eventEmitter = new EventEmitter();
|
const eventEmitter = new EventEmitter();
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import Modal from "./modal.jsx";
|
|||||||
import UserService from "../services/user-service.js";
|
import UserService from "../services/user-service.js";
|
||||||
import EventEmitter from "../tools/event-emitter.js";
|
import EventEmitter from "../tools/event-emitter.js";
|
||||||
import User from "../data/user.js";
|
import User from "../data/user.js";
|
||||||
import ValidatedTextInput from "../components/validated-text-input.jsx";
|
import ValidatedTextInput from "../modules/validated-text-input.jsx";
|
||||||
import ModalHandler from "./modal-handler.js";
|
import ModalHandler from "./modal-handler.js";
|
||||||
|
|
||||||
const [user, setUser] = createSignal(new User());
|
const [user, setUser] = createSignal(new User());
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import ShowRegistrationCodeModal from "./show-registration-code-modal.jsx";
|
|||||||
import DeleteIntegrationModal from "./delete-integration-modal.jsx";
|
import DeleteIntegrationModal from "./delete-integration-modal.jsx";
|
||||||
import CreateCommandModal from "./create-command-modal.jsx";
|
import CreateCommandModal from "./create-command-modal.jsx";
|
||||||
import DeleteCommandModal from "./delete-command-modal.jsx";
|
import DeleteCommandModal from "./delete-command-modal.jsx";
|
||||||
import CreateRemoteModal from "./create-remote-modal.jsx";
|
|
||||||
|
|
||||||
const ModalRegistry = (function () {
|
const ModalRegistry = (function () {
|
||||||
const modals = [
|
const modals = [
|
||||||
@ -51,12 +50,7 @@ const ModalRegistry = (function () {
|
|||||||
id: "deleteCommandModal",
|
id: "deleteCommandModal",
|
||||||
component: DeleteCommandModal,
|
component: DeleteCommandModal,
|
||||||
ref: null,
|
ref: null,
|
||||||
},
|
}
|
||||||
{
|
|
||||||
id: "createRemoteModal",
|
|
||||||
component: CreateRemoteModal,
|
|
||||||
ref: null,
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
function getModals(props) {
|
function getModals(props) {
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import {
|
|||||||
import EventEmitter from "../tools/event-emitter.js";
|
import EventEmitter from "../tools/event-emitter.js";
|
||||||
import User from "../data/user.js";
|
import User from "../data/user.js";
|
||||||
import Modal from "./modal.jsx";
|
import Modal from "./modal.jsx";
|
||||||
import ValidatedTextInput from "../components/validated-text-input.jsx";
|
import ValidatedTextInput from "../modules/validated-text-input.jsx";
|
||||||
import ModalHandler from "./modal-handler.js";
|
import ModalHandler from "./modal-handler.js";
|
||||||
import UserService from "../services/user-service.js";
|
import UserService from "../services/user-service.js";
|
||||||
|
|
||||||
|
|||||||
@ -2,18 +2,9 @@ import Serializer from "../data/serializer";
|
|||||||
|
|
||||||
function RemotesService() {
|
function RemotesService() {
|
||||||
let commands = [];
|
let commands = [];
|
||||||
let remotes = [];
|
|
||||||
|
|
||||||
async function getRemotes() {
|
async function getRemotes() {
|
||||||
return [].concat(remotes);
|
return [];
|
||||||
}
|
|
||||||
|
|
||||||
async function createRemote(remoteObject) {
|
|
||||||
let remote = Serializer.deserializeRemote(remoteObject);
|
|
||||||
let id = Math.random().toString(36).substr(2, 9);
|
|
||||||
remote.setId(id);
|
|
||||||
remotes.push(remote);
|
|
||||||
return remote;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getCommands() {
|
async function getCommands() {
|
||||||
@ -37,7 +28,6 @@ function RemotesService() {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
getRemotes,
|
getRemotes,
|
||||||
createRemote,
|
|
||||||
getCommands,
|
getCommands,
|
||||||
createCommand,
|
createCommand,
|
||||||
deleteCommand,
|
deleteCommand,
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import { createResource, onMount } from "solid-js";
|
import { createResource, onMount } from "solid-js";
|
||||||
import List from "../../components/list";
|
import List from "../../components/list";
|
||||||
import RemotesService from "../../services/remotes-service";
|
import RemotesService from "../../services/remotes-service";
|
||||||
import CreateRemoteModal from "../../modals/create-remote-modal";
|
|
||||||
|
|
||||||
function RemotesList(props) {
|
function RemotesList(props) {
|
||||||
const [remotes, { refetch: refetchRemotes }] = createResource(
|
const [remotes, { refetch: refetchRemotes }] = createResource(
|
||||||
@ -12,15 +11,7 @@ function RemotesList(props) {
|
|||||||
refetchRemotes();
|
refetchRemotes();
|
||||||
});
|
});
|
||||||
|
|
||||||
CreateRemoteModal.onRemoteCreated(() => {
|
function handleNewRemote() {}
|
||||||
refetchRemotes();
|
|
||||||
});
|
|
||||||
|
|
||||||
function handleNewRemote() {
|
|
||||||
CreateRemoteModal.Handler.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleDeleteRemote(remote) {}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user