mirror of
https://github.com/Lissy93/dashy.git
synced 2025-07-26 15:14:22 +02:00
🩹 Move schema to Component.data + remove unnecessary null checks
This commit is contained in:
parent
db0fc0454d
commit
991cf0bf5a
@ -55,39 +55,6 @@
|
|||||||
import WidgetMixin from '@/mixins/WidgetMixin';
|
import WidgetMixin from '@/mixins/WidgetMixin';
|
||||||
import NextcloudMixin from '@/mixins/NextcloudMixin';
|
import NextcloudMixin from '@/mixins/NextcloudMixin';
|
||||||
|
|
||||||
const NextcloudSystemSchema = {
|
|
||||||
opcache: {
|
|
||||||
opcache_enabled: null,
|
|
||||||
full: null,
|
|
||||||
opcache_statistics: {
|
|
||||||
num_cached_scripts: null,
|
|
||||||
num_cached_keys: null,
|
|
||||||
max_cached_keys: null,
|
|
||||||
hits: null,
|
|
||||||
start_time: null,
|
|
||||||
last_restart_time: null,
|
|
||||||
misses: null,
|
|
||||||
opcache_hit_rate: null,
|
|
||||||
},
|
|
||||||
memory_usage: {
|
|
||||||
used_memory: null,
|
|
||||||
free_memory: null,
|
|
||||||
total_memory: null,
|
|
||||||
wasted_memory: null,
|
|
||||||
used_memory_percentage: null,
|
|
||||||
current_wasted_percentage: null,
|
|
||||||
},
|
|
||||||
interned_strings_usage: {
|
|
||||||
buffer_size: null,
|
|
||||||
used_memory: null,
|
|
||||||
total_memory: null,
|
|
||||||
free_memory: null,
|
|
||||||
number_of_strings: null,
|
|
||||||
used_memory_percentage: null,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NextcloudPhpOpcache widget - Shows statistics about PHP opcache performance
|
* NextcloudPhpOpcache widget - Shows statistics about PHP opcache performance
|
||||||
* Used endpoints
|
* Used endpoints
|
||||||
@ -97,7 +64,38 @@ export default {
|
|||||||
mixins: [WidgetMixin, NextcloudMixin],
|
mixins: [WidgetMixin, NextcloudMixin],
|
||||||
components: {},
|
components: {},
|
||||||
data() {
|
data() {
|
||||||
return NextcloudSystemSchema;
|
return {
|
||||||
|
opcache: {
|
||||||
|
opcache_enabled: null,
|
||||||
|
full: null,
|
||||||
|
opcache_statistics: {
|
||||||
|
num_cached_scripts: null,
|
||||||
|
num_cached_keys: null,
|
||||||
|
max_cached_keys: null,
|
||||||
|
hits: null,
|
||||||
|
start_time: null,
|
||||||
|
last_restart_time: null,
|
||||||
|
misses: null,
|
||||||
|
opcache_hit_rate: null,
|
||||||
|
},
|
||||||
|
memory_usage: {
|
||||||
|
used_memory: null,
|
||||||
|
free_memory: null,
|
||||||
|
total_memory: null,
|
||||||
|
wasted_memory: null,
|
||||||
|
used_memory_percentage: null,
|
||||||
|
current_wasted_percentage: null,
|
||||||
|
},
|
||||||
|
interned_strings_usage: {
|
||||||
|
buffer_size: null,
|
||||||
|
used_memory: null,
|
||||||
|
total_memory: null,
|
||||||
|
free_memory: null,
|
||||||
|
number_of_strings: null,
|
||||||
|
used_memory_percentage: null,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
didLoadData() {
|
didLoadData() {
|
||||||
@ -123,7 +121,7 @@ export default {
|
|||||||
},
|
},
|
||||||
processServerInfo(serverData) {
|
processServerInfo(serverData) {
|
||||||
const data = this.validateResponse(serverData);
|
const data = this.validateResponse(serverData);
|
||||||
this.opcache = data?.server?.php?.opcache;
|
this.opcache = data.server?.php?.opcache;
|
||||||
if (!this.opcache) return;
|
if (!this.opcache) return;
|
||||||
this.updateOpcacheMemory();
|
this.updateOpcacheMemory();
|
||||||
this.updateOpcacheInterned();
|
this.updateOpcacheInterned();
|
||||||
|
@ -64,45 +64,44 @@ import NextcloudMixin from '@/mixins/NextcloudMixin';
|
|||||||
* Used endpoints
|
* Used endpoints
|
||||||
* - serverinfo: requires Nextcloud admin user
|
* - serverinfo: requires Nextcloud admin user
|
||||||
*/
|
*/
|
||||||
const NextcloudStatsSchema = {
|
|
||||||
nextcloud: {
|
|
||||||
system: {
|
|
||||||
freespace: null,
|
|
||||||
apps: {
|
|
||||||
num_installed: null,
|
|
||||||
num_updates_available: 0,
|
|
||||||
app_updates: [],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
storage: {
|
|
||||||
num_users: null,
|
|
||||||
num_files: null,
|
|
||||||
num_storages: null,
|
|
||||||
},
|
|
||||||
shares: {
|
|
||||||
num_shares: null,
|
|
||||||
num_shares_user: null,
|
|
||||||
num_shares_groups: null,
|
|
||||||
num_shares_link: null,
|
|
||||||
num_shares_mail: null,
|
|
||||||
num_shares_room: null,
|
|
||||||
num_shares_link_no_password: null,
|
|
||||||
num_fed_shares_sent: null,
|
|
||||||
num_fed_shares_received: null,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
activeUsers: {
|
|
||||||
last5minutes: null,
|
|
||||||
last1hour: null,
|
|
||||||
last24hours: null,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [WidgetMixin, NextcloudMixin],
|
mixins: [WidgetMixin, NextcloudMixin],
|
||||||
components: {},
|
components: {},
|
||||||
data() {
|
data() {
|
||||||
return NextcloudStatsSchema;
|
return {
|
||||||
|
nextcloud: {
|
||||||
|
system: {
|
||||||
|
freespace: null,
|
||||||
|
apps: {
|
||||||
|
num_installed: null,
|
||||||
|
num_updates_available: 0,
|
||||||
|
app_updates: [],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
storage: {
|
||||||
|
num_users: null,
|
||||||
|
num_files: null,
|
||||||
|
num_storages: null,
|
||||||
|
},
|
||||||
|
shares: {
|
||||||
|
num_shares: null,
|
||||||
|
num_shares_user: null,
|
||||||
|
num_shares_groups: null,
|
||||||
|
num_shares_link: null,
|
||||||
|
num_shares_mail: null,
|
||||||
|
num_shares_room: null,
|
||||||
|
num_shares_link_no_password: null,
|
||||||
|
num_fed_shares_sent: null,
|
||||||
|
num_fed_shares_received: null,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
activeUsers: {
|
||||||
|
last5minutes: null,
|
||||||
|
last1hour: null,
|
||||||
|
last24hours: null,
|
||||||
|
},
|
||||||
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
didLoadData() {
|
didLoadData() {
|
||||||
@ -134,8 +133,8 @@ export default {
|
|||||||
},
|
},
|
||||||
processServerInfo(serverResponse) {
|
processServerInfo(serverResponse) {
|
||||||
const data = this.validateResponse(serverResponse);
|
const data = this.validateResponse(serverResponse);
|
||||||
this.nextcloud = data?.nextcloud;
|
this.nextcloud = data.nextcloud;
|
||||||
this.activeUsers = data?.activeUsers;
|
this.activeUsers = data.activeUsers;
|
||||||
},
|
},
|
||||||
/* Tooltip generators */
|
/* Tooltip generators */
|
||||||
activeUsersTooltip() {
|
activeUsersTooltip() {
|
||||||
|
@ -47,39 +47,6 @@ import NextcloudMixin from '@/mixins/NextcloudMixin';
|
|||||||
import GaugeChart from '@/components/Charts/Gauge';
|
import GaugeChart from '@/components/Charts/Gauge';
|
||||||
import ChartingMixin from '@/mixins/ChartingMixin';
|
import ChartingMixin from '@/mixins/ChartingMixin';
|
||||||
|
|
||||||
const NextcloudSystemSchema = {
|
|
||||||
server: {
|
|
||||||
server: {
|
|
||||||
database: {
|
|
||||||
type: null,
|
|
||||||
version: null,
|
|
||||||
size: null,
|
|
||||||
},
|
|
||||||
webserver: null,
|
|
||||||
php: {
|
|
||||||
version: null,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
nextcloud: {
|
|
||||||
system: {
|
|
||||||
version: null,
|
|
||||||
freespace: null,
|
|
||||||
cpuload: [],
|
|
||||||
mem_total: null,
|
|
||||||
mem_free: null,
|
|
||||||
mem_percent: null,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
memoryGauge: {
|
|
||||||
value: 0,
|
|
||||||
color: '#272f4d',
|
|
||||||
showMoreInfo: false,
|
|
||||||
moreInfo: null,
|
|
||||||
background: '#16161d',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NextcloudSystem widget - Visualises CPU load and memory utilisation and shows server versions
|
* NextcloudSystem widget - Visualises CPU load and memory utilisation and shows server versions
|
||||||
* Used endpoints
|
* Used endpoints
|
||||||
@ -89,14 +56,45 @@ export default {
|
|||||||
mixins: [WidgetMixin, NextcloudMixin, ChartingMixin],
|
mixins: [WidgetMixin, NextcloudMixin, ChartingMixin],
|
||||||
components: { GaugeChart },
|
components: { GaugeChart },
|
||||||
data() {
|
data() {
|
||||||
return NextcloudSystemSchema;
|
return {
|
||||||
|
server: {
|
||||||
|
server: {
|
||||||
|
database: {
|
||||||
|
type: null,
|
||||||
|
version: null,
|
||||||
|
size: null,
|
||||||
|
},
|
||||||
|
webserver: null,
|
||||||
|
php: {
|
||||||
|
version: null,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
nextcloud: {
|
||||||
|
system: {
|
||||||
|
version: null,
|
||||||
|
freespace: null,
|
||||||
|
cpuload: [],
|
||||||
|
mem_total: null,
|
||||||
|
mem_free: null,
|
||||||
|
mem_percent: null,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
memoryGauge: {
|
||||||
|
value: 0,
|
||||||
|
color: '#272f4d',
|
||||||
|
showMoreInfo: false,
|
||||||
|
moreInfo: null,
|
||||||
|
background: '#16161d',
|
||||||
|
},
|
||||||
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
cpuLoadChartId() {
|
cpuLoadChartId() {
|
||||||
return `nextcloud-cpu-load-chart-${Math.random().toString().slice(-4)}`;
|
return `nextcloud-cpu-load-chart-${Math.random().toString().slice(-4)}`;
|
||||||
},
|
},
|
||||||
didLoadData() {
|
didLoadData() {
|
||||||
return !!(this?.server?.nextcloud?.system?.version);
|
return !!(this.server?.nextcloud?.system?.version);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -112,11 +110,10 @@ export default {
|
|||||||
processServerInfo(serverData) {
|
processServerInfo(serverData) {
|
||||||
const data = this.validateResponse(serverData);
|
const data = this.validateResponse(serverData);
|
||||||
if (!data || data.length === 0) return;
|
if (!data || data.length === 0) return;
|
||||||
this.server.nextcloud.system = data?.nextcloud?.system;
|
this.server.nextcloud.system = data.nextcloud?.system;
|
||||||
this.$nextTick();
|
this.server.server.php.version = data.server?.php?.version;
|
||||||
this.server.server.php.version = data?.server?.php?.version;
|
this.server.server.database = data.server?.database;
|
||||||
this.server.server.database = data?.server?.database;
|
this.server.server.webserver = data.server?.webserver;
|
||||||
this.server.server.webserver = data?.server?.webserver;
|
|
||||||
},
|
},
|
||||||
updateMemoryGauge(sys) {
|
updateMemoryGauge(sys) {
|
||||||
this.memoryGauge.value = parseFloat(
|
this.memoryGauge.value = parseFloat(
|
||||||
|
@ -152,13 +152,13 @@ export default {
|
|||||||
/* Update the sate based on the capabilites response */
|
/* Update the sate based on the capabilites response */
|
||||||
processCapabilities(capResponse) {
|
processCapabilities(capResponse) {
|
||||||
const ocdata = this.validateResponse(capResponse);
|
const ocdata = this.validateResponse(capResponse);
|
||||||
const capNotif = ocdata?.capabilities?.notifications?.['ocs-endpoints'];
|
const capNotif = ocdata.capabilities?.notifications?.['ocs-endpoints'];
|
||||||
this.branding = ocdata?.capabilities?.theming;
|
this.branding = ocdata.capabilities?.theming;
|
||||||
this.capabilities.notifications.enabled = !!(capNotif?.length);
|
this.capabilities.notifications.enabled = !!(capNotif?.length);
|
||||||
this.capabilities.notifications.features = capNotif || [];
|
this.capabilities.notifications.features = capNotif || [];
|
||||||
this.capabilities.userStatus = !!(ocdata?.capabilities?.user_status?.enabled);
|
this.capabilities.userStatus = !!(ocdata.capabilities?.user_status?.enabled);
|
||||||
this.version.string = ocdata?.version?.string;
|
this.version.string = ocdata.version?.string;
|
||||||
this.version.edition = ocdata?.version?.edition;
|
this.version.edition = ocdata.version?.edition;
|
||||||
this.capabilitiesLastUpdated = new Date().getTime();
|
this.capabilitiesLastUpdated = new Date().getTime();
|
||||||
},
|
},
|
||||||
/* Shared template helpers */
|
/* Shared template helpers */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user