@sassoftware/vi-api 0.0.29 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/LICENSE.txt +333 -0
  2. package/README.md +9 -0
  3. package/alert-reps/index.d.ts +5 -1
  4. package/api-init.service.js +86 -0
  5. package/api.module.js +72 -0
  6. package/component/bindings.d.ts +5 -3
  7. package/component/component-api.service.js +161 -0
  8. package/config/config-api.d.ts +2 -1
  9. package/config/config-api.service.js +54 -0
  10. package/control/control-api.d.ts +21 -9
  11. package/control/data-types.d.ts +6 -1
  12. package/control/page.d.ts +14 -0
  13. package/control/toolbar-property-api.d.ts +2 -1
  14. package/current-user/currentUser-api.service.js +49 -0
  15. package/event/event-api.d.ts +1 -0
  16. package/event/event-api.js +1 -0
  17. package/event/event-api.service.js +32 -0
  18. package/file/file-api.service.js +24 -0
  19. package/http/http-api.service.js +64 -0
  20. package/localization/localization-api.service.js +38 -0
  21. package/metadata/admin/admin-metadata-api.service.js +30 -0
  22. package/metadata/metadata-api.d.ts +3 -0
  23. package/metadata/metadata-api.service.js +85 -0
  24. package/object/object-api.d.ts +9 -20
  25. package/object/object-api.service.js +207 -0
  26. package/package.json +24 -2
  27. package/page-admin/page-admin-api.service.js +25 -0
  28. package/page-model/page-model-api.d.ts +21 -13
  29. package/page-model/page-model-api.service.js +25 -0
  30. package/page-state/page-state-api.d.ts +23 -0
  31. package/page-state/page-state-api.service.js +70 -0
  32. package/property/property-api.d.ts +62 -2
  33. package/property/property-api.service.js +34 -0
  34. package/reference-data/refData.service.js +40 -0
  35. package/resource/resource-api.service.js +24 -0
  36. package/score-reps/index.d.ts +1 -1
  37. package/search/client/client-search-api.d.ts +8 -4
  38. package/search/client/client-search-api.js +1 -1
  39. package/search/client/client-search-api.service.js +111 -0
  40. package/search/search-api.d.ts +6 -6
  41. package/search/search-api.service.js +28 -0
  42. package/sheet/network-menu-handler.service.js +39 -0
  43. package/sheet/sheet-api.d.ts +35 -3
  44. package/sheet/sheet-api.js +9 -1
  45. package/sheet/sheet-api.service.js +140 -0
  46. package/svi-datahub/index.d.ts +203 -171
  47. package/svi-sand/index.d.ts +10 -10
  48. package/tab/tab-api.service.js +35 -0
  49. package/theme/theme-api.d.ts +1 -1
  50. package/theme/theme-api.js +1 -1
  51. package/theme/theme-api.service.js +35 -0
  52. package/time-slider/index.d.ts +6 -0
  53. package/traversal/traversal-api.d.ts +7 -1
  54. package/traversal/traversal-api.service.js +77 -0
  55. package/alert-reps/package.json +0 -5
  56. package/component/package.json +0 -9
  57. package/config/package.json +0 -9
  58. package/control/package.json +0 -9
  59. package/current-user/package.json +0 -9
  60. package/event/package.json +0 -9
  61. package/file/package.json +0 -9
  62. package/http/package.json +0 -9
  63. package/localization/package.json +0 -9
  64. package/metadata/package.json +0 -9
  65. package/object/package.json +0 -9
  66. package/page-admin/package.json +0 -9
  67. package/page-model/package.json +0 -9
  68. package/page-state/package.json +0 -9
  69. package/property/package.json +0 -9
  70. package/reference-data/package.json +0 -9
  71. package/resource/package.json +0 -9
  72. package/score-reps/package.json +0 -5
  73. package/search/package.json +0 -9
  74. package/sheet/package.json +0 -9
  75. package/svi-datahub/package.json +0 -5
  76. package/svi-sand/package.json +0 -5
  77. package/tab/package.json +0 -9
  78. package/theme/package.json +0 -9
  79. package/traversal/package.json +0 -9
@@ -1,5 +1,6 @@
1
+ import { ResourcedString } from "../svi-datahub";
1
2
  import { Control } from "../control/page";
2
- import { TypeAttributes } from "../object/object-api";
3
+ import { ChildNode, TypeAttributes } from "../object/object-api";
3
4
  import { PageTemplateMetadata } from "../page-model/page-model-api";
