fix sort at package list 89/107089/1
authorShaabanEltanany <shaaban.eltanany.ext@orange.com>
Tue, 5 May 2020 09:01:44 +0000 (11:01 +0200)
committerShaabanEltanany <shaaban.eltanany.ext@orange.com>
Tue, 5 May 2020 09:01:44 +0000 (11:01 +0200)
Issue-ID: CCSDK-2320
Signed-off-by: ShaabanEltanany <shaaban.eltanany.ext@orange.com>
Change-Id: Ia91d519c315b6ef0c01089422253599b137eceec

cds-ui/designer-client/src/app/modules/feature-modules/packages/packages-api.service.ts
cds-ui/server/src/controllers/blueprint-rest.controller.ts
cds-ui/server/src/datasources/blueprint.datasource-template.ts
cds-ui/server/src/services/blueprint.service.ts
ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt

index 2332d8e..8275f8c 100644 (file)
@@ -37,10 +37,12 @@ export class PackagesApiService {
     }
 
     getPagedPackages(pageNumber: number, pageSize: number, sortBy: string): Observable<BluePrintPage[]> {
+        const sortType = sortBy.includes('DATE') ? 'DESC' : 'ASC';
         return this.api.get(BlueprintURLs.getPagedBlueprints, {
             offset: pageNumber,
             limit: pageSize,
-            sort: sortBy
+            sort: sortBy,
+            sortType
         });
     }
 
@@ -56,11 +58,12 @@ export class PackagesApiService {
     }
 
     getPagedPackagesByKeyWord(keyWord: string, pageNumber: number, pageSize: number, sortBy: string) {
-
+        const sortType = sortBy.includes('DATE') ? 'DESC' : 'ASC';
         return this.api.get(BlueprintURLs.getMetaDatePageable + '/' + keyWord, {
             offset: pageNumber,
             limit: pageSize,
-            sort: sortBy
+            sort: sortBy,
+            sortType
         });
     }
 }
index 7b2c783..2319e0a 100644 (file)
@@ -20,34 +20,14 @@ limitations under the License.
 */
 
 
-import {
-  Count,
-  CountSchema,
-  Filter,
-  repository,
-  Where,
-} from '@loopback/repository';
-import {
-  post,
-  param,
-  get,
-  getFilterSchemaFor,
-  getWhereSchemaFor,
-  patch,
-  put,
-  del,
-  requestBody,
-  Request,
-  Response,
-  RestBindings,
-} from '@loopback/rest';
+import {get, param, post, Request, requestBody, Response, RestBindings} from '@loopback/rest';
 import {Blueprint} from '../models';
 import {inject} from '@loopback/core';
 import {BlueprintService} from '../services';
 import * as fs from 'fs';
 import * as multiparty from 'multiparty';
 import * as request_lib from 'request';
-import {processorApiConfig, appConfig} from '../config/app-config';
+import {appConfig, processorApiConfig} from '../config/app-config';
 import {bluePrintManagementServiceGrpcClient} from '../clients/blueprint-management-service-grpc-client';
 import {BlueprintDetail} from '../models/blueprint.detail.model';
 
