Project

General

Profile

« Previous | Next » 

Revision 60565

[admin tool| new-UI branch]

- Zenodo Communities - new UI
- Fixes in subjects

View differences:

zenodo-communities.component.ts
17 17
import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes';
18 18
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
19 19
import {Title} from '@angular/platform-browser';
20
import {properties} from '../../../environments/environment';
21
import {Subscription} from 'rxjs';
20 22

  
21 23
@Component({
22 24
    selector: 'zenodo-communities',
23 25
    template: `
24
      <div id="manage-communities">
25
        <div class="menubar uk-margin-bottom ">
26
          <a *ngIf="!toggle" (click)="toggleAction()"   class="uk-button uk-button-primary uk-float-right">{{toggleLinkMessage}}</a>
27
          <div class="manage-projects-title uk-text-large">{{pageTitle}}</div>
28
        </div>
26
<!--      <div id="manage-communities">-->
27
<!--        <div class="menubar uk-margin-bottom ">-->
28
<!--          <a *ngIf="!toggle" (click)="toggleAction()"   class="uk-button uk-button-primary uk-float-right">{{toggleLinkMessage}}</a>-->
29
<!--          <div class="manage-projects-title uk-text-large">{{pageTitle}}</div>-->
30
<!--        </div>-->
29 31

  
30 32
        <div *ngIf="toggle"  >
31 33
            <div *ngIf="zenodoSearchUtils.status == errorCodes.LOADING "
......
37 39
                   No zenodo communities found
38 40
            </div>
39 41

  
40
           <manage-zenodo-communities *ngIf="zenodoSearchUtils.status != errorCodes.LOADING && zenodoSearchUtils.status != errorCodes.ERROR" [masterCommunity]=masterZenodoCommunity [(selectedCommunities)]=selectedCommunities  [properties]=properties [communityId]=communityId  [(searchUtils)]=zenodoSearchUtils></manage-zenodo-communities>
41
          <fab *ngIf="zenodoSearchUtils.status != errorCodes.LOADING && zenodoSearchUtils.status != errorCodes.ERROR" (clicked)="toggleAction()" ></fab>
42
           <manage-zenodo-communities *ngIf="zenodoSearchUtils.status != errorCodes.LOADING && zenodoSearchUtils.status != errorCodes.ERROR" [masterCommunity]=masterZenodoCommunity [selectedCommunities]=selectedCommunities  [properties]=properties [communityId]=communityId  [searchUtils]=zenodoSearchUtils (toggleView)="toggleAction()"></manage-zenodo-communities>
43
<!--          <fab *ngIf="zenodoSearchUtils.status != errorCodes.LOADING && zenodoSearchUtils.status != errorCodes.ERROR" (clicked)="toggleAction()" ></fab>-->
42 44
        </div>
43 45
        <div  *ngIf="!toggle" >
44
           <add-zenodo-communities [masterCommunity]=masterZenodoCommunity [(selectedCommunities)]=selectedCommunities [properties]=properties [communityId]=communityId ></add-zenodo-communities>
46
           <add-zenodo-communities [masterCommunity]=masterZenodoCommunity [selectedCommunities]=selectedCommunities [properties]=properties [communityId]=communityId (toggleView)="toggleAction()" ></add-zenodo-communities>
45 47
        </div>
46
      </div>
48
<!--      </div>-->
49

  
47 50
    `
48 51
})
49 52

  
......
51 54
  private communityId: string = null;
52 55
  private community: CommunityInfo = null;
53 56

  
54
  @Input() communityProjects = [];
55
  @ViewChild (ManageZenodoCommunitiesComponent) manageZenodoCommunitiesComponent: ManageZenodoCommunitiesComponent ;
56
  @ViewChild (AddZenodoCommunitiesComponent) addZenodoCommunitiesComponent: AddZenodoCommunitiesComponent ;
57
  // @Input()
58
  communityProjects = [];
59
  // @ViewChild (ManageZenodoCommunitiesComponent) manageZenodoCommunitiesComponent: ManageZenodoCommunitiesComponent ;
60
  // @ViewChild (AddZenodoCommunitiesComponent) addZenodoCommunitiesComponent: AddZenodoCommunitiesComponent ;
57 61

  
58 62
  public warningMessage = '';
