-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(layermanager): Add copy button to URL
- Loading branch information
1 parent
cb60f0d
commit 6a58830
Showing
6 changed files
with
54 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 16 additions & 17 deletions
33
projects/hslayers/components/layer-manager/widgets/type-widget.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
<div class="form-group"> | ||
<small class="text-secondary" *ngIf="(layerDescriptor | async)"> | ||
{{ | ||
HsLanguageService.getTranslationIgnoreNonExisting( | ||
"LAYERMANAGER.layerEditor", | ||
(layerDescriptor | async).type, | ||
undefined | ||
) | ||
}}<!-- TODO: Remove function call from template --> | ||
<small class="text-secondary" *ngIf="layerDescriptor | async as descriptor"> | ||
{{ descriptor.type | translateHs: { module: "LAYERMANAGER.layerEditor" } }} | ||
{{ "LAYERMANAGER.layerEditor.layerFrom" | translateHs }} | ||
<span class="text-truncate mw-100 d-block"> | ||
{{ | ||
HsLanguageService.getTranslationIgnoreNonExisting( | ||
"LAYERMANAGER.layerEditor", | ||
(layerDescriptor | async).source, | ||
undefined | ||
) | ||
}}<!-- TODO: Remove function call from template --> | ||
</span> | ||
<div class="mw-100 d-flex align-items-center justify-content-between"> | ||
<span class="text-truncate"> | ||
{{ | ||
descriptor.source | ||
| translateHs: { module: "LAYERMANAGER.layerEditor" } | ||
}} | ||
</span> | ||
@if (descriptor.source !== "memory") { | ||
<button class="btn btn-sm text-secondary" data-toggle="tooltip" | ||
[title]="'COMMON.copyToClipboardFailure' | translateHs" (click)="copyToClipBoard()"> | ||
<i [class.icon-check]="showCheck" [class.icon-copy]="!showCheck"></i> | ||
</button> | ||
} | ||
</div> | ||
</small> | ||
</div> |
32 changes: 26 additions & 6 deletions
32
projects/hslayers/components/layer-manager/widgets/type-widget.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,39 @@ | ||
import {Component} from '@angular/core'; | ||
import {Component, inject, signal} from '@angular/core'; | ||
|
||
import {HsLanguageService} from 'hslayers-ng/services/language'; | ||
import {HsLayerEditorWidgetBaseComponent} from './layer-editor-widget-base.component'; | ||
import {HsLayerSelectorService} from 'hslayers-ng/services/layer-manager'; | ||
import {HsToastService} from 'hslayers-ng/common/toast'; | ||
|
||
@Component({ | ||
selector: 'hs-type-widget', | ||
templateUrl: './type-widget.component.html', | ||
}) | ||
export class HsTypeWidgetComponent extends HsLayerEditorWidgetBaseComponent { | ||
constructor( | ||
public HsLanguageService: HsLanguageService, | ||
hsLayerSelectorService: HsLayerSelectorService, | ||
) { | ||
hsToastService = inject(HsToastService); | ||
|
||
showCheck = false; | ||
|
||
constructor(hsLayerSelectorService: HsLayerSelectorService) { | ||
super(hsLayerSelectorService); | ||
} | ||
name = 'type-widget'; | ||
|
||
copyToClipBoard() { | ||
if (!navigator.clipboard) { | ||
this.hsToastService.createToastPopupMessage( | ||
'COMMON.copyToClipboard', | ||
'COMMON.copyToClipboardFailure', | ||
{ | ||
toastStyleClasses: 'bg-danger text-white', | ||
}, | ||
); | ||
return; | ||
} | ||
this.showCheck = true; | ||
const source = this.hsLayerSelectorService.currentLayer.source; | ||
navigator.clipboard.writeText(source); | ||
setTimeout(() => { | ||
this.showCheck = false; | ||
}, 500); | ||
} | ||
} |