Project

General

Profile

« Previous | Next » 

Revision 56889

View differences:

modules/uoa-repository-dashboard-gui/trunk/src/app/pages/adminPg/registration.component.ts
1
import {Component, OnInit} from '@angular/core';
2
import {noServiceMessage} from '../../domain/shared-messages';
3
import {Country, RepositorySnippet} from '../../domain/typeScriptClasses';
4
import {RepositoryService} from '../../services/repository.service';
5
import {FormBuilder, FormGroup} from '@angular/forms';
6
import {ActivatedRoute, Params, Router} from '@angular/router';
7
import {URLParameter} from '../../domain/url-parameter';
8

  
9
@Component({
10
  selector: 'app-registration',
11
  templateUrl: 'registration.component.html',
12
  styleUrls: ['./registration.component.css']
13
})
14

  
15
export class RegistrationComponent implements OnInit {
16

  
17
  errorMessage: string;
18
  successMessage: string;
19
  loadingMessage: string;
20
  countries: Country[] = [];
21
  repositorySnippet: RepositorySnippet[] = [];
22
  urlParams: URLParameter[] = [];
23
  thisIsForBadUse: RepositorySnippet[] = []; // remove if page total is fixed!!!
24

  
25
  formPrepare = {
26
    country: '',
27
    typology: '',
28
    englishName: '',
29
    officialName: '',
30
    requestSortBy: 'registrationdate',
31
    order: 'DESCENDING',
32
    page: '0',
33
    size: '25'
34
  };
35

  
36
  dataForm: FormGroup;
37

  
38
  constructor(private repoService: RepositoryService,
39
              private fb: FormBuilder,
40
              private route: ActivatedRoute,
41
              private router: Router) { }
42

  
43
  ngOnInit() {
44
    this.dataForm = this.fb.group(this.formPrepare);
45
    const tempUrlParams = new Array<URLParameter>();
46

  
47
    this.route.queryParams
48
      .subscribe(params => {
49
        for (const i in params) {
50
          this.dataForm.get(i).setValue(params[i]);
51
        }
52
        for (let i in this.dataForm.controls) {
53
          if (this.dataForm.get(i).value) {
54
            tempUrlParams.push({key: i, value: [this.dataForm.get(i).value]});
55
          }
56
        }
57
        this.handleChange();
58
      },
59
      error => this.errorMessage = <any>error
60
    );
61

  
62
    this.getCountries();
63

  
64

  
65
  }
66

  
67
  getCountries() {
68
    this.repoService.getCountries()
69
      .subscribe(
70
        countries => this.countries = countries.sort(function (a, b) {
71
          if (a.name < b.name) {
72
            return -1;
73
          } else if (a.name > b.name) {
74
            return 1;
75
          } else {
76
            return 0;
77
          }
78
        }),
79
        error => {
80
          this.loadingMessage = '';
81
          this.errorMessage = noServiceMessage;
82
          console.log(error);
83
        }
84
      );
85
  }
86

  
87
  getRegisteredRepositories(urlParams: URLParameter[]) {
88
    this.repoService.searchRegisteredRepositories(this.dataForm.get('page').value,
89
      this.dataForm.get('size').value, urlParams).subscribe(
90
        suc => this.repositorySnippet = suc,
91
        error => console.log(error),
92
      );
93
  }
94

  
95
  handleChange() {
96
    const tempUrlParams = new Array<URLParameter>();
97
    const map: { [name: string]: string; } = {};
98

  
99
    for (let i in this.dataForm.controls) {
100
      if (this.dataForm.get(i).value !== '') {
101
        tempUrlParams.push({key: i, value: [this.dataForm.get(i).value]});
102
        map[i] = this.dataForm.get(i).value;
103
      }
104
    }
105

  
106
    this.router.navigate([`/admin/registrations`],
107
      {queryParams: map});
108
    this.getRegisteredRepositories(tempUrlParams);
109
  }
110

  
111
  handleChangeAndResetPage() {
112
    this.dataForm.get('page').setValue(0);
113
    this.handleChange();
114
  }
115

  
116
  getCountryName(countryCode): string {
117
    for (const country of Object.values(this.countries)) {
118
      if (country.code === countryCode) {
119
        return country.name;
120
      }
121
    }
122
  }
123

  
124
  previousPage() {
125
    if (this.dataForm.get('page').value > 0) {
126
      this.dataForm.get('page').setValue(+this.dataForm.get('page').value - 1);
127
      this.handleChange();
128
    }
129
  }
130

  
131
  nextPage() {
132
    /** remove when page total is fixed!!! **/
133
    const tempUrlParams = new Array<URLParameter>();
134
    for (let i in this.dataForm.controls) {
135
      if (this.dataForm.get(i).value !== '') {
136
        tempUrlParams.push({key: i, value: [this.dataForm.get(i).value]});
137
      }
138
    }
139
      this.repoService.searchRegisteredRepositories(+this.dataForm.get('page').value + 1,
140
      this.dataForm.get('size').value, tempUrlParams).subscribe(
141
      suc => this.thisIsForBadUse = suc,
142
      error => console.log(error),
143
      () => {
144
        if (!(this.thisIsForBadUse.length === 0)) {
145
          this.dataForm.get('page').setValue(+this.dataForm.get('page').value + 1);
146
          this.handleChange();
147
        }
148
      }
149
    );
150
    /** **/
151

  
152
  }
153

  
154
}
modules/uoa-repository-dashboard-gui/trunk/src/app/pages/adminPg/registration.component.css
1
.uk-form-horizontal .uk-form-label {
2
  width: 100px;
3
}
4

  
5
.uk-form-horizontal .uk-form-controls {
6
  margin-left: 115px;
7
}
8

  
9
.uk-search-default .uk-search-input {
10
  padding-left: 15px;
11
  padding-right: 15px;
12
}
modules/uoa-repository-dashboard-gui/trunk/src/app/pages/adminPg/registration.component.html
1
<div class="uk-grid-margin uk-grid uk-grid-stack" uk-grid="">
2
  <div class="uk-width-1-1@m uk-first-column">
3

  
4
    <h1 class="uk-h2">Registrations Admin Page</h1>
5

  
6
    <!-- TOP HELP CONTENT -->
