Skip to content

Instantly share code, notes, and snippets.

@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>
@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
### 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:
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);
}
@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) {}
}
{
"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 / 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": {
function orderBy(property) {
let prop = property;
if (_.isArray(prop)) {
prop = prop.join('.');
}
const [, sign, iterateeString] = prop.match(/^(-?)(.*)$/);
const order = sign === '-' ? 'desc' : 'asc';
let iteratee = iterateeString;
@confraria
confraria / rightdrawerconfig.js
Created June 21, 2019 15:41
Add a a new link to rightdrawer
angular.module('c8y.ui').decorator('c8yDocs', ($delegate) => {
'ngInject';
const listFn = $delegate.list.bind($delegate);
$delegate.list = function() {
return listFn().then(links => {
links.push({
{
icon: 'c8y-book', // choose from http://styleguide.cumulocity.com/icons/fontawesome or http://styleguide.cumulocity.com/icons/cumulocity
label: 'My link'
@confraria
confraria / package.json
Created March 15, 2020 17:54
rollup with typescript
{
"name": "topz2",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"couch:start": "docker run -p 5984:5984 -it -v $(pwd)/couchdata:/opt/couchdb/data -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=local_development_password topzcouch"
},
"keywords": [],
"author": "",