mirror of
https://github.com/gethomepage/homepage.git
synced 2026-01-13 12:42:09 +08:00
Feature: Plant-it widget (#2941)
This commit is contained in:
committed by
GitHub
parent
841c74d58a
commit
619f365c92
21
src/widgets/plantit/widget.js
Normal file
21
src/widgets/plantit/widget.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import { asJson } from "utils/proxy/api-helpers";
|
||||
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||
|
||||
const widget = {
|
||||
api: "{url}/api/{endpoint}",
|
||||
proxyHandler: credentialedProxyHandler,
|
||||
|
||||
mappings: {
|
||||
plantit: {
|
||||
endpoint: "stats",
|
||||
},
|
||||
map: (data) => ({
|
||||
events: Object.values(asJson(data).diaryEntryCount).reduce((acc, i) => acc + i, 0),
|
||||
plants: Object.values(asJson(data).plantCount).reduce((acc, i) => acc + i, 0),
|
||||
photos: Object.values(asJson(data).imageCount).reduce((acc, i) => acc + i, 0),
|
||||
species: Object.values(asJson(data).botanicalInfoCount).reduce((acc, i) => acc + i, 0),
|
||||
}),
|
||||
},
|
||||
};
|
||||
|
||||
export default widget;
|
||||
Reference in New Issue
Block a user