Skip to content

Commit

Permalink
GH-1538:Add Active Cancel Observation support in server-demo UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernard31 committed Nov 30, 2023
1 parent 2f8cca4 commit fbd9d32
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@
<request-button @on-click="observe" title="Composite Observe"
>Obs</request-button
>
<request-button @on-click="stopObserve" title="Passive Cancel Obverse">
<request-button
@on-click="stopPassiveObserve"
title="Passive Cancel Obverse"
>
<v-icon dense small>{{ $icons.mdiEyeOffOutline }}</v-icon></request-button
>
<request-button @on-click="stopActiveObserve" title="Active Cancel Obverse">
<v-icon dense small>{{
$icons.mdiEyeRemoveOutline
}}</v-icon></request-button
Expand Down Expand Up @@ -145,7 +151,7 @@ export default {
requestButton.resetState();
});
},
stopObserve(requestButton) {
stopPassiveObserve(requestButton) {
this.axios
.delete(
`${this.requestPath()}/observe?paths=${this.compositeObject.paths.join(
Expand All @@ -154,7 +160,6 @@ export default {
)
.then(() => {
requestButton.changeState("success");
this.$store.setObserved(this.endpoint, this.path, false);
this.$store.setCompositeObjectObserved(
this.endpoint,
this.compositeObject,
Expand All @@ -165,6 +170,28 @@ export default {
requestButton.resetState();
});
},
stopActiveObserve(requestButton) {
this.axios
.delete(
`${this.requestPath()}/observe?paths=${this.compositeObject.paths.join(
","
)}&active&timeout=${timeout.get()}`
)
.then((response) => {
this.updateState(response.data, requestButton);
if (response.data.success) {
this.$store.newNodes(this.endpoint, response.data.content);
this.$store.setCompositeObjectObserved(
this.endpoint,
this.compositeObject,
false
);
}
})
.catch(() => {
requestButton.resetState();
});
},
openWriteDialog() {
this.dialog = true;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@
>Obs</request-button
>
<request-button
@on-click="stopObserve"
@on-click="stopPassiveObserve"
:title="'Passive Cancel Obverse ' + path"
>
<v-icon dense small>{{ $icons.mdiEyeOffOutline }}</v-icon></request-button
>
<request-button
@on-click="stopActiveObserve"
:title="'Active Cancel Obverse ' + path"
>
<v-icon dense small>{{
$icons.mdiEyeRemoveOutline
Expand Down Expand Up @@ -125,9 +131,9 @@ export default {
requestButton.resetState();
});
},
stopObserve(requestButton) {
stopPassiveObserve(requestButton) {
this.axios
.delete(`${this.requestPath()}/observe`)
.delete(this.requestPath() + "/observe")
.then(() => {
requestButton.changeState("success");
this.$store.setObserved(this.endpoint, this.path, false);
Expand All @@ -136,6 +142,24 @@ export default {
requestButton.resetState();
});
},
stopActiveObserve(requestButton) {
this.axios
.delete(this.requestPath() + `/observe?active&timeout=${timeout.get()}`)
.then((response) => {
this.updateState(response.data, requestButton);
if (response.data.success) {
this.$store.newInstanceValue(
this.endpoint,
this.path,
response.data.content.resources
);
this.$store.setObserved(this.endpoint, this.path, false);
}
})
.catch(() => {
requestButton.resetState();
});
},
openWriteDialog() {
this.dialog = true;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@
>Obs</request-button
>
<request-button
@on-click="stopObserve"
@on-click="stopPassiveObserve"
v-if="readable"
:title="'Passive Cancel Obverse ' + path"
>
<v-icon dense small>{{ $icons.mdiEyeOffOutline }}</v-icon></request-button
>
<request-button
@on-click="stopActiveObserve"
v-if="readable"
:title="'Active Cancel Obverse ' + path"
>
<v-icon dense small>{{
$icons.mdiEyeRemoveOutline
Expand Down Expand Up @@ -152,7 +159,7 @@ export default {
requestButton.resetState();
});
},
stopObserve(requestButton) {
stopPassiveObserve(requestButton) {
this.axios
.delete(this.requestPath() + "/observe")
.then(() => {
Expand All @@ -163,6 +170,24 @@ export default {
requestButton.resetState();
});
},
stopActiveObserve(requestButton) {
this.axios
.delete(this.requestPath() + `/observe?active&timeout=${timeout.get()}`)
.then((response) => {
this.updateState(response.data, requestButton);
if (response.data.success) {
this.$store.newResourceValue(
this.endpoint,
this.path,
response.data.content
);
this.$store.setObserved(this.endpoint, this.path, false);
}
})
.catch(() => {
requestButton.resetState();
});
},
openWriteDialog() {
this.dialog = true;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@
>Obs</request-button
>
<request-button
@on-click="stopObserve"
@on-click="stopPassiveObserve"
v-if="readable"
:title="'Passive Cancel Obverse ' + path"
>
<v-icon dense small>{{ $icons.mdiEyeOffOutline }}</v-icon></request-button
>
<request-button
@on-click="stopActiveObserve"
v-if="readable"
:title="'Active Cancel Obverse ' + path"
>
<v-icon dense small>{{
$icons.mdiEyeRemoveOutline
Expand Down Expand Up @@ -141,7 +148,7 @@ export default {
requestButton.resetState();
});
},
stopObserve(requestButton) {
stopPassiveObserve(requestButton) {
this.axios
.delete(this.requestPath() + "/observe")
.then(() => {
Expand All @@ -152,6 +159,25 @@ export default {
requestButton.resetState();
});
},
stopActiveObserve(requestButton) {
this.axios
.delete(this.requestPath() + `/observe?active&timeout=${timeout.get()}`)
.then((response) => {
this.updateState(response.data, requestButton);
if (response.data.success) {
this.$store.newResourceInstanceValue(
this.endpoint,
this.resourcePath,
this.instanceId,
response.data.content.value
);
this.$store.setObserved(this.endpoint, this.path, false);
}
})
.catch(() => {
requestButton.resetState();
});
},
openWriteDialog() {
this.dialog = true;
},
Expand Down
2 changes: 2 additions & 0 deletions leshan-server-demo/webapp/src/plugins/icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
mdiDevices,
mdiDownload,
mdiExitRun,
mdiEyeOffOutline,
mdiEyeOutline,
mdiEyeRemoveOutline,
mdiFormatListCheckbox,
Expand Down Expand Up @@ -66,6 +67,7 @@ const _icons = {
mdiDevices,
mdiDownload,
mdiExitRun,
mdiEyeOffOutline,
mdiEyeOutline,
mdiEyeRemoveOutline,
mdiFormatListCheckbox,
Expand Down

0 comments on commit fbd9d32

Please sign in to comment.