From a61f5333a92f84ff0b8777515674d5dcf247b36a Mon Sep 17 00:00:00 2001 From: Sveta Fo Date: Fri, 14 Feb 2020 15:44:33 +0300 Subject: [PATCH 1/2] design --- app.js | 18 ++++++------ model/itemModel.js | 4 ++- seed/seed.js | 70 ++++++++++++++++++++++++++++++++++++++++------ views/index.hbs | 55 ++++++++++-------------------------- views/layout.hbs | 4 +-- views/second.hbs | 18 ++++++++++++ 6 files changed, 108 insertions(+), 61 deletions(-) create mode 100644 views/second.hbs diff --git a/app.js b/app.js index 0f34eb0..a9bde9e 100644 --- a/app.js +++ b/app.js @@ -34,7 +34,7 @@ app.get("/test", (req, res) => { app.get("/", async function(req, res) { let objItem = await Item.find({}); - // console.log(objItem); + console.log(objItem, 'first'); res.render("index", { objItem }); @@ -60,20 +60,20 @@ app.set("view engine", "hbs"); // app.use("/users", usersRouter); mongoose.connect( - "mongodb+srv://artem:artem@cluster0-nnm84.mongodb.net/ozonItems", + "mongodb+srv://artem:artem@cluster0-nnm84.mongodb.net/ozon", { useNewUrlParser: true, useUnifiedTopology: true } ); -app.get("/", async function(req, res) { - let objItem = await Item.find({}); - // console.log(objItem); - res.render("index", { - objItem - }); -}); +// app.get("/", async function(req, res) { +// let objItem = await Item.find({}); +// console.log(objItem, 'here'); +// res.render("index", { +// objItem +// }); +// }); // Обработка ошибок. app.use((req, res, next) => { diff --git a/model/itemModel.js b/model/itemModel.js index 280bb7f..c5a34ff 100644 --- a/model/itemModel.js +++ b/model/itemModel.js @@ -11,7 +11,9 @@ const ItemSchema = new Schema({ size: String, cameraResolution: Number, internalMemory: String, - RAM: String + RAM: String, + rating: Number, + color: Array, }); diff --git a/seed/seed.js b/seed/seed.js index d0c820e..5cb20fa 100644 --- a/seed/seed.js +++ b/seed/seed.js @@ -1,6 +1,6 @@ const Item = require('../model/itemModel'); const mongoose = require('mongoose'); - +const app = require('../app') async function createUser() { @@ -9,7 +9,7 @@ async function createUser() { let item1 = await Item.create({ img: 'https://cdn1.ozone.ru/multimedia/c1200/1026952828.jpg', - name: 'Смартфон Honor 10 Lite 3/64GB, черный', + name: 'Смартфон Honor 10 Lite 3/64GB', price: 10990, guarantee: '1 год', screenResolution: '2340x1080', @@ -17,12 +17,13 @@ async function createUser() { size: '154.8 x 73.6 x 8', cameraResolution: 13, internalMemory: '64 ГБ', - RAM: '3 ГБ' + color: ["black", "white", "red", "green"], + rating: 2 }); let item2 = await Item.create({ img: 'https://cdn1.ozone.ru/s3/multimedia-z/c1200/6005742539.jpg', - name: 'Смартфон Honor 9X Premium 6/128GB, черный', + name: 'Смартфон Honor 9X Premium 6/128GB', price: 17382, guarantee: 'Нет информации', screenResolution: '2340x1080', @@ -30,12 +31,14 @@ async function createUser() { size: '163.5 × 77.3 × 8.8', cameraResolution: 48, internalMemory: 'Нет информации', - RAM: 'Нет информации' + RAM: 'Нет информации', + color: ["black", "white", "red", "green"], + rating: 3 }); let item3 = await Item.create({ img: 'https://cdn1.ozone.ru/multimedia/c1200/1028043675.jpg', - name: 'Смартфон Honor 10i 4/128GB, черный', + name: 'Смартфон Honor 10i 4/128GB', price: 12990, guarantee: '1 год', screenResolution: '2340x1080', @@ -43,12 +46,14 @@ async function createUser() { size: 'Нет информации', cameraResolution: 24, internalMemory: '128 ГБ', - RAM: '4 ГБ' + RAM: '4 ГБ', + color: ["black", "white", "red", "green"], + rating: 1 }); let item4 = await Item.create({ img: 'https://cdn1.ozone.ru/multimedia/c1200/1034224013.jpg', - name: 'Смартфон Smartisan U3 4/64GB, бежевый', + name: 'Смартфон Smartisan U3 4/64GB', price: 10495, guarantee: 'Нет информации', screenResolution: '2160х1080', @@ -56,7 +61,54 @@ async function createUser() { size: 'Нет информации', cameraResolution: 13, internalMemory: 'Нет информации', - RAM: 'Нет информации' + RAM: 'Нет информации', + color: ["black", "white", "red", "green"], + rating: 5 + }); + + let item5 = await Item.create({ + img: 'https://cdn1.ozone.ru/s3/multimedia-m/c1200/6005039950.jpg', + name: 'Смартфон realme XT 8/128GB', + price: 35000, + guarantee: '3 года', + screenResolution: '2340x1080', + screenDiagonale: '5,99', + size: 'Нет информации', + cameraResolution: 13, + internalMemory: '128 ГБ', + RAM: '8 ГБ', + color: ["black", "white", "red", "green"], + rating: 3 + }); + + let item6 = await Item.create({ + img: 'https://cdn1.ozone.ru/s3/multimedia-s/c1200/6006221044.jpg', + name: 'Смартфон Xiaomi Redmi Note 8T 4/64GB', + price: 25000, + guarantee: '2 года', + screenResolution: '2340x1080', + screenDiagonale: '5,99', + size: 'Нет информации', + cameraResolution: 13, + internalMemory: '512 ГБ', + RAM: '4 ГБ', + color: ["black", "white", "red", "green"], + rating: 5 + }); + + let item6 = await Item.create({ + img: 'https://cdn1.ozone.ru/s3/multimedia-q/c1200/6001501874.jpg', + name: 'Смартфон Xiaomi Redmi Note 7 4/64GB', + price: 12000, + guarantee: '2 года', + screenResolution: '2340x1080', + screenDiagonale: '5,99', + size: 'Нет информации', + cameraResolution: 13, + internalMemory: '64 ГБ', + RAM: '4 ГБ', + color: ["black", "white", "red", "green"], + rating: 4 }); await mongoose.disconnect(); diff --git a/views/index.hbs b/views/index.hbs index d12cb71..52aabd8 100644 --- a/views/index.hbs +++ b/views/index.hbs @@ -1,5 +1,5 @@
-

Phones

+

Телефоны

{{#each objItem}}
@@ -143,54 +143,29 @@
{{/each}} {{!-- table-hover --}} -{{#each objItem}} - - {{/each}} - -

-

- -

-
- -
-
    + {{#each objItem}} -
  • - альтернативный текст + +

  • {{this.name}}
  • -
  • {{this.price}}
  • -
  • {{this.guarantee}}
  • -
  • {{this.screenResolution}}
  • - - - - - +
  • Цена: {{this.price}}
  • +
  • Гарантия: {{this.guarantee}}
  • +
  • Разрешение: {{this.screenResolution}}
  • + + + + + - Сравнить + {{/each}}
-
-
--}} + + diff --git a/views/layout.hbs b/views/layout.hbs index 45d245b..e3b086f 100644 --- a/views/layout.hbs +++ b/views/layout.hbs @@ -36,7 +36,7 @@ {{{body}}} - +{{!-- ======= @@ -46,5 +46,5 @@ - + --}} diff --git a/views/second.hbs b/views/second.hbs new file mode 100644 index 0000000..103f9c2 --- /dev/null +++ b/views/second.hbs @@ -0,0 +1,18 @@ +
+

Phones

+
+ {{#each objItem}} +
+
+
{{this.name}} +
+ Цена: {{this.price}} Руб
+ +
+
+
+ {{/each}} + + + \ No newline at end of file From 1308a77c569ca5b2e9c64a885a908cb14be631c2 Mon Sep 17 00:00:00 2001 From: Sveta Fo Date: Fri, 14 Feb 2020 16:11:37 +0300 Subject: [PATCH 2/2] nodemon --- .DS_Store | Bin 6148 -> 6148 bytes package.json | 2 +- views/index.hbs | 124 ------------------------------------------------ 3 files changed, 1 insertion(+), 125 deletions(-) diff --git a/.DS_Store b/.DS_Store index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..9226c904d88cd1c887e7a8a95184156848e07cb0 100644 GIT binary patch delta 220 zcmYk0O$x#=6ojWg359|R4PDy{NWF#ENSg{mB*j==y6FK7J%!8Ct@m>4i&Av^&HH9v zU-soa4}-+X+--`C0|p!dqwl`-1M$IWAgBMcOpUqlofEjm=tIG~;#s-WOR_Z`k; z*g5b<3`?ki`iBe`Drj(prCsfZeaROuK72k8Mrrs^ig-$sG@;)|`HF_6C|F3wdf19= I+KFfM239IGIsgCw delta 70 zcmZoMXfc=|#>AjHu~2NHo+1YW5HK<@2y9-+n8vnw1EUw?W_AvK4xj>{$am(+{342+ UKzW7)kiy9(Jj$D6L{=~Z04H+~3jhEB diff --git a/package.json b/package.json index 4060b78..21922b1 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "", "main": "app.js", "scripts": { - "start": "npx nodemon app.js", + "start": "node app.js", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", diff --git a/views/index.hbs b/views/index.hbs index 52aabd8..8ad4dfd 100644 --- a/views/index.hbs +++ b/views/index.hbs @@ -42,130 +42,6 @@
-{{!-- table --}} -
-
- - -
-{{#each objItem}} -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
Название{{this.name}}>{{this.name}}{{this.name}}{{this.name}}{{this.name}}
Камера{{this.cameraResolution}}{{this.cameraResolution}}{{this.cameraResolution}}{{this.cameraResolution}}{{this.cameraResolution}}
Цена{{this.price}}{{this.price}}{{this.price}}{{this.price}}{{this.price}}
Память{{this.internalMemory}}{{this.internalMemory}}{{this.internalMemory}}{{this.internalMemory}}{{this.internalMemory}}
RAM{{this.RAM}}{{this.RAM}}{{this.RAM}}{{this.RAM}}{{this.RAM}}
Размер{{this.size}}{{this.size}}{{this.size}}{{this.size}}{{this.size}}
Гарантия{{this.guarantee}}{{this.guarantee}}{{this.guarantee}}{{this.guarantee}}{{this.guarantee}}
-
-
- {{/each}} -{{!-- table-hover --}} - - - - - - - {{#each objItem}} - -

-
  • {{this.name}}
  • -
  • Цена: {{this.price}}
  • -
  • Гарантия: {{this.guarantee}}
  • -
  • Разрешение: {{this.screenResolution}}
  • - - - - - - - - {{/each}} - -