7
    <help-content #topHelperContent [position]="'top'"
8
                  [ngClass]="topHelperContent.isPresent()?'uk-margin-medium-top uk-margin-medium-bottom':'clear-style'">
9
    </help-content>
10

  
11
    <div class="uk-container uk-container-expand  uk-margin-medium-top uk-margin-medium-bottom">
12
      <div class="uk-grid">
13

  
14
        <!-- LEFT HELP CONTENT -->
15
        <aside-help-content #leftHelperContent [position]="'left'"
16
                            [ngClass]="leftHelperContent.isPresent()?'tm-sidebar uk-width-1-4@m uk-first-column':'clear-style'">
17
        </aside-help-content>
18

  
19
        <!-- MIDDLE -->
20
        <div class="uk-width-expand@m">
21

  
22
          <div *ngIf="errorMessage" class="uk-alert uk-alert-danger">{{ errorMessage }}</div>
23
          <div *ngIf="successMessage" class="uk-alert uk-alert-success">{{ successMessage }}</div>
24
          <div *ngIf="loadingMessage" class="loading-big">
25
            <div class="loader-big"
26
                 style="text-align: center; padding-top: 170px; color: rgb(47, 64, 80); font-weight: bold;">
27
              {{ loadingMessage }}
28
            </div>
29
            <div class="whiteFilm"></div>
30
          </div>
31

  
32

  
33

  
34

  
35
          <div class="uk-grid">
36
            <div class="uk-width-1-1@m uk-padding" style="background-color: #fff; text-align: center">
37
              <form [formGroup]="dataForm" class="uk-search uk-search-default uk-width-1-1@m">
38
                <input class="uk-width-1-2 uk-search-input" type="search" formControlName="officialName" placeholder="Search (official name) ..." style="background-color: #fff">
39
                <button class="uk-button" (click)="handleChangeAndResetPage()">Search</button>
40
              </form>
41
            </div>
42
          </div>
43

  
44
          <div class="uk-grid">
45
            <div class="uk-width-1-4@m">
46
              <form [formGroup]="dataForm" class="uk-form-stacked">
47

  
48
                <div class="uk-form-label uk-text-large">Filtered By</div>
49

  
50
                <div class="uk-margin">
51
                  <div class="uk-form-label uk-text-large">Datasource Type</div>
52
                  <div class="uk-form-controls">
53
                    <label><input class="uk-radio" type="radio" value="" (change)="handleChangeAndResetPage()" formControlName="typology"> Any</label><br>
54
                    <label><input class="uk-radio" type="radio" value="Aggregator" (change)="handleChangeAndResetPage()" formControlName="typology"> Aggregator</label><br>
55
                    <label><input class="uk-radio" type="radio" value="Journal" (change)="handleChangeAndResetPage()" formControlName="typology"> Journal</label><br>
56
                    <label><input class="uk-radio" type="radio" value="datarepository" (change)="handleChangeAndResetPage()" formControlName="typology"> Data Repository</label><br>
57
                    <label><input class="uk-radio" type="radio" value="pubsrepository" (change)="handleChangeAndResetPage()" formControlName="typology"> Public Repository</label><br>
58
                    <label><input class="uk-radio" type="radio" value="entityregistry" (change)="handleChangeAndResetPage()" formControlName="typology"> Entity Registry</label><br>
59
                    <label><input class="uk-radio" type="radio" value="Institutional" (change)="handleChangeAndResetPage()" formControlName="typology"> Institutional</label><br>
60
                    <label><input class="uk-radio" type="radio" value="Thematic" (change)="handleChangeAndResetPage()" formControlName="typology"> Thematic</label><br>
61
                    <label><input class="uk-radio" type="radio" value="Products" (change)="handleChangeAndResetPage()" formControlName="typology"> Products</label><br>
62
                    <label><input class="uk-radio" type="radio" value="Unknown" (change)="handleChangeAndResetPage()" formControlName="typology"> Unknown</label>
63
                  </div>
64
                </div>
65

  
66
                <div class="uk-margin">
67
                  <div class="uk-form-label uk-text-large">Countries</div>
68
                  <div class="uk-form-controls">
69
                    <ng-container *ngIf="countries && countries.length>0">
70
                      <read-more [maxHeight]="238">
71
                        <div><input class="uk-radio" type="radio" value="" (change)="handleChangeAndResetPage()" formControlName="country"> Any</div>
72
                        <ng-container *ngFor="let country of countries">
73
                          <div class="">
74
                            <input class="uk-radio" type="radio" value="{{country.code}}"
75
                                   (change)="handleChangeAndResetPage()" formControlName="country"> {{country.name}}
76
                          </div>
77
                        </ng-container>
78
                      </read-more>
79
                    </ng-container>
80
                  </div>
81
                </div>
82

  
83
              </form>
84
            </div>
85
            <div class="uk-width-expand@m">
86
              <div class="uk-grid">
87
                <div class="uk-width-1-1@m uk-margin-medium">
88
                  <form [formGroup]="dataForm" class="uk-form-horizontal uk-grid">
89

  
90
                    <div class="uk-width-2-5@m">
91
                      <div class="uk-margin">
92
                        <label class="uk-form-label uk-text-right" for="size">Items per page: </label>
93
                        <div class="uk-form-controls">
94
                          <select class="uk-select" id="size" (change)="handleChangeAndResetPage()" formControlName="size">
95
                            <option value="10">10</option>
96
                            <option value="25" selected>25</option>
97
                            <option value="50">50</option>
98
                            <option value="100">100</option>
99
                          </select>
100
                        </div>
101
                      </div>
102
                    </div>
103

  
104
                    <div class="uk-width-expand@m ">
105

  
106
                      <div class="uk-float-right">
107
                        <label class="uk-form-label uk-text-right" for="orderBy">Order by: </label>
108
                        <div class="uk-form-controls">
109
                          <select class="uk-select" id="orderBy" (change)="handleChangeAndResetPage()" formControlName="order">
110
                            <option value="DESCENDING" selected>Descending</option>
111
                            <option value="ASCENDING">Ascending</option>
112
                          </select>
113
                        </div>
114
                      </div>
115

  
116
                      <div class="uk-float-right">
117
                        <label class="uk-form-label uk-text-right" for="sortBy">Sort by: </label>
