Skip to content

Commit 818c08f

Browse files
author
Krit
committed
Merge commit '51e9c9ebcafcd29cbbde6a63fc5a1fe77f98664c'
2 parents 7e2ee21 + 51e9c9e commit 818c08f

25 files changed

+260
-76
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
## Parse Dashboard Changelog
22

3+
### 1.0.10
4+
5+
* Add the ability to specify icons for your app, thanks to [Natan Rolnik](https://github.com/natanrolnik)
6+
* Fix sending push with JSON data
7+
8+
### 1.0.9
9+
10+
* Add the ability to mount the dashboard express app on a custom mount path, thanks to [hpello](https://github.com/hpello) with bugfixes from [mamaso](https://github.com/mamaso)
11+
* Add ability to restrict certain users to certain apps, thanks to [Felipe Andrade](https://github.com/felipemobile)
12+
* Fix Dockerfile, thanks to [Kakashi Liu](https://github.com/kkc)
13+
* Display Parse Dashboard version, thanks to [Aayush Kapoor](https://github.com/xeoneux) and [gateway](https://github.com/gateway)
14+
* Add a refresh button to the data browser, thanks to [TylerBrock](https://github.com/TylerBrock)
15+
* Add logs viewer
16+
* Misc. performance improvements and bugfixes, thanks to [Pavel Ivanov](https://github.com/pivanov)
17+
318
### 1.0.8
419

520
* Allow Dashboard to be mounted as Express middleware, thanks to [Florent Vilmart](https://github.com/flovilmart)

Dockerfile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
FROM node:4.3.2
2-
ADD package.json /src/package.json
3-
RUN cd /src && npm install
4-
ADD . /src
1+
FROM node:4.4.2
52
WORKDIR /src
6-
ENTRYPOINT ["npm", "start", "--"]
3+
ADD . /src
4+
RUN cd /src \
5+
&& npm install \
6+
&& npm run build \
7+
&& npm cache clear \
8+
&& rm -rf ~/.npm \
9+
&& rm -rf /var/lib/apt/lists/*
10+
ENTRYPOINT ["npm", "run", "dashboard"]

Parse-Dashboard/app.js

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ module.exports = function(config, allowInsecureHTTP) {
3333

3434
// Serve the configuration.
3535
app.get('/parse-dashboard-config.json', function(req, res) {
36-
const response = {
36+
let response = {
3737
apps: config.apps,
3838
newFeaturesInLatestVersion: newFeaturesInLatestVersion,
3939
};
40+
4041
const users = config.users;
4142

4243
let auth = null;
@@ -61,18 +62,36 @@ module.exports = function(config, allowInsecureHTTP) {
6162
return res.send({ success: false, error: 'Configure a user to access Parse Dashboard remotely' });
6263
}
6364

65+
let appsUserHasAccess = null;
66+
6467
const successfulAuth =
6568
//they provided auth
6669
auth &&
6770
//there are configured users
6871
users &&
6972
//the provided auth matches one of the users
70-
users.find(user => {
71-
return user.user == auth.name &&
72-
user.pass == auth.pass
73+
users.find(user => {
74+
let isAuthorized = user.user == auth.name &&
75+
user.pass == auth.pass
76+
if (isAuthorized) {
77+
// User restricted apps
78+
appsUserHasAccess = user.apps
79+
}
80+
81+
return isAuthorized
7382
});
83+
7484
if (successfulAuth) {
75-
//They provided correct auth
85+
if(appsUserHasAccess) {
86+
// Restric access to apps defined in user dictionary
87+
// If they didn't supply any app id, user will access all apps
88+
response.apps = response.apps.filter(function (app) {
89+
return appsUserHasAccess.find(appUserHasAccess => {
90+
return app.appId == appUserHasAccess.appId
91+
})
92+
});
93+
}
94+
// They provided correct auth
7695
return res.json(response);
7796
}
7897

@@ -92,6 +111,14 @@ module.exports = function(config, allowInsecureHTTP) {
92111
res.send({ success: false, error: 'Something went wrong.' });
93112
});
94113

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+
95122
// For every other request, go to index.html. Let client-side handle the rest.
96123
app.get('/*', function(req, res) {
97124
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: 102 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
11
# Parse Dashboard
22

3+
[![Build Status](https://img.shields.io/travis/ParsePlatform/parse-dashboard/master.svg?style=flat)](https://travis-ci.org/ParsePlatform/parse-dashboard)
4+
[![npm version](https://img.shields.io/npm/v/parse-dashboard.svg?style=flat)](https://www.npmjs.com/package/parse-dashboard)
5+
36
Parse Dashboard is a standalone dashboard for managing your Parse apps. You can use it to manage your [Parse Server](https://github.com/ParsePlatform/parse-server) apps and your apps that are running on [Parse.com](https://Parse.com).
47

8+
* [Getting Started](#getting-started)
9+
* [Local Installation](#local-installation)
10+
* [Configuring Parse Dashboard](#configuring-parse-dashboard)
11+
* [Managing Multiple Apps](#managing-multiple-apps)
12+
* [Other Configuration Options](#other-configuration-options)
13+
* [Deploying Parse Dashboard](#deploying-parse-dashboard)
14+
* [Preparing for Deployment](#preparing-for-deployment)
15+
* [Security Considerations](#security-considerations)
16+
* [Configuring Basic Authentication](#configuring-basic-authentication)
17+
* [Separating App Access Based on User Identity](#separating-app-access-based-on-user-identity)
18+
* [Run with Docker](#run-with-docker)
19+
* [Contributing](#contributing)
20+
521
# Getting Started
622

7-
[Node.js](https://nodejs.org) version >= 4.3 is required to run the dashboard. You also need to be using Parse Server version 2.1.4 or higher. Install the dashboard from `npm`.
23+
[Node.js](https://nodejs.org) version >= 4.3 is required to run the dashboard. You also need to be using Parse Server version 2.1.4 or higher.
24+
25+
# Local Installation
26+
27+
Install the dashboard from `npm`.
828

929
```
1030
npm install -g parse-dashboard
@@ -16,11 +36,16 @@ You can launch the dashboard for an app with a single command by supplying an ap
1636
parse-dashboard --appId yourAppId --masterKey yourMasterKey --serverURL "https://example.com/parse" --appName optionalName
1737
```
1838

19-
You can then visit the dashboard in your browser at http://localhost:4040. You may set the host, port and mount path by supplying the `--host`, `--port` and `--mountPath` options to parse-dashboard. You can use anything you want as the app name, or leave it out in which case the app ID will be used.
39+
You may set the host, port and mount path by supplying the `--host`, `--port` and `--mountPath` options to parse-dashboard. You can use anything you want as the app name, or leave it out in which case the app ID will be used.
2040

21-
If you want to manage multiple apps from the same dashboard, you can start the dashboard with a config file. For example, you could put your info into a file called `parse-dashboard-config.json` and then start the dashboard using `parse-dashboard --config parse-dashboard-config.json`. The file should match the following format:
41+
After starting the dashboard, you can visit http://localhost:4040 in your browser:
2242

23-
```
43+
![Parse Dashboard](.github/dash-shot.png)
44+
45+
## Configuring Parse Dashboard
46+
You can also start the dashboard from the command line with a config file. To do this, create a new file called `parse-dashboard-config.json` inside your local Parse Dashboard directory hierarchy. The file should match the following format:
47+
48+
```json
2449
{
2550
"apps": [
2651
{
@@ -33,13 +58,19 @@ If you want to manage multiple apps from the same dashboard, you can start the d
3358
}
3459
```
3560

36-
You can also manage apps that on Parse.com from the same dashboard. In your config file, you will need to add the `restKey` and `javascriptKey` as well as the other paramaters, which you can find on `dashboard.parse.com`. Set the serverURL to `http://api.parse.com/1`:
61+
You can then start the dashboard using `parse-dashboard --config parse-dashboard-config.json`.
3762

38-
```
63+
## Managing Multiple Apps
64+
65+
Managing multiple apps from the same dashboard is also possible. Simply add additional entries into the `parse-dashboard-config.json` file's `"apps"` array.
66+
67+
You can manage self-hosted [Parse Server](https://github.com/ParsePlatform/parse-server) apps, *and* apps that are hosted on [Parse.com](http://parse.com/) from the same dashboard. In your config file, you will need to add the `restKey` and `javascriptKey` as well as the other paramaters, which you can find on `dashboard.parse.com`. Set the serverURL to `http://api.parse.com/1`:
68+
69+
```json
3970
{
4071
"apps": [
4172
{
42-
"serverURL": "https://api.parse.com/1",
73+
"serverURL": "https://api.parse.com/1", // Hosted on Parse.com
4374
"appId": "myAppId",
4475
"masterKey": "myMasterKey",
4576
"javascriptKey": "myJavascriptKey",
@@ -48,7 +79,7 @@ You can also manage apps that on Parse.com from the same dashboard. In your conf
4879
"production": true
4980
},
5081
{
51-
"serverURL": "http://localhost:1337/parse",
82+
"serverURL": "http://localhost:1337/parse", // Self-hosted Parse Server
5283
"appId": "myAppId",
5384
"masterKey": "myMasterKey",
5485
"appName": "My Parse Server App"
@@ -57,22 +88,48 @@ You can also manage apps that on Parse.com from the same dashboard. In your conf
5788
}
5889
```
5990

60-
![Parse Dashboard](.github/dash-shot.png)
91+
## App Icon Configuration
6192

62-
# Advanced Usage
93+
Parse Dashboard 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:
6394

64-
## Other options
95+
```json
96+
{
97+
"apps": [
98+
{
99+
"serverURL": "http://localhost:1337/parse",
100+
"appId": "myAppId",
101+
"masterKey": "myMasterKey",
102+
"appName": "My Parse Server App",
103+
"iconName": "MyAppIcon.png",
104+
}
105+
],
106+
"iconsFolder": "icons"
107+
}
108+
```
109+
110+
## Other Configuration Options
111+
112+
You can set `appNameForURL` in the config file for each app to control the url of your app within the dashboard. This can make it easier to use bookmarks or share links on your dashboard.
113+
114+
To change the app to production, simply set `production` to `true` in your config file. The default value is false if not specified.
65115

66-
You can set `appNameForURL` in the config file for each app to control the url of your app within the dashboard. This can make it easier to use bookmarks or share links on your dashboard. To change the app to production, simply set `production` to `true` in your config file. Defaults to false if not specified.
116+
# Deploying Parse Dashboard
67117

68-
## Deploying the dashboard
118+
## Preparing for Deployment
69119

70120
Make sure the server URLs for your apps can be accessed by your browser. If you are deploying the dashboard, then `localhost` urls will not work.
71121

72-
In order to securely deploy the dashboard without leaking your apps master key, you will need to use HTTPS and Basic Auth. You can do this by adding usernames and passwords for HTTP Basic Auth to your configuration file.
73-
```
122+
## Security Considerations
123+
In order to securely deploy the dashboard without leaking your apps master key, you will need to use HTTPS and Basic Authentication.
124+
125+
The deployed dashboard detects if you are using a secure connection. If you are deploying the dashboard behind a load balancer or proxy that does early SSL termination, then the app won't be able to detect that the connection is secure. In this case, you can start the dashboard with the `--allowInsecureHTTP=1` option. You will then be responsible for ensureing that your proxy or load balancer only allows HTTPS.
126+
127+
### Configuring Basic Authentication
128+
You can configure your dashboard for Basic Authentication by adding usernames and passwords your `parse-dashboard-config.json` configuration file:
129+
130+
```json
74131
{
75-
"apps": [...],
132+
"apps": [{"...": "..."}],
76133
"users": [
77134
{
78135
"user":"user1",
@@ -86,7 +143,33 @@ In order to securely deploy the dashboard without leaking your apps master key,
86143
}
87144
```
88145

89-
The deployed dashboard detects if you are using a secure connection. If you are deploying the dashboard behind a load balancer or proxy that does early SSL termination, then the app won't be able to detect that the connection is secure. In this case, you can start the dashboard with the `--allowInsecureHTTP=1` option. You will then be responsible for ensureing that your proxy or load balancer only allows HTTPS.
146+
### Separating App Access Based on User Identity
147+
If you have configured your dashboard to manage multiple applications, you can restrict the management of apps based on user identity.
148+
149+
To do so, update your `parse-dashboard-config.json` configuration file to match the following format:
150+
151+
```json
152+
{
153+
"apps": [{"...": "..."}],
154+
"users": [
155+
{
156+
"user":"user1",
157+
"pass":"pass1",
158+
"apps": [{"appId1": "myAppId1"}, {"appId2": "myAppId2"}]
159+
},
160+
{
161+
"user":"user2",
162+
"pass":"pass2",
163+
"apps": [{"appId1": "myAppId1"}]
164+
} ]
165+
}
166+
```
167+
The effect of such a configuration is as follows:
168+
169+
When `user1` logs in, he/she will be able to manage `appId1` and `appId2` from the dashboard.
170+
171+
When *`user2`* logs in, he/she will only be able to manage *`appId1`* from the dashboard.
172+
90173

91174
## Run with Docker
92175

@@ -110,8 +193,8 @@ In this example, we want to run the application in production mode at port 80 of
110193
docker run -d -p 80:8080 -v host/path/to/config.json:/src/Parse-Dashboard/parse-dashboard-config.json parse-dashboard --port 8080
111194
```
112195

113-
If you are not familiar with Docker, ``--port 8080`` with be passed in as argument to the entrypoint to form the full command ``npm start -- --port 8080``. The application will start at port 8080 inside the container and port ``8080`` will be mounted to port ``80`` on your host machine.
196+
If you are not familiar with Docker, ``--port 8080`` will be passed in as argument to the entrypoint to form the full command ``npm start -- --port 8080``. The application will start at port 8080 inside the container and port ``8080`` will be mounted to port ``80`` on your host machine.
114197

115-
## Contributing
198+
# Contributing
116199

117200
We really want Parse to be yours, to see it grow and thrive in the open source community. Please see the [Contributing to Parse Dashboard guide](CONTRIBUTING.md).

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
"parseDashboardFeatures": [
44
"Data Browser",
55
"Cloud Code Viewer",
6-
"Logs Viewer",
76
"Parse Config",
87
"API Console",
98
"Class Level Permissions Editor",
10-
"Send Push Notifications"
9+
"Send Push Notifications",
10+
"Logs Viewer"
1111
],
1212
"description": "The Parse Dashboard",
1313
"keywords": [
@@ -16,7 +16,7 @@
1616
],
1717
"homepage": "https://github.com/ParsePlatform/parse-dashboard",
1818
"bugs": "https://github.com/ParsePlatform/parse-dashboard/issues",
19-
"version": "1.0.8",
19+
"version": "1.0.10",
2020
"repository": {
2121
"type": "git",
2222
"url": "https://github.com/ParsePlatform/parse-dashboard"

src/components/Field/Field.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
&:last-of-type {
1919
border-bottom-width: 1px;
2020
}
21+
22+
> pre[class*="language-"] {
23+
border-radius: 5px;
24+
}
2125
}
2226

2327
.left {

src/components/LogView/LogViewEntry.react.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
* This source code is licensed under the license found in the LICENSE file in
66
* the root directory of this source tree.
77
*/
8-
import PropTypes from 'lib/PropTypes';
9-
import React from 'react';
10-
import styles from 'components/LogView/LogViewEntry.scss';
8+
import PropTypes from 'lib/PropTypes';
9+
import React from 'react';
10+
import styles from 'components/LogView/LogViewEntry.scss';
1111

1212
const TIMESTAMP_REGEX = [
1313
'([a-z])', // Any Single Word Character (Not Whitespace) 1
@@ -35,12 +35,16 @@ let getLogEntryInfo = (str) => {
3535
//example timestamp: 'I2015-09-30T00:36:45.522Z]'
3636
let getTimestampRegex = () => new RegExp(TIMESTAMP_REGEX,['i']);
3737

38-
let LogViewEntry = (props) => {
39-
let logEntryInfo = getLogEntryInfo(props.text || '');
38+
let LogViewEntry = ({
39+
text = '',
40+
timestamp,
41+
}) => {
42+
let logEntryInfo = getLogEntryInfo(text);
4043
let classes = [styles.entry, logEntryInfo.error ? styles.error: ''];
4144
return (
4245
<li className={classes.join(' ')}>
43-
<span className={styles.time}>{logEntryInfo.time} - </span>
46+
{/* handle the timestamp format used by both Parse Server and Parse.com */}
47+
<span className={styles.time}>{timestamp.iso || timestamp} - </span>
4448
<span className={styles.content}>{logEntryInfo.content}</span>
4549
</li>
4650
);

src/components/Modal/Modal.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@
5959
svg{
6060
position: relative;
6161
top: 50%;
62+
transform-origin: bottom center;
6263
@include transform(translateY(-50%));
64+
65+
use {
66+
transform: translateY(50%);
67+
}
6368
}
6469
}
6570

0 commit comments

Comments
 (0)