summaryrefslogtreecommitdiffstats
path: root/web/react/utils
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2015-09-18 18:11:01 -0400
committerHarrison Healey <harrisonmhealey@gmail.com>2015-09-18 18:11:01 -0400
commit679e20aa4b74b468c7e372c77219142599f2385d (patch)
tree544b2a5f932dc2a2cbd27a800fddcb4ce07b057e /web/react/utils
parent676f2a63999e51a03f2f57209ce4c9f106683da4 (diff)
parentcdf813f07b207c14bb9fa03f38d734b45e40823e (diff)
downloadchat-679e20aa4b74b468c7e372c77219142599f2385d.tar.gz
chat-679e20aa4b74b468c7e372c77219142599f2385d.tar.bz2
chat-679e20aa4b74b468c7e372c77219142599f2385d.zip
Merge pull request #709 from mattermost/PLT-11
PLT-11 adding config for logs to UI
Diffstat (limited to 'web/react/utils')
-rw-r--r--web/react/utils/async_client.jsx26
-rw-r--r--web/react/utils/client.jsx31
-rw-r--r--web/react/utils/utils.jsx23
3 files changed, 79 insertions, 1 deletions
diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx
index 3e23e5c33..ed228f6c4 100644
--- a/web/react/utils/async_client.jsx
+++ b/web/react/utils/async_client.jsx
@@ -345,6 +345,32 @@ export function getLogs() {
);
}
+export function getConfig() {
+ if (isCallInProgress('getConfig')) {
+ return;
+ }
+
+ callTracker.getConfig = utils.getTimestamp();
+ client.getConfig(
+ (data, textStatus, xhr) => {
+ callTracker.getConfig = 0;
+
+ if (xhr.status === 304 || !data) {
+ return;
+ }
+
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECIEVED_CONFIG,
+ config: data
+ });
+ },
+ (err) => {
+ callTracker.getConfig = 0;
+ dispatchError(err, 'getConfig');
+ }
+ );
+}
+
export function findTeams(email) {
if (isCallInProgress('findTeams_' + email)) {
return;
diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx
index ba3042d78..c9eb09c00 100644
--- a/web/react/utils/client.jsx
+++ b/web/react/utils/client.jsx
@@ -297,7 +297,7 @@ export function getLogs(success, error) {
dataType: 'json',
contentType: 'application/json',
type: 'GET',
- success: success,
+ success,
error: function onError(xhr, status, err) {
var e = handleError('getLogs', xhr, status, err);
error(e);
@@ -305,6 +305,35 @@ export function getLogs(success, error) {
});
}
+export function getConfig(success, error) {
+ $.ajax({
+ url: '/api/v1/admin/config',
+ dataType: 'json',
+ contentType: 'application/json',
+ type: 'GET',
+ success,
+ error: function onError(xhr, status, err) {
+ var e = handleError('getConfig', xhr, status, err);
+ error(e);
+ }
+ });
+}
+
+export function saveConfig(config, success, error) {
+ $.ajax({
+ url: '/api/v1/admin/save_config',
+ dataType: 'json',
+ contentType: 'application/json',
+ type: 'POST',
+ data: JSON.stringify(config),
+ success,
+ error: function onError(xhr, status, err) {
+ var e = handleError('saveConfig', xhr, status, err);
+ error(e);
+ }
+ });
+}
+
export function getMeSynchronous(success, error) {
var currentUser = null;
$.ajax({
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index 032cf4ff4..074591489 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -54,6 +54,29 @@ export function isTestDomain() {
return false;
}
+export function isInRole(roles, inRole) {
+ var parts = roles.split(' ');
+ for (var i = 0; i < parts.length; i++) {
+ if (parts[i] === inRole) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+export function isAdmin(roles) {
+ if (isInRole(roles, 'admin')) {
+ return true;
+ }
+
+ if (isInRole(roles, 'system_admin')) {
+ return true;
+ }
+
+ return false;
+}
+
export function getDomainWithOutSub() {
var parts = window.location.host.split('.');