🔍 support for search
This commit is contained in:
@@ -4,6 +4,9 @@
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
- Added search
|
||||||
|
- Some styling improvements
|
||||||
|
|
||||||
## [0.3.0] - 2020-01-09
|
## [0.3.0] - 2020-01-09
|
||||||
|
|
||||||
- Added support for grouping
|
- Added support for grouping
|
||||||
|
|||||||
19
src/App.vue
19
src/App.vue
@@ -1,9 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<TheHeader class="row"
|
<TheHeader class="row" />
|
||||||
github-url="https://github.com/undergroundwires/privacy.sexy" />
|
<TheSearchBar class="row" />
|
||||||
<!-- <TheSearchBar> </TheSearchBar> -->
|
|
||||||
<TheScripts class="row"/>
|
<TheScripts class="row"/>
|
||||||
<TheCodeArea class="row" theme="xcode" />
|
<TheCodeArea class="row" theme="xcode" />
|
||||||
<TheCodeButtons class="row" />
|
<TheCodeButtons class="row" />
|
||||||
@@ -15,20 +14,20 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Component, Vue, Prop } from 'vue-property-decorator';
|
import { Component, Vue, Prop } from 'vue-property-decorator';
|
||||||
import { ApplicationState, IApplicationState } from '@/application/State/ApplicationState';
|
import { ApplicationState, IApplicationState } from '@/application/State/ApplicationState';
|
||||||
import TheHeader from './presentation/TheHeader.vue';
|
import TheHeader from '@/presentation/TheHeader.vue';
|
||||||
import TheFooter from './presentation/TheFooter.vue';
|
import TheFooter from '@/presentation/TheFooter.vue';
|
||||||
import TheCodeArea from './presentation/TheCodeArea.vue';
|
import TheCodeArea from '@/presentation/TheCodeArea.vue';
|
||||||
import TheCodeButtons from './presentation/TheCodeButtons.vue';
|
import TheCodeButtons from '@/presentation/TheCodeButtons.vue';
|
||||||
import TheSearchBar from './presentation/TheSearchBar.vue';
|
import TheSearchBar from '@/presentation/TheSearchBar.vue';
|
||||||
import TheScripts from './presentation/Scripts/TheScripts.vue';
|
import TheScripts from '@/presentation/Scripts/TheScripts.vue';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
components: {
|
components: {
|
||||||
TheHeader,
|
TheHeader,
|
||||||
TheCodeArea,
|
TheCodeArea,
|
||||||
TheCodeButtons,
|
TheCodeButtons,
|
||||||
TheSearchBar,
|
|
||||||
TheScripts,
|
TheScripts,
|
||||||
|
TheSearchBar,
|
||||||
TheFooter,
|
TheFooter,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import applicationFile from 'js-yaml-loader!./../application.yaml';
|
|||||||
import { parseCategory } from './CategoryParser';
|
import { parseCategory } from './CategoryParser';
|
||||||
|
|
||||||
export function parseApplication(): Application {
|
export function parseApplication(): Application {
|
||||||
const name = applicationFile.name as string;
|
|
||||||
const version = applicationFile.version as number;
|
|
||||||
const categories = new Array<Category>();
|
const categories = new Array<Category>();
|
||||||
if (!applicationFile.actions || applicationFile.actions.length <= 0) {
|
if (!applicationFile.actions || applicationFile.actions.length <= 0) {
|
||||||
throw new Error('Application does not define any action');
|
throw new Error('Application does not define any action');
|
||||||
@@ -14,6 +12,10 @@ export function parseApplication(): Application {
|
|||||||
const category = parseCategory(action);
|
const category = parseCategory(action);
|
||||||
categories.push(category);
|
categories.push(category);
|
||||||
}
|
}
|
||||||
const app = new Application(name, version, categories);
|
const app = new Application(
|
||||||
|
applicationFile.name,
|
||||||
|
applicationFile.repositoryUrl,
|
||||||
|
applicationFile.version,
|
||||||
|
categories);
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|||||||
18
src/application/State/Filter/FilterResult.ts
Normal file
18
src/application/State/Filter/FilterResult.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { IFilterResult } from './IFilterResult';
|
||||||
|
import { IScript } from '@/domain/Script';
|
||||||
|
import { ICategory } from '@/domain/ICategory';
|
||||||
|
|
||||||
|
export class FilterResult implements IFilterResult {
|
||||||
|
constructor(
|
||||||
|
public readonly scriptMatches: ReadonlyArray<IScript>,
|
||||||
|
public readonly categoryMatches: ReadonlyArray<ICategory>,
|
||||||
|
public readonly query: string) {
|
||||||
|
if (!query) { throw new Error('Query is empty or undefined'); }
|
||||||
|
if (!scriptMatches) { throw new Error('Script matches is undefined'); }
|
||||||
|
if (!categoryMatches) { throw new Error('Category matches is undefined'); }
|
||||||
|
}
|
||||||
|
public hasAnyMatches(): boolean {
|
||||||
|
return this.scriptMatches.length > 0
|
||||||
|
|| this.categoryMatches.length > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
import { IScript, ICategory } from '@/domain/ICategory';
|
import { IScript, ICategory } from '@/domain/ICategory';
|
||||||
|
|
||||||
export interface IFilterMatches {
|
export interface IFilterResult {
|
||||||
readonly scriptMatches: ReadonlyArray<IScript>;
|
|
||||||
readonly categoryMatches: ReadonlyArray<ICategory>;
|
readonly categoryMatches: ReadonlyArray<ICategory>;
|
||||||
|
readonly scriptMatches: ReadonlyArray<IScript>;
|
||||||
readonly query: string;
|
readonly query: string;
|
||||||
|
hasAnyMatches(): boolean;
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import { IFilterMatches } from './IFilterMatches';
|
import { IFilterResult } from './IFilterResult';
|
||||||
import { ISignal } from '@/infrastructure/Events/Signal';
|
import { ISignal } from '@/infrastructure/Events/Signal';
|
||||||
|
|
||||||
export interface IUserFilter {
|
export interface IUserFilter {
|
||||||
readonly filtered: ISignal<IFilterMatches>;
|
readonly filtered: ISignal<IFilterResult>;
|
||||||
readonly filterRemoved: ISignal<void>;
|
readonly filterRemoved: ISignal<void>;
|
||||||
setFilter(filter: string): void;
|
setFilter(filter: string): void;
|
||||||
removeFilter(): void;
|
removeFilter(): void;
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { IFilterMatches } from './IFilterMatches';
|
import { FilterResult } from './FilterResult';
|
||||||
|
import { IFilterResult } from './IFilterResult';
|
||||||
import { Application } from '../../../domain/Application';
|
import { Application } from '../../../domain/Application';
|
||||||
import { IUserFilter } from './IUserFilter';
|
import { IUserFilter } from './IUserFilter';
|
||||||
import { Signal } from '@/infrastructure/Events/Signal';
|
import { Signal } from '@/infrastructure/Events/Signal';
|
||||||
|
|
||||||
export class UserFilter implements IUserFilter {
|
export class UserFilter implements IUserFilter {
|
||||||
public readonly filtered = new Signal<IFilterMatches>();
|
public readonly filtered = new Signal<IFilterResult>();
|
||||||
public readonly filterRemoved = new Signal<void>();
|
public readonly filterRemoved = new Signal<void>();
|
||||||
|
|
||||||
constructor(private application: Application) {
|
constructor(private application: Application) {
|
||||||
@@ -16,14 +17,17 @@ export class UserFilter implements IUserFilter {
|
|||||||
throw new Error('Filter must be defined and not empty. Use removeFilter() to remove the filter');
|
throw new Error('Filter must be defined and not empty. Use removeFilter() to remove the filter');
|
||||||
}
|
}
|
||||||
const filteredScripts = this.application.getAllScripts().filter(
|
const filteredScripts = this.application.getAllScripts().filter(
|
||||||
(script) => script.name.toLowerCase().includes(filter.toLowerCase()) ||
|
(script) =>
|
||||||
|
script.name.toLowerCase().includes(filter.toLowerCase()) ||
|
||||||
script.code.toLowerCase().includes(filter.toLowerCase()));
|
script.code.toLowerCase().includes(filter.toLowerCase()));
|
||||||
|
const filteredCategories = this.application.getAllCategories().filter(
|
||||||
|
(script) => script.name.toLowerCase().includes(filter.toLowerCase()));
|
||||||
|
|
||||||
const matches: IFilterMatches = {
|
const matches = new FilterResult(
|
||||||
scriptMatches: filteredScripts,
|
filteredScripts,
|
||||||
categoryMatches: null,
|
filteredCategories,
|
||||||
query: filter,
|
filter,
|
||||||
};
|
);
|
||||||
|
|
||||||
this.filtered.notify(matches);
|
this.filtered.notify(matches);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
name: privacy.sexy
|
name: privacy.sexy
|
||||||
version: 0.3.0
|
version: 0.3.0
|
||||||
|
repositoryUrl: https://github.com/undergroundwires/privacy.sexy
|
||||||
actions:
|
actions:
|
||||||
-
|
-
|
||||||
category: Privacy cleanup
|
category: Privacy cleanup
|
||||||
|
|||||||
1
src/application/application.yaml.d.ts
vendored
1
src/application/application.yaml.d.ts
vendored
@@ -20,6 +20,7 @@ declare module 'js-yaml-loader!*' {
|
|||||||
interface ApplicationYaml {
|
interface ApplicationYaml {
|
||||||
name: string;
|
name: string;
|
||||||
version: number;
|
version: number;
|
||||||
|
repositoryUrl: string;
|
||||||
actions: ReadonlyArray<YamlCategory>;
|
actions: ReadonlyArray<YamlCategory>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,14 +11,12 @@ export class Application implements IApplication {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public readonly name: string,
|
public readonly name: string,
|
||||||
|
public readonly repositoryUrl: string,
|
||||||
public readonly version: number,
|
public readonly version: number,
|
||||||
public readonly categories: ReadonlyArray<ICategory>) {
|
public readonly categories: ReadonlyArray<ICategory>) {
|
||||||
if (!name) {
|
if (!name) { throw Error('Application has no name'); }
|
||||||
throw Error('Application has no name');
|
if (!repositoryUrl) { throw Error('Application has no repository url'); }
|
||||||
}
|
if (!version) { throw Error('Version cannot be zero'); }
|
||||||
if (!version) {
|
|
||||||
throw Error('Version cannot be zero');
|
|
||||||
}
|
|
||||||
this.flattened = flatten(categories);
|
this.flattened = flatten(categories);
|
||||||
if (this.flattened.allCategories.length === 0) {
|
if (this.flattened.allCategories.length === 0) {
|
||||||
throw new Error('Application must consist of at least one category');
|
throw new Error('Application must consist of at least one category');
|
||||||
@@ -48,6 +46,10 @@ export class Application implements IApplication {
|
|||||||
public getAllScripts(): IScript[] {
|
public getAllScripts(): IScript[] {
|
||||||
return this.flattened.allScripts;
|
return this.flattened.allScripts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getAllCategories(): ICategory[] {
|
||||||
|
return this.flattened.allCategories;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ensureNoDuplicates<TKey>(entities: ReadonlyArray<IEntity<TKey>>) {
|
function ensureNoDuplicates<TKey>(entities: ReadonlyArray<IEntity<TKey>>) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { ICategory } from '@/domain/ICategory';
|
|||||||
|
|
||||||
export interface IApplication {
|
export interface IApplication {
|
||||||
readonly name: string;
|
readonly name: string;
|
||||||
|
readonly repositoryUrl: string;
|
||||||
readonly version: number;
|
readonly version: number;
|
||||||
readonly categories: ReadonlyArray<ICategory>;
|
readonly categories: ReadonlyArray<ICategory>;
|
||||||
readonly totalScripts: number;
|
readonly totalScripts: number;
|
||||||
@@ -12,6 +13,7 @@ export interface IApplication {
|
|||||||
findCategory(categoryId: number): ICategory | undefined;
|
findCategory(categoryId: number): ICategory | undefined;
|
||||||
findScript(scriptId: string): IScript | undefined;
|
findScript(scriptId: string): IScript | undefined;
|
||||||
getAllScripts(): ReadonlyArray<IScript>;
|
getAllScripts(): ReadonlyArray<IScript>;
|
||||||
|
getAllCategories(): ReadonlyArray<ICategory>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export { IScript } from '@/domain/IScript';
|
export { IScript } from '@/domain/IScript';
|
||||||
|
|||||||
@@ -4,12 +4,12 @@
|
|||||||
<span class="part">
|
<span class="part">
|
||||||
<span
|
<span
|
||||||
class="part"
|
class="part"
|
||||||
v-bind:class="{ 'disabled': isGrouped, 'enabled': !isGrouped}"
|
v-bind:class="{ 'disabled': cardsSelected, 'enabled': !cardsSelected}"
|
||||||
@click="!isGrouped ? toggleGrouping() : undefined">Cards</span>
|
@click="groupByCard()">Cards</span>
|
||||||
<span class="part">|</span>
|
<span class="part">|</span>
|
||||||
<span class="part"
|
<span class="part"
|
||||||
v-bind:class="{ 'disabled': !isGrouped, 'enabled': isGrouped}"
|
v-bind:class="{ 'disabled': noneSelected, 'enabled': !noneSelected}"
|
||||||
@click="isGrouped ? toggleGrouping() : undefined">None</span>
|
@click="groupByNone()">None</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -22,12 +22,30 @@ import { Grouping } from './Grouping';
|
|||||||
|
|
||||||
@Component
|
@Component
|
||||||
export default class TheGrouper extends StatefulVue {
|
export default class TheGrouper extends StatefulVue {
|
||||||
public currentGrouping: Grouping;
|
public cardsSelected = false;
|
||||||
public isGrouped = true;
|
public noneSelected = false;
|
||||||
|
|
||||||
public toggleGrouping() {
|
private currentGrouping: Grouping;
|
||||||
this.currentGrouping = this.currentGrouping === Grouping.None ? Grouping.Cards : Grouping.None;
|
|
||||||
this.isGrouped = this.currentGrouping === Grouping.Cards;
|
public mounted() {
|
||||||
|
this.changeGrouping(Grouping.Cards);
|
||||||
|
}
|
||||||
|
|
||||||
|
public groupByCard() {
|
||||||
|
this.changeGrouping(Grouping.Cards);
|
||||||
|
}
|
||||||
|
|
||||||
|
public groupByNone() {
|
||||||
|
this.changeGrouping(Grouping.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
private changeGrouping(newGrouping: Grouping) {
|
||||||
|
if (this.currentGrouping === newGrouping) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.currentGrouping = newGrouping;
|
||||||
|
this.cardsSelected = newGrouping === Grouping.Cards;
|
||||||
|
this.noneSelected = newGrouping === Grouping.None;
|
||||||
this.$emit('groupingChanged', this.currentGrouping);
|
this.$emit('groupingChanged', this.currentGrouping);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,13 @@ export function parseSingleCategory(categoryId: number, state: IApplicationState
|
|||||||
return tree;
|
return tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getScriptNodeId(script: IScript): string {
|
||||||
|
return script.id;
|
||||||
|
}
|
||||||
|
export function getCategoryNodeId(category: ICategory): string {
|
||||||
|
return `${category.id}`;
|
||||||
|
}
|
||||||
|
|
||||||
function parseCategoryRecursively(
|
function parseCategoryRecursively(
|
||||||
parentCategory: ICategory,
|
parentCategory: ICategory,
|
||||||
selection: IUserSelection): INode[] {
|
selection: IUserSelection): INode[] {
|
||||||
@@ -44,7 +51,7 @@ function parseCategoryRecursively(
|
|||||||
function convertCategoryToNode(
|
function convertCategoryToNode(
|
||||||
category: ICategory, children: readonly INode[]): INode {
|
category: ICategory, children: readonly INode[]): INode {
|
||||||
return {
|
return {
|
||||||
id: `${category.id}`,
|
id: getCategoryNodeId(category),
|
||||||
text: category.name,
|
text: category.name,
|
||||||
selected: false,
|
selected: false,
|
||||||
children,
|
children,
|
||||||
@@ -54,7 +61,7 @@ function convertCategoryToNode(
|
|||||||
|
|
||||||
function convertScriptToNode(script: IScript, selection: IUserSelection): INode {
|
function convertScriptToNode(script: IScript, selection: IUserSelection): INode {
|
||||||
return {
|
return {
|
||||||
id: `${script.id}`,
|
id: getScriptNodeId(script),
|
||||||
text: script.name,
|
text: script.name,
|
||||||
selected: selection.isSelected(script),
|
selected: selection.isSelected(script),
|
||||||
children: undefined,
|
children: undefined,
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<span id="container">
|
<span id="container">
|
||||||
<span v-if="nodes != null && nodes.length > 0">
|
<span v-if="nodes != null && nodes.length > 0">
|
||||||
<SelectableTree
|
<SelectableTree
|
||||||
:nodes="nodes"
|
:nodes="nodes"
|
||||||
:selectedNodeIds="selectedNodeIds"
|
:selectedNodeIds="selectedNodeIds"
|
||||||
:filterPredicate="filterPredicate"
|
:filterPredicate="filterPredicate"
|
||||||
:filterText="filterText"
|
:filterText="filterText"
|
||||||
v-on:nodeSelected="checkNodeAsync($event)">
|
v-on:nodeSelected="checkNodeAsync($event)">
|
||||||
</SelectableTree>
|
</SelectableTree>
|
||||||
</span>
|
</span>
|
||||||
<span v-else>Nooo 😢</span>
|
<span v-else>Nooo 😢</span>
|
||||||
@@ -19,9 +19,11 @@
|
|||||||
import { Category } from '@/domain/Category';
|
import { Category } from '@/domain/Category';
|
||||||
import { IRepository } from '@/infrastructure/Repository/IRepository';
|
import { IRepository } from '@/infrastructure/Repository/IRepository';
|
||||||
import { IScript } from '@/domain/IScript';
|
import { IScript } from '@/domain/IScript';
|
||||||
|
import { ICategory } from '@/domain/ICategory';
|
||||||
|
|
||||||
import { IApplicationState, IUserSelection } from '@/application/State/IApplicationState';
|
import { IApplicationState, IUserSelection } from '@/application/State/IApplicationState';
|
||||||
import { IFilterMatches } from '@/application/State/Filter/IFilterMatches';
|
import { IFilterResult } from '@/application/State/Filter/IFilterResult';
|
||||||
import { parseAllCategories, parseSingleCategory } from './ScriptNodeParser';
|
import { parseAllCategories, parseSingleCategory, getScriptNodeId, getCategoryNodeId } from './ScriptNodeParser';
|
||||||
import SelectableTree, { FilterPredicate } from './SelectableTree/SelectableTree.vue';
|
import SelectableTree, { FilterPredicate } from './SelectableTree/SelectableTree.vue';
|
||||||
import { INode } from './SelectableTree/INode';
|
import { INode } from './SelectableTree/INode';
|
||||||
|
|
||||||
@@ -37,11 +39,11 @@
|
|||||||
public selectedNodeIds?: string[] = null;
|
public selectedNodeIds?: string[] = null;
|
||||||
public filterText?: string = null;
|
public filterText?: string = null;
|
||||||
|
|
||||||
private matches?: IFilterMatches;
|
private filtered?: IFilterResult;
|
||||||
|
|
||||||
public async mounted() {
|
public async mounted() {
|
||||||
// React to state changes
|
|
||||||
const state = await this.getCurrentStateAsync();
|
const state = await this.getCurrentStateAsync();
|
||||||
|
// React to state changes
|
||||||
state.selection.changed.on(this.handleSelectionChanged);
|
state.selection.changed.on(this.handleSelectionChanged);
|
||||||
state.filter.filterRemoved.on(this.handleFilterRemoved);
|
state.filter.filterRemoved.on(this.handleFilterRemoved);
|
||||||
state.filter.filtered.on(this.handleFiltered);
|
state.filter.filtered.on(this.handleFiltered);
|
||||||
@@ -72,7 +74,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public filterPredicate(node: INode): boolean {
|
public filterPredicate(node: INode): boolean {
|
||||||
return this.matches.scriptMatches.some((script: IScript) => script.id === node.id);
|
return this.filtered.scriptMatches.some(
|
||||||
|
(script: IScript) => node.id === getScriptNodeId(script))
|
||||||
|
|| this.filtered.categoryMatches.some(
|
||||||
|
(category: ICategory) => node.id === getCategoryNodeId(category));
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleSelectionChanged(selectedScripts: ReadonlyArray<IScript>) {
|
private handleSelectionChanged(selectedScripts: ReadonlyArray<IScript>) {
|
||||||
@@ -83,9 +88,9 @@
|
|||||||
this.filterText = '';
|
this.filterText = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleFiltered(matches: IFilterMatches) {
|
private handleFiltered(result: IFilterResult) {
|
||||||
this.filterText = matches.query;
|
this.filterText = result.query;
|
||||||
this.matches = matches;
|
this.filtered = result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,18 @@
|
|||||||
<TheGrouper class="right"
|
<TheGrouper class="right"
|
||||||
v-on:groupingChanged="onGroupingChanged($event)" />
|
v-on:groupingChanged="onGroupingChanged($event)" />
|
||||||
</div>
|
</div>
|
||||||
<CardList v-if="showCards" />
|
<div class="scripts">
|
||||||
<ScriptsTree v-if="showList" />
|
<div v-if="!isSearching || searchHasMatches">
|
||||||
|
<CardList v-if="showCards" />
|
||||||
|
<div v-else-if="showList" class="tree">
|
||||||
|
<ScriptsTree />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else class="search-no-matches">
|
||||||
|
Search has no matches 😞
|
||||||
|
Feel free to extend the scripts <a :href="repositoryUrl" target="_blank" class="child github" >here</a>.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -14,11 +24,13 @@
|
|||||||
import { Component, Prop, Vue, Emit } from 'vue-property-decorator';
|
import { Component, Prop, Vue, Emit } from 'vue-property-decorator';
|
||||||
import { Category } from '@/domain/Category';
|
import { Category } from '@/domain/Category';
|
||||||
import { StatefulVue } from '@/presentation/StatefulVue';
|
import { StatefulVue } from '@/presentation/StatefulVue';
|
||||||
|
import { Grouping } from './Grouping/Grouping';
|
||||||
|
import { IFilterResult } from '@/application/State/Filter/IFilterResult';
|
||||||
import TheGrouper from '@/presentation/Scripts/Grouping/TheGrouper.vue';
|
import TheGrouper from '@/presentation/Scripts/Grouping/TheGrouper.vue';
|
||||||
import TheSelector from '@/presentation/Scripts/Selector/TheSelector.vue';
|
import TheSelector from '@/presentation/Scripts/Selector/TheSelector.vue';
|
||||||
import ScriptsTree from '@/presentation/Scripts/ScriptsTree/ScriptsTree.vue';
|
import ScriptsTree from '@/presentation/Scripts/ScriptsTree/ScriptsTree.vue';
|
||||||
import CardList from '@/presentation/Scripts/Cards/CardList.vue';
|
import CardList from '@/presentation/Scripts/Cards/CardList.vue';
|
||||||
import { Grouping } from './Grouping/Grouping';
|
|
||||||
|
|
||||||
/** Shows content of single category or many categories */
|
/** Shows content of single category or many categories */
|
||||||
@Component({
|
@Component({
|
||||||
@@ -30,33 +42,70 @@
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
export default class TheScripts extends StatefulVue {
|
export default class TheScripts extends StatefulVue {
|
||||||
public showCards = true;
|
public showCards = false;
|
||||||
public showList = false;
|
public showList = false;
|
||||||
|
public repositoryUrl = '';
|
||||||
|
private isSearching = false;
|
||||||
|
private searchHasMatches = false;
|
||||||
|
|
||||||
@Prop() public data!: Category | Category[];
|
private currentGrouping: Grouping;
|
||||||
|
|
||||||
|
public async mounted() {
|
||||||
|
const state = await this.getCurrentStateAsync();
|
||||||
|
this.repositoryUrl = state.app.repositoryUrl;
|
||||||
|
state.filter.filterRemoved.on(() => {
|
||||||
|
this.isSearching = false;
|
||||||
|
this.updateGroups();
|
||||||
|
});
|
||||||
|
state.filter.filtered.on((result: IFilterResult) => {
|
||||||
|
this.isSearching = true;
|
||||||
|
this.searchHasMatches = result.hasAnyMatches();
|
||||||
|
this.updateGroups();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public onGroupingChanged(group: Grouping) {
|
public onGroupingChanged(group: Grouping) {
|
||||||
switch (group) {
|
this.currentGrouping = group;
|
||||||
case Grouping.Cards:
|
this.updateGroups();
|
||||||
this.showCards = true;
|
}
|
||||||
this.showList = false;
|
|
||||||
break;
|
private updateGroups(): void {
|
||||||
case Grouping.None:
|
this.showCards = !this.isSearching && this.currentGrouping === Grouping.Cards;
|
||||||
this.showCards = false;
|
this.showList = this.isSearching || this.currentGrouping === Grouping.None;
|
||||||
this.showList = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error('Unknown grouping');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
@import "@/presentation/styles/colors.scss";
|
||||||
|
@import "@/presentation/styles/fonts.scss";
|
||||||
|
.scripts {
|
||||||
|
margin-top:10px;
|
||||||
|
.search-no-matches {
|
||||||
|
word-break:break-word;
|
||||||
|
color: $white;
|
||||||
|
text-transform: uppercase;
|
||||||
|
color: $light-gray;
|
||||||
|
font-size: 1.5em;
|
||||||
|
background-color: $slate;
|
||||||
|
padding:5%;
|
||||||
|
text-align:center;
|
||||||
|
> a {
|
||||||
|
color: $gray;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.tree {
|
||||||
|
padding-left: 3%;
|
||||||
|
margin-top: 15px; // Card margin
|
||||||
|
}
|
||||||
|
}
|
||||||
.help-container {
|
.help-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
.center {
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
.left {
|
.left {
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
}
|
}
|
||||||
@@ -64,4 +113,5 @@
|
|||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<div id="container">
|
<div id="container">
|
||||||
<h1 class="child title" >{{ title }}</h1>
|
<h1 class="child title" >{{ title }}</h1>
|
||||||
<h2 class="child subtitle">{{ subtitle }}</h2>
|
<h2 class="child subtitle">{{ subtitle }}</h2>
|
||||||
<a :href="githubUrl" target="_blank" class="child github" >
|
<a :href="repositoryUrl" target="_blank" class="child github" >
|
||||||
<font-awesome-icon :icon="['fab', 'github']" size="3x" />
|
<font-awesome-icon :icon="['fab', 'github']" size="3x" />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@@ -14,14 +14,15 @@ import { StatefulVue } from './StatefulVue';
|
|||||||
|
|
||||||
@Component
|
@Component
|
||||||
export default class TheHeader extends StatefulVue {
|
export default class TheHeader extends StatefulVue {
|
||||||
private title: string = '';
|
public title = '';
|
||||||
private subtitle: string = '';
|
public subtitle = '';
|
||||||
@Prop() private githubUrl!: string;
|
public repositoryUrl = '';
|
||||||
|
|
||||||
public async mounted() {
|
public async mounted() {
|
||||||
const state = await this.getCurrentStateAsync();
|
const state = await this.getCurrentStateAsync();
|
||||||
this.title = state.app.name;
|
this.title = state.app.name;
|
||||||
this.subtitle = 'Enforce privacy & security on Windows';
|
this.subtitle = 'Enforce privacy & security on Windows';
|
||||||
|
this.repositoryUrl = state.app.repositoryUrl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="search">
|
<div class="search">
|
||||||
<input type="text" class="searchTerm" placeholder="Search for configurations"
|
<input type="text" class="searchTerm" placeholder="Search"
|
||||||
@input="updateFilterAsync($event.target.value)" >
|
@input="updateFilterAsync($event.target.value)" >
|
||||||
<div class="iconWrapper">
|
<div class="iconWrapper">
|
||||||
<font-awesome-icon :icon="['fas', 'search']" />
|
<font-awesome-icon :icon="['fas', 'search']" />
|
||||||
@@ -16,8 +16,6 @@ import { StatefulVue } from './StatefulVue';
|
|||||||
|
|
||||||
@Component
|
@Component
|
||||||
export default class TheSearchBar extends StatefulVue {
|
export default class TheSearchBar extends StatefulVue {
|
||||||
|
|
||||||
|
|
||||||
public async updateFilterAsync(filter: |string) {
|
public async updateFilterAsync(filter: |string) {
|
||||||
const state = await this.getCurrentStateAsync();
|
const state = await this.getCurrentStateAsync();
|
||||||
if (!filter) {
|
if (!filter) {
|
||||||
@@ -35,9 +33,6 @@ export default class TheSearchBar extends StatefulVue {
|
|||||||
@import "@/presentation/styles/fonts.scss";
|
@import "@/presentation/styles/fonts.scss";
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
padding-top: 30px;
|
|
||||||
padding-right: 30%;
|
|
||||||
padding-left: 30%;
|
|
||||||
font: $normal-font;
|
font: $normal-font;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,6 +44,7 @@ export default class TheSearchBar extends StatefulVue {
|
|||||||
|
|
||||||
.searchTerm {
|
.searchTerm {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
min-width: 60px;
|
||||||
border: 1.5px solid $gray;
|
border: 1.5px solid $gray;
|
||||||
border-right: none;
|
border-right: none;
|
||||||
height: 36px;
|
height: 36px;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ describe('Application', () => {
|
|||||||
new ScriptStub('S3').withIsRecommended(true),
|
new ScriptStub('S3').withIsRecommended(true),
|
||||||
new ScriptStub('S4').withIsRecommended(true),
|
new ScriptStub('S4').withIsRecommended(true),
|
||||||
];
|
];
|
||||||
const sut = new Application('name', 2, [
|
const sut = new Application('name', 'repo', 2, [
|
||||||
new CategoryStub(3).withScripts(expected[0], new ScriptStub('S1').withIsRecommended(false)),
|
new CategoryStub(3).withScripts(expected[0], new ScriptStub('S1').withIsRecommended(false)),
|
||||||
new CategoryStub(2).withScripts(expected[1], new ScriptStub('S2').withIsRecommended(false)),
|
new CategoryStub(2).withScripts(expected[1], new ScriptStub('S2').withIsRecommended(false)),
|
||||||
]);
|
]);
|
||||||
@@ -28,7 +28,7 @@ describe('Application', () => {
|
|||||||
const categories = [];
|
const categories = [];
|
||||||
|
|
||||||
// act
|
// act
|
||||||
function construct() { return new Application('name', 2, categories); }
|
function construct() { return new Application('name', 'repo', 2, categories); }
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
expect(construct).to.throw('Application must consist of at least one category');
|
expect(construct).to.throw('Application must consist of at least one category');
|
||||||
@@ -41,7 +41,7 @@ describe('Application', () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
// act
|
// act
|
||||||
function construct() { return new Application('name', 2, categories); }
|
function construct() { return new Application('name', 'repo', 2, categories); }
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
expect(construct).to.throw('Application must consist of at least one script');
|
expect(construct).to.throw('Application must consist of at least one script');
|
||||||
@@ -54,7 +54,7 @@ describe('Application', () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
// act
|
// act
|
||||||
function construct() { return new Application('name', 2, categories); }
|
function construct() { return new Application('name', 'repo', 2, categories); }
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
expect(construct).to.throw('Application must consist of at least one recommended script');
|
expect(construct).to.throw('Application must consist of at least one recommended script');
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ export class ApplicationStub implements IApplication {
|
|||||||
public readonly totalScripts = 0;
|
public readonly totalScripts = 0;
|
||||||
public readonly totalCategories = 0;
|
public readonly totalCategories = 0;
|
||||||
public readonly name = 'StubApplication';
|
public readonly name = 'StubApplication';
|
||||||
|
public readonly repositoryUrl = 'https://privacy.sexy';
|
||||||
public readonly version = 1;
|
public readonly version = 1;
|
||||||
public readonly categories = new Array<ICategory>();
|
public readonly categories = new Array<ICategory>();
|
||||||
|
|
||||||
@@ -23,4 +24,7 @@ export class ApplicationStub implements IApplication {
|
|||||||
public getAllScripts(): ReadonlyArray<IScript> {
|
public getAllScripts(): ReadonlyArray<IScript> {
|
||||||
throw new Error('Method not implemented.');
|
throw new Error('Method not implemented.');
|
||||||
}
|
}
|
||||||
|
public getAllCategories(): ReadonlyArray<ICategory> {
|
||||||
|
throw new Error('Method not implemented.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user