Skip to content

Commit

Permalink
Merge pull request #178 from klauer/fix_offline
Browse files Browse the repository at this point in the history
FIX/ENH: a few more fixes for cached/offline mode + plugin only mode
  • Loading branch information
klauer authored Oct 10, 2023
2 parents 71200d9 + 23cf731 commit 52d508d
Show file tree
Hide file tree
Showing 26 changed files with 304 additions and 184 deletions.
4 changes: 3 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
},
"dependencies": {
"@types/d3-graphviz": "^2.6.7",
"axios": "^1.4.0",
"@types/pako": "^2.0.0",
"axios": "^1.5.0",
"d3-graphviz": "^5.1.0",
"d3-selection": "^3.0.0",
"es6-promise": "^4.2.8",
"pako": "^2.1.0",
"pinia": "^2.1.6",
"primeflex": "^3.3.1",
"primeicons": "^6.0.1",
Expand Down
35 changes: 23 additions & 12 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,32 @@

<script lang="ts">
import TabMenu from "primevue/tabmenu";
import { plugins } from "./settings.ts";
import { plugins, plugins_only_mode } from "./settings.ts";
export default {
name: "App",
components: {
TabMenu,
},
data() {
let tab_menu_items = [
{ label: "Records", icon: "pi pi-fw pi-tags", to: { name: "whatrec" } },
{ label: "IOCs", icon: "pi pi-fw pi-sitemap", to: { name: "iocs" } },
{
let tab_menu_items = [];
if (!plugins_only_mode) {
tab_menu_items.push({
label: "Records",
icon: "pi pi-fw pi-tags",
to: { name: "whatrec" },
});
tab_menu_items.push({
label: "IOCs",
icon: "pi pi-fw pi-sitemap",
to: { name: "iocs" },
});
tab_menu_items.push({
label: "PV Map",
icon: "pi pi-fw pi-compass",
to: { name: "pv-relations" },
},
];
});
}
for (const plugin of plugins) {
tab_menu_items.push({
label: plugin.label,
Expand All @@ -34,11 +43,13 @@ export default {
icon: "pi pi-fw pi-shield",
to: { name: "gateway" },
});
tab_menu_items.push({
label: "Duplicates",
icon: "pi pi-pause",
to: { name: "duplicates" },
});
if (!plugins_only_mode) {
tab_menu_items.push({
label: "Duplicates",
icon: "pi pi-pause",
to: { name: "duplicates" },
});
}
tab_menu_items.push({
label: "Logs",
icon: "pi pi-fw pi-list",
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/epics-format-record.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<router-link
:to="{
name: 'whatrec',
query: { pattern: pvagroup, record: pvagroup, use_regex: 'false' },
query: { pattern: pvagroup, record: pvagroup, regex: 'false' },
}"
>
{{ pvagroup }}
Expand Down Expand Up @@ -67,7 +67,7 @@
query: {
pattern: field.record_name,
record: field.record_name,
use_regex: 'false',
regex: 'false',
},
}"
:title="JSON.stringify(field.metadata, null, 2)"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/gateway-matches.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
query: {
pattern: match.rule.pattern,
record: [],
use_regex: 'true',
regex: 'true',
},
}"
>
Expand Down
36 changes: 14 additions & 22 deletions frontend/src/components/recordinfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,14 @@
</template>

<template v-if="streamdevice_metadata">
<details>
<details class="streamdevice">
<summary>
StreamDevice protocol (
<span class="monospace">
{{ streamdevice_metadata.protocol_file }} </span
>,
<span class="monospace">
"{{ streamdevice_metadata.protocol_name }}"
</span>
)
StreamDevice protocol
<script-context-link
:context="streamdevice_metadata.context"
:short="2"
prefix=""
/>
</summary>
<dictionary-table
:dict="streamdevice_metadata as any"
Expand Down Expand Up @@ -271,7 +269,7 @@ export default {
instance: this.record,
plugin_matches: get_plugin_matches(this.record.metadata),
});
console.log("matches", result);
console.debug("Found match:", result);
}
if (this.pva_group != null) {
result.push({
Expand All @@ -289,18 +287,6 @@ export default {
}
return url + this.record.name;
},
graph_link() {
if (!this.store.is_online) {
return null;
}
return `/api/pv/graph?pv=${this.whatrec.name}&format=svg`;
},
script_graph_link() {
if (!this.store.is_online) {
return null;
}
return `/api/pv/script-graph?pv=${this.whatrec.name}&format=svg`;
},
available_protocols() {
let protocols = [];
if (this.record != null) {
Expand Down Expand Up @@ -377,6 +363,8 @@ export default {
const link_tab = this.$refs.link_tab as HTMLElement | null;
if (!graph_div || !link_tab) {
console.error("What happened? No graph or tab?");
this.pv_graph_dot_source = "digraph { unknown error }";
this.show_graph = false;
return;
}
this.graph_width = graph_div.clientWidth || window.innerWidth * 0.75;
Expand Down Expand Up @@ -433,4 +421,8 @@ iframe {
min-width: 50%;
min-height: 50%;
}
.streamdevice .context {
display: inline;
}
</style>
49 changes: 27 additions & 22 deletions frontend/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@ let routes: RouteRecordRaw[] = [
path: "/",
redirect: "/whatrec",
},
{
name: "whatrec",
path: "/whatrec",
component: WhatRec,
props: (route) => ({
pattern: route.query.pattern ?? "*",
use_regex: route.query.regex === "true",
record: nullable_string_to_array(route.query.record),
}),
},
{
name: "file",
path: "/file",
Expand All @@ -46,7 +36,21 @@ let routes: RouteRecordRaw[] = [
line: route.query.line ? parseInt(route.query.line.toString()) : 0,
}),
},
{
];

if (true) {
routes.push({
name: "whatrec",
path: "/whatrec",
component: WhatRec,
props: (route) => ({
pattern: route.query.pattern ?? "*",
use_regex: route.query.regex === "true",
record: nullable_string_to_array(route.query.record),
}),
});

routes.push({
name: "iocs",
path: "/iocs/",
component: IocView,
Expand All @@ -55,13 +59,20 @@ let routes: RouteRecordRaw[] = [
ioc_filter: route.query.ioc_filter ?? "",
record_filter: route.query.record_filter ?? "",
}),
},
{
});

routes.push({
name: "pv-relations",
path: "/pv-relations",
component: PVRelationsView,
},
];
});

routes.push({
name: "duplicates",
path: "/duplicates",
component: DuplicateView,
});
}

if (happi_enabled) {
routes.push({
Expand Down Expand Up @@ -108,12 +119,6 @@ if (epicsarch_enabled) {
});
}

routes.push({
name: "duplicates",
path: "/duplicates",
component: DuplicateView,
});

routes.push({
name: "logs",
path: "/logs",
Expand All @@ -127,7 +132,7 @@ routes.push({
});

export const router = VueRouter.createRouter({
history: VueRouter.createWebHistory(),
history: VueRouter.createWebHashHistory(import.meta.env.BASE_URL),
routes: routes,
scrollBehavior() {
const app = document.getElementById("app");
Expand Down
1 change: 1 addition & 0 deletions frontend/src/settings.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const enabled_plugins = (
import.meta.env.WHATRECORD_PLUGINS || "happi twincat_pytmc netconfig"
).split(" ");
export const plugins_only_mode = import.meta.env.WHATRECORD_PLUGINS_ONLY == "1";
export const happi_enabled = enabled_plugins.indexOf("happi") >= 0;
export const netconfig_enabled = enabled_plugins.indexOf("netconfig") >= 0;
export const twincat_pytmc_enabled =
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/stores/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,5 +443,11 @@ export const api_server_store = defineStore("api-server", {
}
return matches;
},
async get_server_logs(): Promise<string[]> {
const response = await this.run_query<string[]>("/api/logs/get", {
params: {},
});
return response?.data ?? ["(Error loading logs)"];
},
},
});
Loading

0 comments on commit 52d508d

Please sign in to comment.