|
@@ -1,6 +1,6 @@
|
|
|
<!-- eslint-disable no-fallthrough -->
|
|
|
<script setup lang="ts">
|
|
|
-import { AddressSpace, type IMappingValue } from '@/ua/AddressSpace';
|
|
|
+import { AddressSpace } from '@/ua/AddressSpace';
|
|
|
import { UANodeSet } from '@/ua/UANodeSet';
|
|
|
import { useStore } from '@/util/store'
|
|
|
import { ref } from 'vue';
|
|
@@ -8,20 +8,32 @@ import VDialog from './VDialog.vue'
|
|
|
import JSZip from "jszip";
|
|
|
import YAML from 'yaml'
|
|
|
import { assert } from '@/util/assert';
|
|
|
+import { storeToRefs } from 'pinia';
|
|
|
+import type { IMappingValue } from '@/ua/IAddressSpace';
|
|
|
+import { ServerConfig } from '@/util/sconfig';
|
|
|
|
|
|
const store = useStore()
|
|
|
const newDialogOpen = ref(false);
|
|
|
const newServerConfigOpen = ref(false);
|
|
|
const newDialogDisabled = ref(false); //Disables buttons while loading project
|
|
|
const projectType = ref("ua");
|
|
|
+const { serverConfig } = storeToRefs(store)
|
|
|
|
|
|
|
|
|
-let sconfig = store.sConfig;
|
|
|
-
|
|
|
async function exportProject() {
|
|
|
- const blob = await store.addressSpace?.exportProject();
|
|
|
- if (blob)
|
|
|
- downloadBlob(blob, "project.zip");
|
|
|
+ const zip = new JSZip();
|
|
|
+ const fileNames:string[]=[];
|
|
|
+ const as=store.addressSpace;
|
|
|
+ for(const ns of as.nodesets) {
|
|
|
+ fileNames.push(ns.fileName);
|
|
|
+ zip.file(ns.fileName, ns.toXML(ns.nameSpaceTable, as.nst).toString());
|
|
|
+ }
|
|
|
+ store.serverConfig.configData.nodesets = fileNames;
|
|
|
+ zip.file("project.json", JSON.stringify(store.serverConfig.configData));
|
|
|
+ const mapString=YAML.stringify(as.mapping.values());
|
|
|
+ zip.file("mapping.yaml", mapString)
|
|
|
+ const blob =await zip.generateAsync({type:'blob'});
|
|
|
+ downloadBlob(blob, "project.zip");
|
|
|
}
|
|
|
|
|
|
function downloadBlob(blob: Blob, filename: string) {
|
|
@@ -33,12 +45,6 @@ function downloadBlob(blob: Blob, filename: string) {
|
|
|
document.body.removeChild(link);
|
|
|
}
|
|
|
|
|
|
-async function exportConf() {
|
|
|
- const blob = await sconfig?.exportConfig();
|
|
|
- if (blob)
|
|
|
- downloadBlob(blob, "config.zip");
|
|
|
-}
|
|
|
-
|
|
|
async function newProject() {
|
|
|
newDialogDisabled.value = true;
|
|
|
store.addressSpace = new AddressSpace([] as UANodeSet[])
|
|
@@ -79,9 +85,10 @@ async function handleDrop(e: DragEvent) {
|
|
|
|
|
|
async function loadZip(file: File){
|
|
|
const zip= await JSZip.loadAsync(file.arrayBuffer())
|
|
|
- const filenames=JSON.parse(await zip.files['project.json'].async("string"));
|
|
|
+ const config=ServerConfig.load(JSON.parse(await zip.files["project.json"].async("string")));
|
|
|
+
|
|
|
const as=new AddressSpace([]);
|
|
|
- for(const fileName of filenames) {
|
|
|
+ for(const fileName of config.configData.nodesets||[]) {
|
|
|
as.addNodeset(await UANodeSet.parse(await zip.files[fileName].async("string"), fileName, as));
|
|
|
}
|
|
|
const mlist=YAML.parse(await zip.files['mapping.yaml'].async("string")) as IMappingValue[];
|
|
@@ -90,6 +97,7 @@ async function loadZip(file: File){
|
|
|
mapping.set(entry.path, entry);
|
|
|
}
|
|
|
as.mapping=mapping;
|
|
|
+ store.serverConfig=config;
|
|
|
store.setAddressSpace(as);
|
|
|
}
|
|
|
</script>
|
|
@@ -155,64 +163,63 @@ async function loadZip(file: File){
|
|
|
|
|
|
<v-dialog :open="newServerConfigOpen" @cancel="newServerConfigOpen = false">
|
|
|
<p>Server Configuration</p>
|
|
|
- <div v-if="sconfig">
|
|
|
+ <div v-if="serverConfig">
|
|
|
<div class="input-group mb-3">
|
|
|
<div class="input-group-prepend">
|
|
|
<span class="input-group-text" id="inputGroup-sizing-default">Manufacturer Name</span>
|
|
|
</div>
|
|
|
- <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="sconfig.manufacturerName" v-bind:key="'...'">
|
|
|
+ <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="serverConfig.configData.manufacturerName">
|
|
|
</div>
|
|
|
<div class="input-group mb-3">
|
|
|
<div class="input-group-prepend">
|
|
|
<span class="input-group-text" id="inputGroup-sizing-default">Product Name</span>
|
|
|
</div>
|
|
|
- <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="sconfig.productName" v-bind:key="'...'">
|
|
|
+ <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="serverConfig.configData.productName">
|
|
|
</div>
|
|
|
<div class="input-group mb-3">
|
|
|
<div class="input-group-prepend">
|
|
|
<span class="input-group-text" id="inputGroup-sizing-default">Software Version</span>
|
|
|
</div>
|
|
|
- <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="sconfig.softwareVersion" v-bind:key="'...'">
|
|
|
+ <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="serverConfig.configData.softwareVersion">
|
|
|
</div>
|
|
|
<div class="input-group mb-3">
|
|
|
<div class="input-group-prepend">
|
|
|
<span class="input-group-text" id="inputGroup-sizing-default">Application Name</span>
|
|
|
</div>
|
|
|
- <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="sconfig.applicationName" v-bind:key="'...'">
|
|
|
+ <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="serverConfig.configData.applicationName">
|
|
|
</div>
|
|
|
<div class="input-group mb-3">
|
|
|
<div class="input-group-prepend">
|
|
|
<span class="input-group-text" id="inputGroup-sizing-default">Application Uri</span>
|
|
|
</div>
|
|
|
- <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="sconfig.applicationUri" v-bind:key="'...'">
|
|
|
+ <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="serverConfig.configData.applicationUri">
|
|
|
</div>
|
|
|
<div class="input-group mb-3">
|
|
|
<div class="input-group-prepend">
|
|
|
<span class="input-group-text" id="inputGroup-sizing-default">Product Uri</span>
|
|
|
</div>
|
|
|
- <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="sconfig.productUri" v-bind:key="'...'">
|
|
|
+ <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="serverConfig.configData.productUri">
|
|
|
</div>
|
|
|
<div class="input-group mb-3">
|
|
|
<div class="input-group-prepend">
|
|
|
<span class="input-group-text" id="inputGroup-sizing-default">Port</span>
|
|
|
</div>
|
|
|
- <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="sconfig.port" v-bind:key="4840">
|
|
|
+ <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="serverConfig.configData.port">
|
|
|
</div>
|
|
|
<div class="input-group mb-3">
|
|
|
<div class="input-group-prepend">
|
|
|
<span class="input-group-text" id="inputGroup-sizing-default">Max Connections Per Endpoint</span>
|
|
|
</div>
|
|
|
- <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="sconfig.maxConnections" v-bind:key="100">
|
|
|
+ <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="serverConfig.configData.maxConnections">
|
|
|
</div>
|
|
|
<div class="input-group mb-3">
|
|
|
<div class="input-group-prepend">
|
|
|
- <input type="checkbox" id="checkbox" v-model="sconfig.allowAnonymous" />
|
|
|
+ <input type="checkbox" id="checkbox" v-model="serverConfig.configData.allowAnonymous" />
|
|
|
<label for="checkbox"> Allow Anonymous</label>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
- <button @click="exportConf()"> Export</button>
|
|
|
<button @click="newServerConfigOpen = false" :disabled="newDialogDisabled">Close</button>
|
|
|
</v-dialog>
|
|
|
</template>
|