118
                        <div class="uk-form-controls">
119
                          <select class="uk-select" id="sortBy" (change)="handleChangeAndResetPage()" formControlName="requestSortBy">
120
                            <option value="registrationdate" selected>Date</option>
121
                            <option value="officialname">Name</option>
122
                          </select>
123
                        </div>
124
                      </div>
125

  
126
                    </div>
127

  
128

  
129
                  </form>
130
                </div>
131

  
132
                <div class="uk-width-1-1@m">
133

  
134
                  <table class="uk-table uk-table-striped">
135
                    <thead>
136
                    <tr>
137
                      <th>Repository</th>
138
                      <th>Date</th>
139
                      <th>Organization</th>
140
                      <th>Type</th>
141
                    </tr>
142
                    </thead>
143
                    <tbody>
144
                    <tr *ngFor="let res of repositorySnippet">
145
                      <td class="uk-width-1-6@m">{{res.officialname}} <br> ({{res.id}}) <br> {{res.registeredby}}</td>
146
                      <td >{{res.registrationdate}}</td>
147
                      <td> <div *ngFor="let organization of res.organizations">{{organization.legalname + ' (' + getCountryName(organization.country)}})<br></div></td>
148
                      <td>{{res.typology.split('::')[0]}}<br>{{res.typology.split('::')[1]}}<br>{{res.typology.split('::')[2]}}</td>
149
                    </tr>
150
                    </tbody>
151
                  </table>
152

  
153
                  <ul class="uk-pagination uk-flex-center" uk-margin>
154
                    <li><a (click)="previousPage()"><span uk-pagination-previous></span></a></li>
155
                    <li class="uk-active"><span>{{+dataForm.get('page').value + 1}}</span></li>
156
                    <li><a (click)="nextPage()"><span uk-pagination-next></span></a></li>
157
                  </ul>
158

  
159
                </div>
160

  
161
              </div>
162
            </div>
163
          </div>
164

  
165
        </div>
166
      </div>
167
    </div>
168
  </div>
169
</div>
modules/uoa-repository-dashboard-gui/trunk/src/app/pages/adminPg/adminPg-registrations.component.ts
1
import {Component, OnInit} from '@angular/core';
2
import {loadingReposMessage, noServiceMessage} from '../../domain/shared-messages';
3
import {Country, RepositorySnippet} from '../../domain/typeScriptClasses';
4
import {RepositoryService} from '../../services/repository.service';
5
import {FormBuilder, FormGroup} from '@angular/forms';
6
import {ActivatedRoute, Params, Router} from '@angular/router';
7
import {URLParameter} from '../../domain/url-parameter';
8

  
9
@Component({
10
  selector: 'app-registration',
11
  templateUrl: 'adminPg-registrations.component.html',
12
  styleUrls: ['./adminPg-registrations.component.css']
13
})
14

  
15
export class RegistrationComponent implements OnInit {
16

  
17
  errorMessage: string;
18
  successMessage: string;
19
  loadingMessage: string;
20
  countries: Country[] = [];
21
  repositorySnippet: RepositorySnippet[] = [];
22
  urlParams: URLParameter[] = [];
23
  thisIsForBadUse: RepositorySnippet[] = []; // remove if page total is fixed!!!
24

  
25
  formPrepare = {
26
    country: '',
27
    typology: '',
28
    officialName: '',
29
    requestSortBy: 'registrationdate',
30
    order: 'DESCENDING',
31
    page: '0',
32
    size: '25'
33
  };
34

  
35
  dataForm: FormGroup;
36

  
37
  constructor(private repoService: RepositoryService,
38
              private fb: FormBuilder,
39
              private route: ActivatedRoute,
40
              private router: Router) { }
41

  
42
  ngOnInit() {
43
    this.dataForm = this.fb.group(this.formPrepare);
44
    const tempUrlParams = new Array<URLParameter>();
45
    this.route.queryParams
46
      .subscribe(params => {
47
        for (const i in params) {
48
          this.dataForm.get(i).setValue(params[i]);
49
        }
50
        for (let i in this.dataForm.controls) {
51
          if (this.dataForm.get(i).value) {
52
            tempUrlParams.push({key: i, value: [this.dataForm.get(i).value]});
53
          }
54
        }
55
        this.handleChange();
56
      },
57
      error => this.errorMessage = <any>error
58
    );
59

  
60
    this.getCountries();
61

  
62

  
63
  }
64

  
65
  getCountries() {
66
    this.repoService.getCountries()
67
      .subscribe(
68
        countries => this.countries = countries.sort(function (a, b) {
69
          if (a.name < b.name) {
70
            return -1;
71
          } else if (a.name > b.name) {
72
            return 1;
73
          } else {
74
            return 0;
75
          }
76
        }),
77
        error => {
78
          this.loadingMessage = '';
79
          this.errorMessage = noServiceMessage;
80
          console.log(error);
81
        }
82
      );
83
  }
84

  
85
  getRegisteredRepositories(urlParams: URLParameter[]) {
86
    this.loadingMessage = loadingReposMessage;
87
    this.repoService.searchRegisteredRepositories(this.dataForm.get('page').value,
88
      this.dataForm.get('size').value, urlParams).subscribe(
89
        suc => this.repositorySnippet = suc,
90
        error => {
91
          console.log(error);
92
          this.loadingMessage = '';
93
        },
94
      () => this.loadingMessage = ''
95
      );
96
  }
97

  
98
  handleChange() {
99
    const tempUrlParams = new Array<URLParameter>();
100
    const map: { [name: string]: string; } = {};
101

  
102
    for (let i in this.dataForm.controls) {
103
      if (this.dataForm.get(i).value !== '') {
104
        tempUrlParams.push({key: i, value: [this.dataForm.get(i).value]});
105
        map[i] = this.dataForm.get(i).value;
106
      }
107
    }
108

  
109
    this.router.navigate([`/admin/registrations`],
110
      {queryParams: map});
111
    this.getRegisteredRepositories(tempUrlParams);
112
  }
113

  
114
  handleChangeAndResetPage() {
115
    this.dataForm.get('page').setValue(0);
116
    this.handleChange();
117
  }
118

  
119
  getCountryName(countryCode): string {
120
    for (const country of Object.values(this.countries)) {
121
      if (country.code === countryCode) {
122
        return country.name;
123
      }
124
    }
125
  }
126

  
127
  previousPage() {
128
    if (this.dataForm.get('page').value > 0) {
129
      this.dataForm.get('page').setValue(+this.dataForm.get('page').value - 1);
130
      this.handleChange();
131
    }
132
  }
133

  
134
  nextPage() {
135
    /** remove when page total is fixed!!! **/
136
    const tempUrlParams = new Array<URLParameter>();
137
    for (let i in this.dataForm.controls) {
138
      if (this.dataForm.get(i).value !== '') {
139
        tempUrlParams.push({key: i, value: [this.dataForm.get(i).value]});
140
      }
141
    }
142
      this.repoService.searchRegisteredRepositories(+this.dataForm.get('page').value + 1,
143
      this.dataForm.get('size').value, tempUrlParams).subscribe(
144
      suc => this.thisIsForBadUse = suc,
145
      error => console.log(error),
146
      () => {
147
        if (!(this.thisIsForBadUse.length === 0)) {
148
          this.dataForm.get('page').setValue(+this.dataForm.get('page').value + 1);
149
          this.handleChange();
150
        }
151
      }
152
    );
153
    /** **/
154

  
155
  }
156

  
157
}
modules/uoa-repository-dashboard-gui/trunk/src/app/pages/adminPg/adminPg-registrations.component.css
1
.uk-form-horizontal .uk-form-label {
2
  width: 100px;
3
}
4

  
5
.uk-form-horizontal .uk-form-controls {
6
  margin-left: 115px;
7
}
8

  
9
.uk-search-default .uk-search-input {
10
  padding-left: 15px;
11
  padding-right: 15px;
12
}
modules/uoa-repository-dashboard-gui/trunk/src/app/pages/adminPg/adminPg-metrics.component.html
21 21

  
22 22
          <div *ngIf="errorMessage" class="uk-alert uk-alert-danger">{{ errorMessage }}</div>
