started working on my fallowed sites with drag and drop

This commit is contained in:
Adam 2021-11-08 23:31:52 +01:00
parent 961b975f03
commit 5ebaaa252e
31 changed files with 21957 additions and 0 deletions

View File

@ -0,0 +1,33 @@
# Logs
logs
*.log
npm-debug.log*
# Dependency directories
node_modules
# Build generated files
dist
lib
release
solution
temp
*.sppkg
# Coverage directory used by tools like istanbul
coverage
# OSX
.DS_Store
# Visual Studio files
.ntvs_analysis.dat
.vs
bin
obj
# Resx Generated Code
*.resx.ts
# Styles Generated Code
*.scss.ts

View File

@ -0,0 +1,16 @@
!dist
config
gulpfile.js
release
src
temp
tsconfig.json
tslint.json
*.log
.yo-rc.json
.vscode

View File

@ -0,0 +1,13 @@
{
"@microsoft/generator-sharepoint": {
"plusBeta": false,
"isCreatingSolution": true,
"environment": "spo",
"version": "1.13.0",
"libraryName": "react-followed-drag-and-drop-grid",
"libraryId": "513ca7e1-f774-438a-9790-80a4a3d08c9a",
"packageManager": "npm",
"isDomainIsolated": true,
"componentType": "webpart"
}
}

View File

@ -0,0 +1,73 @@
# react-followed-drag-and-drop-grid
## Summary
Short summary on functionality and used technologies.
[picture of the solution in action, if possible]
## Used SharePoint Framework Version
![version](https://img.shields.io/badge/version-1.13-green.svg)
## Applies to
- [SharePoint Framework](https://aka.ms/spfx)
- [Microsoft 365 tenant](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)
> Get your own free development tenant by subscribing to [Microsoft 365 developer program](http://aka.ms/o365devprogram)
## Prerequisites
> Any special pre-requisites?
## Solution
Solution|Author(s)
--------|---------
folder name | Author details (name, company, twitter alias with link)
## Version history
Version|Date|Comments
-------|----|--------
1.1|March 10, 2021|Update comment
1.0|January 29, 2021|Initial release
## Disclaimer
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
---
## Minimal Path to Awesome
- Clone this repository
- Ensure that you are at the solution folder
- in the command-line run:
- **npm install**
- **gulp serve**
> Include any additional steps as needed.
## Features
Description of the extension that expands upon high-level summary above.
This extension illustrates the following concepts:
- topic 1
- topic 2
- topic 3
> Notice that better pictures and documentation will increase the sample usage and the value you are providing for others. Thanks for your submissions advance.
> Share your web part with others through Microsoft 365 Patterns and Practices program to get visibility and exposure. More details on the community, open-source projects and other activities from http://aka.ms/m365pnp.
## References
- [Getting started with SharePoint Framework](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)
- [Building for Microsoft teams](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/build-for-teams-overview)
- [Use Microsoft Graph in your solution](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/using-microsoft-graph-apis)
- [Publish SharePoint Framework applications to the Marketplace](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/publish-to-marketplace-overview)
- [Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) - Guidance, tooling, samples and open-source controls for your Microsoft 365 development

View File

@ -0,0 +1,18 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
"version": "2.0",
"bundles": {
"drag-and-drop-followed-sites-web-part": {
"components": [
{
"entrypoint": "./lib/webparts/dragAndDropFollowedSites/DragAndDropFollowedSitesWebPart.js",
"manifest": "./src/webparts/dragAndDropFollowedSites/DragAndDropFollowedSitesWebPart.manifest.json"
}
]
}
},
"externals": {},
"localizedResources": {
"DragAndDropFollowedSitesWebPartStrings": "lib/webparts/dragAndDropFollowedSites/loc/{locale}.js"
}
}

View File

@ -0,0 +1,7 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
"workingDir": "./release/assets/",
"account": "<!-- STORAGE ACCOUNT NAME -->",
"container": "react-followed-drag-and-drop-grid",
"accessKey": "<!-- ACCESS KEY -->"
}

View File

@ -0,0 +1,27 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
"name": "react-followed-drag-and-drop-grid-client-side-solution",
"id": "513ca7e1-f774-438a-9790-80a4a3d08c9a",
"version": "1.0.0.0",
"includeClientSideAssets": true,
"skipFeatureDeployment": true,
"isDomainIsolated": true,
"developer": {
"name": "",
"websiteUrl": "",
"privacyUrl": "",
"termsOfUseUrl": "",
"mpnId": "Undefined-1.13.0"
},
"webApiPermissionRequests": [
{
"resource": "Microsoft Graph",
"scope": "Sites.ReadWrite.All"
}
]
},
"paths": {
"zippedPackage": "solution/react-followed-drag-and-drop-grid.sppkg"
}
}

