Project

General

Profile

« Previous | Next » 

Revision 58001

Update branch with a new copy

View differences:

modules/uoa-services-library/branches/elixir/ng-openaire-library/webpack.server.config.js
1
// Work around for https://github.com/angular/angular-cli/issues/7200
2

  
3
const path = require('path');
4
const webpack = require('webpack');
5

  
6
module.exports = {
7
  entry: {
8
    // This is our Express server for Dynamic universal
9
    server: './server.ts',
10
    // This is an example of Static prerendering (generative)
11
    prerender: './prerender.ts'
12
  },
13
  target: 'node',
14
  resolve: { extensions: ['.ts', '.js'] },
15
  // Make sure we include all node_modules etc
16
  externals: [/(node_modules|main\..*\.js)/,],
17
  optimization: {
18
    minimize: false
19
  },
20
  output: {
21
    // Puts the output at the root of the dist folder
22
    path: path.join(__dirname, 'dist'),
23
    filename: '[name].js'
24
  },
25
  module: {
26
    rules: [
27
      { test: /\.ts$/, loader: 'ts-loader' }
28
      ,{
29
        // Mark files inside `@angular/core` as using SystemJS style dynamic imports.
30
        // Removing this will cause deprecation warnings to appear.
31
        test: /(\\|\/)@angular(\\|\/)core(\\|\/).+\.js$/,
32
        parser: { system: true },
33
      },
34
    ]
35
  },
36
  plugins: [
37
    new webpack.ContextReplacementPlugin(
38
      // fixes WARNING Critical dependency: the request of a dependency is an expression
39
      /(.+)?angular(\\|\/)core(.+)?/,
40
      path.join(__dirname, 'src'), // location of your src
41
      {} // a map of your routes
42
    ),
43
    new webpack.ContextReplacementPlugin(
44
      // fixes WARNING Critical dependency: the request of a dependency is an expression
45
      /(.+)?express(\\|\/)(.+)?/,
46
      path.join(__dirname, 'src'),
47
      {}
48
    )
49
  ]
50
}
51
  
