Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-webui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-webui
Merge requests
!68
DOC: update CHANGELOG
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Merged
DOC: update CHANGELOG
release-0.5.0
into
main
Overview
0
Commits
55
Pipelines
3
Changes
1
Merged
Timm Fitschen
requested to merge
release-0.5.0
into
main
3 years ago
Overview
0
Commits
55
Pipelines
3
Changes
1
0
0
Merge request reports
Viewing commit
f3f80025
Prev
Next
Show latest version
1 file
+
104
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Verified
f3f80025
Add module ext_entity_acl
· f3f80025
Timm Fitschen
authored
3 years ago
src/core/js/ext_entity_acl.js
0 → 100644
+
104
−
0
View file @ f3f80025
Edit in single-file editor
Open in Web IDE
/*
* This file is a part of the CaosDB Project.
*
* Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
* Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
"
use strict
"
;
/**
* Adds button to each entity which links to the entity's ACL.
*
* Please enable via build property:
*
* BUILD_MODULE_EXT_ENTITY_ACL=ENABLED
*
* Set the base uri of the EntityACL view (optional, defaults to
* `${connection.getBasePath()}webinterface/acm/entityacl/`):
*
* BUILD_MODULE_EXT_ENTITY_ACL_URI_ROOT=[scheme://host:port]/what/evs
*
*
* @author Timm Fitschen
*/
var
ext_entity_acl
=
function
(
$
,
connection
,
getEntityVersion
,
getEntityID
,
logger
)
{
const
BUILD_MODULE_EXT_ENTITY_ACL_URI_ROOT
=
connection
.
getBasePath
()
+
"
webinterface/acm/entityacl/
"
;
const
_buttons_list_class
=
"
caosdb-v-entity-header-buttons-list
"
;
const
_entity_acl_link_class
=
"
caosdb-f-entity-entity_acl-button
"
;
const
_entity_acl_canvas_container
=
"
caosdb-f-entity-entity_acl
"
;
const
_entity_acl_link_container
=
"
caosdb-f-entity-entity_acl-link
"
;
const
_entity_acl_icon
=
`<i class="bi bi-key"></i>`
;
/**
* Create a link to the Entity ACL.
*
* @param {string} entity_id
* @return {HTMLElement} the newly created link.
*/
var
create_entity_acl_link
=
function
(
entity_id
)
{
const
button
=
$
(
`<a href="
${
BUILD_MODULE_EXT_ENTITY_ACL_URI_ROOT
}${
entity_id
}
" title="Open Entity ACL" class="
${
_entity_acl_link_class
}
caosdb-v-entity-entity_acl-button btn">
${
_entity_acl_icon
}
</a>`
);
return
button
[
0
];
}
/**
* Add a entity_acl button to a given entity.
* @param {HTMLElement} entity
*/
var
add_entity_acl_to_entity
=
function
(
entity
)
{
const
entity_id
=
getEntityID
(
entity
);
$
(
entity
).
find
(
`.
${
_buttons_list_class
}
`
).
append
(
create_entity_acl_link
(
entity_id
));
}
var
remove_entity_acl_link
=
function
(
entity
)
{
$
(
entity
).
find
(
`.
${
_buttons_list_class
}
.
${
_entity_acl_link_class
}
`
).
remove
();
}
var
_init
=
function
()
{
for
(
let
entity
of
$
(
"
.caosdb-entity-panel
"
))
{
remove_entity_acl_link
(
entity
);
add_entity_acl_to_entity
(
entity
);
}
}
/**
* Initialize this module and append a QR Code button to all entities panels on the page.
*
* Removes all respective buttons if present before adding a new one.
*/
var
init
=
function
()
{
_init
();
// edit-mode-listener
document
.
body
.
addEventListener
(
edit_mode
.
end_edit
.
type
,
_init
,
true
);
};
return
{
add_entity_acl_to_entity
:
add_entity_acl_to_entity
,
remove_entity_acl_link
:
remove_entity_acl_link
,
create_entity_acl_link
:
create_entity_acl_link
,
init
:
init
};
}(
$
,
connection
,
getEntityVersion
,
getEntityID
,
log
.
getLogger
(
"
ext_entity_acl
"
));
$
(
document
).
ready
(
function
()
{
if
(
"
${BUILD_MODULE_EXT_ENTITY_ACL}
"
==
"
ENABLED
"
)
{
caosdb_modules
.
register
(
ext_entity_acl
);
}
});
Loading