diff options
author | Thomas Duval <thomas.duval@orange.com> | 2020-06-03 10:06:52 +0200 |
---|---|---|
committer | Thomas Duval <thomas.duval@orange.com> | 2020-06-03 10:06:52 +0200 |
commit | 7bb53c64da2dcf88894bfd31503accdd81498f3d (patch) | |
tree | 4310e12366818af27947b5e2c80cb162da93a4b5 /dashboard/src/components/pdp/AddPolicy.vue | |
parent | cbea4e360e9bfaa9698cf7c61c83c96a1ba89b8c (diff) |
Update to new version 5.4HEADstable/jermamaster
Signed-off-by: Thomas Duval <thomas.duval@orange.com>
Change-Id: Idcd868133d75928a1ffd74d749ce98503e0555ea
Diffstat (limited to 'dashboard/src/components/pdp/AddPolicy.vue')
-rw-r--r-- | dashboard/src/components/pdp/AddPolicy.vue | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/dashboard/src/components/pdp/AddPolicy.vue b/dashboard/src/components/pdp/AddPolicy.vue new file mode 100644 index 00000000..82ad07e2 --- /dev/null +++ b/dashboard/src/components/pdp/AddPolicy.vue @@ -0,0 +1,64 @@ +<template> + <div> + <hr> + <h4>Select policy:</h4> + <form data-vv-scope="select"> + <div class="form-group"> + <select v-model="selectedPolicyId" v-validate.initial="'required'"> + <option disabled value>Please select one</option> + <option + v-for="policy in policies" + :value="policy.id" + :key="policy.id" + >{{policy.name}}</option> + </select> + </div> + <button type="button" class="btn btn-secondary" @click="close()">Cancel</button> + <span> </span> + <button + type="button" + :disabled="errors.any('select')" + class="btn btn-primary" + @click="addPolicy()" + >Add</button> + </form> + <br> + <br> + </div> +</template> + +<script> +import PdpService from "./../../services/Pdp.service.js"; +import util from "./../../services/Util.service.js"; + +export default { + name: "addPolicy", + data: function() { + return { + selectedPolicyId: null, + }; + }, + props: { + pdp: Object + }, + methods: { + addPolicy() { + var policy = PdpService.getPolicy(this.selectedPolicyId); + var pdpCopy = util.clone(this.pdp); + pdpCopy.security_pipeline.push(policy); + PdpService.updatePdp(pdpCopy); + this.close(); + }, + close() { + this.$emit("close"); + } + }, + computed: { + policies() { + return PdpService.policies.filter( + el => !this.pdp.security_pipeline.includes(el) + ); + } + } +}; +</script> |