modules/uoa-services-library/branches/elixir/ng-openaire-library/angular.json
1
{
2
  "$schema": "./node_modules/@angular-devkit/core/src/workspace/workspace-schema.json",
3
  "version": 1,
4
  "newProjectRoot": "projects",
5
  "projects": {
6
    "ng-openaire-library": {
7
      "root": "",
8
      "projectType": "application",
9
      "architect": {
10
        "build": {
11
          "builder": "@angular-devkit/build-angular:browser",
12
          "options": {
13
            "outputPath": "dist/browser",
14
            "index": "src/index.html",
15
            "main": "src/main.ts",
16
            "tsConfig": "src/tsconfig.app.json",
17
            "polyfills": "src/polyfills.ts",
18
            "assets": [
19
              {
20
                "glob": "**/*",
21
                "input": "src/assets",
22
                "output": "/assets"
23
              },
24
              {
25
                "glob": "favicon.ico",
26
                "input": "src",
27
                "output": "/"
28
              }
29
            ],
30
            "styles": [
31
              "src/styles.css",
32
              "node_modules/datatables.net-dt/css/jquery.dataTables.css"
33
            ],
34
            "scripts": [
35
              "node_modules/jquery/dist/jquery.js",
36
              "node_modules/datatables.net/js/jquery.dataTables.js"
37
            ]
38
          },
39
          "configurations": {
40
            "production": {
41
              "optimization": true,
42
              "outputHashing": "all",
43
              "sourceMap": false,
44
              "extractCss": true,
45
              "namedChunks": false,
46
              "aot": true,
47
              "extractLicenses": true,
48
              "vendorChunk": false,
49
              "buildOptimizer": true,
50
              "fileReplacements": [
51
                {
52
                  "replace": "src/environments/environment.ts",
53
                  "with": "src/environments/environment.prod.ts"
54
                }
55
              ]
56
            }
57
          }
58
        },
59
        "serve": {
60
          "builder": "@angular-devkit/build-angular:dev-server",
61
          "options": {
62
            "browserTarget": "ng-openaire-library:build"
63
          },
64
          "configurations": {
65
            "production": {
66
              "browserTarget": "ng-openaire-library:build:production"
67
            }
68
          }
69
        },
70
        "extract-i18n": {
71
          "builder": "@angular-devkit/build-angular:extract-i18n",
72
          "options": {
73
            "browserTarget": "ng-openaire-library:build"
74
          }
75
        },
76
        "test": {
77
          "builder": "@angular-devkit/build-angular:karma",
78
          "options": {
79
            "main": "src/test.ts",
80
            "karmaConfig": "./karma.conf.js",
81
            "polyfills": "src/polyfills.ts",
82
            "tsConfig": "src/tsconfig.spec.json",
83
            "scripts": [],
84
            "styles": [
85
              "src/styles.css"
86
            ],
87
            "assets": [
88
              {
89
                "glob": "**/*",
90
                "input": "src/assets",
91
                "output": "/assets"
92
              },
93
              {
94
                "glob": "favicon.ico",
95
                "input": "src",
96
                "output": "/"
97
              }
98
            ]
99
          }
100
        },
101
        "lint": {
102
          "builder": "@angular-devkit/build-angular:tslint",
103
          "options": {            
104
            "tsConfig": [
105
              "src/tsconfig.app.json"
106
            ],
107
            "exclude": [
108
              "**/node_modules/**"
109
            ]
110
          }
111
        },
112
        "server": {
113
          "builder": "@angular-devkit/build-angular:server",
114
          "options": {
115
            "outputPath": "dist/server",
116
            "main": "src/main.server.ts",
117
            "tsConfig": "src/tsconfig.server.json"
118
          },
119
          "configurations": {
120
            "production": {
121
              "fileReplacements": [
122
                {
123
                  "replace": "src/environments/environment.ts",
124
                  "with": "src/environments/environment.prod.ts"
125
                }
126
              ]
127
            }
128
          }
129
        }
130
      }
131
    },
132
    "ng-openaire-library-e2e": {
133
      "root": "",
134
      "projectType": "application",
135
      "cli": {},
136
      "schematics": {},
137
      "architect": {
138
        "e2e": {
139
          "builder": "@angular-devkit/build-angular:protractor",
140
          "options": {
141
            "protractorConfig": "./protractor.conf.js",
142
            "devServerTarget": "ng-openaire-library:serve"
143
          }
144
        },
145
        "lint": {
146
          "builder": "@angular-devkit/build-angular:tslint",
147
          "options": {
148
            "tsConfig": [],
149
            "exclude": [
150
              "**/node_modules/**"
151
            ]
152
          }
153
        }
154
      }
155
    }
156
  },
157
  "cli": {},
158
  "schematics": {
159
    "@schematics/angular:class": {
160
      "spec": false
161
    },
162
    "@schematics/angular:component": {
163
      "spec": false,
164
      "inlineStyle": true,
165
      "inlineTemplate": true,
166
      "prefix": "app",
167
      "styleext": "css"
168
    },
169
    "@schematics/angular:directive": {
170
      "spec": false,
171
      "prefix": "app"
172
    },
173
    "@schematics/angular:guard": {
174
      "spec": false
175
    },
176
    "@schematics/angular:module": {
177
      "spec": false
178
    },
179
    "@schematics/angular:pipe": {
180
      "spec": false
181
    },
182
    "@schematics/angular:service": {
183
      "spec": false
184
    }
185
  }
186
}
modules/uoa-services-library/branches/elixir/ng-openaire-library/createLibrary.sh
1
rm -rf dist;
2
npm run packagr;
3
cd dist;
4
npm pack;
5
cd ..;
0 6

  
modules/uoa-services-library/branches/elixir/ng-openaire-library/package.json
1
{
2
  "name": "ng-openaire-library",
3
  "version": "1.0.0",
4
  "license": "Openaire",
5
  "contributors": [
6
    "Argiro Kokogiannaki <argirok@di.uoa.gr>",
7
    "Konstantina Galouni <kgalouni@di.uoa.gr>"
8
  ],
9
  "scripts": {
10
    "ng": "ng",
11
    "start": "ng serve --disable-host-check --host 0.0.0.0",
12
    "build": "ng build",
13
    "lint": "ng lint ng-openaire-library",
14
    "build:client-and-server-bundles": "ng build --prod && ng run ng-openaire-library:server:production",
15
    "build:prerender": "npm run build:client-and-server-bundles && npm run webpack:server && npm run generate:prerender",
16
    "build:ssr": "npm run build:client-and-server-bundles && npm run webpack:server",
17
    "generate:prerender": "cd dist && node prerender",
18
    "webpack:server": "webpack --config webpack.server.config.js --progress --colors",
19
    "serve:prerender": "cd dist/browser && http-server",
20
    "serve:ssr": "node dist/server",
21
    "packagr": "ng-packagr -p ng-package.json"
22
  },
23
  "pre-commit": [],
24
  "private": true,
25
  "dependencies": {
26
    "@angular/animations": "7.2.14",
27
    "@angular/cdk": "^7.3.7",
28
    "@angular/common": "7.2.14",
29
    "@angular/compiler": "7.2.14",
30
    "@angular/core": "7.2.14",
31
    "@angular/forms": "7.2.14",
32
    "@angular/http": "7.2.14",
33
    "@angular/material": "^7.3.7",
34
    "@angular/platform-browser": "7.2.14",
35
    "@angular/platform-browser-dynamic": "7.2.14",
36
    "@angular/platform-server": "7.2.14",
37
    "@angular/router": "7.2.14",
38
    "@nguniversal/express-engine": "^6.0.0",
39
    "@nguniversal/module-map-ngfactory-loader": "^6.0.0",
40
    "@types/express": "^4.16.1",
41
    "angular-datatables": "^4.4.1",
42
    "citation-js": "^0.3.4",
43
    "clipboard": "^1.5.16",
44
    "core-js": "^2.4.1",
45
    "datatables.net": "^1.10.19",
46
    "datatables.net-dt": "^1.10.19",
47
    "jquery": "^3.4.1",
48
    "ngx-json-ld": "0.1.6",
49
    "ts-md5": "^1.2.0",
50
    "wikidata-sdk": "^5.2.9",
51
    "zone.js": "^0.8.26"
52
  },
53
  "devDependencies": {
54
    "@angular-devkit/build-angular": "0.11.4",
55
    "@angular/cli": "7.3.9",
56
    "@angular/compiler-cli": "7.2.14",
57
    "@angular/language-service": "7.2.14",
58
    "@types/datatables.net": "^1.10.17",
59
    "@types/jquery": "^3.3.29",
60
    "@types/node": "^8.0.30",
61
    "codelyzer": "^4.0.2",
62
    "cpy-cli": "^1.0.1",
63
    "http-server": "^0.10.0",
64
    "ng-packagr": "^1.6.0",
65
    "pre-commit": "^1.2.2",
66
    "reflect-metadata": "^0.1.10",
67
    "rxjs": "6.5.1",
68
    "rxjs-compat": "^6.5.1",
69
    "rxjs-tslint": "^0.1.7",
70
    "ts-loader": "^4.2.0",
71
    "tslint": "^5.7.0",
72
    "typescript": "3.2.4",
73
    "webpack-cli": "^3.3.2"
74
  }
75
}
modules/uoa-services-library/branches/elixir/ng-openaire-library/tsconfig.json
1
{
2
  "compileOnSave": false,
3
  "compilerOptions": {
4
    "outDir": "./dist/out-tsc",
5
    "sourceMap": true,
6
    "declaration": false,
7
    "moduleResolution": "node",
8
    "emitDecoratorMetadata": true,
9
    "experimentalDecorators": true,
10
    "target": "es5",
11
    "typeRoots": [
12
      "node_modules/@types"
13
    ],
14
    "lib": [
15
      "es2017",
16
      "dom"
17
    ]
18
  }
19
}
modules/uoa-services-library/branches/elixir/ng-openaire-library/ng-package.json
1
{
2
  "$schema": "./node_modules/ng-packagr/ng-package.schema.json",
3
  "lib": {
4
    "entryFile": "public_api.ts"
5
  }
6
}
modules/uoa-services-library/branches/elixir/ng-openaire-library/tslint.json
1
{
2
  "rulesDirectory": [
3
    "node_modules/codelyzer"
4
  ],
5
  "rules": {
6
    "arrow-return-shorthand": true,
7
    "callable-types": true,
8
    "class-name": true,
9
    "comment-format": [
10
      true,
11
      "check-space"
12
    ],
13
    "curly": true,
14
    "deprecation": {
15
      "severity": "warn"
16
    },
17
    "eofline": true,
18
    "forin": true,
19
    "import-blacklist": [
20
      true,
21
      "rxjs/Rx",
22
      "rxjs/operators"
23
    ],
24
    "import-spacing": true,
25
    "indent": [
26
      true,
27
      "spaces"
28
    ],
29
    "interface-over-type-literal": true,
30
    "label-position": true,
31
    "max-line-length": [
32
      true,
33
      140
34
    ],
35
    "member-access": false,
36
    "member-ordering": [
37
      true,
38
      {
39
        "order": [
40
          "static-field",
41
          "instance-field",
42
          "static-method",
43
          "instance-method"
44
        ]
45
      }
46
    ],
47
    "no-arg": true,
48
    "no-bitwise": true,
49
    "no-console": [
50
      true,
51
      "debug",
52
      "info",
53
      "time",
54
      "timeEnd",
55
      "trace"
56
    ],
57
    "no-construct": true,
58
    "no-debugger": true,
59
    "no-duplicate-super": true,
60
    "no-empty": false,
61
    "no-empty-interface": true,
62
    "no-eval": true,
63
    "no-inferrable-types": [
64
      true,
65
      "ignore-params"
66
    ],
67
    "no-misused-new": true,
68
    "no-non-null-assertion": true,
69
    "no-shadowed-variable": true,
70
    "no-string-literal": false,
71
    "no-string-throw": true,
72
    "no-switch-case-fall-through": true,
73
    "no-trailing-whitespace": true,
74
    "no-unnecessary-initializer": true,
75
    "no-unused-expression": true,
76
    "no-use-before-declare": true,
77
    "no-var-keyword": true,
78
    "object-literal-sort-keys": false,
79
    "one-line": [
80
      true,
81
      "check-open-brace",
82
      "check-catch",
83
      "check-else",
84
      "check-whitespace"
85
    ],
86
    "prefer-const": true,
87
    "quotemark": [
88
      true,
89
      "single"
90
    ],
91
    "radix": true,
92
    "semicolon": [
93
      true,
94
      "always"
95
    ],
96
    "triple-equals": [
97
      true,
98
      "allow-null-check"
99
    ],
100
    "typedef-whitespace": [
101
      true,
102
      {
103
        "call-signature": "nospace",
104
        "index-signature": "nospace",
105
        "parameter": "nospace",
106
        "property-declaration": "nospace",
107
        "variable-declaration": "nospace"
108
      }
109
    ],
110
    "typeof-compare": true,
111
    "unified-signatures": true,
112
    "variable-name": false,
113
    "whitespace": [
114
      true,
115
      "check-branch",
116
      "check-decl",
117
      "check-operator",
118
      "check-separator",
119
      "check-type"
120
    ],
121
    "directive-selector": [
122
      true,
123
      "attribute",
124
      "app",
125
      "camelCase"
126
    ],
127
    "component-selector": [
128
      true,
129
      "element",
130
      "app",
131
      "kebab-case"
132
    ],
133
    "no-output-on-prefix": true,
134
    "use-input-property-decorator": true,
135
    "use-output-property-decorator": true,
136
    "use-host-property-decorator": true,
137
    "no-input-rename": true,
138
    "no-output-rename": true,
139
    "use-life-cycle-interface": true,
140
    "use-pipe-transform-interface": true,
141
    "component-class-suffix": true,
142
    "directive-class-suffix": true
143
  }
144
}
modules/uoa-services-library/branches/elixir/ng-openaire-library/src/app/test/test.component.ts
1
import {Component, ElementRef} from '@angular/core';
2
import { Subject , Observable} from 'rxjs';
3

  
4
import {SearchFields, FieldDetails} from '../utils/properties/searchFields';
5

  
6
@Component({
7
    selector: 'test',
8
    template: `
9

  
10

  
11

  
12
`
13

  
14
})
15
export class TestComponent {
16

  
17
  constructor() {
18

  
19
   }
20

  
21

  
22
  ngOnInit() {
23

  
24
    }
25

  
26

  
27
  test(){
28
    var  sf:SearchFields  = new SearchFields();
29
    console.info("~~~RESULT");
30

  
31
    this.checktables(sf.RESULT_REFINE_FIELDS,sf.RESULT_FIELDS,sf.RESULT_FIELDS);
32
    this.checktables(sf.RESULT_ADVANCED_FIELDS,sf.RESULT_FIELDS,sf.RESULT_FIELDS);
33
    console.info("~~~PR");
34

  
35
    this.checktables(sf.PROJECT_REFINE_FIELDS,sf.PROJECT_FIELDS,sf.PROJECT_FIELDS);
36
    this.checktables(sf.PROJECT_ADVANCED_FIELDS,sf.PROJECT_FIELDS,sf.PROJECT_FIELDS);
37
    console.info("~~~DATAPR");
38

  
39
    this.checktables(sf.DATASOURCE_REFINE_FIELDS,sf.DATASOURCE_FIELDS,sf.DATASOURCE_FIELDS);
40
    this.checktables(sf.DATASOURCE_ADVANCED_FIELDS,sf.DATASOURCE_FIELDS,sf.DATASOURCE_FIELDS);
41

  
42
    console.info("~~~ORG");
43
    this.checktables(sf.ORGANIZATION_REFINE_FIELDS,sf.ORGANIZATION_FIELDS,sf.ORGANIZATION_FIELDS);
44
    this.checktables(sf.ORGANIZATION_ADVANCED_FIELDS,sf.ORGANIZATION_FIELDS,sf.ORGANIZATION_FIELDS);
45
    console.info("~~~PERSON");
46
   
47
 }
48
  checktables(fields,fieldsDetails,fieldsParam){
49
 for(var i =0; i < fields.length; i++){
50
   if(!fieldsDetails[fields[i]]){
51
     console.info("!!!!"+fields[i]+ "field has to details");
52
   }
53
   }
54

  
55
 }
56

  
57

  
58

  
59

  
60
}
modules/uoa-services-library/branches/elixir/ng-openaire-library/src/app/test/test.module.ts
1
import { NgModule } from '@angular/core';
2

  
3
import { SharedModule } from '../shared/shared.module';
4
import { TestComponent } from './test.component';
5
import { TestRoutingModule } from './test-routing.module';
6

  
7

  
8
 
