diff --git a/ui/src/components/common/AuthorizationForPeriodDatagroups.vue b/ui/src/components/common/AuthorizationForPeriodDatagroups.vue index 5408b8d19103ead1cff3103624670753e0da71f9..79b6f948d5a9f5cc6a0b806de5ea4f58bb4ab51a 100644 --- a/ui/src/components/common/AuthorizationForPeriodDatagroups.vue +++ b/ui/src/components/common/AuthorizationForPeriodDatagroups.vue @@ -2,36 +2,35 @@ <span> <b-tooltip position="is-right" multilined> <b-button - v-if="(column.withDataGroups && dataGroups.length > 1) || column.withPeriods" - class="show-check-details" - :type="state.state !== 1 ? 'is-grey ' : 'is-primary '" - @click="showDetail" - style="border: none; background-color: transparent; margin: 0px" - ><b-icon - :type="disabled?'is-warning-light':'is-primary'" + v-if="(column.withDataGroups && dataGroups.length > 1) || column.withPeriods" + class="show-check-details" + :type="state.state !== 1 ? 'is-grey ' : 'is-primary '" + @click="showDetail" + style="border: none; background-color: transparent; margin: 0px" + ><b-icon + :type="disabled ? 'is-warning-light' : 'is-primary'" v-if="(column.withDataGroups && dataGroups.length > 1) || column.withPeriods" icon="eye" size="fa-4x" - ></b-icon + ></b-icon ></b-button> <template v-slot:content> - <div v-if="disabled" - class="has-background-warning-light has-text-black-bis"> - {{ $t('validation.noRightsForThisOPeration') }} - </div> + <div v-if="disabled" class="has-background-warning-light has-text-black-bis"> + {{ $t("validation.noRightsForThisOPeration") }} + </div> <div - v-else-if="state.state === 1" - class="has-background-primary show-detail-for-selected" - style="height: 175px" + v-else-if="state.state === 1" + class="has-background-primary show-detail-for-selected" + style="height: 175px" > {{ $t("dataTypeAuthorizations.info-limit-taginput") }} <b v-if="column.withPeriods">{{ $t("dataTypeAuthorizations.a-period") }}</b> <span v-if="(column.withDataGroups && dataGroups.length > 1) || column.withPeriods" - >{{ $t("dataTypeAuthorizations.or") }} + >{{ $t("dataTypeAuthorizations.or") }} </span> <b v-if="column.withDataGroups && dataGroups.length > 1">{{ - $t("dataTypeAuthorizations.a-datagroup") - }}</b> + $t("dataTypeAuthorizations.a-datagroup") + }}</b> <div> <h3> {{ $t("dataTypesRepository.table-file-data-period") }} {{ $t("ponctuation.colon") }} @@ -64,11 +63,11 @@ </template> </b-tooltip> <b-modal - v-if="currentAuthorization" - v-model="showModal" - class="modalCardRef" - has-modal-card - trap-focus + v-if="currentAuthorization" + v-model="showModal" + class="modalCardRef" + has-modal-card + trap-focus > <div class="card"> <header class="card-header"> @@ -78,69 +77,69 @@ </header> <div class="card-content"> <b-field - v-if="column.withDataGroups" - :label="$t('dataTypeAuthorizations.label-tagInput')" - label-position="on-border" + v-if="column.withDataGroups" + :label="$t('dataTypeAuthorizations.label-tagInput')" + label-position="on-border" > <b-taginput - v-model="currentAuthorization.authorizations.dataGroups" - :data="dataGroups" - :open-on-focus="true" - :placeholder="$t('dataTypeAuthorizations.data-groups-placeholder')" - :value="dataGroups.id" - autocomplete - class="column" - field="label" - type="is-primary" + v-model="currentAuthorization.authorizations.dataGroups" + :data="dataGroups" + :open-on-focus="true" + :placeholder="$t('dataTypeAuthorizations.data-groups-placeholder')" + :value="dataGroups.id" + autocomplete + class="column" + field="label" + type="is-primary" > </b-taginput> </b-field> <b-field - v-if="column.withPeriods" - class="column" - :label="$t('dataTypeAuthorizations.label-datePicker')" - label-position="on-border" + v-if="column.withPeriods" + class="column" + :label="$t('dataTypeAuthorizations.label-datePicker')" + label-position="on-border" > <b-datepicker - v-model="currentAuthorization.authorizations.from" - :date-parser="parseDate" - :placeholder=" + v-model="currentAuthorization.authorizations.from" + :date-parser="parseDate" + :placeholder=" $t('dataTypesRepository.placeholder-datepicker') + ' dd-MM-YYYY, dd-MM-YYYY hh, dd-MM-YYYY hh:mm, dd-MM-YYYY HH:mm:ss' " - editable - icon="calendar" - pack="far" - @remove.capture="() => selectCheckbox($event, index, indexColumn, scope)" - @input="selectCheckbox($event, index, indexColumn, scope, 'from')" + editable + icon="calendar" + pack="far" + @remove.capture="() => selectCheckbox($event, index, indexColumn, scope)" + @input="selectCheckbox($event, index, indexColumn, scope, 'from')" > </b-datepicker> </b-field> <b-field - v-if="column.withPeriods" - class="column" - :label="$t('dataTypeAuthorizations.label-datePicker')" - label-position="on-border" + v-if="column.withPeriods" + class="column" + :label="$t('dataTypeAuthorizations.label-datePicker')" + label-position="on-border" > <b-datepicker - v-model="currentAuthorization.authorizations.to" - :date-parser="parseDate" - :placeholder=" + v-model="currentAuthorization.authorizations.to" + :date-parser="parseDate" + :placeholder=" $t('dataTypesRepository.placeholder-datepicker') + ' dd-MM-YYYY, dd-MM-YYYY hh, dd-MM-YYYY hh:mm, dd-MM-YYYY HH:mm:ss' " - editable - icon="calendar" - pack="far" + editable + icon="calendar" + pack="far" > </b-datepicker> </b-field> <div class="buttons"> <b-button - icon-left="check" - type="is-dark" - @click="registerCurrentAuthorization" - style="margin-bottom: 10px" + icon-left="check" + type="is-dark" + @click="registerCurrentAuthorization" + style="margin-bottom: 10px" > {{ $t("dataTypesManagement.validate") }} </b-button> @@ -152,11 +151,11 @@ </template> <script> -import {Component, Prop, Vue} from "vue-property-decorator"; -import {FontAwesomeIcon} from "@fortawesome/vue-fontawesome"; +import { Component, Prop, Vue } from "vue-property-decorator"; +import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; @Component({ - components: {FontAwesomeIcon}, + components: { FontAwesomeIcon }, }) export default class AuthorizationForPeriodDatagroups extends Vue { @Prop() column; @@ -177,7 +176,7 @@ export default class AuthorizationForPeriodDatagroups extends Vue { var authorizations = this.state.fromAuthorization; if (authorizations) { authorizations.dataGroups = this.dataGroups.filter((dg) => - authorizations.dataGroups.find((dg2) => dg.id == dg2) + authorizations.dataGroups.find((dg2) => dg.id == dg2) ); authorizations.from = authorizations.fromDay ? new Date(authorizations.fromDay) : null; authorizations.to = authorizations.toDay ? new Date(authorizations.toDay) : null; @@ -201,7 +200,7 @@ export default class AuthorizationForPeriodDatagroups extends Vue { parseDate(date) { date = - date && date.replace(/(\d{2})\/(\d{2})\/(\d{4})(( \d{2})?(:\d{2})?(:\d{2})?)/, "$3-$2-$1$4"); + date && date.replace(/(\d{2})\/(\d{2})\/(\d{4})(( \d{2})?(:\d{2})?(:\d{2})?)/, "$3-$2-$1$4"); return new Date(date); } } @@ -223,4 +222,4 @@ export default class AuthorizationForPeriodDatagroups extends Vue { .modal .modal-content { height: 70%; } -</style> \ No newline at end of file +</style> diff --git a/ui/src/components/common/AuthorizationTable.vue b/ui/src/components/common/AuthorizationTable.vue index c758535827ca46e4e37c2cda0fb4ca2955e3ef18..6702c897352f79274c092f95ec36b2ca492e0568 100644 --- a/ui/src/components/common/AuthorizationTable.vue +++ b/ui/src/components/common/AuthorizationTable.vue @@ -7,38 +7,59 @@ <slot class="row"></slot> <div v-for="(scope, index) of authReference" :key="index"> <div v-if="canShowLine(index)"> - <div class="columns" @mouseleave="upHere = false" @mouseover="upHere = true" - > + <div class="columns" @mouseleave="upHere = false" @mouseover="upHere = true"> <div v-for="(column, indexColumn) of columnsVisible" :key="indexColumn" :class="{ hover: upHere && scope.isLeaf }" class="column" + :style="!column.display ? 'display : contents':''" > <a v-if=" - column.display && - indexColumn === 'label' && - (!scope.isLeaf || remainingOption.length) - " + column.display && + indexColumn === 'label' && + (!scope.isLeaf || remainingOption.length) + " :class="!scope.isLeaf || remainingOption.length ? 'leaf' : 'folder'" :field="indexColumn" style="min-height: 10px; display: table-cell; vertical-align: middle" @click="indexColumn === 'label' && toggle(index)" > - {{ localName(scope) }} + <span style="margin-right: 10px"> + <FontAwesomeIcon + :icon="openChild ? 'caret-down' : 'caret-right'" + tabindex="0" + /> + </span> + <span> {{ localName(scope) }} </span> </a> <p v-else-if=" - column.display && - indexColumn === 'label' && - !(!scope.isLeaf || remainingOption.length) - " + column.display && + indexColumn === 'label' && + !(!scope.isLeaf || remainingOption.length) + " :class="!scope.isLeaf || remainingOption.length ? 'leaf' : 'folder'" :field="indexColumn" > - {{ localName(scope) }} + {{ localName(scope) }} </p> + <b-field v-else-if="column.display && indexColumn === 'admin'" :field="indexColumn" class="column"> + <b-tooltip + type="is-warning" + :label="$t('dataTypeAuthorizations.all-autorisation')" + > + <b-icon + :icon="STATES[states[indexColumn][getPath(index)].localState] || STATES[0]" + class="clickable" + pack="far" + size="is-medium" + type="is-warning" + @click.native="selectCheckboxAll($event, index, indexColumn)" + /> + </b-tooltip> + </b-field> <b-field v-else-if="column.display" :field="indexColumn" class="column"> <b-tooltip type="is-warning" @@ -47,11 +68,21 @@ > <b-icon :icon="STATES[states[indexColumn][getPath(index)].localState] || STATES[0]" + class="clickable" pack="far" size="is-medium" - :type="(states[indexColumn][getPath(index)].hasPublicStates || canShowWarning(index, indexColumn))?'is-light':'is-primary'" + :type=" + states[indexColumn][getPath(index)].hasPublicStates || + canShowWarning(index, indexColumn) + ? 'is-light' + : 'is-primary' + " :disabled="canShowWarning(index, indexColumn)" - @click.native="canShowWarning(index, indexColumn)?index=>i:selectCheckbox($event, index, indexColumn)" + @click.native=" + canShowWarning(index, indexColumn) + ? (index) => i + : selectCheckbox($event, index, indexColumn) + " /> </b-tooltip> <AuthorizationForPeriodDatagroups @@ -68,9 +99,9 @@ position="is-right" multilined v-if=" - states[indexColumn][getPath(index)].state === 0 || - states[indexColumn][getPath(index)].state === -1 - " + states[indexColumn][getPath(index)].state === 0 || + states[indexColumn][getPath(index)].state === -1 + " > <b-button v-if="(column.withDataGroups && dataGroups.length > 1) || column.withPeriods" @@ -85,7 +116,7 @@ </b-button> <template v-slot:content> <div v-if="canShowWarning(index, indexColumn)"> - {{$t('validation.noRightsForThisOPeration')}} + {{ $t("validation.noRightsForThisOPeration") }} </div> <div v-else-if="states[indexColumn][getPath(index)].state === 0"> <p> @@ -178,6 +209,7 @@ export default class AuthorizationTable extends Vue { states = {}; currentAuthorization = null; showModal = false; + openChild = false; @Watch("authorization") onAuthorizationChanged(auth) { @@ -215,26 +247,36 @@ export default class AuthorizationTable extends Vue { } this.states = states; } - canShowLine(index){ - return (this.isApplicationAdmin || this.ownAuthorizations.find(oa=>this.getPath(index).startsWith(oa)||oa.startsWith(this.getPath(index))))?true:false + + canShowLine(index) { + return this.isApplicationAdmin || + this.ownAuthorizations.find( + (oa) => this.getPath(index).startsWith(oa) || oa.startsWith(this.getPath(index)) + ) + ? true + : false; } - canShowWarning(index, column){ - return ( - this.isApplicationAdmin || (this.ownAuthorizations.find(oa=>this.getPath(index).startsWith(oa)) - && this.isAuthorizedColumnForPath(index, column)) - )?false:true + canShowWarning(index, column) { + return this.isApplicationAdmin || + (this.ownAuthorizations.find((oa) => this.getPath(index).startsWith(oa)) && + this.isAuthorizedColumnForPath(index, column)) + ? false + : true; } - isAuthorizedColumnForPath(index, column){ + + isAuthorizedColumnForPath(index, column) { for (const path in this.ownAuthorizationsColumnsByPath) { - if (this.getPath(index).startsWith(path) && this.ownAuthorizationsColumnsByPath[path].indexOf(column)>=0){ + if ( + this.getPath(index).startsWith(path) && + this.ownAuthorizationsColumnsByPath[path].indexOf(column) >= 0 + ) { return true; } } return false; } - getScope() { return this.authorizationScopes?.[0]?.id; } @@ -265,6 +307,7 @@ export default class AuthorizationTable extends Vue { var open = {}; open[index] = !this.open[index]; this.open = {...this.open, ...open}; + this.openChild = !this.openChild; } select(option) { @@ -275,6 +318,21 @@ export default class AuthorizationTable extends Vue { this.selectCheckbox(event.event, index, event.indexColumn, event.authorizations); } + selectCheckboxAll(event, index, indexColumn, authorizations) { + let thisStateElement = this.states[indexColumn][this.getPath(index)]; + this.selectCheckbox(event, index, indexColumn, authorizations); + for (let nameColumn in this.columnsVisible) { + if(nameColumn !== "admin") { + if (this.states[nameColumn]) { + let stateElement = this.states[nameColumn][this.getPath(index)]; + if (thisStateElement.state === stateElement.state) { + this.selectCheckbox(event, index, nameColumn, authorizations); + } + } + } + } + } + selectCheckbox(event, index, indexColumn, authorizations) { let eventToEmit, checkedAuthorization, authorization, requiredAuthorizations, authReference; if (!indexColumn || !event) { @@ -413,4 +471,4 @@ p { .show-detail-for-selected { height: 60px; } -</style> \ No newline at end of file +</style> diff --git a/ui/src/components/common/CollapsibleTree.vue b/ui/src/components/common/CollapsibleTree.vue index cd6ce1940ce30da6e234d3b8eb088a4d7a1e54b1..6578f2365c1c3f14fcabcde45396e54c419f6ec2 100644 --- a/ui/src/components/common/CollapsibleTree.vue +++ b/ui/src/components/common/CollapsibleTree.vue @@ -113,11 +113,7 @@ type="is-info" > <span class="file-cta" style="border-color: transparent; background-color: transparent"> - <b-icon - class="file-icon" - icon="archive" - style="color: white" - ></b-icon> + <b-icon class="file-icon" icon="archive" style="color: white"></b-icon> </span> </b-button> </div> diff --git a/ui/src/locales/fr.json b/ui/src/locales/fr.json index 641de3ec4753cf127b9aa45dec96721ae0111855..325b6488737a003146d2cfb833435961619edf0c 100644 --- a/ui/src/locales/fr.json +++ b/ui/src/locales/fr.json @@ -333,7 +333,8 @@ "showMore": "Voir plus...", "search": "Recherche...", "save" : "Enregister modification", - "add-application-name": "Ajouter une application" + "add-application-name": "Ajouter une application", + "all-autorisation" : "Coche toutes les cases des droits sur la ligne " }, "ponctuation": { "semicolon" : ";", diff --git a/ui/src/model/authorization/Authorization.js b/ui/src/model/authorization/Authorization.js index 29eb706f47cf5acf6df4cd38c8685681321fcc8f..6bad5f3ee412660b69e80a93bce5030cd9047fbd 100644 --- a/ui/src/model/authorization/Authorization.js +++ b/ui/src/model/authorization/Authorization.js @@ -66,4 +66,4 @@ export class Authorization { } return parsedDate; } -} \ No newline at end of file +} diff --git a/ui/src/model/authorization/Authorizations.js b/ui/src/model/authorization/Authorizations.js index 927a1b7c039aa256b7c15d4d8de5bd151cefba27..43466d98c4d8378669b434fef16480c670f6f7fc 100644 --- a/ui/src/model/authorization/Authorizations.js +++ b/ui/src/model/authorization/Authorizations.js @@ -1,119 +1,119 @@ -import {Authorization} from "@/model/authorization/Authorization"; +import { Authorization } from "@/model/authorization/Authorization"; export class Authorizations { - static ROLES() { - return { - suppression: [], - extraction: [], - admin: [], - depot: [], - publication: [], - }; - } + static ROLES() { + return { + suppression: [], + extraction: [], + admin: [], + depot: [], + publication: [], + }; + } - #scopesId = []; - scopes = {}; - uuid = ""; - applicationNameOrId = ""; - dataType = ""; - name = ""; - users = []; - authorizations = this.ROLE; + #scopesId = []; + scopes = {}; + uuid = ""; + applicationNameOrId = ""; + dataType = ""; + name = ""; + users = []; + authorizations = this.ROLES; - constructor(authorizations, authorizationsScope) { - this.#scopesId = authorizationsScope; - this.users = authorizations.users || []; - this.applicationNameOrId = authorizations.applicationNameOrId; - this.dataType = authorizations.dataType; - this.name = authorizations.name; - this.uuid = authorizations.uuid; - this.#initStates(authorizations.authorizations); - } + constructor(authorizations, authorizationsScope) { + this.#scopesId = authorizationsScope; + this.users = authorizations.users || []; + this.applicationNameOrId = authorizations.applicationNameOrId; + this.dataType = authorizations.dataType; + this.name = authorizations.name; + this.uuid = authorizations.uuid; + this.#initStates(authorizations.authorizations); + } - #initStates(authorizations) { - this.authorizations = authorizations || {}; - this.scopes = {}; - for (const scope in authorizations) { - const scopeId = this.#scopesId; - let scopes = authorizations[scope].reduce((acc, auth) => { - auth = new Authorization(auth); - acc[scope] = acc[scope] || {}; - acc[scope][auth.getPath(scopeId)] = auth; - return acc; - }, {}); - this.scopes = {...this.scopes, ...scopes}; - } + #initStates(authorizations) { + this.authorizations = authorizations || {}; + this.scopes = {}; + for (const scope in authorizations) { + const scopeId = this.#scopesId; + let scopes = authorizations[scope].reduce((acc, auth) => { + auth = new Authorization(auth); + acc[scope] = acc[scope] || {}; + acc[scope][auth.getPath(scopeId)] = auth; + return acc; + }, {}); + this.scopes = { ...this.scopes, ...scopes }; } + } - getDependants(scope, path) { - if (this.authorizations[scope]) { - return this.authorizations[scope].filter((auth) => { - let pathToCompare = new Authorization(auth).getPath(this.#scopesId); - if (pathToCompare.startsWith(path) && pathToCompare != path) { - return true; - } - return false; - }); + getDependants(scope, path) { + if (this.authorizations[scope]) { + return this.authorizations[scope].filter((auth) => { + let pathToCompare = new Authorization(auth).getPath(this.#scopesId); + if (pathToCompare.startsWith(path) && pathToCompare != path) { + return true; } - return []; + return false; + }); } + return []; + } - getState(scope, path, publicState) { - let state = { - state: 0, - fromPath: "", - dataGroups: [], - from: null, - to: null, - fromAuthorization: null, - publicState - }; - if (this.authorizations[scope]) { - for (const auth in this.authorizations[scope]) { - let authorizationElement = new Authorization(this.authorizations[scope][auth]); - let pathToCompare = authorizationElement.getPath(this.#scopesId); - if (path.startsWith(pathToCompare)) { - state.fromPath = pathToCompare; - state.fromAuthorization = authorizationElement; - state.fromDay = authorizationElement.fromDay; - state.toDay = authorizationElement.toDay; - state.from = authorizationElement.fromDay ? new Date(authorizationElement.fromDay) : null; - state.to = authorizationElement.toDay ? new Date(authorizationElement.toDay) : null; - state.dataGroups = authorizationElement.dataGroups; - state.hasPublicStates = false; - state.localState = 0; - } - } - } - for (const scopeKey in this.scopes[scope]) { - if (path.startsWith(scopeKey)) { - state.state = 1; - state.localState = 1; - return state; - } else if (scopeKey.startsWith(path)) { - state.state = -1; - state.localState = -1; - return state; - } - } - if (state.state == 0 && state.publicState != 0) { - state.hasPublicStates = true - state.localState = state.publicState - } else if (state.publicState == 1 && state.state == 1) { - state.hasPublicStates = true - state.localState = state.publicState - } else { - state.hasPublicStates = false - state.localState = state.state + getState(scope, path, publicState) { + let state = { + state: 0, + fromPath: "", + dataGroups: [], + from: null, + to: null, + fromAuthorization: null, + publicState, + }; + if (this.authorizations[scope]) { + for (const auth in this.authorizations[scope]) { + let authorizationElement = new Authorization(this.authorizations[scope][auth]); + let pathToCompare = authorizationElement.getPath(this.#scopesId); + if (path.startsWith(pathToCompare)) { + state.fromPath = pathToCompare; + state.fromAuthorization = authorizationElement; + state.fromDay = authorizationElement.fromDay; + state.toDay = authorizationElement.toDay; + state.from = authorizationElement.fromDay ? new Date(authorizationElement.fromDay) : null; + state.to = authorizationElement.toDay ? new Date(authorizationElement.toDay) : null; + state.dataGroups = authorizationElement.dataGroups; + state.hasPublicStates = false; + state.localState = 0; } + } + } + for (const scopeKey in this.scopes[scope]) { + if (path.startsWith(scopeKey)) { + state.state = 1; + state.localState = 1; + return state; + } else if (scopeKey.startsWith(path)) { + state.state = -1; + state.localState = -1; return state; + } } + if (state.state == 0 && state.publicState != 0) { + state.hasPublicStates = true; + state.localState = state.publicState; + } else if (state.publicState == 1 && state.state == 1) { + state.hasPublicStates = true; + state.localState = state.publicState; + } else { + state.hasPublicStates = false; + state.localState = state.state; + } + return state; + } - getCheckedAuthorization(scope, currentPath) { - for (const scopeKey in this.scopes[scope]) { - if (currentPath.startsWith(scopeKey)) { - return {scopeKey, auth: this.scopes[scope][scopeKey]}; - } - } + getCheckedAuthorization(scope, currentPath) { + for (const scopeKey in this.scopes[scope]) { + if (currentPath.startsWith(scopeKey)) { + return { scopeKey, auth: this.scopes[scope][scopeKey] }; + } } -} \ No newline at end of file + } +} diff --git a/ui/src/views/authorizations/DataTypeAuthorizationInfoView.vue b/ui/src/views/authorizations/DataTypeAuthorizationInfoView.vue index f9d45b79ceee022e93e45029dddc1f5d1afcb614..60019151be7edfee093e88eb8f28d85100a5c5a2 100644 --- a/ui/src/views/authorizations/DataTypeAuthorizationInfoView.vue +++ b/ui/src/views/authorizations/DataTypeAuthorizationInfoView.vue @@ -91,6 +91,7 @@ :field="indexColumn" :label="getColumnTitle(column)" class="column" + :style="!column.display ? 'display : contents':''" ></b-field> </div> </div> @@ -103,7 +104,11 @@ @click="handleSubmit(createAuthorization)" style="margin-bottom: 10px" > - {{ authorization.uuid?$t("dataTypeAuthorizations.modify"):$t("dataTypeAuthorizations.create") }} + {{ + authorization.uuid + ? $t("dataTypeAuthorizations.modify") + : $t("dataTypeAuthorizations.create") + }} </b-button> </div> </ValidationObserver> @@ -325,43 +330,54 @@ export default class DataTypeAuthorizationInfoView extends Vue { authorizationScopes: this.authorizationScopes, dataGroups: this.dataGroups, users: this.users, - authorizationsForUser: authorizationsForUser + authorizationsForUser: authorizationsForUser, } = grantableInfos); - console.log('authorizationsForUser', authorizationsForUser) - let auths = authorizationsForUser.authorizationResults.admin - if (JSON.parse(localStorage.getItem('authenticatedUser'))) { - let ownAuthorizations = JSON.parse(localStorage.getItem('authenticatedUser')).authorizations - this.isApplicationAdmin = ownAuthorizations.find(a => new RegExp(a).test(this.dataTypeId)) + console.log("authorizationsForUser", authorizationsForUser); + let auths = authorizationsForUser.authorizationResults.admin; + if (JSON.parse(localStorage.getItem("authenticatedUser"))) { + let ownAuthorizations = JSON.parse( + localStorage.getItem("authenticatedUser") + ).authorizations; + this.isApplicationAdmin = ownAuthorizations.find((a) => + new RegExp(a).test(this.dataTypeId) + ); } - if (!this.isApplicationAdmin){ + if (!this.isApplicationAdmin) { for (const scope in auths) { - this.ownAuthorizations = this.ownAuthorizations || [] - let scopeAuthorizations = auths[scope] - let scopeAuthorization = new Authorization(scopeAuthorizations) - let path = scopeAuthorization.getPath(this.authorizationScopes.map((a => a.id))); + this.ownAuthorizations = this.ownAuthorizations || []; + let scopeAuthorizations = auths[scope]; + let scopeAuthorization = new Authorization(scopeAuthorizations); + let path = scopeAuthorization.getPath(this.authorizationScopes.map((a) => a.id)); if (this.ownAuthorizations.indexOf(path) === -1) { - if (!this.ownAuthorizations.find(pa => path.startWith(pa))) { - this.ownAuthorizations = this.ownAuthorizations.filter(pa => !pa.startWith(path)) + if (!this.ownAuthorizations.find((pa) => path.startWith(pa))) { + this.ownAuthorizations = this.ownAuthorizations.filter((pa) => !pa.startWith(path)); this.ownAuthorizations.push(path); } } } } - for (const path of this.ownAuthorizations) { + for (const path of this.ownAuthorizations) { for (const scopeId in authorizationsForUser.authorizationByPath) { - console.log('path', path, 'scope', scopeId, "authorizationResults", authorizationsForUser.authorizationResults[scopeId]) - console.log('scope', scopeId) - if(authorizationsForUser.authorizationByPath[scopeId]){ - for (const pathKey in authorizationsForUser.authorizationByPath[scopeId]) { - if (pathKey.startsWith(path) || path.startsWith(pathKey)){ - let autorizedPath = pathKey.startsWith(path) ? path : pathKey; - this.ownAuthorizationsColumnsByPath[autorizedPath] = this.ownAuthorizationsColumnsByPath[autorizedPath] || [] - this.ownAuthorizationsColumnsByPath[autorizedPath].push(scopeId) - - } - } + console.log( + "path", + path, + "scope", + scopeId, + "authorizationResults", + authorizationsForUser.authorizationResults[scopeId] + ); + console.log("scope", scopeId); + if (authorizationsForUser.authorizationByPath[scopeId]) { + for (const pathKey in authorizationsForUser.authorizationByPath[scopeId]) { + if (pathKey.startsWith(path) || path.startsWith(pathKey)) { + let autorizedPath = pathKey.startsWith(path) ? path : pathKey; + this.ownAuthorizationsColumnsByPath[autorizedPath] = + this.ownAuthorizationsColumnsByPath[autorizedPath] || []; + this.ownAuthorizationsColumnsByPath[autorizedPath].push(scopeId); } + } + } } } this.columnsVisible = {...this.columnsVisible, ...grantableInfos.columnsDescription}; @@ -375,18 +391,22 @@ export default class DataTypeAuthorizationInfoView extends Vue { this.authorizationId ); - this.publicAuthorizations = {} + this.publicAuthorizations = {}; for (const authorizationKey in authorizations.publicAuthorizations) { - let auths = authorizations.publicAuthorizations[authorizationKey] + let auths = authorizations.publicAuthorizations[authorizationKey]; for (const scope in auths) { - this.publicAuthorizations[scope] = this.publicAuthorizations[scope] || [] - let scopeAuthorizations = auths[scope] + this.publicAuthorizations[scope] = this.publicAuthorizations[scope] || []; + let scopeAuthorizations = auths[scope]; for (const scopeAuthorizationsKey in scopeAuthorizations) { - let scopeAuthorization = new Authorization(scopeAuthorizations[scopeAuthorizationsKey]) - let path = scopeAuthorization.getPath2(this.authorizationScopes.map((a => a.id))); + let scopeAuthorization = new Authorization( + scopeAuthorizations[scopeAuthorizationsKey] + ); + let path = scopeAuthorization.getPath2(this.authorizationScopes.map((a) => a.id)); if (this.publicAuthorizations[scope].indexOf(path) === -1) { - if (!this.publicAuthorizations[scope].find(pa => path.startWith(pa))) { - this.publicAuthorizations[scope] = this.publicAuthorizations[scope].filter(pa => !pa.startWith(path)) + if (!this.publicAuthorizations[scope].find((pa) => path.startWith(pa))) { + this.publicAuthorizations[scope] = this.publicAuthorizations[scope].filter( + (pa) => !pa.startWith(path) + ); this.publicAuthorizations[scope].push(path); } } @@ -720,4 +740,4 @@ ul li.card-content { a { color: $dark; } -</style> \ No newline at end of file +</style> diff --git a/ui/src/views/authorizations/DataTypeAuthorizationsView.vue b/ui/src/views/authorizations/DataTypeAuthorizationsView.vue index 8c1737fae1bd25b15edab6b78f61943d304cccf0..2cafe704db62fb7ac782bb1e54c5aea25c909e9f 100644 --- a/ui/src/views/authorizations/DataTypeAuthorizationsView.vue +++ b/ui/src/views/authorizations/DataTypeAuthorizationsView.vue @@ -312,9 +312,15 @@ export default class DataTypeAuthorizationsView extends Vue { this.applicationName, this.dataTypeId ); - this.authorizations = authorizations.authorizationResults.filter(auth=>auth.authorizationsForUser.isAdministratorForDatatype || auth.authorizationsForUser.authorizationResults.admin) - let authorizationForUser = authorizations.authorizationsForUser - this.canManageRights = authorizationForUser.isAdministratorForDatatype || authorizationForUser.authorizationResults.admin + this.authorizations = authorizations.authorizationResults.filter( + (auth) => + auth.authorizationsForUser.isAdministratorForDatatype || + auth.authorizationsForUser.authorizationResults.admin + ); + let authorizationForUser = authorizations.authorizationsForUser; + this.canManageRights = + authorizationForUser.isAdministratorForDatatype || + authorizationForUser.authorizationResults.admin; if (this.authorizations && this.authorizations.length !== 0) { this.scopes = Object.keys(this.authorizations[0].authorizations); } @@ -416,4 +422,4 @@ td { .listAuthorization:nth-child(odd) { background-color: #f5f5f5; } -</style> \ No newline at end of file +</style> diff --git a/ui/src/views/datatype/DataTypeTableView.vue b/ui/src/views/datatype/DataTypeTableView.vue index 26712c46bb998d822fc4595a2e5ff87b3a3ad0c3..4bcb895886dcd3d4c4a0f5f52a8104ea972fe830 100644 --- a/ui/src/views/datatype/DataTypeTableView.vue +++ b/ui/src/views/datatype/DataTypeTableView.vue @@ -406,7 +406,7 @@ {{ /.{25}(.*$)/.exec(row[component.variable][component.component])[1] }} </span> <span - v-else-if=" + v-else-if=" row[component.variable][component.computedComponent] && component.checker && component.checker.pattern @@ -422,10 +422,20 @@ > {{ getDisplay(row, component.variable, component.component) }} </a> - <p v-if="!getRefsLinkedToId(row, component) && row[component.variable][component.component]"> + <p + v-if=" + !getRefsLinkedToId(row, component) && + row[component.variable][component.component] + " + > {{ row[component.variable][component.component] }} </p> - <p v-else-if="!getRefsLinkedToId(row, component) && row[component.variable][component.computedComponent]"> + <p + v-else-if=" + !getRefsLinkedToId(row, component) && + row[component.variable][component.computedComponent] + " + > {{ row[component.variable][component.computedComponent] }} </p> </span> @@ -651,11 +661,16 @@ export default class DataTypeTableView extends Vue { } getRefsLinkedToId(row, component) { - return this.refsLinkedTo[row.rowId][component.variable][component.component] ||this.refsLinkedTo[row.rowId][component.variable][component.computedComponent] ; + return ( + this.refsLinkedTo[row.rowId][component.variable][component.component] || + this.refsLinkedTo[row.rowId][component.variable][component.computedComponent] + ); } getTranslation(row, component) { - let translation = row[component.variable][component.component] || row[component.variable][component.computedComponent]; + let translation = + row[component.variable][component.component] || + row[component.variable][component.computedComponent]; return translation; } async getReferenceValues(row, component) { @@ -679,7 +694,7 @@ export default class DataTypeTableView extends Vue { params ); refvalues = reference.referenceValues[0].values; - console.log(refvalues) + console.log(refvalues); } const data = Object.entries(refvalues) .map((entry) => ({ colonne: entry[0], valeur: entry[1] })) @@ -991,4 +1006,4 @@ $row-variable-height: 60px; .icon.is-small { font-size: 5rem; } -</style> \ No newline at end of file +</style> diff --git a/ui/src/views/datatype/DataTypesRepositoryView.vue b/ui/src/views/datatype/DataTypesRepositoryView.vue index 090712f7aa3bfbb95910002fa9be8efa6d941225..361a5301efe08d47f20f4b4a1655e1f0a9e1d3df 100644 --- a/ui/src/views/datatype/DataTypesRepositoryView.vue +++ b/ui/src/views/datatype/DataTypesRepositoryView.vue @@ -50,20 +50,20 @@ <h1> {{ this.requiredAuthorizationsObject - ? Object.entries(this.requiredAuthorizationsObject) - .filter((e) => e[1]) - .map( - (e) => - internationalisationService.getLocaleforPath( - application, - getAuthorizationScopePath(e[0]), - e[0] - ) + - " : " + - e[1] - ) - .join(", ") - : "" + ? Object.entries(this.requiredAuthorizationsObject) + .filter((e) => e[1]) + .map( + (e) => + internationalisationService.getLocaleforPath( + application, + getAuthorizationScopePath(e[0]), + e[0] + ) + + " : " + + e[1] + ) + .join(", ") + : "" }} </h1> </div> @@ -202,13 +202,13 @@ <div v-if="errorsMessages.length" style="margin: 10px"> <div v-for="msg in errorsMessages" v-bind:key="msg"> <b-message - :title="$t('message.data-type-config-error')" - type="is-danger" - has-icon - :aria-close-label="$t('message.close')" - class="mt-4 DataTypesManagementView-message" + :title="$t('message.data-type-config-error')" + type="is-danger" + has-icon + :aria-close-label="$t('message.close')" + class="mt-4 DataTypesManagementView-message" > - <span v-html="msg"/> + <span v-html="msg" /> </b-message> </div> </div> @@ -306,10 +306,10 @@ import {InternationalisationService} from "@/services/InternationalisationServic import {LOCAL_STORAGE_LANG} from "@/services/Fetcher"; import DropDownMenu from "@/components/common/DropDownMenu"; import moment from "moment"; -import {HttpStatusCodes} from "@/utils/HttpUtils"; +import { HttpStatusCodes } from "@/utils/HttpUtils"; @Component({ - components: {DropDownMenu, CollapsibleTree, PageView, SubMenu}, + components: { DropDownMenu, CollapsibleTree, PageView, SubMenu }, }) export default class DataTypesRepositoryView extends Vue { @Prop() applicationName; @@ -362,10 +362,9 @@ export default class DataTypesRepositoryView extends Vue { const prevPath = `/applications/${this.applicationName}/dataTypes`; this.subMenuPaths = [ new SubMenuPath( - this.dataTypeId.toLowerCase(), - () => { - }, - () => this.$router.push(prevPath) + this.dataTypeId.toLowerCase(), + () => {}, + () => this.$router.push(prevPath) ), ]; @@ -442,7 +441,8 @@ export default class DataTypesRepositoryView extends Vue { try { let variable = this.configuration.data[variable]; - refType = ({...variable.components, ...variable.compositeComponents})[component].checker.params.refType; + refType = { ...variable.components, ...variable.compositeComponents }[component].checker + .params.refType; compositeReferenceDependance = false; for (const ref in this.application.references) { if (this.application.references[ref].children.length) { @@ -499,8 +499,8 @@ export default class DataTypesRepositoryView extends Vue { for (let auth in this.authorizations) { let vc = this.authorizations[auth]; let variables = this.configuration.data[vc.variable]; - var reference = - ({...variables.components, ...variables.computedComponents})[vc.component].checker.params.refType; + var reference = { ...variables.components, ...variables.computedComponents }[vc.component] + .checker.params.refType; let ref = await this.getOrLoadReferences(reference); ret[auth] = ref; } @@ -644,7 +644,7 @@ export default class DataTypesRepositoryView extends Vue { for (let i = 0; i < value.length; i++) { if (message.length > 0) { if (JSON.stringify(value[i]) !== JSON.stringify(value[i - message.length])) { - console.log(message) + console.log(message); this.errorsList.push(value[i]); } for (let j = 0; j < message.length; j++) { @@ -657,7 +657,7 @@ export default class DataTypesRepositoryView extends Vue { this.errorsList.push(value[i]); } } - console.log(this.errorsList) + console.log(this.errorsList); if (this.errorsList.length !== 0) { this.errorsMessages = this.errorsService.getCsvErrorsMessages(this.errorsList); } else { @@ -782,7 +782,7 @@ export default class DataTypesRepositoryView extends Vue { if (localName?.values?.["__display_" + lang]) { localName = localName?.values?.["__display_" + lang]; } else { - localName = localName?.naturalKey + localName = localName?.naturalKey; } if (!localName) { localName = key; @@ -879,4 +879,4 @@ caption { .tooltip-content { } } -</style> \ No newline at end of file +</style> diff --git a/ui/vue.config.js b/ui/vue.config.js index 93cffabcef27f855e4ced25fbbfa717fb227aece..2eb76ffcc6fdf9a730fd86e33163c0c5b25a4451 100644 --- a/ui/vue.config.js +++ b/ui/vue.config.js @@ -14,7 +14,7 @@ module.exports = { configureWebpack: { devtool: "source-map", }, - outputDir:'html', + outputDir: "html", pluginOptions: { i18n: { @@ -24,4 +24,4 @@ module.exports = { enableInSFC: false, }, }, -}; \ No newline at end of file +};