MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / ServerGroupModule

Class ServerGroupModule

web/pgadmin/browser/server_groups/__init__.py:53–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51
52
53class ServerGroupModule(BrowserPluginModule):
54 _NODE_TYPE = "server_group"
55 node_icon = "icon-%s" % _NODE_TYPE
56
57 @property
58 def csssnippets(self):
59 """
60 Returns a snippet of css to include in the page
61 """
62 snippets = [render_template("css/server_group.css")]
63
64 for submodule in self.submodules:
65 snippets.extend(submodule.csssnippets)
66
67 return snippets
68
69 @staticmethod
70 def has_shared_server(gid):
71 """
72 To check whether given server group contains shared server or not
73 :param gid:
74 :return: True if servergroup contains shared server else false
75 """
76 servers = Server.query.filter_by(servergroup_id=gid)
77 for s in servers:
78 if s.shared:
79 return True
80 return False
81
82 def get_nodes(self, *arg, **kwargs):
83 """Return a JSON document listing the server groups for the user"""
84
85 if config.SERVER_MODE:
86 groups = ServerGroupView.get_all_server_groups()
87 else:
88 groups = ServerGroup.query.filter_by(
89 user_id=current_user.id
90 ).order_by("id")
91
92 for idx, group in enumerate(groups):
93 icon_class, is_shared = get_icon_css_class(group.id, group.user_id)
94 yield self.generate_browser_node(
95 "%d" % (group.id), None,
96 group.name,
97 icon_class,
98 True,
99 self.node_type,
100 can_delete=True if idx > 0 else False,
101 user_id=group.user_id,
102 is_shared=is_shared
103 )
104
105 @property
106 def node_type(self):
107 """
108 node_type
109 Node type for Server Group is server-group. It is defined by _NODE_TYPE
110 static attribute of the class.

Callers 1

__init__.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected