Commit 4f7e65c6 by Belákovics Ádám

Added template information display

parent 00ea82be
......@@ -28,19 +28,22 @@ SOURCES += main.cpp\
computewidget.cpp \
controller.cpp \
vmchooserdialog.cpp \
sshdialog.cpp
sshdialog.cpp \
templatewidget.cpp
HEADERS += mainwindow.h \
computewidget.h \
controller.h \
vmchooserdialog.h \
computedata.h \
sshdialog.h
sshdialog.h \
templatewidget.h
FORMS += mainwindow.ui \
computewidget.ui \
vmchooserdialog.ui \
sshdialog.ui
sshdialog.ui \
templatewidget.ui
RESOURCES += \
resource.qrc
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.5.1, 2017-06-09T14:43:42. -->
<!-- Written by QtCreator 3.5.1, 2017-07-19T14:25:28. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
......@@ -61,7 +61,7 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{0e908da5-13d9-4d0e-8444-41a4cf76a217}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
......
......@@ -20,11 +20,10 @@ bool Controller::connect(std::string url){
*/
bool Controller::login(std::string username, std::string password){
session->circleOcciLogin(username, password);
if(username == "admin" && password == "admin"){ //TODO TODO lib should handle this
if(username == "admin" && password == "retekretek"){ //TODO TODO lib should handle this
refresh(); //initialize data
return true;
}
OcciClient::Template::getTemplates(session);
return false;
}
......@@ -35,7 +34,6 @@ void Controller::refresh(){
allCompute.clear();
for(auto c : OcciClient::Compute::getComputeInstances(session))
allCompute.push_back(c);
OcciClient::Template::getTemplates(session); //test
allTemplate.clear();
for (auto t : OcciClient::Template::getTemplates(session))
allTemplate.push_back(t);
......
......@@ -51,6 +51,17 @@ void MainWindow::addVM(std::string id, std::string name){
ui->listWidget->setItemWidget(item, cw);
}
void MainWindow::addTemplate(std::string id, std::string name){
QListWidgetItem* item = new QListWidgetItem(ui->lwTemplates);
TemplateWidget* tw = new TemplateWidget();
tw->setId(id);
tw->setName(name);
//connect
item->setSizeHint(tw->minimumSize());
ui->lwTemplates->addItem(item);
ui->lwTemplates->setItemWidget(item, tw);
}
/*!
* \brief loads all data to the UI, which are stored in Controller, DOES NOT COMMUNICATE WITH THE CLOUD SERVER!!
*/
......@@ -60,8 +71,9 @@ void MainWindow::loadAllData(){
for(size_t i = 0; i < VM_names.size(); i++)
addVM(std::to_string(i), VM_names.at(i));
ui->lwTemplates->clear();
for(auto t : myController.getTemplates())
ui->lwTemplates->addItem(t.c_str());
auto templateNames = myController.getTemplates();
for(size_t i = 0; i < templateNames.size(); i++)
addTemplate(std::to_string(i), templateNames.at(i));
}
/*!
......@@ -230,7 +242,7 @@ void MainWindow::on_bNewVM_clicked()
VMChooserDialog* v = new VMChooserDialog(this);
v->setWindowTitle("New Virtual Machine");
v->set_templates(OcciClient::Template::getTemplates(myController.session));
connect(v, SIGNAL(send_chosen_template(OcciClient::Template)), this, SLOT(receive_chosen_template(OcciClient::Template)));
connect(v, SIGNAL(send_chosen_template(std::shared_ptr<OcciClient::Template>)), this, SLOT(receive_chosen_template(std::shared_ptr<OcciClient::Template>)));
v->exec();
}
......@@ -265,7 +277,6 @@ void MainWindow::on_bConnect_clicked()
QTermWidget* console = new QTermWidget(0);
console->setShellProgram("/usr/bin/sshpass");
QString connString = currentSelectedVM.connString.c_str();
//QString connString = "-p WdqxhS7BmK ssh -o StrictHostKeyChecking=no cloud@vm.ik.bme.hu -p 3309"; //test stub
QStringList args = connString.split(" ");
console->setArgs(args);
......
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <iostream>
#include <fstream>
#include <string>
#include <QMainWindow>
#include <QLabel>
#include <QPushButton>
#include <QListWidget>
#include <computewidget.h>
#include <qtermwidget5/qtermwidget.h>
#include "computewidget.h"
#include "libocci/occilib.h"
#include "controller.h"
#include "vmchooserdialog.h"
#include <qtermwidget5/qtermwidget.h>
#include <iostream>
#include <fstream>
#include <string>
#include "templatewidget.h"
namespace Ui {
class MainWindow;
......@@ -26,6 +32,7 @@ public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
void addVM(std::string id, std::string name);
void addTemplate(std::string id, std::string name);
void loadAllData();
void loadVMData(std::string id);
std::string parseConfig();
......
......@@ -164,7 +164,7 @@
<string/>
</property>
<property name="text">
<string>admin</string>
<string>retekretek</string>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
......@@ -791,49 +791,10 @@
<string>Templates</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_6">
<item row="1" column="0">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<item row="0" column="0">
<widget class="QListWidget" name="lwTemplates"/>
</item>
<item row="0" column="1">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......
#include "templatewidget.h"
#include "ui_templatewidget.h"
TemplateWidget::TemplateWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::TemplateWidget)
{
ui->setupUi(this);
ui->lTemplatePic->setPixmap(QPixmap(":/new/icons/compute.png").scaled(80, 55, Qt::KeepAspectRatio));
}
void TemplateWidget::setId(std::string id){
this->id = id;
}
void TemplateWidget::setName(std::string name){
this->name = name;
ui->lTemplateName->setText(name.c_str());
}
TemplateWidget::~TemplateWidget()
{
delete ui;
}
#ifndef TEMPLATEWIDGET_H
#define TEMPLATEWIDGET_H
#include <QWidget>
namespace Ui {
class TemplateWidget;
}
class TemplateWidget : public QWidget
{
Q_OBJECT
public:
explicit TemplateWidget(QWidget *parent = 0);
void setId(std::string id);
void setName(std::string name);
~TemplateWidget();
private:
std::string id;
std::string name;
Ui::TemplateWidget *ui;
};
#endif // TEMPLATEWIDGET_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TemplateWidget</class>
<widget class="QWidget" name="TemplateWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>624</width>
<height>217</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>100</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="lTemplatePic">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lTemplateName">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="2" rowspan="2">
<widget class="QPushButton" name="bVMStart">
<property name="text">
<string>Start new instance</string>
</property>
</widget>
</item>
<item row="0" column="1" rowspan="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment