repo_name
string
dataset
string
owner
string
lang
string
func_name
string
code
string
docstring
string
url
string
sha
string
biome-vscode
github_2023
biomejs
typescript
promptVersionToDownload
const promptVersionToDownload = async () => { debug("Prompting user to select Biome version to download"); // Get the list of versions const compileItems = async (): Promise<QuickPickItem[]> => { const downloadedVersion = (await getDownloadedVersion())?.version; // Get the list of available versions const availableVersions = await getAllVersions(false); return availableVersions.map((version, index) => { return { label: version, description: index === 0 ? "(latest)" : "", detail: downloadedVersion === version ? "(currently installed)" : "", alwaysShow: index < 3, }; }); }; return window.showQuickPick(compileItems(), { title: "Select Biome version to download", placeHolder: "Select Biome version to download", }); };
/** * Prompts the user to select which versions of the Biome CLI to download * * This function will display a QuickPick dialog to the user, allowing them to * select which versions of the Biome CLI they would like to download. Versions * that have already been downloaded will be pre-selected. */
https://github.com/biomejs/biome-vscode/blob/c146d1bf9bdcec376706114d76abdb11d7e9005e/src/downloader.ts#L121-L148
c146d1bf9bdcec376706114d76abdb11d7e9005e
biome-vscode
github_2023
biomejs
typescript
compileItems
const compileItems = async (): Promise<QuickPickItem[]> => { const downloadedVersion = (await getDownloadedVersion())?.version; // Get the list of available versions const availableVersions = await getAllVersions(false); return availableVersions.map((version, index) => { return { label: version, description: index === 0 ? "(latest)" : "", detail: downloadedVersion === version ? "(currently installed)" : "", alwaysShow: index < 3, }; }); };
// Get the list of versions
https://github.com/biomejs/biome-vscode/blob/c146d1bf9bdcec376706114d76abdb11d7e9005e/src/downloader.ts#L125-L142
c146d1bf9bdcec376706114d76abdb11d7e9005e
biome-vscode
github_2023
biomejs
typescript
registerUserFacingCommands
const registerUserFacingCommands = () => { state.context.subscriptions.push( commands.registerCommand("biome.start", startCommand), commands.registerCommand("biome.stop", stopCommand), commands.registerCommand("biome.restart", restartCommand), commands.registerCommand("biome.download", downloadCommand), commands.registerCommand("biome.reset", resetCommand), ); info("User-facing commands registered"); };
/** * Registers the extension's user-facing commands. */
https://github.com/biomejs/biome-vscode/blob/c146d1bf9bdcec376706114d76abdb11d7e9005e/src/extension.ts#L48-L58
c146d1bf9bdcec376706114d76abdb11d7e9005e
biome-vscode
github_2023
biomejs
typescript
listenForConfigurationChanges
const listenForConfigurationChanges = () => { const debouncedConfigurationChangeHandler = debounce( (event: ConfigurationChangeEvent) => { if (event.affectsConfiguration("biome")) { info("Configuration change detected."); if (!["restarting", "stopping"].includes(state.state)) { restart(); } } }, ); state.context.subscriptions.push( workspace.onDidChangeConfiguration(debouncedConfigurationChangeHandler), ); info("Started listening for configuration changes"); };
/** * Listens for configuration changes * * This function sets up a listener for configuration changes in the `biome` * namespace. When a configuration change is detected, the extension is * restarted to reflect the new configuration. */
https://github.com/biomejs/biome-vscode/blob/c146d1bf9bdcec376706114d76abdb11d7e9005e/src/extension.ts#L67-L84
c146d1bf9bdcec376706114d76abdb11d7e9005e
biome-vscode
github_2023
biomejs
typescript
listenForActiveTextEditorChange
const listenForActiveTextEditorChange = () => { state.context.subscriptions.push( window.onDidChangeActiveTextEditor((editor) => { updateActiveProject(editor); }), ); info("Started listening for active text editor changes"); updateActiveProject(window.activeTextEditor); };
/** * Listens for changes to the active text editor * * This function listens for changes to the active text editor and updates the * active project accordingly. This change is then reflected throughout the * extension automatically. Notably, this triggers the status bar to update * with the active project. */
https://github.com/biomejs/biome-vscode/blob/c146d1bf9bdcec376706114d76abdb11d7e9005e/src/extension.ts#L94-L104
c146d1bf9bdcec376706114d76abdb11d7e9005e
biome-vscode
github_2023
biomejs
typescript
listenForLockfilesChanges
const listenForLockfilesChanges = () => { const watcher = workspace.createFileSystemWatcher( "**/{package-lock.json,yarn.lock,bun.lockb,bun.lock,pnpm-lock.yaml}", ); watcher.onDidChange((event) => { info(`Lockfile ${event.fsPath} changed.`); restart(); }); watcher.onDidCreate((event) => { info(`Lockfile ${event.fsPath} created.`); restart(); }); watcher.onDidDelete((event) => { info(`Lockfile ${event.fsPath} deleted.`); restart(); }); info("Started listening for lockfile changes"); state.context.subscriptions.push(watcher); };
/** * Listens for changes to lockfiles in the workspace * * We use this watcher to detect changes to lockfiles and restart the extension * when they occur. We currently rely on this strategy to detect if Biome has been * installed or updated in the workspace until VS Code provides a better way to * detect this. */
https://github.com/biomejs/biome-vscode/blob/c146d1bf9bdcec376706114d76abdb11d7e9005e/src/extension.ts#L114-L137
c146d1bf9bdcec376706114d76abdb11d7e9005e
biome-vscode
github_2023
biomejs
typescript
doStart
const doStart = async () => { try { await createProjectSessions(); await createGlobalSessionWhenNecessary(); } catch (e) { error("Failed to start Biome extension"); state.state = "error"; } };
/** * Runs the startup logic */
https://github.com/biomejs/biome-vscode/blob/c146d1bf9bdcec376706114d76abdb11d7e9005e/src/lifecycle.ts#L47-L55
c146d1bf9bdcec376706114d76abdb11d7e9005e
biome-vscode
github_2023
biomejs
typescript
doStop
const doStop = async () => { // If we end up here following a configuration change, we need to wait // for the notification to be processed before we can stop the LSP session, // otherwise we will get an error. This is a workaround for a race condition // that occurs when the configuration change notification is sent while the // LSP session is already stopped. await new Promise((resolve) => setTimeout(resolve, 1000)); if (state.globalSession) { destroySession(state.globalSession); } for (const session of state.sessions.values()) { await destroySession(session); } state.sessions.clear(); };
/** * Runs the shutdown logic */
https://github.com/biomejs/biome-vscode/blob/c146d1bf9bdcec376706114d76abdb11d7e9005e/src/lifecycle.ts#L60-L77
c146d1bf9bdcec376706114d76abdb11d7e9005e
biome-vscode
github_2023
biomejs
typescript
createProject
const createProject = async ({ folder, path, configFile, }: { folder?: WorkspaceFolder; path: Uri; configFile?: Uri; }): Promise<Project | undefined> => { return { folder: folder, path: path, configFile: configFile, }; };
/** * Creates a new Biome project * * This function creates a new Biome project and automatically resolves the * path to the Biome binary in the context of the project. * * @param folder The parent workspace folder of the project * @param path The URI of the project directory, relative to the workspace folder * @param configFile The URI of the project's Biome configuration file */
https://github.com/biomejs/biome-vscode/blob/c146d1bf9bdcec376706114d76abdb11d7e9005e/src/project.ts#L50-L64
c146d1bf9bdcec376706114d76abdb11d7e9005e
biome-vscode
github_2023
biomejs
typescript
createWorkspaceFolderProjects
const createWorkspaceFolderProjects = async (folder: WorkspaceFolder) => { // If Biome is disabled in the workspace folder, we skip project creation // entirely for that workspace folder. if (!isEnabled(folder)) { return []; } // Retrieve the project definitions in the workspace folder's configuration // or fall back to a default project definition which references the workspace // folder itself. let projectDefinitions = getProjectDefinitions(folder, [ { folder: folder.name, path: "/", }, ]); // Only consider project definitions that have a matching workspace folder projectDefinitions = projectDefinitions.filter((project) => { // If the project definition does not specify a workspace folder, as would // be the case when the project definitions have been specified in the // workspace folder's configuration, we consider it to be valid. if (!project.folder) { return true; } // If the project definition specifies a workspace folder, we only consider // it valid if the workspace folder name matches. This is the case when the // project definition has been specified at the workspace level. return project.folder === folder.name; }); // Filter out project definitions whose path does not exist on disk const definitionsOnDisk = await Promise.all( projectDefinitions.map(async (definition) => { const existsOnDisk = await directoryExists( Uri.joinPath(folder.uri, definition.path), ); if (!existsOnDisk) { warn( `Project directory ${Uri.joinPath(folder.uri, definition.path)} does not exist on disk, skipping project creation.`, ); } return existsOnDisk; }), ); projectDefinitions = projectDefinitions.filter( (_, index) => definitionsOnDisk[index], ); // Filter out project definitions for which the configuration file does not // exist if they require one. const definitionsWithConfigFileIfRequired = await Promise.all( projectDefinitions.map(async (definition) => { const configFileExists = await configFileExistsIfRequired( folder, definition, ); if (!configFileExists) { warn( `Project ${Uri.joinPath(folder.uri, definition.path)} requires a configuration file that does not exist, skipping project creation.`, ); } return configFileExists; }), ); projectDefinitions = projectDefinitions.filter( (_, index) => definitionsWithConfigFileIfRequired[index], ); // At this point, we have a list of project definitions that are valid and // can be created, so we create projects for them. const projects: Project[] = []; for (const projectDefinition of projectDefinitions) { const fullPath = Uri.joinPath(folder.uri, projectDefinition.path); const configFileURI = projectDefinition.configFile ? Uri.joinPath(folder.uri, projectDefinition.configFile) : undefined; projects.push( await createProject({ folder: folder, path: fullPath, configFile: configFileURI, }), ); } return projects; };
/** * Detects projects in the given workspace folder * * This function will detect projects in the given workspace folder by looking * for project definitions in the workspace folder's configuration. If no project * definitions are found, it will create a single project at the root of the * workspace folder. * * Project definitions that reference workspace folders that do not exist will * be ignored, as will project definitions that do not have a configuration file * if they require one. */
https://github.com/biomejs/biome-vscode/blob/c146d1bf9bdcec376706114d76abdb11d7e9005e/src/project.ts#L144-L236
c146d1bf9bdcec376706114d76abdb11d7e9005e
biome-vscode
github_2023
biomejs
typescript
copyBinaryToTemporaryLocation
const copyBinaryToTemporaryLocation = async ( bin: Uri, ): Promise<Uri | undefined> => { // Retrieve the the version of the binary // We call biome with --version which outputs the version in the format // of "Version: 1.0.0" const version = spawnSync(bin.fsPath, ["--version"]) .stdout.toString() .split(":")[1] .trim(); const location = Uri.joinPath( state.context.globalStorageUri, "tmp-bin", generatePlatformSpecificVersionedBinaryName(version), ); try { await workspace.fs.createDirectory( Uri.joinPath(state.context.globalStorageUri, "tmp-bin"), ); if (!(await fileExists(location))) { info("Copying binary to temporary location.", { original: bin.fsPath, destination: location.fsPath, }); copyFileSync(bin.fsPath, location.fsPath); debug("Copied Biome binary binary to temporary location.", { original: bin.fsPath, temporary: location.fsPath, }); } else { debug( `A Biome binary for the same version ${version} already exists in the temporary location.`, { original: bin.fsPath, temporary: location.fsPath, }, ); } const isExecutableBefore = fileIsExecutable(bin); chmodSync(location.fsPath, 0o755); const isExecutableAfter = fileIsExecutable(bin); debug("Ensure binary is executable", { binary: bin.fsPath, before: `is executable: ${isExecutableBefore}`, after: `is executable: ${isExecutableAfter}`, }); return location; } catch (error) { return undefined; } };
/** * Copies the binary to a temporary location if necessary * * This function will copy the binary to a temporary location if it is not already * present in the global storage directory. It will then return the location of * the copied binary. * * This approach allows the user to update the original binary that would otherwise * be locked if we ran the binary directly from the original location. * * Binaries copied in the temp location are uniquely identified by their name and version * identifier. */
https://github.com/biomejs/biome-vscode/blob/c146d1bf9bdcec376706114d76abdb11d7e9005e/src/session.ts#L91-L147
c146d1bf9bdcec376706114d76abdb11d7e9005e
biome-vscode
github_2023
biomejs
typescript
createLanguageClient
const createLanguageClient = (bin: Uri, project?: Project) => { let args = ["lsp-proxy"]; if (project?.configFile) { args = [...args, "--config-path", project.configFile.fsPath]; } const serverOptions: ServerOptions = { command: bin.fsPath, transport: TransportKind.stdio, options: { ...(project?.path && { cwd: project.path.fsPath }), }, args, }; const clientOptions: LanguageClientOptions = { outputChannel: createLspLogger(project), traceOutputChannel: createLspTraceLogger(project), documentSelector: createDocumentSelector(project), progressOnInitialization: true, initializationFailedHandler: (e): boolean => { logError("Failed to initialize the Biome language server", { error: e.toString(), }); return false; }, errorHandler: { error: ( error, message, count, ): ErrorHandlerResult | Promise<ErrorHandlerResult> => { logError("Biome language server error", { error: error.toString(), stack: error.stack, errorMessage: error.message, message: message?.jsonrpc, count: count, }); return { action: ErrorAction.Shutdown, message: "Biome language server error", }; }, closed: (): CloseHandlerResult | Promise<CloseHandlerResult> => { debug("Biome language server closed"); return { action: CloseAction.DoNotRestart, message: "Biome language server closed", }; }, }, initializationOptions: { rootUri: project?.path, rootPath: project?.path?.fsPath, }, workspaceFolder: undefined, }; return new BiomeLanguageClient( "biome.lsp", "biome", serverOptions, clientOptions, ); };
/** * Creates a new Biome LSP client */
https://github.com/biomejs/biome-vscode/blob/c146d1bf9bdcec376706114d76abdb11d7e9005e/src/session.ts#L221-L289
c146d1bf9bdcec376706114d76abdb11d7e9005e
biome-vscode
github_2023
biomejs
typescript
createLspLogger
const createLspLogger = (project?: Project): LogOutputChannel => { // If the project is missing, we're creating a logger for the global LSP // session. In this case, we don't have a workspace folder to display in the // logger name, so we just use the display name of the extension. if (!project?.folder) { return window.createOutputChannel( `${displayName} LSP (global session)`, { log: true, }, ); } // If the project is present, we're creating a logger for a specific project. // In this case, we display the name of the project and the relative path to // the project root in the logger name. Additionally, when in a multi-root // workspace, we prefix the path with the name of the workspace folder. const prefix = operatingMode === "multi-root" ? `${project.folder.name}::` : ""; const path = subtractURI(project.path, project.folder.uri).fsPath; return window.createOutputChannel(`${displayName} LSP (${prefix}${path})`, { log: true, }); };
/** * Creates a new Biome LSP logger */
https://github.com/biomejs/biome-vscode/blob/c146d1bf9bdcec376706114d76abdb11d7e9005e/src/session.ts#L294-L318
c146d1bf9bdcec376706114d76abdb11d7e9005e
biome-vscode
github_2023
biomejs
typescript
createLspTraceLogger
const createLspTraceLogger = (project?: Project): LogOutputChannel => { // If the project is missing, we're creating a logger for the global LSP // session. In this case, we don't have a workspace folder to display in the // logger name, so we just use the display name of the extension. if (!project?.folder) { return window.createOutputChannel( `${displayName} LSP trace (global session)`, { log: true, }, ); } // If the project is present, we're creating a logger for a specific project. // In this case, we display the name of the project and the relative path to // the project root in the logger name. Additionally, when in a multi-root // workspace, we prefix the path with the name of the workspace folder. const prefix = operatingMode === "multi-root" ? `${project.folder.name}::` : ""; const path = subtractURI(project.path, project.folder.uri).fsPath; return window.createOutputChannel( `${displayName} LSP trace (${prefix}${path})`, { log: true, }, ); };
/** * Creates a new Biome LSP logger */
https://github.com/biomejs/biome-vscode/blob/c146d1bf9bdcec376706114d76abdb11d7e9005e/src/session.ts#L323-L350
c146d1bf9bdcec376706114d76abdb11d7e9005e
biome-vscode
github_2023
biomejs
typescript
createDocumentSelector
const createDocumentSelector = (project?: Project): DocumentFilter[] => { if (project) { return supportedLanguageIdentifiers.map((language) => ({ language, scheme: "file", pattern: Uri.joinPath(project.path, "**", "*").fsPath.replaceAll( "\\", "/", ), })); } return supportedLanguageIdentifiers.flatMap((language) => { return ["untitled", "vscode-userdata"].map((scheme) => ({ language, scheme, })); }); };
/** * Creates a new document selector * * This function will create a document selector scoped to the given project, * which will only match files within the project's root directory. If no * project is specified, the document selector will match files that have * not yet been saved to disk (untitled). */
https://github.com/biomejs/biome-vscode/blob/c146d1bf9bdcec376706114d76abdb11d7e9005e/src/session.ts#L360-L378
c146d1bf9bdcec376706114d76abdb11d7e9005e
UTMStack
github_2023
utmstack
typescript
AdTreeComponent.select
select(item: ActiveDirectoryTreeType) { // (item.type === 'USER' || item.type === 'GROUP' || item.type === 'GROUP') && if (item.children.length === 0) { this.itemView = item.id; this.selected.emit(item.objectSid); this.treeObjectBehavior.changeUser(item); } }
/** * Check tree object if user or group to trigger behavior; * @param item Receive select node in tree */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/active-directory/shared/components/active-directory-tree/active-directory-tree.component.ts#L170-L177
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
AdTreeComponent.deployAll
deployAll(item: TreeItem) { this.deployed.push(item.id); for (const it of item.children) { const index = this.deployed.findIndex(value => value === it.id); if (index === -1) { this.deployed.push(it.id); } if (it.children.length > 0) { this.deployAll(it); } } }
// deploy all children in tree when search
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/active-directory/shared/components/active-directory-tree/active-directory-tree.component.ts#L232-L243
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
AdViewComponent.addToTracking
addToTracking() { const modalAddTracking = this.modalService.open(AdTrackerCreateComponent, {centered: true}); modalAddTracking.componentInstance.targetTracking = [{ name: this.adInfo.cn, id: this.adInfo.objectSid, type: resolveType(this.adInfo.objectClass), isAdmin: this.adInfo.adminCount !== null, objectSid: this.adInfo.objectSid }]; }
/*getInfo() { const req = { 'objectSid.equals': this.object, page: 1, size: 50 }; this.activeDirectoryService.query(req).subscribe(object => { if (object.body) { this.adInfo = object.body[0]; } }); }*/
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/active-directory/view/active-directory-view/active-directory-view.component.ts#L86-L95
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
SourcesService.findAllSources
findAllSources(): Observable<HttpResponse<ISource[]>> { return this.http.get<ISource[]>(`${this.resourceUrl}`, {observe: 'response'}); }
/** * Get all alert sources */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/admin/sources/sources.service.ts#L20-L22
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
UtmHealthService.addHealthObject
private addHealthObject(result, isLeaf, healthObject, name): any { const healthData: any = { name }; const details = {}; let hasDetails = false; for (const key in healthObject) { if (healthObject.hasOwnProperty(key)) { const value = healthObject[key]; if (key === 'status' || key === 'error') { healthData[key] = value; } else { if (!this.isHealthObject(value)) { details[key] = value; hasDetails = true; } } } } // Add the details if (hasDetails) { healthData.details = details; } // Only add nodes if they provide additional information if (isLeaf || hasDetails || healthData.error) { result.push(healthData); } return healthData; }
/* private methods */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/app-management/health-checks/health-checks.service.ts#L50-L82
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
IntLdapGroupsComponent.saveConfig
saveConfig() { // this.saving = true; // console.log(this.integrationConfig); // this.utmIntConfigManageService.saveConfig(this.integrationConfig, JSON.stringify(this.group.value)).subscribe(saved => { // if (saved) { // this.toastService.showSuccessBottom('Configuration saved successfully'); // this.saving = false; // } else { // this.saving = false; // this.toastService.showError('Error', 'Error saving configuration, go to application logs for more details'); // } // }); }
// }
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/app-module/conf/int-ldap-groups/int-ldap-groups.component.ts#L79-L91
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
GuideSalesforceComponent.generateDockerCommand
generateDockerCommand(): string { const formData = this.salesforceForm.value; return ` mkdir -p /utmstack/sforceds && docker run --restart=always --name sforceds ` + `-e "clientID=${formData.clientID}" ` + `-e "clientSecret=<secret>${formData.clientSecret}</secret>" ` + `-e "username=${formData.username}" ` + `-e "password=<secret>${formData.password}</secret>" ` + `-e "securityToken=<secret>${formData.securityToken}</secret>" ` + `-e "instanceUrl=${formData.instanceUrl}" ` + `-e "LS_JAVA_OPTS=-Xms1g -Xmx1g -Xss100m" ` + `-v /utmstack/sforceds/:/local_storage ` + `--log-driver json-file --log-opt max-size=10m ` + `--log-opt max-file=3 -d utmstack.azurecr.io/sforceds:v9`; }
// --log-opt max-file=3 -d utmstack.azurecr.io/sforceds:v9
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/app-module/guides/guide-salesforce/guide-salesforce.component.ts#L47-L60
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
AssetsViewComponent.ngOnInit
ngOnInit() { this.setInitialWidth(); this.getAssets(); this.starInterval(); this.accountService.identity().then(account => { this.reasonRun = { command: '', reason: '', originId: account.login, originType: IncidentOriginTypeEnum.USER_EXECUTION }; }); }
// Init get asset on time filter component trigger
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/assets-discover/assets-view/assets-view.component.ts#L93-L106
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
CollectorsViewComponent.ngOnInit
ngOnInit() { this.setInitialWidth(); this.getCollectors(); this.starInterval(); this.accountService.identity().then(account => { this.reasonRun = { command: '', reason: '', originId: account.login, originType: IncidentOriginTypeEnum.USER_EXECUTION }; }); }
// Init get asset on time filter component trigger
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/assets-discover/collectors-view/collectors-view.component.ts#L90-L103
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
UtmNetScanService.create
create(asset: any): Observable<HttpResponse<NetScanType>> { return this.http.post<NetScanType>(this.resourceUrl + '/saveOrUpdateCustomAsset', asset, {observe: 'response'}); }
// POST /api/utm-network-scans/saveOrUpdateCustomAsset
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/assets-discover/shared/services/utm-net-scan.service.ts#L31-L33
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
PaginationConfig.constructor
constructor(private config: NgbPaginationConfig) { config.boundaryLinks = true; config.maxSize = 5; config.pageSize = ITEMS_PER_PAGE; config.size = 'sm'; }
// tslint:disable-next-line: no-unused-variable
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/blocks/config/uib-pagination.config.ts#L9-L14
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
ManageHttpInterceptor.filterRequest
filterRequest(route: string): boolean { return BYPASS_ROUTES.findIndex(value => route.includes(value)) !== -1; }
/** * Determine if cancel request or not on page request * @param route Current route */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/blocks/interceptor/managehttp.interceptor.ts#L29-L31
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
HttpCancelService.cancelPendingRequests
public cancelPendingRequests() { this.pendingHTTPRequests$.next(); }
// Cancel Pending HTTP calls
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/blocks/service/httpcancel.service.ts#L13-L15
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
ComplianceResultViewComponent.getTemplate
getTemplate() { if (this.reportId) { this.cpReportsService.find(this.reportId).subscribe(response => { this.report = response.body; if (this.report.dashboardId) { this.loadVisualizations(this.report.dashboardId); } }); } }
/** * Return template */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/compliance/compliance-result-view/compliance-result-view.component.ts#L139-L148
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
UtmReportInfoViewComponent.deleteSection
deleteSection(index: number) { this.complianceReports.splice(index, 1); this.complianceReportsChange.emit(this.complianceReports); }
// }
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/compliance/shared/components/utm-report-info-view/utm-report-info-view.component.ts#L40-L43
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
CpReportsService.queryByStandard
queryByStandard(req?: any): Observable<HttpResponse<ComplianceReportType[]>> { const options = createRequestOption(req); return this.http.get<ComplianceReportType[]>(this.resourceUrl + '/get-by-filters', { params: options, observe: 'response' }); }
// GET /api/compliance/report-config/get-by-report
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/compliance/shared/services/cp-reports.service.ts#L60-L66
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
CpStandardSectionService.queryWithReports
queryWithReports(req?: any): Observable<HttpResponse<ComplianceStandardSectionType[]>> { const options = createRequestOption(req); return this.http.get<ComplianceStandardSectionType[]>(this.resourceUrl + '/sections-with-reports', { params: options, observe: 'response' }); }
// GET /api/compliance/standard-section/sections-with-reports
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/compliance/shared/services/cp-standard-section.service.ts#L45-L51
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
ComplianceExportComponent.getTemplate
getTemplate() { this.cpReportsService.find(this.reportId).subscribe(response => { this.report = response.body; if (this.report.dashboardId) { this.loadVisualizations(this.report.dashboardId); } }); }
/** * Return template */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/dashboard/compliance-export/compliance-export.component.ts#L143-L150
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
DashboardOverviewComponent.exportToPdf
exportToPdf() { this.spinner.show('buildPrintPDF').then(() => { const params = this.filterTime ? `?filterTime=${encodeURIComponent(JSON.stringify(this.filterTime))}` : ''; const url = `/dashboard/overview${params}`; this.exportPdfService.getPdf(url, 'Dashboard_Overview', 'PDF_TYPE_TOKEN'). subscribe(response => { this.spinner.hide('buildPrintPDF').then(() => { this.pdfExport = false; this.exportPdfService.handlePdfResponse(response); }); }, error => { this.spinner.hide('buildPrintPDF').then(() => { this.utmToastService.showError('Error', 'An error occurred while creating a PDF.'); }); }); }); }
/*exportToPdf() { this.pdfExport = true; // captureScreen('utmDashboardAlert').then((finish) => { // this.pdfExport = false; // }); setTimeout(() => { window.print(); }, 1000); } */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/dashboard/dashboard-overview/dashboard-overview.component.ts#L213-L232
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
DashboardOverviewComponent.synchronizeFields
synchronizeFields() { this.accountService.identity(true).then(value => { if (value) { this.indexPatternService.queryWithFields({page: 0, size: 2000, 'isActive.equals': true}) .pipe( map(response => response.body)) .subscribe((values: UtmIndexPatternFields[]) => { values.forEach(value => { if (value.fields && value.fields.length > 0) { this.localFieldService.setPatternStoredFields(value.indexPattern, value.fields); } }); }); } }); }
/** * Sync field in local storage from index service */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/dashboard/dashboard-overview/dashboard-overview.component.ts#L240-L255
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
ReportExportComponent.getTemplate
getTemplate() { this.reportsService.find(this.reportId).subscribe(response => { this.report = response.body; if (this.report.dashboardId) { this.loadVisualizations(this.report.dashboardId); } }); }
/** * Return template */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/dashboard/report-export/report-export.component.ts#L103-L110
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
SaveAlertReportComponent.constructor
constructor(public activeModal: NgbActiveModal, // private accountService: AccountService, private reportService: AlertReportService, private utmToastService: UtmToastService, private elasticDataExportService: ElasticDataExportService, ) { }
// private user: User;
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/data-management/alert-management/alert-reports/shared/components/save-report/save-report.component.ts#L33-L39
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
SaveAlertReportComponent.applyLimit
applyLimit(limit) { this.limit = limit; }
// }
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/data-management/alert-management/alert-reports/shared/components/save-report/save-report.component.ts#L69-L71
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
AlertViewComponent.resolveDataType
resolveDataType(): Promise<EventDataTypeEnum> { return new Promise<EventDataTypeEnum>(resolve => { const indexOfIsIncident = this.filters.findIndex(value => value.field === ALERT_INCIDENT_FLAG_FIELD && value.operator === ElasticOperatorsEnum.IS); const indexOfIsAlert = this.filters.findIndex(value => value.field === EVENT_IS_ALERT && value.operator === ElasticOperatorsEnum.IS); if (indexOfIsIncident !== -1) { resolve(EventDataTypeEnum.INCIDENT); } else if (indexOfIsAlert !== -1) { resolve(EventDataTypeEnum.ALERT); } else { resolve(EventDataTypeEnum.EVENT); } }); }
/** * Return EventDataTypeEnum based on filters * Check if exist any incident field with operator IS, if exist return INCIDENT * Check if exist any isAlert field with operator IS, if exist return ALERT * else return EVENT */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/data-management/alert-management/alert-view/alert-view.component.ts#L240-L254
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
AlertViewComponent.resolveFieldByDataTypeEnum
resolveFieldByDataTypeEnum(type: EventDataTypeEnum) { switch (type) { case EventDataTypeEnum.ALERT: return EVENT_IS_ALERT; case EventDataTypeEnum.EVENT: return null; case EventDataTypeEnum.INCIDENT: return ALERT_INCIDENT_FLAG_FIELD; } }
/** * Resolve field based on EventDataTypeEnum * @param type EventDataTypeEnum */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/data-management/alert-management/alert-view/alert-view.component.ts#L260-L270
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
AlertViewComponent.setDefaultParams
setDefaultParams() { const indexTime = this.filters.findIndex(value => value.field === ALERT_TIMESTAMP_FIELD); if (indexTime !== -1) { this.defaultTime = new ElasticFilterDefaultTime(this.filters[indexTime].value[0], this.filters[indexTime].value[1]); } else { this.defaultTime = new ElasticFilterDefaultTime('now-7d', 'now'); } this.getCurrentStatus(); this.getAlert('on set default params'); this.updateStatusServiceBehavior.$updateStatus.next(true); this.alertFiltersBehavior.$filters.next(this.filters); }
/** * After merge filter set default values to params new values */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/data-management/alert-management/alert-view/alert-view.component.ts#L275-L286
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
AlertViewComponent.getCurrentStatus
getCurrentStatus(): number { return getCurrentAlertStatus(this.filters); }
/** * Return current status value from filter */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/data-management/alert-management/alert-view/alert-view.component.ts#L291-L293
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
AlertRulesService.query
query(query: any): Observable<HttpResponse<AlertRuleType[]>> { const options = createRequestOption(query); return this.http.get<AlertRuleType[]>(this.resourceUrl , {params: options, observe: 'response'}); }
/** * Find alert-rules by filters */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/data-management/alert-management/shared/services/alert-rules.service.ts#L22-L25
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
AlertRulesService.delete
delete(id: number): Observable<HttpResponse<any>> { return this.http.delete(`${this.resourceUrl}/${id}`, {observe: 'response'}); }
/** * Delete a rule */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/data-management/alert-management/shared/services/alert-rules.service.ts#L30-L32
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
BucketAggregationComponent.changeFieldTextToKeyword
changeFieldTextToKeyword($event, index: number) { if ($event.type === ElasticDataTypesEnum.TEXT) { this.buckets.at(index).get('field').setValue($event.name + '.keyword'); } }
// }
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/graphic-builder/chart-builder/chart-property-builder/bucket-aggregation/bucket-aggregation.component.ts#L203-L207
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
BucketAggregationComponent.buildBucketObject
private buildBucketObject(): MetricBucketsType { const arr: MetricBucketsType[] = this.buckets.value ? this.buckets.value : []; if (arr.length > 1) { for (let i = 0; i < arr.length; i++) { if (arr[i + 1] !== undefined) { arr[i].subBucket = arr[i + 1]; } } } return arr[0]; }
/** * Build object bucket hierarchical */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/graphic-builder/chart-builder/chart-property-builder/bucket-aggregation/bucket-aggregation.component.ts#L234-L244
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
GoalPropertiesOptionComponent.ngOnInit
ngOnInit() { this.initFormGoalOption(); this.metricDataBehavior.$metricDeletedId.subscribe(id => { const indexOption = this.options.controls.findIndex(value => value.get('goalId').value === id); if (indexOption > -1) { this.deleteOption(indexOption); } }); this.metricDataBehavior.$metric.subscribe(m => { this.metrics = m; this.extractDataGoal(); }); if (this.mode === 'edit') { if (typeof this.visualization.chartConfig === 'string') { this.visualization.chartConfig = JSON.parse(this.visualization.chartConfig); } // this.extractGoalOptionEdit(); } this.formGoalOption.valueChanges.subscribe((value) => { this.goalOptions.emit(this.formGoalOption.get('options').value); }); this.goalOptions.emit(this.formGoalOption.get('options').value); }
// }
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/graphic-builder/chart-builder/chart-property-builder/charts/goal-properties-option/goal-properties-option.component.ts#L49-L75
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
ListColumnsComponent.buildBucketObject
private buildBucketObject(): MetricBucketsType { const arr: MetricBucketsType[] = this.columns.value ? this.columns.value : []; if (arr.length > 1) { for (let i = 0; i < arr.length; i++) { if (arr[i + 1] !== undefined) { arr[i].subBucket = arr[i + 1]; } } } return arr[0]; }
/** * Build object bucket hierarchical */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/graphic-builder/chart-builder/chart-property-builder/list-columns/list-columns.component.ts#L135-L145
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
DashboardCreateComponent.getVisualizationToAdd
getVisualizationToAdd(id: number): Promise<boolean> { return new Promise<boolean>(resolve => { this.visualizationService.find(id).subscribe(response => { // call method to select visualization to avoid conflict and code repetition this.onVisSelected([response.body], true); }); resolve(true); }); }
/** * After get callback from created visualization need to add to current layout dasboard * @param id Visualization ID */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/graphic-builder/dashboard-builder/dashboard-create/dashboard-create.component.ts#L144-L152
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
DashboardCreateComponent.orderLayout
orderLayout() { let gr = this.gridsterItems.toArray(); gr = gr.sort((a, b) => { return a.item.y - b.item.y || a.item.x - b.item.x; }); return gr; }
/** * sort array by y and x position */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/graphic-builder/dashboard-builder/dashboard-create/dashboard-create.component.ts#L200-L206
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
DashboardCreateComponent.onVisSelected
onVisSelected($event: VisualizationType[], override?: boolean) { console.log('EVENT:', $event); for (const vis of $event) { const indexVis = this.layout.findIndex(value => value.visualization.id === vis.id); vis.chartConfig = (typeof vis.chartConfig === 'string' && vis.chartType !== ChartTypeEnum.TEXT_CHART) ? JSON.parse(vis.chartConfig) : vis.chartConfig; this.timeEnable.push(vis.id); if (indexVis === -1) { this.layoutService.addItem(vis); } if (override && indexVis !== -1) { // when edit visualization need override current in layout in order to this, first // the visualization at the same position and then delete the previous one this.layoutService.addItem(vis, this.layout[indexVis].grid); this.deleteVisualization(this.layout[indexVis]); } } }
/** * Add visualization to dashboard layout * @param $event Visualization array * @param override Attribute to determine if override visualization in layout */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/graphic-builder/dashboard-builder/dashboard-create/dashboard-create.component.ts#L216-L233
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
DashboardCreateComponent.deleteVisualization
deleteVisualization(item: { grid: GridsterItem; visualization: VisualizationType }) { if (this.dashboardId) { const index = this.visDashboard.findIndex(value => Number(value.idDashboard) === Number(this.dashboardId) && Number(value.idVisualization) === Number(item.visualization.id)); const visDasId = this.visDashboard[index].id; this.tempDelete.push(visDasId); this.layoutService.deleteItem(item.grid); } else { this.layoutService.deleteItem(item.grid); } }
/** * If editing add id to tempDelete array for delete after save dashboard * @param item Item grid to delete */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/graphic-builder/dashboard-builder/dashboard-create/dashboard-create.component.ts#L281-L291
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
DashboardSaveComponent.getMenuEdit
getMenuEdit() { const query = new QueryType(); query.add('dashboardId', this.dashboard.id, Operator.equals); this.menuService.query(query).subscribe(menus => { if (menus.body.length > 0) { this.idMenu = menus.body[0].id; this.authority = menus.body[0].authorities; this.subMenuName = menus.body[0].name; this.menuId = menus.body[0].parentId; this.menuActive = menus.body[0].menuActive; this.saveToMenu = true; this.asNewMenu = false; } else { this.asNewMenu = true; } }); }
/** * Set menu var if dashboard is already in navigation abr */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/graphic-builder/dashboard-builder/dashboard-save/dashboard-save.component.ts#L121-L137
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
DashboardSaveComponent.creatingVisualizationsRecords
creatingVisualizationsRecords(dashboard: UtmDashboardType): Promise<string> { return new Promise<string>((resolve, reject) => { // for (const item of this.grid) { const promises = []; for (let j = 0; j < this.grid.length; j++) { const item = this.grid[j]; const query = { 'idDashboard.equals': dashboard.id, 'idVisualization.equals': this.getVisualizationId(item), }; this.visualizationToSave = this.getVisualizationName(item); const dasVis: UtmDashboardVisualizationType = { height: item.height, idDashboard: dashboard.id, idVisualization: this.getVisualizationId(item), left: item.item.x, order: j, top: item.item.y, width: item.width, gridInfo: JSON.stringify(item.item), showTimeFilter: this.visTimeEnabled.includes(this.getVisualizationId(item)) }; promises.push(this.insertUpdateVisualizationAsync(query, dasVis)); } Promise.all(promises) .then((results) => { resolve('created'); }) .catch((e) => { // Handle errors here }); }); }
/** * Check in database that relations do not exist to create new one * @param dashboard Dashboard to save */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/graphic-builder/dashboard-builder/dashboard-save/dashboard-save.component.ts#L172-L204
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
ChartViewComponent.forceSingle
forceSingle(): boolean { return (this.visualization.chartType === ChartTypeEnum.BAR_CHART || this.visualization.chartType === ChartTypeEnum.BAR_HORIZONTAL_CHART) && this.data[0].series.length === 1 && (this.visualization.aggregationType.bucket !== null && this.visualization.aggregationType.bucket.subBucket !== null); }
/** * This method return if click navigation behavior will treated as single one */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/graphic-builder/shared/components/viewer/chart-view/chart-view.component.ts#L104-L109
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
ChartViewComponent.onChartChange
onChartChange() { if (typeof this.visualization.chartConfig === 'string') { this.visualization.chartConfig = JSON.parse(this.visualization.chartConfig); } this.echartOption = deleteNullValues(this.chartFactory.createChart( this.chart, this.data, this.visualization, this.exportFormat ) ); }
/** * Build echart object */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/graphic-builder/shared/components/viewer/chart-view/chart-view.component.ts#L132-L143
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
MapViewComponent.onChartChange
onChartChange() { // set center this.mapOption = this.visualization.chartConfig.leaflet; const centerLat = (this.data && this.data.length > 0) ? this.data[0].value[0] : this.mapOption.center[0]; const centerLng = (this.data && this.data.length > 0) ? this.data[0].value[1] : this.mapOption.center[1]; this.map.setView([centerLat, centerLng], this.mapOption.zoom); this.map.panTo([centerLat, centerLng]); this.markersLayer.clearLayers(); if (this.data && this.data.length > 0) { this.data.sort((a, b) => a.value[2] < b.value[2] ? 1 : -1); } if (this.data && this.data.length > 0) { for (const dat of this.data) { const tooltip = '<div style="' + 'white-space: nowrap;' + 'padding-top:10px' + 'font: 13px / 20px Poppins, sans-serif;' + 'pointer-events: none;">' + getBucketLabel(0, this.visualization) + '<br>' + '<span style="display:inline-block;' + 'margin-right:5px;' + 'border-radius:10px;' + 'width:10px;' + 'height:10px;' + 'background-color:#c05050;">' + '</span><strong>' + dat.name + ':</strong> ' + dat.value[2] + '</div>'; const myIcon = new L.Icon({ iconUrl: '/assets/img/red_marker.png', iconSize: [15, 25], iconAnchor: [4, 25], popupAnchor: [4, -30], }); const marker = L.marker([dat.value[0], dat.value[1]], {icon: myIcon}) .bindPopup(tooltip, {className: 'class-popup'}); this.markersLayer.addLayer(marker); marker.on('mouseover', (ev) => { marker.openPopup(); }); marker.on('mouseout', (ev) => { marker.closePopup(); }); marker.on('click', (ev) => { const echartClickAction: EchartClickAction = { data: {name: dat.name} }; if (!this.building) { this.utmChartClickActionService.onClickNavigate(this.visualization, echartClickAction); } }); } } setTimeout(() => { this.map.addLayer(this.markersLayer); this.map.invalidateSize(); }, 1); }
/** * Build echart object */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/graphic-builder/shared/components/viewer/map-view/map-view.component.ts#L145-L210
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
TableViewComponent.processVisNameToCsvName
processVisNameToCsvName(): string { let str = this.visualization.name; str = str.replace(/\W+(?!$)/g, '-').toLowerCase(); str = str.replace(/\W$/, '').toLowerCase(); return str; }
/** * Return clean name for csv based on visualization name */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/graphic-builder/shared/components/viewer/table-view/table-view.component.ts#L340-L345
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
TableViewComponent.processToCsv
processToCsv(): Promise<Array<any[]>> { return new Promise<Array<any[]>>(resolve => { const dataExport: Array<any[]> = []; // First extract columns to set the first element of exported array to csv, this // way get csv headers this.addColumnsToCsv().then(csvHeader => { dataExport.push(csvHeader); // after header as been added process row and extract data this.addRowsToCsv().then(csvRows => { csvRows.forEach(row => { dataExport.push(row); }); }); }); resolve(dataExport); }); }
/** * Process current data to csv */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/graphic-builder/shared/components/viewer/table-view/table-view.component.ts#L350-L366
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
TableViewComponent.addRowsToCsv
addRowsToCsv(): Promise<any[]> { return new Promise<any[]>(resolve => { const rows: any[] = []; this.data.rows.forEach((rowsData) => { this.convertRowTableTypeToStringArray(rowsData).then(data => { rows.push(data); }); }); resolve(rows); }); }
/** * Process row to convert to acceptable data to export to csv */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/graphic-builder/shared/components/viewer/table-view/table-view.component.ts#L371-L381
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
TableViewComponent.convertRowTableTypeToStringArray
convertRowTableTypeToStringArray(rowsData: { value: any, metric: boolean }[]): Promise<string[]> { return new Promise<string[]>(resolve => { const dataArr: string[] = []; rowsData.forEach(row => { this.addQuoteToData(row.value).then(value => { dataArr.push(value); }); }); resolve(dataArr); }); }
/** * Extract data value for each row * @param rowsData Row object of TableBuilderResponseType row property */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/graphic-builder/shared/components/viewer/table-view/table-view.component.ts#L387-L397
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
TableViewComponent.addColumnsToCsv
addColumnsToCsv(): Promise<string[]> { return new Promise<string[]>(resolve => { const columns: string[] = []; this.data.columns.forEach((col) => { const columnName = col.split('->')[1]; columns.push((columnName === '' || columnName === null || columnName === undefined) ? '\"\"' : columnName); }); resolve(columns); }); }
/** * Extract table header and covert to acceptable format to export */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/graphic-builder/shared/components/viewer/table-view/table-view.component.ts#L413-L422
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
RunVisualizationService.run
run(visualization: VisualizationType, request: any = {}): Observable<any> { const req = createRequestOption(request); return new Observable<any>(subscriber => { if (typeof visualization.chartConfig !== 'string') { visualization.chartConfig = JSON.stringify(visualization.chartConfig); } if (typeof visualization.chartAction !== 'string') { visualization.chartAction = JSON.stringify(visualization.chartAction); } this.visualizationService.run(visualization, req).subscribe(resp => { if (typeof visualization.chartConfig === 'string') { visualization.chartConfig = JSON.parse(visualization.chartConfig); } if (typeof visualization.chartAction === 'string') { visualization.chartAction = JSON.parse(visualization.chartAction); } subscriber.next(resp.body); }, error => { subscriber.error(error); }); }); }
/** * Method return observable of visualization run response * @param visualization Visualization to run * @param request optional pagination */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/graphic-builder/shared/services/run-visualization.service.ts#L20-L41
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
UtmChartClickActionService.onClickNavigate
onClickNavigate(visualization: VisualizationType, chartClickAction: EchartClickAction, forceSingle?: boolean) { if (visualization.chartAction.active) { const queryParams = this.chartClickFactory.createParams(visualization, chartClickAction, forceSingle); this.spinner.show('loadingSpinner'); this.router.navigate([resolveChartNavigationUrl(visualization)], {queryParams}) .then(() => { this.spinner.hide('loadingSpinner'); }); } else { console.log('NAVIGATION IS DISABLED FOR THIS CHART'); } }
/** * @param visualization Visualization * @param chartClickAction EchartClickAction * Manage click route navigation on chart click * @param forceSingle Force to single on charts with multiple buckets, used by single bar chart navigation */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/graphic-builder/shared/services/utm-chart-click-action.service.ts#L25-L36
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
LogAnalyzerTabsComponent.ngOnInit
ngOnInit(): void { this.activatedRoute.queryParams .pipe(takeUntil(this.destroy$)) .subscribe(params => { this.queryId = params.queryId; const isRefresh = params.refreshRoute || null; if (this.queryId) { this.logAnalyzerQueryService.find(this.queryId).subscribe(vis => { this.query = vis.body; this.addNewTab(this.query.name, this.query, params); }); } else { if (isRefresh) { this.tabService.deleteActiveTab(); } this.addNewTab(null, null, params); } }); this.tabs$ = this.tabService.tabs$.pipe( tap((tabs) => { this.tabSelected = tabs.find(t => t.active); }) ); this.tabService.onSaveTabSubject .pipe(takeUntil(this.destroy$), filter(query => !!query)) .subscribe(query => this.tabService.updateActiveTab(query)); this.router.events.pipe( filter(event => event instanceof NavigationStart), tap((event: NavigationStart) => { if (event.url !== '/discover/log-analyzer-queries' && !event.url.includes('/discover/log-analyzer')) { this.tabService.closeAllTabs(); } }), takeUntil(this.destroy$) ).subscribe(); }
/*ngOnInit() { this.activatedRoute.queryParams.subscribe(params => { this.queryId = params.queryId; const tabName = params.active || null; if (this.queryId) { this.logAnalyzerQueryService.find(this.queryId).subscribe(vis => { this.query = vis.body; this.addNewTab(this.query.name, this.query, params); }); } else { if (tabName) { this.tabService.deleteActiveTab(); } this.addNewTab(); } });*/
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/log-analyzer/explorer/log-analyzer-tabs/log-analyzer-tabs.component.ts#L52-L91
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
LogAnalyzerViewComponent.resolveParams
resolveParams(): Promise<any> { return new Promise<any>(resolve => { let origin: any = DataNatureTypeEnum.ALERT; // If query params exist if (this.queryParams) { origin = this.dataNature; // get filters from url and add to current filter parseQueryParamsToFilter(this.queryParams).then((filters) => { filters.forEach(filterType => { const indexFilter = this.filters.findIndex(value => value.field === filterType.field); if (indexFilter !== -1) { this.filters[indexFilter] = filterType; } else { if (filterType.field !== 'refreshRoute') { this.filters.push(filterType); } } }); // this.filters = this.filters.concat(filters); }); } // If does not have query params and data assign data nature ALERT as default if (!this.data && !this.queryParams) { origin = DataNatureTypeEnum.EVENT; } // If data exist assign current and selected filter to data input if (this.data) { this.selectedFields = []; this.fields = this.data.columnsType; this.filters = this.data.filtersType ? this.data.filtersType : this.filters; origin = this.data.pattern.pattern; this.pattern = this.data.pattern; if (this.fields) { this.fields.forEach(value => { this.selectedFields.push({name: value.field, type: value.type}); }); } else { this.selectedFields.push( {name: '@timestamp', type: ElasticDataTypesEnum.DATE}, ); } } resolve(origin + (new Date().getTime())); }); }
/** * Resolve params and data nature depending on action */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/log-analyzer/explorer/log-analyzer-view/log-analyzer-view.component.ts#L157-L202
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
LogAnalyzerViewComponent.setFilterSearchOnNatureChange
setFilterSearchOnNatureChange() { const indexFieldIn = this.filters.findIndex(value => value.operator === ElasticOperatorsEnum.IS_IN_FIELD); if (indexFieldIn !== -1) { this.filters[indexFieldIn].field = this.resolvePrefix(); } }
/** * Set prefix is data nature change */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/log-analyzer/explorer/log-analyzer-view/log-analyzer-view.component.ts#L353-L358
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
TabService.addTab
public addTab(tab: TabType): void { this.deactivateAllTabs(); const newTab: TabType = { ...tab, id: this.tabs.length + 1, active: true, }; this.tabs.push(newTab); this.emitTabs(); }
/** * Add a new tab and make it active. * @param tab The tab to add. */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/log-analyzer/shared/services/tab.service.ts#L17-L26
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
TabService.removeTab
public removeTab(index: number): void { this.tabs.splice(index, 1); if (this.tabs.length > 0) { this.tabs[this.tabs.length - 1].active = true; } this.emitTabs(); }
/** * Remove a tab by index. Activates the last tab if any remain. * @param index The index of the tab to remove. */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/log-analyzer/shared/services/tab.service.ts#L32-L38
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
TabService.setActiveTab
public setActiveTab(tabId: number): void { this.deactivateAllTabs(); const tab = this.tabs.find(t => t.id === tabId); if (tab) { tab.active = true; } this.emitTabs(); }
/** * Set a specific tab as active by its ID. * @param tabId The ID of the tab to activate. */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/log-analyzer/shared/services/tab.service.ts#L44-L51
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
TabService.updateActiveTab
public updateActiveTab(query: LogAnalyzerQueryType): void { const activeTab = this.getActiveTab(); if (activeTab) { activeTab.title = query.name; this.emitTabs(); } }
/** * Update the active tab with new data. * @param query The query containing updated data. */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/log-analyzer/shared/services/tab.service.ts#L57-L63
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
TabService.closeAllTabs
public closeAllTabs(): void { this.tabs = []; this.emitTabs(); }
/** * Close all tabs. */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/log-analyzer/shared/services/tab.service.ts#L68-L71
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
TabService.getActiveTab
public getActiveTab(): TabType | undefined { return this.tabs.find(t => t.active); }
/** * Get the currently active tab. * @returns The active tab, or undefined if no tab is active. */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/log-analyzer/shared/services/tab.service.ts#L77-L79
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
TabService.deleteActiveTab
public deleteActiveTab(): void { const activeIndex = this.tabs.findIndex(t => t.active); if (activeIndex !== -1) { this.tabs.splice(activeIndex, 1); if (this.tabs.length > 0) { this.tabs[this.tabs.length - 1].active = true; } this.emitTabs(); } }
/** * Delete the currently active tab. */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/log-analyzer/shared/services/tab.service.ts#L84-L93
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
TabService.getTabCount
public getTabCount(): number { return this.tabs.length; }
/** * Get the total number of tabs. * @returns The number of tabs. */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/log-analyzer/shared/services/tab.service.ts#L99-L101
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
TabService.deactivateAllTabs
private deactivateAllTabs(): void { this.tabs.forEach(t => (t.active = false)); }
/** * Deactivate all tabs. */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/log-analyzer/shared/services/tab.service.ts#L106-L108
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
TabService.emitTabs
private emitTabs(): void { this.tabSubject.next(this.tabs); }
/** * Emit the latest state of the tabs. */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/log-analyzer/shared/services/tab.service.ts#L113-L115
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
ReportTemplateResultComponent.getTemplate
getTemplate() { this.reportsService.find(this.reportId).subscribe(response => { this.report = response.body; if (this.report.dashboardId) { this.loadVisualizations(this.report.dashboardId); } }); }
/** * Return template */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/report/report-template-result/report-template-result.component.ts#L74-L81
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
SectionReportService.constructor
constructor(private http: HttpClient) { }
// GET /api/GET /api/utm-reportSectionnologies
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/report/shared/service/section-report.service.ts#L15-L16
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
AssetsDashboardComponent.getHostsByModificationTime
getHostsByModificationTime() { this.loadingLineOption = true; this.assetDashboardService.hostsByModificationTime().subscribe(value => { this.loadingLineOption = false; this.multilineOption = this.multilineSeverityDef.buildChartHostsByModificationTime(value.body); }); }
// multiline chart
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/scanner/assets-discovery/assets-dashboard/assets-dashboard.component.ts#L83-L89
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
AssetsDashboardComponent.getHostsBySeverityClass
getHostsBySeverityClass() { this.loadingPieOption = true; this.assetDashboardService.hostsBySeverityClass().subscribe(value => { this.loadingPieOption = false; if (value.body !== null) { this.pieOption = this.pieSeverityClassDef.buildChartBySeverityClass(value.body[0]); } }); }
// severity chart
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/scanner/assets-discovery/assets-dashboard/assets-dashboard.component.ts#L92-L100
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
AssetsDashboardComponent.getMostVulnerableHost
getMostVulnerableHost(assets: AssetModel[]) { this.loadingBarHostVulnerabilitiesOption = true; this.assetDashboardService.mostVulnerableHost().subscribe(value => { this.barHostVulnerabilitiesOption = this.barHostDef.buildCharMostVulnerableHost(value.body[0], assets); this.loadingBarHostVulnerabilitiesOption = false; }); }
// end severity chart
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/scanner/assets-discovery/assets-dashboard/assets-dashboard.component.ts#L108-L114
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
AssetsHostDetailComponent.onError
private onError(error) { // this.alertService.error(error.error, error.message, null); }
// }
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/scanner/assets-discovery/assets-host-detail/assets-host-detail.component.ts#L186-L188
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
BarHostDef.buildCharOperatingSystemsByVulnerabilityScore
public buildCharOperatingSystemsByVulnerabilityScore(chart: OpenvasOptionModel, assets: AssetModel[]) { let barSo: any = {}; this.processMostVulnerableSo(chart, assets).subscribe(barOption => { barSo = { color: UTM_COLOR_THEME, tooltip: { trigger: 'axis', backgroundColor: 'rgba(0,75,139,0.85)', padding: 10, textStyle: { fontSize: 13, fontFamily: 'Roboto, sans-serif' } }, grid: { left: '180px', top: '35px', right: 15, bottom: 0 }, calculable: true, xAxis: [{ type: 'value', boundaryGap: [0, 0.01], axisLabel: { color: '#333' }, axisLine: { lineStyle: { color: '#999' } }, splitLine: { show: true, lineStyle: { color: '#eee', type: 'dashed' } } }], yAxis: [ { type: 'category', data: barOption.legend } ], series: [ { name: 'Severity', type: 'bar', itemStyle: { // normal: { // color: '#ff705a' // } }, data: barOption.values }, ] }; }); return barSo; }
// SO build option
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/scanner/assets-discovery/shared/chart/bar-host.def.ts#L77-L138
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
PortRangeListComponent.savePortList
savePortList() { this.portListService.update(this.formPortList.value).subscribe(portCreated => { this.portEdited.emit('success'); this.activeModal.dismiss(); this.utmToastService.showSuccessBottom('Port edited successfully'); }, error1 => { this.utmToastService.showError('Error editing port', error1.error.statusText); }); }
// };
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/scanner/scanner-config/port/port-range/port-range-list/port-range-list.component.ts#L105-L114
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
TargetListComponent.resolveSshCredential
resolveSshCredential(target: TargetModel) { let credential = ''; if (target.sshCredential.name !== null) { credential += target.sshCredential.name; if (target.sshCredential.port !== null) { credential += ' on port ' + target.sshCredential.port; } } else { credential = ''; } return credential; }
// }
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/scanner/scanner-config/target/target-list/target-list.component.ts#L148-L159
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
TaskElementViewResolverService.resolveTrendClass
resolveTrendClass(trend: TaskTrendEnum): string { if (trend === TaskTrendEnum.UP || trend === TaskTrendEnum.MORE) { return 'badge-danger'; } else if (trend === TaskTrendEnum.LESS || trend === TaskTrendEnum.DOWN) { return 'badge-success'; } else { return 'badge-primary'; } }
// up|down|more|less|same
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/scanner/scanner-config/task/shared/services/task-element-view-resolver.service.ts#L54-L62
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
UtmAlertErrorService.constructor
constructor(private translateService: TranslateService, public alertService: UtmToastService ) { /* tslint:enable */ // this.cleanHttpErrorListener = eventManager.subscribe('inverdiamond.httpError', response => { // const httpErrorResponse = response.content; // console.log(response); // switch (httpErrorResponse.status) { // // connection refused, server not reachable // case 0: // // this.addErrorAlert('Server not reachable', 'error.server.not.reachable'); // break; // // case 400: // // this.addErrorAlert(response.error, 'error.server.not.reachable'); // break; // // case 404: // // this.addErrorAlert('Not found', 'error.url.not.found'); // break; // } // }); }
/* tslint:disable */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/shared/alert/utm-alert-error.service.ts#L11-L33
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
TagCloud.randomIndex
randomIndex(min, max) { return Math.floor(Math.random() * (max - min + 1) + min); }
// ].join(',') + ')'
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/shared/chart/factories/echart-factory/charts/tag-cloud.ts#L64-L66
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
HeaderMenuNavigationComponent.showAdMenu
showAdMenu(menu: Menu) { return !menu.url.includes('active-directory') && menu.menuActive; }
/** * Determine if show AD or not based on service * @param menu MenuNavType */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/shared/components/layout/header/header-menu-navigation/header-menu-navigation.component.ts#L56-L58
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
ElasticFilterTimeComponent.applyRange
applyRange() { if (this.isValidDate()) { this.dateTo = this.extractDate(this.rangeTimeTo, this.timeTo); this.dateFrom = this.extractDate(this.rangeTimeFrom, this.timeFrom); if (this.isEmitter) { this.timeFilterBehavior.$time.next({ from: this.extractDate(this.rangeTimeFrom, this.timeFrom), to: this.extractDate(this.rangeTimeTo, this.timeTo) }); } else { this.timeFilterChange.emit({ timeFrom: resolveUTCDate(this.dateFrom), timeTo: resolveUTCDate(this.dateTo) }); } } }
/*isValidDate() { if (this.rangeTimeFrom && this.rangeTimeTo) { const from = Number(new Date(this.extractDate(this.rangeTimeFrom, this.timeFrom)).getTime()); const to = Number(new Date(this.extractDate(this.rangeTimeTo, this.timeTo)).getTime()); return to - from >= 0; } else { return false; } }*/
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/shared/components/utm/filters/elastic-filter-time/elastic-filter-time.component.ts#L191-L206
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
ElasticFilterTimeComponent.onTimeFromChange
onTimeFromChange() { this.updateMaxDates('from'); // Update maxDates when timeFrom changes }
// Function called every time the 'timeFrom' date is changed
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/shared/components/utm/filters/elastic-filter-time/elastic-filter-time.component.ts#L229-L231
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
ElasticFilterTimeComponent.onTimeToChange
onTimeToChange() { this.updateMaxDates('to'); // Update maxDates when timeTo changes }
// Function called every time the 'timeTo' date is changed
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/shared/components/utm/filters/elastic-filter-time/elastic-filter-time.component.ts#L234-L236
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
ElasticFilterTimeComponent.updateMaxDates
updateMaxDates(type: 'from' | 'to') { if (this.rangeTimeFrom && type === 'from') { const maxDateTo = new Date(this.rangeTimeFrom.year, this.rangeTimeFrom.month - 1, this.rangeTimeFrom.day); maxDateTo.setDate(maxDateTo.getDate() + 30); // Set maxDateTo to 30 days after timeFrom this.maxDateTo = { year: maxDateTo.getFullYear(), month: maxDateTo.getMonth() + 1, day: maxDateTo.getDate() }; } if (this.rangeTimeTo && type === 'to') { const maxDateFrom = new Date(this.rangeTimeTo.year, this.rangeTimeTo.month - 1, this.rangeTimeTo.day); maxDateFrom.setDate(maxDateFrom.getDate() - 30); // Set maxDateFrom to 30 days before timeTo this.maxDateFrom = { year: maxDateFrom.getFullYear(), month: maxDateFrom.getMonth() + 1, day: maxDateFrom.getDate() }; } }
// Update the maxDate values based on selected 'timeFrom' and 'timeTo' dates
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/shared/components/utm/filters/elastic-filter-time/elastic-filter-time.component.ts#L239-L259
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
ElasticFilterAddComponent.setFilterEdit
setFilterEdit() { this.formFilter.patchValue(this.filter); this.getOperators(); this.isMultipleSelectValue(); if (this.applySelectFilter()) { if (this.field.type === ElasticDataTypesEnum.DATE || (this.field.type === ElasticDataTypesEnum.TEXT && !this.field.name.includes('.keyword'))) { this.fieldValues = this.filter.value; } else { this.getFieldValues(); } } if (this.filter.operator === ElasticOperatorsEnum.IS_BETWEEN || this.filter.operator === ElasticOperatorsEnum.IS_NOT_BETWEEN) { this.valueFrom = this.filter.value[0]; this.valueTo = this.filter.value[1]; } }
/** * Edit Filter */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/shared/components/utm/filters/utm-elastic-filter/elastic-filter-add/elastic-filter-add.component.ts#L100-L116
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
ElasticFilterAddComponent.selectOperator
selectOperator($event) { if (this.formFilter.get('operator').value === this.operatorEnum.IS_ONE_OF || this.formFilter.get('operator').value === this.operatorEnum.IS_NOT_ONE_OF) { this.addValidatorToValue(); // Only get values of field that are atomic(keyword, number) if (this.field.type === ElasticDataTypesEnum.DATE || (this.field.type === ElasticDataTypesEnum.TEXT && !this.field.name.includes('.keyword'))) { this.fieldValues = []; } else { this.getFieldValues(); } } else { this.cancelValidatorToValue(); } }
/** * On operator clicked, determine if cant get field values or not * @param $event Operator */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/shared/components/utm/filters/utm-elastic-filter/elastic-filter-add/elastic-filter-add.component.ts#L131-L145
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
ElasticFilterAddComponent.addValidatorToValue
addValidatorToValue() { this.formFilter.get('value').setValidators(Validators.required); this.formFilter.get('value').updateValueAndValidity(); this.formFilter.updateValueAndValidity(); }
/** * Add validator to input */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/shared/components/utm/filters/utm-elastic-filter/elastic-filter-add/elastic-filter-add.component.ts#L150-L154
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
ElasticFilterAddComponent.cancelValidatorToValue
cancelValidatorToValue() { this.formFilter.get('value').setValidators(null); this.formFilter.get('value').updateValueAndValidity(); this.formFilter.updateValueAndValidity(); }
/** * Clear validator to input */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/shared/components/utm/filters/utm-elastic-filter/elastic-filter-add/elastic-filter-add.component.ts#L159-L163
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
ElasticFilterAddComponent.extractFieldDataType
extractFieldDataType(): string { const field = this.formFilter.get('field').value; const index = this.fields.findIndex(value => value.name === field); return this.fields[index].type; }
/** * Return field data type */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/shared/components/utm/filters/utm-elastic-filter/elastic-filter-add/elastic-filter-add.component.ts#L187-L191
e00c7c4742b5ce01932668d00f6a87bb5307505d
UTMStack
github_2023
utmstack
typescript
ElasticFilterAddComponent.changeField
changeField($event) { // this.formFilter.get('field').setValue($event.name); this.formFilter.get('value').setValue(null); this.formFilter.get('operator').setValue(null); this.getOperators(); this.isMultipleSelectValue(); }
/** * When change field, refresh operator based on field data type, refresh multiple bar * @param $event Field */
https://github.com/utmstack/UTMStack/blob/e00c7c4742b5ce01932668d00f6a87bb5307505d/frontend/src/app/shared/components/utm/filters/utm-elastic-filter/elastic-filter-add/elastic-filter-add.component.ts#L201-L207
e00c7c4742b5ce01932668d00f6a87bb5307505d