4
5
  export interface ToolbarPropertyControl {
5
6
  typeAttributes: TypeAttributes;
@@ -7,8 +8,37 @@ export interface ToolbarPropertyControl {
7
8
  export interface PropertyConfig {
8
9
  [property: string]: any;
9
10
  order?: number;
10
- required?: boolean;
11
11
  type: string;
12
+ displayName: ResourcedString;
13
+ required?: boolean | string;
14
+ localizable?: boolean | string;
15
+ allowMultiple?: boolean | string;
16
+ states?: Record<string, boolean>;
17
+ defaultValue?: any;
18
+ disabledExpression?: string;
19
+ picklistName?: string;
20
+ ignoreRestrictions?: boolean;
21
+ }
22
+ export interface SelectedNode {
23
+ id: number;
24
+ node: ChildNode;
25
+ parentNode?: ChildNode;
26
+ parentSubDocument: string;
27
+ dataSources?: {
28
+ [property: string]: any;
29
+ };
30
+ }
31
+ /**
32
+ * This API is available on property editors.
33
+ */
34
+ export interface EditorApi {
35
+ /**
36
+ * Registers a function to be invoked whenever one of the editor's properties changes.
37
+ * @method
38
+ * @param handler The function to be invoked.
39
+ * @returns A function that stops the handler from being invoked.
40
+ */
41
+ onPropertyChange(handler: (category: string, property: string, currentValue: any, previousValue: any) => void): () => void;
12
42
  }
13
43
  /**
14
44
  * This API provides the utility or miscellaneous functionality in SAS Visual Investigator.
@@ -27,6 +57,36 @@ export interface PropertyApi {
27
57
  * @param [metadataFn] {PropertyApi~getPropertyEditorMetadata} Function to provide custom metadata.
28
58
  */
29
59
  registerCustomEditor(elementName: string, type: string, validatorFn?: (propertyConfig: PropertyConfig, propertyKey: string, control: Control | ToolbarPropertyControl) => boolean, metadataFn?: (propertyConfig: PropertyConfig, propertyKey: string, control: Control | ToolbarPropertyControl) => PageTemplateMetadata): void;
60
+ /**
61
+ * @method
62
+ * @description Determines whether or not the child object data source property editor is valid.
63
+ * Typically passed as a function reference to registerCustomEditor() instead of being called directly.
64
+ * @param {PropertyConfig} propertyConfig Configuration details relating to the property type. For example, required, type and so on.
65
+ * @param {string} propertyKey Key where this property's value is stored.
66
+ * @param {Control | ToolbarPropertyControl} control The control.
67
+ * @example
68
+ * window.sas.vi.property.registerCustomEditor(
69
+ * name,
70
+ * type,
71
+ * window.sas.vi.property.validateChildObjectDataSource,
72
+ * window.sas.vi.property.getChildObjectMetadata)
73
+ */
74
+ validateChildObjectDataSource(propertyConfig: PropertyConfig, propertyKey: string, control: Control): boolean | undefined;
75
+ /**
76
+ * @method
77
+ * @description Get metadata for the child object data source property editor.
78
+ * Typically passed as a function reference to registerCustomEditor() instead of being called directly.
79
+ * @param {PropertyConfig} propertyConfig Configuration details relating to the property type. For example, required, type and so on.
80
+ * @param {string} propertyKey Key where this property's value is stored.
81
+ * @param {Control | ToolbarPropertyControl} control The control.
82
+ * @example
83
+ * window.sas.vi.property.registerCustomEditor(
84
+ * name,
85
+ * type,
86
+ * window.sas.vi.property.validateChildObjectDataSource,
87
+ * window.sas.vi.property.getChildObjectMetadata)
88
+ */
89
+ getChildObjectMetadata(propertyConfig: PropertyConfig, propertyKey: string, control: Control): PageTemplateMetadata | undefined;
30
90
  }
31
91
  /**
32
92
  * Determines whether or not the property editor is valid.
@@ -0,0 +1,34 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Injectable } from "@angular/core";
8
+ import { getAngularJsInjectable } from "../../commons/angular-angularjs-utils";
9
+ let PropertyApiService = class PropertyApiService {
10
+ constructor() {
11
+ this.propertyEditorConfigService = () => getAngularJsInjectable("spbPropertyEditorService");
12
+ this.dataSourceValidatorService = () => getAngularJsInjectable("spbDataSourceValidatorService");
13
+ this.registerCustomEditor = (selector, type, validatorFn, metadataFn) => {
14
+ this.propertyEditorConfigService().registerCustomEditor(selector, type, validatorFn, metadataFn);
15
+ };
16
+ this.validateChildObjectDataSource = (propertyConfig, propertyKey, control) => {
17
+ return this.dataSourceValidatorService().validateSubDocumentDataSource(propertyConfig, propertyKey, control);
18
+ };
19
+ this.getChildObjectMetadata = (propertyConfig, propertyKey, control) => {
20
+ return this.dataSourceValidatorService().getSubDocumentMetadata(propertyConfig, propertyKey, control);
21
+ };
22
+ }
23
+ getApi() {
24
+ return {
25
+ registerCustomEditor: this.registerCustomEditor,
26
+ validateChildObjectDataSource: this.validateChildObjectDataSource,
27
+ getChildObjectMetadata: this.getChildObjectMetadata
28
+ };
29
+ }
30
+ };
31
+ PropertyApiService = __decorate([
32
+ Injectable()
33
+ ], PropertyApiService);
34
+ export { PropertyApiService };
@@ -0,0 +1,40 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Injectable } from "@angular/core";
8
+ import { getAngularJsInjectable, promiseWrap } from "../../commons/angular-angularjs-utils";
9
+ let RefDataApiService = class RefDataApiService {
10
+ constructor() {
11
+ this.referenceDataAdmin = () => getAngularJsInjectable("fdhReferenceDataAdmin");
12
+ this.getReferenceLists = () => {
13
+ return this.referenceDataAdmin().getReferenceLists();
14
+ };
15
+ this.getReferenceHierarchies = () => {
16
+ return this.referenceDataAdmin().getReferenceHierarchies();
17
+ };
18
+ this.getReferenceListByName = (name, includeArchived) => {
19
+ // Negating includeArchived as referenceDataAdmin.getListByName handles this opposite to getHierarchyByName.
20
+ const promise = this.referenceDataAdmin().getListByName(name, !includeArchived);
21
+ return promise.catch(error => Promise.reject(error?.data?.message));
22
+ };
23
+ this.getReferenceHierarchyByName = (name, includeArchived) => {
24
+ const promise = this.referenceDataAdmin().getHierarchyByName(name, includeArchived);
25
+ return promise.catch(error => Promise.reject(error?.data?.message));
26
+ };
27
+ }
28
+ getApi() {
29
+ return {
30
+ getReferenceLists: promiseWrap(this.getReferenceLists),
31
+ getReferenceHierarchies: promiseWrap(this.getReferenceHierarchies),
32
+ getReferenceList: promiseWrap(this.getReferenceListByName),
33
+ getReferenceHierarchy: promiseWrap(this.getReferenceHierarchyByName)
34
+ };
35
+ }
36
+ };
37
+ RefDataApiService = __decorate([
38
+ Injectable()
39
+ ], RefDataApiService);
40
+ export { RefDataApiService };
@@ -0,0 +1,24 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Injectable } from "@angular/core";
8
+ let ResourceApiService = class ResourceApiService {
9
+ constructor(resourceService) {
10
+ this.resourceService = resourceService;
11
+ this.registerResourceBundle = (bundleName, resources) => {
12
+ this.resourceService.addResourceBundle(bundleName, resources);
13
+ };
14
+ }
15
+ getApi() {
16
+ return {
17
+ registerResourceBundle: this.registerResourceBundle
18
+ };
19
+ }
20
+ };
21
+ ResourceApiService = __decorate([
22
+ Injectable()
23
+ ], ResourceApiService);
24
+ export { ResourceApiService };
@@ -1,6 +1,6 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- // Generated using typescript-generator version 2.15.527 on 2022-01-30 09:29:49.
3
+ // Generated using typescript-generator version 2.15.527 on 2023-01-24 10:52:36.
4
4
 
5
5
  export interface BaseRep extends TrackedResource {
6
6
  links?: Link[];
@@ -12,7 +12,7 @@ export declare enum Visualization {
12
12
  Map = "map",
13
13
  Table = "table",
14
14
  Timeline = "timeline",
15
- Network = "network"
15
+ Network = "networkDiagram"
16
16
  }
17
17
  export declare type MapFilter = MapBoundedPolygonFilter | MapRadiusFilter | MapBoundedBoxFilter | MapShapeFilter;
18
18
  export interface SearchQuery {
@@ -39,6 +39,7 @@ export interface NetworkData {
39
39
  showTransactionDetails?: boolean;
40
40
  showTransactionLinks?: boolean;
41
41
  };
42
+ numNodes: number;
42
43
  }
43
44
  export interface ResolvedObjectIdentifier extends ObjectIdentifier {
44
45
  compoundValues: string[];
@@ -50,6 +51,10 @@ export interface SearchAndCreateDialogModel {
50
51
  relateToParentLabel?: string;
51
52
  canCreate?: boolean;
52
53
  linkReasons?: Relationship[];
54
+ /**
55
+ * Values returned on the close of the dialog. May be undefined when dialog is cancelled.
56
+ */
57
+ result?: SearchAndCreateResponse;
53
58
  }
