Skip to content

Commit 78f3d6d

Browse files
authored
Hide advanced features behind config flags (#320)
* Hide some of the more advanced features behind environment variables * Fix default login path * Show Console by default * Added showLogs and showConfig flags * Remove unused envvar * fix bad merge * Remove debug variable
1 parent da8e690 commit 78f3d6d

File tree

9 files changed

+83
-37
lines changed

9 files changed

+83
-37
lines changed

ConfigModule.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@ angular
1717
* Make lodash available for injection into controllers
1818
*/
1919
.constant('_', window._)
20+
21+
/**
22+
* Toggles for hiding the more advanced UI features
23+
*/
24+
.constant('AdvancedFeatures', {
25+
showConsole: true,
26+
showEditService: false,
27+
showRemoveService: false,
28+
showCreateSpec: false,
29+
showImportSpec: false,
30+
showFileManager: false,
31+
showServiceHelpIcon: false,
32+
showLogs: false,
33+
showConfig: false,
34+
})
35+
2036
/**
2137
* The back-up (default) administrator e-mail to use for support,
2238
* in case the /api/contact endpoint is unavailable
@@ -46,7 +62,7 @@ angular
4662
.constant('EditSpecPathSuffix', '/store/edit/:specKey/')
4763

4864
// Navigate here when clicking "Sign In"
49-
.constant('SigninUrl', 'https://www.local.ndslabs.org/oauth2/authorize')
65+
.constant('SigninUrl', 'https://www.local.ndslabs.org/login/')
5066

5167
/**
5268
* The name of the product to display in the UI and the URL to link to when clicked

Dockerfile

+8
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ ENV APISERVER_HOST="localhost" \
3030
APISERVER_PATH="/api" \
3131
APISERVER_SECURE="true" \
3232
ANALYTICS_ACCOUNT="" \
33+
SHOW_CONSOLE="true" \
34+
SHOW_CONFIG="false" \
35+
SHOW_LOGS="false" \
36+
SHOW_IMPORT_SPEC="false" \
37+
SHOW_CREATE_SPEC="false" \
38+
SHOW_FILE_MANAGER="false" \
39+
SHOW_EDIT_SERVICE="false" \
40+
SHOW_SVC_HELP_ICON="false" \
3341
SUPPORT_EMAIL="[email protected]"
3442

3543
# Expose port 3000 for ExpressJS

dashboard/catalog/CatalogController.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ angular
2323
* @see https://opensource.ncsa.illinois.edu/confluence/display/~lambert8/3.%29+Controllers%2C+Scopes%2C+and+Partial+Views
2424
*/
2525
.controller('CatalogController', [ '$scope', '$filter', '$interval', '$uibModal', '$location', '$log', '_', 'Analytics', 'NdsLabsApi', 'Project', 'Stack', 'Stacks',
26-
'StackService', 'Specs', 'clipboard', 'Vocabulary', 'RandomPassword', 'AuthInfo', 'ProductName', 'ApiUri', 'DashboardAppPath', 'HomePathSuffix',
27-
function($scope, $filter, $interval, $uibModal, $location, $log, _, Analytics, NdsLabsApi, Project, Stack, Stacks, StackService, Specs, clipboard, Vocabulary, RandomPassword, AuthInfo, ProductName, ApiUri, DashboardAppPath, HomePathSuffix) {
26+
'StackService', 'Specs', 'clipboard', 'Vocabulary', 'RandomPassword', 'AuthInfo', 'ProductName', 'ApiUri', 'DashboardAppPath', 'HomePathSuffix', 'AdvancedFeatures',
27+
function($scope, $filter, $interval, $uibModal, $location, $log, _, Analytics, NdsLabsApi, Project, Stack, Stacks, StackService, Specs, clipboard, Vocabulary, RandomPassword, AuthInfo, ProductName, ApiUri, DashboardAppPath, HomePathSuffix, AdvancedFeatures) {
2828
"use strict";
2929

30+
$scope.showCreateSpec = AdvancedFeatures.showCreateSpec;
31+
$scope.showImportSpec = AdvancedFeatures.showImportSpec;
3032
$scope.productName = ProductName;
3133

3234
$scope.tags = { all: [], selected: [] };

dashboard/catalog/catalog.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ <h3>Applications</h3>
3333
</button>
3434
</div>
3535
<div class="input-group-btn">
36-
<button id="importApplicationBtn" type="button" class="btn btn-secondary" ng-click="openImport()" style="border-radius:0;">
36+
<button id="importApplicationBtn" ng-if="showImportSpec" type="button" class="btn btn-secondary" ng-click="openImport()" style="border-radius:0;">
3737
<i class="fa fa-fw fa-upload"></i> Import
3838
</button>
3939
</div>
40-
<div class="input-group-btn">
40+
<div class="input-group-btn" ng-if="showCreateSpec">
4141
<a id="createApplicationBtn" type="button" class="btn btn-primary" href="/dashboard/store/add">
4242
<i class="fa fa-fw fa-plus"></i> Create
4343
</a>

dashboard/dashboard/DashboardController.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,20 @@ angular
99
* @author lambert8
1010
* @see https://opensource.ncsa.illinois.edu/confluence/display/~lambert8/3.%29+Controllers%2C+Scopes%2C+and+Partial+Views
1111
*/
12-
.controller('DashboardController', [ '$scope', 'Loading', '$log', '$routeParams', '$location', '$interval', '$q', '$window', '$filter', '$uibModal', '_', 'Analytics', 'Project', 'RandomPassword', 'Stack', 'Stacks', 'Specs', 'AutoRefresh', 'AuthInfo',
13-
'StackService', 'NdsLabsApi', 'ProductName', 'FileManager', 'QuickStart',
14-
function($scope, Loading, $log, $routeParams, $location, $interval, $q, $window, $filter, $uibModal, _, Analytics, Project, RandomPassword, Stack, Stacks, Specs, AutoRefresh, AuthInfo, StackService, NdsLabsApi,
15-
ProductName, FileManager, QuickStart) {
12+
.controller('DashboardController', [ '$scope', 'Loading', '$log', '$routeParams', '$location', '$interval', '$q', '$window', '$filter', '$uibModal', '_', 'Analytics', 'Project', 'RandomPassword', 'Stack', 'Stacks', 'Specs', 'AutoRefresh', 'AuthInfo', 'StackService', 'NdsLabsApi', 'ProductName', 'FileManager', 'QuickStart', 'AdvancedFeatures',
13+
function($scope, Loading, $log, $routeParams, $location, $interval, $q, $window, $filter, $uibModal, _, Analytics, Project, RandomPassword, Stack, Stacks, Specs, AutoRefresh, AuthInfo, StackService, NdsLabsApi, ProductName, FileManager, QuickStart, AdvancedFeatures) {
1614
"use strict";
1715

1816
if ($routeParams.quickstart) {
1917
QuickStart.get($routeParams.quickstart).launch();
2018
}
21-
19+
20+
$scope.showRemoveService = AdvancedFeatures.showRemoveService;
21+
$scope.showServiceHelpIcon = AdvancedFeatures.showServiceHelpIcon;
22+
$scope.showEditService = AdvancedFeatures.showEditService;
23+
$scope.showConsole = AdvancedFeatures.showConsole;
24+
$scope.showConfigColumn = AdvancedFeatures.showConfig;
25+
$scope.showLogsColumn = AdvancedFeatures.showLogs;
2226
$scope.fileManager = FileManager;
2327

2428
$scope.productName = ProductName;

dashboard/dashboard/dashboard.html

+28-24
Original file line numberDiff line numberDiff line change
@@ -79,24 +79,21 @@ <h4>
7979
<!-- Application Services -->
8080
<div class="row">
8181
<div class="col-sm-12">
82+
8283
<!-- List off our stack's services here -->
8384
<div class="table-responsive">
8485
<table class="table table-striped table-hover">
8586
<thead>
8687
<tr>
8788
<td width="15%" class="text-center"><strong>Status</strong></td>
88-
<td width="20%"><strong>Name</strong></td>
89-
<td width="20%" tooltip-append-to-body="true" uib-tooltip="A unique identifier for each part of an application instance"><strong>ID</strong></td>
90-
<td width="10%" class="text-center" tooltip-append-to-body="true" uib-tooltip="Advanced user terminal, allowing for arbitrary console commands"><strong>Console</strong></td>
91-
<td width="10%" class="text-center" tooltip-append-to-body="true" uib-tooltip="{{ (stack.status === 'stopped' ? 'Edit' : 'View') + ' the configuration for part of an application' }}">
92-
<strong ng-if="stack.status !== 'stopped'">Config</strong>
93-
<strong ng-if="stack.status === 'stopped'">Edit</strong>
94-
</td>
95-
<td width="10%" class="text-center" tooltip-append-to-body="true" uib-tooltip="{{ (stack.status === 'stopped' ? 'Remove an optional ' : 'View the logs for ') + 'part of an application' }}">
96-
<strong ng-if="stack.status !== 'stopped'">Logs</strong>
97-
<strong ng-if="stack.status === 'stopped'">Remove</strong>
98-
</td>
99-
<td width="10%" class="text-center" tooltip-append-to-body="true" uib-tooltip="Additional instructions or documentation for a part of an application"><strong>Help</strong></td>
89+
<td><strong>Name</strong></td>
90+
<td tooltip-append-to-body="true" uib-tooltip="A unique identifier for each part of an application instance"><strong>ID</strong></td>
91+
<td width="5%" class="text-center" ng-if="showConsole" tooltip-append-to-body="true" uib-tooltip="Advanced user terminal, allowing for arbitrary console commands"><strong>Console</strong></td>
92+
<td width="5%" class="text-center" ng-if="showEditService && stack.status === 'stopped'" tooltip-append-to-body="true" uib-tooltip="Edit the configuration for part of an application"><strong>Edit</strong></td>
93+
<td width="5%" class="text-center" ng-if="showConfigColumn && stack.status !== 'stopped'" tooltip-append-to-body="true" uib-tooltip="View the configuration for part of an application"><strong >Config</strong></td>
94+
<td width="5%" class="text-center" ng-if="showLogsColumn && stack.status !== 'stopped'" tooltip-append-to-body="true" uib-tooltip="View the logs for part of an application"><strong >Logs</strong></td>
95+
<td width="5%" class="text-center" ng-if="showRemoveService && stack.status === 'stopped'" tooltip-append-to-body="true" uib-tooltip="Remove an optional part of an application"><strong>Remove</strong></td>
96+
<td width="5%" class="text-center" ng-if="showServiceHelpIcon" tooltip-append-to-body="true" uib-tooltip="Additional instructions or documentation for a part of an application"><strong>Help</strong></td>
10097
</tr>
10198
</thead>
10299
<tbody>
@@ -116,8 +113,8 @@ <h4>
116113
</td>
117114

118115
<!-- The Name of the Running Service and link to endpoint, if applicable -->
119-
<td tooltip-append-to-body="true" uib-tooltip="A friendly label for this application instance">
120-
{{ svc.service | specProperty:'label' }}
116+
<td>
117+
<span tooltip-append-to-body="true" uib-tooltip="A friendly label for this application instance">{{ svc.service | specProperty:'label' }}</span>
121118

122119
<a class="btn btn-link btn-sm" ng-repeat="endpt in svc.endpoints track by endpt.port" id="endpointLink"
123120
tooltip-append-to-body="true" uib-tooltip="Navigate to {{ svc.service | capitalize }} port {{ endpt.port }}"
@@ -134,40 +131,47 @@ <h4>
134131
<td tooltip-append-to-body="true" uib-tooltip="A unique identifier for this part of the application instance"><span id="serviceIdText">{{ svc.id }}</span></td>
135132

136133
<!-- Console -->
137-
<td class="text-center" tooltip-append-to-body="true" uib-tooltip="{{ (stack.status === 'stopped' ? 'The application must be launched before the Console can be accessed' : 'Advanced user terminal, allowing for arbitrary console commands') }}">
134+
<td class="text-center" ng-if="showConsole" tooltip-append-to-body="true" uib-tooltip="{{ (stack.status === 'stopped' ? 'The application must be launched before the Console can be accessed' : 'Advanced user terminal, allowing for arbitrary console commands') }}">
138135
<a id="consoleBtn"
139136
ga-track-event="['application', 'console', svc.service, 1, true]"
140137
type="button" class="btn btn-default btn-xs" target="_blank" ng-href="/dashboard/home/{{ stack.id }}/console/{{ svc.service }}"
141138
ng-disabled="svc.status !== 'ready'">
142139
<i class="fa fa-terminal"></i>
143140
</a>
144141
</td>
142+
143+
<!-- Edit Config buttons -->
144+
<td class="text-center" ng-if="showEditService" tooltip-append-to-body="true" uib-tooltip="Edit the configuration for this part of the application">
145145

146-
<!-- View/Edit Config buttons -->
147-
<td class="text-center" tooltip-append-to-body="true" uib-tooltip="{{ (stack.status === 'stopped' ? 'View' : 'Edit') + ' the configuration for this part of the application' }}">
148146
<!-- ng-click="showConfig(svc)" -->
149147
<a id="editServiceBtn" type="button" class="btn btn-default btn-xs" ng-href="/dashboard/home/{{ stack.id }}/edit/{{ svc.service }}"
150148
ng-if="stack.status === 'stopped'" ga-track-event="['application', 'edit', svc.service, 1, true]">
151149
<i class="fa fa-wrench"></i>
152150
</a>
153-
151+
</td>
152+
153+
<!-- View Config buttons -->
154+
<td class="text-center" ng-if="showConfigColumn && stack.status !== 'stopped'">
154155
<button id="viewConfigBtn" type="button" class="btn btn-default btn-xs" ng-click="showConfig(svc)"
155-
ng-if="stack.status !== 'stopped' && (!_.isEmpty(svc.config) || svc.endpoints.length > 0)">
156+
ng-if="!_.isEmpty(svc.config) || svc.endpoints.length > 0">
156157
<i class="fa fa-puzzle-piece"></i>
157158
</button>
158159
</td>
159160

160161
<!-- View Logs of Running Service, or Remove Stopped Service -->
161-
<td class="text-center">
162+
<td class="text-center" ng-if="showLogsColumn && stack.status !== 'stopped'">
162163
<!-- View logs button -->
163164
<button type="button" class="btn btn-xs btn-default" id="viewLogsBtn"
164165
uib-tooltip="View the logs for this part of the application instance"
165-
ng-if="stack.status !== 'stopped'" tooltip-append-to-body="true"
166+
tooltip-append-to-body="true"
166167
ng-disabled="stack.status === 'stopped'" tooltip-placement="left" ng-click="showLogs(svc)">
167168
<i class="fa fa-fw fa-file-text" ng-class="{ 'animated faa-vertical': stack.status === 'starting' && (svc.status === 'waiting' || svc.status === 'starting') }"></i>
168169
</button>
169170

170-
<!-- Remove service from stack button -->
171+
</td>
172+
173+
<!-- Remove optional service from stack -->
174+
<td class="text-center" ng-if="showRemoveService && stack.status === 'stopped'">
171175
<button type="button" ng-disabled="stack.services | isRecursivelyRequired:svc" id="removeBtn"
172176
uib-tooltip="Remove this optional part from this application instance"
173177
ng-if="stack.status === 'stopped' && svc.service !== stack.key && !_.find((stack.key | requirements), [ 'key', svc.service ])"
@@ -178,7 +182,7 @@ <h4>
178182
</td>
179183

180184
<!-- Help Link -->
181-
<td class="text-center"><a id="helpLink" tooltip-append-to-body="true" uib-tooltip="Additional instructions or documentation for a part of an application" ng-if="svc.service | specProperty:'info'" ng-href="{{ svc.service | specProperty:'info' }}" target="_blank" ga-track-event="['application', 'help', svc.service, 1, true]"><i class="fa fa-fw fa-question-circle"></i></a></td>
185+
<td class="text-center" ng-if="showServiceHelpIcon"><a id="helpLink" tooltip-append-to-body="true" uib-tooltip="Additional instructions or documentation for a part of an application" ng-if="svc.service | specProperty:'info'" ng-href="{{ svc.service | specProperty:'info' }}" target="_blank" ga-track-event="['application', 'help', svc.service, 1, true]"><i class="fa fa-fw fa-question-circle"></i></a></td>
182186
</tr>
183187

184188
<!-- Add an artificial row (if necessary) for optional services -->
@@ -200,7 +204,7 @@ <h4>
200204

201205
<td colspan="4">{{ stack.selectedOption | specProperty:'description' }}</td>
202206

203-
<td class="text-center">
207+
<td class="text-center" ng-if="showServiceHelpIcon">
204208
<a id="addServiceHelpLink" ng-if="stack.selectedOption | specProperty:'info'" ng-href="{{ stack.selectedOption | specProperty:'info' }}" target="_blank">
205209
<i class="fa fa-fw fa-question-circle"></i>
206210
</a>

entrypoint.sh

+11
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,16 @@
1616
# Substitute the ANALYTICS_ACCOUNT passed in by "docker run -e" or kubernetes
1717
/bin/sed -i -e "s#^\.constant('GaAccount', .*)#.constant('GaAccount', '${ANALYTICS_ACCOUNT}')#" "$BASEDIR/ConfigModule.js"
1818

19+
# In lieu of actual user management, some instance-wide flags to toggle the more advanced features
20+
/bin/sed -i -e "s#^\showConfig: .*,#showConfig: ${SHOW_CONFIG:-false},#" "$BASEDIR/ConfigModule.js"
21+
/bin/sed -i -e "s#^\showLogs: .*,#showLogs: ${SHOW_LOGS:-false},#" "$BASEDIR/ConfigModule.js"
22+
/bin/sed -i -e "s#^\showConsole: .*,#showConsole: ${SHOW_CONSOLE:-true},#" "$BASEDIR/ConfigModule.js"
23+
/bin/sed -i -e "s#^\showEditService: .*,#showEditService: ${SHOW_EDIT_SERVICE:-false},#" "$BASEDIR/ConfigModule.js"
24+
/bin/sed -i -e "s#^\showRemoveService: .*,#showRemoveService: ${SHOW_REMOVE_SERVICE:-false},#" "$BASEDIR/ConfigModule.js"
25+
/bin/sed -i -e "s#^\showServiceHelpIcon: .*,#showServiceHelpIcon: ${SHOW_SERVICE_HELP_ICON:-false},#" "$BASEDIR/ConfigModule.js"
26+
/bin/sed -i -e "s#^\showCreateSpec: .*,#showCreateSpec: ${SHOW_CREATE_SPEC:-false},#" "$BASEDIR/ConfigModule.js"
27+
/bin/sed -i -e "s#^\showImportSpec: .*,#showImportSpec: ${SHOW_IMPORT_SPEC:-false},#" "$BASEDIR/ConfigModule.js"
28+
/bin/sed -i -e "s#^\showFileManager: .*,#showFileManager: ${SHOW_FILE_MANAGER:-false},#" "$BASEDIR/ConfigModule.js"
29+
1930
# Start ExpressJS
2031
node server.js

shared/navbar/NavbarController.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ angular
2929
* @author lambert8
3030
* @see https://opensource.ncsa.illinois.edu/confluence/display/~lambert8/3.%29+Controllers%2C+Scopes%2C+and+Partial+Views
3131
*/
32-
.controller('NavbarController', [ '$scope', '$rootScope', '$window', '$location', '$cookies', 'Project', 'AuthInfo', 'ProductName', 'ProductUrl', 'HelpLinks', 'FileManager', 'AutoRefresh', 'ReturnRoute', 'CookieOptions', 'SigninUrl',
33-
function($scope, $rootScope, $window, $location, $cookies, Project, AuthInfo, ProductName, ProductUrl, HelpLinks, FileManager, AutoRefresh, ReturnRoute, CookieOptions, SigninUrl) {
32+
.controller('NavbarController', [ '$scope', '$rootScope', '$window', '$location', '$cookies', 'Project', 'AuthInfo', 'ProductName', 'ProductUrl', 'HelpLinks', 'FileManager', 'AutoRefresh', 'ReturnRoute', 'CookieOptions', 'SigninUrl', 'AdvancedFeatures',
33+
function($scope, $rootScope, $window, $location, $cookies, Project, AuthInfo, ProductName, ProductUrl, HelpLinks, FileManager, AutoRefresh, ReturnRoute, CookieOptions, SigninUrl, AdvancedFeatures) {
3434
"use strict"
3535

3636
// Enable JS dropdowns on the navbar
@@ -59,6 +59,7 @@ angular
5959
$scope.signinLink = $scope.enableOAuth ? SigninUrl : '/login/' + ($rootScope.rd ? 'rd=' : '');
6060
$scope.helpLinks = HelpLinks;
6161

62+
$scope.showFileManager = AdvancedFeatures.showFileManager;
6263
$scope.fileManager = FileManager;
6364
$scope.launchingFileManager = FileManager.busy;
6465
$scope.$watch('fileManager.busy', function(newValue, oldValue) {

shared/navbar/navbar.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</li>
3131

3232
<!-- Then draw our Manage Files button -->
33-
<li>
33+
<li ng-if="showFileManager">
3434
<a id="filesNav" type="button" ng-click="fileManager.launch()">
3535
<i class="fa fa-fw" ng-class="{ 'fa-spinner fa-pulse': launchingFileManager, 'fa-files-o': !launchingFileManager }"></i> Files
3636
</a>

0 commit comments

Comments
 (0)