2 Дмитриева, М. Самоучитель JavaScript [Текст]/ – СПб.: "БХВ-Петербург", 2012. – 506с.
3 Машнин, Т. Web-сервисы Java [Текст]/ – СПб.: "БХВ-Петербург", 2012. – 560 с.
4 Ханссон, Д. Х. Гибкая разработка веб-приложений в среде Rails [Текст]/ – СПб.: " Питер ", 2012. – 464 с.
5 Шелдон, Р. MySQL. Базовый курс [Текст]/ – М.: "Вильямс", 2007. – 880 с.
6 Камер, Д. Э. Сети TCP/IP. Разработка приложений типа клиент/сервер для Linux/POSIX [Текст]/ амер, тивенс. – М.: " Вильямс", 2002. – 592 с.
7 Козловский, П. Разработка веб-приложений с использованием AngularJS [Текст]/ – М.: " ДМК-Пресс", 2014. – 394 с.
8 Тейт, Б. Ruby on Rails. Быстрая веб-разработка [Текст]/ – СПб.: "БХВ-Петербург", 2008. – 224 с.
9 JS [Электронный ресурс]. — 2012. — Режим доступа: https://learn. javascript. ru/.- Загл. с экрана
10 AngularJS [Электронный ресурс]. — 2012. — Режим доступа: https://ru. wikipedia. org/wiki/AngularJS.- Загл. с экрана
Приложение А
Программный код
projects_controller. rb
class Api::ProjectsController < ApplicationController
before_action :set_project, only: [:show, :update, :destroy]
# GET /projects
# GET /projects. json
def index
@projects = Project. all
render json: @projects
end
# GET /projects/1
# GET /projects/1.json
def show
render json: @project
end
# POST /projects
# POST /projects. json
def create
@project = Project. new(project_params)
if @project. save
render json: @project, status: :created
else
render json: @project. errors, status: :unprocessable_entity
end
Продолжение приложения А
end
# PATCH/PUT /projects/1
# PATCH/PUT /projects/1.json
def update
@project = Project. find(params[:id])
if @project. update(project_params)
head :no_content
else
render json: @project. errors, status: :unprocessable_entity
end
end
# DELETE /projects/1
# DELETE /projects/1.json
def destroy
@project. destroy
head :no_content
end
private
def set_project
@project = Project. find(params[:id])
end
def project_params
Продолжение приложения А
params. permit(:name)
end
end
tags_controller. rb
class Api::TagsController < ApplicationController
before_action :set_tag, only: [:show, :update, :destroy]
# GET /tags
# GET /tags. json
def index
@tags = Tag. all
render json: @tags
end
# GET /tags/1
# GET /tags/1.json
def show
render json: @tag
end
# POST /tags
# POST /tags. json
def create
@tag = Tag. new(tag_params)
if @tag. save
render json: @tag, status: :created
Продолжение приложения А
else
render json: @tag. errors, status: :unprocessable_entity
end
end
# PATCH/PUT /tags/1
# PATCH/PUT /tags/1.json
def update
@tag = Tag. find(params[:id])
if @tag. update(tag_params)
head :no_content
else
render json: @tag. errors, status: :unprocessable_entity
end
end
# DELETE /tags/1
# DELETE /tags/1.json
def destroy
@tag. destroy
head :no_content
end
def findByName
tags = Tag. where("name like?", "%#{params[:query]}%")
render json: tags
end
Продолжение приложения А
private
def set_tag
@tag = Tag. find(params[:id])
end
def tag_params
params. permit(:name, :query)
end
end
tasks_controller. rb
class Api::TasksController < ApplicationController
before_action :set_project
before_action :set_task, only: [:show, :update, :destroy]
# GET /tasks
# GET /tasks. json
def index
@tasks = @project. tasks
render json: @tasks
end
# GET /tasks/1
# GET /tasks/1.json
def show
render json: @task
end
# POST /tasks
# POST /tasks. json
Продолжение приложения А
def create
@task = Task. new(task_params)
p task_params
p @task
if @task. save
#task_params[:tags].each do |el|
#@task. create_tag(tag_id: el)
#end
render json: @task, status: :created
else
render json: @task. errors, status: :unprocessable_entity
end
end
# PATCH/PUT /tasks/1
# PATCH/PUT /tasks/1.json
def update
if @task. update(task_params)
head :no_content
else
render json: @task. errors, status: :unprocessable_entity
end
end
# DELETE /tasks/1
# DELETE /tasks/1.json
def destroy
@task. destroy
Продолжение приложения А
head :no_content
end
private
def set_project
@project = Project. find params[:project_id]
end
def set_task
@task = Task. find(params[:id])
end
def task_params
params. permit(:name, :desc, :project_id, task_tags_attributes: [:tag_id])
end
end
routes. rb
Rails. application. routes. draw do
mount_devise_token_auth_for 'User', at: 'auth'
namespace :api do
resources :tags, except: [:new, :edit]
get "findTag/:query" => 'tags#findByName'
resources :projects do
resources :tasks, except: [:new, :edit]
end
end
# The priority is based upon order of creation: first created -> highest priority.
Продолжение приложения А
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welcome#index'
# Example of regular route:
# get 'products/:id' => 'catalog#view'
# Example of named route that can be invoked with purchase_url(id: product. id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Example resource route with sub-resources:
Продолжение приложения А
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end
# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable
# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller. rb)
# resources :products
# end
end
projectcreate. coffee
'use strict'
Продолжение приложения А
###*
# @ngdoc function
# @name bagtrackerFrontApp. controller:ProjectcreateCtrl
# @description
# # ProjectcreateCtrl
# Controller of the bagtrackerFrontApp
###
angular. module 'bagtrackerFrontApp'
.controller 'ProjectcreateCtrl', ( $scope, $http, $location )->
$scope. name = ''
$bmit = ->
$http. post( '/api/projects', {name: $scope. name} ).then ->
$location. path '#/projects'
project. coffee
'use strict'
###*
# @ngdoc function
# @name bagtrackerFrontApp. controller:ProjectsCtrl
# @description
# # ProjectsCtrl
# Controller of the bagtrackerFrontApp
###
angular. module 'bagtrackerFrontApp'
.controller 'ProjectsCtrl', ( $scope, $location, $http )->
$scope. projects = []
$http. get( 'api/projects' ).then ( data )->
$scope. projects = data. data
Продолжение приложения А
tags. coffee
'use strict'
###*
# @ngdoc function
# @name bagtrackerFrontApp. controller:TagsCtrl
# @description
# # TagsCtrl
# Controller of the bagtrackerFrontApp
###
angular. module 'bagtrackerFrontApp'
.controller 'TagsCtrl', ( $scope, $http )->
$scope. tags = []
$scope. tags = $http. get( '/api/tags' ).then ( data )->
$scope. tags = data. data
tagscreate. coffee
'use strict'
###*
# @ngdoc function
# @name bagtrackerFrontApp. controller:TagscreateCtrl
# @description
# # TagscreateCtrl
# Controller of the bagtrackerFrontApp
###
angular. module 'bagtrackerFrontApp'
.controller 'TagscreateCtrl', ( $scope, $http, $location )->
$scope. name = ''
Продолжение приложения А
$bmit = ->
$http. post( "/api/tags", {name: $scope. name}).then ->
$location. path '#/tags'
task. coffee
'use strict'
###*
# @ngdoc function
# @name bagtrackerFrontApp. controller:TaskCtrl
# @description
# # TaskCtrl
# Controller of the bagtrackerFrontApp
###
angular. module 'bagtrackerFrontApp'
.controller 'TaskCtrl', ( $scope, $http, $routeParams )->
$scope. project_id = $routeParams. project_id
$scope. name = ''
$scope. description = ''
$http. get("/api/projects/#{$routeParams. project_id}/tasks/#{$routeParams. id}").then ( data ) ->
[$scope. name, $scope. description] = [data. data. name, data. data. desc]
taskcreate. coffee
'use strict'
###*
# @ngdoc function
Продолжение приложения А
# @name bagtrackerFrontApp. controller:TaskcreateCtrl
# @description
# # TaskcreateCtrl
# Controller of the bagtrackerFrontApp
###
angular. module 'bagtrackerFrontApp'
.controller 'TaskcreateCtrl', ( $scope, $http, $location, $routeParams )->
$scope. name = ''
$scope. description = ''
$bmit = ->
$http. post( "/api/projects/#{$routeParams. id}/tasks",
name: $scope. name
desc: $scope. description
task_tags_attributes: $scope. tags. map (el) -> tag_id: el. id
).then ->
$location. path "#/projects/#{$routeParams. id}/tasks"
$scope. loadTags = (query) ->
$http. get "/api/findTag/#{query}"
tasks. coffee
'use strict'
###*
# @ngdoc function
# @name bagtrackerFrontApp. controller:TasksCtrl
# @description
# # TasksCtrl
# Controller of the bagtrackerFrontApp
###
angular. module 'bagtrackerFrontApp'
Продолжение приложения А
.controller 'TasksCtrl', ( $scope, $http, $routeParams, $location )->
$scope. tasks = []
$scope. project_id = $routeParams. id
$http. get("/api/projects/#{$routeParams. id}/tasks").then ( data )->
$scope. tasks = data. data
Приложение Б
Презентационный материал

Продолжение приложения Б


Продолжение приложения Б

Продолжение приложения Б
Продолжение приложения Б 
|
Из за большого объема этот материал размещен на нескольких страницах:
1 2 3 4 5 6 7 8 9 |


