Skip to content

Commit

Permalink
Merge pull request #62 from AMOSTeam1/mark-selected-factor
Browse files Browse the repository at this point in the history
highlight the (factors - criteria - metrics) according to the project's NFRs
  • Loading branch information
jmnietsch authored Jun 27, 2018
2 parents 22302b3 + f515e29 commit 6f3143e
Show file tree
Hide file tree
Showing 7 changed files with 178 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<a class="list-group-item list-group-item-danger clearfix"
[routerLink] = "[index]"
routerLinkActive="active"
style="cursor: pointer;"
>
<div class="pull-left" >
<h6 class="list-group-item-heading">{{nfaFactorNumber}}.{{nfaCriteria.criteriaNumber}} {{ nfaCriteria.criteria}}</h6>
</div>
<span class="pull-right">
</span>
</a>
<a class="list-group-item list-group-item-danger clearfix"
[routerLink] = "[index]"
routerLinkActive="active"
style="cursor: pointer;"
>
<div class="pull-left" >
<h6 class="list-group-item-heading" [class]="class">{{nfaFactorNumber}}.{{nfaCriteria.criteriaNumber}} {{ nfaCriteria.criteria}}</h6>
</div>
<span class="pull-right">
</span>
</a>
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import {Component, Input, OnInit} from '@angular/core';
import {NfaCriteriaModel} from '../../../../shared/nfaCriteria.model';
import {LocalStorageService} from 'angular-web-storage';
import {NfaCatalogModel} from '../../../../shared/nfaCatalog.model';
import {NfaMetric} from '../../../../shared/nfaMetric.model';


