@fonderie/vue-admin-screens 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/index.cjs +119 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +117 -28
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/screens/AdminShell.ts
|
|
2
2
|
import { ConfigEditorScreen, ConfigListScreen } from "@fonderie/vue-config-admin-screens";
|
|
3
3
|
import { TemplateEditorScreen, TemplateListScreen } from "@fonderie/vue-courier-admin-screens";
|
|
4
|
-
import { computed as computed2, defineComponent as
|
|
4
|
+
import { computed as computed2, defineComponent as defineComponent12, h as h13, ref as ref4 } from "vue";
|
|
5
5
|
|
|
6
6
|
// src/styles.ts
|
|
7
7
|
var styles = {
|
|
@@ -788,6 +788,85 @@ var SubscriberScreen = defineComponent10({
|
|
|
788
788
|
}
|
|
789
789
|
});
|
|
790
790
|
|
|
791
|
+
// src/screens/AuditScreen.ts
|
|
792
|
+
import { useAdminAudit } from "@fonderie/vue-admin";
|
|
793
|
+
import { defineComponent as defineComponent11, h as h12, ref as ref3 } from "vue";
|
|
794
|
+
var AuditScreen = defineComponent11({
|
|
795
|
+
name: "FonderieAuditScreen",
|
|
796
|
+
props: {
|
|
797
|
+
client: { type: Object, required: true },
|
|
798
|
+
pageSize: { type: Number, default: 50 }
|
|
799
|
+
},
|
|
800
|
+
setup(props) {
|
|
801
|
+
const draft = ref3({ workspaceId: "", type: "", actorId: "" });
|
|
802
|
+
const query = ref3({ limit: props.pageSize });
|
|
803
|
+
const { events, hasMore, isLoading, error, refresh, loadMore } = useAdminAudit(
|
|
804
|
+
props.client,
|
|
805
|
+
query
|
|
806
|
+
);
|
|
807
|
+
const field = (key, placeholder) => h12("input", {
|
|
808
|
+
value: draft.value[key],
|
|
809
|
+
onInput: (e) => draft.value = { ...draft.value, [key]: e.target.value },
|
|
810
|
+
placeholder,
|
|
811
|
+
style: { ...styles.button, cursor: "text" },
|
|
812
|
+
"aria-label": placeholder
|
|
813
|
+
});
|
|
814
|
+
return () => h12("div", { style: styles.container }, [
|
|
815
|
+
h12("h1", { style: styles.title }, "Audit"),
|
|
816
|
+
h12(
|
|
817
|
+
"form",
|
|
818
|
+
{
|
|
819
|
+
style: styles.toolbar,
|
|
820
|
+
onSubmit: (e) => {
|
|
821
|
+
e.preventDefault();
|
|
822
|
+
const d = draft.value;
|
|
823
|
+
query.value = {
|
|
824
|
+
limit: props.pageSize,
|
|
825
|
+
...d.workspaceId.trim() ? { workspaceId: d.workspaceId.trim() } : {},
|
|
826
|
+
...d.type.trim() ? { type: d.type.trim() } : {},
|
|
827
|
+
...d.actorId.trim() ? { actorId: d.actorId.trim() } : {}
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
},
|
|
831
|
+
[
|
|
832
|
+
field("workspaceId", "workspace id (all if empty)"),
|
|
833
|
+
field("type", "event type"),
|
|
834
|
+
field("actorId", "actor id"),
|
|
835
|
+
h12(
|
|
836
|
+
"button",
|
|
837
|
+
{ type: "submit", style: styles.button, disabled: isLoading.value },
|
|
838
|
+
"Filter"
|
|
839
|
+
),
|
|
840
|
+
refreshButton("Refresh", isLoading.value, () => void refresh())
|
|
841
|
+
]
|
|
842
|
+
),
|
|
843
|
+
error.value ? h12("p", { style: styles.error, role: "alert" }, error.value.explanation) : null,
|
|
844
|
+
events.value.length === 0 && !isLoading.value ? h12("p", { style: styles.muted }, "Nothing recorded for this filter.") : table(
|
|
845
|
+
["When", "Type", "Workspace", "Actor", "Request"],
|
|
846
|
+
events.value.map(
|
|
847
|
+
(e) => h12("tr", { key: e.id }, [
|
|
848
|
+
td(new Date(e.createdAt).toLocaleString(), styles.muted),
|
|
849
|
+
td(e.type, styles.mono),
|
|
850
|
+
td(String(e.payload["workspaceId"] ?? "\u2014"), styles.mono),
|
|
851
|
+
td(e.actorId ?? "\u2014", styles.mono),
|
|
852
|
+
td(e.requestId ?? "", styles.muted)
|
|
853
|
+
])
|
|
854
|
+
)
|
|
855
|
+
),
|
|
856
|
+
isLoading.value ? h12("p", { style: styles.status }, "Loading\u2026") : null,
|
|
857
|
+
hasMore.value && !isLoading.value ? h12(
|
|
858
|
+
"button",
|
|
859
|
+
{
|
|
860
|
+
type: "button",
|
|
861
|
+
style: { ...styles.button, marginTop: "8px" },
|
|
862
|
+
onClick: () => void loadMore()
|
|
863
|
+
},
|
|
864
|
+
"Load more"
|
|
865
|
+
) : null
|
|
866
|
+
]);
|
|
867
|
+
}
|
|
868
|
+
});
|
|
869
|
+
|
|
791
870
|
// src/screens/AdminShell.ts
|
|
792
871
|
var NAV = [
|
|
793
872
|
{ group: "Today", items: [{ page: "attention", label: "Attention" }] },
|
|
@@ -813,12 +892,13 @@ var NAV = [
|
|
|
813
892
|
{
|
|
814
893
|
group: "Activity",
|
|
815
894
|
items: [
|
|
895
|
+
{ page: "audit", label: "Audit", needs: "audit" },
|
|
816
896
|
{ page: "log", label: "Admin log" },
|
|
817
897
|
{ page: "tokens", label: "Access" }
|
|
818
898
|
]
|
|
819
899
|
}
|
|
820
900
|
];
|
|
821
|
-
var AdminShell =
|
|
901
|
+
var AdminShell = defineComponent12({
|
|
822
902
|
name: "FonderieAdminShell",
|
|
823
903
|
props: {
|
|
824
904
|
client: { type: Object, required: true },
|
|
@@ -830,6 +910,8 @@ var AdminShell = defineComponent11({
|
|
|
830
910
|
authClient: { type: Object, default: void 0 },
|
|
831
911
|
// Given ⇒ the Money pages (catalog, subscriber) appear; needs @fonderie/billing ≥ 9.10.
|
|
832
912
|
billingClient: { type: Object, default: void 0 },
|
|
913
|
+
// Given ⇒ the Audit page appears; needs @fonderie/audit ≥ 5.2.
|
|
914
|
+
auditClient: { type: Object, default: void 0 },
|
|
833
915
|
environment: { type: String, default: void 0 },
|
|
834
916
|
// Controlled navigation: pass `page` and listen to `navigate` to own the
|
|
835
917
|
// URL. Omit `page` and the shell keeps it itself.
|
|
@@ -837,15 +919,15 @@ var AdminShell = defineComponent11({
|
|
|
837
919
|
},
|
|
838
920
|
emits: { navigate: (_page) => true },
|
|
839
921
|
setup(props, { emit }) {
|
|
840
|
-
const own =
|
|
922
|
+
const own = ref4("attention");
|
|
841
923
|
const current = computed2(() => props.page ?? own.value);
|
|
842
|
-
const editing =
|
|
924
|
+
const editing = ref4(null);
|
|
843
925
|
const go = (p) => {
|
|
844
926
|
editing.value = null;
|
|
845
927
|
emit("navigate", p);
|
|
846
928
|
if (props.page === void 0) own.value = p;
|
|
847
929
|
};
|
|
848
|
-
const back = () =>
|
|
930
|
+
const back = () => h13(
|
|
849
931
|
"button",
|
|
850
932
|
{ type: "button", style: styles.button, onClick: () => editing.value = null },
|
|
851
933
|
"\u2190 Back"
|
|
@@ -854,37 +936,43 @@ var AdminShell = defineComponent11({
|
|
|
854
936
|
const c = props.client;
|
|
855
937
|
switch (current.value) {
|
|
856
938
|
case "attention":
|
|
857
|
-
return
|
|
939
|
+
return h13(AttentionScreen, { client: c });
|
|
858
940
|
case "modules":
|
|
859
|
-
return
|
|
941
|
+
return h13(ModulesScreen, { client: c });
|
|
860
942
|
case "doctor":
|
|
861
|
-
return
|
|
943
|
+
return h13(DoctorScreen, { client: c });
|
|
862
944
|
case "config":
|
|
863
|
-
return
|
|
945
|
+
return h13(ConfigScreen, { client: c });
|
|
864
946
|
case "routes":
|
|
865
|
-
return
|
|
947
|
+
return h13(RoutesScreen, { client: c });
|
|
866
948
|
case "tokens":
|
|
867
|
-
return
|
|
949
|
+
return h13(TokensScreen, { client: c });
|
|
868
950
|
case "log":
|
|
869
|
-
return
|
|
951
|
+
return h13(AdminLogScreen, { client: c });
|
|
870
952
|
case "catalog":
|
|
871
|
-
return props.billingClient ?
|
|
953
|
+
return props.billingClient ? h13(CatalogScreen, { client: props.billingClient }) : h13(
|
|
872
954
|
"p",
|
|
873
955
|
{ style: styles.status },
|
|
874
956
|
"Pass a BillingAdminClient to see the catalog here."
|
|
875
957
|
);
|
|
876
958
|
case "subscriber":
|
|
877
|
-
return props.billingClient ?
|
|
959
|
+
return props.billingClient ? h13(SubscriberScreen, { client: props.billingClient }) : h13(
|
|
878
960
|
"p",
|
|
879
961
|
{ style: styles.status },
|
|
880
962
|
"Pass a BillingAdminClient to look up subscribers here."
|
|
881
963
|
);
|
|
964
|
+
case "audit":
|
|
965
|
+
return props.auditClient ? h13(AuditScreen, { client: props.auditClient }) : h13(
|
|
966
|
+
"p",
|
|
967
|
+
{ style: styles.status },
|
|
968
|
+
"Pass an AuditAdminClient to see the audit trail here."
|
|
969
|
+
);
|
|
882
970
|
case "users":
|
|
883
|
-
return props.authClient ?
|
|
971
|
+
return props.authClient ? h13(UsersScreen, { client: props.authClient }) : h13("p", { style: styles.status }, "Pass an AuthAdminClient to look up users here.");
|
|
884
972
|
case "settings": {
|
|
885
973
|
const cc = props.configClient;
|
|
886
974
|
if (!cc)
|
|
887
|
-
return
|
|
975
|
+
return h13(
|
|
888
976
|
"p",
|
|
889
977
|
{ style: styles.status },
|
|
890
978
|
"Pass a ConfigAdminClient to manage config and secrets here."
|
|
@@ -893,7 +981,7 @@ var AdminShell = defineComponent11({
|
|
|
893
981
|
if (e && e.kind !== "template")
|
|
894
982
|
return [
|
|
895
983
|
back(),
|
|
896
|
-
|
|
984
|
+
h13(ConfigEditorScreen, {
|
|
897
985
|
client: cc,
|
|
898
986
|
kind: e.kind,
|
|
899
987
|
configKey: e.key,
|
|
@@ -901,7 +989,7 @@ var AdminShell = defineComponent11({
|
|
|
901
989
|
onSaved: () => editing.value = null
|
|
902
990
|
})
|
|
903
991
|
];
|
|
904
|
-
return
|
|
992
|
+
return h13(ConfigListScreen, {
|
|
905
993
|
client: cc,
|
|
906
994
|
...props.environment !== void 0 ? { environment: props.environment } : {},
|
|
907
995
|
"onSelect-config": (key) => editing.value = { kind: "config", key },
|
|
@@ -911,7 +999,7 @@ var AdminShell = defineComponent11({
|
|
|
911
999
|
case "templates": {
|
|
912
1000
|
const kc = props.courierClient;
|
|
913
1001
|
if (!kc)
|
|
914
|
-
return
|
|
1002
|
+
return h13(
|
|
915
1003
|
"p",
|
|
916
1004
|
{ style: styles.status },
|
|
917
1005
|
"Pass a CourierAdminClient to manage templates here."
|
|
@@ -920,32 +1008,32 @@ var AdminShell = defineComponent11({
|
|
|
920
1008
|
if (e?.kind === "template")
|
|
921
1009
|
return [
|
|
922
1010
|
back(),
|
|
923
|
-
|
|
1011
|
+
h13(TemplateEditorScreen, {
|
|
924
1012
|
client: kc,
|
|
925
1013
|
type: e.type,
|
|
926
1014
|
onSaved: () => editing.value = null
|
|
927
1015
|
})
|
|
928
1016
|
];
|
|
929
|
-
return
|
|
1017
|
+
return h13(TemplateListScreen, {
|
|
930
1018
|
client: kc,
|
|
931
1019
|
"onSelect-template": (t) => editing.value = { kind: "template", type: t.type }
|
|
932
1020
|
});
|
|
933
1021
|
}
|
|
934
1022
|
}
|
|
935
1023
|
};
|
|
936
|
-
return () =>
|
|
937
|
-
|
|
1024
|
+
return () => h13("div", { style: styles.shell }, [
|
|
1025
|
+
h13(
|
|
938
1026
|
"nav",
|
|
939
1027
|
{ style: styles.nav, "aria-label": "Admin" },
|
|
940
1028
|
NAV.map((g) => {
|
|
941
1029
|
const items = g.items.filter(
|
|
942
|
-
(i) => !i.needs || (i.needs === "config" ? props.configClient : i.needs === "courier" ? props.courierClient : i.needs === "auth" ? props.authClient : props.billingClient)
|
|
1030
|
+
(i) => !i.needs || (i.needs === "config" ? props.configClient : i.needs === "courier" ? props.courierClient : i.needs === "auth" ? props.authClient : i.needs === "billing" ? props.billingClient : props.auditClient)
|
|
943
1031
|
);
|
|
944
1032
|
if (items.length === 0) return null;
|
|
945
|
-
return
|
|
946
|
-
|
|
1033
|
+
return h13("div", { key: g.group }, [
|
|
1034
|
+
h13("div", { style: styles.navGroup }, g.group),
|
|
947
1035
|
...items.map(
|
|
948
|
-
(i) =>
|
|
1036
|
+
(i) => h13(
|
|
949
1037
|
"button",
|
|
950
1038
|
{
|
|
951
1039
|
key: i.page,
|
|
@@ -963,7 +1051,7 @@ var AdminShell = defineComponent11({
|
|
|
963
1051
|
]);
|
|
964
1052
|
})
|
|
965
1053
|
),
|
|
966
|
-
|
|
1054
|
+
h13("main", { style: styles.main }, body())
|
|
967
1055
|
]);
|
|
968
1056
|
}
|
|
969
1057
|
});
|
|
@@ -971,6 +1059,7 @@ export {
|
|
|
971
1059
|
AdminLogScreen,
|
|
972
1060
|
AdminShell,
|
|
973
1061
|
AttentionScreen,
|
|
1062
|
+
AuditScreen,
|
|
974
1063
|
CatalogScreen,
|
|
975
1064
|
ConfigScreen,
|
|
976
1065
|
DoctorScreen,
|