mirror of
https://github.com/MikroWizard/mikrofront.git
synced 2025-06-28 05:10:02 +02:00
Replace code viewer and fix bug backups not howing when it is huge
This commit is contained in:
parent
860489726f
commit
0d6bdabcbc
6 changed files with 35 additions and 17 deletions
|
@ -54,6 +54,7 @@
|
||||||
"ngx-cron-editor": "^0.8.1",
|
"ngx-cron-editor": "^0.8.1",
|
||||||
"ngx-date-fns": "^11.0.0",
|
"ngx-date-fns": "^11.0.0",
|
||||||
"ngx-diff": "^9.0.0",
|
"ngx-diff": "^9.0.0",
|
||||||
|
"ngx-highlight-js": "^18.0.0",
|
||||||
"ngx-highlightjs": "^12.0.0",
|
"ngx-highlightjs": "^12.0.0",
|
||||||
"ngx-infinite-scroll": "^18.0.0",
|
"ngx-infinite-scroll": "^18.0.0",
|
||||||
"ngx-mat-select-search": "^7.0.6",
|
"ngx-mat-select-search": "^7.0.6",
|
||||||
|
|
|
@ -20,7 +20,6 @@ import { MikroWizardProvider } from './providers/mikrowizard/provider';
|
||||||
import { dataProvider } from './providers/mikrowizard/data';
|
import { dataProvider } from './providers/mikrowizard/data';
|
||||||
import { loginChecker } from './providers/login_checker';
|
import { loginChecker } from './providers/login_checker';
|
||||||
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
||||||
import { provideHighlightOptions, Highlight, HighlightAuto } from 'ngx-highlightjs';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AvatarModule,
|
AvatarModule,
|
||||||
|
@ -98,10 +97,6 @@ export function loginStatusProviderFactory(provider: loginChecker) {
|
||||||
loginChecker,
|
loginChecker,
|
||||||
IconSetService,
|
IconSetService,
|
||||||
provideDateFnsAdapter(),
|
provideDateFnsAdapter(),
|
||||||
provideHighlightOptions({
|
|
||||||
fullLibraryLoader: () => import('highlight.js'),
|
|
||||||
lineNumbersLoader: () => import('ngx-highlightjs/line-numbers')
|
|
||||||
}),
|
|
||||||
{
|
{
|
||||||
provide: APP_INITIALIZER,
|
provide: APP_INITIALIZER,
|
||||||
useFactory: loginStatusProviderFactory,
|
useFactory: loginStatusProviderFactory,
|
||||||
|
|
|
@ -89,9 +89,10 @@
|
||||||
</gui-grid-column>
|
</gui-grid-column>
|
||||||
<gui-grid-column header="Action" field="id">
|
<gui-grid-column header="Action" field="id">
|
||||||
<ng-template let-value="item.id" let-item="item" let-index="index">
|
<ng-template let-value="item.id" let-item="item" let-index="index">
|
||||||
<button cButton color="info" size="sm" (click)="ShowBackup(item)" class="mx-1"><i
|
<button cButton [disabled]="backuploading" color="info" size="sm" (click)="ShowBackup(item)" class="mx-1">
|
||||||
style="margin: 1px 5px;color:#ffffff;" class="fa-solid fa-eye"></i>Show backup</button>
|
<i *ngIf="backuploading" style="margin: 1px 5px;color:#ffffff;" class="fa-solid fa-spinner fa-spin"></i>
|
||||||
<button *ngIf="ispro" color="info" size="sm" (click)="add_for_compare(item)" class="mx-1"><i
|
<i *ngIf="!backuploading" style="margin: 1px 5px;color:#ffffff;" class="fa-solid fa-eye"></i>Show backup</button>
|
||||||
|
<button *ngIf="ispro" cButton color="info" size="sm" (click)="add_for_compare(item)" class="mx-1"><i
|
||||||
style="margin: 1px 5px;color:#ffffff;" class="fa-solid fa-eye"></i>Compare</button>
|
style="margin: 1px 5px;color:#ffffff;" class="fa-solid fa-eye"></i>Compare</button>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</gui-grid-column>
|
</gui-grid-column>
|
||||||
|
@ -107,12 +108,13 @@
|
||||||
<button [cModalToggle]="BakcupModal.id" cButtonClose></button>
|
<button [cModalToggle]="BakcupModal.id" cButtonClose></button>
|
||||||
</c-modal-header>
|
</c-modal-header>
|
||||||
<c-modal-body>
|
<c-modal-body>
|
||||||
<pre style="height: 100%;">
|
<!-- <pre style="height: 100%;">
|
||||||
<code *ngIf="!loading" language="properties" style="height:70vh" [highlight]="codeForHighlightAuto"
|
<code *ngIf="!loading" language="yaml" style="height:70vh" [highlight]="codeForHighlightAuto"
|
||||||
lineNumbers></code></pre>
|
lineNumbers></code></pre> -->
|
||||||
|
<div highlight-js [lang]="hlang" [options]="{}" >{{codeForHighlightAuto}}</div>
|
||||||
|
|
||||||
</c-modal-body>
|
</c-modal-body>
|
||||||
<c-modal-footer style="justify-content: space-between;">
|
<c-modal-footer style="justify-content: space-between;">
|
||||||
|
|
||||||
<button [cdkCopyToClipboard]="codeForHighlightAuto" [style.background-color]="copy_msg ? 'green' : null" (click)="copy_this()" cButton color="secondary">
|
<button [cdkCopyToClipboard]="codeForHighlightAuto" [style.background-color]="copy_msg ? 'green' : null" (click)="copy_this()" cButton color="secondary">
|
||||||
<i class="fa-regular fa-copy"></i> To clipboard
|
<i class="fa-regular fa-copy"></i> To clipboard
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
@import 'ngx-diff/styles/default-theme';
|
@import 'ngx-diff/styles/default-theme';
|
||||||
::ng-deep .modal-xl {
|
::ng-deep .modal-xl {
|
||||||
--cui-modal-width: 90vw!important;
|
--cui-modal-width: 90vw!important;
|
||||||
|
}
|
||||||
|
::ng-deep pre {
|
||||||
|
display: block!important;
|
||||||
}
|
}
|
|
@ -35,6 +35,7 @@ export class BackupsComponent implements OnInit {
|
||||||
public comparecontents:any=[];
|
public comparecontents:any=[];
|
||||||
public compare_type="unified";
|
public compare_type="unified";
|
||||||
public copy_msg:boolean=false;
|
public copy_msg:boolean=false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private data_provider: dataProvider,
|
private data_provider: dataProvider,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
|
@ -71,12 +72,14 @@ export class BackupsComponent implements OnInit {
|
||||||
public source: Array<any> = [];
|
public source: Array<any> = [];
|
||||||
public columns: Array<GuiColumn> = [];
|
public columns: Array<GuiColumn> = [];
|
||||||
public loading: boolean = true;
|
public loading: boolean = true;
|
||||||
|
public backuploading : boolean=false;
|
||||||
public rows: any = [];
|
public rows: any = [];
|
||||||
public Selectedrows: any;
|
public Selectedrows: any;
|
||||||
public BakcupModalVisible: boolean = false;
|
public BakcupModalVisible: boolean = false;
|
||||||
public devid: number = 0;
|
public devid: number = 0;
|
||||||
public filters_visible: boolean = false;
|
public filters_visible: boolean = false;
|
||||||
public currentBackup:any=false;
|
public currentBackup:any=false;
|
||||||
|
public hlang:string='';
|
||||||
public sorting = {
|
public sorting = {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
multiSorting: true,
|
multiSorting: true,
|
||||||
|
@ -157,20 +160,27 @@ export class BackupsComponent implements OnInit {
|
||||||
|
|
||||||
ShowBackup(backup: any) {
|
ShowBackup(backup: any) {
|
||||||
var _self=this;
|
var _self=this;
|
||||||
this.loading = true;
|
this.backuploading = true;
|
||||||
this.currentBackup = backup;
|
this.currentBackup = backup;
|
||||||
|
_self.codeForHighlightAuto='';
|
||||||
|
_self.BakcupModalVisible = true;
|
||||||
this.data_provider.get_backup(backup.id).then((res) => {
|
this.data_provider.get_backup(backup.id).then((res) => {
|
||||||
if('content' in res){
|
if('content' in res){
|
||||||
_self.codeForHighlightAuto = res.content;
|
console.dir(res.content.length);
|
||||||
_self.loading = false;
|
if(res.content.length>115000)
|
||||||
|
_self.hlang='xml';
|
||||||
|
else{
|
||||||
|
_self.hlang='routeros'
|
||||||
|
}
|
||||||
_self.BakcupModalVisible = true;
|
_self.BakcupModalVisible = true;
|
||||||
|
_self.codeForHighlightAuto = res.content;
|
||||||
|
_self.backuploading = false;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
this.show_toast('Error', 'Error loading backup file', 'danger')
|
this.show_toast('Error', 'Error loading backup file', 'danger')
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleCollapse(): void {
|
toggleCollapse(): void {
|
||||||
this.filters_visible = !this.filters_visible;
|
this.filters_visible = !this.filters_visible;
|
||||||
}
|
}
|
||||||
|
@ -205,6 +215,11 @@ export class BackupsComponent implements OnInit {
|
||||||
this.compareitems.forEach((element:any) => {
|
this.compareitems.forEach((element:any) => {
|
||||||
_self.data_provider.get_backup(element.id).then((res) => {
|
_self.data_provider.get_backup(element.id).then((res) => {
|
||||||
if('content' in res){
|
if('content' in res){
|
||||||
|
if(res.content.length>300000){
|
||||||
|
this.comparecontents=[];
|
||||||
|
this.show_toast('Error', 'The file is too big for comparing, Try accessing and comparing locally', 'danger')
|
||||||
|
return;
|
||||||
|
}
|
||||||
_self.comparecontents.push(res.content);
|
_self.comparecontents.push(res.content);
|
||||||
}
|
}
|
||||||
if(_self.comparecontents.length==_self.compareitems.length)
|
if(_self.comparecontents.length==_self.compareitems.length)
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { NgModule } from "@angular/core";
|
||||||
import { CommonModule } from "@angular/common";
|
import { CommonModule } from "@angular/common";
|
||||||
import { Highlight, HighlightAuto } from "ngx-highlightjs";
|
import { Highlight, HighlightAuto } from "ngx-highlightjs";
|
||||||
import { HighlightLineNumbers } from "ngx-highlightjs/line-numbers";
|
import { HighlightLineNumbers } from "ngx-highlightjs/line-numbers";
|
||||||
|
import { HighlightJsModule } from 'ngx-highlight-js';
|
||||||
import {
|
import {
|
||||||
ButtonModule,
|
ButtonModule,
|
||||||
CardModule,
|
CardModule,
|
||||||
|
@ -13,6 +13,7 @@ import {
|
||||||
FormModule,
|
FormModule,
|
||||||
ToastModule,
|
ToastModule,
|
||||||
} from "@coreui/angular";
|
} from "@coreui/angular";
|
||||||
|
|
||||||
import { BackupsRoutingModule } from "./backups-routing.module";
|
import { BackupsRoutingModule } from "./backups-routing.module";
|
||||||
import { BackupsComponent } from "./backups.component";
|
import { BackupsComponent } from "./backups.component";
|
||||||
import { GuiGridModule } from "@generic-ui/ngx-grid";
|
import { GuiGridModule } from "@generic-ui/ngx-grid";
|
||||||
|
@ -48,6 +49,7 @@ import { ClipboardModule } from "@angular/cdk/clipboard";
|
||||||
UnifiedDiffComponent,
|
UnifiedDiffComponent,
|
||||||
SideBySideDiffComponent,
|
SideBySideDiffComponent,
|
||||||
ToastModule,
|
ToastModule,
|
||||||
|
HighlightJsModule,
|
||||||
ClipboardModule
|
ClipboardModule
|
||||||
],
|
],
|
||||||
declarations: [BackupsComponent],
|
declarations: [BackupsComponent],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue