Blame view

api/dashboard/src/components/CeptdCard.vue 1.63 KB
0d8c0f816   Thanasis Naskos   initial commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
  <template>
    <b-card bg-variant="light">
      <template v-slot:header>
        <b-row>
          <b-col class="text-left">
            <h5>CEPTD</h5>
          </b-col>
          <b-col class="text-right">
            <b-card-text>Status: Running</b-card-text>
          </b-col>
        </b-row>
      </template>
      <capec-list />
    </b-card>
  </template>
  
  <script>
  import axios from 'axios'
  import CapecList from './CapecList'
  
  export default {
    name: 'CeptdCard',
    components: {
      CapecList
    },
    data () {
      return {
        file: null,
        fields: [
          { key: 'process_id', label: 'Process' },
          { key: 'created_at', label: 'Running for' },
          { key: 'actions', label: 'Actions' }
        ],
        analyzePid: '',
        items: []
      }
    },
    created () {
      this.status()
    },
    methods: {
      async start () {
        try {
          await axios.get('/v1/od/start')
          this.status()
          this.$toasted.success('OD instance started!')
        } catch (e) {
          this.$toasted.error('There was an error!')
        }
      },
      async status () {
        try {
          const { data } = await axios.get('/v1/od/status')
          this.items = data
        } catch (e) {
          this.$toasted.error('There was an error while fetching running OD instances!')
        }
      },
      async showPcapModal (pid) {
        this.analyzePid = pid
        this.$refs['pcap-modal'].show()
      },
      async stop (pid) {
        try {
          await axios.get('/v1/od/stop/' + pid)
          this.status()
          this.$toasted.success('OD instance stopped!')
        } catch (e) {
          this.$toasted.error('There was an error!')
        }
      }
    }
  }
  </script>
  
  <style scoped>
  
  </style>