Skip to content

Instantly share code, notes, and snippets.

View rattanchauhan's full-sized avatar
🎯
Focusing

Rattan Chauhan rattanchauhan

🎯
Focusing
View GitHub Profile
@rattanchauhan
rattanchauhan / MainController.js
Last active October 13, 2017 15:13
Securing routes in Extjs 6
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 / Startup.js
Created September 26, 2017 06:59
Sencha event logger
(function() {
// No mouse version
Ext.Component.prototype.fireEvent =
Ext.Function.createInterceptor(Ext.Component.prototype.fireEvent, function() {
if (arguments && arguments[0].indexOf("mouse") === -1 && arguments[0] != "uievent") {
console.log(this.$className, arguments, this);
}
return true;
});})();
@rattanchauhan
rattanchauhan / Remote.js
Created July 14, 2017 07:56
Remote api simulator in Extjs
Ext.define('Example.util.Remote',{
singleton: true,
requires: [
'Ext.ux.ajax.JsonSimlet',
'Ext.ux.ajax.SimManager'
],
constructor: function () {
Ext.ux.ajax.SimManager.init({
@rattanchauhan
rattanchauhan / Poller.js
Created May 30, 2017 13:11
Extjs Poller utility
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 January 11, 2017 04:29
Saving Grid state in Extjs
Ext.application({
.
.
.
// init method
init: function() {
// initialize state provider for saving component states
Ext.state.Manager.setProvider(Ext.create('Ext.state.LocalStorageProvider'));
}
@rattanchauhan
rattanchauhan / Java8.java
Last active November 24, 2016 17:14
Java8 features in practice
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 / Usage.js
Last active November 16, 2016 06:26
Capturing User details for re-using throughout a Sencha app
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 November 14, 2016 13:23
Adding gmaps to extjs app
addGmap: function (googlemapcontainer, viewModel) {
var mapcontainer = googlemapcontainer.down('#mapcontainer');
googlemapcontainer.setHidden(true);
// remove old map
if(mapcontainer) {
mapcontainer.destroy();
}
// create new map
@rattanchauhan
rattanchauhan / app.js
Last active November 10, 2016 17:16
Adding a loading spinner at app startup in Sencha Architect
if(Ext.fly('initialLoader')){
Ext.fly('initialLoader').destroy();
}
@rattanchauhan
rattanchauhan / formatXml.js
Created November 10, 2016 06:12
Utility method to format an xml string
/*
* 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