awacke1 commited on
Commit
5e0521d
β€’
1 Parent(s): b78f540

Update BestYet2.app.py

Browse files
Files changed (1) hide show
  1. BestYet2.app.py +211 -53
BestYet2.app.py CHANGED
@@ -11,6 +11,64 @@ CLIENT_SECRET_KEY = os.getenv('CLIENT_SECRET_KEY')
11
  AUTHORITY_URL = 'https://login.microsoftonline.com/common'
12
  REDIRECT_URI = 'https://huggingface.co/spaces/awacke1/MSGraphAPI'
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  # Define product to scope mapping, links, AI capabilities, and Graph solutions
15
  PRODUCT_SCOPES = {
16
  "πŸ“§ Outlook": {
@@ -29,7 +87,7 @@ PRODUCT_SCOPES = {
29
  'scopes': ['Tasks.ReadWrite'],
30
  'link': 'https://to-do.office.com/tasks/',
31
  'ai_capabilities': "πŸ€–πŸ“ Task prioritization",
32
- 'graph_solution': "βœ… Task management API"
33
  },
34
  "πŸ—‚οΈ OneDrive": {
35
  'scopes': ['Files.ReadWrite.All'],
@@ -37,6 +95,48 @@ PRODUCT_SCOPES = {
37
  'ai_capabilities': "πŸ€–πŸ” Smart file organization",
38
  'graph_solution': "πŸ“ File & folder API"
39
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  "πŸ“’ OneNote": {
41
  'scopes': ['Notes.Read', 'Notes.Create'],
42
  'link': 'https://www.onenote.com/notebooks',
@@ -55,18 +155,6 @@ PRODUCT_SCOPES = {
55
  'ai_capabilities': "πŸ€–βœοΈ Smart drafting & editing",
56
  'graph_solution': "πŸ“ Document content API"
57
  },
58
- "πŸ—ƒοΈ SharePoint": {
59
- 'scopes': ['Sites.Read.All', 'Sites.ReadWrite.All'],
60
- 'link': 'https://www.microsoft.com/microsoft-365/sharepoint/collaboration',
61
- 'ai_capabilities': "πŸ€–πŸ” Smart search & tagging",
62
- 'graph_solution': "🌐 Sites & lists API"
63
- },
64
- "πŸ“… Teams": {
65
- 'scopes': ['Team.ReadBasic.All', 'Channel.ReadBasic.All'],
66
- 'link': 'https://teams.microsoft.com/',
67
- 'ai_capabilities': "πŸ€–πŸ’¬ Meeting insights & summaries",
68
- 'graph_solution': "πŸ‘₯ Teams & chats API"
69
- },
70
  "πŸ’¬ Viva": {
71
  'scopes': ['Analytics.Read'],
72
  'link': 'https://www.microsoft.com/microsoft-viva',
@@ -79,48 +167,12 @@ PRODUCT_SCOPES = {
79
  'ai_capabilities': "πŸ€–βš™οΈ AI-powered automation",
80
  'graph_solution': "πŸ”§ Workflow & app API"
81
  },
82
- "🧠 Copilot": {
83
- 'scopes': ['Cognitive.Read'],
84
- 'link': 'https://www.microsoft.com/microsoft-365/copilot',
85
- 'ai_capabilities': "πŸ€–πŸš€ Cross-app AI assistance",
86
- 'graph_solution': "🧠 AI integration API"
87
- },
88
  "πŸ’‘ PowerPoint": {
89
  'scopes': ['Files.ReadWrite.All'],
90
  'link': 'https://www.office.com/launch/powerpoint',
91
  'ai_capabilities': "πŸ€–πŸŽ¨ Design & coaching AI",
92
  'graph_solution': "πŸ“Š Presentation API"
93
  },
94
- "πŸ“š Microsoft Bookings": {
95
- 'scopes': ['Bookings.Read.All', 'Bookings.ReadWrite.All'],
96
- 'link': 'https://outlook.office.com/bookings/',
97
- 'ai_capabilities': "πŸ€–πŸ“… Smart scheduling",
98
- 'graph_solution': "πŸ“† Booking services API"
99
- },
100
- "πŸ““ Loop": {
101
- 'scopes': ['Files.ReadWrite.All'],
102
- 'link': 'https://loop.microsoft.com/',
103
- 'ai_capabilities': "πŸ€–πŸ”„ Real-time collaboration AI",
104
- 'graph_solution': "πŸ” Workspace API"
105
- },
106
- "πŸ—£οΈ Translator": {
107
- 'scopes': ['Translation.Read'],
108
- 'link': 'https://www.microsoft.com/translator/',
109
- 'ai_capabilities': "πŸ€–πŸŒ Real-time translation",
110
- 'graph_solution': "πŸ—¨οΈ Translation services API"
111
- },
112
- "πŸ“‹ To Do & Planner": {
113
- 'scopes': ['Tasks.ReadWrite'],
114
- 'link': 'https://todo.microsoft.com/',
115
- 'ai_capabilities': "πŸ€–πŸ“ Smart task management",
116
- 'graph_solution': "βœ… Task & plan API"
117
- },
118
- "πŸ”— Azure OpenAI Service": {
119
- 'scopes': ['AzureAIServices.ReadWrite.All'],
120
- 'link': 'https://azure.microsoft.com/products/cognitive-services/openai-service/',
121
- 'ai_capabilities': "πŸ€–πŸ§  Custom AI model access",
122
- 'graph_solution': "πŸ”Œ AI model integration API"
123
- }
124
  }
125
 
126
  BASE_SCOPES = ['User.Read']
@@ -264,13 +316,16 @@ def handle_calendar_integration(access_token):
264
  day_placeholders[day].write(f"{start_date.strftime('%H:%M')} - {event['subject']}")
265
  else:
266
  st.write("No events found or unable to fetch events.")
 
 
 
267
 
268
- # Create event
269
- st.write("Add a new event:")
270
  event_subject = st.text_input("Event Subject")
271
  event_date = st.date_input("Event Date")
272
  event_time = st.time_input("Event Time")
273
- if st.button("Add Event"):
274
  event_start = datetime.combine(event_date, event_time)
275
  event_end = event_start + timedelta(hours=1)
276
  new_event = {
@@ -430,12 +485,79 @@ def handle_onedrive_integration(access_token):
430
  else:
431
  st.error("Failed to delete file.")
432
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
433
 
434
 
435
 
436
  def main():
437
  st.title("πŸ¦„ MS Graph API with AI & Cloud Integration for M365")
438
 
 
 
 
439
  st.sidebar.title("πŸ“ M365 Products")
440
  st.sidebar.write("Select products to integrate:")
441
 
@@ -475,6 +597,15 @@ def main():
475
  except Exception as e:
476
  st.error(f"Error acquiring access token: {str(e)}")
477
  st.stop()
 
 
 
 
 
 
 
 
 
478
  else:
479
  access_token = st.session_state['access_token']
480
 
@@ -492,9 +623,36 @@ def main():
492
  handle_tasks_integration(access_token)
493
  elif product == "πŸ—‚οΈ OneDrive":
494
  handle_onedrive_integration(access_token)
495
- # Add more product integrations here
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
496
  else:
497
  st.write("No products selected. Please select products from the sidebar.")
 
498
 
499
  if __name__ == "__main__":
500
  main()
 
11
  AUTHORITY_URL = 'https://login.microsoftonline.com/common'
12
  REDIRECT_URI = 'https://huggingface.co/spaces/awacke1/MSGraphAPI'
13
 
14
+ # 1. Configuration
15
+ Site_Name = '🏠Event πŸ“…Schedule and πŸ“Agenda πŸ”Dashboard'
16
+ title="🏠Event πŸ“…Schedule and πŸ“Agenda πŸ”Dashboard"
17
+ helpURL='https://huggingface.co/awacke1'
18
+ bugURL='https://huggingface.co/spaces/awacke1'
19
+ icons='πŸ“…'
20
+ #icons = Image.open("icons.ico")
21
+ st.set_page_config(
22
+ page_title=title,
23
+ page_icon=icons,
24
+ layout="wide",
25
+ #initial_sidebar_state="expanded",
26
+ initial_sidebar_state="auto",
27
+ menu_items={
28
+ 'Get Help': helpURL,
29
+ 'Report a bug': bugURL,
30
+ 'About': title
31
+ }
32
+ )
33
+
34
+ # Sticky navigation menu
35
+ def sticky_menu():
36
+ st.markdown(
37
+ """
38
+ <style>
39
+ .menu-bar {
40
+ position: -webkit-sticky;
41
+ position: sticky;
42
+ top: 0;
43
+ background-color: white;
44
+ z-index: 999;
45
+ padding: 10px;
46
+ border-bottom: 1px solid #f0f0f0;
47
+ }
48
+ .menu-bar a {
49
+ margin: 0 10px;
50
+ padding: 5px;
51
+ text-decoration: none;
52
+ color: #000;
53
+ }
54
+ .menu-bar a:hover {
55
+ background-color: #f0f0f0;
56
+ }
57
+ </style>
58
+ <div class="menu-bar">
59
+ <a href="#dashboard">1️⃣ Dashboard</a>
60
+ <a href="#landing-page">🏠 Landing Page</a>
61
+ <a href="#upcoming-events">πŸ“… Upcoming Events</a>
62
+ <a href="#schedule">πŸ“† Schedule</a>
63
+ <a href="#agenda">πŸ“ Agenda</a>
64
+ <a href="#event-details">πŸ” Event Details</a>
65
+ <a href="#add-event">βž• Add Event</a>
66
+ <a href="#filter-by">πŸ”Ž Filter By</a>
67
+ </div>
68
+ """,
69
+ unsafe_allow_html=True
70
+ )
71
+
72
  # Define product to scope mapping, links, AI capabilities, and Graph solutions
73
  PRODUCT_SCOPES = {
74
  "πŸ“§ Outlook": {
 
87
  'scopes': ['Tasks.ReadWrite'],
88
  'link': 'https://to-do.office.com/tasks/',
89
  'ai_capabilities': "πŸ€–πŸ“ Task prioritization",
90
+ 'graph_solution': "βœ… Task & plan management"
91
  },
92
  "πŸ—‚οΈ OneDrive": {
93
  'scopes': ['Files.ReadWrite.All'],
 
95
  'ai_capabilities': "πŸ€–πŸ” Smart file organization",
96
  'graph_solution': "πŸ“ File & folder API"
97
  },
98
+ "πŸ—ƒοΈ SharePoint": {
99
+ 'scopes': ['Sites.Read.All', 'Sites.ReadWrite.All'],
100
+ 'link': 'https://www.microsoft.com/microsoft-365/sharepoint/collaboration',
101
+ 'ai_capabilities': "πŸ€–πŸ” Smart search & tagging",
102
+ 'graph_solution': "🌐 Sites & lists API"
103
+ },
104
+ "πŸ“… Teams": {
105
+ 'scopes': ['Team.ReadBasic.All', 'Channel.ReadBasic.All'],
106
+ 'link': 'https://teams.microsoft.com/',
107
+ 'ai_capabilities': "πŸ€–πŸ’¬ Meeting insights & summaries",
108
+ 'graph_solution': "πŸ‘₯ Teams & chats API"
109
+ },
110
+ "πŸ“š Microsoft Bookings": {
111
+ 'scopes': ['Bookings.Read.All', 'Bookings.ReadWrite.All'],
112
+ 'link': 'https://outlook.office.com/bookings/',
113
+ 'ai_capabilities': "πŸ€–πŸ“… Smart scheduling",
114
+ 'graph_solution': "πŸ“† Booking services API"
115
+ },
116
+ "πŸ—£οΈ Translator": {
117
+ 'scopes': ['Translation.Read'],
118
+ 'link': 'https://www.microsoft.com/translator/',
119
+ 'ai_capabilities': "πŸ€–πŸŒ Real-time translation",
120
+ 'graph_solution': "πŸ—¨οΈ Translation services API"
121
+ },
122
+ "πŸ““ Loop": {
123
+ 'scopes': ['Files.ReadWrite.All'],
124
+ 'link': 'https://loop.microsoft.com/',
125
+ 'ai_capabilities': "πŸ€–πŸ”„ Real-time collaboration AI",
126
+ 'graph_solution': "πŸ” Workspace API"
127
+ },
128
+ "πŸ”— Azure OpenAI Service": {
129
+ 'scopes': ['AzureAIServices.ReadWrite.All'],
130
+ 'link': 'https://azure.microsoft.com/products/cognitive-services/openai-service/',
131
+ 'ai_capabilities': "πŸ€–πŸ§  Custom AI model access",
132
+ 'graph_solution': "πŸ”Œ AI model integration API"
133
+ },
134
+ "🧠 Copilot": {
135
+ 'scopes': ['Cognitive.Read'],
136
+ 'link': 'https://www.microsoft.com/microsoft-365/copilot',
137
+ 'ai_capabilities': "πŸ€–πŸš€ Cross-app AI assistance",
138
+ 'graph_solution': "🧠 AI integration API"
139
+ },
140
  "πŸ“’ OneNote": {
141
  'scopes': ['Notes.Read', 'Notes.Create'],
142
  'link': 'https://www.onenote.com/notebooks',
 
155
  'ai_capabilities': "πŸ€–βœοΈ Smart drafting & editing",
156
  'graph_solution': "πŸ“ Document content API"
157
  },
 
 
 
 
 
 
 
 
 
 
 
 
158
  "πŸ’¬ Viva": {
159
  'scopes': ['Analytics.Read'],
160
  'link': 'https://www.microsoft.com/microsoft-viva',
 
167
  'ai_capabilities': "πŸ€–βš™οΈ AI-powered automation",
168
  'graph_solution': "πŸ”§ Workflow & app API"
169
  },
 
 
 
 
 
 
170
  "πŸ’‘ PowerPoint": {
171
  'scopes': ['Files.ReadWrite.All'],
172
  'link': 'https://www.office.com/launch/powerpoint',
173
  'ai_capabilities': "πŸ€–πŸŽ¨ Design & coaching AI",
174
  'graph_solution': "πŸ“Š Presentation API"
175
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  }
177
 
178
  BASE_SCOPES = ['User.Read']
 
316
  day_placeholders[day].write(f"{start_date.strftime('%H:%M')} - {event['subject']}")
317
  else:
318
  st.write("No events found or unable to fetch events.")
319
+
320
+ # Anchor for Add Event
321
+ st.markdown("<a id='add-event'></a>", unsafe_allow_html=True)
322
 
323
+ # Create event βž• Add Event
324
+ st.write("βž• Add New Event:")
325
  event_subject = st.text_input("Event Subject")
326
  event_date = st.date_input("Event Date")
327
  event_time = st.time_input("Event Time")
328
+ if st.button("βž• Add Event"):
329
  event_start = datetime.combine(event_date, event_time)
330
  event_end = event_start + timedelta(hours=1)
331
  new_event = {
 
485
  else:
486
  st.error("Failed to delete file.")
487
 
488
+ def handle_sharepoint_integration(access_token):
489
+ st.subheader("πŸ—ƒοΈ SharePoint Integration")
490
+ st.markdown(f"[Open SharePoint]({PRODUCT_SCOPES['πŸ—ƒοΈ SharePoint']['link']})")
491
+ st.write("Smart search & tagging features coming soon.")
492
+
493
+ def handle_teams_integration(access_token):
494
+ st.subheader("πŸ“… Teams Integration")
495
+ st.markdown(f"[Open Teams]({PRODUCT_SCOPES['πŸ“… Teams']['link']})")
496
+ st.write("Meeting insights & summaries features coming soon.")
497
+
498
+ def handle_bookings_integration(access_token):
499
+ st.subheader("πŸ“š Microsoft Bookings Integration")
500
+ st.markdown(f"[Open Microsoft Bookings]({PRODUCT_SCOPES['πŸ“š Microsoft Bookings']['link']})")
501
+ st.write("Smart scheduling features coming soon.")
502
+
503
+ def handle_translator_integration(access_token):
504
+ st.subheader("πŸ—£οΈ Translator Integration")
505
+ st.markdown(f"[Open Translator]({PRODUCT_SCOPES['πŸ—£οΈ Translator']['link']})")
506
+ st.write("Real-time translation features coming soon.")
507
+
508
+ def handle_loop_integration(access_token):
509
+ st.subheader("πŸ““ Loop Integration")
510
+ st.markdown(f"[Open Loop]({PRODUCT_SCOPES['πŸ““ Loop']['link']})")
511
+ st.write("Real-time collaboration AI features coming soon.")
512
+
513
+ def handle_openai_service_integration(access_token):
514
+ st.subheader("πŸ”— Azure OpenAI Service Integration")
515
+ st.markdown(f"[Open Azure OpenAI Service]({PRODUCT_SCOPES['πŸ”— Azure OpenAI Service']['link']})")
516
+ st.write("Custom AI model access features coming soon.")
517
+
518
+ def handle_copilot_integration(access_token):
519
+ st.subheader("🧠 Copilot Integration")
520
+ st.markdown(f"[Open Copilot]({PRODUCT_SCOPES['🧠 Copilot']['link']})")
521
+ st.write("Cross-app AI assistance features coming soon.")
522
+
523
+ def handle_onenote_integration(access_token):
524
+ st.subheader("πŸ“’ OneNote Integration")
525
+ st.markdown(f"[Open OneNote]({PRODUCT_SCOPES['πŸ“’ OneNote']['link']})")
526
+ st.write("Content suggestion & OCR features coming soon.")
527
+
528
+ def handle_excel_integration(access_token):
529
+ st.subheader("πŸ“Š Excel Integration")
530
+ st.markdown(f"[Open Excel]({PRODUCT_SCOPES['πŸ“Š Excel']['link']})")
531
+ st.write("Data analysis & insights features coming soon.")
532
+
533
+ def handle_word_integration(access_token):
534
+ st.subheader("πŸ“„ Word Integration")
535
+ st.markdown(f"[Open Word]({PRODUCT_SCOPES['πŸ“„ Word']['link']})")
536
+ st.write("Smart drafting & editing features coming soon.")
537
+
538
+ def handle_viva_integration(access_token):
539
+ st.subheader("πŸ’¬ Viva Integration")
540
+ st.markdown(f"[Open Viva]({PRODUCT_SCOPES['πŸ’¬ Viva']['link']})")
541
+ st.write("Personalized insights features coming soon.")
542
+
543
+ def handle_power_platform_integration(access_token):
544
+ st.subheader("πŸš€ Power Platform Integration")
545
+ st.markdown(f"[Open Power Platform]({PRODUCT_SCOPES['πŸš€ Power Platform']['link']})")
546
+ st.write("AI-powered automation features coming soon.")
547
+
548
+ def handle_powerpoint_integration(access_token):
549
+ st.subheader("πŸ’‘ PowerPoint Integration")
550
+ st.markdown(f"[Open PowerPoint]({PRODUCT_SCOPES['πŸ’‘ PowerPoint']['link']})")
551
+ st.write("Design & coaching AI features coming soon.")
552
 
553
 
554
 
555
  def main():
556
  st.title("πŸ¦„ MS Graph API with AI & Cloud Integration for M365")
557
 
558
+ # Sticky Menu
559
+ sticky_menu()
560
+
561
  st.sidebar.title("πŸ“ M365 Products")
562
  st.sidebar.write("Select products to integrate:")
563
 
 
597
  except Exception as e:
598
  st.error(f"Error acquiring access token: {str(e)}")
599
  st.stop()
600
+
601
+ fragment = query_params.get('code', [None])[0] # For example, 'add-event'
602
+ # Handle section jumping based on the URL fragment
603
+ if fragment:
604
+ st.write(f"Detected URL fragment: {fragment}")
605
+ # Simulate the scrolling or jump based on fragment
606
+ if fragment == 'add-event':
607
+ st.markdown("<script>document.getElementById('add-event').scrollIntoView();</script>", unsafe_allow_html=True)
608
+
609
  else:
610
  access_token = st.session_state['access_token']
611
 
 
623
  handle_tasks_integration(access_token)
624
  elif product == "πŸ—‚οΈ OneDrive":
625
  handle_onedrive_integration(access_token)
626
+ elif product == "πŸ—ƒοΈ SharePoint":
627
+ handle_sharepoint_integration(access_token)
628
+ elif product == "πŸ“… Teams":
629
+ handle_teams_integration(access_token)
630
+ elif product == "πŸ“š Microsoft Bookings":
631
+ handle_bookings_integration(access_token)
632
+ elif product == "πŸ—£οΈ Translator":
633
+ handle_translator_integration(access_token)
634
+ elif product == "πŸ““ Loop":
635
+ handle_loop_integration(access_token)
636
+ elif product == "πŸ”— Azure OpenAI Service":
637
+ handle_openai_service_integration(access_token)
638
+ elif product == "🧠 Copilot":
639
+ handle_copilot_integration(access_token)
640
+ elif product == "πŸ“’ OneNote":
641
+ handle_onenote_integration(access_token)
642
+ elif product == "πŸ“Š Excel":
643
+ handle_excel_integration(access_token)
644
+ elif product == "πŸ“„ Word":
645
+ handle_word_integration(access_token)
646
+ elif product == "πŸ’¬ Viva":
647
+ handle_viva_integration(access_token)
648
+ elif product == "πŸš€ Power Platform":
649
+ handle_power_platform_integration(access_token)
650
+ elif product == "πŸ’‘ PowerPoint":
651
+ handle_powerpoint_integration(access_token)
652
+
653
  else:
654
  st.write("No products selected. Please select products from the sidebar.")
655
+
656
 
657
  if __name__ == "__main__":
658
  main()