Added sample js-gitHubBadge (#846)
This commit is contained in:
parent
dcec947cd6
commit
97be6dd8d0
|
@ -0,0 +1,25 @@
|
||||||
|
# EditorConfig helps developers define and maintain consistent
|
||||||
|
# coding styles between different editors and IDEs
|
||||||
|
# editorconfig.org
|
||||||
|
|
||||||
|
root = true
|
||||||
|
|
||||||
|
|
||||||
|
[*]
|
||||||
|
|
||||||
|
# change these settings to your own preference
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
# we recommend you to keep these unchanged
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[{package,bower}.json]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
|
@ -0,0 +1,36 @@
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules
|
||||||
|
|
||||||
|
# Build generated files
|
||||||
|
dist
|
||||||
|
lib
|
||||||
|
solution
|
||||||
|
temp
|
||||||
|
*.sppkg
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
|
||||||
|
# OSX
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Visual Studio files
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
.vs
|
||||||
|
bin
|
||||||
|
obj
|
||||||
|
|
||||||
|
# Resx Generated Code
|
||||||
|
*.resx.ts
|
||||||
|
|
||||||
|
# Styles Generated Code
|
||||||
|
*.scss.ts
|
||||||
|
|
||||||
|
# Added
|
||||||
|
package-lock.json
|
||||||
|
yarn.lock
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"@pnp/generator-spfx": {
|
||||||
|
"framework": "none",
|
||||||
|
"pnpFramework": "none.plus",
|
||||||
|
"pnp-libraries": [],
|
||||||
|
"pnp-ci": [],
|
||||||
|
"pnp-vetting": [],
|
||||||
|
"spfxenv": "spo"
|
||||||
|
},
|
||||||
|
"@microsoft/generator-sharepoint": {
|
||||||
|
"environment": "spo",
|
||||||
|
"framework": "none",
|
||||||
|
"isCreatingSolution": true,
|
||||||
|
"version": "1.8.0",
|
||||||
|
"libraryName": "git-hub-badge-web-part",
|
||||||
|
"libraryId": "d40be93e-575e-419a-a56a-05067c51bfae",
|
||||||
|
"packageManager": "npm",
|
||||||
|
"isDomainIsolated": false,
|
||||||
|
"componentType": "webpart"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
# GitHub Badge
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
Displays information from GitHub for a specified user.
|
||||||
|
![drop](./assets/1.png)
|
||||||
|
|
||||||
|
## Used SharePoint Framework Version
|
||||||
|
![drop](https://img.shields.io/badge/version-GA-green.svg)
|
||||||
|
|
||||||
|
## Applies to
|
||||||
|
|
||||||
|
* [SharePoint Framework](https:/dev.office.com/sharepoint)
|
||||||
|
* [Office 365 tenant](https://dev.office.com/sharepoint/docs/spfx/set-up-your-development-environment)
|
||||||
|
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
## Solution
|
||||||
|
|
||||||
|
Solution|Author(s)
|
||||||
|
--------|---------
|
||||||
|
js-GitHubBadge | Eric Skaggs [@skaggej](https://www.twitter.com/skaggej)
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
Version|Date|Comments
|
||||||
|
-------|----|--------
|
||||||
|
1.0 | April 18, 2019 | Initial release
|
||||||
|
|
||||||
|
## Disclaimer
|
||||||
|
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Minimal Path to Awesome
|
||||||
|
|
||||||
|
- Clone this repository
|
||||||
|
- in the command line run:
|
||||||
|
- `npm install`
|
||||||
|
- `gulp serve`
|
||||||
|
|
||||||
|
> Include any additional steps as needed.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
It's not the prettiest thing in the world, but the goal here was to create a web part that demonstrates something a bit beyond the standard "Hello, World!" web part in which we change some HTML. This sample shows how to pull in data from somewhere without authentication and without over-complicating things.
|
||||||
|
|
||||||
|
Future samples will refactor this into something more professional that follows recommended coding patterns and practices and leverage modern frameworks.
|
||||||
|
|
||||||
|
Ultimately, this sample along with its yet-to-be-created future samples could be a useful teaching tool to developers new to SPFx as well as developers who aren't well-versed in SPFx coding patterns or the various frameworks available.
|
||||||
|
|
||||||
|
<img src="https://telemetry.sharepointpnp.com/sp-dev-fx-webparts/samples/js-gitHubBadge" />
|
Binary file not shown.
After Width: | Height: | Size: 132 KiB |
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
|
||||||
|
"version": "2.0",
|
||||||
|
"bundles": {
|
||||||
|
"git-hub-badge-web-part": {
|
||||||
|
"components": [
|
||||||
|
{
|
||||||
|
"entrypoint": "./lib/webparts/gitHubBadge/GitHubBadgeWebPart.js",
|
||||||
|
"manifest": "./src/webparts/gitHubBadge/GitHubBadgeWebPart.manifest.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"externals": {},
|
||||||
|
"localizedResources": {
|
||||||
|
"GitHubBadgeWebPartStrings": "lib/webparts/gitHubBadge/loc/{locale}.js"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/copy-assets.schema.json",
|
||||||
|
"deployCdnPath": "temp/deploy"
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
|
||||||
|
"workingDir": "./temp/deploy/",
|
||||||
|
"account": "<!-- STORAGE ACCOUNT NAME -->",
|
||||||
|
"container": "git-hub-badge-web-part",
|
||||||
|
"accessKey": "<!-- ACCESS KEY -->"
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"preset": "@voitanos/jest-preset-spfx",
|
||||||
|
"rootDir": "../src"
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
|
||||||
|
"solution": {
|
||||||
|
"name": "git-hub-badge-web-part-client-side-solution",
|
||||||
|
"id": "d40be93e-575e-419a-a56a-05067c51bfae",
|
||||||
|
"version": "1.0.0.0",
|
||||||
|
"includeClientSideAssets": true,
|
||||||
|
"skipFeatureDeployment": true,
|
||||||
|
"isDomainIsolated": false
|
||||||
|
},
|
||||||
|
"paths": {
|
||||||
|
"zippedPackage": "solution/git-hub-badge-web-part.sppkg"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json",
|
||||||
|
"port": 4321,
|
||||||
|
"hostname": "0.0.0.0",
|
||||||
|
"https": true,
|
||||||
|
"initialPage": "https://localhost:5432/workbench",
|
||||||
|
"api": {
|
||||||
|
"port": 5432,
|
||||||
|
"entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
|
||||||
|
"cdnBasePath": "<!-- PATH TO CDN -->",
|
||||||
|
"debugBasePath": "https://localhost:4321/"
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
// check if gulp dist was called
|
||||||
|
if (process.argv.indexOf('dist') !== -1) {
|
||||||
|
// add ship options to command call
|
||||||
|
process.argv.push('--ship');
|
||||||
|
}
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
|
const gulp = require('gulp');
|
||||||
|
const build = require('@microsoft/sp-build-web');
|
||||||
|
const gulpSequence = require('gulp-sequence');
|
||||||
|
|
||||||
|
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
|
||||||
|
|
||||||
|
// Create clean distrubution package
|
||||||
|
gulp.task('dist', gulpSequence('clean', 'bundle', 'package-solution'));
|
||||||
|
// Create clean development package
|
||||||
|
gulp.task('dev', gulpSequence('clean', 'bundle', 'package-solution'));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom Framework Specific gulp tasks
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
build.initialize(gulp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Continuous Integration
|
||||||
|
*/
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
{
|
||||||
|
"name": "git-hub-badge-web-part",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"private": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "gulp bundle",
|
||||||
|
"clean": "gulp clean",
|
||||||
|
"preversion": "node ./tools/pre-version.js",
|
||||||
|
"postversion": "gulp dist",
|
||||||
|
"test": "./node_modules/.bin/jest --config ./config/jest.config.json",
|
||||||
|
"test:watch": "./node_modules/.bin/jest --config ./config/jest.config.json --watchAll"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@microsoft/sp-core-library": "1.8.0",
|
||||||
|
"@microsoft/sp-lodash-subset": "1.8.0",
|
||||||
|
"@microsoft/sp-office-ui-fabric-core": "1.8.0",
|
||||||
|
"@microsoft/sp-property-pane": "1.8.0",
|
||||||
|
"@microsoft/sp-webpart-base": "1.8.0",
|
||||||
|
"@types/es6-promise": "0.0.33",
|
||||||
|
"@types/webpack-env": "1.13.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@microsoft/rush-stack-compiler-2.7": "0.4.0",
|
||||||
|
"@microsoft/sp-build-web": "1.8.0",
|
||||||
|
"@microsoft/sp-module-interfaces": "1.8.0",
|
||||||
|
"@microsoft/sp-tslint-rules": "1.8.0",
|
||||||
|
"@microsoft/sp-webpart-workbench": "1.8.0",
|
||||||
|
"@types/chai": "3.4.34",
|
||||||
|
"@types/mocha": "2.2.38",
|
||||||
|
"@voitanos/jest-preset-spfx": "^1.1.0",
|
||||||
|
"ajv": "~5.2.2",
|
||||||
|
"gulp": "~3.9.1",
|
||||||
|
"gulp-sequence": "1.0.0",
|
||||||
|
"jest": "^23.6.0",
|
||||||
|
"karma-junit-reporter": "^1.2.0"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
// A file is required to be in the root of the /src directory by the TypeScript compiler
|
|
@ -0,0 +1,28 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
|
||||||
|
"id": "130674a1-0182-4b57-8ce9-88e1516abbcf",
|
||||||
|
"alias": "GitHubBadgeWebPart",
|
||||||
|
"componentType": "WebPart",
|
||||||
|
|
||||||
|
// The "*" signifies that the version should be taken from the package.json
|
||||||
|
"version": "*",
|
||||||
|
"manifestVersion": 2,
|
||||||
|
|
||||||
|
// If true, the component can only be installed on sites where Custom Script is allowed.
|
||||||
|
// Components that allow authors to embed arbitrary script code should set this to true.
|
||||||
|
// https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f
|
||||||
|
"requiresCustomScript": false,
|
||||||
|
"supportedHosts": ["SharePointWebPart"],
|
||||||
|
|
||||||
|
"preconfiguredEntries": [{
|
||||||
|
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other
|
||||||
|
"group": { "default": "Other" },
|
||||||
|
"title": { "default": "GitHub Badge" },
|
||||||
|
"description": { "default": "Displays information from GitHub for a specified user." },
|
||||||
|
"officeFabricIconFontName": "Page",
|
||||||
|
"properties": {
|
||||||
|
"description": "GitHub Badge",
|
||||||
|
"gitHubUserName": "skaggej"
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
@import '~@microsoft/sp-office-ui-fabric-core/dist/sass/SPFabricCore.scss';
|
||||||
|
|
||||||
|
.gitHubBadge {
|
||||||
|
.container {
|
||||||
|
max-width: 700px;
|
||||||
|
margin: 0px auto;
|
||||||
|
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 25px 50px 0 rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.row {
|
||||||
|
@include ms-Grid-row;
|
||||||
|
@include ms-fontColor-white;
|
||||||
|
background-color: $ms-color-themeDark;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.column {
|
||||||
|
@include ms-Grid-col;
|
||||||
|
@include ms-lg10;
|
||||||
|
@include ms-xl8;
|
||||||
|
@include ms-xlPush2;
|
||||||
|
@include ms-lgPush1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
@include ms-font-xl;
|
||||||
|
@include ms-fontColor-white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subTitle {
|
||||||
|
@include ms-font-l;
|
||||||
|
@include ms-fontColor-white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.description {
|
||||||
|
@include ms-font-l;
|
||||||
|
@include ms-fontColor-white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button {
|
||||||
|
// Our button
|
||||||
|
text-decoration: none;
|
||||||
|
height: 32px;
|
||||||
|
|
||||||
|
// Primary Button
|
||||||
|
min-width: 80px;
|
||||||
|
background-color: $ms-color-themePrimary;
|
||||||
|
border-color: $ms-color-themePrimary;
|
||||||
|
color: $ms-color-white;
|
||||||
|
|
||||||
|
// Basic Button
|
||||||
|
outline: transparent;
|
||||||
|
position: relative;
|
||||||
|
font-family: "Segoe UI WestEuropean","Segoe UI",-apple-system,BlinkMacSystemFont,Roboto,"Helvetica Neue",sans-serif;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
font-size: $ms-font-size-m;
|
||||||
|
font-weight: $ms-font-weight-regular;
|
||||||
|
border-width: 0;
|
||||||
|
text-align: center;
|
||||||
|
cursor: pointer;
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0 16px;
|
||||||
|
|
||||||
|
.label {
|
||||||
|
font-weight: $ms-font-weight-semibold;
|
||||||
|
font-size: $ms-font-size-m;
|
||||||
|
height: 32px;
|
||||||
|
line-height: 32px;
|
||||||
|
margin: 0 4px;
|
||||||
|
vertical-align: top;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,216 @@
|
||||||
|
import { Version } from '@microsoft/sp-core-library';
|
||||||
|
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
|
||||||
|
import {
|
||||||
|
IPropertyPaneConfiguration,
|
||||||
|
PropertyPaneTextField
|
||||||
|
} from '@microsoft/sp-property-pane';
|
||||||
|
import { HttpClient, SPHttpClient, HttpClientConfiguration, HttpClientResponse, ODataVersion, IHttpClientConfiguration, IHttpClientOptions, ISPHttpClientOptions } from '@microsoft/sp-http';
|
||||||
|
import { escape } from '@microsoft/sp-lodash-subset';
|
||||||
|
|
||||||
|
import styles from './GitHubBadgeWebPart.module.scss';
|
||||||
|
import * as strings from 'GitHubBadgeWebPartStrings';
|
||||||
|
|
||||||
|
export interface IGitHubBadgeWebPartProps {
|
||||||
|
description: string;
|
||||||
|
gitHubUserName: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IGitHubBadgeUserProfileProps {
|
||||||
|
login: string;
|
||||||
|
id: string;
|
||||||
|
node_id: string;
|
||||||
|
avatar_url: string;
|
||||||
|
gravatar_id: string;
|
||||||
|
url: string;
|
||||||
|
html_url: string;
|
||||||
|
followers_url: string;
|
||||||
|
following_url: string;
|
||||||
|
gists_url: string;
|
||||||
|
starred_url: string;
|
||||||
|
subscriptions_url: string;
|
||||||
|
organizations_url: string;
|
||||||
|
repos_url: string;
|
||||||
|
events_url: string;
|
||||||
|
received_events_url: string;
|
||||||
|
type: string;
|
||||||
|
site_admin: string;
|
||||||
|
name: string;
|
||||||
|
company: string;
|
||||||
|
blog: string;
|
||||||
|
location: string;
|
||||||
|
email: string;
|
||||||
|
hireable: string;
|
||||||
|
bio: string;
|
||||||
|
public_repos: string;
|
||||||
|
public_gists: string;
|
||||||
|
followers: string;
|
||||||
|
following: string;
|
||||||
|
created_at: string;
|
||||||
|
updated_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class GitHubBadgeWebPart extends BaseClientSideWebPart<IGitHubBadgeWebPartProps> {
|
||||||
|
|
||||||
|
protected getGitHubData(): void {
|
||||||
|
let gitHubUrl: string = "https://api.github.com/users/"+this.properties.gitHubUserName;
|
||||||
|
let responseText: string = "";
|
||||||
|
let notfound: HTMLElement = document.getElementById("notfound");
|
||||||
|
let gitHubUserProfilePic: HTMLElement = document.getElementById("gitHubUserProfilePic");
|
||||||
|
let login: HTMLElement = document.getElementById("login");
|
||||||
|
let id: HTMLElement = document.getElementById("id");
|
||||||
|
let node_id: HTMLElement = document.getElementById("node_id");
|
||||||
|
let avatar_url: HTMLElement = document.getElementById("avatar_url");
|
||||||
|
let gravatar_id: HTMLElement = document.getElementById("gravatar_id");
|
||||||
|
let url: HTMLElement = document.getElementById("url");
|
||||||
|
let html_url: HTMLElement = document.getElementById("html_url");
|
||||||
|
let followers_url: HTMLElement = document.getElementById("followers_url");
|
||||||
|
let following_url: HTMLElement = document.getElementById("following_url");
|
||||||
|
let gists_url: HTMLElement = document.getElementById("gists_url");
|
||||||
|
let starred_url: HTMLElement = document.getElementById("starred_url");
|
||||||
|
let subscriptions_url: HTMLElement = document.getElementById("subscriptions_url");
|
||||||
|
let organizations_url: HTMLElement = document.getElementById("organizations_url");
|
||||||
|
let repos_url: HTMLElement = document.getElementById("repos_url");
|
||||||
|
let events_url: HTMLElement = document.getElementById("events_url");
|
||||||
|
let received_events_url: HTMLElement = document.getElementById("received_events_url");
|
||||||
|
let type: HTMLElement = document.getElementById("type");
|
||||||
|
let site_admin: HTMLElement = document.getElementById("site_admin");
|
||||||
|
let name: HTMLElement = document.getElementById("name");
|
||||||
|
let company: HTMLElement = document.getElementById("company");
|
||||||
|
let blog: HTMLElement = document.getElementById("blog");
|
||||||
|
let location: HTMLElement = document.getElementById("location");
|
||||||
|
let email: HTMLElement = document.getElementById("email");
|
||||||
|
let hireable: HTMLElement = document.getElementById("hireable");
|
||||||
|
let bio: HTMLElement = document.getElementById("bio");
|
||||||
|
let public_repos: HTMLElement = document.getElementById("public_repos");
|
||||||
|
let public_gists: HTMLElement = document.getElementById("public_gists");
|
||||||
|
let followers: HTMLElement = document.getElementById("followers");
|
||||||
|
let following: HTMLElement = document.getElementById("following");
|
||||||
|
let created_at: HTMLElement = document.getElementById("created_at");
|
||||||
|
let updated_at: HTMLElement = document.getElementById("updated_at");
|
||||||
|
let responseJSONparsed: IGitHubBadgeUserProfileProps;
|
||||||
|
this.context.httpClient.get(gitHubUrl, HttpClient.configurations.v1).then((response: HttpClientResponse) => {
|
||||||
|
response.json().then((responseJSON: JSON) => {
|
||||||
|
responseText = JSON.stringify(responseJSON);
|
||||||
|
responseJSONparsed = JSON.parse(responseText);
|
||||||
|
gitHubUserProfilePic.innerHTML= `<img src="${responseJSONparsed.avatar_url}" alt="GitHub User Profile Picture"></img>`;
|
||||||
|
login.innerText = responseJSONparsed.login;
|
||||||
|
id.innerText = responseJSONparsed.id;
|
||||||
|
node_id.innerText = responseJSONparsed.node_id;
|
||||||
|
avatar_url.innerText = responseJSONparsed.avatar_url;
|
||||||
|
gravatar_id.innerText = responseJSONparsed.gravatar_id;
|
||||||
|
url.innerText = responseJSONparsed.url;
|
||||||
|
html_url.innerText = responseJSONparsed.html_url;
|
||||||
|
followers_url.innerText = responseJSONparsed.followers_url;
|
||||||
|
following_url.innerText = responseJSONparsed.following_url;
|
||||||
|
gists_url.innerText = responseJSONparsed.gists_url;
|
||||||
|
starred_url.innerText = responseJSONparsed.starred_url;
|
||||||
|
subscriptions_url.innerText = responseJSONparsed.subscriptions_url;
|
||||||
|
organizations_url.innerText = responseJSONparsed.organizations_url;
|
||||||
|
repos_url.innerText = responseJSONparsed.repos_url;
|
||||||
|
events_url.innerText = responseJSONparsed.events_url;
|
||||||
|
received_events_url.innerText = responseJSONparsed.received_events_url;
|
||||||
|
type.innerText = responseJSONparsed.type;
|
||||||
|
site_admin.innerText = responseJSONparsed.site_admin;
|
||||||
|
name.innerText = responseJSONparsed.name;
|
||||||
|
company.innerText = responseJSONparsed.company;
|
||||||
|
blog.innerText = responseJSONparsed.blog;
|
||||||
|
location.innerText = responseJSONparsed.location;
|
||||||
|
email.innerText = responseJSONparsed.email;
|
||||||
|
hireable.innerText = responseJSONparsed.hireable;
|
||||||
|
bio.innerText = responseJSONparsed.bio;
|
||||||
|
public_repos.innerText = responseJSONparsed.public_repos;
|
||||||
|
public_gists.innerText = responseJSONparsed.public_gists;
|
||||||
|
followers.innerText = responseJSONparsed.followers;
|
||||||
|
following.innerText = responseJSONparsed.following;
|
||||||
|
created_at.innerText = responseJSONparsed.created_at;
|
||||||
|
updated_at.innerText = responseJSONparsed.updated_at;
|
||||||
|
})
|
||||||
|
.catch ((response: any) => {
|
||||||
|
let errMsg: string = `WARNING - error when calling URL ${gitHubUrl}. Error = ${response.message}`;
|
||||||
|
notfound.style.color = "red";
|
||||||
|
console.log(errMsg);
|
||||||
|
notfound.innerText = errMsg;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public render(): void {
|
||||||
|
this.domElement.innerHTML = `
|
||||||
|
<div class="${ styles.gitHubBadge }">
|
||||||
|
<div class="${ styles.container }">
|
||||||
|
<div class="${ styles.row }">
|
||||||
|
<div class="${ styles.column }">
|
||||||
|
<div id="gitHubUserProfilePic"></div>
|
||||||
|
<div id="gitHubUserName" class="${ styles.title }">${this.properties.gitHubUserName}</div>
|
||||||
|
<div id="login" class="${ styles.label }"></div>
|
||||||
|
<div id="id" class="${ styles.label }"></div>
|
||||||
|
<div id="node_id" class="${ styles.label }"></div>
|
||||||
|
<div id="avatar_url" class="${ styles.label }"></div>
|
||||||
|
<div id="gravatar_id" class="${ styles.label }"></div>
|
||||||
|
<div id="url" class="${ styles.label }"></div>
|
||||||
|
<div id="html_url" class="${ styles.label }"></div>
|
||||||
|
<div id="followers_url" class="${ styles.label }"></div>
|
||||||
|
<div id="following_url" class="${ styles.label }"></div>
|
||||||
|
<div id="gists_url" class="${ styles.label }"></div>
|
||||||
|
<div id="starred_url" class="${ styles.label }"></div>
|
||||||
|
<div id="subscriptions_url" class="${ styles.label }"></div>
|
||||||
|
<div id="organizations_url" class="${ styles.label }"></div>
|
||||||
|
<div id="repos_url" class="${ styles.label }"></div>
|
||||||
|
<div id="events_url" class="${ styles.label }"></div>
|
||||||
|
<div id="received_events_url" class="${ styles.label }"></div>
|
||||||
|
<div id="type" class="${ styles.label }"></div>
|
||||||
|
<div id="site_admin" class="${ styles.label }"></div>
|
||||||
|
<div id="name" class="${ styles.label }"></div>
|
||||||
|
<div id="company" class="${ styles.label }"></div>
|
||||||
|
<div id="blog" class="${ styles.label }"></div>
|
||||||
|
<div id="location" class="${ styles.label }"></div>
|
||||||
|
<div id="email" class="${ styles.label }"></div>
|
||||||
|
<div id="hireable" class="${ styles.label }"></div>
|
||||||
|
<div id="bio" class="${ styles.label }"></div>
|
||||||
|
<div id="public_repos" class="${ styles.label }"></div>
|
||||||
|
<div id="public_gists" class="${ styles.label }"></div>
|
||||||
|
<div id="followers" class="${ styles.label }"></div>
|
||||||
|
<div id="following" class="${ styles.label }"></div>
|
||||||
|
<div id="created_at" class="${ styles.label }"></div>
|
||||||
|
<div id="updated_at" class="${ styles.label }"></div>
|
||||||
|
<div id="notfound" class="${styles.label}"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>`;
|
||||||
|
this.getGitHubData();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected get dataVersion(): Version {
|
||||||
|
return Version.parse('1.0');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected get disableReactivePropertyChanges(): boolean {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
|
||||||
|
return {
|
||||||
|
pages: [
|
||||||
|
{
|
||||||
|
header: {
|
||||||
|
description: strings.PropertyPaneDescription
|
||||||
|
},
|
||||||
|
groups: [
|
||||||
|
{
|
||||||
|
groupName: strings.BasicGroupName,
|
||||||
|
groupFields: [
|
||||||
|
PropertyPaneTextField('description', {
|
||||||
|
label: strings.DescriptionFieldLabel
|
||||||
|
}),
|
||||||
|
PropertyPaneTextField('gitHubUserName', {
|
||||||
|
label: strings.GitHubUserNameFieldLabel
|
||||||
|
})
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
define([], function() {
|
||||||
|
return {
|
||||||
|
"PropertyPaneDescription": "Description",
|
||||||
|
"BasicGroupName": "Group Name",
|
||||||
|
"DescriptionFieldLabel": "Description Field",
|
||||||
|
"GitHubUserNameFieldLabel": "GitHub User Name"
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,11 @@
|
||||||
|
declare interface IGitHubBadgeWebPartStrings {
|
||||||
|
PropertyPaneDescription: string;
|
||||||
|
BasicGroupName: string;
|
||||||
|
DescriptionFieldLabel: string;
|
||||||
|
GitHubUserNameFieldLabel: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module 'GitHubBadgeWebPartStrings' {
|
||||||
|
const strings: IGitHubBadgeWebPartStrings;
|
||||||
|
export = strings;
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 3.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
|
@ -0,0 +1,64 @@
|
||||||
|
/**
|
||||||
|
* This script updates the package-solution version analogue to the
|
||||||
|
* the package.json file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (process.env.npm_package_version === undefined) {
|
||||||
|
|
||||||
|
throw 'Package version cannot be evaluated';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// define path to package-solution file
|
||||||
|
const solution = './config/package-solution.json',
|
||||||
|
teams = './teams/manifest.json';
|
||||||
|
|
||||||
|
// require filesystem instanc
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
// get next automated package version from process variable
|
||||||
|
const nextPkgVersion = process.env.npm_package_version;
|
||||||
|
|
||||||
|
// make sure next build version match
|
||||||
|
const nextVersion = nextPkgVersion.indexOf('-') === -1 ?
|
||||||
|
nextPkgVersion : nextPkgVersion.split('-')[0];
|
||||||
|
|
||||||
|
// Update version in SPFx package-solution if exists
|
||||||
|
if (fs.existsSync(solution)) {
|
||||||
|
|
||||||
|
// read package-solution file
|
||||||
|
const solutionFileContent = fs.readFileSync(solution, 'UTF-8');
|
||||||
|
// parse file as json
|
||||||
|
const solutionContents = JSON.parse(solutionFileContent);
|
||||||
|
|
||||||
|
// set property of version to next version
|
||||||
|
solutionContents.solution.version = nextVersion + '.0';
|
||||||
|
|
||||||
|
// save file
|
||||||
|
fs.writeFileSync(
|
||||||
|
solution,
|
||||||
|
// convert file back to proper json
|
||||||
|
JSON.stringify(solutionContents, null, 2),
|
||||||
|
'UTF-8');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update version in teams manifest if exists
|
||||||
|
if (fs.existsSync(teams)) {
|
||||||
|
|
||||||
|
// read package-solution file
|
||||||
|
const teamsManifestContent = fs.readFileSync(teams, 'UTF-8');
|
||||||
|
// parse file as json
|
||||||
|
const teamsContent = JSON.parse(teamsManifestContent);
|
||||||
|
|
||||||
|
// set property of version to next version
|
||||||
|
teamsContent.version = nextVersion;
|
||||||
|
|
||||||
|
// save file
|
||||||
|
fs.writeFileSync(
|
||||||
|
teams,
|
||||||
|
// convert file back to proper json
|
||||||
|
JSON.stringify(teamsContent, null, 2),
|
||||||
|
'UTF-8');
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
{
|
||||||
|
"extends": "./node_modules/@microsoft/rush-stack-compiler-2.7/includes/tsconfig-web.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es5",
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"module": "esnext",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"jsx": "react",
|
||||||
|
"declaration": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"outDir": "lib",
|
||||||
|
"inlineSources": false,
|
||||||
|
"strictNullChecks": false,
|
||||||
|
"noUnusedLocals": false,
|
||||||
|
"typeRoots": [
|
||||||
|
"./node_modules/@types",
|
||||||
|
"./node_modules/@microsoft"
|
||||||
|
],
|
||||||
|
"types": [
|
||||||
|
"es6-promise",
|
||||||
|
"webpack-env"
|
||||||
|
],
|
||||||
|
"lib": [
|
||||||
|
"es5",
|
||||||
|
"dom",
|
||||||
|
"es2015.collection"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src/**/*.ts"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"lib"
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"extends": "@microsoft/sp-tslint-rules/base-tslint.json",
|
||||||
|
"rules": {
|
||||||
|
"class-name": false,
|
||||||
|
"export-name": false,
|
||||||
|
"forin": false,
|
||||||
|
"label-position": false,
|
||||||
|
"member-access": true,
|
||||||
|
"no-arg": false,
|
||||||
|
"no-console": false,
|
||||||
|
"no-construct": false,
|
||||||
|
"no-duplicate-variable": true,
|
||||||
|
"no-eval": false,
|
||||||
|
"no-function-expression": true,
|
||||||
|
"no-internal-module": true,
|
||||||
|
"no-shadowed-variable": true,
|
||||||
|
"no-switch-case-fall-through": true,
|
||||||
|
"no-unnecessary-semicolons": true,
|
||||||
|
"no-unused-expression": true,
|
||||||
|
"no-use-before-declare": true,
|
||||||
|
"no-with-statement": true,
|
||||||
|
"semicolon": true,
|
||||||
|
"trailing-comma": false,
|
||||||
|
"typedef": false,
|
||||||
|
"typedef-whitespace": false,
|
||||||
|
"use-named-parameter": true,
|
||||||
|
"variable-name": false,
|
||||||
|
"whitespace": false
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue