Skip to content

Commit

Permalink
Merge pull request #2 from conterra/favourite_update
Browse files Browse the repository at this point in the history
Favourite update
  • Loading branch information
cherry13579 authored Dec 4, 2024
2 parents ad5a567 + 44c1bd5 commit c20d9c6
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 14 deletions.
8 changes: 6 additions & 2 deletions src/main/js/bundles/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ This bundle allows to add portal content to your map.apps app.
{
"id": "my-content",
"title": "${ui.spaceFilters.my-content}"
},
{
"id": "fav",
"title": "${ui.spaceFilters.fav}"
}
],
"spaceFilter": "all",
Expand Down Expand Up @@ -113,8 +117,8 @@ This bundle allows to add portal content to your map.apps app.
| portals | Object | | | used portal |
| rowsPerPageItems | Array | ``` 10 ``` |``` 25``` |```50``` |```100``` | ``` 10 ``` |``` 25``` |```50``` |```100``` | possible number of rows per page |
| pagination | Object | [``` 10 ``` |``` 25``` |```50``` |```100``` ] | ``` 10 ``` | number of rows per page |
| spaceFilter | Array | ```all``` | ``` orgarnisation``` | ```my-content``` | ```all``` | all possible filter portal spaces |
| spaceFilters | Array | ```all``` | ``` orgarnisation``` | ```my-content``` | ```all``` | filter portal space |
| spaceFilter | Array | ```all``` | ``` orgarnisation``` | ```my-content```| ```fav``` | ```all``` | all possible filter portal spaces |
| spaceFilters | Array | ```all``` | ``` orgarnisation``` | ```my-content```| ```fav``` | ```all``` | filter portal space |



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default class PortalItemLoaderWidgetController {
});
}

queryPortalItems(pagination: any, searchText: string, spaceFilter: "all" | "organisation" | "my-content", typeFilter: string,
queryPortalItems(pagination: any, searchText: string, spaceFilter: "all" | "organisation" | "my-content" | "fav", typeFilter: string,
sortAscending: boolean,
sortByField: string): void {
const model = this.portalItemLoaderModel;
Expand All @@ -102,8 +102,9 @@ export default class PortalItemLoaderWidgetController {
}, 500);
}

private changeSelectedPortal(portalId: string) {
private changeSelectedPortal(portalId: string): void {
const model = this.portalItemLoaderModel;
model.spaceFilter = "all";
const selectedPortal = model.portals.find((portalConfig) => portalConfig.id === portalId);
const portal = this.portal = new Portal({ url: selectedPortal.url, authMode: selectedPortal.authMode || "auto" });
portal.load().then(() => {
Expand All @@ -115,7 +116,7 @@ export default class PortalItemLoaderWidgetController {
});
}

private async queryPortal(portal: __esri.Portal, pagination: any, searchText: string, spaceFilter: "all" | "organisation" | "my-content", typeFilter: string,
private async queryPortal(portal: __esri.Portal, pagination: any, searchText: string, spaceFilter: "all" | "organisation" | "my-content" | "fav", typeFilter: string,
sortAscending: boolean, sortByField: string): Promise<__esri.PortalQueryResult> {
const page = pagination.page;
const rowsPerPage = pagination.rowsPerPage;
Expand All @@ -125,19 +126,27 @@ export default class PortalItemLoaderWidgetController {
const filter = "typeKeywords:Service";
switch (spaceFilter) {
case "all":
query = "1=1";
case "fav":
break;
case "organisation":
query = "orgid:" + portal.user.orgId;
break;
case "my-content":
query = "owner:" + portal.user.username;
break;

}
if (searchText !== "") {
query += " AND (title:" + searchText + " OR description:" + searchText + " OR snippet:" + searchText + " OR tags:" + searchText + ")";
if (searchText !== "" && searchText !== undefined) {
if (query === "") {
query += " AND ";
}
query += "(title:" + searchText + " OR description:" + searchText + " OR snippet:" + searchText + " OR tags:" + searchText + ")";
}
if (typeFilter !== "all") {
query += " AND type:" + typeFilter;
if (query === "") {
query += " AND ";
}
query += "type:" + typeFilter;
}
const queryParams: __esri.PortalQueryParamsProperties = {
query: query,
Expand All @@ -147,9 +156,13 @@ export default class PortalItemLoaderWidgetController {
num: rowsPerPage,
start: page * rowsPerPage - rowsPerPage + 1
};

const abortController = this.abortController = new AbortController();
return portal.queryItems(queryParams, { signal: abortController.signal });
if (spaceFilter === "fav") {
return portal.user.queryFavorites(queryParams);
}
else {
return portal.queryItems(queryParams, { signal: abortController.signal });
}
}

private loginToPortal(): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface PortalItemLoaderModelProps {
pagination: object,
portalFilter: string,
spaceFilters: any[],
spaceFilter: "all" | "organisation" | "my-content",
spaceFilter: "all" | "organisation" | "my-content" | "fav",
typeFilter: string,
typeFilters: any[],
searchText: "",
Expand Down
4 changes: 4 additions & 0 deletions src/main/js/bundles/dn_portalitemloader/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@
{
"id": "my-content",
"title": "${ui.spaceFilters.my-content}"
},
{
"id": "fav",
"title": "${ui.spaceFilters.fav}"
}
],
"spaceFilter": "all",
Expand Down
3 changes: 2 additions & 1 deletion src/main/js/bundles/dn_portalitemloader/nls/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ module.exports = {
spaceFilters: {
all: "Everywhere",
organisation: "Only my organisation",
"my-content": "Only my content"
"my-content": "Only my content",
fav:"My favourites"
},
allLayers: {
all: "Everywhere",
Expand Down
3 changes: 2 additions & 1 deletion src/main/js/bundles/dn_portalitemloader/nls/de/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ module.exports = {
spaceFilters: {
all: "Überall",
organisation: "Nur meine Organisation",
"my-content": "Nur meine Inhalte"
"my-content": "Nur meine Inhalte",
fav:"Meine Favoriten"
},
allLayers: {
all: "Everywhere",
Expand Down

0 comments on commit c20d9c6

Please sign in to comment.