Skip to content

Commit

Permalink
in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
hplahar committed Dec 1, 2023
1 parent 2225a9c commit 5670a1d
Show file tree
Hide file tree
Showing 14 changed files with 551 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/main/ngapp/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
} from "./components/admin/admin-web-of-registries/admin-web-of-registries.component";
import {AdminSampleRequestsComponent} from "./components/admin/admin-sample-requests/admin-sample-requests.component";
import {AdminPublicGroupsComponent} from "./components/admin/admin-public-groups/admin-public-groups.component";
import {AdminCustomFieldsComponent} from "./components/admin/admin-custom-fields/admin-custom-fields.component";

const routes: Routes = [
{path: '', redirectTo: '/collection/personal', pathMatch: 'full'},
Expand Down Expand Up @@ -80,7 +81,8 @@ const routes: Routes = [
{path: 'users', component: AdminUsersComponent},
{path: 'web', component: AdminWebOfRegistriesComponent},
{path: 'samples', component: AdminSampleRequestsComponent},
{path: 'groups', component: AdminPublicGroupsComponent}
{path: 'groups', component: AdminPublicGroupsComponent},
{path: 'fields', component: AdminCustomFieldsComponent}
]
}, // todo resolver
{path: 'create/:type', component: CreateNewEntryComponent},
Expand Down
6 changes: 6 additions & 0 deletions src/main/ngapp/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ import {
} from './components/admin/admin-web-of-registries/admin-web-of-registries.component';
import {AdminSampleRequestsComponent} from './components/admin/admin-sample-requests/admin-sample-requests.component';
import {AdminPublicGroupsComponent} from './components/admin/admin-public-groups/admin-public-groups.component';
import {AdminCustomFieldsComponent} from './components/admin/admin-custom-fields/admin-custom-fields.component';
import {
EditCustomFieldModalComponent
} from './components/modal/edit-custom-field-modal/edit-custom-field-modal.component';