54
59
  export interface SearchObject extends ObjectIdentifier {
55
60
  title?: string;
@@ -152,8 +157,7 @@ export interface ClientSearchApi extends SearchApi {
152
157
  * @description Launches a wizard allowing users to search first, before creating an object/relationship.
153
158
  * Relationship wizard is determined by relateToParentLabel or relateToParentName being defined within the wizardValues parameter.
154
159
  * @param wizardValues {SearchAndCreateDialogModel} Object containing entity and relationship data.
155
- * @param [onRelationshipSuccess] {function} A callback function that is defined when creating a relationship.
156
- * It is invoked when a relationship is saved successfully.
160
+ * @returns {Promise<SearchAndCreateDialogModel>} A promise resolving
157
161
  */
158
- openSearchAndCreateDialog(wizardValues: SearchAndCreateDialogModel, onRelationshipSuccess?: () => void): Promise<SearchAndCreateResponse>;
162
+ openSearchAndCreateDialog(wizardValues: SearchAndCreateDialogModel): Promise<SearchAndCreateDialogModel>;
159
163
  }
@@ -10,5 +10,5 @@ export var Visualization;
10
10
  Visualization["Map"] = "map";
11
11
  Visualization["Table"] = "table";
12
12
  Visualization["Timeline"] = "timeline";
13
- Visualization["Network"] = "network";
13
+ Visualization["Network"] = "networkDiagram";
14
14
  })(Visualization || (Visualization = {}));
