get settings overview data from controller
This commit is contained in:
@@ -100,7 +100,7 @@ namespace zero.Core.Identity
|
||||
// check claims
|
||||
if (!Permission.IsNullOrEmpty())
|
||||
{
|
||||
bool isSuperUser = false; // TODO user.HasClaim(Constants.Auth.Claims.IsSuper, PermissionsValue.True);
|
||||
bool isSuperUser = user.HasClaim(Constants.Auth.Claims.IsSuper, PermissionsValue.True);
|
||||
bool hasPassed = isSuperUser;
|
||||
|
||||
if (!isSuperUser)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="apps-items">
|
||||
<router-link v-for="app in apps" :key="app.id" :to="getAppLink(app)" class="apps-item">
|
||||
<router-link v-for="app in value" :key="app.id" :to="getAppLink(app)" class="apps-item">
|
||||
<strong class="apps-item-name">{{app.name}}</strong>
|
||||
<span class="apps-item-minor">{{app.domains[0]}}</span>
|
||||
<span class="apps-item-status" :class="{ 'is-active': app.isActive }" v-localize="getStatus(app)"></span>
|
||||
@@ -13,21 +13,14 @@
|
||||
|
||||
|
||||
<script>
|
||||
import ApplicationsApi from 'zero/resources/applications.js';
|
||||
|
||||
const baseRoute = zero.alias.sections.settings + '-' + zero.alias.settings.applications;
|
||||
|
||||
export default {
|
||||
data: () => ({
|
||||
apps: []
|
||||
}),
|
||||
|
||||
created()
|
||||
{
|
||||
ApplicationsApi.getAll().then(response =>
|
||||
{
|
||||
this.apps = response.items;
|
||||
});
|
||||
props: {
|
||||
value: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="apps">
|
||||
<ui-header-bar title="@application.list" :back-button="true" />
|
||||
<div class="ui-blank-box">
|
||||
<applications-items />
|
||||
<applications-items v-model="apps" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -10,13 +10,22 @@
|
||||
|
||||
<script>
|
||||
import ApplicationsItems from 'zero/pages/settings/applications-items'
|
||||
import ApplicationsApi from 'zero/resources/applications.js'
|
||||
|
||||
export default {
|
||||
data: () => ({
|
||||
apps: []
|
||||
}),
|
||||
|
||||
components: { ApplicationsItems }
|
||||
components: { ApplicationsItems },
|
||||
|
||||
mounted()
|
||||
{
|
||||
ApplicationsApi.getAll().then(response =>
|
||||
{
|
||||
this.apps = response.items;
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<div class="settings">
|
||||
<div class="settings-group">
|
||||
<div class="settings-group" v-if="apps.length > 0">
|
||||
<h2 class="ui-headline xl settings-group-headline" v-localize="'@application.list'"></h2>
|
||||
<applications-items />
|
||||
<applications-items v-model="apps" />
|
||||
</div>
|
||||
<div class="settings-group" v-for="group in groups">
|
||||
<h2 class="ui-headline xl settings-group-headline" v-localize="group.name"></h2>
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
<script>
|
||||
import ApplicationsItems from 'zero/pages/settings/applications-items'
|
||||
import SettingsApi from 'zero/resources/settings.js';
|
||||
|
||||
export default {
|
||||
name: 'app-settings',
|
||||
@@ -34,12 +35,22 @@
|
||||
|
||||
data: () => ({
|
||||
page: true,
|
||||
groups: zero.settingsAreas,
|
||||
groups: [],
|
||||
apps: [],
|
||||
tokens: {
|
||||
'zero_version': zero.version,
|
||||
'plugin_count': zero.pluginCount
|
||||
}
|
||||
})
|
||||
}),
|
||||
|
||||
mounted()
|
||||
{
|
||||
SettingsApi.getAreas().then(response =>
|
||||
{
|
||||
this.groups = response.groups;
|
||||
this.apps = response.applications;
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
using zero.Core.Api;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using zero.Core;
|
||||
using zero.Core.Api;
|
||||
using zero.Core.Entities;
|
||||
using zero.Core.Extensions;
|
||||
using zero.Core.Identity;
|
||||
|
||||
namespace zero.Web.Controllers
|
||||
@@ -6,11 +12,74 @@ namespace zero.Web.Controllers
|
||||
[ZeroAuthorize(Permissions.Sections.Settings, PermissionsValue.Read)]
|
||||
public class SettingsController : BackofficeController
|
||||
{
|
||||
ISettingsApi Api;
|
||||
IAuthenticationApi AuthApi;
|
||||
|
||||
public SettingsController(ISettingsApi api)
|
||||
IApplicationsApi<Application> ApplicationsApi;
|
||||
|
||||
|
||||
public SettingsController(IAuthenticationApi authApi, IApplicationsApi<Application> applicationsApi)
|
||||
{
|
||||
Api = api;
|
||||
AuthApi = authApi;
|
||||
ApplicationsApi = applicationsApi;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get all settings areas
|
||||
/// </summary>
|
||||
public async Task<IActionResult> GetAreas()
|
||||
{
|
||||
bool isSuperUser = AuthApi.IsSuper();
|
||||
IList<Permission> permissions = AuthApi.GetPermissions(Permissions.Settings.PREFIX);
|
||||
|
||||
List<ZeroVueSettingsGroup> groups = new List<ZeroVueSettingsGroup>();
|
||||
|
||||
foreach (SettingsGroup group in Options.Settings.GetAllItems())
|
||||
{
|
||||
List<ZeroVueSettingsArea> areas = new List<ZeroVueSettingsArea>();
|
||||
|
||||
foreach (SettingsArea area in group.Items)
|
||||
{
|
||||
if (!isSuperUser && !Permission.CanReadKey(permissions, area.Alias, true))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ZeroVueSettingsArea vueArea = new ZeroVueSettingsArea()
|
||||
{
|
||||
Alias = area.Alias,
|
||||
Name = area.Name,
|
||||
Description = area.Description,
|
||||
Icon = area.Icon,
|
||||
Url = Constants.Sections.Settings.EnsureStartsWith('/') + Alias.Generate(area.Alias).EnsureStartsWith('/')
|
||||
};
|
||||
|
||||
areas.Add(vueArea);
|
||||
}
|
||||
|
||||
if (areas.Count > 0)
|
||||
{
|
||||
groups.Add(new ZeroVueSettingsGroup()
|
||||
{
|
||||
Name = group.Name,
|
||||
Items = areas
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
IList<Application> applications = new List<Application>();
|
||||
|
||||
if (Permission.CanReadKey(permissions, Permissions.Settings.Applications, false))
|
||||
{
|
||||
applications = await ApplicationsApi.GetAll();
|
||||
}
|
||||
|
||||
return Json(new
|
||||
{
|
||||
groups,
|
||||
applications
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user