Remove Create Smart Rule and Source option from the alarm created and updated

Hi,

  1. How do I remove the Create Smart Rule option from the alarm action menu?
  2. How do I remove the source option from the alarm I created and updated in the change log page?

Please help me with the solutions. ASAP

Hi Ranjithkumar,

your problem is quite similar to this one How to disable Apply dashboard to devices of type option.

There isn’t an out-of-the-box solution to easily remove these elements from the component, as the component is a Cumulocity core component. You would need to override the Cockpit application and hide the elements either by extending the branding/styling or by modifiying them directly in the c8y sdk.

Similar to the other post, I suggest to implement these changes as a patch. The alarms list is still implemented in AngularJS and therefore can be found in @c8y/ng1-modules package. The files you want to change are .\node_modules\@c8y\ng1-modules\core\ui\views\alarmList.html and .\node_modules\@c8y\ng1-modules\core\ui\views\auditList.html.

  1. Clone cockpit application
  2. remove following snippet from .\node_modules\@c8y\ng1-modules\core\ui\views\alarmList.html
<li ng-if="smartRules">
      <c8y-if-allowed cfg="smartRulesSvc.permissionsCfgs.create">
        <a
          title="{{ 'Create smart rule' | translate }}"
          href=""
          ng-click="createSmartRule(alarm)"
        >
          <i c8y-icon="cogs"></i> {{ 'Create smart rule' | translate }}
        </a>
      </c8y-if-allowed>
    </li>
  1. remove following snippet from .\node_modules\@c8y\ng1-modules\core\ui\views\auditList.html
<span ng-if="audit.user" class="m-r-16">
    <span class="text-label-small">
      {{ 'By`user`' | translate }}
    </span>
    {{ audit.user }}
  </span>
  1. Test your cloned Cockpit application locally to see whether the changes have been applied
  2. install patch-package by running: npm install patch-package --save-dev
  3. Create patch by running npx patch-package @c8y/ng1-modules
  4. Add patch-package ot postinstall script in the package.json: "postinstall": "patch-package && ngcc"

Best regards
Christian

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.