diff --git a/service/model_manager/model_installer.py b/service/model_manager/model_installer.py
index 5c45351..4028fe3 100644
--- a/service/model_manager/model_installer.py
+++ b/service/model_manager/model_installer.py
@@ -147,10 +147,22 @@ def download_url_with_agent(url, save_path, progress_callback=None):
req = urllib.request.Request(url, headers=headers)
with urllib.request.urlopen(req) as response:
+ if response.status != 200:
+ raise Exception(f"Request returned status code {response.status}")
+
file_size = int(response.headers.get('content-length', 0))
+ print(f"File size: {file_size} bytes")
chunk_size = 1024 # 1KB per chunk
downloaded = 0
+ if file_size == 0:
+ html = response.read().decode()
+ title = re.search(r'
(.*?)', html)[0]
+ if 'Sign in' in title:
+ raise Exception(f"You need to add API key to download this model.")
+ else:
+ raise Exception(f"Download failed. {title}")
+
if not os.path.exists(os.path.dirname(temp_save_path)):
os.makedirs(os.path.dirname(temp_save_path))
diff --git a/ui/src/components/Draggable.tsx b/ui/src/components/Draggable.tsx
index 9ae4b04..0850aac 100644
--- a/ui/src/components/Draggable.tsx
+++ b/ui/src/components/Draggable.tsx
@@ -1,17 +1,24 @@
-import { useState, useCallback, MouseEvent, useRef } from "react";
+import { useState, useCallback, MouseEvent, useRef, PropsWithChildren } from "react";
const POSITION = { x: 0, y: 0 };
-export default function Draggable({ children, onDragEnd }) {
+interface Props {
+ onDragEnd: (position: { x: number; y: number }) => void;
+}
+
+export default function Draggable({ children, onDragEnd }: PropsWithChildren) {
const originRef = useRef(POSITION);
const isDraggingRef = useRef(false);
const [translation, setTranslation] = useState(POSITION);
const handleMouseDown = (e: MouseEvent) => {
+ if (!(e.target instanceof Element) || !(e.target.parentNode instanceof Element)) {
+ return;
+ }
if ([e.target?.id, e.target?.parentNode?.id].includes("dragPanelIcon")) {
originRef.current = {
x: e.clientX,
- y: e.clientY,
+ y: e.clientY,
};
isDraggingRef.current = true;
window.addEventListener("mousemove", handleMouseMove);
@@ -21,7 +28,7 @@ export default function Draggable({ children, onDragEnd }) {
}
};
- const handleMouseMove = useCallback((e: MouseEvent) => {
+ const handleMouseMove = useCallback((e: globalThis.MouseEvent) => {
const translation = {
x: e.clientX - originRef.current.x,
y: e.clientY - originRef.current.y,
diff --git a/ui/src/components/DropdownTitle.tsx b/ui/src/components/DropdownTitle.tsx
index 8e15a6f..3ba2f9b 100644
--- a/ui/src/components/DropdownTitle.tsx
+++ b/ui/src/components/DropdownTitle.tsx
@@ -121,7 +121,7 @@ export default function DropdownTitle() {
return (
<>