Improved react-teams-lead-dashboard sample

This commit is contained in:
Paolo Pialorsi 2021-10-06 11:46:19 +02:00
parent 7f6430507f
commit 846f06feb0
6 changed files with 9 additions and 9 deletions

View File

@ -3,7 +3,7 @@
"solution": {
"name": "lead-assist-client-side-solution",
"id": "c311a0fc-3dcb-4316-a798-fd7d8a6d5344",
"version": "1.0.11.0",
"version": "1.0.13.0",
"includeClientSideAssets": true,
"skipFeatureDeployment": true,
"isDomainIsolated": false,

View File

@ -1,6 +1,6 @@
{
"name": "lead-assist",
"version": "1.0.11",
"version": "1.0.13",
"private": true,
"main": "lib/index.js",
"scripts": {

View File

@ -7,10 +7,10 @@ export default class SettingsService {
* @param httpClient Http client to be used for the request
* @returns Object representing the JSON settings file
*/
public static async getSettings(graphClient: MSGraphClient, httpClient: HttpClient): Promise<any> {
public static async getSettings(graphClient: MSGraphClient, httpClient: HttpClient, settingsFilename: string): Promise<any> {
// Get approot files
const approotFiles = await graphClient
.api('/me/drive/special/approot/children')
.api(`/me/drive/special/approot/children?$filter=name%20eq%20'${settingsFilename}'`)
.version("v1.0")
.get();
@ -34,10 +34,10 @@ export default class SettingsService {
* @param graphClient Graph client to be used for the request
* @param settings Object representing the settings to be saved on the JSON settings file
*/
public static async saveSiteUrl(graphClient: MSGraphClient, settings: any) {
public static async saveSiteUrl(graphClient: MSGraphClient, settings: any, settingsFilename: string) {
// Save the settings in the application dedicated folder
await graphClient
.api('/me/drive/special/approot:/settings.json:/content')
.api(`/me/drive/special/approot:/${settingsFilename}:/content`)
.version("v1.0")
.header('content-type', 'text/plain')
.put(JSON.stringify(settings));

View File

@ -39,7 +39,7 @@ export default class LeadAssistDashboardWebPart extends BaseClientSideWebPart<IL
this.graphClient = await this.context.msGraphClientFactory.getClient();
// Get the settings
const settings = await SettingsService.getSettings(this.graphClient, this.context.httpClient);
const settings = await SettingsService.getSettings(this.graphClient, this.context.httpClient, 'lead_dashboard_settings.json');
// If there are settings specified
if (settings) {

View File

@ -136,7 +136,7 @@ export default class LeadAssistDashboard extends React.Component<ILeadAssistDash
<TextField value={this.props.siteUrl} onChange={this.changeSiteUrlHandler} />
</div>
<div className={styles.padding5}>
<PrimaryButton text={strings.SaveConfiguration} onClick={() => { SettingsService.saveSiteUrl(this.props.graphClient, { siteUrl: this.state.siteUrl }); }} />
<PrimaryButton text={strings.SaveConfiguration} onClick={() => { SettingsService.saveSiteUrl(this.props.graphClient, { siteUrl: this.state.siteUrl }, 'lead_dashboard_settings.json'); }} />
</div>
</div>;
}

View File

@ -28,7 +28,7 @@ export default class LeadAssistDashboardSettingsWebPart extends BaseClientSideWe
const graphClient = await this.context.msGraphClientFactory.getClient();
// Get the settings
const settings = await SettingsService.getSettings(graphClient, this.context.httpClient);
const settings = await SettingsService.getSettings(graphClient, this.context.httpClient, 'lead_dashboard_settings.json');
// If there are settings specified
if (settings) {