forked from deblan/side_menu
add admin settings
This commit is contained in:
parent
b9bb3989f4
commit
ec8b0a2866
|
@ -24,12 +24,24 @@ use OCP\Util;
|
|||
|
||||
$config = \OC::$server->getConfig();
|
||||
$cspnm = \OC::$server->getContentSecurityPolicyNonceManager();
|
||||
$stylesheet = \OC::$server->getURLGenerator()->linkToRoute(
|
||||
'side_menu.Css.stylesheet',
|
||||
[
|
||||
'v' => $config->getAppValue('side_menu', 'cache', '0'),
|
||||
]
|
||||
);
|
||||
|
||||
Util::addHeader(
|
||||
'link',
|
||||
[
|
||||
'href' => $stylesheet,
|
||||
'rel' => 'stylesheet'
|
||||
], ''
|
||||
);
|
||||
|
||||
Util::addScript('side_menu', 'main');
|
||||
Util::addScript('side_menu', 'sideMenu');
|
||||
Util::addStyle('side_menu', 'sideMenu');
|
||||
|
||||
|
||||
// whitelist the URL to allow loading JS from this external domain
|
||||
// $CSPManager = \OC::$server->getContentSecurityPolicyManager();
|
||||
// $policy = new ContentSecurityPolicy();
|
||||
|
|
|
@ -17,4 +17,8 @@
|
|||
<dependencies>
|
||||
<nextcloud min-version="18" max-version="18"/>
|
||||
</dependencies>
|
||||
<settings>
|
||||
<admin>OCA\SideMenu\Settings\Admin</admin>
|
||||
<admin-section>OCA\SideMenu\Settings\Section</admin-section>
|
||||
</settings>
|
||||
</info>
|
||||
|
|
|
@ -19,5 +19,6 @@
|
|||
|
||||
return [
|
||||
'routes' => [
|
||||
['name' => 'Css#stylesheet', 'url' => '/css/stylesheet', 'verb' => 'GET'],
|
||||
],
|
||||
];
|
||||
|
|
25
css/admin.css
Normal file
25
css/admin.css
Normal file
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#side-menu-section input[type="color"] {
|
||||
width: 100px;
|
||||
margin: 10px 0 10px 0;
|
||||
}
|
||||
|
||||
#side-menu-section select {
|
||||
margin: 10px 0 10px 0;
|
||||
}
|
|
@ -38,7 +38,7 @@
|
|||
}
|
||||
|
||||
.side-menu-opener {
|
||||
background: url('../img/side-menu-opener.svg');
|
||||
background: var(--side-menu-opener, url('../img/side-menu-opener.svg'));
|
||||
height: 40px;
|
||||
width: 40px;
|
||||
border-radius: 0;
|
||||
|
|
1
img/app-dark.svg
Normal file
1
img/app-dark.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M10.707 11.412l-.587-.587-.03-.03a.513.513 0 0 1-.074-.526L13.07 3.4l-1.5-1.498-.15.15-.708-.706.505-.505a.538.538 0 0 1 .224-.128c.04-.01.05-.01.087-.016h.087c.04.006.05.006.086.016.072.02.134.055.192.1.74.676 1.42 1.415 2.127 2.124a.503.503 0 0 1 .103.556l-3.053 6.87.344.343.49-.49 3.01 3.01a1.192 1.192 0 0 1-1.685 1.686l-3.012-3.01.49-.488zm-.533-10.217a.986.986 0 0 0-1.396 0l-7.582 7.58a.99.99 0 0 0 0 1.398l1.397 1.396a.986.986 0 0 0 1.396 0l7.58-7.583a.988.988 0 0 0 0-1.396l-1.396-1.395z" fill="#000"/></svg>
|
After Width: | Height: | Size: 611 B |
7
img/side-menu-opener-hamburger.svg
Normal file
7
img/side-menu-opener-hamburger.svg
Normal file
|
@ -0,0 +1,7 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 10.583 10.583">
|
||||
<g color="#000" fill="#fff" fill-opacity=".855" transform="translate(0 -286.417)">
|
||||
<rect ry=".545" rx="0" y="288.816" x="2.516" height="1.451" width="5.551" style="marker:none" overflow="visible" paint-order="stroke markers fill"/>
|
||||
<rect ry=".545" rx="0" y="290.973" x="2.516" height="1.451" width="5.551" style="marker:none" overflow="visible" paint-order="stroke markers fill"/>
|
||||
<rect ry=".545" rx="0" y="293.15" x="2.516" height="1.451" width="5.551" style="marker:none" overflow="visible" paint-order="stroke markers fill"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 649 B |
|
@ -1,159 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="40"
|
||||
height="40"
|
||||
viewBox="0 0 10.583333 10.583333"
|
||||
version="1.1"
|
||||
id="svg8"
|
||||
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
|
||||
sodipodi:docname="side-menu-opener.svg">
|
||||
<defs
|
||||
id="defs2" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="9.7123697"
|
||||
inkscape:cx="61.421304"
|
||||
inkscape:cy="18.194306"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
units="px"
|
||||
inkscape:window-width="1918"
|
||||
inkscape:window-height="1027"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="21"
|
||||
inkscape:window-maximized="0" />
|
||||
<metadata
|
||||
id="metadata5">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Calque 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(0,-286.41667)">
|
||||
<g
|
||||
id="g1014"
|
||||
transform="translate(0.30030892,0.3423999)"
|
||||
style="fill:#ffffff">
|
||||
<rect
|
||||
ry="0"
|
||||
rx="0"
|
||||
y="288.47351"
|
||||
x="4.2660251"
|
||||
height="1.4506654"
|
||||
width="1.4506654"
|
||||
id="rect817-7"
|
||||
style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:0.85507244;fill-rule:nonzero;stroke:#ffffff;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;paint-order:stroke markers fill;enable-background:accumulate" />
|
||||
<g
|
||||
transform="translate(-0.12939894)"
|
||||
id="g952"
|
||||
style="fill:#ffffff">
|
||||
<rect
|
||||
style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:0.85507244;fill-rule:nonzero;stroke:#ffffff;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;paint-order:stroke markers fill;enable-background:accumulate"
|
||||
id="rect817-7-5"
|
||||
width="1.4506654"
|
||||
height="1.4506654"
|
||||
x="6.4453764"
|
||||
y="288.47351"
|
||||
rx="0"
|
||||
ry="0" />
|
||||
<rect
|
||||
style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:0.85507244;fill-rule:nonzero;stroke:#ffffff;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;paint-order:stroke markers fill;enable-background:accumulate"
|
||||
id="rect817-7-3"
|
||||
width="1.4506654"
|
||||
height="1.4506654"
|
||||
x="2.3454716"
|
||||
y="288.47351"
|
||||
rx="0"
|
||||
ry="0" />
|
||||
</g>
|
||||
<rect
|
||||
ry="0"
|
||||
rx="0"
|
||||
y="290.63095"
|
||||
x="4.2660251"
|
||||
height="1.4506654"
|
||||
width="1.4506654"
|
||||
id="rect817-7-56"
|
||||
style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:0.85507244;fill-rule:nonzero;stroke:#ffffff;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;paint-order:stroke markers fill;enable-background:accumulate" />
|
||||
<g
|
||||
transform="translate(-0.12939893,2.157457)"
|
||||
id="g952-2"
|
||||
style="fill:#ffffff">
|
||||
<rect
|
||||
style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:0.85507244;fill-rule:nonzero;stroke:#ffffff;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;paint-order:stroke markers fill;enable-background:accumulate"
|
||||
id="rect817-7-5-9"
|
||||
width="1.4506654"
|
||||
height="1.4506654"
|
||||
x="6.4453764"
|
||||
y="288.47351"
|
||||
rx="0"
|
||||
ry="0" />
|
||||
<rect
|
||||
style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:0.85507244;fill-rule:nonzero;stroke:#ffffff;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;paint-order:stroke markers fill;enable-background:accumulate"
|
||||
id="rect817-7-3-1"
|
||||
width="1.4506654"
|
||||
height="1.4506654"
|
||||
x="2.3454716"
|
||||
y="288.47351"
|
||||
rx="0"
|
||||
ry="0" />
|
||||
</g>
|
||||
<rect
|
||||
ry="0"
|
||||
rx="0"
|
||||
y="292.80765"
|
||||
x="4.2660251"
|
||||
height="1.4506654"
|
||||
width="1.4506654"
|
||||
id="rect817-7-56-2"
|
||||
style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:0.85507244;fill-rule:nonzero;stroke:#ffffff;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;paint-order:stroke markers fill;enable-background:accumulate" />
|
||||
<g
|
||||
transform="translate(-0.12939893,4.3341867)"
|
||||
id="g952-2-7"
|
||||
style="fill:#ffffff">
|
||||
<rect
|
||||
style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:0.85507244;fill-rule:nonzero;stroke:#ffffff;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;paint-order:stroke markers fill;enable-background:accumulate"
|
||||
id="rect817-7-5-9-0"
|
||||
width="1.4506654"
|
||||
height="1.4506654"
|
||||
x="6.4453764"
|
||||
y="288.47351"
|
||||
rx="0"
|
||||
ry="0" />
|
||||
<rect
|
||||
style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:0.85507244;fill-rule:nonzero;stroke:#ffffff;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;paint-order:stroke markers fill;enable-background:accumulate"
|
||||
id="rect817-7-3-1-9"
|
||||
width="1.4506654"
|
||||
height="1.4506654"
|
||||
x="2.3454716"
|
||||
y="288.47351"
|
||||
rx="0"
|
||||
ry="0" />
|
||||
</g>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 10.583 10.583">
|
||||
<g transform="translate(.3 -286.074)" fill="#fff" color="#000" fill-opacity=".855">
|
||||
<rect ry="0" rx="0" y="288.474" x="4.266" height="1.451" width="1.451" style="marker:none" overflow="visible" paint-order="stroke markers fill"/>
|
||||
<g transform="translate(-.13)">
|
||||
<rect style="marker:none" width="1.451" height="1.451" x="6.445" y="288.474" rx="0" ry="0" overflow="visible" paint-order="stroke markers fill"/>
|
||||
<rect style="marker:none" width="1.451" height="1.451" x="2.345" y="288.474" rx="0" ry="0" overflow="visible" paint-order="stroke markers fill"/>
|
||||
</g>
|
||||
<rect ry="0" rx="0" y="290.631" x="4.266" height="1.451" width="1.451" style="marker:none" overflow="visible" paint-order="stroke markers fill"/>
|
||||
<g transform="translate(-.13 2.157)">
|
||||
<rect style="marker:none" width="1.451" height="1.451" x="6.445" y="288.474" rx="0" ry="0" overflow="visible" paint-order="stroke markers fill"/>
|
||||
<rect style="marker:none" width="1.451" height="1.451" x="2.345" y="288.474" rx="0" ry="0" overflow="visible" paint-order="stroke markers fill"/>
|
||||
</g>
|
||||
<rect ry="0" rx="0" y="292.808" x="4.266" height="1.451" width="1.451" style="marker:none" overflow="visible" paint-order="stroke markers fill"/>
|
||||
<g transform="translate(-.13 4.334)">
|
||||
<rect style="marker:none" width="1.451" height="1.451" x="6.445" y="288.474" rx="0" ry="0" overflow="visible" paint-order="stroke markers fill"/>
|
||||
<rect style="marker:none" width="1.451" height="1.451" x="2.345" y="288.474" rx="0" ry="0" overflow="visible" paint-order="stroke markers fill"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 1.7 KiB |
74
lib/Controller/CssController.php
Normal file
74
lib/Controller/CssController.php
Normal file
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
/**
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace OCA\SideMenu\Controller;
|
||||
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\DataDownloadResponse;
|
||||
use OCP\AppFramework\Http\Response;
|
||||
use OCP\IConfig;
|
||||
use OCP\IRequest;
|
||||
|
||||
class CssController extends Controller
|
||||
{
|
||||
|
||||
/** @var \OCP\IConfig */
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* @param string $appName
|
||||
* @param IRequest $request
|
||||
* @param IConfig $config
|
||||
*/
|
||||
public function __construct($appName, IRequest $request, IConfig $config)
|
||||
{
|
||||
parent::__construct($appName, $request);
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @PublicPage
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function stylesheet()
|
||||
{
|
||||
$parameters = [
|
||||
'--side-menu-background-color' => $this->config->getAppValue('side_menu', 'background-color', '#333333'),
|
||||
'--side-menu-current-app-background-color' => $this->config->getAppValue('side_menu', 'current-app-background-color', '#444444'),
|
||||
'--side-menu-text-color' => $this->config->getAppValue('side_menu', 'text-color', '#FFFFFF'),
|
||||
'--side-menu-opener' => $this->config->getAppValue('side_menu', 'opener', 'side-menu-opener'),
|
||||
];
|
||||
|
||||
$css = '';
|
||||
|
||||
foreach ($parameters as $key => $value) {
|
||||
if ($key === '--side-menu-opener') {
|
||||
$value = sprintf("url('../img/%s.svg')", $value);
|
||||
}
|
||||
|
||||
$css.= sprintf('%s: %s;', $key, $value);
|
||||
}
|
||||
|
||||
$css = sprintf(':root { %s }', $css);
|
||||
|
||||
return new DataDownloadResponse($css, 'stylesheet', 'text/css');
|
||||
}
|
||||
}
|
79
lib/Settings/Admin.php
Normal file
79
lib/Settings/Admin.php
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
/**
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace OCA\SideMenu\Settings;
|
||||
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\IL10N;
|
||||
use OCP\ILogger;
|
||||
use OCP\Settings\ISettings;
|
||||
use OCP\IConfig;
|
||||
|
||||
class Admin implements ISettings
|
||||
{
|
||||
/** @var IL10N */
|
||||
private $l;
|
||||
|
||||
/** @var ILogger */
|
||||
private $logger;
|
||||
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
public function __construct(IL10N $l, ILogger $logger, IConfig $config) {
|
||||
$this->l = $l;
|
||||
$this->logger = $logger;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TemplateResponse
|
||||
*/
|
||||
public function getForm()
|
||||
{
|
||||
$parameters = [
|
||||
'background-color' => $this->config->getAppValue('side_menu', 'background-color', '#333333'),
|
||||
'current-app-background-color' => $this->config->getAppValue('side_menu', 'current-app-background-color', '#444444'),
|
||||
'text-color' => $this->config->getAppValue('side_menu', 'text-color', '#FFFFFF'),
|
||||
'cache' => $this->config->getAppValue('side_menu', 'cache', '0'),
|
||||
'opener' => $this->config->getAppValue('side_menu', 'opener', 'side-menu-opener'),
|
||||
];
|
||||
|
||||
return new TemplateResponse('side_menu', 'settings/admin-form', $parameters, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string the section ID, e.g. 'sharing'
|
||||
*/
|
||||
public function getSection()
|
||||
{
|
||||
return 'side_menu';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int whether the form should be rather on the top or bottom of
|
||||
* the admin section. The forms are arranged in ascending order of the
|
||||
* priority values. It is required to return a value between 0 and 100.
|
||||
*
|
||||
* E.g.: 70
|
||||
*/
|
||||
public function getPriority()
|
||||
{
|
||||
return 70;
|
||||
}
|
||||
}
|
84
lib/Settings/Section.php
Normal file
84
lib/Settings/Section.php
Normal file
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
/**
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace OCA\SideMenu\Settings;
|
||||
|
||||
use OCP\IL10N;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\Settings\IIconSection;
|
||||
|
||||
class Section implements IIconSection
|
||||
{
|
||||
/** @var IL10N */
|
||||
private $l;
|
||||
|
||||
/** @var IURLGenerator */
|
||||
private $url;
|
||||
|
||||
/**
|
||||
* @param IURLGenerator $url
|
||||
* @param IL10N $l
|
||||
*/
|
||||
public function __construct(IURLGenerator $url, IL10N $l)
|
||||
{
|
||||
$this->url = $url;
|
||||
$this->l = $l;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the ID of the section. It is supposed to be a lower case string,
|
||||
* e.g. 'ldap'
|
||||
*
|
||||
* @returns string
|
||||
*/
|
||||
public function getID()
|
||||
{
|
||||
return 'side_menu';
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the translated name as it should be displayed, e.g. 'LDAP / AD
|
||||
* integration'. Use the L10N service to translate it.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->l->t('Side menu');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int whether the form should be rather on the top or bottom of
|
||||
* the settings navigation. The sections are arranged in ascending order of
|
||||
* the priority values. It is required to return a value between 0 and 99.
|
||||
*
|
||||
* E.g.: 70
|
||||
*/
|
||||
public function getPriority()
|
||||
{
|
||||
return 70;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIcon()
|
||||
{
|
||||
return $this->url->imagePath('theming', 'app-dark.svg');
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@ import SideMenu from './SideMenu.vue'
|
|||
|
||||
Vue.prototype.t = t
|
||||
Vue.prototype.OC = OC
|
||||
Vue.prototype.OC = OCP
|
||||
|
||||
const View = Vue.extend(SideMenu)
|
||||
const sideMenu = new View({
|
||||
|
|
65
src/admin.js
Normal file
65
src/admin.js
Normal file
|
@ -0,0 +1,65 @@
|
|||
/**
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const elements = [
|
||||
'side-menu-background-color',
|
||||
'side-menu-current-app-background-color',
|
||||
'side-menu-text-color',
|
||||
'side-menu-save',
|
||||
'side-menu-opener',
|
||||
'side-menu-cache',
|
||||
];
|
||||
|
||||
const selector = '#side-menu-message';
|
||||
|
||||
const saveSettings = (key) => {
|
||||
const element = elements[key]
|
||||
const name = $('#' + element).attr('name')
|
||||
let value = $('#' + element).val()
|
||||
const size = elements.length
|
||||
|
||||
if (element === 'side-menu-cache') {
|
||||
value++
|
||||
}
|
||||
|
||||
OCP.AppConfig.setValue('side_menu', name, value, {
|
||||
success: () => {
|
||||
OC.msg.finishedSuccess(
|
||||
selector,
|
||||
t('settings', (key + 1) + '/' + size)
|
||||
)
|
||||
|
||||
if (key < size -1) {
|
||||
saveSettings(++key)
|
||||
} else {
|
||||
OC.msg.finishedSuccess(selector, t('settings', 'Saved'))
|
||||
}
|
||||
},
|
||||
error: () => {
|
||||
OC.msg.finishedError(selector, t('side_menu', 'Error while saving "' + element + '"'))
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(() => {
|
||||
$('#side-menu-save').on('click', (event) => {
|
||||
event.preventDefault()
|
||||
OC.msg.startSaving(selector)
|
||||
|
||||
saveSettings(0)
|
||||
});
|
||||
});
|
94
templates/settings/admin-form.php
Normal file
94
templates/settings/admin-form.php
Normal file
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
/**
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
script('side_menu', 'admin');
|
||||
style('side_menu', 'admin');
|
||||
|
||||
?>
|
||||
|
||||
<div id="side-menu-section" class="section">
|
||||
<h2 class="inlineblock"><?php p($l->t('Side menu settings')); ?></h2>
|
||||
|
||||
<div>
|
||||
<label for="side-menu-background-color" class="settings-hint">
|
||||
<?php p($l->t('Background color')); ?>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input
|
||||
id="side-menu-background-color"
|
||||
name="background-color"
|
||||
type="color"
|
||||
value="<?php print_unescaped($_['background-color']); ?>">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="side-menu-current-app-background-color" class="settings-hint">
|
||||
<?php p($l->t('Background color of current app')); ?>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input
|
||||
id="side-menu-current-app-background-color"
|
||||
name="current-app-background-color"
|
||||
type="color"
|
||||
value="<?php print_unescaped($_['current-app-background-color']); ?>">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="side-menu-text-color" class="settings-hint">
|
||||
<?php p($l->t('Text color')); ?>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input
|
||||
id="side-menu-text-color"
|
||||
name="text-color"
|
||||
type="color"
|
||||
value="<?php print_unescaped($_['text-color']); ?>">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="side-menu-opener" class="settings-hint">
|
||||
<?php p($l->t('Opener icon')); ?>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$choices = [
|
||||
'Default' => 'side-menu-opener',
|
||||
'Hamburger' => 'side-menu-opener-hamburger',
|
||||
];
|
||||
?>
|
||||
|
||||
<div>
|
||||
<select id="side-menu-opener" name="opener">
|
||||
<?php foreach ($choices as $label => $value): ?>
|
||||
<option value="<?php echo $value ?>" <?php if ($value === $_['opener']): ?>selected<?php endif; ?>>
|
||||
<?php echo $l->t($label); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<input type="hidden" id="side-menu-cache" name="cache" value="<?php print_unescaped($_['cache']); ?>">
|
||||
|
||||
<button id="side-menu-save" class="btn btn-primary"><?php p($l->t('Save')); ?></button>
|
||||
|
||||
<span id="side-menu-message" class="msg"></span>
|
||||
</div>
|
|
@ -5,6 +5,7 @@ const StyleLintPlugin = require('stylelint-webpack-plugin')
|
|||
module.exports = {
|
||||
entry: {
|
||||
'main': path.join(__dirname, 'src', 'main.js'),
|
||||
'admin': path.join(__dirname, 'src', 'admin.js'),
|
||||
'sideMenu': path.join(__dirname, 'src', 'SideMenu.js'),
|
||||
},
|
||||
output: {
|
||||
|
|
Loading…
Reference in a new issue