mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-07 20:44:05 +09:00
wqXMerge branch 'more.image-info' of github.com:webstudio-is/webstudio-designer into s3-images
This commit is contained in:
commit
4fe51db6c4
7 files changed
+17
-8
No files matched your search
File renamed without changes.
@@ -1,5 +1,5 @@
|
||||
import * as components from "./components";
|
||||
import * as tree from "./tree";
|
||||
import * as imageUpload from "./image-upload";
|
||||
import * as assetManager from "./asset-manager";
|
||||
|
||||
export const panels = { components, tree, imageUpload } as const;
|
||||
export const panels = { components, tree, assetManager } as const;
|
||||
@@ -68,7 +68,7 @@ export const SidebarLeft = ({
|
||||
const enabledPanels = (
|
||||
isFeatureEnabled("assets")
|
||||
? Object.keys(panels)
|
||||
: Object.keys(panels).filter((panel) => panel !== "imageUpload")
|
||||
: Object.keys(panels).filter((panel) => panel !== "assetManager")
|
||||
) as Array<TabName>;
|
||||
|
||||
return (
|
||||
|
||||
@@ -11,7 +11,6 @@ import { Designer, links } from "~/designer";
|
||||
import * as db from "~/shared/db";
|
||||
import config from "~/config";
|
||||
import env from "~/env.server";
|
||||
import { ImagesUpload } from "~/designer/features/sidebar-left/types";
|
||||
import { s3UploadHandler } from "~/shared/uploads/s3-upload-handler";
|
||||
import { sentryException } from "~/shared/sentry";
|
||||
import { uploadToS3 } from "~/shared/uploads/upload-to-s3";
|
||||
|
||||
@@ -9,11 +9,18 @@ export const loadByProject = async (projectId?: Project["id"]) => {
|
||||
|
||||
const assets = await prisma.asset.findMany({
|
||||
where: { projectId },
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
});
|
||||
|
||||
return assets;
|
||||
};
|
||||
|
||||
const forceFloat = (number: number) => {
|
||||
return parseFloat(Number(number).toFixed(1));
|
||||
};
|
||||
|
||||
const createAssetInDb = async (
|
||||
projectId: Project["id"],
|
||||
values: {
|
||||
@@ -31,8 +38,8 @@ const createAssetInDb = async (
|
||||
path,
|
||||
size,
|
||||
format: metadata.format,
|
||||
...(metadata.width ? { width: Math.round(metadata.width) } : {}),
|
||||
...(metadata.height ? { height: Math.round(metadata.height) } : {}),
|
||||
...(metadata.width ? { width: forceFloat(metadata.width) } : {}),
|
||||
...(metadata.height ? { height: forceFloat(metadata.height) } : {}),
|
||||
projectId,
|
||||
},
|
||||
});
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Asset" ALTER COLUMN "height" SET DATA TYPE DOUBLE PRECISION,
|
||||
ALTER COLUMN "width" SET DATA TYPE DOUBLE PRECISION;
|
||||
@@ -21,8 +21,8 @@ model Asset {
|
||||
projectId String
|
||||
format String?
|
||||
size Int
|
||||
width Int?
|
||||
height Int?
|
||||
width Float?
|
||||
height Float?
|
||||
name String
|
||||
path String
|
||||
alt String?
|
||||
|
||||
Reference in new issue
Block a user