Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
user-client
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7a7d24d7
authored
7 years ago
by
Belákovics Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
masodik iteracio
parent
a4adc867
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
342 additions
and
100 deletions
+342
-100
computedata.h
+1
-0
computewidget.cpp
+19
-14
computewidget.h
+6
-7
computewidget.ui
+7
-14
controller.cpp
+23
-4
controller.h
+4
-1
mainwindow.cpp
+131
-30
mainwindow.h
+7
-3
mainwindow.ui
+144
-27
No files found.
computedata.h
View file @
7a7d24d7
...
@@ -8,6 +8,7 @@ struct ComputeData{
...
@@ -8,6 +8,7 @@ struct ComputeData{
int
cores
;
int
cores
;
std
::
string
hostname
;
std
::
string
hostname
;
int
port
;
std
::
string
username
;
std
::
string
username
;
std
::
string
password
;
std
::
string
password
;
};
};
...
...
This diff is collapsed.
Click to expand it.
computewidget.cpp
View file @
7a7d24d7
...
@@ -28,22 +28,27 @@ void ComputeWidget::on_bRenew_clicked()
...
@@ -28,22 +28,27 @@ void ComputeWidget::on_bRenew_clicked()
emit
renew
(
id
);
emit
renew
(
id
);
}
}
void
ComputeWidget
::
on_bWakeUp_clicked
()
void
ComputeWidget
::
on_bStart_clicked
()
{
emit
wakeup
(
id
);
}
void
ComputeWidget
::
on_bSleep_clicked
()
{
emit
sleep
(
id
);
}
void
ComputeWidget
::
on_pushButton_clicked
()
{
{
//TODO
emit
start
(
id
);
}
}
void
ComputeWidget
::
on_b
Start
_clicked
()
void
ComputeWidget
::
on_b
WakeUpSleep
_clicked
()
{
{
emit
start
(
id
);
emit
wakeupsleep
(
id
);
}
void
ComputeWidget
::
stateChangedHandler
(
std
::
string
newState
,
std
::
string
_id
){
if
(
id
==
_id
){
//check if we changed or not
if
(
newState
==
"suspended"
||
newState
==
"inactive"
){
ui
->
bWakeUpSleep
->
setText
(
"Wake up"
);
ui
->
bWakeUpSleep
->
setStyleSheet
(
"background-color:green"
);
}
else
if
(
newState
==
"active"
){
ui
->
bWakeUpSleep
->
setText
(
"Sleep"
);
ui
->
bWakeUpSleep
->
setStyleSheet
(
"background-color:yellow"
);
}
else
throw
std
::
runtime_error
(
"undefined VM state!"
);
}
}
}
This diff is collapsed.
Click to expand it.
computewidget.h
View file @
7a7d24d7
...
@@ -22,20 +22,19 @@ public:
...
@@ -22,20 +22,19 @@ public:
signals
:
signals
:
void
start
(
std
::
string
id
);
void
start
(
std
::
string
id
);
void
sleep
(
std
::
string
id
);
void
wakeupsleep
(
std
::
string
id
);
void
wakeup
(
std
::
string
id
);
void
renew
(
std
::
string
id
);
void
renew
(
std
::
string
id
);
public
slots
:
void
stateChangedHandler
(
std
::
string
newState
,
std
::
string
id
);
private
slots
:
private
slots
:
void
on_bRenew_clicked
();
void
on_bRenew_clicked
();
void
on_bWakeUp_clicked
();
void
on_bStart_clicked
();
void
on_bSleep_clicked
();
void
on_
pushButton
_clicked
();
void
on_
bWakeUpSleep
_clicked
();
void
on_bStart_clicked
();
private
:
private
:
Ui
::
ComputeWidget
*
ui
;
Ui
::
ComputeWidget
*
ui
;
...
...
This diff is collapsed.
Click to expand it.
computewidget.ui
View file @
7a7d24d7
...
@@ -22,21 +22,21 @@
...
@@ -22,21 +22,21 @@
<layout
class=
"QGridLayout"
name=
"gridLayout_2"
>
<layout
class=
"QGridLayout"
name=
"gridLayout_2"
>
<item
row=
"0"
column=
"0"
>
<item
row=
"0"
column=
"0"
>
<layout
class=
"QGridLayout"
name=
"gridLayout"
>
<layout
class=
"QGridLayout"
name=
"gridLayout"
>
<item
row=
"
7"
column=
"3
"
rowspan=
"2"
>
<item
row=
"
6"
column=
"2
"
rowspan=
"2"
>
<widget
class=
"QPushButton"
name=
"bRenew"
>
<widget
class=
"QPushButton"
name=
"bRenew"
>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
Renew
</string>
<string>
Renew
</string>
</property>
</property>
</widget>
</widget>
</item>
</item>
<item
row=
"
5"
column=
"3
"
rowspan=
"2"
>
<item
row=
"
4"
column=
"2
"
rowspan=
"2"
>
<widget
class=
"QPushButton"
name=
"bWakeUp"
>
<widget
class=
"QPushButton"
name=
"bWakeUp
Sleep
"
>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
Wake up
</string>
<string>
Wake up
</string>
</property>
</property>
</widget>
</widget>
</item>
</item>
<item
row=
"
7
"
column=
"0"
rowspan=
"2"
>
<item
row=
"
6
"
column=
"0"
rowspan=
"2"
>
<widget
class=
"QLabel"
name=
"lHostName"
>
<widget
class=
"QLabel"
name=
"lHostName"
>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
Virtual Machine
</string>
<string>
Virtual Machine
</string>
...
@@ -46,7 +46,7 @@
...
@@ -46,7 +46,7 @@
</property>
</property>
</widget>
</widget>
</item>
</item>
<item
row=
"2"
column=
"0"
rowspan=
"
5
"
>
<item
row=
"2"
column=
"0"
rowspan=
"
4
"
>
<widget
class=
"QLabel"
name=
"lComputeIcon"
>
<widget
class=
"QLabel"
name=
"lComputeIcon"
>
<property
name=
"sizePolicy"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Fixed"
vsizetype=
"Fixed"
>
<sizepolicy
hsizetype=
"Fixed"
vsizetype=
"Fixed"
>
...
@@ -67,7 +67,7 @@
...
@@ -67,7 +67,7 @@
</property>
</property>
</widget>
</widget>
</item>
</item>
<item
row=
"2"
column=
"1"
rowspan=
"
7
"
>
<item
row=
"2"
column=
"1"
rowspan=
"
6
"
>
<spacer
name=
"horizontalSpacer"
>
<spacer
name=
"horizontalSpacer"
>
<property
name=
"orientation"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
<enum>
Qt::Horizontal
</enum>
...
@@ -80,14 +80,7 @@
...
@@ -80,14 +80,7 @@
</property>
</property>
</spacer>
</spacer>
</item>
</item>
<item
row=
"5"
column=
"2"
rowspan=
"2"
>
<item
row=
"2"
column=
"2"
rowspan=
"2"
>
<widget
class=
"QPushButton"
name=
"bSleep"
>
<property
name=
"text"
>
<string>
Sleep
</string>
</property>
</widget>
</item>
<item
row=
"2"
column=
"3"
rowspan=
"3"
>
<widget
class=
"QPushButton"
name=
"bStart"
>
<widget
class=
"QPushButton"
name=
"bStart"
>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
Start
</string>
<string>
Start
</string>
...
...
This diff is collapsed.
Click to expand it.
controller.cpp
View file @
7a7d24d7
#include "controller.h"
#include "controller.h"
bool
Controller
::
connect
(){
bool
Controller
::
connect
(
std
::
string
url
){
session
=
new
OcciClient
::
OcciSession
(
"https://vm.ik.bme.hu:9366/occi/"
,
true
,
true
);
session
=
new
OcciClient
::
OcciSession
(
url
.
c_str
()
,
true
,
true
);
return
true
;
//TODO validation
return
true
;
//TODO validation
}
}
...
@@ -14,11 +14,16 @@ bool Controller::login(std::string username, std::string password){
...
@@ -14,11 +14,16 @@ bool Controller::login(std::string username, std::string password){
return
false
;
return
false
;
}
}
/*!
* \brief Refreshes all data, communicates with the server
*/
void
Controller
::
refresh
(){
void
Controller
::
refresh
(){
allCompute
.
clear
();
allCompute
.
clear
();
for
(
auto
c
:
OcciClient
::
Compute
::
getComputeInstances
(
session
))
{
for
(
auto
c
:
OcciClient
::
Compute
::
getComputeInstances
(
session
))
allCompute
.
push_back
(
c
);
allCompute
.
push_back
(
c
);
}
allTemplate
.
clear
();
for
(
auto
t
:
OcciClient
::
getTemplates
(
session
))
allTemplate
.
push_back
(
t
);
}
}
std
::
vector
<
std
::
string
>
Controller
::
getVMs
(){
std
::
vector
<
std
::
string
>
Controller
::
getVMs
(){
...
@@ -29,20 +34,32 @@ std::vector<std::string> Controller::getVMs(){
...
@@ -29,20 +34,32 @@ std::vector<std::string> Controller::getVMs(){
return
VMs
;
return
VMs
;
}
}
std
::
vector
<
std
::
string
>
Controller
::
getTemplates
(){
std
::
vector
<
std
::
string
>
templates
;
for
(
auto
t
:
allTemplate
){
templates
.
push_back
(
t
);
}
return
templates
;
}
void
Controller
::
renewByID
(
std
::
string
id
){
void
Controller
::
renewByID
(
std
::
string
id
){
allCompute
.
at
(
std
::
stoi
(
id
))
->
renew
();
allCompute
.
at
(
std
::
stoi
(
id
))
->
renew
();
refresh
();
}
}
void
Controller
::
startByID
(
std
::
string
id
){
void
Controller
::
startByID
(
std
::
string
id
){
allCompute
.
at
(
std
::
stoi
(
id
))
->
start
();
allCompute
.
at
(
std
::
stoi
(
id
))
->
start
();
refresh
();
}
}
void
Controller
::
wakeupByID
(
std
::
string
id
){
void
Controller
::
wakeupByID
(
std
::
string
id
){
allCompute
.
at
(
std
::
stoi
(
id
))
->
wakeup
();
allCompute
.
at
(
std
::
stoi
(
id
))
->
wakeup
();
refresh
();
}
}
void
Controller
::
sleepByID
(
std
::
string
id
){
void
Controller
::
sleepByID
(
std
::
string
id
){
allCompute
.
at
(
std
::
stoi
(
id
))
->
sleep
();
allCompute
.
at
(
std
::
stoi
(
id
))
->
sleep
();
refresh
();
}
}
std
::
string
Controller
::
getState
(
std
::
string
id
){
std
::
string
Controller
::
getState
(
std
::
string
id
){
...
@@ -55,6 +72,7 @@ ComputeData Controller::getDataByID(std::string id){
...
@@ -55,6 +72,7 @@ ComputeData Controller::getDataByID(std::string id){
data
.
cpu
=
allCompute
.
at
(
std
::
stoi
(
id
))
->
getCpuShare
();
data
.
cpu
=
allCompute
.
at
(
std
::
stoi
(
id
))
->
getCpuShare
();
data
.
cores
=
allCompute
.
at
(
std
::
stoi
(
id
))
->
getCores
();
data
.
cores
=
allCompute
.
at
(
std
::
stoi
(
id
))
->
getCores
();
data
.
hostname
=
allCompute
.
at
(
std
::
stoi
(
id
))
->
getCredentialHost
();
data
.
hostname
=
allCompute
.
at
(
std
::
stoi
(
id
))
->
getCredentialHost
();
data
.
port
=
allCompute
.
at
(
std
::
stoi
(
id
))
->
getCredentialPort
();
data
.
username
=
allCompute
.
at
(
std
::
stoi
(
id
))
->
getCredentialUsername
();
data
.
username
=
allCompute
.
at
(
std
::
stoi
(
id
))
->
getCredentialUsername
();
data
.
password
=
allCompute
.
at
(
std
::
stoi
(
id
))
->
getCredentialPassword
();
data
.
password
=
allCompute
.
at
(
std
::
stoi
(
id
))
->
getCredentialPassword
();
return
data
;
return
data
;
...
@@ -62,4 +80,5 @@ ComputeData Controller::getDataByID(std::string id){
...
@@ -62,4 +80,5 @@ ComputeData Controller::getDataByID(std::string id){
void
Controller
::
newCompute
(
Template
t
){
void
Controller
::
newCompute
(
Template
t
){
OcciClient
::
Compute
::
createComputeInstance
(
session
,
t
);
OcciClient
::
Compute
::
createComputeInstance
(
session
,
t
);
refresh
();
}
}
This diff is collapsed.
Click to expand it.
controller.h
View file @
7a7d24d7
...
@@ -12,8 +12,9 @@ class Controller
...
@@ -12,8 +12,9 @@ class Controller
public
:
public
:
OcciClient
::
OcciSession
*
session
;
OcciClient
::
OcciSession
*
session
;
std
::
vector
<
std
::
shared_ptr
<
OcciClient
::
Compute
>
>
allCompute
;
std
::
vector
<
std
::
shared_ptr
<
OcciClient
::
Compute
>
>
allCompute
;
std
::
vector
<
Template
>
allTemplate
;
bool
connect
();
bool
connect
(
std
::
string
url
);
bool
login
(
std
::
string
username
,
std
::
string
password
);
bool
login
(
std
::
string
username
,
std
::
string
password
);
...
@@ -34,6 +35,8 @@ public:
...
@@ -34,6 +35,8 @@ public:
std
::
string
getState
(
std
::
string
id
);
std
::
string
getState
(
std
::
string
id
);
std
::
vector
<
std
::
string
>
getVMs
();
std
::
vector
<
std
::
string
>
getVMs
();
std
::
vector
<
std
::
string
>
getTemplates
();
};
};
#endif // CONTROLLER_H
#endif // CONTROLLER_H
This diff is collapsed.
Click to expand it.
mainwindow.cpp
View file @
7a7d24d7
#include "mainwindow.h"
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "ui_mainwindow.h"
///Implementation for class MainWindow
///
///---------------------------------------------------------------------------------------------------
/// Basic Methods
/*!
* \brief Constructor, sets up ui, disable tabs other than login
* \param parent
*/
MainWindow
::
MainWindow
(
QWidget
*
parent
)
:
MainWindow
::
MainWindow
(
QWidget
*
parent
)
:
QMainWindow
(
parent
),
QMainWindow
(
parent
),
ui
(
new
Ui
::
MainWindow
)
ui
(
new
Ui
::
MainWindow
)
...
@@ -8,39 +17,80 @@ MainWindow::MainWindow(QWidget *parent) :
...
@@ -8,39 +17,80 @@ MainWindow::MainWindow(QWidget *parent) :
ui
->
setupUi
(
this
);
ui
->
setupUi
(
this
);
ui
->
tabWidget
->
setTabEnabled
(
1
,
false
);
ui
->
tabWidget
->
setTabEnabled
(
1
,
false
);
ui
->
tabWidget
->
setTabEnabled
(
2
,
false
);
ui
->
tabWidget
->
setTabEnabled
(
2
,
false
);
myController
.
connect
();
}
}
/*!
* \brief Destructor
*/
MainWindow
::~
MainWindow
()
{
delete
ui
;
}
///---------------------------------------------------------------------------------------------------
/// Methods for loading data to the UI
/*!
* \brief Adds a VM to the listWidget, sets its id, connects all Quick Action buttons
* \param id
* \param name
*/
void
MainWindow
::
addVM
(
std
::
string
id
,
std
::
string
name
){
void
MainWindow
::
addVM
(
std
::
string
id
,
std
::
string
name
){
QListWidgetItem
*
item
=
new
QListWidgetItem
(
ui
->
listWidget
);
QListWidgetItem
*
item
=
new
QListWidgetItem
(
ui
->
listWidget
);
ComputeWidget
*
cw
=
new
ComputeWidget
();
ComputeWidget
*
cw
=
new
ComputeWidget
();
cw
->
setID
(
id
);
cw
->
setID
(
id
);
cw
->
setName
(
name
);
cw
->
setName
(
name
);
connect
(
this
,
SIGNAL
(
stateChanged
(
std
::
string
,
std
::
string
)),
cw
,
SLOT
(
stateChangedHandler
(
std
::
string
,
std
::
string
)));
emit
stateChanged
(
myController
.
getState
(
id
),
id
);
connect
(
cw
,
SIGNAL
(
renew
(
std
::
string
)),
this
,
SLOT
(
renewClicked
(
std
::
string
)));
connect
(
cw
,
SIGNAL
(
renew
(
std
::
string
)),
this
,
SLOT
(
renewClicked
(
std
::
string
)));
connect
(
cw
,
SIGNAL
(
start
(
std
::
string
)),
this
,
SLOT
(
startClicked
(
std
::
string
)));
connect
(
cw
,
SIGNAL
(
start
(
std
::
string
)),
this
,
SLOT
(
startClicked
(
std
::
string
)));
connect
(
cw
,
SIGNAL
(
wakeup
(
std
::
string
)),
this
,
SLOT
(
wakeupClicked
(
std
::
string
)));
connect
(
cw
,
SIGNAL
(
wakeupsleep
(
std
::
string
)),
this
,
SLOT
(
wakeupsleepClicked
(
std
::
string
)));
connect
(
cw
,
SIGNAL
(
sleep
(
std
::
string
)),
this
,
SLOT
(
sleepClicked
(
std
::
string
)));
item
->
setSizeHint
(
cw
->
minimumSize
());
item
->
setSizeHint
(
cw
->
minimumSize
());
ui
->
listWidget
->
addItem
(
item
);
ui
->
listWidget
->
addItem
(
item
);
ui
->
listWidget
->
setItemWidget
(
item
,
cw
);
ui
->
listWidget
->
setItemWidget
(
item
,
cw
);
}
}
MainWindow
::~
MainWindow
()
/*!
{
* \brief loads all data to the UI, which are stored in Controller, DOES NOT COMMUNICATE WITH THE CLOUD SERVER!!
delete
ui
;
*/
}
void
MainWindow
::
loadAllData
(){
void
MainWindow
::
loadData
(){
VM_names
=
myController
.
getVMs
();
VM_names
=
myController
.
getVMs
();
ui
->
listWidget
->
clear
();
ui
->
listWidget
->
clear
();
for
(
size_t
i
=
0
;
i
<
VM_names
.
size
();
i
++
)
for
(
size_t
i
=
0
;
i
<
VM_names
.
size
();
i
++
)
addVM
(
std
::
to_string
(
i
),
VM_names
.
at
(
i
));
addVM
(
std
::
to_string
(
i
),
VM_names
.
at
(
i
));
for
(
auto
t
:
getTemplates
(
myController
.
session
))
ui
->
lwTemplates
->
clear
();
for
(
auto
t
:
myController
.
getTemplates
())
ui
->
lwTemplates
->
addItem
(
t
.
c_str
());
ui
->
lwTemplates
->
addItem
(
t
.
c_str
());
}
}
/*!
* \brief Loads all data for a VM specified by the id, does NOT communicate with the cloud server!!
* \param id
*/
void
MainWindow
::
loadVMData
(
std
::
string
id
){
ui
->
lStatus
->
setText
(
myController
.
getState
(
id
).
c_str
());
ComputeData
data
=
myController
.
getDataByID
(
id
.
c_str
());
ui
->
lCPU
->
setText
(
std
::
to_string
(
data
.
cpu
).
c_str
());
ui
->
lMemory
->
setText
(
std
::
to_string
(
data
.
memory
).
c_str
());
ui
->
lCores
->
setText
(
std
::
to_string
(
data
.
cores
).
c_str
());
ui
->
lHostname
->
setText
((
data
.
hostname
+
":"
+
std
::
to_string
(
data
.
port
)).
c_str
());
ui
->
lUsernameVM
->
setText
(
data
.
username
.
c_str
());
ui
->
lPasswordVM
->
setText
(
data
.
password
.
c_str
());
}
///---------------------------------------------------------------------------------------------------
/// Button handlers
///Tab 0 - Login Screen
/*!
* \brief Login Button handler, connects to server, if authentication is succesful enables all tabs, and loads all data
*/
void
MainWindow
::
on_bLogin_clicked
()
void
MainWindow
::
on_bLogin_clicked
()
{
{
std
::
string
serverUrl
=
ui
->
iCloudServer
->
text
().
toStdString
();
myController
.
connect
(
serverUrl
);
std
::
string
username
=
ui
->
iUsername
->
text
().
toStdString
();
std
::
string
username
=
ui
->
iUsername
->
text
().
toStdString
();
std
::
string
password
=
ui
->
iPassword
->
text
().
toStdString
();
std
::
string
password
=
ui
->
iPassword
->
text
().
toStdString
();
if
(
!
myController
.
login
(
username
,
password
)){
if
(
!
myController
.
login
(
username
,
password
)){
...
@@ -49,47 +99,72 @@ void MainWindow::on_bLogin_clicked()
...
@@ -49,47 +99,72 @@ void MainWindow::on_bLogin_clicked()
}
}
ui
->
tabWidget
->
setTabEnabled
(
1
,
true
);
ui
->
tabWidget
->
setTabEnabled
(
1
,
true
);
ui
->
tabWidget
->
setTabEnabled
(
2
,
true
);
ui
->
tabWidget
->
setTabEnabled
(
2
,
true
);
loadData
();
load
All
Data
();
ui
->
tabWidget
->
setCurrentIndex
(
1
);
ui
->
tabWidget
->
setCurrentIndex
(
1
);
}
}
/// Tab 1 - Virtual Machines
/*!
* \brief handles Renew button, all static data is refreshed
* \param id
*/
void
MainWindow
::
renewClicked
(
std
::
string
id
){
void
MainWindow
::
renewClicked
(
std
::
string
id
){
myController
.
renewByID
(
id
);
myController
.
renewByID
(
id
);
loadVMData
(
id
);
ui
->
listWidget
->
item
(
std
::
stoi
(
id
))
->
setSelected
(
true
);
}
}
/*!
* \brief handles Start button (fetches data from server)
* \param id
*/
void
MainWindow
::
startClicked
(
std
::
string
id
){
void
MainWindow
::
startClicked
(
std
::
string
id
){
myController
.
startByID
(
id
);
myController
.
startByID
(
id
);
loadVMData
(
id
);
ui
->
listWidget
->
item
(
std
::
stoi
(
id
))
->
setSelected
(
true
);
}
}
void
MainWindow
::
wakeupClicked
(
std
::
string
id
){
myController
.
wakeupByID
(
id
);
void
MainWindow
::
wakeupsleepClicked
(
std
::
string
id
){
}
std
::
string
state
=
myController
.
getState
(
id
);
void
MainWindow
::
sleepClicked
(
std
::
string
id
){
if
(
state
==
"active"
){
//sleep
myController
.
sleepByID
(
id
);
myController
.
sleepByID
(
id
);
emit
stateChanged
(
myController
.
getState
(
id
),
id
);
loadVMData
(
id
);
ui
->
listWidget
->
item
(
std
::
stoi
(
id
))
->
setSelected
(
true
);
}
else
if
(
state
==
"suspended"
||
state
==
"inactive"
){
//wake up
myController
.
wakeupByID
(
id
);
emit
stateChanged
(
myController
.
getState
(
id
),
id
);
loadVMData
(
id
);
ui
->
listWidget
->
item
(
std
::
stoi
(
id
))
->
setSelected
(
true
);
}
else
{
throw
std
::
runtime_error
(
"undefined VM STATE!!!"
);
}
}
}
/*!
* \brief handles Renew button (fetches data from server)
* \param id
*/
void
MainWindow
::
on_listWidget_clicked
(
const
QModelIndex
&
index
)
void
MainWindow
::
on_listWidget_clicked
(
const
QModelIndex
&
index
)
{
{
ui
->
lStatus
->
setText
(
myController
.
getState
(
std
::
to_string
(
index
.
row
())).
c_str
());
loadVMData
(
std
::
to_string
(
index
.
row
()));
ComputeData
data
=
myController
.
getDataByID
(
std
::
to_string
(
index
.
row
()).
c_str
());
ui
->
lCPU
->
setText
(
std
::
to_string
(
data
.
cpu
).
c_str
());
ui
->
lMemory
->
setText
(
std
::
to_string
(
data
.
memory
).
c_str
());
ui
->
lCores
->
setText
(
std
::
to_string
(
data
.
cores
).
c_str
());
ui
->
lHostname
->
setText
((
data
.
hostname
+
":21231"
).
c_str
());
//TODO
ui
->
lUsername
->
setText
(
data
.
username
.
c_str
());
ui
->
lPassword
->
setText
(
data
.
password
.
c_str
());
}
}
/*!
* \brief handles Refresh button, refreshes Controller's data and loads to the UI (fetches data from server)
*/
void
MainWindow
::
on_bRefresh_clicked
()
void
MainWindow
::
on_bRefresh_clicked
()
{
{
myController
.
refresh
();
myController
.
refresh
();
loadData
();
loadAllData
();
}
void
MainWindow
::
receive_chosen_template
(
Template
t
){
myController
.
newCompute
(
t
);
}
}
/*!
* \brief handles new VM button, Opens a dialog for choosing from templates
*/
void
MainWindow
::
on_bNewVM_clicked
()
void
MainWindow
::
on_bNewVM_clicked
()
{
{
VMChooserDialog
*
v
=
new
VMChooserDialog
(
this
);
VMChooserDialog
*
v
=
new
VMChooserDialog
(
this
);
...
@@ -97,3 +172,29 @@ void MainWindow::on_bNewVM_clicked()
...
@@ -97,3 +172,29 @@ void MainWindow::on_bNewVM_clicked()
connect
(
v
,
SIGNAL
(
send_chosen_template
(
Template
)),
this
,
SLOT
(
receive_chosen_template
(
Template
)));
connect
(
v
,
SIGNAL
(
send_chosen_template
(
Template
)),
this
,
SLOT
(
receive_chosen_template
(
Template
)));
v
->
exec
();
v
->
exec
();
}
}
/*!
* \brief Slot for dialog, creates new VM by the chosen template
* \param t
*/
void
MainWindow
::
receive_chosen_template
(
Template
t
){
myController
.
newCompute
(
t
);
loadAllData
();
}
/*!
* \brief handler, shows/hides VM password
*/
void
MainWindow
::
on_bShowPassword_clicked
()
{
if
(
ui
->
lPasswordVM
->
echoMode
()
==
QLineEdit
::
Password
){
ui
->
lPasswordVM
->
setEchoMode
(
QLineEdit
::
Normal
);
ui
->
bShowPassword
->
setText
(
"Hide"
);
}
else
if
(
ui
->
lPasswordVM
->
echoMode
()
==
QLineEdit
::
Normal
){
ui
->
lPasswordVM
->
setEchoMode
(
QLineEdit
::
Password
);
ui
->
bShowPassword
->
setText
(
"Show"
);
}
else
ui
->
lPasswordVM
->
setEchoMode
(
QLineEdit
::
Password
);
}
This diff is collapsed.
Click to expand it.
mainwindow.h
View file @
7a7d24d7
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#include <QMainWindow>
#include <QMainWindow>
#include <QLabel>
#include <QLabel>
#include <QPushButton>
#include <QPushButton>
#include <QListWidget>
#include <computewidget.h>
#include <computewidget.h>
#include "libocci/occilib.h"
#include "libocci/occilib.h"
#include "controller.h"
#include "controller.h"
...
@@ -21,17 +22,18 @@ public:
...
@@ -21,17 +22,18 @@ public:
explicit
MainWindow
(
QWidget
*
parent
=
0
);
explicit
MainWindow
(
QWidget
*
parent
=
0
);
~
MainWindow
();
~
MainWindow
();
void
addVM
(
std
::
string
id
,
std
::
string
name
);
void
addVM
(
std
::
string
id
,
std
::
string
name
);
void
loadData
();
void
loadAllData
();
void
loadVMData
(
std
::
string
id
);
signals
:
signals
:
void
send_templates
(
std
::
vector
<
Template
>
);
void
send_templates
(
std
::
vector
<
Template
>
);
void
stateChanged
(
std
::
string
state
,
std
::
string
id
);
private
slots
:
private
slots
:
void
on_bLogin_clicked
();
void
on_bLogin_clicked
();
void
renewClicked
(
std
::
string
);
void
renewClicked
(
std
::
string
);
void
startClicked
(
std
::
string
);
void
startClicked
(
std
::
string
);
void
wakeupClicked
(
std
::
string
);
void
wakeupsleepClicked
(
std
::
string
);
void
sleepClicked
(
std
::
string
);
void
receive_chosen_template
(
Template
);
void
receive_chosen_template
(
Template
);
...
@@ -41,6 +43,8 @@ private slots:
...
@@ -41,6 +43,8 @@ private slots:
void
on_bNewVM_clicked
();
void
on_bNewVM_clicked
();
void
on_bShowPassword_clicked
();
private
:
private
:
Ui
::
MainWindow
*
ui
;
Ui
::
MainWindow
*
ui
;
Controller
myController
;
Controller
myController
;
...
...
This diff is collapsed.
Click to expand it.
mainwindow.ui
View file @
7a7d24d7
...
@@ -48,7 +48,7 @@
...
@@ -48,7 +48,7 @@
</palette>
</palette>
</property>
</property>
<property
name=
"windowTitle"
>
<property
name=
"windowTitle"
>
<string>
MainWindow
</string>
<string>
CircleClient
</string>
</property>
</property>
<widget
class=
"QWidget"
name=
"centralWidget"
>
<widget
class=
"QWidget"
name=
"centralWidget"
>
<layout
class=
"QGridLayout"
name=
"gridLayout"
>
<layout
class=
"QGridLayout"
name=
"gridLayout"
>
...
@@ -95,7 +95,7 @@
...
@@ -95,7 +95,7 @@
<enum>
QTabWidget::Rounded
</enum>
<enum>
QTabWidget::Rounded
</enum>
</property>
</property>
<property
name=
"currentIndex"
>
<property
name=
"currentIndex"
>
<number>
1
</number>
<number>
0
</number>
</property>
</property>
<property
name=
"iconSize"
>
<property
name=
"iconSize"
>
<size>
<size>
...
@@ -108,14 +108,20 @@
...
@@ -108,14 +108,20 @@
<string>
Welcome
</string>
<string>
Welcome
</string>
</attribute>
</attribute>
<layout
class=
"QGridLayout"
name=
"gridLayout_4"
>
<layout
class=
"QGridLayout"
name=
"gridLayout_4"
>
<item
row=
"
8
"
column=
"1"
>
<item
row=
"
10
"
column=
"1"
>
<widget
class=
"QPushButton"
name=
"bLogin"
>
<widget
class=
"QPushButton"
name=
"bLogin"
>
<property
name=
"toolTip"
>
<string>
<
html
><
head/
><
body
><
p
>
Log in
<
/p
><
/body
><
/html
>
</string>
</property>
<property
name=
"whatsThis"
>
<string>
<
html
><
head/
><
body
><
p
><
br/
><
/p
><
/body
><
/html
>
</string>
</property>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
Login
</string>
<string>
Login
</string>
</property>
</property>
</widget>
</widget>
</item>
</item>
<item
row=
"
7
"
column=
"1"
>
<item
row=
"
9
"
column=
"1"
>
<widget
class=
"QLineEdit"
name=
"iPassword"
>
<widget
class=
"QLineEdit"
name=
"iPassword"
>
<property
name=
"palette"
>
<property
name=
"palette"
>
<palette>
<palette>
...
@@ -165,7 +171,7 @@
...
@@ -165,7 +171,7 @@
</property>
</property>
</widget>
</widget>
</item>
</item>
<item
row=
"3"
column=
"2"
rowspan=
"
8
"
>
<item
row=
"3"
column=
"2"
rowspan=
"
10
"
>
<spacer
name=
"horizontalSpacer_2"
>
<spacer
name=
"horizontalSpacer_2"
>
<property
name=
"orientation"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
<enum>
Qt::Horizontal
</enum>
...
@@ -181,7 +187,7 @@
...
@@ -181,7 +187,7 @@
</property>
</property>
</spacer>
</spacer>
</item>
</item>
<item
row=
"3"
column=
"0"
rowspan=
"
8
"
>
<item
row=
"3"
column=
"0"
rowspan=
"
10
"
>
<spacer
name=
"horizontalSpacer"
>
<spacer
name=
"horizontalSpacer"
>
<property
name=
"orientation"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
<enum>
Qt::Horizontal
</enum>
...
@@ -197,7 +203,7 @@
...
@@ -197,7 +203,7 @@
</property>
</property>
</spacer>
</spacer>
</item>
</item>
<item
row=
"1
0
"
column=
"1"
>
<item
row=
"1
2
"
column=
"1"
>
<spacer
name=
"verticalSpacer"
>
<spacer
name=
"verticalSpacer"
>
<property
name=
"orientation"
>
<property
name=
"orientation"
>
<enum>
Qt::Vertical
</enum>
<enum>
Qt::Vertical
</enum>
...
@@ -213,14 +219,14 @@
...
@@ -213,14 +219,14 @@
</property>
</property>
</spacer>
</spacer>
</item>
</item>
<item
row=
"
6
"
column=
"1"
>
<item
row=
"
8
"
column=
"1"
>
<widget
class=
"QLabel"
name=
"lPassword"
>
<widget
class=
"QLabel"
name=
"lPassword"
>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
Password
</string>
<string>
Password
</string>
</property>
</property>
</widget>
</widget>
</item>
</item>
<item
row=
"
5
"
column=
"1"
>
<item
row=
"
7
"
column=
"1"
>
<widget
class=
"QLineEdit"
name=
"iUsername"
>
<widget
class=
"QLineEdit"
name=
"iUsername"
>
<property
name=
"palette"
>
<property
name=
"palette"
>
<palette>
<palette>
...
@@ -277,7 +283,7 @@
...
@@ -277,7 +283,7 @@
</property>
</property>
</spacer>
</spacer>
</item>
</item>
<item
row=
"
4
"
column=
"1"
>
<item
row=
"
6
"
column=
"1"
>
<widget
class=
"QLabel"
name=
"lUsername"
>
<widget
class=
"QLabel"
name=
"lUsername"
>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
Username
</string>
<string>
Username
</string>
...
@@ -307,7 +313,7 @@
...
@@ -307,7 +313,7 @@
</property>
</property>
</widget>
</widget>
</item>
</item>
<item
row=
"
9
"
column=
"1"
>
<item
row=
"
11
"
column=
"1"
>
<widget
class=
"QLabel"
name=
"lInfo"
>
<widget
class=
"QLabel"
name=
"lInfo"
>
<property
name=
"palette"
>
<property
name=
"palette"
>
<palette>
<palette>
...
@@ -354,6 +360,57 @@
...
@@ -354,6 +360,57 @@
</property>
</property>
</widget>
</widget>
</item>
</item>
<item
row=
"4"
column=
"1"
>
<widget
class=
"QLabel"
name=
"lCloudServer"
>
<property
name=
"text"
>
<string>
Cloud Server:
</string>
</property>
</widget>
</item>
<item
row=
"5"
column=
"1"
>
<widget
class=
"QLineEdit"
name=
"iCloudServer"
>
<property
name=
"palette"
>
<palette>
<active>
<colorrole
role=
"Base"
>
<brush
brushstyle=
"SolidPattern"
>
<color
alpha=
"255"
>
<red>
255
</red>
<green>
255
</green>
<blue>
255
</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole
role=
"Base"
>
<brush
brushstyle=
"SolidPattern"
>
<color
alpha=
"255"
>
<red>
255
</red>
<green>
255
</green>
<blue>
255
</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole
role=
"Base"
>
<brush
brushstyle=
"SolidPattern"
>
<color
alpha=
"255"
>
<red>
240
</red>
<green>
240
</green>
<blue>
240
</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property
name=
"text"
>
<string>
https://vm.ik.bme.hu:9366/occi/
</string>
</property>
</widget>
</item>
</layout>
</layout>
</widget>
</widget>
<widget
class=
"QWidget"
name=
"tVM"
>
<widget
class=
"QWidget"
name=
"tVM"
>
...
@@ -417,6 +474,13 @@
...
@@ -417,6 +474,13 @@
</property>
</property>
</widget>
</widget>
</item>
</item>
<item
row=
"3"
column=
"1"
>
<widget
class=
"QLabel"
name=
"lMemoryTag"
>
<property
name=
"text"
>
<string>
Memory:
</string>
</property>
</widget>
</item>
<item
row=
"0"
column=
"2"
>
<item
row=
"0"
column=
"2"
>
<spacer
name=
"horizontalSpacer_3"
>
<spacer
name=
"horizontalSpacer_3"
>
<property
name=
"orientation"
>
<property
name=
"orientation"
>
...
@@ -514,10 +578,17 @@
...
@@ -514,10 +578,17 @@
</property>
</property>
</widget>
</widget>
</item>
</item>
<item
row=
"
3"
column=
"1
"
>
<item
row=
"
7"
column=
"2
"
>
<widget
class=
"QLabel"
name=
"l
MemoryTag
"
>
<widget
class=
"QLabel"
name=
"l
Hostname
"
>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
Memory:
</string>
<string/>
</property>
</widget>
</item>
<item
row=
"8"
column=
"2"
>
<widget
class=
"QLabel"
name=
"lUsernameVM"
>
<property
name=
"text"
>
<string/>
</property>
</property>
</widget>
</widget>
</item>
</item>
...
@@ -554,29 +625,75 @@
...
@@ -554,29 +625,75 @@
</property>
</property>
</spacer>
</spacer>
</item>
</item>
<item
row=
"7"
column=
"2"
>
<item
row=
"9"
column=
"2"
>
<widget
class=
"QLabel"
name=
"lHostname"
>
<widget
class=
"QLineEdit"
name=
"lPasswordVM"
>
<property
name=
"text"
>
<property
name=
"palette"
>
<string/>
<palette>
<active>
<colorrole
role=
"Base"
>
<brush
brushstyle=
"SolidPattern"
>
<color
alpha=
"255"
>
<red>
255
</red>
<green>
255
</green>
<blue>
255
</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole
role=
"Base"
>
<brush
brushstyle=
"SolidPattern"
>
<color
alpha=
"255"
>
<red>
255
</red>
<green>
255
</green>
<blue>
255
</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole
role=
"Base"
>
<brush
brushstyle=
"SolidPattern"
>
<color
alpha=
"255"
>
<red>
240
</red>
<green>
240
</green>
<blue>
240
</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
</property>
</widget>
<property
name=
"echoMode"
>
</item>
<enum>
QLineEdit::Password
</enum>
<item
row=
"8"
column=
"2"
>
</property>
<widget
class=
"QLabel"
name=
"lUsernameVM"
>
<property
name=
"readOnly"
>
<property
name=
"text"
>
<bool>
true
</bool>
<string/>
</property>
</property>
</widget>
</widget>
</item>
</item>
<item
row=
"9"
column=
"
2
"
>
<item
row=
"9"
column=
"
3
"
>
<widget
class=
"Q
Label"
name=
"lPasswordVM
"
>
<widget
class=
"Q
PushButton"
name=
"bShowPassword
"
>
<property
name=
"text"
>
<property
name=
"text"
>
<string
/
>
<string
>
Show
</string
>
</property>
</property>
</widget>
</widget>
</item>
</item>
</layout>
</layout>
</item>
</item>
<item
row=
"0"
column=
"2"
>
<spacer
name=
"horizontalSpacer_6"
>
<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>
</layout>
</widget>
</widget>
<widget
class=
"QWidget"
name=
"tTemplate"
>
<widget
class=
"QWidget"
name=
"tTemplate"
>
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment