-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
674 changed files
with
3,098 additions
and
1,636 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,6 @@ | |
/ee/**/lib | ||
|
||
.pnpm-lock.yaml | ||
|
||
|
||
!/server/bundle/**/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* @Author: [email protected] | ||
* @Date: 2022-03-28 09:35:34 | ||
* @LastEditors: [email protected] | ||
* @LastEditTime: 2022-06-29 16:05:04 | ||
* @LastEditTime: 2022-12-05 09:08:08 | ||
* @Description: | ||
*/ | ||
export interface ConnectionInformations { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
/* | ||
* @Author: [email protected] | ||
* @Date: 2022-08-12 14:07:01 | ||
* @LastEditors: [email protected] | ||
* @LastEditTime: 2022-12-05 09:09:03 | ||
* @Description: | ||
*/ | ||
import { Tokens } from './tokens'; | ||
|
||
export interface LoginResult { | ||
|
@@ -6,4 +13,5 @@ export interface LoginResult { | |
tokens: Tokens; | ||
user: any; | ||
space?: string; | ||
spaces?: Array<any> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
/* | ||
* @Author: [email protected] | ||
* @Date: 2022-06-20 19:02:47 | ||
* @LastEditors: sunhaolin@hotoa.com | ||
* @LastEditTime: 2022-10-20 11:25:29 | ||
* @LastEditors: baozhoutao@steedos.com | ||
* @LastEditTime: 2022-12-06 09:56:31 | ||
* @Description: | ||
*/ | ||
|
||
|
@@ -23,4 +23,5 @@ export const EXPAND_SUFFIX = '__expand'; | |
export const DISPLAY_PREFIX = '_display'; | ||
export const UI_PREFIX = '_ui'; | ||
export const RELATED_PREFIX = '_related'; | ||
export const GRAPHQL_ACTION_PREFIX = 'graphql_'; | ||
export const GRAPHQL_ACTION_PREFIX = 'graphql_'; | ||
export const PERMISSIONS_PREFIX = '_permissions'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
/* | ||
* @Author: [email protected] | ||
* @Date: 2022-06-15 15:49:44 | ||
* @LastEditors: sunhaolin@hotoa.com | ||
* @LastEditTime: 2022-11-07 20:55:13 | ||
* @LastEditors: baozhoutao@steedos.com | ||
* @LastEditTime: 2022-12-06 10:31:30 | ||
* @Description: | ||
*/ | ||
|
||
|
@@ -17,7 +17,7 @@ import { getSteedosSchema, getUserLocale } from '../../..'; | |
import { getQueryFields } from "./getQueryFields"; | ||
import { getPrimaryFieldType } from "./getPrimaryFieldType"; | ||
|
||
import { BASIC_TYPE_MAPPING, EXPAND_SUFFIX, DISPLAY_PREFIX, RELATED_PREFIX, GRAPHQL_ACTION_PREFIX, UI_PREFIX } from "./consts"; | ||
import { BASIC_TYPE_MAPPING, EXPAND_SUFFIX, DISPLAY_PREFIX, RELATED_PREFIX, GRAPHQL_ACTION_PREFIX, UI_PREFIX, PERMISSIONS_PREFIX } from "./consts"; | ||
|
||
export function generateActionGraphqlProp(actionName: string, objectConfig: SteedosObjectTypeConfig) { | ||
let gplObj: any = {}; | ||
|
@@ -76,6 +76,26 @@ export function generateActionGraphqlProp(actionName: string, objectConfig: Stee | |
return gplObj; | ||
} | ||
|
||
const callObjectServiceAction = async function(actionName, userSession, data?){ | ||
const broker = getSteedosSchema().broker; | ||
return broker.call(actionName, data, { meta: { user: userSession}}) | ||
} | ||
|
||
const formatFileSize = function(fileSize) { | ||
var rev, unit; | ||
rev = fileSize / 1024.00; | ||
unit = 'KB'; | ||
if (rev > 1024.00) { | ||
rev = rev / 1024.00; | ||
unit = 'MB'; | ||
} | ||
if (rev > 1024.00) { | ||
rev = rev / 1024.00; | ||
unit = 'GB'; | ||
} | ||
return rev.toFixed(2) + unit; | ||
}; | ||
|
||
export function generateSettingsGraphql(objectConfig: SteedosObjectTypeConfig) { | ||
let objectName = objectConfig.name; | ||
let fields = objectConfig.fields; | ||
|
@@ -194,6 +214,27 @@ export function generateSettingsGraphql(objectConfig: SteedosObjectTypeConfig) { | |
${type} | ||
`; | ||
|
||
// _permissions | ||
let _permissions_type_name = `${PERMISSIONS_PREFIX}_${objectName}`; | ||
type += `${PERMISSIONS_PREFIX}: ${_permissions_type_name} `; | ||
resolvers[objectName][PERMISSIONS_PREFIX] = { | ||
action: `${getObjectServiceName( | ||
objectName | ||
)}.${GRAPHQL_ACTION_PREFIX}${PERMISSIONS_PREFIX}`, | ||
rootParams: { | ||
_id: "_id" | ||
}, | ||
params: { | ||
'__objectName': objectName | ||
}, | ||
}; | ||
// define _permissions_type | ||
let _permissions_type = _getPermissionsType(_permissions_type_name, fields); | ||
type = gql` | ||
${_permissions_type} | ||
${type} | ||
`; | ||
|
||
// _related | ||
if (objectConfig.enable_files) { | ||
let relatedObjName = "cms_files"; | ||
|
@@ -478,6 +519,17 @@ export function getGraphqlActions(objectConfig: SteedosObjectTypeConfig) { | |
}, | ||
}; | ||
|
||
actions[`${GRAPHQL_ACTION_PREFIX}${PERMISSIONS_PREFIX}`] = { | ||
handler: async function (ctx) { | ||
let params = ctx.params; | ||
let { __objectName } = params; | ||
let userSession = ctx.meta.user; | ||
return await callObjectServiceAction(`@${__objectName}.getRecordPermissionsById`, userSession, { | ||
recordId: params._id | ||
});; | ||
}, | ||
}; | ||
|
||
return actions; | ||
} | ||
|
||
|
@@ -988,6 +1040,8 @@ async function translateToUI(objectName, doc, userSession: any, selectorFieldNam | |
} | ||
} | ||
displayObj[name] = fileValue; | ||
}else if(fType == "filesize"){ | ||
displayObj[name] = formatFileSize(doc[name]); | ||
} else { | ||
displayObj[name] = formatBasicFieldValue(fType, field, doc[name], objConfig, userSession); | ||
} | ||
|
@@ -1049,6 +1103,35 @@ function _getUIType(typeName, fields) { | |
return type; | ||
} | ||
|
||
function _getPermissionsType(typeName, fields) { | ||
return ` | ||
type ${typeName} { | ||
allowCreate: Boolean | ||
allowCreateFiles: Boolean | ||
allowDelete: Boolean | ||
allowDeleteFiles: Boolean | ||
allowEdit: Boolean | ||
allowEditFiles: Boolean | ||
allowRead: Boolean | ||
allowReadFiles: Boolean | ||
disabled_actions: [String] | ||
disabled_list_views: [String] | ||
field_permissions: JSON | ||
modifyAllFiles: Boolean | ||
modifyAllRecords: Boolean | ||
modifyAssignCompanysRecords: [String] | ||
modifyCompanyRecords: Boolean | ||
uneditable_fields: [String] | ||
unreadable_fields: [String] | ||
unrelated_objects: [String] | ||
viewAllFiles: Boolean | ||
viewAllRecords: Boolean | ||
viewAssignCompanysRecords: [String] | ||
viewCompanyRecords: Boolean | ||
} | ||
` | ||
} | ||
|
||
// 获取object元数据 | ||
export function getLocalService(objectApiName: string) { | ||
let steedosSchema = getSteedosSchema(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.