File size: 5,798 Bytes
a6b6b45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
{% extends 'base.html' %}

{% block content %}
<style>

    html, body {

        height: 50%;

        margin: 0;

    }



    .container {

        display: flex;

        flex-direction: column;

        height: 80vh; /* Fill the viewport height */

    }



    .card {

        margin: auto;

        background-color: #2c2c3e;

        color: #f5f5f5;

        border: none;

        width: 50%;

        height: 70%; /* Fixed height for the card */

        display: flex;

        flex-direction: column;

        justify-content: space-between;

        padding: 1rem;

    }



    .card-header {

        background-color: #181831;

        border-bottom: 2px solid #444;

        padding: 1rem;

        text-align: center;

    }



    .form-label {

        font-weight: bold;

        color: #cfcfcf;

    }



    .form-control {

        background-color: #1e1e2f;

        color: #f5f5f5;

        border: 1px solid #444;

    }



    .form-control:focus {

        background-color: #1e1e2f;

        color: #f5f5f5;

        border-color: #4c4cff;

        box-shadow: 0 0 4px #4c4cff;

    }



    .button-spinner {

        display: none;

        border: 2px solid #f5f5f5;

        border-radius: 50%;

        border-top: 2px solid #4c4cff;

        width: 24px;

        height: 24px;

        animation: spin 1s linear infinite;

    }

    

    @keyframes spin {

        0% { transform: rotate(0deg); }

        100% { transform: rotate(360deg); }

    }

    

    .btn:active .button-spinner {

        display: block;

    }





    .btn-primary {

        background-color: #4c4cff;

        border-color: #4c4cff;

        display: flex;

        justify-content: center;

        align-items: center;

    }



    .btn-primary:hover {

        background-color: #3838e8;

        border-color: #3838e8;

    }



    .toggle-switch {

        margin: 1rem 0;

        display: flex;

        justify-content: center;

        align-items: center;

    }



    .toggle-switch input {

        display: none;

    }



    .toggle-label {

        background-color: #444;

        color: #cfcfcf;

        padding: 0.5rem 1.5rem;

        border: 1px solid #555;

        cursor: pointer;

        margin-right: 1rem;

        text-align: center;

        border-radius: 4px;

    }



    .toggle-label.active {

        background-color: #4c4cff;

        color: #fff;

    }



    .toggle-label:hover {

        background-color: #3838e8;

        color: #fff;

    }



    .hidden {

        display: none;

    }



    .text-center.d-flex {

        display: flex;

        justify-content: center;

        align-items: center;

        height: 100px;

    }

</style>

<div class="container mt-5">
    <div class="card shadow">
        <div class="card-header">
            <h3>Create a New Vector Database</h3>
        </div>
        <div class="card-body">
            <form id="db-form" method="post" enctype="multipart/form-data">
                <!-- Database Name Input -->
                <div class="form-group">
                    <label for="db_name" class="form-label">Database Name</label>
                    <input type="text" id="db_name" name="db_name" class="form-control" placeholder="Enter database name" required>
                </div>

                <!-- Toggle Upload Mode -->
                <div class="toggle-switch">
                    <label class="toggle-label active" id="folder-label" for="folder">Upload Folder</label>
                    <label class="toggle-label" id="file-label" for="file">Upload Files</label>
                </div>

                <!-- Folder Upload Input -->
                <div id="folder-upload" class="form-group mt-3 hidden">
                    <label for="folder" class="form-label">Upload Folder</label>
                    <input type="file" id="folder" name="folder" class="form-control" webkitdirectory directory multiple>
                    <small class="text-muted">Note: You can upload a folder containing multiple files.</small>
                </div>

                <!-- Single File Upload Input -->
                <div id="file-upload" class="form-group mt-3 hidden">
                    <label for="file" class="form-label">Upload Files</label>
                    <input type="file" id="file" name="file" class="form-control" multiple >
                    <small class="text-muted">Note: You can upload one or more files.</small>
                </div>

                <!-- Submit Button -->
                <div class="mt-4 text-center d-flex justify-content-center align-items-center">
                    <button type="submit" class="btn btn-primary px-5">
                        <span class="btn-text">Create</span>
                        <div class="button-spinner"></div>
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>

<script>

    const folderLabel = document.getElementById('folder-label');

    const fileLabel = document.getElementById('file-label');

    const folderUpload = document.getElementById('folder-upload');

    const fileUpload = document.getElementById('file-upload');



    // Toggle upload mode

    folderLabel.addEventListener('click', () => {

        folderLabel.classList.add('active');

        fileLabel.classList.remove('active');

        folderUpload.classList.remove('hidden');

        fileUpload.classList.add('hidden');

    });



    fileLabel.addEventListener('click', () => {

        fileLabel.classList.add('active');

        folderLabel.classList.remove('active');

        fileUpload.classList.remove('hidden');

        folderUpload.classList.add('hidden');

    });

</script>

{% endblock %}