-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
server-demo: Add ObjLink write support.
- Loading branch information
1 parent
99ea91f
commit 3cb4007
Showing
3 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
leshan-server-demo/webapp/src/components/values/input/ObjLinkValueInput.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<!----------------------------------------------------------------------------- | ||
* Copyright (c) 2021 Sierra Wireless and others. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* and Eclipse Distribution License v1.0 which accompany this distribution. | ||
* | ||
* The Eclipse Public License is available at | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
* and the Eclipse Distribution License is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.html. | ||
-----------------------------------------------------------------------------> | ||
<template> | ||
<v-row> | ||
<v-col> | ||
<v-text-field | ||
single-line | ||
label="Object Id" | ||
:rules="[(v) => !v || isValidId(v) || 'Invalid object id']" | ||
:value="objectId" | ||
@input="$emit('input', objectIdChanged($event))" | ||
clearable | ||
/> | ||
</v-col> | ||
<v-col> | ||
<v-text-field | ||
single-line | ||
label="Object Instance Id" | ||
:rules="[(v) => !v || isValidId(v) || 'Invalid object instance id']" | ||
:value="objectInstanceId" | ||
@input="$emit('input', objectInstanceIdChanged($event))" | ||
clearable | ||
/> | ||
</v-col> | ||
</v-row> | ||
</template> | ||
<script> | ||
import { isInteger } from "../../../js/utils.js"; | ||
|
||
/** | ||
* An input for OBJLNK single value LWM2M node ("Single Instance Resource" or "Resource Instance") | ||
*/ | ||
export default { | ||
props: { | ||
value: null, // the input value for this LWM2M Node (v-model) | ||
resourcedef: Object, // the model of the resource | ||
}, | ||
data() { | ||
return { | ||
objectId: "", | ||
objectInstanceId: "", | ||
}; | ||
}, | ||
watch: { | ||
value(v) { | ||
this.objectId = v.objectId; | ||
this.objectInstanceId = v.objectInstanceId; | ||
}, | ||
}, | ||
|
||
methods: { | ||
convertToNumber(v){ | ||
if (isInteger(v)){ | ||
return Number(v) | ||
}else{ | ||
return v; | ||
} | ||
}, | ||
isValidId(v) { | ||
return isInteger(v); | ||
}, | ||
objectIdChanged(v) { | ||
if (v === "" && this.objectInstanceId === "") { | ||
return null; | ||
} else { | ||
return { | ||
objectId: this.convertToNumber(v), | ||
objectInstanceId: this.objectInstanceId, | ||
}; | ||
} | ||
}, | ||
objectInstanceIdChanged(v) { | ||
if (this.objectId === "" && v === "") { | ||
return null; | ||
} else { | ||
return { | ||
objectId: this.objectId, | ||
objectInstanceId: this.convertToNumber(v) | ||
}; | ||
} | ||
}, | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters