authscape 1.0.620 → 1.0.622

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.
@@ -1,483 +0,0 @@
1
-
2
- import React, { useState, useRef, useEffect } from "react";
3
- import Editor, { useMonaco } from "@monaco-editor/react";
4
- import Button from '@mui/material/Button';
5
- import CheckIcon from '@mui/icons-material/Check';
6
- import Tabs from '@mui/material/Tabs';
7
- import Tab from '@mui/material/Tab';
8
- import Box from '@mui/material/Box';
9
- import { Grid } from "@mui/material";
10
- import { DataGrid } from "@mui/x-data-grid";
11
- import PublishRoundedIcon from '@mui/icons-material/PublishRounded';
12
- import InputLabel from '@mui/material/InputLabel';
13
- import MenuItem from '@mui/material/MenuItem';
14
- import FormControl from '@mui/material/FormControl';
15
- import Select from '@mui/material/Select';
16
-
17
- // remove after NPM
18
- // import {FileUploader, apiService, ColorPicker, Dropzone} from 'authscape';
19
- // import AddDomain from "./AddDomainModal";
20
-
21
- export function PrivateLabelEditor({loadedUser, notification, showAllDomains = false, companyId = null, azureWebsite = "", azureTxtValue = ""}) {
22
-
23
- const monaco = useMonaco();
24
-
25
- const cssEditorRef = useRef(null);
26
- const htmlEditorRef = useRef(null);
27
-
28
- const [data, setData] = useState(null);
29
- const [value, setValue] = useState(0);
30
- const [fonts, setFonts] = useState([]);
31
- const [oEMDomainList, setOEMDomainList] = useState([]);
32
- const [dnsFields, setDnsFields] = useState([]);
33
- const [selectedFont, setSelectedFont] = useState(null);
34
- const [fontUri, setFontUri] = useState(null);
35
-
36
- const [oEMDomain, setOEMDomain] = useState(null);
37
-
38
- const [stateBaseUri, setBaseUri] = useState('');
39
-
40
- const [isNewAccount, setIsNewAccount] = useState(false);
41
-
42
-
43
- const handleChange = (event, newValue) => {
44
- setValue(newValue);
45
- };
46
-
47
- const GetBaseUrl = () => {
48
- return window.location.protocol + "//" + window.location.host;
49
- }
50
-
51
- const loadDNSFields = async (_domain = null) => {
52
-
53
- var domain = null;
54
- if (_domain != null)
55
- {
56
- domain = _domain;
57
- }
58
- else
59
- {
60
- domain = GetBaseUrl();
61
- }
62
-
63
- let responseFields = await apiService().get("/PrivateLabel/GetFields?domain=" + domain + (companyId != null ? ("&companyId=" + companyId) : ""));
64
- if (responseFields != null && responseFields.status == 200)
65
- {
66
- setDnsFields(responseFields.data);
67
- }
68
- }
69
-
70
- useEffect(() => {
71
-
72
- if (oEMDomain != null)
73
- {
74
- loadDNSFields(oEMDomain);
75
- }
76
-
77
- }, [oEMDomain]);
78
-
79
-
80
- const FetchOEMData = async () => {
81
-
82
- let response = await apiService().get("/PrivateLabel/GetFonts");
83
- if (response != null && response.status == 200)
84
- {
85
- setFonts(response.data);
86
- }
87
-
88
- if (showAllDomains)
89
- {
90
- let response = await apiService().get("/PrivateLabel/GetAllDomains");
91
- if (response != null && response.status == 200)
92
- {
93
- setOEMDomainList(response.data);
94
-
95
- if (response.data.length > 0)
96
- {
97
- setOEMDomain(response.data[0].name);
98
- }
99
- else
100
- {
101
- setIsNewAccount(true);
102
- }
103
- }
104
- }
105
- else
106
- {
107
- let response = await apiService().get("/PrivateLabel/GetAllDomainsUser");
108
- if (response != null && response.status == 200)
109
- {
110
- setOEMDomainList(response.data);
111
-
112
- if (response.data.length > 0)
113
- {
114
- setOEMDomain(response.data[0].name);
115
- }
116
- else
117
- {
118
- setIsNewAccount(true);
119
- }
120
- }
121
- }
122
-
123
- }
124
-
125
- useEffect(() => {
126
-
127
- if (loadedUser)
128
- {
129
- FetchOEMData();
130
- }
131
-
132
- }, [loadedUser]);
133
-
134
-
135
- const [paginationModel, setPaginationModel] = React.useState({
136
- page: 0,
137
- pageSize: 12,
138
- });
139
-
140
-
141
- function handleCSSEditorDidMount(editor, monaco) {
142
- cssEditorRef.current = editor;
143
- }
144
-
145
- function handleHtmlEditorDidMount(editor, monaco) {
146
- htmlEditorRef.current = editor;
147
- }
148
-
149
- const columns = [
150
- {
151
- field: "label",
152
- headerName: "Fonts",
153
- editable: false,
154
- width:300,
155
- renderCell: (params) => {
156
- const RenderData = (row) => {
157
- // const { id, value, field } = params;
158
- // const apiRef = useGridApiContext();
159
- return (
160
- <>
161
- <Box sx={{fontFamily: row.value, fontSize:20, cursor:"pointer"}}>{row.value}</Box>
162
- <link href={"https://fonts.googleapis.com/css2?family=" + row.value} rel="stylesheet"></link>
163
- </>
164
- );
165
- };
166
- return RenderData(params);
167
- },
168
- }
169
- ];
170
-
171
- useEffect(() => {
172
-
173
- const fetchData = async () => {
174
-
175
- // if (monaco) {
176
- // //console.log("here is the monaco instance:", monaco);
177
- // }
178
-
179
- setData(null);
180
-
181
- let response = await apiService().get("/PrivateLabel/GetEditorData?domain=" + oEMDomain + (companyId != null ? ("&companyId=" + companyId) : ""));
182
- if (response.status == 200)
183
- {
184
- setData(response.data);
185
- setSelectedFont(response.data.fontFamily);
186
- setFontUri(response.data.fontUrl);
187
- }
188
- }
189
- fetchData();
190
-
191
- }, [monaco, oEMDomain]);
192
-
193
- return (
194
- <>
195
- <Box sx={{ width: '100%' }}>
196
-
197
- {(selectedFont != null && fontUri == null) &&
198
- <link href={"https://fonts.googleapis.com/css2?family=" + selectedFont} rel="stylesheet"></link>
199
- }
200
-
201
- <Box sx={{paddingTop:6}}>
202
- {oEMDomain != null &&
203
- <FormControl fullWidth>
204
- <InputLabel id="demo-simple-select-label">Website Domain</InputLabel>
205
- <Select
206
- labelId="demo-simple-select-label"
207
- id="demo-simple-select"
208
- defaultValue={oEMDomain}
209
- label="Website Domain"
210
- onChange={(val) => {
211
- setOEMDomain(val.target.value)
212
- }}>
213
- {oEMDomainList.map((dns) => {
214
- return (
215
- <MenuItem value={dns.name}>{dns.name}</MenuItem>
216
- )
217
- })}
218
- </Select>
219
- </FormControl>
220
- }
221
- </Box>
222
-
223
- <Box sx={{ borderBottom: 1, borderColor: 'divider', paddingTop:2 }}>
224
- <Tabs value={value} onChange={handleChange} aria-label="basic tabs example">
225
- <Tab label="App Icon / Colors" />
226
- <Tab label="Fonts" />
227
- {/* <Tab label="Content" /> */}
228
- <Tab label="Style Sheet Editor" />
229
- <Tab label="HTML Import Editor" />
230
- </Tabs>
231
- </Box>
232
- <Box>
233
-
234
- <Box sx={{padding:2}}>
235
- {value == 0 &&
236
- <Box>
237
- {data != null &&
238
- <Box>
239
- <Grid container spacing={2}>
240
- <Grid item xs={4}>
241
- <Box sx={{paddingBottom:4}}>
242
- <Dropzone
243
- image={"/DefaultNoImage.svg"}
244
- text={"Drag 'n' drop your app icon here"}
245
- onDrop={async (file) => {
246
- const data = new FormData();
247
-
248
- data.append("file", file);
249
- data.append("domain", stateBaseUri);
250
-
251
- let response = await apiService().post(
252
- "/PrivateLabel/UploadAppIcon",
253
- data
254
- );
255
- if (response != null && response.status == 200) {
256
- window.location.reload();
257
- }
258
- }}
259
- />
260
- </Box>
261
- </Grid>
262
- <Grid item xs={8}>
263
- <Box sx={{paddingBottom:2, fontWeight:"bold", fontSize:16}}>
264
- Adjust the colors for your site
265
- </Box>
266
- <Box>
267
- {dnsFields != null && dnsFields.map((dnsField, index) => {
268
- return (
269
- <Box key={index}>
270
- <Grid container spacing={2}>
271
- <Grid item xs={3}>
272
- {dnsField.name}
273
- </Grid>
274
- <Grid item xs={9}>
275
-
276
- <ColorPicker name={dnsField.name} defaultColor={dnsField.value} onColorChanged={async (name, hex) => {
277
-
278
- await apiService().post("/PrivateLabel/SetFieldValue", {
279
- id: dnsField.id,
280
- fieldId: dnsField.fieldId,
281
- value: hex
282
- });
283
-
284
- notification(dnsField.name + " Saved");
285
-
286
- }} />
287
- </Grid>
288
- </Grid>
289
- </Box>
290
- )
291
- })}
292
- </Box>
293
- </Grid>
294
- </Grid>
295
- </Box>
296
- }
297
- </Box>
298
- }
299
-
300
- {value == 1 &&
301
- <Box value={value} index={1}>
302
- {data != null &&
303
- <Box>
304
- <Grid container spacing={2}>
305
- <Grid item xs={6}>
306
-
307
- {loadedUser == true &&
308
-
309
- <Box>
310
- <DataGrid
311
- rows={fonts}
312
- columns={columns}
313
- sx={{height:"80vh", width:"100%"}}
314
- pagination
315
- disableSelectionOnClick={true}
316
- onPaginationModelChange={setPaginationModel}
317
- paginationModel={paginationModel}
318
- //pageSizeOptions={[5]}
319
- // rowCount={100}
320
- // rowSelectionModel={selectedFont}
321
- onRowClick={async (params) => {
322
-
323
- let response = await apiService().post("/PrivateLabel/SetFont", {
324
- companyId: companyId,
325
- domain: oEMDomain,
326
- value: params.row.label
327
- });
328
- if (response != null && response.status == 200)
329
- {
330
- setSelectedFont(params.row.label);
331
- setFontUri(null);
332
- notification("Font saved!");
333
- }
334
- }}
335
- />
336
- </Box>
337
- }
338
-
339
-
340
- </Grid>
341
- <Grid item xs={6} >
342
-
343
- <FileUploader url={"/PrivateLabel/UploadCustomFont"} accept={".otf,.ttf,.woff"} params={{
344
- domain: stateBaseUri
345
- }} multiple={true} variant='custom' onUploadCompleted={() => {
346
- window.location.reload();
347
- }}>
348
-
349
- <Button color="primary" variant="contained" fullWidth={true} sx={{height:50}} startIcon={<PublishRoundedIcon/>}><Box>Upload Font</Box>&nbsp;<Box sx={{textAlign:"center"}}><small>(.OTF, .TTF, OR .WOFF)</small></Box></Button>
350
-
351
- </FileUploader>
352
-
353
-
354
- <Box sx={{marginTop:4}}>Font Selected:</Box>
355
- <Box sx={{marginBottom:2, fontWeight:"bold", fontSize:20}}> {selectedFont}</Box>
356
- <hr />
357
- <Box sx={{fontFamily: selectedFont}}>
358
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ut ultricies odio. Nunc ut quam turpis. In hac habitasse platea dictumst.
359
- Suspendisse potenti. Nullam malesuada, purus id sagittis vestibulum, massa tellus gravida elit, vitae ultrices tortor nulla ac nunc.
360
- Aenean tempus semper est vel convallis. Sed feugiat, risus eu tincidunt eleifend, purus metus vulputate nulla, et condimentum sapien erat in nisi.
361
- Nunc non malesuada libero. Donec tempus tincidunt mi at vulputate. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;
362
- Suspendisse potenti. Etiam nec eleifend orci. Suspendisse in est vel nunc rhoncus bibendum vitae id felis.
363
- Integer bibendum dolor elit, at tincidunt lacus tempor ac. Maecenas lobortis, mauris at condimentum feugiat, nulla orci condimentum massa, sed facilisis tellus ligula vitae metus.
364
- Aliquam erat volutpat. Quisque dignissim felis augue, at semper nisl posuere ut. Proin fringilla diam vitae faucibus finibus.
365
- <br/><br/>
366
- Aenean tempus semper est vel convallis. Sed feugiat, risus eu tincidunt eleifend, purus metus vulputate nulla, et condimentum sapien erat in nisi. Nunc non malesuada libero. Donec tempus tincidunt mi at vulputate. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse potenti
367
- </Box>
368
- </Grid>
369
- </Grid>
370
- </Box>
371
- }
372
- </Box>
373
- }
374
-
375
- {/* {value == 2 &&
376
- <Box value={value} index={2}>
377
- <Grid container spacing={2}>
378
- <Grid item xs={6}>
379
- <h4 style={{marginBottom:"0px"}}>Content</h4>
380
- <small>You can adjust the content within your site</small>
381
- </Grid>
382
- </Grid>
383
- <Box sx={{paddingTop:2}}>
384
- <TextField id="outlined-basic" label="Outlined" variant="outlined" />
385
- </Box>
386
- </Box>
387
- } */}
388
-
389
- {value == 2 &&
390
- <Box value={value} index={3}>
391
-
392
- <Grid container spacing={2}>
393
- <Grid item xs={6}>
394
- <h4 style={{marginBottom:"0px"}}>Global CSS edits</h4>
395
- <small>You can make edits to your stylesheet</small>
396
- </Grid>
397
- <Grid item xs={6} sx={{textAlign:"right"}}>
398
- <Button startIcon={<CheckIcon/>} sx={{marginTop:4}} variant="contained" onClick={async () => {
399
-
400
- let response = await apiService().post("/PrivateLabel/SetGlobalCSS", {
401
- companyId: companyId,
402
- domain: oEMDomain,
403
- value: cssEditorRef.current.getValue()
404
- });
405
- if (response != null && response.status == 200)
406
- {
407
- notification("CSS Saved!")
408
- }
409
-
410
- }}>Save Changes</Button>
411
- </Grid>
412
- </Grid>
413
-
414
- <Box sx={{paddingTop:1}}>
415
-
416
- {data != null &&
417
- <Editor
418
- height="70vh"
419
- onMount={handleCSSEditorDidMount}
420
- defaultLanguage="css"
421
- theme="vs-dark"
422
- defaultValue={(data == null || data.prettyCSS == null) ? "" : data.prettyCSS}
423
- />
424
- }
425
- </Box>
426
-
427
- </Box>
428
- }
429
-
430
- {value == 3 &&
431
- <Box value={value} index={4}>
432
-
433
-
434
- <Grid container spacing={2}>
435
- <Grid item xs={6}>
436
- <h4 style={{marginBottom:"0px"}}>HTML import Edits</h4>
437
- <small>You can add imports such as google analytics or clarity</small>
438
- </Grid>
439
- <Grid item xs={6} sx={{textAlign:"right"}}>
440
- <Button startIcon={<CheckIcon/>} sx={{marginTop:4}} variant="contained" onClick={async () => {
441
-
442
- let response = await apiService().post("/PrivateLabel/SetGlobalHTML", {
443
- companyId: companyId,
444
- domain: oEMDomain,
445
- value: htmlEditorRef.current.getValue()
446
- });
447
-
448
- if (response != null && response.status == 200)
449
- {
450
- notification("HTML saved!")
451
- }
452
-
453
- }}>Save Changes</Button>
454
- </Grid>
455
- </Grid>
456
-
457
- <Box sx={{paddingTop:1}}>
458
- {data != null &&
459
- <Editor
460
- height="70vh"
461
- onMount={handleHtmlEditorDidMount}
462
- defaultLanguage="html"
463
- theme="vs-dark"
464
- defaultValue={(data == null || data.prettyHTML == null) ? "" : data.prettyHTML}
465
- />
466
- }
467
- </Box>
468
-
469
-
470
- </Box>
471
- }
472
- </Box>
473
-
474
- </Box>
475
-
476
- <AddDomain open={isNewAccount} azureWebsite={azureWebsite} azureTxtValue={azureTxtValue} handleClose={async () => {
477
- setIsNewAccount(false);
478
- await FetchOEMData();
479
- }} />
480
- </Box>
481
- </>
482
- )
483
- }