59 63
  public infoMessage = '';
......
75 79
  zenodocommunitiesloadedCount = 0;
76 80
  zenodoSearchUtils: SearchUtilsClass = new SearchUtilsClass();
77 81
  private errorCodes: ErrorCodes = new ErrorCodes();
78

  
82
  subscriptions = [];
79 83
  constructor(private element: ElementRef, private route: ActivatedRoute, private _router: Router,
80
              private _ΖenodoCommunitieService: ZenodoCommunitiesService, private title: Title,
84
              private _zenodoCommunitieService: ZenodoCommunitiesService, private title: Title,
81 85
              private _communityService: CommunityService,
82 86
              private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService) {}
83 87

  
84 88
    ngOnInit() {
85 89
      this.zenodoSearchUtils.status = this.errorCodes.LOADING;
86
        this.route.data.subscribe((data: { envSpecific: EnvProperties }) => {
87
        this.properties = data.envSpecific;
88
          this.route.queryParams.subscribe(params => {
90
         this.properties = properties;
91
          this.route.params.subscribe(params => {
89 92
            HelperFunctions.scroll();
90

  
91
            if (params['communityId']) {
92
              this.communityId = params['communityId'];
93
            this.communityId = params['community'];
94
            if (this.communityId) {
93 95
              this.title.setTitle('Administration Dashboard | Zenodo Communities');
94 96
              if (!Session.isLoggedIn()) {
95 97
                this._router.navigate(['/user-info'], {
......
97 99
              } else {
98 100
                if (this.communityId != null && this.communityId !== '') {
99 101

  
100
                    this._communityService.getCommunity(this.communityId).subscribe (
102
                  this.subscriptions.push(this._communityService.getCommunityAsObservable().subscribe (
101 103
                      community => {
102 104
                            this.community = community;
103 105
                            this.masterZenodoCommunityId = this.community.zenodoCommunity;
104 106
                            if (this.masterZenodoCommunityId) {
105
                              this.enodoCommunitieService.getZenodoCommunityById(this.properties,
107
                              this.subscriptions.push(this._zenodoCommunitieService.getZenodoCommunityById(this.properties,
106 108
                                  this.properties.zenodoCommunities + this.masterZenodoCommunityId,
107 109
                                  null).subscribe(
108 110
                                  result  => {
......
116 118
                                this.masterZenodoCommunity = emptyCommunity;
117 119
                                // console.log("Master Zenodo community'"+this.masterZenodoCommunityId+"' couldn't be loaded");
118 120
                              }
119
                            );
121
                            ));
120 122
                            }
121 123
                            this.zenodoSearchUtils.status = this.errorCodes.LOADING;
122 124
                            this._searchZenodoCommunitiesService.searchZCommunities(this.properties, this.communityId).subscribe (
......
144 146
                        console.log('Community couldn\'t be loaded');
145 147
                        this.zenodoSearchUtils.status = this.errorCodes.ERROR;
146 148
                      }
147
                    );
149
                    ));
148 150

  
149 151

  
150 152
                }
......
152 154

  
153 155

  
154 156
            }
155
          });
157

  
156 158
        });
157 159
}
160
  ngOnDestroy() {
161
    this.subscriptions.forEach(subscription => {
162
      if (subscription instanceof Subscription) {
163
        subscription.unsubscribe();
164
      }
165
    });
166
  }
158 167

  
159

  
160

  
161
  public ngOnDestroy() {}
162

  
163 168
  public toggleAction() {
164 169
    if (!Session.isLoggedIn()) {
165 170
      this._router.navigate(['/user-info'], {
......
179 184
  }
180 185

  
181 186
  getZenodoCommunityById(zenodoid, openaireId) {
182
    this.enodoCommunitieService.getZenodoCommunityById(this.properties,
187
    this.subscriptions.push(this._zenodoCommunitieService.getZenodoCommunityById(this.properties,
183 188
        this.properties.zenodoCommunities + zenodoid, openaireId).subscribe(
184 189
        result  => {
185 190
                 this.selectedCommunities.push(result);
......
202 207
      }
203 208
      console.log('Zenodo community\'' + zenodoid + '\' couldn\'t be loaded');
204 209
    }
205
  );
210
  ));
206 211
  }
207 212
}

Also available in: Unified diff