@Component({
selector: 'app-nfacatalog-criteria-item',
Expand All @@ -12,9 +16,41 @@ export class NfacatalogCriteriaItemComponent implements OnInit {
@Input() index: number;
@Input() nfaFactorNumber: number;

constructor() { }
selectedNfs: NfaCatalogModel[]
metrics: NfaMetric[];
factorNfs: NfaCatalogModel[];
class: string;

constructor(public local: LocalStorageService) {
}

ngOnInit() {

/** read the project nfas from the local variable
* get the nfas of the curret criteria
* check if the nfa of the current criteria is one of the project nfas then set the class according to the condition result
*/
if (this.local.get('selNfs') != null) {
this.selectedNfs = this.local.get('selNfs');
if (this.selectedNfs.length === 0) {
this.class = 'list-group-item-text';
}
else {
this.metrics = this.nfaCriteria.metricList;
for (const met of this.metrics) {
this.factorNfs = met.nfaList;
for (const nfa of this.factorNfs) {
for (const selnfa of this.selectedNfs) {
if (selnfa.nfaCatalogId == nfa.nfaCatalogId) {
this.class = 'list-group-item-success';
}
}

}
}
}
}
else{ this.class = 'list-group-item-text';}
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<div class="row" *ngIf ="onView">
<div class="col-xs-12">
<div class="col-xs-12" *ngIf="isSelected==true">
<button class="btn btn-default btn-lg col-xs-1" (click)="onPrev()" [disabled] = "metricIdx == 0"> < </button>
<button class="btn btn-success btn-lg col-xs-10"
style="text-align: center"
(click)="onView = !onView">
{{nfaFactor.nfa_id}}.{{criteria.criteriaNumber}}.{{nfaMetrics[metricIdx].metricNumber}} {{nfaMetrics[metricIdx].bezeichnung}}</button>
<button class="btn btn-default btn-lg col-xs-1" (click)="onNext()" [disabled] = "metricIdx == nfaMetrics.length-1"> > </button>
</div>
<div class="col-xs-12" *ngIf="isSelected==false">
<button class="btn btn-default btn-lg col-xs-1" (click)="onPrev()" [disabled] = "metricIdx == 0"> < </button>
<button class="btn btn-default btn-lg col-xs-10"
style="text-align: center"
Expand All @@ -12,11 +20,11 @@
<div class="col-xs-12" *ngIf="!onView">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{{ 'nfa.metric' | translate }}</h3>
<h3 class="panel-title" >{{ 'nfa.metric' | translate }}</h3>
</div>
<div class="panel-body">
<div class="row text-center" *ngFor="let metric of nfaMetrics; let j = index">
<button class="btn btn-default small" style="margin:0 0 1px" (click)="onGoto(j)">
<button class="btn btn-default small" style="margin:0 0 1px" (click)="onGoto(j)">
{{nfaFactor.nfa_id}}.{{criteria.criteriaNumber}}.{{metric.metricNumber}} {{metric.bezeichnung}}
</button>
<hr>
Expand All @@ -28,10 +36,10 @@ <h3 class="panel-title">{{ 'nfa.metric' | translate }}</h3>
<hr>
<div class="panel panel-primary" *ngIf ="onView">
<div class="panel-heading">
<h3 class="panel-title">{{ 'nfa.catalog.explanation' | translate }}</h3>
<h3 class="panel-title" >{{ 'nfa.catalog.explanation' | translate }}</h3>
</div>
<div class="panel-body">
<p class="small">{{nfaMetrics[metricIdx].erklaerungMessgroesse}}</p>
<p class="small" >{{nfaMetrics[metricIdx].erklaerungMessgroesse}}</p>
</div>
</div>
<div class="panel panel-primary" *ngIf ="onView">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {NfacatalogService} from '../../nfacatalog.service';
import {NfaMetric} from '../../../shared/nfaMetric.model';
import {NfaFactorModel} from "../../../shared/nfaFactor.model";
import {NfaCriteriaModel} from "../../../shared/nfaCriteria.model";
import {LocalStorageService} from 'angular-web-storage';
import {NfaCatalogModel} from '../../../shared/nfaCatalog.model';

@Component({
selector: 'app-nfacatalog-metric',
Expand All @@ -20,9 +22,17 @@ export class NfacatalogMetricComponent implements OnInit {
private onView = true;
metricIdx: number;
nfaIdx: number;

selectedNfs: NfaCatalogModel[]
factorNfs: NfaCatalogModel[];
isSelected = false;
class: string;

constructor(private nfaCatalogService: NfacatalogService,
private route: ActivatedRoute,
private router: Router) { }
private router: Router,
public local: LocalStorageService
) { }

ngOnInit() {

Expand All @@ -44,14 +54,16 @@ export class NfacatalogMetricComponent implements OnInit {
this.nfaIdx = 0;
}
);

this.isMetricSelected();
}

onNext(){
this.metricIdx = this.metricIdx + 1;
this.isMetricSelected();
}
onPrev() {
this.metricIdx = this.metricIdx - 1;
this.isMetricSelected();
}

onNfa(){
Expand All @@ -68,4 +80,32 @@ export class NfacatalogMetricComponent implements OnInit {
this.onView = !this.onView;
}

/**
* this function is used to check if the metric should be hihlighted or not
*/
isMetricSelected(){
this.isSelected= false;
/** read the project nfas from the local variable
* get the nfas of the curret metric
* check if the nfa of the current metric is one of the projec nfas then set iseselcted by the condition result
*/
if (this.local.get('selNfs') != null) {
this.selectedNfs = this.local.get('selNfs');
if (this.selectedNfs.length === 0) {
this.class = 'list-group-item-text';
}
else {
this.factorNfs = this.nfaMetrics[this.metricIdx].nfaList;
for (const nfa of this.factorNfs) {
for (const selnfa of this.selectedNfs) {
if (selnfa.nfaCatalogId == nfa.nfaCatalogId) {
this.isSelected = true;
}
}
}
}
}
else{ this.isSelected = false;}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
[routerLink] = "[index]"
routerLinkActive="active"
style="cursor: pointer;"

>

<div class="text-center" >
<h3 class="list-group-item-heading">{{nfaFactor.nfa_id}}. {{ nfaFactor.factor}}</h3>
<h3 class = {{class}} >{{nfaFactor.nfa_id}}. {{ nfaFactor.factor}}</h3>
</div>
<span class="pull-right">
</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import {Component, Input, OnInit} from '@angular/core';
import {NfaFactorModel} from '../../../shared/nfaFactor.model';
import {LocalStorageService} from 'angular-web-storage';
import {NfaCatalogModel} from '../../../shared/nfaCatalog.model';
import {NfaMetric} from '../../../shared/nfaMetric.model';
import {NfaCriteriaModel} from '../../../shared/nfaCriteria.model';

@Component({
selector: 'app-nfacatalog-item',
Expand All @@ -10,10 +14,44 @@ export class NfacatalogItemComponent implements OnInit {

@Input() nfaFactor: NfaFactorModel;
@Input() index: number;
selectedNfs: NfaCatalogModel[]
metrics: NfaMetric[];
criertia: NfaCriteriaModel[];
isSelected = false;
factorNfs: NfaCatalogModel[];
class: string;

constructor() { }
constructor(public local: LocalStorageService) {
}

ngOnInit() {
}
/** read the project nfas from the local variable
* get the nfas of the curret factor
* check if the nfa of the current factor is one of the project nfas then set the class according to the condition result
*/
if (this.local.get('selNfs') != null) {
this.selectedNfs = this.local.get('selNfs');
if (this.selectedNfs.length === 0) {
this.class = 'list-group-item-text';
}
else {
this.criertia = this.nfaFactor.criteriaList;
for (const crt of this.criertia) {
this.metrics = crt.metricList;
for (const met of this.metrics) {
this.factorNfs = met.nfaList;
for (const nfa of this.factorNfs) {
for (const selnfa of this.selectedNfs) {
if (selnfa.nfaCatalogId == nfa.nfaCatalogId) {
this.class = 'list-group-item-success';
}
}

}
}
}
}
}
else{ this.class = 'list-group-item-text';}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@

import { Component, OnInit } from '@angular/core';
import {NfaCatalogModel} from "../../shared/nfaCatalog.model";
import {DataStorageService} from "../../shared/data-storage.service";

import {NfacatalogService} from "../nfacatalog.service";
import {Response} from "@angular/http";
import {NfaFactorModel} from "../../shared/nfaFactor.model";
import {NfaCatalogModel} from '../../shared/nfaCatalog.model';
import {DataStorageService} from '../../shared/data-storage.service';

import {NfacatalogService} from '../nfacatalog.service';
import {Response} from '@angular/http';
import {NfaFactorModel} from '../../shared/nfaFactor.model';
import {NfaMetric} from '../../shared/nfaMetric.model';
import {NfaCriteriaModel} from '../../shared/nfaCriteria.model';
import {LocalStorageService} from 'angular-web-storage';
import {CurrentProjectService} from '../../current-project/current-project.service';
import {Project} from '../../shared/project.model';

@Component({
selector: 'app-nfacatalog-list',
Expand All @@ -16,20 +21,36 @@ export class NfacatalogListComponent implements OnInit {


// nfaCatalog: NfaCatalogModel[];
nfaFactors: NfaFactorModel[];
nfaFactors: NfaFactorModel[] = [];
savedNfas: NfaCatalogModel[];
savedFactors: NfaFactorModel[] = [];

metrics: NfaMetric[] ;
criteria: NfaCriteriaModel[];
nfa: NfaCatalogModel[];
id: number;
projectNfs: NfaCatalogModel[];
project: Project;

constructor(private nfaCatalogService: NfacatalogService,
private dataStorageService: DataStorageService) { }
private dataStorageService: DataStorageService,
private currentProjectService: CurrentProjectService,
public local: LocalStorageService,
) { }

ngOnInit() {
this.dataStorageService.getNfaFactor()
.subscribe(
(response: Response) => {
const nfaFactors: NfaFactorModel[]=response.json();
const nfaFactors: NfaFactorModel[] = response.json();
this.nfaCatalogService.setNfaFactors(nfaFactors);
this.nfaFactors = nfaFactors;
}
);
this.project = this.local.get('currProject');
this.projectNfs = this.currentProjectService.getProject(this.project.id).projectNfas.slice();
if (this.project.id != null && this.local.get('selNfs') == null ){
this.local.set('selNfs', this.projectNfs );
}
}


}

0 comments on commit 6f3143e

Please sign in to comment.