This project aims to create a Ticketing System within MS Teams using Azure Services for implementations in different Business Cases.
Prerequisites To run the dashboard template in your local dev machine, you will need:
- Node.js, supported versions: 16, 18
- A Microsoft 365 account for development
- Set up your dev environment for extending Teams apps across Microsoft 365 Please note that after you enrolled your developer tenant in Office 365 Target Release, it may take couple days for the enrollment to take effect.
- Teams Toolkit Visual Studio Code Extension version 5.0.0 and higher or Teams Toolkit CLI
Debug (Edge)
or Debug (Chrome)
.Folder | Contents |
---|---|
.vscode |
VSCode files for debugging |
appPackage |
Templates for the Teams application manifest |
env |
Environment files |
infra |
Templates for provisioning Azure resources |
src |
The source code for the dashboard Teams application |
The following files can be customized and demonstrate an example implementation to get you started.
File | Contents |
---|---|
src/models/chartModel.ts |
Data model for the chart widget |
src/models/listModel.ts |
Data model for the list widget |
src/services/chartService.ts |
A data retrive implementation for the chart widget |
src/services/listService.ts |
A data retrive implementation for the list widget |
src/dashboards/SampleDashboard.tsx |
A sample dashboard layout implementation |
src/styles/ChartWidget.css |
The chart widget style file |
src/styles/ListWidget.css |
The list widget style file |
src/widgets/ChartWidget.tsx |
A widget implementation that can display a chart |
src/widgets/ListWidget.tsx |
A widget implementation that can display a list |
src/App.css |
The style of application route |
src/App.tsx |
Application route |
The following are project-related files. You generally will not need to customize these files.
File | Contents |
---|---|
src/index.css |
The style of application entry point |
src/index.tsx |
Application entry point |
src/internal/addNewScopes.ts |
Implementation of new scopes add |
src/internal/context.ts |
TeamsFx Context |
src/internal/login.ts |
Implementation of login |
src/internal/singletonContext.ts |
Implementation of the TeamsUserCredential instance singleton |
File | Contents |
---|---|
teamsapp.yml |
This is the main Teams Toolkit project file. The project file defines two primary things: Properties and configuration Stage definitions. |
teamsapp.local.yml |
This overrides teamsapp.yml with actions that enable local execution and debugging. |
Define a data model based on the business scenario, we recommend that you place the data model under the src/models
directory. Here is an example of a data model::
//sampleModel.ts
export interface SampleModel {
content: string;
}
Typically, a widget requires a service to retrieve the necessary data for displaying its content. This service can either fetch static data from a predefined source or retrieve dynamic data from a backend service or API.
For instance, we will implement a service that returns static data and place it under the src/services
directory.
Here is a sample service for retrieving static data:
//sampleService.ts
import { SampleModel } from "../models/sampleModel";
export const getSampleData = (): SampleModel => {
return { content: "Hello world!" };
};
Create a widget file in the src/widgets
folder. Inherit the BaseWidget
class from @microsoft/teamsfx-react
. The following table lists the methods that you can override to customize your widget.
Methods | Function |
---|---|
getData() |
This method is used to get the data for the widget. You can implement it to get data from the backend service or from the Microsoft Graph API |
header() |
Customize the content of the widget header |
body() |
Customize the content of the widget body |
footer() |
Customize the content of the widget footer |
styling() |
Customize the widget style |
All method overrides are optional.
Here's a sample widget implementation:
//SampleWidget.tsx
import { Button, Text } from "@fluentui/react-components";
import { BaseWidget } from "@microsoft/teamsfx-react";
import { SampleModel } from "../models/sampleModel";
import { getSampleData } from "../services/sampleService";
interface SampleWidgetState {
data?: SampleModel;
}
export class SampleWidget extends BaseWidget<any, SampleWidgetState> {
override async getData(): Promise<SampleWidgetState> {
return { data: getSampleData() };
}
override header(): JSX.Element | undefined {
return <Text>Sample Widget</Text>;
}
override body(): JSX.Element | undefined {
return <div>{this.state.data?.content}</div>;
}
override footer(): JSX.Element | undefined {
return <Button>View Details</Button>;
}
}
Open the src/dashboards/SampleDashboard.tsx
file and add the widget to the implementation of the layout
method. If you want to create a new dashboard, please refer to How to add a new dashboard.
override layout(): JSX.Element | undefined {
return (
<>
<ListWidget />
<ChartWidget />
<SampleWidget />
</>
);
}
Optional: If you want to arrange multiple widgets in the same column, you can refer to the following code snippet:
.one-column {
display: grid;
gap: 20px;
grid-template-rows: 1fr 1fr;
}
override layout(): JSX.Element | undefined {
return (
<>
<ListWidget />
<div className="one-column">
<ChartWidget />
<SampleWidget />
</div>
</>
);
}