9
@NgModule({
10
  imports: [
11
    SharedModule,
12
    TestRoutingModule,
13

  
14
  ],
15
  declarations: [
16
    TestComponent
17
  ]
18
})
19
export class TestModule { }
modules/uoa-services-library/branches/elixir/ng-openaire-library/src/app/test/test-routing.module.ts
1
import { NgModule } from '@angular/core';
2
import { RouterModule } from '@angular/router';
3

  
4
import { TestComponent } from './test.component';
5

  
6
@NgModule({
7
  imports: [
8
    RouterModule.forChild([
9
      { path: '', component: TestComponent},
10

  
11
    ])
12
  ]
13
})
14
export class TestRoutingModule { }
modules/uoa-services-library/branches/elixir/ng-openaire-library/src/app/contact-us/contact-us.component.html
1
<div class="uk-margin-auto uk-text-bold uk-h4">{{formTitle}}</div>
2
<div *ngIf="errorMessage" class="uk-width-1-1 uk-alert uk-alert-danger uk-text-center"
3
     role="alert">{{errorMessage}}</div>
4
<div class="uk-margin-top" uk-grid [formGroup]="contactForm">
5
    <div class="uk-margin-small uk-width-1-1 uk-text-danger uk-text-bold uk-margin-remove-bottom">
6
        *Required fields
7
    </div>
8
    <div *ngIf="contactForm.get('name')" class="uk-width-1-2@s uk-margin-small-top">
9
        <label class="uk-h5 uk-text-bold">