// register Handsontable's modules
registerAllModules();
Expand Down Expand Up @@ -102,6 +106,8 @@ registerAllModules();
AdminWebOfRegistriesComponent,
AdminSampleRequestsComponent,
AdminPublicGroupsComponent,
AdminCustomFieldsComponent,
EditCustomFieldModalComponent,
],
imports: [
BrowserModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<div class="container-fluid">
<div class="row">
<div class="col p-3">
<div ng-controller="AdminCustomFieldsController" style="height: 1050px">

<uib-tabset class="pad_top">
<uib-tab select="selectedTab('plasmid')">
<uib-tab-heading>Plasmid</uib-tab-heading>
</uib-tab>

<uib-tab select="selectedTab('strain')">
<uib-tab-heading>Strain</uib-tab-heading>
</uib-tab>

<uib-tab select="selectedTab('part')">
<uib-tab-heading>Part</uib-tab-heading>
</uib-tab>

<uib-tab select="selectedTab('seed')">
<uib-tab-heading>Seed</uib-tab-heading>
</uib-tab>

<uib-tab select="selectedTab('protein')">
<uib-tab-heading>Protein</uib-tab-heading>
</uib-tab>

</uib-tabset>

<br>
<button class="ice-button" ng-click="addNewCustomEntryField()">Create Custom Field</button>
<br><br>

<div ng-if="partCustomFields.length">
<table class="table table-border-bottom table-hover table-condensed font-95em"
ng-class="{'opacity_4':loadingPage}">
<thead>
<th>Label</th>
<th>Field Type</th>
<th>Entry Type</th>
<th>Required</th>
<th>Value(s)</th>
<th></th>
</thead>
<tbody ng-repeat="field in partCustomFields">
<tr>
<td>{{field.label}}</td>
<td>{{optionsText(field.fieldType)}}</td>
<td>{{field.entryType}}</td>
<td style="text-align: center; width: 80px">
<i class="fa fa-fw fa-check green" ng-if="field.required"></i></td>
<td>
<div ng-repeat="option in field.options">{{option.name}}</div>
</td>
<td style="width: 180px; border: 1px solid #ccc; vertical-align: middle">
<i ng-if="!field.delete" class="fa fa-fw fa-trash-o opacity_hover font-14em"
ng-click="field.delete = true"></i>
<span ng-if="field.delete">Permanently remove field?<br>
<button class="btn btn-xs btn-primary" ng-click="deleteCustomField(field)">Yes</button>
<button class="btn btn-xs btn-default" ng-click="field.delete = false">No</button>
</span>
</td>
</tr>
</tbody>
</table>
</div>

<div class="pad_top" ng-if="!partCustomFields.length">
<i>No custom fields available for parts of type <b class="text-muted">{{selection | capitalize}}</b></i>
</div>

</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {ComponentFixture, TestBed} from '@angular/core/testing';

import {AdminCustomFieldsComponent} from './admin-custom-fields.component';

describe('AdminCustomFieldsComponent', () => {
let component: AdminCustomFieldsComponent;
let fixture: ComponentFixture<AdminCustomFieldsComponent>;

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [AdminCustomFieldsComponent]
});
fixture = TestBed.createComponent(AdminCustomFieldsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import {Component} from '@angular/core';
import {HttpService} from "../../../services/http.service";
import {NgbModal, NgbModalOptions} from "@ng-bootstrap/ng-bootstrap";
import {EditCustomFieldModalComponent} from "../../modal/edit-custom-field-modal/edit-custom-field-modal.component";

@Component({
selector: 'app-admin-custom-fields',
templateUrl: './admin-custom-fields.component.html',
styleUrls: ['./admin-custom-fields.component.css']
})
export class AdminCustomFieldsComponent {

selection = 'plasmid';
loading: boolean;
partCustomFields: any;

constructor(private http: HttpService, private modalService: NgbModal) {
this.retrievePartFields();
}

options = [
{name: "Built in field", value: 'EXISTING'},
{name: 'Text', value: 'TEXT_INPUT'},
{name: 'Options', value: 'MULTI_CHOICE'},
{name: 'Options with Text', value: 'MULTI_CHOICE_PLUS'}];

optionsText(value: string): string {
for (let i = 0; i < this.options.length; i += 1) {
if (value === this.options[i].value) {
return this.options[i].name;
}
}
return value;
}

retrievePartFields(): void {
this.partCustomFields = undefined;
this.loading = true;
this.http.get("rest/fields/" + this.selection).subscribe({
next: (result: any) => {
this.partCustomFields = result.data;
}
});
};

selectedTab(selection: string): void {
if (this.selection === selection)
return;

this.selection = selection;
this.retrievePartFields();
};

deleteCustomField(customField: any): void {
this.http.delete("rest/fields/" + customField.entryType + "/" + customField.id)
.subscribe({
next: (result: any) => {
const index = this.partCustomFields.indexOf(customField);
if (index !== -1)
this.partCustomFields.splice(index, 1);
}
});
};

addNewCustomEntryField() {
const options: NgbModalOptions = {backdrop: 'static', size: 'md'};
const modalInstance = this.modalService.open(EditCustomFieldModalComponent, options);
modalInstance.componentInstance.entryType = this.selection;

modalInstance.result.then((result) => {
if (!result)
return;

if (!this.partCustomFields)
this.partCustomFields = [];
this.partCustomFields.push(result);
});
};
}


Original file line number Diff line number Diff line change
@@ -1 +1,88 @@
<p>admin-public-groups works!</p>
<div>
<div class="pad_top">
<button type="button" (click)="openCreatePublicGroupModal(null)" class="ice-button">
Create Public Group
</button>
</div>

<div class="pad_top" *ngIf="!groups.length">
<i class="text-muted">No public groups available</i>
</div>

<div class="pad_top" *ngIf="groups.length" style="width: 96%">
<table class="table table-hover table-border-bottom" [ngClass]="{'opacity_4':loadingPage}">
<thead>
<tr>
<th>&nbsp;</th>
<th class="entry-table-header" style="width: 360px">Label</th>
<th class="entry-table-header" style="width: 130px">Members</th>
<th class="entry-table-header">Created</th>
<th style="width:120px"></th>
</tr>
</thead>
<tbody>
<tr data-ng-repeat="group in groups">
<td style="vertical-align: middle; line-height:1; opacity:0.2; text-shadow:0 1px 0 #fff"
class="font-14em">
<b></b>
</td>
<td>{{group.label}}
<br>
<i class="small text-muted">{{group.description || 'No description provided'}}</i>
</td>
<td style="width:180px; white-space:nowrap; vertical-align: middle">
<span class="label"
[ngClass]="{
'label-primary': group.memberCount,
'label-default': group.memberCount == 0}">{{group.memberCount | number}}
</span>
</td>
<td style="width:190px">
{{group.ownerEmail}} <br>
<small class="text-muted">{{group.creationTime | date:'MMM d, yyyy'}}</small>
</td>
<td style="border-left: 1px solid #EEEEEE; width:150px; white-space:nowrap; vertical-align: middle">
<div *ngIf="!group.confirmDeleteGroup">
<i class="fa fa-fw fa-pencil font-14em edit_icon" [ngbTooltip]="'Edit'"
(click)="openCreatePublicGroupModal(group)"></i>
&nbsp;
<i class="fa fa-fw fa-trash font-14em delete_icon" (click)="group.confirmDeleteGroup = true"
[ngbTooltip]="'Delete'"></i>
</div>

<div *ngIf="group.confirmDeleteGroup">
Delete?
<button class="btn btn-primary btn-xs" (click)="deletePublicGroup(group)">Yes</button>
<button class="btn btn-default btn-xs" (click)="group.confirmDeleteGroup=false">No</button>
</div>
</td>
</tr>
</tbody>
</table>

<div class="col-md-5" style="padding-left: 0">
<ngb-pagination [collectionSize]="paging.available" [pageSize]="paging.limit" [(page)]="paging.currentPage"
[boundaryLinks]="true" [maxSize]="5" (pageChange)="pageChange($event)" size="sm">
<ng-template ngbPaginationFirst><i
class="fa fa-fw fa-angle-double-left"></i> First
</ng-template>
<ng-template ngbPaginationPrevious><i
class="fa fa-fw fa-angle-left"></i>Prev
</ng-template>
<!-- <ng-template ngbPaginationNumber let-p><button class="btn btn-sm btn-white">{{p}}</button></ng-template>-->
<ng-template ngbPaginationNext>Next<i
class="fa fa-fw fa-angle-right"></i></ng-template>
<ng-template ngbPaginationLast>Last<i
class="fa fa-fw fa-angle-double-right"></i>
</ng-template>
</ngb-pagination>
</div>

<div class="col-md-7" style="margin-top: 25px;">
<strong class="small">
<i *ngIf="loadingPage" class="fa fa-spin fa-gear opacity_4"></i>
{{pageNumber | number}} - {{pageCount | number}} of {{paging.available}}
</strong>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import {Component} from '@angular/core';
import {HttpService} from "../../../services/http.service";
import {Group} from "../../../models/group";
import {NgbModal} from "@ng-bootstrap/ng-bootstrap";
import {Paging} from "../../../models/paging";

@Component({
selector: 'app-admin-public-groups',
Expand All @@ -7,4 +11,65 @@ import {Component} from '@angular/core';
})
export class AdminPublicGroupsComponent {

groups = undefined;
group: Group;
loadingPage: boolean;
paging: Paging;
pageNumber: number;
pageCount: number;

adminGroupsPagingParams = {
offset: 0,
limit: 10,
available: 0,
currentPage: 1,
maxSize: 5,
type: 'PUBLIC'
};

constructor(private http: HttpService, private modalService: NgbModal) {
this.groupListPageChanged();
this.paging = new Paging();
}

groupListPageChanged(): void {
this.http.get("rest/groups", this.adminGroupsPagingParams).subscribe({
next: (result: any) => {
this.groups = result.data;
this.adminGroupsPagingParams.available = result.resultCount;
}
})
};

pageChange(page: number): void {
this.paging.offset = ((page - 1) * this.paging.limit);
}


openCreatePublicGroupModal(group: Group): void {
//
// const modalInstance = this.modalService.open();
// modalInstance.result.then(function (result) {
// if (!result)
// return;
//
// var msg = "Group successfully ";
// if (group && group.id)
// msg += "updated";
// else
// msg += "created";
// // Util.setFeedback(msg, "success");
// this.groupListPageChanged();
// })
};

deletePublicGroup(group: Group): void {
this.http.delete("rest/groups/" + group.id).subscribe({
next: () => {
const i = this.groups.indexOf(group);
if (i !== -1)
this.groups.splice(i, 1);
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@
</div>
</li>
<li class="nav-item">
<div class="nav-link cursor-pointer" [ngClass]="{'active': active === 'keys'}"
aria-current="page" (click)="goToActiveTab('keys')">Public Groups
<div class="nav-link cursor-pointer" [ngClass]="{'active': active === 'groups'}"
aria-current="page" (click)="goToActiveTab('groups')">Public Groups
</div>
</li>
<li class="nav-item">
<div class="nav-link cursor-pointer" [ngClass]="{'active': active === 'keys'}"
aria-current="page" (click)="goToActiveTab('keys')">Custom Fields
<div class="nav-link cursor-pointer" [ngClass]="{'active': active === 'fields'}"
aria-current="page" (click)="goToActiveTab('fields')">Custom Fields
</div>
</li>
<li class="nav-item">
Expand Down
Loading

0 comments on commit 5670a1d

Please sign in to comment.