⚙️Settings-driven AirDC++ configuration first draft
This commit is contained in:
@@ -30,10 +30,16 @@ function sleep(ms: number): Promise<NodeJS.Timeout> {
|
||||
}
|
||||
|
||||
export const search =
|
||||
(data: SearchData, ADCPPSocket: any) => async (dispatch) => {
|
||||
(data: SearchData, ADCPPSocket: any, credentials: any) =>
|
||||
async (dispatch) => {
|
||||
try {
|
||||
console.log(credentials);
|
||||
if (!ADCPPSocket.isConnected()) {
|
||||
await ADCPPSocket.connect("admin", "password", true);
|
||||
await ADCPPSocket.connect(
|
||||
credentials.username,
|
||||
credentials.password,
|
||||
true,
|
||||
);
|
||||
}
|
||||
const instance: SearchInstance = await ADCPPSocket.post("search");
|
||||
dispatch({
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import axios from "axios";
|
||||
import { SETTINGS_OBJECT_FETCHED } from "../constants/action-types";
|
||||
import {
|
||||
SETTINGS_OBJECT_FETCHED,
|
||||
SETTINGS_OBJECT_DELETED,
|
||||
} from "../constants/action-types";
|
||||
import { SETTINGS_SERVICE_BASE_URI } from "../constants/endpoints";
|
||||
|
||||
export const saveSettings =
|
||||
@@ -29,3 +32,17 @@ export const getSettings = (settingsKey?) => async (dispatch) => {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const deleteSettings = () => async (dispatch) => {
|
||||
const result = await axios({
|
||||
url: `${SETTINGS_SERVICE_BASE_URI}/deleteSettings`,
|
||||
method: "POST",
|
||||
});
|
||||
|
||||
if (result.data.ok === 1) {
|
||||
dispatch({
|
||||
type: SETTINGS_OBJECT_FETCHED,
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user