Skip to content

Commit

Permalink
Merge pull request #201 from geneontology/sprint-1
Browse files Browse the repository at this point in the history
Sprint 1
  • Loading branch information
tmushayahama authored Jul 21, 2022
2 parents a8dd62f + 152892b commit 438362e
Show file tree
Hide file tree
Showing 52 changed files with 532 additions and 204 deletions.
25 changes: 25 additions & 0 deletions src/@noctua.announcement/@noctua.announcement.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { AnnouncementPanelComponent } from './components/announcement-panel/announcement-panel.component';
import { MatIconModule } from '@angular/material/icon';
import { MatButtonModule } from '@angular/material/button';
import { MatSidenavModule } from '@angular/material/sidenav';
import { FlexLayoutModule } from '@angular/flex-layout';
import { NoctuaSharedModule } from '@noctua/shared.module';

@NgModule({
imports: [
CommonModule,
MatIconModule,
MatButtonModule,
MatSidenavModule,
FlexLayoutModule,
NoctuaSharedModule
],
exports: [
AnnouncementPanelComponent
],
declarations: [
AnnouncementPanelComponent],
})
export class NoctuaAnnouncementModule { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<form fxLayout="column" fxLayoutAlign="start stretch" class="noc-cam-form noc-drawer h-100-p">
<div class="noc-drawer-header" fxLayout="row" fxLayoutAlign="start center">
<span class="noc-drawer-header-title">
Announcements</span>
<span fxFlex></span>
<button mat-stroked-button (click)="close()" class="noc-rounded-button noc-sm" color="primary"
aria-label="Close dialog">
<mat-icon>close</mat-icon> Close
</button>
</div>
<div class="noc-drawer-body w-100-p p-8" noctuaPerfectScrollbar>
<div *ngFor="let announcement of announcements" class="alert alert-{{announcement.level}} w-100-p my-8">
<strong>{{announcement.title}}</strong><br>
{{announcement.description}}
<a *ngIf="announcement.descriptionUrl" href="{{announcement.descriptionUrl}}" target="_banl">
More Details
</a>
</div>
</div>
</form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
@use "@angular/material" as mat;
@import "src/@noctua/scss/noctua";
@import "src/@noctua.common/scss/noctua.common";

:host {
//width: 100%; // display: block;

background-color: white;
@include mat.elevation(4);

.noc-cam-form {
@include deep-width(500px);
}

.noc-header {
@include deep-height(40px);
background-color: #eee;
border-bottom: #ccc solid 1px;

mat-icon-button {
@include deep-height(40px);
@include deep-width(40px);
line-height: 40px;
}

.noc-title {
font-size: 10px;
padding: 0 14px;
}
}

.noc-body {
padding: 0 14px 14px 14px;
}

.noc-item {
@include deep-width(100%);
font-size: 12px;

.noc-title {
font-weight: bold;
margin-right: 8px;
color: #999;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Component, Input, OnInit, OnDestroy } from '@angular/core';
import { MatDrawer, MatSidenav } from '@angular/material/sidenav';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import {
NoctuaFormMenuService
} from '@geneontology/noctua-form-base';
import { NoctuaSearchMenuService } from '@noctua.search/services/search-menu.service';
import { NoctuaAnnouncementService } from '@noctua.announcement/services/cam.service';
import { Announcement } from '@noctua.announcement/models/announcement';


@Component({
selector: 'noc-announcement-panel',
templateUrl: './announcement-panel.component.html',
styleUrls: ['./announcement-panel.component.scss'],
})

export class AnnouncementPanelComponent implements OnInit, OnDestroy {

@Input('sidenav') sidenav: MatSidenav;
announcements: Announcement[];

private _unsubscribeAll: Subject<any>;

constructor(
public noctuaSearchMenuService: NoctuaSearchMenuService,
public noctuaFormMenuService: NoctuaFormMenuService,
private noctuaAnnouncementService: NoctuaAnnouncementService,
) {
this._unsubscribeAll = new Subject();
}

ngOnInit(): void {
this.noctuaAnnouncementService.onAnnouncementsChanged.pipe(
takeUntil(this._unsubscribeAll))
.subscribe((announcements: Announcement[]) => {
if (announcements) {
this.announcements = announcements
}
});
}

ngOnDestroy(): void {
this._unsubscribeAll.next(null);
this._unsubscribeAll.complete();
}

close() {
this.sidenav.close();
}


}
8 changes: 8 additions & 0 deletions src/@noctua.announcement/models/announcement.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export class Announcement {
type: string;
date: string;
level: string;
title: string;
content: string;
moreContentUrl?: string;
}
33 changes: 33 additions & 0 deletions src/@noctua.announcement/services/cam.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { HttpClient } from "@angular/common/http";
import { Injectable } from "@angular/core";
import { Announcement } from "@noctua.announcement/models/announcement";
import { environment } from "environments/environment";
import { BehaviorSubject } from "rxjs";

@Injectable({
providedIn: 'root'
})
export class NoctuaAnnouncementService {
cursor = 0;
onAnnouncementsChanged: BehaviorSubject<any>;
onAnnouncementChanged: BehaviorSubject<any>;

constructor(
private httpClient: HttpClient) {

this.onAnnouncementsChanged = new BehaviorSubject(null);
this.onAnnouncementChanged = new BehaviorSubject(null);

}

getAnnouncement() {
return this.httpClient.get(environment.announcementUrl).subscribe((response: Announcement[]) => {
if (response) {
if (response.length > 0) {
this.onAnnouncementChanged.next(response[this.cursor]);
}
this.onAnnouncementsChanged.next(response);
}
});
}
}
2 changes: 2 additions & 0 deletions src/@noctua.common/models/menu-panels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export enum LeftPanel {
activityForm = 'activityForm',
camForm = 'camForm',
copyModel = 'copyModel',
apps = 'apps',
announcement = 'announcement'
};

export enum MiddlePanel {
Expand Down
5 changes: 5 additions & 0 deletions src/@noctua.common/services/noctua-common-menu.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { WorkbenchId } from '@noctua.common/models/workench-id';
export class NoctuaCommonMenuService {

onCamSettingsChanged: BehaviorSubject<SettingsOptions>;
selectedLeftSidenav: LeftPanel = LeftPanel.apps;
selectedLeftPanel: LeftPanel;
selectedMiddlePanel: MiddlePanel;
selectedRightPanel: RightPanel;
Expand Down Expand Up @@ -64,6 +65,10 @@ export class NoctuaCommonMenuService {
return this._leftSidenav.open();
}

selectLeftSidenav(panel: LeftPanel) {
this.selectedLeftSidenav = panel;
}


selectLeftPanel(panel: LeftPanel) {
this.selectedLeftPanel = panel;
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Injectable } from '@angular/core';
import { MatDrawer } from '@angular/material/sidenav';
import { NoctuaPerfectScrollbarDirective } from '@noctua/directives/noctua-perfect-scrollbar/noctua-perfect-scrollbar.directive';
import { PerfectScrollbarDirective } from 'ngx-perfect-scrollbar';
import { LeftPanel, MiddlePanel, RightPanel } from './../models/menu-panels';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,15 @@ export class NoctuaEditorDropdownComponent implements OnInit, OnDestroy {
case EditorCategory.evidenceAll:
self.noctuaActivityEntityService.addEvidence().then(() => {
this.close();
self.noctuaFormDialogService.openInfoToast('Activity successfully updated.', 'OK');
self.noctuaFormDialogService.openInfoToast('Evidence successfully updated.', 'OK');
});
break;
default:
self.noctuaActivityEntityService.saveActivity().then(() => {
case EditorCategory.all:
self.noctuaActivityEntityService.addIndividual().then(() => {
this.close();
self.noctuaFormDialogService.openInfoToast('Activity successfully updated.', 'OK');
});
break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/@noctua.form/data/config/shape-definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export const canInsertEntity = {
label: 'Add Happens During (Biological Phase)',
id: ActivityNodeType.GoBiologicalPhase,
node: <ActivityNodeDisplay>{
category: [EntityDefinition.GoBiologicalPhase],
category: [EntityDefinition.GoBiologicalPhase, EntityDefinition.UberonStage],
type: ActivityNodeType.GoBiologicalPhase,
label: 'happens during (Biological Phase)',
displaySection: noctuaFormConfig.displaySection.fd,
Expand Down
11 changes: 11 additions & 0 deletions src/@noctua.form/models/activity/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,17 @@ export class Activity extends SaeGraph<ActivityNode> {
return saveData;
}

createAddIndividual(srcActivity: Activity, predicate: Predicate) {
const self = this;

const addTriples = self.getEdge(predicate.subjectId, predicate.objectId)

const saveData = {
addTriples: addTriples,
};

return saveData;
}

createDelete() {
const self = this;
Expand Down
9 changes: 9 additions & 0 deletions src/@noctua.form/models/contributor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ export class Contributor {
get groups() {
return this._groups;
}

static fromResponse(response) {
const user = new Contributor()
user.orcid = response.uri;
user.name = response.nickname;
user.groups = response.groups;

return user;
}
}

export function compareContributor(a: Contributor, b: Contributor): number {
Expand Down
14 changes: 14 additions & 0 deletions src/@noctua.form/services/activity-entity.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,20 @@ export class NoctuaActivityEntityService {
saveData.removeIds);
}

addIndividual() {
const self = this;

self.activityEntityFormToActivity();

const saveData = self.activity.createAddIndividual(self.currentActivity, self.entity.predicate);

return self.noctuaGraphService.editActivity(self.cam,
[self.entity],
[saveData.addTriples],
[],
[]);
}

saveSearchDatabase() {
const self = this;

Expand Down
1 change: 0 additions & 1 deletion src/@noctua.form/services/cam.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export class CamService {
private curieService: CurieService) {

this.onCamChanged = new BehaviorSubject(null);
this.curieUtil = this.curieService.getCurieUtil();
this.camFormGroup = new BehaviorSubject(null);
this.camFormGroup$ = this.camFormGroup.asObservable();

Expand Down
14 changes: 6 additions & 8 deletions src/@noctua.form/services/graph.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ import { Article } from './../models/article';
import { Contributor, equalContributor } from '../models/contributor';
import * as moment from 'moment';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { graph as bbopGraph } from 'bbop-graph-noctua';

declare const require: any;

const model = require('bbop-graph-noctua');
//const model = require('bbop-graph-noctua');
const barista_client = require('bbop-client-barista');
const amigo = require('amigo2');
const barista_response = require('bbop-response-barista');
Expand Down Expand Up @@ -158,10 +159,9 @@ export class NoctuaGraphService {

getMetadata(responseData) {
const self = this;
const noctua_graph = model.graph;
const cam = new Cam()

cam.graph = new noctua_graph();
cam.graph = new bbopGraph();
cam.graph.load_data_basic(responseData);

cam.id = responseData.id;
Expand Down Expand Up @@ -197,18 +197,17 @@ export class NoctuaGraphService {

rebuild(cam: Cam, response) {
const self = this;
const noctua_graph = model.graph;

// cam.loading.status = true;
// cam.loading.message = 'Loading Model Entities Metadata...';

if (cam.graph) {
const inGraph = new noctua_graph();
const inGraph = new bbopGraph();

inGraph.load_data_basic(response.data());
cam.graph.merge_special(inGraph);
} else {
cam.graph = new noctua_graph();
cam.graph = new bbopGraph();
cam.graph.load_data_basic(response.data());
}

Expand Down Expand Up @@ -265,9 +264,8 @@ export class NoctuaGraphService {

rebuildFromStoredApi(cam: Cam, activeModel) {
const self = this;
const noctua_graph = model.graph;

cam.graph = new noctua_graph();
cam.graph = new bbopGraph();
cam.graph.load_data_basic(activeModel);

cam.id = activeModel.id;
Expand Down
Loading

0 comments on commit 438362e

Please sign in to comment.