Skip to content

Instantly share code, notes, and snippets.

View arutnik's full-sized avatar

Andres Rutnik arutnik

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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 / visualforce_transform.py
Created November 5, 2017 20:09
SFA Part 4: Injecting the controller name
#only added lines shown
parser.add_argument("--assets", help="")
args = parser.parse_args()
assetsName = args.assets
html = html.replace('#RESOURCES#', assetsName)
@arutnik
arutnik / pipe.ts
Created November 5, 2017 20:10
SFA Part 4: Static asset pipe
declare var getSfStaticResourceRoot : () => string;
export function getStaticPathForResource(resourcePath : string) {
return getSfStaticResourceRoot() + resourcePath;
}
/*
* Ensures a static asset path gets the right prefix
*/
@Pipe({name: 'staticpath'})
@arutnik
arutnik / app.component.html
Created November 5, 2017 20:12
SFA Part 4: Using static resource pipe
<!--The content below is only a placeholder and can be replaced.-->
<div style="text-align:center">
<h1>
{{title}}!
</h1>
<img [src]="'assets/salesforce.png' | staticpath">
</div>
<h2>Here are some links to help you start: </h2>
<ul>
<router-outlet></router-outlet>