summaryrefslogtreecommitdiffstats
path: root/ogcp/forms/action_forms.py
blob: 4d5d52aa193b4e58999f768f246de3382ae3d5d9 (plain)
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# Copyright (C) 2020-2024 Soleta Networks <info@soleta.eu>
#
# 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.

from wtforms import (
    Form, SubmitField, HiddenField, SelectField, BooleanField, IntegerField,
    StringField, RadioField, FormField, FieldList, DecimalField, TextAreaField,
    SelectMultipleField
)
from wtforms.validators import InputRequired
from flask_wtf import FlaskForm
from flask_babel import lazy_gettext as _l
from flask_babel import _


class GenericForm(FlaskForm):
    ips = HiddenField()
    ids = HiddenField()
    server = HiddenField()
    submit = SubmitField(label=_l('Submit'))


class WOLForm(FlaskForm):
    ips = HiddenField()
    wol_type = SelectField(label=_l('Type'),
                           choices=[('broadcast', 'Broadcast'),
                                    ('unicast', 'Unicast')])
    submit = SubmitField(label=_l('Submit'))

class PartitionForm(FlaskForm):
    partition = IntegerField(label=_l('Partition'),
                             render_kw={'readonly': True},
                             default=1)
    part_type = SelectField(label=_l('Type'),
                            validators=[InputRequired()],
                            choices=[('LINUX', 'Linux'),
                                     ('NTFS', 'NTFS'),
                                     ('CACHE', 'CACHE'),
                                     ('EFI', 'EFI'),
                                     ('DATA', 'DATA'),
                                     ('LINUX-SWAP', 'LINUX-SWAP'),
                                     ('EXTENDED', 'EXTENDED'),
                                     ('FAT32', 'FAT32'),
                                     ('LINUX-LVM', 'LINUX-LVM'),
                                     ('LINUX-RAID', 'LINUX-RAID'),
                                     ('WIN-RECOV', 'WIN-RECOV'),
                                     ('HNTFS', 'HNTFS'),
                                     ('HFAT32', 'HFAT32'),
                                     ('HNTFS-WINRE', 'HNTFS-WINRE'),
                                     ('EMPTY', 'Empty')],
                            default='EMPTY')
    fs = SelectField(label=_l('Filesystem'),
                     validators=[InputRequired()],
                     choices=[('EXT4', 'EXT4'),
                              ('NTFS', 'NTFS'),
                              ('CACHE', 'CACHE'),
                              ('LINUX-SWAP', 'LINUX-SWAP'),
                              ('FAT32', 'FAT32'),
                              ('EMPTY', 'Empty')],
                     default='EMPTY')
    size = IntegerField(label=_l('Size (KB)'), validators=[InputRequired()],)

class SelectClientForm(FlaskForm):
    ips = HiddenField()
    selected_client = SelectField(label=_l('Select one client as reference to '
                                           'define the partition scheme'))
    submit = SubmitField(label=_l('Select'))

class SetupForm(FlaskForm):
    ips = HiddenField()
    disk = SelectField(label='Disk', validate_choice=False)
    disk_type = SelectField(label=_l('Type'),
                            choices=[('MSDOS', 'MBR'),
                                     ('GPT', 'GPT')])
    partitions = FieldList(FormField(PartitionForm),
                           min_entries=1,
                           max_entries=16)

class HardwareForm(FlaskForm):
    ips = HiddenField()
    refresh = SubmitField(label=_l('Refresh'))

class SoftwareForm(FlaskForm):
    ips = HiddenField()
    os = SelectField(label=_l('Partition'), choices=[])
    view = SubmitField(label=_l('View'))
    update = SubmitField(label=_l('Update'))

class SessionForm(FlaskForm):
    ips = HiddenField()
    os = RadioField(label=_l('Session'), choices=[])

class CacheImage(FlaskForm):
    selected = BooleanField()
    image_name = HiddenField()
    clients = HiddenField()

class CacheForm(FlaskForm):
    ips = HiddenField()
    images = FieldList(FormField(CacheImage))

class ImageRestoreForm(FlaskForm):
    ips = HiddenField()
    partition = SelectField(label=_l('Partition'), choices=[])
    image = SelectField(label=_l('Image'), choices=[])
    method = SelectField(label=_l('Method'),
                         choices=[('TIPTORRENT', 'TIPTORRENT'),
                                  ('UNICAST', 'UNICAST'),
                                  ('UNICAST-DIRECT', 'UNICAST-DIRECT')])
    restore = SubmitField(label=_l('Restore'))

class ImageFetchForm(FlaskForm):
    ips = HiddenField()
    image = SelectField(label=_l('Image'), choices=[])
    method = SelectField(label=_l('Method'),
                         choices=[('TIPTORRENT', 'TIPTORRENT'),
                                  ('UNICAST', 'UNICAST')])
    submit = SubmitField(label=_l('Submit'))

class RepoForm(FlaskForm):
    server = HiddenField()
    repo_id = HiddenField()
    name = StringField(label=_l('Name'))
    addr = FieldList(
        StringField(label=_l('Address')),
        label=_l('Addresses'),
    )
    submit = SubmitField(label=_l('Submit'))

class FolderForm(FlaskForm):
    folder_id = HiddenField()
    server = HiddenField()
    room = HiddenField()
    center = HiddenField()
    name = StringField(label=_l('Name'))
    submit = SubmitField(label=_l('Submit'))

