|
| 1 | +<template> |
| 2 | + <b-card no-body :header="header"> |
| 3 | + <b-card-body> |
| 4 | + <c-switch id="enabled" color="primary" v-model="enabled" label v-bind="labelIcon" />{{$t('admin.integration_defectdojo_enable')}} |
| 5 | + <b-validated-input-group-form-input |
| 6 | + id="defectdojo-cadence" |
| 7 | + :label="$t('admin.synchronization_cadence_minutes')" |
| 8 | + input-group-size="mb-3" |
| 9 | + rules="required" |
| 10 | + type="number" |
| 11 | + v-model="cadence" |
| 12 | + lazy="true" |
| 13 | + /> |
| 14 | + <p class="text-muted">{{ $t('admin.synchronization_cadence_restart_required') }}</p> |
| 15 | + <b-validated-input-group-form-input |
| 16 | + id="defectdojo-url" |
| 17 | + :label="$t('admin.url')" |
| 18 | + input-group-size="mb-3" |
| 19 | + rules="required" |
| 20 | + type="url" |
| 21 | + v-model="url" |
| 22 | + lazy="true" |
| 23 | + /> |
| 24 | + <b-validated-input-group-form-input |
| 25 | + id="defectdojo-apiKey" |
| 26 | + :label="$t('admin.api_token')" |
| 27 | + input-group-size="mb-3" |
| 28 | + rules="required" |
| 29 | + type="password" |
| 30 | + v-model="apiKey" |
| 31 | + lazy="true" |
| 32 | + /> |
| 33 | + </b-card-body> |
| 34 | + <b-card-footer> |
| 35 | + <b-button variant="outline-primary" class="px-4" @click="saveChanges">{{ $t('message.update') }}</b-button> |
| 36 | + </b-card-footer> |
| 37 | + </b-card> |
| 38 | +</template> |
| 39 | + |
| 40 | +<script> |
| 41 | + import { Switch as cSwitch } from '@coreui/vue'; |
| 42 | + import BValidatedInputGroupFormInput from '../../../forms/BValidatedInputGroupFormInput'; |
| 43 | + import common from "../../../shared/common"; |
| 44 | + import configPropertyMixin from "../mixins/configPropertyMixin"; |
| 45 | +
|
| 46 | + export default { |
| 47 | + mixins: [configPropertyMixin], |
| 48 | + props: { |
| 49 | + header: String |
| 50 | + }, |
| 51 | + components: { |
| 52 | + cSwitch, |
| 53 | + BValidatedInputGroupFormInput |
| 54 | + }, |
| 55 | + data() { |
| 56 | + return { |
| 57 | + enabled: false, |
| 58 | + cadence: '60', |
| 59 | + url: '', |
| 60 | + apiKey: '', |
| 61 | + labelIcon: { |
| 62 | + dataOn: '\u2713', |
| 63 | + dataOff: '\u2715' |
| 64 | + }, |
| 65 | + } |
| 66 | + }, |
| 67 | + methods: { |
| 68 | + saveChanges: function() { |
| 69 | + this.updateConfigProperties([ |
| 70 | + {groupName: 'integrations', propertyName: 'defectdojo.enabled', propertyValue: this.enabled}, |
| 71 | + {groupName: 'integrations', propertyName: 'defectdojo.sync.cadence', propertyValue: this.cadence}, |
| 72 | + {groupName: 'integrations', propertyName: 'defectdojo.url', propertyValue: this.url}, |
| 73 | + {groupName: 'integrations', propertyName: 'defectdojo.apiKey', propertyValue: this.apiKey}, |
| 74 | + ]); |
| 75 | + } |
| 76 | + }, |
| 77 | + created () { |
| 78 | + this.axios.get(this.configUrl).then((response) => { |
| 79 | + let configItems = response.data.filter(function (item) { return item.groupName === "integrations" }); |
| 80 | + for (let i=0; i<configItems.length; i++) { |
| 81 | + let item = configItems[i]; |
| 82 | + switch (item.propertyName) { |
| 83 | + case "defectdojo.enabled": |
| 84 | + this.enabled = common.toBoolean(item.propertyValue); break; |
| 85 | + case "defectdojo.sync.cadence": |
| 86 | + this.cadence = item.propertyValue; break; |
| 87 | + case "defectdojo.url": |
| 88 | + this.url = item.propertyValue; break; |
| 89 | + case "defectdojo.apiKey": |
| 90 | + this.apiKey = item.propertyValue; break; |
| 91 | + } |
| 92 | + } |
| 93 | + }); |
| 94 | + } |
| 95 | + } |
| 96 | +</script> |
0 commit comments