This is an old revision of the document!
Yet another method of reading the JSON-RPC interface.
The example below reads the result of the latest softwareAudit and displays it as a table. Information about installed sw products are merged in.
All needed files (.html, .js, .css) should be hosted below /usr/share/opsiconfd/static/AngularExample folder thus avoiding cross scripting complaints of modern browsers.
The location would then read https://opsi:4447/AngularExample.
configed will currently answer /rpc? requests with Encoding “deflate”, but will anounce it as “gzip”. This issue is known and a patch is mentioned in the forums.
Most requests require a logon, some even special rights. The script user should be member of a new group opsireader and the acl.conf file should be prepended with appropriate lines:
getProducts_.* : sys_group(opsireader); sys_group(opsiadmin); opsi_depotserver; self; opsi_client productOnClient_get.* : sys_group(opsireader); sys_group(opsiadmin); opsi_depotserver;self; opsi_client auditSoftwareOnClient_get.* : sys_group(opsireader); sys_group(opsiadmin); opsi_depotserver; self; opsi_client product_get.* : sys_group(opsireader); sys_group(opsiadmin); opsi_depotserver; self; opsi_client
index.html
<!DOCTYPE html> <html ng-app="opsi-swinv"> <head> <link rel="stylesheet" type="text/css" href="swinv.css" > <script type="text/javascript" src="angular.js"></script> <!-- chenge to angular-min for production --> <!-- script type="text/javascript" src="angular-resource.js"></script --> <script type="text/javascript" src="swinv.js"></script> <script type="text/javascript" src="swpattern.js"></script> </head> <body ng-controller="swinvController as sw"> <div class="swlist"> <input id="inputId" ng-model="sw.clientId"></input> <button ng-click="sw.refresh(sw.clientId)">refresh list</button> <table border > <tr><th>Name</th><th>Version</th><th>Lizenz</th><th>Installationsgrund</th></tr> <tr ng-repeat="swp in sw.products" ng-show="sw.nonMS(swp.name)"> <td>{{swp.name}} </td> <td> {{swp.version}}</td> <td>{{sw.reason(swp.name)}}</td> <td class={{sw.csswarn(swp.name)}}><span ng-show="!sw.isOpsi(swp.name)">{{sw.reason(swp.name)}} </span>{{sw.opsiProdId(swp.name)}}</td> </tr> </table> <br/><label><input type="checkbox" ng-model="sw.showopsiinstalled" />installed OPSI products on this client <span>({{sw.clientId}})</span></label> <div ng-show="sw.showopsiinstalled"> <table border> <tr><th>OpsiProduct</th></tr> <tr ng-repeat="inst in sw.installed"> <td>{{inst}}</td> </tr> </table> </div> <br/><label><input type="checkbox" ng-model="sw.showallprods" />available products</label> <table ng-show="sw.showallprods" border width="100%"> <tr><th>productInfo</th><th>productId</th><th>...............................................</th></tr> <tr ng-repeat="prod in sw.productinfos"> <td>{{prod.productId}}</td> <td>{{prod.name}}</td> <td></td> </tr> </table> </div> </body> </html>