new sample react-my-dashboard

This commit is contained in:
João Mendes 2023-06-23 23:24:53 +01:00
parent 8665d4665a
commit 01cf2238c4
118 changed files with 49788 additions and 0 deletions

20
samples/react-my-dashboard/.gitignore vendored Normal file
View File

@ -0,0 +1,20 @@
# TeamsFx files
env/.env.*.user
env/.env.local
.DS_Store
build
appPackage/build
# dependencies
/node_modules
# testing
/coverage
# production
/build
# misc
.DS_Store
.env
.deployment

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -0,0 +1,63 @@
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.16/MicrosoftTeams.schema.json",
"manifestVersion": "1.16",
"packageName": "com.microsoft.teams.extension",
"id": "${{TEAMS_APP_ID}}",
"version": "1.0.0",
"developer": {
"name": "SPFx + Teams Dev",
"websiteUrl": "https://products.office.com/en-us/sharepoint/collaboration",
"privacyUrl": "https://privacy.microsoft.com/en-us/privacystatement",
"termsOfUseUrl": "https://www.microsoft.com/en-us/servicesagreement"
},
"name": {
"short": "MyDashBoardSPFx-${{TEAMSFX_ENV}}",
"full": "Full name for MyDashBoardSPFx"
},
"description": {
"short": "Short description of MyDashBoardSPFx",
"full": "Full description of MyDashBoardSPFx"
},
"icons": {
"color": "color.png",
"outline": "outline.png"
},
"accentColor": "#004578",
"staticTabs": [
{
"entityId": "90a4a655-2864-4cda-bc53-f3d46b02f75d",
"name": "DashBoard",
"contentUrl": "https://{teamSiteDomain}/_layouts/15/TeamsLogon.aspx?SPFX=true&dest=/_layouts/15/teamshostedapp.aspx%3Fteams%26personal%26componentId=90a4a655-2864-4cda-bc53-f3d46b02f75d%26forceLocale={locale}",
"websiteUrl": "https://products.office.com/en-us/sharepoint/collaboration",
"scopes": [
"personal"
]
}
],
"configurableTabs": [
{
"configurationUrl": "https://{teamSiteDomain}{teamSitePath}/_layouts/15/TeamsLogon.aspx?SPFX=true&dest={teamSitePath}/_layouts/15/teamshostedapp.aspx%3FopenPropertyPane=true%26teams%26componentId=90a4a655-2864-4cda-bc53-f3d46b02f75d%26forceLocale={locale}",
"canUpdateConfiguration": true,
"scopes": [
"team"
]
}
],
"permissions": [
"identity",
"messageTeamMembers"
],
"validDomains": [
"*.login.microsoftonline.com",
"*.sharepoint.com",
"*.sharepoint-df.com",
"spoppe-a.akamaihd.net",
"spoprod-a.akamaihd.net",
"resourceseng.blob.core.windows.net",
"msft.spoppe.com"
],
"webApplicationInfo": {
"resource": "https://{teamSiteDomain}",
"id": "00000003-0000-0ff1-ce00-000000000000"
}
}

View File

@ -0,0 +1,63 @@
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.16/MicrosoftTeams.schema.json",
"manifestVersion": "1.16",
"packageName": "com.microsoft.teams.extension",
"id": "${{TEAMS_APP_ID}}",
"version": "1.0.0",
"developer": {
"name": "SPFx + Teams Dev",
"websiteUrl": "https://products.office.com/en-us/sharepoint/collaboration",
"privacyUrl": "https://privacy.microsoft.com/en-us/privacystatement",
"termsOfUseUrl": "https://www.microsoft.com/en-us/servicesagreement"
},
"name": {
"short": "MyDashBoardSPFx-${{TEAMSFX_ENV}}",
"full": "Full name for MyDashBoardSPFx"
},
"description": {
"short": "Short description of MyDashBoardSPFx",
"full": "Full description of MyDashBoardSPFx"
},
"icons": {
"color": "color.png",
"outline": "outline.png"
},
"accentColor": "#004578",
"staticTabs": [
{
"entityId": "90a4a655-2864-4cda-bc53-f3d46b02f75d",
"name": "DashBoard",
"contentUrl": "https://{teamSiteDomain}/_layouts/15/TeamsLogon.aspx?SPFX=true&dest={teamSitePath}/_layouts/15/TeamsWorkBench.aspx%3FcomponentId=90a4a655-2864-4cda-bc53-f3d46b02f75d%26teams%26personal%26forceLocale={locale}%26loadSPFX%3Dtrue%26debugManifestsFile%3Dhttps%3A%2F%2Flocalhost%3A4321%2Ftemp%2Fmanifests.js",
"websiteUrl": "https://products.office.com/en-us/sharepoint/collaboration",
"scopes": [
"personal"
]
}
],
"configurableTabs": [
{
"configurationUrl": "https://{teamSiteDomain}{teamSitePath}/_layouts/15/TeamsLogon.aspx?SPFX=true&dest={teamSitePath}/_layouts/15/TeamsWorkBench.aspx%3FcomponentId=90a4a655-2864-4cda-bc53-f3d46b02f75d%26openPropertyPane=true%26teams%26forceLocale={locale}%26loadSPFX%3Dtrue%26debugManifestsFile%3Dhttps%3A%2F%2Flocalhost%3A4321%2Ftemp%2Fmanifests.js",
"canUpdateConfiguration": true,
"scopes": [
"team"
]
}
],
"permissions": [
"identity",
"messageTeamMembers"
],
"validDomains": [
"*.login.microsoftonline.com",
"*.sharepoint.com",
"*.sharepoint-df.com",
"spoppe-a.akamaihd.net",
"spoprod-a.akamaihd.net",
"resourceseng.blob.core.windows.net",
"msft.spoppe.com"
],
"webApplicationInfo": {
"resource": "https://{teamSiteDomain}",
"id": "00000003-0000-0ff1-ce00-000000000000"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

View File

@ -0,0 +1,7 @@
# Built-in environment variables
TEAMSFX_ENV=dev
# Generated during provision, you can also add your own variables.
TEAMS_APP_ID=
# Secrets. Keys prefixed with `SECRET_` will be masked in Teams Toolkit logs.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,20 @@
{
"name": "teamsfx-template-spfx-tab",
"version": "0.0.1",
"description": "",
"engines": {
"node": "16"
},
"author": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"@microsoft/teamsfx-cli": "1.*"
},
"license": "MIT",
"dependencies": {
"gulp": "^4.0.2",
"webpack": "^5.84.1"
}
}

View File

@ -0,0 +1,352 @@
require('@rushstack/eslint-config/patch/modern-module-resolution');
module.exports = {
extends: ['@microsoft/eslint-config-spfx/lib/profiles/react'],
parserOptions: { tsconfigRootDir: __dirname },
overrides: [
{
files: ['*.ts', '*.tsx'],
parser: '@typescript-eslint/parser',
'parserOptions': {
'project': './tsconfig.json',
'ecmaVersion': 2018,
'sourceType': 'module'
},
rules: {
// Prevent usage of the JavaScript null value, while allowing code to access existing APIs that may require null. https://www.npmjs.com/package/@rushstack/eslint-plugin
'@rushstack/no-new-null': 1,
// Require Jest module mocking APIs to be called before any other statements in their code block. https://www.npmjs.com/package/@rushstack/eslint-plugin
'@rushstack/hoist-jest-mock': 1,
// Require regular expressions to be constructed from string constants rather than dynamically building strings at runtime. https://www.npmjs.com/package/@rushstack/eslint-plugin-security
'@rushstack/security/no-unsafe-regexp': 1,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/adjacent-overload-signatures': 1,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
//
// CONFIGURATION: By default, these are banned: String, Boolean, Number, Object, Symbol
'@typescript-eslint/ban-types': [
1,
{
'extendDefaults': false,
'types': {
'String': {
'message': 'Use \'string\' instead',
'fixWith': 'string'
},
'Boolean': {
'message': 'Use \'boolean\' instead',
'fixWith': 'boolean'
},
'Number': {
'message': 'Use \'number\' instead',
'fixWith': 'number'
},
'Object': {
'message': 'Use \'object\' instead, or else define a proper TypeScript type:'
},
'Symbol': {
'message': 'Use \'symbol\' instead',
'fixWith': 'symbol'
},
'Function': {
'message': 'The \'Function\' type accepts any function-like value.\nIt provides no type safety when calling the function, which can be a common source of bugs.\nIt also accepts things like class declarations, which will throw at runtime as they will not be called with \'new\'.\nIf you are expecting the function to accept certain arguments, you should explicitly define the function shape.'
}
}
}
],
// RATIONALE: Code is more readable when the type of every variable is immediately obvious.
// Even if the compiler may be able to infer a type, this inference will be unavailable
// to a person who is reviewing a GitHub diff. This rule makes writing code harder,
// but writing code is a much less important activity than reading it.
//
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/explicit-function-return-type': [
1,
{
'allowExpressions': true,
'allowTypedFunctionExpressions': true,
'allowHigherOrderFunctions': false
}
],
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
// Rationale to disable: although this is a recommended rule, it is up to dev to select coding style.
// Set to 1 (warning) or 2 (error) to enable.
'@typescript-eslint/explicit-member-accessibility': 0,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/no-array-constructor': 1,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
//
// RATIONALE: The "any" keyword disables static type checking, the main benefit of using TypeScript.
// This rule should be suppressed only in very special cases such as JSON.stringify()
// where the type really can be anything. Even if the type is flexible, another type
// may be more appropriate such as "unknown", "{}", or "Record<k,V>".
'@typescript-eslint/no-explicit-any': 1,
// RATIONALE: The #1 rule of promises is that every promise chain must be terminated by a catch()
// handler. Thus wherever a Promise arises, the code must either append a catch handler,
// or else return the object to a caller (who assumes this responsibility). Unterminated
// promise chains are a serious issue. Besides causing errors to be silently ignored,
// they can also cause a NodeJS process to terminate unexpectedly.
'@typescript-eslint/no-floating-promises': 2,
// RATIONALE: Catches a common coding mistake.
'@typescript-eslint/no-for-in-array': 2,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/no-misused-new': 2,
// RATIONALE: The "namespace" keyword is not recommended for organizing code because JavaScript lacks
// a "using" statement to traverse namespaces. Nested namespaces prevent certain bundler
// optimizations. If you are declaring loose functions/variables, it's better to make them
// static members of a class, since classes support property getters and their private
// members are accessible by unit tests. Also, the exercise of choosing a meaningful
// class name tends to produce more discoverable APIs: for example, search+replacing
// the function "reverse()" is likely to return many false matches, whereas if we always
// write "Text.reverse()" is more unique. For large scale organization, it's recommended
// to decompose your code into separate NPM packages, which ensures that component
// dependencies are tracked more conscientiously.
//
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/no-namespace': [
1,
{
'allowDeclarations': false,
'allowDefinitionFiles': false
}
],
// RATIONALE: Parameter properties provide a shorthand such as "constructor(public title: string)"
// that avoids the effort of declaring "title" as a field. This TypeScript feature makes
// code easier to write, but arguably sacrifices readability: In the notes for
// "@typescript-eslint/member-ordering" we pointed out that fields are central to
// a class's design, so we wouldn't want to bury them in a constructor signature
// just to save some typing.
//
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
// Set to 1 (warning) or 2 (error) to enable the rule
'@typescript-eslint/parameter-properties': 0,
// RATIONALE: When left in shipping code, unused variables often indicate a mistake. Dead code
// may impact performance.
//
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/no-unused-vars': [
1,
{
'vars': 'all',
// Unused function arguments often indicate a mistake in JavaScript code. However in TypeScript code,
// the compiler catches most of those mistakes, and unused arguments are fairly common for type signatures
// that are overriding a base class method or implementing an interface.
'args': 'none'
}
],
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/no-use-before-define': [
2,
{
'functions': false,
'classes': true,
'variables': true,
'enums': true,
'typedefs': true
}
],
// Disallows require statements except in import statements.
// In other words, the use of forms such as var foo = require("foo") are banned. Instead use ES6 style imports or import foo = require("foo") imports.
'@typescript-eslint/no-var-requires': 'error',
// RATIONALE: The "module" keyword is deprecated except when describing legacy libraries.
//
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/prefer-namespace-keyword': 1,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
// Rationale to disable: it's up to developer to decide if he wants to add type annotations
// Set to 1 (warning) or 2 (error) to enable the rule
'@typescript-eslint/no-inferrable-types': 0,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
// Rationale to disable: declaration of empty interfaces may be helpful for generic types scenarios
'@typescript-eslint/no-empty-interface': 0,
// RATIONALE: This rule warns if setters are defined without getters, which is probably a mistake.
'accessor-pairs': 1,
// RATIONALE: In TypeScript, if you write x["y"] instead of x.y, it disables type checking.
'dot-notation': [
1,
{
'allowPattern': '^_'
}
],
// RATIONALE: Catches code that is likely to be incorrect
'eqeqeq': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'for-direction': 1,
// RATIONALE: Catches a common coding mistake.
'guard-for-in': 2,
// RATIONALE: If you have more than 2,000 lines in a single source file, it's probably time
// to split up your code.
'max-lines': ['warn', { max: 2000 }],
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-async-promise-executor': 2,
// RATIONALE: Deprecated language feature.
'no-caller': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-compare-neg-zero': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-cond-assign': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-constant-condition': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-control-regex': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-debugger': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-delete-var': 2,
// RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-duplicate-case': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-empty': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-empty-character-class': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-empty-pattern': 1,
// RATIONALE: Eval is a security concern and a performance concern.
'no-eval': 1,
// RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-ex-assign': 2,
// RATIONALE: System types are global and should not be tampered with in a scalable code base.
// If two different libraries (or two versions of the same library) both try to modify
// a type, only one of them can win. Polyfills are acceptable because they implement
// a standardized interoperable contract, but polyfills are generally coded in plain
// JavaScript.
'no-extend-native': 1,
// Disallow unnecessary labels
'no-extra-label': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-fallthrough': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-func-assign': 1,
// RATIONALE: Catches a common coding mistake.
'no-implied-eval': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-invalid-regexp': 2,
// RATIONALE: Catches a common coding mistake.
'no-label-var': 2,
// RATIONALE: Eliminates redundant code.
'no-lone-blocks': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-misleading-character-class': 2,
// RATIONALE: Catches a common coding mistake.
'no-multi-str': 2,
// RATIONALE: It's generally a bad practice to call "new Thing()" without assigning the result to
// a variable. Either it's part of an awkward expression like "(new Thing()).doSomething()",
// or else implies that the constructor is doing nontrivial computations, which is often
// a poor class design.
'no-new': 1,
// RATIONALE: Obsolete language feature that is deprecated.
'no-new-func': 2,
// RATIONALE: Obsolete language feature that is deprecated.
'no-new-object': 2,
// RATIONALE: Obsolete notation.
'no-new-wrappers': 1,
// RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-octal': 2,
// RATIONALE: Catches code that is likely to be incorrect
'no-octal-escape': 2,
// RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-regex-spaces': 2,
// RATIONALE: Catches a common coding mistake.
'no-return-assign': 2,
// RATIONALE: Security risk.
'no-script-url': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-self-assign': 2,
// RATIONALE: Catches a common coding mistake.
'no-self-compare': 2,
// RATIONALE: This avoids statements such as "while (a = next(), a && a.length);" that use
// commas to create compound expressions. In general code is more readable if each
// step is split onto a separate line. This also makes it easier to set breakpoints
// in the debugger.
'no-sequences': 1,
// RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-shadow-restricted-names': 2,
// RATIONALE: Obsolete language feature that is deprecated.
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-sparse-arrays': 2,
// RATIONALE: Although in theory JavaScript allows any possible data type to be thrown as an exception,
// such flexibility adds pointless complexity, by requiring every catch block to test
// the type of the object that it receives. Whereas if catch blocks can always assume
// that their object implements the "Error" contract, then the code is simpler, and
// we generally get useful additional information like a call stack.
'no-throw-literal': 2,
// RATIONALE: Catches a common coding mistake.
'no-unmodified-loop-condition': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-unsafe-finally': 2,
// RATIONALE: Catches a common coding mistake.
'no-unused-expressions': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-unused-labels': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-useless-catch': 1,
// RATIONALE: Avoids a potential performance problem.
'no-useless-concat': 1,
// RATIONALE: The "var" keyword is deprecated because of its confusing "hoisting" behavior.
// Always use "let" or "const" instead.
//
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'no-var': 2,
// RATIONALE: Generally not needed in modern code.
'no-void': 1,
// RATIONALE: Obsolete language feature that is deprecated.
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-with': 2,
// RATIONALE: Makes logic easier to understand, since constants always have a known value
// @typescript-eslint\eslint-plugin\dist\configs\eslint-recommended.js
'prefer-const': 1,
// RATIONALE: Catches a common coding mistake where "resolve" and "reject" are confused.
'promise/param-names': 2,
// RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'require-atomic-updates': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'require-yield': 1,
// "Use strict" is redundant when using the TypeScript compiler.
'strict': [
2,
'never'
],
// RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'use-isnan': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
// Set to 1 (warning) or 2 (error) to enable.
// Rationale to disable: !!{}
'no-extra-boolean-cast': 0,
// ====================================================================
// @microsoft/eslint-plugin-spfx
// ====================================================================
'@microsoft/spfx/import-requires-chunk-name': 1,
'@microsoft/spfx/no-require-ensure': 2,
'@microsoft/spfx/pair-react-dom-render-unmount': 1
}
},
{
// For unit tests, we can be a little bit less strict. The settings below revise the
// defaults specified in the extended configurations, as well as above.
files: [
// Test files
'*.test.ts',
'*.test.tsx',
'*.spec.ts',
'*.spec.tsx',
// Facebook convention
'**/__mocks__/*.ts',
'**/__mocks__/*.tsx',
'**/__tests__/*.ts',
'**/__tests__/*.tsx',
// Microsoft convention
'**/test/*.ts',
'**/test/*.tsx'
],
rules: {}
}
]
};