View File

@ -0,0 +1,6 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json",
"port": 4321,
"https": true,
"initialPage": "https://enter-your-SharePoint-site/_layouts/workbench.aspx"
}

View File

@ -0,0 +1,4 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
"cdnBasePath": "<!-- PATH TO CDN -->"
}

View File

@ -0,0 +1,16 @@
'use strict';
const build = require('@microsoft/sp-build-web');
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
var getTasks = build.rig.getTasks;
build.rig.getTasks = function () {
var result = getTasks.call(build.rig);
result.set('serve', result.get('serve-deprecated'));
return result;
};
build.initialize(require('gulp'));

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,32 @@
{
"name": "react-followed-drag-and-drop-grid",
"version": "0.0.1",
"private": true,
"main": "lib/index.js",
"scripts": {
"build": "gulp bundle",
"clean": "gulp clean",
"test": "gulp test"
},
"dependencies": {
"react": "16.13.1",
"react-dom": "16.13.1",
"office-ui-fabric-react": "7.174.1",
"@microsoft/sp-core-library": "1.13.0",
"@microsoft/sp-property-pane": "1.13.0",
"@microsoft/sp-webpart-base": "1.13.0",
"@microsoft/sp-lodash-subset": "1.13.0",
"@microsoft/sp-office-ui-fabric-core": "1.13.0"
},
"devDependencies": {
"@types/react": "16.9.51",
"@types/react-dom": "16.9.8",
"@microsoft/sp-build-web": "1.13.0",
"@microsoft/sp-tslint-rules": "1.13.0",
"@microsoft/sp-module-interfaces": "1.13.0",
"@microsoft/rush-stack-compiler-3.9": "0.4.47",
"gulp": "~4.0.2",
"ajv": "~5.2.2",
"@types/webpack-env": "1.13.1"
}
}

View File

@ -0,0 +1 @@
// A file is required to be in the root of the /src directory by the TypeScript compiler

View File

@ -0,0 +1,26 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
"id": "b63d60a8-f42c-40ef-ad08-c893ea055c5c",
"alias": "DragAndDropFollowedSitesWebPart",
"componentType": "WebPart",
// The "*" signifies that the version should be taken from the package.json
"version": "*",
"manifestVersion": 2,
// If true, the component can only be installed on sites where Custom Script is allowed.
// Components that allow authors to embed arbitrary script code should set this to true.
// https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f
"requiresCustomScript": false,
"supportedHosts": ["SharePointWebPart", "TeamsPersonalApp", "TeamsTab", "SharePointFullPage"],
"supportsThemeVariants": true,
"preconfiguredEntries": [{
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other
"group": { "default": "Other" },
"title": { "default": "DragAndDropFollowedSites" },
"description": { "default": "DragAndDropFollowedSites description" },
"officeFabricIconFontName": "Page",
"properties": {}
}]
}

View File

@ -0,0 +1,45 @@
import * as React from 'react';
import * as ReactDom from 'react-dom';
import * as strings from 'DragAndDropFollowedSitesWebPartStrings';
import { Version } from '@microsoft/sp-core-library';
import { IPropertyPaneConfiguration } from '@microsoft/sp-property-pane';
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
import DragAndDropFollowedSites from './components/DragAndDropFollowedSites';
import { IDragAndDropFollowedSitesProps } from './components/IDragAndDropFollowedSitesProps';
import { IDragAndDropFollowedSitesWebPartProps } from './IDragAndDropFollowedSitesWebPartProps';
export default class DragAndDropFollowedSitesWebPart extends BaseClientSideWebPart<IDragAndDropFollowedSitesWebPartProps> {
public render(): void {
const element: React.ReactElement<IDragAndDropFollowedSitesProps> = React.createElement(
DragAndDropFollowedSites,
{
context: this.context
}
);
ReactDom.render(element, this.domElement);
}
protected onDispose(): void {
ReactDom.unmountComponentAtNode(this.domElement);
}
protected get dataVersion(): Version {
return Version.parse('1.0');
}
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
return {
pages: [
{
header: {
description: strings.PropertyPaneDescription
},
groups: [
]
}
]
};
}
}

