@@ -70,22 +70,38 @@ const pagination = ref({
7070});
7171
7272function loadFacts() {
73- const query = ` facts {certname = '${node .value }' and environment = '${settings .environment }' } ` ;
74-
75- void Backend .getRawQueryResult <ApiPuppetFact []>(query ).then ((result ) => {
76- if (result .status === 200 ) {
77- node_facts .value = result .data .Data .Data .map ((s ) =>
78- PuppetFact .fromApi (s ),
79- );
80- }
81- });
73+ const queryBuilder = new PqlQuery (PqlEntity .Facts );
74+ queryBuilder .filter ().and ().equal (' certname' , node .value );
75+
76+ if (settings .hasEnvironment ()) {
77+ queryBuilder .filter ().and ().equal (' environment' , settings .environment );
78+ }
79+
80+ void Backend .getRawQueryResult <ApiPuppetFact []>(queryBuilder .build ()).then (
81+ (result ) => {
82+ if (result .status === 200 ) {
83+ node_facts .value = result .data .Data .Data .map ((s ) =>
84+ PuppetFact .fromApi (s ),
85+ );
86+ }
87+ },
88+ );
8289}
8390
8491function loadNodeInfo() {
85- const query = ` nodes { certname = '${node .value }' and catalog_environment = '${settings .environment }' } ` ;
92+ const queryBuilder = new PqlQuery (PqlEntity .Nodes );
93+ queryBuilder .filter ().and ().equal (' certname' , node .value );
94+
95+ if (settings .hasEnvironment ()) {
96+ queryBuilder
97+ .filter ()
98+ .and ()
99+ .equal (' catalog_environment' , settings .environment );
100+ }
101+
86102 isLoading .value = true ;
87103
88- void Backend .getRawQueryResult <ApiPuppetNode []>(query )
104+ void Backend .getRawQueryResult <ApiPuppetNode []>(queryBuilder . build () )
89105 .then ((result ) => {
90106 if (result .status === 200 ) {
91107 node_info .value = PuppetNode .fromApi (result .data .Data .Data [0 ]! );
0 commit comments