View File

@ -0,0 +1,34 @@
# Logs
logs
*.log
npm-debug.log*
# Dependency directories
node_modules
# Build generated files
dist
lib
release
solution
temp
*.sppkg
.heft
# 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,24 @@
{
"@microsoft/generator-sharepoint": {
"whichFolder": "subdir",
"solutionName": "MyDashBoardSPFx",
"environment": "spo",
"skipFeatureDeployment": true,
"isDomainIsolated": false,
"componentType": "webpart",
"template": "react",
"componentName": "DashBoard",
"plusBeta": false,
"isCreatingSolution": true,
"nodeVersion": "14.15.2",
"sdksVersions": {
"@microsoft/microsoft-graph-client": "3.0.2",
"@microsoft/teams-js": "2.9.1"
},
"version": "1.17.2",
"libraryName": "my-dash-board-sp-fx",
"libraryId": "300aa27b-51c6-4b0d-8f82-b9743c1f9257",
"packageManager": "npm",
"solutionShortDescription": "MyDashBoardSPFx description"
}
}

View File

@ -0,0 +1,108 @@
# My Dashboard
## Summary
This SPFx app alows quick access to user agenda, ToDo Tasks, Files and News and Relevenat People related to user.
![react-my-dashboard](./src/assets/MyDashboard_dark.png)
![react-my-dashboard](./src/assets/MyDashboard_sp.png)
![react-my-dashboard](./src/assets/MyDashboard_office.png)
![react-my-dashboard](./src/assets/mobileTeamsApp02.PNG) ![react-my-dashboard](./src/assets/mobileTeamsApp01.PNG) ![react-my-dashboard](./src/assets/mobileTeamsApp03.PNG)
## Compatibility
| :warning: Important |
|:---------------------------|
| Every SPFx version is only compatible with specific version(s) of Node.js. In order to be able to build this sample, please ensure that the version of Node on your workstation matches one of the versions listed in this section. This sample will not work on a different version of Node.|
|Refer to <https://aka.ms/spfx-matrix> for more information on SPFx compatibility. |
![SPFx 1.16.1](https://img.shields.io/badge/SPFx-1.16.1-green.svg)
![Node.js v16 | v14](https://img.shields.io/badge/Node.js-v16%20|%20v14-green.svg)
![SharePoint Online](https://img.shields.io/badge/SharePoint-Online-yellow.svg)
![Workbench Hosted: Does not work with local workbench](https://img.shields.io/badge/Workbench-Hosted-yellow.svg "Does not work with local workbench")
![Compatible with Remote Containers](https://img.shields.io/badge/Remote%20Containers-Compatible-green.svg)
## Applies to
* [SharePoint Framework](https://learn.microsoft.com/sharepoint/dev/spfx/sharepoint-framework-overview)
* [Microsoft 365 tenant](https://learn.microsoft.com/sharepoint/dev/spfx/set-up-your-development-environment)
## Prerequisites
This sample use Microsoft Graph Toolkit V3 RC and use the folling components :
- mgt-Agenda
- mgt-ToDo
- mgt-Person and PersonCard
- mgt-Search-results
- mgt-get
- mgt-files
Please add the required Microsoft Graph Permissions. Please see [Microsoft Graph Toolkit overview](https://learn.microsoft.com/en-us/graph/toolkit/overview)
## Contributors
* [João Mendes](https://github.com/joaojmendes)
## Version history
Version|Date|Comments
-------|----|--------
1.0.0|June 23, 2023|Initial release
## Minimal Path to Awesome
The project was created with Visual Studio Teams Toolkit.
* Clone this repository
* Navigate to src folder
* in the command line run:
* `npm install`
* `gulp build`
* `gulp bundle --ship`
* `gulp package-solution --ship`
* Add and Deploy Package to AppCatalog
> This sample can also be opened with [VS Code Remote Development](https://code.visualstudio.com/docs/remote/remote-overview). Visit <https://aka.ms/spfx-devcontainer> for further instructions.
## Features
This sample illustrates the following concepts on top of the SharePoint Framework:
* using React for building SharePoint Framework client-side web parts
* using Microsoft Graph Toolkit
* Using React Hooks
* using Global State Management (JOTAI)
* using FLuentUI V9
* using Visuatl Studio Teams Toolkit
## References
* [Getting started with SharePoint Framework](https://learn.microsoft.com/sharepoint/dev/spfx/set-up-your-developer-tenant)
* [Building for Microsoft teams](https://learn.microsoft.com/sharepoint/dev/spfx/build-for-teams-overview)
* [Use Microsoft Graph in your solution](https://learn.microsoft.com/sharepoint/dev/spfx/web-parts/get-started/using-microsoft-graph-apis)
* [Publish SharePoint Framework applications to the Marketplace](https://learn.microsoft.com/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
* [Fluent UI version 9](https://github.com/microsoft/fluentui/tree/master/packages/react-components) - Converged Fluent UI components
## Help
We do not support samples, but we this community is always willing to help, and we want to improve these samples. We use GitHub to track issues, which makes it easy for community members to volunteer their time and help resolve issues.
If you're having issues building the solution, please run [spfx doctor](https://pnp.github.io/cli-microsoft365/cmd/spfx/spfx-doctor/) from within the solution folder to diagnose incompatibility issues with your environment.
If you encounter any issues while using this sample, [create a new issue](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected%2Csample%3A%20react-birthdays&template=bug-report.yml&sample=react-birthdays&authors=@smaity%20@joaojmendes&title=react-birthdays%20-%20).
For questions regarding this sample, [create a new question](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Aquestion%2Csample%3A%20react-birthdays&template=question.yml&sample=react-birthdays&authors=@smaity%20@joaojmendes&title=react-birthdays%20-%20).
Finally, if you have an idea for improvement, [make a suggestion](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Aenhancement%2Csample%3A%20react-birthdays&template=question.yml&sample=react-birthdays&authors=@smaity%20@joaojmendes&title=react-birthdays%20-%20).
## 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.**
<img src="https://m365-visitor-stats.azurewebsites.net/sp-dev-fx-webparts/samples/react-my-dashboard" />

View File

@ -0,0 +1,19 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
"version": "2.0",
"bundles": {
"dash-board-web-part": {
"components": [
{
"entrypoint": "./lib/webparts/dashBoard/DashBoardWebPart.js",
"manifest": "./src/webparts/dashBoard/DashBoardWebPart.manifest.json"
}
]
}
},
"externals": {},
"localizedResources": {
"DashBoardWebPartStrings": "lib/webparts/dashBoard/loc/{locale}.js",
"ControlStrings": "node_modules/@pnp/spfx-controls-react/lib/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": "my-dash-board-sp-fx",
"accessKey": "<!-- ACCESS KEY -->"
}

View File

@ -0,0 +1,40 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
"name": "my-dash-board-sp-fx",
"id": "300aa27b-51c6-4b0d-8f82-b9743c1f9257",
"version": "1.0.0.0",
"includeClientSideAssets": true,
"skipFeatureDeployment": true,
"isDomainIsolated": false,
"developer": {
"name": "",
"websiteUrl": "",
"privacyUrl": "",
"termsOfUseUrl": "",
"mpnId": "Undefined-1.17.2"
},
"metadata": {
"shortDescription": {
"default": "My Dashboard"
},
"longDescription": {
"default": "My Dashboard"
},
"screenshotPaths": [],
"videoUrl": "",
"categories": []
},
"features": [
{
"title": "my-dash-board-sp-fx Feature",
"description": "The feature that activates elements of the my-dash-board-sp-fx solution.",
"id": "d2d72346-382b-4d70-bfd6-e2ef988ac8fc",
"version": "1.0.0.0"
}
]
},
"paths": {
"zippedPackage": "solution/my-dash-board-spfx.sppkg"
}
}

View File

@ -0,0 +1,3 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/core-build/sass.schema.json"
}

View File

@ -0,0 +1,6 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/spfx-serve.schema.json",
"port": 4321,
"https": true,
"initialPage": "https://{tenantDomain}/_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,61 @@
{
"name": "my-dash-board-sp-fx",
"version": "0.0.1",
"private": true,
"engines": {
"node": ">=16.13.0 <17.0.0"
},
"main": "lib/index.js",
"scripts": {
"build": "gulp bundle",
"clean": "gulp clean",
"test": "gulp test"
},
"dependencies": {
"@fluentui/react": "^7.199.1",
"@fluentui/react-components": "^9.20.4",
"@microsoft/load-themed-styles": "^2.0.45",
"@microsoft/mgt": "^3.0.0-rc.3",
"@microsoft/mgt-react": "^3.0.0-rc.3",
"@microsoft/sp-component-base": "1.17.2",
"@microsoft/sp-core-library": "1.17.2",
"@microsoft/sp-lodash-subset": "1.17.2",
"@microsoft/sp-office-ui-fabric-core": "1.17.2",
"@microsoft/sp-property-pane": "1.17.2",
"@microsoft/sp-webpart-base": "1.17.2",
"@pnp/logging": "3.14",
"@pnp/sp": "3.16",
"@pnp/spfx-controls-react": "^3.14.0",
"adaptive-expressions": "^4.19.3",
"adaptivecards": "^2.0",
"adaptivecards-templating": "^2.2.0",
"data-fns": "^1.1.0",
"date-fns-tz": "^2.0.0",
"jotai": "^2.1.0",
"markdown-it": "^13.0.1",
"office-ui-fabric-react": "^7.199.1",
"react": "17.0.1",
"react-dom": "17.0.1",
"swiper": "^8.4.7",
"tslib": "2.3.1",
"webpack": "^5.85.1"
},
"devDependencies": {
"@fluentui/react": "^7.199.1",
"@microsoft/eslint-config-spfx": "1.17.2",
"@microsoft/eslint-plugin-spfx": "1.17.2",
"@microsoft/rush-stack-compiler-4.5": "0.5.0",
"@microsoft/sp-build-web": "1.17.2",
"@microsoft/sp-module-interfaces": "1.17.2",
"@rushstack/eslint-config": "2.5.1",
"@types/markdown-it": "^12.2.3",
"@types/react": "17.0.45",
"@types/react-dom": "17.0.17",
"@types/webpack-env": "~1.15.2",
"ajv": "^6.12.5",
"eslint": "8.7.0",
"eslint-plugin-react-hooks": "4.3.0",
"gulp": "4.0.2",
"typescript": "4.5.5"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 945 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 975 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 720 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 KiB

View File

@ -0,0 +1,5 @@
import { atom } from 'jotai';
import { IAppState } from '../models/IAppState';
export const appStateAtom = atom<IAppState>({} as IAppState);

View File

@ -0,0 +1,16 @@
import * as React from 'react';
import { useCenterStyles } from './useCenterStyles';
export interface IHeaderProps {
children?: React.ReactNode;
}
export const Center: React.FunctionComponent<IHeaderProps> = (props: React.PropsWithChildren<IHeaderProps>) => {
const centerStyles = useCenterStyles();
return (
<>
<div className={centerStyles.root}>{props.children}</div>
</>
);
};

View File

@ -0,0 +1,22 @@
import {
makeStyles,
shorthands,
} from '@fluentui/react-components';
export const useCenterStyles = makeStyles({
root: {
display: "grid",
minWidth: "60%",
gridTemplateColumns: "50% 50%",
columnGap: "0px",
height: "100%",
...shorthands.gridArea("center"),
alignItems: "start",
justifyContent: "start",
paddingRight: "5px",
"@media only screen and (max-width: 1200px)": {
gridTemplateColumns: "100%",
},
},
});

View File

@ -0,0 +1,66 @@
/* eslint-disable @typescript-eslint/explicit-function-return-type */
/* eslint-disable @typescript-eslint/no-var-requires */
import * as React from 'react';
import { useAtom } from 'jotai';
import { Subtitle1 } from '@fluentui/react-components';
import { appStateAtom } from '../../atoms/appStateAtom';
import { useUtils } from '../../hooks/useUtils';
import { IDashBoardProps } from '../../webparts/dashBoard/IDashBoardProps';
import { Center } from '../center/Center';
import { Left } from '../left/Left';
import { MyDay } from '../myDay/MyDay';
import { MyFeed } from '../myFeed/MyFeed';
import { MyFiles } from '../myFiles/MyFiles';
import { People } from '../people/People';
import { Right } from '../right/Right';
import { useDashboardStyles } from './useDashboardStyles';
export const DashboardControl: React.FunctionComponent<IDashBoardProps> = (
props: React.PropsWithChildren<IDashBoardProps>
) => {
const [appGlobalState, setAppState] = useAtom(appStateAtom);
const { title } = props;
const { isInTeams } = useUtils();
const dashboardStyles = useDashboardStyles();
React.useEffect(() => {
setAppState({
...appGlobalState,
...props,
});
}, []);
const showTitle = React.useMemo(() => {
if (!isInTeams) {
return (
<div className={dashboardStyles.titleStyles}>
<Subtitle1>{title}</Subtitle1>
</div>
);
}
return null;
}, [isInTeams, title]);
return (
<>
<div className={dashboardStyles.root}>
{showTitle}
<div className={dashboardStyles.grid}>
<Left>
<MyDay />
</Left>
<Center>
<MyFiles />
<MyFeed />
</Center>
<Right>
<People />
</Right>
</div>
</div>
</>
);
};

View File

@ -0,0 +1,52 @@
import {
makeStyles,
shorthands,
tokens,
} from '@fluentui/react-components';
export const useDashboardStyles = makeStyles({
root: {
marginTop: "0px",
backgroundColor: tokens.colorNeutralBackground3,
position: "absolute",
},
grid: {
...shorthands.padding("0px 10px 10px 0px"),
backgroundColor: tokens.colorNeutralBackground1,
display: "grid",
gridTemplateColumns: "1fr 3fr 1fr",
gridTemplateAreas: `"left center right"`,
gridTemplateRows: "1fr",
columnGap: "10px",
...shorthands.overflow("hidden"),
overflowY: "auto",
"@media only screen and (max-width: 1024px)": {
gridTemplateColumns: "1fr",
gridTemplateAreas: `"left" "center" "right"`,
},
},
wrapper: {
...shorthands.padding("10px"),
},
tab: {
alignItems: "flex-start",
display: "flex",
flexDirection: "column",
justifyContent: "flex-start",
...shorthands.padding("50px", "20px"),
rowGap: "20px",
},
titleStyles : {
display: "flex",
justifyContent: "center",
alignContent: "center",
width: "100%",
...shorthands.padding("15px"),
backgroundColor: "white",
marginBottom: "1px",
},
});

View File

@ -0,0 +1,16 @@
import * as React from 'react';
import { useHeaderStyles } from './useHeaderStyles';
export interface IHeaderProps {
children?: React.ReactNode;
}
export const Header: React.FunctionComponent<IHeaderProps> = (props: React.PropsWithChildren<IHeaderProps>) => {
const headerStyles = useHeaderStyles();
return (
<>
<div className={headerStyles.root}>{props.children}</div>
</>
);
};

View File

@ -0,0 +1,17 @@
import {
makeStyles,
shorthands,
} from '@fluentui/react-components';
export const useHeaderStyles = makeStyles({
root: {
display: 'flex',
alignItems: 'start',
justifyContent: 'end',
flexDirection: 'row',
...shorthands.gridArea('header'),
paddingBottom: "10px",
maxHeight: "60px",
height: "fit-content",
} ,
});

View File

@ -0,0 +1,21 @@
import * as React from 'react';
import { useLeftStyles } from './useLeftStyles';
export interface ILeftProps {
children?: React.ReactNode;
}
export const Left: React.FunctionComponent<ILeftProps> = (props: React.PropsWithChildren<ILeftProps>) => {
const leftStyles = useLeftStyles();
const { children } = props;
const divRef = React.useRef<HTMLDivElement>(null);
return (
<>
<div className={leftStyles.root} ref={divRef}>
{children}
</div>
</>
);
};

View File

@ -0,0 +1,18 @@
import {
makeStyles,
shorthands,
tokens,
} from '@fluentui/react-components';
export const useLeftStyles = makeStyles({
root: {
minWidth: "300px",
borderRightWidth: "1px",
borderRightStyle: "solid",
borderRightColor: tokens.colorNeutralStroke3,
height: "100%",
...shorthands.gridArea("left"),
paddingLeft: "15px",
paddingRight: "30px",
},
});

View File

@ -0,0 +1,27 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import * as React from 'react';
import {
MgtTemplateProps,
} from '@microsoft/mgt-react/dist/es6/MgtTemplateProps';
import {
HEIGHT_ON_SPSITE,
HEIGHT_ON_TEAMS,
} from '../../constants/constants';
import { useUtils } from '../../hooks/useUtils';
import { Event } from './Event';
import { useMgtAgendaStyles } from './useMgtAgendaStyles';
export const AgendaDefaultTemplate: React.FunctionComponent<MgtTemplateProps> = (props: React.PropsWithChildren<MgtTemplateProps>) => {
const agendaStyles = useMgtAgendaStyles();
const { events } = props.dataContext;
const { isInTeams} = useUtils();
return (
<div className={agendaStyles.root} style={{height: isInTeams ? HEIGHT_ON_TEAMS: HEIGHT_ON_SPSITE}}>
{events?.map((event: any, index: number) => {
return <Event key={index} event={event} />;
})}
</div>
);
};

View File

@ -0,0 +1,17 @@
import * as React from 'react';
import { Spinner } from '@fluentui/react-components';
import {
MgtTemplateProps,
} from '@microsoft/mgt-react/dist/es6/MgtTemplateProps';
import { useMgtAgendaStyles } from './useMgtAgendaStyles';
export const AgendaLoadingTemplate: React.FunctionComponent<MgtTemplateProps> = (props: React.PropsWithChildren<MgtTemplateProps>) => {
const agendaStyles = useMgtAgendaStyles();
return (
<div className={agendaStyles.spinnerStyles}>
<Spinner size="tiny" />
</div>
);
};

View File

@ -0,0 +1,19 @@
import * as React from 'react';
import { tokens } from '@fluentui/react-components';
import { CalendarAgenda24Filled } from '@fluentui/react-icons';
import {
MgtTemplateProps,
} from '@microsoft/mgt-react/dist/es6/MgtTemplateProps';
import { NoData } from '../noData/NoData';
export const AgendaNoDataTemplate: React.FunctionComponent<MgtTemplateProps> = (props: MgtTemplateProps) => {
return (
<>
<NoData message="No events found">
<CalendarAgenda24Filled primaryFill={tokens.colorNeutralStroke1} style={{ width: 60, height: 60 }} />
</NoData>
</>
);
};

View File

@ -0,0 +1,125 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-function-return-type */
/* eslint-disable @typescript-eslint/no-unused-vars */
import * as React from 'react';
import * as strings from 'DashBoardWebPartStrings';
import {
format,
isSameDay,
parseISO,
} from 'date-fns';
import {
Badge,
Caption1,
Caption1Strong,
Card,
Link,
} from '@fluentui/react-components';
import { PersonCardInteraction } from '@microsoft/mgt';
import {
MgtTemplateProps,
Person,
} from '@microsoft/mgt-react/dist/es6/spfx';
/* import { useCache } from '../../hooks/useLocalStorage';
import { useTimeZoneHelper } from '../../hooks/useTimeZoneHelper'; */
import { useEventStyles } from './useEventStyles';
export interface IEventProps {
event: any;
}
export const Event: React.FunctionComponent<IEventProps> = (props: React.PropsWithChildren<IEventProps>) => {
const { event } = props;
const eventStyles = useEventStyles();
const { end, start, subject, organizer, webLink, importance } = event;
const { emailAddress } = organizer;
const { name, address } = emailAddress || {};
const { dateTime: endDate } = end;
const { dateTime: startDate } = start;
const convertedStartDate = React.useMemo(() => (event.start.timeZone === "UTC" ? `${startDate}Z` : startDate), [
startDate,
event.start.timeZone,
]);
const convertedEndDate = React.useMemo(() => (event.end.timeZone === "UTC" ? `${endDate}Z` : endDate), [
endDate,
event.end.timeZone,
]);
const startHour = React.useMemo(() => format(parseISO(convertedStartDate), "hh:mm aaa"), [convertedStartDate]);
const endHour = React.useMemo(() => format(parseISO(convertedEndDate), "hh:mm aaa"), [convertedEndDate]);
const startDateString = React.useMemo(() => {
return format(parseISO(convertedStartDate), "PPpp");
}, [convertedStartDate]);
const isToday = React.useMemo((): boolean => {
return isSameDay(parseISO(convertedStartDate), new Date());
}, [convertedStartDate]);
const renderDate = React.useMemo(() => {
if (isToday) {
return `${startHour} - ${endHour}`;
}
return startDateString;
}, [startDateString, isToday, startHour, endHour]);
const PersonTemplateLine1 = React.useCallback((props: MgtTemplateProps): JSX.Element => {
const { person } = props.dataContext;
const { displayName } = person;
return <Caption1Strong className={eventStyles.userDisplayName}>{displayName}</Caption1Strong>;
}, []);
const PersonTemplateLine2 = React.useCallback((props: MgtTemplateProps): JSX.Element => {
return name ? <Caption1>{strings.eventOrganizer}</Caption1> : <></>;
}, []);
const importanceBadgeColor = React.useMemo(() => {
switch (importance) {
case "low":
return "informative";
case "normal":
return "brand";
case "high":
return "danger";
default:
return "informative";
}
}, [importance]);
if (!event) return null;
return (
<>
<Card className={eventStyles.card} size="large" appearance="outline">
<header className={eventStyles.cardHeader}>
<Caption1 className={eventStyles.dateTitle}>{renderDate}</Caption1>
<Badge color={importanceBadgeColor} shape="rounded" appearance="tint">
{importance}
</Badge>
</header>
<div>
<Link appearance="subtle" href={webLink} target="_blank">
<Caption1Strong block truncate wrap={false} className={eventStyles.cardTextSubject} title={subject}>
{subject}
</Caption1Strong>
</Link>
<div style={{ width: 40, height: 40 }}> {/* bug with person card on Teams App mobile need to specify with and heigt*/}
<Person
personQuery={address}
showPresence
view={4}
avatarSize="small"
personCardInteraction={PersonCardInteraction.hover}
>
<PersonTemplateLine1 template="line1" />
<PersonTemplateLine2 template="line2" />
</Person>
</div>
</div>
</Card>
</>
);
};

View File

@ -0,0 +1,28 @@
import * as React from 'react';
import {
Badge,
Caption1,
} from '@fluentui/react-components';
import { useImportanceTagsStyles } from './useImportanceTagsStyles';
export interface IImportanceTagsProps {}
export const ImportanceTags: React.FunctionComponent<IImportanceTagsProps> = (
props: React.PropsWithChildren<IImportanceTagsProps>
) => {
const importanceTagsStyles = useImportanceTagsStyles();
return (
<>
<div className={importanceTagsStyles.root}>
<Caption1>Importance</Caption1>
<div className={importanceTagsStyles.badges}>
<Badge color="brand" appearance="tint">Normal</Badge>
<Badge color="danger" appearance="tint">High</Badge>
<Badge color="informative" appearance="tint">Low</Badge>
</div>
</div>
</>
);
};

View File

@ -0,0 +1,30 @@
/* eslint-disable @typescript-eslint/explicit-function-return-type */
/* eslint-disable @typescript-eslint/no-explicit-any */
import * as React from 'react';
import { Agenda } from '@microsoft/mgt-react/dist/es6/spfx';
import { useUtils } from '../../hooks/useUtils';
import { AgendaDefaultTemplate } from './AgendaDefaultTemplate';
import { AgendaLoadingTemplate } from './AgendaLoadingTemplate';
import { AgendaNoDataTemplate } from './AgendaNoDataTemplate';
import { useMgtAgendaStyles } from './useMgtAgendaStyles';
export const MgtAgenda: React.FunctionComponent = () => {
const {getContainerHeight} = useUtils();
const styles = useMgtAgendaStyles();
return (
<>
<div className={styles.root} style={{height: getContainerHeight()}}>
<Agenda days={5} className={styles.agenda}>
<AgendaLoadingTemplate template="loading" />
<AgendaDefaultTemplate template="default" />
<AgendaNoDataTemplate template="no-data" />
</Agenda>
</div>
</>
);
};

View File

@ -0,0 +1,42 @@
import {
makeStyles,
shorthands,
tokens,
} from '@fluentui/react-components';
export const useEventStyles = makeStyles({
card: {
marginRight: "10px",
marginBottom: "10px",
rowGap: "5px",
maxWidth: "100%",
width: "100%",
height: "fit-content",
backgroundColor: tokens.colorNeutralBackground1,
...shorthands.overflow("hidden"),
},
cardHeader:{
display: "flex",
flexDirection: "row",
justifyContent: "space-between",
alignItems: "start",
},
cardBody:{
display: "flex",
flexDirection: "column",
justifyContent: "start",
alignItems: "start",
},
cardTextSubject:{
paddingBottom: "20px",
} ,
userDisplayName:{
color: tokens.colorNeutralForeground2
} ,
dateTitle:{
color: tokens.colorNeutralForeground2,
paddingRight: "10px"
} ,
});

View File

@ -0,0 +1,27 @@
import {
makeStyles,
shorthands,
} from '@fluentui/react-components';
export const useImportanceTagsStyles = makeStyles({
badges: {
display: "flex",
flexDirection: "row",
justifyContent: "start",
alignItems: "center",
rowGap: "10px",
columnGap: "10px",
width: "fit-content",
height: "fit-content",
flexWrap: "wrap",
},
root: {
display: "flex",
flexDirection: "column",
rowGap: "10px",
...shorthands.padding("10px"),
/* position: "absolute",
bottom: "20px", */
}
});

View File

@ -0,0 +1,43 @@
import {
makeStyles,
shorthands,
tokens,
} from '@fluentui/react-components';
export const useMgtAgendaStyles = makeStyles({
root: {
paddingBottom: "20px",
paddingRight: "10px",
width: "100%",
maxWidth: "100%",
overflowY: "auto",
overflowX: "hidden",
/* height: "calc(100vh - 320px)", */
justifyContent: "start",
"::-webkit-scrollbar-thumb": {
...shorthands.borderRadius("10px"),
backgroundColor: tokens.colorNeutralStroke1,
paddingRight: "5px",
},
"::-webkit-scrollbar": {
height: "10PX",
width: "7PX",
},
"scrollbar-width": "thin",
"@media only screen and (max-width: 1024px)": {
height: "600px",
},
},
spinnerStyles: {
display: "flex",
alignItems: "center",
justifyContent: "center",
height: "100%",
},
agenda:{
"--agenda-background-color": "transparent"
}
});

View File

@ -0,0 +1,21 @@
/* eslint-disable @typescript-eslint/explicit-function-return-type */
import * as React from 'react';
import { Todo } from '@microsoft/mgt-react/dist/es6/spfx';
import { useUtils } from '../../hooks/useUtils';
import { useMgtTodoStyles } from './useMgtTodoStyles';
export interface IMgtTodoProps {}
export const MgtTodo: React.FunctionComponent<IMgtTodoProps> = (props: React.PropsWithChildren<IMgtTodoProps>) => {
const styles = useMgtTodoStyles();
const {getContainerHeight} = useUtils();
return (
<>
<div className={styles.root} style={{height: getContainerHeight()}} >
<Todo className={styles.todo}/>
</div>
</>
);
};

View File

@ -0,0 +1,46 @@
import {
makeStyles,
shorthands,
tokens,
} from '@fluentui/react-components';
export const useMgtTodoStyles = makeStyles({
root: {
display: "flex",
flexDirection: "column",
backgroundColor: tokens.colorNeutralBackground1,
...shorthands.overflow("hidden"),
...shorthands.gap("10px"),
paddingLeft: "10px",
paddingRight: "10px",
paddingBottom: "20px",
position: "relative",
width: "100%",
overflowY: "auto",
/* height: "calc(100vh - 160px)", */
justifyContent: "start",
textAlign: "center",
"::-webkit-scrollbar-thumb": {
...shorthands.borderRadius("10px"),
backgroundColor: tokens.colorNeutralBackground4,
},
"::-webkit-scrollbar": {
height: "10PX",
width: "7PX",
},
"scrollbar-width": "thin",
},
todo: {
"--neutral-stroke-input-rest": tokens.colorNeutralForeground2,
"--neutral-fill-input-rest": tokens.colorNeutralBackground4,
"--task-complete-background": tokens.colorNeutralBackground4,
"--neutral-foreground-rest": tokens.colorNeutralForeground1,
"--task-background-color": "transparent",
"--task-complete-background-color": tokens.colorNeutralForeground2,
"--task-background-color-hover": tokens.colorNeutralBackground4,
"--task-box-shadow": "none" ,
"--task-radio-background-color": tokens.colorBrandForeground1
}
});

View File

@ -0,0 +1,64 @@
import * as React from 'react';
import * as strings from 'DashBoardWebPartStrings';
import { Subtitle2 } from '@fluentui/react-components';
import {
bundleIcon,
CalendarAgendaFilled,
CalendarAgendaRegular,
TasksAppFilled,
TasksAppRegular,
} from '@fluentui/react-icons';
import { ITab } from '../../models/ITab';
import { MgtAgenda } from '../mgtAgenda/MgtAgenda';
import { MgtTodo } from '../mgtTodo/mgtTodo';
import { TabMenu } from '../tabMenu/TabMenu';
import { useMyDayStyles } from './useMyDayStyles';
export interface IMyDayProps {}
export const MyDay: React.FunctionComponent<IMyDayProps> = (props: React.PropsWithChildren<IMyDayProps>) => {
const styles = useMyDayStyles();
const CalendarAgenda = bundleIcon(CalendarAgendaFilled, CalendarAgendaRegular);
const TasksApp = bundleIcon(TasksAppFilled, TasksAppRegular);
const [selectedValue, setSelectedValue] = React.useState<string>("tab1");
const onTabSelect = React.useCallback((tabId: string) => {
setSelectedValue(tabId);
}, []);
const tabs: ITab[] = [
{
id: "tab1",
name: strings.Agenda,
icon: <CalendarAgenda />,
},
{
id: "tab2",
name: strings.Todo,
icon: <TasksApp />,
},
];
const renderSelectedTab = React.useCallback(() => {
switch (selectedValue) {
case "tab1":
return <MgtAgenda />;
case "tab2":
return <MgtTodo />
default:
return null;
}
}, [selectedValue]);
return (
<>
<div className={styles.myDayContainer}>
<Subtitle2 className={styles.myDayTitle}>My Day</Subtitle2>
<TabMenu tabs={tabs} selectedTabId={selectedValue} onSelectedTab={onTabSelect} />
{ renderSelectedTab()}
</div>
</>
);
};

View File

@ -0,0 +1,20 @@
import {
makeStyles,
shorthands,
} from '@fluentui/react-components';
export const useMyDayStyles = makeStyles({
myDayContainer: {
width: "100%",
display: "flex",
flexDirection: "column",
justifyContent: "start",
alignContent: "start",
...shorthands.gap("10px", "0px"),
},
myDayTitle: {
paddingLeft: "10px",
paddingTop: "25px",
paddingBottom: "10px",
},
});

View File

@ -0,0 +1,61 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/explicit-function-return-type */
import * as React from 'react';
import * as strings from 'DashBoardWebPartStrings';
import { Subtitle2 } from '@fluentui/react-components';
import {
bundleIcon,
News24Filled,
News24Regular,
} from '@fluentui/react-icons';
import { ITab } from '../../models/ITab';
import { TabMenu } from '../tabMenu/TabMenu';
import { News } from './News';
import { useItemStyles } from './useItemStyles';
export interface IFeedProps {}
export const MyFeed: React.FunctionComponent<IFeedProps> = (props: React.PropsWithChildren<IFeedProps>) => {
const [selectedValue, setSelectedValue] = React.useState<string>("tab1");
const styles = useItemStyles();
const onTabSelect = React.useCallback((tabId: string) => {
setSelectedValue(tabId);
}, []);
const NewsIcon = bundleIcon(News24Filled, News24Regular);
const tabs: ITab[] = [
{
id: "tab1",
name: strings.CompanyAnnoucements,
icon: <NewsIcon />,
}
];
const renderSelectedTab = React.useCallback(() => {
switch (selectedValue) {
case "tab1":
return <News />;
case "tab2":
return <div>Under Constrution</div>
default:
return null;
}
}, [selectedValue]);
return (
<>
<div className={styles.listItemContainer}>
<Subtitle2 className={styles.feedTitle}>Feed</Subtitle2>
<TabMenu tabs={tabs} selectedTabId={selectedValue} onSelectedTab={onTabSelect} />
{ renderSelectedTab()}
</div>
</>
);
};

View File

@ -0,0 +1,69 @@
/* eslint-disable no-unused-expressions */
import * as React from 'react';
import { Spinner } from '@fluentui/react-components';
import {
SearchResults,
} from '@microsoft/mgt-react/dist/es6/generated/react-preview';
import {
MgtTemplateProps,
} from '@microsoft/mgt-react/dist/es6/MgtTemplateProps';
import { useUtils } from '../../hooks/useUtils';
import { RenderItemTemplate } from './RenderItemTemplate';
import { RenderNoDataTemplate } from './RenderNoDataTemplate';
import { useItemStyles } from './useItemStyles';
export interface INewsProps {}
export const News: React.FunctionComponent<INewsProps> = (props: React.PropsWithChildren<INewsProps>) => {
const styles = useItemStyles();
const {getContainerHeight } = useUtils();
const ListItemTemplate = React.useCallback((props: MgtTemplateProps): JSX.Element => {
return <RenderItemTemplate dataContext={props.dataContext} />;
}, []);
const LoadingTemplate = React.useCallback((props: MgtTemplateProps) => {
return (
<div className={styles.spinnerStyles}>
<Spinner size="tiny" />
</div>
);
}, []);
return (
<>
<div className={styles.centerContainer} style={{height: getContainerHeight()}}>
<SearchResults
size={10}
pagingMax={0}
queryString={`PromotedSTate:2 AND contentclass:STS_ListItem_WebPageLibrary AND
(FirstPublishedDate > 1970-01-01 AND FirstPublishedDate < ${new Date().toISOString()})`}
fetchThumbnail={true}
entityTypes={["listItem"]}
fields={[
"id",
"ListItemID",
"FirstPublishedDate",
"description",
"siteId",
"webId",
"path",
"listId",
"parentReference",
"CreatedBy",
"ViewsLifeTime",
"SiteTitle",
"title",
"bannerImageUrlOWSURLH",
]}
>
<LoadingTemplate template="loading" />
<ListItemTemplate template="result-listItem" />
<RenderNoDataTemplate template="no-data" />
</SearchResults>
</div>
</>
);
};

View File

@ -0,0 +1,63 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-floating-promises */
import * as React from 'react';
import {
Caption1Strong,
tokens,
} from '@fluentui/react-components';
import {
Comment20Filled,
ThumbLike20Filled,
} from '@fluentui/react-icons';
import { usePnPjs } from '../../hooks/usePnPjs';
import { ICommentsAndLikes } from '../../models/ICommentsAndLikes';
import { useItemStyles } from './useItemStyles';
export interface IRenderCardFooterProps {
fields: any;
}
export const RenderCardFooter: React.FunctionComponent<IRenderCardFooterProps> = (
props: React.PropsWithChildren<IRenderCardFooterProps>
) => {
const { fields } = props;
const { path, listId, listItemID } = fields || {};
const styles = useItemStyles();
const [commentsAndLikes, setCommentsAndLikes] = React.useState<ICommentsAndLikes>(null);
const { getCommentsAndLikesForPage } = usePnPjs();
React.useEffect(() => {
(async () => {
const commentsAndLikes: ICommentsAndLikes = await getCommentsAndLikesForPage(path, listId, listItemID);
setCommentsAndLikes(commentsAndLikes);
})();
}, [path, listId, listItemID]);
/* const LikesIcon = React.useMemo(() => bundleIcon(ThumbLike20Filled, ThumbLike20Regular), []);
const CommentsIcon = React.useMemo(() =>bundleIcon(Comment20Filled, Comment20Regular), []); */
const iconLikesPrimaryFill = React.useMemo(
() => (commentsAndLikes?.likes ? tokens.colorBrandForeground1 : tokens.colorNeutralStroke1),
[commentsAndLikes?.likes]
);
const iconCommentsPrimaryFill = React.useMemo(
() => (commentsAndLikes?.comments ? tokens.colorBrandForeground1 : tokens.colorNeutralStroke1),
[commentsAndLikes?.comments]
);
return (
<>
<div className={styles.footerContainer}>
<div className={styles.footerIconContainer}>
<ThumbLike20Filled primaryFill={iconLikesPrimaryFill} />
<Caption1Strong>{commentsAndLikes?.likes}</Caption1Strong>
</div>
<div className={styles.footerIconContainer}>
<Comment20Filled primaryFill={iconCommentsPrimaryFill} />{" "}
<Caption1Strong>{commentsAndLikes?.comments}</Caption1Strong>
</div>
</div>
</>
);
};

View File

@ -0,0 +1,98 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-floating-promises */
/* eslint-disable @typescript-eslint/no-unused-vars */
import * as React from 'react';
import {
format,
parseISO,
} from 'date-fns';
import {
Badge,
Body1Strong,
Caption1,
Caption1Strong,
Card,
Divider,
Image,
Link,
tokens,
} from '@fluentui/react-components';
import { PersonCardInteraction } from '@microsoft/mgt';
import {
MgtTemplateProps,
Person,
} from '@microsoft/mgt-react/dist/es6/spfx';
import { RenderCardFooter } from './RenderCardFooter';
import { useItemStyles } from './useItemStyles';
export interface IListItemTemplateProps {
dataContext: any;
}
export const RenderItemTemplate: React.FunctionComponent<IListItemTemplateProps> = (
props: React.PropsWithChildren<IListItemTemplateProps>
) => {
const { resource } = props.dataContext;
const { fields, lastModifiedBy, lastModifiedDateTime, webUrl, thumbnail } = resource;
const { title, description, siteTitle } = fields;
const styles = useItemStyles();
const [imageUrl] = React.useState<string>(thumbnail?.url);
const localeDate = React.useMemo(() => {
return format(parseISO(lastModifiedDateTime), "PPP");
}, [lastModifiedDateTime]);
const PersonTemplateLine1 = React.useCallback(
(props: MgtTemplateProps): JSX.Element => {
const { displayName } = lastModifiedBy.user;
return <Caption1Strong style={{ color: tokens.colorNeutralForeground2 }}>{displayName}</Caption1Strong>;
},
[lastModifiedBy]
);
const PersonTemplateLine2 = React.useCallback(
(props: MgtTemplateProps): JSX.Element => {
return <Caption1 style={{ fontSize: 12 }}>at {localeDate}</Caption1>;
},
[localeDate]
);
return (
<>
<Card className={styles.card} size="large">
<header className={styles.cardHeader}>
<div className={styles.personContainer}>
<Person
personQuery={lastModifiedBy.user.email}
showPresence
view={4}
avatarSize="small"
personCardInteraction={PersonCardInteraction.hover}
>
<PersonTemplateLine1 template="line1" />
<PersonTemplateLine2 template="line2" />
</Person>
</div>
</header>
<div className={styles.badgeContainer}>
<Badge color="brand" shape="rounded" appearance="tint">
{siteTitle}
</Badge>
</div>
<Image fit="cover" src={imageUrl} style={{ height: 100 }} />
<Link appearance="subtle" href={webUrl} target="_blank">
<Body1Strong className={styles.cardTextSubject} title={title}>
{title}
</Body1Strong>
</Link>
<Caption1 className={styles.cardTextDisplay}>{description}</Caption1>
<Divider />
<RenderCardFooter fields={fields} />
</Card>
</>
);
};

View File

@ -0,0 +1,26 @@
import * as React from 'react';
import * as strings from 'DashBoardWebPartStrings';
import { tokens } from '@fluentui/react-components';
import { News28Filled } from '@fluentui/react-icons';
import {
MgtTemplateProps,
} from '@microsoft/mgt-react/dist/es6/MgtTemplateProps';
import { NoData } from '../noData/NoData';
export interface IRenderNoDataTemplateProps {
}
export const RenderNoDataTemplate: React.FunctionComponent<MgtTemplateProps> = (props: MgtTemplateProps) => {
return (
<>
<NoData message={strings.NoNews}>
<News28Filled primaryFill={tokens.colorNeutralStroke1} style={{ width: 60, height: 60 }} />
</NoData>
</>
);
};

View File

@ -0,0 +1,22 @@
/* eslint-disable no-unused-expressions */
import * as React from 'react';
import { Get } from '@microsoft/mgt-react/dist/es6/spfx';
import { useItemStyles } from './useItemStyles';
export interface INewsProps {}
export const TrendingList: React.FunctionComponent<INewsProps> = (props: React.PropsWithChildren<INewsProps>) => {
const styles = useItemStyles();
return (
<>
<div className={styles.centerContainer}>
<Get
resource="/me/insights/trending"
maxPages={1}
/>
</div>
</>
);
};

View File

@ -0,0 +1,21 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import * as React from 'react';
import {
MgtTemplateProps,
} from '@microsoft/mgt-react/dist/es6/MgtTemplateProps';
export const TrendingTempplateDefault: React.FunctionComponent<MgtTemplateProps> = (props: MgtTemplateProps) => {
const { value } = props.dataContext;
return (
<>
{value?.map((item: any, index: number) => {
return (
<>
</>
);
})}
</>
);
};

View File

@ -0,0 +1,144 @@
import {
makeStyles,
shorthands,
tokens,
} from '@fluentui/react-components';
export const useItemStyles = makeStyles({
listItemContainer: {
marginLeft: "5px",
backgroundColor: tokens.colorNeutralStroke3,
width: "100%",
height: "100%",
display: "flex",
flexDirection: "column",
justifyContent: "start",
textAlign: "center",
...shorthands.gap("10px", "0px"),
},
centerContainer: {
paddingBottom: "20px",
backgroundColor: tokens.colorNeutralStroke3,
width: "100%",
overflowY: "auto",
/* height: "calc(100vh - 320px)", */
justifyContent: "center",
textAlign: "center",
"::-webkit-scrollbar-thumb": {
...shorthands.borderRadius("10px"),
backgroundColor: tokens.colorNeutralStroke1,
},
"::-webkit-scrollbar": {
height: "10PX",
width: "7PX",
},
"scrollbar-width": "thin",
"@media only screen and (max-width: 1024px)": {
height: "600px",
},
},
card: {
paddingBottom: "20px",
rowGap: "15px",
height: "fit-content",
backgroundColor: tokens.colorNeutralBackground1,
flexWrap: "wrap",
...shorthands.overflow("hidden"),
...shorthands.padding("20px"),
...shorthands.margin("20px"),
marginTop: "0px",
},
cardHeader: {
display: "flex",
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
},
cardBody: {
display: "flex",
flexDirection: "column",
justifyContent: "start",
alignItems: "start",
},
cardTextSubject: {
width: "100%",
maxWidth: "100%",
...shorthands.overflow("hidden"),
display: "-webkit-box",
"-webkit-line-clamp": "2",
"-webkit-box-orient": "vertical",
paddingBottom: "0px",
textAlign: "start",
},
cardTextDisplay: {
width: "100%",
maxWidth: "100%",
height: "30px",
paddingBottom: "20px",
...shorthands.overflow("hidden"),
display: "-webkit-box",
"-webkit-line-clamp": "3",
"-webkit-box-orient": "vertical",
...shorthands.overflow("hidden"),
textAlign: "start",
},
badgeContainer: {
display: "flex",
flexDirection: "row",
justifyContent: "end",
alignItems: "center",
},
footerContainer: {
display: "flex",
flexDirection: "row",
justifyContent: "start",
alignItems: "center",
...shorthands.gap("25px"),
},
footerIconContainer: {
display: "flex",
flexDirection: "row",
justifyContent: "start",
alignItems: "center",
...shorthands.gap("5px"),
},
feedTitle: {
paddingLeft: "10px",
paddingTop: "25px",
paddingBottom: "10px",
},
personContainer: {
display: "flex",
flexDirection: "column",
justifyContent: "start",
textAlign: "start",
width: "40px",
height: "40px",
},
menu: {
backgroundColor: tokens.colorNeutralBackground1,
},
menuButton: {
alignSelf: "center",
},
spinnerStyles: {
display: "flex",
alignItems: "center",
justifyContent: "center",
...shorthands.margin("auto"),
width: "100%",
...shorthands.gap("20px", "0px"),
},
noData: {
display: "flex",
alignItems: "center",
flexDirection: "column",
justifyContent: "center",
...shorthands.margin("auto"),
width: "100%",
...shorthands.gap("20px", "0px"),
},
});

View File

@ -0,0 +1,12 @@
import * as React from 'react';
import {
MgtTemplateProps,
} from '@microsoft/mgt-react/dist/es6/MgtTemplateProps';
import { RenderFileCard } from './RenderFileCard';
export const FileTemplate: React.FunctionComponent<MgtTemplateProps> = (props: React.PropsWithChildren<MgtTemplateProps>) => {
const { file } = props.dataContext;
return <RenderFileCard file={file} />;
};

View File

@ -0,0 +1,28 @@
import * as React from 'react';
import { FileList } from '@microsoft/mgt-react/dist/es6/spfx';
import { useUtils } from '../../hooks/useUtils';
import { FileTemplate } from './FileTemplate';
import { LoadingTemplate } from './LoadingTemplate';
import { NoDataTemplate } from './NoDataTemplate';
import { useMyFilesStyles } from './useMyFilesStyles';
export interface IFilesProps {}
export const Files: React.FunctionComponent<IFilesProps> = (props: React.PropsWithChildren<IFilesProps>) => {
const styles = useMyFilesStyles();
const { getContainerHeight} = useUtils();
return (
<>
<div className={styles.centerContainer}style={{height: getContainerHeight()}}>
<FileList id="fileList" className={styles.fileList} >
<FileTemplate template="file" />
<LoadingTemplate template="loading" />
<NoDataTemplate template="no-data" />
</FileList>
</div>
</>
);
};

View File

@ -0,0 +1,24 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import * as React from 'react';
import {
MgtTemplateProps,
} from '@microsoft/mgt-react/dist/es6/MgtTemplateProps';
import { RenderFileCard } from './RenderFileCard';
import { useMyFilesStyles } from './useMyFilesStyles';
export const FilesTemplate: React.FunctionComponent<MgtTemplateProps> = (
props: React.PropsWithChildren<MgtTemplateProps>
) => {
const { files } = props.dataContext;
const styles = useMyFilesStyles();
return (
<div className={styles.centerContainer}>
{files?.map((file: any, index: number) => {
// bug workaround
return <RenderFileCard key={index} file={typeof file === "string" ? JSON.parse(file) : file } />;
})}
</div>
);
};

View File

@ -0,0 +1,17 @@
import * as React from 'react';
import { Spinner } from '@fluentui/react-components';
import {
MgtTemplateProps,
} from '@microsoft/mgt-react/dist/es6/MgtTemplateProps';
import { useMyFilesStyles } from './useMyFilesStyles';
export const LoadingTemplate: React.FunctionComponent<MgtTemplateProps> = (props: React.PropsWithChildren<MgtTemplateProps>) => {
const styles = useMyFilesStyles();
return (
<div className={styles.spinnerStyles}>
<Spinner size="tiny" />
</div>
);
};

View File

@ -0,0 +1,78 @@
import * as React from 'react';
import * as strings from 'DashBoardWebPartStrings';
import { Subtitle2 } from '@fluentui/react-components';
import {
bundleIcon,
DocumentBulletList24Filled,
DocumentBulletList24Regular,
DocumentEdit24Filled,
DocumentEdit24Regular,
Share24Filled,
Share24Regular,
} from '@fluentui/react-icons';
import { ITab } from '../../models/ITab';
import { TabMenu } from '../tabMenu/TabMenu';
import { Files } from './Files';
import { Shared } from './Shared';
import { Used } from './Used';
import { useMyFilesStyles } from './useMyFilesStyles';
export interface IMyFilesProps {}
export const MyFiles: React.FunctionComponent<IMyFilesProps> = (props: React.PropsWithChildren<IMyFilesProps>) => {
const styles = useMyFilesStyles();
const [selectedValue, setSelectedValue] = React.useState<string>("tab1");
const FilesIcon = bundleIcon(DocumentBulletList24Filled, DocumentBulletList24Regular);
const SharedIcon = bundleIcon(Share24Filled, Share24Regular);
const UsedIcon = bundleIcon(DocumentEdit24Filled, DocumentEdit24Regular);
const onTabSelect = React.useCallback((tabId: string) => {
setSelectedValue(tabId);
}, []);
const tabs: ITab[] = React.useMemo(
() => [
{
id: "tab1",
name: strings.Files,
icon: <FilesIcon />,
},
{
id: "tab2",
name: strings.Used,
icon: <UsedIcon />,
},
{
id: "tab3",
name: strings.Shared,
icon: <SharedIcon />,
},
],
[]
);
const renderSelectedTab = React.useCallback(() => {
switch (selectedValue) {
case "tab1":
return <Files />;
case "tab2":
return <Used />;
case "tab3":
return <Shared />;
default:
return null;
}
}, [selectedValue]);
return (
<>
<div className={styles.root}>
<Subtitle2 className={styles.filesTitle}>{strings.MyFiles}</Subtitle2>
<TabMenu tabs={tabs} selectedTabId={selectedValue} onSelectedTab={onTabSelect} />
{renderSelectedTab()}
</div>
</>
);
};

View File

@ -0,0 +1,23 @@
import * as React from 'react';
import * as strings from 'DashBoardWebPartStrings';
import { tokens } from '@fluentui/react-components';
import { DocumentBulletListMultiple24Filled } from '@fluentui/react-icons';
import {
MgtTemplateProps,
} from '@microsoft/mgt-react/dist/es6/MgtTemplateProps';
import { NoData } from '../noData/NoData';
export interface IComponentProps {}
export const NoDataTemplate: React.FunctionComponent<MgtTemplateProps> = (props: React.PropsWithChildren<MgtTemplateProps>) => {
return (
<>
<NoData message={strings.NoFiles}>
<DocumentBulletListMultiple24Filled primaryFill={tokens.colorNeutralStroke1} style={{ width: 60, height: 60 }} />
</NoData>
</>
);
};

View File

@ -0,0 +1,102 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import * as React from 'react';
import {
format,
parseISO,
} from 'date-fns';
import {
Caption1,
Caption1Strong,
Card,
CardHeader,
Link,
} from '@fluentui/react-components';
import {
MgtTemplateProps,
} from '@microsoft/mgt-react/dist/es6/MgtTemplateProps';
import { Person } from '@microsoft/mgt-react/dist/es6/spfx';
import { useUtils } from '../../hooks/useUtils';
import { useMyFilesStyles } from './useMyFilesStyles';
export interface IRenderFileCardProps {
file: any;
}
export const RenderFileCard: React.FunctionComponent<IRenderFileCardProps> = (
props: React.PropsWithChildren<IRenderFileCardProps>
) => {
const { file } = props;
const { lastModifiedBy, lastModifiedDateTime, size, name, webUrl } = file;
const { user } = lastModifiedBy;
const { GetFileImageUrl, formatFileSize, getFolderIcon } = useUtils();
const styles = useMyFilesStyles();
const localeDate = React.useMemo(() => {
return format(parseISO(lastModifiedDateTime), "PPP");
}, [lastModifiedDateTime]);
const PersonTemplateLine1 = React.useCallback(
(props: MgtTemplateProps): JSX.Element => {
const { displayName } = user;
return (
<>
<div className={styles.personLine1Container}>
<div className={styles.personLine1}>
<Caption1Strong className={styles.personline1Styles}>{displayName}</Caption1Strong>
<Caption1 className={styles.personline1Styles}>modified file </Caption1>
</div>
</div>
</>
);
},
[lastModifiedBy]
);
const PersonTemplateLine2 = React.useCallback(
(props: MgtTemplateProps): JSX.Element => {
return <Caption1 className={styles.personline2Styles}>at {localeDate}</Caption1>;
},
[localeDate]
);
const isFolder = React.useMemo(() => {
return file?.folder ? true : false;
}, [name]);
return (
<>
<Card className={styles.card} size="large" appearance="subtle">
<header className={styles.cardHeader}>
<div className={styles.personContainer}>
<Person personQuery={user.email} showPresence view={4} avatarSize="small">
<PersonTemplateLine1 template="line1" />
<PersonTemplateLine2 template="line2" />
</Person>
</div>
</header>
<Card style={{ padding: "5px 10px", maxWidth: "100%" }} size="large">
<CardHeader
image={{
className: styles.fileIcon,
as: "img",
src: isFolder ? getFolderIcon() : GetFileImageUrl(name),
alt: name,
}}
header={
<Link appearance="subtle" href={webUrl} target="_blank">
<Caption1Strong className={styles.cardTextSubject} title={name}>
{name}
</Caption1Strong>
</Link>
}
description={<Caption1>{formatFileSize(size as number, 0)}</Caption1>}
/>
</Card>
</Card>
</>
);
};

View File

@ -0,0 +1,23 @@
import * as React from 'react';
import { FileList } from '@microsoft/mgt-react/dist/es6/spfx';
import { FilesTemplate } from './FilesTemplate';
import { LoadingTemplate } from './LoadingTemplate';
import { NoDataTemplate } from './NoDataTemplate';
import { useMyFilesStyles } from './useMyFilesStyles';
export interface ISharedProps {}
export const Shared: React.FunctionComponent<ISharedProps> = (props: React.PropsWithChildren<ISharedProps>) => {
const styles = useMyFilesStyles();
return (
<>
<FileList id="fileListUsed" className={styles.fileList} insightType="shared">
<FilesTemplate template="default" />
<LoadingTemplate template="loading" />
<NoDataTemplate template="no-data" />
</FileList>
</>
);
};

View File

@ -0,0 +1,23 @@
import * as React from 'react';
import { FileList } from '@microsoft/mgt-react/dist/es6/spfx';
import { FilesTemplate } from './FilesTemplate';
import { LoadingTemplate } from './LoadingTemplate';
import { NoDataTemplate } from './NoDataTemplate';
import { useMyFilesStyles } from './useMyFilesStyles';
export interface IUsedProps {}
export const Used: React.FunctionComponent<IUsedProps> = (props: React.PropsWithChildren<IUsedProps>) => {
const styles = useMyFilesStyles();
return (
<>
<FileList id="fileListUsed" className={styles.fileList} insightType="used">
<FilesTemplate template="default" />
<LoadingTemplate template="loading" />
<NoDataTemplate template="no-data" />
</FileList>
</>
);
};

View File

@ -0,0 +1,161 @@
import {
makeStyles,
shorthands,
tokens,
} from '@fluentui/react-components';
export const useMyFilesStyles = makeStyles({
root: {
width: "100%",
display: "flex",
flexDirection: "column",
justifyContent: "start",
...shorthands.gap("10px", "0px"),
},
filesTitle: {
paddingLeft: "10px",
paddingTop: "25px",
paddingBottom: "10px",
},
fileList: {
"--file-list-box-shadow": "none",
"--file-list-border": "none",
"--file-list-background-color": "transparent",
"--file-background-color-hover": "transparent",
"--show-more-button-padding": "0px 10px",
"--show-more-button-background-color": "transparent",
"--show-more-button-background-color--hover:": "transparent",
},
global: {
':global(.show-more)': {
backgroundColor: "transparent",
},
':global(.show-more:hover)': {
backgroundColor: "transparent",
}
},
card: {
maxWidth: "100%",
rowGap: "10px",
paddingBottom: "20px",
height: "fit-content",
backgroundColor: tokens.colorNeutralBackground5Pressed,
flexWrap: "wrap",
...shorthands.overflow("hidden"),
...shorthands.padding("15px"),
...shorthands.margin("10px"),
marginTop: "0px",
},
cardHeader: {
display: "flex",
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
},
cardBody: {
display: "flex",
flexDirection: "column",
justifyContent: "start",
alignItems: "start",
},
cardTextSubject: {
width: "100%",
...shorthands.overflow("hidden"),
display: "-webkit-box",
"-webkit-line-clamp": "1",
"-webkit-box-orient": "vertical",
paddingBottom: "0px",
textAlign: "start",
wordBreak: "break-word",
textOverflow: "ellipsis",
color: tokens.colorBrandForeground1,
},
cardTextDisplay: {
width: "100%",
maxWidth: "100%",
height: "30px",
paddingBottom: "20px",
...shorthands.overflow("hidden"),
display: "-webkit-box",
"-webkit-line-clamp": "3",
"-webkit-box-orient": "vertical",
...shorthands.overflow("hidden"),
textAlign: "start",
textOverflow: "ellipsis",
},
personLine1Container: {
display: "flex",
flexDirection: "row",
justifyContent: "start",
alignItems: "center",
width: "100%",
maxWidth: "100%",
...shorthands.overflow("hidden"),
paddingBottom: "0px",
},
personLine1: {
width: "100%",
maxWidth: "100%",
...shorthands.overflow("hidden"),
display: "-webkit-box",
"-webkit-line-clamp": "1",
"-webkit-box-orient": "vertical",
paddingBottom: "0px",
textAlign: "start",
},
centerContainer: {
paddingBottom: "20px",
width: "100%",
overflowY: "auto",
/* height: "calc(100vh - 320px)", */
justifyContent: "start",
"::-webkit-scrollbar-thumb": {
...shorthands.borderRadius("10px"),
backgroundColor: tokens.colorNeutralStroke1,
paddingRight: "5px",
},
"::-webkit-scrollbar": {
height: "10PX",
width: "7PX",
},
"scrollbar-width": "thin",
"@media only screen and (max-width: 1024px)": {
height: "600px",
},
},
fileIcon: {
width: "30px",
height: "30px",
},
spinnerStyles: {
display: "flex",
alignItems: "center",
justifyContent: "center",
...shorthands.margin("auto"),
width: "100%",
...shorthands.gap("20px", "0px"),
},
personline1Styles: {
paddingRight: "5px",
color: tokens.colorNeutralForeground2
},
personline2Styles: {
fontSize: "12px",
},
trendingCard: {
maxWidth: "100%",
width: "100%",
height: "fit-content",
},
personContainer: {
display: "flex",
flexDirection: "column",
justifyContent: "start",
textAlign: "start",
width: "40px",
height: "40px",
},
});

View File

@ -0,0 +1,25 @@
import * as React from 'react';
import * as strings from 'DashBoardWebPartStrings';
import { Body1 } from '@fluentui/react-components';
import { useNoDataStyles } from './useNoDataStyles';
export interface INoDataProps {
children?: React.ReactNode;
message?: string;
}
export const NoData: React.FunctionComponent<INoDataProps> = (props: React.PropsWithChildren<INoDataProps>) => {
const styles = useNoDataStyles();
const { children, message } = props;
return (
<>
<div className={styles.noData}>
{children}
<Body1>{message ?? strings.NoData}</Body1>
</div>
</>
);
};

View File

@ -0,0 +1,16 @@
import {
makeStyles,
shorthands,
} from '@fluentui/react-components';
export const useNoDataStyles = makeStyles({
noData: {
display: "flex",
alignItems: "center",
flexDirection: "column",
justifyContent: "center",
...shorthands.margin("auto"),
width: "100%",
...shorthands.gap("20px", "0px"),
},
});

View File

@ -0,0 +1,6 @@
import { ITab } from '../../models/ITab';
export interface IOverFlowMenuProps {
onTabSelect?: (tabId: string) => void;
tabdata: ITab[];
}

View File

@ -0,0 +1,6 @@
import { ITab } from '../../models/ITab';
export interface OverflowMenuItemProps {
tab: ITab;
onClick: React.MouseEventHandler;
}

View File

@ -0,0 +1,55 @@
import * as React from 'react';
import {
Button,
Menu,
MenuList,
MenuPopover,
MenuTrigger,
useOverflowMenu,
} from '@fluentui/react-components';
import {
bundleIcon,
MoreHorizontalFilled,
MoreHorizontalRegular,
} from '@fluentui/react-icons';
import { IOverFlowMenuProps } from './IOverFLowMenuProps';
import { OverflowMenuItem } from './OverflowMenuItem';
import { useOverflowMenuStyles } from './useOverflowMenuStyles';
export const OverflowMenu: React.FunctionComponent<IOverFlowMenuProps> = (props: React.PropsWithChildren<IOverFlowMenuProps>) => {
const { onTabSelect, tabdata } = props;
const { ref, isOverflowing, overflowCount } = useOverflowMenu<HTMLButtonElement>();
const styles = useOverflowMenuStyles();
const MoreHorizontal = React.useMemo(() => bundleIcon(MoreHorizontalFilled, MoreHorizontalRegular), []);
const onItemClick = (tabId: string):void => {
onTabSelect?.(tabId);
};
if (!isOverflowing) {
return null;
}
return (
<Menu hasIcons>
<MenuTrigger disableButtonEnhancement>
<Button
appearance="transparent"
className={styles.menuButton}
ref={ref}
icon={<MoreHorizontal />}
aria-label={`${overflowCount} more tabs`}
role="tab"
/>
</MenuTrigger>
<MenuPopover>
<MenuList className={styles.menu}>
{tabdata.map((tab) => (
<OverflowMenuItem key={tab.id} tab={tab} onClick={() => onItemClick(tab.id)} />
))}
</MenuList>
</MenuPopover>
</Menu>
);
};

View File

@ -0,0 +1,23 @@
import * as React from 'react';
import {
MenuItem,
useIsOverflowItemVisible,
} from '@fluentui/react-components';
import { OverflowMenuItemProps } from './IOverFlowMenuItemProps';
export const OverflowMenuItem: React.FunctionComponent<OverflowMenuItemProps> = (props: React.PropsWithChildren<OverflowMenuItemProps>) => {
const { tab, onClick } = props;
const isVisible = useIsOverflowItemVisible(tab.id);
if (isVisible) {
return null;
}
return (
<MenuItem key={tab.id} icon={tab.icon} onClick={onClick}>
<div>{tab.name}</div>
</MenuItem>
);
};

View File

@ -0,0 +1,13 @@
import {
makeStyles,
tokens,
} from '@fluentui/react-components';
export const useOverflowMenuStyles = makeStyles({
menu: {
backgroundColor: tokens.colorNeutralBackground1,
},
menuButton: {
alignSelf: "center",
},
});

View File

@ -0,0 +1,64 @@
import * as React from 'react';
import * as strings from 'DashBoardWebPartStrings';
import { Subtitle2 } from '@fluentui/react-components';
import {
bundleIcon,
People24Filled,
People24Regular,
} from '@fluentui/react-icons';
import { ITab } from '../../models/ITab';
import { TabMenu } from '../tabMenu/TabMenu';
import { RelevantPeopleList } from './RelevantPeopleList';
import { usePeopleStyles } from './usePeopleStyles';
export interface IPeopleProps {}
export const People: React.FunctionComponent<IPeopleProps> = (props: React.PropsWithChildren<IPeopleProps>) => {
const [selectedValue, setSelectedValue] = React.useState<string>("tab1");
const styles = usePeopleStyles();
const RevelantIcon = bundleIcon(People24Filled, People24Regular);
const onTabSelect = React.useCallback((tabId: string) => {
setSelectedValue(tabId);
}, []);
const tabs: ITab[] = [
{
id: "tab1",
name: strings.Relevant,
icon: <RevelantIcon />,
},
/* {
id: "tab2",
name: "Recente",
icon: <RecentPeople />,
}, */
];
const renderSelectedTab = React.useCallback(() => {
switch (selectedValue) {
case "tab1":
return <div><RelevantPeopleList/></div>;
/* case "tab2":
return <div><RecentPeopleList /> </div>; */
default:
return null;
}
}, [selectedValue]);
return (
<>
<div id="main-container" className={styles.peopleContainer}>
<Subtitle2 className={styles.peopleTitle}>People</Subtitle2>
<TabMenu tabs={tabs} selectedTabId={selectedValue} onSelectedTab={onTabSelect} />
{renderSelectedTab()}
</div>
</>
);
};

View File

@ -0,0 +1,86 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-unused-vars */
import * as React from 'react';
import {
Caption1,
Caption1Strong,
Card,
Divider,
} from '@fluentui/react-components';
import {
PersonCardInteraction,
ViewType,
} from '@microsoft/mgt';
import { Person } from '@microsoft/mgt-react/dist/es6/spfx';
import { EPeopleType } from '../../constants/EPeopleType';
import {
RenderAttributesForRelevantPeople,
} from './RenderAtrributesForRelevantPeople';
import { usePeopleStyles } from './usePeopleStyles';
export interface IPeopleCardProps {
user: any;
peopleType: EPeopleType;
}
export const PeopleCard: React.FunctionComponent<IPeopleCardProps> = (
props: React.PropsWithChildren<IPeopleCardProps>
) => {
const { user, peopleType } = props;
const { userPrincipalName, displayName, jobTitle } = user;
const styles = usePeopleStyles();
const onClickEmail = React.useCallback((ev: React.MouseEvent<HTMLElement>) => {
window.open(`mailto:${userPrincipalName}`, "_blank");
}, []);
return (
<>
<Card className={styles.card} size="large" appearance="outline">
<div className={styles.personContainer}>
<div style={{ width: 56, height: 56 }}> {/* bug with person card on Teams App mobile need to specify with and heigt*/}
<Person
personQuery={user.userPrincipalName}
showPresence
view={ViewType.image}
avatarSize="large"
personCardInteraction={PersonCardInteraction.hover}
/>
</div>
<div className={styles.personInfoContainer}>
<div className={styles.cardTextSubject}>
<Caption1>
<Caption1Strong block truncate wrap={false} title={displayName}>
{displayName}
</Caption1Strong>
</Caption1>
</div>
<div className={styles.cardTextSubject}>
<Caption1 style={{ fontSize: 12 }}>
{jobTitle}
</Caption1>
</div>
<div className={styles.cardTextSubject}>
<Caption1
style={{ fontSize: 12 }}
onClick={onClickEmail}
className={styles.hover}
>
{userPrincipalName}
</Caption1>
</div>
</div>
</div>
<Divider />
<div className={styles.cardBody}>
{peopleType === EPeopleType.Relevant && <RenderAttributesForRelevantPeople user={user} />}
</div>
</Card>
</>
);
};

View File

@ -0,0 +1,85 @@
import * as React from 'react';
import {
Badge,
Caption1,
mergeClasses,
} from '@fluentui/react-components';
import { IAttribute } from '../../models/IAttribute';
import { usePeopleStyles } from './usePeopleStyles';
export interface IPeopleAttributeProps {
attribute: IAttribute;
}
export const PeopleCardAttribute: React.FunctionComponent<IPeopleAttributeProps> = (
props: React.PropsWithChildren<IPeopleAttributeProps>
) => {
const { attribute } = props;
const { icon, attributeValue, attributelink } = attribute;
const styles = usePeopleStyles();
if (!attribute) {
return null;
}
const renderValue = React.useMemo(() => {
if (React.isValidElement(attribute.attributeValue)) {
return attributeValue;
}
return (
<div className={styles.cardTextSubject}>
<Caption1 block truncate wrap={false}>
{attributeValue}
</Caption1>
</div>
);
}, [attributeValue]);
const renderValueWithIcon = React.useMemo(() => {
if (icon) {
return (
<>
{icon}
{renderValue}
</>
);
}
return renderValue;
}, [icon, renderValue]);
const renderAttribute = React.useMemo(() => {
if (icon) {
return <>{renderValueWithIcon}</>;
} else {
return renderValue;
}
}, [attributelink, icon, renderValueWithIcon]);
const onClickBadge = React.useCallback(
(ev: React.MouseEvent<HTMLElement>) => {
if (attributelink) {
window.open(attributelink, "_blank");
}
},
[attributelink]
);
return (
<>
<div className={styles.attributeContainer}>
<Badge
className={mergeClasses(styles.attributeBadge, attributelink ? styles.hover : "")}
as="div"
appearance="outline"
size="large"
onClick={onClickBadge}
>
<div className={mergeClasses(styles.attributeLabel)}>{renderAttribute}</div>
</Badge>
</div>
</>
);
};

View File

@ -0,0 +1,23 @@
import * as React from 'react';
import * as strings from 'DashBoardWebPartStrings';
import { tokens } from '@fluentui/react-components';
import { PeopleCommunity24Filled } from '@fluentui/react-icons';
import {
MgtTemplateProps,
} from '@microsoft/mgt-react/dist/es6/MgtTemplateProps';
import { NoData } from '../noData/NoData';
export interface IPeopleNoDataTemplateProps {}
export const PeopleNoDataTemplate: React.FunctionComponent<MgtTemplateProps> = (props: MgtTemplateProps) => {
return (
<>
<NoData message={strings.NoPeople}>
<PeopleCommunity24Filled primaryFill={tokens.colorNeutralStroke1} style={{ width: 60, height: 60 }} />
</NoData>
</>
);
};

View File

@ -0,0 +1,24 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import * as React from 'react';
import {
MgtTemplateProps,
} from '@microsoft/mgt-react/dist/es6/MgtTemplateProps';
import { EPeopleType } from '../../constants/EPeopleType';
import { PeopleCard } from './PeopleCard';
export const PeopleTemplateRelevant: React.FunctionComponent<MgtTemplateProps> = (props: MgtTemplateProps) => {
const { value } = props.dataContext;
return (
<>
{value?.map((people: any, index: number) => {
return (
<>
<PeopleCard key={index} user={people} peopleType={EPeopleType.Relevant} />
</>
);
})}
</>
);
};

View File

@ -0,0 +1,30 @@
import * as React from 'react';
import { Get } from '@microsoft/mgt-react/dist/es6/spfx';
import { useUtils } from '../../hooks/useUtils';
import { PeopleNoDataTemplate } from './PeopleNoDataTemplate';
import { PeopleTemplateRelevant } from './PeopleTemplateRelevant';
import { usePeopleStyles } from './usePeopleStyles';
export interface IRelevantPeopleListProps {}
export const RelevantPeopleList: React.FunctionComponent<IRelevantPeopleListProps> = (
props: React.PropsWithChildren<IRelevantPeopleListProps>
) => {
const styles = usePeopleStyles();
const { getContainerHeight} = useUtils();
return (
<>
<div id="right-container-relevant" className={styles.rightContainer} style={{ height: getContainerHeight() }}>
<Get
resource="/me/people/?$filter=personType/class eq 'Person' and personType/subclass eq 'OrganizationUser'"
maxPages={1}
>
<PeopleTemplateRelevant template="default" />
<PeopleNoDataTemplate template="no-data" />
</Get>
</div>
</>
);
};

View File

@ -0,0 +1,43 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import * as React from 'react';
import {
Mail20Filled,
MyLocation24Filled,
Phone20Filled,
} from '@fluentui/react-icons';
import { PeopleCardAttribute } from './PeopleCardAttribute';
export interface IRenderAttributesForRelevantPeopleProps {
user: any;
}
export const RenderAttributesForRelevantPeople: React.FunctionComponent<IRenderAttributesForRelevantPeopleProps> = (
props: React.PropsWithChildren<IRenderAttributesForRelevantPeopleProps>
) => {
const { user } = props || {};
const { phones, department, officeLocation, userPrincipalName } = user;
if (!user) return null;
return (
<>
{(phones as any[]).length && (
<PeopleCardAttribute attribute={{ icon: <Phone20Filled />, attributeValue: phones[0].number }} />
)}
{userPrincipalName && (
<PeopleCardAttribute
attribute={{
icon: <Mail20Filled />,
attributeValue: userPrincipalName,
attributelink: `mailto:${userPrincipalName}`,
}}
/>
)}
{officeLocation && (
<PeopleCardAttribute attribute={{ icon: <MyLocation24Filled />, attributeValue: officeLocation }} />
)}
{department && <PeopleCardAttribute attribute={{ attributeValue: department }} />}
</>
);
};

View File

@ -0,0 +1,21 @@
import {
makeStyles,
shorthands,
} from '@fluentui/react-components';
export const useMyPeopleStyles = makeStyles({
myPeopleContainer: {
width: "100%",
height: "calc(100vh - 250px)",
display: "flex",
flexDirection: "column",
justifyContent: "start",
alignContent: "start",
...shorthands.gap("10px", "0px"),
},
myPeopleTitle: {
paddingLeft: "10px",
paddingTop: "25px",
paddingBottom: "10px",
},
});

View File

@ -0,0 +1,150 @@
import {
makeStyles,
shorthands,
tokens,
} from '@fluentui/react-components';
export const usePeopleStyles = makeStyles({
peopleContainer: {
display: "flex",
flexDirection: "column",
justifyContent: "start",
alignContent: "start",
...shorthands.gap("10px", "0px"),
},
peopleTitle: {
paddingLeft: "10px",
paddingTop: "25px",
paddingBottom: "10px",
},
rightContainer: {
display: "flex",
flexDirection: "column",
backgroundColor: tokens.colorNeutralBackground1,
...shorthands.overflow("hidden"),
...shorthands.gap("10px"),
paddingLeft: "10px",
paddingRight: "10px",
paddingBottom: "20px",
/* height: "calc(100vh - 150px)", */
overflowY: "auto",
justifyContent: "start",
"::-webkit-scrollbar-thumb": {
...shorthands.borderRadius("10px"),
backgroundColor: tokens.colorNeutralStroke1,
},
"::-webkit-scrollbar": {
height: "10PX",
width: "7PX",
},
"scrollbar-width": "thin",
"@media only screen and (max-width: 1024px)": {
height: "600px",
},
},
card: {
...shorthands.padding("10px"),
rowGap: "5px",
maxWidth: "100%",
marginRight: "20px",
marginBottom: "10px",
height: "fit-content",
width: "100%",
backgroundColor: tokens.colorNeutralBackground1,
...shorthands.overflow("hidden"),
},
cardHeader: {
display: "flex",
flexDirection: "row",
justifyContent: "space-between",
alignItems: "start",
},
cardBody: {
display: "flex",
flexDirection: "column",
justifyContent: "start",
alignItems: "start",
...shorthands.gap("5px"),
paddingTop: "10px",
paddingBottom: "10px",
},
cardTextSubject: {
width: "100%",
maxWidth: "100%",
minWidth: "0px",
...shorthands.overflow("hidden"),
display: "-webkit-box",
"-webkit-line-clamp": "1",
"-webkit-box-orient": "vertical",
paddingBottom: "0px",
textAlign: "start",
wordBreak: "break-word",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
},
personContainer: {
display: "flex",
flexDirection: "row",
justifyContent: "start",
alignItems: "start",
maxWidth: "100%",
...shorthands.overflow("hidden"),
...shorthands.padding("10px"),
...shorthands.gap("10px"),
backgroundColor: tokens.colorNeutralBackground2,
},
personInfoContainer: {
display: "flex",
flexDirection: "column",
justifyContent: "start",
alignItems: "start",
width: "100%",
maxWidth: "100%",
...shorthands.overflow("hidden"),
paddingBottom: "0px",
...shorthands.gap("0px"),
},
attributeContainer: {
display: "flex",
flexDirection: "row",
flexWrap: "wrap",
justifyContent: "start",
alignItems: "start",
width: "100%",
},
attributeLabel: {
display: "flex",
flexDirection: "row",
justifyContent: "start",
alignItems: "center",
...shorthands.gap("10px"),
paddingBottom: "10px",
paddingTop: "10px",
paddingLeft: "10px",
paddingRight: "10px",
...shorthands.overflow("hidden"),
minWidth: "0px",
},
attributeText: {
display: "-webkit-box",
"-webkit-line-clamp": "1",
"-webkit-box-orient": "vertical",
wordBreak: "break-word",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
textAlign: "center",
},
hover: {
":hover": {
textDecorationLine: "underline",
cursor: "pointer",
},
},
attributeBadge: {
width: "100%",
minWidth: 0,
},
});

View File

@ -0,0 +1,17 @@
import * as React from 'react';
import { useRightStyles } from './useRightStyles';
export interface ILeftProps {
children?: React.ReactNode;
}
export const Right: React.FunctionComponent<ILeftProps> = (props: React.PropsWithChildren<ILeftProps>) => {
const rightStyles = useRightStyles();
const { children } = props;
return (
<>
<div className={rightStyles.root}>{children}</div>
</>
);
};

View File

@ -0,0 +1,15 @@
import {
makeStyles,
shorthands,
tokens,
} from '@fluentui/react-components';
export const useRightStyles = makeStyles({
root: {
minWidth: "220px",
borderRightColor: tokens.colorNeutralStroke3,
...shorthands.gridArea("right"),
},
});

View File

@ -0,0 +1,7 @@
import { ITab } from '../../models/ITab';
export interface ITabMenuProps {
tabs: ITab[];
selectedTabId: string | undefined;
onSelectedTab : (tabId: string) => void;
}

View File

@ -0,0 +1,51 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/explicit-function-return-type */
import * as React from 'react';
import {
Overflow,
OverflowItem,
Tab,
TabList,
TabValue,
} from '@fluentui/react-components';
import { OverflowMenu } from '../overflowMenu/OverflowMenu';
import { ITabMenuProps } from './ITabMenuProps';
export const TabMenu: React.FunctionComponent<ITabMenuProps> = (props: React.PropsWithChildren<ITabMenuProps>) => {
const { onSelectedTab, tabs, selectedTabId } = props;
const [selectedValue, setSelectedValue] = React.useState<TabValue>(selectedTabId);
const onTabSelect = React.useCallback(
(tabId: string) => {
setSelectedValue(tabId);
if (onSelectedTab) {
onSelectedTab(tabId);
}
},
[onSelectedTab]
);
return (
<>
<Overflow minimumVisible={1}>
<TabList
defaultSelectedValue="tab1"
onTabSelect={(_, d) => onTabSelect(d.value as string)}
style={{ paddingBottom: 20 }}
>
{tabs.map((tab) => {
return (
<OverflowItem key={tab.id} id={tab.id} priority={tab.id === selectedValue ? 2 : 1}>
<Tab value={tab.id} icon={<span>{tab.icon}</span>}>
{tab.name}
</Tab>
</OverflowItem>
);
})}
<OverflowMenu onTabSelect={onTabSelect} tabdata={tabs} />
</TabList>
</Overflow>
</>
);
};

View File

@ -0,0 +1,4 @@
export enum EPeopleType {
Recent = 0,
Relevant = 1,
}

View File

@ -0,0 +1,7 @@
export const DATA_IMAGE = "data:image";
export const JPG_IMAGE_TYPE = "image/jpeg";
export const PNG_IMAGE_TYPE = "image/png";
export const MS_TEAMS_IMAGE_WIDTH = 250;
export const HEIGHT_ON_SPSITE = "calc(100vh - 400px)"; // height when not in Teams
export const HEIGHT_ON_TEAMS = "calc(100vh - 200px)"; // height when in Teams
export const HEIGHT_ON_OFFICE = "calc(100vh - 142px)"; // height when in Office

View File

@ -0,0 +1,40 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import addSeconds from 'date-fns/addSeconds';
import isAfter from 'date-fns/isAfter';
/* eslint-disable @typescript-eslint/explicit-function-return-type */
interface IStorage {
value: unknown;
expires?: Date;
}
const DEFAULT_EXPIRED_IN_SECONDS = 60 * 30; // 30 min
export const useCache = (cacheType: "local" | "session") => {
const setCacheValue = (key: string, newValue: unknown, expiredInSeconds?: number) => {
const expires = addSeconds(new Date(), expiredInSeconds ?? DEFAULT_EXPIRED_IN_SECONDS);
if (cacheType === "session") {
sessionStorage.setItem(key, JSON.stringify({ value: newValue, expires }));
} else {
localStorage.setItem(key, JSON.stringify({ value: newValue, expires }));
}
};
const getCacheValue = (key: string): any => {
let storage: IStorage = {} as IStorage;
if (cacheType === "session") {
storage = JSON.parse(sessionStorage.getItem(key) || "{}");
} else {
storage = JSON.parse(localStorage.getItem(key) || "{}");
}
// getting stored value
const { value, expires } = storage || ({} as IStorage);
if (isAfter(new Date(expires), new Date())) {
return value;
}
return undefined;
};
return { getCacheValue, setCacheValue };
};

View File

@ -0,0 +1,102 @@
import '@pnp/sp/lists';
import '@pnp/sp/sites';
import '@pnp/sp/files';
import '@pnp/sp/files/web';
import { useCallback } from 'react';
/* eslint-disable @typescript-eslint/explicit-function-return-type */
import { SPFI } from '@pnp/sp';
import { IRenderListDataParameters } from '@pnp/sp/lists';
import { Web } from '@pnp/sp/webs';
import { ICommentsAndLikes } from '../models/ICommentsAndLikes';
import { FileInfo } from '../models/IFileInfo';
import { getSP } from '../pnpjs/pnpjsConfig';
import { useUtils } from './useUtils';
/* eslint-disable no-useless-escape */
export const usePnPjs = () => {
const sp: SPFI = getSP();
const { trimBeginDoubleSlash } = useUtils();
const getCommentsAndLikesForPage = useCallback(
async (pageUrl: string, listId: string, itemId: string): Promise<ICommentsAndLikes> => {
try {
const webUrl = pageUrl.split("/SitePages")[0];
// bug error when title has "'" character disbale PnPJs getWebUrlFromPageUrl
/* const webUrl: string = await sp.site.getWebUrlFromPageUrl(encodeURI(pageUrl)); */
const spWebNews = Web([sp.web, webUrl]);
const list = spWebNews.lists.getById(listId);
const renderListDataParams: IRenderListDataParameters = {
ViewXml: `<View><ViewFields><FieldRef Name=\"_LikeCount\" /><FieldRef Name=\"_CommentCount\" /></ViewFields><Query><Where><Eq><FieldRef Name=\"ID\"/><Value Type=\"Number\">${itemId}</Value></Eq></Where></Query><RowLimit /></View>`,
};
const rs = await list.renderListDataAsStream(renderListDataParams);
return { comments: rs.Row[0]._CommentCount.toString(), likes: rs.Row[0]._LikeCount.toString() };
} catch (error) {
throw new Error(`Something went wrong when retriving Comments and Likes Url='${pageUrl}`);
return { comments: undefined, likes: undefined };
}
},
[sp]
);
const getSPSiteAbsoluteUrl = useCallback((absolutefileUrl: string): string => {
const hostname = window.location.hostname;
const rootSiteUrl = `https://${hostname}`;
if (
absolutefileUrl.indexOf(`${rootSiteUrl}/sites/`) > -1 ||
absolutefileUrl.indexOf(`${rootSiteUrl}/teams/`) > -1
) {
const fileServerRelativeUrl = absolutefileUrl.split(hostname)[1];
// Split server relative URL by '/' to obtain web name
const webName = fileServerRelativeUrl.split("/")[2];
let webAbsoluteUrl = `https://${hostname}/sites/${webName}`;
if (absolutefileUrl.indexOf(`${rootSiteUrl}/teams/`) > -1) {
webAbsoluteUrl = `https://${hostname}/teams/${webName}`;
}
return webAbsoluteUrl;
}
return rootSiteUrl;
}, []);
const getFileServerRelativeUrl = useCallback((absoluteFileUrl: string): string => {
let fileServerRelativeUrl = absoluteFileUrl.split(window.location.hostname)[1];
fileServerRelativeUrl = trimBeginDoubleSlash(fileServerRelativeUrl);
return fileServerRelativeUrl;
}, []);
const getSPFileInfo = useCallback(async (absoluteFileUrl: string): Promise<FileInfo> => {
// Parse URL to obtain proper web URL
try {
const remoteWebAbsoluteUrl = getSPSiteAbsoluteUrl(absoluteFileUrl);
const fileServerRelativeUrl = getFileServerRelativeUrl(absoluteFileUrl);
const spWeb = Web([sp.web, remoteWebAbsoluteUrl]);
const fileInfoResult = spWeb.getFileByServerRelativePath(fileServerRelativeUrl).select("UniqueId", "ListId", "WebId", "SiteId");
/* const apiUrl = `${remoteWebAbsoluteUrl}/_api/web/getFileByServerRelativeUrl('${fileServerRelativeUrl}')?$select=UniqueId,ListId,WebId,SiteId`;
const fileInfoResult = await spHttpClient.get(apiUrl, SPHttpClient.configurations.v1); */
if (!fileInfoResult ) {
throw new Error(`Something went wrong when retriving file info. Url='${absoluteFileUrl}`);
}
const fileInfoData = await fileInfoResult();
const result: FileInfo = {
Id: fileInfoData.UniqueId,
ListId: fileInfoData.ListId,
WebId: fileInfoData.WebId,
ServerRelativeUrl: fileServerRelativeUrl,
AbsoluteFileUrl: absoluteFileUrl,
SiteId: fileInfoData.SiteId,
};
return result;
} catch (err) {
console.error(`[getFileInfo.getFileInfo]: Err='${err.message}'`);
return null;
}
}, []);
return {getCommentsAndLikesForPage,getSPFileInfo };
};

View File

@ -0,0 +1,218 @@
/* eslint-disable @typescript-eslint/explicit-function-return-type */
import * as React from 'react';
import { useAtom } from 'jotai';
import { appStateAtom } from '../atoms/appStateAtom';
import {
HEIGHT_ON_OFFICE,
HEIGHT_ON_SPSITE,
HEIGHT_ON_TEAMS,
} from '../constants/constants';
import { EAppHostName } from '../models/EAppHostName';
export const DOCICONURL_XLSX = "https://static2.sharepointonline.com/files/fabric/assets/item-types/96/xlsx.png";
export const DOCICONURL_DOCX = "https://static2.sharepointonline.com/files/fabric/assets/item-types/96/docx.png";
export const DOCICONURL_PPTX = "https://static2.sharepointonline.com/files/fabric/assets/item-types/96/pptx.png";
export const DOCICONURL_MPPX = "https://static2.sharepointonline.com/files/fabric/assets/item-types/96/mpp.png";
export const DOCICONURL_PHOTO = "https://static2.sharepointonline.com/files/fabric/assets/item-types/96/photo.png";
export const DOCICONURL_PDF = "https://static2.sharepointonline.com/files/fabric/assets/item-types/96/pdf.png";
export const DOCICONURL_TXT = "https://static2.sharepointonline.com/files/fabric/assets/item-types/96/txt.png";
export const DOCICONURL_EMAIL = "https://static2.sharepointonline.com/files/fabric/assets/item-types/96/email.png";
export const DOCICONURL_CSV = "https://static2.sharepointonline.com/files/fabric/assets/item-types/96/csv.png";
export const DOCICONURL_ONE = "https://static2.sharepointonline.com/files/fabric/assets/item-types/96/one.png";
export const DOCICONURL_VSDX = "https://static2.sharepointonline.com/files/fabric/assets/item-types/96/vsdx.png";
export const DOCICONURL_VSSX = "https://static2.sharepointonline.com/files/fabric/assets/item-types/96/vssx.png";
export const DOCICONURL_PUB = "https://static2.sharepointonline.com/files/fabric/assets/item-types/96/pub.png";
export const DOCICONURL_ACCDB = "https://static2.sharepointonline.com/files/fabric/assets/item-types/96/accdb.png";
export const DOCICONURL_ZIP = "https://static2.sharepointonline.com/files/fabric/assets/item-types/96/zip.png";
export const DOCICONURL_GENERIC =
"https://static2.sharepointonline.com/files/fabric/assets/item-types/96/genericfile.png";
export const DOCICONURL_CODE = "https://static2.sharepointonline.com/files/fabric/assets/item-types/96/code.png";
export const DOCICONURL_HTML = "https://static2.sharepointonline.com/files/fabric/assets/item-types/96/html.png";
export const DOCICONURL_XML = "https://static2.sharepointonline.com/files/fabric/assets/item-types/96/xml.png";
export const DOCICONURL_SPO = "https://static2.sharepointonline.com/files/fabric/assets/item-types/96/spo.png";
export const DOCICONURL_VIDEO = "https://static2.sharepointonline.com/files/fabric/assets/item-types/96/video.png";
export const DOCICONURL_AUDIO = "https://static2.sharepointonline.com/files/fabric/assets/item-types/96/audio.png";
export const DOCICONURL_FOLDER = "https://static2.sharepointonline.com/files/fabric/assets/item-types/96/folder.png";
export const useUtils = () => {
const [appGlobalState] = useAtom(appStateAtom);
const {hasTeamsContext, appHostName} = appGlobalState;
const isInTeams = React.useMemo(() => {
return hasTeamsContext;
}, [hasTeamsContext]);
const getContainerHeight = React.useCallback( () => {
if (isInTeams) {
return appHostName === EAppHostName.Office ? HEIGHT_ON_OFFICE : HEIGHT_ON_TEAMS
}
return HEIGHT_ON_SPSITE
}, [isInTeams]);
/**
* GetFileImageUrl
*/
const GetFileImageUrl = (file: string): string => {
let _fileImageUrl: string = DOCICONURL_GENERIC;
const i = file.lastIndexOf(".");
const _fileTypes = i > -1 ? file.substring(i + 1, file.length) : "";
const _fileExtension = _fileTypes.toLowerCase();
if (!_fileExtension) {
return _fileImageUrl;
}
switch (_fileExtension.toLowerCase()) {
case "xlsx":
_fileImageUrl = DOCICONURL_XLSX;
break;
case "xls":
_fileImageUrl = DOCICONURL_XLSX;
break;
case "docx":
_fileImageUrl = DOCICONURL_DOCX;
break;
case "doc":
_fileImageUrl = DOCICONURL_DOCX;
break;
case "pptx":
_fileImageUrl = DOCICONURL_PPTX;
break;
case "ppt":
_fileImageUrl = DOCICONURL_PPTX;
break;
case "mppx":
_fileImageUrl = DOCICONURL_MPPX;
break;
case "mpp":
_fileImageUrl = DOCICONURL_MPPX;
break;
case "csv":
_fileImageUrl = DOCICONURL_CSV;
break;
case "pdf":
_fileImageUrl = DOCICONURL_PDF;
break;
case "txt":
_fileImageUrl = DOCICONURL_TXT;
break;
case "jpg":
_fileImageUrl = DOCICONURL_PHOTO;
break;
case "msg":
_fileImageUrl = DOCICONURL_EMAIL;
break;
case "jpeg":
_fileImageUrl = DOCICONURL_PHOTO;
break;
case "png":
_fileImageUrl = DOCICONURL_PHOTO;
break;
case "ico":
_fileImageUrl = DOCICONURL_PHOTO;
break;
case "gif":
_fileImageUrl = DOCICONURL_PHOTO;
break;
case "heic":
_fileImageUrl = DOCICONURL_PHOTO;
break;
case "tiff":
_fileImageUrl = DOCICONURL_PHOTO;
break;
case "eml":
_fileImageUrl = DOCICONURL_EMAIL;
break;
case "pub":
_fileImageUrl = DOCICONURL_PUB;
break;
case "accdb":
_fileImageUrl = DOCICONURL_ACCDB;
break;
case "zip":
_fileImageUrl = DOCICONURL_ZIP;
break;
case "7z":
_fileImageUrl = DOCICONURL_ZIP;
break;
case "tar":
_fileImageUrl = DOCICONURL_ZIP;
break;
case "js":
_fileImageUrl = DOCICONURL_CODE;
break;
case "json":
_fileImageUrl = DOCICONURL_CODE;
break;
case "html":
_fileImageUrl = DOCICONURL_HTML;
break;
case "xml":
_fileImageUrl = DOCICONURL_XML;
break;
case "aspx":
_fileImageUrl = DOCICONURL_SPO;
break;
case "mp4":
_fileImageUrl = DOCICONURL_VIDEO;
break;
case "mov":
_fileImageUrl = DOCICONURL_VIDEO;
break;
case "wmv":
_fileImageUrl = DOCICONURL_VIDEO;
break;
case "ogg":
_fileImageUrl = DOCICONURL_VIDEO;
break;
case "webm":
_fileImageUrl = DOCICONURL_VIDEO;
break;
default:
_fileImageUrl = DOCICONURL_GENERIC;
break;
}
return _fileImageUrl;
};
const getShortName = (name: string): string => {
if (!name) return "";
const splitedName = name.split(".");
const displayCreatedFileName = splitedName[0].substring(0, 25);
const displayCreatedFileNameExt = splitedName[splitedName.length - 1];
const displayCreatedFile = `${displayCreatedFileName}...${displayCreatedFileNameExt}`;
return displayCreatedFile;
};
const isOndrive = async (name: string): Promise<boolean> => {
if (!name) return false;
return name.indexOf("my.sharepoint.com") > -1;
};
const formatFileSize = (bytes: number, decimalPoint: number) => {
if (bytes === 0) return "0 Bytes";
const k = 1000,
dm = decimalPoint || 2,
sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"],
i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
};
const getFolderIcon = (): string => {
return DOCICONURL_FOLDER;
};
const trimBeginDoubleSlash = (value: string) => {
if (value.charAt(0) === "/" && value.charAt(1) === "/") {
return value.substring(1, value.length);
}
return value;
}
return {isInTeams, GetFileImageUrl, getShortName, isOndrive, formatFileSize, getFolderIcon,trimBeginDoubleSlash, getContainerHeight };
};

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,6 @@
export enum EAppHostName {
SharePoint = "SharePoint",
Teams = "Teams",
Outlook = "Outlook",
Office = "Office",
}

View File

@ -0,0 +1,3 @@
import { IDashBoardProps } from '../webparts/dashBoard/IDashBoardProps';
export interface IAppState extends IDashBoardProps{}

View File

@ -0,0 +1,7 @@
import * as React from 'react';
export interface IAttribute{
attributelink?: string;
attributeValue: string | React.ReactNode;
icon?: React.ReactNode;
}

View File

@ -0,0 +1,4 @@
export interface ICommentsAndLikes {
comments: string;
likes: string;
}

View File

@ -0,0 +1,9 @@
export interface FileInfo {
AbsoluteFileUrl: string;
ServerRelativeUrl: string;
FileExtension?: string;
Id: string;
ListId: string;
WebId: string;
SiteId: string;
}

Some files were not shown because too many files have changed in this diff Show More