1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-02 20:15:24 +02:00

migration changes

This commit is contained in:
Hayden 2021-01-01 16:51:55 -09:00
parent e5304f0589
commit e313741a25
59 changed files with 368 additions and 22124 deletions

View file

@ -3,6 +3,7 @@ import recipe from "./api/recipe";
import mealplan from "./api/mealplan";
import settings from "./api/settings";
import themes from "./api/themes";
import migration from "./api/migration";
// import api from "../api";
@ -12,4 +13,5 @@ export default {
mealPlans: mealplan,
settings: settings,
themes: themes,
migrations: migration,
};

View file

@ -2,13 +2,17 @@ const baseURL = "/api/";
import axios from "axios";
import store from "../store/store";
// look for data.snackbar in response
function processResponse(response) {
if (("data" in response) & ("snackbar" in response.data)) {
try {
store.commit("setSnackBar", {
text: response.data.snackbar.text,
type: response.data.snackbar.type,
});
} else return;
} catch (err) {
return;
}
return;
}
const apiReq = {

View file

@ -0,0 +1,19 @@
import { baseURL } from "./api-utils";
import { apiReq } from "./api-utils";
import { store } from "../store/store";
const migrationBase = baseURL + "migration/";
const migrationURLs = {
chowdownURL: migrationBase + "chowdown/repo/",
};
export default {
async migrateChowdown(repoURL) {
let postBody = { url: repoURL };
let response = await apiReq.post(migrationURLs.chowdownURL, postBody);
console.log(response);
store.dispatch("requestRecentRecipes");
return response.data;
},
};

View file

@ -20,7 +20,10 @@ const recipeURLs = {
export default {
async createByURL(recipeURL) {
let response = await apiReq.post(recipeURLs.createByURL, { url: recipeURL });
let response = await apiReq.post(recipeURLs.createByURL, {
url: recipeURL,
});
console.log(response);
let recipeSlug = response.data;
store.dispatch("requestRecentRecipes");
router.push(`/recipe/${recipeSlug}`);

View file

@ -3,6 +3,7 @@
<Theme />
<Backup />
<Webhooks />
<Migration />
</v-container>
</template>
@ -10,11 +11,13 @@
import Backup from "./Backup";
import Webhooks from "./Webhooks";
import Theme from "./Theme";
import Migration from "./Migration";
export default {
components: {
Backup,
Webhooks,
Theme,
Migration,
},
};
</script>

View file

@ -0,0 +1,69 @@
<template>
<v-card :loading="loading">
<v-card-title class="secondary white--text mt-1">
Recipe Migration
</v-card-title>
<v-card-text>
<p>
Currently Chowdown via public Repo URL is the only supported type of
migration
</p>
<v-form>
<v-row dense align="center">
<v-col cols="12" md="5" sm="5">
<v-text-field v-model="repo" label="Chowdown Repo URL">
</v-text-field>
</v-col>
<v-col cols="12" md="4" sm="5">
<v-btn text color="info" @click="importRepo"> Migrate </v-btn>
</v-col>
</v-row>
</v-form>
<v-alert v-if="failedRecipes[1]" outlined dense type="error">
<h4>Failed Recipes</h4>
<v-list dense>
<v-list-item v-for="fail in this.failedRecipes" :key="fail">
{{ fail }}
</v-list-item>
</v-list>
</v-alert>
<v-alert v-if="failedImages[1]" outlined dense type="error">
<h4>Failed Images</h4>
<v-list dense>
<v-list-item v-for="fail in this.failedImages" :key="fail">
{{ fail }}
</v-list-item>
</v-list>
</v-alert>
</v-card-text>
</v-card>
</template>
<script>
import api from "../../api";
// import TimePicker from "./Webhooks/TimePicker";
export default {
data() {
return {
processRan: false,
loading: false,
failedImages: [],
failedRecipes: [],
repo: "",
};
},
methods: {
async importRepo() {
this.loading = true;
let response = await api.migrations.migrateChowdown(this.repo);
this.failedImages = response.failedImages;
this.failedRecipes = response.failedRecipes;
this.loading = false;
this.processRan = true;
},
},
};
</script>
<style>
</style>