Skip to content

Commit 51b6c08

Browse files
natanrolnikdrew-gross
authored andcommitted
Allows showing app icons (#274)
1 parent 4b2d12c commit 51b6c08

File tree

6 files changed

+39
-3
lines changed

6 files changed

+39
-3
lines changed

Parse-Dashboard/app.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ module.exports = function(config, allowInsecureHTTP) {
3737
apps: config.apps,
3838
newFeaturesInLatestVersion: newFeaturesInLatestVersion,
3939
};
40+
4041
const users = config.users;
4142

4243
let auth = null;
@@ -110,6 +111,14 @@ module.exports = function(config, allowInsecureHTTP) {
110111
res.send({ success: false, error: 'Something went wrong.' });
111112
});
112113

114+
// Serve the app icons. Uses the optional `iconsFolder` parameter as
115+
// directory name, that was setup in the config file.
116+
// We are explicitly not using `__dirpath` here because one may be
117+
// running parse-dashboard from globally installed npm.
118+
if (config.iconsFolder) {
119+
app.use('/appicons', express.static(config.iconsFolder));
120+
}
121+
113122
// For every other request, go to index.html. Let client-side handle the rest.
114123
app.get('/*', function(req, res) {
115124
let mountPath = getMount(req);

Parse-Dashboard/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ if (!program.config && !process.env.PARSE_DASHBOARD_CONFIG) {
7777
}
7878

7979
let p = null;
80+
let configFilePath = null;
8081
if (configFile) {
8182
p = jsonFile(configFile);
83+
configFilePath = path.dirname(configFile);
8284
} else if (configFromCLI) {
8385
p = Promise.resolve(configFromCLI);
8486
} else {
@@ -93,6 +95,10 @@ p.then(config => {
9395
}
9496
});
9597

98+
if (config.data.iconsFolder && configFilePath) {
99+
config.data.iconsFolder = path.join(configFilePath, config.data.iconsFolder);
100+
}
101+
96102
const app = express();
97103

98104
app.use(mountPath, parseDashboard(config.data, allowInsecureHTTP));

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,23 @@ You can also manage apps that on Parse.com from the same dashboard. In your conf
6060
}
6161
```
6262

63+
Parse Dashboard also supports adding an optional icon for each app, so you can identify them easier in the list. To do so, you *must* use the configuration file, define an `iconsFolder` in it, and define the `iconName` parameter for each app (including the extension). The path of the `iconsFolder` is relative to the configuration file. To visualize what it means, in the following example `icons` is a directory located under the same directory as the configuration file:
64+
65+
```
66+
{
67+
"apps": [
68+
{
69+
"serverURL": "http://localhost:1337/parse",
70+
"appId": "myAppId",
71+
"masterKey": "myMasterKey",
72+
"appName": "My Parse Server App",
73+
"iconName": "MyAppIcon.png",
74+
}
75+
],
76+
"iconsFolder": "icons"
77+
}
78+
```
79+
6380
![Parse Dashboard](.github/dash-shot.png)
6481

6582
# Advanced Usage

src/dashboard/Apps/AppsIndex.react.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ let AppCard = ({
7676
</div>;
7777

7878
return <li onClick={canBrowse}>
79-
{icon ? <a className={styles.icon}><img src={icon} /></a> : null}
79+
<a className={styles.icon}>
80+
{icon ? <img src={'appicons/' + icon} width={56} height={56}/> : <Icon width={56} height={56} name='blank-app-outline' fill='#1E384D' />}
81+
</a>
8082
<div className={styles.details}>
8183
<a className={styles.appname}>{app.name}</a>
8284
{versionMessage}
@@ -156,7 +158,7 @@ export default class AppsIndex extends React.Component {
156158
<ul className={styles.apps}>
157159
{apps.map(app =>
158160
app.name.toLowerCase().indexOf(search) > -1 ?
159-
<AppCard key={app.slug} app={app} /> :
161+
<AppCard key={app.slug} app={app} icon={app.icon ? app.icon : null}/> :
160162
null
161163
)}
162164
</ul>

src/dashboard/Apps/AppsIndex.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
height: 56px;
125125
margin-top: 9px;
126126
margin-right: 15px;
127-
border-radius: 5px;
127+
border-radius: 10px;
128128
overflow: hidden;
129129
}
130130

src/lib/ParseApp.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export default class ParseApp {
3838
serverURL,
3939
serverInfo,
4040
production,
41+
iconName,
4142
...params,
4243
}) {
4344
this.name = appName;
@@ -58,6 +59,7 @@ export default class ParseApp {
5859
this.production = production;
5960
this.serverURL = serverURL;
6061
this.serverInfo = serverInfo;
62+
this.icon = iconName;
6163

6264
this.settings = {
6365
fields: {},

0 commit comments

Comments
 (0)