@hitachivantara/uikit-cli 6.0.1
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/README.md +46 -0
- package/package.json +68 -0
- package/src/app-shell.js +106 -0
- package/src/baselines/app-shell/vite/_gitignore +30 -0
- package/src/baselines/app-shell/vite/_oxlintrc.json +5 -0
- package/src/baselines/app-shell/vite/_package.json +55 -0
- package/src/baselines/app-shell/vite/public/locales/en/example.json +8 -0
- package/src/baselines/app-shell/vite/src/lib/data/config.ts +15 -0
- package/src/baselines/app-shell/vite/src/lib/i18n.ts +44 -0
- package/src/baselines/app-shell/vite/src/pages/Example/index.tsx +25 -0
- package/src/baselines/app-shell/vite/src/providers/Provider.tsx +31 -0
- package/src/baselines/app-shell/vite/src/tests/mocks.ts +1 -0
- package/src/baselines/app-shell/vite/src/tests/providers.tsx +13 -0
- package/src/baselines/app-shell/vite/src/tests/setupTests.ts +24 -0
- package/src/baselines/app-shell/vite/src/types/theme.d.ts +8 -0
- package/src/baselines/app-shell/vite/src/types/vite-env.d.ts +1 -0
- package/src/baselines/app-shell/vite/tsconfig.json +10 -0
- package/src/baselines/app-shell/vite/tsconfig.node.json +9 -0
- package/src/baselines/app-shell/vite/uno.config.ts +6 -0
- package/src/baselines/app-shell/vite/vite.config.ts +45 -0
- package/src/baselines/vite/_gitignore +30 -0
- package/src/baselines/vite/_oxlintrc.json +5 -0
- package/src/baselines/vite/_package.json +53 -0
- package/src/baselines/vite/index.html +18 -0
- package/src/baselines/vite/public/favicon.ico +0 -0
- package/src/baselines/vite/public/locales/en/common.json +16 -0
- package/src/baselines/vite/public/locales/en/home.json +4 -0
- package/src/baselines/vite/public/logo192.png +0 -0
- package/src/baselines/vite/src/App.tsx +31 -0
- package/src/baselines/vite/src/assets/HitachiLogo.tsx +27 -0
- package/src/baselines/vite/src/components/common/Loading/Loading.test.tsx +18 -0
- package/src/baselines/vite/src/components/common/Loading/Loading.tsx +15 -0
- package/src/baselines/vite/src/components/common/Loading/index.ts +1 -0
- package/src/baselines/vite/src/context/NavigationContext.tsx +67 -0
- package/src/baselines/vite/src/lib/i18n.ts +29 -0
- package/src/baselines/vite/src/main.tsx +12 -0
- package/src/baselines/vite/src/pages/Home/index.tsx +13 -0
- package/src/baselines/vite/src/pages/NotFound/NotFound.tsx +39 -0
- package/src/baselines/vite/src/pages/NotFound/index.tsx +1 -0
- package/src/baselines/vite/src/pages/layout/navigation.tsx +82 -0
- package/src/baselines/vite/src/routes.tsx +14 -0
- package/src/baselines/vite/src/tests/mocks.ts +1 -0
- package/src/baselines/vite/src/tests/providers.tsx +13 -0
- package/src/baselines/vite/src/tests/setupTests.ts +24 -0
- package/src/baselines/vite/src/types/theme.d.ts +8 -0
- package/src/baselines/vite/src/vite-env.d.ts +1 -0
- package/src/baselines/vite/tsconfig.json +10 -0
- package/src/baselines/vite/tsconfig.node.json +9 -0
- package/src/baselines/vite/uno.config.ts +6 -0
- package/src/baselines/vite/vite.config.ts +31 -0
- package/src/contents.js +63 -0
- package/src/create.js +172 -0
- package/src/index.js +22 -0
- package/src/navigation.js +21 -0
- package/src/package.js +37 -0
- package/src/plop-templates/README.md.hbs +10 -0
- package/src/plop-templates/app-shell/app-shell.config.ts.hbs +54 -0
- package/src/plop-templates/app-shell/index.html.hbs +15 -0
- package/src/plopfile.js +61 -0
- package/src/templates/AssetInventory/CardView.tsx +167 -0
- package/src/templates/AssetInventory/ListView.tsx +56 -0
- package/src/templates/AssetInventory/data.tsx +255 -0
- package/src/templates/AssetInventory/index.tsx +198 -0
- package/src/templates/AssetInventory/usePaginationData.ts +158 -0
- package/src/templates/Canvas/Context.tsx +49 -0
- package/src/templates/Canvas/ListView.tsx +189 -0
- package/src/templates/Canvas/Node.tsx +203 -0
- package/src/templates/Canvas/Sidebar.tsx +51 -0
- package/src/templates/Canvas/StatusEdge.tsx +75 -0
- package/src/templates/Canvas/StickyNode.tsx +475 -0
- package/src/templates/Canvas/Table.tsx +202 -0
- package/src/templates/Canvas/TreeView.tsx +211 -0
- package/src/templates/Canvas/dependencies.json +7 -0
- package/src/templates/Canvas/index.tsx +363 -0
- package/src/templates/Canvas/styles.tsx +41 -0
- package/src/templates/Canvas/utils.tsx +70 -0
- package/src/templates/Dashboard/GridPanel.tsx +33 -0
- package/src/templates/Dashboard/Kpi.tsx +107 -0
- package/src/templates/Dashboard/Map.styles.ts +681 -0
- package/src/templates/Dashboard/Map.tsx +71 -0
- package/src/templates/Dashboard/data.ts +67 -0
- package/src/templates/Dashboard/dependencies.json +11 -0
- package/src/templates/Dashboard/index.tsx +173 -0
- package/src/templates/DetailsView/KPIs.tsx +70 -0
- package/src/templates/DetailsView/MetadataItem.tsx +35 -0
- package/src/templates/DetailsView/Properties.tsx +127 -0
- package/src/templates/DetailsView/Table.tsx +104 -0
- package/src/templates/DetailsView/data.ts +67 -0
- package/src/templates/DetailsView/index.tsx +102 -0
- package/src/templates/DetailsView/usePaginationData.ts +155 -0
- package/src/templates/DetailsView/utils.ts +51 -0
- package/src/templates/Form/index.tsx +107 -0
- package/src/templates/KanbanBoard/ColumnContainer.tsx +89 -0
- package/src/templates/KanbanBoard/TaskCard.tsx +130 -0
- package/src/templates/KanbanBoard/data.tsx +140 -0
- package/src/templates/KanbanBoard/dependencies.json +6 -0
- package/src/templates/KanbanBoard/index.tsx +179 -0
- package/src/templates/KanbanBoard/styles.tsx +76 -0
- package/src/templates/KanbanBoard/types.ts +21 -0
- package/src/templates/ListView/Indicator.tsx +42 -0
- package/src/templates/ListView/Kpi.tsx +120 -0
- package/src/templates/ListView/Table.tsx +55 -0
- package/src/templates/ListView/data.tsx +179 -0
- package/src/templates/ListView/dependencies.json +5 -0
- package/src/templates/ListView/index.tsx +245 -0
- package/src/templates/ListView/usePaginationData.ts +158 -0
- package/src/templates/Welcome/index.tsx +101 -0
- package/src/templates/package.json +30 -0
- package/src/utils.js +37 -0
package/src/create.js
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
import inquirer from "inquirer";
|
|
5
|
+
|
|
6
|
+
import { createAppShellBaseline, setupAppShell } from "./app-shell.js";
|
|
7
|
+
import { createAppContents } from "./contents.js";
|
|
8
|
+
import { createNavigationFiles } from "./navigation.js";
|
|
9
|
+
import { updatePackageJson } from "./package.js";
|
|
10
|
+
import { __dirname, toPascalCase, toSentenceCase } from "./utils.js";
|
|
11
|
+
|
|
12
|
+
/** @type import("inquirer").QuestionCollection */
|
|
13
|
+
const questions = [
|
|
14
|
+
{
|
|
15
|
+
type: "input",
|
|
16
|
+
name: "name",
|
|
17
|
+
message: "App name",
|
|
18
|
+
default: "uikit-app",
|
|
19
|
+
validate(val) {
|
|
20
|
+
if (typeof val === "string") {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return "Please enter a valid name";
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
type: "confirm",
|
|
29
|
+
name: "useAppShell",
|
|
30
|
+
message: "Use App Shell?",
|
|
31
|
+
default: true,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
type: "checkbox",
|
|
35
|
+
message: "Do you want to enable App Shell features? If so, choose which:",
|
|
36
|
+
name: "appShellFeatures",
|
|
37
|
+
choices: ["Help Link", "Color Mode Switcher", "App Switcher"],
|
|
38
|
+
when(answers) {
|
|
39
|
+
return answers.useAppShell;
|
|
40
|
+
},
|
|
41
|
+
filter(val) {
|
|
42
|
+
return val.map((v) => toPascalCase(v));
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
type: "confirm",
|
|
47
|
+
name: "appShellAutoMenu",
|
|
48
|
+
message: "Use automatic menu generation in App Shell?",
|
|
49
|
+
default: true,
|
|
50
|
+
when(answers) {
|
|
51
|
+
return answers.useAppShell;
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: "checkbox",
|
|
56
|
+
message: "Do you want to use templates? If so, choose which:",
|
|
57
|
+
name: "templates",
|
|
58
|
+
choices: fs
|
|
59
|
+
.readdirSync(`${__dirname}/templates`, { withFileTypes: true })
|
|
60
|
+
.filter((d) => d.isDirectory())
|
|
61
|
+
.map((d) => toSentenceCase(d.name)),
|
|
62
|
+
filter(val) {
|
|
63
|
+
return val.map((v) => toPascalCase(v));
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
const createAppBaseline = (appPath) => {
|
|
69
|
+
const basePath = `${__dirname}/baselines/vite`;
|
|
70
|
+
|
|
71
|
+
console.log(`\nCreating a new UI Kit app in\n${chalk.green(appPath)}\n`);
|
|
72
|
+
|
|
73
|
+
// copy baseline contents
|
|
74
|
+
fs.copySync(basePath, appPath, { overwrite: true });
|
|
75
|
+
fs.moveSync(`${appPath}/_gitignore`, `${appPath}/.gitignore`);
|
|
76
|
+
fs.moveSync(`${appPath}/_package.json`, `${appPath}/package.json`);
|
|
77
|
+
fs.moveSync(`${appPath}/_oxlintrc.json`, `${appPath}/.oxlintrc.json`);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const create = async ({
|
|
81
|
+
name = "uikit-app",
|
|
82
|
+
useAppShell = true,
|
|
83
|
+
appShellFeatures = [],
|
|
84
|
+
appShellAutoMenu = true,
|
|
85
|
+
templates = [],
|
|
86
|
+
}) => {
|
|
87
|
+
console.log(chalk.cyan("\nUI kit app generator\n"));
|
|
88
|
+
|
|
89
|
+
const packageName = name
|
|
90
|
+
.replace(/([a-z])([A-Z])/g, "$1-$2")
|
|
91
|
+
.toLowerCase()
|
|
92
|
+
.replace(/ /g, "-")
|
|
93
|
+
.replace(/[^a-z0-9-]/g, "");
|
|
94
|
+
const appPath = `${process.cwd()}/${packageName}`;
|
|
95
|
+
|
|
96
|
+
// create app baseline from receipt
|
|
97
|
+
if (useAppShell) {
|
|
98
|
+
await createAppShellBaseline(appPath);
|
|
99
|
+
} else {
|
|
100
|
+
createAppBaseline(appPath);
|
|
101
|
+
}
|
|
102
|
+
// create app contents from recipe templates selection
|
|
103
|
+
const dependencies = await createAppContents(
|
|
104
|
+
appPath,
|
|
105
|
+
name,
|
|
106
|
+
templates,
|
|
107
|
+
useAppShell,
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
if (useAppShell) {
|
|
111
|
+
await setupAppShell(
|
|
112
|
+
appPath,
|
|
113
|
+
name,
|
|
114
|
+
appShellFeatures,
|
|
115
|
+
appShellAutoMenu,
|
|
116
|
+
packageName,
|
|
117
|
+
);
|
|
118
|
+
console.log(
|
|
119
|
+
`App Shell documentation: ${chalk.cyan(
|
|
120
|
+
"https://pentaho.github.io/uikit-docs/master/app-shell",
|
|
121
|
+
)}`,
|
|
122
|
+
);
|
|
123
|
+
} else {
|
|
124
|
+
await createNavigationFiles(appPath);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
updatePackageJson(appPath, packageName, dependencies);
|
|
128
|
+
|
|
129
|
+
console.log(`\nDone! Now run:\n`);
|
|
130
|
+
console.log(` cd ${chalk.green(packageName)}`);
|
|
131
|
+
console.log(` npm install`);
|
|
132
|
+
console.log(` npm run dev`);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export const createCommand = new Command()
|
|
136
|
+
.command("create [name]")
|
|
137
|
+
.description(
|
|
138
|
+
"Create new UI Kit app using the provided baselines and templates",
|
|
139
|
+
)
|
|
140
|
+
.option("-w --without-app-shell", "Whether to not include AppShell.")
|
|
141
|
+
.option(
|
|
142
|
+
"--app-shell-features <appShellFeatures>",
|
|
143
|
+
"AppShell features to enable (comma separated).",
|
|
144
|
+
)
|
|
145
|
+
.option(
|
|
146
|
+
"--disable-file-based-routing",
|
|
147
|
+
"Disable AppShell options for file based routing and automatic menu generation.",
|
|
148
|
+
)
|
|
149
|
+
.option("-t --templates <templates>", "Templates to use (comma separated).")
|
|
150
|
+
.action(async (name, options) => {
|
|
151
|
+
const isInteractive = !name;
|
|
152
|
+
|
|
153
|
+
if (isInteractive) {
|
|
154
|
+
const results = await inquirer.prompt(questions);
|
|
155
|
+
create(results);
|
|
156
|
+
} else {
|
|
157
|
+
const {
|
|
158
|
+
withoutAppShell,
|
|
159
|
+
appShellFeatures,
|
|
160
|
+
disableFileBasedRouting,
|
|
161
|
+
templates,
|
|
162
|
+
} = options;
|
|
163
|
+
|
|
164
|
+
create({
|
|
165
|
+
name,
|
|
166
|
+
useAppShell: !withoutAppShell,
|
|
167
|
+
appShellFeatures: appShellFeatures?.split(",").map(toPascalCase),
|
|
168
|
+
appShellAutoMenu: !disableFileBasedRouting,
|
|
169
|
+
templates: templates?.split(",").map(toPascalCase),
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
});
|
package/src/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import fs from "fs-extra";
|
|
5
|
+
|
|
6
|
+
import { createCommand as create } from "./create.js";
|
|
7
|
+
import { __rootPath } from "./utils.js";
|
|
8
|
+
|
|
9
|
+
const pkg = JSON.parse(fs.readFileSync(`${__rootPath}/package.json`, "utf-8"));
|
|
10
|
+
|
|
11
|
+
const program = new Command(pkg.name)
|
|
12
|
+
// metadata
|
|
13
|
+
.description(pkg.description)
|
|
14
|
+
.version(pkg.version)
|
|
15
|
+
// commands
|
|
16
|
+
.addCommand(create);
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
program.parse(process.argv);
|
|
20
|
+
} catch (error) {
|
|
21
|
+
if (error) console.log(chalk.red(error));
|
|
22
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import nodePlop from "node-plop";
|
|
4
|
+
|
|
5
|
+
import { __dirname } from "./utils.js";
|
|
6
|
+
|
|
7
|
+
const plop = await nodePlop(`${__dirname}/plopfile.js`);
|
|
8
|
+
|
|
9
|
+
const createRoute = plop.getGenerator("createRoute");
|
|
10
|
+
|
|
11
|
+
export const createNavigationFiles = async (path) => {
|
|
12
|
+
const pages = fs.readdirSync(join(path, "src/pages"));
|
|
13
|
+
|
|
14
|
+
/* eslint-disable no-await-in-loop */
|
|
15
|
+
for (const page of pages) {
|
|
16
|
+
if (page === "NotFound") break;
|
|
17
|
+
|
|
18
|
+
// create routes file from plop template
|
|
19
|
+
await createRoute.runActions({ path, name: page });
|
|
20
|
+
}
|
|
21
|
+
};
|
package/src/package.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import fs from "fs-extra";
|
|
2
|
+
|
|
3
|
+
// utility function to order alphabetically an object's keys
|
|
4
|
+
const sortObjectKeys = (obj) => {
|
|
5
|
+
return Object.keys(obj)
|
|
6
|
+
.sort()
|
|
7
|
+
.reduce((result, key) => {
|
|
8
|
+
result[key] = obj[key];
|
|
9
|
+
return result;
|
|
10
|
+
}, {});
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const updatePackageJson = async (appPath, packageName, dependencies) => {
|
|
14
|
+
// replace package name
|
|
15
|
+
const pckgFile = `${appPath}/package.json`;
|
|
16
|
+
const pckgData = fs.readFileSync(pckgFile, { encoding: "utf-8" });
|
|
17
|
+
const pckgUpdated = pckgData.replace("uikit-app", packageName);
|
|
18
|
+
fs.writeFileSync(pckgFile, pckgUpdated);
|
|
19
|
+
|
|
20
|
+
// if there are any dependencies.dependencies or dependencies.devDependencies, append them to the package.json file
|
|
21
|
+
if (Object.keys(dependencies).length) {
|
|
22
|
+
const packageJsonPath = `${appPath}/package.json`;
|
|
23
|
+
const packageJson = fs.readJsonSync(packageJsonPath);
|
|
24
|
+
|
|
25
|
+
if (dependencies.dependencies != null) {
|
|
26
|
+
Object.assign(packageJson.dependencies, dependencies.dependencies);
|
|
27
|
+
packageJson.dependencies = sortObjectKeys(packageJson.dependencies);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (dependencies.devDependencies != null) {
|
|
31
|
+
Object.assign(packageJson.devDependencies, dependencies.devDependencies);
|
|
32
|
+
packageJson.devDependencies = sortObjectKeys(packageJson.devDependencies);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
fs.writeJsonSync(packageJsonPath, packageJson, { spaces: 2 });
|
|
36
|
+
}
|
|
37
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { HvAppShellConfig } from "@hitachivantara/app-shell-vite-plugin";
|
|
2
|
+
|
|
3
|
+
export default (): HvAppShellConfig => ({
|
|
4
|
+
name: "{{appName}}",
|
|
5
|
+
|
|
6
|
+
baseUrl: "/",
|
|
7
|
+
|
|
8
|
+
logo: {
|
|
9
|
+
name: "PENTAHO",
|
|
10
|
+
},
|
|
11
|
+
theming: {
|
|
12
|
+
theme: "pentaho",
|
|
13
|
+
colorMode: "light",
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
{{#if feats}}
|
|
17
|
+
header: {
|
|
18
|
+
actions: [
|
|
19
|
+
{{#each feats}}
|
|
20
|
+
{ bundle: "{{bundle}}"{{#if config}},
|
|
21
|
+
config: {{{config}}}
|
|
22
|
+
{{/if}}
|
|
23
|
+
}{{#unless @last}},{{/unless}}
|
|
24
|
+
{{/each}}
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
{{/if}}
|
|
28
|
+
|
|
29
|
+
mainPanel: {
|
|
30
|
+
maxWidth: "xl"{{#unless appShellAutoMenu}},
|
|
31
|
+
views: [
|
|
32
|
+
{{#each pages}}
|
|
33
|
+
{ bundle: "@self/{{pagesPath}}/{{name}}.js", route: "/{{kebabCase name}}" }{{#unless @last}},{{/unless}}
|
|
34
|
+
{{/each}}
|
|
35
|
+
]
|
|
36
|
+
{{/unless}}
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
{{#unless appShellAutoMenu}}
|
|
40
|
+
menu: [
|
|
41
|
+
{{#each pages}}
|
|
42
|
+
{ label: "key_{{name}}", target: "/{{kebabCase name}}" }{{#unless @last}},{{/unless}}
|
|
43
|
+
{{/each}}
|
|
44
|
+
],
|
|
45
|
+
|
|
46
|
+
translations: {
|
|
47
|
+
en: {
|
|
48
|
+
{{#each pages}}
|
|
49
|
+
key_{{name}}: "{{pageName}}"{{#unless @last}},{{/unless}}
|
|
50
|
+
{{/each}}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
{{/unless}}
|
|
54
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<html lang="en">
|
|
2
|
+
<head>
|
|
3
|
+
<meta charset="UTF-8" />
|
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
5
|
+
<title>{{appName}}</title>
|
|
6
|
+
<link
|
|
7
|
+
href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&family=Open+Sans:wght@400;600&display=swap"
|
|
8
|
+
rel="stylesheet"
|
|
9
|
+
/>
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<div id="hv-root"></div>
|
|
13
|
+
<script type="module" src="/virtual/main.tsx"></script>
|
|
14
|
+
</body>
|
|
15
|
+
</html>
|
package/src/plopfile.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const createRoute = {
|
|
2
|
+
actions: [
|
|
3
|
+
{
|
|
4
|
+
type: "append",
|
|
5
|
+
path: "{{path}}/src/routes.tsx",
|
|
6
|
+
pattern: "// APP ROUTES",
|
|
7
|
+
template: ` { path: "{{kebabCase name}}", lazy: () => import("./pages/{{name}}") },`,
|
|
8
|
+
},
|
|
9
|
+
],
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const createReadMe = {
|
|
13
|
+
actions: [
|
|
14
|
+
{
|
|
15
|
+
type: "add",
|
|
16
|
+
path: "{{path}}/README.md",
|
|
17
|
+
templateFile: "plop-templates/README.md.hbs",
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const createAppShellIndexHtml = {
|
|
23
|
+
actions: [
|
|
24
|
+
{
|
|
25
|
+
type: "add",
|
|
26
|
+
path: "{{path}}/index.html",
|
|
27
|
+
templateFile: "plop-templates/app-shell/index.html.hbs",
|
|
28
|
+
force: true,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const createAppShellConfig = {
|
|
34
|
+
actions: [
|
|
35
|
+
{
|
|
36
|
+
type: "add",
|
|
37
|
+
path: "{{path}}/app-shell.config.ts",
|
|
38
|
+
templateFile: "plop-templates/app-shell/app-shell.config.ts.hbs",
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const createAppShellAutoMenu = {
|
|
44
|
+
actions: [
|
|
45
|
+
{
|
|
46
|
+
type: "append",
|
|
47
|
+
path: "{{path}}/vite.config.ts",
|
|
48
|
+
pattern: "autoViewsAndRoutes: true,",
|
|
49
|
+
template: ` autoMenu: true,`,
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default (plop) => {
|
|
55
|
+
plop.setHelper("precurly", (t) => `${t}`);
|
|
56
|
+
plop.setGenerator("createRoute", createRoute);
|
|
57
|
+
plop.setGenerator("createReadMe", createReadMe);
|
|
58
|
+
plop.setGenerator("createAppShellIndexHtml", createAppShellIndexHtml);
|
|
59
|
+
plop.setGenerator("createAppShellConfig", createAppShellConfig);
|
|
60
|
+
plop.setGenerator("createAppShellAutoMenu", createAppShellAutoMenu);
|
|
61
|
+
};
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HvActionBar,
|
|
3
|
+
HvButton,
|
|
4
|
+
HvCard,
|
|
5
|
+
HvCardContent,
|
|
6
|
+
HvCardHeader,
|
|
7
|
+
HvCardMedia,
|
|
8
|
+
HvCheckBox,
|
|
9
|
+
HvSimpleGrid,
|
|
10
|
+
HvSkeleton,
|
|
11
|
+
HvTableInstance,
|
|
12
|
+
HvTypography,
|
|
13
|
+
} from "@hitachivantara/uikit-react-core";
|
|
14
|
+
|
|
15
|
+
import { AssetInventoryEntry, getStatusIcon } from "./data";
|
|
16
|
+
|
|
17
|
+
interface CardViewProps {
|
|
18
|
+
id?: string;
|
|
19
|
+
instance: HvTableInstance<AssetInventoryEntry, string>;
|
|
20
|
+
loading?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const CardView = ({ id, instance, loading }: CardViewProps) => {
|
|
24
|
+
const selectedCardsIds = instance.selectedFlatRows.map((r) => r.id);
|
|
25
|
+
const mode = "wave";
|
|
26
|
+
|
|
27
|
+
const items = loading
|
|
28
|
+
? Array.from({ length: 6 }).map((_, i) => ({
|
|
29
|
+
id: String(i),
|
|
30
|
+
name: "",
|
|
31
|
+
eventType: "",
|
|
32
|
+
severity: "",
|
|
33
|
+
status: "",
|
|
34
|
+
priority: "",
|
|
35
|
+
image: "",
|
|
36
|
+
statusColor: "",
|
|
37
|
+
}))
|
|
38
|
+
: instance.page.map((p) => ({ ...p.original, id: p.id }));
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<HvSimpleGrid
|
|
42
|
+
id={id}
|
|
43
|
+
breakpoints={[
|
|
44
|
+
{ minWidth: 1919, cols: 4, spacing: "md" },
|
|
45
|
+
{ minWidth: 960, cols: 3, spacing: "md" },
|
|
46
|
+
{ minWidth: 600, cols: 2, spacing: "sm" },
|
|
47
|
+
{ minWidth: 0, cols: 1, spacing: "sm" },
|
|
48
|
+
]}
|
|
49
|
+
>
|
|
50
|
+
{items.map((item) => {
|
|
51
|
+
const rowId = item?.id;
|
|
52
|
+
const statusColor = item?.statusColor;
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<HvCard
|
|
56
|
+
selectable
|
|
57
|
+
selected={rowId ? selectedCardsIds.includes(rowId) : undefined}
|
|
58
|
+
bgcolor="bgContainer"
|
|
59
|
+
key={item.id}
|
|
60
|
+
style={{ width: "100%" }}
|
|
61
|
+
statusColor={statusColor}
|
|
62
|
+
icon={
|
|
63
|
+
!loading ? (
|
|
64
|
+
getStatusIcon(statusColor)
|
|
65
|
+
) : (
|
|
66
|
+
<HvSkeleton
|
|
67
|
+
hidden={!loading}
|
|
68
|
+
variant="circle"
|
|
69
|
+
animation="wave"
|
|
70
|
+
width={32}
|
|
71
|
+
height={32}
|
|
72
|
+
/>
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
>
|
|
76
|
+
<HvCardHeader
|
|
77
|
+
title={
|
|
78
|
+
loading ? (
|
|
79
|
+
<HvSkeleton animation="wave" width="50%" />
|
|
80
|
+
) : (
|
|
81
|
+
item.name
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
/>
|
|
85
|
+
<div
|
|
86
|
+
style={{
|
|
87
|
+
display: "grid",
|
|
88
|
+
gridTemplateColumns: "1fr 1fr",
|
|
89
|
+
}}
|
|
90
|
+
>
|
|
91
|
+
<div>
|
|
92
|
+
<HvCardContent>
|
|
93
|
+
<HvTypography variant="label">Event</HvTypography>
|
|
94
|
+
<HvTypography noWrap component="div">
|
|
95
|
+
<HvSkeleton hidden={!loading} animation={mode}>
|
|
96
|
+
{item.eventType}
|
|
97
|
+
</HvSkeleton>
|
|
98
|
+
</HvTypography>
|
|
99
|
+
</HvCardContent>
|
|
100
|
+
<HvCardContent>
|
|
101
|
+
<HvTypography variant="label">Severity</HvTypography>
|
|
102
|
+
<HvTypography noWrap component="div">
|
|
103
|
+
<HvSkeleton hidden={!loading} animation={mode}>
|
|
104
|
+
{item.severity}
|
|
105
|
+
</HvSkeleton>
|
|
106
|
+
</HvTypography>
|
|
107
|
+
</HvCardContent>
|
|
108
|
+
</div>
|
|
109
|
+
<div>
|
|
110
|
+
<HvCardContent>
|
|
111
|
+
<HvTypography variant="label">Status</HvTypography>
|
|
112
|
+
<HvTypography noWrap component="div">
|
|
113
|
+
<HvSkeleton hidden={!loading} animation={mode}>
|
|
114
|
+
{item.status}{" "}
|
|
115
|
+
</HvSkeleton>
|
|
116
|
+
</HvTypography>
|
|
117
|
+
</HvCardContent>
|
|
118
|
+
<HvCardContent>
|
|
119
|
+
<HvTypography variant="label">Priority</HvTypography>
|
|
120
|
+
<HvTypography noWrap component="div">
|
|
121
|
+
<HvSkeleton hidden={!loading} animation={mode}>
|
|
122
|
+
{item.priority}{" "}
|
|
123
|
+
</HvSkeleton>
|
|
124
|
+
</HvTypography>
|
|
125
|
+
</HvCardContent>
|
|
126
|
+
</div>
|
|
127
|
+
</div>
|
|
128
|
+
<HvSkeleton
|
|
129
|
+
hidden={!loading}
|
|
130
|
+
width="auto"
|
|
131
|
+
variant="square"
|
|
132
|
+
animation={mode}
|
|
133
|
+
backgroundImage="https://storage.googleapis.com/proudcity/mebanenc/uploads/2021/03/placeholder-image.png"
|
|
134
|
+
>
|
|
135
|
+
<HvCardMedia
|
|
136
|
+
component="img"
|
|
137
|
+
alt={item.name}
|
|
138
|
+
height={140}
|
|
139
|
+
image={item.image}
|
|
140
|
+
/>
|
|
141
|
+
</HvSkeleton>
|
|
142
|
+
<HvActionBar>
|
|
143
|
+
<HvSkeleton hidden={!loading} variant="square" animation={mode}>
|
|
144
|
+
<HvCheckBox
|
|
145
|
+
onChange={
|
|
146
|
+
rowId
|
|
147
|
+
? () => instance.toggleRowSelected?.(rowId)
|
|
148
|
+
: undefined
|
|
149
|
+
}
|
|
150
|
+
checked={instance.selectedFlatRows.some(
|
|
151
|
+
(r) => r.id === rowId,
|
|
152
|
+
)}
|
|
153
|
+
value="value"
|
|
154
|
+
inputProps={{ "aria-label": "Tick to select the card" }}
|
|
155
|
+
/>
|
|
156
|
+
</HvSkeleton>
|
|
157
|
+
<div aria-hidden style={{ flex: 1 }} />
|
|
158
|
+
<HvSkeleton hidden={!loading} variant="square" animation={mode}>
|
|
159
|
+
<HvButton variant="secondaryGhost">View</HvButton>
|
|
160
|
+
</HvSkeleton>
|
|
161
|
+
</HvActionBar>
|
|
162
|
+
</HvCard>
|
|
163
|
+
);
|
|
164
|
+
})}
|
|
165
|
+
</HvSimpleGrid>
|
|
166
|
+
);
|
|
167
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HvTable,
|
|
3
|
+
HvTableBody,
|
|
4
|
+
HvTableCell,
|
|
5
|
+
HvTableColumnConfig,
|
|
6
|
+
HvTableContainer,
|
|
7
|
+
HvTableHead,
|
|
8
|
+
HvTableHeader,
|
|
9
|
+
HvTableInstance,
|
|
10
|
+
HvTableRow,
|
|
11
|
+
} from "@hitachivantara/uikit-react-core";
|
|
12
|
+
|
|
13
|
+
import { AssetInventoryEntry } from "./data";
|
|
14
|
+
|
|
15
|
+
interface ListViewProps {
|
|
16
|
+
id?: string;
|
|
17
|
+
columns: HvTableColumnConfig<AssetInventoryEntry, string>[];
|
|
18
|
+
instance: HvTableInstance<AssetInventoryEntry, string>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const ListView = ({ id, instance, columns }: ListViewProps) => {
|
|
22
|
+
return (
|
|
23
|
+
<HvTableContainer style={{ padding: "2px" }} id={id}>
|
|
24
|
+
<HvTable variant="listrow" {...instance.getTableProps()}>
|
|
25
|
+
<HvTableHead>
|
|
26
|
+
<HvTableRow>
|
|
27
|
+
<HvTableCell variant="listcheckbox" />
|
|
28
|
+
{columns.map((col) => (
|
|
29
|
+
<HvTableHeader key={col.Header}>{col.Header}</HvTableHeader>
|
|
30
|
+
))}
|
|
31
|
+
</HvTableRow>
|
|
32
|
+
</HvTableHead>
|
|
33
|
+
<HvTableBody withNavigation {...instance.getTableBodyProps()}>
|
|
34
|
+
{instance.page.map((row) => {
|
|
35
|
+
instance.prepareRow(row);
|
|
36
|
+
const { key, ...rowProps } = row.getRowProps();
|
|
37
|
+
return (
|
|
38
|
+
<HvTableRow key={key} {...rowProps}>
|
|
39
|
+
{row.cells.map((cell) => {
|
|
40
|
+
const { key: cellKey, ...cellProps } = cell.getCellProps();
|
|
41
|
+
return (
|
|
42
|
+
<HvTableCell key={cellKey} {...cellProps}>
|
|
43
|
+
{cell.render("Cell")}
|
|
44
|
+
</HvTableCell>
|
|
45
|
+
);
|
|
46
|
+
})}
|
|
47
|
+
</HvTableRow>
|
|
48
|
+
);
|
|
49
|
+
})}
|
|
50
|
+
</HvTableBody>
|
|
51
|
+
</HvTable>
|
|
52
|
+
</HvTableContainer>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default ListView;
|