@things-factory/font-base 5.0.0-alpha.5 → 5.0.0-alpha.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/bootstrap.js +4 -5
- package/client/index.js +0 -1
- package/client/themes/font-theme.css +14 -0
- package/dist-server/service/font/font-mutation.js +28 -9
- package/dist-server/service/font/font-mutation.js.map +1 -1
- package/dist-server/service/font/font-query.js +18 -2
- package/dist-server/service/font/font-query.js.map +1 -1
- package/dist-server/service/font/font-type.js +9 -0
- package/dist-server/service/font/font-type.js.map +1 -1
- package/dist-server/service/font/font.js +5 -0
- package/dist-server/service/font/font.js.map +1 -1
- package/package.json +5 -4
- package/server/service/font/font-mutation.ts +36 -3
- package/server/service/font/font-query.ts +16 -3
- package/server/service/font/font-type.ts +8 -1
- package/server/service/font/font.ts +4 -0
- package/translations/en.json +5 -0
- package/translations/ko.json +5 -0
- package/translations/ms.json +5 -0
- package/translations/zh.json +5 -0
- package/client/actions/font.js +0 -58
- package/client/graphql-client.js +0 -104
- package/client/reducers/font.js +0 -63
package/client/bootstrap.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import font from './reducers/font'
|
|
1
|
+
import { actionUpdateFontList, ReducerFont } from '@operato/font'
|
|
2
|
+
import { store } from '@operato/shell'
|
|
4
3
|
import { auth } from '@things-factory/auth-base'
|
|
5
4
|
|
|
6
5
|
export default function bootstrap() {
|
|
7
6
|
store.addReducers({
|
|
8
|
-
font
|
|
7
|
+
font: ReducerFont
|
|
9
8
|
})
|
|
10
9
|
|
|
11
10
|
auth.on('profile', () => {
|
|
12
|
-
store.dispatch(
|
|
11
|
+
store.dispatch(actionUpdateFontList())
|
|
13
12
|
})
|
|
14
13
|
}
|
package/client/index.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './actions/font'
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
body {
|
|
2
|
+
--font-tools-background-color: var(--primary-color);
|
|
3
|
+
--font-selector-background-color: #fff;
|
|
4
|
+
--font-selector-name-font: bold 14px var(--theme-font);
|
|
5
|
+
--font-selector-border: 1px solid rgba(0, 0, 0, 0.2);
|
|
6
|
+
--font-selector-icon-size: 35px;
|
|
7
|
+
--font-selector-icon-font: normal 20px/35px var(--mdc-icon-font, 'Material Icons');
|
|
8
|
+
--font-selector-icon-color: var(--primary-color);
|
|
9
|
+
--font-selector-icon-background-color: rgba(255, 255, 255, 0.85);
|
|
10
|
+
--font-selector-etc-background-color: var(--primary-color);
|
|
11
|
+
--font-selector-etc-font: bold 9px var(--theme-font);
|
|
12
|
+
--font-selector-etc-icon-font: normal 72px var(--mdc-icon-font, 'Material Icons');
|
|
13
|
+
--font-selector-etc-icon-color: var(--secondary-color);
|
|
14
|
+
}
|
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.FontMutation = void 0;
|
|
16
16
|
const type_graphql_1 = require("type-graphql");
|
|
17
17
|
const typeorm_1 = require("typeorm");
|
|
18
|
+
const attachment_base_1 = require("@things-factory/attachment-base");
|
|
18
19
|
const shell_1 = require("@things-factory/shell");
|
|
19
20
|
const font_1 = require("./font");
|
|
20
21
|
const font_type_1 = require("./font-type");
|
|
@@ -36,14 +37,21 @@ function notifyChanges(event, domain, font) {
|
|
|
36
37
|
});
|
|
37
38
|
}
|
|
38
39
|
let FontMutation = class FontMutation {
|
|
39
|
-
async createFont(font, context) {
|
|
40
|
+
async createFont(_, font, context) {
|
|
40
41
|
const { domain, user } = context.state;
|
|
41
42
|
const repository = (0, typeorm_1.getRepository)(font_1.Font);
|
|
42
43
|
const created = await repository.save(Object.assign({ domain, creator: user, updater: user }, font));
|
|
44
|
+
if (font.files) {
|
|
45
|
+
await (0, attachment_base_1.createAttachments)(_, {
|
|
46
|
+
attachments: font.files.map(file => {
|
|
47
|
+
return { file, refBy: created.id };
|
|
48
|
+
})
|
|
49
|
+
}, context);
|
|
50
|
+
}
|
|
43
51
|
notifyChanges('created', domain, created);
|
|
44
52
|
return created;
|
|
45
53
|
}
|
|
46
|
-
async updateFont(id, patch, context) {
|
|
54
|
+
async updateFont(_, id, patch, context) {
|
|
47
55
|
const { domain, user } = context.state;
|
|
48
56
|
const repository = (0, typeorm_1.getRepository)(font_1.Font);
|
|
49
57
|
const font = await repository.findOne({
|
|
@@ -53,6 +61,14 @@ let FontMutation = class FontMutation {
|
|
|
53
61
|
}
|
|
54
62
|
});
|
|
55
63
|
const updated = await repository.save(Object.assign(Object.assign(Object.assign({}, font), patch), { updater: user }));
|
|
64
|
+
if (patch.files) {
|
|
65
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [id] }, context);
|
|
66
|
+
await (0, attachment_base_1.createAttachments)(_, {
|
|
67
|
+
attachments: patch.files.map(file => {
|
|
68
|
+
return { file, refBy: updated.id };
|
|
69
|
+
})
|
|
70
|
+
}, context);
|
|
71
|
+
}
|
|
56
72
|
notifyChanges('updated', domain, updated);
|
|
57
73
|
return updated;
|
|
58
74
|
}
|
|
@@ -65,25 +81,28 @@ let FontMutation = class FontMutation {
|
|
|
65
81
|
if (font) {
|
|
66
82
|
await repository.remove(font);
|
|
67
83
|
}
|
|
84
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [id] }, context);
|
|
68
85
|
notifyChanges('removed', domain, font);
|
|
69
86
|
return true;
|
|
70
87
|
}
|
|
71
88
|
};
|
|
72
89
|
__decorate([
|
|
73
90
|
(0, type_graphql_1.Mutation)(returns => font_1.Font, { description: 'To create new Font' }),
|
|
74
|
-
__param(0, (0, type_graphql_1.
|
|
75
|
-
__param(1, (0, type_graphql_1.
|
|
91
|
+
__param(0, (0, type_graphql_1.Root)()),
|
|
92
|
+
__param(1, (0, type_graphql_1.Arg)('font')),
|
|
93
|
+
__param(2, (0, type_graphql_1.Ctx)()),
|
|
76
94
|
__metadata("design:type", Function),
|
|
77
|
-
__metadata("design:paramtypes", [font_type_1.NewFont, Object]),
|
|
95
|
+
__metadata("design:paramtypes", [Object, font_type_1.NewFont, Object]),
|
|
78
96
|
__metadata("design:returntype", Promise)
|
|
79
97
|
], FontMutation.prototype, "createFont", null);
|
|
80
98
|
__decorate([
|
|
81
99
|
(0, type_graphql_1.Mutation)(returns => font_1.Font, { description: 'To modify Font information' }),
|
|
82
|
-
__param(0, (0, type_graphql_1.
|
|
83
|
-
__param(1, (0, type_graphql_1.Arg)('
|
|
84
|
-
__param(2, (0, type_graphql_1.
|
|
100
|
+
__param(0, (0, type_graphql_1.Root)()),
|
|
101
|
+
__param(1, (0, type_graphql_1.Arg)('id')),
|
|
102
|
+
__param(2, (0, type_graphql_1.Arg)('patch')),
|
|
103
|
+
__param(3, (0, type_graphql_1.Ctx)()),
|
|
85
104
|
__metadata("design:type", Function),
|
|
86
|
-
__metadata("design:paramtypes", [String, font_type_1.FontPatch, Object]),
|
|
105
|
+
__metadata("design:paramtypes", [Object, String, font_type_1.FontPatch, Object]),
|
|
87
106
|
__metadata("design:returntype", Promise)
|
|
88
107
|
], FontMutation.prototype, "updateFont", null);
|
|
89
108
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"font-mutation.js","sourceRoot":"","sources":["../../../server/service/font/font-mutation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"font-mutation.js","sourceRoot":"","sources":["../../../server/service/font/font-mutation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAiE;AACjE,qCAAuC;AAEvC,qEAA2F;AAC3F,iDAA8C;AAE9C,iCAA6B;AAC7B,2CAAgD;AAEhD,SAAS,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI;IACxC,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IAClD,MAAM,EAAE,SAAS,EAAE,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;IADC,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,WAAI,EAAE,EAAE,WAAW,EAAE,oBAAoB,EAAE,CAAC;IAC/C,WAAA,IAAA,mBAAI,GAAE,CAAA;IAAK,WAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAiB,WAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAf,mBAAO;;8CA2BrD;AAGD;IADC,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,WAAI,EAAE,EAAE,WAAW,EAAE,4BAA4B,EAAE,CAAC;IAEtE,WAAA,IAAA,mBAAI,GAAE,CAAA;IACN,WAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IACT,WAAA,IAAA,kBAAG,EAAC,OAAO,CAAC,CAAA;IACZ,WAAA,IAAA,kBAAG,GAAE,CAAA;;qDADe,qBAAS;;8CAmC/B;AAGD;IADC,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC;IAC9C,WAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;8CAiB7C;AA1FU,YAAY;IADxB,IAAA,uBAAQ,EAAC,WAAI,CAAC;GACF,YAAY,CA2FxB;AA3FY,oCAAY"}
|
|
@@ -16,8 +16,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16
16
|
exports.FontQuery = void 0;
|
|
17
17
|
const type_graphql_1 = require("type-graphql");
|
|
18
18
|
const typeorm_1 = require("typeorm");
|
|
19
|
-
const
|
|
19
|
+
const attachment_base_1 = require("@things-factory/attachment-base");
|
|
20
20
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
21
|
+
const shell_1 = require("@things-factory/shell");
|
|
21
22
|
const font_1 = require("./font");
|
|
22
23
|
const font_type_1 = require("./font-type");
|
|
23
24
|
let FontQuery = class FontQuery {
|
|
@@ -29,13 +30,20 @@ let FontQuery = class FontQuery {
|
|
|
29
30
|
}
|
|
30
31
|
async fonts(params, context) {
|
|
31
32
|
const { domain } = context.state;
|
|
32
|
-
const convertedParams = (0, shell_1.convertListParams)(params, domain
|
|
33
|
+
const convertedParams = (0, shell_1.convertListParams)(params, { domain });
|
|
33
34
|
const [items, total] = await (0, typeorm_1.getRepository)(font_1.Font).findAndCount(convertedParams);
|
|
34
35
|
return { items, total };
|
|
35
36
|
}
|
|
36
37
|
async domain(font) {
|
|
37
38
|
return await (0, typeorm_1.getRepository)(shell_1.Domain).findOne(font.domainId);
|
|
38
39
|
}
|
|
40
|
+
async files(font, context) {
|
|
41
|
+
const { domain } = context.state;
|
|
42
|
+
return await (0, typeorm_1.getRepository)(attachment_base_1.Attachment).find({
|
|
43
|
+
domain,
|
|
44
|
+
refBy: font.id
|
|
45
|
+
});
|
|
46
|
+
}
|
|
39
47
|
async updater(font) {
|
|
40
48
|
return await (0, typeorm_1.getRepository)(auth_base_1.User).findOne(font.updaterId);
|
|
41
49
|
}
|
|
@@ -66,6 +74,14 @@ __decorate([
|
|
|
66
74
|
__metadata("design:paramtypes", [font_1.Font]),
|
|
67
75
|
__metadata("design:returntype", Promise)
|
|
68
76
|
], FontQuery.prototype, "domain", null);
|
|
77
|
+
__decorate([
|
|
78
|
+
(0, type_graphql_1.FieldResolver)(type => attachment_base_1.Attachment),
|
|
79
|
+
__param(0, (0, type_graphql_1.Root)()),
|
|
80
|
+
__param(1, (0, type_graphql_1.Ctx)()),
|
|
81
|
+
__metadata("design:type", Function),
|
|
82
|
+
__metadata("design:paramtypes", [font_1.Font, Object]),
|
|
83
|
+
__metadata("design:returntype", Promise)
|
|
84
|
+
], FontQuery.prototype, "files", null);
|
|
69
85
|
__decorate([
|
|
70
86
|
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
|
|
71
87
|
__param(0, (0, type_graphql_1.Root)()),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"font-query.js","sourceRoot":"","sources":["../../../server/service/font/font-query.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"font-query.js","sourceRoot":"","sources":["../../../server/service/font/font-query.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAAmF;AACnF,qCAAuC;AAEvC,qEAA4D;AAC5D,yDAAgD;AAChD,iDAA4E;AAE5E,iCAA6B;AAC7B,2CAAsC;AAGtC,IAAa,SAAS,GAAtB,MAAa,SAAS;IAEpB,KAAK,CAAC,IAAI,CAAY,EAAU,EAAS,OAAY;QACnD,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,OAAO,MAAM,IAAA,uBAAa,EAAC,WAAI,CAAC,CAAC,OAAO,CAAC;YACvC,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;SACtB,CAAC,CAAA;IACJ,CAAC;IAGD,KAAK,CAAC,KAAK,CAAS,MAAiB,EAAS,OAAY;QACxD,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,MAAM,eAAe,GAAG,IAAA,yBAAiB,EAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;QAC7D,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,IAAA,uBAAa,EAAC,WAAI,CAAC,CAAC,YAAY,CAAC,eAAe,CAAC,CAAA;QAE9E,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;IACzB,CAAC;IAGD,KAAK,CAAC,MAAM,CAAS,IAAU;QAC7B,OAAO,MAAM,IAAA,uBAAa,EAAC,cAAM,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC3D,CAAC;IAGD,KAAK,CAAC,KAAK,CAAS,IAAU,EAAS,OAAY;QACjD,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,OAAO,MA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;IACb,WAAA,IAAA,mBAAI,GAAE,CAAA;;qCAAO,WAAI;;wCAE/B;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,WAAA,IAAA,mBAAI,GAAE,CAAA;;qCAAO,WAAI;;wCAE/B;AA3CU,SAAS;IADrB,IAAA,uBAAQ,EAAC,WAAI,CAAC;GACF,SAAS,CA4CrB;AA5CY,8BAAS"}
|
|
@@ -10,6 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.FontList = exports.FontPatch = exports.NewFont = void 0;
|
|
13
|
+
const graphql_upload_1 = require("graphql-upload");
|
|
13
14
|
const type_graphql_1 = require("type-graphql");
|
|
14
15
|
const font_1 = require("./font");
|
|
15
16
|
let NewFont = class NewFont {
|
|
@@ -30,6 +31,10 @@ __decorate([
|
|
|
30
31
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
31
32
|
__metadata("design:type", String)
|
|
32
33
|
], NewFont.prototype, "path", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, type_graphql_1.Field)(type => [graphql_upload_1.GraphQLUpload], { nullable: true }),
|
|
36
|
+
__metadata("design:type", Array)
|
|
37
|
+
], NewFont.prototype, "files", void 0);
|
|
33
38
|
__decorate([
|
|
34
39
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
35
40
|
__metadata("design:type", Boolean)
|
|
@@ -56,6 +61,10 @@ __decorate([
|
|
|
56
61
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
57
62
|
__metadata("design:type", String)
|
|
58
63
|
], FontPatch.prototype, "path", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
(0, type_graphql_1.Field)(type => [graphql_upload_1.GraphQLUpload], { nullable: true }),
|
|
66
|
+
__metadata("design:type", Array)
|
|
67
|
+
], FontPatch.prototype, "files", void 0);
|
|
59
68
|
__decorate([
|
|
60
69
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
61
70
|
__metadata("design:type", Boolean)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"font-type.js","sourceRoot":"","sources":["../../../server/service/font/font-type.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"font-type.js","sourceRoot":"","sources":["../../../server/service/font/font-type.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAA0D;AAC1D,+CAAgE;AAEhE,iCAA6B;AAG7B,IAAa,OAAO,GAApB,MAAa,OAAO;CAkBnB,CAAA;AAhBC;IADC,IAAA,oBAAK,GAAE;;qCACI;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCACT;AAGjB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oCACd;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qCACb;AAGb;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,8BAAa,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;sCAC/B;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uCACV;AAjBL,OAAO;IADnB,IAAA,wBAAS,GAAE;GACC,OAAO,CAkBnB;AAlBY,0BAAO;AAqBpB,IAAa,SAAS,GAAtB,MAAa,SAAS;CAkBrB,CAAA;AAhBC;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uCACd;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACT;AAGjB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;sCACd;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uCACb;AAGb;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,8BAAa,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;wCAC/B;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCACV;AAjBL,SAAS;IADrB,IAAA,wBAAS,GAAE;GACC,SAAS,CAkBrB;AAlBY,8BAAS;AAqBtB,IAAa,QAAQ,GAArB,MAAa,QAAQ;CAMpB,CAAA;AAJC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,WAAI,CAAC,CAAC;;uCACT;AAGb;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;uCACN;AALF,QAAQ;IADpB,IAAA,yBAAU,GAAE;GACA,QAAQ,CAMpB;AANY,4BAAQ"}
|
|
@@ -13,6 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
exports.Font = void 0;
|
|
14
14
|
const type_graphql_1 = require("type-graphql");
|
|
15
15
|
const typeorm_1 = require("typeorm");
|
|
16
|
+
const attachment_base_1 = require("@things-factory/attachment-base");
|
|
16
17
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
17
18
|
const shell_1 = require("@things-factory/shell");
|
|
18
19
|
let Font = class Font {
|
|
@@ -60,6 +61,10 @@ __decorate([
|
|
|
60
61
|
(0, type_graphql_1.Field)(),
|
|
61
62
|
__metadata("design:type", Boolean)
|
|
62
63
|
], Font.prototype, "active", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
(0, type_graphql_1.Field)(type => [attachment_base_1.Attachment], { nullable: true }),
|
|
66
|
+
__metadata("design:type", Array)
|
|
67
|
+
], Font.prototype, "files", void 0);
|
|
63
68
|
__decorate([
|
|
64
69
|
(0, typeorm_1.CreateDateColumn)(),
|
|
65
70
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"font.js","sourceRoot":"","sources":["../../../server/service/font/font.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+CAAoD;AACpD,qCASgB;AAEhB,yDAAgD;AAChD,iDAA8C;AAK9C,IAAa,IAAI,GAAjB,MAAa,IAAI;
|
|
1
|
+
{"version":3,"file":"font.js","sourceRoot":"","sources":["../../../server/service/font/font.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+CAAoD;AACpD,qCASgB;AAEhB,qEAA4D;AAC5D,yDAAgD;AAChD,iDAA8C;AAK9C,IAAa,IAAI,GAAjB,MAAa,IAAI;CAgEhB,CAAA;AA7DC;IAFC,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;gCACC;AAInB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;kDACjB,cAAM,oBAAN,cAAM;oCAAA;AAGf;IADC,IAAA,oBAAU,EAAC,CAAC,IAAU,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;;sCACvB;AAIjB;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,GAAE;;kCACI;AAIZ;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,GAAE;;sCACQ;AAMhB;IAJC,IAAA,gBAAM,EAAC;QACN,QAAQ,EAAE,IAAI;KACf,CAAC;IACD,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iCACd;AAMZ;IAJC,IAAA,gBAAM,EAAC;QACN,QAAQ,EAAE,IAAI;KACf,CAAC;IACD,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;k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,yBAAU,EAAC,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC;GAClC,IAAI,CAgEhB;AAhEY,oBAAI"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/font-base",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.52",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -24,8 +24,9 @@
|
|
|
24
24
|
"migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@things-factory/
|
|
28
|
-
"@things-factory/
|
|
27
|
+
"@things-factory/attachment-base": "^5.0.0-alpha.52",
|
|
28
|
+
"@things-factory/auth-base": "^5.0.0-alpha.52",
|
|
29
|
+
"@things-factory/shell": "^5.0.0-alpha.52"
|
|
29
30
|
},
|
|
30
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "dd9c8f2e256e256e42bd9bd26db5eaa955f85620"
|
|
31
32
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Arg, Ctx, Mutation, Resolver } from 'type-graphql'
|
|
1
|
+
import { Arg, Ctx, Mutation, Resolver, Root } from 'type-graphql'
|
|
2
2
|
import { getRepository } from 'typeorm'
|
|
3
3
|
|
|
4
|
+
import { createAttachments, deleteAttachmentsByRef } from '@things-factory/attachment-base'
|
|
4
5
|
import { pubsub } from '@things-factory/shell'
|
|
5
6
|
|
|
6
7
|
import { Font } from './font'
|
|
@@ -26,7 +27,7 @@ function notifyChanges(event, domain, font) {
|
|
|
26
27
|
@Resolver(Font)
|
|
27
28
|
export class FontMutation {
|
|
28
29
|
@Mutation(returns => Font, { description: 'To create new Font' })
|
|
29
|
-
async createFont(@Arg('font') font: NewFont, @Ctx() context: any): Promise<Font> {
|
|
30
|
+
async createFont(@Root() _, @Arg('font') font: NewFont, @Ctx() context: any): Promise<Font> {
|
|
30
31
|
const { domain, user } = context.state
|
|
31
32
|
|
|
32
33
|
const repository = getRepository(Font)
|
|
@@ -38,13 +39,30 @@ export class FontMutation {
|
|
|
38
39
|
...font
|
|
39
40
|
})
|
|
40
41
|
|
|
42
|
+
if (font.files) {
|
|
43
|
+
await createAttachments(
|
|
44
|
+
_,
|
|
45
|
+
{
|
|
46
|
+
attachments: font.files.map(file => {
|
|
47
|
+
return { file, refBy: created.id }
|
|
48
|
+
})
|
|
49
|
+
},
|
|
50
|
+
context
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
41
54
|
notifyChanges('created', domain, created)
|
|
42
55
|
|
|
43
56
|
return created
|
|
44
57
|
}
|
|
45
58
|
|
|
46
59
|
@Mutation(returns => Font, { description: 'To modify Font information' })
|
|
47
|
-
async updateFont(
|
|
60
|
+
async updateFont(
|
|
61
|
+
@Root() _,
|
|
62
|
+
@Arg('id') id: string,
|
|
63
|
+
@Arg('patch') patch: FontPatch,
|
|
64
|
+
@Ctx() context: any
|
|
65
|
+
): Promise<Font> {
|
|
48
66
|
const { domain, user } = context.state
|
|
49
67
|
|
|
50
68
|
const repository = getRepository(Font)
|
|
@@ -61,6 +79,19 @@ export class FontMutation {
|
|
|
61
79
|
updater: user
|
|
62
80
|
})
|
|
63
81
|
|
|
82
|
+
if (patch.files) {
|
|
83
|
+
await deleteAttachmentsByRef(null, { refBys: [id] }, context)
|
|
84
|
+
await createAttachments(
|
|
85
|
+
_,
|
|
86
|
+
{
|
|
87
|
+
attachments: patch.files.map(file => {
|
|
88
|
+
return { file, refBy: updated.id }
|
|
89
|
+
})
|
|
90
|
+
},
|
|
91
|
+
context
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
|
|
64
95
|
notifyChanges('updated', domain, updated)
|
|
65
96
|
|
|
66
97
|
return updated
|
|
@@ -79,6 +110,8 @@ export class FontMutation {
|
|
|
79
110
|
await repository.remove(font)
|
|
80
111
|
}
|
|
81
112
|
|
|
113
|
+
await deleteAttachmentsByRef(null, { refBys: [id] }, context)
|
|
114
|
+
|
|
82
115
|
notifyChanges('removed', domain, font)
|
|
83
116
|
|
|
84
117
|
return true
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
|
|
2
2
|
import { getRepository } from 'typeorm'
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
import { Attachment } from '@things-factory/attachment-base'
|
|
4
5
|
import { User } from '@things-factory/auth-base'
|
|
6
|
+
import { convertListParams, Domain, ListParam } from '@things-factory/shell'
|
|
7
|
+
|
|
5
8
|
import { Font } from './font'
|
|
6
9
|
import { FontList } from './font-type'
|
|
7
10
|
|
|
@@ -20,7 +23,7 @@ export class FontQuery {
|
|
|
20
23
|
async fonts(@Args() params: ListParam, @Ctx() context: any): Promise<FontList> {
|
|
21
24
|
const { domain } = context.state
|
|
22
25
|
|
|
23
|
-
const convertedParams = convertListParams(params, domain
|
|
26
|
+
const convertedParams = convertListParams(params, { domain })
|
|
24
27
|
const [items, total] = await getRepository(Font).findAndCount(convertedParams)
|
|
25
28
|
|
|
26
29
|
return { items, total }
|
|
@@ -31,6 +34,16 @@ export class FontQuery {
|
|
|
31
34
|
return await getRepository(Domain).findOne(font.domainId)
|
|
32
35
|
}
|
|
33
36
|
|
|
37
|
+
@FieldResolver(type => Attachment)
|
|
38
|
+
async files(@Root() font: Font, @Ctx() context: any) {
|
|
39
|
+
const { domain } = context.state
|
|
40
|
+
|
|
41
|
+
return await getRepository(Attachment).find({
|
|
42
|
+
domain,
|
|
43
|
+
refBy: font.id
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
|
|
34
47
|
@FieldResolver(type => User)
|
|
35
48
|
async updater(@Root() font: Font): Promise<User> {
|
|
36
49
|
return await getRepository(User).findOne(font.updaterId)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FileUpload, GraphQLUpload } from 'graphql-upload'
|
|
2
|
+
import { Field, InputType, Int, ObjectType } from 'type-graphql'
|
|
2
3
|
|
|
3
4
|
import { Font } from './font'
|
|
4
5
|
|
|
@@ -16,6 +17,9 @@ export class NewFont {
|
|
|
16
17
|
@Field({ nullable: true })
|
|
17
18
|
path?: string
|
|
18
19
|
|
|
20
|
+
@Field(type => [GraphQLUpload], { nullable: true })
|
|
21
|
+
files?: FileUpload[]
|
|
22
|
+
|
|
19
23
|
@Field({ nullable: true })
|
|
20
24
|
active?: boolean
|
|
21
25
|
}
|
|
@@ -34,6 +38,9 @@ export class FontPatch {
|
|
|
34
38
|
@Field({ nullable: true })
|
|
35
39
|
path?: string
|
|
36
40
|
|
|
41
|
+
@Field(type => [GraphQLUpload], { nullable: true })
|
|
42
|
+
files?: FileUpload[]
|
|
43
|
+
|
|
37
44
|
@Field({ nullable: true })
|
|
38
45
|
active?: boolean
|
|
39
46
|
}
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
UpdateDateColumn
|
|
11
11
|
} from 'typeorm'
|
|
12
12
|
|
|
13
|
+
import { Attachment } from '@things-factory/attachment-base'
|
|
13
14
|
import { User } from '@things-factory/auth-base'
|
|
14
15
|
import { Domain } from '@things-factory/shell'
|
|
15
16
|
|
|
@@ -52,6 +53,9 @@ export class Font {
|
|
|
52
53
|
@Field()
|
|
53
54
|
active: boolean
|
|
54
55
|
|
|
56
|
+
@Field(type => [Attachment], { nullable: true })
|
|
57
|
+
files?: Attachment[]
|
|
58
|
+
|
|
55
59
|
@CreateDateColumn()
|
|
56
60
|
@Field({ nullable: true })
|
|
57
61
|
createdAt?: Date
|
package/client/actions/font.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import * as client from '../graphql-client'
|
|
2
|
-
|
|
3
|
-
export const UPDATE_FONT_LIST = 'UPDATE_FONT_LIST'
|
|
4
|
-
export const CLEAR_FONT_LIST = 'CLEAR_FONT_LIST'
|
|
5
|
-
|
|
6
|
-
export const fetchFontList = listParams => async dispatch => {
|
|
7
|
-
try {
|
|
8
|
-
const fonts = await client.fetchFontList(listParams || { filters: [] })
|
|
9
|
-
|
|
10
|
-
dispatch({
|
|
11
|
-
type: UPDATE_FONT_LIST,
|
|
12
|
-
list: fonts && fonts.items
|
|
13
|
-
})
|
|
14
|
-
} catch (error) {
|
|
15
|
-
console.error(error)
|
|
16
|
-
dispatch({
|
|
17
|
-
type: CLEAR_FONT_LIST
|
|
18
|
-
})
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const createFont = font => async dispatch => {
|
|
23
|
-
try {
|
|
24
|
-
const data = await client.createFont(font)
|
|
25
|
-
|
|
26
|
-
const createdFont = data.createFont
|
|
27
|
-
|
|
28
|
-
dispatch(fetchFontList())
|
|
29
|
-
} catch (error) {
|
|
30
|
-
console.error(error)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export const updateFont = font => async dispatch => {
|
|
35
|
-
try {
|
|
36
|
-
const data = await client.updateFont(font)
|
|
37
|
-
|
|
38
|
-
const updatedFont = data.updateFont
|
|
39
|
-
|
|
40
|
-
dispatch(fetchFontList())
|
|
41
|
-
} catch (error) {
|
|
42
|
-
console.error(error)
|
|
43
|
-
/* TODO error */
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export const deleteFont = font => async dispatch => {
|
|
48
|
-
try {
|
|
49
|
-
var { id } = font
|
|
50
|
-
|
|
51
|
-
const data = await client.deleteFont(id)
|
|
52
|
-
|
|
53
|
-
dispatch(fetchFontList())
|
|
54
|
-
} catch (error) {
|
|
55
|
-
console.error(error)
|
|
56
|
-
/* TODO error */
|
|
57
|
-
}
|
|
58
|
-
}
|
package/client/graphql-client.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import gql from 'graphql-tag'
|
|
2
|
-
import { client } from '@things-factory/shell'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @param {Object} listParam {filters, pagination, sortings}
|
|
6
|
-
*/
|
|
7
|
-
export async function fetchFontList(listParam) {
|
|
8
|
-
const response = await client.query({
|
|
9
|
-
query: gql`
|
|
10
|
-
query($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
|
|
11
|
-
fonts(filters: $filters, pagination: $pagination, sortings: $sortings) {
|
|
12
|
-
items {
|
|
13
|
-
id
|
|
14
|
-
name
|
|
15
|
-
provider
|
|
16
|
-
uri
|
|
17
|
-
path
|
|
18
|
-
active
|
|
19
|
-
createdAt
|
|
20
|
-
updatedAt
|
|
21
|
-
}
|
|
22
|
-
total
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
`,
|
|
26
|
-
variables: listParam
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
return response.data && response.data.fonts
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @param {Object} font Font patch
|
|
34
|
-
*/
|
|
35
|
-
export async function createFont(font) {
|
|
36
|
-
const response = await client.mutate({
|
|
37
|
-
mutation: gql`
|
|
38
|
-
mutation CreateFont($font: NewFont!) {
|
|
39
|
-
createFont(font: $font) {
|
|
40
|
-
name
|
|
41
|
-
provider
|
|
42
|
-
uri
|
|
43
|
-
path
|
|
44
|
-
active
|
|
45
|
-
createdAt
|
|
46
|
-
updatedAt
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
`,
|
|
50
|
-
variables: {
|
|
51
|
-
font: { active: false, ...font }
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
return response.data
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* @param {Object} font Font patch
|
|
60
|
-
*/
|
|
61
|
-
export async function updateFont(font) {
|
|
62
|
-
var { id, ...patch } = font
|
|
63
|
-
|
|
64
|
-
const response = await client.mutate({
|
|
65
|
-
mutation: gql`
|
|
66
|
-
mutation UpdateFont($id: String!, $patch: FontPatch!) {
|
|
67
|
-
updateFont(id: $id, patch: $patch) {
|
|
68
|
-
id
|
|
69
|
-
name
|
|
70
|
-
provider
|
|
71
|
-
uri
|
|
72
|
-
path
|
|
73
|
-
active
|
|
74
|
-
createdAt
|
|
75
|
-
updatedAt
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
`,
|
|
79
|
-
variables: {
|
|
80
|
-
id,
|
|
81
|
-
patch
|
|
82
|
-
}
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
return response.data
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* @param {String} id Font id
|
|
90
|
-
*/
|
|
91
|
-
export async function deleteFont(id) {
|
|
92
|
-
const response = await client.mutate({
|
|
93
|
-
mutation: gql`
|
|
94
|
-
mutation($id: String!) {
|
|
95
|
-
deleteFont(id: $id)
|
|
96
|
-
}
|
|
97
|
-
`,
|
|
98
|
-
variables: {
|
|
99
|
-
id
|
|
100
|
-
}
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
return response.data
|
|
104
|
-
}
|
package/client/reducers/font.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import WebFont from 'webfontloader'
|
|
2
|
-
import { UPDATE_FONT_LIST, CLEAR_FONT_LIST } from '../actions/font'
|
|
3
|
-
|
|
4
|
-
const font = (state = [], action) => {
|
|
5
|
-
switch (action.type) {
|
|
6
|
-
case UPDATE_FONT_LIST:
|
|
7
|
-
let newState = action.list
|
|
8
|
-
let activatedFonts = newState.filter(font => font.active)
|
|
9
|
-
|
|
10
|
-
let googles = []
|
|
11
|
-
let customs = []
|
|
12
|
-
let customFontCSS = ''
|
|
13
|
-
|
|
14
|
-
activatedFonts.forEach(font => {
|
|
15
|
-
switch (font.provider) {
|
|
16
|
-
case 'google':
|
|
17
|
-
googles.push(font.name)
|
|
18
|
-
break
|
|
19
|
-
case 'custom':
|
|
20
|
-
customs.push(font.name)
|
|
21
|
-
customFontCSS += `@font-face {
|
|
22
|
-
font-family: '${font.name}';
|
|
23
|
-
src: local('${font.name}')${font.uri ? `, url(${font.uri})` : ''};
|
|
24
|
-
}
|
|
25
|
-
` // TODO: format('woff2') 등 파일 형식에 맞는 포맷 추가
|
|
26
|
-
break
|
|
27
|
-
}
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
let style = document.head.querySelector('#custom-fonts')
|
|
31
|
-
if (!style) {
|
|
32
|
-
style = document.createElement('style')
|
|
33
|
-
style.id = 'custom-fonts'
|
|
34
|
-
style.type = 'text/css'
|
|
35
|
-
document.head.appendChild(style)
|
|
36
|
-
}
|
|
37
|
-
style.innerHTML = customFontCSS
|
|
38
|
-
|
|
39
|
-
// TODO: typekit 등 타 서비스 지원
|
|
40
|
-
let WebFontConfig = {}
|
|
41
|
-
if (googles.length) {
|
|
42
|
-
WebFontConfig.google = {
|
|
43
|
-
families: googles
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
if (customs.length) {
|
|
47
|
-
WebFontConfig.custom = {
|
|
48
|
-
families: customs
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
if (Object.keys(WebFontConfig).length) WebFont.load(WebFontConfig)
|
|
52
|
-
|
|
53
|
-
return newState
|
|
54
|
-
|
|
55
|
-
case CLEAR_FONT_LIST:
|
|
56
|
-
return []
|
|
57
|
-
|
|
58
|
-
default:
|
|
59
|
-
return state
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export default font
|