diff --git a/app/index.ts b/app/index.ts index d3be30fa9..f79d58141 100644 --- a/app/index.ts +++ b/app/index.ts @@ -68,15 +68,6 @@ require("./lib/jquery.tooltip.pack.js") require("./scripts/main") require("./scripts/app") -require("./scripts/controllers/comparison_controller") -require("./scripts/controllers/kwic_controller") -require("./scripts/controllers/example_controller") -require("./scripts/controllers/statistics_controller") -require("./scripts/controllers/trend_diagram_controller") -require("./scripts/controllers/word_picture_controller") -require("./scripts/controllers/map_controller") -require("./scripts/controllers/text_reader_controller") - require("./scripts/video_controllers.js") require("./scripts/backend/struct-service") require("./scripts/filter_directives.js") diff --git a/app/scripts/components/dynamic_tabs/compare-tabs.js b/app/scripts/components/dynamic_tabs/compare-tabs.js deleted file mode 100644 index 50371a87c..000000000 --- a/app/scripts/components/dynamic_tabs/compare-tabs.js +++ /dev/null @@ -1,56 +0,0 @@ -/** @format */ -import angular from "angular" -import { html } from "@/util" -import "@/components/korp-error" -import "@/components/loglike-meter" -import "@/controllers/comparison_controller" -import "@/directives/tab-spinner" - -angular.module("korpApp").directive("compareTabs", () => ({ - replace: true, - template: html` - - {{'compare_vb' | loc:$root.lang}} -
- -
-

{{'compare_distinctive' | loc:$root.lang}} {{cmp1.label}}

-
    -
  • - -
  • -
-
-
-

{{'compare_distinctive' | loc:$root.lang}} {{cmp2.label}}

-
    -
  • - -
  • -
-
-
-
- `, - bindToController: { - tabs: "<", - }, - scope: {}, - controllerAs: "$ctrl", - controller: [() => {}], -})) diff --git a/app/scripts/components/dynamic_tabs/graph-tabs.js b/app/scripts/components/dynamic_tabs/graph-tabs.js deleted file mode 100644 index 24c5c1ca5..000000000 --- a/app/scripts/components/dynamic_tabs/graph-tabs.js +++ /dev/null @@ -1,25 +0,0 @@ -/** @format */ -import angular from "angular" -import { html } from "@/util" -import "@/components/trend-diagram" -import "@/directives/tab-spinner" - -angular.module("korpApp").directive("graphTabs", () => ({ - replace: true, - template: html` - - {{'graph' | loc:$root.lang}} -
- -
- -
- `, - bindToController: { - tabs: "<", - }, - scope: {}, - controllerAs: "$ctrl", - controller: [() => {}], -})) diff --git a/app/scripts/components/dynamic_tabs/kwic-tabs.js b/app/scripts/components/dynamic_tabs/kwic-tabs.js deleted file mode 100644 index 937ec8667..000000000 --- a/app/scripts/components/dynamic_tabs/kwic-tabs.js +++ /dev/null @@ -1,48 +0,0 @@ -/** @format */ -import angular from "angular" -import { html } from "@/util" -import "@/components/korp-error" -import "@/components/kwic" -import "@/directives/tab-spinner" - -// This is a directives because it needs `replace: true`, which is not supported in component -angular.module("korpApp").directive("kwicTabs", () => ({ - replace: true, - template: html` - - KWIC - -
- -
-
- `, - bindToController: { - tabs: "<", - }, - scope: {}, - controllerAs: "$ctrl", - controller: [() => {}], -})) diff --git a/app/scripts/components/dynamic_tabs/map-tabs.js b/app/scripts/components/dynamic_tabs/map-tabs.js deleted file mode 100644 index 3023a6cdf..000000000 --- a/app/scripts/components/dynamic_tabs/map-tabs.js +++ /dev/null @@ -1,58 +0,0 @@ -/** @format */ -import angular from "angular" -import { html } from "@/util" -import "@/components/korp-error" -import "@/components/result-map" -import "@/directives/tab-spinner" - -angular.module("korpApp").directive("mapTabs", () => ({ - replace: true, - template: html` - - {{ 'map' | loc:$root.lang}} -
- -
-
-
- -
- Σ -
-
- -
-
- -
-
-
- `, - bindToController: { - tabs: "<", - }, - scope: {}, - controllerAs: "$ctrl", - controller: [() => {}], -})) diff --git a/app/scripts/components/dynamic_tabs/text-tabs.js b/app/scripts/components/dynamic_tabs/text-tabs.js deleted file mode 100644 index d5f5d229c..000000000 --- a/app/scripts/components/dynamic_tabs/text-tabs.js +++ /dev/null @@ -1,32 +0,0 @@ -/** @format */ -import angular from "angular" -import { html } from "@/util" -import "@/components/korp-error" -import "@/directives/tab-spinner" - -angular.module("korpApp").directive("textTabs", () => ({ - replace: true, - template: html` - {{ 'text_tab_header' | loc:$root.lang}} -
- -
-
-
`, - bindToController: { - tabs: "<", - }, - scope: {}, - controllerAs: "$ctrl", - controller: [() => {}], -})) diff --git a/app/scripts/components/results.ts b/app/scripts/components/results.ts index 5d420d574..48fa411f1 100644 --- a/app/scripts/components/results.ts +++ b/app/scripts/components/results.ts @@ -2,18 +2,24 @@ import angular, { IController } from "angular" import { html } from "@/util" import "@/services/searches" -import "@/components/dynamic_tabs/compare-tabs" -import "@/components/dynamic_tabs/graph-tabs" -import "@/components/dynamic_tabs/kwic-tabs" -import "@/components/dynamic_tabs/map-tabs" -import "@/components/dynamic_tabs/text-tabs" import "@/components/korp-error" import "@/components/kwic" +import "@/components/loglike-meter" +import "@/components/result-map" import "@/components/statistics" import "@/components/sidebar" +import "@/components/trend-diagram" import "@/components/word-picture" +import "@/controllers/comparison_controller" +import "@/controllers/example_controller" +import "@/controllers/kwic_controller" +import "@/controllers/statistics_controller" +import "@/controllers/trend_diagram_controller" +import "@/controllers/text_reader_controller" +import "@/controllers/word_picture_controller" import "@/directives/tab-hash" import "@/directives/tab-preloader" +import "@/directives/tab-spinner" import { SearchesService } from "@/services/searches" type ResultsController = IController & { @@ -22,14 +28,18 @@ type ResultsController = IController & { hasResult: () => boolean } +// This huge component was previously split so that each type of dynamic tabs had its own directive. +// They had to be directives and not components, because components always wrap their template in a tag (e.g. ...), and uib-tabset needs uib-tab as immediate children. +// But we're converting directives to components in preparation for exiting AngularJS. angular.module("korpApp").component("results", { template: html`
- KWIC + KWIC +
+ - {{'statistics' | loc:$root.lang}} + + {{'statistics' | loc:$root.lang}} + - - - - - + + + + KWIC + + + +
+ +
+
+ + + + {{'graph' | loc:$root.lang}} +
+ +
+ +
+ + + + {{'compare_vb' | loc:$root.lang}} + + +
+ +
+

