Project

General

Profile

« Previous | Next » 

Revision 59464

[use-UoaAdminToolsLibrary | Library]: Merge trunk into branch.

View differences:

modules/uoa-services-library/branches/use-UoaAdminToolsLibrary/ng-openaire-library/src/app/connect/connectHelper.ts
4 4
export class ConnectHelper {
5 5

  
6 6
  public static  getCommunityFromDomain(domain: string): string{
7
    // domain = "https://mes.openaire.eu"; //for testing
7
    domain = "beta.ee.openaire.eu"; //for testing
8 8
    domain = domain.indexOf("//") != -1? domain.split("//")[1]:domain; //remove https:// prefix
9 9
    if (domain.indexOf('openaire.eu') === -1) {
10 10
      return null;
modules/uoa-services-library/branches/use-UoaAdminToolsLibrary/ng-openaire-library/src/app/reload/reload.component.ts
4 4
import {HelperFunctions} from "../utils/HelperFunctions.class";
5 5

  
6 6
@Component({
7
    selector: 'reload',
8
    template: `
9
    <div id="tm-main" class=" uk-section  uk-margin-small-top tm-middle"   >
7
  selector: 'reload',
8
  template: `
9
    <div id="tm-main" class=" uk-section  uk-margin-small-top tm-middle">
10 10
      <div uk-grid uk-grid>
11
       <div class="tm-main uk-width-1-1@s uk-width-1-1@m  uk-width-1-1@l uk-row-first ">
11
        <div class="tm-main uk-width-1-1@s uk-width-1-1@m  uk-width-1-1@l uk-row-first ">
12 12
          <div class="uk-container uk-margin-top publication">
13 13
            Go to initial page....
14 14
          </div>
15 15
        </div>
16 16
      </div>
17 17
    </div>
18
     `
18
  `
19 19
})
20 20
export class ReloadComponent {
21

  
22
  constructor (private route: ActivatedRoute, private _router: Router) {}
23

  
21
  
22
  constructor(private route: ActivatedRoute, private _router: Router) {
23
  }
24
  
24 25
  public ngOnInit() {
25
      HelperFunctions.scroll();
26

  
27
      var URL = Session.getReloadUrl();
28

  
29
        if(URL && URL["path"] && URL["path"] != null && URL["path"] != ""){
30
          var url = URL["path"];
31
          var host = URL["host"];
32
          var paramsObject = ((URL["params"] && URL["params"] != null)? Session.getParamsObj(URL["params"]):null);
33
          if(host == (location.protocol+"//"+location.host)){
34
            let baseUrl = (document && document.getElementsByTagName('base'))?document.getElementsByTagName('base')[0].href.split(document.location.host)[1]:"/";
35
            url = (baseUrl.length>1 && url.indexOf(baseUrl)!=-1 )?("/"+url.split(baseUrl)[1]):url;
36
            if(paramsObject &&  paramsObject != null){
37
              Session.setReloadUrl("","","")
38
              this._router.navigate([url],{ queryParams: paramsObject});
39
            }else{
40
              Session.setReloadUrl("","","")
41
              this._router.navigate([url]);
42
            }
43
          }else{
44
            Session.setReloadUrl("","","")
45
            window.location.href = host+url+((URL["params"] && URL["params"] !=null)?((URL["params"].indexOf("?")==-1?"?":"")+URL["params"]):"");
46
          }
47

  
48
        }else{
49
          Session.setReloadUrl("","","")
50
          this._router.navigate(['/']);
51

  
26
    HelperFunctions.scroll();
27
    var URL = Session.getReloadUrl();
28
    if (URL && URL["path"] && URL["path"] != null && URL["path"] != "") {
29
      var url = URL["path"];
30
      var host = URL["host"];
31
      var paramsObject = ((URL["params"] && URL["params"] != null) ? Session.getParamsObj(URL["params"]) : null);
32
      if (host == (location.protocol + "//" + location.host)) {
33
        let baseUrl = (document && document.getElementsByTagName('base')) ? document.getElementsByTagName('base')[0].href.split(document.location.host)[1] : "/";
34
        url = (baseUrl.length > 1 && url.indexOf(baseUrl) != -1) ? ("/" + url.split(baseUrl)[1]) : url;
35
        if (paramsObject) {
36
          Session.setReloadUrl("", "", "")
37
          this._router.navigate([url], {queryParams: paramsObject});
38
        } else {
39
          Session.setReloadUrl("", "", "")
40
          this._router.navigate([url]);
52 41
        }
42
      } else {
43
        Session.setReloadUrl("", "", "")
44
        window.location.href = host + url + ((URL["params"] && URL["params"] != null) ? ((URL["params"].indexOf("?") == -1 ? "?" : "") + URL["params"]) : "");
45
      }
46
      
47
    } else {
48
      Session.setReloadUrl("", "", "")
49
      this._router.navigate(['/']);
50
      
51
    }
53 52
  }
54

  
53
  
55 54
}
modules/uoa-services-library/branches/use-UoaAdminToolsLibrary/ng-openaire-library/src/app/login/utils/helper.class.ts
13 13
export class Session{
14 14
  public static removeUser() {
15 15
    COOKIE.deleteCookie(COOKIE.cookieName_id);
16
    COOKIE.deleteCookie("openAIRESession");
16
    //COOKIE.deleteCookie("openAIRESession");
17 17
    COOKIE.deleteCookie("openAIREUser");
18 18
  }
19 19

  
modules/uoa-services-library/branches/use-UoaAdminToolsLibrary/ng-openaire-library/src/app/login/userMini.component.ts
1 1
import {Component, ElementRef, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core';
2
import {ActivatedRoute, Router} from '@angular/router';
2
import {ActivatedRoute, NavigationStart, Router} from '@angular/router';
3 3
import {Location} from '@angular/common';
4 4
import {User, Session} from './utils/helper.class';
5 5
import {RouterHelper} from '../utils/routerHelper.class';
......
176 176
  @Input() logInUrl;
177 177
  @Input() logOutUrl;
178 178
  @Input() cookieDomain;
179
  @Input() fixRedirectUrl: string;
179 180
  @Input() redirectUrl: string;
180 181
  @Input() dark: boolean = false;
181 182
  search: string = '';
182 183
  sub: any;
183 184
  
184
  constructor(private router: Router, private  route: ActivatedRoute, private location: Location) {
185
  constructor(private router: Router, private  route: ActivatedRoute) {
186
    this.router.events.forEach(event => {
187
      if(event instanceof NavigationStart) {
188
        this.initialize(event.url);
189
      }
190
    });
185 191
  }
186 192
  
187 193
  ngOnInit() {
188
    
189 194
    if (typeof document !== 'undefined') {
190 195
      this.server = false;
191 196
    }
192
    this.initialize();
193 197
    this.sub = this.route.queryParams.subscribe(params => {
194 198
      this.initialize();
195 199
    });
196
    
197
    
198 200
  }
199 201
  
200 202
  ngOnChanges(changes: SimpleChanges): void {
......
209 211
    }
210 212
  }
211 213
  
212
  initialize() {
213
    if (!this.redirectUrl && typeof location !== 'undefined') {
214
      this.redirectUrl = location.pathname;
215
      this.search = location.search;
214
  initialize(url: string = null) {
215
    if (typeof location !== 'undefined') {
216
      if(url) {
217
        let parts = StringUtils.split(url, ['?']);
218
        this.redirectUrl = properties.baseLink + parts[0];
219
        if(parts.length == 2) {
220
          this.search = parts[1];
221
        } else {
222
          this.search = null;
223
        }
224
      } else {
225
        this.redirectUrl = location.pathname;
226
        this.search = location.search;
227
      }
216 228
    }
217 229
    if (this.user) {
218 230
      this.loggedIn = true;
......
230 242
  logOut() {
231 243
    if (this.user) {
232 244
      Session.removeUser();
233
      window.location.href = this.logOutUrl + StringUtils.URIEncode(location.href);
234
      
245
      // New method
246
      if(properties.logoutUrl.includes('openid_logout')) {
247
        Session.setReloadUrl(location.protocol + "//" + location.host, this.redirectUrl, this.search);
248
        window.location.href = this.logOutUrl;
249
      } else {
250
        window.location.href = this.logOutUrl + StringUtils.URIEncode(location.href);
251
      }
235 252
    }
236 253
    this.loggedIn = false;
237 254
    this.isAuthorized = false;
......
239 256
  }
240 257
  
241 258
  logIn() {
242
    Session.setReloadUrl(location.protocol + "//" + location.host, this.redirectUrl, this.search);
259
    Session.setReloadUrl(location.protocol + "//" + location.host,
260
      this.fixRedirectUrl?(properties.baseLink + this.fixRedirectUrl):this.redirectUrl, this.search);
243 261
    window.location.href = this.logInUrl;
244 262
  }
245 263
  
modules/uoa-services-library/branches/use-UoaAdminToolsLibrary/ng-openaire-library/src/app/sharedComponents/navigationBar.component.html
116 116
                </ng-container>
117 117
                <ng-container *ngIf="userMenu">
118 118
                  <user-mini [user]="user" mobileView=true
119
                             [redirectUrl]="(communityId && communityId !== 'connect')?null:properties.afterLoginRedirectLink"
119
                             [fixRedirectUrl]="(communityId && communityId !== 'connect')?null:properties.afterLoginRedirectLink"
120 120
                             [userMenuItems]=userMenuItems [logInUrl]=properties.loginUrl
121 121
                             [logOutUrl]=properties.logoutUrl [cookieDomain]=properties.cookieDomain></user-mini>
122 122
                </ng-container>
......
299 299
            <!-- <div  *ngIf="userMenu" class="uk-navbar-right"> -->
300 300
            <!-- <div  *ngIf="userMenu" class="uk-navbar-right"> -->
301 301
            <user-mini *ngIf="userMenu" [user]="user" [dark]="dark"
302
                       [redirectUrl]="(communityId && communityId !== 'connect')?null:properties.afterLoginRedirectLink"
302
                       [fixRedirectUrl]="(communityId && communityId !== 'connect')?null:properties.afterLoginRedirectLink"
303 303
                       [userMenuItems]=userMenuItems [logInUrl]=properties.loginUrl [logOutUrl]=properties.logoutUrl
304 304
                       [cookieDomain]=properties.cookieDomain></user-mini>
305 305

  

Also available in: Unified diff