将数据恢复,底图上传,查看底图,升级的http转化

This commit is contained in:
miao 2023-02-15 11:36:19 +08:00 committed by fangxiang
parent 71abf1bba2
commit e68eb4c8d6
6 changed files with 463 additions and 547 deletions

View File

@ -1,256 +1,226 @@
<template> <template>
<q-dialog <q-dialog
persistent persistent
v-model="show_dialog" v-model="show_dialog"
@before-hide="resetData" @before-hide="resetData"
@keydown=" @keydown="
(evt) => { (evt) => {
if (!loading && evt.keyCode == 27) { if (!loading && evt.keyCode == 27) {
show_dialog = false; show_dialog = false;
} }
} }
" "
> >
<q-card class="overflow-hidden" style="overflow-y: scroll; max-width: 35vw"> <q-card class="overflow-hidden" style="overflow-y: scroll; max-width: 35vw">
<q-form @submit="onSubmit"> <q-form @submit="onSubmit">
<q-card-section class="q-ma-none q-pa-sm"> <q-card-section class="q-ma-none q-pa-sm">
<div class="row"> <div class="row">
<div class="col-11 text-h6"> <div class="col-11 text-h6">
{{ $t("background image") }} {{ $t("background image") }}
</div> </div>
<div class="col-1"> <div class="col-1">
<q-btn <q-btn
:loading="loading" :loading="loading"
flat flat
round round
icon="close" icon="close"
:disable="loading" :disable="loading"
color="red" color="red"
v-close-popup v-close-popup
> >
<q-tooltip> <q-tooltip>
{{ $t("close") }} {{ $t("close") }}
</q-tooltip> </q-tooltip>
</q-btn> </q-btn>
</div> </div>
</div> </div>
</q-card-section> </q-card-section>
<q-separator /> <q-separator />
<q-card-section style="max-height: 50vh; width: 35vw" class="scroll"> <q-card-section style="max-height: 50vh; width: 35vw" class="scroll">
<q-list> <q-list>
<q-item> <q-item>
<q-item-section> <q-item-section>
<q-uploader <q-uploader
class="full-width" class="full-width"
ref="uploader" ref="uploader"
:url="upload_url" :url="upload_url"
method="post" method="post"
:headers="generatorFileUploadHeaders" :label="$t('select background image') + ':'"
:label="$t('select background image') + ':'" :accept="$store.state.isSpecialVideo() ? '.svdoj' : 'image/*'"
:accept="$store.state.isSpecialVideo() ? '.svdoj' : 'image/*'" :hide-upload-btn="true"
:hide-upload-btn="true" @uploaded="onUploaded"
@uploaded="onUploaded" @failed="onFailed"
@failed="onFailed" @added="(files) => files && (file_count += files.length)"
@added="(files) => files && (file_count += files.length)" @removed="(files) => files && (file_count -= files.length)"
@removed="(files) => files && (file_count -= files.length)" />
/> <!-- :headers="generatorFileUploadHeaders" -->
</q-item-section> </q-item-section>
</q-item> </q-item>
</q-list> </q-list>
</q-card-section> </q-card-section>
<q-separator /> <q-separator />
<q-card-actions align="left"> <q-card-actions align="left">
<q-btn <q-btn
v-if="$store.state.isLedPlayer()" v-if="$store.state.isLedPlayer()"
flat flat
no-caps no-caps
:loading="loading" :loading="loading"
color="primary" color="primary"
@click="showBackgroundImage" @click="showBackgroundImage()"
:label="$t('view current background image')" :label="$t('view current background image')"
/> />
<q-space /> <q-space />
<q-btn <q-btn
:loading="loading" :loading="loading"
flat flat
:label="$t('Cancel')" :label="$t('Cancel')"
no-caps no-caps
color="primary" color="primary"
v-close-popup v-close-popup
/> />
<q-btn <q-btn
ref="accept" ref="accept"
flat flat
:label="$t('Accept')" :label="$t('Accept')"
no-caps no-caps
:loading="loading" :loading="loading"
type="submit" type="submit"
color="primary" color="primary"
/> />
</q-card-actions> </q-card-actions>
</q-form> </q-form>
</q-card> </q-card>
</q-dialog> </q-dialog>
</template> </template>
<style scoped></style> <style scoped></style>
<script lang="ts"> <script lang="ts">
import { defineComponent, ref, watch, computed } from "vue"; import { defineComponent, ref, watch, computed } from "vue";
import { useStore } from "src/store"; import { useStore } from "src/store";
import { useQuasar } from "quasar"; import { useQuasar } from "quasar";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import GlobalData from "src/common/GlobalData"; import GlobalData from "src/common/GlobalData";
import { HttpProtocol } from "src/entities/HttpProtocol"; import { HttpProtocol } from "src/entities/HttpProtocol";
import { api as viewerApi } from "v-viewer"; import { api as viewerApi } from "v-viewer";
export default defineComponent({ export default defineComponent({
name: "ComponentBackgroundImageDialog", name: "ComponentBackgroundImageDialog",
setup() { setup() {
let $store = useStore(); let $store = useStore();
let $q = useQuasar(); let $q = useQuasar();
let $t = useI18n(); let $t = useI18n();
let show_dialog = ref(false); let show_dialog = ref(false);
let uploader: any = ref(null); let uploader: any = ref(null);
let loading = ref(false); let loading = ref(false);
let upload_url = ref(""); let upload_url = ref("");
let file_count = ref(0); let file_count = ref(0);
return { return {
show_dialog, show_dialog,
loading, loading,
upload_url, upload_url,
uploader, uploader,
file_count, file_count,
loga(a: any) { loga(a: any) {
console.log(a); console.log(a);
}, },
generatorFileUploadHeaders(files: File[]) { showDialog() {
if (files.length > 0) { show_dialog.value = true;
return [ let url = GlobalData.getInstance().createCurrentRequestUrl();
{ if (url) {
name: HttpProtocol.kHeaderXProductName, url.pathname = "/upload_background_image_file";
value: HttpProtocol.getProductName($store), upload_url.value = url.toString();
}, }
{ },
name: HttpProtocol.kHeaderXFileLength, resetData() {
value: files[0].size, loading.value = false;
}, upload_url.value = "";
]; file_count.value = 0;
} },
return []; showBackgroundImage() {
}, try {
showDialog() { let url = GlobalData.getInstance().createCurrentRequestUrl();
show_dialog.value = true; if (url) {
let client = GlobalData.getInstance().getCurrentClient(); url.pathname = "/get_background_image_file";
if (client) { viewerApi({
let url = new URL(client.url); options: {
url.port = toolbar: true,
GlobalData.getInstance().applicationConfig?.httpserver_port ?? url: "data-source",
HttpProtocol.DefaultHttpPort.toString(); initialViewIndex: 0,
url.pathname = HttpProtocol.RequestUploadFile; },
url.protocol = "http:"; images: [
url.searchParams.append( {
"type", src: url.toString(),
HttpProtocol.UploadTypeBackgroundImage "data-source": url.toString(),
); },
upload_url.value = url.toString(); ],
} });
}, }
resetData() { } catch {}
loading.value = false; },
upload_url.value = ""; async onSubmit() {
file_count.value = 0; if (file_count.value <= 0) {
}, $q.notify({
showBackgroundImage() { type: "warning",
const temp_port = message: $t.t("please select file first") + "!",
GlobalData.getInstance().applicationConfig?.httpserver_port ?? position: "top",
HttpProtocol.DefaultHttpPort.toString(); timeout: 1500,
try { });
const url = new URL( return;
GlobalData.getInstance().getCurrentClient()?.url ?? }
"http://127.0.0.1:" + temp_port loading.value = true;
); try {
url.protocol = "http"; $q.dialog({
url.port = temp_port.toString(); title: $t.t("Confirm"),
url.pathname = "/static/background_image.png"; message: $t.t("use this image to background image") + "?",
viewerApi({ ok: {
options: { label: $t.t("ok"),
toolbar: true, noCaps: true,
url: "data-source", flat: true,
initialViewIndex: 0, },
}, cancel: {
images: [ label: $t.t("cancel"),
{ noCaps: true,
src: url.toString(), flat: true,
"data-source": url.toString(), },
}, persistent: true,
], })
}); .onOk(() => {
} catch {} uploader.value.upload();
}, })
async onSubmit() { .onCancel(() => {
if (file_count.value <= 0) { loading.value = false;
$q.notify({ });
type: "warning", } catch {}
message: $t.t("please select file first") + "!", },
position: "top", onUploaded() {
timeout: 1500, $q.notify({
}); type: "positive",
return; message: $t.t("upload background image") + $t.t("success") + "!",
} position: "top",
loading.value = true; timeout: 1500,
try { });
$q.dialog({ loading.value = false;
title: $t.t("Confirm"), show_dialog.value = false;
message: $t.t("use this image to background image") + "?", },
ok: { onFailed(info: any) {
label: $t.t("ok"), console.log(info);
noCaps: true, $q.notify({
flat: true, type: "warning",
}, message: $t.t("upload background image") + $t.t("fail") + "!",
cancel: { position: "top",
label: $t.t("cancel"), timeout: 1500,
noCaps: true, });
flat: true, loading.value = false;
}, },
persistent: true, };
}) },
.onOk(() => { });
uploader.value.upload(); </script>
})
.onCancel(() => {
loading.value = false;
});
} catch {}
},
onUploaded() {
$q.notify({
type: "positive",
message: $t.t("upload background image") + $t.t("success") + "!",
position: "top",
timeout: 1500,
});
loading.value = false;
show_dialog.value = false;
},
onFailed(info: any) {
console.log(info);
$q.notify({
type: "warning",
message: $t.t("upload background image") + $t.t("fail") + "!",
position: "top",
timeout: 1500,
});
loading.value = false;
},
};
},
});
</script>

