مستوى الترميز:
مبتدئ
المدة: 15 دقيقة
نوع المشروع: التشغيل الآلي باستخدام عامل تشغيل مستند إلى الحدث
الأهداف
- افهم ما يفعله الحل.
- تعرّف على ما تقوم به خدمات "برمجة تطبيقات Google" ضمن الحل.
- ابدأ إعداد النص البرمجي.
- شغِّل النص البرمجي.
لمحة عن هذا الحلّ
يمكنك إنشاء مستندات جدول الأعمال تلقائيًا في "مستندات Google" وإرفاقها اجتماعات "تقويم Google"
آلية العمل
ينشئ النص البرمجي قالب مستند لجدول أعمال. عند تحديث يتحقّق النص البرمجي لمعرفة ما إذا كانت أي أحداث تمتلكها تتضمن "#agenda" بوصة الوصف. إذا كانت العلامة موجودة، سينشئ النص البرمجي نسخة من النموذج، وإضافته إلى حدث التقويم ومشاركته مع ضيوف الحدث.
خدمات برمجة التطبيقات
يستخدم هذا الحلّ الخدمات التالية:
- خدمة Drive: للتحقّق مما إذا كان النموذج مستند حالي وإذا لم يكن كذلك، يتم إنشاء مجلد جديد للنموذج جلسة المراجعة. ينشئ نسخة من مستند النموذج لكل جدول أعمال جديد.
- خدمة المستند: لإنشاء جدول الأعمال القالب.
- خدمة التقويم: للبحث عن الأحداث التي تتضمن "#جدول أعمال" علامة وتحديث وصف الحدث برابط إلى جدول الأعمال مستند
- الخدمة الأساسية: تستخدم الفئة
Session
للحصول على عنوان البريد الإلكتروني للمستخدم. يساعد هذا في إنشاء المشغل للمستخدم الحالي. - خدمة النص البرمجي: تنشئ مشغِّلاً يتم تنشيطه. كلما حدث تغيير في تقويم المستخدم.
المتطلبات الأساسية
لاستخدام هذا النموذج، تحتاج إلى المتطلبات الأساسية التالية:
- حساب Google (قد يكون لدى حسابات Google Workspace طلب موافقة المشرف).
- متصفح ويب متصل بالإنترنت.
إعداد النص البرمجي
- انقر على الزر أدناه لفتح النموذج إنشاء جدول أعمال للاجتماعات.
مشروع برمجة التطبيقات.
فتح المشروع - انقر على رمز نظرة عامة .
- في صفحة النظرة العامة، انقر على رمز "إنشاء نسخة" .
- في المشروع المنسوخ، اختَر setUp في القائمة المنسدلة للدوال.
- انقر على تشغيل.
- امنح الإذن للنص البرمجي عندما يُطلب منك ذلك. إذا عرضت شاشة موافقة OAuth التحذير، لم يتم التحقق من هذا التطبيق، المتابعة من خلال اختيار إعدادات متقدّمة > انتقِل إلى {Project Name} (غير آمن).
تشغيل النص البرمجي
- افتَح تقويم Google.
- أنشِئ حدثًا جديدًا أو عدِّل حدثًا حاليًا.
- في الوصف، أضِف
#agenda
واحفظ الحدث. - تحقَّق من بريدك الإلكتروني بحثًا عن إشعار عبر البريد الإلكتروني بأنّه تمت مشاركة مستند. معك، أو قم بتحديث التقويم وانقر على مرة أخرى لمشاهدة الرابط إلى مستند جدول الأعمال.
يتلقى جميع الحاضرين إشعارًا عبر البريد الإلكتروني لعرض جدول الأعمال. تشير رسالة الأشكال البيانية يمنح البرنامج النصي الحاضرين الإذن بتعديله، لكن يمكنك تعديل النص البرمجي من أجل تحديث أذونات مستندات جدول الأعمال للحاضرين
مراجعة الرمز البرمجي
لمراجعة رمز "برمجة تطبيقات Google" لهذا الحلّ، انقر على عرض رمز المصدر أدناه:
عرض رمز المصدر
Code.gs
التعديلات
يمكنك تعديل العيّنة بالقدر الذي تريده وفقًا لاحتياجاتك. فيما يلي بعض التغييرات الاختيارية التي يمكنك إجراؤها.
تحديث أذونات مستندات جدول الأعمال للضيوف
يمنح النص البرمجي الحاضرين الإذن بالتعديل. إذا كنت ترغب في
حصر الأذونات للعرض فقط، استبدال طريقة addEditor
باستخدام الطريقة addViewer
في الجزء التالي من الرمز:
for (let i in event.getGuestList()) { let guest = event.getGuestList()[i]; newDoc.addEditor(guest.getEmail());
تعديل نموذج مستند جدول الأعمال
لتعديل نموذج مستند جدول الأعمال، اتّبِع الخطوات التالية:
- بعد إنشاء أول جدول أعمال لك في حدث في التقويم، افتح Google Drive.
- افتح المجلد المُسمى Agenda Maker - App.
- افتح مستند نموذج جدول الأعمال## وأجرِ التعديلات التي تريدها.
المساهمون
تم إنشاء هذه العينة بواسطة جيريمي غلاسنبرغ، إدارة المنتجات والنظام الأساسي مستشار استراتيجية. يمكنك البحث عن "جيريمي" على Twitter من خلال @jglassenberg.
تحتفظ Google بهذه العينة بمساعدة خبراء التطوير في Google.