Skip to content

Commit

Permalink
cleaned up
Browse files Browse the repository at this point in the history
  • Loading branch information
Davo00 committed Nov 30, 2023
1 parent 7e5145e commit 88759a2
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 42 deletions.
2 changes: 0 additions & 2 deletions workbench/frontend/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import { ResourceQueryComponent } from './common/components/resource-query/resou
import { SaveDialog } from './common/components/plugin-editor/save-dialog/save-dialog.component';
import { SelectSheet } from './common/components/select-sheet/select-sheet.component';
import { PluginEditorComponent } from './common/components/plugin-editor/plugin-editor.component';
import { MatRadioModule } from '@angular/material/radio';


@NgModule({
Expand Down Expand Up @@ -67,7 +66,6 @@ import { MatRadioModule } from '@angular/material/radio';
MonacoEditorModule.forRoot(ngxMonacoEditorConfig),
FlexLayoutModule,
...MatModules,
MatRadioModule,
FormsModule
],
providers: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ <h2>Query Templates:</h2>

<div style="display: inline-flex; flex-wrap: wrap; margin-top: 16px;">
<div style="display: flex; flex-direction: row;">
<mat-checkbox style="margin-right: 16px;" [(ngModel)]="crowdChecked" (change)="updateSqlCode()">Crowd</mat-checkbox>
<mat-checkbox [(ngModel)]="internalChecked" (change)="updateSqlCode()">Internal</mat-checkbox>
<mat-checkbox style="margin-right: 16px;" [(ngModel)]="crowdChecked" (change)="switchCrowdInternal('CROWD')">Crowd</mat-checkbox>
<mat-checkbox [(ngModel)]="internalChecked" (change)="switchCrowdInternal('INTERNAL')">Internal</mat-checkbox>
</div>
</div>

Expand All @@ -52,23 +52,6 @@ <h2>Query Templates:</h2>
</form>

<div style="display: flex; justify-content: right; align-items: start; margin-top: 15px;">
<!--<form [formGroup]="form">
<mat-form-field style="margin-left: 24px;">
<mat-label>Skills</mat-label>
<mat-select formControlName="selectedSkills" multiple>
<mat-select-trigger>
{{ form.get('selectedSkills').value ? form.get('selectedSkills').value.length + ' selected' : 'Select Skills' }}
</mat-select-trigger>
<mat-option *ngFor="let skill of allSkills" [value]="skill">
{{ skill }}
</mat-option>
</mat-select>
</mat-form-field>
</form>-->


<button mat-raised-button (click)="doQuery()" style="" color="primary" class="margin-10">run query</button>
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
.selected {
background-color: #e0e0e0; /* Greyish color for selected tab */
color: #333; /* Adjust text color for better contrast */
border-bottom: 3px solid #ccc; /* Border color for selected tab */
background-color: #e0e0e0;
color: #333;
border-bottom: 3px solid #ccc;
}

.mat-button {
transition: background-color 0.3s; /* Add a smooth transition for background color */
transition: background-color 0.3s;
}

.mat-button:not(.selected):hover {
background-color: #e0e0e0; /* Change background color on hover for non-selected buttons */
background-color: #e0e0e0;
}

.selected:hover {
background-color: #e0e0e0; /* Change background color on hover for non-selected buttons */
background-color: #e0e0e0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { HttpErrorResponse } from '@angular/common/http';
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { MatSnackBar } from '@angular/material/snack-bar';
import { BehaviorSubject, merge, Observable, of, Subject } from 'rxjs';
import { BehaviorSubject, merge, of, Subject } from 'rxjs';
import { catchError, map, mergeMap, take, takeUntil, tap, withLatestFrom } from 'rxjs/operators';
import { QueryService } from '../../services/query.service';
import { SharedSkillsService } from '../../services/shared-skill.service';
Expand Down Expand Up @@ -165,7 +165,7 @@ export class ResourceQueryComponent implements OnInit, OnDestroy {

public removeSkill(skill: string): void {
this.sharedSkillsService.selectedSkills$.pipe(
take(1), // Take only one emission to avoid unnecessary subscriptions
take(1),
map((selectedSkills) => selectedSkills.filter((s) => s !== skill))
).subscribe((updatedSkills) => {
this.selectedSkills$.next(updatedSkills);
Expand Down Expand Up @@ -199,17 +199,27 @@ export class ResourceQueryComponent implements OnInit, OnDestroy {
}
}


public switchCrowdInternal(changed: string): void {
if (changed === 'CROWD' && this.crowdChecked) {
this.internalChecked = false;
}
else if (changed === 'INTERNAL' && this.internalChecked) {
this.crowdChecked = false;
}

this.updateSqlCode();
}

public updateSqlCode(): void {
const updateCondition = (conditionToAdd: string, include: boolean): void => {
const query = this.form.value.query;

if (query.trim() !== '') {
if (include) {
// If including, add the new condition
const updatedQuery = this.insertTextAfterWhere(query, conditionToAdd);
this.form.patchValue({ query: updatedQuery });
} else {
// If excluding, remove the existing condition
const modifiedQuery = this.removeCondition(query, conditionToAdd);
this.form.patchValue({ query: modifiedQuery });
}
Expand All @@ -221,7 +231,7 @@ export class ResourceQueryComponent implements OnInit, OnDestroy {
}

private insertTextAfterWhere(input: string, newText: string): string {
const whereRegex = /\bWHERE\b/i; // case-insensitive match for WHERE
const whereRegex = /\bWHERE\b/i;
const whereMatch = whereRegex.exec(input);

if (whereMatch) {
Expand All @@ -236,6 +246,4 @@ export class ResourceQueryComponent implements OnInit, OnDestroy {
private removeCondition(query: string, conditionToRemove: string): string {
return query.replace(conditionToRemove, '');
}


}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// shared-skills.service.ts
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,3 @@
margin-left: 3px;
font-size: 9px;
}

.highlighted-resources {
background-color: khaki;
display: block;
padding-top: 8px;
padding-bottom: 8px;
}

0 comments on commit 88759a2

Please sign in to comment.