View File

@ -1065,12 +1065,13 @@ export default defineComponent({
setTimeout(() => { setTimeout(() => {
if (files.value.length != file_list.files.length) { if (files.value.length != file_list.files.length) {
$q.notify({ $q.notify({
type: "warning", type: "positive",
message: $t.t("file upload") + $t.t("fail") + "!", message: $t.t("file upload") + $t.t("finish") + "!",
position: "top", position: "top",
timeout: 1500, timeout: 1500,
}); });
loading.value = false; loading.value = false;
uploading.value=false;
} }
}, 500); }, 500);
}, },

View File

@ -1,247 +1,225 @@
<template> <template>
<q-dialog <q-dialog
persistent persistent
v-model="show_dialog" v-model="show_dialog"
@before-hide="resetData" @before-hide="resetData"
@keydown=" @keydown="
(evt) => { (evt) => {
if (!loading && evt.keyCode == 27) { if (!loading && evt.keyCode == 27) {
show_dialog = false; show_dialog = false;
} }
} }
" "
> >
<q-card class="overflow-hidden" style="overflow-y: scroll; max-width: 35vw"> <q-card class="overflow-hidden" style="overflow-y: scroll; max-width: 35vw">
<q-form @submit="onSubmit"> <q-form @submit="onSubmit">
<q-card-section class="q-ma-none q-pa-sm"> <q-card-section class="q-ma-none q-pa-sm">
<div class="row"> <div class="row">
<div class="col-auto text-h6"> <div class="col-auto text-h6">
{{ $t("database import") }} {{ $t("database import") }}
</div> </div>
<q-space /> <q-space />
<div> <div>
<q-btn <q-btn
:loading="loading" :loading="loading"
flat flat
round round
icon="close" icon="close"
:disable="loading" :disable="loading"
color="red" color="red"
v-close-popup v-close-popup
> >
<q-tooltip> <q-tooltip>
{{ $t("close") }} {{ $t("close") }}
</q-tooltip> </q-tooltip>
</q-btn> </q-btn>
</div> </div>
</div> </div>
</q-card-section> </q-card-section>
<q-separator /> <q-separator />
<q-card-section style="max-height: 50vh; width: 35vw" class="scroll"> <q-card-section style="max-height: 50vh; width: 35vw" class="scroll">
<q-list> <q-list>
<q-item> <q-item>
<q-item-section> <q-item-section>
<q-uploader <q-uploader
class="full-width" class="full-width"
ref="uploader" ref="uploader"
:url="upload_url" :url="upload_url"
method="post" method="POST"
:headers="generatorFileUploadHeaders" :label="$t('select data(DBP) file') + ':'"
:label="$t('select data(DBP) file') + ':'" accept=".dbp"
accept=".dbp" :hide-upload-btn="true"
:hide-upload-btn="true" @uploaded="onUploaded"
@uploaded="onUploaded" @failed="onFailed"
@failed="onFailed" @added="(files) => files && (file_count += files.length)"
@added="(files) => files && (file_count += files.length)" @removed="(files) => files && (file_count -= files.length)"
@removed="(files) => files && (file_count -= files.length)" />
/> </q-item-section>
</q-item-section> </q-item>
</q-item> </q-list>
</q-list> </q-card-section>
</q-card-section>
<q-separator />
<q-separator />
<q-card-actions align="right">
<q-card-actions align="right"> <q-btn
<q-btn :loading="loading"
:loading="loading" flat
flat :label="$t('Cancel')"
:label="$t('Cancel')" no-caps
no-caps color="primary"
color="primary" v-close-popup
v-close-popup />
/> <q-btn
<q-btn ref="accept"
ref="accept" flat
flat :label="$t('Accept')"
:label="$t('Accept')" no-caps
no-caps :loading="loading"
:loading="loading" type="submit"
type="submit" color="primary"
color="primary" />
/> </q-card-actions>
</q-card-actions> </q-form>
</q-form> </q-card>
</q-card> </q-dialog>
</q-dialog> </template>
</template>
<style scoped></style>
<style scoped></style>
<script lang="ts">
<script lang="ts"> import { defineComponent, ref, watch, computed } from "vue";
import { defineComponent, ref, watch, computed } from "vue"; import { useStore } from "src/store";
import { useStore } from "src/store"; import { useQuasar } from "quasar";
import { useQuasar } from "quasar"; import { useI18n } from "vue-i18n";
import { useI18n } from "vue-i18n"; import GlobalData from "src/common/GlobalData";
import GlobalData from "src/common/GlobalData"; import { HttpProtocol } from "src/entities/HttpProtocol";
import { HttpProtocol } from "src/entities/HttpProtocol"; import { api as viewerApi } from "v-viewer";
import { api as viewerApi } from "v-viewer";
export default defineComponent({
export default defineComponent({ name: "ComponentRecoveryDatabaseDialog",
name: "ComponentRecoveryDatabaseDialog",
setup() {
setup() { let $store = useStore();
let $store = useStore(); let $q = useQuasar();
let $q = useQuasar(); let $t = useI18n();
let $t = useI18n();
let show_dialog = ref(false);
let show_dialog = ref(false); let uploader: any = ref(null);
let uploader: any = ref(null); let loading = ref(false);
let loading = ref(false); let upload_url = ref("");
let upload_url = ref(""); let file_count = ref(0);
let file_count = ref(0);
return {
return { show_dialog,
show_dialog, loading,
loading, upload_url,
upload_url, uploader,
uploader, file_count,
file_count, showDialog() {
generatorFileUploadHeaders(files: File[]) { show_dialog.value = true;
if (files.length > 0) { let url = GlobalData.getInstance().createCurrentRequestUrl();
return [ if (url) {
{ url.pathname = "/upload_db_file";
name: HttpProtocol.kHeaderXProductName, upload_url.value = url.toString();
value: HttpProtocol.getProductName($store), }
}, },
{ resetData() {
name: HttpProtocol.kHeaderXFileLength, loading.value = false;
value: files[0].size, upload_url.value = "";
}, file_count.value = 0;
]; },
} async onSubmit() {
return []; if (file_count.value <= 0) {
}, $q.notify({
showDialog() { type: "warning",
show_dialog.value = true; message: $t.t("please select file first") + "!",
let client = GlobalData.getInstance().getCurrentClient(); position: "top",
if (client) { timeout: 1500,
let url = new URL(client.url); });
url.port = return;
GlobalData.getInstance().applicationConfig?.httpserver_port ?? }
HttpProtocol.DefaultHttpPort.toString(); loading.value = true;
url.pathname = HttpProtocol.RequestUploadFile; try {
url.protocol = "http:"; $q.dialog({
url.searchParams.append("type", HttpProtocol.UploadTypeDatabase); title: $t.t("Confirm"),
upload_url.value = url.toString(); message: $t.t("use this file to recovery data") + "?",
} ok: {
}, label: $t.t("ok"),
resetData() { noCaps: true,
loading.value = false; flat: true,
upload_url.value = ""; },
file_count.value = 0; cancel: {
}, label: $t.t("cancel"),
async onSubmit() { noCaps: true,
if (file_count.value <= 0) { flat: true,
$q.notify({ },
type: "warning", persistent: true,
message: $t.t("please select file first") + "!", })
position: "top", .onOk(() => {
timeout: 1500, uploader.value.upload();
}); })
return; .onCancel(() => {
} loading.value = false;
loading.value = true; });
try { } catch {}
$q.dialog({ },
title: $t.t("Confirm"), onUploaded() {
message: $t.t("use this file to recovery data") + "?", $q.notify({
ok: { type: "positive",
label: $t.t("ok"), message: $t.t("data import") + $t.t("success") + "!",
noCaps: true, position: "top",
flat: true, timeout: 1500,
}, });
cancel: { $q.dialog({
label: $t.t("cancel"), title: $t.t("Confirm"),
noCaps: true, message:
flat: true, $t.t("data changes will take effect after the restart") +
}, "!" +
persistent: true, "<p class='text-red'>" +
}) $t.t("reboot now") +
.onOk(() => { "?" +
uploader.value.upload(); "</p>",
}) html: true,
.onCancel(() => { ok: {
loading.value = false; label: $t.t("ok"),
}); noCaps: true,
} catch {} flat: true,
}, },
onUploaded() { cancel: {
$q.notify({ label: $t.t("cancel"),
type: "positive", noCaps: true,
message: $t.t("data import") + $t.t("success") + "!", flat: true,
position: "top", },
timeout: 1500, persistent: true,
}); })
$q.dialog({ .onOk(() => {
title: $t.t("Confirm"), GlobalData.getInstance().getCurrentClient()?.restartDevice();
message: $q.notify({
$t.t("data changes will take effect after the restart") + type: "positive",
"!" + message: $t.t("reboot device command sended") + "!",
"<p class='text-red'>" + position: "top",
$t.t("reboot now") + timeout: 1500,
"?" + });
"</p>", })
html: true, .onDismiss(() => {
ok: { loading.value = false;
label: $t.t("ok"), show_dialog.value = false;
noCaps: true, });
flat: true, },
}, onFailed(info: any) {
cancel: { console.log(info);
label: $t.t("cancel"), $q.notify({
noCaps: true, type: "warning",
flat: true, message: $t.t("data import") + $t.t("fail") + "!",
}, position: "top",
persistent: true, timeout: 1500,
}) });
.onOk(() => { loading.value = false;
GlobalData.getInstance().getCurrentClient()?.restartDevice(); },
$q.notify({ };
type: "positive", },
message: $t.t("reboot device command sended") + "!", });
position: "top", </script>
timeout: 1500,
});
})
.onDismiss(() => {
loading.value = false;
show_dialog.value = false;
});
},
onFailed(info: any) {
console.log(info);
$q.notify({
type: "warning",
message: $t.t("data import") + $t.t("fail") + "!",
position: "top",
timeout: 1500,
});
loading.value = false;
},
};
},
});
</script>

