Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bob widget issues #56

Merged
merged 9 commits into from
Jun 6, 2024
24 changes: 13 additions & 11 deletions src/ui/widgets/EmbeddedDisplay/bobParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ function bobParseFormatType(jsonProp: ElementCompact): string {
}

export function bobParseFont(jsonProp: ElementCompact): Font {
const opiStyles: { [key: number]: FontStyle } = {
0: FontStyle.Regular,
1: FontStyle.Bold,
2: FontStyle.Italic,
3: FontStyle.BoldItalic
const opiStyles: { [key: string]: FontStyle } = {
REGULAR: FontStyle.Regular,
BOLD: FontStyle.Bold,
ITALIC: FontStyle.Italic,
BOLD_ITALIC: FontStyle.BoldItalic
};
const fontAttributes = jsonProp["font"]._attributes;
const { family, size, style } = fontAttributes;
Expand Down Expand Up @@ -245,10 +245,10 @@ export function parseBob(
(pvName: ElementCompact): PV => opiParsePvName(pvName, defaultProtocol)
],
font: ["font", bobParseFont],
rules: [
"rules",
(rules: Rule[]): Rule[] => opiParseRules(rules, defaultProtocol)
],
// rules: [
abigailalexander marked this conversation as resolved.
Show resolved Hide resolved
// "rules",
// (rules: Rule[]): Rule[] => opiParseRules(rules, defaultProtocol)
// ],
actions: [
"actions",
(actions: ElementCompact): WidgetActions =>
Expand All @@ -259,12 +259,14 @@ export function parseBob(
points: ["points", bobParsePoints],
resize: ["resize", bobParseResizing],
squareLed: ["square", opiParseBoolean],
formatType: ["format", bobParseFormatType]
formatType: ["format", bobParseFormatType],
stretchToFit: ["stretch_image", opiParseBoolean]
};

const complexParsers = {
...BOB_COMPLEX_PARSERS,
rules: (rules: Rule[]): Rule[] => opiParseRules(rules, defaultProtocol)
rules: (rules: Rule[]): Rule[] =>
opiParseRules(rules, defaultProtocol, false)
};

const displayWidget = parseWidget(
Expand Down
8 changes: 5 additions & 3 deletions src/ui/widgets/EmbeddedDisplay/opiParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ export function opiParseActions(
*/
export const opiParseRules = (
jsonProp: ElementCompact,
defaultProtocol: string
defaultProtocol: string,
isOpiFile: boolean
): Rule[] => {
if (!jsonProp.rules) {
return [];
Expand All @@ -269,7 +270,7 @@ export const opiParseRules = (
const xmlProp = ruleElement._attributes?.prop_id as string;

const outExp = ruleElement._attributes?.out_exp === "true";
const pvArray = toArray(ruleElement.pv);
const pvArray = toArray(isOpiFile ? ruleElement.pv : ruleElement.pv_name);
const pvs = pvArray.map((pv: ElementCompact) => {
return {
pvName: opiParsePvName(pv, defaultProtocol),
Expand Down Expand Up @@ -856,7 +857,8 @@ export function parseOpi(

const complexParsers = {
...OPI_COMPLEX_PARSERS,
rules: (rules: Rule[]): Rule[] => opiParseRules(rules, defaultProtocol)
rules: (rules: Rule[]): Rule[] =>
opiParseRules(rules, defaultProtocol, true)
};

log.debug(compactJSON.display);
Expand Down
2 changes: 1 addition & 1 deletion src/ui/widgets/Label/__snapshots__/label.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`<Label /> it matches the snapshot 1`] = `
<DocumentFragment>
<div
class="Label Label"
style="background-color: transparent; cursor: default; justify-content: center; align-items: center;"
style="background-color: transparent; cursor: default; justify-content: flex-start; align-items: flex-start;"
>
<span>
hello
Expand Down
4 changes: 2 additions & 2 deletions src/ui/widgets/Label/label.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
width: 100%;
display: flex;
padding: 0;
background-color: #c8c8c8;
background-color: #ffffff;
font: 14px helvetica, sans-serif;
text-align: center;
justify-content: center;
align-items: center;
white-space: pre;
overflow: hidden;
}
}
4 changes: 2 additions & 2 deletions src/ui/widgets/Label/label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export const LabelComponent = (
};
const style: CSSProperties = commonCss(editedProps);
const {
textAlign = "center",
textAlignV = "center",
textAlign = "left",
textAlignV = "top",
text = "",
rotationAngle,
wrapWords
Expand Down
4 changes: 2 additions & 2 deletions src/ui/widgets/Readback/readback.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
white-space: nowrap;
text-overflow: ellipsis;
background-color: #383838;
abigailalexander marked this conversation as resolved.
Show resolved Hide resolved
color: #00bb00;
color: #000000;
font: 14px helvetica, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100%;
width: 100%;
}
}
4 changes: 2 additions & 2 deletions src/ui/widgets/Readback/readback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export const ReadbackComponent = (
alarmSensitive = true,
transparent = false,
text = "######",
textAlign = "center",
textAlignV = "center",
textAlign = "left",
textAlignV = "top",
showUnits = false,
precisionFromPv = false,
rotationAngle,
Expand Down
2 changes: 1 addition & 1 deletion src/ui/widgets/Symbol/__snapshots__/symbol.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exports[`<Symbol /> matches snapshot 1`] = `
>
<div
class="Label Label"
style="background-color: transparent; cursor: default; justify-content: center; align-items: center;"
style="background-color: transparent; cursor: default; justify-content: flex-start; align-items: flex-start;"
>
<span>
Fake value
Expand Down
Loading