View File

@ -0,0 +1 @@
export interface IDragAndDropFollowedSitesWebPartProps {}

View File

@ -0,0 +1 @@
@import '~office-ui-fabric-react/dist/sass/References.scss';

View File

@ -0,0 +1,22 @@
import * as React from 'react';
import { MSGraphClient } from '@microsoft/sp-http';
import { IDragAndDropFollowedSitesProps } from './IDragAndDropFollowedSitesProps';
export default class DragAndDropFollowedSites extends React.Component<IDragAndDropFollowedSitesProps, {}> {
public componentDidMount(): void {
this.props.context.msGraphClientFactory
.getClient()
.then((client: MSGraphClient): void => {
});
}
public render(): React.ReactElement<IDragAndDropFollowedSitesProps> {
return (
<div>
<span>fallowed sites</span>
</div>
);
}
}

View File

@ -0,0 +1,5 @@
import { WebPartContext } from '@microsoft/sp-webpart-base';
export interface IDragAndDropFollowedSitesProps {
context: WebPartContext;
}

View File

@ -0,0 +1,7 @@
define([], function() {
return {
"PropertyPaneDescription": "Description",
"BasicGroupName": "Group Name",
"DescriptionFieldLabel": "Description Field"
}
});

View File

@ -0,0 +1,10 @@
declare interface IDragAndDropFollowedSitesWebPartStrings {
PropertyPaneDescription: string;
BasicGroupName: string;
DescriptionFieldLabel: string;
}
declare module 'DragAndDropFollowedSitesWebPartStrings' {
const strings: IDragAndDropFollowedSitesWebPartStrings;
export = strings;
}

View File

@ -0,0 +1,24 @@
import { MSGraphClient } from '@microsoft/sp-http';
export default class FallowedSitesService {
private graphClient: MSGraphClient = null;
constructor(graphClient: MSGraphClient) {
this.graphClient = graphClient;
}
public async getMyFallowedSites(): Promise<any> {
return new Promise<any>((resolve, reject) =>
this.graphClient
.api('/me/followedSites')
.version('v1.0')
.get((error, response: any, rawResponse?: any) => {
if (error) {
resolve(error);
}
resolve(response);
}));
}
}

View File

@ -0,0 +1,8 @@
import { MSGraphClient, HttpClient } from '@microsoft/sp-http';
export default interface IMyDataServiceInput {
mSGraphClient: MSGraphClient;
httpClient: HttpClient;
appDataFolderName: string;
appDataJsonFileName: string;
}

View File