10
            Name <span class="uk-text-danger uk-text-bold">*</span>
11
        </label>
12
        <input class="uk-input" type="text" placeholder="Your name" formControlName="name"
13
               [class.uk-form-danger]="contactForm.get('name').invalid && contactForm.get('name').touched">
14
    </div>
15
    <div *ngIf="contactForm.get('surname')" class="uk-width-1-2@s uk-margin-small-top">
16
        <label class="uk-h5 uk-text-bold">
17
            Surname <span class="uk-text-danger uk-text-bold">*</span>
18
        </label>
19
        <input class="uk-input" type="text" placeholder="Your surname" formControlName="surname"
20
               [class.uk-form-danger]="contactForm.get('surname').invalid && contactForm.get('surname').touched">
21
    </div>
22
    <div *ngIf="contactForm.get('email')" class="uk-width-1-2@s uk-margin-small-top">
23
        <label class="uk-h5 uk-text-bold">
24
            Email <span class="uk-text-danger uk-text-bold">*</span>
25
        </label>
26
        <input class="uk-input" type="text" placeholder="Your email" formControlName="email"
27
               [class.uk-form-danger]="contactForm.get('email').invalid && contactForm.get('email').touched">
28
    </div>
29
    <div *ngIf="contactForm.get('affiliation')" class="uk-width-1-2@s uk-margin-small-top">
30
        <label class="uk-h5 uk-text-bold">
31
            Affiliation <span class="uk-text-danger uk-text-bold">*</span>
32
        </label>
33
        <input class="uk-input" type="text" placeholder="Your affiliation" formControlName="affiliation"
34
               [class.uk-form-danger]="contactForm.get('affiliation').invalid && contactForm.get('affiliation').touched">
35
    </div>
36
    <div *ngIf="contactForm.get('community')" class="uk-width-1-2@s uk-margin-top">
37
        <label class="uk-h5 uk-text-bold">
38
            Community Name <span class="uk-text-danger uk-text-bold">*</span>
39
        </label>
40
        <input class="uk-input" type="text" placeholder="Your community name" formControlName="community"
41
               [class.uk-form-danger]="contactForm.get('community').invalid && contactForm.get('community').touched">
42
    </div>
43
    <div *ngIf="contactForm.get('funder')" class="uk-width-1-2@s uk-margin-top">
44
        <label class="uk-h5 uk-text-bold">
45
            Funder Name <span class="uk-text-danger uk-text-bold">*</span>
46
        </label>
47
        <input class="uk-input" type="text" placeholder="Your funder name" formControlName="funder"
48
               [class.uk-form-danger]="contactForm.get('funder').invalid && contactForm.get('funder').touched">
49
    </div>
50
    <div *ngIf="contactForm.get('message')" class="uk-width-1-1 uk-margin-top">
51
        <label class="uk-h5 uk-text-bold">
52
            Message <span class="uk-text-danger uk-text-bold">*</span>
53
        </label>
54
        <textarea rows="4" class="uk-textarea" placeholder="Your message" formControlName="message"
55
                  [class.uk-form-danger]="contactForm.get('message').invalid && contactForm.get('message').touched">
56
        </textarea>
57
    </div>
58
    <div *ngIf="contactForm.get('message')" class="uk-width-1-1 uk-margin-top">
59
        <re-captcha (resolved)="handleRecaptcha($event)" [(siteKey)]="properties.reCaptchaSiteKey">
60
        </re-captcha>
61
    </div>
62
    <div class="uk-width-1-1 uk-text-right">
63
        <button class="uk-button uk-button-default uk-margin-small-right"
64
                (click)="reset()">Reset</button>
65
        <button class="uk-button portal-button" (click)="send()">Send</button>
66
    </div>
67
</div>
modules/uoa-services-library/branches/elixir/ng-openaire-library/src/app/contact-us/contact-us.component.ts
1
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
2
import {FormGroup} from '@angular/forms';
3
import {EnvProperties} from "../utils/properties/env-properties";
4

  
5
@Component({
6
    selector: 'contact-us',
7
    templateUrl: './contact-us.component.html',
8
})
9

  
10
export class ContactUsComponent implements OnInit {
11
    @Input()
12
    public contactForm: FormGroup;
13
    @Input() formTitle: string;
14
    @Input() properties: EnvProperties;
15
    @Output() sendEmitter: EventEmitter<any> = new EventEmitter<any>();
16
    @Output() resetEmitter: EventEmitter<any> = new EventEmitter<any>();
17
    @Input() errorMessage;
18

  
19
    constructor() {
20
    }
21

  
22
    ngOnInit() {
23
    }
24

  
25
    public send() {
26
        this.sendEmitter.emit({
27
            valid: this.contactForm.valid
28
        });
29
    }
30

  
31
    public reset() {
32
        this.resetEmitter.emit();
33
    }
34

  
35

  
36
    public handleRecaptcha(captchaResponse: string) {
37
        this.contactForm.get('recaptcha').setValue(captchaResponse);
38
    }
39
}
modules/uoa-services-library/branches/elixir/ng-openaire-library/src/app/contact-us/contact-us.module.ts
1
import {NgModule} from '@angular/core';
2
import {CommonModule} from '@angular/common';
3
import {RouterModule} from '@angular/router';
4

  
5
import {ContactUsComponent} from './contact-us.component';
6
import {RecaptchaModule} from "ng-recaptcha";
7
import {ReactiveFormsModule} from "@angular/forms";
8

  
9
@NgModule({
10
    imports: [
11
        CommonModule, RouterModule,
12
        RecaptchaModule.forRoot(), ReactiveFormsModule],
13
    declarations: [
14
        ContactUsComponent
15
    ],
16
    providers: [],
17
    exports: [
18
        ContactUsComponent
19
    ]
20
})
21

  
22
export class ContactUsModule {
23
}
modules/uoa-services-library/branches/elixir/ng-openaire-library/src/app/services/adminToolService.module.ts
1
import { NgModule } from '@angular/core';
2
import { CommonModule } from '@angular/common';
3
import {HelpContentService} from "./help-content.service";
4

  
5

  
6
@NgModule({
7
  imports: [
8
    CommonModule,
9
  ],
10
  declarations:[ ],
11
  providers: [HelpContentService],
12

  
13

  
14
})
15
export class AdminToolServiceModule { }
modules/uoa-services-library/branches/elixir/ng-openaire-library/src/app/services/searchDataproviders.service.ts
1
import {Injectable} from '@angular/core';
2
import {Http, Response} from '@angular/http';
3
import {HttpClient} from "@angular/common/http";
4
import {Observable}     from 'rxjs';
5
import {SearchResult}     from '../utils/entities/searchResult';
6
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
7

  
8

  
9

  
10
import {StringUtils} from '../utils/string-utils.class';
11
import{EnvProperties} from '../utils/properties/env-properties';
12
import {map} from "rxjs/operators";
13

  
14
@Injectable()
15
export class SearchDataprovidersService {
16
    constructor(private http: HttpClient ) {}
17

  
18
    searchDataproviders (params: string, refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties, usedBy: string="search" ):any {
19
        let link = properties.searchAPIURLLAst+"datasources";
20

  
21
        let url = link+"?";
22
        if(params!= null && params != ''  ) {
23
            url += params;
24
        }
25
        if(refineParams!= null && refineParams != ''  ) {
26
            url += refineParams;
27
        }
28
        url += "&page="+(page-1)+"&size="+size+"&format=json";
29

  
30

  
31
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
32
                    //.map(res => <any> res.json())
33
                    //.do(res => console.info(res))
34
                    .pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource", usedBy)]));
35
    }
36
    //((oaftype exact datasource) and(collectedfromdatasourceid exact "openaire____::47ce9e9f4fad46e732cff06419ecaabb"))
37
    advancedSearchDataproviders (params: string, page: number, size: number, properties: EnvProperties ):any {
38
      let url =  properties.searchResourcesAPIURL;
39
      var basicQuery = "(oaftype exact datasource) " +
40
      'and (datasourcecompatibilityid <> "UNKNOWN")';
41
      url += "?query=";
42
      if(params!= null && params != ''  ) {
43
        url +=" ( "+basicQuery+ " ) " +" and (" + params + ")";
44
      }else{
45
        url +=" ( "+basicQuery+ " ) ";
46
      }
47

  
48
      url += "&page="+(page-1)+"&size="+size+"&format=json";
49

  
50
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
51
      //.map(res => <any> res.json())
52
      //.do(res => console.info(res))
53
      .pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]))
