forked from OfficeDev/Microsoft-Teams-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tasks.cshtml
83 lines (75 loc) · 3.84 KB
/
Tasks.cshtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
@using Microsoft.Teams.Samples.TaskModule.Web.Helper;
<div class="font-semibold font-title">Microsoft Teams Task Modules Demo</div>
<p>
A task module allows Teams app developers to create one or more custom, modal experiences with custom code for their users, particularly useful for initiating and/or completing tasks using a GUI that does not litter a Teams conversation with superfluous,
intermediate task completion information.
</p>
<p>
Let's try it out!
<div style="text-align: center; margin-left: auto; margin-right: auto;">
<button class="button-primary" onclick="submit('youtube');">YouTube</button>
<button class="button-primary" onclick="submit('powerapp');">PowerApp</button>
<p></p>
<button class="button-primary" onclick="submit('customform');">Custom Form (results → tab)</button>
<p></p>
<button class="button-primary" onclick="submit('customform bot');">Custom Form (results → bot)</button>
<p></p>
<button class="button-primary" onclick="submit('adaptivecard');">Adaptive Card (results → tab)</button>
<p></p>
<button class="button-primary" onclick="submit('adaptivecard bot');">Adaptive Card (results → bot)</button>
<p></p>
<p></p>
<a target="_blank" href="@(DeeplinkHelper.DeepLink)">Deep link to Custom Form page</a>
</div>
<p></p>
<script src="~/Scripts/teamsapp.js"></script>
<script>
microsoftTeams.initialize();
submitHandler = (err, result) => {
console.log(`Submit handler - err: ${err}`);
alert("Result = " + JSON.stringify(result) + "\nError = " + JSON.stringify(err));
};
function submit(type) {
let taskInfo = {
title: null,
height: null,
width: null,
url: null,
card: null,
fallbackUrl: null,
completionBotId: null,
};
taskInfo.title = "Task Module Demo";
taskInfo.height = "medium";
taskInfo.width = "medium";
if (type.includes('youtube')) {
taskInfo.url = "@(ApplicationSettings.BaseUrl)" + "/youtube";
taskInfo.title = "@(TaskModuleUIConstants.YouTube.Title)";
taskInfo.height = "@(TaskModuleUIConstants.YouTube.Height)";
taskInfo.width = "@(TaskModuleUIConstants.YouTube.Width)";
}
else if (type.includes('powerapp')) {
taskInfo.url = "@(ApplicationSettings.BaseUrl)" + "/powerapp";
taskInfo.title = "@(TaskModuleUIConstants.PowerApp.Title)";
taskInfo.height = "@(TaskModuleUIConstants.PowerApp.Height)";
taskInfo.width = "@(TaskModuleUIConstants.PowerApp.Width)";
}
else if (type.includes('customform')) {
taskInfo.url = "@(ApplicationSettings.BaseUrl)" + "/customform";
taskInfo.title = "@(TaskModuleUIConstants.CustomForm.Title)";
taskInfo.height = "@(TaskModuleUIConstants.CustomForm.Height)";
taskInfo.width = "@(TaskModuleUIConstants.CustomForm.Width)";
}
else {
taskInfo.card = @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(AdaptiveCardHelper.GetAdaptiveCard()));
taskInfo.title = "@(TaskModuleUIConstants.AdaptiveCard.Title)";
taskInfo.height = "@(TaskModuleUIConstants.AdaptiveCard.Height)";
taskInfo.width = "@(TaskModuleUIConstants.AdaptiveCard.Width)";
}
// Set fallback URL
taskInfo.fallbackUrl = taskInfo.url;
if (type.includes('bot'))
taskInfo.completionBotId = "@(ApplicationSettings.MicrosoftAppId)";
microsoftTeams.tasks.startTask(taskInfo, submitHandler);
}
</script>