From f22eeb13ce2b9974029c9a9748bf9116d89716c7 Mon Sep 17 00:00:00 2001 From: kirillius Date: Tue, 30 Sep 2025 20:44:59 +0300 Subject: [PATCH] =?UTF-8?q?=D1=83=D0=B4=D0=B0=D0=BB=D0=B8=D0=BB=20=D0=B3?= =?UTF-8?q?=D0=B5=D0=BD=D0=B5=D1=80=D0=B8=D1=80=D1=83=D0=B5=D0=BC=D1=8B?= =?UTF-8?q?=D0=B9=20=D1=84=D0=B0=D0=B9=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webui/src/json-rpc.js | 167 ------------------------------------------ 1 file changed, 167 deletions(-) delete mode 100644 webui/src/json-rpc.js diff --git a/webui/src/json-rpc.js b/webui/src/json-rpc.js deleted file mode 100644 index f0cae5a..0000000 --- a/webui/src/json-rpc.js +++ /dev/null @@ -1,167 +0,0 @@ -export const JSONRPC = { - url: "/jsonrpc/rpc", - __id: 1, - /** - * - * @param method - * @param params - * @returns Object - * @private - */ - __invoke: async function (method, params) { - const request = await JSONRPC.__performRequest(method, params); - - if (!request.success) { - console.error(request.result); - throw new Error("Failed to invoke method " + method + " with params " + JSON.stringify(params)); - } - - return request.result; - }, - __performRequest: async function (method, params) { - const __this = this; - const resp = await fetch( - __this.url, - { - method: "POST", - mode: "cors", - cache: "no-cache", - credentials: "include", - headers: { - "Content-Type": "application/json" - }, - redirect: "follow", - referrerPolicy: "no-referrer", - body: JSON.stringify({ - jsonrpc: '2.0', - method: method, - params: params, - id: __this.__id++ - }) - } - ); - const success = resp.status === 200; - const result = (success ? (await resp.json()).result : { - "error": true, - "code": resp.status, - "status": resp.statusText, - "body": await resp.text() - }); - - return { - "result": result, - "success": success - }; - } -}; - -export const TYPES = {}; -JSONRPC.SubscriptionManager = {}; - -JSONRPC.SubscriptionManager.getSubscribedResources=async function(){ - return await JSONRPC.__invoke("web.RPC.SubscriptionManager::getSubscribedResources", {}); -}; - -JSONRPC.SubscriptionManager.getAvailableResources=async function(){ - return await JSONRPC.__invoke("web.RPC.SubscriptionManager::getAvailableResources", {}); -}; - -JSONRPC.SubscriptionManager.setSubscribedResources=async function(resources){ - return await JSONRPC.__invoke("web.RPC.SubscriptionManager::setSubscribedResources", {"resources":resources}); -}; - -JSONRPC.SubscriptionManager.isUpdating=async function(){ - return await JSONRPC.__invoke("web.RPC.SubscriptionManager::isUpdating", {}); -}; - -JSONRPC.SubscriptionManager.triggerUpdate=async function(){ - return await JSONRPC.__invoke("web.RPC.SubscriptionManager::triggerUpdate", {}); -}; -JSONRPC.Auth = {}; - -JSONRPC.Auth.createToken=async function(){ - return await JSONRPC.__invoke("web.RPC.Auth::createToken", {}); -}; - -JSONRPC.Auth.listTokens=async function(){ - return await JSONRPC.__invoke("web.RPC.Auth::listTokens", {}); -}; - -JSONRPC.Auth.removeToken=async function(token){ - return await JSONRPC.__invoke("web.RPC.Auth::removeToken", {"token":token}); -}; - -JSONRPC.Auth.createAPIToken=async function(description){ - return await JSONRPC.__invoke("web.RPC.Auth::createAPIToken", {"description":description}); -}; - -JSONRPC.Auth.startSessionByPassword=async function(password){ - return await JSONRPC.__invoke("web.RPC.Auth::startSessionByPassword", {"password":password}); -}; - -JSONRPC.Auth.startSessionByToken=async function(token){ - return await JSONRPC.__invoke("web.RPC.Auth::startSessionByToken", {"token":token}); -}; - -JSONRPC.Auth.isAuthenticated=async function(){ - return await JSONRPC.__invoke("web.RPC.Auth::isAuthenticated", {}); -}; - -JSONRPC.Auth.logout=async function(){ - return await JSONRPC.__invoke("web.RPC.Auth::logout", {}); -}; -JSONRPC.System = {}; - -JSONRPC.System.shutdown=async function(){ - return await JSONRPC.__invoke("web.RPC.System::shutdown", {}); -}; - -JSONRPC.System.getEnabledComponents=async function(){ - return await JSONRPC.__invoke("web.RPC.System::getEnabledComponents", {}); -}; - -JSONRPC.System.setEnabledComponents=async function(components){ - return await JSONRPC.__invoke("web.RPC.System::setEnabledComponents", {"components":components}); -}; - -JSONRPC.System.isConfigChanged=async function(){ - return await JSONRPC.__invoke("web.RPC.System::isConfigChanged", {}); -}; - -JSONRPC.System.hasUpdates=async function(){ - return await JSONRPC.__invoke("web.RPC.System::hasUpdates", {}); -}; - -JSONRPC.System.getAvailableComponents=async function(){ - return await JSONRPC.__invoke("web.RPC.System::getAvailableComponents", {}); -}; - -JSONRPC.System.getConfig=async function(){ - return await JSONRPC.__invoke("web.RPC.System::getConfig", {}); -}; - -JSONRPC.System.restart=async function(){ - return await JSONRPC.__invoke("web.RPC.System::restart", {}); -}; -JSONRPC.NetworkManager = {}; - -JSONRPC.NetworkManager.getOutputResources=async function(){ - return await JSONRPC.__invoke("web.RPC.NetworkManager::getOutputResources", {}); -}; - -JSONRPC.NetworkManager.isUpdating=async function(){ - return await JSONRPC.__invoke("web.RPC.NetworkManager::isUpdating", {}); -}; - -JSONRPC.NetworkManager.triggerUpdate=async function(ignoreCache){ - return await JSONRPC.__invoke("web.RPC.NetworkManager::triggerUpdate", {"ignoreCache":ignoreCache}); -}; -JSONRPC.OVPN = {}; - -JSONRPC.OVPN.restartSystemService=async function(){ - return await JSONRPC.__invoke("ru.kirillius.pf.sdn.External.API.Components.OVPN::restartSystemService", {}); -}; - -JSONRPC.OVPN.getManagedRoutes=async function(){ - return await JSONRPC.__invoke("ru.kirillius.pf.sdn.External.API.Components.OVPN::getManagedRoutes", {}); -};