mirror of
				https://github.com/karl0ss/homepage.git
				synced 2025-11-04 08:20:58 +00:00 
			
		
		
		
	Merge pull request #1093 from Zlendy/immich
Fix: Use human readable units for storage in Immich widget
This commit is contained in:
		
						commit
						c00946cdc5
					
				@ -1,8 +1,11 @@
 | 
				
			|||||||
 | 
					import { useTranslation } from "next-i18next";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import Container from "components/services/widget/container";
 | 
					import Container from "components/services/widget/container";
 | 
				
			||||||
import Block from "components/services/widget/block";
 | 
					import Block from "components/services/widget/block";
 | 
				
			||||||
import useWidgetAPI from "utils/proxy/use-widget-api";
 | 
					import useWidgetAPI from "utils/proxy/use-widget-api";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default function Component({ service }) {
 | 
					export default function Component({ service }) {
 | 
				
			||||||
 | 
					  const { t } = useTranslation();
 | 
				
			||||||
  const { widget } = service;
 | 
					  const { widget } = service;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const { data: immichData, error: immichError } = useWidgetAPI(widget);
 | 
					  const { data: immichData, error: immichError } = useWidgetAPI(widget);
 | 
				
			||||||
@ -27,7 +30,17 @@ export default function Component({ service }) {
 | 
				
			|||||||
      <Block label="immich.users" value={immichData.usageByUser.length} />
 | 
					      <Block label="immich.users" value={immichData.usageByUser.length} />
 | 
				
			||||||
      <Block label="immich.photos" value={immichData.photos} />
 | 
					      <Block label="immich.photos" value={immichData.photos} />
 | 
				
			||||||
      <Block label="immich.videos" value={immichData.videos} />
 | 
					      <Block label="immich.videos" value={immichData.videos} />
 | 
				
			||||||
      <Block label="immich.storage" value={immichData.usage} />
 | 
					      <Block label="immich.storage"
 | 
				
			||||||
 | 
					        value={
 | 
				
			||||||
 | 
					          // backwards-compatible e.g. '9 GiB'
 | 
				
			||||||
 | 
					          immichData.usage.toString().toLowerCase().includes('b') ? 
 | 
				
			||||||
 | 
					          immichData.usage : 
 | 
				
			||||||
 | 
					          t("common.bytes", {
 | 
				
			||||||
 | 
					            value: immichData.usage,
 | 
				
			||||||
 | 
					            maximumFractionDigits: 1,
 | 
				
			||||||
 | 
					            binary: true // match immich
 | 
				
			||||||
 | 
					          })
 | 
				
			||||||
 | 
					        } />
 | 
				
			||||||
    </Container>
 | 
					    </Container>
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user