-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ceph#37193 from rhcs-dashboard/log_download
Reviewed-by: Aashish Sharma <[email protected]> Reviewed-by: Ernesto Puerta <[email protected]> Reviewed-by: Tatjana Dehler <[email protected]> Reviewed-by: Tiago Melo <[email protected]> Reviewed-by: Volker Theile <[email protected]>
- Loading branch information
Showing
14 changed files
with
165 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,12 @@ p { | |
} | ||
|
||
.card { | ||
.btn-group { | ||
margin-top: -45px; | ||
position: absolute; | ||
right: 0; | ||
} | ||
|
||
div p { | ||
display: flex; | ||
|
||
|
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
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
23 changes: 23 additions & 0 deletions
23
...shboard/frontend/src/app/shared/components/download-button/download-button.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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<div ngbDropdown | ||
placement="bottom-right"> | ||
<button type="button" | ||
[title]="title" | ||
class="btn btn-light dropdown-toggle-split" | ||
ngbDropdownToggle> | ||
<i [ngClass]="[icons.download]"></i> | ||
</button> | ||
<div ngbDropdownMenu> | ||
<button ngbDropdownItem | ||
(click)="download('json')" | ||
*ngIf="objectItem"> | ||
<i [ngClass]="[icons.json]"></i> | ||
<span>JSON</span> | ||
</button> | ||
<button ngbDropdownItem | ||
(click)="download()" | ||
*ngIf="textItem"> | ||
<i [ngClass]="[icons.text]"></i> | ||
<span>Text</span> | ||
</button> | ||
</div> | ||
</div> |
Empty file.
39 changes: 39 additions & 0 deletions
39
...oard/frontend/src/app/shared/components/download-button/download-button.component.spec.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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { configureTestBed } from '../../../../testing/unit-test-helper'; | ||
import { TextToDownloadService } from '../../services/text-to-download.service'; | ||
import { DownloadButtonComponent } from './download-button.component'; | ||
|
||
describe('DownloadButtonComponent', () => { | ||
let component: DownloadButtonComponent; | ||
let fixture: ComponentFixture<DownloadButtonComponent>; | ||
|
||
configureTestBed({ | ||
declarations: [DownloadButtonComponent], | ||
providers: [TextToDownloadService] | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(DownloadButtonComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should call download function', () => { | ||
component.objectItem = { | ||
testA: 'testA', | ||
testB: 'testB' | ||
}; | ||
const downloadSpy = spyOn(TestBed.inject(TextToDownloadService), 'download'); | ||
component.fileName = `${'reportText.json'}_${new Date().toLocaleDateString()}`; | ||
component.download('json'); | ||
expect(downloadSpy).toHaveBeenCalledWith( | ||
JSON.stringify(component.objectItem, null, 2), | ||
`${component.fileName}.json` | ||
); | ||
}); | ||
}); |
31 changes: 31 additions & 0 deletions
31
...dashboard/frontend/src/app/shared/components/download-button/download-button.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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Component, Input } from '@angular/core'; | ||
|
||
import { Icons } from '../../enum/icons.enum'; | ||
import { TextToDownloadService } from '../../services/text-to-download.service'; | ||
|
||
@Component({ | ||
selector: 'cd-download-button', | ||
templateUrl: './download-button.component.html', | ||
styleUrls: ['./download-button.component.scss'] | ||
}) | ||
export class DownloadButtonComponent { | ||
@Input() objectItem: object; | ||
@Input() textItem: string; | ||
@Input() fileName: any; | ||
@Input() title = $localize`Download`; | ||
|
||
icons = Icons; | ||
constructor(private textToDownloadService: TextToDownloadService) {} | ||
|
||
download(format?: string) { | ||
this.fileName = `${this.fileName}_${new Date().toLocaleDateString()}`; | ||
if (format === 'json') { | ||
this.textToDownloadService.download( | ||
JSON.stringify(this.objectItem, null, 2), | ||
`${this.fileName}.json` | ||
); | ||
} else { | ||
this.textToDownloadService.download(this.textItem, `${this.fileName}.txt`); | ||
} | ||
} | ||
} |
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