54
    }
55

  
56
    searchCompatibleDataprovidersTable ( properties:EnvProperties):any {
57
      let size: number = 0;
58
      let url: string= properties.searchResourcesAPIURL;
59
      url += '?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other) not(datasourcetypeuiid exact "pubsrepository::journal") not(datasourcetypeuiid exact "aggregator::pubsrepository::journals"))';
60
      url += "&page=0&size=0&format=json";
61

  
62

  
63

  
64
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
65
                      //.map(res => <any> res.json())
66
                      .pipe(map(res => res['meta'].total));
67
    }
68

  
69
    searchCompatibleDataproviders (params: string,refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any {
70
      let url: string = properties.searchResourcesAPIURL;
71
      url += '?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other) not(datasourcetypeuiid exact "pubsrepository::journal") not(datasourcetypeuiid exact "aggregator::pubsrepository::journals"))';
72
      if(params!= null && params != ''  ) {
73
        url += params;
74
      }
75
      if(refineParams!= null && refineParams != ''  ) {
76
        url += refineParams;
77
      }
78
      url += "&page="+(page-1)+"&size="+size+"&format=json";
79

  
80
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
81
      //.map(res => <any> res.json())
82
      //.do(res => console.info(res))
83
      .pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]));
84
    }
85

  
86
    searchEntityRegistriesTable (properties:EnvProperties):any {
87
      let size: number = 0;
88
      let url: string= properties.searchResourcesAPIURL;
89
      url += "?query=((oaftype exact datasource) and(datasourcetypeuiid = other))";
90
      url += "&page=0&size=0&format=json";
91

  
92

  
93

  
94
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
95
                      //.map(res => <any> res.json())
96
                      .pipe(map(res => res['meta'].total));
97
    }
98

  
99
    searchEntityRegistries (params: string,refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any {
100
      let url = properties.searchResourcesAPIURL;
101
      url += "?query=((oaftype exact datasource) and(datasourcetypeuiid = other))";
102
      if(params!= null && params != ''  ) {
103
        url += params;
104
      }
105
      if(refineParams!= null && refineParams != ''  ) {
106
        url += refineParams;
107
      }
108
      url += "&page="+(page-1)+"&size="+size+"&format=json";
109

  
110
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
111
      //.map(res => <any> res.json())
112
      //.do(res => console.info(res))
113
      .pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]));
114
    }
115

  
116
    searchJournalsTable ( properties:EnvProperties):any {
117
      let size: number = 0;
118
      let url: string= properties.searchResourcesAPIURL;
119
      url += '?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) and (datasourcetypeuiid exact "pubsrepository::journal" or datasourcetypeuiid exact "aggregator::pubsrepository::journals" ))';
120
      url += "&page=0&size=0&format=json";
121

  
122
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)//.map(res => <any> res.json())
123
                        .pipe(map(res => res['meta'].total));
124
    }
125

  
126
    searchJournals (params: string,refineParams:string, page: number, size: number, refineFields:string[] , properties:EnvProperties):any {
127
      let url: string = properties.searchResourcesAPIURL;
128
      //url += "?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other))"
129
      url += '?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) and (datasourcetypeuiid exact "pubsrepository::journal" or datasourcetypeuiid exact "aggregator::pubsrepository::journals" ))';
130

  
131
      if(params!= null && params != ''  ) {
132
        url += params;
133
      }
134
      if(refineParams!= null && refineParams != ''  ) {
135
        url += refineParams;
136
      }
137
      url += "&page="+(page-1)+"&size="+size+"&format=json";
138

  
139
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
140
      //.map(res => <any> res.json())
141
      //.do(res => console.info(res))
142
      .pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]));
143
    }
144

  
145
    searchDataprovidersForDeposit (id: string,type:string, page: number, size: number, properties:EnvProperties):any {
146
        let link = properties.searchResourcesAPIURL;
147
        var compatibilities = "";
148
        if(type == "Research Data"){
149
          //compatibilities = " and (datasourcecompatibilityid <> UNKNOWN) and (datasourcecompatibilityid = openaire2.0_data)"
150
          compatibilities = " and (datasourcecompatibilityid = openaire2.0_data)";
151
        }else if(type == "Publications"){
152
          //compatibilities = " and (datasourcecompatibilityid <> UNKNOWN) and (datasourcecompatibilityid <> openaire2.0_data)"
153
          compatibilities = " and (datasourcecompatibilityid <> openaire2.0_data)";
154
        }
155
        let url = link+"?query=(((deletedbyinference = false) AND (oaftype exact datasource)) "+((compatibilities && compatibilities.length > 0)?" "+compatibilities+" ":"")+") and (relorganizationid exact \""+id+"\")";
156
        url += "&page="+(page-1)+"&size="+size+"&format=json";
157

  
158

  
159
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
160
                    //.map(res => <any> res.json())
161
                    .pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
162
    }
