Upgraded to API v2
This commit is contained in:
parent
6b9d83f26a
commit
a0cd7fc39a
1 changed files with 38 additions and 21 deletions
|
|
@ -101,8 +101,8 @@
|
|||
<hr />
|
||||
|
||||
<ul uk-accordion="multiple: true; animation: false">
|
||||
<!--Show stack and scan if default plugin is enabled-->
|
||||
<li v-if="this.$store.state.apiState.plugin.includes('default_scan')">
|
||||
<!--Show stack and scan if scan plugin is enabled-->
|
||||
<li v-if="scanUri">
|
||||
<a class="uk-accordion-title" href="#">Stack and Scan</a>
|
||||
<div class="uk-accordion-content">
|
||||
<div class="uk-margin">
|
||||
|
|
@ -234,7 +234,7 @@
|
|||
|
||||
<taskSubmitter
|
||||
v-if="scanCapture"
|
||||
:submit-url="scanApiUri"
|
||||
:submit-url="scanUri"
|
||||
:submit-data="scanPayload"
|
||||
:submit-label="'Start Scan'"
|
||||
@submit="onScanSubmit"
|
||||
|
|
@ -296,7 +296,8 @@ export default {
|
|||
tags: [],
|
||||
metadata: {
|
||||
Client: `${process.env.PACKAGE.name}.${process.env.PACKAGE.version}`
|
||||
}
|
||||
},
|
||||
scanUri: null
|
||||
};
|
||||
},
|
||||
|
||||
|
|
@ -306,11 +307,15 @@ export default {
|
|||
"uk-disabled": !this.resizeCapture
|
||||
};
|
||||
},
|
||||
captureApiUri: function() {
|
||||
return this.$store.getters.uri + "/camera/capture";
|
||||
captureActionUri: function() {
|
||||
return `http://${this.$store.state.host}:${
|
||||
this.$store.state.port
|
||||
}/api/v2/actions/camera/capture`;
|
||||
},
|
||||
scanApiUri: function() {
|
||||
return this.$store.getters.uri + "/plugin/default/scan/tile";
|
||||
pluginsUri: function() {
|
||||
return `http://${this.$store.state.host}:${
|
||||
this.$store.state.port
|
||||
}/api/v2/plugins`;
|
||||
},
|
||||
basePayload: function() {
|
||||
var payload = {};
|
||||
|
|
@ -373,25 +378,17 @@ export default {
|
|||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.updateScanUri();
|
||||
},
|
||||
|
||||
methods: {
|
||||
handleCapture: function() {
|
||||
var payload = this.basePayload;
|
||||
|
||||
// Do capture
|
||||
this.newCaptureRequest(payload);
|
||||
},
|
||||
|
||||
handleScan: function() {
|
||||
var payload = this.scanPayload;
|
||||
|
||||
// Do capture
|
||||
this.newScanRequest(payload);
|
||||
},
|
||||
|
||||
newCaptureRequest: function(params) {
|
||||
// Send move request
|
||||
axios
|
||||
.post(this.captureApiUri, params)
|
||||
.post(this.captureActionUri, payload)
|
||||
.then(() => {
|
||||
// Flash the stream (capture animation)
|
||||
this.$root.$emit("globalFlashStream");
|
||||
|
|
@ -403,6 +400,26 @@ export default {
|
|||
});
|
||||
},
|
||||
|
||||
updateScanUri: function() {
|
||||
axios
|
||||
.get(this.pluginsUri) // Get a list of plugins
|
||||
.then(response => {
|
||||
var plugins = response.data;
|
||||
// if ScanPlugin is enabled
|
||||
if ("ScanPlugin" in plugins) {
|
||||
// Get plugin action link
|
||||
var link = plugins.ScanPlugin.views.tile.links.self;
|
||||
// Store plugin action URI
|
||||
this.scanUri = `http://${this.$store.state.host}:${
|
||||
this.$store.state.port
|
||||
}${link}`;
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
this.modalError(error); // Let mixin handle error
|
||||
});
|
||||
},
|
||||
|
||||
onScanSubmit: function() {},
|
||||
|
||||
onScanResponse: function(responseData) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue