feat: add simple app ping (#580)
* feat: add simple ping * refactor: make ping run on server and show errors * fix: format issues * fix: missing translation for enabled ping option for app * refactor: remove ping queue as no longer needed * chore: address pull request feedback * test: add some unit tests * fix: format issues * fix: deepsource issues
This commit is contained in:
1 parent
3dca787fa7
commit
d7ecdf5567
25 files changed
+542
-22
No files matched your search
@@ -1,14 +1,25 @@
|
||||
"use server";
|
||||
|
||||
import type { RouterOutputs } from "@homarr/api";
|
||||
import { api } from "@homarr/api/server";
|
||||
|
||||
import type { WidgetProps } from "../definition";
|
||||
|
||||
export default async function getServerDataAsync({ options }: WidgetProps<"app">) {
|
||||
if (!options.appId) {
|
||||
return { app: null, pingResult: null };
|
||||
}
|
||||
|
||||
try {
|
||||
const app = await api.app.byId({ id: options.appId });
|
||||
return { app };
|
||||
let pingResult: RouterOutputs["widget"]["app"]["ping"] | null = null;
|
||||
|
||||
if (app.href && options.pingEnabled) {
|
||||
pingResult = await api.widget.app.ping({ url: app.href });
|
||||
}
|
||||
|
||||
return { app, pingResult };
|
||||
} catch (error) {
|
||||
return { app: null };
|
||||
return { app: null, pingResult: null };
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user