Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some resources diff error #175

Merged
merged 3 commits into from
Dec 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/frontend/src/app/portal/ingress/ingress.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<button (click)="deleteResource('删除 Ingress','是否确定删除 Ingress','已上线 Ingress 禁止直接删除!')" class="wayne-button normal" *ngIf="authService.currentAppPermission.ingress.offline || authService.currentUser.admin">
删除 ingress
</button>
<button class="wayne-button normal" (click)="diffTmp()">{{'BUTTON.DIFF_TMP' | translate}}</button>
<button class="wayne-button normal" (click)="diffTpl()">{{'BUTTON.DIFF_TMP' | translate}}</button>
<wayne-filter-box (confirm)="onConfirmClick()" (cancel)="onCancelClick()">
<wayne-checkbox-group [(ngModel)]="showList">
<wayne-checkbox>创建时间</wayne-checkbox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<button (click)="deletePvc()" class="wayne-button normal" *ngIf="authService.currentAppPermission.pvc.offline || authService.currentUser.admin">
{{'PVC.DELETE' | translate}}
</button>
<button class="wayne-button normal" (click)="diffTmp()">{{'BUTTON.DIFF_TMP' | translate}}</button>
<button class="wayne-button normal" (click)="diffTpl()">{{'BUTTON.DIFF_TMP' | translate}}</button>
</div>
<div class="table-search-right">
<div class="toggle-switch">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class PersistentVolumeClaimComponent implements OnInit, OnDestroy {

}

diffTmp() {
diffTpl() {
this.pvcService.diff();
}

Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/app/portal/secret/secret.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*ngIf="authService.currentAppPermission.secret.offline || authService.currentUser.admin">
{{'SECRET.DELETE' | translate}}
</button>
<button class="wayne-button normal" (click)="diffTmp()">{{'BUTTON.DIFF_TMP' | translate}}</button>
<button class="wayne-button normal" (click)="diffTpl()">{{'BUTTON.DIFF_TMP' | translate}}</button>
<wayne-filter-box (confirm)="confirmEvent()" (cancel)="cancelEvent()">
<wayne-checkbox-group [(ngModel)]="showList">
<wayne-checkbox value="create_time">{{'TITLE.CREATE_TIME' | translate}}</wayne-checkbox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*ngIf="authService.currentAppPermission.statefulset.offline || authService.currentUser.admin">
{{'STATEFULSET.DELETE' | translate}}
</button>
<button class="wayne-button normal" (click)="diffTmp()">{{'BUTTON.DIFF_TMP' | translate}}</button>
<button class="wayne-button normal" (click)="diffTpl()">{{'BUTTON.DIFF_TMP' | translate}}</button>
<wayne-filter-box (confirm)="confirmEvent()" (cancel)="cancelEvent()">
<wayne-checkbox-group class=".filter-body-content" [(ngModel)]="showList">
<wayne-checkbox value="create_time">{{'TITLE.CREATE_TIME' | translate}}</wayne-checkbox>
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/src/app/shared/diff/diff.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createPatch } from 'diff';
import { Diff2Html } from 'diff2html';
import { DiffService } from './diff.service';
import { Subscription } from 'rxjs';
import { DiffTmp } from './diff';
import { DiffTpl } from './diff';
import * as YAML from 'js-yaml';
import { MessageHandlerService } from '../message-handler/message-handler.service';
/**
Expand Down Expand Up @@ -38,7 +38,7 @@ export class DiffComponent implements OnDestroy {
html = '';
inputType = 'json';
outStyle = 'side-by-side';
diffTpl: DiffTmp;
diffTpl: DiffTpl;
get style() {
return this._style;
}
Expand Down
14 changes: 7 additions & 7 deletions src/frontend/src/app/shared/diff/diff.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs/Subject';
import { DiffTmp } from './diff';
import { DiffTpl } from './diff';
import { MessageHandlerService } from '../message-handler/message-handler.service';
const defaultTmp: DiffTmp = {
const defaultTmp: DiffTpl = {
fileName: '',
oldStr: '',
newStr: '',
Expand All @@ -19,18 +19,18 @@ export class DiffService {

}

diffSub = new Subject<DiffTmp>();
diffSub = new Subject<DiffTpl>();

diffOb = this.diffSub.asObservable();

diff(selected: any[], tmpPropName = 'template', namePropName = 'id') {
const length = selected.length;
let diffTmp;
let diffTpl;
if (length < 2) {
this.messageHandlerService.showError('SHARED.DIFF.TMP_LESS');
return;
} else {
diffTmp = {
diffTpl = {
oldStr: selected[1][tmpPropName],
newStr: selected[0][tmpPropName],
oldHeader: `${selected[1][namePropName]}`,
Expand All @@ -40,8 +40,8 @@ export class DiffService {
this.messageHandlerService.showInfo('SHARED.DIFF.TMP_MORE');
}
}
diffTmp = { ...defaultTmp, ...diffTmp };
this.diffSub.next(diffTmp);
diffTpl = { ...defaultTmp, ...diffTpl };
this.diffSub.next(diffTpl);
}

}
2 changes: 1 addition & 1 deletion src/frontend/src/app/shared/diff/diff.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface DiffTmp {
export interface DiffTpl {
fileName?: string;
oldStr: string;
newStr: string;
Expand Down