Skip to content

Commit fdf543c

Browse files
authored
Merge pull request plotly#166 from plotly/dash-salesforce-crm
Dash salesforce crm
2 parents e01379a + d6b33bb commit fdf543c

File tree

18 files changed

+2797
-0
lines changed

18 files changed

+2797
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
venv/
2+
.env
3+
__pycache__/
4+
apps/__pycache__/
5+
*.DS_Store
6+
.vscode
7+
secrets.sh

apps/dash-salesforce-crm/Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: gunicorn --pythonpath apps/dash-salesforce-crm index:server

apps/dash-salesforce-crm/README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Dash Salesforce CRM
2+
3+
This is a demo of the Dash interactive Python framework developed by [Plotly](https://plot.ly/).
4+
5+
Dash abstracts away all of the technologies and protocols required to build an interactive web-based application and is a simple and effective way to bind a user interface around your Python code.
6+
7+
To learn more check out our [documentation](https://plot.ly/dash).
8+
9+
## Getting Started
10+
11+
### Running the app locally
12+
13+
First create a virtual environment with conda or venv inside a temp folder, then activate it.
14+
15+
```
16+
virtualenv venv
17+
18+
# Windows
19+
venv\Scripts\activate
20+
# Or Linux
21+
source venv/bin/activate
22+
23+
```
24+
25+
Clone the git repo, then install the requirements with pip
26+
27+
```
28+
29+
git clone https://github.com/plotly/dash-sample-apps
30+
cd dash-sample-apps/apps/dash-salesforce-crm
31+
pip install -r requirements.txt
32+
33+
```
34+
35+
To run the app, please create a SalesForce developer account (link is in the `About the App` section). There is an example of how the bash script should look like in the `secrets.example.sh` file. Be sure to create a new file named `secrets.sh` file and put your credentials in the file. Therefore, your credentials will not get pushed to github as the `secrets.sh` file is in the `.gitignore`.
36+
37+
Run the app
38+
39+
```
40+
source secrets.sh
41+
python index.py
42+
43+
```
44+
45+
## About the App
46+
47+
This app uses Salesforce API in order to implement a custom CRM dashboard. The API is used via the module [Simple-Salesforce](https://pypi.org/project/simple-salesforce/). Create a free SalesForce developer trial account: [https://developer.salesforce.com/signup](https://developer.salesforce.com/signup) to utilize this API and run the app.
48+
49+
## Built With
50+
51+
- [Dash](https://dash.plot.ly/) - Main server and interactive components
52+
- [Plotly Python](https://plot.ly/python/) - Used to create the interactive plots
53+
54+
## Screenshots
55+
56+
The following are screenshots for the app in this repo:
57+
58+
![Screenshot1](screenshots/opportunities_screenshot.png)
59+
60+
![Screenshot1](screenshots/leads_screenshot.png)
61+
62+
![Screenshot1](screenshots/cases_screenshot.png)
63+
64+
![Animated](screenshots/dash-salesforce-demo.gif)

apps/dash-salesforce-crm/app.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import math
2+
import dash
3+
import dash_html_components as html
4+
5+
from sfManager import sf_Manager
6+
7+
app = dash.Dash(
8+
__name__, meta_tags=[{"name": "viewport", "content": "width=device-width"}]
9+
)
10+
11+
app.config.suppress_callback_exceptions = True
12+
13+
sf_manager = sf_Manager()
14+
15+
millnames = ["", " K", " M", " B", " T"] # used to convert numbers
16+
17+
18+
# return html Table with dataframe values
19+
def df_to_table(df):
20+
return html.Table(
21+
[html.Tr([html.Th(col) for col in df.columns])]
22+
+ [
23+
html.Tr([html.Td(df.iloc[i][col]) for col in df.columns])
24+
for i in range(len(df))
25+
]
26+
)
27+
28+
29+
# returns most significant part of a number
30+
def millify(n):
31+
n = float(n)
32+
millidx = max(
33+
0,
34+
min(
35+
len(millnames) - 1, int(math.floor(0 if n == 0 else math.log10(abs(n)) / 3))
36+
),
37+
)
38+
39+
return "{:.0f}{}".format(n / 10 ** (3 * millidx), millnames[millidx])
40+
41+
42+
# returns top indicator div
43+
def indicator(color, text, id_value):
44+
return html.Div(
45+
[
46+
html.P(id=id_value, className="indicator_value"),
47+
html.P(text, className="twelve columns indicator_text"),
48+
],
49+
className="four columns indicator pretty_container",
50+
)
9.67 KB
Loading

0 commit comments

Comments
 (0)