23 23
          <div *ngIf="successMessage" class="uk-alert uk-alert-success">{{ successMessage }}</div>
24
          <div *ngIf="loadingMessage" class="loading-big">
25
            <div class="loader-big" style="text-align: center; padding-top: 170px; color: rgb(47, 64, 80); font-weight: bold;">
26
              {{ loadingMessage }}
24

  
25

  
26
          <div class="uk-grid">
27
            <div class="uk-width-1-1@m uk-padding" style="background-color: #fff; text-align: center">
28
              <form [formGroup]="dataForm" class="uk-search uk-search-default uk-width-1-1@m">
29
                <input class="uk-width-1-2 uk-search-input" type="search" formControlName="searchField" placeholder="Search..." style="background-color: #fff">
30
                <button class="uk-button" (click)="handleChangeAndResetPage()">Search</button>
31
                <div class="uk-position-right">
32
                  <button class="uk-button uk-button-primary" (click)="downloadCSV()">Export to CSV</button>
33
                </div>
34
              </form>
27 35
            </div>
28
            <div class="whiteFilm"></div>
29 36
          </div>
30
          <div *ngIf="piwiks && piwiks.length>0">
31
            <table class="uk-table uk-table-striped uk-table-middle" style="font-size: 12px;">
32
              <thead>
33
              <tr>
34
                <th class="uk-text-nowrap">Repository</th>
35
                <th class="uk-text-nowrap">Piwik site</th>
36
                <th class="uk-text-nowrap">Requested on</th>
37
                <th class="uk-text-nowrap">Requestor</th>
38
                <th class="uk-text-nowrap">Validated</th>
39
                <th class="uk-text-nowrap">Actions</th>
40
              </tr>
41
              </thead>
42
              <tbody>
43
              <tr class="el-item" *ngFor="let piwik of piwiks">
44
                <td class="uk-table-shrink uk-text-truncate" style="min-width: 400px;">
45
                  {{ piwik.repositoryName }}<br>(ID: {{ piwik.repositoryId }})
46
                </td>
47
                <td class="uk-table-shrink">ID: {{ piwik.siteId }}<br>Authentication Token: {{ piwik.authenticationToken }}</td>
48
                <td class="uk-text-nowrap uk-table-shrink">{{ piwik.creationDate | date : "yyyy-MM-dd" }}</td>
49
                <td class="uk-text-nowrap uk-table-shrink">{{ piwik.requestorName }}<br>{{ piwik.requestorEmail }}</td>
50
                <td class="uk-text-nowrap uk-table-shrink">
51
                  <span *ngIf="piwik.validated">YES<br>on {{ piwik.validationDate | date : "yyyy-MM-dd" }}</span>
52
                  <span *ngIf="!piwik.validated">NO</span>
53
                </td>
54
                <td class="uk-text-nowrap uk-table-shrink">
55
                  <button id="{{ piwik.repositoryId }}"
56
                          *ngIf="!piwik.validated"
57
                          class="uk-button uk-button-primary validate"
58
                          (click)="confirmApproval(piwik.repositoryId)">Validate</button>
59
                </td>
60
              </tr>
61
              </tbody>
62
            </table>
37

  
38
          <div class="uk-grid">
39
            <div class="uk-width-expand@m">
40
              <div class="uk-grid">
41
                <div class="uk-width-1-1@m uk-margin-medium">
42
                  <form [formGroup]="dataForm" class="uk-form-horizontal uk-grid">
43

  
44
                    <div class="uk-width-2-5@m">
45
                      <div class="uk-margin">
46
                        <label class="uk-form-label uk-text-right" for="quantity">Items per page: </label>
47
                        <div class="uk-form-controls">
48
                          <select class="uk-select" id="quantity" (change)="handleChangeAndResetPage()" formControlName="quantity">
49
                            <option value="10">10</option>
50
                            <option value="25" selected>25</option>
51
                            <option value="50">50</option>
52
                            <option value="100">100</option>
53
                          </select>
54
                        </div>
55
                      </div>
56
                    </div>
57

  
58
                    <div class="uk-width-expand@m ">
59

  
60
                      <div class="uk-float-right">
61
                        <label class="uk-form-label uk-text-right" for="orderBy">Order by: </label>
62
                        <div class="uk-form-controls">
