#ifndef DEVICEHUBWINDOW_H
#define DEVICEHUBWINDOW_H

#include <QWidget>
#include <QComboBox>

#include "common/HttpRequestController.h"
#include "common/HttpServer.h"
#include "common/utils/QKafkaConsumer.h"
#include "device/DeviceBase.h"
#include "FrequencyTuningForm.h"
#include "SignalGeneratorForm.h"
#include "TimeSwitcherForm.h"
#include "FreqSwitcherForm.h"
#include "BCodeTerminalForm.h"
#include "TimeReplicatorForm.h"
#include "FreqReplicatorForm.h"
#include "NtpServerForm.h"

QT_BEGIN_NAMESPACE
namespace Ui { class DeviceHubWindow; }
QT_END_NAMESPACE

class DeviceHubWindow : public QWidget
{
    Q_OBJECT

public:
    DeviceHubWindow(QWidget *parent = nullptr);
    ~DeviceHubWindow();

    QString currentDevType;
    int currentDevIndex;
    QMap<QString, QList<DeviceBase *>> allTypeDevList;

    QKafkaConsumer * kafkaConsumer;

    QComboBox * getDevTypeSelect();
    QComboBox * getDevSelect();

    // forms
    FrequencyTuningForm * freqTunForm;
    SignalGeneratorForm * signGenForm;
    TimeSwitcherForm * tmSwitForm;
    FreqSwitcherForm * freqSwitForm;
    BCodeTerminalForm * bCodeTermForm;
    TimeReplicatorForm * timeRepForm;
    FreqReplicatorForm * freqRepForm;
    NtpServerForm * ntpServForm;

private slots:
    void on_minButt_clicked();
    void on_exitButt_clicked();
    void on_devTypeSelect_currentIndexChanged(int index);

    void on_devSelect_currentIndexChanged(int index);

private:
    Ui::DeviceHubWindow *ui;

    // private objects
    HttpRequestController * httpReq;

    int initHttpToken();
    int initDictDeviceTypes();
    void initAllDeviceList();
    void initDeviceForm(QString devType);
};
#endif // DEVICEHUBWINDOW_H
