-
Notifications
You must be signed in to change notification settings - Fork 640
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
155 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
angular.module('theHiveControllers').controller('AdminUiSettingsCtrl', function(UiSettingsSrv, uiConfig) { | ||
var self = this; | ||
|
||
self.save = function(/*form*/) { | ||
self.settingsKeys.forEach(function(key) { | ||
//if(form[key].$dirty) { | ||
if(!self.currentSettings[key]) { | ||
UiSettingsSrv.create(key, self.configs[key]); | ||
} else { | ||
UiSettingsSrv.update(self.currentSettings[key].id, key, self.configs[key]); | ||
} | ||
//} | ||
}); | ||
}; | ||
|
||
self.loadSettings = function() { | ||
self.settingsKeys = UiSettingsSrv.keys; | ||
self.currentSettings = uiConfig; | ||
|
||
self.configs = {}; | ||
self.settingsKeys.forEach(function(key) { | ||
self.configs[key] = (uiConfig[key] || {}).value; | ||
}); | ||
}; | ||
|
||
self.loadSettings(); | ||
|
||
}); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
(function() { | ||
'use strict'; | ||
angular.module('theHiveServices').factory('UiSettingsSrv', function(ListSrv, $q) { | ||
|
||
var settings = null; | ||
|
||
return { | ||
keys: [ | ||
'hideEmptyCaseButton' | ||
], | ||
clearCache: function() { | ||
settings = null; | ||
}, | ||
|
||
get: function(name) { | ||
return settings[name]; | ||
}, | ||
|
||
create: function(name, value) { | ||
return ListSrv.save({listId: 'ui_settings'}, { | ||
value: { | ||
name: name, | ||
value: value | ||
} | ||
}).$promise; | ||
}, | ||
|
||
update: function(id, name, value) { | ||
return ListSrv.update({itemId: id}, { | ||
value: { | ||
name: name, | ||
value: value | ||
} | ||
}).$promise; | ||
}, | ||
|
||
all: function(force) { | ||
var deferred = $q.defer(); | ||
|
||
if(settings === null || force) { | ||
ListSrv.query({listId: 'ui_settings'}, {}, function(response) { | ||
var json = response.toJSON(); | ||
|
||
settings = {}; | ||
|
||
_.each(_.keys(json), function(key) { | ||
var setting = json[key]; | ||
|
||
settings[setting.name] = setting; | ||
settings[setting.name].id = key; | ||
}); | ||
|
||
deferred.resolve(settings); | ||
}, function(response) { | ||
deferred.reject(response); | ||
}); | ||
} else { | ||
deferred.resolve(settings); | ||
} | ||
|
||
return deferred.promise; | ||
} | ||
}; | ||
}); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<form name="settingsForm" class="form-horizontal" ng-submit="$vm.save(settingsForm)" novalidate> | ||
<div class="box"> | ||
<div class="box-header"> | ||
<h3 class="box-title">UI Settings</h3> | ||
</div> | ||
<div class="box-body"> | ||
|
||
<div class="form-group"> | ||
<label class="col-md-3 control-label">Hide <em>Empty Case</em> button</label> | ||
<div class="col-md-9"> | ||
<div class="checkbox"> | ||
<label> | ||
<input name="hideEmptyCaseButton" type="checkbox" ng-model="$vm.configs.hideEmptyCaseButton"> Check this to disallow creating empty cases | ||
</label> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="mt-s"> | ||
<button class="btn btn-primary pull-right" ng-disabled="settingsForm.$invalid" type="submit">Save</button> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
</div> |