Skip to content

Instantly share code, notes, and snippets.

@klinki
klinki / select.component.html
Created September 29, 2016 14:05
Angular 2 select
<h2>One way binding</h2>
<select [ngModel]="selectedItems" (ngModelChange)="onChange($event)" multiple>
<option [ngValue]="i" *ngFor="let i of collection">{{i.name}}</option>
</select>
<h2>Two way binding</h2>
<button>Select all</button><button>Clear selection</button>
<select [(ngModel)]="selectedItems" (ngModelChange)="onChange($event)" multiple>
<option [ngValue]="i" *ngFor="let i of collection">{{i.name}}</option>
</select>
@klinki
klinki / anguar2-select-changed-stuff.ts
Created December 9, 2016 10:07
Angular 2 select with custom comparator
import {Directive, Renderer, ElementRef, Input, OnDestroy, Optional, Host} from "@angular/core";
import {SelectMultipleControlValueAccessor} from "@angular/forms";
import {looseIdentical} from "@angular/core/src/facade/lang";
import {Comparator, ComparatorCallback, CUSTOM_SELECT_MULTIPLE_VALUE_ACCESSOR} from "./custom-select.directive";
// [formControlName],select[multiple][wu-select][formControl],select[multiple][wu-select][ngModel]
@Directive({
selector: 'select[multiple][wu-select]',
host: {'(change)': 'onChange($event.target)', '(blur)': 'onTouched()'},
@klinki
klinki / RouteLinkProviderService.ts
Created December 13, 2016 13:43
RouteLinkProviderService - service which maps component into its route
import {Routes, Route} from "@angular/router";
import {Injectable} from "@angular/core";
@Injectable()
export class RouteLinkProviderService {
protected routes: Routes;
protected routesByComponents = new Map<any, any>();
constructor(routes: Routes) {
@klinki
klinki / route-flattener.service.ts
Created March 22, 2017 10:00
Angular Route Flattener
import {ActivatedRouteSnapshot, UrlSegment, Params, Data, Route} from "@angular/router";
import {Type, Injectable} from "@angular/core";
import {Subject, ReplaySubject} from "rxjs";
@Injectable()
export class RouteFlattenerService {
public getFlattenedRouteData(route: ActivatedRouteSnapshot): FlattenedRouteData {
let downLevel = this.getActivatedRouteSnapshotWithChildren(route);
downLevel.splice(0, 1);
let upLevel = this.getActivatedRouteSnapshotWithParents(route);
@klinki
klinki / expand-collapse.component.html
Last active April 19, 2017 11:23
Expand/collapse component
<div>
<a [ngClass]="{'active': isActive}" (click)="toggle()">{{tabTitle}}</a>
<ng-content *ngIf="isActive"></ng-content>
</div>
@klinki
klinki / crisis-detail-component-01-param.ts
Last active May 3, 2017 21:21
Angular Router Pain - Examples
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Crisis } from './crisis.service';
@Component({
template: `
<div *ngIf="crisis">
<h3>"{{ editName }}"</h3>
<div>
<label>Id: </label>{{ crisis.id }}</div>
import { Component, OnInit } from '@angular/core';
import { Crisis } from './crisis.service';
@Component({
template: `.......`
})
export class CrisisDetailComponent implements OnInit, OnChanges {
editName: string;
@RouteParam()
#!/usr/bin/env groovy
updateGitlabCommitStatus state: 'pending'
pipeline {
agent any
options {
// Here add name of your saved gitlab configuration with API key
gitLabConnection('Configured gitlab')
}
stages {
stage('Build') {
import { autoinject } from 'aurelia-framework';
import { Redirect } from 'aurelia-router';
import { FirebaseAuthService } from '../shared/firebase/authentication.service';
@autoinject()
export class AuthorizeStep {
protected static LOGIN_ADDRESS = '/login';
constructor(protected auth: FirebaseAuthService) {
@klinki
klinki / UserDto.java
Created April 27, 2018 09:20
DTO Entities - public or private with getters and setters
package cz.profinit.dagensia.tradeportal.backofficegui.rest.dto;
/**
* @author David Klingenberg
*/
public class UserDto {
public Long id;
public String nickname;
public String personName;
public String personSurname;