File size: 12,022 Bytes
c7525e3
 
294253d
 
 
 
 
 
c7525e3
294253d
c7525e3
294253d
 
 
c7525e3
 
 
294253d
c7525e3
 
 
294253d
c7525e3
 
294253d
c7525e3
294253d
c7525e3
294253d
 
c7525e3
 
 
294253d
 
 
c7525e3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
294253d
c7525e3
 
 
 
 
 
 
 
 
c532f8a
c7525e3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
294253d
c7525e3
294253d
c7525e3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
294253d
 
 
c7525e3
 
294253d
c7525e3
294253d
 
 
 
 
 
 
c7525e3
294253d
c7525e3
 
 
 
294253d
c7525e3
 
 
 
 
 
294253d
c7525e3
 
294253d
 
 
 
 
c7525e3
 
 
294253d
c7525e3
 
294253d
 
c7525e3
294253d
 
c7525e3
 
 
 
 
294253d
c7525e3
 
 
 
 
 
294253d
 
c7525e3
 
 
 
 
 
 
294253d
c7525e3
 
 
 
 
 
 
 
 
 
 
294253d
c7525e3
 
 
 
294253d
c7525e3
294253d
c7525e3
294253d
c7525e3
294253d
c7525e3
294253d
c7525e3
 
 
 
 
 
 
 
 
 
294253d
c7525e3
294253d
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<!-- sidepane.html -->
<!-- This file represents the sidepane component of a web application. It contains the navigation menu and sidebar. -->
<!DOCTYPE html>
<html lang="en">

<head>

    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <!-- Include Bootstrap JS -->
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.bundle.min.js"></script>
     <link rel="stylesheet" href="/static/css/sidepane.css">
</head>

