Skip to content

Commit

Permalink
Merge pull request #3 from gsanchietti/server-manager-ui
Browse files Browse the repository at this point in the history
Add basic UI

NethServer/dev#5448
  • Loading branch information
gsanchietti committed Apr 3, 2018
2 parents bcd8aa1 + ce1d57e commit fa51e4b
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 5 deletions.
29 changes: 24 additions & 5 deletions createlinks
Expand Up @@ -21,24 +21,43 @@

use esmith::Build::CreateLinks qw(:all);

#
#--------------------------------------------------
# Event nethserver-mattermost-update
#
event_actions("nethserver-mattermost-update", qw(
#--------------------------------------------------

$event = 'nethserver-mattermost-update';

event_actions($event, qw(
initialize-default-databases 00
nethserver-mattermost-conf 20
nethserver-mattermost-conf-json 30
));

event_templates("nethserver-mattermost-update", qw(
event_templates($event, qw(
/etc/httpd/conf.d/zz_mattermost.conf
));

event_services($event, qw(
httpd restart
mattermost restart
));

#--------------------------------------------------
# Event nethserver-mattermost-save
#--------------------------------------------------

$event = 'nethserver-mattermost-save';

event_templates($event, qw(
/etc/httpd/conf.d/zz_mattermost.conf
));

event_services("nethserver-mattermost-update", qw(
event_services($event, qw(
httpd restart
mattermost restart
));


#--------------------------------------------------
# actions for pre-backup-data event
#--------------------------------------------------
Expand Down
@@ -0,0 +1 @@
none
@@ -0,0 +1,8 @@
<?php

$L['Mattermost_Description'] = 'Mattermost Team Edition';
$L['Mattermost_Tags'] = 'mattermost chat team edition';
$L['Mattermost_Title'] = 'Team chat';
$L['status_label'] = 'Enable Mattermost Team Edition';
$L['info_label'] = 'Mattermost is accessible only using a dedicated host name (eg. mattermost.yourdomain.org). If you\'re using Let\'s Encrypt certificate, remember to add the hostname below to the "${1}" field inside the "${1}" page';
$L['VirtualHost_label'] = 'Virtual host name';
@@ -0,0 +1,43 @@
<?php
namespace NethServer\Module\Dashboard\Applications;

/*
* Copyright (C) 2018 Nethesis S.r.l.
*
* This script is part of NethServer.
*
* NethServer 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 3 of the License, or
* (at your option) any later version.
*
* NethServer 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 NethServer. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* WebTop
*
* @author Giacomo Sanchietti
*/
class Mattermost extends \Nethgui\Module\AbstractModule implements \NethServer\Module\Dashboard\Interfaces\ApplicationInterface
{

public function getName()
{
return "Mattermost";
}

public function getInfo()
{
$host = $this->getPlatform()->getDatabase('configuration')->getProp('mattermost', 'VirtualHost');
return array(
'url' => "https://".$host
);
}
}
60 changes: 60 additions & 0 deletions root/usr/share/nethesis/NethServer/Module/Mattermost.php
@@ -0,0 +1,60 @@
<?php

namespace NethServer\Module;

/*
* Copyright (C) 2018 Nethesis S.r.l.
*
* This script is part of NethServer.
*
* NethServer 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 3 of the License, or
* (at your option) any later version.
*
* NethServer 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 NethServer. If not, see <http://www.gnu.org/licenses/>.
*/

use Nethgui\System\PlatformInterface as Validate;

/**
* Configure Mattermost
*
* @author Giacomo Sanchietti<giacomo.sanchietti@nethesis.it>
*/
class Mattermost extends \Nethgui\Controller\AbstractController
{

protected function initializeAttributes(\Nethgui\Module\ModuleAttributesInterface $base)
{
return new \NethServer\Tool\CustomModuleAttributesProvider($base, array(
'languageCatalog' => array('NethServer_Module_Mattermost','NethServer_Module_Pki'),
'category' => 'Configuration')
);
}

public function initialize()
{
parent::initialize();
$this->declareParameter('VirtualHost', Validate::HOSTNAME_FQDN, array('configuration', 'mattermost', 'VirtualHost'));
$this->declareParameter('status', Validate::SERVICESTATUS, array('configuration', 'mattermost', 'status'));
}

public function prepareView(\Nethgui\View\ViewInterface $view)
{
$domain = $this->getPlatform()->getDatabase('configuration')->getType("DomainName");
$view['DefaultUrl'] = "mattermost.$domain";
}

protected function onParametersSaved($changes)
{
$this->getPlatform()->signalEvent('nethserver-mattermost-save');
}

}
20 changes: 20 additions & 0 deletions root/usr/share/nethesis/NethServer/Template/Mattermost.php
@@ -0,0 +1,20 @@
<?php

echo $view->header()->setAttribute('template', $T('Mattermost_Title'));

$url = $view->getModuleUrl('/Pki');
$info = "<div class='mattermost-info'><p><span class='fa fa-info-circle'></span>".$T('info_label', array($T('LetsEncryptDomains_label'),$T('Pki_Title')))."</p></div>";

echo $view->panel()
->insert($view->fieldsetSwitch('status', 'enabled', $view::FIELDSETSWITCH_CHECKBOX | $view::FIELDSETSWITCH_EXPANDABLE)->setAttribute('uncheckedValue', 'disabled')
->insert($view->panel()->insert($view->literal($info)))
->insert($view->textInput('VirtualHost')->setAttribute('placeholder',$view['DefaultUrl']))
);

echo $view->buttonList($view::BUTTON_SUBMIT);

$view->includeCss("
.mattermost-info { padding: 10px; margin: 10px; border: 1px solid #c2c2c2; width: 50%; background-color: #eee }
.mattermost-info .fa { padding-right: 5px }
");

0 comments on commit fa51e4b

Please sign in to comment.