Merge pull request #394 from mattermost/mm-1410
MM-1410 Initial implementaiton of import from Slack
Этот коммит содержится в:
@@ -397,7 +397,7 @@ func JoinChannel(c *Context, channelId string, role string) {
|
||||
}
|
||||
}
|
||||
|
||||
func JoinDefaultChannels(c *Context, user *model.User, channelRole string) *model.AppError {
|
||||
func JoinDefaultChannels(user *model.User, channelRole string) *model.AppError {
|
||||
// We don't call JoinChannel here since c.Session is not populated on user creation
|
||||
|
||||
var err *model.AppError = nil
|
||||
|
||||
57
api/import.go
Обычный файл
57
api/import.go
Обычный файл
@@ -0,0 +1,57 @@
|
||||
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
l4g "code.google.com/p/log4go"
|
||||
"github.com/mattermost/platform/model"
|
||||
"github.com/mattermost/platform/utils"
|
||||
)
|
||||
|
||||
//
|
||||
// Import functions are sutible for entering posts and users into the database without
|
||||
// some of the usual checks. (IsValid is still run)
|
||||
//
|
||||
|
||||
func ImportPost(post *model.Post) {
|
||||
post.Hashtags, _ = model.ParseHashtags(post.Message)
|
||||
|
||||
if result := <-Srv.Store.Post().Save(post); result.Err != nil {
|
||||
l4g.Debug("Error saving post. user=" + post.UserId + ", message=" + post.Message)
|
||||
}
|
||||
}
|
||||
|
||||
func ImportUser(user *model.User) *model.User {
|
||||
user.MakeNonNil()
|
||||
if len(user.Props["theme"]) == 0 {
|
||||
user.AddProp("theme", utils.Cfg.TeamSettings.DefaultThemeColor)
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.User().Save(user); result.Err != nil {
|
||||
l4g.Error("Error saving user. err=%v", result.Err)
|
||||
return nil
|
||||
} else {
|
||||
ruser := result.Data.(*model.User)
|
||||
|
||||
if err := JoinDefaultChannels(ruser, ""); err != nil {
|
||||
l4g.Error("Encountered an issue joining default channels user_id=%s, team_id=%s, err=%v", ruser.Id, ruser.TeamId, err)
|
||||
}
|
||||
|
||||
if cresult := <-Srv.Store.User().VerifyEmail(ruser.Id); cresult.Err != nil {
|
||||
l4g.Error("Failed to set email verified err=%v", cresult.Err)
|
||||
}
|
||||
|
||||
return ruser
|
||||
}
|
||||
}
|
||||
|
||||
func ImportChannel(channel *model.Channel) *model.Channel {
|
||||
if result := <-Srv.Store.Channel().Save(channel); result.Err != nil {
|
||||
return nil
|
||||
} else {
|
||||
sc := result.Data.(*model.Channel)
|
||||
|
||||
return sc
|
||||
}
|
||||
}
|
||||
244
api/slackimport.go
Обычный файл
244
api/slackimport.go
Обычный файл
@@ -0,0 +1,244 @@
|
||||
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
"archive/zip"
|
||||
"bytes"
|
||||
l4g "code.google.com/p/log4go"
|
||||
"encoding/json"
|
||||
"github.com/mattermost/platform/model"
|
||||
"io"
|
||||
"mime/multipart"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type SlackChannel struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Members []string `json:"members"`
|
||||
Topic map[string]string `json:"topic"`
|
||||
}
|
||||
|
||||
type SlackUser struct {
|
||||
Id string `json:"id"`
|
||||
Username string `json:"name"`
|
||||
Profile map[string]string `json:"profile"`
|
||||
}
|
||||
|
||||
type SlackPost struct {
|
||||
User string `json:"user"`
|
||||
BotId string `json:"bot_id"`
|
||||
BotUsername string `json:"username"`
|
||||
Text string `json:"text"`
|
||||
TimeStamp string `json:"ts"`
|
||||
Type string `json:"type"`
|
||||
SubType string `json:"subtype"`
|
||||
Comment map[string]string `json:"comment"`
|
||||
}
|
||||
|
||||
func SlackConvertTimeStamp(ts string) int64 {
|
||||
timeString := strings.SplitN(ts, ".", 2)[0]
|
||||
|
||||
timeStamp, err := strconv.ParseInt(timeString, 10, 64)
|
||||
if err != nil {
|
||||
l4g.Warn("Bad timestamp detected")
|
||||
return 1
|
||||
}
|
||||
return timeStamp * 1000 // Convert to milliseconds
|
||||
}
|
||||
|
||||
func SlackParseChannels(data io.Reader) []SlackChannel {
|
||||
decoder := json.NewDecoder(data)
|
||||
|
||||
var channels []SlackChannel
|
||||
if err := decoder.Decode(&channels); err != nil {
|
||||
return make([]SlackChannel, 0)
|
||||
}
|
||||
return channels
|
||||
}
|
||||
|
||||
func SlackParseUsers(data io.Reader) []SlackUser {
|
||||
decoder := json.NewDecoder(data)
|
||||
|
||||
var users []SlackUser
|
||||
if err := decoder.Decode(&users); err != nil {
|
||||
return make([]SlackUser, 0)
|
||||
}
|
||||
return users
|
||||
}
|
||||
|
||||
func SlackParsePosts(data io.Reader) []SlackPost {
|
||||
decoder := json.NewDecoder(data)
|
||||
|
||||
var posts []SlackPost
|
||||
if err := decoder.Decode(&posts); err != nil {
|
||||
return make([]SlackPost, 0)
|
||||
}
|
||||
return posts
|
||||
}
|
||||
|
||||
func SlackAddUsers(teamId string, slackusers []SlackUser, log *bytes.Buffer) map[string]*model.User {
|
||||
// Log header
|
||||
log.WriteString("\n Users Created\n")
|
||||
log.WriteString("===============\n\n")
|
||||
|
||||
addedUsers := make(map[string]*model.User)
|
||||
for _, sUser := range slackusers {
|
||||
firstName := ""
|
||||
lastName := ""
|
||||
if name, ok := sUser.Profile["first_name"]; ok {
|
||||
firstName = name
|
||||
}
|
||||
if name, ok := sUser.Profile["last_name"]; ok {
|
||||
lastName = name
|
||||
}
|
||||
|
||||
password := model.NewId()
|
||||
|
||||
newUser := model.User{
|
||||
TeamId: teamId,
|
||||
Username: sUser.Username,
|
||||
FirstName: firstName,
|
||||
LastName: lastName,
|
||||
Email: sUser.Profile["email"],
|
||||
Password: password,
|
||||
}
|
||||
|
||||
if mUser := ImportUser(&newUser); mUser != nil {
|
||||
addedUsers[sUser.Id] = mUser
|
||||
log.WriteString("Email, Password: " + newUser.Email + ", " + password + "\n")
|
||||
} else {
|
||||
log.WriteString("Unable to import user: " + sUser.Username)
|
||||
}
|
||||
}
|
||||
|
||||
return addedUsers
|
||||
}
|
||||
|
||||
func SlackAddPosts(channel *model.Channel, posts []SlackPost, users map[string]*model.User) {
|
||||
for _, sPost := range posts {
|
||||
switch {
|
||||
case sPost.Type == "message" && (sPost.SubType == "" || sPost.SubType == "file_share"):
|
||||
if sPost.User == "" {
|
||||
l4g.Debug("Message without user")
|
||||
continue
|
||||
} else if users[sPost.User] == nil {
|
||||
l4g.Debug("User: " + sPost.User + " does not exist!")
|
||||
continue
|
||||
}
|
||||
newPost := model.Post{
|
||||
UserId: users[sPost.User].Id,
|
||||
ChannelId: channel.Id,
|
||||
Message: sPost.Text,
|
||||
CreateAt: SlackConvertTimeStamp(sPost.TimeStamp),
|
||||
}
|
||||
ImportPost(&newPost)
|
||||
case sPost.Type == "message" && sPost.SubType == "file_comment":
|
||||
if sPost.Comment["user"] == "" {
|
||||
l4g.Debug("Message without user")
|
||||
continue
|
||||
} else if users[sPost.Comment["user"]] == nil {
|
||||
l4g.Debug("User: " + sPost.User + " does not exist!")
|
||||
continue
|
||||
}
|
||||
newPost := model.Post{
|
||||
UserId: users[sPost.Comment["user"]].Id,
|
||||
ChannelId: channel.Id,
|
||||
Message: sPost.Comment["comment"],
|
||||
CreateAt: SlackConvertTimeStamp(sPost.TimeStamp),
|
||||
}
|
||||
ImportPost(&newPost)
|
||||
case sPost.Type == "message" && sPost.SubType == "bot_message":
|
||||
// In the future this will use the "Action Post" spec to post
|
||||
// a message without using a username. For now we just warn that we don't handle this case
|
||||
l4g.Warn("Slack bot posts are not imported yet")
|
||||
default:
|
||||
l4g.Warn("Unsupported post type: " + sPost.Type + ", " + sPost.SubType)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func SlackAddChannels(teamId string, slackchannels []SlackChannel, posts map[string][]SlackPost, users map[string]*model.User, log *bytes.Buffer) map[string]*model.Channel {
|
||||
// Write Header
|
||||
log.WriteString("\n Channels Added \n")
|
||||
log.WriteString("=================\n\n")
|
||||
|
||||
addedChannels := make(map[string]*model.Channel)
|
||||
for _, sChannel := range slackchannels {
|
||||
newChannel := model.Channel{
|
||||
TeamId: teamId,
|
||||
Type: model.CHANNEL_OPEN,
|
||||
DisplayName: sChannel.Name,
|
||||
Name: sChannel.Name,
|
||||
Description: sChannel.Topic["value"],
|
||||
}
|
||||
mChannel := ImportChannel(&newChannel)
|
||||
if mChannel == nil {
|
||||
// Maybe it already exists?
|
||||
if result := <-Srv.Store.Channel().GetByName(teamId, sChannel.Name); result.Err != nil {
|
||||
l4g.Debug("Failed to import: %s", newChannel.DisplayName)
|
||||
log.WriteString("Failed to import: " + newChannel.DisplayName + "\n")
|
||||
continue
|
||||
} else {
|
||||
mChannel = result.Data.(*model.Channel)
|
||||
log.WriteString("Merged with existing channel: " + newChannel.DisplayName + "\n")
|
||||
}
|
||||
}
|
||||
log.WriteString(newChannel.DisplayName + "\n")
|
||||
addedChannels[sChannel.Id] = mChannel
|
||||
SlackAddPosts(mChannel, posts[sChannel.Name], users)
|
||||
}
|
||||
|
||||
return addedChannels
|
||||
}
|
||||
|
||||
func SlackImport(fileData multipart.File, fileSize int64, teamID string) (*model.AppError, *bytes.Buffer) {
|
||||
zipreader, err := zip.NewReader(fileData, fileSize)
|
||||
if err != nil || zipreader.File == nil {
|
||||
return model.NewAppError("SlackImport", "Unable to open zip file", err.Error()), nil
|
||||
}
|
||||
|
||||
// Create log file
|
||||
log := bytes.NewBufferString("Mattermost Slack Import Log\n")
|
||||
|
||||
var channels []SlackChannel
|
||||
var users []SlackUser
|
||||
posts := make(map[string][]SlackPost)
|
||||
for _, file := range zipreader.File {
|
||||
reader, err := file.Open()
|
||||
if err != nil {
|
||||
return model.NewAppError("SlackImport", "Unable to open: "+file.Name, err.Error()), log
|
||||
}
|
||||
if file.Name == "channels.json" {
|
||||
channels = SlackParseChannels(reader)
|
||||
} else if file.Name == "users.json" {
|
||||
users = SlackParseUsers(reader)
|
||||
} else {
|
||||
spl := strings.Split(file.Name, "/")
|
||||
if len(spl) == 2 && strings.HasSuffix(spl[1], ".json") {
|
||||
newposts := SlackParsePosts(reader)
|
||||
channel := spl[0]
|
||||
if _, ok := posts[channel]; ok == false {
|
||||
posts[channel] = newposts
|
||||
} else {
|
||||
posts[channel] = append(posts[channel], newposts...)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
addedUsers := SlackAddUsers(teamID, users, log)
|
||||
SlackAddChannels(teamID, channels, posts, addedUsers, log)
|
||||
|
||||
log.WriteString("\n Notes \n")
|
||||
log.WriteString("=======\n\n")
|
||||
|
||||
log.WriteString("- Some posts may not have been imported because they where not supported by this importer.\n")
|
||||
log.WriteString("- Slack bot posts are currently not supported.\n")
|
||||
|
||||
return nil, log
|
||||
}
|
||||
70
api/team.go
70
api/team.go
@@ -4,6 +4,7 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
l4g "code.google.com/p/log4go"
|
||||
"fmt"
|
||||
"github.com/gorilla/mux"
|
||||
@@ -13,6 +14,7 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func InitTeam(r *mux.Router) {
|
||||
@@ -29,6 +31,7 @@ func InitTeam(r *mux.Router) {
|
||||
sr.Handle("/update_name", ApiUserRequired(updateTeamDisplayName)).Methods("POST")
|
||||
sr.Handle("/update_valet_feature", ApiUserRequired(updateValetFeature)).Methods("POST")
|
||||
sr.Handle("/me", ApiUserRequired(getMyTeam)).Methods("GET")
|
||||
sr.Handle("/import_team", ApiUserRequired(importTeam)).Methods("POST")
|
||||
}
|
||||
|
||||
func signupTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
@@ -489,3 +492,70 @@ func getMyTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func importTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if !c.HasPermissionsToTeam(c.Session.TeamId, "import") || !c.IsTeamAdmin(c.Session.UserId) {
|
||||
c.Err = model.NewAppError("importTeam", "Only a team admin can import data.", "userId="+c.Session.UserId)
|
||||
c.Err.StatusCode = http.StatusForbidden
|
||||
return
|
||||
}
|
||||
|
||||
if err := r.ParseMultipartForm(10000000); err != nil {
|
||||
c.Err = model.NewAppError("importTeam", "Could not parse multipart form", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
importFromArray, ok := r.MultipartForm.Value["importFrom"]
|
||||
importFrom := importFromArray[0]
|
||||
|
||||
fileSizeStr, ok := r.MultipartForm.Value["filesize"]
|
||||
if !ok {
|
||||
c.Err = model.NewAppError("importTeam", "Filesize unavilable", "")
|
||||
c.Err.StatusCode = http.StatusBadRequest
|
||||
return
|
||||
}
|
||||
|
||||
fileSize, err := strconv.ParseInt(fileSizeStr[0], 10, 64)
|
||||
if err != nil {
|
||||
c.Err = model.NewAppError("importTeam", "Filesize not an integer", "")
|
||||
c.Err.StatusCode = http.StatusBadRequest
|
||||
return
|
||||
}
|
||||
|
||||
fileInfoArray, ok := r.MultipartForm.File["file"]
|
||||
if !ok {
|
||||
c.Err = model.NewAppError("importTeam", "No file under 'file' in request", "")
|
||||
c.Err.StatusCode = http.StatusBadRequest
|
||||
return
|
||||
}
|
||||
|
||||
if len(fileInfoArray) <= 0 {
|
||||
c.Err = model.NewAppError("importTeam", "Empty array under 'file' in request", "")
|
||||
c.Err.StatusCode = http.StatusBadRequest
|
||||
return
|
||||
}
|
||||
|
||||
fileInfo := fileInfoArray[0]
|
||||
|
||||
fileData, err := fileInfo.Open()
|
||||
defer fileData.Close()
|
||||
if err != nil {
|
||||
c.Err = model.NewAppError("importTeam", "Could not open file", err.Error())
|
||||
c.Err.StatusCode = http.StatusBadRequest
|
||||
return
|
||||
}
|
||||
|
||||
var log *bytes.Buffer
|
||||
switch importFrom {
|
||||
case "slack":
|
||||
var err *model.AppError
|
||||
if err, log = SlackImport(fileData, fileSize, c.Session.TeamId); err != nil {
|
||||
c.Err = err
|
||||
c.Err.StatusCode = http.StatusBadRequest
|
||||
}
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Disposition", "attachment; filename=MattermostImportLog.txt")
|
||||
w.Header().Set("Content-Type", "application/octet-stream")
|
||||
http.ServeContent(w, r, "MattermostImportLog.txt", time.Now(), bytes.NewReader(log.Bytes()))
|
||||
}
|
||||
|
||||
@@ -181,12 +181,13 @@ func CreateUser(c *Context, team *model.Team, user *model.User) *model.User {
|
||||
|
||||
if result := <-Srv.Store.User().Save(user); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
l4g.Error("Filae err=%v", result.Err)
|
||||
return nil
|
||||
} else {
|
||||
ruser := result.Data.(*model.User)
|
||||
|
||||
// Soft error if there is an issue joining the default channels
|
||||
if err := JoinDefaultChannels(c, ruser, channelRole); err != nil {
|
||||
if err := JoinDefaultChannels(ruser, channelRole); err != nil {
|
||||
l4g.Error("Encountered an issue joining default channels user_id=%s, team_id=%s, err=%v", ruser.Id, ruser.TeamId, err)
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,9 @@ func (o *Post) PreSave() {
|
||||
|
||||
o.OriginalId = ""
|
||||
|
||||
o.CreateAt = GetMillis()
|
||||
if o.CreateAt <= 0 {
|
||||
o.CreateAt = GetMillis()
|
||||
}
|
||||
o.UpdateAt = o.CreateAt
|
||||
|
||||
if o.Props == nil {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
module.exports = React.createClass({
|
||||
render: function() {
|
||||
var client_error = this.props.client_error ? <div className='form-group'><label className='col-sm-12 has-error'>{ this.props.client_error }</label></div> : null;
|
||||
var clientError = this.props.clientError ? <div className='form-group'><label className='col-sm-12 has-error'>{ this.props.clientError }</label></div> : null;
|
||||
var server_error = this.props.server_error ? <div className='form-group'><label className='col-sm-12 has-error'>{ this.props.server_error }</label></div> : null;
|
||||
|
||||
var inputs = this.props.inputs;
|
||||
@@ -19,7 +19,7 @@ module.exports = React.createClass({
|
||||
<li className="setting-list-item">
|
||||
<hr />
|
||||
{ server_error }
|
||||
{ client_error }
|
||||
{ clientError }
|
||||
{ this.props.submit ? <a className="btn btn-sm btn-primary" onClick={this.props.submit}>Submit</a> : "" }
|
||||
<a className="btn btn-sm theme" href="#" onClick={this.props.updateSection}>Cancel</a>
|
||||
</li>
|
||||
|
||||
79
web/react/components/setting_upload.jsx
Обычный файл
79
web/react/components/setting_upload.jsx
Обычный файл
@@ -0,0 +1,79 @@
|
||||
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
module.exports = React.createClass({
|
||||
displayName: 'Setting Upload',
|
||||
propTypes: {
|
||||
title: React.PropTypes.string.isRequired,
|
||||
submit: React.PropTypes.func.isRequired,
|
||||
fileTypesAccepted: React.PropTypes.string.isRequired,
|
||||
clientError: React.PropTypes.string,
|
||||
serverError: React.PropTypes.string
|
||||
},
|
||||
getInitialState: function() {
|
||||
return {
|
||||
clientError: this.props.clientError,
|
||||
serverError: this.props.serverError
|
||||
};
|
||||
},
|
||||
componentWillReceiveProps: function() {
|
||||
this.setState({
|
||||
clientError: this.props.clientError,
|
||||
serverError: this.props.serverError
|
||||
});
|
||||
},
|
||||
doFileSelect: function(e) {
|
||||
e.preventDefault();
|
||||
this.setState({
|
||||
clientError: '',
|
||||
serverError: ''
|
||||
});
|
||||
},
|
||||
doSubmit: function(e) {
|
||||
e.preventDefault();
|
||||
var inputnode = this.refs.uploadinput.getDOMNode();
|
||||
if (inputnode.files && inputnode.files[0]) {
|
||||
this.props.submit(inputnode.files[0]);
|
||||
} else {
|
||||
this.setState({clientError: 'No file selected.'});
|
||||
}
|
||||
},
|
||||
doCancel: function(e) {
|
||||
e.preventDefault();
|
||||
this.refs.uploadinput.getDOMNode().value = '';
|
||||
this.setState({
|
||||
clientError: '',
|
||||
serverError: ''
|
||||
});
|
||||
},
|
||||
render: function() {
|
||||
var clientError = null;
|
||||
if (this.state.clientError) {
|
||||
clientError = (
|
||||
<div className='form-group has-error'><label className='control-label'>{this.state.clientError}</label></div>
|
||||
);
|
||||
}
|
||||
var serverError = null;
|
||||
if (this.state.serverError) {
|
||||
serverError = (
|
||||
<div className='form-group has-error'><label className='control-label'>{this.state.serverError}</label></div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<ul className='section-max'>
|
||||
<li className='col-xs-12 section-title'>{this.props.title}</li>
|
||||
<li className='col-xs-offset-3 col-xs-8'>
|
||||
<ul className='setting-list'>
|
||||
<li className='setting-list-item'>
|
||||
{serverError}
|
||||
{clientError}
|
||||
<span className='btn btn-sm btn-primary btn-file sel-btn'>SelectFile<input ref='uploadinput' accept={this.props.fileTypesAccepted} type='file' onChange={this.onFileSelect}/></span>
|
||||
<a className={'btn btn-sm btn-primary'} onClick={this.doSubmit}>Import</a>
|
||||
<a className='btn btn-sm theme' href='#' onClick={this.doCancel}>Cancel</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -15,7 +15,7 @@ module.exports = React.createClass({
|
||||
<div className="">
|
||||
<ul className="nav nav-pills nav-stacked">
|
||||
{this.props.tabs.map(function(tab) {
|
||||
return <li key={tab.name+'_li'} className={self.props.activeTab == tab.name ? 'active' : ''}><a key={tab.name + '_a'} href="#" onClick={function(){self.updateTab(tab.name);}}><i key={tab.name+'_i'} className={tab.icon}></i>{tab.ui_name}</a></li>
|
||||
return <li key={tab.name+'_li'} className={self.props.activeTab == tab.name ? 'active' : ''}><a key={tab.name + '_a'} href="#" onClick={function(){self.updateTab(tab.name);}}><i key={tab.name+'_i'} className={tab.icon}></i>{tab.uiName}</a></li>
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
147
web/react/components/team_feature_tab.jsx
Обычный файл
147
web/react/components/team_feature_tab.jsx
Обычный файл
@@ -0,0 +1,147 @@
|
||||
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
var SettingItemMin = require('./setting_item_min.jsx');
|
||||
var SettingItemMax = require('./setting_item_max.jsx');
|
||||
|
||||
var client = require('../utils/client.jsx');
|
||||
var AsyncClient = require('../utils/async_client.jsx');
|
||||
|
||||
module.exports = React.createClass({
|
||||
displayName: 'Feature Tab',
|
||||
propTypes: {
|
||||
updateSection: React.PropTypes.func.isRequired,
|
||||
team: React.PropTypes.object.isRequired,
|
||||
activeSection: React.PropTypes.string.isRequired
|
||||
},
|
||||
submitValetFeature: function() {
|
||||
var data = {};
|
||||
data.allowValet = this.state.allowValet;
|
||||
|
||||
client.updateValetFeature(data,
|
||||
function() {
|
||||
this.props.updateSection('');
|
||||
AsyncClient.getMyTeam();
|
||||
}.bind(this),
|
||||
function(err) {
|
||||
var state = this.getInitialState();
|
||||
state.serverError = err;
|
||||
this.setState(state);
|
||||
}.bind(this)
|
||||
);
|
||||
},
|
||||
handleValetRadio: function(val) {
|
||||
this.setState({allowValet: val});
|
||||
this.refs.wrapper.getDOMNode().focus();
|
||||
},
|
||||
componentWillReceiveProps: function(newProps) {
|
||||
var team = newProps.team;
|
||||
|
||||
var allowValet = 'false';
|
||||
if (team && team.allowValet) {
|
||||
allowValet = 'true';
|
||||
}
|
||||
|
||||
this.setState({allowValet: allowValet});
|
||||
},
|
||||
getInitialState: function() {
|
||||
var team = this.props.team;
|
||||
|
||||
var allowValet = 'false';
|
||||
if (team && team.allowValet) {
|
||||
allowValet = 'true';
|
||||
}
|
||||
|
||||
return {allowValet: allowValet};
|
||||
},
|
||||
onUpdateSection: function() {
|
||||
if (this.props.activeSection === 'valet') {
|
||||
self.props.updateSection('valet');
|
||||
} else {
|
||||
self.props.updateSection('');
|
||||
}
|
||||
},
|
||||
render: function() {
|
||||
var clientError = null;
|
||||
var serverError = null;
|
||||
if (this.state.clientError) {
|
||||
clientError = this.state.clientError;
|
||||
}
|
||||
if (this.state.serverError) {
|
||||
serverError = this.state.serverError;
|
||||
}
|
||||
|
||||
var valetSection;
|
||||
var self = this;
|
||||
|
||||
if (this.props.activeSection === 'valet') {
|
||||
var valetActive = ['', ''];
|
||||
if (this.state.allowValet === 'false') {
|
||||
valetActive[1] = 'active';
|
||||
} else {
|
||||
valetActive[0] = 'active';
|
||||
}
|
||||
|
||||
var inputs = [];
|
||||
|
||||
function valetActivate() {
|
||||
self.handleValetRadio('true');
|
||||
}
|
||||
|
||||
function valetDeactivate() {
|
||||
self.handleValetRadio('false');
|
||||
}
|
||||
|
||||
inputs.push(
|
||||
<div>
|
||||
<div className='btn-group' data-toggle='buttons-radio'>
|
||||
<button className={'btn btn-default ' + valetActive[0]} onClick={valetActivate}>On</button>
|
||||
<button className={'btn btn-default ' + valetActive[1]} onClick={valetDeactivate}>Off</button>
|
||||
</div>
|
||||
<div><br/>Valet is a preview feature for enabling a non-user account limited to basic member permissions that can be manipulated by 3rd parties.<br/><br/>IMPORTANT: The preview version of Valet should not be used without a secure connection and a trusted 3rd party, since user credentials are used to connect. OAuth2 will be used in the final release.</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
valetSection = (
|
||||
<SettingItemMax
|
||||
title='Valet (Preview - EXPERTS ONLY)'
|
||||
inputs={inputs}
|
||||
submit={this.submitValetFeature}
|
||||
serverError={serverError}
|
||||
clientError={clientError}
|
||||
updateSection={this.onUpdateSection}
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
var describe = '';
|
||||
if (this.state.allowValet === 'false') {
|
||||
describe = 'Off';
|
||||
} else {
|
||||
describe = 'On';
|
||||
}
|
||||
|
||||
valetSection = (
|
||||
<SettingItemMin
|
||||
title='Valet (Preview - EXPERTS ONLY)'
|
||||
describe={describe}
|
||||
updateSection={this.onUpdateSection}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className='modal-header'>
|
||||
<button type='button' className='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>×</span></button>
|
||||
<h4 className='modal-title' ref='title'><i className='modal-back'></i>Feature Settings</h4>
|
||||
</div>
|
||||
<div ref='wrapper' className='user-settings'>
|
||||
<h3 className='tab-header'>Feature Settings</h3>
|
||||
<div className='divider-dark first'/>
|
||||
{valetSection}
|
||||
<div className='divider-dark'/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
68
web/react/components/team_import_tab.jsx
Обычный файл
68
web/react/components/team_import_tab.jsx
Обычный файл
@@ -0,0 +1,68 @@
|
||||
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
var utils = require('../utils/utils.jsx');
|
||||
var SettingUpload = require('./setting_upload.jsx');
|
||||
|
||||
module.exports = React.createClass({
|
||||
displayName: 'Import Tab',
|
||||
getInitialState: function() {
|
||||
return {status: 'ready', link: ''};
|
||||
},
|
||||
onImportFailure: function() {
|
||||
this.setState({status: 'fail', link: ''});
|
||||
},
|
||||
onImportSuccess: function(data) {
|
||||
this.setState({status: 'done', link: 'data:application/octet-stream;charset=utf-8,' + encodeURIComponent(data)});
|
||||
},
|
||||
doImportSlack: function(file) {
|
||||
this.setState({status: 'in-progress', link: ''});
|
||||
utils.importSlack(file, this.onImportSuccess, this.onImportFailure);
|
||||
},
|
||||
render: function() {
|
||||
var uploadSection = (
|
||||
<SettingUpload
|
||||
title='Import from Slack'
|
||||
submit={this.doImportSlack}
|
||||
fileTypesAccepted='.zip'/>
|
||||
);
|
||||
|
||||
var messageSection;
|
||||
switch (this.state.status) {
|
||||
case 'ready':
|
||||
messageSection = '';
|
||||
break;
|
||||
case 'in-progress':
|
||||
messageSection = (
|
||||
<p>Importing...</p>
|
||||
);
|
||||
break;
|
||||
case 'done':
|
||||
messageSection = (
|
||||
<p>Import sucessfull: <a href={this.state.link} download='MattermostImportSummery.txt'>View Summery</a></p>
|
||||
);
|
||||
break;
|
||||
case 'fail':
|
||||
messageSection = (
|
||||
<p>Import failure: <a href={this.state.link} download='MattermostImportSummery.txt'>View Summery</a></p>
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className='modal-header'>
|
||||
<button type='button' className='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>×</span></button>
|
||||
<h4 className='modal-title' ref='title'><i className='modal-back'></i>Import</h4>
|
||||
</div>
|
||||
<div ref='wrapper' className='user-settings'>
|
||||
<h3 className='tab-header'>Import</h3>
|
||||
<div className='divider-dark first'/>
|
||||
{uploadSection}
|
||||
{messageSection}
|
||||
<div className='divider-dark'/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -1,161 +1,62 @@
|
||||
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
var UserStore = require('../stores/user_store.jsx');
|
||||
var TeamStore = require('../stores/team_store.jsx');
|
||||
var SettingItemMin = require('./setting_item_min.jsx');
|
||||
var SettingItemMax = require('./setting_item_max.jsx');
|
||||
var SettingPicture = require('./setting_picture.jsx');
|
||||
var ImportTab = require('./team_import_tab.jsx');
|
||||
var FeatureTab = require('./team_feature_tab.jsx');
|
||||
var utils = require('../utils/utils.jsx');
|
||||
|
||||
var client = require('../utils/client.jsx');
|
||||
var AsyncClient = require('../utils/async_client.jsx');
|
||||
var Constants = require('../utils/constants.jsx');
|
||||
|
||||
var FeatureTab = React.createClass({
|
||||
submitValetFeature: function() {
|
||||
data = {};
|
||||
data['allow_valet'] = this.state.allow_valet;
|
||||
|
||||
client.updateValetFeature(data,
|
||||
function(data) {
|
||||
this.props.updateSection("");
|
||||
AsyncClient.getMyTeam();
|
||||
}.bind(this),
|
||||
function(err) {
|
||||
state = this.getInitialState();
|
||||
state.server_error = err;
|
||||
this.setState(state);
|
||||
}.bind(this)
|
||||
);
|
||||
},
|
||||
handleValetRadio: function(val) {
|
||||
this.setState({ allow_valet: val });
|
||||
this.refs.wrapper.getDOMNode().focus();
|
||||
},
|
||||
componentWillReceiveProps: function(newProps) {
|
||||
var team = newProps.team;
|
||||
|
||||
var allow_valet = "false";
|
||||
if (team && team.allow_valet) {
|
||||
allow_valet = "true";
|
||||
}
|
||||
|
||||
this.setState({ allow_valet: allow_valet });
|
||||
},
|
||||
getInitialState: function() {
|
||||
var team = this.props.team;
|
||||
|
||||
var allow_valet = "false";
|
||||
if (team && team.allow_valet) {
|
||||
allow_valet = "true";
|
||||
}
|
||||
|
||||
return { allow_valet: allow_valet };
|
||||
},
|
||||
render: function() {
|
||||
var team = this.props.team;
|
||||
|
||||
var client_error = this.state.client_error ? this.state.client_error : null;
|
||||
var server_error = this.state.server_error ? this.state.server_error : null;
|
||||
|
||||
var valetSection;
|
||||
var self = this;
|
||||
|
||||
if (this.props.activeSection === 'valet') {
|
||||
var valetActive = ["",""];
|
||||
if (this.state.allow_valet === "false") {
|
||||
valetActive[1] = "active";
|
||||
} else {
|
||||
valetActive[0] = "active";
|
||||
}
|
||||
|
||||
var inputs = [];
|
||||
|
||||
inputs.push(
|
||||
<div>
|
||||
<div className="btn-group" data-toggle="buttons-radio">
|
||||
<button className={"btn btn-default "+valetActive[0]} onClick={function(){self.handleValetRadio("true")}}>On</button>
|
||||
<button className={"btn btn-default "+valetActive[1]} onClick={function(){self.handleValetRadio("false")}}>Off</button>
|
||||
</div>
|
||||
<div><br/>Valet is a preview feature for enabling a non-user account limited to basic member permissions that can be manipulated by 3rd parties.<br/><br/>IMPORTANT: The preview version of Valet should not be used without a secure connection and a trusted 3rd party, since user credentials are used to connect. OAuth2 will be used in the final release.</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
valetSection = (
|
||||
<SettingItemMax
|
||||
title="Valet (Preview - EXPERTS ONLY)"
|
||||
inputs={inputs}
|
||||
submit={this.submitValetFeature}
|
||||
server_error={server_error}
|
||||
client_error={client_error}
|
||||
updateSection={function(e){self.props.updateSection("");e.preventDefault();}}
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
var describe = "";
|
||||
if (this.state.allow_valet === "false") {
|
||||
describe = "Off";
|
||||
} else {
|
||||
describe = "On";
|
||||
}
|
||||
|
||||
valetSection = (
|
||||
<SettingItemMin
|
||||
title="Valet (Preview - EXPERTS ONLY)"
|
||||
describe={describe}
|
||||
updateSection={function(){self.props.updateSection("valet");}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="modal-header">
|
||||
<button type="button" className="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 className="modal-title" ref="title"><i className="modal-back"></i>Feature Settings</h4>
|
||||
</div>
|
||||
<div ref="wrapper" className="user-settings">
|
||||
<h3 className="tab-header">Feature Settings</h3>
|
||||
<div className="divider-dark first"/>
|
||||
{valetSection}
|
||||
<div className="divider-dark"/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = React.createClass({
|
||||
displayName: 'Team Settings',
|
||||
propTypes: {
|
||||
activeTab: React.PropTypes.string.isRequired,
|
||||
activeSection: React.PropTypes.string.isRequired,
|
||||
updateSection: React.PropTypes.func.isRequired
|
||||
},
|
||||
componentDidMount: function() {
|
||||
TeamStore.addChangeListener(this._onChange);
|
||||
TeamStore.addChangeListener(this.onChange);
|
||||
},
|
||||
componentWillUnmount: function() {
|
||||
TeamStore.removeChangeListener(this._onChange);
|
||||
TeamStore.removeChangeListener(this.onChange);
|
||||
},
|
||||
_onChange: function () {
|
||||
onChange: function() {
|
||||
var team = TeamStore.getCurrent();
|
||||
if (!utils.areStatesEqual(this.state.team, team)) {
|
||||
this.setState({ team: team });
|
||||
this.setState({team: team});
|
||||
}
|
||||
},
|
||||
getInitialState: function() {
|
||||
return { team: TeamStore.getCurrent() };
|
||||
return {team: TeamStore.getCurrent()};
|
||||
},
|
||||
render: function() {
|
||||
if (this.props.activeTab === 'general') {
|
||||
return (
|
||||
<div>
|
||||
</div>
|
||||
);
|
||||
} else if (this.props.activeTab === 'feature') {
|
||||
return (
|
||||
<div>
|
||||
<FeatureTab team={this.state.team} activeSection={this.props.activeSection} updateSection={this.props.updateSection} />
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return <div/>;
|
||||
var result;
|
||||
switch (this.props.activeTab) {
|
||||
case 'general':
|
||||
result = (
|
||||
<div>
|
||||
</div>
|
||||
);
|
||||
break;
|
||||
case 'feature':
|
||||
result = (
|
||||
<div>
|
||||
<FeatureTab team={this.state.team} activeSection={this.props.activeSection} updateSection={this.props.updateSection} />
|
||||
</div>
|
||||
);
|
||||
break;
|
||||
case 'import':
|
||||
result = (
|
||||
<div>
|
||||
<ImportTab team={this.state.team} activeSection={this.props.activeSection} updateSection={this.props.updateSection} />
|
||||
</div>
|
||||
);
|
||||
break;
|
||||
default:
|
||||
result = (
|
||||
<div/>
|
||||
);
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -5,50 +5,52 @@ var SettingsSidebar = require('./settings_sidebar.jsx');
|
||||
var TeamSettings = require('./team_settings.jsx');
|
||||
|
||||
module.exports = React.createClass({
|
||||
displayName: 'Team Settings Modal',
|
||||
componentDidMount: function() {
|
||||
$('body').on('click', '.modal-back', function(){
|
||||
$('body').on('click', '.modal-back', function onClick() {
|
||||
$(this).closest('.modal-dialog').removeClass('display--content');
|
||||
});
|
||||
$('body').on('click', '.modal-header .close', function(){
|
||||
setTimeout(function() {
|
||||
$('body').on('click', '.modal-header .close', function onClick() {
|
||||
setTimeout(function removeContent() {
|
||||
$('.modal-dialog.display--content').removeClass('display--content');
|
||||
}, 500);
|
||||
});
|
||||
},
|
||||
updateTab: function(tab) {
|
||||
this.setState({ active_tab: tab });
|
||||
this.setState({activeTab: tab});
|
||||
},
|
||||
updateSection: function(section) {
|
||||
this.setState({ active_section: section });
|
||||
this.setState({activeSection: section});
|
||||
},
|
||||
getInitialState: function() {
|
||||
return { active_tab: "feature", active_section: "" };
|
||||
return {activeTab: 'feature', activeSection: ''};
|
||||
},
|
||||
render: function() {
|
||||
var tabs = [];
|
||||
tabs.push({name: "feature", ui_name: "Features", icon: "glyphicon glyphicon-wrench"});
|
||||
tabs.push({name: 'feature', uiName: 'Features', icon: 'glyphicon glyphicon-wrench'});
|
||||
tabs.push({name: 'import', uiName: 'Import', icon: 'glyphicon glyphicon-upload'});
|
||||
|
||||
return (
|
||||
<div className="modal fade" ref="modal" id="team_settings" role="dialog" tabIndex="-1" aria-hidden="true">
|
||||
<div className="modal-dialog settings-modal">
|
||||
<div className="modal-content">
|
||||
<div className="modal-header">
|
||||
<button type="button" className="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 className="modal-title" ref="title">Team Settings</h4>
|
||||
<div className='modal fade' ref='modal' id='team_settings' role='dialog' tabIndex='-1' aria-hidden='true'>
|
||||
<div className='modal-dialog settings-modal'>
|
||||
<div className='modal-content'>
|
||||
<div className='modal-header'>
|
||||
<button type='button' className='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>×</span></button>
|
||||
<h4 className='modal-title' ref='title'>Team Settings</h4>
|
||||
</div>
|
||||
<div className="modal-body">
|
||||
<div className="settings-table">
|
||||
<div className="settings-links">
|
||||
<div className='modal-body'>
|
||||
<div className='settings-table'>
|
||||
<div className='settings-links'>
|
||||
<SettingsSidebar
|
||||
tabs={tabs}
|
||||
activeTab={this.state.active_tab}
|
||||
activeTab={this.state.activeTab}
|
||||
updateTab={this.updateTab}
|
||||
/>
|
||||
</div>
|
||||
<div className="settings-content minimize-settings">
|
||||
<div className='settings-content minimize-settings'>
|
||||
<TeamSettings
|
||||
activeTab={this.state.active_tab}
|
||||
activeSection={this.state.active_section}
|
||||
activeTab={this.state.activeTab}
|
||||
activeSection={this.state.activeSection}
|
||||
updateSection={this.updateSection}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
var BrowserStore = require('../stores/browser_store.jsx');
|
||||
@@ -14,73 +13,73 @@ module.exports.trackPage = function() {
|
||||
global.window.analytics.page();
|
||||
};
|
||||
|
||||
function handleError(method_name, xhr, status, err) {
|
||||
var _LTracker = global.window._LTracker || [];
|
||||
function handleError(methodName, xhr, status, err) {
|
||||
var LTracker = global.window.LTracker || [];
|
||||
|
||||
var e = null;
|
||||
try {
|
||||
e = JSON.parse(xhr.responseText);
|
||||
}
|
||||
catch(parse_error) {
|
||||
} catch(parseError) {
|
||||
e = null;
|
||||
}
|
||||
|
||||
var msg = "";
|
||||
var msg = '';
|
||||
|
||||
if (e) {
|
||||
msg = "error in " + method_name + " msg=" + e.message + " detail=" + e.detailed_error + " rid=" + e.request_id;
|
||||
}
|
||||
else {
|
||||
msg = "error in " + method_name + " status=" + status + " statusCode=" + xhr.status + " err=" + err;
|
||||
msg = 'error in ' + methodName + ' msg=' + e.message + ' detail=' + e.detailed_error + ' rid=' + e.request_id;
|
||||
} else {
|
||||
msg = 'error in ' + methodName + ' status=' + status + ' statusCode=' + xhr.status + ' err=' + err;
|
||||
|
||||
if (xhr.status === 0)
|
||||
e = { message: "There appears to be a problem with your internet connection" };
|
||||
else
|
||||
e = { message: "We received an unexpected status code from the server (" + xhr.status + ")"};
|
||||
if (xhr.status === 0) {
|
||||
e = {message: 'There appears to be a problem with your internet connection'};
|
||||
} else {
|
||||
e = {message: 'We received an unexpected status code from the server (' + xhr.status + ')'};
|
||||
}
|
||||
}
|
||||
|
||||
console.error(msg)
|
||||
console.error(e);
|
||||
_LTracker.push(msg);
|
||||
console.error(msg); //eslint-disable-line no-console
|
||||
console.error(e); //eslint-disable-line no-console
|
||||
LTracker.push(msg);
|
||||
|
||||
module.exports.track('api', 'api_weberror', method_name, 'message', msg);
|
||||
module.exports.track('api', 'api_weberror', methodName, 'message', msg);
|
||||
|
||||
if (xhr.status == 401) {
|
||||
if (window.location.href.indexOf("/channels") === 0) {
|
||||
window.location.pathname = '/login?redirect=' + encodeURIComponent(window.location.pathname+window.location.search);
|
||||
if (xhr.status === 401) {
|
||||
if (window.location.href.indexOf('/channels') === 0) {
|
||||
window.location.pathname = '/login?redirect=' + encodeURIComponent(window.location.pathname + window.location.search);
|
||||
} else {
|
||||
var teamURL = window.location.href.split('/channels')[0];
|
||||
window.location.href = teamURL + '/login?redirect=' + encodeURIComponent(window.location.pathname+window.location.search);
|
||||
window.location.href = teamURL + '/login?redirect=' + encodeURIComponent(window.location.pathname + window.location.search);
|
||||
}
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
module.exports.createTeamFromSignup = function(team_signup, success, error) {
|
||||
module.exports.createTeamFromSignup = function(teamSignup, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/teams/create_from_signup",
|
||||
url: '/api/v1/teams/create_from_signup',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(team_signup),
|
||||
data: JSON.stringify(teamSignup),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("createTeamFromSignup", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('createTeamFromSignup', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.createUser = function(user, data, email_hash, success, error) {
|
||||
module.exports.createUser = function(user, data, emailHash, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/users/create?d=" + encodeURIComponent(data) + "&h=" + encodeURIComponent(email_hash),
|
||||
url: '/api/v1/users/create?d=' + encodeURIComponent(data) + '&h=' + encodeURIComponent(emailHash),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(user),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("createUser", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('createUser', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -90,14 +89,14 @@ module.exports.createUser = function(user, data, email_hash, success, error) {
|
||||
|
||||
module.exports.updateUser = function(user, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/users/update",
|
||||
url: '/api/v1/users/update',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(user),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("updateUser", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('updateUser', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -107,14 +106,14 @@ module.exports.updateUser = function(user, success, error) {
|
||||
|
||||
module.exports.updatePassword = function(data, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/users/newpassword",
|
||||
url: '/api/v1/users/newpassword',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(data),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("newPassword", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('newPassword', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -124,14 +123,14 @@ module.exports.updatePassword = function(data, success, error) {
|
||||
|
||||
module.exports.updateUserNotifyProps = function(data, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/users/update_notify",
|
||||
url: '/api/v1/users/update_notify',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(data),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("updateUserNotifyProps", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('updateUserNotifyProps', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -139,14 +138,14 @@ module.exports.updateUserNotifyProps = function(data, success, error) {
|
||||
|
||||
module.exports.updateRoles = function(data, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/users/update_roles",
|
||||
url: '/api/v1/users/update_roles',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(data),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("updateRoles", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('updateRoles', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -155,19 +154,19 @@ module.exports.updateRoles = function(data, success, error) {
|
||||
};
|
||||
|
||||
module.exports.updateActive = function(userId, active, success, error) {
|
||||
var data = {};
|
||||
data["user_id"] = userId;
|
||||
data["active"] = "" + active;
|
||||
|
||||
var data = {};
|
||||
data.user_id = userId;
|
||||
data.active = '' + active;
|
||||
|
||||
$.ajax({
|
||||
url: "/api/v1/users/update_active",
|
||||
url: '/api/v1/users/update_active',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(data),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("updateActive", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('updateActive', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -177,14 +176,14 @@ module.exports.updateActive = function(userId, active, success, error) {
|
||||
|
||||
module.exports.sendPasswordReset = function(data, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/users/send_password_reset",
|
||||
url: '/api/v1/users/send_password_reset',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(data),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("sendPasswordReset", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('sendPasswordReset', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -194,14 +193,14 @@ module.exports.sendPasswordReset = function(data, success, error) {
|
||||
|
||||
module.exports.resetPassword = function(data, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/users/reset_password",
|
||||
url: '/api/v1/users/reset_password',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(data),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("resetPassword", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('resetPassword', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -213,24 +212,24 @@ module.exports.logout = function() {
|
||||
module.exports.track('api', 'api_users_logout');
|
||||
var currentTeamUrl = TeamStore.getCurrentTeamUrl();
|
||||
BrowserStore.clear();
|
||||
window.location.href = currentTeamUrl + "/logout";
|
||||
window.location.href = currentTeamUrl + '/logout';
|
||||
};
|
||||
|
||||
module.exports.loginByEmail = function(name, email, password, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/users/login",
|
||||
url: '/api/v1/users/login',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify({name: name, email: email, password: password}),
|
||||
success: function(data, textStatus, xhr) {
|
||||
success: function onSuccess(data, textStatus, xhr) {
|
||||
module.exports.track('api', 'api_users_login_success', data.team_id, 'email', data.email);
|
||||
success(data, textStatus, xhr);
|
||||
},
|
||||
error: function(xhr, status, err) {
|
||||
error: function onError(xhr, status, err) {
|
||||
module.exports.track('api', 'api_users_login_fail', window.getSubDomain(), 'email', email);
|
||||
|
||||
e = handleError("loginByEmail", xhr, status, err);
|
||||
var e = handleError('loginByEmail', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -238,14 +237,14 @@ module.exports.loginByEmail = function(name, email, password, success, error) {
|
||||
|
||||
module.exports.revokeSession = function(altId, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/users/revoke_session",
|
||||
url: '/api/v1/users/revoke_session',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify({id: altId}),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("revokeSession", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('revokeSession', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -253,13 +252,13 @@ module.exports.revokeSession = function(altId, success, error) {
|
||||
|
||||
module.exports.getSessions = function(userId, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/users/"+userId+"/sessions",
|
||||
url: '/api/v1/users/' + userId + '/sessions',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'GET',
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("getSessions", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('getSessions', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -267,13 +266,13 @@ module.exports.getSessions = function(userId, success, error) {
|
||||
|
||||
module.exports.getAudits = function(userId, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/users/"+userId+"/audits",
|
||||
url: '/api/v1/users/' + userId + '/audits',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'GET',
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("getAudits", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('getAudits', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -281,10 +280,9 @@ module.exports.getAudits = function(userId, success, error) {
|
||||
|
||||
module.exports.getMeSynchronous = function(success, error) {
|
||||
var currentUser = null;
|
||||
|
||||
$.ajax({
|
||||
async: false,
|
||||
url: "/api/v1/users/me",
|
||||
url: '/api/v1/users/me',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'GET',
|
||||
@@ -294,14 +292,14 @@ module.exports.getMeSynchronous = function(success, error) {
|
||||
success(data, textStatus, xhr);
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, err) {
|
||||
error: function onError(xhr, status, err) {
|
||||
var ieChecker = window.navigator.userAgent; // This and the condition below is used to check specifically for browsers IE10 & 11 to suppress a 200 'OK' error from appearing on login
|
||||
if (xhr.status != 200 || !(ieChecker.indexOf("Trident/7.0") > 0 || ieChecker.indexOf("Trident/6.0") > 0)) {
|
||||
if (xhr.status !== 200 || !(ieChecker.indexOf('Trident/7.0') > 0 || ieChecker.indexOf('Trident/6.0') > 0)) {
|
||||
if (error) {
|
||||
e = handleError('getMeSynchronous', xhr, status, err);
|
||||
var e = handleError('getMeSynchronous', xhr, status, err);
|
||||
error(e);
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -310,14 +308,14 @@ module.exports.getMeSynchronous = function(success, error) {
|
||||
|
||||
module.exports.inviteMembers = function(data, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/teams/invite_members",
|
||||
url: '/api/v1/teams/invite_members',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(data),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("inviteMembers", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('inviteMembers', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -327,14 +325,14 @@ module.exports.inviteMembers = function(data, success, error) {
|
||||
|
||||
module.exports.updateTeamDisplayName = function(data, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/teams/update_name",
|
||||
url: '/api/v1/teams/update_name',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(data),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("updateTeamDisplayName", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('updateTeamDisplayName', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -344,14 +342,14 @@ module.exports.updateTeamDisplayName = function(data, success, error) {
|
||||
|
||||
module.exports.signupTeam = function(email, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/teams/signup",
|
||||
url: '/api/v1/teams/signup',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify({email: email}),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("singupTeam", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('singupTeam', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -361,14 +359,14 @@ module.exports.signupTeam = function(email, success, error) {
|
||||
|
||||
module.exports.createTeam = function(team, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/teams/create",
|
||||
url: '/api/v1/teams/create',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(team),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("createTeam", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('createTeam', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -376,14 +374,14 @@ module.exports.createTeam = function(team, success, error) {
|
||||
|
||||
module.exports.findTeamByName = function(teamName, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/teams/find_team_by_name",
|
||||
url: '/api/v1/teams/find_team_by_name',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify({name: teamName}),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("findTeamByName", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('findTeamByName', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -391,14 +389,14 @@ module.exports.findTeamByName = function(teamName, success, error) {
|
||||
|
||||
module.exports.findTeamsSendEmail = function(email, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/teams/email_teams",
|
||||
url: '/api/v1/teams/email_teams',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify({email: email}),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("findTeamsSendEmail", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('findTeamsSendEmail', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -408,14 +406,14 @@ module.exports.findTeamsSendEmail = function(email, success, error) {
|
||||
|
||||
module.exports.findTeams = function(email, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/teams/find_teams",
|
||||
url: '/api/v1/teams/find_teams',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify({email: email}),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("findTeams", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('findTeams', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -423,14 +421,14 @@ module.exports.findTeams = function(email, success, error) {
|
||||
|
||||
module.exports.createChannel = function(channel, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/channels/create",
|
||||
url: '/api/v1/channels/create',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(channel),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("createChannel", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('createChannel', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -457,14 +455,14 @@ module.exports.createDirectChannel = function(channel, userId, success, error) {
|
||||
|
||||
module.exports.updateChannel = function(channel, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/channels/update",
|
||||
url: '/api/v1/channels/update',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(channel),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("updateChannel", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('updateChannel', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -474,14 +472,14 @@ module.exports.updateChannel = function(channel, success, error) {
|
||||
|
||||
module.exports.updateChannelDesc = function(data, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/channels/update_desc",
|
||||
url: '/api/v1/channels/update_desc',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(data),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("updateChannelDesc", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('updateChannelDesc', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -491,14 +489,14 @@ module.exports.updateChannelDesc = function(data, success, error) {
|
||||
|
||||
module.exports.updateNotifyLevel = function(data, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/channels/update_notify_level",
|
||||
url: '/api/v1/channels/update_notify_level',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(data),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("updateNotifyLevel", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('updateNotifyLevel', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -506,13 +504,13 @@ module.exports.updateNotifyLevel = function(data, success, error) {
|
||||
|
||||
module.exports.joinChannel = function(id, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/channels/" + id + "/join",
|
||||
url: '/api/v1/channels/' + id + '/join',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("joinChannel", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('joinChannel', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -522,13 +520,13 @@ module.exports.joinChannel = function(id, success, error) {
|
||||
|
||||
module.exports.leaveChannel = function(id, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/channels/" + id + "/leave",
|
||||
url: '/api/v1/channels/' + id + '/leave',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("leaveChannel", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('leaveChannel', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -538,13 +536,13 @@ module.exports.leaveChannel = function(id, success, error) {
|
||||
|
||||
module.exports.deleteChannel = function(id, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/channels/" + id + "/delete",
|
||||
url: '/api/v1/channels/' + id + '/delete',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("deleteChannel", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('deleteChannel', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -554,13 +552,13 @@ module.exports.deleteChannel = function(id, success, error) {
|
||||
|
||||
module.exports.updateLastViewedAt = function(channelId, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/channels/" + channelId + "/update_last_viewed_at",
|
||||
url: '/api/v1/channels/' + channelId + '/update_last_viewed_at',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("updateLastViewedAt", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('updateLastViewedAt', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -573,7 +571,7 @@ function getChannels(success, error) {
|
||||
type: 'GET',
|
||||
success: success,
|
||||
ifModified: true,
|
||||
error: function(xhr, status, err) {
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('getChannels', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
@@ -583,12 +581,12 @@ module.exports.getChannels = getChannels;
|
||||
|
||||
module.exports.getChannel = function(id, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/channels/" + id + "/",
|
||||
url: '/api/v1/channels/' + id + '/',
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("getChannel", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('getChannel', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -598,13 +596,13 @@ module.exports.getChannel = function(id, success, error) {
|
||||
|
||||
module.exports.getMoreChannels = function(success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/channels/more",
|
||||
url: '/api/v1/channels/more',
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
success: success,
|
||||
ifModified: true,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("getMoreChannels", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('getMoreChannels', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -617,7 +615,7 @@ function getChannelCounts(success, error) {
|
||||
type: 'GET',
|
||||
success: success,
|
||||
ifModified: true,
|
||||
error: function(xhr, status, err) {
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('getChannelCounts', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
@@ -627,12 +625,12 @@ module.exports.getChannelCounts = getChannelCounts;
|
||||
|
||||
module.exports.getChannelExtraInfo = function(id, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/channels/" + id + "/extra_info",
|
||||
url: '/api/v1/channels/' + id + '/extra_info',
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("getChannelExtraInfo", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('getChannelExtraInfo', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -640,14 +638,14 @@ module.exports.getChannelExtraInfo = function(id, success, error) {
|
||||
|
||||
module.exports.executeCommand = function(channelId, command, suggest, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/command",
|
||||
url: '/api/v1/command',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify({channelId: channelId, command: command, suggest: "" + suggest}),
|
||||
data: JSON.stringify({channelId: channelId, command: command, suggest: '' + suggest}),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("executeCommand", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('executeCommand', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -655,18 +653,14 @@ module.exports.executeCommand = function(channelId, command, suggest, success, e
|
||||
|
||||
module.exports.getPosts = function(channelId, offset, limit, success, error, complete) {
|
||||
$.ajax({
|
||||
url: "/api/v1/channels/" + channelId + "/posts/" + offset + "/" + limit,
|
||||
url: '/api/v1/channels/' + channelId + '/posts/' + offset + '/' + limit,
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
ifModified: true,
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
try {
|
||||
e = handleError("getPosts", xhr, status, err);
|
||||
error(e);
|
||||
} catch(er) {
|
||||
console.error(er);
|
||||
}
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('getPosts', xhr, status, err);
|
||||
error(e);
|
||||
},
|
||||
complete: complete
|
||||
});
|
||||
@@ -674,13 +668,13 @@ module.exports.getPosts = function(channelId, offset, limit, success, error, com
|
||||
|
||||
module.exports.getPost = function(channelId, postId, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/channels/" + channelId + "/post/" + postId,
|
||||
url: '/api/v1/channels/' + channelId + '/post/' + postId,
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
ifModified: false,
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("getPost", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('getPost', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -688,13 +682,13 @@ module.exports.getPost = function(channelId, postId, success, error) {
|
||||
|
||||
module.exports.search = function(terms, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/posts/search",
|
||||
url: '/api/v1/posts/search',
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
data: {"terms": terms},
|
||||
data: {terms: terms},
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("search", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('search', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -704,13 +698,13 @@ module.exports.search = function(terms, success, error) {
|
||||
|
||||
module.exports.deletePost = function(channelId, id, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/channels/" + channelId + "/post/" + id + "/delete",
|
||||
url: '/api/v1/channels/' + channelId + '/post/' + id + '/delete',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("deletePost", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('deletePost', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -720,14 +714,14 @@ module.exports.deletePost = function(channelId, id, success, error) {
|
||||
|
||||
module.exports.createPost = function(post, channel, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/channels/"+ post.channel_id + "/create",
|
||||
url: '/api/v1/channels/' + post.channel_id + '/create',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(post),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("createPost", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('createPost', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -740,20 +734,20 @@ module.exports.createPost = function(post, channel, success, error) {
|
||||
// channel_type: channel.type,
|
||||
// length: post.message.length,
|
||||
// files: (post.filenames || []).length,
|
||||
// mentions: (post.message.match("/<mention>/g") || []).length
|
||||
// mentions: (post.message.match('/<mention>/g') || []).length
|
||||
// });
|
||||
};
|
||||
|
||||
module.exports.updatePost = function(post, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/channels/"+ post.channel_id + "/update",
|
||||
url: '/api/v1/channels/' + post.channel_id + '/update',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(post),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("updatePost", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('updatePost', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -763,14 +757,14 @@ module.exports.updatePost = function(post, success, error) {
|
||||
|
||||
module.exports.addChannelMember = function(id, data, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/channels/" + id + "/add",
|
||||
url: '/api/v1/channels/' + id + '/add',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(data),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("addChannelMember", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('addChannelMember', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -780,14 +774,14 @@ module.exports.addChannelMember = function(id, data, success, error) {
|
||||
|
||||
module.exports.removeChannelMember = function(id, data, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/channels/" + id + "/remove",
|
||||
url: '/api/v1/channels/' + id + '/remove',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(data),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("removeChannelMember", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('removeChannelMember', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -797,14 +791,14 @@ module.exports.removeChannelMember = function(id, data, success, error) {
|
||||
|
||||
module.exports.getProfiles = function(success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/users/profiles",
|
||||
url: '/api/v1/users/profiles',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'GET',
|
||||
success: success,
|
||||
ifModified: true,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("getProfiles", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('getProfiles', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -812,16 +806,16 @@ module.exports.getProfiles = function(success, error) {
|
||||
|
||||
module.exports.uploadFile = function(formData, success, error) {
|
||||
var request = $.ajax({
|
||||
url: "/api/v1/files/upload",
|
||||
url: '/api/v1/files/upload',
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
error: function onError(xhr, status, err) {
|
||||
if (err !== 'abort') {
|
||||
e = handleError("uploadFile", xhr, status, err);
|
||||
var e = handleError('uploadFile', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
}
|
||||
@@ -834,13 +828,13 @@ module.exports.uploadFile = function(formData, success, error) {
|
||||
|
||||
module.exports.getPublicLink = function(data, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/files/get_public_link",
|
||||
url: '/api/v1/files/get_public_link',
|
||||
dataType: 'json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(data),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("getPublicLink", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('getPublicLink', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -848,15 +842,31 @@ module.exports.getPublicLink = function(data, success, error) {
|
||||
|
||||
module.exports.uploadProfileImage = function(imageData, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/users/newimage",
|
||||
url: '/api/v1/users/newimage',
|
||||
type: 'POST',
|
||||
data: imageData,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("uploadProfileImage", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('uploadProfileImage', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.importSlack = function(fileData, success, error) {
|
||||
$.ajax({
|
||||
url: '/api/v1/teams/import_team',
|
||||
type: 'POST',
|
||||
data: fileData,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: success,
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('importTeam', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -864,13 +874,13 @@ module.exports.uploadProfileImage = function(imageData, success, error) {
|
||||
|
||||
module.exports.getStatuses = function(success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/users/status",
|
||||
url: '/api/v1/users/status',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'GET',
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("getStatuses", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('getStatuses', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -878,13 +888,13 @@ module.exports.getStatuses = function(success, error) {
|
||||
|
||||
module.exports.getMyTeam = function(success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/teams/me",
|
||||
url: '/api/v1/teams/me',
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
success: success,
|
||||
ifModified: true,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("getMyTeam", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('getMyTeam', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -892,14 +902,14 @@ module.exports.getMyTeam = function(success, error) {
|
||||
|
||||
module.exports.updateValetFeature = function(data, success, error) {
|
||||
$.ajax({
|
||||
url: "/api/v1/teams/update_valet_feature",
|
||||
url: '/api/v1/teams/update_valet_feature',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(data),
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
e = handleError("updateValetFeature", xhr, status, err);
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('updateValetFeature', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
@@ -914,10 +924,10 @@ function getConfig(success, error) {
|
||||
type: 'GET',
|
||||
ifModified: true,
|
||||
success: success,
|
||||
error: function(xhr, status, err) {
|
||||
error: function onError(xhr, status, err) {
|
||||
var e = handleError('getConfig', xhr, status, err);
|
||||
error(e);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
module.exports.getConfig = getConfig;
|
||||
|
||||
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@@ -56,11 +56,11 @@
|
||||
|
||||
<script>
|
||||
if (config.LogglyWriteKey != null && config.LogglyWriteKey !== "") {
|
||||
var _LTracker = _LTracker || [];
|
||||
window._LTracker = _LTracker;
|
||||
_LTracker.push({'logglyKey': config.LogglyWriteKey, 'sendConsoleErrors' : config.LogglyConsoleErrors });
|
||||
var LTracker = LTracker || [];
|
||||
window.LTracker = LTracker;
|
||||
LTracker.push({'logglyKey': config.LogglyWriteKey, 'sendConsoleErrors' : config.LogglyConsoleErrors });
|
||||
} else {
|
||||
window._LTracker = [];
|
||||
window.LTracker = [];
|
||||
console.warn("config.js missing LogglyWriteKey, Loggly analytics is not reporting");
|
||||
}
|
||||
</script>
|
||||
|
||||
Ссылка в новой задаче
Block a user