Add mining icon. Add method to get Affiliations in affiliations service. Remove cancel emit from ok button in full modal

This commit is contained in:
Konstantinos Triantafyllou 2022-07-04 21:38:27 +03:00
parent be48608545
commit 721a8c6a09
8 changed files with 72 additions and 48 deletions

View File

@ -3,25 +3,29 @@ import {HttpClient, HttpHeaders} from '@angular/common/http';
import {BehaviorSubject, Observable, Subscriber} from 'rxjs';
import {Affiliation} from '../../utils/entities/CuratorInfo';
import {properties} from "../../../../environments/environment";
import {AdvancedAsyncSubject} from "../../utils/AdvancedAsyncSubject";
@Injectable()
export class AffiliationService {
private affiliationsSubject: BehaviorSubject<Affiliation[]> = new BehaviorSubject([]);
sub;
constructor(private http: HttpClient) {
}
ngOnDestroy() {
this.clearSubscriptions();
}
clearSubscriptions(){
clearSubscriptions() {
if (this.sub instanceof Subscriber) {
this.sub.unsubscribe();
}
}
public initAffiliations(communityId: string): void {
let url = properties.communityAPI + communityId + "/organizations";
this.sub = this.http.get<Affiliation[]>((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url).subscribe((affiliations) => {
this.sub = this.getAffiliations(communityId).subscribe((affiliations) => {
this.affiliationsSubject.next(affiliations);
},
error => {
@ -33,6 +37,11 @@ export class AffiliationService {
return this.affiliationsSubject.asObservable();
}
public getAffiliations(communityId: string): Observable<Affiliation[]> {
let url = properties.communityAPI + communityId + "/organizations";
return this.http.get<Affiliation[]>((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url);
}
public updateAffiliation(url: string, affiliation: Affiliation) {
let headers = new HttpHeaders({'Content-Type': 'application/json', 'accept': 'application/json'});
return this.http.post<Affiliation>(url, JSON.stringify(affiliation), {headers: headers});

View File

@ -70,14 +70,14 @@ declare var UIkit;
<ng-template [ngIf]="type === 'select'">
<ng-container *ngIf="placeholderInfo?.static">
<div *ngIf="!getLabel(formControl.value)"
class="placeholder uk-text-truncate">{{placeholderInfo.label}}</div>
class="input uk-width-expand uk-text-truncate">{{placeholderInfo.label}}</div>
<div *ngIf="getLabel(formControl.value)"
class="input uk-text-truncate">{{getLabel(formControl.value)}}</div>
class="input uk-width-expand uk-text-truncate">{{getLabel(formControl.value)}}</div>
</ng-container>
<ng-container *ngIf="!placeholderInfo?.static">
<div *ngIf="!getLabel(formControl.value)" class="input uk-text-truncate">{{noValueSelected}}</div>
<div *ngIf="!getLabel(formControl.value)" class="input uk-width-expand uk-text-truncate">{{noValueSelected}}</div>
<div *ngIf="getLabel(formControl.value)"
class="input uk-text-truncate">{{getLabel(formControl.value)}}</div>
class="input uk-width-expand uk-text-truncate">{{getLabel(formControl.value)}}</div>
</ng-container>
</ng-template>
<ng-template [ngIf]="type === 'autocomplete'">

View File

@ -35,8 +35,24 @@ import {Component} from "@angular/core";
<div class="uk-text-bold uk-margin-small-top">graph</div>
</div>
<div class="uk-text-center">
<icon name="filters"></icon>
<div class="uk-text-bold uk-margin-small-top">filters</div>
<icon name="orcid_add"></icon>
<div class="uk-text-bold uk-margin-small-top">orcid_add</div>
</div>
<div class="uk-text-center">
<icon name="orcid_bin"></icon>
<div class="uk-text-bold uk-margin-small-top">orcid_bin</div>
</div>
<div class="uk-text-center">
<icon name="link"></icon>
<div class="uk-text-bold uk-margin-small-top">link</div>
</div>
<div class="uk-text-center">
<icon name="quotes"></icon>
<div class="uk-text-bold uk-margin-small-top">quotes</div>
</div>
<div class="uk-text-center">
<icon name="mining"></icon>
<div class="uk-text-bold uk-margin-small-top">mining</div>
</div>
</div>
<div class="uk-margin-medium-top">

View File

@ -4,7 +4,19 @@ import {RouterModule} from "@angular/router";
import {IconsPreviewComponent} from "./icons-preview.component";
import {IconsService} from "../icons.service";
import {IconsModule} from "../icons.module";
import {book, cog, database, earth, filters, graph, incognito, restricted} from "../icons";
import {
book,
cog,
database,
earth,
filters,
graph,
incognito, link, mining,
orcid_add,
orcid_bin,
quotes,
restricted
} from "../icons";
@NgModule({
imports: [CommonModule, RouterModule.forChild([
@ -15,6 +27,6 @@ import {book, cog, database, earth, filters, graph, incognito, restricted} from
})
export class IconsPreviewModule {
constructor(private iconsService: IconsService) {
this.iconsService.registerIcons([book, database, cog, earth, incognito, restricted, graph, filters])
this.iconsService.registerIcons([book, database, cog, earth, incognito, restricted, graph, filters, orcid_add, orcid_bin, link, quotes, mining])
}
}

View File

@ -16,7 +16,7 @@ export interface StopRule {
}
/**
* By default this component uses Material Icons Library to render an icon with
* By default, this component uses Material Icons Library to render an icon with
* a specific @name. For custom icons you should:
*
* - Add your icon in icons.ts and register it to Icon registry, by adding this to your component Module.
@ -47,8 +47,8 @@ export interface StopRule {
selector: 'icon',
template: `
<span #icon *ngIf="svg" class="uk-icon" [class.uk-preserve]="gradient" [class.uk-flex]="flex" [ngClass]="customClass" [ngStyle]="style" [innerHTML]="svg | safeHtml"></span>
<span [class.uk-flex]="flex" [ngClass]="customClass" [class.uk-display-inline-block]="!flex">
<span *ngIf="!svg && iconName" class="material-icons" [ngClass]="type" [ngStyle]="style">{{iconName}}</span>
<span *ngIf="!svg && iconName" [class.uk-flex]="flex" [ngClass]="customClass" [class.uk-display-inline-block]="!flex">
<span class="material-icons" [ngClass]="type" [ngStyle]="style">{{iconName}}</span>
</span>
<span *ngIf="visuallyHidden" class="visually-hidden">{{visuallyHidden}}</span>
`

View File

@ -213,9 +213,14 @@ export const link = {
data: '<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" data-svg="link"><path fill="none" stroke="#000" stroke-width="1.1" d="M10.625,12.375 L7.525,15.475 C6.825,16.175 5.925,16.175 5.225,15.475 L4.525,14.775 C3.825,14.074 3.825,13.175 4.525,12.475 L7.625,9.375"></path><path fill="none" stroke="#000" stroke-width="1.1" d="M9.325,7.375 L12.425,4.275 C13.125,3.575 14.025,3.575 14.724,4.275 L15.425,4.975 C16.125,5.675 16.125,6.575 15.425,7.275 L12.325,10.375"></path><path fill="none" stroke="#000" stroke-width="1.1" d="M7.925,11.875 L11.925,7.975"></path></svg>'
}
/** Add new icon under this line to be sure that it will be added on preview */
export const quotes = {
name: 'quotes',
data: '<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" data-svg="quote-right"><path d="M17.27,7.79 C17.27,9.45 16.97,10.43 15.99,12.02 C14.98,13.64 13,15.23 11.56,15.97 L11.1,15.08 C12.34,14.2 13.14,13.51 14.02,11.82 C14.27,11.34 14.41,10.92 14.49,10.54 C14.3,10.58 14.09,10.6 13.88,10.6 C12.06,10.6 10.59,9.12 10.59,7.3 C10.59,5.48 12.06,4 13.88,4 C15.39,4 16.67,5.02 17.05,6.42 C17.19,6.82 17.27,7.27 17.27,7.79 L17.27,7.79 Z"></path><path d="M8.68,7.79 C8.68,9.45 8.38,10.43 7.4,12.02 C6.39,13.64 4.41,15.23 2.97,15.97 L2.51,15.08 C3.75,14.2 4.55,13.51 5.43,11.82 C5.68,11.34 5.82,10.92 5.9,10.54 C5.71,10.58 5.5,10.6 5.29,10.6 C3.47,10.6 2,9.12 2,7.3 C2,5.48 3.47,4 5.29,4 C6.8,4 8.08,5.02 8.46,6.42 C8.6,6.82 8.68,7.27 8.68,7.79 L8.68,7.79 Z"></path></svg>'
}
export const mining = {
name: 'mining',
data: '<svg width="20" height="20" viewBox="0 0 600 500" xmlns="http://www.w3.org/2000/svg"><g><path d="m449.68 334.84-90.93-52.5c-5.4258-3.1133-12.074-3.1133-17.5 0l-90.93 52.5c-5.4258 3.1328-8.75 8.9062-8.75 15.156v105c0 6.2461 3.3242 12.039 8.75 15.156l90.93 52.5c2.7109 1.5547 5.7227 2.3438 8.75 2.3438s6.0391-0.78906 8.75-2.3438l90.93-52.5c5.4258-3.1328 8.75-8.9062 8.75-15.156v-105c0-6.2461-3.3242-12.023-8.75-15.156zm-99.68 120.16c-28.945 0-52.5-23.555-52.5-52.5s23.555-52.5 52.5-52.5 52.5 23.555 52.5 52.5-23.555 52.5-52.5 52.5z"/><path d="m545.93 35h-391.86c-27.055 0-49.07 22.016-49.07 49.07v20.93h490v-20.93c0-27.055-22.016-49.07-49.07-49.07z"/><path d="m105 370.93c0 27.055 22.016 49.07 49.07 49.07h70v-70c0-12.477 6.7031-24.078 17.5-30.309l90.93-52.5c5.3359-3.0625 11.375-4.6914 17.5-4.6914s12.164 1.6289 17.465 4.6719l90.965 52.516c10.797 6.2305 17.5 17.852 17.5 30.309v70h70c27.055 0.003906 49.07-22.012 49.07-49.066v-230.93h-490zm57.629-138.3 52.5-52.5c6.8438-6.8438 17.902-6.8438 24.746 0l42.84 42.84 75.793-45.484c6.8945-4.1289 15.715-3.0469 21.387 2.625l58.922 58.922 75.266-60.219c7.543-6.0391 18.551-4.8125 24.586 2.7305 6.0391 7.543 4.8125 18.566-2.7305 24.605l-87.5 70c-3.2188 2.5898-7.0859 3.8516-10.938 3.8516-4.4961 0-8.9961-1.7344-12.391-5.1289l-60.34-60.34-75.793 45.484c-6.8789 4.1289-15.68 3.0625-21.387-2.625l-40.09-40.145-40.129 40.129c-6.8438 6.8438-17.902 6.8438-24.746 0-6.8398-6.8438-6.8398-17.906 0.003906-24.746z"/></g></svg>'
}
/** Add new icon under this line to be sure that it will be added on preview */

View File

@ -120,7 +120,8 @@ export class FullScreenModalComponent implements AfterViewInit, OnDestroy {
}
ok() {
this.cancel();
UIkit.modal(this.modal.nativeElement).hide();
HelperFunctions.scroll();
this.okEmitter.emit(true);
}
}

View File

@ -1,5 +1,4 @@
import {Component, Input, Output, EventEmitter} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import{EnvProperties} from './properties/env-properties';
import {properties} from "../../../environments/environment";
@ -32,39 +31,21 @@ import {properties} from "../../../environments/environment";
export class pagingFormatterNoLoad {
@Input() public currentPage: number = 1;
@Input() public customClasses: string = 'uk-flex-center';
// @Input() public navigateTo: string;
@Input() public term: string='';
@Input() public size: number=10;
@Input() public totalResults: number = 10;
@Input() public limitPaging: boolean = false;
// @Input() public params;
@Output() pageChange = new EventEmitter();
private limit: number;
properties:EnvProperties;
public properties:EnvProperties = properties;
private limit: number = this.properties.pagingLimit;
@Input()
public loading:boolean = false;
constructor (private route: ActivatedRoute) {
}
ngOnInit() {
//console.info("In paging -- CurrentPage:"+this.currentPage+" "+"total Pages = "+this.getTotalPages() +" Results num:"+this.totalResults);
this.properties = properties;
this.limit = this.properties.pagingLimit;
}
getTotalPages(){
let total: number = 0;
//let limit: number = 20;//OpenaireProperties.getPagingLimit();
var i= this.totalResults/this.size;
var integerI=parseInt(''+i);
let i= this.totalResults/this.size;
let integerI=parseInt(''+i);
total = parseInt(''+((i==integerI)?i:i+1));
if(this.limitPaging) {
if((this.currentPage == this.limit) && (total > this.limit)) {
total = this.limit;
@ -74,21 +55,21 @@ export class pagingFormatterNoLoad {
}
return total;
}
onPrev(){
this.currentPage=this.currentPage-1;
this.pageChange.emit({
value: this.currentPage
});
value: this.currentPage
});
}
onNext(){
this.currentPage=this.currentPage+1;
this.pageChange.emit({
value: this.currentPage
});
value: this.currentPage
});
}
onPage(pageNum: number){
if(!this.loading) {
this.currentPage = pageNum;