mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-03 14:19:56 +00:00
parent
6b05833c8b
commit
2a2705f6fe
@ -185,3 +185,17 @@ export interface IdMap<T extends Doc> extends Map<Ref<T>, T> {}
|
|||||||
export function toIdMap<T extends Doc> (arr: T[]): IdMap<T> {
|
export function toIdMap<T extends Doc> (arr: T[]): IdMap<T> {
|
||||||
return new Map(arr.map((p) => [p._id, p]))
|
return new Map(arr.map((p) => [p._id, p]))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export function concatLink (host: string, path: string): string {
|
||||||
|
if (!host.endsWith('/') && !path.startsWith('/')) {
|
||||||
|
return `${host}/${path}`
|
||||||
|
} else if (host.endsWith('/') && path.startsWith('/')) {
|
||||||
|
const newPath = path.slice(1)
|
||||||
|
return `${host}${newPath}`
|
||||||
|
} else {
|
||||||
|
return `${host}${path}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
import { createEventDispatcher } from 'svelte'
|
import { createEventDispatcher } from 'svelte'
|
||||||
import login from '@hcengineering/login'
|
import login from '@hcengineering/login'
|
||||||
import gmail from '../plugin'
|
import gmail from '../plugin'
|
||||||
|
import { concatLink } from '@hcengineering/core'
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
@ -27,7 +28,8 @@
|
|||||||
|
|
||||||
async function sendRequest (): Promise<void> {
|
async function sendRequest (): Promise<void> {
|
||||||
connecting = true
|
connecting = true
|
||||||
const url = new URL(gmailUrl + '/signin')
|
const link = concatLink(gmailUrl, '/signin')
|
||||||
|
const url = new URL(link)
|
||||||
url.search = new URLSearchParams({
|
url.search = new URLSearchParams({
|
||||||
redirectURL: window.location.href
|
redirectURL: window.location.href
|
||||||
}).toString()
|
}).toString()
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
import login from '@hcengineering/login'
|
import login from '@hcengineering/login'
|
||||||
import PinPad from './PinPad.svelte'
|
import PinPad from './PinPad.svelte'
|
||||||
import telegram from '../plugin'
|
import telegram from '../plugin'
|
||||||
|
import { concatLink } from '@hcengineering/core'
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
@ -60,7 +61,7 @@
|
|||||||
|
|
||||||
async function sendRequest (path: string, data: any): Promise<any> {
|
async function sendRequest (path: string, data: any): Promise<any> {
|
||||||
connecting = true
|
connecting = true
|
||||||
const response = await fetch(url + path, {
|
const response = await fetch(concatLink(url, path), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: 'Bearer ' + getMetadata(login.metadata.LoginToken),
|
Authorization: 'Bearer ' + getMetadata(login.metadata.LoginToken),
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
import telegram from '../plugin'
|
import telegram from '../plugin'
|
||||||
import { getClient } from '@hcengineering/presentation'
|
import { getClient } from '@hcengineering/presentation'
|
||||||
import setting from '@hcengineering/setting'
|
import setting from '@hcengineering/setting'
|
||||||
import { getCurrentAccount, Ref, Space } from '@hcengineering/core'
|
import { concatLink, getCurrentAccount, Ref, Space } from '@hcengineering/core'
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
@ -63,7 +63,7 @@
|
|||||||
|
|
||||||
async function sendRequest (path: string, data: any): Promise<any> {
|
async function sendRequest (path: string, data: any): Promise<any> {
|
||||||
connecting = true
|
connecting = true
|
||||||
const response = await fetch(url + path, {
|
const response = await fetch(concatLink(url, path), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: 'Bearer ' + getMetadata(login.metadata.LoginToken),
|
Authorization: 'Bearer ' + getMetadata(login.metadata.LoginToken),
|
||||||
|
@ -21,6 +21,7 @@ import Connect from './components/Connect.svelte'
|
|||||||
import Reconnect from './components/Reconnect.svelte'
|
import Reconnect from './components/Reconnect.svelte'
|
||||||
import IconTelegram from './components/icons/TelegramColor.svelte'
|
import IconTelegram from './components/icons/TelegramColor.svelte'
|
||||||
import TxSharedCreate from './components/activity/TxSharedCreate.svelte'
|
import TxSharedCreate from './components/activity/TxSharedCreate.svelte'
|
||||||
|
import { concatLink } from '@hcengineering/core'
|
||||||
|
|
||||||
export default async (): Promise<Resources> => ({
|
export default async (): Promise<Resources> => ({
|
||||||
component: {
|
component: {
|
||||||
@ -35,7 +36,7 @@ export default async (): Promise<Resources> => ({
|
|||||||
handler: {
|
handler: {
|
||||||
DisconnectHandler: async () => {
|
DisconnectHandler: async () => {
|
||||||
const url = getMetadata(login.metadata.TelegramUrl) ?? ''
|
const url = getMetadata(login.metadata.TelegramUrl) ?? ''
|
||||||
await fetch(url + '/signout', {
|
await fetch(concatLink(url, '/signout'), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: 'Bearer ' + (getMetadata(login.metadata.LoginToken) ?? ''),
|
Authorization: 'Bearer ' + (getMetadata(login.metadata.LoginToken) ?? ''),
|
||||||
|
@ -28,7 +28,8 @@ import core, {
|
|||||||
TxProcessor,
|
TxProcessor,
|
||||||
TxUpdateDoc,
|
TxUpdateDoc,
|
||||||
TxRemoveDoc,
|
TxRemoveDoc,
|
||||||
TxCollectionCUD
|
TxCollectionCUD,
|
||||||
|
concatLink
|
||||||
} from '@hcengineering/core'
|
} from '@hcengineering/core'
|
||||||
import login from '@hcengineering/login'
|
import login from '@hcengineering/login'
|
||||||
import { getMetadata } from '@hcengineering/platform'
|
import { getMetadata } from '@hcengineering/platform'
|
||||||
@ -41,7 +42,9 @@ import { workbenchId } from '@hcengineering/workbench'
|
|||||||
export async function channelHTMLPresenter (doc: Doc, control: TriggerControl): Promise<string> {
|
export async function channelHTMLPresenter (doc: Doc, control: TriggerControl): Promise<string> {
|
||||||
const channel = doc as ChunterSpace
|
const channel = doc as ChunterSpace
|
||||||
const front = getMetadata(login.metadata.FrontUrl) ?? ''
|
const front = getMetadata(login.metadata.FrontUrl) ?? ''
|
||||||
return `<a href="${front}/${workbenchId}/${control.workspace.name}/${chunterId}/${channel._id}">${channel.name}</a>`
|
const path = `${workbenchId}/${control.workspace.name}/${chunterId}/${channel._id}`
|
||||||
|
const link = concatLink(front, path)
|
||||||
|
return `<a href="${link}">${channel.name}</a>`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import contact, { Contact, contactId, formatName, Organization, Person } from '@hcengineering/contact'
|
import contact, { Contact, contactId, formatName, Organization, Person } from '@hcengineering/contact'
|
||||||
import core, { Doc, Tx, TxCreateDoc, TxRemoveDoc, TxUpdateDoc } from '@hcengineering/core'
|
import core, { concatLink, Doc, Tx, TxCreateDoc, TxRemoveDoc, TxUpdateDoc } from '@hcengineering/core'
|
||||||
import login from '@hcengineering/login'
|
import login from '@hcengineering/login'
|
||||||
import { getMetadata } from '@hcengineering/platform'
|
import { getMetadata } from '@hcengineering/platform'
|
||||||
import type { TriggerControl } from '@hcengineering/server-core'
|
import type { TriggerControl } from '@hcengineering/server-core'
|
||||||
@ -75,9 +75,9 @@ export async function OnContactDelete (tx: Tx, { findAll, hierarchy, storageFx }
|
|||||||
export function personHTMLPresenter (doc: Doc, control: TriggerControl): string {
|
export function personHTMLPresenter (doc: Doc, control: TriggerControl): string {
|
||||||
const person = doc as Person
|
const person = doc as Person
|
||||||
const front = getMetadata(login.metadata.FrontUrl) ?? ''
|
const front = getMetadata(login.metadata.FrontUrl) ?? ''
|
||||||
return `<a href="${front}/${workbenchId}/${control.workspace.name}/${contactId}#${view.component.EditDoc}|${
|
const path = `${workbenchId}/${control.workspace.name}/${contactId}#${view.component.EditDoc}|${person._id}|${person._class}|content`
|
||||||
person._id
|
const link = concatLink(front, path)
|
||||||
}|${person._class}|content">${formatName(person.name)}</a>`
|
return `<a href="${link}">${formatName(person.name)}</a>`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,7 +94,9 @@ export function personTextPresenter (doc: Doc): string {
|
|||||||
export function organizationHTMLPresenter (doc: Doc, control: TriggerControl): string {
|
export function organizationHTMLPresenter (doc: Doc, control: TriggerControl): string {
|
||||||
const organization = doc as Organization
|
const organization = doc as Organization
|
||||||
const front = getMetadata(login.metadata.FrontUrl) ?? ''
|
const front = getMetadata(login.metadata.FrontUrl) ?? ''
|
||||||
return `<a href="${front}/${workbenchId}/${control.workspace.name}/${contactId}#${view.component.EditDoc}|${organization._id}|${organization._class}|content">${organization.name}</a>`
|
const path = `${workbenchId}/${control.workspace.name}/${contactId}#${view.component.EditDoc}|${organization._id}|${organization._class}|content`
|
||||||
|
const link = concatLink(front, path)
|
||||||
|
return `<a href="${link}">${organization.name}</a>`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
import { Doc } from '@hcengineering/core'
|
import { concatLink, Doc } from '@hcengineering/core'
|
||||||
import { inventoryId, Product } from '@hcengineering/inventory'
|
import { inventoryId, Product } from '@hcengineering/inventory'
|
||||||
import login from '@hcengineering/login'
|
import login from '@hcengineering/login'
|
||||||
import { getMetadata } from '@hcengineering/platform'
|
import { getMetadata } from '@hcengineering/platform'
|
||||||
@ -27,7 +27,9 @@ import { workbenchId } from '@hcengineering/workbench'
|
|||||||
export async function productHTMLPresenter (doc: Doc, control: TriggerControl): Promise<string> {
|
export async function productHTMLPresenter (doc: Doc, control: TriggerControl): Promise<string> {
|
||||||
const product = doc as Product
|
const product = doc as Product
|
||||||
const front = getMetadata(login.metadata.FrontUrl) ?? ''
|
const front = getMetadata(login.metadata.FrontUrl) ?? ''
|
||||||
return `<a href="${front}/${workbenchId}/${control.workspace.name}/${inventoryId}/Products/#${view.component.EditDoc}|${product._id}|${product._class}|content">${product.name}</a>`
|
const path = `${workbenchId}/${control.workspace.name}/${inventoryId}/Products/#${view.component.EditDoc}|${product._id}|${product._class}|content`
|
||||||
|
const link = concatLink(front, path)
|
||||||
|
return `<a href="${link}">${product.name}</a>`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
import core, {
|
import core, {
|
||||||
AttachedDoc,
|
AttachedDoc,
|
||||||
|
concatLink,
|
||||||
Doc,
|
Doc,
|
||||||
Tx,
|
Tx,
|
||||||
TxCollectionCUD,
|
TxCollectionCUD,
|
||||||
@ -37,7 +38,9 @@ import { addAssigneeNotification } from '@hcengineering/server-task-resources'
|
|||||||
export async function leadHTMLPresenter (doc: Doc, control: TriggerControl): Promise<string> {
|
export async function leadHTMLPresenter (doc: Doc, control: TriggerControl): Promise<string> {
|
||||||
const lead = doc as Lead
|
const lead = doc as Lead
|
||||||
const front = getMetadata(login.metadata.FrontUrl) ?? ''
|
const front = getMetadata(login.metadata.FrontUrl) ?? ''
|
||||||
return `<a href="${front}/${workbenchId}/${control.workspace.name}/${leadId}/${lead.space}/#${view.component.EditDoc}|${lead._id}|${lead._class}|content">${lead.title}</a>`
|
const path = `${workbenchId}/${control.workspace.name}/${leadId}/${lead.space}/#${view.component.EditDoc}|${lead._id}|${lead._class}|content`
|
||||||
|
const link = concatLink(front, path)
|
||||||
|
return `<a href="${link}">${lead.title}</a>`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
import contact from '@hcengineering/contact'
|
import contact from '@hcengineering/contact'
|
||||||
import core, {
|
import core, {
|
||||||
AttachedDoc,
|
AttachedDoc,
|
||||||
|
concatLink,
|
||||||
Doc,
|
Doc,
|
||||||
Tx,
|
Tx,
|
||||||
TxCollectionCUD,
|
TxCollectionCUD,
|
||||||
@ -39,7 +40,9 @@ import { workbenchId } from '@hcengineering/workbench'
|
|||||||
export async function vacancyHTMLPresenter (doc: Doc, control: TriggerControl): Promise<string> {
|
export async function vacancyHTMLPresenter (doc: Doc, control: TriggerControl): Promise<string> {
|
||||||
const vacancy = doc as Vacancy
|
const vacancy = doc as Vacancy
|
||||||
const front = getMetadata(login.metadata.FrontUrl) ?? ''
|
const front = getMetadata(login.metadata.FrontUrl) ?? ''
|
||||||
return `<a href="${front}/${workbenchId}/${control.workspace.name}/${recruitId}/${vacancy._id}/#${recruit.component.EditVacancy}|${vacancy._id}|${vacancy._class}|content">${vacancy.name}</a>`
|
const path = `${workbenchId}/${control.workspace.name}/${recruitId}/${vacancy._id}/#${recruit.component.EditVacancy}|${vacancy._id}|${vacancy._class}|content`
|
||||||
|
const link = concatLink(front, path)
|
||||||
|
return `<a href="${link}">${vacancy.name}</a>`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,7 +59,9 @@ export async function vacancyTextPresenter (doc: Doc): Promise<string> {
|
|||||||
export async function applicationHTMLPresenter (doc: Doc, control: TriggerControl): Promise<string> {
|
export async function applicationHTMLPresenter (doc: Doc, control: TriggerControl): Promise<string> {
|
||||||
const applicant = doc as Applicant
|
const applicant = doc as Applicant
|
||||||
const front = getMetadata(login.metadata.FrontUrl) ?? ''
|
const front = getMetadata(login.metadata.FrontUrl) ?? ''
|
||||||
return `<a href="${front}/${workbenchId}/${control.workspace.name}/${recruitId}/${applicant.space}/#${view.component.EditDoc}|${applicant._id}|${applicant._class}|content">APP-${applicant.number}</a>`
|
const path = `${workbenchId}/${control.workspace.name}/${recruitId}/${applicant.space}/#${view.component.EditDoc}|${applicant._id}|${applicant._class}|content`
|
||||||
|
const link = concatLink(front, path)
|
||||||
|
return `<a href="${link}">APP-${applicant.number}</a>`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,7 +14,16 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import { Employee } from '@hcengineering/contact'
|
import { Employee } from '@hcengineering/contact'
|
||||||
import core, { AttachedDoc, Doc, Ref, Tx, TxCollectionCUD, TxProcessor, TxUpdateDoc } from '@hcengineering/core'
|
import core, {
|
||||||
|
AttachedDoc,
|
||||||
|
concatLink,
|
||||||
|
Doc,
|
||||||
|
Ref,
|
||||||
|
Tx,
|
||||||
|
TxCollectionCUD,
|
||||||
|
TxProcessor,
|
||||||
|
TxUpdateDoc
|
||||||
|
} from '@hcengineering/core'
|
||||||
import login from '@hcengineering/login'
|
import login from '@hcengineering/login'
|
||||||
import { NotificationAction } from '@hcengineering/notification'
|
import { NotificationAction } from '@hcengineering/notification'
|
||||||
import { getMetadata, Resource } from '@hcengineering/platform'
|
import { getMetadata, Resource } from '@hcengineering/platform'
|
||||||
@ -31,7 +40,9 @@ import { workbenchId } from '@hcengineering/workbench'
|
|||||||
export async function issueHTMLPresenter (doc: Doc, control: TriggerControl): Promise<string> {
|
export async function issueHTMLPresenter (doc: Doc, control: TriggerControl): Promise<string> {
|
||||||
const issue = doc as Issue
|
const issue = doc as Issue
|
||||||
const front = getMetadata(login.metadata.FrontUrl) ?? ''
|
const front = getMetadata(login.metadata.FrontUrl) ?? ''
|
||||||
return `<a href="${front}/${workbenchId}/${control.workspace.name}/${taskId}/${issue.space}/#${view.component.EditDoc}|${issue._id}|${issue._class}|content">Task-${issue.number}</a>`
|
const path = `${workbenchId}/${control.workspace.name}/${taskId}/${issue.space}/#${view.component.EditDoc}|${issue._id}|${issue._class}|content`
|
||||||
|
const link = concatLink(front, path)
|
||||||
|
return `<a href="${link}">Task-${issue.number}</a>`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
import { Employee } from '@hcengineering/contact'
|
import { Employee } from '@hcengineering/contact'
|
||||||
import core, {
|
import core, {
|
||||||
AttachedDoc,
|
AttachedDoc,
|
||||||
|
concatLink,
|
||||||
Doc,
|
Doc,
|
||||||
DocumentUpdate,
|
DocumentUpdate,
|
||||||
Ref,
|
Ref,
|
||||||
@ -59,7 +60,9 @@ export async function issueHTMLPresenter (doc: Doc, control: TriggerControl): Pr
|
|||||||
const issueName = `${team?.identifier ?? '?'}-${issue.number}`
|
const issueName = `${team?.identifier ?? '?'}-${issue.number}`
|
||||||
|
|
||||||
const front = getMetadata(login.metadata.FrontUrl) ?? ''
|
const front = getMetadata(login.metadata.FrontUrl) ?? ''
|
||||||
return `<a href="${front}/${workbenchId}/${control.workspace.name}/${trackerId}/${issue.space}/#${tracker.component.EditIssue}|${issue._id}|${issue._class}|content">${issueName}</a>`
|
const path = `${workbenchId}/${control.workspace.name}/${trackerId}/${issue.space}/#${tracker.component.EditIssue}|${issue._id}|${issue._class}|content`
|
||||||
|
const link = concatLink(front, path)
|
||||||
|
return `<a href="${link}">${issueName}</a>`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,6 +23,7 @@ import contact, {
|
|||||||
} from '@hcengineering/contact'
|
} from '@hcengineering/contact'
|
||||||
import core, {
|
import core, {
|
||||||
AccountRole,
|
AccountRole,
|
||||||
|
concatLink,
|
||||||
Data,
|
Data,
|
||||||
getWorkspaceId,
|
getWorkspaceId,
|
||||||
Ref,
|
Ref,
|
||||||
@ -674,7 +675,7 @@ export async function requestPassword (db: Db, productId: string, email: string)
|
|||||||
restore: email
|
restore: email
|
||||||
})
|
})
|
||||||
|
|
||||||
const link = `${front}/login/recovery?id=${token}`
|
const link = concatLink(front, `/login/recovery?id=${token}`)
|
||||||
|
|
||||||
const text = `We received a request to reset the password for your account. To reset your password, please paste the following link in your web browser's address bar: ${link}. If you have not ordered a password recovery just ignore this letter.`
|
const text = `We received a request to reset the password for your account. To reset your password, please paste the following link in your web browser's address bar: ${link}. If you have not ordered a password recovery just ignore this letter.`
|
||||||
const html = `<p>We received a request to reset the password for your account. To reset your password, please click the link below: <a href=${link}>Reset password</a></p><p>
|
const html = `<p>We received a request to reset the password for your account. To reset your password, please click the link below: <a href=${link}>Reset password</a></p><p>
|
||||||
|
Loading…
Reference in New Issue
Block a user