Skip to content

Instantly share code, notes, and snippets.

View jsanta's full-sized avatar

Jose Ignacio Santa Cruz G. jsanta

View GitHub Profile
@jsanta
jsanta / data-grid.component.html
Created March 9, 2018 15:44
DataGridComponent template
<div class="row mt-3">
<div class="col-2 p-1 text-center align-self-center"
[ngClass]="{
'bg-info': item.color === 'blue',
'bg-success': item.color === 'green',
'bg-warning': item.color === 'yellow',
'bg-danger': item.color === 'red'
}"
*ngFor="let item of filteredData">
<strong>{{item.company}}</strong><br>
@jsanta
jsanta / bounce-in.sass
Created March 9, 2018 17:38
bounce-in CSS animation style in Sass
.bounceIn
opacity: 0;
animation-name: bounceIn;
animation-duration: 450ms;
animation-timing-function: linear;
animation-fill-mode: forwards;
@keyframes bounceIn
0%
opacity: 0;
@jsanta
jsanta / applyFilterAnimation.ts
Last active March 9, 2018 17:49
applyFilterAnimation function that toggles the filterApplied boolean value from true to false past 1500 ms (1.5s)
filterApplied: boolean = false;
private applyFilterAnimation(): void {
this.filterApplied = true;
setTimeout(() => this.filterApplied = false, 1500);
}
@jsanta
jsanta / data-grid.component.html
Created March 9, 2018 17:52
Updated DataGridComponent template to include animations.
<div class="row mt-3">
<div class="col-2 p-1 text-center align-self-center"
[ngClass]="{
'bg-info': item.color === 'blue',
'bg-success': item.color === 'green',
'bg-warning': item.color === 'yellow',
'bg-danger': item.color === 'red',
'bounceIn': filterApplied
}"
[ngStyle]="(filterApplied)?{ 'animation-delay': (150 + gridIdx * 1000 / filteredData.length ) + 'ms' }:{}"
@jsanta
jsanta / query-generator.js
Last active August 16, 2018 19:47
Sequelize sequelize/lib/dialects/mssql/query-generator.js file for case sensitive MS SQL Server databases ( constraint_type has to be in lowercase and watch for changes on _getForeignKeysQueryPrefix method)
'use strict';
const _ = require('lodash');
const Utils = require('../../utils');
const DataTypes = require('../../data-types');
const TableHints = require('../../table-hints');
const AbstractQueryGenerator = require('../abstract/query-generator');
const randomBytes = require('crypto').randomBytes;
const semver = require('semver');
import { TransitionService } from '@uirouter/core';
import { AuthService } from './auth.service';
/**
* This file contains a Transition Hook which protects a
* route that requires authentication.
*
* This hook redirects to /login when both:
* - The user is not authenticated
* - The user is navigating to a state that requires authentication
@jsanta
jsanta / apps.modules.ts
Created May 29, 2018 20:03
apps.modules excerpt for Angular UI Router Sample App
imports: [
UIRouterModule.forRoot({
states: APP_STATES,
useHash: true,
otherwise: { state: 'home' },
config: routerConfigFn,
}),
GlobalModule,
BrowserModule,
FormsModule,
@jsanta
jsanta / route.ts
Created May 29, 2018 20:11
Valid Angular UI Router state for Sample App (excerpt)
{
name: 'main.dashboards',
url: '/dashboards',
data: {
requiresAuth: true,
routeEnabled: true
},
views: {
'desktop-view@main': DashboardsPageComponent
}
@jsanta
jsanta / auth.hook.ts
Created May 29, 2018 20:35
Auth Hook with the routeEnabled condition included (for Angular UI Router Sample App)
const redirectToLogin = (transition) => {
const authService: AuthService = transition.injector().get(AuthService);
const $state = transition.router.stateService;
if (!authService.isAuthenticated()) {
return $state.target('login', undefined, { location: false });
} else {
const toState = transition.to();
try {
if (!toState.data.routeEnabled) {
return $state.target(null, undefined, { location: false });
@jsanta
jsanta / routes.ts
Created May 29, 2018 21:46
UIRouter Config with hooks (based on Angular UI Router Sample App)
/** UIRouter Config */
export function uiRouterConfigFn(router: UIRouter, injector: Injector) {
// If no URL matches, go to the `login` state by default
router.urlService.rules.otherwise({
state: 'login'
});
const transitionService = router.transitionService;
requiresAuthHook(transitionService);