Reimplement the Storage page

Reimplement the functionality of the Storage page which shows which
items are stored in the shared subspace on the master server.
This commit is contained in:
Hornwitser committed 2021-03-20 03:35:05 +01:00
1 parent cebe83542f
commit c16dc74ad9
5 files changed
+234 -3

No files matched your search

+23 -2
View File
@@ -1,6 +1,7 @@
"use strict";
const libLink = require("@clusterio/lib/link");
const libConfig = require("@clusterio/lib/config");
const libUsers = require("@clusterio/lib/users");
class MasterConfigGroup extends libConfig.PluginConfigGroup {}
MasterConfigGroup.defaultAccess = ["master", "slave", "control"];
@@ -41,6 +42,13 @@ InstanceConfigGroup.define({
});
InstanceConfigGroup.finalize();
libUsers.definePermission({
name: "subspace_storage.storage.view",
title: "View Subspace Storage",
description: "View the items and fluids stored in the shared subspace.",
grantByDefault: true,
});
// JSON schema for subspace storage items
const items = {
type: "array",
@@ -65,6 +73,9 @@ module.exports = {
masterEntrypoint: "master",
MasterConfigGroup,
webEntrypoint: "./web",
routes: ["/storage"],
messages: {
// XXX this should be a request to be reliable
place: new libLink.Event({
@@ -90,7 +101,8 @@ module.exports = {
}),
getStorage: new libLink.Request({
type: "subspace_storage:get_storage",
links: ["instance-slave", "slave-master"],
links: ["instance-slave", "slave-master", "control-master"],
permission: "subspace_storage.storage.view",
forwardTo: "master",
responseProperties: {
"items": items,
@@ -98,11 +110,20 @@ module.exports = {
}),
updateStorage: new libLink.Event({
type: "subspace_storage:update_storage",
links: ["master-slave", "slave-instance"],
links: ["master-slave", "slave-instance", "master-control"],
broadcastTo: "instance",
eventProperties: {
"items": items,
},
}),
setStorageSubscription: new libLink.Request({
type: "subspace_storage:set_storage_subscription",
links: ["control-master"],
permission: "subspace_storage.storage.view",
requestProperties: {
"storage": { type: "boolean" },
},
}),
},
};