Skip to content

Commit

Permalink
edgecreator,edgecreator-api: Fix upload
Browse files Browse the repository at this point in the history
  • Loading branch information
bperel committed Jan 24, 2025
1 parent 5bdfd8c commit 81f003f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
10 changes: 10 additions & 0 deletions apps/edgecreator/api/services/upload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ export default (io: Server) => {
({ services: edgeCreatorServices } =
dmSocket.addNamespace<EdgeCreatorServices>(
EdgeCreatorServices.namespaceEndpoint,
{
session: {
getToken: () => socket.handshake.auth.token,
clearSession: () => {},
sessionExists: () => Promise.resolve(true),
}
}
));
console.log("connected to upload");

Expand All @@ -36,6 +43,9 @@ export default (io: Server) => {
});
const [countrycode, magazinecode] = publicationcode.split("/");
const path = `${edgesPath}/${countrycode}/photos`;
if (!fs.existsSync(path)) {
fs.mkdirSync(path, { recursive: true });
}
const tentativeFileName = `${magazinecode}.${issuenumber}.photo`;
const fileName = getNextAvailableFile(
`${path}/${tentativeFileName}`,
Expand Down
12 changes: 8 additions & 4 deletions apps/edgecreator/src/components/IssueSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
}
"
@change="
currentFirstIssuecode = $event;
currentFirstIssuecode = $event.issuecode;
onChange();
"
/>
Expand Down Expand Up @@ -67,7 +67,7 @@
</b-form-select-option>
</template>
</b-form-select>
<template v-if="canBeMultiple && currentFirstIssuecode !== null">
<template v-if="canBeMultiple && currentFirstIssuecode !== undefined">
<b-form-group class="mt-2">
<b-form-radio
v-model="editMode"
Expand Down Expand Up @@ -97,7 +97,7 @@
</template>
</template>
</template>
<slot v-if="$slots.dimensions && currentFirstIssuecode !== null" />
<slot v-if="slots.dimensions && currentFirstIssuecode !== undefined" name="dimensions" />
</div>
</template>
<script setup lang="ts">
Expand All @@ -111,6 +111,11 @@ const { t: $t } = useI18n();
const edgeCatalogStore = edgeCatalog();
const coaStore = webStores.coa();
const slots = defineSlots<{
default(): never;
dimensions?(): never;
}>();
interface Selection {
editMode: "single" | "range";
countrycode: string;
Expand Down Expand Up @@ -187,7 +192,6 @@ const publicationIssues = computed(
const issues = computed(
() =>
publicationIssues.value &&
edgeCatalogStore.publishedEdges[currentPublicationcode.value!] &&
coaStore.issuecodesByPublicationcode[currentPublicationcode.value!].map(
(issuecode) => {
const status = edgeCatalogStore.getEdgeStatus(issuecode);
Expand Down
9 changes: 5 additions & 4 deletions apps/edgecreator/src/pages/upload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ meta:
"
disable-ongoing-or-published
:disable-not-ongoing-nor-published="false"
@change="currentCrop = $event && $event.width ? $event : null"
@change="currentCrop = $event?.issuecode ? (currentCrop ? { ...currentCrop, ...$event.issuecode } : $event.issuecode): undefined"
>
<template #dimensions>
<dimensions
:width="currentCrop ? currentCrop.width : 15"
:height="currentCrop ? currentCrop.height : 200"
@change="currentCrop = $event && $event.width ? $event : null"
@change="currentCrop = currentCrop ? { ...currentCrop, ...$event } : $event"
/>
</template>
</issue-select>
Expand Down Expand Up @@ -164,6 +164,7 @@ import { useCookies } from "@vueuse/integrations/useCookies";
import { useToastController } from "bootstrap-vue-next";
import type Cropper from "cropperjs";
import { nextTick } from "vue";
import VueCropper from 'vue-cropperjs';
import type { CropperData } from "vue-cropperjs";
import { useI18n } from "vue-i18n";
Expand All @@ -188,7 +189,7 @@ type CropWithData = Crop & {
error?: string;
};
const currentCrop = ref<CropWithData | null>(null);
const currentCrop = ref<CropWithData>();
const crops = ref<CropWithData[]>([]);
const uploadedImageData = ref<{ url: string } | null>(null);
const cropper = ref<Cropper | null>(null);
Expand Down Expand Up @@ -223,7 +224,7 @@ const addCrop = () => {
"image/jpeg"
),
});
currentCrop.value = null;
currentCrop.value = undefined;
}
};
const uploadAll = async () => {
Expand Down
11 changes: 3 additions & 8 deletions packages/api/services/edges/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const getEdges = async (filters: {
publicationcode?: string;
issuecodes?: string[];
}) => {
if (!filters.publicationcode || !filters.issuecodes) {
if (!(filters.publicationcode || filters.issuecodes)) {
throw new Error("Invalid filter");
}
const issuecode = filters.issuecodes
Expand All @@ -26,13 +26,7 @@ const getEdges = async (filters: {
issuecode,
},
})
).reduce(
(acc, model) => {
acc[model.issuecode] = model;
return acc;
},
{} as Record<string, edgeModel>,
);
).groupBy('issuecode');

return (
await prismaDm.edge.findMany({
Expand All @@ -41,6 +35,7 @@ const getEdges = async (filters: {
issuecode: true,
},
where: {
publicationcode: filters.publicationcode,
issuecode,
},
})
Expand Down

0 comments on commit 81f003f

Please sign in to comment.