63
                          <select class="uk-select" id="orderBy" (change)="handleChangeAndResetPage()" formControlName="order">
64
                            <option value="DSC">Descending</option>
65
                            <option value="ASC" selected>Ascending</option>
66
                          </select>
67
                        </div>
68
                      </div>
69

  
70
                      <div class="uk-float-right">
71
                        <label class="uk-form-label uk-text-right" for="sortBy">Sort by: </label>
72
                        <div class="uk-form-controls">
73
                          <select class="uk-select" id="sortBy" (change)="handleChangeAndResetPage()" formControlName="orderField">
74
                            <option value="CREATION_DATE" >Date</option>
75
                            <option value="REPOSITORY_NAME" selected>Name</option>
76
                          </select>
77
                        </div>
78
                      </div>
79

  
80
                    </div>
81

  
82
                  </form>
83
                </div>
84

  
85
                <div class="uk-width-1-1@m">
86

  
87
                  <div *ngIf="loadingMessage" class="loading-big">
88
                    <div class="loader-big" style="text-align: center; padding-top: 170px; color: rgb(47, 64, 80); font-weight: bold;">
89
                      {{ loadingMessage }}
90
                    </div>
91
                    <div class="whiteFilm"></div>
92
                  </div>
93

  
94
                  <!-- TABLE -->
95
                  <div *ngIf="piwiks && piwiks.results.length>0">
96
                    <table class="uk-table uk-table-striped uk-table-middle" style="font-size: 12px;">
97
                      <thead>
98
                      <tr>
99
                        <th class="uk-text-nowrap">Repository</th>
100
                        <th class="uk-text-nowrap">Piwik site</th>
101
                        <th class="uk-text-nowrap">Requested on</th>
102
                        <th class="uk-text-nowrap">Requestor</th>
103
                        <th class="uk-text-nowrap">Validated</th>
104
                        <th class="uk-text-nowrap">Actions</th>
105
                      </tr>
106
                      </thead>
107
                      <tbody>
108
                      <tr class="el-item" *ngFor="let piwik of piwiks.results">
109
                        <td class="uk-table-shrink uk-text-truncate" style="min-width: 400px;">
110
                          {{ piwik.repositoryName }}<br>(ID: {{ piwik.repositoryId }})
111
                        </td>
112
                        <td class="uk-table-shrink">ID: {{ piwik.siteId }}<br>Authentication Token: {{ piwik.authenticationToken }}</td>
113
                        <td class="uk-text-nowrap uk-table-shrink">{{ piwik.creationDate | date : "yyyy-MM-dd" }}</td>
114
                        <td class="uk-text-nowrap uk-table-shrink">{{ piwik.requestorName }}<br>{{ piwik.requestorEmail }}</td>
115
                        <td class="uk-text-nowrap uk-table-shrink">
116
                          <span *ngIf="piwik.validated">YES<br>on {{ piwik.validationDate | date : "yyyy-MM-dd" }}</span>
117
                          <span *ngIf="!piwik.validated">NO</span>
118
                        </td>
119
                        <td class="uk-text-nowrap uk-table-shrink">
120
                          <button id="{{ piwik.repositoryId }}"
121
                                  *ngIf="!piwik.validated"
122
                                  class="uk-button uk-button-primary validate"
123
                                  (click)="confirmApproval(piwik.repositoryId)">Validate</button>
124
                        </td>
125
                      </tr>
126
                      </tbody>
127
                    </table>
128
                  </div>
129

  
130
                  <ul class="uk-pagination uk-flex-center" uk-margin>
131
                    <li><a (click)="previousPage()"><span uk-pagination-previous></span></a></li>
132
<!--                    <li class="uk-active"><span>{{+dataForm.get('page').value + 1}}</span></li>-->
133
                    <li [ngClass]="{'uk-active': (this.dataForm.get('page').value == page) }" *ngFor="let page of pages">
134
                      <a (click)="selectPage(page)">{{page+1}}</a> </li>
135
                    <li><a (click)="nextPage()"><span uk-pagination-next></span></a></li>
136
                  </ul>
137

  
138
                </div>
139

  
140
              </div>
141
            </div>
63 142
          </div>
64 143

  
65 144
        </div>