163

  
164
    searchDataprovidersForDepositSearch(params: string, refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties, usedBy: string="search" ):any {
165
    let link = properties.searchResourcesAPIURL;
166
      let url = link+"?query=((deletedbyinference = false) AND (oaftype exact datasource)) "+params;
167
      if(refineParams!= null && refineParams != ''  ) {
168
        url += refineParams;
169
      }
170
      url += "&page="+(page-1)+"&size="+size+"&format=json";
171

  
172
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
173
                      .pipe(map(res => [res['meta'].total, this.parseResults(res['results']), RefineResultsUtils.parse(res['refineResults'],
174
                                              refineFields, "datasource", usedBy)]));
175
  }
176

  
177
    searchDataProvidersBySubjects(keyword:string, type:string, page: number, size: number, properties:EnvProperties):any {
178
      let link = properties.searchResourcesAPIURL;
179
      var compatibilities = "";
180
      if(type == "Research Data"){
181
        compatibilities = " and (datasourcecompatibilityid <> UNKNOWN) and (datasourcecompatibilityid = openaire2.0_data)"
182
      }else if(type == "Publications"){
183
        compatibilities = " and (datasourcecompatibilityid <> UNKNOWN) and (datasourcecompatibilityid <> openaire2.0_data)"
184
      }
185
      let url = link+"?query=(((deletedbyinference = false) AND (oaftype exact datasource)) "+((compatibilities && compatibilities.length > 0)?" "+
186
      compatibilities+" ":"")+") "+
187
      " and (datasourcesubject all "+'"'+keyword+'"'+") " ;
188
      url += "&page="+(page-1)+"&size="+size+"&format=json";
189

  
190

  
191
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
192
                  //.map(res => <any> res.json())
193
                  .pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
194

  
195
    }
196

  
197
    getDataProvidersforEntityRegistry(datasourceId: string, page: number, size: number , properties:EnvProperties):any {
198
      let url = properties.searchResourcesAPIURL;
199
      var basicQuery = "(oaftype exact datasource) "
200
      url += "?query=";
201
      if(datasourceId!= null && datasourceId != ''  ) {
202
        url +=" ( "+basicQuery+ " ) " +" and (collectedfromdatasourceid exact \"" + datasourceId + "\")";
203
      }else{
204
        url +=" ( "+basicQuery+ " ) ";
205
      }
206

  
207
      url += "&page="+(page-1)+"&size="+size+"&format=json";
208

  
209
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
210
      //.map(res => <any> res.json())
211
      .pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
212
    }
213
    searchDataprovidersForEntity (params: string, page: number, size: number, properties:EnvProperties):any {
214
        let link = properties.searchAPIURLLAst;
215
        let url = link+params+"/datasources?format=json";
216

  
217
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
218
                    //.map(res => <any> res.json())
219
                    .pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
220
    }
221
/*
222
    searchDataprovidersCSV (params: string, refineParams:string, page: number, size: number):any {
223

  
224
        let link = OpenaireProperties. getSearchAPIURLLast()+"datasources";
225

  
226
        let url = link+"?";
227
        if(params!= null && params != ''  ) {
228
            url += params;
229
        }
230
        if(refineParams!= null && refineParams != ''  ) {
231
            url += refineParams;
232
        }
233
        url += "&page="+(page-1)+"&size="+size+"&format=json";
234

  
235
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
236
                    .map(res => <any> res.json())
237
                    //.do(res => console.info(res))
238

  
239
                    .map(res => this.parseResultsCSV(res['results']));
240
    }
241
*/
242
/*
243
    searchEntityRegistriesCSV (params: string,refineParams:string, page: number, size: number):any {
244
      let url = properties.searchAPIURLLAst;
245
      url += "?query=((oaftype exact datasource) and(datasourcetypeuiid = other))"
246
      if(params!= null && params != ''  ) {
247
        url += params;
248
      }
249
      if(refineParams!= null && refineParams != ''  ) {
250
        url += refineParams;
251
      }
252
      url += "&page="+(page - 1)+"&size="+size+"&format=json";
253

  
254
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
255
      .map(res => <any> res.json())
256
      //.do(res => console.info(res))
257

  
258
      .map(res => this.parseResultsCSV(res['results']));
259
    }
260
*/
261
/*
262
    searchCompatibleDataprovidersCSV (params: string,refineParams:string, page: number, size: number):any {
263
      let url = properties.searchAPIURLLAst;
264
      url += "?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other))"
265
      if(params!= null && params != ''  ) {
266
        url += params;
267
      }
268
      if(refineParams!= null && refineParams != ''  ) {
269
        url += refineParams;
270
      }
271
      url += "&page="+(page - 1)+"&size="+size+"&format=json";
272

  
273
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
274
      .map(res => <any> res.json())
275
      //.do(res => console.info(res))
276

  
277
      .map(res => this.parseResultsCSV(res['results']));
278
    }
279
*/
280

  
281

  
282
    parseResults(data: any): SearchResult[] {
283
        let results: SearchResult[] = [];
284

  
285
        let length = Array.isArray(data) ? data.length : 1;
286

  
287
        for(let i=0; i<length; i++) {
288
            let resData = Array.isArray(data) ? data[i]['result']['metadata']['oaf:entity']['oaf:datasource'] : data['result']['metadata']['oaf:entity']['oaf:datasource'];
289

  
290
            var result: SearchResult = new SearchResult();
291

  
292
            result['title'] = {"name": '', "accessMode": '', "sc39": ''};
293

  
294
            result['title'].name = resData.officialname;
295
            result['englishname'] = resData.englishname;
296

  
297
            //result['title'].url = OpenaireProperties.getsearchLinkToDataProvider();
298
            //result['title'].url += Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
299
            result['id'] = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
300

  
301
            result['type'] = this.getDataproviderType(resData);
302

  
303
            let typeid: string = resData['datasourcetype'].classid;
304
            //console.info(typeid);
305
            if(typeid != "entityregistry" && typeid != "entityregistry::projects" && typeid != "entityregistry::repositories") {
306

  
307
                if(resData.hasOwnProperty('accessinfopackage')) {
308
                    let OAIPMHURL: string;
309
                    if(Array.isArray(resData['accessinfopackage'])) {
310
                        OAIPMHURL = resData['accessinfopackage'][0];
311
                    } else {
312
                        OAIPMHURL = resData['accessinfopackage'];
313
                    }
314

  
315
                    if(OAIPMHURL != '' && OAIPMHURL != 'unknown') {
316
                        result['OAIPMHURL'] = OAIPMHURL;
317
                    }
318
                }
319
                let compatibility = this.getDataproviderCompatibility(resData);
320
                result['compatibility'] = compatibility.classname;
321
                if(compatibility.classid == "UNKNOWN") {
322
                  result['compatibilityUNKNOWN'] = true;
323
                }
324
            } else {
325
              result['compatibility'] = "";
326
            }
327

  
328
            result['websiteURL'] = resData.websiteurl;
329

  
330
            let res:[string[], {"name":string, "id":string}[]] = this.getDataproviderCountriesOrganizations(resData, true, true);
331
            result['organizations'] = res[1];
332
            result['countries'] = res[0];
333
            result['subjects'] = this.getDataproviderSubjects(resData);
334
            //console.log(result['subjects']);
335
            results.push(result);
336
        }
337

  
338
        return results;
339
    }
