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


TypeScript sp-pnp-js.setup函數代碼示例

本文整理匯總了TypeScript中sp-pnp-js.setup函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript setup函數的具體用法?TypeScript setup怎麽用?TypeScript setup使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: resolve

    return new Promise<void>((resolve) => {
      if (!this.properties.tasksListTitle) {
        resolve();
        return;
      }

      let batch: any = pnp.sp.createBatch();
      let today: Date = new Date();
      today.setHours(0, 0, 0, 0);

      pnp.setup({
        spfxContext: this.context
      });

      pnp.sp.web.get().then((web: any) => { console.log(web); });

      pnp.sp.web.lists.getByTitle(this.properties.tasksListTitle).views.getByTitle('Late Tasks').inBatch(batch).get().then((view: any) => {
        this._viewUrl = `${view.ServerRelativeUrl}?FilterField1=AssignedTo&FilterValue1=${escape(this.context.pageContext.user.displayName)}`;
      });

      pnp.sp.web.lists.getByTitle(this.properties.tasksListTitle)
        .items.expand('AssignedTo/Id').select('Title, AssignedTo, AssignedTo/Id, DueDate')
        .filter(`AssignedTo/Id eq ${this.context.pageContext.legacyPageContext.userId} and DueDate lt datetime'${today.toISOString()}' and (PercentComplete eq '' or PercentComplete eq '100%')`)
        .get().then((items: any) => {
          this._dueTasks = items;
        });

      batch.execute().then(() => {
        this._renderPlaceholder();
        resolve();
      });
    });
開發者ID:AdrianDiaz81,項目名稱:sp-dev-fx-extensions,代碼行數:32,代碼來源:DueTasksApplicationCustomizer.ts

示例2:

    return super.onInit().then(_ => {

      pnp.setup({
        spfxContext: this.context
      });

    });
開發者ID:,項目名稱:,代碼行數:7,代碼來源:

示例3: resolve

    return new Promise<ISPList[]>((resolve: any) => {
      pnp.setup({
        headers: {
          "Accept": "application/json; odata=verbose",
        },
      });

      pnp.sp.web.lists.get().then((response: any) => {

        let items: ISPList[] = [];

        response.forEach(function (item: any) {
          items.push({ Title: item.Title, Id: item.Id });

        });

        resolve(items);
      });
    });
開發者ID:lebiku,項目名稱:webpack-react,代碼行數:19,代碼來源:SharepointListClient.ts

示例4: onInit

  @override
  public onInit(): Promise<void> {
    Log.info(LOG_SOURCE, `Initialized ${strings.Title}`);

    //Configure PnP JS Core
    pnp.setup({
      spfxContext: this.context
    });

    try {
      //Grab the placeholders that the page currently offers
      let pagePlaceHolders: ReadonlyArray<PlaceholderName> = this.context.placeholderProvider.placeholderNames;

      //Get our list of placeholders
      PlaceholderItems.GetItems(this.context.pageContext.web.id.toString()).then((data: IPlaceholderItem[]) => {

        //Loop through returned placeholders
        data.forEach((element: IPlaceholderItem) => {

          //Look for a matching placeholder in the list of official placeholders
          let index: Number = pagePlaceHolders.indexOf(PlaceholderName[element.Title]);
          if (index !== -1) {

            //Grab the placeholder
            let currentPlaceholder: PlaceholderContent = this.context.placeholderProvider.tryCreateContent(PlaceholderName[element.Title]);

            //Insert our content
            currentPlaceholder.domElement.innerHTML = element.SPFxContent;
          }
        });
      }
      );
    }
    finally {
    }



    return Promise.resolve<void>();
  }
開發者ID:AdrianDiaz81,項目名稱:sp-dev-fx-extensions,代碼行數:40,代碼來源:PlaceholdersExtensionApplicationCustomizer.ts

示例5: onInit

  @override
  public async onInit(): Promise<void> {
    Log.info(LOG_SOURCE, `Initialized ${strings.Title}`);

    // Added to handle possible changes on the existence of placeholders
    // this.context.placeholderProvider.changedEvent.add(this, this._renderPlaceHolders);

    // Configure caching
    pnp.setup({
      defaultCachingStore: "session",
      defaultCachingTimeoutSeconds: 900, //15min
      globalCacheDisable: false // true to disable caching in case of debugging/testing
    });

    // Retrieve the menu items from taxonomy
    let termStoreService: SPTermStore.SPTermStoreService = new SPTermStore.SPTermStoreService({
      spHttpClient: this.context.spHttpClient,
      siteAbsoluteUrl: this.context.pageContext.web.absoluteUrl,
    });

    if (this.properties.TopMenuTermSet != null) {
      let cachedTerms = pnp.storage.session.get(NAV_TERMS_KEY);
      if(cachedTerms != null){
        this._topMenuItems = cachedTerms;
      }
      else {
        this._topMenuItems = await termStoreService.getTermsFromTermSetAsync(this.properties.TopMenuTermSet, this.context.pageContext.web.language);
        pnp.storage.session.put(NAV_TERMS_KEY,this._topMenuItems);
      }
    }
    if (this.properties.BottomMenuTermSet != null) {
      this._bottomMenuItems = await termStoreService.getTermsFromTermSetAsync(this.properties.BottomMenuTermSet, this.context.pageContext.web.language);
    }

    // Call render method for generating the needed html elements
    this._renderPlaceHolders();

    return Promise.resolve<void>();
  }
開發者ID:AdrianDiaz81,項目名稱:sp-dev-fx-extensions,代碼行數:39,代碼來源:TenantGlobalNavBarApplicationCustomizer.ts


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