當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript CoreSitesProvider.getSite方法代碼示例

本文整理匯總了TypeScript中@providers/sites.CoreSitesProvider.getSite方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript CoreSitesProvider.getSite方法的具體用法?TypeScript CoreSitesProvider.getSite怎麽用?TypeScript CoreSitesProvider.getSite使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@providers/sites.CoreSitesProvider的用法示例。


在下文中一共展示了CoreSitesProvider.getSite方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: ionViewDidLoad

    /**
     * View loaded.
     */
    ionViewDidLoad(): void {
        if (this.siteConfig) {
            this.identityProviders = this.loginHelper.getValidIdentityProviders(this.siteConfig);
        }

        this.sitesProvider.getSite(this.siteId).then((site) => {
            this.site = {
                id: site.id,
                fullname: site.infos.fullname,
                avatar: site.infos.userpictureurl
            };

            this.username = site.infos.username;
            this.siteUrl = site.infos.siteurl;
            this.siteName = site.infos.sitename;

            // Check logoURL if user avatar is not set.
            if (this.site.avatar.startsWith(site.infos.siteurl + '/theme/image.php')) {
                this.site.avatar = false;

                return site.getPublicConfig().then((config) => {
                    this.logoUrl = config.logourl || config.compactlogourl;
                }).catch(() => {
                    // Ignore errors.
                });
            }
        }).catch(() => {
            // Shouldn't happen. Just leave the view.
            this.cancel();
        });

    }
開發者ID:jleyva,項目名稱:moodlemobile2,代碼行數:35,代碼來源:reconnect.ts

示例2: getEntry

    /**
     * Get an online or offline entry.
     *
     * @param  {any} data             Database.
     * @param  {number} entryId       Entry ID.
     * @param  {any} [offlineActions] Offline data with the actions done. Required for offline entries.
     * @param  {string} [siteId]      Site ID. If not defined, current site.
     * @return {Promise<any>}         Promise resolved with the entry.
     */
    getEntry(data: any, entryId: number, offlineActions?: any, siteId?: string): Promise<any> {
        if (entryId > 0) {
            // It's an online entry, get it from WS.
            return this.dataProvider.getEntry(data.id, entryId, siteId);
        }

        // It's an offline entry, search it in the offline actions.
        return this.sitesProvider.getSite(siteId).then((site) => {
            const offlineEntry = offlineActions.find((offlineAction) => offlineAction.action == 'add');

            if (offlineEntry) {
                const siteInfo = site.getInfo();

                return {entry: {
                        id: offlineEntry.entryid,
                        canmanageentry: true,
                        approved: !data.approval || data.manageapproved,
                        dataid: offlineEntry.dataid,
                        groupid: offlineEntry.groupid,
                        timecreated: -offlineEntry.entryid,
                        timemodified: -offlineEntry.entryid,
                        userid: siteInfo.userid,
                        fullname: siteInfo.fullname,
                        contents: {}
                    }
                };
            }
        });
    }
開發者ID:jleyva,項目名稱:moodlemobile2,代碼行數:38,代碼來源:helper.ts


注:本文中的@providers/sites.CoreSitesProvider.getSite方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。