Skip to content

Commit

Permalink
bug on image change fixed, update at for podcast set for sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexRoehm committed Aug 3, 2024
1 parent 7df3746 commit 3f546d2
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 10 deletions.
2 changes: 2 additions & 0 deletions backend/src/controller/Podcast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getEnumFunctions } from "../tools/Enumerations";
import { generateRss } from "../tools/RssGenerator";
import { FEED_SLUG } from "../tools/Configuration";
import { createDir, dataPath } from "../tools/DataFiles";
import { setLastUpdate } from '../services/podcastService';

export async function generateRssAction(request: Request, response: Response) {
try {
Expand All @@ -29,6 +30,7 @@ export async function generateRssAction(request: Request, response: Response) {
createDir(dir)
const target_file = dir + podcast.slug+".xml"
fs.writeFileSync(target_file, xml)
setLastUpdate(podcast.id)
respond(response, 201, { message: "RSS for podcast slug=" + podcast.slug + " successfully generated" });
} catch (error) {
respond(response, 500, {
Expand Down
6 changes: 3 additions & 3 deletions backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ const proxy = require('express-http-proxy');
initDataSource().then(() => {
// create express app
const app = express();
app.use("/s", express.static('./public/s'));
app.use("/img", express.static('./public/img'));
app.use("/test", express.static('./public/test'));
app.use("/s", express.static(DATA_PATH+'/s'));
app.use("/img", express.static(DATA_PATH+'/img'));
app.use("/test", express.static(DATA_PATH+'/test'));
app.use(bodyParser.json());
app.use(cookieParser());

Expand Down
1 change: 0 additions & 1 deletion backend/src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ export const AppRoutes = [
order: {
lastEpisode: 'DESC'
},
relations: ['episodes'],
}, req, res)
},
{
Expand Down
10 changes: 9 additions & 1 deletion backend/src/services/podcastService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { createDir, dataPath, writeRss } from "../tools/DataFiles";
import Enumerations from "../tools/Enumerations";
import { generateRss } from "../tools/RssGenerator";
import getRepository from "./datasourceService";
import { getQueryGen, updateGen } from "./genericService";

export function getPodcast(from : any): Podcast {
var podcast = new Podcast();
Expand Down Expand Up @@ -40,7 +41,14 @@ export function getPodcast(from : any): Podcast {
return podcast;
}


export const setLastUpdate = async ( id: number ) : Promise<string> => {
const podcast = await getQueryGen(Podcast, { id: id })
podcast.lastbuild = Date.now().toLocaleString()
podcast.updatedAt = Date.now()
updateGen(Podcast, podcast as Podcast)
return podcast.lastbuild
}


// if (object.hasOwnProperty("updatedAt"))
// (object as any).updatedAt = new Date();
1 change: 0 additions & 1 deletion components/AudioFileSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export default defineComponent({
audioFile.value.imgblob = array2blob(
id3tag.image.data,
id3tag.image.mime)
console.log(audioFile.value.cover_preview)
}
} catch(err) {
console.log(err)
Expand Down
6 changes: 4 additions & 2 deletions components/EpisodeDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
:labelChecked="$t('episode.label.block_true')" :labelUnChecked="$t('episode.label.block_false')" />
<switch-box :checked="fields.explicit" @checkedChanged="(val) => fields.explicit = val"
:labelChecked="$t('episode.label.explicit_true')" :labelUnChecked="$t('episode.label.explicit_false')" />
<input-area :name="'cross_ref'" :label="'episode.label.cross_ref'" v-model:value="fields.cross_ref"
<input-area :name="'cross_ref'" :label="'episode.label.cross_ref'" v-model:value="(fields.cross_ref)"
@change="setShortInfo" />
<input-area :name="'video_link'" :label="'episode.label.video_link'" v-model:value="fields.video_link"
@change="setShortInfo" />
Expand Down Expand Up @@ -113,6 +113,8 @@ export default defineComponent({
const myFetch = useFetchApi()
const errors = ref([] as Array<IValidationError>);
const fields = ref({ ...props.episode } as IEpisode);
if (!fields.value.cross_ref) fields.value.cross_ref = ''
if (!fields.value.video_link) fields.value.video_link = ''
const isEdit = computed(() => (fields.value as any).id != undefined);
const uploadIndicator = ref(false)
const keepImage = ref(isEdit.value)
Expand Down Expand Up @@ -266,7 +268,7 @@ export default defineComponent({
// Upload Image
if (imgMetadata.value.preview != serie.cover_file && (imgMetadata.value.selectedFile || audioMetadata.value.imgblob != undefined)) {
if (!imgMetadata.value.preview.endsWith(serie.cover_file) && (imgMetadata.value.selectedFile || audioMetadata.value.imgblob != undefined)) {
var { result, link, nothingToDo } = await upload(SERVER_IMG_PATH, imgMetadata.value.selectedFile, audioMetadata.value.imgblob)
if (result.statusCode != 201) {
errors.value.push({ field: "", text: "episode.validation.upload" })
Expand Down
2 changes: 0 additions & 2 deletions components/ImageSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,13 @@ export default defineComponent({
img.onload = () => {
imgMetadata.value.imgWidth = img.naturalWidth;
imgMetadata.value.imgHeight = img.naturalHeight;
console.log('hi')
callback();
}
img.onerror = () => {
imgMetadata.value.preview = undefined;
imgMetadata.value.selectedFile = undefined;
imgMetadata.value.blob = undefined;
imgMetadata.value.imgWidth = 0;
console.log('hi+')
imgMetadata.value.imgHeight = 0;
callback();
}
Expand Down
1 change: 1 addition & 0 deletions composables/usePodcast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function usePodcast(slug:string) {
loading.value = true
await dataRefresh()
episodes.value = podcast.value?.episodes as Array<IEpisode>
delete podcast.value.episodes
loading.value = false
}

Expand Down

0 comments on commit 3f546d2

Please sign in to comment.