diff --git a/client/src/app/editor/components/edit-record/edit-record.component.ts b/client/src/app/editor/components/edit-record/edit-record.component.ts index 731b815..8259d3a 100644 --- a/client/src/app/editor/components/edit-record/edit-record.component.ts +++ b/client/src/app/editor/components/edit-record/edit-record.component.ts @@ -171,23 +171,8 @@ export class EditRecordComponent implements OnInit { } public copyToClip(text: string) { - const modalElement = document.querySelector('#recordModalRef .modal-title') - - if (modalElement) { - const selBox = document.createElement('textarea') - selBox.style.position = 'fixed' - selBox.style.left = '0' - selBox.style.top = '0' - selBox.style.opacity = '0' - selBox.style.zIndex = '5000' - selBox.value = text - modalElement.appendChild(selBox) - selBox.focus() - selBox.select() - document.execCommand('copy') - modalElement.removeChild(selBox) - this.generatedRecordUrl = text - } + navigator.clipboard.writeText(text) + this.generatedRecordUrl = text } async generateEditRecordUrl() { diff --git a/client/src/app/licensing/licensing.component.ts b/client/src/app/licensing/licensing.component.ts index cbde4f4..986d3bc 100644 --- a/client/src/app/licensing/licensing.component.ts +++ b/client/src/app/licensing/licensing.component.ts @@ -1,178 +1,181 @@ -import { Component, OnInit, ViewEncapsulation } from '@angular/core' -import { ActivatedRoute, Router } from '@angular/router' -import { AppService, LicenceService, SasService } from '../services' -import { LicenseKeyData } from '../models/LicenseKeyData' -import { RequestWrapperResponse } from '../models/request-wrapper/RequestWrapperResponse' - -enum LicenseActions { - key = 'key', - register = 'register', - limit = 'limit', - update = 'update' -} - -@Component({ - selector: 'app-licensing', - templateUrl: './licensing.component.html', - styleUrls: ['./licensing.component.scss'], - encapsulation: ViewEncapsulation.None -}) -export class LicensingComponent implements OnInit { - public action: LicenseActions | null = null - - public licenseErrors: { [key: string]: string } = { - missing: `Licence key is missing - please contact support@datacontroller.io and enter valid keys below.`, - expired: `Licence key is expired - please contact support@datacontroller.io and enter valid keys below.`, - invalid: `Licence key is invalid - please contact support@datacontroller.io and enter valid keys below.`, - missmatch: `Your SYSSITE (below) is not found in the licence key - please contact support@datacontroller.io and enter valid keys below.` - } - - public keyError: string | undefined - public errorDetails: string | undefined - public missmatchedKey: string | undefined - public licenceKeyValue: string = '' - public activationKeyValue: string = '' - - public applyingKeys: boolean = false - - public syssite = this.appService.syssite - public currentLicenceKey = this.licenceService.licenceKey - public currentActivationKey = this.licenceService.activationKey - public isAppFreeTier = this.licenceService.isAppFreeTier - public userCountLimitation = this.licenceService.userCountLimitation - - public licenseKeyData: LicenseKeyData | null = null - - public inputType: 'file' | 'paste' = 'file' - public licenceFileError: string | undefined - public licenceFileLoading: boolean = false - public licencefile: { filename: string } = { - filename: '' - } - - constructor( - private route: ActivatedRoute, - private licenceService: LicenceService, - private sasService: SasService, - private appService: AppService - ) {} - - ngOnInit(): void { - this.licenceKeyValue = this.currentLicenceKey || '' - this.activationKeyValue = this.currentActivationKey || '' - - this.route.queryParams.subscribe((queryParams: any) => { - this.keyError = queryParams.error - this.missmatchedKey = queryParams.missmatchId - - if (queryParams.details) { - this.errorDetails = atob(queryParams.details) - } - }) - - this.route.params.subscribe((params: any) => { - let actionInUrl = params.action - - if (actionInUrl) { - if (Object.values(LicenseActions).includes(actionInUrl)) { - this.action = actionInUrl - } - } - }) - - this.licenseKeyData = this.licenceService.getLicenseKeyData() - } - - public trimKeys() { - this.licenceKeyValue = this.licenceKeyValue.trim() - this.activationKeyValue = this.activationKeyValue.trim() - } - - public copySyssite(copyIconRef: any, copyTooltip: any, syssite: string[]) { - const syssiteString = syssite.join('\n') - - navigator.clipboard.writeText(syssiteString).then(() => { - copyIconRef.setAttribute('shape', 'check') - copyIconRef.setAttribute('class', 'is-success') - copyTooltip.innerText = 'Copied!' - - setTimeout(() => { - copyIconRef.setAttribute('shape', 'copy') - copyIconRef.removeAttribute('class') - copyTooltip.innerText = 'Copy to clipboard' - }, 1000) - }) - } - - public applyKeys() { - this.applyingKeys = true - - let table = { - keyupload: [ - { - ACTIVATION_KEY: this.activationKeyValue, - LICENCE_KEY: this.licenceKeyValue - } - ] - } - - this.sasService - .request('admin/registerkey', table) - .then((res: RequestWrapperResponse) => { - if ( - res.adapterResponse.return && - res.adapterResponse.return[0] && - res.adapterResponse.return[0].MSG === 'SUCCESS' - ) { - location.replace(location.href.split('#')[0]) - } - }) - .finally(() => { - this.applyingKeys = false - }) - } - - public onFileCapture(event: any, dropped = false) { - let file = dropped ? event[0] : event.target.files[0] - this.licencefile.filename = file.name - - if (!file) return - - this.licenceFileLoading = true - - const reader = new FileReader() - - reader.onload = (evt) => { - this.licenceFileError = 'Error reading file.' - - if (!evt || !evt.target) return - if (evt.target.readyState != 2) return - if (evt.target.error) return - if (!evt.target.result) return - - this.licenceFileLoading = false - this.licenceFileError = undefined - const fileArr = evt.target.result.toString().split('\n') - this.activationKeyValue = fileArr[1] - this.licenceKeyValue = fileArr[0] - } - - reader.readAsText(file) - } - - public switchType(type: 'paste' | 'file') { - this.inputType = type - } - - get disableApplyButton(): boolean { - if (this.licenceKeyValue.length < 1 || this.activationKeyValue.length < 1) - return true - if ( - this.licenceKeyValue === this.currentLicenceKey && - this.activationKeyValue === this.currentActivationKey - ) - return true - - return false - } -} +import { Component, OnInit, ViewEncapsulation } from '@angular/core' +import { ActivatedRoute, Router } from '@angular/router' +import { AppService, LicenceService, SasService } from '../services' +import { LicenseKeyData } from '../models/LicenseKeyData' +import { RequestWrapperResponse } from '../models/request-wrapper/RequestWrapperResponse' + +enum LicenseActions { + key = 'key', + register = 'register', + limit = 'limit', + update = 'update' +} + +@Component({ + selector: 'app-licensing', + templateUrl: './licensing.component.html', + styleUrls: ['./licensing.component.scss'], + encapsulation: ViewEncapsulation.None +}) +export class LicensingComponent implements OnInit { + public action: LicenseActions | null = null + + public licenseErrors: { [key: string]: string } = { + missing: `Licence key is missing - please contact support@datacontroller.io and enter valid keys below.`, + expired: `Licence key is expired - please contact support@datacontroller.io and enter valid keys below.`, + invalid: `Licence key is invalid - please contact support@datacontroller.io and enter valid keys below.`, + missmatch: `Your SYSSITE (below) is not found in the licence key - please contact support@datacontroller.io and enter valid keys below.` + } + + public keyError: string | undefined + public errorDetails: string | undefined + public missmatchedKey: string | undefined + public licenceKeyValue: string = '' + public activationKeyValue: string = '' + + public applyingKeys: boolean = false + + public syssite = this.appService.syssite + public currentLicenceKey = this.licenceService.licenceKey + public currentActivationKey = this.licenceService.activationKey + public isAppFreeTier = this.licenceService.isAppFreeTier + public userCountLimitation = this.licenceService.userCountLimitation + + public licenseKeyData: LicenseKeyData | null = null + + public inputType: 'file' | 'paste' = 'file' + public licenceFileError: string | undefined + public licenceFileLoading: boolean = false + public licencefile: { filename: string } = { + filename: '' + } + + constructor( + private route: ActivatedRoute, + private router: Router, + private licenceService: LicenceService, + private sasService: SasService, + private appService: AppService + ) {} + + ngOnInit(): void { + this.licenceKeyValue = this.currentLicenceKey || '' + this.activationKeyValue = this.currentActivationKey || '' + + this.route.queryParams.subscribe((queryParams: any) => { + this.keyError = queryParams.error + this.missmatchedKey = queryParams.missmatchId + + if (queryParams.details) { + this.errorDetails = atob(queryParams.details) + } + }) + + this.route.params.subscribe((params: any) => { + let actionInUrl = params.action + + if (actionInUrl) { + if (Object.values(LicenseActions).includes(actionInUrl)) { + this.action = actionInUrl + } + } + }) + + this.licenseKeyData = this.licenceService.getLicenseKeyData() + } + + public trimKeys() { + this.licenceKeyValue = this.licenceKeyValue.trim() + this.activationKeyValue = this.activationKeyValue.trim() + } + + public copySyssite(copyIconRef: any, copyTooltip: any, syssite: string[]) { + const syssiteString = syssite.join('\n') + + navigator.clipboard.writeText(syssiteString).then(() => { + copyIconRef.setAttribute('shape', 'check') + copyIconRef.setAttribute('class', 'is-success') + copyTooltip.innerText = 'Copied!' + + setTimeout(() => { + copyIconRef.setAttribute('shape', 'copy') + copyIconRef.removeAttribute('class') + copyTooltip.innerText = 'Copy to clipboard' + }, 1000) + }) + } + + public applyKeys() { + this.applyingKeys = true + + let table = { + keyupload: [ + { + ACTIVATION_KEY: this.activationKeyValue, + LICENCE_KEY: this.licenceKeyValue + } + ] + } + + this.sasService + .request('admin/registerkey', table) + .then((res: RequestWrapperResponse) => { + if ( + res.adapterResponse.return && + res.adapterResponse.return[0] && + res.adapterResponse.return[0].MSG === 'SUCCESS' + ) { + this.router.navigateByUrl('/').then(() => { + window.location.reload() + }) + } + }) + .finally(() => { + this.applyingKeys = false + }) + } + + public onFileCapture(event: any, dropped = false) { + let file = dropped ? event[0] : event.target.files[0] + this.licencefile.filename = file.name + + if (!file) return + + this.licenceFileLoading = true + + const reader = new FileReader() + + reader.onload = (evt) => { + this.licenceFileError = 'Error reading file.' + + if (!evt || !evt.target) return + if (evt.target.readyState != 2) return + if (evt.target.error) return + if (!evt.target.result) return + + this.licenceFileLoading = false + this.licenceFileError = undefined + const fileArr = evt.target.result.toString().split('\n') + this.activationKeyValue = fileArr[1] + this.licenceKeyValue = fileArr[0] + } + + reader.readAsText(file) + } + + public switchType(type: 'paste' | 'file') { + this.inputType = type + } + + get disableApplyButton(): boolean { + if (this.licenceKeyValue.length < 1 || this.activationKeyValue.length < 1) + return true + if ( + this.licenceKeyValue === this.currentLicenceKey && + this.activationKeyValue === this.currentActivationKey + ) + return true + + return false + } +} diff --git a/client/src/app/lineage/lineage.component.ts b/client/src/app/lineage/lineage.component.ts index 5d21941..9234e11 100644 --- a/client/src/app/lineage/lineage.component.ts +++ b/client/src/app/lineage/lineage.component.ts @@ -746,28 +746,13 @@ export class LineageComponent { return URL.createObjectURL(svg_blob) } - private getSVGBlob() { - let svg: any = document.getElementById('graph') - let serializer = new XMLSerializer() - let svg_blob = new Blob([serializer.serializeToString(svg)], { - type: 'image/svg+xml' - }) - return svg_blob - } - downloadSVG() { d3Viz.graphviz('#graph').resetZoom() - if (navigator.appVersion.toString().indexOf('.NET') > 0) { - window.navigator.msSaveBlob(this.getSVGBlob(), this.constructName('svg')) - } else { - let downloadLink = document.createElement('a') - downloadLink.href = this.getSVGURL() - downloadLink.download = this.constructName('svg') - document.body.appendChild(downloadLink) - downloadLink.click() - document.body.removeChild(downloadLink) - } + let downloadLink = document.createElement('a') + downloadLink.href = this.getSVGURL() + downloadLink.download = this.constructName('svg') + downloadLink.click() } async downloadPNG() { @@ -795,16 +780,11 @@ export class LineageComponent { var a = document.createElement('a') var blob = new Blob([csvArray], { type: 'text/csv' }) - if (navigator.appVersion.toString().indexOf('.NET') > 0) { - window.navigator.msSaveBlob(blob, this.constructName('csv')) - } else { - var url = window.URL.createObjectURL(blob) - a.href = url - a.download = this.constructName('csv') - a.click() - window.URL.revokeObjectURL(url) - a.remove() - } + var url = window.URL.createObjectURL(blob) + a.href = url + a.download = this.constructName('csv') + a.click() + window.URL.revokeObjectURL(url) } private getDotUrl() { @@ -813,23 +793,11 @@ export class LineageComponent { return window.URL.createObjectURL(dot_blob) } - private getDotBlob() { - let data = this.vizInput - let dot_blob = new Blob([data], { type: 'text/plain' }) - return dot_blob - } - downloadDot() { - if (navigator.appVersion.toString().indexOf('.NET') > 0) { - window.navigator.msSaveBlob(this.getDotBlob(), this.constructName('txt')) - } else { - let downloadLink = document.createElement('a') - downloadLink.href = this.getDotUrl() - downloadLink.download = this.constructName('txt') - document.body.appendChild(downloadLink) - downloadLink.click() - document.body.removeChild(downloadLink) - } + let downloadLink = document.createElement('a') + downloadLink.href = this.getDotUrl() + downloadLink.download = this.constructName('txt') + downloadLink.click() } public showSvg() { diff --git a/client/src/app/viewer/viewer.component.ts b/client/src/app/viewer/viewer.component.ts index f3dce0f..85ac146 100644 --- a/client/src/app/viewer/viewer.component.ts +++ b/client/src/app/viewer/viewer.component.ts @@ -536,17 +536,7 @@ export class ViewerComponent } public copyToClip() { - let selBox = document.createElement('textarea') - selBox.style.position = 'fixed' - selBox.style.left = '0' - selBox.style.top = '0' - selBox.style.opacity = '0' - selBox.value = this.webQueryText - document.body.appendChild(selBox) - selBox.focus() - selBox.select() - document.execCommand('copy') - document.body.removeChild(selBox) + navigator.clipboard.writeText(this.webQueryText) } public goToViewer() {