Updated react-teams-lead-dashboard sample

This commit is contained in:
Paolo Pialorsi 2021-10-07 11:52:29 +02:00
parent 347ed56030
commit f4cf63665a
2 changed files with 6 additions and 4 deletions

View File

@ -2,9 +2,10 @@ import { HttpClient, MSGraphClient } from "@microsoft/sp-http";
export default class SettingsService { export default class SettingsService {
/** /**
* Get the application settings from drive * Get the application settings from OneDrive
* @param graphClient Graph client to be used for the request * @param graphClient Graph client to be used for the request
* @param httpClient Http client to be used for the request * @param httpClient Http client to be used for the request
* @param settingsFilename Name of the file to read the settings from
* @returns Object representing the JSON settings file * @returns Object representing the JSON settings file
*/ */
public static async getSettings(graphClient: MSGraphClient, httpClient: HttpClient, settingsFilename: string): Promise<any> { public static async getSettings(graphClient: MSGraphClient, httpClient: HttpClient, settingsFilename: string): Promise<any> {
@ -30,11 +31,12 @@ export default class SettingsService {
} }
/** /**
* Save the specified settings to drive * Save the specified settings to OneDrive
* @param graphClient Graph client to be used for the request * @param graphClient Graph client to be used for the request
* @param settings Object representing the settings to be saved on the JSON settings file * @param settings Object representing the settings to be saved on the JSON settings file
* @param settingsFilename Name of the file to store the settings on
*/ */
public static async saveSiteUrl(graphClient: MSGraphClient, settings: any, settingsFilename: string) { public static async saveSettings(graphClient: MSGraphClient, settings: any, settingsFilename: string) {
// Save the settings in the application dedicated folder // Save the settings in the application dedicated folder
await graphClient await graphClient
.api(`/me/drive/special/approot:/${settingsFilename}:/content`) .api(`/me/drive/special/approot:/${settingsFilename}:/content`)

View File

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