@@ -0,0 +1,111 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Injectable } from "@angular/core";
8
+ import { each } from "lodash-es";
9
+ import { getAngularJsInjectable } from "../../../commons/angular-angularjs-utils";
10
+ import { SEARCH_SELECTION_ID, VisualizationTypes } from "../../../sand/search/search";
11
+ import { zoneWrap } from "../../../commons/api-utils";
12
+ let ClientSearchApiService = class ClientSearchApiService {
13
+ constructor(ngZone, searchApiService, sandRestService, sandDoSearchService, sandSearchStorageService, sandMetadataService, sandDocumentInfoService, searchAndCreateWizardService) {
14
+ this.ngZone = ngZone;
15
+ this.searchApiService = searchApiService;
16
+ this.sandRestService = sandRestService;
17
+ this.sandDoSearchService = sandDoSearchService;
18
+ this.sandSearchStorageService = sandSearchStorageService;
19
+ this.sandMetadataService = sandMetadataService;
20
+ this.sandDocumentInfoService = sandDocumentInfoService;
21
+ this.searchAndCreateWizardService = searchAndCreateWizardService;
22
+ this.performSearch = (query) => {
23
+ return new Promise(resolve => {
24
+ this.sandRestService.search(query).subscribe(result => {
25
+ resolve(result);
26
+ });
27
+ });
28
+ };
29
+ this.navigateSearch = (queryText, visualizationName, mapFilters, queryMode) => {
30
+ this.sandDoSearchService.doSearch(queryText, visualizationName, mapFilters, queryMode);
31
+ };
32
+ this.getCurrentSearchQuery = () => {
33
+ return this.sandSearchStorageService.getCurrentSearchQuery();
34
+ };
35
+ this.createQueryStringFromModel = (queryModel) => {
36
+ const sandQueryBuilderQueryService = getAngularJsInjectable("sandQueryBuilderQueryService");
37
+ return this.sandMetadataService
38
+ .getMetadata()
39
+ .toPromise()
40
+ .then(metadata => {
41
+ return sandQueryBuilderQueryService.createQueryStringFromModel(queryModel, metadata);
42
+ });
43
+ };
44
+ this.getQueryBuilderModel = (id) => {
45
+ if (!id) {
46
+ id = SEARCH_SELECTION_ID;
47
+ }
48
+ return this.sandSearchStorageService.getQueryBuilderModel(id);
49
+ };
50
+ this.setQueryBuilderModel = (queryModel, id) => {
51
+ if (!id) {
52
+ id = SEARCH_SELECTION_ID;
53
+ }
54
+ this.sandSearchStorageService.saveQueryBuilderModel(id, queryModel);
55
+ };
56
+ this.openAddObjectsToWorkspaceDialog = (visualizationName, objects, currentObject, networkData) => {
57
+ this.sandDocumentSelectionDialogService = getAngularJsInjectable("sandDocumentSelectionDialogService");
58
+ this.sandDocumentSelectionDialogService.openAddAllObjectsToWorkspaceDialog(visualizationName, currentObject, objects, networkData);
59
+ };
60
+ this.openAddImageToInsightsDialog = (imageData, contentType, height, width) => {
61
+ this.sandDocumentSelectionDialogService = getAngularJsInjectable("sandDocumentSelectionDialogService");
62
+ this.sandDocumentSelectionDialogService.openAddImageToInsightDialog(VisualizationTypes.Image, imageData, height ?? undefined, width ?? undefined, contentType);
63
+ };
64
+ this.addToNewWorkspace = (objectsToAdd, targetObjectType, targetObjectId, visualization, workspaceName, networkData) => {
65
+ const worksheetService = getAngularJsInjectable("worksheetService");
66
+ const sheetService = getAngularJsInjectable("sheetService");
67
+ each(objectsToAdd, object => {
68
+ this.sandDocumentInfoService.createUniqueKey(object);
69
+ });
70
+ const targetObject = {
71
+ id: targetObjectId,
72
+ type: targetObjectType,
73
+ objectType: targetObjectType,
74
+ isNewDocument: targetObjectId ? false : true
75
+ };
76
+ if (!targetObject.isNewDocument && !sheetService.getOpenDocument(targetObject.id, targetObject.type)) {
77
+ throw Error(`Cannot add objects to workspace. Object of type ${targetObject.type} and id ${targetObject.id} is not open.`);
78
+ }
79
+ else {
80
+ worksheetService.addToSheet(targetObject, undefined, objectsToAdd, visualization, networkData, workspaceName);
81
+ }
82
+ };
83
+ this.openSearchAndCreateDialog = (wizardValues) => {
84
+ const values = {
85
+ ...wizardValues,
86
+ searchFirst: true,
87
+ initialCreateData: null
88
+ };
89
+ return this.searchAndCreateWizardService.launch(values).closeResult.toPromise();
90
+ };
91
+ }
92
+ getApi() {
93
+ return {
94
+ ...this.searchApiService.getApi(),
95
+ performSearch: this.performSearch,
96
+ navigateSearch: zoneWrap(this.navigateSearch, this.ngZone),
97
+ getCurrentSearchQuery: this.getCurrentSearchQuery,
98
+ createQueryStringFromModel: this.createQueryStringFromModel,
99
+ getQueryBuilderModel: this.getQueryBuilderModel,
100
+ setQueryBuilderModel: this.setQueryBuilderModel,
101
+ openAddObjectsToWorkspaceDialog: zoneWrap(this.openAddObjectsToWorkspaceDialog, this.ngZone),
102
+ openAddImageToInsightsDialog: zoneWrap(this.openAddImageToInsightsDialog, this.ngZone),
103
+ addToNewWorkspace: zoneWrap(this.addToNewWorkspace, this.ngZone),
104
+ openSearchAndCreateDialog: zoneWrap(this.openSearchAndCreateDialog, this.ngZone)
105
+ };
106
+ }
107
+ };
108
+ ClientSearchApiService = __decorate([
109
+ Injectable()
110
+ ], ClientSearchApiService);
111
+ export { ClientSearchApiService };
@@ -1,12 +1,12 @@
1
1
  export interface QueryBuilderItem {
2
2
  booleanValue?: boolean | string;
3
3
  boost?: number;
4
- dateTimeValue?: string;
5
- dateValue?: string;
4
+ dateTimeValue?: string | Date;
5
+ dateValue?: string | Date;
6
6
  exclude?: boolean;
7
7
  field?: string;
8
- fromDateTimeValue?: string;
9
- fromDateValue?: string;
8
+ fromDateTimeValue?: string | Date;
9
+ fromDateValue?: string | Date;
10
10
  fromNumericValue?: number;
11
11
  numericValue?: number;
12
12
  operator?: string;
@@ -22,8 +22,8 @@ export interface QueryBuilderItem {
22
22
  stringValidationError?: boolean;
23
23
  synonym?: boolean;
24
24
  textValue?: string;
25
- toDateTimeValue?: string;
26
- toDateValue?: string;
25
+ toDateTimeValue?: string | Date;
26
+ toDateValue?: string | Date;
27
27
  toNumericValue?: number;
28
28
  userGroupValue?: Array<{
29
29
  id: string;
@@ -0,0 +1,28 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Injectable } from "@angular/core";
8
+ import { zoneWrap } from "../../commons/api-utils";
9
+ let SearchApiService = class SearchApiService {
10
+ constructor(sandQueryBuilderDialogService, ngZone) {
11
+ this.sandQueryBuilderDialogService = sandQueryBuilderDialogService;
12
+ this.ngZone = ngZone;
13
+ this.openQueryBuilderDialog = (dialogTitle, submitButtonText, queryModel, enforceObjectType, restrictObjectTypes) => {
14
+ return this.sandQueryBuilderDialogService
15
+ .openQueryBuilderDialog(queryModel, dialogTitle, submitButtonText, enforceObjectType, restrictObjectTypes)
16
+ .toPromise();
17
+ };
18
+ }
19
+ getApi() {
20
+ return {
21
+ openQueryBuilderDialog: zoneWrap(this.openQueryBuilderDialog, this.ngZone)
22
+ };
23
+ }
24
+ };
25
+ SearchApiService = __decorate([
26
+ Injectable()
27
+ ], SearchApiService);
28
+ export { SearchApiService };
@@ -0,0 +1,39 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Injectable } from "@angular/core";
8
+ /**
9
+ * This service is an intermediary between the client API and the Network.
10
+ * It keeps a record of network menu handlers registered via the client API.
11
+ */
12
+ let NetworkMenuHandlerService = class NetworkMenuHandlerService {
13
+ constructor() {
14
+ this.networkMenuHandlers = new Map();
15
+ }
16
+ /**
17
+ * Call the registered callback function to modify/extend the context menu
18
+ * @param menuType The type of menu
19
+ * @param menu The menu object to be modified
20
+ * @param workspaceClientId The Client ID of the current workspace
21
+ */
22
+ extendNetworkContextMenu(menuType, menu, workspaceClientId) {
23
+ this.networkMenuHandlers.get(menuType)?.(menu, workspaceClientId);
24
+ }
25
+ /**
26
+ * Register a callback function for the given menu type
27
+ * @param menuType The type of menu: Node or Network
28
+ * @param callback The callback function
29
+ */
30
+ registerNetworkMenuCallback(menuType, callback) {
31
+ this.networkMenuHandlers.set(menuType, callback);
32
+ }
33
+ };
34
+ NetworkMenuHandlerService = __decorate([
35
+ Injectable({
36
+ providedIn: "root"
37
+ })
38
+ ], NetworkMenuHandlerService);
39
+ export { NetworkMenuHandlerService };
@@ -27,15 +27,35 @@ export interface SheetApi {
27
27
  */
28
28
  getOpenObjectBySheet(sheet: ClientSheet): VIObject | undefined;
29
29
  /**
30
+ * @deprecated use {@link registerNetworkMenuCallback} instead.
30
31
  * @method
31
- * @description Creates and returns the list containing all Context Menu Items for a right-click on a network diagram node.
32
+ * @description Deprecated. This function is deprecated and replaced with registerNetworkMenuCallback. The original
33
+ * function did not allow users to extend the menu being constructed by a context click.
34
+ *
35
+ * Creates and returns the list containing all Context Menu Items for a right-click on a network diagram node.
32
36
  * The menu is not rendered on the network diagram.
33
- * @param workspace {ClientSheet} Workspace containing the network.
37
+ * @param workspace {ClientSheet} Workspace containing the network. The workspace should not be manually constructed.
34
38
  * @param handleAddToWorkspaceFn {function} A callback to handle adding the selected nodes to a Workspace.
35
39
  * @param handleAddToInsightsFn {function} A callback to handle adding the NLD to an Insight.
36
40
  * @returns Promise resolving to the list containing all Context Menu Items.
37
41
  */
38
- createContextMenuForNodes(workspace: ClientSheet, handleAddToWorkspaceFn: () => void, handleAddToInsightsFn: () => void): Promise<ContextMenuItem[]>;
42
+ createContextMenuForNodes(workspace: ClientSheet, handleAddToWorkspaceFn?: () => void, handleAddToInsightsFn?: () => void): Promise<ContextMenuItem[]>;
43
+ /**
44
+ * @method
45
+ * @description Registers a callback that is invoked whenever the node or network context menu is constructed.
46
+ * The caller can extend the menu to provide access to extra functionality. It is the caller's responsibility
47
+ * to ensure that they properly extend the menu. Failing to do so can result in application errors.
48
+ *
49
+ * The callback can be unregistered by calling this function without passing in a callback function
50
+ * or setting it to undefined.
51
+ *
52
+ * @param menuType {NetworkMenuType} The type of menu to extend.
53
+ * @param callback {NetworkMenuCallback} The callback function invoked when the context menu is constructed.
54
+ * This function is passed the menu object, which can be modified/extended, and the "client Id" of the current workspace.
55
+ * If callback not passed in or is undefined, the callback is unregistered.
56
+ * @returns void
57
+ */
58
+ registerNetworkMenuCallback(menuType: NetworkMenuType, callback?: NetworkMenuCallback): void;
39
59
  /**
40
60
  * @method
41
61
  * @description Adds objects to a workspace selected in the "Add Objects to Workspace" dialog box.
@@ -182,3 +202,15 @@ export interface ClientSheet extends Sheet {
182
202
  clientId: string;
183
203
  document: ObjectSheetSettings;
184
204
  }
205
+ /**
206
+ * The set of menu types which can be extended
207
+ * via the registerNetworkMenuCallback function.
208
+ */
209
+ export declare enum NetworkMenuType {
210
+ NetworkContext = "networkContext",
211
+ NodeContext = "nodeContext"
212
+ }
213
+ /**
214
+ * The type of function that can be registered as a callback for modifying the Network menus.
215
+ */
216
+ export declare type NetworkMenuCallback = (menu: ContextMenuItem, workspaceClientId: string) => void;
@@ -1 +1,9 @@
1
- export {};
1
+ /**
2
+ * The set of menu types which can be extended
3
+ * via the registerNetworkMenuCallback function.
4
+ */
5
+ export var NetworkMenuType;
6
+ (function (NetworkMenuType) {
7
+ NetworkMenuType["NetworkContext"] = "networkContext";
8
+ NetworkMenuType["NodeContext"] = "nodeContext";
9
+ })(NetworkMenuType || (NetworkMenuType = {}));
@@ -0,0 +1,140 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Injectable } from "@angular/core";
8
+ import { each } from "lodash-es";
9
+ import { getAngularJsInjectable } from "../../commons/angular-angularjs-utils";
10
+ import { VisualizationTypes } from "../../sand/search/search";
11
+ import { zoneWrap } from "../../commons/api-utils";
12
+ let SheetApiService = class SheetApiService {
13
+ constructor(networkMenuHandlerService, ngZone, notificationService, resourceService, sandDocumentInfoService) {
14
+ this.networkMenuHandlerService = networkMenuHandlerService;
15
+ this.ngZone = ngZone;
16
+ this.notificationService = notificationService;
17
+ this.resourceService = resourceService;
18
+ this.sandDocumentInfoService = sandDocumentInfoService;
19
+ this.getOpenObject = (objectId, objectType) => {
20
+ this.sheetService = getAngularJsInjectable("sheetService");
21
+ return this.sheetService.getOpenDocument(objectId, objectType) ?? undefined;
22
+ };
23
+ this.getOpenObjects = () => {
24
+ this.sheetService = getAngularJsInjectable("sheetService");
25
+ return this.sheetService.getOpenDocuments();
26
+ };
27
+ this.getOpenObjectBySheet = (sheet) => {
28
+ const worksheetService = getAngularJsInjectable("worksheetService");
29
+ return worksheetService.getCurrentDocument(sheet);
30
+ };
31
+ this.createContextMenuForNodes = (workspace, handleAddToWorkspaceFn, handleAddToInsightsFn) => {
32
+ return workspace.networkDiagramComponent.framework.view.constructNodeContextMenu(handleAddToWorkspaceFn, handleAddToInsightsFn).items;
33
+ };
34
+ this.registerNetworkMenuCallback = (menuType, callback) => {
35
+ this.networkMenuHandlerService.registerNetworkMenuCallback(menuType, callback);
36
+ };
37
+ this.openAddAllObjectsToWorkspaceDialog = (objects, options) => {
38
+ this.sandDocumentSelectionDialogService = getAngularJsInjectable("sandDocumentSelectionDialogService");
39
+ this.sandDocumentSelectionDialogService.openAddAllObjectsToWorkspaceDialog(options?.visualizationName, options?.currentObject, objects, options?.networkData);
40
+ };
41
+ this.openAddImageToInsightsDialog = (imageData, contentType = "image/png", height, width) => {
42
+ this.sandDocumentSelectionDialogService = getAngularJsInjectable("sandDocumentSelectionDialogService");
43
+ if (imageData instanceof Uint8Array) {
44
+ this.sandDocumentSelectionDialogService.openAddImageToInsightDialog(VisualizationTypes.Image, imageData, height, width, contentType);
45
+ }
46
+ else {
47
+ const util = getAngularJsInjectable("Util");
48
+ return this.imgToB64(imageData).then((image) => {
49
+ const imageBlob = util.b64toBlob(image);
50
+ this.sandDocumentSelectionDialogService.openAddImageToInsightDialog(VisualizationTypes.Image, imageBlob, undefined, undefined, contentType);
51
+ });
52
+ }
53
+ };
54
+ /**
55
+ * Creates an HTML canvas for the img element.
56
+ * Generates a new unscaled image based on the original image source.
57
+ * If there is an error loading the new image, an error alert is displayed.
58
+ *
59
+ * @param element {HTMLElement} Element containing the image.
60
+ * @returns {Promise<string>} A Promise which resolves to the Base64 string representing the image.
61
+ * @ignore
62
+ */
63
+ this.imgToB64 = (element) => {
64
+ const canvasElement = document.createElement("canvas");
65
+ const canvasContext = canvasElement.getContext("2d");
66
+ return new Promise(resolve => {
67
+ if (canvasContext) {
68
+ const originalImageElement = element.querySelector("img");
69
+ const unscaledImage = new Image();
70
+ unscaledImage.crossOrigin = "Anonymous";
71
+ unscaledImage.onload = () => {
72
+ canvasElement.width = unscaledImage.width;
73
+ canvasElement.height = unscaledImage.height;
74
+ // An intermittent issue in IE11 means we use a timeout to move the drawimage out
75
+ // of the current execution
76
+ // https://stackoverflow.com/questions/25214395/unexpected-call-to-method-or-property-access-while-
77
+ // drawing-svg-image-onto-canvas
78
+ setTimeout(() => {
79
+ canvasContext.drawImage(unscaledImage, 0, 0, unscaledImage.width, unscaledImage.height);
80
+ resolve(canvasElement.toDataURL());
81
+ canvasElement.remove();
82
+ });
83
+ };
84
+ unscaledImage.onerror = () => {
85
+ this.notificationService.alertError(this.resourceService.get("spb.images.addToWorkspaceError.title"), this.resourceService.get("spb.images.addToWorkspaceError.txt"));
86
+ canvasElement.remove();
87
+ };
88
+ unscaledImage.src = originalImageElement.src;
89
+ }
90
+ });
91
+ };
92
+ this.addToNewWorkspace = (objectsToAdd, targetObjectType, options) => {
93
+ const worksheetService = getAngularJsInjectable("worksheetService");
94
+ const sheetService = getAngularJsInjectable("sheetService");
95
+ each(objectsToAdd, object => {
96
+ this.sandDocumentInfoService.createUniqueKey(object);
97
+ });
98
+ const targetObject = {
99
+ id: options?.targetObjectId,
100
+ type: targetObjectType,
101
+ objectType: targetObjectType,
102
+ isNewDocument: !options?.targetObjectId
103
+ };
104
+ if (!targetObject.isNewDocument &&
105
+ targetObject.id &&
106
+ !sheetService.getOpenDocument(targetObject.id, targetObject.type)) {
107
+ console.warn(`Cannot add objects to workspace. Object of type ${targetObject.type} and id ${targetObject.id} is not open.`);
108
+ }
109
+ else {
110
+ worksheetService.addToSheet(targetObject, undefined, objectsToAdd, options?.visualization, options?.networkData, options?.workspaceName);
111
+ }
112
+ };
113
+ this.addToExistingWorkspace = (targetObject, workspaceClientId, objectsToAdd, networkData, isUndoRedo) => {
114
+ const worksheetService = getAngularJsInjectable("worksheetService");
115
+ each(objectsToAdd, object => {
116
+ this.sandDocumentInfoService.createUniqueKey(object);
117
+ });
118
+ worksheetService.addToExistingWorksheet(targetObject, workspaceClientId, objectsToAdd, true, networkData, isUndoRedo);
119
+ };
120
+ }
121
+ getApi() {
122
+ return {
123
+ getOpenObject: this.getOpenObject,
124
+ getOpenObjects: this.getOpenObjects,
125
+ getOpenObjectBySheet: this.getOpenObjectBySheet,
126
+ createContextMenuForNodes: zoneWrap(this.createContextMenuForNodes, this.ngZone),
127
+ registerNetworkMenuCallback: zoneWrap(this.registerNetworkMenuCallback, this.ngZone),
128
+ openAddAllObjectsToWorkspaceDialog: zoneWrap(this.openAddAllObjectsToWorkspaceDialog, this.ngZone),
129
+ openAddImageToInsightsDialog: zoneWrap(this.openAddImageToInsightsDialog, this.ngZone),
130
+ addToExistingWorkspace: zoneWrap(this.addToExistingWorkspace, this.ngZone),
131
+ addToNewWorkspace: zoneWrap(this.addToNewWorkspace, this.ngZone)
132
+ };
133
+ }
134
+ };
135
+ SheetApiService = __decorate([
136
+ Injectable({
137
+ providedIn: "root"
138
+ })
139
+ ], SheetApiService);
140
+ export { SheetApiService };