Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions Dockerfile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No change in this file, just removing a newline.

Original file line number Diff line number Diff line change
@@ -1,11 +1,40 @@
FROM python:3.9.0-alpine3.12
FROM python:3.9-slim

# Set environment variable to avoid buffering
ENV PYTHONUNBUFFERED 1

# Create and set the working directory
RUN mkdir /app
COPY . /app/
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app/

# Install Rust and other required dependencies
RUN apt-get update && \
apt-get install -y curl build-essential && \
curl https://sh.rustup.rs -sSf | sh -s -- -y && \
. $HOME/.cargo/env && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Install NVM
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

# Set up NVM environment variables and install Node.js
ENV NVM_DIR /root/.nvm
ENV NODE_VERSION 7.10.1
RUN . "$NVM_DIR/nvm.sh" && nvm install $NODE_VERSION && nvm use $NODE_VERSION && nvm alias default $NODE_VERSION

# Ensure Node.js and npm are available in the PATH
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH

# Install any needed packages specified in requirements.txt as well as uwsgi
RUN pip install -r requirements.txt
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt

# Make port 8000 available to the world outside this container
# Expose the application port
EXPOSE 8000

# Define the default command to run the application (you might need to adjust this based on your specific application)
CMD ["uwsgi", "--ini", "uwsgi.ini"]
2 changes: 1 addition & 1 deletion docker-compose.yml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this change necessary?

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
volumes:
- ./../postgres-data:/var/lib/postgresql/data
ports:
- "5432:5432"
- "5435:5432"
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
Expand Down
4 changes: 0 additions & 4 deletions formulaic/static/admin/formulaic/ember-formulaic/.bowerrc

This file was deleted.

1 change: 0 additions & 1 deletion formulaic/static/admin/formulaic/ember-formulaic/.nvmrc

This file was deleted.

24 changes: 0 additions & 24 deletions formulaic/static/admin/formulaic/ember-formulaic/.travis.yml

This file was deleted.

56 changes: 28 additions & 28 deletions formulaic/static/admin/formulaic/ember-formulaic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,51 @@ A short introduction of this app could easily go here.

You will need the following things properly installed on your computer.

