This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum MediaType | |
| { | |
| case image | |
| case video | |
| case audio | |
| case document | |
| } | |
| struct Media | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DragDropAreView: NSView { | |
| private var fileTypeIsOk = false | |
| private var acceptedFileExtensions = ["jpg","png","doc","docx","pdf","mov","mp4","mp3"] | |
| var delegate: DragDropViewDelegate? | |
| var isReceivingDrag = false { | |
| didSet { | |
| needsDisplay = true | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Cocoa | |
| class CollectionViewItem: NSCollectionViewItem { | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| view.wantsLayer = true | |
| view.layer?.backgroundColor = NSColor.lightGray.cgColor | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| dragDropAreaView.delegate = self | |
| setupView() | |
| } | |
| override func viewDidAppear() { | |
| let flowLayout = NSCollectionViewFlowLayout() | |
| flowLayout.itemSize = NSSize(width: 160.0, height: 120.0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func createDirectory(sourcePath: String, type: MediaType) { | |
| // path to documents directory | |
| let documentDirectoryPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first | |
| if let documentDirectoryPath = documentDirectoryPath { | |
| // create the custom folder path | |
| var subDirectoryPath = "" | |
| switch type | |
| { | |
| case .audio: | |
| subDirectoryPath = documentDirectoryPath.appending("/audios") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @IBAction func didClickOnExploreButton(_ sender: NSButtonCell) | |
| { | |
| toggleViewStates(state: false) | |
| files = [String:Media]() | |
| switch sender.tag { | |
| case 101: | |
| getFilesFromDoucmentDir(type: .image) | |
| case 102: | |
| getFilesFromDoucmentDir(type: .video) | |
| case 103: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension HomeViewController: DragDropViewDelegate | |
| { | |
| func draggedMediaType(type: MediaType, url: NSURL) { | |
| switch type { | |
| case .audio: | |
| self.createDirectory(sourcePath: url.absoluteString!, type: .audio) | |
| case .video: | |
| self.createDirectory(sourcePath: url.absoluteString!, type: .video) | |
| case .image: | |
| self.createDirectory(sourcePath: url.absoluteString!, type: .image) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const mongoose = require('mongoose'); | |
| const Schema = mongoose.Schema; | |
| const movieSchema = new Schema({ | |
| title: { | |
| type: String, | |
| required: true | |
| }, | |
| year: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = {'movieBuildSchema':` | |
| type Movie { | |
| _id: ID! | |
| title: String! | |
| year: Int! | |
| released: String! | |
| genre: String! | |
| director: String! | |
| actors: String! | |
| plot: String! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| movies: () => { | |
| return Movie.find() | |
| .then(movies => { | |
| return movies.map(movie => { | |
| return { ...movie._doc, _id: movie._doc._id.toString()}; //overwriting id | |
| }); | |
| }) | |
| .catch(err => { | |
| throw err; | |
| }); |
OlderNewer