-
Notifications
You must be signed in to change notification settings - Fork 1
Vir 1644 update formulaic ember js #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 11 commits
a67626f
f8c0ceb
5af179f
d675ae4
b632c68
ac5210a
0f1c7f6
fd7ba8a
2ff2f66
a43ac8f
2292cb8
ddc5de8
36bcd14
698da35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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"] |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this change necessary? |
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
| } | ||
| } |
| 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; | ||
|
|
||
| } |
There was a problem hiding this comment.
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.