|
@@ -6,19 +6,14 @@ import { useStore } from '@/store'
|
|
|
import { ref } from 'vue';
|
|
|
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 '@/ServerConfig';
|
|
|
+import { ServerConfig, type IMappingEntry } from '@/ServerConfig';
|
|
|
|
|
|
const store = useStore()
|
|
|
const newProjectOpen = ref(false);
|
|
|
const newProjectDisabled = ref(false); //Disables buttons while loading project
|
|
|
const serverConfigOpen = ref(false);
|
|
|
const projectType = ref("ua");
|
|
|
-const { serverConfig } = storeToRefs(store)
|
|
|
-
|
|
|
|
|
|
async function exportProject() {
|
|
|
const zip = new JSZip();
|
|
@@ -28,10 +23,9 @@ async function exportProject() {
|
|
|
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)
|
|
|
+ store.config.nodesets = fileNames;
|
|
|
+ store.config.mapping= [...as.mapping.values()]
|
|
|
+ zip.file("project.json", JSON.stringify(store.config));
|
|
|
const blob =await zip.generateAsync({type:'blob'});
|
|
|
downloadBlob(blob, "project.zip");
|
|
|
}
|
|
@@ -88,16 +82,15 @@ async function loadZip(file: File){
|
|
|
const config=ServerConfig.load(JSON.parse(await zip.files["project.json"].async("string")));
|
|
|
|
|
|
const as=new AddressSpace([]);
|
|
|
- for(const fileName of config.configData.nodesets||[]) {
|
|
|
+ for(const fileName of config.nodesets||[]) {
|
|
|
as.addNodeset(UANodeSet.parse(await zip.files[fileName].async("string"), fileName, as));
|
|
|
}
|
|
|
- const mlist=YAML.parse(await zip.files['mapping.yaml'].async("string")) as IMappingValue[];
|
|
|
- const mapping=new Map<string, IMappingValue>();
|
|
|
- for(const entry of mlist) {
|
|
|
+ const mapping=new Map<string, IMappingEntry>();
|
|
|
+ for(const entry of config.mapping) {
|
|
|
mapping.set(entry.path, entry);
|
|
|
}
|
|
|
as.mapping=mapping;
|
|
|
- store.serverConfig=config;
|
|
|
+ store.config=config;
|
|
|
store.setAddressSpace(as);
|
|
|
}
|
|
|
</script>
|
|
@@ -168,46 +161,46 @@ async function loadZip(file: File){
|
|
|
<v-dialog :open="serverConfigOpen" @cancel="serverConfigOpen = false">
|
|
|
<h5>Server Configuration</h5>
|
|
|
<p></p>
|
|
|
- <div v-if="serverConfig">
|
|
|
+ <div v-if="store.config">
|
|
|
<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="serverConfig.configData.manufacturerName">
|
|
|
+ <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="store.config.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="serverConfig.configData.productName">
|
|
|
+ <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="store.config.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="serverConfig.configData.softwareVersion">
|
|
|
+ <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="store.config.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="serverConfig.configData.applicationName">
|
|
|
+ <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="store.config.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="serverConfig.configData.applicationUri">
|
|
|
+ <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="store.config.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="serverConfig.configData.productUri">
|
|
|
+ <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="store.config.productUri">
|
|
|
</div>
|
|
|
<div class="input-group mb-3">
|
|
|
<div class="input-group-prepend form-check">
|
|
|
- <input class="form-check-input" type="checkbox" id="checkAllowAnon" v-model="serverConfig.configData.allowAnonymous" />
|
|
|
+ <input class="form-check-input" type="checkbox" id="checkAllowAnon" v-model="store.config.allowAnonymous" />
|
|
|
<label class="form-check-label" for="checkAllowAnon">Allow Anonymous</label>
|
|
|
</div>
|
|
|
</div>
|