<body>


    <nav class="main-header navbar navbar-expand navbar-light bg-white shadow-sm" style="padding: 15px; position: sticky;top: 0%; z-index: 100 !important; ">
        <div class="container-fluid d-flex justify-content-between align-items-center">
            <!-- Toggle Sidebar Button -->
            <button class="btn btn-outline-secondary" id="sidebarToggle" style="margin-right: 15px;display: none">
                <i class="fas fa-bars"></i>
            </button>

            <!-- Logo and Title Section -->
            <div class="d-flex align-items-center">
                <img src="/static/img/redmindlogo3.jpg" alt="Logo"

                    style="width: 70px; height: auto; margin-right: 15px;">
                <h3 class="m-0" style="font-weight: 500;">RedMindGPT - {{title}}</h3>
            </div>

            <!-- Buttons Section -->
            <div>
                <button class="btn btn-primary" onclick="logout()">Logout</button>
            </div>
        </div>
    </nav>
    <div id="wrapper">
        <!-- Main Sidebar Container -->
        <aside class="main-sidebar sidebar-custom elevation-4" id="sidebarPanel" style=" position: fixed">
            <!-- Sidebar -->
            <div class="sidebar">
                <!-- Sidebar Menu -->
                <nav class="mt-2">
                    <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu"

                        data-accordion="false" id="sidebarMenu">
                        <input type="hidden" id="userRole" name="userRole" value={{role}}>
                        <input type="hidden" id="company_id" name="company_id" value={{company_id}}>
                        <div class="form-group" style="display: none;">
                            <label for="llm_tools">LLM Tools<span class="text-danger">*</span></label>
                            <select class="form-control" id="llm_tools" name="llm_tools" multiple required

                                style="display: none;">
                                <option value="Database">Database</option>
                                <option value="Static Documents">Static Documents</option>
                                <option value="API">API</option>
                            </select>
                            <div class="invalid-feedback">
                                Please select at least one LLM tool.
                            </div>
                        </div>

                        <li class="nav-item">
                            <a href="{{url_for('dashboard')}}" class="nav-link">
                                <i class="nav-icon fas fa-home"></i>
                                <p>Dashboard</p>
                            </a>
                        </li>
                        <li class="nav-item">
                            <div class="sidebar-header">
                                <i class="nav-icon fas fa-building"></i>
                                <span class="menu-text" id="selectedCompany" style="margin-left: -6px;">Select a company</span>
                                <!-- Initial text as fallback -->
                                <!-- <span class="menu-text" id="selectedCompany">{{company_name}}</span> -->
                            </div>
                        </li>

                        <li class="nav-item">
                            <a href="{{ url_for('company_profile') }}" class="nav-link">
                                <i class="nav-icon fas fa-users"></i>
                                <p>Company Profile</p>
                            </a>
                        </li>
                        <li class="nav-item" id="knowledgebase_link">
                            <a href="{{ url_for('knowledgebase') }}" class="nav-link">
                                <i class="nav-icon fas fa-cogs"></i>
                                <p>KnowledgeBase</p>
                            </a>
                        </li>
                        <li class="nav-item" id="data_connectors_link">
                            <a href="{{ url_for('data_connectors') }}" class="nav-link">
                                <i class="nav-icon fas fa-cogs"></i>
                                <p>Data Connectors</p>
                            </a>
                        </li>
                        <li class="nav-item" id="api_connectors_link">
                            <a href="{{ url_for('API_connectors') }}" class="nav-link">
                                <i class="nav-icon fas fa-cogs"></i>
                                <p>API Connectors</p>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a href="{{url_for('prompt_template')}}" class="nav-link">
                                <i class="nav-icon fas fa-cogs"></i>
                                <p>Prompt Templates</p>
                            </a>
                        </li>
                        <!--<li class="nav-item">

                    <a href="#" class="nav-link">

                        <i class="nav-icon fas fa-cogs"></i>

                        <p>LLM Settings</p>

                    </a>

                    <ul class="nav nav-treeview">

                        <li class="nav-item">

                            <a href="#" class="nav-link">

                                <i class="far fa-circle nav-icon"></i>

                                <p>Sublink 1</p>

                            </a>

                        </li>

                        <li class="nav-item">

                            <a href="#" class="nav-link">

                                <i class="far fa-circle nav-icon"></i>

                                <p>Sublink 2</p>

                            </a>

                        </li>

                        

                    </ul>

                </li> -->

                        <!-- Add more navigation links here -->
                    </ul>
                </nav>
                <!-- /.sidebar-menu -->
            </div>
            <!-- /.sidebar -->
        </aside>


        <input type="hidden" id="userRole" name="userRole" value={{role}}>
        <input type="hidden" id="company_id" name="company_id" value={{company_id}}>
        <div class="form-group" style="display: none;">
            <label for="llm_tools">LLM Tools<span class="text-danger">*</span></label>
            <select class="form-control" id="llm_tools" name="llm_tools" multiple required style="display: none;">
                <option value="Database">Database</option>
                <option value="Static Documents">Static Documents</option>
                <option value="API">API</option>
            </select>
            <div class="invalid-feedback">
                Please select at least one LLM tool.
            </div>
        </div>
    </div>

    <!-- AdminLTE JS -->

    <script>



        function logout() {

            sessionStorage.removeItem('role');

            sessionStorage.clear();

            window.location.href = '/';

        }





        document.addEventListener("DOMContentLoaded", function () {



            const company_id1 = document.getElementById("company_id").value;

            const role1 = document.getElementById("userRole").value;

            sessionStorage.setItem('siderole1', role1);

            sessionStorage.setItem('sidecompanyId1', company_id1);



            const sidecompanyId = sessionStorage.getItem('sidecompanyId1');

            const siderole = sessionStorage.getItem('siderole1');

            if (siderole === 'admin') {

                console.log("Company ID inside sidepane:", sidecompanyId);

                console.log("Role inside sidepane:", siderole);

                editCompany(sidecompanyId, siderole);



                console.log("inside admin after edit");

                updateLinkVisibility(siderole);



            }



        });



        async function updateLinkVisibility(siderole) {

            //const role = sessionStorage.getItem('role');

            if (siderole === 'admin') {

                const displayState = JSON.parse(sessionStorage.getItem('displayState'));



                // Update the visibility of links based on the stored state

                document.getElementById('api_connectors_link').style.display = displayState.apiConnectors;

                document.getElementById('knowledgebase_link').style.display = displayState.knowledgeBase;

                document.getElementById('data_connectors_link').style.display = displayState.dataConnectors

            }

        }

        async function editCompany(sidecompanyId, siderole) {

            console.log("inside edit company id", sidecompanyId);

            console.log("inside edit role role", siderole);

            $.getJSON(`/api/getcompanydetails/${sidecompanyId}`, function (company) {

                // Set the value of #llm_tools and trigger change event

                $('#llm_tools').val(company.llm_tools.split(',')).trigger('change');



                // Get the selected values from #llm_tools

                const llmTools = $('#llm_tools').val(); // This is an array



                console.log("inside sidepane edit llmTools", llmTools);

                //const role =sessionStorage.getItem('role');



                if (llmTools && llmTools.length > 0) {

                    console.log("inside if");



                    // Example: Conditionally display some links based on llm_tools

                    if (api_connectors_link) {

                        api_connectors_link.style.display = llmTools.includes('API') ? 'block' : 'none';

                        console.log("state api", api_connectors_link.style.display);

                    }



                    if (knowledgebase_link) {

                        knowledgebase_link.style.display = llmTools.includes('Static Documents') ? 'block' : 'none';

                        console.log("state know", knowledgebase_link.style.display);

                    }



                    if (data_connectors_link) {

                        data_connectors_link.style.display = llmTools.includes('Database') ? 'block' : 'none';

                        console.log("state dataconn", data_connectors_link.style.display);

                    }



                    console.log("inside storageadmin");

                    sessionStorage.setItem('displayState', JSON.stringify({

                        apiConnectors: api_connectors_link.style.display,

                        knowledgeBase: knowledgebase_link.style.display,

                        dataConnectors: data_connectors_link.style.display



                    }));

                    updateLinkVisibility(siderole);

                }



            }).fail(function () {

                alert("Error retrieving company details.");

            });



        }

        document.getElementById('sidebarToggle').addEventListener('click', function () {

            const sidebar = document.getElementById('sidebarPanel');



            if (sidebar.style.display === 'block') {

                sidebar.style.display = 'none';

            } else {

                sidebar.style.display = 'block';

            }



        });

    </script>

</body>

</html>