add menu element: link to settings

このコミットが含まれているのは:
Simon Vieille 2020-10-15 15:46:59 +02:00
コミット ae74e745db
署名者: deblan
GPGキーID: 03383D15A1D31745
5個のファイルの変更92行の追加11行の削除

ファイルの表示

@ -37,6 +37,34 @@
margin-left: 5px;
}
.side-menu-settings {
margin-right: 9px;
margin-top: 2px;
float: right;
line-height: 34px;
height: 28px;
display: none;
}
.side-menu-settings a {
color: var(--side-menu-text-color, #fff);
display: block;
padding: 4px 7px;
}
.side-menu-settings:hover a, .side-menu-settings a:active, .side-menu-settings a:focus {
background: var(--side-menu-current-app-background-color, #444);
}
.side-menu-settings img {
vertical-align: bottom;
margin-left: 3px;
}
#side-menu.open .side-menu-settings {
display: block;
}
.side-menu-opener {
background: var(--side-menu-opener, url('../img/side-menu-opener.svg'));
height: 40px;

ファイルの表示

@ -28,6 +28,7 @@ use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IRequest;
use OCP\IUserSession;
use OCP\L10N\IFactory;
class JsController extends Controller
{
@ -46,14 +47,25 @@ class JsController extends Controller
*/
protected $themingDefaults;
public function __construct(string $appName, IRequest $request, ConfigProxy $config, ThemingDefaults $themingDefaults)
{
/**
* @var IFactory
*/
protected $l10nFactory;
public function __construct(
string $appName,
IRequest $request,
ConfigProxy $config,
ThemingDefaults $themingDefaults,
IFactory $l10nFactory
) {
parent::__construct($appName, $request);
$this->themingDefaults = $themingDefaults;
$this->user = OC::$server[IUserSession::class]->getUser();
$this->config = $config;
$this->l10nFactory = $l10nFactory;
}
/**
@ -86,6 +98,7 @@ class JsController extends Controller
$useAvatar = $this->config->getAppValueBool('use-avatar', '0');
$isForced = $this->config->getAppValueBool('force', '0');
$avatar = null;
$settings = null;
if ($this->user) {
$userTopMenuApps = $this->config->getUserValueArray($this->user, 'top-menu-apps', '[]');
@ -104,13 +117,27 @@ class JsController extends Controller
$isAvatarSet = OC::$server->getAvatarManager()->getAvatar($this->user->getUid())->exists();
if ($useAvatar && $isAvatarSet) {
$avatar = OC::$server->getURLGenerator()->linkToRoute(
'core.avatar.getAvatar', [
'userId' => $this->user->getUid(),
'size' => 128,
'v' => $this->config->getUserValueInt($this->user, 'avatar', 'version', 0),
]
);
$avatar = OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', [
'userId' => $this->user->getUid(),
'size' => 128,
'v' => $this->config->getUserValueInt($this->user, 'avatar', 'version', 0),
]);
}
if ($this->config->getAppValueBool('show-settings', '0')) {
$settingsNav = OC::$server->getNavigationManager()->getAll('settings');
if (isset($settingsNav['settings'])) {
$settings = [
'href' => $settingsNav['settings']['href'],
'name' => $settingsNav['settings']['name'],
'avatar' => OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', [
'userId' => $this->user->getUid(),
'size' => 32,
'v' => $this->config->getUserValueInt($this->user, 'avatar', 'version', 0),
]),
];
}
}
}
@ -126,6 +153,7 @@ class JsController extends Controller
'avatar' => $avatar,
'top-menu-apps' => $topMenuApps,
'target-blank-apps' => $targetBlankApps,
'settings' => $settings,
'logo' => $this->themingDefaults->getLogo(),
];
}

ファイルの表示

@ -73,8 +73,8 @@ class NavController extends Controller
CategoryFetcher $categoryFetcher,
URLGenerator $router,
IL10N $trans,
IFactory $l10nFactory)
{
IFactory $l10nFactory
) {
parent::__construct($appName, $request);
$this->config = $config;

ファイルの表示

@ -17,6 +17,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<template>
<div id="side-menu">
<div class="side-menu-header">
<div class="side-menu-settings" v-if="settings">
<a v-bind:href="settings.href">
{{ settings.name }}
<span class="avatardiv avatardiv-shown">
<img v-bind:src="settings.avatar" v-bind:alt="settings.name" v-bind:title="settings.name">
</span>
</a>
</div>
<button class="side-menu-opener"></button>
<div v-if="!avatar && logo" v-bind:class="{'side-menu-logo': true, 'avatardiv': false}">
@ -51,6 +61,7 @@ export default {
avatar: null,
forceLightIcon: false,
targetBlankApps: [],
settings: null,
}
},
methods: {
@ -120,6 +131,7 @@ export default {
that.forceLightIcon = config['force-light-icon']
that.avatar = config['avatar']
that.logo = config['logo']
that.settings = config['settings']
});
},
},

ファイルの表示

@ -18,6 +18,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<div id="side-menu" class="side-menu-big">
<div class="side-menu-header">
<button class="side-menu-opener side-menu-closer"></button>
<div class="side-menu-settings" v-if="settings">
<a v-bind:href="settings.href">
{{ settings.name }}
<span class="avatardiv avatardiv-shown">
<img v-bind:src="settings.avatar" v-bind:alt="settings.name" v-bind:title="settings.name">
</span>
</a>
</div>
<button class="side-menu-opener"></button>
</div>
@ -71,6 +82,7 @@ export default {
activeApp: null,
targetBlank: false,
targetBlankApps: [],
settings: null,
}
},
methods: {
@ -109,6 +121,7 @@ export default {
const config = response.data
that.targetBlankApps = config['target-blank-apps']
that.settings = config['settings']
});
},
},