diff options
author | Matthias <ilovemilk@wusa.io> | 2020-04-11 12:57:03 +0300 |
---|---|---|
committer | Matthias <ilovemilk@wusa.io> | 2020-04-11 12:57:03 +0300 |
commit | 5e9cebdcad048e166f9392e3aefeea1529669bc0 (patch) | |
tree | 4ff37e522cba5762369b320f0919c115393f29a8 /src | |
parent | 133a820b88a78a4281e017d88d11bed169b5fdbf (diff) |
fix frontend and controller to work without services
Diffstat (limited to 'src')
-rw-r--r-- | src/components/FileOperationsTable.vue | 1 | ||||
-rw-r--r-- | src/components/ProtectionStatus.vue | 25 | ||||
-rw-r--r-- | src/components/ServiceStatus.vue | 92 | ||||
-rw-r--r-- | src/views/Protection.vue | 33 |
4 files changed, 7 insertions, 144 deletions
diff --git a/src/components/FileOperationsTable.vue b/src/components/FileOperationsTable.vue index c5cc5b4..a5f6715 100644 --- a/src/components/FileOperationsTable.vue +++ b/src/components/FileOperationsTable.vue @@ -16,6 +16,7 @@ import '@polymer/iron-icon/iron-icon.js'; import '@polymer/iron-icons/iron-icons.js'; import '../webcomponents/ransomware-icons' import 'time-elements/dist/time-elements'; +import moment from 'moment' export default { name: 'FileOperationsTable', diff --git a/src/components/ProtectionStatus.vue b/src/components/ProtectionStatus.vue index 62e4805..e60220e 100644 --- a/src/components/ProtectionStatus.vue +++ b/src/components/ProtectionStatus.vue @@ -19,11 +19,6 @@ import axios from 'nextcloud-axios' export default { name: 'ProtectionStatus', props: { - protectionLink: { - type: String, - default: '', - required: true - }, detectionLink: { type: String, default: '', @@ -31,32 +26,15 @@ export default { } }, created() { - this.fetchServicesStatus(); this.fetchDetectionStatus(); }, data() { return { detection: 0, - protection: 0 + protection: 1 }; }, methods: { - fetchServicesStatus() { - axios({ - method: 'GET', - url: this.protectionLink - }) - .then(json => { - this.protection = 1; - for (i = 0; i < json.data.length; i++) { - if (json.data[i].status == 0) { - this.protection = 0; - } - } - this.$emit('protection-state-changed'); - }) - .catch( error => { console.error(error); }); - }, fetchDetectionStatus() { axios({ method: 'GET', @@ -67,6 +45,7 @@ export default { if (json.data.length > 0) { this.detection = 1; } + this.$emit('protection-state-changed'); }) .catch( error => { console.error(error); }); } diff --git a/src/components/ServiceStatus.vue b/src/components/ServiceStatus.vue deleted file mode 100644 index 9c005b5..0000000 --- a/src/components/ServiceStatus.vue +++ /dev/null @@ -1,92 +0,0 @@ -<template> - <div> - <h2 class="container"> - <div class="item name">{{ serviceName }}</div> - <div v-if="serviceStatus" class="item status active">Active</div> - <div v-if="!serviceStatus" class="item status offline">Offline</div> - </h2> - <div v-if="!serviceStatus" class="description">{{description}}</div> - </div> -</template> - -<script> -import '@polymer/paper-card/paper-card.js'; -import '@polymer/paper-button/paper-button.js'; -import '@polymer/iron-icon/iron-icon.js'; -import '@polymer/iron-icons/iron-icons.js'; -import axios from 'nextcloud-axios' - -export default { - name: 'ServiceStatus', - props: { - link: { - type: String, - default: '', - required: true - }, - description: { - type: String, - default: '', - required: true - } - }, - data() { - return { - serviceName: "Not available.", - serviceStatus: 0 - }; - }, - created () { - this.fetchServiceName(); - this.fetchServiceStatus(); - }, - methods: { - fetchServiceName: function() { - axios({ - method: 'GET', - url: this.link - }) - .then(json => { - this.serviceName = json.data.name; - }) - .catch( error => { console.error(error); }); - }, - fetchServiceStatus() { - axios({ - method: 'GET', - url: this.link - }) - .then(json => { - this.serviceStatus = json.data.status; - this.$emit('service-state-changed'); - }) - .catch( error => { console.error(error); }); - } - } -} -</script> - -<style lang="scss" scoped> - .container { - display: flex; - width: 100%; - justify-content: space-between; - } - h2 { - margin: 0px; - } - .item { - padding: 5px 10px 5px 10px; - } - .description { - color: #9b9b9b; - padding: 0px 10px 0px 10px; - } - .active { - color: #18b977; - } - .offline { - color: #e2523d; - } - -</style>
\ No newline at end of file diff --git a/src/views/Protection.vue b/src/views/Protection.vue index 3ce0848..201919f 100644 --- a/src/views/Protection.vue +++ b/src/views/Protection.vue @@ -5,11 +5,7 @@ <paper-spinner active></paper-spinner> </div> <div> - <ProtectionStatus :detection-link="detectionUrl" :protection-link="servicesUrl" id="protection-status" v-on:protection-state-changed="protectionStateChanged"></ProtectionStatus> - <div id="services"> - <ServiceStatus :link="detectionServiceUrl" description="Your files currently cannot be analyzed for ransomware. To enable ransomware detection, contact your system administator." v-on:service-state-changed="detectionStateChanged" class="service"></ServiceStatus> - <ServiceStatus :link="monitorServiceUrl" description="There may be a problem with your Nextcloud installation. Please contact your system administator." v-on:service-state-changed="monitorStateChanged" class="service"></ServiceStatus> - </div> + <ProtectionStatus :detection-link="detectionUrl" id="protection-status" v-on:protection-state-changed="protectionStateChanged"></ProtectionStatus> </div> </iron-pages> </AppContent> @@ -20,51 +16,30 @@ import '@polymer/paper-spinner/paper-spinner.js'; import '@polymer/iron-pages/iron-pages.js'; import AppContent from 'nextcloud-vue/dist/Components/AppContent' import ProtectionStatus from '../components/ProtectionStatus' -import ServiceStatus from '../components/ServiceStatus' export default { name: 'Protection', components: { AppContent, - ProtectionStatus, - ServiceStatus + ProtectionStatus }, data() { return { protectionReady: false, - detectionReady: false, - monitorReady: false }; }, computed: { detectionUrl() { return OC.generateUrl('/apps/ransomware_detection/api/v1/detection'); - }, - servicesUrl() { - return OC.generateUrl('/apps/ransomware_detection/api/v1/service'); - }, - detectionServiceUrl() { - return OC.generateUrl('/apps/ransomware_detection/api/v1/service/0'); - }, - monitorServiceUrl() { - return OC.generateUrl('/apps/ransomware_detection/api/v1/service/1'); - } + } }, methods: { protectionStateChanged() { this.protectionReady = true; this.hideSpinner(); }, - monitorStateChanged() { - this.monitorReady = true; - this.hideSpinner(); - }, - detectionStateChanged() { - this.detectionReady = true; - this.hideSpinner(); - }, hideSpinner() { - if (this.protectionReady && this.monitorReady && this.detectionReady) { + if (this.protectionReady) { document.querySelector('iron-pages').selectIndex(1); } } |