Project

General

Profile

« Previous | Next » 

Revision 50432

reorganized services

View differences:

modules/uoa-repository-dashboard-gui/trunk/app/pages/adminPg/adminPg-metrics.component.ts
1 1
import { Component, OnInit, ViewChild } from '@angular/core';
2
import { RepositoryService } from '../../services/repository.service';
2
import { PiwikService } from '../../services/piwik.service';
3 3
import { PiwikInfo } from '../../domain/typeScriptClasses';
4
import { AuthenticationService } from '../../services/authentication.service';
5 4
import { loadingReposMessage, reposRetrievalError } from '../../domain/shared-messages';
6 5
import { ConfirmationDialogComponent } from '../../shared/reusablecomponents/confirmation-dialog.component';
7 6

  
......
23 22
  @ViewChild('confirmApprovalModal')
24 23
  public confirmApprovalModal: ConfirmationDialogComponent;
25 24

  
26
  constructor(private repoService: RepositoryService) {}
25
  constructor(private piwikService: PiwikService) {}
27 26

  
28 27
  ngOnInit() {
29 28
    this.getPiwiks();
......
34 33
  getPiwiks(){
35 34
    this.showSpinner = true;
36 35
    this.loadingMessage = loadingReposMessage;
37
    this.repoService.getPiwikSitesForRepos()
36
    this.piwikService.getPiwikSitesForRepos()
38 37
      .subscribe(
39 38
        piwiks => this.piwiks = piwiks.sort( function(a,b){
40 39
          if(a.repositoryName<b.repositoryName){
modules/uoa-repository-dashboard-gui/trunk/app/pages/sources/sources-forms/datasource-interface-form.component.ts
1
import { Component } from '@angular/core';
1
import { Component, Injector } from '@angular/core';
2 2
import { MyGroup } from '../../../shared/reusablecomponents/forms/my-group.interface';
3 3
import { Validators } from '@angular/forms';
4
import { formErrorRequiredFields, formSuccessAddedInterface } from '../../../domain/shared-messages';
4
import {
5
  formErrorRequiredFields, formSuccessAddedInterface,
6
  invalidCustomBaseUrl
7
} from '../../../domain/shared-messages';
8
import { ValidatorService } from '../../../services/validator.service';
5 9

  
6 10
@Component ({
7 11
  selector: 'datasource-interface-form',
......
21 25
    compatibilityLevel: ['', Validators.required],
22 26
  };
23 27

  
28
  constructor(injector: Injector, private valService: ValidatorService){
29
    super(injector);
30
  }
24 31

  
25 32
  ngOnInit(){
26 33

  
......
62 69

  
63 70
  saveInterface() {
64 71
    if(this.group.valid) {
65
      this.successMessage = formSuccessAddedInterface;
66
      this.errorMessage = '';
72
      let response: boolean;
73
      this.valService.identifyRepository(this.group.get('baseUrl').value).subscribe(
74
        res => response = res,
75
        error => console.log(error)
76
      );
77
      if ( response ) {
78
        this.successMessage = formSuccessAddedInterface;
79
        this.errorMessage = '';
80
      } else {
81
        this.errorMessage = invalidCustomBaseUrl;
82
        this.successMessage = '';
83
      }
67 84
    } else {
68 85
      this.errorMessage = formErrorRequiredFields;
69 86
      this.successMessage = '';
modules/uoa-repository-dashboard-gui/trunk/app/pages/sources/sources-forms/datasource-info-form.component.html
33 33
  <form-inline [description]="countryDesc">
34 34
    <select formControlName="country" class="form-control">
35 35
      <option value="">-- none selected --</option>
36
      <option value="{{ selectedRepo.countryCode }}">{{ selectedRepo.countryName }}</option>
36
      <option *ngFor="let country of countries" value="{{country.code}}">{{ country.name }}</option>
37 37
    </select>
38 38
  </form-inline>
39 39
  <form-inline [description]="longtitudeDesc" [valid]="updateGroup.get('longtitude').valid">
modules/uoa-repository-dashboard-gui/trunk/app/pages/metrics/metrics-show.component.ts
1
import { Component, Input, OnInit } from '@angular/core';
1
import { Component, OnInit } from '@angular/core';
2 2
import { ActivatedRoute } from '@angular/router';
3 3
import { PiwikInfo } from '../../domain/typeScriptClasses';
4
import { RepositoryService } from '../../services/repository.service';
4
import { PiwikService } from '../../services/piwik.service';
5 5

  
6 6
@Component ({
7 7
  selector: 'metrics-show',
......
13 13

  
14 14
  constructor(
15 15
    private route: ActivatedRoute,
16
    private repoService: RepositoryService
16
    private piwikService: PiwikService
17 17
  ) {}
18 18

  
19 19
  ngOnInit() {
......
22 22

  
23 23
  getPiwik(): void {
24 24
    let id = this.route.snapshot.paramMap.get('id');
25
    this.repoService.getPiwikInfo(id).subscribe(
25
    this.piwikService.getPiwikInfo(id).subscribe(
26 26
      piwik => this.piwik = piwik,
27 27
      error => console.log(error)
28 28
    );
modules/uoa-repository-dashboard-gui/trunk/app/pages/metrics/metrics-instructions.component.ts
4 4

  
5 5
import {Component, OnInit} from '@angular/core';
6 6
import {PiwikInfo} from '../../domain/typeScriptClasses';
7
import {RepositoryService} from '../../services/repository.service';
8 7
import {ActivatedRoute} from '@angular/router';
8
import { PiwikService } from '../../services/piwik.service';
9 9

  
10 10
@Component ({
11 11
  selector: 'app-metrics-instructions',
......
18 18

  
19 19
  constructor(
20 20
    private route: ActivatedRoute,
21
    private repoService: RepositoryService
21
    private piwikService: PiwikService
22 22
  ) {}
23 23

  
24 24
  ngOnInit() {
......
27 27

  
28 28
  getPiwik(): void {
29 29
    let id = this.route.snapshot.paramMap.get('id');
30
    this.repoService.getPiwikInfo(id).subscribe(
30
    this.piwikService.getPiwikInfo(id).subscribe(
31 31
      piwik => this.piwik = piwik,
32 32
      error => console.log(error)
33 33
    );
modules/uoa-repository-dashboard-gui/trunk/app/pages/compatibility/compatibility-validate-type.component.html
107 107
      </div>
108 108
    </div>
109 109
    <div *ngIf="showParameters">parameters</div>
110
    <div *ngIf="showFinish">finish</div>
111 110
  </div>
112 111
</div>
113 112

  
modules/uoa-repository-dashboard-gui/trunk/app/pages/compatibility/compatibility-validate-forms/compatibility-validate-step1.component.ts
38 38
    }
39 39
  }
40 40

  
41
  goToNext() {
41
  submitForm() {
42 42
    if ( this.group.get('selectBaseUrl').value || this.group.get('customBaseUrl').value ) {
43 43
      let response: boolean;
44 44
      if (this.group.get('customBaseUrl').value ) {
modules/uoa-repository-dashboard-gui/trunk/app/pages/compatibility/compatibility-validate-forms/compatibility-validate-step1.component.html
16 16
      <span>or enter new</span>
17 17
    </label>
18 18
  </div>
19
  <span *ngIf="group.get('customBaseUrl').invalid && group.get('customBaseUrl').touched && group.get('customBaseUrl').dirty"
20
        class="help-block inline"
21
        style="margin-top: 0px; margin-bottom: 0px; padding-left: 10px;">The url is not valid</span>
22
  <input id="customBaseUrl" formControlName="customBaseUrl" class="form-control" type="text" (focus)="group.get('customBaseUrl').markAsUntouched()" (blur)="group.get('customBaseUrl').updateValueAndValidity()">
19
  <input id="customBaseUrl" formControlName="customBaseUrl" class="form-control" type="text">
23 20
</div>
modules/uoa-repository-dashboard-gui/trunk/app/pages/compatibility/compatibility-validate-type.component.ts
47 47

  
48 48
  moveAStep(){
49 49
    if (this.showDatasource) {
50
      if(this.step1ChooseBaseUrl.goToNext()) {
50
      if(this.step1ChooseBaseUrl.submitForm()) {
51 51
        this.showGuidelines = true;
52 52
        this.showDatasource = false;
53 53
        this.step2 = 'active';
modules/uoa-repository-dashboard-gui/trunk/app/services/repository.service.ts
11 11

  
12 12
import { Observable } from 'rxjs/Observable';
13 13

  
14
import { Country, PiwikInfo, Repository, RepositoryInterface, Timezone, Topic } from '../domain/typeScriptClasses';
14
import { Country, Repository, RepositoryInterface, Timezone, Topic } from '../domain/typeScriptClasses';
15 15
import 'rxjs/add/operator/map';
16 16
import { Http, Response } from '@angular/http';
17
import { AuthenticationService } from './authentication.service';
18 17

  
19 18
const httpOptions = {
20 19
  headers: new HttpHeaders().set('Content-Type', 'application/json')
......
78 77
      .catch(this.handleError);
79 78
  }
80 79

  
81
  getPiwikInfo(id: string): Observable<PiwikInfo> {
82
    let url = `${this.apiUrl}/piwik/getPiwikSiteForRepo/${id}`;
83
    console.log(`knocking on: ${url}`);
84
    return this.http.get(url)
85
      .map( piwik => <PiwikInfo>piwik.json() )
86
      .catch(this.handleError);
87
  }
88

  
89 80
  getTopicsForDataSource(name: string): Observable<Topic[]> {
90 81
    let url = `${this.apiUrl}/broker/getTopicsForDatasource/${name}`;
91 82
    console.log(`knocking on: ${url}`);
......
102 93
      .catch(this.handleError);
103 94
  }
104 95

  
105
  getPiwikSitesForRepos(): Observable<PiwikInfo[]> {
106
    let url = `${this.apiUrl}/piwik/getPiwikSitesForRepos`;
107
    console.log(`knocking on: ${url}`);
108
    return this.http.get(url)
109
      .map( res => <PiwikInfo[]>res.json())
110
      .catch(this.handleError);
111
  }
112

  
113 96
  private handleError(error: Response | any) {
114 97
    // In a real world app, we might use a remote logging infrastructure
115 98
    // We'd also dig deeper into the error to get a better message
modules/uoa-repository-dashboard-gui/trunk/app/services/piwik.service.ts
1
/*
2
* Created by myrto on 12/05/2017
3
*/
4

  
5
/*
6
*  !!! USING TEMPORARY API ADDRESS AND USER
7
*/
8

  
9
import { Injectable } from '@angular/core';
10
import { HttpHeaders } from '@angular/common/http';
11

  
12
import { Observable } from 'rxjs/Observable';
13

  
14
import { PiwikInfo } from '../domain/typeScriptClasses';
15
import 'rxjs/add/operator/map';
16
import { Http, Response } from '@angular/http';
17

  
18
const httpOptions = {
19
  headers: new HttpHeaders().set('Content-Type', 'application/json')
20
};
21

  
22
@Injectable ()
23
export class PiwikService {
24
  /*  private apiUrl = 'http://195.134.66.230:8380/uoa-repository-manager-service';*/
25
  private apiUrl = 'http://194.177.192.121:8380/uoa-repository-manager-service';
26

  
27
  constructor(private http: Http) { }
28

  
29
  getPiwikInfo(id: string): Observable<PiwikInfo> {
30
    let url = `${this.apiUrl}/piwik/getPiwikSiteForRepo/${id}`;
31
    console.log(`knocking on: ${url}`);
32
    return this.http.get(url)
33
      .map( piwik => <PiwikInfo>piwik.json() )
34
      .catch(this.handleError);
35
  }
36

  
37
  getPiwikSitesForRepos(): Observable<PiwikInfo[]> {
38
    let url = `${this.apiUrl}/piwik/getPiwikSitesForRepos`;
39
    console.log(`knocking on: ${url}`);
40
    return this.http.get(url)
41
      .map( res => <PiwikInfo[]>res.json())
42
      .catch(this.handleError);
43
  }
44

  
45
  private handleError(error: Response | any) {
46
    // In a real world app, we might use a remote logging infrastructure
47
    // We'd also dig deeper into the error to get a better message
48
    let errMsg = "";
49
    console.log(error);
50
    if (error instanceof Response) {
51
      const body = error.text() || '';
52
      //const err = body.error || JSON.stringify(body);
53
      errMsg = `${error.status} - ${error.statusText || ''} ${body}`;
54
    } else {
55
      errMsg = (error.message) ? error.message :
56
        error.status ? `${error.status} - ${error.statusText}` : 'Server error';
57
      console.error(errMsg); // log to console instead
58
    }
59
    return Observable.throw(errMsg);
60
  }
61
}
modules/uoa-repository-dashboard-gui/trunk/app/shared/topmenu/topmenu.component.html
105 105
              <ul class="uk-navbar-nav">
106 106
                <li class="uk-parent" [routerLinkActive]="['uk-active']">
107 107
                  <a [routerLink]="['home']" [routerLinkActive]="['active']">
108
                    Home
108
                    Dashboard
109 109
                  </a>
110 110
                </li>
111 111
                <li class="uk-parent" [routerLinkActive]="['uk-active']"><a href="#" class=""
modules/uoa-repository-dashboard-gui/trunk/app/app.module.ts
23 23
import {AuthenticationService} from './services/authentication.service';
24 24
import {AuthGuardService} from './services/auth-guard.service';
25 25
import { ValidatorService } from './services/validator.service';
26
import { PiwikService } from './services/piwik.service';
26 27

  
27 28

  
28 29
@NgModule({
......
51 52
  ],
52 53
  providers: [
53 54
//    appRoutingProviders
55
    PiwikService,
54 56
    RepositoryService,
55 57
    ValidatorService,
56 58
    AuthGuardService,

Also available in: Unified diff