Removed 8 additional files

This commit is contained in:
Romaric Mourgues
2023-04-20 12:03:11 +02:00
parent c4cd108a51
commit 3ad32f0a56
12 changed files with 3 additions and 979 deletions
@@ -1,50 +0,0 @@
import Observable from '@deprecated/CollectionsV1/observable.js';
import Globals from '@features/global/services/globals-tdrive-app-service';
class ConfiguratorsManager extends Observable {
constructor() {
super();
this.setObservableName('configurators_manager');
Globals.window.configuratorsManager = this;
this.currentConfigurators = {};
this.configurator_order = [];
}
openConfigurator(app, form, hidden_data, id) {
this.currentConfigurators[app.id] = {
app: app,
form: form,
hidden_data: hidden_data,
id: id,
};
var _new_order = [];
this.configurator_order.forEach(id => {
if (app.id !== id) {
_new_order.push(id);
}
});
_new_order.push(app.id);
this.configurator_order = _new_order;
this.notify();
}
closeConfigurator(app) {
delete this.currentConfigurators[app.id];
var _new_order = [];
this.configurator_order.forEach(id => {
if (app.id !== id) {
_new_order.push(id);
}
});
this.configurator_order = _new_order;
this.notify();
}
}
const conf_serv = new ConfiguratorsManager();
export default conf_serv;
@@ -1,226 +0,0 @@
import Api from '@features/global/framework/api-service';
import Languages from '@features/global/services/languages-service';
import DepreciatedCollections from '@deprecated/CollectionsV1/Collections/Collections.js';
import Login from '../../features/auth/login-service';
import { getUser } from '../../features/users/hooks/use-user-list';
/**
* This service is depreciated as Tdrive will exclusively use Console in the future
*/
class Account {
notify() {
Login.notify();
}
/**
* Recover password
*/
recover(mail, funct, th) {
var data = {
email: mail,
};
var that = this;
this.login_loading = true;
that.error_recover_nosuchmail = false;
this.notify();
Api.post('/ajax/users/recover/mail', data, function (res) {
if (res.data.token) {
that.recover_token = res.data.token;
that.login_loading = false;
that.notify();
funct(th);
} else {
that.error_recover_nosuchmail = true;
that.login_loading = false;
that.notify();
//appel de funtion error
}
});
}
recoverCode(code, funct, th) {
var data = {
code: code,
token: this.recover_token,
};
var that = this;
that.error_recover_badcode = false;
this.login_loading = true;
this.notify();
Api.post('/ajax/users/recover/verify', data, function (res) {
if (res.data.status === 'success') {
that.recover_code = code;
that.login_loading = false;
that.notify();
funct(th);
} else {
that.error_recover_badcode = true;
that.login_loading = false;
that.notify();
}
});
}
recoverNewPassword(password, password2, funct, th) {
this.login_loading = true;
this.notify();
if (password !== password2 || password.length < 8) {
this.error_recover_badpasswords = true;
this.login_loading = false;
this.notify();
return;
}
var data = {
code: this.recover_code,
token: this.recover_token,
password: password,
};
var that = this;
that.error_recover_badpasswords = false;
that.error_recover_unknown = false;
this.notify();
Api.post('/ajax/users/recover/password', data, function (res) {
if (res.data.status === 'success') {
funct(th);
that.login_loading = false;
that.notify();
} else {
that.error_recover_unknown = true;
that.login_loading = false;
that.notify();
}
});
}
subscribeMail(username, password, name, first_name, phone, mail, newsletter, cb, th) {
if (this.doing_subscribe) {
return;
}
var data = {
email: mail,
username: username,
password: password,
name: name,
first_name: first_name,
phone: phone,
language: Languages.language,
newsletter: newsletter,
};
var that = this;
that.error_subscribe_mailalreadyused = false;
that.login_loading = true;
that.doing_subscribe = true;
this.notify();
Api.post('/ajax/users/subscribe/mail', data, function (res) {
that.login_loading = false;
that.doing_subscribe = false;
that.notify();
if (res.data.token) {
that.subscribe_token = res.data.token;
cb(th, 0);
that.waitForVerification(username, password, th);
} else {
cb(th, 1);
that.error_subscribe_mailalreadyused = true;
}
});
}
waitForVerification(username, password, th) {
if (this.waitForVerificationTimeout) {
clearTimeout(this.waitForVerificationTimeout);
}
this.waitForVerificationTimeout = setTimeout(() => {
this.waitForVerification(username, password, th);
Login.login({ username, password }, true);
}, 2000);
}
doVerifyMail(mail, code, token, success, fail) {
Api.post(
'/ajax/users/subscribe/doverifymail',
{
code: code,
token: token,
mail: mail,
device: {},
},
function (res) {
if (res.data.status === 'success') {
success();
} else {
fail();
}
},
);
}
checkMailandUsername(mail, username, callback, th) {
var that = this;
that.error_subscribe_username = false;
that.error_subscribe_mailalreadyused = false;
var data = {
mail: mail,
username: username,
};
that.login_loading = true;
that.notify();
Api.post('/ajax/users/subscribe/availability', data, function (res) {
that.login_loading = false;
if (res.data.status === 'success') {
callback(th, 0);
} else {
if (res.errors.length === 1 && res.errors[0] === 'mailalreadytaken') {
callback(th, 1);
that.error_subscribe_mailalreadyused = true;
} else if (res.errors.length === 1 && res.errors[0] === 'usernamealreadytaken') {
callback(th, 2);
that.error_subscribe_username = true;
} else {
callback(th, 3);
that.error_subscribe_mailalreadyused = true;
that.error_subscribe_username = true;
}
}
that.notify();
});
}
addNewMail(mail, cb, thot) {
var that = this;
that.loading = true;
that.error_secondary_mail_already = false;
that.error_code = false;
that.notify();
Api.post('/ajax/users/account/addmail', { mail: mail }, function (res) {
that.loading = false;
if (res.errors.indexOf('badmail') > -1) {
that.error_secondary_mail_already = true;
that.notify();
} else {
that.addmail_token = res.data.token;
that.notify();
cb(thot);
}
});
}
verifySecondMail(mail, code, cb, thot) {
//unimplemented
}
}
const æccount = new Account();
export default æccount;
@@ -1,125 +0,0 @@
import Observable from '@deprecated/CollectionsV1/observable.js';
import Api from '@features/global/framework/api-service';
import ws from '@deprecated/websocket/websocket.js';
import Collections from '@deprecated/CollectionsV1/Collections/Collections.js';
import Workspaces from '@deprecated/workspaces/workspaces.jsx';
import ListenGroups from './listen_groups.js';
import $ from 'jquery';
import JWTStorage from '@features/auth/jwt-storage-service';
import CompanyAPIClient from '../../features/companies/api/company-api-client';
import UserService from '@features/users/services/current-user-service';
import Globals from '@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;
+3
View File
@@ -0,0 +1,3 @@
export const Groups: { currentGroupId: null | string } = {
currentGroupId: null,
};
@@ -1,47 +0,0 @@
import ws from '@deprecated/websocket/websocket.js';
import Collections from '@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;
@@ -2,8 +2,6 @@ import DepreciatedCollections from '@deprecated/CollectionsV1/Collections/Collec
import Observable from '@deprecated/CollectionsV1/observable.js';
import { default as popupManager, default as PopupManager } from '@deprecated/popupManager/popupManager.js';
import ws from '@deprecated/websocket/websocket.js';
import Groups from '@deprecated/workspaces/groups.js';
import workspacesApps from '@deprecated/workspaces/workspaces_apps.jsx';
import JWTStorage from '@features/auth/jwt-storage-service';
import loginService from '@features/auth/login-service';
import ConsoleService from '@features/console/services/console-service';
@@ -53,7 +51,6 @@ class Workspaces extends Observable {
if (!this.getting_details[workspaceId]) {
this.getting_details[workspaceId] = true;
workspacesApps.unload(this.currentWorkspaceId);
WorkspaceAPIClient.get(workspace.company_id, workspaceId)
.then(workspace => {
if (!workspace) {
@@ -76,7 +73,6 @@ class Workspaces extends Observable {
updateCurrentCompanyId(companyId, notify = false) {
if (this.currentGroupId !== companyId && companyId) {
Groups.currentGroupId = companyId;
this.currentGroupId = companyId;
notify && this.notify();
}
@@ -1,262 +0,0 @@
import React from 'react';
import Observable from '@deprecated/CollectionsV1/observable.js';
import CurrentUser from '@deprecated/user/CurrentUser';
import Api from '@features/global/framework/api-service';
import ws from '@deprecated/websocket/websocket.js';
import Collections from '@deprecated/CollectionsV1/Collections/Collections.js';
import Groups from './groups.js';
import Workspaces from './workspaces.jsx';
import Globals from '@features/global/services/globals-tdrive-app-service';
import Icon from '@components/icon/icon';
import { getUser } from '@features/users/hooks/use-user-list';
import Login from '@features/auth/login-service';
import { Folder, Calendar, CheckSquare, Hexagon } from 'react-feather';
import { getCompanyApplication as getApplication } from '@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;
@@ -10,7 +10,6 @@ import _ from 'lodash';
import RouterService from '@features/router/services/router-service';
import WorkspacesService from '@deprecated/workspaces/workspaces.jsx';
import AccessRightsService from '@features/workspace-members/services/workspace-members-access-rights-service';
import Groups from '@deprecated/workspaces/groups.js';
import LoginService from '@features/auth/login-service';
import UserAPIClient from '@features/users/api/user-api-client';
import { useRealtimeRoom } from '@features/global/hooks/use-realtime';
@@ -72,7 +71,6 @@ export const useCurrentCompany = () => {
//Always set the current company in localstorage to open it automatically later
if (routerCompanyId && company) {
//Depreciated retrocompatibility
Groups.addToUser(company);
AccessRightsService.updateCompanyLevel(
company.id,
company.role === 'admin' || company.role === 'owner'
@@ -1,7 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/ban-types */
import Observable from '@deprecated/CollectionsV1/observable';
import DateTime from '@features/global/utils/datetime';
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import Backend from 'i18next-http-backend';
@@ -66,7 +65,6 @@ class LanguagesService extends Observable {
}
await i18n.changeLanguage(language);
DateTime.setCurrentLanguage(language);
this.notify();
}
@@ -1,39 +0,0 @@
import $ from 'jquery';
class DroppableManager {
constructor() {
this.drop = {};
this.draggingData = {};
this.dragging = false;
}
over(key, callback, event) {
this.drop[key] = {
callback: callback,
element: event.target,
};
}
out(key) {
this.drop[key] = undefined;
delete this.drop[key];
}
up() {
var that = this;
if (!that.draggingData.type || !that.draggingData.data || that.draggingData.data.length == 0) {
return;
}
if (!this.dragging) {
return;
}
this.drop.forEach(el => {
if (el && el.callback) {
el.callback(that.draggingData);
}
});
}
}
const instanceDroppableManager = new DroppableManager();
export default instanceDroppableManager;
@@ -1,191 +0,0 @@
import moment from 'moment';
import 'moment/locale/ru';
import 'moment/locale/fr';
import 'moment/locale/de';
import 'moment/locale/ja';
import 'moment/locale/es';
import Observable from '@deprecated/CollectionsV1/observable.js';
import UserService from '@features/users/services/current-user-service';
import Globals from '@features/global/services/globals-tdrive-app-service';
class DateTime extends Observable {
constructor() {
super();
if (!Globals.window.navigator) {
Globals.window.navigator = {};
}
this.observableName = 'dateTimeService';
this.locale = this.cleanLocal(
Globals.window.navigator.userLanguage || Globals.window.navigator.language || 'en',
);
}
getCurrentLanguage() {
return this.locale;
}
setCurrentLanguage(lang) {
this.locale = this.cleanLocal(lang);
moment.locale(this.locale);
this.notify();
}
cleanLocal(string) {
if (string.split('-').length > 1) {
return string.split('-')[0];
}
return string;
}
getDefaultTimeFormat() {
var h24list = [
'af',
'ar-dz',
'ar-kw',
'ar-ly',
'ar-ma',
'ar-sa',
'ar-tn',
'ar',
'az',
'be',
'bg',
'bn',
'bo',
'br',
'bs',
'ca',
'cs',
'cv',
'cy',
'da',
'de-at',
'de-ch',
'de',
'dv',
'el',
'en-au',
'en-ca',
'en-gb',
'en-ie',
'en-nz',
'eo',
'es-do',
'es',
'et',
'eu',
'fa',
'fi',
'fo',
'fr-ca',
'fr-ch',
'fr',
'fy',
'gd',
'gl',
'gom-latn',
'he',
'hi',
'hr',
'hu',
'hy-am',
'id',
'is',
'it',
'ja',
'jv',
'ka',
'kk',
'km',
'kn',
'ko',
'ky',
'lb',
'lo',
'lt',
'lv',
'me',
'mi',
'mk',
'ml',
'mr',
'ms-my',
'ms',
'my',
'nb',
'ne',
'nl-be',
'nl',
'nn',
'pa-in',
'pl',
'pt-br',
'pt',
'ro',
'ru',
'sd',
'se',
'si',
'sk',
'sl',
'sq',
'sr-cyrl',
'sr',
'ss',
'sv',
'sw',
'ta',
'te',
'tet',
'th',
'tl-ph',
'tlh',
'tr',
'tzl',
'tzm-latn',
'tzm',
'uk',
'ur',
'uz-latn',
'uz',
'vi',
'x-pseudo',
'yo',
'zh-cn',
'zh-hk',
'zh-tw',
];
if (
h24list.indexOf(
(UserService.getCurrentUser() || {}).language ||
Globals.window.navigator.language ||
Globals.window.navigator.userLanguage ||
'en',
) >= 0
) {
return 'H:mm';
}
return 'LT';
}
isDateFirstInFormat() {
var numbers = moment().format('L').split('/');
if (numbers[0] === new Date().getDate()) {
return true;
} else {
return false;
}
}
getDefaultDateFormat() {
/*var numbers = moment().format("L").split("/");
if(numbers[0] == (new Date()).getDate()){
return "DD/MM/YYYY";
}else{
return "MM/DD/YYYY";
}*/
return 'LL'; //Default format for country better but US is "May 11, 2019" instead of "11 may 2019"
}
}
var x = new DateTime();
Globals.window.dateTimeService = x;
export default x;
@@ -1,31 +0,0 @@
import Observable from '@deprecated/CollectionsV1/observable.js';
import Api from '@features/global/framework/api-service';
class WorkspacePicker extends Observable {
constructor() {
super();
this.observableName = 'workspacePicker';
this.searchedWorkspace = null;
this.refresh = false;
this.searchInput = '';
this.searchLabel = '';
this.isSearching = false;
}
getWorkspaceByName(name) {
var data = {
name: name,
};
this.isSearching = true;
this.notify();
var that = this;
Api.post('/ajax/workspace/getByName', data, function (res) {
that.searchedWorkspace = res.data.workspace;
that.isSearching = false;
that.notify();
});
}
}
const wsPicker = new WorkspacePicker();
export default wsPicker;