* [Git](https://git-scm.com/)
* [nvm](https://github.com/creationix/nvm)
* [Node.js](https://nodejs.org/) (with NPM)
* [Bower](https://bower.io/)
* [Ember CLI](https://ember-cli.com/)
* [PhantomJS](http://phantomjs.org/) - TK: for testing
- [Git](https://git-scm.com/)
- [Node.js](https://nodejs.org/) (with npm)
- [Ember CLI](https://cli.emberjs.com/release/)
- [Google Chrome](https://google.com/chrome/)

## Installation

* `nvm use`
* `npm install`
* `bower install`
- `git clone <repository-url>` this repository
- `cd ember-formulaic`
- `ember g ember-cli-sass`
- `npm install`

## Running / Development

* `nvm use`
* `ember serve`
- `npm run start`
- Visit your app at [http://localhost:4200](http://localhost:4200).
- Visit your tests at [http://localhost:4200/tests](http://localhost:4200/tests).

### Code Generators

Make use of the many generators for code, try `ember help generate` for more details

### Running Tests - TK
### Running Tests

* `ember test`
* `ember test --server`
- `npm run test`
- `npm run test:ember -- --server`

### Building - TK: I generally don't differentiate the build created by `ember serve` from `ember build`
### Linting

* `ember build` (development)
* `ember build --environment production` (production)
- `npm run lint`
- `npm run lint:fix`

### Building

- `npm exec ember build` (development)
- `npm run build` (production)
Comment on lines +10 to +47
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate on these instructions? It's not actually too clear what I actually need to do to build the ember project?

We're modifying the dockerfile to install node, but then don't do anything else? Is the intention to be able to build the project inside of docker or not?

Can I have a more step by step guide to building the project?


### Deploying

Most JavaScript changes can be deployed without any special effort. The templates point
to `/dist/` already. However, if you make a configuration change
(e.g. `config/environment.js`) or anything else that requires a new commit of
`app/index.html`, you may need to update the Django template
(`<formulaic-dir>/templates/admin/formulaic/form/index.html`) with the change.
Specify what it takes to deploy your app.

## Further Reading / Useful Links

* [GEMG Wiki Entry on Dep Management](https://github.com/Govexec/ge-govexec/wiki/JavaScript-Dependency-Management)
* [ember.js](http://emberjs.com/)
* [ember-cli](https://ember-cli.com/)
* Development Browser Extensions
* [ember inspector for chrome](https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi)
* [ember inspector for firefox](https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/)
- [ember.js](https://emberjs.com/)
- [ember-cli](https://cli.emberjs.com/release/)
- Development Browser Extensions
- [ember inspector for chrome](https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi)
- [ember inspector for firefox](https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/)
Original file line number Diff line number Diff line change
@@ -1,30 +1,49 @@
import Ember from 'ember';
import DRFAdapter from './drf';

export default DRFAdapter.extend({
buildURL: function(type, id, snapshot, requestType) {
/**
* Overriding `buildURL` to keep data fresh. Without this,
* I was getting old data on refresh.
*/

var url = this._super(type, id, snapshot, requestType);

// TODO: replace this with a global constant that gets changed every time cache should be invalidated?
var cacheBreaker = 'cacheBreaker=' + Math.round(new Date().getTime() / 1000);
cacheBreaker = ((url.indexOf('?') > -1) ? '&' : '?') + cacheBreaker;

return url + cacheBreaker;
},

headers: Ember.computed(function() {
/**
* Adding CSRF header to protect against cross-domain
* forgery attacks.
*/

return {
"X-CSRFToken": this.cookie.getCookie('csrftoken')
};
}).volatile()
});
import RESTAdapter from '@ember-data/adapter/rest';


export default class ApplicationAdapter extends RESTAdapter {

get host() {

return "";
}

get namespace() {
return "formulaic/api";
}

buildURL(modelName, id, snapshot, requestType, query) {
let url = super.buildURL(...arguments);

// Add cache breaker (if needed)
let cacheBreaker = 'cacheBreaker=' + Math.round(new Date().getTime() / 1000);
cacheBreaker = ((url.indexOf('?') > -1) ? '&' : '?') + cacheBreaker;

return url + "/" + cacheBreaker;
}

get headers() {
let csrfToken = this.getCsrfTokenFromCookies();
return {
'X-CSRFToken': csrfToken,
'Accept': 'application/json, text/javascript, */*; q=0.01',
};
}

getCsrfTokenFromCookies() {
let csrfToken = null;
const cookies = document.cookie.split(';');
for (let cookie of cookies) {
const [name, value] = cookie.trim().split('=');
if (name === 'csrftoken') {
csrfToken = value;
break;
}
}
return csrfToken;
}

handleResponse(status, headers, payload, requestData) {
return super.handleResponse(status, headers, payload, requestData);
}
}
22 changes: 8 additions & 14 deletions formulaic/static/admin/formulaic/ember-formulaic/app/app.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import Ember from 'ember';
import Application from '@ember/application';
import Resolver from './resolver';
import loadInitializers from 'ember-load-initializers';
import config from './config/environment';
import config from 'ember-formulaic/config/environment';

let App;

Ember.MODEL_FACTORY_INJECTIONS = true;

App = Ember.Application.extend({
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix,
rootElement: "#formulaic-container",
Resolver
});
export default class App extends Application {
modulePrefix = config.modulePrefix;
podModulePrefix = config.podModulePrefix;
rootElement= "#formulaic-container";
Resolver = Resolver;
}

loadInitializers(App, config.modulePrefix);

export default App;
Original file line number Diff line number Diff line change
@@ -1,43 +1,13 @@
import Ember from 'ember';

export default Ember.Component.extend({
templateName: 'sortable',
sortableSelector: '.sortable',

didInsertElement: function() {
let thisView = this;

this.sortable = this.$(this.sortableSelector).sortable({
update: function() {
thisView.updateSortable(this);
},
containment: 'parent',
tolerance: 'pointer',
cursor: 'move'
});

// Listen to controller
// this.get('controller').on('orderInvalidated', this, this.updateSortable);
},
updateSortable: function() {
let $ = Ember.$;

this.sortable.find('.item').each(function(index) {
let positionElement = $(this).find('.position');
positionElement.val(index);
positionElement.trigger('change');
});

this.sortable.sortable("refresh");
},
willDestroy: function() {
// Un-register listener
// this.get('controller').off('orderInvalidated', this, this.updateSortable);
},
actions: {
triggerUpdateSortable: function() {
this.updateSortable();
}
}
});

// components/base-sortable.js
import Component from '@glimmer/component';
import { action } from '@ember/object';

export default class BaseSortableComponent extends Component {
@action
updateSortable(sortedItems) {
sortedItems.forEach((item, index) => {
item.position = index;
item.save(); // or dispatch a change event if needed
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//components/form.js

import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';

export default class FormComponent extends Component {
@tracked isEditing = false;

}
Loading