mirror of https://github.com/Icinga/icinga2.git
Merge pull request #6059 from gunnarbeutner/feature/remove-icinga-studio
Remove Icinga Studio
This commit is contained in:
commit
3fcbe03b55
|
@ -35,7 +35,6 @@ option(ICINGA2_WITH_COMPAT "Build the compat module" ON)
|
|||
option(ICINGA2_WITH_LIVESTATUS "Build the Livestatus module" ON)
|
||||
option(ICINGA2_WITH_NOTIFICATION "Build the notification module" ON)
|
||||
option(ICINGA2_WITH_PERFDATA "Build the perfdata module" ON)
|
||||
option(ICINGA2_WITH_STUDIO "Build the Icinga Studio application" OFF)
|
||||
option(ICINGA2_WITH_TESTS "Run unit tests" ON)
|
||||
|
||||
option (USE_SYSTEMD
|
||||
|
@ -364,10 +363,6 @@ if(MSVC)
|
|||
add_subdirectory(icinga-installer)
|
||||
endif()
|
||||
|
||||
if(ICINGA2_WITH_STUDIO)
|
||||
add_subdirectory(icinga-studio)
|
||||
endif()
|
||||
|
||||
if(ICINGA2_WITH_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
@ -379,7 +374,7 @@ set(CPACK_PACKAGE_INSTALL_DIRECTORY "ICINGA2")
|
|||
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icinga-app\\\\icinga.ico")
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
|
||||
|
||||
set(CPACK_PACKAGE_EXECUTABLES "Icinga2SetupAgent;Icinga 2 Agent Wizard;icinga-studio;Icinga Studio")
|
||||
set(CPACK_PACKAGE_EXECUTABLES "Icinga2SetupAgent;Icinga 2 Agent Wizard")
|
||||
set(CPACK_WIX_PRODUCT_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icinga-app\\\\icinga.ico")
|
||||
set(CPACK_WIX_UPGRADE_GUID "52F2BEAA-4DF0-4C3E-ABDC-C0F61DE4DF8A")
|
||||
set(CPACK_WIX_EXTENSIONS "WixUtilExtension")
|
||||
|
|
|
@ -66,9 +66,6 @@ application using a dist tarball (including notes for distributions):
|
|||
* Termcap (only required if libedit doesn't already link against termcap/ncurses)
|
||||
- RHEL/Fedora: libtermcap-devel
|
||||
- Debian/Ubuntu: (not necessary)
|
||||
* wxWidgets (only required when building the Icinga 2 Studio)
|
||||
- Fedora: wxGTK-devel and wxBase
|
||||
- Debian/Ubuntu: libwxgtk2.8-dev
|
||||
|
||||
## Special requirements
|
||||
|
||||
|
@ -160,7 +157,6 @@ In addition to `CMAKE_INSTALL_PREFIX` here are most of the supported Icinga-spec
|
|||
- `ICINGA2_WITH_LIVESTATUS`: Determines whether the Livestatus module is built; defaults to `ON`
|
||||
- `ICINGA2_WITH_NOTIFICATION`: Determines whether the notification module is built; defaults to `ON`
|
||||
- `ICINGA2_WITH_PERFDATA`: Determines whether the perfdata module is built; defaults to `ON`
|
||||
- `ICINGA2_WITH_STUDIO`: Determines whether the Icinga Studio application is built; defaults to `OFF`
|
||||
- `ICINGA2_WITH_TESTS`: Determines whether the unit tests are built; defaults to `ON`
|
||||
|
||||
**MySQL or MariaDB:**
|
||||
|
|
|
@ -1846,7 +1846,6 @@ There are a couple of existing clients which can be used with the Icinga 2 API:
|
|||
|
||||
* [curl](https://curl.haxx.se/) or any other HTTP client really
|
||||
* [Icinga 2 console (CLI command)](12-icinga2-api.md#icinga2-api-clients-cli-console)
|
||||
* [Icinga Studio](12-icinga2-api.md#icinga2-api-clients-icinga-studio)
|
||||
* [Icinga Web 2 Director](https://www.icinga.com/products/icinga-web-2-modules/)
|
||||
|
||||
Demo cases:
|
||||
|
@ -1857,23 +1856,6 @@ Demo cases:
|
|||
Additional [programmatic examples](12-icinga2-api.md#icinga2-api-clients-programmatic-examples)
|
||||
will help you getting started using the Icinga 2 API in your environment.
|
||||
|
||||
### Icinga Studio <a id="icinga2-api-clients-icinga-studio"></a>
|
||||
|
||||
Icinga Studio is a graphical application to query configuration objects provided by the API.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
Please check the package repository of your distribution for available
|
||||
packages.
|
||||
|
||||
> **Note**
|
||||
> Icinga Studio does not currently support SSL certificate verification.
|
||||
|
||||
The Windows installer already includes Icinga Studio. On Debian and Ubuntu the package
|
||||
`icinga2-studio` can be used to install Icinga Studio.
|
||||
|
||||
### Icinga 2 Console <a id="icinga2-api-clients-cli-console"></a>
|
||||
|
||||
By default the [console CLI command](11-cli-commands.md#cli-command-console) evaluates
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
# Icinga 2
|
||||
# Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com/)
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
set(wxWidgets_CONFIGURATION mswu)
|
||||
find_package(wxWidgets COMPONENTS core base propgrid adv REQUIRED)
|
||||
include(${wxWidgets_USE_FILE})
|
||||
|
||||
if(MSVC)
|
||||
set(WindowsSources icinga.rc)
|
||||
else()
|
||||
set(WindowsSources "")
|
||||
endif()
|
||||
|
||||
set(icinga_studio_SOURCES
|
||||
icinga-studio.cpp
|
||||
forms.cpp
|
||||
aboutform.cpp aboutform.hpp
|
||||
connectform.cpp connectform.hpp
|
||||
mainform.cpp mainform.hpp
|
||||
icinga.icns ${WindowsSources}
|
||||
${base_OBJS}
|
||||
$<TARGET_OBJECTS:config>
|
||||
$<TARGET_OBJECTS:remote>
|
||||
)
|
||||
|
||||
add_executable(icinga-studio MACOSX_BUNDLE WIN32 ${icinga_studio_SOURCES})
|
||||
|
||||
target_link_libraries(icinga-studio ${base_DEPS} ${wxWidgets_LIBRARIES})
|
||||
|
||||
if(APPLE)
|
||||
set_source_files_properties(icinga.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
|
||||
endif()
|
||||
|
||||
set_target_properties (
|
||||
icinga-studio PROPERTIES
|
||||
INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
|
||||
FOLDER Bin
|
||||
OUTPUT_NAME icinga-studio
|
||||
MACOSX_BUNDLE_INFO_STRING "Icinga Studio"
|
||||
MACOSX_BUNDLE_BUNDLE_NAME "Icinga Studio"
|
||||
MACOSX_BUNDLE_GUI_IDENTIFIER "Icinga Studio"
|
||||
MACOSX_BUNDLE_ICON_FILE icinga.icns
|
||||
MACOSX_BUNDLE_SHORT_VERSION_STRING "${GIT_VERSION}"
|
||||
MACOSX_BUNDLE_LONG_VERSION_STRING "${GIT_VERSION}"
|
||||
MACOSX_BUNDLE_COPYRIGHT "(c) Icinga Development Team"
|
||||
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/MacOSXBundleInfo.plist.in"
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
set(InstallPath "${CMAKE_INSTALL_SBINDIR}")
|
||||
else()
|
||||
set(InstallPath "${CMAKE_INSTALL_BINDIR}")
|
||||
endif()
|
||||
|
||||
install(
|
||||
TARGETS icinga-studio
|
||||
RUNTIME DESTINATION ${InstallPath}
|
||||
BUNDLE DESTINATION ${InstallPath}
|
||||
)
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -1,38 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>${MACOSX_BUNDLE_INFO_STRING}</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>${MACOSX_BUNDLE_ICON_FILE}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleLongVersionString</key>
|
||||
<string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
|
||||
<key>CSResourcesFileMapped</key>
|
||||
<true/>
|
||||
<key>LSRequiresCarbon</key>
|
||||
<false/>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
|
@ -1,30 +0,0 @@
|
|||
/******************************************************************************
|
||||
* Icinga 2 *
|
||||
* Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com/) *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the Free Software Foundation *
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#include "base/application.hpp"
|
||||
#include "icinga-studio/aboutform.hpp"
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
AboutForm::AboutForm(wxWindow *parent)
|
||||
: AboutFormBase(parent)
|
||||
{
|
||||
std::string version = "Version " + Application::GetAppVersion();
|
||||
m_VersionLabel->SetLabelText(version);
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
/******************************************************************************
|
||||
* Icinga 2 *
|
||||
* Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com/) *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the Free Software Foundation *
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef ABOUTFORM_H
|
||||
#define ABOUTFORM_H
|
||||
|
||||
#include "icinga-studio/forms.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class AboutForm final : public AboutFormBase
|
||||
{
|
||||
public:
|
||||
AboutForm(wxWindow *parent);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* ABOUTFORM_H */
|
|
@ -1,65 +0,0 @@
|
|||
/******************************************************************************
|
||||
* Icinga 2 *
|
||||
* Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com/) *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the Free Software Foundation *
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#include "icinga-studio/connectform.hpp"
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
ConnectForm::ConnectForm(wxWindow *parent, const Url::Ptr& url)
|
||||
: ConnectFormBase(parent)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
SetIcon(wxICON(icinga));
|
||||
#endif /* _WIN32 */
|
||||
|
||||
std::string authority = url->GetAuthority();
|
||||
|
||||
std::vector<std::string> tokens;
|
||||
boost::algorithm::split(tokens, authority, boost::is_any_of("@"));
|
||||
|
||||
if (tokens.size() > 1) {
|
||||
std::vector<std::string> userinfo;
|
||||
boost::algorithm::split(userinfo, tokens[0], boost::is_any_of(":"));
|
||||
|
||||
m_UserText->SetValue(userinfo[0]);
|
||||
m_PasswordText->SetValue(userinfo[1]);
|
||||
}
|
||||
|
||||
std::vector<std::string> hostport;
|
||||
boost::algorithm::split(hostport, tokens.size() > 1 ? tokens[1] : tokens[0], boost::is_any_of(":"));
|
||||
|
||||
m_HostText->SetValue(hostport[0]);
|
||||
|
||||
if (hostport.size() > 1)
|
||||
m_PortText->SetValue(hostport[1]);
|
||||
else
|
||||
m_PortText->SetValue("5665");
|
||||
|
||||
SetDefaultItem(m_ButtonsOK);
|
||||
}
|
||||
|
||||
Url::Ptr ConnectForm::GetUrl() const
|
||||
{
|
||||
wxString url = "https://" + m_UserText->GetValue() + ":" + m_PasswordText->GetValue()
|
||||
+ "@" + m_HostText->GetValue() + ":" + m_PortText->GetValue() + "/";
|
||||
|
||||
return new Url(url.ToStdString());
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
/******************************************************************************
|
||||
* Icinga 2 *
|
||||
* Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com/) *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the Free Software Foundation *
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef CONNECTFORM_H
|
||||
#define CONNECTFORM_H
|
||||
|
||||
#include "remote/url.hpp"
|
||||
#include "icinga-studio/forms.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class ConnectForm final : public ConnectFormBase
|
||||
{
|
||||
public:
|
||||
ConnectForm(wxWindow *parent, const Url::Ptr& url);
|
||||
|
||||
Url::Ptr GetUrl() const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* CONNECTFORM_H */
|
|
@ -1,239 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Jun 17 2015)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "forms.h"
|
||||
|
||||
#include "icinga.xpm"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
MainFormBase::MainFormBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
|
||||
{
|
||||
this->SetSizeHints( wxSize( 800,569 ), wxDefaultSize );
|
||||
|
||||
m_MenuBar = new wxMenuBar( 0 );
|
||||
wxMenu* m_FileMenu;
|
||||
m_FileMenu = new wxMenu();
|
||||
wxMenuItem* m_QuitMenuItem;
|
||||
m_QuitMenuItem = new wxMenuItem( m_FileMenu, wxID_EXIT, wxString( wxT("&Quit") ) , wxEmptyString, wxITEM_NORMAL );
|
||||
m_FileMenu->Append( m_QuitMenuItem );
|
||||
|
||||
m_MenuBar->Append( m_FileMenu, wxT("&File") );
|
||||
|
||||
wxMenu* m_HelpMenu;
|
||||
m_HelpMenu = new wxMenu();
|
||||
wxMenuItem* m_AboutMenuItem;
|
||||
m_AboutMenuItem = new wxMenuItem( m_HelpMenu, wxID_ABOUT, wxString( wxT("&About Icinga Studio...") ) , wxEmptyString, wxITEM_NORMAL );
|
||||
m_HelpMenu->Append( m_AboutMenuItem );
|
||||
|
||||
m_MenuBar->Append( m_HelpMenu, wxT("&Help") );
|
||||
|
||||
this->SetMenuBar( m_MenuBar );
|
||||
|
||||
wxBoxSizer* m_DialogSizer;
|
||||
m_DialogSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxBoxSizer* m_ConnectionDetailsSizer;
|
||||
m_ConnectionDetailsSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_TypesTree = new wxTreeCtrl( this, wxID_ANY, wxDefaultPosition, wxSize( 315,-1 ), wxTR_DEFAULT_STYLE|wxTR_HIDE_ROOT );
|
||||
m_ConnectionDetailsSizer->Add( m_TypesTree, 0, wxALL|wxEXPAND, 2 );
|
||||
|
||||
wxBoxSizer* m_ObjectDetailsSizer;
|
||||
m_ObjectDetailsSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_ObjectsList = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT );
|
||||
m_ObjectDetailsSizer->Add( m_ObjectsList, 1, wxALL|wxEXPAND, 2 );
|
||||
|
||||
m_PropertyGrid = new wxPropertyGrid(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxPG_DEFAULT_STYLE);
|
||||
m_ObjectDetailsSizer->Add( m_PropertyGrid, 1, wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
m_ConnectionDetailsSizer->Add( m_ObjectDetailsSizer, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
m_DialogSizer->Add( m_ConnectionDetailsSizer, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
this->SetSizer( m_DialogSizer );
|
||||
this->Layout();
|
||||
m_StatusBar = this->CreateStatusBar( 1, wxST_SIZEGRIP, wxID_ANY );
|
||||
|
||||
this->Centre( wxBOTH );
|
||||
|
||||
// Connect Events
|
||||
this->Connect( m_QuitMenuItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFormBase::OnQuitClicked ) );
|
||||
this->Connect( m_AboutMenuItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFormBase::OnAboutClicked ) );
|
||||
m_TypesTree->Connect( wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler( MainFormBase::OnTypeSelected ), nullptr, this );
|
||||
m_ObjectsList->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( MainFormBase::OnObjectSelected ), nullptr, this );
|
||||
}
|
||||
|
||||
MainFormBase::~MainFormBase()
|
||||
{
|
||||
// Disconnect Events
|
||||
this->Disconnect( wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFormBase::OnQuitClicked ) );
|
||||
this->Disconnect( wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFormBase::OnAboutClicked ) );
|
||||
m_TypesTree->Disconnect( wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler( MainFormBase::OnTypeSelected ), nullptr, this );
|
||||
m_ObjectsList->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( MainFormBase::OnObjectSelected ), nullptr, this );
|
||||
|
||||
}
|
||||
|
||||
ConnectFormBase::ConnectFormBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
|
||||
{
|
||||
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
|
||||
|
||||
wxBoxSizer* m_DialogSizer;
|
||||
m_DialogSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxPanel* m_ConnectionDetailsPanel;
|
||||
m_ConnectionDetailsPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
wxStaticBoxSizer* m_DetailsSizer;
|
||||
m_DetailsSizer = new wxStaticBoxSizer( new wxStaticBox( m_ConnectionDetailsPanel, wxID_ANY, wxT("Connection Details") ), wxVERTICAL );
|
||||
|
||||
wxStaticText* m_HostLabel;
|
||||
m_HostLabel = new wxStaticText( m_DetailsSizer->GetStaticBox(), wxID_ANY, wxT("Host:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_HostLabel->Wrap( -1 );
|
||||
m_DetailsSizer->Add( m_HostLabel, 0, wxALL, 5 );
|
||||
|
||||
m_HostText = new wxTextCtrl( m_DetailsSizer->GetStaticBox(), wxID_OK, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_DetailsSizer->Add( m_HostText, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
wxStaticText* m_PortLabel;
|
||||
m_PortLabel = new wxStaticText( m_DetailsSizer->GetStaticBox(), wxID_ANY, wxT("Port:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_PortLabel->Wrap( -1 );
|
||||
m_DetailsSizer->Add( m_PortLabel, 0, wxALL, 5 );
|
||||
|
||||
m_PortText = new wxTextCtrl( m_DetailsSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_DetailsSizer->Add( m_PortText, 0, wxALL, 5 );
|
||||
|
||||
wxStaticText* m_UserLabel;
|
||||
m_UserLabel = new wxStaticText( m_DetailsSizer->GetStaticBox(), wxID_ANY, wxT("API User:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_UserLabel->Wrap( -1 );
|
||||
m_DetailsSizer->Add( m_UserLabel, 0, wxALL, 5 );
|
||||
|
||||
m_UserText = new wxTextCtrl( m_DetailsSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_DetailsSizer->Add( m_UserText, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
wxStaticText* m_PasswordLabel;
|
||||
m_PasswordLabel = new wxStaticText( m_DetailsSizer->GetStaticBox(), wxID_ANY, wxT("API Password:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_PasswordLabel->Wrap( -1 );
|
||||
m_DetailsSizer->Add( m_PasswordLabel, 0, wxALL, 5 );
|
||||
|
||||
m_PasswordText = new wxTextCtrl( m_DetailsSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD );
|
||||
m_DetailsSizer->Add( m_PasswordText, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
wxStaticText* m_InfoLabel;
|
||||
m_InfoLabel = new wxStaticText( m_DetailsSizer->GetStaticBox(), wxID_ANY, wxT("You can find the username and password for the default user in /etc/icinga2/conf.d/api-users.conf."), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_InfoLabel->Wrap( 270 );
|
||||
m_DetailsSizer->Add( m_InfoLabel, 0, wxALL, 5 );
|
||||
|
||||
|
||||
m_ConnectionDetailsPanel->SetSizer( m_DetailsSizer );
|
||||
m_ConnectionDetailsPanel->Layout();
|
||||
m_DetailsSizer->Fit( m_ConnectionDetailsPanel );
|
||||
m_DialogSizer->Add( m_ConnectionDetailsPanel, 1, wxEXPAND | wxALL, 5 );
|
||||
|
||||
wxPanel* m_ButtonsPanel;
|
||||
m_ButtonsPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
wxBoxSizer* m_ButtonsSizer;
|
||||
m_ButtonsSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_Buttons = new wxStdDialogButtonSizer();
|
||||
m_ButtonsOK = new wxButton( m_ButtonsPanel, wxID_OK );
|
||||
m_Buttons->AddButton( m_ButtonsOK );
|
||||
m_ButtonsCancel = new wxButton( m_ButtonsPanel, wxID_CANCEL );
|
||||
m_Buttons->AddButton( m_ButtonsCancel );
|
||||
m_Buttons->Realize();
|
||||
|
||||
m_ButtonsSizer->Add( m_Buttons, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
m_ButtonsPanel->SetSizer( m_ButtonsSizer );
|
||||
m_ButtonsPanel->Layout();
|
||||
m_ButtonsSizer->Fit( m_ButtonsPanel );
|
||||
m_DialogSizer->Add( m_ButtonsPanel, 0, wxEXPAND | wxALL, 5 );
|
||||
|
||||
|
||||
this->SetSizer( m_DialogSizer );
|
||||
this->Layout();
|
||||
m_DialogSizer->Fit( this );
|
||||
|
||||
this->Centre( wxBOTH );
|
||||
}
|
||||
|
||||
ConnectFormBase::~ConnectFormBase()
|
||||
{
|
||||
}
|
||||
|
||||
AboutFormBase::AboutFormBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
|
||||
{
|
||||
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
|
||||
|
||||
wxBoxSizer* m_DialogSizer;
|
||||
m_DialogSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxBoxSizer* m_InfoSizer;
|
||||
m_InfoSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
wxStaticBitmap* m_ProductIcon;
|
||||
m_ProductIcon = new wxStaticBitmap( this, wxID_ANY, wxBitmap( icinga_xpm ), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_InfoSizer->Add( m_ProductIcon, 0, wxALL, 5 );
|
||||
|
||||
wxBoxSizer* m_AboutInfoSizer;
|
||||
m_AboutInfoSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxStaticText* m_ProductNameLabel;
|
||||
m_ProductNameLabel = new wxStaticText( this, wxID_ANY, wxT("Icinga Studio"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_ProductNameLabel->Wrap( -1 );
|
||||
m_AboutInfoSizer->Add( m_ProductNameLabel, 0, wxALL, 5 );
|
||||
|
||||
m_VersionLabel = new wxStaticText( this, wxID_ANY, wxT("Version"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_VersionLabel->Wrap( -1 );
|
||||
m_AboutInfoSizer->Add( m_VersionLabel, 0, wxALL, 5 );
|
||||
|
||||
wxStaticText* m_CopyrightLabel;
|
||||
m_CopyrightLabel = new wxStaticText( this, wxID_ANY, wxT("Copyright (c) 2015 Icinga Development Team"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_CopyrightLabel->Wrap( -1 );
|
||||
m_AboutInfoSizer->Add( m_CopyrightLabel, 0, wxALL, 5 );
|
||||
|
||||
|
||||
m_InfoSizer->Add( m_AboutInfoSizer, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
m_DialogSizer->Add( m_InfoSizer, 1, wxEXPAND, 5 );
|
||||
|
||||
wxPanel* m_ButtonsPanel;
|
||||
m_ButtonsPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
wxBoxSizer* m_ButtonsSizer;
|
||||
m_ButtonsSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxStdDialogButtonSizer* m_Buttons;
|
||||
wxButton* m_ButtonsOK;
|
||||
m_Buttons = new wxStdDialogButtonSizer();
|
||||
m_ButtonsOK = new wxButton( m_ButtonsPanel, wxID_OK );
|
||||
m_Buttons->AddButton( m_ButtonsOK );
|
||||
m_Buttons->Realize();
|
||||
|
||||
m_ButtonsSizer->Add( m_Buttons, 0, wxEXPAND, 5 );
|
||||
|
||||
|
||||
m_ButtonsPanel->SetSizer( m_ButtonsSizer );
|
||||
m_ButtonsPanel->Layout();
|
||||
m_ButtonsSizer->Fit( m_ButtonsPanel );
|
||||
m_DialogSizer->Add( m_ButtonsPanel, 0, wxEXPAND | wxALL, 5 );
|
||||
|
||||
|
||||
this->SetSizer( m_DialogSizer );
|
||||
this->Layout();
|
||||
m_DialogSizer->Fit( this );
|
||||
|
||||
this->Centre( wxBOTH );
|
||||
}
|
||||
|
||||
AboutFormBase::~AboutFormBase()
|
||||
{
|
||||
}
|
|
@ -1,108 +0,0 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Jun 17 2015)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __FORMS_H__
|
||||
#define __FORMS_H__
|
||||
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/bitmap.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/icon.h>
|
||||
#include <wx/menu.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/font.h>
|
||||
#include <wx/colour.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/treectrl.h>
|
||||
#include <wx/listctrl.h>
|
||||
#include <wx/propgrid/propgrid.h>
|
||||
#include <wx/propgrid/advprops.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/statusbr.h>
|
||||
#include <wx/frame.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/statbox.h>
|
||||
#include <wx/panel.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/statbmp.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Class MainFormBase
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class MainFormBase : public wxFrame
|
||||
{
|
||||
private:
|
||||
|
||||
protected:
|
||||
wxMenuBar* m_MenuBar;
|
||||
wxTreeCtrl* m_TypesTree;
|
||||
wxListCtrl* m_ObjectsList;
|
||||
wxPropertyGrid* m_PropertyGrid;
|
||||
wxStatusBar* m_StatusBar;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void OnQuitClicked( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnAboutClicked( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnTypeSelected( wxTreeEvent& event ) { event.Skip(); }
|
||||
virtual void OnObjectSelected( wxListEvent& event ) { event.Skip(); }
|
||||
|
||||
|
||||
public:
|
||||
|
||||
MainFormBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Icinga Studio"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 800,569 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );
|
||||
|
||||
~MainFormBase() override;
|
||||
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Class ConnectFormBase
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class ConnectFormBase : public wxDialog
|
||||
{
|
||||
private:
|
||||
|
||||
protected:
|
||||
wxTextCtrl* m_HostText;
|
||||
wxTextCtrl* m_PortText;
|
||||
wxTextCtrl* m_UserText;
|
||||
wxTextCtrl* m_PasswordText;
|
||||
wxStdDialogButtonSizer* m_Buttons;
|
||||
wxButton* m_ButtonsOK;
|
||||
wxButton* m_ButtonsCancel;
|
||||
|
||||
public:
|
||||
|
||||
ConnectFormBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Icinga Studio - Connect"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE );
|
||||
~ConnectFormBase() override;
|
||||
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Class AboutFormBase
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class AboutFormBase : public wxDialog
|
||||
{
|
||||
private:
|
||||
|
||||
protected:
|
||||
wxStaticText* m_VersionLabel;
|
||||
|
||||
public:
|
||||
|
||||
AboutFormBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("About Icinga Studio"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE );
|
||||
~AboutFormBase() override;
|
||||
|
||||
};
|
||||
|
||||
#endif //__FORMS_H__
|
|
@ -1,66 +0,0 @@
|
|||
/******************************************************************************
|
||||
* Icinga 2 *
|
||||
* Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com/) *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the Free Software Foundation *
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#include "icinga-studio/connectform.hpp"
|
||||
#include "icinga-studio/mainform.hpp"
|
||||
#include "base/application.hpp"
|
||||
#include <wx/wx.h>
|
||||
#include <wx/app.h>
|
||||
#include <wx/config.h>
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
class IcingaStudio final : public wxApp
|
||||
{
|
||||
public:
|
||||
bool OnInit() override
|
||||
{
|
||||
Application::InitializeBase();
|
||||
|
||||
Url::Ptr pUrl;
|
||||
|
||||
if (argc < 2) {
|
||||
wxConfig config("IcingaStudio");
|
||||
wxString wUrl;
|
||||
|
||||
if (!config.Read("url", &wUrl))
|
||||
wUrl = "https://localhost:5665/";
|
||||
|
||||
std::string url = wUrl.ToStdString();
|
||||
|
||||
ConnectForm f(nullptr, new Url(url));
|
||||
if (f.ShowModal() != wxID_OK)
|
||||
return false;
|
||||
|
||||
pUrl = f.GetUrl();
|
||||
url = pUrl->Format(false, true);
|
||||
wUrl = url;
|
||||
config.Write("url", wUrl);
|
||||
} else {
|
||||
pUrl = new Url(argv[1].ToStdString());
|
||||
}
|
||||
|
||||
auto *m = new MainForm(nullptr, pUrl);
|
||||
m->Show();
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
wxIMPLEMENT_APP(IcingaStudio);
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 766 B |
|
@ -1,34 +0,0 @@
|
|||
#include <windows.h>
|
||||
#include "icinga-version.h"
|
||||
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
|
||||
icinga ICON "icinga.ico"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,0
|
||||
PRODUCTVERSION 1,0,0,0
|
||||
FILEOS VOS__WINDOWS32
|
||||
FILETYPE VFT_APP
|
||||
FILESUBTYPE VFT2_UNKNOWN
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Icinga Development Team"
|
||||
VALUE "FileDescription", "Icinga Studio"
|
||||
VALUE "FileVersion", VERSION
|
||||
VALUE "InternalName", "icinga-studio.exe"
|
||||
VALUE "LegalCopyright", "© Icinga Development Team"
|
||||
VALUE "OriginalFilename", "icinga-studio.exe"
|
||||
VALUE "ProductName", "Icinga 2"
|
||||
VALUE "ProductVersion", VERSION
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 0x04E4
|
||||
END
|
||||
END
|
|
@ -1,40 +0,0 @@
|
|||
/* XPM */
|
||||
static const char *icinga_xpm[] = {
|
||||
"32 32 5 1",
|
||||
" c None",
|
||||
". c #808080",
|
||||
"+ c #000000",
|
||||
"@ c #C0C0C0",
|
||||
"# c #FFFFFF",
|
||||
" ",
|
||||
" .++++++++++++++++++++++++. ",
|
||||
" .+++++++++++++++..+++++++++. ",
|
||||
" .+++++++++++++++@##@+++++++++. ",
|
||||
" +++++++++++++++.####.+++++++++ ",
|
||||
" +++++++++++++++.####.+++++++++ ",
|
||||
" ++++++++++++++++####++++++++++ ",
|
||||
" ++++++++++++++++@@..++++++++++ ",
|
||||
" +++++..+++++++++#.++++++++++++ ",
|
||||
" ++++.##@+++++++@#+++++++++++++ ",
|
||||
" ++++.###+++++++#.+++++++++.+++ ",
|
||||
" ++++.###@++.@@@#+++++++++@##.+ ",
|
||||
" +++++++.@#######.+++++++.###@+ ",
|
||||
" +++++++++########++++..@####.+ ",
|
||||
" ++++++++.########@@###@...@.++ ",
|
||||
" ++++++++.#########@..+++++++++ ",
|
||||
" ++++++++.########@++++++++++++ ",
|
||||
" ++++++++.########.++++++++++++ ",
|
||||
" +++++++++########+++++++++++++ ",
|
||||
" +++++++++.######.+++++++++++++ ",
|
||||
" +++++++++.#....#.+++++++++++++ ",
|
||||
" ++++++++.#.++++.#.++++++++++++ ",
|
||||
" ++++++++@@++++++##.+++++++++++ ",
|
||||
" ++++@##@#+++++++##@+++++++++++ ",
|
||||
" +++@####@+++++++..++++++++++++ ",
|
||||
" +++######.++++++++++++++++++++ ",
|
||||
" +++######.++++++++++++++++++++ ",
|
||||
" +++######+++++++++++++++++++++ ",
|
||||
" .++.####.++++++++++++++++++++. ",
|
||||
" .+++..+++++++++++++++++++++. ",
|
||||
" .++++++++++++++++++++++++. ",
|
||||
" "};
|
|
@ -1,316 +0,0 @@
|
|||
/******************************************************************************
|
||||
* Icinga 2 *
|
||||
* Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com/) *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the Free Software Foundation *
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#include "icinga-studio/mainform.hpp"
|
||||
#include "icinga-studio/aboutform.hpp"
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
#include <wx/msgdlg.h>
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
MainForm::MainForm(wxWindow *parent, const Url::Ptr& url)
|
||||
: MainFormBase(parent)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
SetIcon(wxICON(icinga));
|
||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
|
||||
#endif /* _WIN32 */
|
||||
|
||||
String port = url->GetPort();
|
||||
|
||||
if (port.IsEmpty())
|
||||
port = "5665";
|
||||
|
||||
m_ApiClient = new ApiClient(url->GetHost(), port, url->GetUsername(), url->GetPassword());
|
||||
m_ApiClient->GetTypes(std::bind(&MainForm::TypesCompletionHandler, this, _1, _2, true));
|
||||
|
||||
std::string title = url->Format() + " - Icinga Studio";
|
||||
SetTitle(title);
|
||||
|
||||
m_ObjectsList->InsertColumn(0, "Name", 0, 300);
|
||||
|
||||
m_PropertyGrid->SetColumnCount(3);
|
||||
}
|
||||
|
||||
void MainForm::TypesCompletionHandler(boost::exception_ptr eptr, const std::vector<ApiType::Ptr>& types, bool forward)
|
||||
{
|
||||
if (forward) {
|
||||
CallAfter(std::bind(&MainForm::TypesCompletionHandler, this, eptr, types, false));
|
||||
return;
|
||||
}
|
||||
|
||||
m_TypesTree->DeleteAllItems();
|
||||
|
||||
if (eptr) {
|
||||
try {
|
||||
boost::rethrow_exception(eptr);
|
||||
} catch (const std::exception& ex) {
|
||||
std::string message = "HTTP query failed: " + std::string(ex.what());
|
||||
wxMessageBox(message, "Icinga Studio", wxOK | wxCENTRE | wxICON_ERROR, this);
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
wxTreeItemId rootNode = m_TypesTree->AddRoot("root");
|
||||
|
||||
for (const ApiType::Ptr& type : types) {
|
||||
m_Types[type->Name] = type;
|
||||
}
|
||||
|
||||
for (const ApiType::Ptr& type : types) {
|
||||
if (type->Abstract)
|
||||
continue;
|
||||
|
||||
bool configObject = false;
|
||||
ApiType::Ptr currentType = type;
|
||||
|
||||
for (;;) {
|
||||
if (currentType->BaseName.IsEmpty())
|
||||
break;
|
||||
|
||||
currentType = m_Types[currentType->BaseName];
|
||||
|
||||
if (!currentType)
|
||||
break;
|
||||
|
||||
if (currentType->Name == "ConfigObject") {
|
||||
configObject = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (configObject) {
|
||||
std::string name = type->Name;
|
||||
m_TypesTree->AppendItem(rootNode, name, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainForm::OnTypeSelected(wxTreeEvent& event)
|
||||
{
|
||||
wxTreeItemId selectedId = m_TypesTree->GetSelection();
|
||||
wxString typeName = m_TypesTree->GetItemText(selectedId);
|
||||
ApiType::Ptr type = m_Types[typeName.ToStdString()];
|
||||
|
||||
std::vector<String> attrs;
|
||||
attrs.emplace_back("__name");
|
||||
|
||||
m_ApiClient->GetObjects(type->PluralName, std::bind(&MainForm::ObjectsCompletionHandler, this, _1, _2, true),
|
||||
std::vector<String>(), attrs);
|
||||
}
|
||||
|
||||
static bool ApiObjectLessComparer(const ApiObject::Ptr& o1, const ApiObject::Ptr& o2)
|
||||
{
|
||||
return o1->Name < o2->Name;
|
||||
}
|
||||
|
||||
void MainForm::ObjectsCompletionHandler(boost::exception_ptr eptr, const std::vector<ApiObject::Ptr>& objects, bool forward)
|
||||
{
|
||||
if (forward) {
|
||||
CallAfter(std::bind(&MainForm::ObjectsCompletionHandler, this, eptr, objects, false));
|
||||
return;
|
||||
}
|
||||
|
||||
m_ObjectsList->DeleteAllItems();
|
||||
m_PropertyGrid->Clear();
|
||||
|
||||
if (eptr) {
|
||||
try {
|
||||
boost::rethrow_exception(eptr);
|
||||
} catch (const std::exception& ex) {
|
||||
std::string message = "HTTP query failed: " + std::string(ex.what());
|
||||
wxMessageBox(message, "Icinga Studio", wxOK | wxCENTRE | wxICON_ERROR, this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<ApiObject::Ptr> sortedObjects = objects;
|
||||
std::sort(sortedObjects.begin(), sortedObjects.end(), ApiObjectLessComparer);
|
||||
|
||||
for (const ApiObject::Ptr& object : sortedObjects) {
|
||||
std::string name = object->Name;
|
||||
m_ObjectsList->InsertItem(0, name);
|
||||
}
|
||||
}
|
||||
|
||||
void MainForm::OnObjectSelected(wxListEvent& event)
|
||||
{
|
||||
wxTreeItemId selectedId = m_TypesTree->GetSelection();
|
||||
wxString typeName = m_TypesTree->GetItemText(selectedId);
|
||||
ApiType::Ptr type = m_Types[typeName.ToStdString()];
|
||||
|
||||
long itemIndex = -1;
|
||||
std::string objectName;
|
||||
|
||||
while ((itemIndex = m_ObjectsList->GetNextItem(itemIndex,
|
||||
wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED)) != wxNOT_FOUND) {
|
||||
objectName = m_ObjectsList->GetItemText(itemIndex);
|
||||
break;
|
||||
}
|
||||
|
||||
if (objectName.empty())
|
||||
return;
|
||||
|
||||
std::vector<String> names;
|
||||
names.emplace_back(objectName);
|
||||
|
||||
m_ApiClient->GetObjects(type->PluralName, std::bind(&MainForm::ObjectDetailsCompletionHandler, this, _1, _2, true),
|
||||
names, std::vector<String>(), std::vector<String>(), true);
|
||||
}
|
||||
|
||||
wxPGProperty *MainForm::ValueToProperty(const String& name, const Value& value)
|
||||
{
|
||||
wxPGProperty *prop;
|
||||
|
||||
if (value.IsNumber()) {
|
||||
prop = new wxFloatProperty(name.GetData(), wxPG_LABEL, value);
|
||||
prop->SetAttribute(wxPG_ATTR_UNITS, "Number");
|
||||
return prop;
|
||||
} else if (value.IsBoolean()) {
|
||||
prop = new wxBoolProperty(name.GetData(), wxPG_LABEL, value);
|
||||
prop->SetAttribute(wxPG_ATTR_UNITS, "Boolean");
|
||||
return prop;
|
||||
} else if (value.IsObjectType<Array>()) {
|
||||
wxArrayString val;
|
||||
Array::Ptr arr = value;
|
||||
|
||||
{
|
||||
ObjectLock olock(arr);
|
||||
for (const Value& aitem : arr) {
|
||||
String val1 = aitem;
|
||||
val.Add(val1.GetData());
|
||||
}
|
||||
}
|
||||
|
||||
prop = new wxArrayStringProperty(name.GetData(), wxPG_LABEL, val);
|
||||
prop->SetAttribute(wxPG_ATTR_UNITS, "Array");
|
||||
return prop;
|
||||
} else if (value.IsObjectType<Dictionary>()) {
|
||||
wxStringProperty *prop = new wxStringProperty(name.GetData(), wxPG_LABEL);
|
||||
|
||||
Dictionary::Ptr dict = value;
|
||||
|
||||
{
|
||||
ObjectLock olock(dict);
|
||||
for (const Dictionary::Pair& kv : dict) {
|
||||
if (kv.first != "type")
|
||||
prop->AppendChild(ValueToProperty(kv.first, kv.second));
|
||||
}
|
||||
}
|
||||
|
||||
String type = "Dictionary";
|
||||
|
||||
if (dict->Contains("type"))
|
||||
type = dict->Get("type");
|
||||
|
||||
prop->SetAttribute(wxPG_ATTR_UNITS, type.GetData());
|
||||
|
||||
return prop;
|
||||
} else if (value.IsEmpty() && !value.IsString()) {
|
||||
prop = new wxStringProperty(name.GetData(), wxPG_LABEL, "");
|
||||
prop->SetAttribute(wxPG_ATTR_UNITS, "Empty");
|
||||
return prop;
|
||||
} else {
|
||||
String val = value;
|
||||
prop = new wxStringProperty(name.GetData(), wxPG_LABEL, val.GetData());
|
||||
prop->SetAttribute(wxPG_ATTR_UNITS, "String");
|
||||
return prop;
|
||||
}
|
||||
}
|
||||
|
||||
void MainForm::ObjectDetailsCompletionHandler(boost::exception_ptr eptr, const std::vector<ApiObject::Ptr>& objects, bool forward)
|
||||
{
|
||||
if (forward) {
|
||||
CallAfter(std::bind(&MainForm::ObjectDetailsCompletionHandler, this, eptr, objects, false));
|
||||
return;
|
||||
}
|
||||
|
||||
m_PropertyGrid->Clear();
|
||||
|
||||
if (eptr) {
|
||||
try {
|
||||
boost::rethrow_exception(eptr);
|
||||
} catch (const std::exception& ex) {
|
||||
std::string message = "HTTP query failed: " + std::string(ex.what());
|
||||
wxMessageBox(message, "Icinga Studio", wxOK | wxCENTRE | wxICON_ERROR, this);
|
||||
}
|
||||
}
|
||||
|
||||
wxTreeItemId selectedId = m_TypesTree->GetSelection();
|
||||
wxString typeName = m_TypesTree->GetItemText(selectedId);
|
||||
ApiType::Ptr type = m_Types[typeName.ToStdString()];
|
||||
|
||||
String nameAttr = type->Name.ToLower() + ".__name";
|
||||
|
||||
if (objects.empty())
|
||||
return;
|
||||
|
||||
ApiObject::Ptr object = objects[0];
|
||||
|
||||
std::map<String, wxStringProperty *> parents;
|
||||
|
||||
for (const auto& kv : object->Attrs) {
|
||||
std::vector<String> tokens;
|
||||
boost::algorithm::split(tokens, kv.first, boost::is_any_of("."));
|
||||
|
||||
std::map<String, wxStringProperty *>::const_iterator it = parents.find(tokens[0]);
|
||||
|
||||
wxStringProperty *parent;
|
||||
|
||||
if (it == parents.end()) {
|
||||
parent = new wxStringProperty(tokens[0].GetData(), wxPG_LABEL);
|
||||
parent->SetAttribute(wxPG_ATTR_UNITS, "Object");
|
||||
parents[tokens[0]] = parent;
|
||||
} else
|
||||
parent = it->second;
|
||||
|
||||
wxPGProperty *prop = ValueToProperty(tokens[1], kv.second);
|
||||
parent->AppendChild(prop);
|
||||
}
|
||||
|
||||
/* Make sure the property node for the real object (as opposed to joined objects) is the first one */
|
||||
String propName = type->Name.ToLower();
|
||||
wxStringProperty *objProp = parents[propName];
|
||||
|
||||
if (objProp) {
|
||||
m_PropertyGrid->Append(objProp);
|
||||
m_PropertyGrid->SetPropertyReadOnly(objProp);
|
||||
parents.erase(propName);
|
||||
}
|
||||
|
||||
for (const auto& kv : parents) {
|
||||
m_PropertyGrid->Append(kv.second);
|
||||
m_PropertyGrid->SetPropertyReadOnly(kv.second);
|
||||
}
|
||||
|
||||
m_PropertyGrid->FitColumns();
|
||||
}
|
||||
|
||||
void MainForm::OnQuitClicked(wxCommandEvent& event)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
void MainForm::OnAboutClicked(wxCommandEvent& event)
|
||||
{
|
||||
AboutForm form(this);
|
||||
form.ShowModal();
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
/******************************************************************************
|
||||
* Icinga 2 *
|
||||
* Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com/) *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the Free Software Foundation *
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef MAINFORM_H
|
||||
#define MAINFORM_H
|
||||
|
||||
#include "remote/apiclient.hpp"
|
||||
#include "remote/url.hpp"
|
||||
#include "base/exception.hpp"
|
||||
#include "icinga-studio/forms.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class MainForm final : public MainFormBase
|
||||
{
|
||||
public:
|
||||
MainForm(wxWindow *parent, const Url::Ptr& url);
|
||||
|
||||
void OnQuitClicked(wxCommandEvent& event) override;
|
||||
void OnAboutClicked(wxCommandEvent& event) override;
|
||||
void OnTypeSelected(wxTreeEvent& event) override;
|
||||
void OnObjectSelected(wxListEvent& event) override;
|
||||
|
||||
private:
|
||||
ApiClient::Ptr m_ApiClient;
|
||||
std::map<String, ApiType::Ptr> m_Types;
|
||||
|
||||
void TypesCompletionHandler(boost::exception_ptr eptr, const std::vector<ApiType::Ptr>& types, bool forward);
|
||||
void ObjectsCompletionHandler(boost::exception_ptr eptr, const std::vector<ApiObject::Ptr>& objects, bool forward);
|
||||
void ObjectDetailsCompletionHandler(boost::exception_ptr eptr, const std::vector<ApiObject::Ptr>& objects, bool forward);
|
||||
|
||||
wxPGProperty *ValueToProperty(const String& name, const Value& value);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* MAINFORM_H */
|
Loading…
Reference in New Issue