Skip to content

Instantly share code, notes, and snippets.

@confraria
confraria / ng-c8y-cli.md
Last active February 13, 2019 12:17
Project setup using the ng-cli app setup
  1. ng new myc8yapp --routing
  2. cd myc8yapp
  3. npm i @c8y/ngx-components@next @c8y/style@next && npm i @c8y/cli@next uglifyjs-webpack-plugin autoprefixer@^7.1.1 -D
  4. In package.json

append the following properties:

  "main": "src/main.ts",
  "c8y": {
    "application": {
{
"globalTitle": "Testing",
"faviconUrl": "https://assets-cdn.github.com/favicon.ico",
"brandingCssVars": {
"brand-primary": "pink",
"brand-complementary": "#14629F",
"brand-dark": " #0B385B",
"brand-light": "#5FAEEC",
"gray-text": "#333",
"link-color": "var(--brand-primary)",
@confraria
confraria / my-component.ts
Created April 11, 2018 10:43
sketch for single injectable
import { Client } from '@c8y/client';
@Component()
class MyComponent() {
constructor(client: Client) {}
}
import { Client, BasicAuth } from './core';
import * as services from './services';
export const serviceProviders: any = [
{ provide: BasicAuth, useValue: new BasicAuth()},
{ provide: Client, useFactory: factory.bind(Client), deps: [BasicAuth]}
].concat(Object.values(services).map(toProvider))
function factory(dep) {
return new this(dep);
}
### Keybase proof
I hereby claim:
* I am confraria on github.
* I am confraria (https://keybase.io/confraria) on keybase.
* I have a public key whose fingerprint is 215D 1923 EF98 AE66 989E 4A65 6A94 6C78 5436 3CD9
To claim this, I am signing this object:
@confraria
confraria / questions.md
Created October 10, 2017 16:41
Question

How can I hide and block access to menu items and plugins based on user role?

When calling addNavigation you can defined two properties showIf and showIfPermissions

c8yNavigatorProvider.addNavigation({
  name: gettext('Example Navigation'),
  icon: 'pencil',
  priority: 1000,
  path: 'example',
  showIf: ShowMenuItemIf, // This is an angular injectable function that should return a promise that resolves in a boolean
@confraria
confraria / htmlWidget.html
Last active January 30, 2017 15:19
Example of html widget
<!-- this is needed to initialize the variable -->
<i style="display:none">{{device.valueToRead}}</i>
<div style="transition:none" ng-show="device.valueToRead > 10"> more than 10</div>
<div style="transition:none" ng-show="device.valueToRead == 10"> exactly 10!</div>
<div style="transition:none" ng-show="device.valueToRead < 10"> less than 10!</div>
<div ng-switch="device.valueToRead">
<div style="transition:none" ng-switch-when="high" >HIGH</div>