Skip to content

Instantly share code, notes, and snippets.

View anoopt's full-sized avatar

Anoop T anoopt

View GitHub Profile
item.attachmentFiles.select("FileName,ServerRelativeUrl").get().then(function (itemAttachments) {
var attachments = itemAttachments.map(function (result) {
return NWF$('<img/>', {
src: result.ServerRelativeUrl,
alt: result.FileName,
style: "margin:5px;width:100px;height:100px;float:left;",
class: "item-attachment"
});
});
NWF$(document).ready(function () {
$pnp.setup({
sp: {
headers: {
"Accept": "application/json; odata=verbose"
}
}
});
@anoopt
anoopt / useAzureFunctions.ts
Created March 7, 2023 17:31
A custom react hook to call Azure functions
import * as React from 'react';
import { AadHttpClient, AadHttpClientFactory } from "@microsoft/sp-http";
import { APP_ID } from './constants';
export const useAzureFunctions = (aadHttpClientFactory: AadHttpClientFactory) => {
const clientRef = React.useRef<AadHttpClient>();
const getClient = React.useCallback(async () => {
if (!aadHttpClientFactory) {
return undefined;
@anoopt
anoopt / msgraph.ts
Last active March 7, 2023 17:12
Helper wrapper for calling Graph
//* Helper wrapper for calling Graph
//* based on https://gist.github.com/wobba/37416d3107b85675d896105554b3df28
//* Thank you Mikael Svenson
import { WebPartContext } from '@microsoft/sp-webpart-base';
import { GraphError } from '@microsoft/microsoft-graph-client';
import { MSGraphClientV3 } from '@microsoft/sp-http';
export class msgraph {
private static _graphClient: MSGraphClientV3;
@anoopt
anoopt / gpt-3.5-turbo-get-page-summary-in-different-languages.ps1
Last active March 2, 2023 09:02
Multilingual SharePoint Page Summarization with Open AI API and Microsoft Graph PowerShell SDK
# A script to get summary of a SharePoint site page using GPT-3.5 turbo
# The script accepts the following parameters:
# SiteAbsoluteUrl, PageName
Param(
[Parameter(Mandatory = $true)]
[string]$SiteAbsoluteUrl,
[Parameter(Mandatory = $true)]
[string]$PageName
)
name: "On pull request"
on:
pull_request:
branches:
- main
jobs:
create-task:
runs-on: ubuntu-latest
steps:
@anoopt
anoopt / devcontainer.json
Created October 9, 2020 10:43
Devcontainer.json file needed for GitHub codespaces SPFx develoment
{
"name": "SPFx",
"build": {
"dockerfile": "Dockerfile"
},
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
@anoopt
anoopt / Dockerfile
Created October 9, 2020 10:42
Docker file needed for GitHub codespaces SPFx development
FROM node:10.22.0
RUN npm i -g gulp@3 yo @microsoft/generator-sharepoint@1.11.0
VOLUME /usr/app/spfx
WORKDIR /usr/app/spfx
RUN useradd --create-home --shell /bin/bash spfx && \
usermod -aG sudo spfx && \
chown -R spfx:spfx /usr/app/spfx
# For better pipelines see - https://www.voitanos.io/blog/sharepoint-framework-azure-pipelines-templates/
parameters:
- name: sppkg_file_name
type: string
default: name_of_the_package.sppkg
- name: site_url
type: string
default: https://contoso.sharepoint.com/sites/teamsite
- name: tenant_name
@anoopt
anoopt / spfx-cicd-with-pnp-poweshell-oidc.yml
Last active November 11, 2022 09:50
SPFx CICD with PnP PowerShell OIDC
name: SPFx CICD with PnP PowerShell OIDC
on:
workflow_dispatch:
push:
branches:
- main
permissions:
id-token: write