Пример #1
0
  onOpenRequestsNext: function(nextPageLink) {
    var operation = this.requestCancellableOperation(OPERATION.LIST);

    if (operation) {
      this.setInData(['itemsLoading'], true);
      this.emitChange();

      operation.forPromise(services.loadNextPage(nextPageLink)).then((result) => {
        var items = mergeItems(this.data.items.asMutable(),
            result.documentLinks.map((documentLink) => result.documents[documentLink]));

        this.processItems(items, result.nextPageLink);
      });
    }
    this.emitChange();
  },
Пример #2
0
  onOpenHostsNext: function(queryOptions, nextPageLink) {
    this.setInData(['listView', 'queryOptions'], queryOptions);

    var operation = this.requestCancellableOperation(OPERATION.LIST, queryOptions);

    if (operation) {
      this.cancelOperations(OPERATION.DETAILS);
      this.setInData(['listView', 'itemsLoading'], true);

      operation.forPromise(services.loadNextPage(nextPageLink)).then((result) => {
        let documents = result.documentLinks.map((documentLink) =>
            result.documents[documentLink]).filter(({customProperties}) =>
                customProperties && customProperties.__computeContainerHost);
        let nextPageLink = result.nextPageLink;

        // Transforming to the model of the view
        let hosts = documents.map((document) => toViewModel(document));
        this.getPlacementZonesForHostsCall(hosts).then((result) => {
          hosts.forEach((host) => {
            host.epzs.forEach((epz) => {
              if (result[epz.epzLink]) {
                epz.epzName = result[epz.epzLink].resourcePoolState.name;
              }
            });
          });

          this.setInData(['listView', 'items'],
              utils.mergeDocuments(this.data.listView.items.asMutable(), hosts));
          this.setInData(['listView', 'itemsLoading'], false);
          this.setInData(['listView', 'nextPageLink'], nextPageLink);
          this.emitChange();
        });
      });
    }

    this.emitChange();
  },