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 admin mode #737

Merged
merged 2 commits into from
Jun 11, 2019
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
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
define(['../module'], function(module) {
define(['../module'], function (module) {
'use strict'

const checkAdmin = async $currentDataService => {
try {
return await $currentDataService.isAdmin()
} catch (error) {
return false
}
}

module.config([
'$stateProvider',
'BASE_URL',
function($stateProvider, BASE_URL) {
function ($stateProvider, BASE_URL) {
$stateProvider
// Manager
.state('manager', {
Expand Down Expand Up @@ -84,13 +92,7 @@ define(['../module'], function(module) {
resolve: {
isAdmin: [
'$currentDataService',
async $currentDataService => {
try {
return await $currentDataService.isAdmin()
} catch (error) {
return false
}
}
async $currentDataService => { return await checkAdmin($currentDataService) }
]
}
})
Expand Down Expand Up @@ -129,6 +131,10 @@ define(['../module'], function(module) {
return false
}
}
],
isAdmin: [
'$currentDataService',
async $currentDataService => { return await checkAdmin($currentDataService) }
]
}
})
Expand All @@ -145,13 +151,7 @@ define(['../module'], function(module) {
resolve: {
isAdmin: [
'$currentDataService',
async $currentDataService => {
try {
return await $currentDataService.isAdmin()
} catch (error) {
return false
}
}
async $currentDataService => { return await checkAdmin($currentDataService) }
]
}
})
Expand Down Expand Up @@ -190,6 +190,10 @@ define(['../module'], function(module) {
return false
}
}
],
isAdmin: [
'$currentDataService',
async $currentDataService => { return await checkAdmin($currentDataService) }
]
}
})
Expand All @@ -207,13 +211,7 @@ define(['../module'], function(module) {
resolve: {
isAdmin: [
'$currentDataService',
async $currentDataService => {
try {
return await $currentDataService.isAdmin()
} catch (error) {
return false
}
}
async $currentDataService => { return await checkAdmin($currentDataService) }
]
}
})
Expand All @@ -231,13 +229,7 @@ define(['../module'], function(module) {
resolve: {
isAdmin: [
'$currentDataService',
async $currentDataService => {
try {
return await $currentDataService.isAdmin()
} catch (error) {
return false
}
}
async $currentDataService => { return await checkAdmin($currentDataService) }
],
cdbInfo: [
'$cdbEditor',
Expand Down Expand Up @@ -282,6 +274,10 @@ define(['../module'], function(module) {
return false
}
}
],
isAdmin: [
'$currentDataService',
async $currentDataService => { return await checkAdmin($currentDataService) }
]
}
})
Expand All @@ -298,13 +294,7 @@ define(['../module'], function(module) {
resolve: {
isAdmin: [
'$currentDataService',
async $currentDataService => {
try {
return await $currentDataService.isAdmin()
} catch (error) {
return false
}
}
async $currentDataService => { return await checkAdmin($currentDataService) }
],
clusterInfo: [
'$requestService',
Expand Down Expand Up @@ -350,13 +340,7 @@ define(['../module'], function(module) {
resolve: {
isAdmin: [
'$currentDataService',
async $currentDataService => {
try {
return await $currentDataService.isAdmin()
} catch (error) {
return false
}
}
async $currentDataService => { return await checkAdmin($currentDataService) }
],
clusterInfo: [
'$requestService',
Expand Down Expand Up @@ -402,13 +386,7 @@ define(['../module'], function(module) {
resolve: {
isAdmin: [
'$currentDataService',
async $currentDataService => {
try {
return await $currentDataService.isAdmin()
} catch (error) {
return false
}
}
async $currentDataService => { return await checkAdmin($currentDataService) }
],
statusData: [
'$requestService',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ define(['../../module', '../rules/ruleset'], function(controllers, Ruleset) {
extensions,
$fileEditor,
$restartService,
$requestService
$requestService,
isAdmin
) {
super(
$scope,
Expand All @@ -43,6 +44,7 @@ define(['../../module', '../rules/ruleset'], function(controllers, Ruleset) {
this.restartService = $restartService
this.requestService = $requestService
this.currentDecoder = currentDecoder
this.scope.adminMode = isAdmin
}

/**
Expand All @@ -59,7 +61,6 @@ define(['../../module', '../rules/ruleset'], function(controllers, Ruleset) {
this.scope.downloadCsv = (path, name) => this.downloadCsv(path, name)
this.scope.addDetailFilter = (name, value) =>
this.addDetailFilter(name, value)
this.scope.adminMode = this.extensions['admin'] === 'true'
this.scope.isLocal = this.scope.currentDecoder.path === 'etc/decoders'
this.scope.saveDecoderConfig = fileName =>
this.saveDecoderConfig(fileName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ define(['../../module', 'FileSaver'], function(controllers) {
$beautifierJson,
$notificationService,
$groupHandler,
extensions
extensions,
isAdmin
) {
this.scope = $scope
this.state = $state
Expand Down Expand Up @@ -60,6 +61,7 @@ define(['../../module', 'FileSaver'], function(controllers) {
}
})
this.extensions = extensions
this.scope.adminMode = isAdmin
this.scope.addingGroup = false
this.scope.addingAgents = false
this.scope.$on('groupsIsReloaded', () => {
Expand Down Expand Up @@ -230,8 +232,6 @@ define(['../../module', 'FileSaver'], function(controllers) {
this.scope.saveGroupAgentConfig = content =>
this.saveGroupAgentConfig(content)

this.scope.adminMode = this.extensions['admin'] === 'true'

this.scope.$applyAsync()
} catch (err) {
console.error('err ', err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ define(['../../module', './ruleset'], function(controllers, Ruleset) {
extensions,
$fileEditor,
$restartService,
$requestService
$requestService,
isAdmin
) {
super(
$scope,
Expand All @@ -43,6 +44,7 @@ define(['../../module', './ruleset'], function(controllers, Ruleset) {
this.fileEditor = $fileEditor
this.restartService = $restartService
this.requestService = $requestService
this.scope.adminMode = isAdmin
try {
this.filters = JSON.parse(window.localStorage.ruleset) || []
} catch (err) {
Expand Down Expand Up @@ -72,7 +74,6 @@ define(['../../module', './ruleset'], function(controllers, Ruleset) {
this.scope.downloadCsv = (path, name) => this.downloadCsv(path, name)
this.scope.addDetailFilter = (name, value) =>
this.addDetailFilter(name, value)
this.scope.adminMode = this.extensions['admin'] === 'true'
this.scope.isLocal = this.scope.ruleInfo.path === 'etc/rules'
this.scope.saveRuleConfig = fileName => this.saveRuleConfig(fileName)
this.scope.closeEditingFile = () => this.closeEditingFile()
Expand Down