diff options
author | 2020-06-03 10:06:52 +0200 | |
---|---|---|
committer | 2020-06-03 10:06:52 +0200 | |
commit | 7bb53c64da2dcf88894bfd31503accdd81498f3d (patch) | |
tree | 4310e12366818af27947b5e2c80cb162da93a4b5 /dashboard/src/views | |
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/views')
-rw-r--r-- | dashboard/src/views/Admin.vue | 52 | ||||
-rw-r--r-- | dashboard/src/views/Assignments.vue | 54 | ||||
-rw-r--r-- | dashboard/src/views/Auth.vue | 65 | ||||
-rw-r--r-- | dashboard/src/views/Error.vue | 8 | ||||
-rw-r--r-- | dashboard/src/views/Models.vue | 80 | ||||
-rw-r--r-- | dashboard/src/views/Pdps.vue | 53 | ||||
-rw-r--r-- | dashboard/src/views/Rules.vue | 50 |
7 files changed, 362 insertions, 0 deletions
diff --git a/dashboard/src/views/Admin.vue b/dashboard/src/views/Admin.vue new file mode 100644 index 00000000..414e68a0 --- /dev/null +++ b/dashboard/src/views/Admin.vue @@ -0,0 +1,52 @@ +<template> + <div> + <div v-if="isLoading" > + <div class="d-flex justify-content-center"> + <div class="spinner-border" role="status"> + <span class="sr-only">Loading...</span> + </div> + </div> + </div> + <div v-else class="row justify-content-center"> + <label for="file" class="label-file btn btn-primary"> + <span class="fa fa-upload"></span> + Import + </label> + <input + id="file" + class="input-file" + type="file" + @change="readFile" + accept="application/json, .json" + /> + + + </div> + </div> +</template> + +<script> +import ImportService from "./../services/Import.service.js"; + +export default { + data(){ + return { + isLoading: false + } + }, + methods: { + readFile(event) { + var reader = new FileReader(); + reader.onload = async function() { + this.isLoading = true; + var fileContents = reader.result; + await ImportService.importData(JSON.parse(fileContents)); + this.isLoading = false; + }.bind(this); + reader.readAsText(event.target.files[0]); + }, + } +}; +</script> + + diff --git a/dashboard/src/views/Assignments.vue b/dashboard/src/views/Assignments.vue new file mode 100644 index 00000000..d0e500e3 --- /dev/null +++ b/dashboard/src/views/Assignments.vue @@ -0,0 +1,54 @@ +<template> + <div> + <form-header + placeholder="Filter by Policy" + needButton + buttonText="Create Policy" + @click="creatingPolicy = true" + v-model="filter" + ></form-header> + <br/> + + <CreatePolicy v-if="creatingPolicy" @close="creatingPolicy = false"></CreatePolicy> + <div class="list-group row" v-else> + <policy v-for="policy in filteredPolicies" :key="policy.id" :policy="policy"></policy> + </div> + </div> +</template> + +<script> + import PolicyService from './../services/Policy.service.js' + //import util from './../services/Util.service.js' + import FormHeader from "./../components/FormHeader.vue" + import Policy from "./../components/assignment/Policy.vue" + import CreatePolicy from "./../components/policy/CreatePolicy.vue" + import util from "../services/Util.service"; + + export default { + data() { + return { + filter: "", + creatingPolicy: false, + policies: [] + }; + }, + mounted() { + PolicyService.initialize(); + this.policies = PolicyService.policies; + }, + components: { + FormHeader, + Policy, + CreatePolicy, + }, + computed: { + filteredPolicies() { + return util.filterAndSortByName(this.policies, this.filter); + } + } + } +</script> + +<style scoped> + +</style>
\ No newline at end of file diff --git a/dashboard/src/views/Auth.vue b/dashboard/src/views/Auth.vue new file mode 100644 index 00000000..c057e284 --- /dev/null +++ b/dashboard/src/views/Auth.vue @@ -0,0 +1,65 @@ +<template> + <div class="row justify-content-center"> + <form> + <div class="form-group"> + <label for="login">Login</label> + <input + type="text" + name="login" + v-model="name" + v-validate.initial="'required'" + class="form-control" + id="login" + /> + </div> + <div class="form-group"> + <label for="password">Password</label> + <input + type="password" + name="password" + v-model="password" + v-validate.initial="'required'" + class="form-control" + id="password" + /> + </div> + <button type="button" class="btn btn-primary btn-xlg col-auto" @click="login()">Login</button> + </form> + + </div> +</template> + +<script> +import Vue from "vue"; +import util from "./../services/Util.service.js"; +import config from '../config.js' + +var host = config.host; + +export default { + name: "auth", + data() { + return { + name: "", + password: "" + }; + }, + methods: { + login() { + Vue.http.headers.common["Authorization"] = + "Basic " + btoa(this.name + ":" + this.password); + Vue.http.get(host + "/auth").then( + response => { + Vue.http.headers.common["Authorization"] = "Basic "; + Vue.http.headers.common["x-api-key"] = response.data; + localStorage.setItem("auth-key", response.data); + this.$router.push("models"); + }, + response => { + util.displayError("Unable to log in " + response); + } + ); + } + } +}; +</script> diff --git a/dashboard/src/views/Error.vue b/dashboard/src/views/Error.vue new file mode 100644 index 00000000..528fb8aa --- /dev/null +++ b/dashboard/src/views/Error.vue @@ -0,0 +1,8 @@ +<template> + <div class="row justify-content-center"> + /!\ Error please configure CORS on server + </div> +</template> + + + diff --git a/dashboard/src/views/Models.vue b/dashboard/src/views/Models.vue new file mode 100644 index 00000000..bdd46483 --- /dev/null +++ b/dashboard/src/views/Models.vue @@ -0,0 +1,80 @@ +<template> + <div> + <orphans + @close="allowAlert = false" + v-if="showAlert" + :orphanMetaRules="orphanMetaRules" + :orphanSubjectCategories="orphanSubjectCategories" + :orphanObjectCategories="orphanObjectCategories" + :orphanActionCategories="orphanActionCategories" + ></orphans> + + <br /> + <form-header + placeholder="Filter" + buttonText="Create Model" + @click="creatingModel = true" + v-model="filter" + need-button + ></form-header> + <br /> + + <CreateModel v-if="creatingModel" @close="creatingModel = false"></CreateModel> + <div class="list-group row" v-else> + <Model v-for="model in filteredModels" :key="model.id" :model="model"></Model> + </div> + </div> +</template> + +<script> +import Model from "./../components/model/Model.vue"; +import CreateModel from "./../components/model/CreateModel.vue"; +import ModelService from "./../services/Model.service.js"; +import util from "./../services/Util.service.js"; +import Orphans from "./../components/model/Orphans.vue"; +import FormHeader from "./../components/FormHeader.vue"; + +export default { + name: "models", + components: { + Model, + CreateModel, + FormHeader, + Orphans + }, + mounted() { + ModelService.initialize(); + this.models = ModelService.models; + this.orphanMetaRules = ModelService.orphanMetaRules; + this.orphanSubjectCategories = ModelService.orphanSubjectCategories; + this.orphanObjectCategories = ModelService.orphanObjectCategories; + this.orphanActionCategories = ModelService.orphanActionCategories; + }, + data() { + return { + filter: "", + creatingModel: false, + allowAlert: true, + orphanMetaRules: [], + orphanSubjectCategories: [], + orphanActionCategories: [], + orphanObjectCategories: [], + models: [] + }; + }, + computed: { + showAlert() { + return ( + this.allowAlert && + (this.orphanMetaRules.length || + this.orphanSubjectCategories.length || + this.orphanActionCategories.length || + this.orphanObjectCategories.length) + ); + }, + filteredModels() { + return util.filterAndSortByName(this.models, this.filter); + } + } +}; +</script> diff --git a/dashboard/src/views/Pdps.vue b/dashboard/src/views/Pdps.vue new file mode 100644 index 00000000..778f23fe --- /dev/null +++ b/dashboard/src/views/Pdps.vue @@ -0,0 +1,53 @@ +<template> + <div> + <form-header + placeholder="Filter" + buttonText="Create PDP" + @click="creatingPdp = true" + v-model="filter" + need-button + ></form-header> + <br /> + + <CreatePdp v-if="creatingPdp" @close="creatingPdp = false"></CreatePdp> + <div class="list-group row" v-else> + <pdp v-for="pdp in filteredPdps" :key="pdp.id" :pdp="pdp"></pdp> + </div> + </div> +</template> + +<script> +import PdpService from "./../services/Pdp.service.js"; +import util from "./../services/Util.service.js"; +import Pdp from "./../components/pdp/Pdp.vue"; +import CreatePdp from "./../components/pdp/CreatePdp.vue"; +import FormHeader from "./../components/FormHeader.vue"; +import PolicyService from "../services/Policy.service"; + +export default { + data() { + return { + filter: "", + creatingPdp: false, + pdps: [] + }; + }, + mounted() { + PdpService.initialize(); + PolicyService.initialize(); + this.pdps = PdpService.pdps; + }, + components: { + Pdp, + CreatePdp, + FormHeader + }, + computed: { + filteredPdps() { + return util.filterAndSortByName(this.pdps, this.filter); + } + } +}; +</script> + + diff --git a/dashboard/src/views/Rules.vue b/dashboard/src/views/Rules.vue new file mode 100644 index 00000000..042b00c0 --- /dev/null +++ b/dashboard/src/views/Rules.vue @@ -0,0 +1,50 @@ +<template> + <div> + <form-header + placeholder="Filter by Policy" + needButton + buttonText="Create Policy" + @click="creatingPolicy = true" + v-model="filter" + ></form-header> + <br/> + + <CreatePolicy v-if="creatingPolicy" @close="creatingPolicy = false"></CreatePolicy> + <div class="list-group row" v-else> + <policy v-for="policy in filteredPolicies" :key="policy.id" :policy="policy"></policy> + </div> + </div> +</template> + +<script> +import PolicyService from './../services/Policy.service.js' +//import util from './../services/Util.service.js' +import FormHeader from "./../components/FormHeader.vue" +import Policy from "./../components/policy/Policy.vue" +import CreatePolicy from "./../components/policy/CreatePolicy.vue" +import util from "../services/Util.service"; + +export default { + data() { + return { + filter: "", + creatingPolicy: false, + policies: [] + }; + }, + mounted() { + PolicyService.initialize(); + this.policies = PolicyService.policies; + }, + components: { + FormHeader, + Policy, + CreatePolicy, + }, + computed: { + filteredPolicies() { + return util.filterAndSortByName(this.policies, this.filter); + } + } +} +</script> |