Channel Restore Final

Channel Restore Final
pull/209/head
Shahana Farooqui 5 years ago
parent aac9d42bb4
commit 4678acadda

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -9,5 +9,5 @@
<link rel="stylesheet" href="styles.41a6644c686ce68dce93.css"></head>
<body>
<rtl-app></rtl-app>
<script src="runtime.881b21e05dd0455c6919.js"></script><script src="polyfills-es5.763f4f23e8aee5ec234d.js" nomodule></script><script src="polyfills.e59b6f9dc696bd89cf7f.js"></script><script src="main.c17160159e9da3b43373.js"></script></body>
<script src="runtime.353035627f09c4610120.js"></script><script src="polyfills-es5.763f4f23e8aee5ec234d.js" nomodule></script><script src="polyfills.e59b6f9dc696bd89cf7f.js"></script><script src="main.23f7c8bc7bb9dd44ff2c.js"></script></body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1 +1 @@
!function(e){function r(r){for(var n,a,i=r[0],c=r[1],f=r[2],p=0,s=[];p<i.length;p++)o[a=i[p]]&&s.push(o[a][0]),o[a]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(l&&l(r);s.length;)s.shift()();return u.push.apply(u,f||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++)0!==o[t[i]]&&(n=!1);n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={0:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise(function(r,n){t=o[e]=[r,n]});r.push(t[2]=n);var u,i=document.createElement("script");i.charset="utf-8",i.timeout=120,a.nc&&i.setAttribute("nonce",a.nc),i.src=function(e){return a.p+""+({}[e]||e)+"."+{1:"54f1b90d9c910a1bad05",6:"f85bb53688936c6adfce",7:"88fbff9ea7b98c0141e7"}[e]+".js"}(e);var c=new Error;u=function(r){i.onerror=i.onload=null,clearTimeout(f);var t=o[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;c.message="Loading chunk "+e+" failed.\n("+n+": "+u+")",c.name="ChunkLoadError",c.type=n,c.request=u,t[1](c)}o[e]=void 0}};var f=setTimeout(function(){u({type:"timeout",target:i})},12e4);i.onerror=i.onload=u,document.head.appendChild(i)}return Promise.all(r)},a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)a.d(t,n,(function(r){return e[r]}).bind(null,n));return t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p="",a.oe=function(e){throw console.error(e),e};var i=window.webpackJsonp=window.webpackJsonp||[],c=i.push.bind(i);i.push=r,i=i.slice();for(var f=0;f<i.length;f++)r(i[f]);var l=c;t()}([]);
!function(e){function r(r){for(var n,a,i=r[0],c=r[1],f=r[2],p=0,s=[];p<i.length;p++)o[a=i[p]]&&s.push(o[a][0]),o[a]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(l&&l(r);s.length;)s.shift()();return u.push.apply(u,f||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++)0!==o[t[i]]&&(n=!1);n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={0:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise(function(r,n){t=o[e]=[r,n]});r.push(t[2]=n);var u,i=document.createElement("script");i.charset="utf-8",i.timeout=120,a.nc&&i.setAttribute("nonce",a.nc),i.src=function(e){return a.p+""+({}[e]||e)+"."+{1:"54f1b90d9c910a1bad05",6:"9f46ff9d0ed319a0a92b",7:"89c90020d3d29a9ec67f"}[e]+".js"}(e);var c=new Error;u=function(r){i.onerror=i.onload=null,clearTimeout(f);var t=o[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;c.message="Loading chunk "+e+" failed.\n("+n+": "+u+")",c.name="ChunkLoadError",c.type=n,c.request=u,t[1](c)}o[e]=void 0}};var f=setTimeout(function(){u({type:"timeout",target:i})},12e4);i.onerror=i.onload=u,document.head.appendChild(i)}return Promise.all(r)},a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)a.d(t,n,(function(r){return e[r]}).bind(null,n));return t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p="",a.oe=function(e){throw console.error(e),e};var i=window.webpackJsonp=window.webpackJsonp||[],c=i.push.bind(i);i.push=r,i=i.slice();for(var f=0;f<i.length;f++)r(i[f]);var l=c;t()}([]);

