Skip to content
Snippets Groups Projects
Commit 4d08840d authored by digrazia2038's avatar digrazia2038
Browse files

Implemented public dashboards

parent 64fdc9a9
No related branches found
No related tags found
No related merge requests found
Showing
with 98 additions and 5 deletions
......@@ -10,6 +10,8 @@ import { MenuType } from '../../../model/enumeration/menu-type.model';
import { DashboardCloneWizardComponent } from '../dashboard-clone-wizard/dashboard-clone-wizard.component';
import { TargetCrudService } from '../services/target-crud.service';
import { OidcUserInformationService } from '../../../auth/services/oidc-user-information.service';
import { UserCrudService } from '../services/user-crud.service';
import { IGroupRepresentation } from '../../../model/group-representation.model';
@Component({
selector: 'ngx-dashboard-card-view',
......@@ -22,7 +24,7 @@ export class DashboardCardViewComponent implements OnInit {
constructor(private route: ActivatedRoute, private service: DashboardPageCrudService, private translateService: TranslateService,
private toastrService: NbToastrService, private router: Router, private dashboardCloneService: DashboardCloneWizardComponent,
private targetService: TargetCrudService,
private userService: OidcUserInformationService,
private userService: OidcUserInformationService, private userCrudService: UserCrudService
) {
route.params.subscribe(params => {
if (params['dashboardType'] != undefined && params['dashboardType'] != null) {
......@@ -55,6 +57,9 @@ export class DashboardCardViewComponent implements OnInit {
);
this.getSharedWithUser();
this.getSharedWithRole();
this.getSharedWithGroup();
this.getPublic();
}
openDashboard(dashboardId: number) {
this.dashboardCloneService.previewDashboard(dashboardId);
......@@ -100,6 +105,10 @@ export class DashboardCardViewComponent implements OnInit {
);
}
getSharedWithRole(){
console.log(this.userService.user);
console.log("GROUP IDM")
this.userCrudService.getIdmGroups().subscribe(res => {console.log(res)});
console.log()
this.targetService.getAll().subscribe(
(data) => {
for (let i = 0; i < data.length; i++) {
......@@ -118,6 +127,33 @@ export class DashboardCardViewComponent implements OnInit {
error => (this.showError(error))
);
}
getSharedWithGroup(){
let groups: string[] = [];
this.targetService.getAll().subscribe(
(data) => {
this.userCrudService.getUserGroups(this.userService.user.preferred_username)
.subscribe(res => {
groups = Object.keys(res);
console.log(groups)
for (let i = 0; i < data.length; i++) {
for(let j = 0; j<groups.length; j++){
if (data[i].createdBy !== this.userService.user.preferred_username && data[i].name == groups[j]) {
this.service.getPageById(data[i].dashboardPage.id.toString()).subscribe(res => {
if(res.type.toString()=== this.dashboardType.toString()){
this.pages.push(res);
}
});
}
}
}
});
},
error => (this.showError(error))
);
}
getPublic(){
this.targetService.getAll().subscribe(
(data) => {
......@@ -130,7 +166,7 @@ export class DashboardCardViewComponent implements OnInit {
// console.log(data[i].name);
console.log("IS EQUAL");
this.service.getPageById(data[i].dashboardPage.id.toString()).subscribe(res => {
if(res.type.toString()=== this.dashboardType.toString()){
if(data[i].name === this.dashboardType.toString()){
console.log("LOG-----> getPageById----> res");
console.log(res);
this.pages.push(res);
......
......@@ -17,6 +17,7 @@ import { DashboardSharingComponent } from '../dashboard-sharing/dashboard-sharin
import { DashboardPageCrudService } from '../services/dashboard-page-crud.service';
import { MenuBlockCrudService } from '../services/menu-block-crud.service';
import { TargetCrudService } from '../services/target-crud.service';
import { UserCrudService } from '../services/user-crud.service';
@Component({
selector: 'ngx-manage-dashboard-page',
......@@ -37,7 +38,7 @@ export class ManageDashboardPageComponent implements OnInit {
private toastrService: NbToastrService,
private targetService: TargetCrudService,
private userService: OidcUserInformationService,
private dashboardCloneService: DashboardCloneWizardComponent,
private dashboardCloneService: DashboardCloneWizardComponent, private userCrudService: UserCrudService
) {
this.initTableSettings();
}
......@@ -84,6 +85,8 @@ export class ManageDashboardPageComponent implements OnInit {
error => (this.showError(error))
);
this.getSharedWithRole();
this.getSharedWithGroup();
this.getPublic();
}
getSharedWithRole() {
......@@ -105,6 +108,49 @@ export class ManageDashboardPageComponent implements OnInit {
);
}
getSharedWithGroup() {
let groups: string[] = [];
this.targetService.getAll().subscribe(
(data) => {
this.userCrudService.getUserGroups(this.userService.user.preferred_username)
.subscribe(res => {
groups = Object.keys(res);
console.log(groups)
for (let i = 0; i < data.length; i++) {
for (let j = 0; j < groups.length; j++) {
if (data[i].createdBy !== this.userService.user.preferred_username && data[i].name == groups[j]) {
this.service.getPageById(data[i].dashboardPage.id.toString()).subscribe(res => {
this.pages.push(res);
this.source.empty();
this.source.load(this.pages);
});
}
}
}
});
},
error => (this.showError(error))
);
}
getPublic(){
this.targetService.getAll().subscribe(
(data) => {
for (let i = 0; i < data.length; i++) {
if (data[i].name === "PUBLIC") {
console.log("IS EQUAL");
this.service.getPageById(data[i].dashboardPage.id.toString()).subscribe(res => {
this.pages.push(res);
this.source.empty();
this.source.load(this.pages);
});
}
}
},
error => (this.showError(error))
);
}
showSuccess() {
this.toastrService.success(this.translateService.instant('dashboardPage.deleted'), this.translateService.instant('general.success'));
}
......
......@@ -32,4 +32,8 @@ export class UserCrudService {
return this.http.get<Array<string>>(`${this.apiURL}/user/get-user-roles`);
}
getUserGroups(username:string): Observable<Array<string>> {
return this.http.get<Array<string>>(`${this.apiURL}/user/get-user-groups/${username}`);
}
}
......@@ -45,7 +45,8 @@
</button>
<!-- GROUPS -->
<!-- <nb-select *ngIf="!useIDM4Target" size="small" placeholder="{{'target.select_group'|translate}}" formControlName="selectedAvailableGroup"
<nb-select *ngIf="!useIDM4Target" size="small" placeholder="{{'target.select_group'|translate}}" formControlName="selectedAvailableGroup"
nbTooltip="{{'target.select_group'|translate}}">
<nb-option *ngFor="let group of filterTarget(fullListAvailableGroup,'GROUP'); " [value]="group">
{{group.code}} - {{group.value}}
......@@ -59,7 +60,7 @@
</nb-select>
<button nbButton size="small" status="primary" (click)="addTargetGroup()">
<nb-icon icon="globe-2-outline"></nb-icon>{{'general.add' | translate}} {{'TargetType.GROUP'| translate}}
</button> -->
</button>
</div>
......
This diff is collapsed.
[{"id": "urn:ngsi-ld:MapLayer:Bilbao:air_quality", "alternateName": "bilbao_air_quality.geojson", "name": "bilbao_air_quality", "description": "test", "type": "MapLayer", "@context": ["https://smartdatamodels.org/context.jsonld", "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld", "https://git.code.tecnalia.com/urbanite/public/-/raw/main/datamodels/maplayer-ngsi.jsonld"], "map": {"@context": ["https://smartdatamodels.org/context.jsonld"], "type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"coordinates": [-2.935188110338201, 43.26750551179745], "type": "Point"}, "properties": {"name": "60", "type": "GtfsShape", "no": 2.19, "no2": 15.29, "nox": 12.06, "o3": 71.88, "pm10": 14.0, "pm25": 10.14, "so2": 3.2}}, {"type": "Feature", "geometry": {"coordinates": [-2.902376115931137, 43.25491056506432], "type": "Point"}, "properties": {"name": "62", "type": "GtfsShape", "no": 2.19, "no2": 15.29, "nox": 12.06, "o3": 71.88, "pm10": 14.0, "pm25": 10.14, "so2": 3.2}}, {"type": "Feature", "geometry": {"coordinates": [-2.960475856567045, 43.245553729819484], "type": "Point"}, "properties": {"name": "92", "type": "GtfsShape", "no": 2.19, "no2": 15.29, "nox": 12.06, "o3": 71.88, "pm10": 14.0, "pm25": 10.14, "so2": 3.2}}, {"type": "Feature", "geometry": {"coordinates": [-2.9475439999557134, 43.26522199716327], "type": "Point"}, "properties": {"name": "88", "type": "GtfsShape", "no": 2.19, "no2": 15.29, "nox": 12.06, "o3": 71.88, "pm10": 14.0, "pm25": 10.14, "so2": 3.2}}, {"type": "Feature", "geometry": {"coordinates": [-2.953278416670214, 43.28099012364825], "type": "Point"}, "properties": {"name": "87", "type": "GtfsShape", "no": 2.19, "no2": 15.29, "nox": 12.06, "o3": 71.88, "pm10": 14.0, "pm25": 10.14, "so2": 3.2}}, {"type": "Feature", "geometry": {"coordinates": [-2.945656664175787, 43.25880286639215], "type": "Point"}, "properties": {"name": "81", "type": "GtfsShape", "no": 2.19, "no2": 15.29, "nox": 12.06, "o3": 71.88, "pm10": 14.0, "pm25": 10.14, "so2": 3.2}}]}}]
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
{"@context": ["https://smartdatamodels.org/context.jsonld"], "type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"coordinates": [-2.935188110338201, 43.26750551179745], "type": "Point"}, "properties": {"name": "60", "type": "GtfsShape", "no": 2.19, "no2": 15.29, "nox": 12.06, "o3": 71.88, "pm10": 14.0, "pm25": 10.14, "so2": 3.2}}, {"type": "Feature", "geometry": {"coordinates": [-2.902376115931137, 43.25491056506432], "type": "Point"}, "properties": {"name": "62", "type": "GtfsShape", "no": 2.19, "no2": 15.29, "nox": 12.06, "o3": 71.88, "pm10": 14.0, "pm25": 10.14, "so2": 3.2}}, {"type": "Feature", "geometry": {"coordinates": [-2.960475856567045, 43.245553729819484], "type": "Point"}, "properties": {"name": "92", "type": "GtfsShape", "no": 2.19, "no2": 15.29, "nox": 12.06, "o3": 71.88, "pm10": 14.0, "pm25": 10.14, "so2": 3.2}}, {"type": "Feature", "geometry": {"coordinates": [-2.9475439999557134, 43.26522199716327], "type": "Point"}, "properties": {"name": "88", "type": "GtfsShape", "no": 2.19, "no2": 15.29, "nox": 12.06, "o3": 71.88, "pm10": 14.0, "pm25": 10.14, "so2": 3.2}}, {"type": "Feature", "geometry": {"coordinates": [-2.953278416670214, 43.28099012364825], "type": "Point"}, "properties": {"name": "87", "type": "GtfsShape", "no": 2.19, "no2": 15.29, "nox": 12.06, "o3": 71.88, "pm10": 14.0, "pm25": 10.14, "so2": 3.2}}, {"type": "Feature", "geometry": {"coordinates": [-2.945656664175787, 43.25880286639215], "type": "Point"}, "properties": {"name": "81", "type": "GtfsShape", "no": 2.19, "no2": 15.29, "nox": 12.06, "o3": 71.88, "pm10": 14.0, "pm25": 10.14, "so2": 3.2}}]}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment