diff --git a/tdrive/frontend/src/app/deprecated/Configurators/ConfiguratorsManager.js b/tdrive/frontend/src/app/deprecated/Configurators/ConfiguratorsManager.js deleted file mode 100755 index 96ee55eb..00000000 --- a/tdrive/frontend/src/app/deprecated/Configurators/ConfiguratorsManager.js +++ /dev/null @@ -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; diff --git a/tdrive/frontend/src/app/deprecated/login/account.js b/tdrive/frontend/src/app/deprecated/login/account.js deleted file mode 100755 index 3d264422..00000000 --- a/tdrive/frontend/src/app/deprecated/login/account.js +++ /dev/null @@ -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; diff --git a/tdrive/frontend/src/app/deprecated/workspaces/groups.js b/tdrive/frontend/src/app/deprecated/workspaces/groups.js deleted file mode 100755 index bff154e2..00000000 --- a/tdrive/frontend/src/app/deprecated/workspaces/groups.js +++ /dev/null @@ -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; diff --git a/tdrive/frontend/src/app/deprecated/workspaces/groups.ts b/tdrive/frontend/src/app/deprecated/workspaces/groups.ts new file mode 100755 index 00000000..6ed7a964 --- /dev/null +++ b/tdrive/frontend/src/app/deprecated/workspaces/groups.ts @@ -0,0 +1,3 @@ +export const Groups: { currentGroupId: null | string } = { + currentGroupId: null, +}; diff --git a/tdrive/frontend/src/app/deprecated/workspaces/listen_groups.js b/tdrive/frontend/src/app/deprecated/workspaces/listen_groups.js deleted file mode 100755 index f30461c1..00000000 --- a/tdrive/frontend/src/app/deprecated/workspaces/listen_groups.js +++ /dev/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; diff --git a/tdrive/frontend/src/app/deprecated/workspaces/workspaces.jsx b/tdrive/frontend/src/app/deprecated/workspaces/workspaces.jsx index e26e577a..09927904 100755 --- a/tdrive/frontend/src/app/deprecated/workspaces/workspaces.jsx +++ b/tdrive/frontend/src/app/deprecated/workspaces/workspaces.jsx @@ -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(); } diff --git a/tdrive/frontend/src/app/deprecated/workspaces/workspaces_apps.jsx b/tdrive/frontend/src/app/deprecated/workspaces/workspaces_apps.jsx deleted file mode 100755 index e02ac315..00000000 --- a/tdrive/frontend/src/app/deprecated/workspaces/workspaces_apps.jsx +++ /dev/null @@ -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 ( -
- ); - } else { - if (typeof IconType === 'string') { - return ( -