Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Письменов Дмитрий Иванович
/
yourroomads
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit c78151bc
authored
May 14, 2021
by
Vladislav
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://gitlab.veeble.ru/pismenov/yourroomads
2 parents
58833cb1
4125404e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
14 deletions
app/Console/Commands/FirstLoadCampaigns.php
app/Http/Controllers/TokensController.php
resources/js/Pages/Tokens/CitySettings.vue
resources/js/Pages/Tokens/Edit.vue
routes/web.php
app/Console/Commands/FirstLoadCampaigns.php
View file @
c78151b
...
@@ -52,8 +52,7 @@ class FirstLoadCampaigns extends Command
...
@@ -52,8 +52,7 @@ class FirstLoadCampaigns extends Command
$factory
=
APIRequest
::
getInstance
(
API
::
YANDEX
);
$factory
=
APIRequest
::
getInstance
(
API
::
YANDEX
);
$factory
->
setToken
(
$token
);
$factory
->
setToken
(
$token
);
$factory
->
getRequest
(
'change'
,
'CheckDictionaries'
)
$factory
->
getRequest
(
'change'
,
'CheckDictionaries'
)
->
call
();
->
call
();
$factory
->
getRequest
(
'campaigns'
,
'get'
)
->
call
();
$factory
->
getRequest
(
'campaigns'
,
'get'
)
->
call
();
return
0
;
return
0
;
...
...
app/Http/Controllers/TokensController.php
View file @
c78151b
...
@@ -35,7 +35,7 @@ class TokensController extends Controller
...
@@ -35,7 +35,7 @@ class TokensController extends Controller
}
}
function
edit
(
Tokens
$token
){
function
edit
(
Tokens
$token
){
$mainToken
=
Tokens
::
where
(
'type'
,
Tokens
::
MAIN
)
->
get
();
$mainToken
=
Tokens
::
where
(
'type'
,
Tokens
::
MAIN
)
->
get
()
->
first
()
;
return
Inertia
::
render
(
'Tokens/Edit'
,
[
return
Inertia
::
render
(
'Tokens/Edit'
,
[
'token'
=>
[
'token'
=>
[
'id'
=>
$token
->
id
,
'id'
=>
$token
->
id
,
...
@@ -43,16 +43,18 @@ class TokensController extends Controller
...
@@ -43,16 +43,18 @@ class TokensController extends Controller
'api'
=>
$token
->
api
,
'api'
=>
$token
->
api
,
'token'
=>
$token
->
token
,
'token'
=>
$token
->
token
,
'type'
=>
$token
->
type
,
'type'
=>
$token
->
type
,
'main'
=>
$token
->
type
==
Tokens
::
MAIN
,
'campaigns'
=>
(
'campaigns'
=>
(
$token
->
type
===
Tokens
::
MAIN
$token
->
type
===
Tokens
::
MAIN
?
$token
->
campaignsForManaged
?
$token
->
campaignsForManaged
:
[]
:
[]
),
),
'cities'
=>
(
$token
->
type
==
Tokens
::
GOAL
?
$token
->
cities
:
null
),
'cities'
=>
(
$token
->
type
==
Tokens
::
GOAL
?
$token
->
cities
:
[]
),
],
],
'cities'
=>
Dictionary
::
where
(
'type'
,
Dictionary
::
CITY
)
->
get
(),
'cities'
=>
Dictionary
::
where
(
'type'
,
Dictionary
::
CITY
)
->
get
(),
'campaigns'
=>
$token
->
campaigns
,
'campaigns'
=>
$token
->
campaigns
,
'types'
=>
$mainToken
->
count
()
&&
$token
->
type
!=
Tokens
::
MAIN
'main_token_campaigns'
=>
$mainToken
->
campaignsForManaged
,
'types'
=>
$mainToken
&&
$token
->
type
!=
Tokens
::
MAIN
?
[
Tokens
::
GOAL
=>
'Целевой аккаунт'
]
:
?
[
Tokens
::
GOAL
=>
'Целевой аккаунт'
]
:
[
Tokens
::
MAIN
=>
'Основной аккаунт'
,
Tokens
::
GOAL
=>
'Целевой аккаунт'
],
[
Tokens
::
MAIN
=>
'Основной аккаунт'
,
Tokens
::
GOAL
=>
'Целевой аккаунт'
],
]);
]);
...
@@ -125,6 +127,9 @@ class TokensController extends Controller
...
@@ -125,6 +127,9 @@ class TokensController extends Controller
public
function
addCity
(
Tokens
$token
)
public
function
addCity
(
Tokens
$token
)
{
{
$token
;
$city
=
Dictionary
::
findOrFail
(
Request
::
input
(
'city'
));
$token
->
cities
()
->
save
(
$city
);
return
Redirect
::
route
(
'token.edit'
,
$token
->
id
)
->
with
(
'success'
,
'City added.'
);
}
}
}
}
resources/js/Pages/Tokens/CitySettings.vue
View file @
c78151b
...
@@ -24,14 +24,45 @@
...
@@ -24,14 +24,45 @@
<div
class=
"mt-6 bg-white rounded shadow"
>
<div
class=
"mt-6 bg-white rounded shadow"
>
<table
class=
"w-full whitespace-nowrap"
>
<table
class=
"w-full whitespace-nowrap"
>
<tr
class=
"text-left font-bold"
>
<tr
class=
"text-left font-bold"
>
<th
class=
"px-6 pt-6 pb-4"
>
Name
</th>
<th
class=
"px-6 pt-6 pb-4"
colspan=
"2"
>
Name
</th>
<th
class=
"px-6 pt-6 pb-4"
>
Обновлять?
</th>
<th
class=
"px-6 pt-6 pb-4"
></th>
</tr>
</tr>
<t
r
v-for=
"city in cities"
:key=
"city.id"
<t
emplate
v-for=
"city in cities"
>
class=
"hover:bg-gray-100 focus-within:bg-gray-100"
>
<tr
:key=
"city.id"
class=
"hover:bg-gray-100 focus-within:bg-gray-100"
>
<td
class=
"border-t"
>
<td
colspan=
"2"
class=
"border-t"
>
<span
class=
"px-6 py-4 flex items-center focus:text-indigo-500"
>
{{
city
.
name
}}
</span>
<span
class=
"px-6 py-4 flex items-center focus:text-indigo-500"
>
{{
city
.
name
}}
</span>
</td>
</td>
<td
class=
"border-t"
>
<input
:checked=
"city.update"
@
change=
""
type=
"checkbox"
>
</td>
<td>
<inertia-link
class=
"px-4 flex items-center"
:href=
"route('token.city.delete', city.id)"
tabindex=
"-1"
>
<icon
name=
"trash"
class=
"block w-6 h-6 fill-gray-400"
/>
</inertia-link>
</td>
</tr>
</tr>
<tr>
<th
class=
"px-6 pt-6 pb-4"
></th>
<th
class=
"px-6 pt-6 pb-4"
>
Кампания
</th>
<th
class=
"px-6 pt-6 pb-4"
>
Синхронизировать?
</th>
<th></th>
</tr>
<tr
v-for=
"camp in main_token_campaigns"
>
<td
class=
"border-t"
></td>
<td
class=
"border-t"
><span
class=
"px-6 py-4 flex items-center focus:text-indigo-500"
>
{{
camp
.
name
}}
</span></td>
<td
class=
"border-t"
>
<input
:checked=
"camp.update"
@
change=
""
type=
"checkbox"
>
</td>
<td></td>
</tr>
</
template
>
<tr
v-if=
"cities.length === 0"
>
<tr
v-if=
"cities.length === 0"
>
<td
class=
"border-t px-6 py-4"
colspan=
"4"
>
No City found.
</td>
<td
class=
"border-t px-6 py-4"
colspan=
"4"
>
No City found.
</td>
</tr>
</tr>
...
@@ -43,11 +74,13 @@
...
@@ -43,11 +74,13 @@
<
script
>
<
script
>
import
SelectInput
from
"../../Shared/SelectInput"
;
import
SelectInput
from
"../../Shared/SelectInput"
;
import
Icon
from
"../../Shared/Icon"
;
export
default
{
export
default
{
components
:
{
SelectInput
},
components
:
{
Icon
,
SelectInput
},
props
:
{
props
:
{
cities
:
Array
,
cities
:
Array
,
all_cities
:
Array
,
all_cities
:
Array
,
main_token_campaigns
:
Array
,
},
},
data
()
{
data
()
{
return
{
return
{
...
...
resources/js/Pages/Tokens/Edit.vue
View file @
c78151b
...
@@ -36,7 +36,7 @@
...
@@ -36,7 +36,7 @@
</div>
</div>
</form>
</form>
</div>
</div>
<div
v-if=
"campaigns.length
|| token.campaigns.length
"
>
<div
v-if=
"campaigns.length
&& token.main
"
>
<h2
class=
"mt-12 font-bold text-2xl"
>
Campaigns
</h2>
<h2
class=
"mt-12 font-bold text-2xl"
>
Campaigns
</h2>
<div
class=
"mt-4 flex flex-wrap"
>
<div
class=
"mt-4 flex flex-wrap"
>
<form
v-if=
"campaigns.length"
@
submit
.
prevent=
"campaignAdd"
class=
"flex flex-wrap"
>
<form
v-if=
"campaigns.length"
@
submit
.
prevent=
"campaignAdd"
class=
"flex flex-wrap"
>
...
@@ -93,7 +93,12 @@
...
@@ -93,7 +93,12 @@
</div>
</div>
</div>
</div>
<city-settings
:cities=
"state.cities"
:all_cities=
"cities"
v-on:add=
"addCity"
></city-settings>
<city-settings
v-if=
"!token.main"
:cities=
"state.cities"
:all_cities=
"cities"
:main_token_campaigns=
"main_token_campaigns"
v-on:add=
"addCity"
></city-settings>
</div>
</div>
</
template
>
</
template
>
...
@@ -124,6 +129,7 @@ export default {
...
@@ -124,6 +129,7 @@ export default {
token
:
Object
,
token
:
Object
,
types
:
Object
,
types
:
Object
,
cities
:
Array
,
cities
:
Array
,
main_token_campaigns
:
Array
,
},
},
remember
:
'form'
,
remember
:
'form'
,
data
()
{
data
()
{
...
@@ -157,7 +163,7 @@ export default {
...
@@ -157,7 +163,7 @@ export default {
this
.
state
.
cities
.
push
(
found
)
this
.
state
.
cities
.
push
(
found
)
this
.
$inertia
.
form
({
this
.
$inertia
.
form
({
city
:
id
city
:
id
}).
post
(
this
.
route
(
'token.city.add'
),
this
.
token
.
id
)
}).
post
(
this
.
route
(
'token.city.add'
,
this
.
token
.
id
)
)
},
},
tokenUpdate
()
{
tokenUpdate
()
{
this
.
form
.
post
(
this
.
route
(
'token.update'
,
this
.
token
.
id
))
this
.
form
.
post
(
this
.
route
(
'token.update'
,
this
.
token
.
id
))
...
...
routes/web.php
View file @
c78151b
...
@@ -178,6 +178,9 @@ Route::post('token/campaigns/enabled/{token}/{campaign_id}/{enabled}', [TokensCo
...
@@ -178,6 +178,9 @@ Route::post('token/campaigns/enabled/{token}/{campaign_id}/{enabled}', [TokensCo
Route
::
post
(
'token/city/add/{token}'
,
[
TokensController
::
class
,
'addCity'
])
Route
::
post
(
'token/city/add/{token}'
,
[
TokensController
::
class
,
'addCity'
])
->
name
(
'token.city.add'
)
->
name
(
'token.city.add'
)
->
middleware
(
'auth'
);
->
middleware
(
'auth'
);
Route
::
post
(
'token/city/delete/{city}'
,
[
TokensController
::
class
,
'removeCity'
])
->
name
(
'token.city.delete'
)
->
middleware
(
'auth'
);
Route
::
delete
(
'token/delete/{token}'
,
[
TokensController
::
class
,
'destroy'
])
Route
::
delete
(
'token/delete/{token}'
,
[
TokensController
::
class
,
'destroy'
])
->
name
(
'token.destroy'
)
->
name
(
'token.destroy'
)
->
middleware
(
'auth'
);
->
middleware
(
'auth'
);
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment