@@ -19,7 +19,8 @@ export const networkService = { | |||
deleteNetwork, | |||
requestNetworkKeys, | |||
retrieveNetworkKeys, | |||
getNetworkBackups | |||
getNetworkBackups, | |||
getLogFlag, enableLog, disableLog | |||
}; | |||
function getAllNetworks(userId, messages, errors) { | |||
@@ -92,3 +93,19 @@ function getNetworkBackups(userId, networkId, messages, errors) { | |||
return fetch(`${config.apiUrl}/users/${userId}/networks/${networkId}/backups`, util.getWithAuth()) | |||
.then(util.handleCrudResponse(messages, errors)); | |||
} | |||
function getLogFlag(messages, errors) { | |||
return fetch(`${config.apiUrl}/me/nodes/logs/status`, util.getWithAuth()) | |||
.then(util.handleCrudResponse(messages, errors)); | |||
} | |||
function disableLog(messages, errors) { | |||
return fetch(`${config.apiUrl}/me/nodes/logs/stop`, util.postWithAuth()) | |||
.then(util.handleBasicResponse(messages, errors)); | |||
} | |||
function enableLog(disableInDays, messages, errors) { | |||
let ttlDaysParam = ''; | |||
if (typeof dispatchEvent !== 'undefined' && disableInDays !== null) ttlDaysParam = '?ttlDays=' + disableInDays; | |||
return fetch(`${config.apiUrl}/me/nodes/logs/start` + ttlDaysParam, util.postWithAuth()) | |||
.then(util.handleBasicResponse(messages, errors)); | |||
} |
@@ -10,7 +10,7 @@ const state = { | |||
loading: { | |||
networks: false, network: false, stopping: false, restoring: false, deleting: false, | |||
nearestRegions: false, startingNetwork: false, networkStatuses: false, networkNodes: false, | |||
requestNetworkKeys: false, retrieveNetworkKeys: false, queueBackup: false | |||
requestNetworkKeys: false, retrieveNetworkKeys: false, queueBackup: false, managingLogFlag: false | |||
}, | |||
creating: null, | |||
error: null, | |||
@@ -24,6 +24,7 @@ const state = { | |||
networkKeysRequested: null, | |||
restoreKey: null, | |||
backups: null, | |||
logFlag: null | |||
}; | |||
const actions = { | |||
@@ -154,6 +155,25 @@ const actions = { | |||
error => commit('retrieveNetworkKeysFailure', error)); | |||
}, | |||
getLogFlag({ commit }, { messages, errors }) { | |||
commit('getLogFlagRequest'); | |||
networkService.getLogFlag(messages, errors) | |||
.then(logFlag => commit('getLogFlagSuccess', logFlag), | |||
error => commit('getLogFlagFailure', error)); | |||
}, | |||
disableLog({ commit }, { messages, errors }) { | |||
commit('disableLogRequest'); | |||
networkService.disableLog(messages, errors) | |||
.then(ok => commit('disableLogSuccess'), error => commit('disableLogFailure', error)); | |||
}, | |||
enableLog({ commit, dispatch }, { disableInDays, messages, errors }) { | |||
commit('enableLogRequest'); | |||
networkService.enableLog(disableInDays, messages, errors) | |||
.then(ok => commit('enableLogSuccess', disableInDays), | |||
error => commit('enableLogFailure', error)) | |||
.then(r => dispatch('getLogFlag', { messages: messages, errors: errors })); | |||
}, | |||
resetRestoreKey({ commit }) { commit('resetRestoreKey'); } | |||
}; | |||
@@ -333,6 +353,41 @@ const mutations = { | |||
state.backups = null; | |||
state.loading.queueBackup = false; | |||
state.error = { error }; | |||
}, | |||
getLogFlagRequest(state) { | |||
state.logFlag = null; | |||
state.loading.managingLogFlag = true; | |||
}, | |||
getLogFlagSuccess(state, logFlag) { | |||
state.logFlag = logFlag; | |||
state.loading.managingLogFlag = false; | |||
}, | |||
getLogFlagFailure(state, error) { | |||
state.logFlag = null; | |||
state.loading.managingLogFlag = false; | |||
state.error = { error }; | |||
}, | |||
disableLogRequest(state) { | |||
state.loading.managingLogFlag = true; | |||
}, | |||
disableLogSuccess(state) { | |||
state.logFlag = null; | |||
state.loading.managingLogFlag = false; | |||
}, | |||
disableLogFailure(state, error) { | |||
state.loading.managingLogFlag = false; | |||
state.error = { error }; | |||
}, | |||
enableLogRequest(state) { | |||
state.loading.managingLogFlag = true; | |||
}, | |||
enableLogSuccess(state) { | |||
state.logFlag = null; | |||
state.loading.managingLogFlag = false; | |||
}, | |||
enableLogFailure(state, error) { | |||
state.loading.managingLogFlag = false; | |||
state.error = { error }; | |||
} | |||
}; | |||
@@ -129,6 +129,39 @@ | |||
<div v-else-if="this.statsError === null" v-html="messages.restore_not_possible_nodes_exist_html" /> | |||
</div> | |||
<hr/> | |||
<div v-if="loading && loading.managingLogFlag"><img :src="loadingImgSrc" /></div> | |||
<div else> | |||
<div v-if="logFlag.flag"> | |||
{{ messages.node_logs_enabled }} {{ messages.node_logs_until }} | |||
{{ messages.date_format_app_data_epoch_time.parseDateMessage(logFlag.expireAt, messages) }} | |||
<div v-if="this.isSelfNet"> | |||
<button @click="disableLogs()" class="btn btn-primary" | |||
:disabled="loading && loading.managingLogFlag"> | |||
{{ messages.button_node_logs_disable }} | |||
</button> | |||
<br/> | |||
<label for="logsExpirationDays">{{ messages.node_logs_disable_after }}</label> | |||
<select v-model="this.logsExpirationDays" name="logsExpirationDays" class="form-control"> | |||
<option v-for="day in this.logsExpirationDaysMax" :value="day">{{ day }}</option> | |||
</select> | |||
<button @click="enableLogs(logsExpirationDays)" class="btn btn-primary" | |||
:disabled="loading && loading.managingLogFlag"> | |||
{{ messages.button_node_logs_set_disable_after }} | |||
</button> | |||
</div> | |||
</div> | |||
<div v-else> | |||
{{ messages.node_logs_disabled }} | |||
<div v-if="this.isSelfNet"> | |||
<button @click="enableLogs()" class="btn btn-primary" | |||
:disabled="loading && loading.managingLogFlag"> | |||
{{ messages.button_label_restore }} | |||
</button> | |||
</div> | |||
</div> | |||
</div> | |||
<div v-if="configs.sageLauncher"> | |||
<div class="text-danger"><h4>{{messages.title_network_danger_zone}}</h4></div> | |||
<div v-if="errors.has('node')" class="invalid-feedback d-block">{{ errors.first('node') }}</div> | |||
@@ -181,13 +214,14 @@ | |||
restoreKeyPassword: null, | |||
loadingImgSrc: loadingImgSrc, | |||
checkingForUpgrade: null, | |||
upgradeRefresher: null | |||
upgradeRefresher: null, | |||
logsExpirationDays: null | |||
}; | |||
}, | |||
computed: { | |||
...mapState('networks', [ | |||
'network', 'newNodeNotification', 'networkStatuses', 'networkNodes', 'networkKeysRequested', | |||
'deletedNetworkUuid', 'loading', 'restoreKey', 'backups' | |||
'deletedNetworkUuid', 'loading', 'restoreKey', 'backups', 'logFlag' | |||
]), | |||
...mapState('system', ['messages', 'configs', 'appLinks', 'upgradeCheck', 'upgrading']), | |||
showSetupHelp () { | |||
@@ -237,13 +271,16 @@ | |||
isInReadyToRestoreState: function() { | |||
return this.network && this.network.state === 'restoring' && (!this.stats || this.stats.percent === 100) | |||
&& this.networkNodes && this.networkNodes.length === 1 | |||
}, | |||
logsExpirationDaysMax: function() { | |||
return 7; | |||
} | |||
}, | |||
methods: { | |||
...mapActions('networks', [ | |||
'getNetworkById', 'deleteNetwork', 'getStatusesByNetworkId', 'getNodesByNetworkId', | |||
'stopNetwork', 'queueBackup', 'restoreNetwork', 'deleteNetwork', 'requestNetworkKeys', | |||
'retrieveNetworkKeys', 'getBackups', 'resetRestoreKey' | |||
'retrieveNetworkKeys', 'getBackups', 'resetRestoreKey', 'getLogFlag', 'disableLog', 'enableLog' | |||
]), | |||
...mapActions('system', ['getAppLinks', 'loadSystemConfigs', 'checkForUpgrade', 'upgrade']), | |||
refreshStatus (userId) { | |||
@@ -261,6 +298,8 @@ | |||
messages: this.messages, | |||
errors: this.errors | |||
}); | |||
this.getLogFlag({ userId: userId, messages: this.messages, errors: this.errors }); | |||
if (this.backups === null || this.refresher === null) { | |||
// note about the second part of the condition above: if refreshes is turned on, then fetch backups | |||
// from BE only once | |||
@@ -347,6 +386,14 @@ | |||
errors: this.errors | |||
}); | |||
}, | |||
disableLogs () { | |||
this.errors.clear(); | |||
this.diableLog({messages: this.messages, errors: this.errors}); | |||
}, | |||
enableLogs (expirationDays) { | |||
this.errors.clear(); | |||
this.enableLog({disableInDays: expirationDays, messages: this.messages, errors: this.errors}); | |||
}, | |||
doUpgrade () { | |||
this.upgrade(); | |||
} | |||