wiki:AddComponent

Version 3 (modified by 233051, 12 hours ago) ( diff )

--

Add component to build

Actors

Admin

Scenario

  1. In the admin dashboard, there is a button labeled 'Add Component' with which the admin can add any component needed. The labels and text fields are populated by back-end logic, so it's as seamless as possible.

  1. When the button is clicked, a popup appears which has some basic information, but one of the fields is a dropdown with all the component types. The admins can choose which component they want and the fields populate.

  1. When the admin selects a cpu, for example, it automatically populates the needed fields and then he can enter the information.

  1. After the admin clicks create component, the popup disappears and if we check popup with all the cpus we can see that the new cpu is inserted successfully.
BEGIN;

INSERT INTO components (name, brand, price, img_url, type)
VALUES ($name, $brand, $price, $imgUrl, $type)
RETURNING id AS new_component_id

-- if type == 'cpu'
INSERT INTO cpu (component_id, socket, cores, threads, base_clock, boost_clock, tdp)
VALUES ($new_component_id, $socket, $cores, $threads, $base_clock, $boost_clock, $tdp);

INSERT INTO cooler_cpu_sockets (cooler_id, socket)
VALUES ($new_component_id, $socket);

-- if type == 'gpu'
INSERT INTO gpu (component_id, vram, tdp, base_clock, boost_clock, chipset, length)
VALUES ($new_component_id, $vram, $tdp, $base_clock, $boost_clock, $chipset, $length);

-- if type == 'memory'
INSERT INTO memory (component_id, type, speed, capacity, modules)
VALUES ($new_component_id, $memory_type, $speed, $capacity, $modules);

-- if type == 'storage'
INSERT INTO storage (component_id, type, capacity, form_factor)
VALUES ($new_component_id, $storage_type, $capacity, $form_factor);

-- if type == 'power_supply'
INSERT INTO power_supply (component_id, type, wattage, form_factor)
VALUES ($new_component_id, $psu_type, $wattage, $form_factor);

-- if type == 'motherboard'
INSERT INTO motherboard (component_id, socket, chipset, form_factor, ram_type, num_ram_slots, max_ram_capacity, pci_express_slots)
VALUES ($new_component_id, $socket, $chipset, $form_factor, $ram_type, $num_ram_slots, $max_ram_capacity, $pci_express_slots);

-- if type == 'case'
INSERT INTO pc_case (component_id, cooler_max_height, gpu_max_length)
VALUES ($new_component_id, $cooler_max_height, $gpu_max_length);

INSERT INTO case_storage_form_factors (case_id, form_factor, num_slots)
VALUES ($new_component_id, $sf_form_factor, $sf_num_slots);

INSERT INTO case_ps_form_factors (case_id, form_factor)
VALUES ($new_component_id, $pf_form_factor);

INSERT INTO case_mobo_form_factors (case_id, form_factor)
VALUES ($new_component_id, $mf_form_factor);

-- if type == 'cooler'
INSERT INTO cooler (component_id, type, height, max_tdp_supported)
VALUES ($new_component_id, $cooler_type, $height, $max_tdp_supported);

-- if type == 'memory_card'
INSERT INTO memory_card (component_id, num_slots, interface)
VALUES ($new_component_id, $num_slots, $interface);

-- if type == 'optical_drive'
INSERT INTO optical_drive (component_id, form_factor, type, interface, write_speed, read_speed)
VALUES ($new_component_id, $form_factor, $optical_type, $interface, $write_speed, $read_speed);

-- if type == 'sound_card'
INSERT INTO sound_card (component_id, sample_rate, bit_depth, chipset, interface, channel)
VALUES ($new_component_id, $sample_rate, $bit_depth, $chipset, $interface, $channel);

-- if$type == 'cables'
INSERT INTO cables (component_id, length_cm, type)
VALUES ($new_component_id, $length_cm, $cable_type);

-- if type == 'network_adapter'
INSERT INTO network_adapter (component_id, wifi_version, interface, num_antennas)
VALUES ($new_component_id, $wifi_version, $interface, $num_antennas);

-- if type == 'network_card'
INSERT INTO network_card (component_id, num_ports, speed, interface)
VALUES ($new_component_id, $num_ports, $speed, $interface);

COMMIT;

Attachments (5)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.