{{'compare_distinctive' | loc:$root.lang}} {{cmp1.label}}

+
    +
  • + +
  • +
+
+
+

{{'compare_distinctive' | loc:$root.lang}} {{cmp2.label}}

+
    +
  • + +
  • +
+
+
+
+ + + + {{ 'map' | loc:$root.lang}} + + +
+ +
+
+
+ +
+ + Σ +
+
+ +
+
+ +
+
+
+ + + + {{ 'text_tab_header' | loc:$root.lang}} + + +
+ +
+
+
+
+ void @@ -15,7 +15,7 @@ type CompareCtrlScope = IScope & { error: boolean loading: boolean max: number - promise: JQuery.Promise + promise: CompareTab resultOrder: (item: CompareItem) => number reduce: string[] rowClick: (row: CompareItem, cmp_index: number) => void diff --git a/app/scripts/controllers/example_controller.ts b/app/scripts/controllers/example_controller.ts index f47d13831..4504cd98e 100644 --- a/app/scripts/controllers/example_controller.ts +++ b/app/scripts/controllers/example_controller.ts @@ -55,7 +55,7 @@ class ExampleCtrl extends KwicCtrl { s.corpusHits = undefined s.aborted = false - s.tabindex = s.$parent.$parent.$parent.tabset.tabs.length - 1 + s.$index + s.tabindex = s.$parent.$parent.tabset.tabs.length - 1 + s.$index s.newDynamicTab() @@ -157,7 +157,7 @@ class ExampleCtrl extends KwicCtrl { } s.isActive = () => { - return s.tabindex == s.$parent.$parent.$parent.tabset.active + return s.tabindex == s.$parent.$parent.tabset.active } if (s.kwicTab.queryParams) { diff --git a/app/scripts/controllers/map_controller.ts b/app/scripts/controllers/map_controller.ts index a85883a22..6ba46b5fe 100644 --- a/app/scripts/controllers/map_controller.ts +++ b/app/scripts/controllers/map_controller.ts @@ -3,7 +3,7 @@ import _ from "lodash" import angular, { IScope, ITimeoutService } from "angular" import settings from "@/settings" import { regescape } from "@/util" -import { RootScope } from "@/root-scope.types" +import { MapTab, RootScope } from "@/root-scope.types" import { AppSettings } from "@/settings/app-settings.types" import { MapRequestResult } from "@/services/backend" import { MapResult, Point } from "@/map_services" @@ -17,7 +17,7 @@ type MapControllerScope = IScope & { loading: boolean numResults: number useClustering: boolean - promise: Promise + promise: MapTab restColor: string newDynamicTab: any // TODO Defined in tabHash (services.js) closeDynamicTab: any // TODO Defined in tabHash (services.js) diff --git a/app/scripts/controllers/trend_diagram_controller.ts b/app/scripts/controllers/trend_diagram_controller.ts index 816f2a4df..f252e9a0e 100644 --- a/app/scripts/controllers/trend_diagram_controller.ts +++ b/app/scripts/controllers/trend_diagram_controller.ts @@ -1,9 +1,10 @@ /** @format */ -import { RootScope } from "@/root-scope.types" +import { GraphTab, RootScope } from "@/root-scope.types" import angular, { IScope } from "angular" type GraphCtrlScope = IScope & { closeTab: (idx: number, e: Event) => void + data: GraphTab loading: boolean onProgress: (progress: number) => void progress: number diff --git a/app/scripts/root-scope.types.ts b/app/scripts/root-scope.types.ts index da04ebe79..5013eecb1 100644 --- a/app/scripts/root-scope.types.ts +++ b/app/scripts/root-scope.types.ts @@ -1,10 +1,11 @@ /** @format */ -import { IDeferred, IRootScopeService } from "angular" +import { IDeferred, IPromise, IRootScopeService } from "angular" import { Settings } from "./settings/settings.types" import { LangLocMap, LocLangMap } from "@/i18n/types" import { KorpQueryRequestOptions } from "./backend/kwic-proxy" import { CqpQuery } from "./cqp_parser/cqp.types" import { CorpusListing } from "./corpus_listing" +import { CompareResult, MapRequestResult } from "./services/backend" /** Extends the Angular Root Scope interface with properties used by this app. */ export type RootScope = IRootScopeService & { @@ -14,11 +15,11 @@ export type RootScope = IRootScopeService & { globalFilterDef: IDeferred searchtabs: any simpleCQP?: string - kwicTabs: KwicTab[] - compareTabs: {}[] + compareTabs: CompareTab[] graphTabs: GraphTab[] - mapTabs: {}[] - textTabs: {}[] + kwicTabs: KwicTab[] + mapTabs: MapTab[] + textTabs: TextTab[] waitForLogin: boolean jsonUrl?: string lang: string @@ -32,10 +33,7 @@ export type RootScope = IRootScopeService & { }) => void } -export type KwicTab = { - queryParams: KorpQueryRequestOptions - readingMode?: boolean -} +export type CompareTab = IPromise export type GraphTab = { cqp: string @@ -45,6 +43,13 @@ export type GraphTab = { corpusListing: CorpusListing } +export type KwicTab = { + queryParams: KorpQueryRequestOptions + readingMode?: boolean +} + +export type MapTab = IPromise + export type TextTab = { corpus: string sentenceData: Record