Skip to content

Instantly share code, notes, and snippets.

View arutnik's full-sized avatar

Andres Rutnik arutnik

View GitHub Profile
@arutnik
arutnik / index.html
Last active November 8, 2017 22:26
SFA Part 4: Getting the static root path
<app-root></app-root>
<script>
<!-- Only Added lines shown -->
gSfStaticRoot = "{!URLFOR($Resource.#RESOURCES#, 'favicon.ico')}"
if (!(gSfStaticRoot[0] === "{")) { //in local mode this will not have been replaced
gSfStaticRoot = gSfStaticRoot.substr(0, gSfStaticRoot.lastIndexOf('/')) + '/';
} else {
gSfStaticRoot = "";
}
@arutnik
arutnik / app.component.ts
Created November 5, 2017 20:01
SFA Part 3: Calling Salesforce controller in Angular
import { SalesforceApiService } from './sf-api-service';
import { Component, OnInit } from '@angular/core';
declare var getSfApiWrapper : () => DataApi;
//Response information
export interface ApiStatus {
statusCode: number;
status: boolean;
code: string;
@arutnik
arutnik / visualforce_transform.py
Created November 5, 2017 19:57
SFA Part 3: Injecting controller name
#Only Added/modified lines shown
parser.add_argument("--controller", help="")
controller = args.controller
html = html.replace('<html lang="en">', '<apex:page showheader="false" sidebar="false" standardStylesheets="false" controller="' + controller + '" >' )
html = html.replace('$SFCONTROLLER', controller)
@arutnik
arutnik / index.html
Last active November 8, 2017 22:24
SFA Part 3: Controller access in Angular
<body>
<!-- Removed for brevity -->
<app-root></app-root>
<script>
gSfApiWrapper = null;
if (typeof $SFCONTROLLER !== 'undefined') {
gSfApiWrapper = $SFCONTROLLER;
}
function getSfApiWrapper() {
return gSfApiWrapper;
@arutnik
arutnik / role.yaml
Created October 26, 2017 14:45
EBS Backup IAM Role
EBSSnapshotRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: automation.amazonaws.com
Action:
@arutnik
arutnik / salesforce-hash-location-strategy.ts
Last active November 8, 2017 22:30
SFA Part 5 : Salesforce # Strategy
import { Injectable } from '@angular/core';
import { Location, PlatformLocation, LocationStrategy, LocationChangeListener } from "@angular/common";
declare var gSfPageRoot : any;
/*
A location strategy that works similar to the HashLocationStrategy but
works better for Salesforce
@arutnik
arutnik / sftestcontroller.cls
Last active October 29, 2017 17:29
SFA Part 3 : Basic Controller
public class sftestcontroller {
@RemoteAction
public static string helloAngular(string name) {
return 'User ' + UserInfo.getUserId() + ' says hello ' + name;
}
}
@arutnik
arutnik / script.sh
Created October 22, 2017 19:47
SFA Part 2: package and deploy
python salesforce/visualforce_transform.py --assets sftestassets --pagename sftestpage --builddir src-dev-deploy
ant localDevDeploy -f salesforce/build.xml -lib salesforce/lib
@arutnik
arutnik / visualforce_transform.py
Created October 22, 2017 19:38
SFA Part 2: Package project
import sys
import re
import argparse
import shutil
import os
import zipfile
parser = argparse.ArgumentParser()
parser.add_argument("--assets", help="")
@arutnik
arutnik / build.xml
Created October 22, 2017 19:30
SFA Part 2: build.xml
<project name="Standard Salesforce Build File" default="validate" basedir="." xmlns:sf="antlib:com.salesforce">
<property name="workingDir" location="." />
<property name="logFile" value="log/ant.log" />
<taskdef uri="antlib:com.salesforce"
resource="com/salesforce/antlib.xml"
classpath="${basedir}/lib/ant-salesforce.jar"/>
<target name="intro" >