diff --git a/server/src/uds/REST/methods/services.py b/server/src/uds/REST/methods/services.py index 7018dc7df..604cd13c8 100644 --- a/server/src/uds/REST/methods/services.py +++ b/server/src/uds/REST/methods/services.py @@ -243,7 +243,7 @@ class Services(DetailHandler): # pylint: disable=too-many-public-methods 'id': i.uuid, 'name': i.name, 'thumb': i.image.thumb64 if i.image is not None else DEFAULT_THUMB_BASE64, - 'user_services_count': i.userServices.count(), + 'user_services_count': i.userServices.exclude(state__in=(State.REMOVED, State.ERROR)).count(), 'state': _('With errors') if i.isRestrained() else _('Ok'), }) diff --git a/server/src/uds/REST/methods/users_groups.py b/server/src/uds/REST/methods/users_groups.py index ae14488f5..c88475f36 100644 --- a/server/src/uds/REST/methods/users_groups.py +++ b/server/src/uds/REST/methods/users_groups.py @@ -57,8 +57,17 @@ logger = logging.getLogger(__name__) # Details of /auth -def getPoolsForGroups(groups): +def getGroupsFromMeta(groups): for g in groups: + if g.is_meta: + for x in g.groups.all(): + yield x + else: + yield g + + +def getPoolsForGroups(groups): + for g in getGroupsFromMeta(groups): for servicePool in g.deployedServices.all(): yield servicePool @@ -184,7 +193,7 @@ class Users(DetailHandler): 'id': i.uuid, 'name': i.name, 'thumb': i.image.thumb64 if i.image is not None else DEFAULT_THUMB_BASE64, - 'user_services_count': i.userServices.count(), + 'user_services_count': i.userServices.exclude(state__in=(State.REMOVED, State.ERROR)).count(), 'state': _('With errors') if i.isRestrained() else _('Ok'), }) @@ -207,7 +216,7 @@ class Users(DetailHandler): class Groups(DetailHandler): - custom_methods = ['servicesPools'] + custom_methods = ['servicesPools', 'users'] def getItems(self, parent, item): try: @@ -337,8 +346,26 @@ class Groups(DetailHandler): 'id': i.uuid, 'name': i.name, 'thumb': i.image.thumb64 if i.image is not None else DEFAULT_THUMB_BASE64, - 'user_services_count': i.userServices.count(), + 'user_services_count': i.userServices.exclude(state__in=(State.REMOVED, State.ERROR)).count(), 'state': _('With errors') if i.isRestrained() else _('Ok'), }) return res + + def users(self, parent, item): + uuid = processUuid(item) + group = parent.groups.get(uuid=processUuid(uuid)) + groups = getGroupsFromMeta((group,)) + + res = [] + for group in groups: + for i in group.users.all(): + res.append({ + 'id': i.uuid, + 'name': i.name, + 'real_name': i.real_name, + 'state': i.state, + 'last_access': i.last_access + }) + + return res diff --git a/server/src/uds/static/adm/js/gui-d-authenticators.coffee b/server/src/uds/static/adm/js/gui-d-authenticators.coffee index 1ebadac9a..3cef21a25 100644 --- a/server/src/uds/static/adm/js/gui-d-authenticators.coffee +++ b/server/src/uds/static/adm/js/gui-d-authenticators.coffee @@ -174,10 +174,8 @@ gui.authenticators.link = (event) -> id = selected[0].id type = gui.authenticators.types[selected[0].type] gui.doLog "Type", type - userAPI = api.authenticators.detail(id, "users", { permission: selected[0].permission }) - user = new GuiElement(userAPI, "users") - groupAPI = api.authenticators.detail(id, "groups", { permission: selected[0].permission }) - group = new GuiElement(groupAPI, "groups") + user = new GuiElement(api.authenticators.detail(id, "users", { permission: selected[0].permission }), "users") + group = new GuiElement(api.authenticators.detail(id, "groups", { permission: selected[0].permission }), "groups") grpTable = group.table( icon: 'groups' container: "groups-placeholder" @@ -186,6 +184,133 @@ gui.authenticators.link = (event) -> buttons: [ "new" "edit" + { + text: gui.tools.iconAndText( 'fa-info', gettext('Information') ) + css: "disabled" + disabled: true + + click: (vals, value, btn, tbl, refreshFnc) -> + + if vals.length > 1 + return + + val = vals[0] + group.rest.invoke val.id + "/servicesPools", (pools) -> + group.rest.invoke val.id + "/users", (users) -> + group.rest.overview (groups) -> # Get groups + renderDate = gui.tools.renderDate(api.tools.djangoFormat(get_format("SHORT_DATETIME_FORMAT"))) + #for _, i in users + # users[i].last_access = renderDate(users[i].last_access) + + gui.tools.renderDate(api.tools.djangoFormat(get_format("SHORT_DATETIME_FORMAT"))) + gui.doLog "Pools", pools + api.templates.get "group-info", (tmpl) -> + content = api.templates.evaluate(tmpl, + id: 'information', + pools: pools, + users: users, + groups: if val.type == 'meta' then val.groups else null, + meta: val.type == 'meta', + meta_if_any: val.meta_if_any, + groups_all: groups, + goClass: 'goLink' + ) + modalId = gui.launchModal(gettext('Group information'), content, + actionButton: " " + ) + + $('#information-pools-table').DataTable( + colReorder: true + stateSave: true + paging: true + info: false + autoWidth: false + lengthChange: false + pageLength: 10 + + columnDefs: [ + { 'width': '50%', 'targets': 0 }, + { 'width': '120px', 'targets': 1 }, + { 'width': '40px', 'targets': 2 }, + { 'width': '160px', 'targets': 3 }, + ] + + ordering: true + order: [[ 1, 'asc' ]] + + dom: '<>fr<"uds-table"t>ip' + + language: gui.config.dataTablesLanguage + ) + + $('#information-users-table').DataTable( + colReorder: true + stateSave: true + paging: true + info: false + autoWidth: false + lengthChange: false + pageLength: 10 + + columnDefs: [ + { 'width': '30%', 'targets': 0 }, + { 'width': '30%', 'targets': 1 }, + { 'width': '15%', 'targets': 2 }, + { 'width': '25%', 'targets': 3, 'render': renderDate }, + ] + + ordering: true + order: [[ 1, 'asc' ]] + + dom: '<>fr<"uds-table"t>ip' + + language: gui.config.dataTablesLanguage + ) + + $('#information-groups-table').DataTable( + colReorder: true + stateSave: true + paging: true + info: false + autoWidth: false + lengthChange: false + pageLength: 10 + + columnDefs: [ + { 'width': '40%', 'targets': 0 }, + { 'width': '60%', 'targets': 1 }, + ] + + ordering: true + order: [[ 1, 'asc' ]] + + dom: '<>fr<"uds-table"t>ip' + + language: gui.config.dataTablesLanguage + ) + + + $('.goLink').on('click', (event) -> + $this = $(this); + event.preventDefault(); + gui.lookupUuid = $this.attr('href').substr(1) + $(modalId).modal('hide') + setTimeout( -> + $(".lnk-deployed_services").click(); + , 500); + ) + + return + + select: (vals, value, btn, tbl, refreshFnc) -> + unless vals.length == 1 + $(btn).addClass("disabled").prop('disabled', true) + return + + $(btn).removeClass("disabled").prop('disabled', false) + return + + } "delete" "xls" ] @@ -305,8 +430,8 @@ gui.authenticators.link = (event) -> return val = vals[0] - userAPI.invoke val.id + "/servicesPools", (pools) -> - userAPI.invoke val.id + "/userServices", (userServices) -> + user.rest.invoke val.id + "/servicesPools", (pools) -> + user.rest.invoke val.id + "/userServices", (userServices) -> user.rest.item val.id, (item) -> group.rest.overview (groups) -> # Get groups gui.doLog "Pools", pools diff --git a/server/src/uds/static/adm/js/gui-d-servicespools.coffee b/server/src/uds/static/adm/js/gui-d-servicespools.coffee index 5db23f239..17a4adc45 100644 --- a/server/src/uds/static/adm/js/gui-d-servicespools.coffee +++ b/server/src/uds/static/adm/js/gui-d-servicespools.coffee @@ -322,8 +322,9 @@ gui.servicesPools.link = (event) -> $select = $(modalId + " #id_group_select") $select.empty() # Sorts groups, expression means that "if a > b returns 1, if b > a returns -1, else returns 0" + maxCL = 32 $.each data, (undefined_, value) -> - $select.append "" + $select.append "" return diff --git a/server/src/uds/templates/uds/admin/index.html b/server/src/uds/templates/uds/admin/index.html index 29c5667a6..8e5b4db97 100644 --- a/server/src/uds/templates/uds/admin/index.html +++ b/server/src/uds/templates/uds/admin/index.html @@ -192,6 +192,7 @@ {% js_template 'service-info' %} {% js_template 'authenticators' %} {% js_template 'user-info' %} + {% js_template 'group-info' %} {% js_template 'osmanagers' %} {% js_template 'connectivity' %} {% js_template 'services_pool' %} diff --git a/server/src/uds/templates/uds/admin/tmpl/group-info.html b/server/src/uds/templates/uds/admin/tmpl/group-info.html new file mode 100644 index 000000000..58dfc5fb2 --- /dev/null +++ b/server/src/uds/templates/uds/admin/tmpl/group-info.html @@ -0,0 +1,106 @@ +{% load i18n html5 %} +{% verbatim %} + +
+
+
+
+ + + + + + + + + + + {{#each pools }} + + + + + + + {{/each }} + +
{% endverbatim %}{% trans 'Pool' %}{% verbatim %}{% endverbatim %}{% trans 'State' %}{% verbatim %}{% endverbatim %}{% trans 'Image' %}{% verbatim %}
{{ name }} {{ state }}{{ user_services_count }}
+
+
+
+
+
+
+ + + + + + + + + + + {{#each users }} + + + + + + + {{/each }} + +
{% endverbatim %}{% trans 'Name' %}{% verbatim %}{% endverbatim %}{% trans 'Real Name' %}{% verbatim %}{% endverbatim %}{% trans 'State' %}{% verbatim %}{% endverbatim %}{% trans 'Last Access' %}{% verbatim %}
{{ name }}{{ real_name }} + {{# ifequals state 'A'}}{% endverbatim %}{% trans 'Enabled' %}{% verbatim %}{{/ ifequals }} + {{# ifequals state 'I'}}{% endverbatim %}{% trans 'Disabled' %}{% verbatim %}{{/ ifequals }} + {{# ifequals state 'B'}}{% endverbatim %}{% trans 'Blocked' %}{% verbatim %}{{/ ifequals }} + {{{ last_access }}}
+
+
+
+ {{#if meta }} +
+
+
+ +
+ {{# if meta_if_any}} + {% endverbatim %}{% trans 'Any' %}{% verbatim %} + {{ else }} + {% endverbatim %}{% trans 'All' %}{% verbatim %} + {{/if }} +
+
+
+
+
+ + + + + + + + + {{#each groups_all }} + {{# ifbelongs id ../groups }} + + + + + {{/ ifbelongs}} + {{/each }} + +
{% endverbatim %}{% trans 'Name' %}{% verbatim %}{% endverbatim %}{% trans 'Comment' %}{% verbatim %}
{{ name }}{{ comments }}
+
+
+
+ {{/if }} +
+{% endverbatim %} diff --git a/server/src/uds/templates/uds/admin/tmpl/service-info.html b/server/src/uds/templates/uds/admin/tmpl/service-info.html index 51c5d9fbf..6ee124068 100644 --- a/server/src/uds/templates/uds/admin/tmpl/service-info.html +++ b/server/src/uds/templates/uds/admin/tmpl/service-info.html @@ -1,8 +1,8 @@ {% load i18n html5 %} {% verbatim %}
@@ -21,7 +21,7 @@ {% endverbatim %}{% trans 'Pool' %}{% verbatim %} {% endverbatim %}{% trans 'State' %}{% verbatim %} {% endverbatim %}{% trans 'Image' %}{% verbatim %} - + {% endverbatim %}{% trans 'User Services' %}{% verbatim %} diff --git a/server/src/uds/templates/uds/admin/tmpl/user-info.html b/server/src/uds/templates/uds/admin/tmpl/user-info.html index 12a469d80..ef8196e6a 100644 --- a/server/src/uds/templates/uds/admin/tmpl/user-info.html +++ b/server/src/uds/templates/uds/admin/tmpl/user-info.html @@ -37,7 +37,7 @@ {% endverbatim %}{% trans 'Pool' %}{% verbatim %} {% endverbatim %}{% trans 'State' %}{% verbatim %} {% endverbatim %}{% trans 'Image' %}{% verbatim %} - + {% endverbatim %}{% trans 'User Services' %}{% verbatim %}