Project

General

Profile

« Previous | Next » 

Revision 51057

add login components, create admin connect Guard, use env.properties

View differences:

entities.component.ts
1 1
import { Component, ViewChild, OnInit } from '@angular/core';
2
import { ActivatedRoute } from "@angular/router";
2 3
import { HelpContentService } from "../../services/help-content.service";
3 4
import { FormGroup } from "@angular/forms";
4 5
import { ModalFormComponent } from "../modal-form.component";
......
6 7
import { EntityFormComponent } from "./entity-form.component";
7 8
import { CheckEntity, Entity } from "../../domain/entity";
8 9
import { Community } from "../../domain/community";
10
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
9 11

  
10 12
@Component({
11 13
    selector: 'entities',
......
44 46
    public okModal:ModalFormComponent;
45 47
public toggleIds: string[];
46 48
public toggleStatus: boolean;
49
public properties:EnvProperties = null;
47 50

  
48 51
    ngOnInit() {
49
        this.getCommunities();
52
      this.formGroup = this.formComponent.form;
53
      this.route.data
54
        .subscribe((data: { envSpecific: EnvProperties }) => {
55
           this.properties = data.envSpecific;
56
           this.getCommunities();
57
      });
50 58

  
51
        this.formGroup = this.formComponent.form;
52 59
    }
53 60

  
54
    constructor(private _helpContentService: HelpContentService) {}
61
    constructor(private route: ActivatedRoute, private _helpContentService: HelpContentService) {}
55 62

  
56 63
    getCommunities() {
57 64
        let self = this;
58
        this._helpContentService.getCommunities().subscribe(
65
        this._helpContentService.getCommunities(this.properties.adminToolsAPIURL).subscribe(
59 66
            communities => {
60 67
                self.communities = communities;
61 68
                self.selectedCommunityPid = self.communities[0].pid;
......
66 73

  
67 74
    getEntities(community_pid: string) {
68 75
        let self = this;
69
        this._helpContentService.getCommunityEntities(community_pid).subscribe(
76
        this._helpContentService.getCommunityEntities(community_pid, this.properties.adminToolsAPIURL).subscribe(
70 77
            entities => {
71 78
                self.entities = entities;
72 79
                self.checkboxes = [];
......
113 120
    }
114 121

  
115 122
    public confirmedDeleteEntities(ids : string[]) {
116
        this._helpContentService.deleteEntities(ids).subscribe(
123
        this._helpContentService.deleteEntities(ids, this.properties.adminToolsAPIURL).subscribe(
117 124
            _ => this.deleteEntitiesFromArray(ids),
118 125
            error => this.handleError('System error deleting the selected entities', error)
119 126
        );
......
177 184
    }
178 185

  
179 186
    public continueToggling(event: any) {
180
      this._helpContentService.toggleEntities(this.selectedCommunityPid,this.toggleIds,this.toggleStatus).subscribe(
187
      this._helpContentService.toggleEntities(this.selectedCommunityPid,this.toggleIds,this.toggleStatus, this.properties.adminToolsAPIURL).subscribe(
181 188
          () => {
182 189
            for(let id of this.toggleIds) {
183 190
              let i = this.checkboxes.findIndex(_ => _.entity._id == id);

Also available in: Unified diff