View File

@ -61,7 +61,6 @@
ref="uploader_software" ref="uploader_software"
:url="upload_url_software" :url="upload_url_software"
method="post" method="post"
:headers="generatorFileUploadHeaders"
:label="$t('select software upgrade file') + ':'" :label="$t('select software upgrade file') + ':'"
accept=".zip,.tar,.tar.gz" accept=".zip,.tar,.tar.gz"
:hide-upload-btn="true" :hide-upload-btn="true"
@ -76,7 +75,6 @@
ref="uploader_rootfs" ref="uploader_rootfs"
:url="upload_url_rootfs" :url="upload_url_rootfs"
method="post" method="post"
:headers="generatorFileUploadHeaders"
:label="$t('select rootfs upgrade file') + ':'" :label="$t('select rootfs upgrade file') + ':'"
accept=".img" accept=".img"
:hide-upload-btn="true" :hide-upload-btn="true"
@ -85,6 +83,7 @@
@added="(files) => files && (file_count += files.length)" @added="(files) => files && (file_count += files.length)"
@removed="(files) => files && (file_count -= files.length)" @removed="(files) => files && (file_count -= files.length)"
/> />
<!-- :headers="generatorFileUploadHeaders" -->
</q-item-section> </q-item-section>
</q-item> </q-item>
</q-list> </q-list>
@ -92,9 +91,7 @@
<q-separator /> <q-separator />
<q-card-actions> <q-card-actions align="right">
<q-item-section>V: {{ server_version }}</q-item-section>
<q-space />
<q-btn <q-btn
:loading="loading" :loading="loading"
flat flat
@ -146,7 +143,6 @@ export default defineComponent({
let select_options = [$t.t("software"), $t.t("rootfs")]; let select_options = [$t.t("software"), $t.t("rootfs")];
let upgrade_type = ref($t.t("software")); let upgrade_type = ref($t.t("software"));
const server_version = ref("unknow");
return { return {
show_dialog, show_dialog,
@ -158,49 +154,18 @@ export default defineComponent({
file_count, file_count,
upgrade_type, upgrade_type,
select_options, select_options,
server_version,
generatorFileUploadHeaders(files: File[]) {
if (files.length > 0) {
return [
{
name: HttpProtocol.kHeaderXProductName,
value: HttpProtocol.getProductName($store),
},
{
name: HttpProtocol.kHeaderXFileLength,
value: files[0].size,
},
];
}
return [];
},
loga(a: any) { loga(a: any) {
console.log(a); console.log(a);
}, },
showDialog() { showDialog() {
show_dialog.value = true; show_dialog.value = true;
let client = GlobalData.getInstance().getCurrentClient(); let url = GlobalData.getInstance().createCurrentRequestUrl();
if (client) { if (url) {
let url = new URL(client.url); url.pathname = "/upload_soft_file";
url.port =
GlobalData.getInstance().applicationConfig?.httpserver_port ??
HttpProtocol.DefaultHttpPort.toString();
url.pathname = HttpProtocol.RequestUploadFile;
url.protocol = "http:";
url.searchParams.append("type", HttpProtocol.UploadTypeRootFS);
upload_url_rootfs.value = url.toString();
url.searchParams.set("type", HttpProtocol.UploadTypeSoftware);
upload_url_software.value = url.toString(); upload_url_software.value = url.toString();
try { url.pathname = "/upload_root_fs_file";
client?.getBuildInfo()?.then((build_info) => { upload_url_rootfs.value = url.toString();
if (build_info) {
server_version.value = build_info.version;
}
});
// console.log(build_info);
} catch {}
} }
}, },
resetData() { resetData() {

View File

@ -294,6 +294,7 @@ export default {
"open left tool bar": "Open Left Tool Bar", "open left tool bar": "Open Left Tool Bar",
"open right tool bar": "Open Right Tool Bar", "open right tool bar": "Open Right Tool Bar",
fail: " Fail", fail: " Fail",
finish:"Finish",
"edit group": "Edit Group", "edit group": "Edit Group",
"open window": "Open Window", "open window": "Open Window",
"close all windows": "Close All Windows", "close all windows": "Close All Windows",

View File

@ -5,6 +5,7 @@ export default {
" ": "", " ": "",
title: "MediaPlayerWebApp", title: "MediaPlayerWebApp",
failed: "失败", failed: "失败",
finish:"完成",
fail: "失败", fail: "失败",
error: "错误", error: "错误",
Confirm: "确认", Confirm: "确认",