340
    getDataproviderSubjects(resData: any): string [] {
341
      var subjects:string [] = [];
342

  
343
      let length = Array.isArray(resData['subjects']) ? resData['subjects'].length : 1;
344
      for(let i=0; i<length; i++) {
345
          let subject = Array.isArray(resData['subjects']) ? resData['subjects'][i] :resData['subjects'];
346
          if(subject.content) {
347
            subjects.push(subject.content);
348
          }
349
      }
350
      return subjects;
351
    }
352
    getDataproviderType(resData: any): string {
353
        if(resData['datasourcetype'].hasOwnProperty("classname")) {
354
            return resData['datasourcetype'].classname;
355
        } else {
356
            return '';
357
        }
358
    }
359

  
360
    getDataproviderCompatibility(resData: any): {"classid": string, "classname": string} {
361
        if(resData.hasOwnProperty('openairecompatibility')) {
362
            return {"classid": resData['openairecompatibility'].classid, "classname": resData['openairecompatibility'].classname};
363
        } else {
364
            return {"classid": "", "classname": ""};
365
        }
366
    }
367

  
368
    getDataproviderCountriesOrganizations(resData: any, getCountries: boolean, getOrganizations: boolean): [string[], {"name": string, "id": string}[]] {
369
        let countries: string[] = [];
370
        let organizations: {"name": string, "id": string}[] = [];
371

  
372
        if(resData['rels'].hasOwnProperty("rel")) {
373
            let countriesSet: Set<string> = new Set<string>();
374

  
375
            let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1;
376

  
377
            for(let i=0; i<relLength; i++) {
378
                let relation = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'][i] : resData['rels']['rel'];
379

  
380
                if(relation.hasOwnProperty("to")) {
381
                    if(relation['to'].class == "provides" && relation['to'].type == "organization") {
382
                        if(getOrganizations) {
383
                            let item: {"name":string, "id":string} = {"name": "", "id": ""};
384
                            //item['name'] = relation.legalname;
385
                            if(relation.legalshortname) {
386
                              item['name'] = relation.legalshortname;
387
                            } else {
388
                              item['name'] = relation.legalname;
389
                            }
390
                            item['id'] = /*OpenaireProperties.getsearchLinkToOrganization()+*/relation['to'].content;
391
                            organizations.push(item);
392
                        }
393

  
394
                        if(getCountries) {
395
                            if(relation.hasOwnProperty('country') &&
396
                               relation.country.hasOwnProperty('classname')) {
397
                                if(!countriesSet.has(relation.country.classname)) {
398
                                    countriesSet.add(relation.country.classname);
399
                                    countries.push(relation.country.classname);
400
                                }
401
                            }
402
                        }
403
                    }
404
                }
405
            }
406
        }
407
        return [countries, organizations];
408
    }
409
/*
410
    parseResultsCSV(data: any): any {
411
        let results: any = [];
412
        let length = Array.isArray(data) ? data.length : 1;
413

  
414
        for(let i=0; i<length; i++) {
415
            let resData = Array.isArray(data) ? data[i]['result']['metadata']['oaf:entity']['oaf:datasource'] : data['result']['metadata']['oaf:entity']['oaf:datasource'];
416

  
417
            var result: any = [];
418

  
419
            result.push(this.quote(resData.officialname));
420
            result.push(this.quote(this.getDataproviderType(resData)));
421
            result.push(this.quote(this.getDataproviderCountriesOrganizations(resData, true, false)[0]));
422
            result.push(this.quote(this.getDataproviderCompatibility(resData)));
423
            results.push(result);
424
        }
425
        return results;
426
    }
427
*/
428
    numOfDataproviders(url: string, properties:EnvProperties):any {
429
        //let url = OpenaireProperties. getSearchAPIURLLast()+params+(params.indexOf("?") == -1 ?"?":"&")+"format=json";
430

  
431
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
432
                    //.map(res => <any> res.json())
433
                    .pipe(map(res => res['total']));
434
    }
435

  
436
    numOfEntityDataproviders(id: string, entity: string, properties:EnvProperties):any {
437
        var parameters = "";
438
        if(entity == "organization") {
439
          parameters = "organizations/"+id+"/datasources/count";
440
        }
441

  
442
        let url = properties.searchAPIURLLAst+parameters+"?format=json";
443
        return this.numOfDataproviders(url, properties);
444
    }
445

  
446
    numOfSearchDataproviders(params: string, properties:EnvProperties, refineQuery:string=null):any {
447
        let url: string = properties.searchAPIURLLAst+"datasources/count?format=json";
448
        if(params != "") {
449
          url += "&q=" + StringUtils.URIEncode(params);
450
        }
451
      if(refineQuery!= null && refineQuery != ''  ) {
452
        url += refineQuery;
453
      }
454

  
455
        return this.numOfDataproviders(url, properties);
456
    }