class ClientDetailsForm(FlaskForm):
    server = HiddenField()
    client_id = HiddenField()
    name = StringField(label=_l('Name'),
                       validators=[InputRequired()])
    ip = StringField(label=_l('IP'),
                     validators=[InputRequired()])
    mac = StringField(label=_l('MAC'),
                      validators=[InputRequired()])
    serial_number = StringField(label=_l('Serial Number'))
    livedir = SelectField(label=_l('ogLive'),
                          choices=[('ogLive', 'Default'),])
    remote = BooleanField(label=_l('Remote'))
    maintenance = BooleanField(label=_l('Maintenance'))
    repo = SelectField(label=_l('Repository'), validate_choice=False)
    room = SelectField(label=_l('Room'), validate_choice=False)
    folder_id = HiddenField()
    boot = SelectField(label=_l('Boot Mode'), validate_choice=False)
    submit = SubmitField(label=_l('Submit'))

class ClientMoveForm(FlaskForm):
    ips = HiddenField()
    scopes = SelectField(label=_l('Scopes'), validate_choice=False)
    submit = SubmitField(label=_l('Submit'))

class RunScriptForm(FlaskForm):
    ips = HiddenField()
    script = SelectField(label=_l('Script'),
                                  choices=[],
                                  validators=[InputRequired()],
                                  validate_choice=False)
    arguments = StringField(label=_l('Arguments'))
    submit = SubmitField(label=_l('Submit'))

class RunCmdForm(FlaskForm):
    ips = HiddenField()
    command = StringField(label=_l('Command'))
    submit = SubmitField(label=_l('Submit'))

class ImportClientsForm(FlaskForm):
    server = HiddenField()
    room = SelectField(label=_l('Room'))
    repo = SelectField(label=_l('Repository'))
    client_conf = TextAreaField(label=_l('Client configuration'))
    import_btn = SubmitField(label=_l('Import'))

class BootModeForm(FlaskForm):
    ips = HiddenField()
    boot = SelectField(label=_l('Boot mode'))
    ok = SubmitField(label=_l('Submit'))

class OgliveForm(FlaskForm):
    ips = HiddenField()
    server = HiddenField()
    oglive = SelectField(label=_l('ogLive'))
    ok = SubmitField(label=_l('Submit'))

class SetRepoForm(FlaskForm):
    ips = HiddenField()
    repo = SelectField(label=_l('Repository'))
    ok = SubmitField(label=_l('Submit'))

class ImageCreateForm(FlaskForm):
    ip = HiddenField()
    os = SelectField(label=_l('Partition'), choices=[])
    name = StringField(label=_l('Image name'),
                       validators=[InputRequired()])
    description = StringField(label=_l('Description'))
    repository = SelectField(label=_l('Repository'), choices=[],
                             validators=[InputRequired()])
    create = SubmitField(label=_l('Create'))


class ImageUpdateForm(FlaskForm):
    ip = HiddenField()
    os = SelectField(label=_l('Partition'), choices=[])
    image = SelectField(label=_l('Image'), choices=[])
    backup = BooleanField(label=_l('Backup'))
    update = SubmitField(label=_l('Update'))


class CenterForm(FlaskForm):
    server = SelectField(label=_l('Server'),
                         validators=[InputRequired()])
    center = HiddenField()
    name = StringField(label=_l('Center name'),
                       validators=[InputRequired()])
    comment = StringField(label=_l('Comment'))
    submit = SubmitField(label=_l('Submit'))

class DeleteCenterForm(FlaskForm):
    server = HiddenField()
    center = HiddenField()
    submit = SubmitField(label=_l('Submit'))

class RoomForm(FlaskForm):
    server = HiddenField()
    room = HiddenField()
    center = SelectField(label=_l('Center'),
                         validators=[InputRequired()])
    name = StringField(label=_l('Room name'),
                       validators=[InputRequired()])
    netmask = StringField(label=_l('Netmask'),
                          validators=[InputRequired()])
    gateway = StringField(label=_l('Gateway'),
                          validators=[InputRequired()])
    folder_id = HiddenField()
    submit = SubmitField(label=_l('Submit'))

class DeleteRoomForm(FlaskForm):
    server = HiddenField()
    room = HiddenField()
    submit = SubmitField(label=_l('Submit'))

class ImageDetailsForm(FlaskForm):
    name = StringField(label=_l('Name'))
    description = StringField(label=_l('Description'))
    size = DecimalField(label=_l('Size (MiB)'))
    datasize = DecimalField(label=_l('Datasize (MiB)'))
    modified = StringField(label=_l('Last update'))
    permissions = StringField(label=_l('Permissions'))
    software_id = StringField(label=_l('Software id'))
    checksum = StringField(label=_l('Checksum'))
    scopes = SelectMultipleField(
        label=_l('Allowed scopes'),
        description=_l('No scope selection gives full access'),
    )

class ImageConfigForm(FlaskForm):
    image_id = HiddenField()
    server = HiddenField()
    name = HiddenField()
    scopes = SelectMultipleField(
        label=_l('Allowed scopes'),
        description=_l('No scope selection gives full access'),
    )
    submit = SubmitField(label=_l('Submit'))

class ServerForm(FlaskForm):
    name = StringField(label=_l('Name'),
                       validators=[InputRequired()])
    ip = StringField(label=_l('IP'),
                     validators=[InputRequired()])
    port = StringField(label=_l('Port'),
                     validators=[InputRequired()])
    api_token = StringField(label=_l('API token'),
                     validators=[InputRequired()])
    submit = SubmitField(label=_l('Submit'))

class ServerConfigurationForm(FlaskForm):
    server_addr = HiddenField()
    addr = FieldList(
        StringField(label=_l('Address')),
        label=_l('Addresses'),
    )
    submit = SubmitField(label=_l('Submit'))

class DeleteRepositoryForm(FlaskForm):
    repository = SelectField(label=_l('Repository'),
                             validators=[InputRequired()])
    submit = SubmitField(label=_l('Submit'))