@@ -94,8 +74,9 @@ export class BlueprintRestController {
   async getPagedBlueprints(
     @param.query.number('limit') limit: number,
     @param.query.number('offset') offset: number,
-    @param.query.string('sort') sort: string) {
-    return await this.bpservice.getPagedBueprints(limit, offset, sort);
+    @param.query.string('sort') sort: string,
+    @param.query.string('sortType') sortType: string) {
+    return await this.bpservice.getPagedBueprints(limit, offset, sort, sortType);
   }
 
   @get('/controllerblueprint/metadata/paged/{keyword}', {
@@ -110,8 +91,9 @@ export class BlueprintRestController {
     @param.path.string('keyword') keyword: string,
     @param.query.number('limit') limit: number,
     @param.query.number('offset') offset: number,
-    @param.query.string('sort') sort: string) {
-    return await this.bpservice.getMetaDataPagedBlueprints(limit, offset, sort, keyword);
+    @param.query.string('sort') sort: string,
+    @param.query.string('sortType') sortType: string) {
+    return await this.bpservice.getMetaDataPagedBlueprints(limit, offset, sort, keyword, sortType);
   }
 
   @get('/controllerblueprint/meta-data/{keyword}', {
index d7ac14b..9b8e06a 100644 (file)
@@ -73,7 +73,7 @@ export default {
         {
             "template": {
                 "method": "GET",
-                "url": processorApiConfig.http.url + "/blueprint-model/paged?limit={limit}&offset={offset}&sort={sort}",
+                "url": processorApiConfig.http.url + "/blueprint-model/paged?limit={limit}&offset={offset}&sort={sort}&sortType={sortType}",
                 "headers": {
                     "accepts": "application/json",
                     "content-type": "application/json",
@@ -82,13 +82,13 @@ export default {
                 "responsePath": "$",
             },
             "functions": {
-                "getPagedBueprints": ["limit", "offset", "sort"],
+                "getPagedBueprints": ["limit", "offset", "sort","sortType"],
             }
         },
         {
             "template": {
                 "method": "GET",
-                "url": processorApiConfig.http.url + "/blueprint-model/paged/meta-data/{keyword}?limit={limit}&offset={offset}&sort={sort}",
+                "url": processorApiConfig.http.url + "/blueprint-model/paged/meta-data/{keyword}?limit={limit}&offset={offset}&sort={sort}&sortType={sortType}",
                 "headers": {
                     "accepts": "application/json",
                     "content-type": "application/json",
@@ -97,7 +97,7 @@ export default {
                 "responsePath": "$",
             },
             "functions": {
-                "getMetaDataPagedBlueprints": ["limit", "offset", "sort", "keyword"],
+                "getMetaDataPagedBlueprints": ["limit", "offset", "sort", "keyword","sortType"],
             }
         },
         {
index cb601f3..2680e10 100644 (file)
@@ -7,8 +7,8 @@ export interface BlueprintService {
    getAllblueprints(): Promise<any>;
    getBlueprintsByKeyword(keyword: string): Promise<any>;
    getByTags(tags: string): Promise<JSON>;
-   getPagedBueprints(limit: number, offset: number , sort: string): Promise<any>;
-   getMetaDataPagedBlueprints(limit: number, offset: number, sort: string, keyword: string): Promise<any>;
+   getPagedBueprints(limit: number, offset: number , sort: string,sortType: String): Promise<any>;
+   getMetaDataPagedBlueprints(limit: number, offset: number, sort: string, keyword: string,sortType: String): Promise<any>;
    getBlueprintByNameAndVersion(name:string, version:string): Promise<any>;
 
 
index 1f01d1c..3973f36 100644 (file)
@@ -89,9 +89,11 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint
     fun allBlueprintModel(
         @RequestParam(defaultValue = "20") limit: Int,
         @RequestParam(defaultValue = "0") offset: Int,
-        @RequestParam(defaultValue = "DATE") sort: BlueprintSortByOption
+        @RequestParam(defaultValue = "DATE") sort: BlueprintSortByOption,
+        @RequestParam(defaultValue = "ASC") sortType: String
     ): Page<BlueprintModelSearch> {
-        val pageRequest = PageRequest.of(offset, limit, Sort.Direction.ASC, sort.columnName)
+        val pageRequest = PageRequest.of(offset, limit,
+                Sort.Direction.fromString(sortType), sort.columnName)
         return this.bluePrintModelHandler.allBlueprintModel(pageRequest)
     }
 
@@ -110,9 +112,11 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint
         @NotNull @PathVariable(value = "keyword") keyWord: String,
         @RequestParam(defaultValue = "20") limit: Int,
         @RequestParam(defaultValue = "0") offset: Int,
-        @RequestParam(defaultValue = "DATE") sort: BlueprintSortByOption
+        @RequestParam(defaultValue = "DATE") sort: BlueprintSortByOption,
+        @RequestParam(defaultValue = "ASC") sortType: String
     ): Page<BlueprintModelSearch> {
-        val pageRequest = PageRequest.of(offset, limit, Sort.Direction.ASC, sort.columnName)
+        val pageRequest = PageRequest.of(offset, limit,
+                Sort.Direction.fromString(sortType), sort.columnName)
         return this.bluePrintModelHandler.searchBluePrintModelsByKeyWordPaged(keyWord, pageRequest)
     }