457
/*
458
    private quote(word: any): string {
459
        return '"'+word+'"';
460
    }
461
*/
462
getDataprovidersTableResults (queryType:string, properties:EnvProperties):any {
463
  let size: number = 0;
464
  let url: string= properties.searchAPIURLLAst;
465
  if(queryType == "compatible"){
466
      url += '?query=((oaftype exact datasource) not (datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other) not(datasourcetypeuiid exact "pubsrepository::journal") not(datasourcetypeuiid exact "aggregator::pubsrepository::journals"))';
467
  }else if(queryType=="registries"){
468
    url += "?query=((oaftype exact datasource) and(datasourcetypeuiid = other))";
469
  }else if(queryType=="journals"){
470
    url += '?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) and (datasourcetypeuiid exact "pubsrepository::journal" or datasourcetypeuiid exact "aggregator::pubsrepository::journals" ))';
471

  
472
  }
473

  
474
  url += "&page=0&size=0&format=json";
475

  
476

  
477

  
478
  return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
479
                  //.map(res => <any> res.json())
480
                  .pipe(map(res => res['meta'].total));
481
}
482
}
modules/uoa-services-library/branches/elixir/ng-openaire-library/src/app/services/organizationsService.module.ts
1
import { NgModule}            from '@angular/core';
2
import { CommonModule }        from '@angular/common';
3
import { FormsModule }         from '@angular/forms';
4

  
5
import {SearchOrganizationsService} from './searchOrganizations.service';
6

  
7

  
8
@NgModule({
9
  imports: [
10
    CommonModule, FormsModule
11
  ],
12
  declarations: [
13
  ],
14
  providers:[
15
  SearchOrganizationsService
16
],
17
  exports: [
18
    ]
19
})
20
export class OrganizationsServiceModule { }
modules/uoa-services-library/branches/elixir/ng-openaire-library/src/app/services/reports.service.ts
1
import {Injectable} from '@angular/core';
2
import {Http, Response, Headers} from '@angular/http';
3
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
4
import {Observable, throwError} from 'rxjs';
5

  
6

  
7

  
8
import {map, tap} from "rxjs/operators";
9

  
10
@Injectable()
11
export class ReportsService {
12
    // url:string = "http://beta.services.openaire.eu:8480/search/rest/v2/api/publications?format=csv&page=0&size=3&q=(%22test%22)&fq=instancetypename%20exact%20%22Dataset%22";
13
    constructor(private http: HttpClient) {}
14

  
15
    //On the service:
16
   downloadCSVFile(url: string){
17
     //var headers = new Headers();
18
     //headers.append('responseType', 'arraybuffer');
19
     return this.http.get(url, {responseType: 'text'})
20
                .pipe(map(res => new Blob([res], { type: 'text/csv' })));
21
   }
22
   getCSVResponse(url: string){
23
     //var headers = new Headers();
24
     //headers.append('responseType', 'arraybuffer');
25
     return this.http.get(url, {responseType: 'text'});
26
                //.pipe(map(res => res));
27
   }
28

  
29
  /**
30
   * @deprecated not used
31
   */
32
   downloadHTMLFile(url: string, info: string){
33
     //var headers = new Headers();
34
     //headers.append('responseType', 'arraybuffer');
35
     return this.http.get(url)
36
                .pipe(map(res => this.addInfo(res, info)))
37
                .pipe(map(res => new Blob([res['_body']], { type: 'text/html' })))
38
                .pipe(tap(res => console.log(res)))
39
   }
40

  
41
  /**
42
   * @deprecated not used
43
   */
44
   addInfo(res:any, info:string) {
45
       /*
46
       var para = res.document.createElement("P");                       // Create a <p> element
47
       var t = res.document.createTextNode("This is a paragraph");       // Create a text node
48
       para.appendChild(t);                                          // Append the text to <p>
49
       res.document.body.appendChild(para);
50
       */
51
       res['_body'] = info+res['_body'];
52
       return res;
53
   }
54

  
55
    private handleError (error: HttpErrorResponse) {
56
    // in a real world app, we may send the error to some remote logging infrastructure
57
    // instead of just logging it to the console
58
        console.log(error);
59
        return throwError(error  || 'Server error');
60
    }
61

  
62

  
63
}
modules/uoa-services-library/branches/elixir/ng-openaire-library/src/app/services/refineFieldResults.service.ts
1
import {Injectable} from '@angular/core';
2
import {Http, Response} from '@angular/http';
3
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
4
import {Observable, throwError} from 'rxjs';
5
import {AutoCompleteValue} from '../searchPages/searchUtils/searchHelperClasses.class';
6

  
7

  
8

  
9
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
10
import{EnvProperties} from '../utils/properties/env-properties';
11
import {map} from "rxjs/operators";
12

  
13
@Injectable()
14
export class RefineFieldResultsService {
15
     constructor(private http: HttpClient ) {}
16
     getRefineFieldsResultsByEntityName(fields:string[], entityName:string, properties:EnvProperties, communityQuery=null):any{
17
        let url = properties.searchAPIURLLAst + this.getSearchAPIURLForEntity(entityName)+"?format=json&refine=true&page=1&size=0";
18
        for(var i=0; i < fields.length; i++){
19
            url += "&fields="+fields[i];
20
        }
21
        if(communityQuery!= null && communityQuery != ''  ) {
22
            url += communityQuery;
23
        }
24
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
25
                    //.map(res => <any> res.json())
26

  
27
                    .pipe(map(res =>   [res['meta'].total, RefineResultsUtils.parse(res['refineResults'],fields, entityName)]));
28

  
29
     }
30
    getRefineFieldResultsByFieldName(fieldName:string, entityName:string, properties:EnvProperties):any{
31
       let key:string="fundinglevel";
32
       let link = properties.searchAPIURLLAst +this.getSearchAPIURLForEntity(entityName)+"?fields="+fieldName +(fieldName.toString().indexOf(key)!=-1?('&sf='+fieldName):'')+ "&format=json";
33
        return  this.getField(link,fieldName, properties);
34

  
35
    }
36

  
37
    getField (link:string,fieldName:string, properties:EnvProperties):any{
38
      let url = link+"&refine=true&page=1&size=0";
39

  
40
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
41
                  //.map(res => <any> res.json())
42
                  .pipe(map(res => res['refineResults']))
43
                  .pipe(map(res =>  this.parse(res,fieldName)));
44

  
45
    }
46
    parse(data: any,fieldName:string):any {
47
      var values:AutoCompleteValue[] = [];
48
      if(data){
49
          let field = data[fieldName];
50
          for(let i=0; i<field.length; i++) {
51
            var value:AutoCompleteValue = new AutoCompleteValue();
52
            value.label = field[i].name;
53
            value.label = RefineResultsUtils.inParenthesisThePartAfterCharacters(field[i],"||");
54
            value.id = field[i].id;
55
            values.push(value);
56

  
57
        }
58
    }
59

  
60
    return values;
61
    }
62
    getSearchAPIURLForEntity(entityType:string):string{
63
      var suffix = "";
64
      if(entityType == "project"){
65
        suffix="projects/";
66
      }else if(entityType == "publication"){
67
        suffix="publications/";
68
      }else if(entityType == "dataset"){
69
        suffix="datasets/";
70
      } else if(entityType == "software"){
71
        suffix="software/";
72
      } else if(entityType == "other"){
73
        suffix="other/";
74
      }else if(entityType == "organization"){
75
        suffix="organizations/";
76
      }else if(entityType == "dataprovider"){
77
        suffix="datasources/";
78
      }else if(entityType == "person"){
79
        suffix="people/";
80
      }
81
      return  suffix;
82
    }
83
    private handleError (error: HttpErrorResponse) {
84
      // in a real world app, we may send the error to some remote logging infrastructure
85
      // instead of just logging it to the console
86
      console.log(error);
87
      return throwError(error  || 'Server error');
88
    }
89
}
modules/uoa-services-library/branches/elixir/ng-openaire-library/src/app/services/projectsService.module.ts
1
import { NgModule}            from '@angular/core';
2
import { CommonModule }        from '@angular/common';
3
import { FormsModule }         from '@angular/forms';
4

  
5
import {SearchProjectsService} from './searchProjects.service';
6

  
7

  
8
@NgModule({
9
  imports: [
10
    CommonModule, FormsModule
11
  ],
12
  declarations: [
13
  ],
14
  providers:[
15
  SearchProjectsService
16
],
17
  exports: [
18
    ]
19
})
20
export class ProjectsServiceModule { }
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff