+125
@@ -0,0 +1,125 @@
|
||||
import Observable from 'app/deprecated/CollectionsV1/observable.js';
|
||||
import Api from 'app/features/global/framework/api-service';
|
||||
import ws from 'app/deprecated/websocket/websocket.js';
|
||||
import Collections from 'app/deprecated/CollectionsV1/Collections/Collections.js';
|
||||
import Workspaces from 'app/deprecated/workspaces/workspaces.jsx';
|
||||
import ListenGroups from './listen_groups.js';
|
||||
|
||||
import $ from 'jquery';
|
||||
import JWTStorage from 'app/features/auth/jwt-storage-service';
|
||||
import CompanyAPIClient from '../../features/companies/api/company-api-client';
|
||||
import UserService from 'app/features/users/services/current-user-service';
|
||||
import Globals from 'app/features/global/services/globals-tdrive-app-service';
|
||||
|
||||
class Groups extends Observable {
|
||||
constructor() {
|
||||
super();
|
||||
this.setObservableName('groups');
|
||||
this.currentGroupId = null;
|
||||
|
||||
this.user_groups = {};
|
||||
Globals.window.gs = this;
|
||||
}
|
||||
|
||||
select(group) {
|
||||
if (this.currentGroupId === group.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!group.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.currentGroupId) {
|
||||
ListenGroups.cancelListenGroup(this.currentGroupId);
|
||||
}
|
||||
ListenGroups.listenGroup(group.id);
|
||||
|
||||
this.currentGroupId = group.id;
|
||||
Workspaces.changeGroup(group);
|
||||
this.notify();
|
||||
}
|
||||
|
||||
addToUser(group) {
|
||||
var current_group = Collections.get('groups').find(group.id);
|
||||
if (current_group && current_group._user_hasnotifications) {
|
||||
group._user_hasnotifications =
|
||||
group._user_hasnotifications || current_group._user_hasnotifications;
|
||||
}
|
||||
|
||||
var id = group.id;
|
||||
Collections.get('groups').updateObject(group);
|
||||
this.user_groups[id] = Collections.get('groups').known_objects_by_id[id];
|
||||
}
|
||||
|
||||
async getOrderedGroups() {
|
||||
const userCompanies = await CompanyAPIClient.listCompanies(UserService.getCurrentUserId());
|
||||
|
||||
return userCompanies;
|
||||
//.sort((a, b) => String(a.name).localeCompare(String(b.name)));
|
||||
}
|
||||
|
||||
updateName(name) {
|
||||
var that = this;
|
||||
this.loading = true;
|
||||
this.notify();
|
||||
Api.post('/ajax/workspace/group/data/name', { groupId: this.currentGroupId, name }, res => {
|
||||
if (res.errors.length === 0) {
|
||||
var group = { id: that.currentGroupId, name: name };
|
||||
Collections.get('groups').updateObject(group);
|
||||
ws.publish('group/' + group.id, { data: { group: group } });
|
||||
}
|
||||
that.loading = false;
|
||||
that.notify();
|
||||
});
|
||||
}
|
||||
updateLogo(logo) {
|
||||
this.loading = true;
|
||||
this.notify();
|
||||
var route = `${Globals.api_root_url}/ajax/workspace/group/data/logo`;
|
||||
|
||||
var data = new FormData();
|
||||
if (logo !== false) {
|
||||
data.append('logo', logo);
|
||||
}
|
||||
data.append('groupId', this.currentGroupId);
|
||||
var that = this;
|
||||
|
||||
$.ajax({
|
||||
url: route,
|
||||
type: 'POST',
|
||||
data: data,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
|
||||
headers: {
|
||||
Authorization: JWTStorage.getAutorizationHeader(),
|
||||
},
|
||||
xhrFields: {
|
||||
withCredentials: true,
|
||||
},
|
||||
xhr: function () {
|
||||
var myXhr = $.ajaxSettings.xhr();
|
||||
myXhr.onreadystatechange = function () {
|
||||
if (myXhr.readyState === XMLHttpRequest.DONE) {
|
||||
that.loading = false;
|
||||
var resp = JSON.parse(myXhr.responseText);
|
||||
if (resp.errors.indexOf('badimage') > -1) {
|
||||
that.error_identity_badimage = true;
|
||||
} else {
|
||||
var group = resp.data;
|
||||
Collections.get('groups').updateObject(group);
|
||||
ws.publish('group/' + group.id, { data: { group: group } });
|
||||
}
|
||||
that.notify();
|
||||
}
|
||||
};
|
||||
return myXhr;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const service = new Groups();
|
||||
export default service;
|
||||
@@ -0,0 +1,47 @@
|
||||
import ws from 'app/deprecated/websocket/websocket.js';
|
||||
import Collections from 'app/deprecated/CollectionsV1/Collections/Collections.js';
|
||||
|
||||
class ListenGroups {
|
||||
constructor() {
|
||||
this.groups_repository = Collections.get('groups');
|
||||
this.listenerCount = {};
|
||||
}
|
||||
|
||||
listenGroup(idGroup) {
|
||||
if (!idGroup) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.listenerCount[idGroup]) {
|
||||
this.listenerCount[idGroup] = 0;
|
||||
}
|
||||
this.listenerCount[idGroup] += 1;
|
||||
|
||||
var that = this;
|
||||
if (this.listenerCount[idGroup] === 1) {
|
||||
ws.subscribe('group/' + idGroup, function (uri, data) {
|
||||
data = data.data;
|
||||
if (data.group) {
|
||||
data.group.id = idGroup;
|
||||
that.groups_repository.updateObject(data.group);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
cancelListenGroup(idGroup) {
|
||||
if (!idGroup) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.listenerCount[idGroup]) {
|
||||
this.listenerCount[idGroup] += -1;
|
||||
}
|
||||
if (!this.listenerCount[idGroup] || this.listenerCount[idGroup] === 0) {
|
||||
ws.unsubscribe('group/' + idGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const service = new ListenGroups();
|
||||
export default service;
|
||||
@@ -0,0 +1,46 @@
|
||||
import ws from 'app/deprecated/websocket/websocket.js';
|
||||
import Collections from 'app/deprecated/CollectionsV1/Collections/Collections.js';
|
||||
|
||||
class ListenWorkspace {
|
||||
constructor() {
|
||||
this.workspaces_repository = Collections.get('workspaces');
|
||||
this.listenerCount = {};
|
||||
}
|
||||
|
||||
listenWorkspace(idWorkspace) {
|
||||
if (!idWorkspace) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.listenerCount[idWorkspace]) {
|
||||
this.listenerCount[idWorkspace] = 0;
|
||||
}
|
||||
this.listenerCount[idWorkspace] += 1;
|
||||
|
||||
var that = this;
|
||||
if (this.listenerCount[idWorkspace] === 1) {
|
||||
ws.subscribe('workspace/' + idWorkspace, function (uri, data) {
|
||||
if (data.workspace) {
|
||||
data.workspace.id = idWorkspace;
|
||||
that.workspaces_repository.updateObject(data.workspace);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
cancelListenWorkspace(idWorkspace) {
|
||||
if (!idWorkspace) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.listenerCount[idWorkspace]) {
|
||||
this.listenerCount[idWorkspace] += -1;
|
||||
}
|
||||
if (!this.listenerCount[idWorkspace] || this.listenerCount[idWorkspace] === 0) {
|
||||
ws.unsubscribe('workspace/' + idWorkspace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const service = new ListenWorkspace();
|
||||
export default service;
|
||||
@@ -0,0 +1,309 @@
|
||||
import DepreciatedCollections from 'app/deprecated/CollectionsV1/Collections/Collections.js';
|
||||
import Observable from 'app/deprecated/CollectionsV1/observable.js';
|
||||
import { default as popupManager, default as PopupManager } from 'app/deprecated/popupManager/popupManager.js';
|
||||
import ws from 'app/deprecated/websocket/websocket.js';
|
||||
import Groups from 'app/deprecated/workspaces/groups.js';
|
||||
import workspacesApps from 'app/deprecated/workspaces/workspaces_apps.jsx';
|
||||
import JWTStorage from 'app/features/auth/jwt-storage-service';
|
||||
import loginService from 'app/features/auth/login-service';
|
||||
import ConsoleService from 'app/features/console/services/console-service';
|
||||
import Api from 'app/features/global/framework/api-service';
|
||||
import LocalStorage from 'app/features/global/framework/local-storage-service';
|
||||
import Logger from 'app/features/global/framework/logger-service';
|
||||
import Globals from 'app/features/global/services/globals-tdrive-app-service';
|
||||
import WindowService from 'app/features/global/utils/window';
|
||||
import RouterServices from 'app/features/router/services/router-service';
|
||||
import workspacesUsers from 'app/features/workspace-members/services/workspace-members-service';
|
||||
import $ from 'jquery';
|
||||
import WorkspaceAPIClient from '../../features/workspaces/api/workspace-api-client';
|
||||
|
||||
class Workspaces extends Observable {
|
||||
constructor() {
|
||||
super();
|
||||
Globals.window.workspaceService = this;
|
||||
|
||||
this.setObservableName('workspaces');
|
||||
this.logger = Logger.getLogger('services/Workspaces');
|
||||
|
||||
this.currentWorkspaceId = '';
|
||||
this.currentWorkspaceIdByGroup = {};
|
||||
this.currentGroupId = null;
|
||||
|
||||
this.user_workspaces = {};
|
||||
this.getting_details = {};
|
||||
this.showNoWorkspacesPage = false;
|
||||
this.showNoCompaniesPage = false;
|
||||
this.loading = false;
|
||||
|
||||
this.url_values = WindowService.getInfoFromUrl() || {};
|
||||
|
||||
this.didFirstSelection = false;
|
||||
}
|
||||
|
||||
updateCurrentWorkspaceId(workspaceId, notify = false) {
|
||||
if (this.currentWorkspaceId !== workspaceId && workspaceId) {
|
||||
const workspace = DepreciatedCollections.get('workspaces').find(workspaceId);
|
||||
if (!workspace) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.currentWorkspaceId = workspaceId;
|
||||
this.currentWorkspaceIdByGroup[workspace.company_id] = workspaceId;
|
||||
|
||||
if (!this.getting_details[workspaceId]) {
|
||||
this.getting_details[workspaceId] = true;
|
||||
|
||||
workspacesApps.unload(this.currentWorkspaceId);
|
||||
WorkspaceAPIClient.get(workspace.company_id, workspaceId)
|
||||
.then(workspace => {
|
||||
if (!workspace) {
|
||||
this.removeFromUser(workspaceId);
|
||||
}
|
||||
DepreciatedCollections.get('workspaces').updateObject(workspace);
|
||||
notify && this.notify();
|
||||
|
||||
// FIXME: What is this???
|
||||
setTimeout(() => {
|
||||
this.getting_details[workspaceId] = false;
|
||||
}, 10000);
|
||||
})
|
||||
.catch(() => {
|
||||
this.removeFromUser(workspaceId);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateCurrentCompanyId(companyId, notify = false) {
|
||||
if (this.currentGroupId !== companyId && companyId) {
|
||||
Groups.currentGroupId = companyId;
|
||||
this.currentGroupId = companyId;
|
||||
notify && this.notify();
|
||||
}
|
||||
}
|
||||
|
||||
openNoWorkspacesPage() {
|
||||
this.showNoWorkspacesPage = true;
|
||||
this.notify();
|
||||
}
|
||||
|
||||
closeNoWorkspacesPage() {
|
||||
this.showNoWorkspacesPage = false;
|
||||
popupManager.close();
|
||||
this.notify();
|
||||
}
|
||||
|
||||
openNoCompaniesPage() {
|
||||
this.showNoCompaniesPage = true;
|
||||
this.notify();
|
||||
}
|
||||
|
||||
closeNoCompaniesPage() {
|
||||
this.showNoCompaniesPage = false;
|
||||
popupManager.close();
|
||||
this.notify();
|
||||
}
|
||||
|
||||
openCreateCompanyPage(page) {
|
||||
popupManager.open(page, this.user_workspaces.length > 0);
|
||||
}
|
||||
|
||||
closeCreateCompanyPage() {
|
||||
popupManager.close();
|
||||
}
|
||||
|
||||
closeCreateWorkspacePage() {
|
||||
popupManager.close();
|
||||
}
|
||||
|
||||
changeGroup(group) {
|
||||
this.updateCurrentCompanyId(group.id);
|
||||
this.notify();
|
||||
if (this.currentWorkspaceIdByGroup[group.id]) {
|
||||
this.select(this.user_workspaces[this.currentWorkspaceIdByGroup[group.id]]);
|
||||
return;
|
||||
}
|
||||
this.select(this.getOrderedWorkspacesInGroup(group.id)[0]);
|
||||
}
|
||||
|
||||
select(workspace, replace = false) {
|
||||
if (!workspace) {
|
||||
return;
|
||||
}
|
||||
if (workspace.id === this.currentWorkspaceId) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.updateCurrentWorkspaceId(workspace.id);
|
||||
|
||||
const route = RouterServices.generateRouteFromState({
|
||||
companyId: workspace.company_id,
|
||||
workspaceId: workspace.id,
|
||||
channelId: '',
|
||||
});
|
||||
if (replace) {
|
||||
RouterServices.replace(route);
|
||||
} else {
|
||||
RouterServices.push(route);
|
||||
}
|
||||
|
||||
LocalStorage.setItem(`default_workspace_id_${workspace.company_id}`, workspace.id);
|
||||
|
||||
this.notify();
|
||||
}
|
||||
|
||||
removeFromUser(workspace) {
|
||||
if (!workspace) {
|
||||
return;
|
||||
}
|
||||
|
||||
var id = workspace.id || workspace;
|
||||
delete this.user_workspaces[id];
|
||||
}
|
||||
|
||||
getOrderedWorkspacesInGroup(group_id) {
|
||||
var object = [];
|
||||
Object.keys(this.user_workspaces)
|
||||
.sort((_a, _b) => {
|
||||
var a = this.user_workspaces[_a] || {};
|
||||
var b = this.user_workspaces[_b] || {};
|
||||
return (a.name || '').localeCompare(b.name || '');
|
||||
})
|
||||
.forEach(e => {
|
||||
// eslint-disable-next-line no-redeclare
|
||||
var e = this.user_workspaces[e];
|
||||
if (!group_id || e?.company_id === group_id) {
|
||||
object.push(e);
|
||||
}
|
||||
});
|
||||
return object;
|
||||
}
|
||||
|
||||
async createWorkspace(wsName, wsMembers, groupId, groupName, groupCreationData) {
|
||||
var that = this;
|
||||
that.loading = true;
|
||||
that.notify();
|
||||
const res = await WorkspaceAPIClient.create(groupId, {
|
||||
name: wsName,
|
||||
logo: '',
|
||||
default: false,
|
||||
});
|
||||
var workspace = res;
|
||||
if (workspace) {
|
||||
//Update rights and more
|
||||
loginService.updateUser();
|
||||
if (wsMembers.length > 0) {
|
||||
//Invite using console
|
||||
ConsoleService.addMailsInWorkspace({
|
||||
workspace_id: workspace.id || '',
|
||||
company_id: workspace?.group?.id || workspace.company_id || '',
|
||||
emails: wsMembers,
|
||||
}).finally(() => {
|
||||
that.loading = false;
|
||||
popupManager.close();
|
||||
if (workspace) {
|
||||
that.select(workspace);
|
||||
} else {
|
||||
that.notify();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
that.loading = false;
|
||||
popupManager.close();
|
||||
if (workspace) {
|
||||
that.select(workspace);
|
||||
} else {
|
||||
that.notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async updateWorkspaceName(name) {
|
||||
this.loading = true;
|
||||
this.notify();
|
||||
|
||||
try {
|
||||
const result = await WorkspaceAPIClient.update(this.currentGroupId, this.currentWorkspaceId, {
|
||||
name,
|
||||
});
|
||||
this.logger.debug('Workspace updated', result);
|
||||
DepreciatedCollections.get('workspaces').updateObject({
|
||||
id: this.currentWorkspaceId,
|
||||
name,
|
||||
});
|
||||
} catch (err) {
|
||||
this.logger.error('Can not update the workspace', err);
|
||||
}
|
||||
this.loading = false;
|
||||
this.notify();
|
||||
}
|
||||
|
||||
updateWorkspaceLogo(logo) {
|
||||
this.loading = true;
|
||||
this.notify();
|
||||
var route = `${Globals.api_root_url}/ajax/workspace/data/logo`;
|
||||
|
||||
var data = new FormData();
|
||||
if (logo !== false) {
|
||||
data.append('logo', logo);
|
||||
}
|
||||
data.append('workspaceId', this.currentWorkspaceId);
|
||||
var that = this;
|
||||
|
||||
$.ajax({
|
||||
url: route,
|
||||
type: 'POST',
|
||||
data: data,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
|
||||
headers: {
|
||||
Authorization: JWTStorage.getAutorizationHeader(),
|
||||
},
|
||||
xhrFields: {
|
||||
withCredentials: true,
|
||||
},
|
||||
xhr: function () {
|
||||
var myXhr = $.ajaxSettings.xhr();
|
||||
myXhr.onreadystatechange = function () {
|
||||
if (myXhr.readyState === XMLHttpRequest.DONE) {
|
||||
that.loading = false;
|
||||
var resp = JSON.parse(myXhr.responseText);
|
||||
if (resp.errors.indexOf('badimage') > -1) {
|
||||
that.error_identity_badimage = true;
|
||||
that.notify();
|
||||
} else {
|
||||
var update = resp.data;
|
||||
DepreciatedCollections.get('workspaces').updateObject(update);
|
||||
ws.publish('workspace/' + update.id, { workspace: update });
|
||||
that.notify();
|
||||
}
|
||||
}
|
||||
};
|
||||
return myXhr;
|
||||
},
|
||||
});
|
||||
}
|
||||
deleteWorkspace() {
|
||||
if (
|
||||
workspacesUsers.getUsersByWorkspace(this.currentWorkspaceId) &&
|
||||
(Object.keys(workspacesUsers.getUsersByWorkspace(this.currentWorkspaceId)) || []).length > 1
|
||||
) {
|
||||
this.errorDeleteWorkspaceMember = true;
|
||||
this.notify();
|
||||
} else if (this.currentWorkspaceId) {
|
||||
Api.post('/ajax/workspace/delete', { workspaceId: this.currentWorkspaceId }, function (res) {
|
||||
PopupManager.close();
|
||||
});
|
||||
}
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
getCurrentWorkspace() {
|
||||
return DepreciatedCollections.get('workspaces').find(this.currentWorkspaceId) || {};
|
||||
}
|
||||
}
|
||||
|
||||
export default new Workspaces();
|
||||
@@ -0,0 +1,262 @@
|
||||
import React from 'react';
|
||||
import Observable from 'app/deprecated/CollectionsV1/observable.js';
|
||||
import CurrentUser from 'app/deprecated/user/CurrentUser';
|
||||
import Api from 'app/features/global/framework/api-service';
|
||||
import ws from 'app/deprecated/websocket/websocket.js';
|
||||
import Collections from 'app/deprecated/CollectionsV1/Collections/Collections.js';
|
||||
import Groups from './groups.js';
|
||||
import Workspaces from './workspaces.jsx';
|
||||
import Globals from 'app/features/global/services/globals-tdrive-app-service';
|
||||
import Icon from 'app/components/icon/icon';
|
||||
import { getUser } from 'app/features/users/hooks/use-user-list';
|
||||
import Login from 'app/features/auth/login-service';
|
||||
import { Folder, Calendar, CheckSquare, Hexagon } from 'react-feather';
|
||||
import { getCompanyApplication as getApplication } from 'app/features/applications/state/company-applications';
|
||||
|
||||
class WorkspacesApps extends Observable {
|
||||
constructor() {
|
||||
super();
|
||||
this.setObservableName('workspaces_apps');
|
||||
|
||||
Collections.get('applications');
|
||||
var options = {
|
||||
base_url: 'applications',
|
||||
use_cache: true,
|
||||
};
|
||||
Collections.updateOptions('applications', options);
|
||||
|
||||
this.apps_by_workspace = {};
|
||||
this.apps_by_group = {};
|
||||
this.findingApp = {};
|
||||
this.did_first_load = {};
|
||||
|
||||
Globals.window.workspacesApps = this;
|
||||
|
||||
this.loading_by_workspace = {};
|
||||
}
|
||||
|
||||
notifyApp(app_id, type, event, data, workspace_id = undefined, group_id = undefined) {
|
||||
workspace_id = workspace_id || Workspaces.currentWorkspaceId;
|
||||
group_id = group_id || Workspaces.currentGroupId;
|
||||
|
||||
const connection_id = CurrentUser.unique_connection_id;
|
||||
|
||||
// eslint-disable-next-line no-redeclare
|
||||
data = {
|
||||
workspace_id: workspace_id,
|
||||
company_id: group_id,
|
||||
app_id: app_id,
|
||||
type: type,
|
||||
name: event,
|
||||
data: { user: Collections.get('users').find(Login.currentUserId), ...data },
|
||||
content: {},
|
||||
connection_id: connection_id,
|
||||
};
|
||||
|
||||
Api.post(
|
||||
`/internal/services/applications/v1/applications/${app_id}/event`,
|
||||
data,
|
||||
res => {},
|
||||
).then();
|
||||
}
|
||||
|
||||
unload(workspace_id) {
|
||||
ws.unsubscribe('workspace_apps/' + workspace_id);
|
||||
}
|
||||
|
||||
load(workspace_id, reset_offset, options) {
|
||||
if (!workspace_id) {
|
||||
return;
|
||||
}
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
|
||||
if (this.loading_by_workspace[workspace_id]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.loading_by_workspace[workspace_id] = true;
|
||||
this.notify();
|
||||
|
||||
var data = {
|
||||
workspace_id: workspace_id,
|
||||
};
|
||||
|
||||
var loadApps = data => {
|
||||
if (data.length > 0) {
|
||||
this.apps_by_workspace[data[0].workspace_id] = {};
|
||||
}
|
||||
|
||||
data.forEach(item => {
|
||||
this.apps_by_workspace[item.workspace_id][item.app.id] = item.app;
|
||||
Collections.get('applications').updateObject(item.app);
|
||||
});
|
||||
|
||||
this.did_first_load[workspace_id] = true;
|
||||
|
||||
this.notify();
|
||||
};
|
||||
|
||||
if (options.apps) {
|
||||
this.loading_by_workspace[workspace_id] = false;
|
||||
loadApps(options.apps);
|
||||
} else {
|
||||
Api.post('/ajax/workspace/apps/get', data, res => {
|
||||
if (res.data) {
|
||||
loadApps(res.data);
|
||||
}
|
||||
|
||||
this.loading_by_workspace[workspace_id] = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
loadGroupApps() {
|
||||
Api.post('/ajax/workspace/group/apps/get', { group_id: Groups.currentGroupId }, res => {
|
||||
if (res.data) {
|
||||
res.data.forEach(item => {
|
||||
var app_link = {
|
||||
workspace_count: item.workspace_count,
|
||||
workspace_default: item.workspace_default,
|
||||
app: item.app,
|
||||
};
|
||||
if (!this.apps_by_group) this.apps_by_group = {};
|
||||
if (!this.apps_by_group[item.group_id]) this.apps_by_group[item.group_id] = {};
|
||||
this.apps_by_group[item.group_id][item.app.id] = app_link;
|
||||
});
|
||||
|
||||
this.notify();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
recieveWS(res) {
|
||||
if (res.type === 'add') {
|
||||
var app_link = {
|
||||
workspace_count: res.workspace_app.workspace_count,
|
||||
workspace_default: res.workspace_app.workspace_default,
|
||||
app: res.workspace_app.app,
|
||||
};
|
||||
this.apps_by_workspace[res.workspace_app.workspace_id][res.workspace_app.app.id] =
|
||||
res.workspace_app.app;
|
||||
this.apps_by_group[res.workspace_app.group_id][res.workspace_app.app.id] = app_link;
|
||||
Collections.get('applications').completeObject(
|
||||
res.workspace_app.app,
|
||||
res.workspace_app.app.front_id,
|
||||
);
|
||||
} else if (res.type === 'remove') {
|
||||
delete this.apps_by_workspace[res.workspace_app.workspace_id][res.workspace_app.app.id];
|
||||
}
|
||||
this.notify();
|
||||
}
|
||||
|
||||
forceInEntreprise(id) {
|
||||
var data = {
|
||||
group_id: Groups.currentGroupId,
|
||||
app_id: id,
|
||||
};
|
||||
|
||||
if (
|
||||
this.apps_by_group[Groups.currentGroupId] &&
|
||||
this.apps_by_group[Groups.currentGroupId][id]
|
||||
) {
|
||||
this.apps_by_workspace[Workspaces.currentWorkspaceId][id] =
|
||||
this.apps_by_group[Groups.currentGroupId][id].app;
|
||||
}
|
||||
|
||||
Api.post('/ajax/workspace/group/application/force', data, function (res) {});
|
||||
|
||||
this.notify();
|
||||
}
|
||||
|
||||
forceRemoveFromEntreprise(id) {
|
||||
var data = {
|
||||
group_id: Groups.currentGroupId,
|
||||
app_id: id,
|
||||
};
|
||||
|
||||
if (
|
||||
this.apps_by_group[Groups.currentGroupId] &&
|
||||
this.apps_by_group[Groups.currentGroupId][id]
|
||||
) {
|
||||
delete this.apps_by_group[Groups.currentGroupId][id];
|
||||
}
|
||||
if (
|
||||
this.apps_by_workspace[Workspaces.currentWorkspaceId] &&
|
||||
this.apps_by_workspace[Workspaces.currentWorkspaceId][id]
|
||||
) {
|
||||
delete this.apps_by_workspace[Workspaces.currentWorkspaceId][id];
|
||||
}
|
||||
|
||||
Api.post('/ajax/workspace/group/application/remove', data, function (res) {});
|
||||
|
||||
this.notify();
|
||||
}
|
||||
|
||||
defaultForWorkspacesInEntreprise(id, state) {
|
||||
var data = {
|
||||
group_id: Groups.currentGroupId,
|
||||
app_id: id,
|
||||
state: state,
|
||||
};
|
||||
|
||||
if (
|
||||
this.apps_by_group[Groups.currentGroupId] &&
|
||||
this.apps_by_group[Groups.currentGroupId][id]
|
||||
) {
|
||||
this.apps_by_group[Groups.currentGroupId][id].workspace_default = state;
|
||||
}
|
||||
|
||||
Api.post('/ajax/workspace/group/workspacedefault/set', data, function (res) {});
|
||||
|
||||
this.notify();
|
||||
}
|
||||
|
||||
openAppPopup(app_id) {}
|
||||
|
||||
getAppIcon(app, feather = false) {
|
||||
if (app && app?.identity?.code) {
|
||||
switch (app?.identity?.code.toLocaleLowerCase()) {
|
||||
case 'tdrive_calendar':
|
||||
return feather ? Calendar : 'calendar-alt';
|
||||
case 'tdrive_drive':
|
||||
return feather ? Folder : 'folder';
|
||||
case 'tdrive_tasks':
|
||||
return feather ? CheckSquare : 'check-square';
|
||||
default:
|
||||
return app.identity?.icon || (feather ? Hexagon : 'puzzle-piece');
|
||||
}
|
||||
}
|
||||
return feather ? Hexagon : 'puzzle-piece';
|
||||
}
|
||||
|
||||
getAppIconComponent(item, options = {}) {
|
||||
const application = getApplication(item.application_id ? item.application_id : item.id);
|
||||
const IconType = this.getAppIcon(application, true);
|
||||
|
||||
if (item.code === 'jitsi') {
|
||||
return (
|
||||
<div
|
||||
className="menu-app-icon"
|
||||
style={item.icon_url ? { backgroundImage: 'url(' + item.icon_url + ')' } : {}}
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
if (typeof IconType === 'string') {
|
||||
return (
|
||||
<Icon
|
||||
type={IconType}
|
||||
style={{ width: options.size || 18, height: options.size || 18 }}
|
||||
className="small-right-margin"
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
return <IconType size={options.size || 18} className="small-right-margin" />;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const workspaces = new WorkspacesApps();
|
||||
export default workspaces;
|
||||
Reference in New Issue
Block a user