mirror of
				https://github.com/ClusterCockpit/cc-backend
				synced 2025-10-31 16:05:06 +01:00 
			
		
		
		
	Merge pull request #366 from ClusterCockpit/hotfix
fix: always return hasNextPage boolean to frontend
This commit is contained in:
		| @@ -354,30 +354,28 @@ func (r *queryResolver) Jobs(ctx context.Context, filter []*model.JobFilter, pag | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	if !config.Keys.UiDefaults["job_list_usePaging"].(bool) { | ||||
| 		hasNextPage := false | ||||
| 		// page.Page += 1 		   : Simple, but expensive | ||||
| 		// Example Page 4 @ 10 IpP : Does item 41 exist? | ||||
| 		// Minimal Page 41 @ 1 IpP : If len(result) is 1, Page 5 @ 10 IpP exists. | ||||
| 		nextPage := &model.PageRequest{ | ||||
| 			ItemsPerPage: 1, | ||||
| 			Page:         ((page.Page * page.ItemsPerPage) + 1), | ||||
| 		} | ||||
|  | ||||
| 		nextJobs, err := r.Repo.QueryJobs(ctx, filter, nextPage, order) | ||||
| 		if err != nil { | ||||
| 			log.Warn("Error while querying next jobs") | ||||
| 			return nil, err | ||||
| 		} | ||||
|  | ||||
| 		if len(nextJobs) == 1 { | ||||
| 			hasNextPage = true | ||||
| 		} | ||||
|  | ||||
| 		return &model.JobResultList{Items: jobs, Count: &count, HasNextPage: &hasNextPage}, nil | ||||
| 	} else { | ||||
| 		return &model.JobResultList{Items: jobs, Count: &count}, nil | ||||
| 	// Note: Even if App-Default 'config.Keys.UiDefaults["job_list_usePaging"]' is set, always return hasNextPage boolean. | ||||
| 	// Users can decide in frontend to use continuous scroll, even if app-default is paging! | ||||
| 	/* | ||||
| 	  Example Page 4 @ 10 IpP : Does item 41 exist? | ||||
| 	  Minimal Page 41 @ 1 IpP : If len(result) is 1, Page 5 @ 10 IpP exists. | ||||
| 	*/ | ||||
| 	nextPage := &model.PageRequest{ | ||||
| 		ItemsPerPage: 1, | ||||
| 		Page:         ((page.Page * page.ItemsPerPage) + 1), | ||||
| 	} | ||||
| 	nextJobs, err := r.Repo.QueryJobs(ctx, filter, nextPage, order) | ||||
| 	if err != nil { | ||||
| 		log.Warn("Error while querying next jobs") | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	hasNextPage := false | ||||
| 	if len(nextJobs) == 1 { | ||||
| 		hasNextPage = true | ||||
| 	} | ||||
|  | ||||
| 	return &model.JobResultList{Items: jobs, Count: &count, HasNextPage: &hasNextPage}, nil | ||||
| } | ||||
|  | ||||
| // JobsStatistics is the resolver for the jobsStatistics field. | ||||
|   | ||||
| @@ -231,7 +231,7 @@ | ||||
|   <Col xs={12} md={6} xl={3} class="mb-3 mb-xxl-0"> | ||||
|     {#if $initq.error} | ||||
|       <Card body color="danger">{$initq.error.message}</Card> | ||||
|     {:else if $initq.data} | ||||
|     {:else if $initq?.data} | ||||
|       <Card class="overflow-auto" style="height: 400px;"> | ||||
|         <TabContent> <!-- on:tab={(e) => (status = e.detail)} --> | ||||
|           {#if $initq.data?.job?.metaData?.message} | ||||
| @@ -305,7 +305,7 @@ | ||||
| <Card class="mb-3"> | ||||
|   <CardBody> | ||||
|     <Row class="mb-2"> | ||||
|       {#if $initq.data} | ||||
|       {#if $initq?.data} | ||||
|         <Col xs="auto"> | ||||
|             <Button outline on:click={() => (isMetricsSelectionOpen = true)} color="primary"> | ||||
|               Select Metrics (Selected {selectedMetrics.length} of {availableMetrics.size} available) | ||||
| @@ -318,7 +318,7 @@ | ||||
|     {#if $jobMetrics.error} | ||||
|       <Row class="mt-2"> | ||||
|         <Col> | ||||
|           {#if $initq.data.job.monitoringStatus == 0 || $initq.data.job.monitoringStatus == 2} | ||||
|           {#if $initq?.data && ($initq.data.job?.monitoringStatus == 0 || $initq.data.job?.monitoringStatus == 2)} | ||||
|             <Card body color="warning">Not monitored or archiving failed</Card> | ||||
|             <br /> | ||||
|           {/if} | ||||
| @@ -365,7 +365,7 @@ | ||||
| <!-- Statistcics Table --> | ||||
| <Row class="mb-3"> | ||||
|   <Col> | ||||
|     {#if $initq.data} | ||||
|     {#if $initq?.data} | ||||
|       <Card> | ||||
|         <TabContent> | ||||
|           {#if somethingMissing} | ||||
| @@ -440,7 +440,7 @@ | ||||
|   </Col> | ||||
| </Row> | ||||
|  | ||||
| {#if $initq.data} | ||||
| {#if $initq?.data} | ||||
|   <MetricSelection | ||||
|     cluster={$initq.data.job.cluster} | ||||
|     subCluster={$initq.data.job.subCluster} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user