modules/uoa-repository-dashboard-gui/trunk/src/app/pages/adminPg/adminPg.module.ts
6 6
import { ReusableComponentsModule } from '../../shared/reusablecomponents/reusable-components.module';
7 7
import { AdminPgComponent } from './adminPg.component';
8 8
import { AdminPgMetricsComponent } from './adminPg-metrics.component';
9
import {RegistrationComponent} from './registration.component';
9
import {RegistrationComponent} from './adminPg-registrations.component';
10 10

  
11 11
@NgModule ({
12 12
  imports: [
modules/uoa-repository-dashboard-gui/trunk/src/app/pages/adminPg/adminPg-metrics.component.ts
1
import { Component, OnInit, ViewChild } from '@angular/core';
1
import {Component, Input, OnInit, ViewChild} from '@angular/core';
2 2
import { PiwikService } from '../../services/piwik.service';
3 3
import { PiwikInfo } from '../../domain/typeScriptClasses';
4 4
import {
......
9 9
  validatePiwikSiteSuccess
10 10
} from '../../domain/shared-messages';
11 11
import { ConfirmationDialogComponent } from '../../shared/reusablecomponents/confirmation-dialog.component';
12
import {URLParameter} from '../../domain/url-parameter';
13
import {FormBuilder, FormGroup} from '@angular/forms';
14
import {RepositoryService} from '../../services/repository.service';
15
import {ActivatedRoute, Router} from '@angular/router';
16
import {PiwikInfoPage} from '../../domain/page-content';
17
import {environment} from '../../../environments/environment';
18
import {st} from '@angular/core/src/render3';
12 19

  
13 20
@Component ({
14 21
  selector: 'app-admin-metrics',
......
16 23
})
17 24

  
18 25
export class AdminPgMetricsComponent implements OnInit {
19
  piwiks: PiwikInfo[] = [];
26
  piwiks: PiwikInfoPage;
27
  urlParams: URLParameter[] = [];
20 28
  errorMessage: string;
21 29
  successMessage: string;
22 30
  loadingMessage: string;
......
25 33
  modalButton = 'Yes, validate';
26 34
  isModalShown: boolean;
27 35

  
36
  formPrepare = {
37
    searchField: '',
38
    orderField: 'REPOSITORY_NAME',
39
    order: 'ASC',
40
    page: '0',
41
    quantity: '25',
42
    from: '0'
43
  };
44

  
45
  dataForm: FormGroup;
46

  
28 47
  @ViewChild('confirmApprovalModal')
29 48
  public confirmApprovalModal: ConfirmationDialogComponent;
49
  private pageTotal: number;
50
  private piwiksTotal: number;
51
  private pages = [];
52
  private offset = 2;
30 53

  
31
  constructor(private piwikService: PiwikService) {}
54
  constructor(private piwikService: PiwikService,
55
              private fb: FormBuilder,
56
              private route: ActivatedRoute,
57
              private router: Router) {}
32 58

  
33 59
  ngOnInit() {
34
    this.getPiwiks();
60
    this.dataForm = this.fb.group(this.formPrepare);
61
    this.urlParams = [];
62
    this.route.queryParams
63
      .subscribe(params => {
64
          for (const i in params) {
65
            this.dataForm.get(i).setValue(params[i]);
66
          }
67
          for (let i in this.dataForm.controls) {
68
            if (this.dataForm.get(i).value) {
69
              this.urlParams.push({key: i, value: [this.dataForm.get(i).value]});
70
            }
71
          }
72
          this.handleChange();
73
        },
74
        error => this.errorMessage = <any>error
75
      );
76

  
35 77
    this.isModalShown = false;
36 78
  }
37 79

  
80
  downloadCSV() {
81
    const url = environment.API_ENDPOINT;
82
    let csvUrlParams = '/piwik/getPiwikSitesForRepos/csv?';
83
    for (let i in this.dataForm.controls) {
84
      if (this.dataForm.get(i).value !== '') {
85
        csvUrlParams = csvUrlParams.concat(i, '=', this.dataForm.get(i).value, '&');
86
      }
87
    }
88
    csvUrlParams = csvUrlParams.split('&page=')[0];
89
    window.open(url + csvUrlParams, '_blank');
90
  }
38 91

  
39 92
  getPiwiks() {
40 93
    this.loadingMessage = loadingReposMessage;
41
    this.piwikService.getPiwikSitesForRepos()
42
      .subscribe (
43
        piwiks => this.piwiks = piwiks.sort( function(a, b) {
44
          if (a.repositoryName < b.repositoryName) {
45
            return -1;
46
          } else if (a.repositoryName > b.repositoryName) {
47
            return 1;
48
          } else {
49
            return 0;
50
          }
51
        } ),
94
    this.piwikService.getPiwikSitesForRepos(this.urlParams)
95
      .subscribe(
96
        piwiks => {
97
          this.piwiks = piwiks;
98
          this.getPages();
99
        },
52 100
        error => {
53 101
          console.log(error);
54 102
          this.loadingMessage = '';
......
94 142
    );
95 143
  }
96 144

  
145
  handleChange() {
146
    this.urlParams = [];
147
    const map: { [name: string]: string; } = {};
148
    for (let i in this.dataForm.controls) {
149
      if (this.dataForm.get(i).value !== '') {
150
        this.urlParams.push({key: i, value: [this.dataForm.get(i).value]});
151
        map[i] = this.dataForm.get(i).value;
152
      }
153
    }
154

  
155
    this.router.navigate([`/admin/metrics`], {queryParams: map});
156
    this.getPiwiks();
157
  }
158

  
159
  handleChangeAndResetPage() {
160
    this.dataForm.get('page').setValue(0);
161
    this.dataForm.get('from').setValue(0);
162
    this.handleChange();
163
  }
164

  
165
  getPages() {
166
    let addToEndCounter = 0;
167
    let addToStartCounter = 0;
168
    this.pages = [];
169
    this.pageTotal = Math.ceil(this.piwiks.total / (this.dataForm.get('quantity').value));
170
    for ( let i = (+this.dataForm.get('page').value - this.offset); i < (+this.dataForm.get('page').value + 1 + this.offset); ++i ) {
171
      if ( i < 0 ) { addToEndCounter++; }
172
      if ( i >= this.pageTotal ) { addToStartCounter++; }
173
      if ((i >= 0) && (i < this.pageTotal)) {
174
        this.pages.push(i);
175
      }
176
    }
177
    for ( let i = 0; i < addToEndCounter; ++i ) {
178
      if (this.pages.length < this.pageTotal) {
179
        this.pages.push(this.pages.length);
180
      }
181
    }
182
    for ( let i = 0; i < addToStartCounter; ++i ) {
183
      if (this.pages[0] > 0) {
184
        this.pages.unshift(this.pages[0] - 1 );
185
      }
186
    }
187
  }
188

  
189
  selectPage(page) {
190
    this.dataForm.get('page').setValue(page);
191
    this.dataForm.get('from').setValue(((+this.dataForm.get('page').value) * (+this.dataForm.get('quantity').value)));
192
    this.handleChange();
193
  }
194

  
195
  previousPage() {
196
    if (this.dataForm.get('page').value > 0) {
197
      this.dataForm.get('page').setValue(+this.dataForm.get('page').value - 1);
198
      this.dataForm.get('from').setValue(+this.dataForm.get('from').value - +this.dataForm.get('quantity').value);
199
      this.handleChange();
200
    }
201
  }
202

  
203
  nextPage() {
204
    // if ((this.dataForm.get('searchField').value) !== '') { this.piwiksTotal = this.piwiks.to; } else { this.piwiksTotal = this.piwiks.total; }
205
    this.pageTotal = Math.ceil(this.piwiks.total / (this.dataForm.get('quantity').value)) - 1;
206
    if (this.dataForm.get('page').value < this.pageTotal) {
207
      this.dataForm.get('page').setValue(+this.dataForm.get('page').value + 1);
208
      this.dataForm.get('from').setValue(+this.dataForm.get('from').value + +this.dataForm.get('quantity').value);
209
      this.handleChange();
210
    }
211
  }
212

  
97 213
}
modules/uoa-repository-dashboard-gui/trunk/src/app/pages/adminPg/adminPg.routing.ts
4 4
import { AdminPgComponent } from './adminPg.component';
5 5
import { AdminPgMetricsComponent } from './adminPg-metrics.component';
6 6
import { AuthGuardService } from '../../services/auth-guard.service';
7
import {RegistrationComponent} from './registration.component';
7
import {RegistrationComponent} from './adminPg-registrations.component';
8 8

  
9 9
const adminRoutes: Routes = [
10 10
  {
modules/uoa-repository-dashboard-gui/trunk/src/app/pages/adminPg/adminPg-registrations.component.html
1
<div class="uk-grid-margin uk-grid uk-grid-stack" uk-grid="">
2
  <div class="uk-width-1-1@m uk-first-column">
3

  
4
    <h1 class="uk-h2">Registrations Admin</h1>
5

  
6
    <!-- TOP HELP CONTENT -->
7
    <help-content #topHelperContent [position]="'top'"
8
                  [ngClass]="topHelperContent.isPresent()?'uk-margin-medium-top uk-margin-medium-bottom':'clear-style'">
9
    </help-content>
10

  
11
    <div class="uk-container uk-container-expand uk-margin-medium-top uk-margin-medium-bottom">
12
      <div class="uk-grid">
13

  
14
        <!-- LEFT HELP CONTENT -->
15
        <aside-help-content #leftHelperContent [position]="'left'"
16
                            [ngClass]="leftHelperContent.isPresent()?'tm-sidebar uk-width-1-4@m uk-first-column':'clear-style'">
17
        </aside-help-content>
18

  
19
        <!-- MIDDLE -->
20
        <div class="uk-width-expand@m">
21

  
22
          <div *ngIf="errorMessage" class="uk-alert uk-alert-danger">{{ errorMessage }}</div>
23
          <div *ngIf="successMessage" class="uk-alert uk-alert-success">{{ successMessage }}</div>
24

  
25

  
26
          <div class="uk-grid">
27
            <div class="uk-width-1-1@m uk-padding" style="background-color: #fff; text-align: center">
28
              <form [formGroup]="dataForm" class="uk-search uk-search-default uk-width-1-1@m">
29
                <input class="uk-width-1-2 uk-search-input" type="search" formControlName="officialName" placeholder="Search (official name) ..." style="background-color: #fff">
30
                <button class="uk-button" (click)="handleChangeAndResetPage()">Search</button>
31
              </form>
32
            </div>
33
          </div>
34

  
35
          <div class="uk-grid">
36
            <div class="uk-width-1-4@m">
37
              <form [formGroup]="dataForm" class="uk-form-stacked">
38

  
39
                <div class="uk-form-label uk-text-large">Filtered By</div>
40

  
41
                <div class="uk-margin">
42
                  <div class="uk-form-label uk-text-large">Datasource Type</div>
43
                  <div class="uk-form-controls">
44
                    <label><input class="uk-radio" type="radio" value="" (change)="handleChangeAndResetPage()" formControlName="typology"> Any</label><br>
45
                    <label><input class="uk-radio" type="radio" value="Aggregator" (change)="handleChangeAndResetPage()" formControlName="typology"> Aggregator</label><br>
46
                    <label><input class="uk-radio" type="radio" value="Journal" (change)="handleChangeAndResetPage()" formControlName="typology"> Journal</label><br>
47
                    <label><input class="uk-radio" type="radio" value="datarepository" (change)="handleChangeAndResetPage()" formControlName="typology"> Data Repository</label><br>
48
                    <label><input class="uk-radio" type="radio" value="pubsrepository" (change)="handleChangeAndResetPage()" formControlName="typology"> Public Repository</label><br>
49
                    <label><input class="uk-radio" type="radio" value="entityregistry" (change)="handleChangeAndResetPage()" formControlName="typology"> Entity Registry</label><br>
50
                    <label><input class="uk-radio" type="radio" value="Institutional" (change)="handleChangeAndResetPage()" formControlName="typology"> Institutional</label><br>
51
                    <label><input class="uk-radio" type="radio" value="Thematic" (change)="handleChangeAndResetPage()" formControlName="typology"> Thematic</label><br>
52
                    <label><input class="uk-radio" type="radio" value="Products" (change)="handleChangeAndResetPage()" formControlName="typology"> Products</label><br>
53
                    <label><input class="uk-radio" type="radio" value="Unknown" (change)="handleChangeAndResetPage()" formControlName="typology"> Unknown</label>
54
                  </div>
55
                </div>
56

  
57
                <div class="uk-margin">
58
                  <div class="uk-form-label uk-text-large">Countries</div>
59
                  <div class="uk-form-controls">
60
                    <ng-container *ngIf="countries && countries.length>0">
61
                      <read-more [maxHeight]="238">
62
                        <div><input class="uk-radio" type="radio" value="" (change)="handleChangeAndResetPage()" formControlName="country"> Any</div>
63
                        <ng-container *ngFor="let country of countries">
64
                          <div class="">
65
                            <input class="uk-radio" type="radio" value="{{country.code}}"
66
                                   (change)="handleChangeAndResetPage()" formControlName="country"> {{country.name}}
67
                          </div>
68
                        </ng-container>
69
                      </read-more>
70
                    </ng-container>
71
                  </div>
72
                </div>
73

  
74
              </form>
75
            </div>
76
            <div class="uk-width-expand@m">
77
              <div class="uk-grid">
78
                <div class="uk-width-1-1@m uk-margin-medium">
79
                  <form [formGroup]="dataForm" class="uk-form-horizontal uk-grid">
80

  
81
                    <div class="uk-width-2-5@m">
82
                      <div class="uk-margin">
83
                        <label class="uk-form-label uk-text-right" for="size">Items per page: </label>
84
                        <div class="uk-form-controls">
85
                          <select class="uk-select" id="size" (change)="handleChangeAndResetPage()" formControlName="size">
86
                            <option value="10">10</option>
87
                            <option value="25" selected>25</option>
88
                            <option value="50">50</option>
89
                            <option value="100">100</option>
90
                          </select>
91
                        </div>
92
                      </div>
93
                    </div>
94

  
95
                    <div class="uk-width-expand@m ">
96

  
97
                      <div class="uk-float-right">
98
                        <label class="uk-form-label uk-text-right" for="orderBy">Order by: </label>
99
                        <div class="uk-form-controls">
100
                          <select class="uk-select" id="orderBy" (change)="handleChangeAndResetPage()" formControlName="order">
101
                            <option value="DESCENDING" selected>Descending</option>
102
                            <option value="ASCENDING">Ascending</option>
103
                          </select>
104
                        </div>
105
                      </div>
106

  
107
                      <div class="uk-float-right">
108
                        <label class="uk-form-label uk-text-right" for="sortBy">Sort by: </label>
109
                        <div class="uk-form-controls">
110
                          <select class="uk-select" id="sortBy" (change)="handleChangeAndResetPage()" formControlName="requestSortBy">
111
                            <option value="registrationdate" selected>Date</option>
112
                            <option value="officialname">Name</option>
113
                          </select>
114
                        </div>
115
                      </div>
116

  
117
                    </div>
118

  
119

  
120
                  </form>
121
                </div>
122

  
123
                <div class="uk-width-1-1@m">
124

  
125
                  <div *ngIf="loadingMessage" class="loading-big">
126
                    <div class="loader-big" style="text-align: center; padding-top: 170px; color: rgb(47, 64, 80); font-weight: bold;">
127
                      {{ loadingMessage }}
128

  
129
                    </div>
130
                    <div class="whiteFilm"></div>
131
                  </div>
132

  
133
                  <!-- TABLE -->
134
                  <table class="uk-table uk-table-striped">
135
                    <thead>
136
                    <tr>
137
                      <th>Repository</th>
138
                      <th>Date</th>
139
                      <th>Organization</th>
140
                      <th>Type</th>
141
                    </tr>
142
                    </thead>
143
                    <tbody>
144
                    <tr *ngFor="let res of repositorySnippet">
145
                      <td class="uk-width-1-6@m">{{res.officialname}} <br> ({{res.id}}) <br> {{res.registeredby}}</td>
146
                      <td >{{res.registrationdate}}</td>
147
                      <td> <div *ngFor="let organization of res.organizations">{{organization.legalname + ' (' + getCountryName(organization.country) + ')'}}<br></div></td>
148
                      <td>{{res.typology.split('::')[0]}}<br>{{res.typology.split('::')[1]}}<br>{{res.typology.split('::')[2]}}</td>
149
                    </tr>
150
                    </tbody>
151
                  </table>
152

  
153
                  <ul class="uk-pagination uk-flex-center" uk-margin>
154
                    <li><a (click)="previousPage()"><span uk-pagination-previous></span></a></li>
155
                    <li class="uk-active"><span>{{+dataForm.get('page').value + 1}}</span></li>
156
                    <li><a (click)="nextPage()"><span uk-pagination-next></span></a></li>
157
                  </ul>
158

  
159
                </div>
160

  
161
              </div>
162
            </div>
163
          </div>
164

  
165
        </div>
166
      </div>
167
    </div>
168
  </div>
169
</div>
modules/uoa-repository-dashboard-gui/trunk/src/app/services/piwik.service.ts
2 2
* Created by myrto on 12/05/2017
3 3
*/
4 4

  
5
import { HttpClient, HttpHeaders } from '@angular/common/http';
5
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
6 6
import { Injectable } from '@angular/core';
7 7
import { environment } from '../../environments/environment';
8 8
import { PiwikInfo } from '../domain/typeScriptClasses';
9 9
import { Observable } from 'rxjs';
10
import {URLParameter} from '../domain/url-parameter';
11
import {PiwikInfoPage} from '../domain/page-content';
10 12

  
11 13
const headerOptions = {
12 14
  headers : new HttpHeaders().set('Content-Type', 'application/json')
......
50 52
    return this.httpClient.get<PiwikInfo>(url, headerOptions);
51 53
  }
52 54

  
53
  getPiwikSitesForRepos(): Observable<PiwikInfo[]> {
55
  getPiwikSitesForRepos(urlParams: URLParameter[]): Observable<PiwikInfoPage> {
54 56
    const url = `${this.apiUrl}getPiwikSitesForRepos`;
55 57
    console.log(`knocking on: ${url}`);
58
    let params = new HttpParams();
59
    for (const urlParameter of urlParams) {
60
      for (const value of urlParameter.value) {
61
        params = params.append(urlParameter.key, value);
62
      }
63
    }
56 64

  
57
    return this.httpClient.get<PiwikInfo[]>(url, headerOptions);
65
    return this.httpClient.get<PiwikInfoPage>(url, {params, withCredentials: true});
58 66
  }
59 67

  
60

  
61 68
  markPiwikSiteAsValidated (repositoryId: string) {
62 69
    const url = `${this.apiUrl}markPiwikSiteAsValidated/${repositoryId}`;
63 70
    console.log(`knocking on: ${url}`);
modules/uoa-repository-dashboard-gui/trunk/src/app/shared/topmenu/topmenu.component.html
212 212
                            <ul *ngIf="getIsUserAdmin()" class="uk-nav uk-navbar-dropdown-nav">
213 213
                              <li class="uk-nav-header" style="display: block;">Admin</li>
214 214
                              <li style="display: block"><a href="{{adminHomePage}}" target="_blank">Help Texts</a></li>
215
                              <li style="display: block"><a [routerLink]="['/admin','metrics']">Metrics</a></li>
215
                              <li style="display: block"><a [routerLink]="['/admin/metrics']">Metrics</a></li>
216 216
                              <li style="display: block" class="uk-margin-small-bottom"><a [routerLink]="['/admin/registrations']">Registrations</a></li>
217 217
                            </ul>
218 218
                            <li><a class="" (click)="logout()">Log out</a></li>
modules/uoa-repository-dashboard-gui/trunk/src/app/domain/page-content.ts
1 1
/**
2 2
 * Created by stefania on 7/17/17.
3 3
 */
4
import {PiwikInfo} from './typeScriptClasses';
5

  
4 6
export class PageContent {
5 7

  
6 8
  content: PositionContents;
......
33 35
  route: string;
34 36
  name: string;
35 37
}
38

  
39
export class PiwikInfoPage {
40
  total: number;
41
  from: number;
42
  to: number;
43
  results: PiwikInfo[];
44
}

Also available in: Unified diff