Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Rattan Chauhan rattanchauhan

🎯
Focusing
Block or report user

Report or block rattanchauhan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rattanchauhan
rattanchauhan / Poller.js
Created May 30, 2017
Extjs Poller utility
View Poller.js
Ext.define('Empty.common.Poller', {
singleton: true,
alternateClassName: ['Poller'],
/**
* Utility to poll an endpoint provided with the required parameters
* Mandatory parameters are : params.pollInterval, params.pollTimeout, params.success
* @params {Object} params
*
@rattanchauhan
rattanchauhan / Application.js
Last active Jan 11, 2017
Saving Grid state in Extjs
View Application.js
Ext.application({
.
.
.
// init method
init: function() {
// initialize state provider for saving component states
Ext.state.Manager.setProvider(Ext.create('Ext.state.LocalStorageProvider'));
}
@rattanchauhan
rattanchauhan / MainController.js
Last active Oct 13, 2017
Securing routes in Extjs 6
View MainController.js
Ext.define('App.controller.MainController', {
extend: Ext.app.Controller,
routes: {
'home': {
before: function(action) {
Ext.Ajax.request({
url: Config.endpoints.user,
method: 'GET',
scope: this,
failure: function(data, operation) {
@rattanchauhan
rattanchauhan / Java8.java
Last active Nov 24, 2016
Java8 features in practice
View Java8.java
package com.practice.test;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.stream.Stream;
@rattanchauhan
rattanchauhan / formatXml.js
Created Nov 10, 2016
Utility method to format an xml string
View formatXml.js
/*
* Utility method to format an xml string
* text : xml String
* step : no of spaces for indentation
*/
formatXml : function(text,step) {
function createShiftArr(step) {
var space = ' ';
if ( isNaN(parseInt(step)) ) { // argument is string
@rattanchauhan
rattanchauhan / app.js
Last active Nov 6, 2016
AngularJs | Directive for Auto Focus Next element on Enter
View app.js
var app = angular.module("myApp", []);
app.directive("moveNextOnEnter", function() {
return {
restrict: "A",
link: function($scope, element) {
element.bind("keyup", function(e) {
if (e.which == 13) {
var $nextElement = element.next();
if($nextElement.length) {
$nextElement[0].focus();
@rattanchauhan
rattanchauhan / Usage.js
Last active Nov 16, 2016
Capturing User details for re-using throughout a Sencha app
View Usage.js
onMenuPanelRenderer : function() {
var hasWebRole = User.hasRole(Config.role.web);
var hasAdminRole = User.hasRole(Config.role.admin);
if (hasWebRole) {
// set mentu item visible true based on role
}
if (hasAdminRole) {
// set mentu item visible true based on role
@rattanchauhan
rattanchauhan / ViewController1.js
Last active Nov 14, 2016
Adding gmaps to extjs app
View ViewController1.js
addGmap: function (googlemapcontainer, viewModel) {
var mapcontainer = googlemapcontainer.down('#mapcontainer');
googlemapcontainer.setHidden(true);
// remove old map
if(mapcontainer) {
mapcontainer.destroy();
}
// create new map
@rattanchauhan
rattanchauhan / Sencha 4
Created Oct 7, 2016
Saving component state in LocalStorage in Sencha Architect
View Sencha 4
Create a function init under Application and add the below code to initialze a state provider to store states of different components
in the browser's local storage.
// initialize state provided for saving component states
Ext.state.Manager.setProvider(Ext.create('Ext.state.LocalStorageProvider'));
Add the below two configs to the component you want to save the state for.
{
@rattanchauhan
rattanchauhan / app.js
Last active Nov 10, 2016
Adding a loading spinner at app startup in Sencha Architect
View app.js
if(Ext.fly('initialLoader')){
Ext.fly('initialLoader').destroy();
}
You can’t perform that action at this time.