2021-01-01 16:51:55 -09:00
|
|
|
import { baseURL } from "./api-utils";
|
|
|
|
import { apiReq } from "./api-utils";
|
|
|
|
import { store } from "../store/store";
|
|
|
|
|
|
|
|
const migrationBase = baseURL + "migration/";
|
|
|
|
|
|
|
|
const migrationURLs = {
|
2021-01-09 18:55:26 -09:00
|
|
|
upload: migrationBase + "upload/",
|
|
|
|
delete: (file) => `${migrationBase}${file}/delete/`,
|
2021-01-01 16:51:55 -09:00
|
|
|
chowdownURL: migrationBase + "chowdown/repo/",
|
2021-01-09 18:04:53 -09:00
|
|
|
nextcloudAvaiable: migrationBase + "nextcloud/available/",
|
|
|
|
nextcloudImport: (selection) =>
|
|
|
|
`${migrationBase}nextcloud/${selection}/import/`,
|
2021-01-01 16:51:55 -09:00
|
|
|
};
|
|
|
|
|
|
|
|
export default {
|
|
|
|
async migrateChowdown(repoURL) {
|
|
|
|
let postBody = { url: repoURL };
|
|
|
|
let response = await apiReq.post(migrationURLs.chowdownURL, postBody);
|
|
|
|
store.dispatch("requestRecentRecipes");
|
|
|
|
return response.data;
|
|
|
|
},
|
2021-01-09 18:04:53 -09:00
|
|
|
async getNextcloudImports() {
|
|
|
|
let response = await apiReq.get(migrationURLs.nextcloudAvaiable);
|
|
|
|
return response.data;
|
|
|
|
},
|
|
|
|
async importNextcloud(selected) {
|
|
|
|
let response = await apiReq.post(migrationURLs.nextcloudImport(selected));
|
|
|
|
return response.data;
|
|
|
|
},
|
2021-01-09 18:55:26 -09:00
|
|
|
async uploadFile(form_data) {
|
|
|
|
let response = await apiReq.post(migrationURLs.upload, form_data, {
|
|
|
|
headers: {
|
|
|
|
"Content-Type": "multipart/form-data",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
return response.data;
|
|
|
|
},
|
|
|
|
async delete(file_folder_name) {
|
|
|
|
let response = await apiReq.delete(migrationURLs.delete(file_folder_name));
|
|
|
|
return response.data;
|
|
|
|
},
|
2021-01-01 16:51:55 -09:00
|
|
|
};
|