@ -4,6 +4,26 @@ var common = require('../../common');
var logger = require('../logger');
var options = {};
function getFilesList(callback) {
let files_list = [];
let all_restore_exists = false;
let response = {all_restore_exists: false, files: []};
fs.readdir(common.selectedNode.channel_backup_path + common.path_separator + 'restore', function (err, files) {
if (err && err.code !== 'ENOENT' && err.errno !== -4058) { response = { message: 'Channels Restore List Failed!', error: err } }
files.forEach(file => {
if (!file.includes('.restored')) {
if (file === 'channel-all.bak') {
all_restore_exists = true;
} else {
files_list.push({channel_point: file.substring(8, file.length - 4).replace('-', ':')});
}
}
});
response = {all_restore_exists: all_restore_exists, files: files_list};
callback(response);
});
}
exports.getBackup = (req, res, next) => {
options = common.getOptions();
let channel_backup_file = '';
@ -113,7 +133,6 @@ exports.postRestore = (req, res, next) => {
restore_backup = fs.readFileSync(channel_restore_file, 'utf-8');
if (restore_backup !== '') {
restore_backup = JSON.parse(restore_backup);
// options.form = JSON.stringify({chan_backups: restore_backup.single_chan_backups});
options.form = JSON.stringify({multi_chan_backup: restore_backup.multi_chan_backup.multi_chan_backup});
} else {
res.status(404).json({ message: 'Channels backup to restore does not Exist!' });
@ -137,7 +156,15 @@ exports.postRestore = (req, res, next) => {
if (restore_backup !== '') {
request.post(options).then(function (body) {
logger.info({fileName: 'Channels Backup Restore', msg: 'Channel Backup Restore: ' + JSON.stringify(body)});
res.status(201).json({ message: message });
fs.rename(channel_restore_file, channel_restore_file + '.restored', () => {
getFilesList(getFilesListRes => {
if (getFilesListRes.error) {
return res.status(500).json({ message: 'Channel restore failed!', list: getFilesListRes });
} else {
return res.status(201).json({ message: 'Channel restore failed!', list: getFilesListRes });
}
});
});
})
.catch(function (err) {
logger.error({fileName: 'Channels Backup Restore', lineNum: 143, msg: 'Channel Backup Restore: ' + JSON.stringify(err)});
@ -150,23 +177,11 @@ exports.postRestore = (req, res, next) => {
};
exports.getRestoreList = (req, res, next) => {
let files_list = [];
let all_restore_exists = false;
fs.readdir(common.selectedNode.channel_backup_path + common.path_separator + 'restore', function (err, files) {
if (err) {
if (err.code === 'ENOENT' && err.errno === -4058) {
return res.status(200).json({all_restore_exists: false, files: []});
} else {
return res.status(500).json({ message: 'Channels Restore List Failed!', error: err });
}
getFilesList(getFilesListRes => {
if (getFilesListRes.error) {
return res.status(500).json(getFilesListRes);
} else {
return res.status(200).json(getFilesListRes);
}
files.forEach(file => {
if (file === 'channel-all.bak') {
all_restore_exists = true;
} else {
files_list.push({channel_point: file.substring(8, file.length - 4).replace('-', ':')});
}
});
return res.status(200).json({all_restore_exists: all_restore_exists, files: files_list});
});
});
};

@ -9,8 +9,8 @@
<mat-card-content>
<div fxLayout="column" fxLayout.gt-sm="row wrap" fxFlex="100" fxLayoutAlign="space-between start">
<h4 fxFlex="100">Backup folder location: {{selNode.channelBackupPath}}</h4>
<button fxFlex="49" fxLayoutAlign="center center" mat-raised-button color="primary" tabindex="1" (click)="onBackupChannels({})">All Channels Backup</button>
<button fxFlex="49" fxLayoutAlign="center center" mat-raised-button color="primary" tabindex="2" (click)="onVerifyChannels({})">All Channels Verify Backup</button>
<button fxFlex="49" fxLayoutAlign="center center" mat-raised-button color="primary" tabindex="1" (click)="onBackupChannels({})">Backup All Channels</button>
<button fxFlex="49" fxLayoutAlign="center center" mat-raised-button color="primary" tabindex="2" (click)="onVerifyChannels({})">Verify All Channels Backup</button>
</div>
</mat-card-content>
</mat-card>

@ -1,51 +1,69 @@
<div fxLayout="column">
<div class="padding-gap" *ngIf="allRestoreExists">
<mat-card>
<mat-card-header>
<mat-card-subtitle>
<h2>Channels Restore</h2>
</mat-card-subtitle>
</mat-card-header>
<mat-card-content>
<div fxLayout="column" fxLayout.gt-sm="row wrap" fxFlex="100" fxLayoutAlign="space-between start">
<h4 fxFlex="100">Restore folder location: {{selNode.channelBackupPath}}/restore</h4>
<button fxFlex="49" fxLayoutAlign="center center" mat-raised-button color="primary" tabindex="1" (click)="onRestoreChannels({})">All Channels Restore</button>
</div>
</mat-card-content>
</mat-card>
</div>
<div class="padding-gap">
<mat-card>
<mat-card-header *ngIf="!allRestoreExists">
<mat-card-subtitle>
<h2>Channels Restore</h2>
<h4 fxLayout="row" fxLayoutAlign="start start" class="pt-2">Restore folder location: {{selNode.channelBackupPath}}/restore</h4>
</mat-card-subtitle>
</mat-card-header>
<mat-card-content class="table-card-content" *ngIf="!channels || channels.data.length<=0">Backup file/s not found!<br>To perform channel restoration, channel backup file/s must be placed at the above location.</mat-card-content>
<mat-card-content class="table-card-content" *ngIf="channels && channels.data.length>0">
<div fxLayout="row" fxLayoutAlign="start start">
<mat-form-field fxFlex="30">
<input matInput (keyup)="applyFilter($event.target.value)" placeholder="Filter">
</mat-form-field>
</div>
<div perfectScrollbar class="table-container mat-elevation-z8">
<mat-progress-bar *ngIf="flgLoading[0]===true" mode="indeterminate"></mat-progress-bar>
<table mat-table #table [dataSource]="channels" matSort [ngClass]="{'mat-elevation-z8 overflow-x-auto error-border': flgLoading[0]==='error','mat-elevation-z8 overflow-x-auto': true}">
<ng-container matColumnDef="chan_point">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Channel Point </th>
<td mat-cell *matCellDef="let channel">{{channel?.channel_point}}</td>
</ng-container>
<ng-container matColumnDef="restore">
<th mat-header-cell *matHeaderCellDef>Restore</th>
<td mat-cell *matCellDef="let channel"><mat-icon color="primary" (click)="onRestoreChannels(channel)">restore</mat-icon></td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: flgSticky;"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
</div>
</mat-card-content>
</mat-card>
</div>
</div>
<div class="padding-gap" *ngIf="allRestoreExists">
<mat-card>
<mat-card-header>
<mat-card-subtitle>
<h2>Channels Restore</h2>
</mat-card-subtitle>
</mat-card-header>
<mat-card-content>
<div fxLayout="column" fxLayout.gt-sm="row wrap" fxFlex="100" fxLayoutAlign="space-between start">
<h4 fxFlex="100">Restore folder location: {{selNode.channelBackupPath}}/restore</h4>
<button fxFlex="49" fxLayoutAlign="center center" mat-raised-button color="primary" tabindex="1"
(click)="onRestoreChannels({})">Restore All Channels</button>
</div>
</mat-card-content>
</mat-card>
</div>
<div class="padding-gap" *ngIf="!allRestoreExists && (!channels || channels.data.length<=0)">
<mat-card>
<mat-card-header>
<mat-card-subtitle>
<h2>Channels Restore</h2>
<h4 fxLayout="row" fxLayoutAlign="start start" class="pt-2">
Restore folder location: {{selNode.channelBackupPath}}/restore
</h4>
</mat-card-subtitle>
</mat-card-header>
<mat-card-content class="table-card-content">
Backup file/s not found!<br>To perform channel restoration, channel backup file/s must be placed at the above location.
</mat-card-content>
</mat-card>
</div>
<div class="padding-gap" *ngIf="channels && channels.data.length>0">
<mat-card>
<mat-card-header *ngIf="!allRestoreExists">
<mat-card-subtitle>
<h2>Channels Restore</h2>
<h4 fxLayout="row" fxLayoutAlign="start start" class="pt-2">Restore folder location:
{{selNode.channelBackupPath}}/restore</h4>
</mat-card-subtitle>
</mat-card-header>
<mat-card-content class="table-card-content">
<div fxLayout="row" fxLayoutAlign="start start">
<mat-form-field fxFlex="30">
<input matInput (keyup)="applyFilter($event.target.value)" placeholder="Filter">
</mat-form-field>
</div>
<div perfectScrollbar class="table-container mat-elevation-z8">
<mat-progress-bar *ngIf="flgLoading[0]===true" mode="indeterminate"></mat-progress-bar>
<table mat-table #table [dataSource]="channels" matSort
[ngClass]="{'mat-elevation-z8 overflow-x-auto error-border': flgLoading[0]==='error','mat-elevation-z8 overflow-x-auto': true}">
<ng-container matColumnDef="chan_point">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Channel Point </th>
<td mat-cell *matCellDef="let channel">{{channel?.channel_point}}</td>
</ng-container>
<ng-container matColumnDef="restore">
<th mat-header-cell *matHeaderCellDef>Restore</th>
<td mat-cell *matCellDef="let channel">
<mat-icon color="primary" (click)="onRestoreChannels(channel)">restore</mat-icon>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: flgSticky;"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
</div>
</mat-card-content>
</mat-card>
</div>
</div>

@ -433,6 +433,7 @@ export class LNDEffects implements OnDestroy {
this.logger.info(postRes);
this.store.dispatch(new RTLActions.CloseSpinner());
this.store.dispatch(new RTLActions.OpenAlert({ width: '70%', data: { type: 'SUCCESS', titleMessage: postRes.message } }));
this.store.dispatch(new RTLActions.SetRestoreChannelsList(postRes.list));
return {
type: RTLActions.RESTORE_CHANNELS_RES,
payload: postRes.message

@ -159,8 +159,11 @@ export class RTLEffects implements OnDestroy {
ofType(RTLActions.IS_AUTHORIZED),
withLatestFrom(this.store.select('root')),
mergeMap(([action, store]: [RTLActions.IsAuthorized, any]) => {
this.store.dispatch(new RTLActions.ClearEffectErrorRoot('IsAuthorized'));
return this.httpClient.post(environment.AUTHENTICATE_API, { password: action.payload })
this.store.dispatch(new RTLActions.ClearEffectErrorRoot('IsAuthorized'));
return this.httpClient.post(environment.AUTHENTICATE_API, {
authenticateWith: (undefined === action.payload || action.payload == null || action.payload === '') ? AuthenticateWith.TOKEN : AuthenticateWith.PASSWORD,
authenticationValue: (undefined === action.payload || action.payload == null || action.payload === '') ? (sessionStorage.getItem('token') ? sessionStorage.getItem('token') : '') : action.payload
})
.pipe(
map((postRes: any) => {
this.logger.info(postRes);

Loading…
Cancel
Save