@ -0,0 +1,111 @@
import {
MSGraphClient,
HttpClient,
HttpClientResponse } from '@microsoft/sp-http';
import IAppData from '../../../model/IAppData';
import IAppDataFolderExistsOutput from '../../../model/IAppDataFolderExistsOutput';
import IMyDataServiceInput from "./IMyDataServiceInput";
export default class MyDataService {
private input: IMyDataServiceInput = null;
private graphClient: MSGraphClient = this.input.mSGraphClient;
private httpClient: HttpClient = this.input.httpClient;
constructor(input: IMyDataServiceInput) {
this.input = input;
}
public async getAppDataFolder(): Promise<any> {
return new Promise<any>((resolve, reject) =>
this.graphClient
.api(`/me/drive/special/approot/children?$filter=name eq '${this.input.appDataFolderName}'`)
.version('v1.0')
.get((error, response: any, rawResponse?: any) => {
if (error) {
resolve(error);
}
resolve(response);
}));
}
public async checkIfAppDataFolderExists(): Promise<IAppDataFolderExistsOutput> {
return new Promise<IAppDataFolderExistsOutput>((resolve, reject) => {
resolve(this.getAppDataFolder().then(result => {
const isError = result.errorCode !== undefined;
return {
isError,
errorMessage: isError ? result.errorMessage : '',
folderExists: !isError ? result.value.some(item => item.name === this.input.appDataFolderName) : false
} as IAppDataFolderExistsOutput;
}));
});
}
public async createAppDataFolder(): Promise<string> {
const driveItem = {
name: this.input.appDataFolderName,
folder: {},
'@microsoft.graph.conflictBehavior': 'fail'
};
return new Promise<string>((resolve, reject) =>
this.graphClient
.api('/me/drive/special/approot/children')
.version('v1.0')
.post(driveItem)
.then(result => {
if (result != null) {
resolve(result.name.toString());
}
}));
}
public createOrUpdateJsonDataFile(appData: IAppData): void {
this.getAppDataFolder()
.then(response => {
const id = response.value.filter(item => item.name === this.input.appDataFolderName)[0].id;
const stream = JSON.stringify(appData);
this.graphClient
.api(`/me/drive/items/${id}:/${this.input.appDataJsonFileName}:/content`)
.version('v1.0')
.put(stream);
});
}
public async getJsonAppDataFile(): Promise<IAppData> {
return new Promise<IAppData>((resolve, reject) =>
this.graphClient
.api(`/me/drive/special/approot:/${this.input.appDataFolderName}:/children?$filter=name eq '${this.input.appDataJsonFileName}'`)
.version('v1.0')
.get((error, response: any, rawResponse?: any) => {
if (error) {
return;
}
if (response.value.length === 0) {
resolve(
{
userFallowedSites: []
} as IAppData);
}
const downloadUrl = response.value.filter(item => item.name === this.input.appDataJsonFileName)[0]['@microsoft.graph.downloadUrl'];
this.httpClient
.get(downloadUrl, HttpClient.configurations.v1)
.then((innerResponse: HttpClientResponse): Promise<string> => {
if (innerResponse.ok) {
return innerResponse.text();
}
return Promise.reject(innerResponse.statusText);
})
.then((settingsString: string) => {
const settings: IAppData = JSON.parse(settingsString);
resolve(settings);
});
}));
}
}

View File

@ -0,0 +1,5 @@
import ISiteItem from './ISiteItem';
export default interface IAppData {
userFallowedSites: ISiteItem[];
}

View File

@ -0,0 +1,5 @@
export default interface IAppDataFolderExistsOutput {
isError: boolean;
errorMessage: string;
folderExists: boolean;
}

View File

@ -0,0 +1,4 @@
export default interface ISiteItem {
id: number;
url: string;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 542 B

View File

@ -0,0 +1,35 @@
{
"extends": "./node_modules/@microsoft/rush-stack-compiler-3.9/includes/tsconfig-web.json",
"compilerOptions": {
"target": "es5",
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"jsx": "react",
"declaration": true,
"sourceMap": true,
"experimentalDecorators": true,
"skipLibCheck": true,
"outDir": "lib",
"inlineSources": false,
"strictNullChecks": false,
"noUnusedLocals": false,
"typeRoots": [
"./node_modules/@types",
"./node_modules/@microsoft"
],
"types": [
"webpack-env"
],
"lib": [
"es5",
"dom",
"es2015.collection",
"es2015.promise"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx"
]
}

View File

@ -0,0 +1,29 @@
{
"extends": "./node_modules/@microsoft/sp-tslint-rules/base-tslint.json",
"rules": {
"class-name": false,
"export-name": false,
"forin": false,
"label-position": false,
"member-access": true,
"no-arg": false,
"no-console": false,
"no-construct": false,
"no-duplicate-variable": true,
"no-eval": false,
"no-function-expression": true,
"no-internal-module": true,
"no-shadowed-variable": true,
"no-switch-case-fall-through": true,
"no-unnecessary-semicolons": true,
"no-unused-expression": true,
"no-with-statement": true,
"semicolon": true,
"trailing-comma": false,
"typedef": false,
"typedef-whitespace": false,
"use-named-parameter": true,
"variable-name": false,
"whitespace": false
}
}