Skip to content
Snippets Groups Projects
Verified Commit 6bd6f4cd authored by Peter Oettig's avatar Peter Oettig
Browse files

draft: current state

parent 47208b4d
Branches vault-upload
No related tags found
No related merge requests found
Pipeline #416726 passed
......@@ -138,7 +138,9 @@ export async function requestBackendWithResponseHeaders<ResponseType>(
if (body) {
init.method = "POST";
init.headers = { ...init.headers, ...{ "Content-Type": "application/json" } };
if (!(body instanceof FormData)) {
init.headers = { ...init.headers, ...{ "Content-Type": "application/json" } };
}
init.body = JSON.stringify(body);
}
......
......@@ -29,10 +29,6 @@
}}
</v-card-subtitle>
<v-card-actions class="ma-auto">
<!-- TODO implement details button using JS p12 parser -->
<!-- <v-btn color="secondary" variant="flat" class="px-4" @click="openMoreDetails()">-->
<!-- <v-icon icon="fas fa-circle-info" class="pr-2" />{{ $t("createIdent.search.result.moreDetailsButton") }}-->
<!-- </v-btn>-->
<v-btn color="primary" variant="flat" class="px-4" @click="install(item)">
<icon-with-text icon="download">{{ $t("distribute.available.download") }}</icon-with-text>
</v-btn>
......@@ -40,6 +36,16 @@
</v-card>
</v-col>
</v-row>
<v-row justify="center">
<v-col cols="6">
<v-file-input
v-model="uploadFile"
accept="application/x-pkcs12"
append-icon="fas fa-upload"
:on-click:append="upload"
></v-file-input>
</v-col>
</v-row>
</v-container>
</FunctionPage>
</template>
......@@ -58,6 +64,7 @@ type DistributeData = {
results: Array<PKCS12>;
error: APIError | null;
};
uploadFile: File | null;
};
export default defineComponent({
......@@ -74,6 +81,7 @@ export default defineComponent({
results: [],
error: null,
},
uploadFile: null,
};
},
mounted() {
......@@ -103,7 +111,6 @@ export default defineComponent({
(wrappedResponse) => {
const downloadLink = document.createElement("a");
downloadLink.href = window.URL.createObjectURL(wrappedResponse.response);
console.log(downloadLink.href);
downloadLink.setAttribute("download", item.filename);
downloadLink.click();
downloadLink.remove();
......@@ -113,6 +120,25 @@ export default defineComponent({
}
);
},
upload: function () {
if (this.uploadFile == null) {
return;
}
const formData = new FormData();
formData.append("type", this.uploadFile.type);
formData.append("pkcs12", this.uploadFile.name);
formData.append("file", this.uploadFile);
console.log(this.uploadFile.stream());
requestBackend<null>("/vault/pkcs12", formData).then(
(response) => {
console.log(response);
},
(error) => {
console.log(error);
}
);
},
},
});
</script>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment